[tarantool-patches] Re: [PATCH v1 0/4] sql: remove Triggers to server

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Mon Jun 4 16:27:29 MSK 2018


Thanks for the patch! Why did not you send it? See 1 comment below.

> commit 7e6143c51e520f68db9a4fe96d6980ba65f653d8
> Author: Kirill Shcherbatov <kshcherbatov at gmail.com>
> Date:   Fri Jun 1 15:38:30 2018 +0300
> 
>     sql: refactor sql_expr_compile to return AST
> 
> diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c
> index 42c70a255..2555adbf4 100644
> --- a/src/box/sql/tokenize.c
> +++ b/src/box/sql/tokenize.c
> @@ -539,9 +539,8 @@ sqlite3RunParser(Parse * pParse, const char *zSql, char **pzErrMsg)
>  	return nErr;
>  }
>  
> -int
> -sql_expr_compile(sqlite3 *db, const char *expr, int expr_len,
> -		 struct Expr **result)
> +struct Expr *
> +sql_expr_compile(sqlite3 *db, const char *expr, int expr_len)
>  {
>  	const char *outer = "SELECT ";
>  	int len = strlen(outer) + expr_len;
> @@ -550,19 +549,23 @@ sql_expr_compile(sqlite3 *db, const char *expr, int expr_len,
>  	sql_parser_create(&parser, db);
>  	parser.parse_only = true;
>  
> +	struct Expr *expression = NULL;
>  	char *stmt = (char *)region_alloc(&parser.region, len + 1);
>  	if (stmt == NULL) {
>  		diag_set(OutOfMemory, len + 1, "region_alloc", "stmt");
> -		return -1;
> +		goto cleanup;
>  	}
>  	sprintf(stmt, "%s%.*s", outer, expr_len, expr);
>  
> -	char *unused;
> -	if (sqlite3RunParser(&parser, stmt, &unused) != SQLITE_OK) {
> -		diag_set(ClientError, ER_SQL_EXECUTE, expr);
> -		return -1;
> +	char *sql_error;
> +	if (sqlite3RunParser(&parser, stmt, &sql_error) != SQLITE_OK) {
> +		char *error = tt_static_buf();
> +		snprintf(error, TT_STATIC_BUF_LEN, "%s", sql_error);
> +		diag_set(ClientError, ER_SQL_EXECUTE, stmt);
> +		goto cleanup;

1. What is happening here? 'Error' variable is unused, as well as sql_error
as I can see.




More information about the Tarantool-patches mailing list