[tarantool-patches] Re: [PATCH v1 9/9] sql: set errors in VDBE using diag_set()

Mergen Imeev imeevma at tarantool.org
Mon Jun 3 15:10:10 MSK 2019


On Sun, Jun 02, 2019 at 06:34:12PM +0200, Vladislav Shpilevoy wrote:
> 
> > diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
> > index 43d7329..5bf5e6e 100644
> > --- a/src/box/sql/vdbe.c
> > +++ b/src/box/sql/vdbe.c
> > @@ -3903,7 +3852,8 @@ case OP_SorterCompare: {
> >  			pIn3 = &aMem[pOp->p3];
> >  			nKeyCol = pOp->p4.i;
> >  			res = 0;
> > -			rc = sqlVdbeSorterCompare(pC, pIn3, nKeyCol, &res);
> > +			if (sqlVdbeSorterCompare(pC, pIn3, nKeyCol, &res) != 0)
> > +				rc = SQL_TARANTOOL_ERROR;
> 
> In all the similar places you remove SQL_TARANTOOL_ERROR,
> but here you added it. Why?
> 
I thought the next command was doing something useful and
should be executed in any case. Now I see that I was wrong.

> >  			VdbeBranchTaken(res!=0,2);
> >  			if (rc) goto abort_due_to_error;
> >  			if (res) goto jump_to_p2;
> > @@ -4137,15 +4085,18 @@ case OP_Rewind: {        /* jump */
> >  	pC->seekOp = OP_Rewind;
> >  #endif
> >  	if (isSorter(pC)) {
> > -		rc = sqlVdbeSorterRewind(pC, &res);
> > +		if (sqlVdbeSorterRewind(pC, &res) != SQL_OK)
> > +			goto abort_due_to_error;
> >  	} else {
> >  		assert(pC->eCurType==CURTYPE_TARANTOOL);
> >  		pCrsr = pC->uc.pCursor;
> >  		assert(pCrsr);
> > -		rc = tarantoolsqlFirst(pCrsr, &res);
> > +		if (tarantoolsqlFirst(pCrsr, &res) != SQL_OK)
> > +			rc = SQL_TARANTOOL_ERROR;
> 
> The same.
> 
As in the previous case, I thought that pC->cacheStatus
should be set, but now I see that it is checked only in
OP_Column, and in case of an error, it will not be
checked at all.

> Consider my review fixes on the branch and below. They are motivated
> by several points:
> 
> 1) in the original code there were places comparing 'rc' with 0, but
> you replaced them with 'rc ==/!= SQL_OK'. I rolled back such changes,
> because we move towards removal of SQL_OK. So when you need to choose
> between 0 and SQL_OK - use 0.
> 
> 2) there were places using SQL_OK, but very easy to fix and compare
> with 0. I did it.
> 
> 3) in a couple of places you kept 'rc = SQL_TARANTOOL_ERROR'. I don't
> know why, but I dropped it, and the tests passed. If I was wrong, tell
> me, please.
> 
Thank you, I squashed your patch. Actually, all of SQL
errcodes are removed in the follow-up patch-set.





More information about the Tarantool-patches mailing list