[tarantool-patches] Re: [PATCH v1 06/21] sql: remove SQL_NOTFOUND error/status code

Mergen Imeev imeevma at tarantool.org
Sun May 26 12:45:00 MSK 2019


On Sat, May 25, 2019 at 05:58:19PM +0300, n.pettik wrote:
> 
> 
> > On 25 May 2019, at 13:44, imeevma at tarantool.org wrote:
> > 
> > Removing this error/status code is part of getting rid of the SQL
> > error system.
> > ---
> > src/box/sql/os_unix.c |  2 +-
> > src/box/sql/sqlInt.h  |  2 --
> > src/box/sql/where.c   | 13 ++-----------
> > 3 files changed, 3 insertions(+), 14 deletions(-)
> > 
> > diff --git a/src/box/sql/where.c b/src/box/sql/where.c
> > index 0b1ccd9..060dfee 100644
> > --- a/src/box/sql/where.c
> > +++ b/src/box/sql/where.c
> > @@ -1528,21 +1528,14 @@ whereEqualScanEst(Parse * pParse,	/* Parsing & code generating context */
> > 	assert(nEq >= 1);
> > 	assert(nEq <= (int) p->key_def->part_count);
> > 	assert(pBuilder->nRecValid < nEq);
> > -
> > -	/* If values are not available for all fields of the index to the left
> > -	 * of this one, no estimate can be made. Return SQL_NOTFOUND.
> > -	 */
> > -	if (pBuilder->nRecValid < (nEq - 1)) {
> > -		return SQL_NOTFOUND;
> > -	}
> > +	assert(pBuilder->nRecValid >= (nEq - 1));
> 
> Taking into consideration assert above, it could
> be replaced with assert(pBuilder->nRecValid == nEq - 1);
Fixed.

diff --git a/src/box/sql/where.c b/src/box/sql/where.c
index 060dfee..81a2739 100644
--- a/src/box/sql/where.c
+++ b/src/box/sql/where.c
@@ -1527,8 +1527,7 @@ whereEqualScanEst(Parse * pParse,	/* Parsing & code generating context */
 
 	assert(nEq >= 1);
 	assert(nEq <= (int) p->key_def->part_count);
-	assert(pBuilder->nRecValid < nEq);
-	assert(pBuilder->nRecValid >= (nEq - 1));
+	assert(pBuilder->nRecValid == (nEq - 1));
 
 	rc = sqlStat4ProbeSetValue(pParse, p, &pRec, pExpr, 1, nEq - 1,
 				       &bOk);

> Btw, this function doesn’t seem to be called at all:
> unreachable() assert doesn’t fire. I can assume that it is
> connected with stat tables.
> 
I think that we do not have the right way to check this, so
I think that we will either enable or delete this function
when the statistics table is created.





More information about the Tarantool-patches mailing list