[tarantool-patches] [PATCH v2 2/2] sql: remove space_column_default_expr()
imeevma at tarantool.org
imeevma at tarantool.org
Thu Nov 15 15:09:24 MSK 2018
---
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
More information about the Tarantool-patches
mailing list