[Tarantool-patches] [PATCH v1 1/3] sql: properly set INTEGER type in struct Expr
imeevma at tarantool.org
imeevma at tarantool.org
Thu Oct 28 13:52:29 MSK 2021
Prior to this patch, in some cases a struct Expr value with an opcode
TK_INTEGER could have field type ANY. This patch sets such values to the
INTEGER field type.
Part of #3174
---
src/box/sql/expr.c | 2 ++
src/box/sql/resolve.c | 1 +
src/box/sql/select.c | 1 +
3 files changed, 4 insertions(+)
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index db8355f33..d3fde9501 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -1010,6 +1010,7 @@ sql_expr_new_int(struct sql *db, int value)
{
struct Expr *e = sql_expr_new_empty(db, TK_INTEGER, 0);
if (e != NULL) {
+ e->type = FIELD_TYPE_INTEGER;
e->flags |= EP_IntValue;
e->u.iValue = value;
}
@@ -3886,6 +3887,7 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
return target;
} else {
tempX.op = TK_INTEGER;
+ tempX.type = FIELD_TYPE_INTEGER;
tempX.flags = EP_IntValue | EP_TokenOnly;
tempX.u.iValue = 0;
r1 = sqlExprCodeTemp(pParse, &tempX,
diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c
index 21fe124d7..22b4e6799 100644
--- a/src/box/sql/resolve.c
+++ b/src/box/sql/resolve.c
@@ -928,6 +928,7 @@ resolveCompoundOrderBy(Parse * pParse, /* Parsing context. Leave error messages
}
pNew->flags |= EP_IntValue;
pNew->u.iValue = iCol;
+ pNew->type = FIELD_TYPE_INTEGER;
if (pItem->pExpr == pE) {
pItem->pExpr = pNew;
} else {
diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index 8ca967108..2f97d121d 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -3566,6 +3566,7 @@ multiSelectOrderBy(Parse * pParse, /* Parsing context */
}
pNew->flags |= EP_IntValue;
pNew->u.iValue = i;
+ pNew->type = FIELD_TYPE_INTEGER;
pOrderBy = sql_expr_list_append(pParse->db,
pOrderBy, pNew);
if (pOrderBy)
--
2.25.1
More information about the Tarantool-patches
mailing list