Skip to content
Permalink
Browse files
HAWQ-1838. fix attribute typmod for CREATE TABLE AS SELECT
  • Loading branch information
ztao1987 committed Apr 20, 2022
1 parent 3f7a197 commit 04b8497dc54659d237d2c4283f080819a494ca8e
Showing 9 changed files with 11 additions and 0 deletions.
@@ -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)
@@ -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);
@@ -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;
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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;

@@ -2579,6 +2579,7 @@ exprTypmod(Node *expr)
}
break;
default:
return con->consttypmod;
break;
}
}

0 comments on commit 04b8497

Please sign in to comment.