From: imeevma@tarantool.org To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org Subject: [tarantool-patches] [PATCH v2 2/2] sql: remove space_column_default_expr() Date: Thu, 15 Nov 2018 15:09:24 +0300 [thread overview] Message-ID: <7227f2cec4d380e69edbe438721b46d661e406be.1542282499.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1542282499.git.imeevma@gmail.com> --- 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
next prev parent reply other threads:[~2018-11-15 12:09 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-15 12:09 [tarantool-patches] [PATCH v2 0/2] sql: proper check for index in sqlite3Insert() imeevma 2018-11-15 12:09 ` [tarantool-patches] [PATCH v2 1/2] " imeevma 2018-11-15 13:47 ` [tarantool-patches] " n.pettik 2018-11-15 12:09 ` imeevma [this message] 2018-11-15 13:47 ` [tarantool-patches] Re: [PATCH v2 2/2] sql: remove space_column_default_expr() n.pettik 2018-11-15 12:27 ` [tarantool-patches] Re: [PATCH v2 0/2] sql: proper check for index in sqlite3Insert() Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=7227f2cec4d380e69edbe438721b46d661e406be.1542282499.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v2 2/2] sql: remove space_column_default_expr()' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox