From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id EC0452F4D3 for ; Thu, 15 Nov 2018 07:09:26 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VBfaf7NucZO3 for ; Thu, 15 Nov 2018 07:09:26 -0500 (EST) Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 9D8212D7B5 for ; Thu, 15 Nov 2018 07:09:26 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v2 2/2] sql: remove space_column_default_expr() Date: Thu, 15 Nov 2018 15:09:24 +0300 Message-Id: <7227f2cec4d380e69edbe438721b46d661e406be.1542282499.git.imeevma@gmail.com> In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org --- src/box/sql.c | 14 -------------- src/box/sql.h | 11 ----------- src/box/sql/insert.c | 19 +++++++++---------- 3 files changed, 9 insertions(+), 35 deletions(-) diff --git a/src/box/sql.c b/src/box/sql.c index caa6614..98c4ebd 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -1405,20 +1405,6 @@ tarantoolSqlNextSeqId(uint64_t *max_id) return tuple_field_u64(tuple, BOX_SEQUENCE_FIELD_ID, max_id); } -struct Expr* -space_column_default_expr(uint32_t space_id, uint32_t fieldno) -{ - struct space *space; - space = space_cache_find(space_id); - assert(space != NULL); - assert(space->def != NULL); - if (space->def->opts.is_view) - return NULL; - assert(space->def->field_count > fieldno); - - return space->def->fields[fieldno].default_value_expr; -} - struct space_def * sql_ephemeral_space_def_new(struct Parse *parser, const char *name) { diff --git a/src/box/sql.h b/src/box/sql.h index ec6d9d3..1c48417 100644 --- a/src/box/sql.h +++ b/src/box/sql.h @@ -162,17 +162,6 @@ void sql_expr_extract_select(struct Parse *parser, struct Select *select); /** - * Given space_id and field number, return default value - * for the field. - * @param space_id Space ID. - * @param fieldno Field index. - * @retval Pointer to AST corresponding to default value. - * Can be NULL if no DEFAULT specified or it is a view. - */ -struct Expr* -space_column_default_expr(uint32_t space_id, uint32_t fieldno); - -/** * Get server checks list by space_id. * @param space_id Space ID. * @retval Checks list. diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c index 01bffa4..6f77202 100644 --- a/src/box/sql/insert.c +++ b/src/box/sql/insert.c @@ -601,11 +601,12 @@ sqlite3Insert(Parse * pParse, /* Parser context */ regCols + i + 1); } else { struct Expr *dflt = NULL; - dflt = space_column_default_expr( - space_id, - i); - sqlite3ExprCode(pParse, - dflt, + if (! is_view) { + struct field_def *f = + &def->fields[i]; + dflt = f->default_value_expr; + } + sqlite3ExprCode(pParse, dflt, regCols + i + 1); } } else if (useTempTable) { @@ -665,10 +666,8 @@ sqlite3Insert(Parse * pParse, /* Parser context */ space_id, iRegStore); continue; } - struct Expr *dflt = NULL; - dflt = space_column_default_expr( - space_id, - i); + struct Expr *dflt = + def->fields[i].default_value_expr; sqlite3ExprCodeFactorable(pParse, dflt, iRegStore); @@ -903,7 +902,7 @@ vdbe_emit_constraint_checks(struct Parse *parse_context, struct Table *tab, /* ABORT is a default error action. */ if (on_conflict_nullable == ON_CONFLICT_ACTION_DEFAULT) on_conflict_nullable = ON_CONFLICT_ACTION_ABORT; - struct Expr *dflt = space_column_default_expr(def->id, i); + struct Expr *dflt = def->fields[i].default_value_expr; if (on_conflict_nullable == ON_CONFLICT_ACTION_REPLACE && dflt == NULL) on_conflict_nullable = ON_CONFLICT_ACTION_ABORT; -- 2.7.4