[tarantool-patches] Re: [PATCH] sql: refactor primary index creation

n.pettik korablev at tarantool.org
Fri Jul 20 17:34:26 MSK 2018


LGTM, except for 1 comment.

> @@ -862,10 +861,6 @@ sqlite3AddDefaultValue(Parse * pParse, ExprSpan * pSpan)
>  * a primary key (and this is the second primary key) then create an
>  * error.
>  *
> - * Set the Table.iPKey field of the table under construction to be the
> - * index of the INTEGER PRIMARY KEY column.
> - * Table.iPKey is set to -1 if there is no INTEGER PRIMARY KEY.
> - *
>  * If the key is not an INTEGER PRIMARY KEY, then create a unique
>  * index for the key.  No index is created for INTEGER PRIMARY KEYs.
>  */
> @@ -923,14 +918,24 @@ sqlite3AddPrimaryKey(Parse * pParse,	/* Parsing context */
> 	    (pTab->def->fields[iCol].type == FIELD_TYPE_INTEGER) &&
> 	    sortOrder != SORT_ORDER_DESC) {
> 		assert(autoInc == 0 || autoInc == 1);
> -		pTab->iPKey = iCol;
> -		pTab->keyConf = (u8) onError;
> 		if (autoInc) {
> 			pTab->iAutoIncPKey = iCol;
> 			pTab->tabFlags |= TF_Autoincrement;
> 		}
> -		if (pList)
> -			pParse->iPkSortOrder = pList->a[0].sort_order;
> +		struct sqlite3 *db = pParse->db;
> +		struct ExprList *list;
> +		struct Token token;
> +		sqlite3TokenInit(&token, pTab->def->fields[iCol].name);
> +		list = sql_expr_list_append(db, NULL,
> +					    sqlite3ExprAlloc(db, TK_ID,
> +							     &token, 0));
> +		if (list == NULL)
> +			return;

I guess here should also be goto primary_key_exit;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20180720/877f8334/attachment.html>


More information about the Tarantool-patches mailing list