[tarantool-patches] Re: [PATCH] sql: prohibit negative values under LIMIT clause

Konstantin Osipov kostja at tarantool.org
Fri Feb 8 20:37:09 MSK 2019


* Stanislav Zudin <szudin at tarantool.org> [19/02/04 14:32]:
> +	const char *negativeLimitError =
> +			"Only positive numbers allowed "
> +			"in the LIMIT clause";

We should use diag_set, to ensure error are visible to the
documentation team and can be localized in the future.


>  	if (p->iLimit)
>  		return;
>  
> @@ -2098,6 +2101,13 @@ computeLimitRegisters(Parse * pParse, Select * p, int iBreak)
>  		v = sqlite3GetVdbe(pParse);
>  		assert(v != 0);
>  		if (sqlite3ExprIsInteger(p->pLimit, &n)) {
> +		    if (n < 0) {
> +                sqlite3VdbeAddOp4(v, OP_Halt,
> +                                  SQLITE_MISMATCH,
> +                                  0, 0, negativeLimitError,
> +                                  P4_STATIC);
> +            }
> +

I don't think we should do any check for  limit values during
parsing, since limit should allow bind parameters anyway. This
could should become superfluous if the patch is done right.
> +			int lPosOffsetValue = sqlite3VdbeMakeLabel(v);
> +			const char *negativeOffsetError =
> +					"Only positive numbers allowed "
> +					"in the OFFSET clause";

Ugh, same message is copied multiple times?!


-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov




More information about the Tarantool-patches mailing list