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

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Jun 2 19:34:12 MSK 2019


> 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?

>  			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.

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.

=======================================================================

commit e203a7c93132605e04931045ccc8ba4fd4bce7fa
Author: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
Date:   Sun Jun 2 18:28:25 2019 +0200

    Review fixes

diff --git a/src/box/sql.c b/src/box/sql.c
index 59a8bfbd5..d4d9d9671 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -325,21 +325,19 @@ int tarantoolsqlMovetoUnpacked(BtCursor *pCur, UnpackedRecord *pIdxKey,
  *
  * @retval SQL_OK
  */
-int tarantoolsqlEphemeralCount(struct BtCursor *pCur, i64 *pnEntry)
+int64_t
+tarantoolsqlEphemeralCount(struct BtCursor *pCur)
 {
 	assert(pCur->curFlags & BTCF_TEphemCursor);
-
 	struct index *primary_index = space_index(pCur->space, 0 /* PK */);
-	*pnEntry = index_count(primary_index, pCur->iter_type, NULL, 0);
-	return SQL_OK;
+	return index_count(primary_index, pCur->iter_type, NULL, 0);
 }
 
-int tarantoolsqlCount(BtCursor *pCur, i64 *pnEntry)
+int64_t
+tarantoolsqlCount(struct BtCursor *pCur)
 {
 	assert(pCur->curFlags & BTCF_TaCursor);
-
-	*pnEntry = index_count(pCur->index, pCur->iter_type, NULL, 0);
-	return SQL_OK;
+	return index_count(pCur->index, pCur->iter_type, NULL, 0);
 }
 
 struct space *
@@ -621,12 +619,12 @@ int tarantoolsqlRenameTrigger(const char *trig_name,
 	char *key_begin = (char*) region_alloc(&fiber()->gc, key_len);
 	if (key_begin == NULL) {
 		diag_set(OutOfMemory, key_len, "region_alloc", "key_begin");
-		return SQL_TARANTOOL_ERROR;
+		return -1;
 	}
 	char *key = mp_encode_array(key_begin, 1);
 	key = mp_encode_str(key, trig_name, trig_name_len);
 	if (box_index_get(BOX_TRIGGER_ID, 0, key_begin, key, &tuple) != 0)
-		return SQL_TARANTOOL_ERROR;
+		return -1;
 	assert(tuple != NULL);
 	assert(tuple_field_count(tuple) == 3);
 	const char *field = tuple_field(tuple, BOX_TRIGGER_FIELD_SPACE_ID);
@@ -645,7 +643,7 @@ int tarantoolsqlRenameTrigger(const char *trig_name,
 	if (trigger_stmt == NULL) {
 		diag_set(OutOfMemory, trigger_stmt_len + 1, "region_alloc",
 			 "trigger_stmt");
-		return SQL_TARANTOOL_ERROR;
+		return -1;
 	}
 	memcpy(trigger_stmt, trigger_stmt_old, trigger_stmt_len);
 	trigger_stmt[trigger_stmt_len] = '\0';
@@ -662,7 +660,7 @@ int tarantoolsqlRenameTrigger(const char *trig_name,
 	char *new_tuple = (char*)region_alloc(&fiber()->gc, key_len);
 	if (new_tuple == NULL) {
 		diag_set(OutOfMemory, key_len, "region_alloc", "new_tuple");
-		return SQL_TARANTOOL_ERROR;
+		return -1;
 	}
 	char *new_tuple_end = mp_encode_array(new_tuple, 3);
 	new_tuple_end = mp_encode_str(new_tuple_end, trig_name, trig_name_len);
@@ -672,15 +670,12 @@ int tarantoolsqlRenameTrigger(const char *trig_name,
 	new_tuple_end = mp_encode_str(new_tuple_end, trigger_stmt,
 				      trigger_stmt_new_len);
 
-	if (box_replace(BOX_TRIGGER_ID, new_tuple, new_tuple_end, NULL) != 0)
-		return SQL_TARANTOOL_ERROR;
-	else
-		return SQL_OK;
+	return box_replace(BOX_TRIGGER_ID, new_tuple, new_tuple_end, NULL);
 
 rename_fail:
 	diag_set(ClientError, ER_SQL_EXECUTE, "can't modify name of space "
 		"created not via SQL facilities");
-	return SQL_TARANTOOL_ERROR;
+	return -1;
 }
 
 int
@@ -695,7 +690,7 @@ sql_rename_table(uint32_t space_id, const char *new_name)
 	char *raw = (char *) region_alloc(region, size);
 	if (raw == NULL) {
 		diag_set(OutOfMemory, size, "region_alloc", "raw");
-		return SQL_TARANTOOL_ERROR;
+		return -1;
 	}
 	/* Encode key. */
 	char *pos = mp_encode_array(raw, 1);
@@ -709,7 +704,7 @@ sql_rename_table(uint32_t space_id, const char *new_name)
 	pos = mp_encode_uint(pos, BOX_SPACE_FIELD_NAME);
 	pos = mp_encode_str(pos, new_name, name_len);
 	if (box_update(BOX_SPACE_ID, 0, raw, ops, ops, pos, 0, NULL) != 0)
-		return SQL_TARANTOOL_ERROR;
+		return -1;
 	return 0;
 }
 
@@ -834,8 +829,8 @@ tarantoolsqlIncrementMaxid(uint64_t *space_max_id)
 	request.space_id = space_schema->def->id;
 	if (box_process_rw(&request, space_schema, &res) != 0 || res == NULL ||
 	    tuple_field_u64(res, 1, space_max_id) != 0)
-		return SQL_TARANTOOL_ERROR;
-	return SQL_OK;
+		return -1;
+	return 0;
 }
 
 /*
diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
index 979542948..4106bce37 100644
--- a/src/box/sql/analyze.c
+++ b/src/box/sql/analyze.c
@@ -1691,7 +1691,7 @@ sql_analysis_load(struct sql *db)
 	assert(stat_space != NULL);
 	ssize_t index_count = box_index_len(stat_space->def->id, 0);
 	if (index_count < 0)
-		return SQL_TARANTOOL_ERROR;
+		return -1;
 	if (box_txn_begin() != 0)
 		goto fail;
 	size_t stats_size = index_count * sizeof(struct index_stat);
@@ -1712,7 +1712,7 @@ sql_analysis_load(struct sql *db)
 		goto fail;
 	if (info.index_count == 0) {
 		box_txn_commit();
-		return SQL_OK;
+		return 0;
 	}
 	/*
 	 * This query is used to allocate enough memory for
@@ -1768,12 +1768,9 @@ sql_analysis_load(struct sql *db)
 	 */
 	const char *order_query = "SELECT \"tbl\",\"idx\" FROM "
 				  "\"_sql_stat4\" GROUP BY \"tbl\",\"idx\"";
-	if (load_stat_to_index(db, order_query, heap_stats) != 0)
-		goto fail;
-	if (box_txn_commit() != 0)
-		return SQL_TARANTOOL_ERROR;
-	return SQL_OK;
+	if (load_stat_to_index(db, order_query, heap_stats) == 0)
+		return box_txn_commit();
 fail:
 	box_txn_rollback();
-	return SQL_TARANTOOL_ERROR;
+	return -1;
 }
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 9c0659bc9..777527865 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -4591,7 +4591,8 @@ sql_index_tuple_size(struct space *space, struct index *idx);
  * samples[] arrays.
  *
  * @param db Database handler.
- * @retval sql_OK on success, smth else otherwise.
+ * @retval 0 Success.
+ * @retval -1 Error.
  */
 int
 sql_analysis_load(struct sql *db);
diff --git a/src/box/sql/tarantoolInt.h b/src/box/sql/tarantoolInt.h
index f15e1472b..0474f2976 100644
--- a/src/box/sql/tarantoolInt.h
+++ b/src/box/sql/tarantoolInt.h
@@ -34,7 +34,8 @@ int tarantoolsqlNext(BtCursor * pCur, int *pRes);
 int tarantoolsqlPrevious(BtCursor * pCur, int *pRes);
 int tarantoolsqlMovetoUnpacked(BtCursor * pCur, UnpackedRecord * pIdxKey,
 				   int *pRes);
-int tarantoolsqlCount(BtCursor * pCur, i64 * pnEntry);
+int64_t
+tarantoolsqlCount(struct BtCursor *pCur);
 int tarantoolsqlInsert(struct space *space, const char *tuple,
 			   const char *tuple_end);
 int tarantoolsqlReplace(struct space *space, const char *tuple,
@@ -62,7 +63,8 @@ int tarantoolsqlClearTable(struct space *space, uint32_t *tuple_count);
  * @param space_id Table's space identifier.
  * @param new_name new name of table
  *
- * @retval 0 on success, SQL_TARANTOOL_ERROR otherwise.
+ * @retval 0 Success.
+ * @retval -1 Error.
  */
 int
 sql_rename_table(uint32_t space_id, const char *new_name);
@@ -100,7 +102,8 @@ sql_ephemeral_space_create(uint32_t filed_count, struct sql_key_info *key_info);
 int tarantoolsqlEphemeralInsert(struct space *space, const char *tuple,
 				    const char *tuple_end);
 int tarantoolsqlEphemeralDelete(BtCursor * pCur);
-int tarantoolsqlEphemeralCount(BtCursor * pCur, i64 * pnEntry);
+int64_t
+tarantoolsqlEphemeralCount(struct BtCursor *pCur);
 int tarantoolsqlEphemeralDrop(BtCursor * pCur);
 int tarantoolsqlEphemeralClearTable(BtCursor * pCur);
 
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 5bf5e6e88..0b1d7888d 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -1432,7 +1432,7 @@ case OP_Concat: {           /* same as TK_CONCAT, in1, in2, out3 */
 			 mem_type_to_str(pIn2), mem_type_to_str(pIn1));
 		goto abort_due_to_error;
 	}
-	if (ExpandBlob(pIn1) != SQL_OK || ExpandBlob(pIn2) != SQL_OK)
+	if (ExpandBlob(pIn1) != 0 || ExpandBlob(pIn2) != 0)
 		goto abort_due_to_error;
 	nByte = pIn1->n + pIn2->n;
 	if (nByte>db->aLimit[SQL_LIMIT_LENGTH]) {
@@ -1892,7 +1892,7 @@ case OP_Realify: {                  /* in1 */
  */
 case OP_Cast: {                  /* in1 */
 	pIn1 = &aMem[pOp->p1];
-	if (ExpandBlob(pIn1) != SQL_OK)
+	if (ExpandBlob(pIn1) != 0)
 		goto abort_due_to_error;
 	rc = sqlVdbeMemCast(pIn1, pOp->p2);
 	UPDATE_MAX_BLOBSIZE(pIn1);
@@ -2659,7 +2659,7 @@ case OP_Column: {
 	if ((pDest->flags & (MEM_Ephem | MEM_Str)) == (MEM_Ephem | MEM_Str)) {
 		int len = pDest->n;
 		if (pDest->szMalloc<len+1) {
-			if (sqlVdbeMemGrow(pDest, len + 1, 1)) {
+			if (sqlVdbeMemGrow(pDest, len + 1, 1) != 0) {
 				if (zData != pC->aRow)
 					sqlVdbeMemRelease(&sMem);
 				goto abort_due_to_error;
@@ -2790,7 +2790,8 @@ case OP_MakeRecord: {
 	 * routine.
 	 */
 	if (bIsEphemeral) {
-		rc = sqlVdbeMemClearAndResize(pOut, tuple_size);
+		if (sqlVdbeMemClearAndResize(pOut, tuple_size) != 0)
+			goto abort_due_to_error;
 		pOut->flags = MEM_Blob;
 		pOut->n = tuple_size;
 		memcpy(pOut->z, tuple, tuple_size);
@@ -2805,8 +2806,6 @@ case OP_MakeRecord: {
 		pOut->n = tuple_size;
 		pOut->z = tuple;
 	}
-	if (rc)
-		goto no_mem;
 	assert(sqlVdbeCheckMemInvariants(pOut));
 	assert(pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor));
 	REGISTER_TRACE(pOp->p3, pOut);
@@ -2827,15 +2826,11 @@ case OP_Count: {         /* out2 */
 	assert(p->apCsr[pOp->p1]->eCurType==CURTYPE_TARANTOOL);
 	pCrsr = p->apCsr[pOp->p1]->uc.pCursor;
 	assert(pCrsr);
-	nEntry = 0;  /* Not needed.  Only used to silence a warning. */
 	if (pCrsr->curFlags & BTCF_TaCursor) {
-		if (tarantoolsqlCount(pCrsr, &nEntry) != SQL_OK)
-			goto abort_due_to_error;
-	} else if (pCrsr->curFlags & BTCF_TEphemCursor) {
-		if (tarantoolsqlEphemeralCount(pCrsr, &nEntry) != SQL_OK)
-			goto abort_due_to_error;
+		nEntry = tarantoolsqlCount(pCrsr);
 	} else {
-		unreachable();
+		assert((pCrsr->curFlags & BTCF_TEphemCursor) != 0);
+		nEntry = tarantoolsqlEphemeralCount(pCrsr);
 	}
 	pOut = out2Prerelease(p, pOp);
 	pOut->u.i = nEntry;
@@ -2905,7 +2900,7 @@ case OP_Savepoint: {
 					p->rc = rc = SQL_BUSY;
 					goto vdbe_return;
 				}
-				if (p->rc != SQL_OK)
+				if (p->rc != 0)
 					goto abort_due_to_error;
 			} else {
 				if (p1==SAVEPOINT_ROLLBACK)
@@ -3154,7 +3149,7 @@ case OP_SorterOpen: {
 	pCx = allocateCursor(p, pOp->p1, pOp->p2, CURTYPE_SORTER);
 	if (pCx==0) goto no_mem;
 	pCx->key_def = def;
-	if (sqlVdbeSorterInit(db, pCx) != SQL_OK)
+	if (sqlVdbeSorterInit(db, pCx) != 0)
 		goto abort_due_to_error;
 	break;
 }
@@ -3851,11 +3846,9 @@ case OP_SorterCompare: {
 			assert(pOp->p4type==P4_INT32);
 			pIn3 = &aMem[pOp->p3];
 			nKeyCol = pOp->p4.i;
-			res = 0;
 			if (sqlVdbeSorterCompare(pC, pIn3, nKeyCol, &res) != 0)
-				rc = SQL_TARANTOOL_ERROR;
+				goto abort_due_to_error;
 			VdbeBranchTaken(res!=0,2);
-			if (rc) goto abort_due_to_error;
 			if (res) goto jump_to_p2;
 			break;
 		};
@@ -3878,7 +3871,7 @@ case OP_SorterData: {
 	pOut = &aMem[pOp->p2];
 	pC = p->apCsr[pOp->p1];
 	assert(isSorter(pC));
-	if (sqlVdbeSorterRowkey(pC, pOut) != SQL_OK)
+	if (sqlVdbeSorterRowkey(pC, pOut) != 0)
 		goto abort_due_to_error;
 	assert(pOut->flags & MEM_Blob);
 	assert(pOp->p1>=0 && pOp->p1<p->nCursor);
@@ -3948,8 +3941,8 @@ case OP_RowData: {
 	testcase( n==0);
 
 	sqlVdbeMemRelease(pOut);
-	if (sql_vdbe_mem_alloc_region(pOut, n) != SQL_OK ||
-	    sqlCursorPayload(pCrsr, 0, n, pOut->z) != SQL_OK)
+	if (sql_vdbe_mem_alloc_region(pOut, n) != 0 ||
+	    sqlCursorPayload(pCrsr, 0, n, pOut->z) != 0)
 		goto abort_due_to_error;
 	UPDATE_MAX_BLOBSIZE(pOut);
 	REGISTER_TRACE(pOp->p2, pOut);
@@ -4013,10 +4006,10 @@ case OP_Last: {        /* jump */
 	pC->seekOp = OP_Last;
 #endif
 	if (pOp->p3==0 || !sqlCursorIsValidNN(pCrsr)) {
-		rc = tarantoolsqlLast(pCrsr, &res);
+		if (tarantoolsqlLast(pCrsr, &res) != 0)
+			goto abort_due_to_error;
 		pC->nullRow = (u8)res;
 		pC->cacheStatus = CACHE_STALE;
-		if (rc) goto abort_due_to_error;
 		if (pOp->p2>0) {
 			VdbeBranchTaken(res!=0,2);
 			if (res) goto jump_to_p2;
@@ -4085,17 +4078,15 @@ case OP_Rewind: {        /* jump */
 	pC->seekOp = OP_Rewind;
 #endif
 	if (isSorter(pC)) {
-		if (sqlVdbeSorterRewind(pC, &res) != SQL_OK)
+		if (sqlVdbeSorterRewind(pC, &res) != 0)
 			goto abort_due_to_error;
 	} else {
 		assert(pC->eCurType==CURTYPE_TARANTOOL);
 		pCrsr = pC->uc.pCursor;
 		assert(pCrsr);
-		if (tarantoolsqlFirst(pCrsr, &res) != SQL_OK)
-			rc = SQL_TARANTOOL_ERROR;
-		pC->cacheStatus = CACHE_STALE;
-		if (rc != SQL_OK)
+		if (tarantoolsqlFirst(pCrsr, &res) != 0)
 			goto abort_due_to_error;
+		pC->cacheStatus = CACHE_STALE;
 	}
 	pC->nullRow = (u8)res;
 	assert(pOp->p2>0 && pOp->p2<p->nOp);
@@ -4179,7 +4170,8 @@ case OP_SorterNext: {  /* jump */
 	pC = p->apCsr[pOp->p1];
 	assert(isSorter(pC));
 	res = 0;
-	rc = sqlVdbeSorterNext(db, pC, &res);
+	if (sqlVdbeSorterNext(db, pC, &res) != 0)
+		goto abort_due_to_error;
 	goto next_tail;
 case OP_PrevIfOpen:    /* jump */
 case OP_NextIfOpen:    /* jump */
@@ -4210,11 +4202,11 @@ case OP_Next:          /* jump */
 	       || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
 	       || pC->seekOp==OP_Last);
 
-	rc = pOp->p4.xAdvance(pC->uc.pCursor, &res);
+	if (pOp->p4.xAdvance(pC->uc.pCursor, &res) != 0)
+		goto abort_due_to_error;
 			next_tail:
 	pC->cacheStatus = CACHE_STALE;
 	VdbeBranchTaken(res==0,2);
-	if (rc) goto abort_due_to_error;
 	if (res==0) {
 		pC->nullRow = 0;
 		p->aCounter[pOp->p5]++;
@@ -4242,8 +4234,8 @@ case OP_SorterInsert: {      /* in2 */
 	assert(isSorter(cursor));
 	pIn2 = &aMem[pOp->p2];
 	assert((pIn2->flags & MEM_Blob) != 0);
-	if (ExpandBlob(pIn2) != SQL_OK ||
-	    sqlVdbeSorterWrite(cursor, pIn2) != SQL_OK)
+	if (ExpandBlob(pIn2) != 0 ||
+	    sqlVdbeSorterWrite(cursor, pIn2) != 0)
 		goto abort_due_to_error;
 	break;
 }
@@ -4273,7 +4265,7 @@ case OP_IdxInsert: {
 	assert((pIn2->flags & MEM_Blob) != 0);
 	if (pOp->p5 & OPFLAG_NCHANGE)
 		p->nChange++;
-	if (ExpandBlob(pIn2) != SQL_OK)
+	if (ExpandBlob(pIn2) != 0)
 		goto abort_due_to_error;
 	struct space *space;
 	if (pOp->p4type == P4_SPACEPTR)
@@ -4457,7 +4449,7 @@ case OP_SDelete: {
 	struct space *space = space_by_id(pOp->p1);
 	assert(space != NULL);
 	assert(space_is_system(space));
-	if (sql_delete_by_key(space, 0, pIn2->z, pIn2->n) != SQL_OK)
+	if (sql_delete_by_key(space, 0, pIn2->z, pIn2->n) != 0)
 		goto abort_due_to_error;
 	if (pOp->p5 & OPFLAG_NCHANGE)
 		p->nChange++;
@@ -4491,15 +4483,15 @@ case OP_IdxDelete: {
 	r.default_rc = 0;
 	r.aMem = &aMem[pOp->p2];
 	r.opcode = OP_IdxDelete;
-	if (sqlCursorMovetoUnpacked(pCrsr, &r, &res) != SQL_OK)
+	if (sqlCursorMovetoUnpacked(pCrsr, &r, &res) != 0)
 		goto abort_due_to_error;
 	if (res==0) {
 		assert(pCrsr->eState == CURSOR_VALID);
 		if (pCrsr->curFlags & BTCF_TaCursor) {
-			if (tarantoolsqlDelete(pCrsr, 0) != SQL_OK)
+			if (tarantoolsqlDelete(pCrsr, 0) != 0)
 				goto abort_due_to_error;
 		} else if (pCrsr->curFlags & BTCF_TEphemCursor) {
-			if (tarantoolsqlEphemeralDelete(pCrsr) != SQL_OK)
+			if (tarantoolsqlEphemeralDelete(pCrsr) != 0)
 				goto abort_due_to_error;
 		} else {
 			unreachable();
@@ -4612,13 +4604,12 @@ case OP_Clear: {
 	uint32_t space_id = pOp->p1;
 	struct space *space = space_by_id(space_id);
 	assert(space != NULL);
-	rc = 0;
 	if (pOp->p2 > 0) {
 		if (box_truncate(space_id) != 0)
 			goto abort_due_to_error;
 	} else {
 		uint32_t tuple_count;
-		if (tarantoolsqlClearTable(space, &tuple_count) != SQL_OK)
+		if (tarantoolsqlClearTable(space, &tuple_count) != 0)
 			goto abort_due_to_error;
 		if ((pOp->p5 & OPFLAG_NCHANGE) != 0)
 			p->nChange += tuple_count;
@@ -4645,7 +4636,7 @@ case OP_ResetSorter: {
 	} else {
 		assert(pC->eCurType==CURTYPE_TARANTOOL);
 		assert(pC->uc.pCursor->curFlags & BTCF_TEphemCursor);
-		if (tarantoolsqlEphemeralClearTable(pC->uc.pCursor) != SQL_OK)
+		if (tarantoolsqlEphemeralClearTable(pC->uc.pCursor) != 0)
 			goto abort_due_to_error;
 	}
 	break;
@@ -4679,7 +4670,7 @@ case OP_RenameTable: {
 	zNewTableName = pOp->p4.z;
 	zOldTableName = sqlDbStrNDup(db, zOldTableName,
 					 sqlStrlen30(zOldTableName));
-	if (sql_rename_table(space_id, zNewTableName) != SQL_OK)
+	if (sql_rename_table(space_id, zNewTableName) != 0)
 		goto abort_due_to_error;
 	/*
 	 * Rebuild 'CREATE TRIGGER' expressions of all triggers
@@ -4691,16 +4682,13 @@ case OP_RenameTable: {
 		/* Store pointer as trigger will be destructed. */
 		struct sql_trigger *next_trigger = trigger->next;
 		/*
-		 * FIXME: In the case of error,
-		 * part of triggers would have invalid
-		 * space name in tuple so can not been
-		 * persisted.
-		 * Server could be restarted.
-		 * In this case, rename table back and
-		 * try again.
+		 * FIXME: In the case of error, part of triggers
+		 * would have invalid space name in tuple so can
+		 * not been persisted. Server could be restarted.
+		 * In this case, rename table back and try again.
 		 */
 		if (tarantoolsqlRenameTrigger(trigger->zName, zOldTableName,
-					      zNewTableName) != SQL_OK)
+					      zNewTableName) != 0)
 			goto abort_due_to_error;
 		trigger = next_trigger;
 	}
@@ -4716,7 +4704,7 @@ case OP_RenameTable: {
  */
 case OP_LoadAnalysis: {
 	assert(pOp->p1==0 );
-	if (sql_analysis_load(db) != SQL_OK)
+	if (sql_analysis_load(db) != 0)
 		goto abort_due_to_error;
 	break;
 }
@@ -5241,7 +5229,7 @@ case OP_IncMaxid: {
 	assert(pOp->p1 > 0);
 	pOut = &aMem[pOp->p1];
 
-	if (tarantoolsqlIncrementMaxid((uint64_t*) &pOut->u.i) != SQL_OK)
+	if (tarantoolsqlIncrementMaxid((uint64_t*) &pOut->u.i) != 0)
 		goto abort_due_to_error;
 	pOut->flags = MEM_Int;
 	break;




More information about the Tarantool-patches mailing list