diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-17 00:11:05 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-17 00:11:05 +0000 |
commit | 0f4ff460c479e9c9bff90e8208f0a5272b9925df (patch) | |
tree | f22187ef35d7284cbc42f9255c369378d16ffe07 /src/backend/parser/parse_node.c | |
parent | 51d7741db13332523708cd7ac75a8ca60c9d16a9 (diff) | |
download | postgresql-0f4ff460c479e9c9bff90e8208f0a5272b9925df.tar.gz postgresql-0f4ff460c479e9c9bff90e8208f0a5272b9925df.zip |
Fix up the remaining places where the expression node structure would lose
available information about the typmod of an expression; namely, Const,
ArrayRef, ArrayExpr, and EXPR and ARRAY SubLinks. In the ArrayExpr and
SubLink cases it wasn't really the data structure's fault, but exprTypmod()
being lazy. This seems like a good idea in view of the expected increase in
typmod usage from Teodor's work to allow user-defined types to have typmods.
In particular this responds to the concerns we had about eliminating the
special-purpose hack that exprTypmod() used to have for BPCHAR Consts.
We can now tell whether or not such a Const has been cast to a specific
length, and report or display properly if so.
initdb forced due to changes in stored rules.
Diffstat (limited to 'src/backend/parser/parse_node.c')
-rw-r--r-- | src/backend/parser/parse_node.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index 4836159805b..a8dfa2666bb 100644 --- a/src/backend/parser/parse_node.c +++ b/src/backend/parser/parse_node.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.96 2007/01/05 22:19:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.97 2007/03/17 00:11:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -153,7 +153,8 @@ transformArrayType(Oid arrayType) * arrayType OID of array's datatype (should match type of arrayBase) * elementType OID of array's element type (fetch with transformArrayType, * or pass InvalidOid to do it here) - * elementTypMod typmod to be applied to array elements (if storing) + * elementTypMod typmod to be applied to array elements (if storing) or of + * the source array (if fetching) * indirection Untransformed list of subscripts (must not be NIL) * assignFrom NULL for array fetch, else transformed expression for source. */ @@ -166,7 +167,6 @@ transformArraySubscripts(ParseState *pstate, List *indirection, Node *assignFrom) { - Oid resultType; bool isSlice = false; List *upperIndexpr = NIL; List *lowerIndexpr = NIL; @@ -197,16 +197,6 @@ transformArraySubscripts(ParseState *pstate, } /* - * The type represented by the subscript expression is the element type if - * we are fetching a single element, but it is the same as the array type - * if we are fetching a slice or storing. - */ - if (isSlice || assignFrom != NULL) - resultType = arrayType; - else - resultType = elementType; - - /* * Transform the subscript expressions. */ foreach(idx, indirection) @@ -235,6 +225,7 @@ transformArraySubscripts(ParseState *pstate, { /* Make a constant 1 */ subexpr = (Node *) makeConst(INT4OID, + -1, sizeof(int32), Int32GetDatum(1), false, @@ -284,9 +275,9 @@ transformArraySubscripts(ParseState *pstate, * Ready to build the ArrayRef node. */ aref = makeNode(ArrayRef); - aref->refrestype = resultType; aref->refarraytype = arrayType; aref->refelemtype = elementType; + aref->reftypmod = elementTypMod; aref->refupperindexpr = upperIndexpr; aref->reflowerindexpr = lowerIndexpr; aref->refexpr = (Expr *) arrayBase; @@ -399,6 +390,7 @@ make_const(Value *value) case T_Null: /* return a null const */ con = makeConst(UNKNOWNOID, + -1, -2, (Datum) 0, true, @@ -411,6 +403,7 @@ make_const(Value *value) } con = makeConst(typeid, + -1, /* typmod -1 is OK for all cases */ typelen, val, false, |