[tarantool-patches] Re: [PATCH v2 5/5] sql: remove field nErr of struct Parse

n.pettik korablev at tarantool.org
Tue Feb 26 17:48:23 MSK 2019


> diff --git a/src/box/sql/build.c b/src/box/sql/build.c
> index 6afca4a..6621af4 100644
> --- a/src/box/sql/build.c
> +++ b/src/box/sql/build.c
> @@ -92,7 +92,6 @@ save_record(struct Parse *parser, uint32_t space_id, int reg_key,
> 		diag_set(OutOfMemory, sizeof(*record), "region_alloc",
> 			 "record");
> 		parser->rc = SQL_TARANTOOL_ERROR;
> -		parser->nErr++;
> 		return;
> 	}
> 	record->space_id = space_id;
> @@ -145,9 +144,11 @@ sql_finish_coding(struct Parse *parse_context)
> 			     "Exit with an error if CREATE statement fails"));
> 	}
> 
> -	if (db->mallocFailed || parse_context->nErr != 0) {
> -		if (parse_context->rc == SQL_OK)
> -			parse_context->rc = SQL_ERROR;
> +	if (parse_context->rc == SQL_TARANTOOL_ERROR)

rc == 0 / ! abort

> +		return;
> +	if (db->mallocFailed) {
> +		diag_set(ClientError, ER_SQL_PARSER_GENERIC, "Out of memory”);

Why generic when it is OOM error?

> +		parse_context->rc = SQL_TARANTOOL_ERROR;

rc = -1 / abort = true

> 		return;
> 	}
> 	/*
> @@ -189,13 +190,13 @@ sql_finish_coding(struct Parse *parse_context)
> 		sqlVdbeGoto(v, 1);
> 	}
> 	/* Get the VDBE program ready for execution. */
> -	if (parse_context->nErr == 0 && !db->mallocFailed) {
> +	if (parse_context->rc != SQL_TARANTOOL_ERROR && !db->mallocFailed) {
> 		assert(parse_context->iCacheLevel == 0);
> 		sqlVdbeMakeReady(v, parse_context);
> 		parse_context->rc = SQL_DONE;
> -	} else {
> -		if (parse_context->rc != SQL_TARANTOOL_ERROR)
> -			parse_context->rc = SQL_ERROR;
> +	} else if (parse_context->rc != SQL_TARANTOOL_ERROR) {
> +		diag_set(ClientError, ER_SQL_PARSER_GENERIC, "Out of memory");
> +		parse_context->rc = SQL_TARANTOOL_ERROR;

The same is here and in other places .





More information about the Tarantool-patches mailing list