summaryrefslogtreecommitdiff
path: root/src/backend/nodes/makefuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-03-17 00:11:05 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-03-17 00:11:05 +0000
commit0f4ff460c479e9c9bff90e8208f0a5272b9925df (patch)
treef22187ef35d7284cbc42f9255c369378d16ffe07 /src/backend/nodes/makefuncs.c
parent51d7741db13332523708cd7ac75a8ca60c9d16a9 (diff)
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/nodes/makefuncs.c')
-rw-r--r--src/backend/nodes/makefuncs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c
index 83dd71737c0..9b7f42e4631 100644
--- a/src/backend/nodes/makefuncs.c
+++ b/src/backend/nodes/makefuncs.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.54 2007/01/05 22:19:30 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.55 2007/03/17 00:11:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -140,6 +140,7 @@ flatCopyTargetEntry(TargetEntry *src_tle)
*/
Const *
makeConst(Oid consttype,
+ int32 consttypmod,
int constlen,
Datum constvalue,
bool constisnull,
@@ -148,6 +149,7 @@ makeConst(Oid consttype,
Const *cnst = makeNode(Const);
cnst->consttype = consttype;
+ cnst->consttypmod = consttypmod;
cnst->constlen = constlen;
cnst->constvalue = constvalue;
cnst->constisnull = constisnull;
@@ -159,6 +161,8 @@ makeConst(Oid consttype,
/*
* makeNullConst -
* creates a Const node representing a NULL of the specified type
+ *
+ * Note: for all current uses, OK to set typmod of the Const to -1.
*/
Const *
makeNullConst(Oid consttype)
@@ -168,6 +172,7 @@ makeNullConst(Oid consttype)
get_typlenbyval(consttype, &typLen, &typByVal);
return makeConst(consttype,
+ -1,
(int) typLen,
(Datum) 0,
true,
@@ -182,7 +187,8 @@ Node *
makeBoolConst(bool value, bool isnull)
{
/* note that pg_type.h hardwires size of bool as 1 ... duplicate it */
- return (Node *) makeConst(BOOLOID, 1, BoolGetDatum(value), isnull, true);
+ return (Node *) makeConst(BOOLOID, -1, 1,
+ BoolGetDatum(value), isnull, true);
}
/*