Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
HAWQ-1838. fix attribute typmod for CREATE TABLE AS SELECT
Browse files Browse the repository at this point in the history
  • Loading branch information
ztao1987 committed Apr 20, 2022
1 parent 3f7a197 commit 04b8497
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/backend/nodes/copyfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,7 @@ _copyConst(Const *from)
Const *newnode = makeNode(Const);

COPY_SCALAR_FIELD(consttype);
COPY_SCALAR_FIELD(consttypmod);
COPY_SCALAR_FIELD(constlen);

if (from->constbyval || from->constisnull)
Expand Down
1 change: 1 addition & 0 deletions src/backend/nodes/equalfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ static bool
_equalConst(Const *a, Const *b)
{
COMPARE_SCALAR_FIELD(consttype);
COMPARE_SCALAR_FIELD(consttypmod);
COMPARE_SCALAR_FIELD(constlen);
COMPARE_SCALAR_FIELD(constisnull);
COMPARE_SCALAR_FIELD(constbyval);
Expand Down
1 change: 1 addition & 0 deletions src/backend/nodes/makefuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ makeConst(Oid consttype,
Const *cnst = makeNode(Const);

cnst->consttype = consttype;
cnst->consttypmod = consttypmod;
cnst->constlen = constlen;
cnst->constvalue = constvalue;
cnst->constisnull = constisnull;
Expand Down
1 change: 1 addition & 0 deletions src/backend/nodes/outfast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,7 @@ _outConst(StringInfo str, Const *node)
WRITE_NODE_TYPE("CONST");

WRITE_OID_FIELD(consttype);
WRITE_INT_FIELD(consttypmod);
WRITE_INT_FIELD(constlen);
WRITE_BOOL_FIELD(constbyval);
WRITE_BOOL_FIELD(constisnull);
Expand Down
1 change: 1 addition & 0 deletions src/backend/nodes/outfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ _outConst(StringInfo str, Const *node)
WRITE_NODE_TYPE("CONST");

WRITE_OID_FIELD(consttype);
WRITE_INT_FIELD(consttypmod);
WRITE_INT_FIELD(constlen);
WRITE_BOOL_FIELD(constbyval);
WRITE_BOOL_FIELD(constisnull);
Expand Down
1 change: 1 addition & 0 deletions src/backend/nodes/readfast.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ _readConst(const char ** str)
READ_LOCALS(Const);

READ_OID_FIELD(consttype);
READ_INT_FIELD(consttypmod);
READ_INT_FIELD(constlen);
READ_BOOL_FIELD(constbyval);
READ_BOOL_FIELD(constisnull);
Expand Down
1 change: 1 addition & 0 deletions src/backend/nodes/readfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ _readConst(void)
READ_LOCALS(Const);

READ_OID_FIELD(consttype);
READ_INT_FIELD(consttypmod);
READ_INT_FIELD(constlen);
READ_BOOL_FIELD(constbyval);
READ_BOOL_FIELD(constisnull);
Expand Down
3 changes: 3 additions & 0 deletions src/backend/optimizer/util/clauses.c
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,9 @@ eval_const_expressions_mutator(Node *node,
*/
simple = simplify_function(expr->funcid, expr->funcresulttype, args,
true, context);
if (simple && IsA(simple, Const)) {
((Const*)simple)->consttypmod = exprTypmod(expr);
}
if (simple) /* successfully simplified it */
return (Node *) simple;

Expand Down
1 change: 1 addition & 0 deletions src/backend/parser/parse_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,7 @@ exprTypmod(Node *expr)
}
break;
default:
return con->consttypmod;
break;
}
}
Expand Down

0 comments on commit 04b8497

Please sign in to comment.