Commit 2c482cdb authored by Bruce Momjian's avatar Bruce Momjian

Pass attypmod through to executor by adding to Var and Resdom.

parent 2535fcde
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.23 1998/01/31 04:38:03 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.24 1998/02/10 04:00:12 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -123,7 +123,8 @@ printtup(HeapTuple tuple, TupleDesc typeinfo) ...@@ -123,7 +123,8 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
if (!isnull && OidIsValid(typoutput)) if (!isnull && OidIsValid(typoutput))
{ {
outputstr = fmgr(typoutput, attr, outputstr = fmgr(typoutput, attr,
gettypelem(typeinfo->attrs[i]->atttypid)); gettypelem(typeinfo->attrs[i]->atttypid),
(int)typeinfo->attrs[i]->atttypmod);
pq_putint(strlen(outputstr) + VARHDRSZ, VARHDRSZ); pq_putint(strlen(outputstr) + VARHDRSZ, VARHDRSZ);
pq_putnchar(outputstr, strlen(outputstr)); pq_putnchar(outputstr, strlen(outputstr));
pfree(outputstr); pfree(outputstr);
...@@ -189,7 +190,8 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo) ...@@ -189,7 +190,8 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo)
if (!isnull && OidIsValid(typoutput)) if (!isnull && OidIsValid(typoutput))
{ {
value = fmgr(typoutput, attr, value = fmgr(typoutput, attr,
gettypelem(typeinfo->attrs[i]->atttypid)); gettypelem(typeinfo->attrs[i]->atttypid),
(int)typeinfo->attrs[i]->atttypmod);
printatt((unsigned) i + 1, typeinfo->attrs[i], value); printatt((unsigned) i + 1, typeinfo->attrs[i], value);
pfree(value); pfree(value);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.33 1998/02/07 06:10:30 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.34 1998/02/10 04:00:14 momjian Exp $
* *
* NOTES * NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be * some of the executor utility code such as "ExecTypeFromTL" should be
...@@ -254,7 +254,8 @@ bool ...@@ -254,7 +254,8 @@ bool
TupleDescInitEntry(TupleDesc desc, TupleDescInitEntry(TupleDesc desc,
AttrNumber attributeNumber, AttrNumber attributeNumber,
char *attributeName, char *attributeName,
char *typeName, Oid typeid,
int typmod,
int attdim, int attdim,
bool attisset) bool attisset)
{ {
...@@ -274,7 +275,6 @@ TupleDescInitEntry(TupleDesc desc, ...@@ -274,7 +275,6 @@ TupleDescInitEntry(TupleDesc desc,
* why that is, though -- Jolly * why that is, though -- Jolly
*/ */
/* AssertArg(NameIsValid(attributeName));*/ /* AssertArg(NameIsValid(attributeName));*/
/* AssertArg(NameIsValid(typeName));*/
AssertArg(!PointerIsValid(desc->attrs[attributeNumber - 1])); AssertArg(!PointerIsValid(desc->attrs[attributeNumber - 1]));
...@@ -301,7 +301,7 @@ TupleDescInitEntry(TupleDesc desc, ...@@ -301,7 +301,7 @@ TupleDescInitEntry(TupleDesc desc,
att->attdisbursion = 0; /* dummy value */ att->attdisbursion = 0; /* dummy value */
att->attcacheoff = -1; att->attcacheoff = -1;
att->atttypmod = -1; att->atttypmod = typmod;
att->attnum = attributeNumber; att->attnum = attributeNumber;
att->attnelems = attdim; att->attnelems = attdim;
...@@ -327,7 +327,7 @@ TupleDescInitEntry(TupleDesc desc, ...@@ -327,7 +327,7 @@ TupleDescInitEntry(TupleDesc desc,
* -cim 6/14/90 * -cim 6/14/90
* ---------------- * ----------------
*/ */
tuple = SearchSysCacheTuple(TYPNAME, PointerGetDatum(typeName), tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(typeid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
{ {
...@@ -448,6 +448,7 @@ BuildDescForRelation(List *schema, char *relname) ...@@ -448,6 +448,7 @@ BuildDescForRelation(List *schema, char *relname)
TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr)); TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
char *attname; char *attname;
char *typename; char *typename;
int atttypmod;
int attdim; int attdim;
int ndef = 0; int ndef = 0;
bool attisset; bool attisset;
...@@ -481,6 +482,7 @@ BuildDescForRelation(List *schema, char *relname) ...@@ -481,6 +482,7 @@ BuildDescForRelation(List *schema, char *relname)
attname = entry->colname; attname = entry->colname;
arry = entry->typename->arrayBounds; arry = entry->typename->arrayBounds;
attisset = entry->typename->setof; attisset = entry->typename->setof;
atttypmod = entry->typename->typmod;
if (arry != NIL) if (arry != NIL)
{ {
...@@ -495,7 +497,8 @@ BuildDescForRelation(List *schema, char *relname) ...@@ -495,7 +497,8 @@ BuildDescForRelation(List *schema, char *relname)
} }
if (!TupleDescInitEntry(desc, attnum, attname, if (!TupleDescInitEntry(desc, attnum, attname,
typename, attdim, attisset)) typeTypeId(typenameType(typename)),
atttypmod, attdim, attisset))
{ {
/* ---------------- /* ----------------
* if TupleDescInitEntry() fails, it means there is * if TupleDescInitEntry() fails, it means there is
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.24 1998/01/05 16:38:49 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.25 1998/02/10 04:00:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -304,6 +304,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr) ...@@ -304,6 +304,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
typename = makeNode(TypeName); typename = makeNode(TypeName);
def->colname = pstrdup(attributeName); def->colname = pstrdup(attributeName);
typename->name = pstrdup(attributeType); typename->name = pstrdup(attributeType);
typename->typmod = attribute->atttypmod;
def->typename = typename; def->typename = typename;
def->is_not_null = attribute->attnotnull; def->is_not_null = attribute->attnotnull;
def->defval = NULL; def->defval = NULL;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.18 1998/01/20 22:10:53 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.19 1998/02/10 04:00:24 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -494,6 +494,7 @@ tg_replaceNumberedParam(Node *expression, ...@@ -494,6 +494,7 @@ tg_replaceNumberedParam(Node *expression,
newVar = makeVar(rt_ind, newVar = makeVar(rt_ind,
0, /* the whole tuple */ 0, /* the whole tuple */
TypeGet(teeRelName, &defined), TypeGet(teeRelName, &defined),
-1,
0, 0,
rt_ind, rt_ind,
0); 0);
...@@ -504,6 +505,7 @@ tg_replaceNumberedParam(Node *expression, ...@@ -504,6 +505,7 @@ tg_replaceNumberedParam(Node *expression,
1, /* just the first field, 1, /* just the first field,
* which is 'result' */ * which is 'result' */
TypeGet(teeRelName, &defined), TypeGet(teeRelName, &defined),
-1,
0, 0,
rt_ind, rt_ind,
0); 0);
...@@ -1067,8 +1069,8 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) ...@@ -1067,8 +1069,8 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
if (!TupleDescInitEntry(tupdesc, 1, if (!TupleDescInitEntry(tupdesc, 1,
"result", "result",
NULL, InvalidOid,
0, false)) -1, 0, false))
{ {
elog(NOTICE, "tg_parseSubQuery: unexpected result from TupleDescInitEntry"); elog(NOTICE, "tg_parseSubQuery: unexpected result from TupleDescInitEntry");
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.19 1998/01/05 16:39:08 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.20 1998/02/10 04:00:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -77,6 +77,8 @@ DefineVirtualRelation(char *relname, List *tlist) ...@@ -77,6 +77,8 @@ DefineVirtualRelation(char *relname, List *tlist)
typename = makeNode(TypeName); typename = makeNode(TypeName);
typename->name = pstrdup(restypename); typename->name = pstrdup(restypename);
typename->typmod = res->restypmod;
def->colname = pstrdup(resname); def->colname = pstrdup(resname);
def->typename = typename; def->typename = typename;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.40 1998/01/19 02:37:32 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.41 1998/02/10 04:00:45 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -563,8 +563,6 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) ...@@ -563,8 +563,6 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
*/ */
tupdesc = CreateTupleDescCopy(tupType); tupdesc = CreateTupleDescCopy(tupType);
setAtttypmodForCreateTable(tupdesc, targetList, rangeTable);
intoRelationId = heap_create_with_catalog(intoName, tupdesc); intoRelationId = heap_create_with_catalog(intoName, tupdesc);
FreeTupleDesc(tupdesc); FreeTupleDesc(tupdesc);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.15 1998/01/07 21:02:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.16 1998/02/10 04:00:50 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -986,7 +986,8 @@ ExecTypeFromTL(List *targetList) ...@@ -986,7 +986,8 @@ ExecTypeFromTL(List *targetList)
resdom->resno, resdom->resno,
resdom->resname, resdom->resname,
/* fix for SELECT NULL ... */ /* fix for SELECT NULL ... */
typeidTypeName(restype ? restype : UNKNOWNOID), (restype ? restype : UNKNOWNOID),
resdom->restypmod,
0, 0,
false); false);
...@@ -1019,7 +1020,8 @@ ExecTypeFromTL(List *targetList) ...@@ -1019,7 +1020,8 @@ ExecTypeFromTL(List *targetList)
TupleDescInitEntry(typeInfo, TupleDescInitEntry(typeInfo,
fjRes->resno, fjRes->resno,
fjRes->resname, fjRes->resname,
typeidTypeName(restype), restype,
fjRes->restypmod,
0, 0,
false); false);
/* /*
...@@ -1042,7 +1044,8 @@ ExecTypeFromTL(List *targetList) ...@@ -1042,7 +1044,8 @@ ExecTypeFromTL(List *targetList)
TupleDescInitEntry(typeInfo, TupleDescInitEntry(typeInfo,
fjRes->resno, fjRes->resno,
fjRes->resname, fjRes->resname,
typeidTypeName(restype), restype,
fjRes->restypmod,
0, 0,
false); false);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.27 1998/02/07 06:11:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.28 1998/02/10 04:00:52 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1179,46 +1179,3 @@ ExecInsertIndexTuples(TupleTableSlot *slot, ...@@ -1179,46 +1179,3 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
if (econtext != NULL) if (econtext != NULL)
pfree(econtext); pfree(econtext);
} }
/* ----------------------------------------------------------------
* setAtttyplenForCreateTable -
* called when we do a SELECT * INTO TABLE tab
* needed for attributes that have atttypmod like bpchar and
* varchar
* ----------------------------------------------------------------
*/
void
setAtttypmodForCreateTable(TupleDesc tupType, List *targetList,
List *rangeTable)
{
List *tl;
TargetEntry *tle;
Node *expr;
int varno;
tl = targetList;
for (varno = 0; varno < tupType->natts; varno++)
{
tle = lfirst(tl);
if (USE_ATTTYPMOD(tupType->attrs[varno]->atttypid))
{
expr = tle->expr;
if (expr && IsA(expr, Var))
{
Var *var;
RangeTblEntry *rtentry;
var = (Var *) expr;
rtentry = rt_fetch(var->varnoold, rangeTable);
tupType->attrs[varno]->atttypmod =
get_atttypmod(rtentry->relid, var->varoattno);
}
else
elog(ERROR, "setAtttypmodForCreateTable: can't get atttypmod for field (for length, etc.)");
}
tl = lnext(tl);
}
}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* columns. (ie. tuples from the same group are consecutive) * columns. (ie. tuples from the same group are consecutive)
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.14 1998/01/31 04:38:29 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.15 1998/02/10 04:00:53 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -417,9 +417,11 @@ sameGroup(TupleTableSlot *oldslot, ...@@ -417,9 +417,11 @@ sameGroup(TupleTableSlot *oldslot,
continue; continue;
val1 = fmgr(typoutput, attr1, val1 = fmgr(typoutput, attr1,
gettypelem(tupdesc->attrs[att - 1]->atttypid)); gettypelem(tupdesc->attrs[att - 1]->atttypid),
(int)tupdesc->attrs[att - 1]->atttypmod);
val2 = fmgr(typoutput, attr2, val2 = fmgr(typoutput, attr2,
gettypelem(tupdesc->attrs[att - 1]->atttypid)); gettypelem(tupdesc->attrs[att - 1]->atttypid),
(int)tupdesc->attrs[att - 1]->atttypmod);
/* /*
* now, val1 and val2 are ascii representations so we can use * now, val1 and val2 are ascii representations so we can use
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.12 1998/01/31 04:38:31 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.13 1998/02/10 04:00:55 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -196,8 +196,12 @@ ExecUnique(Unique *node) ...@@ -196,8 +196,12 @@ ExecUnique(Unique *node)
{ {
if (isNull1) /* both are null, they are equal */ if (isNull1) /* both are null, they are equal */
continue; continue;
val1 = fmgr(typoutput, attr1, gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid)); val1 = fmgr(typoutput, attr1,
val2 = fmgr(typoutput, attr2, gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid)); gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid),
(int)tupDesc->attrs[uniqueAttrNum - 1]->atttypmod);
val2 = fmgr(typoutput, attr2,
gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid),
(int)tupDesc->attrs[uniqueAttrNum - 1]->atttypmod);
/* /*
* now, val1 and val2 are ascii representations so we can * now, val1 and val2 are ascii representations so we can
......
...@@ -430,7 +430,9 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) ...@@ -430,7 +430,9 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
return (NULL); return (NULL);
} }
return (fmgr(foutoid, val, gettypelem(tupdesc->attrs[fnumber - 1]->atttypid))); return (fmgr(foutoid, val,
gettypelem(tupdesc->attrs[fnumber - 1]->atttypid),
(int)tupdesc->attrs[fnumber - 1]->atttypmod));
} }
Datum Datum
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.11 1998/01/31 04:38:34 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.12 1998/02/10 04:00:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -312,7 +312,9 @@ be_printtup(HeapTuple tuple, TupleDesc typeinfo) ...@@ -312,7 +312,9 @@ be_printtup(HeapTuple tuple, TupleDesc typeinfo)
if (!isnull && OidIsValid(typoutput)) if (!isnull && OidIsValid(typoutput))
{ {
values[i] = fmgr(typoutput, attr, gettypelem(typeinfo->attrs[i]->atttypid)); values[i] = fmgr(typoutput, attr,
gettypelem(typeinfo->attrs[i]->atttypid),
(int)typeinfo->attrs[i]->atttypmod);
} }
else else
values[i] = NULL; values[i] = NULL;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.36 1998/01/21 23:42:15 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.37 1998/02/10 04:00:44 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -591,7 +591,7 @@ _copyResdom(Resdom *from) ...@@ -591,7 +591,7 @@ _copyResdom(Resdom *from)
newnode->resno = from->resno; newnode->resno = from->resno;
newnode->restype = from->restype; newnode->restype = from->restype;
newnode->reslen = from->reslen; newnode->restypmod = from->restypmod;
if (from->resname != NULL) if (from->resname != NULL)
newnode->resname = pstrdup(from->resname); newnode->resname = pstrdup(from->resname);
...@@ -671,6 +671,7 @@ _copyVar(Var *from) ...@@ -671,6 +671,7 @@ _copyVar(Var *from)
newnode->varno = from->varno; newnode->varno = from->varno;
newnode->varattno = from->varattno; newnode->varattno = from->varattno;
newnode->vartype = from->vartype; newnode->vartype = from->vartype;
newnode->vartypmod = from->vartypmod;
newnode->varlevelsup = from->varlevelsup; newnode->varlevelsup = from->varlevelsup;
newnode->varnoold = from->varnoold; newnode->varnoold = from->varnoold;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.13 1998/01/20 22:11:02 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.14 1998/02/10 04:00:47 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -42,7 +42,7 @@ _equalResdom(Resdom *a, Resdom *b) ...@@ -42,7 +42,7 @@ _equalResdom(Resdom *a, Resdom *b)
return (false); return (false);
if (a->restype != b->restype) if (a->restype != b->restype)
return (false); return (false);
if (a->reslen != b->reslen) if (a->restypmod != b->restypmod)
return (false); return (false);
if (strcmp(a->resname, b->resname) != 0) if (strcmp(a->resname, b->resname) != 0)
return (false); return (false);
...@@ -129,6 +129,8 @@ _equalVar(Var *a, Var *b) ...@@ -129,6 +129,8 @@ _equalVar(Var *a, Var *b)
return (false); return (false);
if (a->vartype != b->vartype) if (a->vartype != b->vartype)
return (false); return (false);
if (a->vartypmod != b->vartypmod)
return (false);
if (a->varlevelsup != b->varlevelsup) if (a->varlevelsup != b->varlevelsup)
return (false); return (false);
if (a->varnoold != b->varnoold) if (a->varnoold != b->varnoold)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.5 1998/01/20 22:11:05 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.6 1998/02/10 04:00:50 momjian Exp $
* *
* NOTES * NOTES
* Creator functions in POSTGRES 4.2 are generated automatically. Most of * Creator functions in POSTGRES 4.2 are generated automatically. Most of
...@@ -53,6 +53,7 @@ Var * ...@@ -53,6 +53,7 @@ Var *
makeVar(Index varno, makeVar(Index varno,
AttrNumber varattno, AttrNumber varattno,
Oid vartype, Oid vartype,
int vartypmod,
Index varlevelsup, Index varlevelsup,
Index varnoold, Index varnoold,
AttrNumber varoattno) AttrNumber varoattno)
...@@ -62,6 +63,7 @@ makeVar(Index varno, ...@@ -62,6 +63,7 @@ makeVar(Index varno,
var->varno = varno; var->varno = varno;
var->varattno = varattno; var->varattno = varattno;
var->vartype = vartype; var->vartype = vartype;
var->vartypmod = vartypmod;
var->varlevelsup = varlevelsup; var->varlevelsup = varlevelsup;
var->varnoold = varnoold; var->varnoold = varnoold;
var->varoattno = varoattno; var->varoattno = varoattno;
...@@ -76,7 +78,7 @@ makeVar(Index varno, ...@@ -76,7 +78,7 @@ makeVar(Index varno,
Resdom * Resdom *
makeResdom(AttrNumber resno, makeResdom(AttrNumber resno,
Oid restype, Oid restype,
int reslen, int restypmod,
char *resname, char *resname,
Index reskey, Index reskey,
Oid reskeyop, Oid reskeyop,
...@@ -86,7 +88,7 @@ makeResdom(AttrNumber resno, ...@@ -86,7 +88,7 @@ makeResdom(AttrNumber resno,
resdom->resno = resno; resdom->resno = resno;
resdom->restype = restype; resdom->restype = restype;
resdom->reslen = reslen; resdom->restypmod = restypmod;
resdom->resname = resname; resdom->resname = resname;
resdom->reskey = reskey; resdom->reskey = reskey;
resdom->reskeyop = reskeyop; resdom->reskeyop = reskeyop;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.27 1998/01/25 04:07:52 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.28 1998/02/10 04:00:57 momjian Exp $
* *
* NOTES * NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which * Every (plan) node in POSTGRES has an associated "out" routine which
...@@ -606,7 +606,7 @@ _outResdom(StringInfo str, Resdom *node) ...@@ -606,7 +606,7 @@ _outResdom(StringInfo str, Resdom *node)
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :restype %u ", node->restype); sprintf(buf, " :restype %u ", node->restype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :reslen %d ", node->reslen); sprintf(buf, " :restypmod %d ", node->restypmod);
appendStringInfo(str, buf); appendStringInfo(str, buf);
appendStringInfo(str, " :resname "); appendStringInfo(str, " :resname ");
appendStringInfo(str, node->resname); appendStringInfo(str, node->resname);
...@@ -698,6 +698,8 @@ _outVar(StringInfo str, Var *node) ...@@ -698,6 +698,8 @@ _outVar(StringInfo str, Var *node)
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :vartype %u ", node->vartype); sprintf(buf, " :vartype %u ", node->vartype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :vartypmod %u ", node->vartypmod);
appendStringInfo(str, buf);
sprintf(buf, " :varlevelsup %u ", node->varlevelsup); sprintf(buf, " :varlevelsup %u ", node->varlevelsup);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :varnoold %d ", node->varnoold); sprintf(buf, " :varnoold %d ", node->varnoold);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.22 1998/01/20 22:11:15 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.23 1998/02/10 04:01:03 momjian Exp $
* *
* NOTES * NOTES
* Most of the read functions for plan nodes are tested. (In fact, they * Most of the read functions for plan nodes are tested. (In fact, they
...@@ -706,9 +706,9 @@ _readResdom() ...@@ -706,9 +706,9 @@ _readResdom()
token = lsptok(NULL, &length); /* get restype */ token = lsptok(NULL, &length); /* get restype */
local_node->restype = atol(token); local_node->restype = atol(token);
token = lsptok(NULL, &length); /* eat :reslen */ token = lsptok(NULL, &length); /* eat :restypmod */
token = lsptok(NULL, &length); /* get reslen */ token = lsptok(NULL, &length); /* get restypmod */
local_node->reslen = atoi(token); local_node->restypmod = atoi(token);
token = lsptok(NULL, &length); /* eat :resname */ token = lsptok(NULL, &length); /* eat :resname */
token = lsptok(NULL, &length); /* get the name */ token = lsptok(NULL, &length); /* get the name */
...@@ -814,6 +814,10 @@ _readVar() ...@@ -814,6 +814,10 @@ _readVar()
token = lsptok(NULL, &length); /* get vartype */ token = lsptok(NULL, &length); /* get vartype */
local_node->vartype = (Oid) atol(token); local_node->vartype = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :vartypmod */
token = lsptok(NULL, &length); /* get vartypmod */
local_node->vartypmod = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :varlevelsup */ token = lsptok(NULL, &length); /* eat :varlevelsup */
token = lsptok(NULL, &length); /* get varlevelsup */ token = lsptok(NULL, &length); /* get varlevelsup */
local_node->varlevelsup = (Oid) atol(token); local_node->varlevelsup = (Oid) atol(token);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.24 1998/01/20 22:11:25 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.25 1998/02/10 04:01:09 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -701,6 +701,7 @@ fix_indxqual_references(Node *clause, Path *index_path) ...@@ -701,6 +701,7 @@ fix_indxqual_references(Node *clause, Path *index_path)
makeVar((Index) lfirsti(index_path->parent->relids), makeVar((Index) lfirsti(index_path->parent->relids),
1, /* func indices have one key */ 1, /* func indices have one key */
((Func *) ((Expr *) clause)->oper)->functype, ((Func *) ((Expr *) clause)->oper)->functype,
-1,
0, 0,
(Index) lfirsti(index_path->parent->relids), (Index) lfirsti(index_path->parent->relids),
0); 0);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.9 1998/01/20 22:11:27 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.10 1998/02/10 04:01:11 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -116,7 +116,7 @@ add_missing_vars_to_base_rels(Query *root, List *tlist) ...@@ -116,7 +116,7 @@ add_missing_vars_to_base_rels(Query *root, List *tlist)
!rel_member(relids, root->base_relation_list_)) !rel_member(relids, root->base_relation_list_))
{ {
var = makeVar(varno, -2, 26, 0, varno, -2); var = makeVar(varno, -2, -1, 26, 0, varno, -2);
/* add it to base_relation_list_ */ /* add it to base_relation_list_ */
result = get_base_rel(root, varno); result = get_base_rel(root, varno);
add_tl_element(result, var); add_tl_element(result, var);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.17 1998/01/20 22:11:29 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.18 1998/02/10 04:01:12 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -464,6 +464,7 @@ make_groupPlan(List **tlist, ...@@ -464,6 +464,7 @@ make_groupPlan(List **tlist,
else else
te->expr = (Node *) makeVar(1, resdom->resno, te->expr = (Node *) makeVar(1, resdom->resno,
resdom->restype, resdom->restype,
resdom->restypmod,
0, -1, resdom->resno); 0, -1, resdom->resno);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.16 1998/01/20 22:11:32 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.17 1998/02/10 04:01:13 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -440,6 +440,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist) ...@@ -440,6 +440,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist)
return (makeVar(OUTER, return (makeVar(OUTER,
outer_resdom->resno, outer_resdom->resno,
var->vartype, var->vartype,
var->vartypmod,
0, 0,
var->varnoold, var->varnoold,
var->varoattno)); var->varoattno));
...@@ -454,6 +455,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist) ...@@ -454,6 +455,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist)
return (makeVar(INNER, return (makeVar(INNER,
inner_resdom->resno, inner_resdom->resno,
var->vartype, var->vartype,
var->vartypmod,
0, 0,
var->varnoold, var->varnoold,
var->varoattno)); var->varoattno));
...@@ -499,6 +501,7 @@ tlist_temp_references(Oid tempid, ...@@ -499,6 +501,7 @@ tlist_temp_references(Oid tempid,
(Node *) makeVar(tempid, (Node *) makeVar(tempid,
xtl->resdom->resno, xtl->resdom->resno,
xtl->resdom->restype, xtl->resdom->restype,
xtl->resdom->restypmod,
0, 0,
tempid, tempid,
oattno)); oattno));
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.8 1998/01/20 22:11:34 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.9 1998/02/10 04:01:15 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -108,13 +108,13 @@ preprocess_targetlist(List *tlist, ...@@ -108,13 +108,13 @@ preprocess_targetlist(List *tlist,
resdom = makeResdom(length(t_list) + 1, resdom = makeResdom(length(t_list) + 1,
27, 27,
6, -1,
"ctid", "ctid",
0, 0,
0, 0,
1); 1);
var = makeVar(result_relation, -1, 27, 0, result_relation, -1); var = makeVar(result_relation, -1, 27, -1, 0, result_relation, -1);
ctid = makeNode(TargetEntry); ctid = makeNode(TargetEntry);
ctid->resdom = resdom; ctid->resdom = resdom;
...@@ -260,23 +260,20 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type) ...@@ -260,23 +260,20 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
AttrNumber attno; AttrNumber attno;
List *t_list = NIL; List *t_list = NIL;
char *attname; char *attname;
int typlen;
Oid atttype = 0; Oid atttype = 0;
int16 typlen = 0;
bool attisset = false; bool attisset = false;
/* Oid type_id; */
/* type_id = RelationIdGetTypeId(relid); */
for (attno = 1; attno <= get_relnatts(relid); attno++) for (attno = 1; attno <= get_relnatts(relid); attno++)
{ {
attname = get_attname( /* type_id, */ relid, attno); attname = get_attname(relid, attno);
atttype = get_atttype( /* type_id, */ relid, attno); atttype = get_atttype(relid, attno);
/* /*
* Since this is an append or replace, the size of any set * Since this is an append or replace, the size of any set
* attribute is the size of the OID used to represent it. * attribute is the size of the OID used to represent it.
*/ */
attisset = get_attisset( /* type_id, */ relid, attname); attisset = get_attisset(relid, attname);
if (attisset) if (attisset)
typlen = typeLen(typeidType(OIDOID)); typlen = typeLen(typeidType(OIDOID));
else else
...@@ -300,14 +297,14 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type) ...@@ -300,14 +297,14 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
temp, temp,
(Datum) typedefault, (Datum) typedefault,
(typedefault == (struct varlena *) NULL), (typedefault == (struct varlena *) NULL),
/* XXX this is bullshit */ /* XXX ? */
false, false,
false, /* not a set */ false, /* not a set */
false); false);
temp3 = MakeTLE(makeResdom(attno, temp3 = MakeTLE(makeResdom(attno,
atttype, atttype,
typlen, -1,
attname, attname,
0, 0,
(Oid) 0, (Oid) 0,
...@@ -322,11 +319,13 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type) ...@@ -322,11 +319,13 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
TargetEntry *temp_list = NULL; TargetEntry *temp_list = NULL;
temp_var = temp_var =
makeVar(rt_index, attno, atttype, 0, rt_index, attno); makeVar(rt_index, attno, atttype,
get_atttypmod(relid, attno),
0, rt_index, attno);
temp_list = MakeTLE(makeResdom(attno, temp_list = MakeTLE(makeResdom(attno,
atttype, atttype,
typlen, get_atttypmod(relid, attno),
attname, attname,
0, 0,
(Oid) 0, (Oid) 0,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.9 1998/01/20 22:11:41 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.10 1998/02/10 04:01:21 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -108,6 +108,7 @@ add_tl_element(Rel *rel, Var *var) ...@@ -108,6 +108,7 @@ add_tl_element(Rel *rel, Var *var)
Var *newvar = makeVar(var->varno, Var *newvar = makeVar(var->varno,
var->varattno, var->varattno,
var->vartype, var->vartype,
var->vartypmod,
var->varlevelsup, var->varlevelsup,
var->varno, var->varno,
var->varoattno); var->varoattno);
...@@ -137,7 +138,7 @@ create_tl_element(Var *var, int resdomno) ...@@ -137,7 +138,7 @@ create_tl_element(Var *var, int resdomno)
tlelement->resdom = tlelement->resdom =
makeResdom(resdomno, makeResdom(resdomno,
var->vartype, var->vartype,
get_typlen(var->vartype), var->vartypmod,
NULL, NULL,
(Index) 0, (Index) 0,
(Oid) 0, (Oid) 0,
...@@ -398,7 +399,7 @@ flatten_tlist(List *tlist) ...@@ -398,7 +399,7 @@ flatten_tlist(List *tlist)
r = makeResdom(last_resdomno, r = makeResdom(last_resdomno,
var->vartype, var->vartype,
get_typlen(var->vartype), var->vartypmod,
NULL, NULL,
(Index) 0, (Index) 0,
(Oid) 0, (Oid) 0,
...@@ -591,7 +592,7 @@ AddGroupAttrToTlist(List *tlist, List *grpCl) ...@@ -591,7 +592,7 @@ AddGroupAttrToTlist(List *tlist, List *grpCl)
r = makeResdom(last_resdomno, r = makeResdom(last_resdomno,
var->vartype, var->vartype,
get_typlen(var->vartype), var->vartypmod,
NULL, NULL,
(Index) 0, (Index) 0,
(Oid) 0, (Oid) 0,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.8 1998/01/20 22:11:43 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.9 1998/02/10 04:01:27 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -209,6 +209,7 @@ var_equal(Var *var1, Var *var2) ...@@ -209,6 +209,7 @@ var_equal(Var *var1, Var *var2)
if (IsA(var1, Var) &&IsA(var2, Var) && if (IsA(var1, Var) &&IsA(var2, Var) &&
(((Var *) var1)->varno == ((Var *) var2)->varno) && (((Var *) var1)->varno == ((Var *) var2)->varno) &&
(((Var *) var1)->vartype == ((Var *) var2)->vartype) && (((Var *) var1)->vartype == ((Var *) var2)->vartype) &&
(((Var *) var1)->vartypmod == ((Var *) var2)->vartypmod) &&
(((Var *) var1)->varlevelsup == ((Var *) var2)->varlevelsup) && (((Var *) var1)->varlevelsup == ((Var *) var2)->varlevelsup) &&
(((Var *) var1)->varattno == ((Var *) var2)->varattno)) (((Var *) var1)->varattno == ((Var *) var2)->varattno))
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.69 1998/02/06 16:46:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.70 1998/02/10 04:01:38 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -307,7 +307,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) ...@@ -307,7 +307,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
te = makeNode(TargetEntry); te = makeNode(TargetEntry);
te->resdom = makeResdom(defval[ndef].adnum, te->resdom = makeResdom(defval[ndef].adnum,
att[defval[ndef].adnum - 1]->atttypid, att[defval[ndef].adnum - 1]->atttypid,
att[defval[ndef].adnum - 1]->attlen, att[defval[ndef].adnum - 1]->atttypmod,
pstrdup(nameout(&(att[defval[ndef].adnum - 1]->attname))), pstrdup(nameout(&(att[defval[ndef].adnum - 1]->attname))),
0, 0, 0); 0, 0, 0);
te->fjoin = NULL; te->fjoin = NULL;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.104 1998/02/04 06:11:46 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.105 1998/02/10 04:01:44 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -1314,6 +1314,7 @@ def_arg: ColId { $$ = (Node *)makeString($1); } ...@@ -1314,6 +1314,7 @@ def_arg: ColId { $$ = (Node *)makeString($1); }
n->name = $2; n->name = $2;
n->setof = TRUE; n->setof = TRUE;
n->arrayBounds = NULL; n->arrayBounds = NULL;
n->typmod = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
| DOUBLE { $$ = (Node *)makeString("double"); } | DOUBLE { $$ = (Node *)makeString("double"); }
...@@ -2218,6 +2219,7 @@ LockStmt: LOCK_P relation_name ...@@ -2218,6 +2219,7 @@ LockStmt: LOCK_P relation_name
c->val.val.str = "f"; c->val.val.str = "f";
c->typename = makeNode(TypeName); c->typename = makeNode(TypeName);
c->typename->name = xlateSqlType("bool"); c->typename->name = xlateSqlType("bool");
c->typename->typmod = -1;
n->relname = $2; n->relname = $2;
n->whereClause = (Node *)c; n->whereClause = (Node *)c;
...@@ -2656,6 +2658,7 @@ Generic: generic ...@@ -2656,6 +2658,7 @@ Generic: generic
{ {
$$ = makeNode(TypeName); $$ = makeNode(TypeName);
$$->name = xlateSqlType($1); $$->name = xlateSqlType($1);
$$->typmod = -1;
} }
; ;
...@@ -2674,16 +2677,19 @@ Numeric: FLOAT opt_float ...@@ -2674,16 +2677,19 @@ Numeric: FLOAT opt_float
{ {
$$ = makeNode(TypeName); $$ = makeNode(TypeName);
$$->name = xlateSqlType($2); $$->name = xlateSqlType($2);
$$->typmod = -1;
} }
| DECIMAL opt_decimal | DECIMAL opt_decimal
{ {
$$ = makeNode(TypeName); $$ = makeNode(TypeName);
$$->name = xlateSqlType("integer"); $$->name = xlateSqlType("integer");
$$->typmod = -1;
} }
| NUMERIC opt_numeric | NUMERIC opt_numeric
{ {
$$ = makeNode(TypeName); $$ = makeNode(TypeName);
$$->name = xlateSqlType("integer"); $$->name = xlateSqlType("integer");
$$->typmod = -1;
} }
; ;
...@@ -2779,6 +2785,7 @@ Character: character '(' Iconst ')' ...@@ -2779,6 +2785,7 @@ Character: character '(' Iconst ')'
{ {
$$ = makeNode(TypeName); $$ = makeNode(TypeName);
$$->name = xlateSqlType($1); $$->name = xlateSqlType($1);
$$->typmod = -1;
} }
; ;
...@@ -2824,22 +2831,26 @@ Datetime: datetime ...@@ -2824,22 +2831,26 @@ Datetime: datetime
{ {
$$ = makeNode(TypeName); $$ = makeNode(TypeName);
$$->name = xlateSqlType($1); $$->name = xlateSqlType($1);
$$->typmod = -1;
} }
| TIMESTAMP opt_timezone | TIMESTAMP opt_timezone
{ {
$$ = makeNode(TypeName); $$ = makeNode(TypeName);
$$->name = xlateSqlType("timestamp"); $$->name = xlateSqlType("timestamp");
$$->timezone = $2; $$->timezone = $2;
$$->typmod = -1;
} }
| TIME | TIME
{ {
$$ = makeNode(TypeName); $$ = makeNode(TypeName);
$$->name = xlateSqlType("time"); $$->name = xlateSqlType("time");
$$->typmod = -1;
} }
| INTERVAL opt_interval | INTERVAL opt_interval
{ {
$$ = makeNode(TypeName); $$ = makeNode(TypeName);
$$->name = xlateSqlType("interval"); $$->name = xlateSqlType("interval");
$$->typmod = -1;
} }
; ;
...@@ -3327,6 +3338,7 @@ a_expr: attr opt_indirection ...@@ -3327,6 +3338,7 @@ a_expr: attr opt_indirection
t->name = xlateSqlType("date"); t->name = xlateSqlType("date");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -3341,6 +3353,7 @@ a_expr: attr opt_indirection ...@@ -3341,6 +3353,7 @@ a_expr: attr opt_indirection
t->name = xlateSqlType("time"); t->name = xlateSqlType("time");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -3359,6 +3372,7 @@ a_expr: attr opt_indirection ...@@ -3359,6 +3372,7 @@ a_expr: attr opt_indirection
t->name = xlateSqlType("time"); t->name = xlateSqlType("time");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
if ($3 != 0) if ($3 != 0)
elog(NOTICE,"CURRENT_TIME(%d) precision not implemented; zero used instead",$3); elog(NOTICE,"CURRENT_TIME(%d) precision not implemented; zero used instead",$3);
...@@ -3376,6 +3390,7 @@ a_expr: attr opt_indirection ...@@ -3376,6 +3390,7 @@ a_expr: attr opt_indirection
t->name = xlateSqlType("timestamp"); t->name = xlateSqlType("timestamp");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -3394,6 +3409,7 @@ a_expr: attr opt_indirection ...@@ -3394,6 +3409,7 @@ a_expr: attr opt_indirection
t->name = xlateSqlType("timestamp"); t->name = xlateSqlType("timestamp");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
if ($3 != 0) if ($3 != 0)
elog(NOTICE,"CURRENT_TIMESTAMP(%d) precision not implemented; zero used instead",$3); elog(NOTICE,"CURRENT_TIMESTAMP(%d) precision not implemented; zero used instead",$3);
...@@ -3487,6 +3503,7 @@ a_expr: attr opt_indirection ...@@ -3487,6 +3503,7 @@ a_expr: attr opt_indirection
n->val.val.str = "t"; n->val.val.str = "t";
n->typename = makeNode(TypeName); n->typename = makeNode(TypeName);
n->typename->name = xlateSqlType("bool"); n->typename->name = xlateSqlType("bool");
n->typename->typmod = -1;
$$ = makeA_Expr(OP, "=", $1,(Node *)n); $$ = makeA_Expr(OP, "=", $1,(Node *)n);
} }
| a_expr IS NOT FALSE_P | a_expr IS NOT FALSE_P
...@@ -3496,6 +3513,7 @@ a_expr: attr opt_indirection ...@@ -3496,6 +3513,7 @@ a_expr: attr opt_indirection
n->val.val.str = "t"; n->val.val.str = "t";
n->typename = makeNode(TypeName); n->typename = makeNode(TypeName);
n->typename->name = xlateSqlType("bool"); n->typename->name = xlateSqlType("bool");
n->typename->typmod = -1;
$$ = makeA_Expr(OP, "=", $1,(Node *)n); $$ = makeA_Expr(OP, "=", $1,(Node *)n);
} }
| a_expr IS FALSE_P | a_expr IS FALSE_P
...@@ -3505,6 +3523,7 @@ a_expr: attr opt_indirection ...@@ -3505,6 +3523,7 @@ a_expr: attr opt_indirection
n->val.val.str = "f"; n->val.val.str = "f";
n->typename = makeNode(TypeName); n->typename = makeNode(TypeName);
n->typename->name = xlateSqlType("bool"); n->typename->name = xlateSqlType("bool");
n->typename->typmod = -1;
$$ = makeA_Expr(OP, "=", $1,(Node *)n); $$ = makeA_Expr(OP, "=", $1,(Node *)n);
} }
| a_expr IS NOT TRUE_P | a_expr IS NOT TRUE_P
...@@ -3514,6 +3533,7 @@ a_expr: attr opt_indirection ...@@ -3514,6 +3533,7 @@ a_expr: attr opt_indirection
n->val.val.str = "f"; n->val.val.str = "f";
n->typename = makeNode(TypeName); n->typename = makeNode(TypeName);
n->typename->name = xlateSqlType("bool"); n->typename->name = xlateSqlType("bool");
n->typename->typmod = -1;
$$ = makeA_Expr(OP, "=", $1,(Node *)n); $$ = makeA_Expr(OP, "=", $1,(Node *)n);
} }
| a_expr BETWEEN b_expr AND b_expr | a_expr BETWEEN b_expr AND b_expr
...@@ -3906,6 +3926,7 @@ b_expr: attr opt_indirection ...@@ -3906,6 +3926,7 @@ b_expr: attr opt_indirection
t->name = xlateSqlType("date"); t->name = xlateSqlType("date");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -3920,6 +3941,7 @@ b_expr: attr opt_indirection ...@@ -3920,6 +3941,7 @@ b_expr: attr opt_indirection
t->name = xlateSqlType("time"); t->name = xlateSqlType("time");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -3938,6 +3960,7 @@ b_expr: attr opt_indirection ...@@ -3938,6 +3960,7 @@ b_expr: attr opt_indirection
t->name = xlateSqlType("time"); t->name = xlateSqlType("time");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
if ($3 != 0) if ($3 != 0)
elog(NOTICE,"CURRENT_TIME(%d) precision not implemented; zero used instead",$3); elog(NOTICE,"CURRENT_TIME(%d) precision not implemented; zero used instead",$3);
...@@ -3955,6 +3978,7 @@ b_expr: attr opt_indirection ...@@ -3955,6 +3978,7 @@ b_expr: attr opt_indirection
t->name = xlateSqlType("timestamp"); t->name = xlateSqlType("timestamp");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -3973,6 +3997,7 @@ b_expr: attr opt_indirection ...@@ -3973,6 +3997,7 @@ b_expr: attr opt_indirection
t->name = xlateSqlType("timestamp"); t->name = xlateSqlType("timestamp");
t->setof = FALSE; t->setof = FALSE;
t->typmod = -1;
if ($3 != 0) if ($3 != 0)
elog(NOTICE,"CURRENT_TIMESTAMP(%d) precision not implemented; zero used instead",$3); elog(NOTICE,"CURRENT_TIMESTAMP(%d) precision not implemented; zero used instead",$3);
...@@ -4478,6 +4503,7 @@ AexprConst: Iconst ...@@ -4478,6 +4503,7 @@ AexprConst: Iconst
n->val.val.str = "t"; n->val.val.str = "t";
n->typename = makeNode(TypeName); n->typename = makeNode(TypeName);
n->typename->name = xlateSqlType("bool"); n->typename->name = xlateSqlType("bool");
n->typename->typmod = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
| FALSE_P | FALSE_P
...@@ -4487,6 +4513,7 @@ AexprConst: Iconst ...@@ -4487,6 +4513,7 @@ AexprConst: Iconst
n->val.val.str = "f"; n->val.val.str = "f";
n->typename = makeNode(TypeName); n->typename = makeNode(TypeName);
n->typename->name = xlateSqlType("bool"); n->typename->name = xlateSqlType("bool");
n->typename->typmod = -1;
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.12 1998/02/05 04:08:42 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.13 1998/02/10 04:01:52 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -192,13 +192,10 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, ...@@ -192,13 +192,10 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
*/ */
if (get_attnum(relid, funcname) != InvalidAttrNumber) if (get_attnum(relid, funcname) != InvalidAttrNumber)
{ {
Oid dummyTypeId; return (Node *) make_var(pstate,
return ((Node *) make_var(pstate,
relid, relid,
refname, refname,
funcname, funcname);
&dummyTypeId));
} }
else else
{ {
...@@ -311,7 +308,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, ...@@ -311,7 +308,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
toid = typeTypeId(typenameType(relname)); toid = typeTypeId(typenameType(relname));
/* replace it in the arg list */ /* replace it in the arg list */
lfirst(fargs) = lfirst(fargs) =
makeVar(vnum, 0, toid, 0, vnum, 0); makeVar(vnum, 0, toid, -1, 0, vnum, 0);
} }
else if (!attisset) else if (!attisset)
{ /* set functions don't have parameters */ { /* set functions don't have parameters */
...@@ -1059,6 +1056,7 @@ setup_tlist(char *attname, Oid relid) ...@@ -1059,6 +1056,7 @@ setup_tlist(char *attname, Oid relid)
Resdom *resnode; Resdom *resnode;
Var *varnode; Var *varnode;
Oid typeid; Oid typeid;
int type_mod;
int attno; int attno;
attno = get_attnum(relid, attname); attno = get_attnum(relid, attname);
...@@ -1066,14 +1064,16 @@ setup_tlist(char *attname, Oid relid) ...@@ -1066,14 +1064,16 @@ setup_tlist(char *attname, Oid relid)
elog(ERROR, "cannot reference attribute '%s' of tuple params/return values for functions", attname); elog(ERROR, "cannot reference attribute '%s' of tuple params/return values for functions", attname);
typeid = get_atttype(relid, attno); typeid = get_atttype(relid, attno);
type_mod = get_atttypmod(relid, attno);
resnode = makeResdom(1, resnode = makeResdom(1,
typeid, typeid,
typeLen(typeidType(typeid)), type_mod,
get_attname(relid, attno), get_attname(relid, attno),
0, 0,
(Oid) 0, (Oid) 0,
0); 0);
varnode = makeVar(-1, attno, typeid, 0, -1, attno); varnode = makeVar(-1, attno, typeid, type_mod, 0, -1, attno);
tle = makeNode(TargetEntry); tle = makeNode(TargetEntry);
tle->resdom = resnode; tle->resdom = resnode;
...@@ -1095,12 +1095,12 @@ setup_base_tlist(Oid typeid) ...@@ -1095,12 +1095,12 @@ setup_base_tlist(Oid typeid)
resnode = makeResdom(1, resnode = makeResdom(1,
typeid, typeid,
typeLen(typeidType(typeid)), -1,
"<noname>", "<noname>",
0, 0,
(Oid) 0, (Oid) 0,
0); 0);
varnode = makeVar(-1, 1, typeid, 0, -1, 1); varnode = makeVar(-1, 1, typeid, -1, 0, -1, 1);
tle = makeNode(TargetEntry); tle = makeNode(TargetEntry);
tle->resdom = resnode; tle->resdom = resnode;
tle->expr = (Node *) varnode; tle->expr = (Node *) varnode;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.10 1998/01/20 22:11:57 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.11 1998/02/10 04:01:55 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -240,12 +240,13 @@ make_op(char *opname, Node *ltree, Node *rtree) ...@@ -240,12 +240,13 @@ make_op(char *opname, Node *ltree, Node *rtree)
Var * Var *
make_var(ParseState *pstate, Oid relid, char *refname, make_var(ParseState *pstate, Oid relid, char *refname,
char *attrname, Oid *type_id) char *attrname)
{ {
Var *varnode; Var *varnode;
int vnum, int vnum,
attid; attid;
Oid vartypeid; Oid vartypeid;
int type_mod;
int sublevels_up; int sublevels_up;
vnum = refnameRangeTablePosn(pstate, refname, &sublevels_up); vnum = refnameRangeTablePosn(pstate, refname, &sublevels_up);
...@@ -255,9 +256,10 @@ make_var(ParseState *pstate, Oid relid, char *refname, ...@@ -255,9 +256,10 @@ make_var(ParseState *pstate, Oid relid, char *refname,
elog(ERROR, "Relation %s does not have attribute %s", elog(ERROR, "Relation %s does not have attribute %s",
refname, attrname); refname, attrname);
vartypeid = get_atttype(relid, attid); vartypeid = get_atttype(relid, attid);
type_mod = get_atttypmod(relid, attid);
varnode = makeVar(vnum, attid, vartypeid, sublevels_up, vnum, attid); varnode = makeVar(vnum, attid, vartypeid, type_mod,
*type_id = vartypeid; sublevels_up, vnum, attid);
return varnode; return varnode;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.9 1998/02/05 22:48:44 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.10 1998/02/10 04:01:56 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -234,8 +234,6 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno) ...@@ -234,8 +234,6 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
Var *varnode; Var *varnode;
int varattno, int varattno,
maxattrs; maxattrs;
Oid type_id;
int type_len;
RangeTblEntry *rte; RangeTblEntry *rte;
rte = refnameRangeTableEntry(pstate, refname); rte = refnameRangeTableEntry(pstate, refname);
...@@ -257,9 +255,7 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno) ...@@ -257,9 +255,7 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
TargetEntry *te = makeNode(TargetEntry); TargetEntry *te = makeNode(TargetEntry);
attrname = pstrdup((rdesc->rd_att->attrs[varattno]->attname).data); attrname = pstrdup((rdesc->rd_att->attrs[varattno]->attname).data);
varnode = (Var *) make_var(pstate, rte->relid, refname, varnode = (Var *) make_var(pstate, rte->relid, refname, attrname);
attrname, &type_id);
type_len = (int) typeLen(typeidType(type_id));
handleTargetColname(pstate, &resname, refname, attrname); handleTargetColname(pstate, &resname, refname, attrname);
if (resname != NULL) if (resname != NULL)
...@@ -271,8 +267,8 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno) ...@@ -271,8 +267,8 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
*/ */
te->resdom = makeResdom((AttrNumber) (*this_resno)++, te->resdom = makeResdom((AttrNumber) (*this_resno)++,
type_id, varnode->vartype,
(Size) type_len, varnode->vartypmod,
attrname, attrname,
(Index) 0, (Index) 0,
(Oid) 0, (Oid) 0,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.7 1998/01/20 05:04:26 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.8 1998/02/10 04:01:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "parser/parse_relation.h" #include "parser/parse_relation.h"
#include "parser/parse_target.h" #include "parser/parse_target.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/lsyscache.h"
static List *expandAllTables(ParseState *pstate); static List *expandAllTables(ParseState *pstate);
static char *figureColname(Node *expr, Node *resval); static char *figureColname(Node *expr, Node *resval);
...@@ -54,7 +55,7 @@ transformTargetList(ParseState *pstate, List *targetlist) ...@@ -54,7 +55,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
{ {
Node *expr; Node *expr;
Oid type_id; Oid type_id;
int type_len; int type_mod;
char *identname; char *identname;
char *resname; char *resname;
...@@ -67,11 +68,14 @@ transformTargetList(ParseState *pstate, List *targetlist) ...@@ -67,11 +68,14 @@ transformTargetList(ParseState *pstate, List *targetlist)
*/ */
expr = transformIdent(pstate, (Node *) res->val, EXPR_COLUMN_FIRST); expr = transformIdent(pstate, (Node *) res->val, EXPR_COLUMN_FIRST);
type_id = exprType(expr); type_id = exprType(expr);
type_len = typeLen(typeidType(type_id)); if (nodeTag(expr) == T_Var)
type_mod = ((Var *)expr)->vartypmod;
else
type_mod = -1;
resname = (res->name) ? res->name : identname; resname = (res->name) ? res->name : identname;
tent->resdom = makeResdom((AttrNumber) pstate->p_last_resno++, tent->resdom = makeResdom((AttrNumber) pstate->p_last_resno++,
(Oid) type_id, (Oid) type_id,
(Size) type_len, type_mod,
resname, resname,
(Index) 0, (Index) 0,
(Oid) 0, (Oid) 0,
...@@ -190,7 +194,7 @@ transformTargetList(ParseState *pstate, List *targetlist) ...@@ -190,7 +194,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
case T_Attr: case T_Attr:
{ {
Oid type_id; Oid type_id;
int type_len; int type_mod;
Attr *att = (Attr *) res->val; Attr *att = (Attr *) res->val;
Node *result; Node *result;
char *attrname; char *attrname;
...@@ -253,8 +257,7 @@ transformTargetList(ParseState *pstate, List *targetlist) ...@@ -253,8 +257,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
/* /*
* Target item is fully specified: ie. * Target item is fully specified: ie. relation.attribute
* relation.attribute
*/ */
result = ParseNestedFuncOrColumn(pstate, att, &pstate->p_last_resno,EXPR_COLUMN_FIRST); result = ParseNestedFuncOrColumn(pstate, att, &pstate->p_last_resno,EXPR_COLUMN_FIRST);
handleTargetColname(pstate, &res->name, att->relname, attrname); handleTargetColname(pstate, &res->name, att->relname, attrname);
...@@ -273,14 +276,17 @@ transformTargetList(ParseState *pstate, List *targetlist) ...@@ -273,14 +276,17 @@ transformTargetList(ParseState *pstate, List *targetlist)
result = (Node *) make_array_ref(result, att->indirection); result = (Node *) make_array_ref(result, att->indirection);
} }
type_id = exprType(result); type_id = exprType(result);
type_len = typeLen(typeidType(type_id)); if (nodeTag(result) == T_Var)
type_mod = ((Var *)result)->vartypmod;
else
type_mod = -1;
/* move to last entry */ /* move to last entry */
while (lnext(attrs) != NIL) while (lnext(attrs) != NIL)
attrs = lnext(attrs); attrs = lnext(attrs);
resname = (res->name) ? res->name : strVal(lfirst(attrs)); resname = (res->name) ? res->name : strVal(lfirst(attrs));
resnode = makeResdom((AttrNumber) pstate->p_last_resno++, resnode = makeResdom((AttrNumber) pstate->p_last_resno++,
(Oid) type_id, (Oid) type_id,
(Size) type_len, type_mod,
resname, resname,
(Index) 0, (Index) 0,
(Oid) 0, (Oid) 0,
...@@ -326,8 +332,7 @@ make_targetlist_expr(ParseState *pstate, ...@@ -326,8 +332,7 @@ make_targetlist_expr(ParseState *pstate,
{ {
Oid type_id, Oid type_id,
attrtype; attrtype;
int type_len, int type_mod,
attrlen,
attrtypmod; attrtypmod;
int resdomno; int resdomno;
Relation rd; Relation rd;
...@@ -339,12 +344,10 @@ make_targetlist_expr(ParseState *pstate, ...@@ -339,12 +344,10 @@ make_targetlist_expr(ParseState *pstate,
elog(ERROR, "make_targetlist_expr: invalid use of NULL expression"); elog(ERROR, "make_targetlist_expr: invalid use of NULL expression");
type_id = exprType(expr); type_id = exprType(expr);
if (type_id == InvalidOid) if (nodeTag(expr) == T_Var)
{ type_mod = ((Var *)expr)->vartypmod;
type_len = 0;
}
else else
type_len = typeLen(typeidType(type_id)); type_mod = -1;
/* Processes target columns that will be receiving results */ /* Processes target columns that will be receiving results */
if (pstate->p_is_insert || pstate->p_is_update) if (pstate->p_is_insert || pstate->p_is_update)
...@@ -361,7 +364,6 @@ make_targetlist_expr(ParseState *pstate, ...@@ -361,7 +364,6 @@ make_targetlist_expr(ParseState *pstate,
attrtype = attnumTypeId(rd, resdomno); attrtype = attnumTypeId(rd, resdomno);
if ((arrayRef != NIL) && (lfirst(arrayRef) == NIL)) if ((arrayRef != NIL) && (lfirst(arrayRef) == NIL))
attrtype = GetArrayElementType(attrtype); attrtype = GetArrayElementType(attrtype);
attrlen = typeLen(typeidType(attrtype));
attrtypmod = rd->rd_att->attrs[resdomno - 1]->atttypmod; attrtypmod = rd->rd_att->attrs[resdomno - 1]->atttypmod;
#if 0 #if 0
if (Input_is_string && Typecast_ok) if (Input_is_string && Typecast_ok)
...@@ -486,20 +488,20 @@ make_targetlist_expr(ParseState *pstate, ...@@ -486,20 +488,20 @@ make_targetlist_expr(ParseState *pstate,
lowerIndexpr, lowerIndexpr,
(Expr *) expr); (Expr *) expr);
attrtype = attnumTypeId(rd, resdomno); attrtype = attnumTypeId(rd, resdomno);
attrlen = typeLen(typeidType(attrtype)); attrtypmod = get_atttypmod(rd->rd_id, resdomno);
} }
} }
else else
{ {
resdomno = pstate->p_last_resno++; resdomno = pstate->p_last_resno++;
attrtype = type_id; attrtype = type_id;
attrlen = type_len; attrtypmod = type_mod;
} }
tent = makeNode(TargetEntry); tent = makeNode(TargetEntry);
resnode = makeResdom((AttrNumber) resdomno, resnode = makeResdom((AttrNumber) resdomno,
(Oid) attrtype, (Oid) attrtype,
(Size) attrlen, attrtypmod,
colname, colname,
(Index) 0, (Index) 0,
(Oid) 0, (Oid) 0,
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.11 1998/01/21 04:24:39 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.12 1998/02/10 04:02:02 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -206,7 +206,7 @@ FixResdomTypes(List *tlist) ...@@ -206,7 +206,7 @@ FixResdomTypes(List *tlist)
Var *var = (Var *) tle->expr; Var *var = (Var *) tle->expr;
tle->resdom->restype = var->vartype; tle->resdom->restype = var->vartype;
tle->resdom->reslen = get_typlen(var->vartype); tle->resdom->restypmod = var->vartypmod;
} }
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.27 1998/01/31 04:38:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.28 1998/02/10 04:02:05 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "catalog/index.h" /* for index_create() */ #include "catalog/index.h" /* for index_create() */
#include "catalog/catalog.h" /* for newoid() */ #include "catalog/catalog.h" /* for newoid() */
#include "catalog/pg_am.h" /* for BTREE_AM_OID */ #include "catalog/pg_am.h" /* for BTREE_AM_OID */
#include "catalog/pg_type.h" /* for INT4OID */
#include "catalog/pg_opclass.h" /* for INT4_OPS_OID */ #include "catalog/pg_opclass.h" /* for INT4_OPS_OID */
#include "catalog/pg_proc.h" /* for INT4GE_PROC_OID */ #include "catalog/pg_proc.h" /* for INT4GE_PROC_OID */
#include "storage/itemptr.h" #include "storage/itemptr.h"
...@@ -127,12 +128,12 @@ inv_create(int flags) ...@@ -127,12 +128,12 @@ inv_create(int flags)
tupdesc = CreateTemplateTupleDesc(2); tupdesc = CreateTemplateTupleDesc(2);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, TupleDescInitEntry(tupdesc, (AttrNumber) 1,
"olastbye", "olastbye",
"int4", INT4OID,
0, false); -1, 0, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, TupleDescInitEntry(tupdesc, (AttrNumber) 2,
"odata", "odata",
"bytea", BYTEAOID,
0, false); -1, 0, false);
/* /*
* First create the table to hold the inversion large object. It will * First create the table to hold the inversion large object. It will
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: tupdesc.h,v 1.13 1998/01/24 22:48:12 momjian Exp $ * $Id: tupdesc.h,v 1.14 1998/02/10 04:02:13 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -68,7 +68,8 @@ extern void FreeTupleDesc(TupleDesc tupdesc); ...@@ -68,7 +68,8 @@ extern void FreeTupleDesc(TupleDesc tupdesc);
extern bool TupleDescInitEntry(TupleDesc desc, extern bool TupleDescInitEntry(TupleDesc desc,
AttrNumber attributeNumber, AttrNumber attributeNumber,
char *attributeName, char *attributeName,
char *typeName, Oid typeid,
int typmod,
int attdim, int attdim,
bool attisset); bool attisset);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_attribute.h,v 1.25 1998/02/07 06:11:56 momjian Exp $ * $Id: pg_attribute.h,v 1.26 1998/02/10 04:02:16 momjian Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -95,8 +95,6 @@ CATALOG(pg_attribute) BOOTSTRAP ...@@ -95,8 +95,6 @@ CATALOG(pg_attribute) BOOTSTRAP
* typed constant associated with a variable. We also have a hack in * typed constant associated with a variable. We also have a hack in
* execMain.c/execUtils.c that uses atttypmod to properly create tables * execMain.c/execUtils.c that uses atttypmod to properly create tables
* for SELECT * INTO TABLE test2 FROM test; * for SELECT * INTO TABLE test2 FROM test;
* One day, we may add this to Resdom, and pass it through all areas.
* 1998/1/18 bjm
*/ */
bool attbyval; bool attbyval;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_type.h,v 1.31 1998/02/04 21:32:12 momjian Exp $ * $Id: pg_type.h,v 1.32 1998/02/10 04:02:17 momjian Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -156,6 +156,8 @@ DESCR("boolean 'true'/'false'"); ...@@ -156,6 +156,8 @@ DESCR("boolean 'true'/'false'");
DATA(insert OID = 17 ( bytea PGUID -1 -1 f b t \054 0 18 byteain byteaout byteain byteaout i _null_ )); DATA(insert OID = 17 ( bytea PGUID -1 -1 f b t \054 0 18 byteain byteaout byteain byteaout i _null_ ));
DESCR("variable length array of bytes"); DESCR("variable length array of bytes");
#define BYTEAOID 17
DATA(insert OID = 18 ( char PGUID 1 1 t b t \054 0 0 charin charout charin charout c _null_ )); DATA(insert OID = 18 ( char PGUID 1 1 t b t \054 0 0 charin charout charin charout c _null_ ));
DESCR("single character"); DESCR("single character");
#define CHAROID 18 #define CHAROID 18
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: executor.h,v 1.18 1998/01/19 02:37:51 momjian Exp $ * $Id: executor.h,v 1.19 1998/02/10 04:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,11 +18,6 @@ ...@@ -18,11 +18,6 @@
#include <stdio.h> #include <stdio.h>
#include <executor/execdesc.h> #include <executor/execdesc.h>
/* ----------------------------------------------------------------
* ----------------------------------------------------------------
*/
/* /*
* prototypes from functions in execAmi.c * prototypes from functions in execAmi.c
*/ */
...@@ -120,8 +115,6 @@ extern TupleDesc ExecTypeFromTL(List *targetList); ...@@ -120,8 +115,6 @@ extern TupleDesc ExecTypeFromTL(List *targetList);
extern void ResetTupleCount(void); extern void ResetTupleCount(void);
extern void ExecAssignNodeBaseInfo(EState *estate, CommonState *basenode, extern void ExecAssignNodeBaseInfo(EState *estate, CommonState *basenode,
Plan *parent); Plan *parent);
extern void setAtttypmodForCreateTable(TupleDesc tupType, List *targetList,
List *rangeTable);
extern void ExecAssignExprContext(EState *estate, CommonState *commonstate); extern void ExecAssignExprContext(EState *estate, CommonState *commonstate);
extern void ExecAssignResultType(CommonState *commonstate, extern void ExecAssignResultType(CommonState *commonstate,
TupleDesc tupDesc); TupleDesc tupDesc);
...@@ -143,14 +136,5 @@ extern void ExecOpenIndices(Oid resultRelationOid, ...@@ -143,14 +136,5 @@ extern void ExecOpenIndices(Oid resultRelationOid,
extern void ExecCloseIndices(RelationInfo *resultRelationInfo); extern void ExecCloseIndices(RelationInfo *resultRelationInfo);
extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid, extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid,
EState *estate, bool is_update); EState *estate, bool is_update);
extern void resetVarAttrLenForCreateTable(TupleDesc tupType);
extern void setVarAttrLenForCreateTable(TupleDesc tupType,
List *targetList, List *rangeTable);
/* ----------------------------------------------------------------
* the end
* ----------------------------------------------------------------
*/
#endif /* EXECUTOR_H */ #endif /* EXECUTOR_H */
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: makefuncs.h,v 1.7 1998/01/24 22:49:25 momjian Exp $ * $Id: makefuncs.h,v 1.8 1998/02/10 04:02:23 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -25,13 +25,14 @@ extern Oper * makeOper(Oid opno, ...@@ -25,13 +25,14 @@ extern Oper * makeOper(Oid opno,
extern Var * makeVar(Index varno, extern Var * makeVar(Index varno,
AttrNumber varattno, AttrNumber varattno,
Oid vartype, Oid vartype,
int vartypmod,
Index varlevelsup, Index varlevelsup,
Index varnoold, Index varnoold,
AttrNumber varoattno); AttrNumber varoattno);
extern Resdom * makeResdom(AttrNumber resno, extern Resdom * makeResdom(AttrNumber resno,
Oid restype, Oid restype,
int reslen, int restypmod,
char *resname, char *resname,
Index reskey, Index reskey,
Oid reskeyop, Oid reskeyop,
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: primnodes.h,v 1.16 1998/01/20 22:12:14 momjian Exp $ * $Id: primnodes.h,v 1.17 1998/02/10 04:02:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* Resdom (Result Domain) * Resdom (Result Domain)
* resno - attribute number * resno - attribute number
* restype - type of the resdom * restype - type of the resdom
* reslen - length (in bytes) of the result * restypmod - type-specific modifier of the result
* resname - name of the resdom (could be NULL) * resname - name of the resdom (could be NULL)
* reskey - order of key in a sort (for those > 0) * reskey - order of key in a sort (for those > 0)
* reskeyop - sort operator Oid * reskeyop - sort operator Oid
...@@ -41,7 +41,7 @@ typedef struct Resdom ...@@ -41,7 +41,7 @@ typedef struct Resdom
NodeTag type; NodeTag type;
AttrNumber resno; AttrNumber resno;
Oid restype; Oid restype;
int reslen; int restypmod;
char *resname; char *resname;
Index reskey; Index reskey;
Oid reskeyop; Oid reskeyop;
...@@ -104,6 +104,7 @@ typedef struct Expr ...@@ -104,6 +104,7 @@ typedef struct Expr
* (could be INNER or OUTER) * (could be INNER or OUTER)
* varattno - attribute number of this var, or zero for all * varattno - attribute number of this var, or zero for all
* vartype - pg_type tuple oid for the type of this var * vartype - pg_type tuple oid for the type of this var
* vartypmod - pg_attribute typmod value
* varlevelsup - for subquery variables referencing outer relations * varlevelsup - for subquery variables referencing outer relations
* varnoold - keep varno around in case it got changed to INNER/ * varnoold - keep varno around in case it got changed to INNER/
* OUTER (see match_varid) * OUTER (see match_varid)
...@@ -123,6 +124,7 @@ typedef struct Var ...@@ -123,6 +124,7 @@ typedef struct Var
Index varno; Index varno;
AttrNumber varattno; AttrNumber varattno;
Oid vartype; Oid vartype;
int vartypmod;
Index varlevelsup; /* erased by upper optimizer */ Index varlevelsup; /* erased by upper optimizer */
Index varnoold; /* only used by optimizer */ Index varnoold; /* only used by optimizer */
AttrNumber varoattno; /* only used by optimizer */ AttrNumber varoattno; /* only used by optimizer */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: parse_node.h,v 1.8 1998/01/31 04:39:26 momjian Exp $ * $Id: parse_node.h,v 1.9 1998/02/10 04:02:47 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -45,7 +45,7 @@ typedef struct ParseState ...@@ -45,7 +45,7 @@ typedef struct ParseState
extern ParseState *make_parsestate(ParseState *parentParseState); extern ParseState *make_parsestate(ParseState *parentParseState);
extern Expr *make_op(char *opname, Node *ltree, Node *rtree); extern Expr *make_op(char *opname, Node *ltree, Node *rtree);
extern Var *make_var(ParseState *pstate, Oid relid, char *refname, extern Var *make_var(ParseState *pstate, Oid relid, char *refname,
char *attrname, Oid *type_id); char *attrname);
extern ArrayRef *make_array_ref(Node *expr, extern ArrayRef *make_array_ref(Node *expr,
List *indirection); List *indirection);
extern ArrayRef *make_array_set(Expr *target_expr, extern ArrayRef *make_array_set(Expr *target_expr,
......
.\" This is -*-nroff-*- .\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here.... .\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/explain.l,v 1.8 1998/01/11 22:17:35 momjian Exp $ .\" $Header: /cvsroot/pgsql/src/man/Attic/explain.l,v 1.9 1998/02/10 04:02:59 momjian Exp $
.TH EXPLAIN SQL 06/12/97 PostgreSQL PostgreSQL .TH EXPLAIN SQL 06/12/97 PostgreSQL PostgreSQL
.SH NAME .SH NAME
explain - explains statement execution details explain - explains statement execution details
...@@ -30,12 +30,12 @@ tgl=> explain verbose select sum(a) from test; ...@@ -30,12 +30,12 @@ tgl=> explain verbose select sum(a) from test;
NOTICE:QUERY PLAN: NOTICE:QUERY PLAN:
{AGG :cost 0 :size 0 :width 0 :state <> :qptargetlist {AGG :cost 0 :size 0 :width 0 :state <> :qptargetlist
({TLE :resdom {RESDOM :resno 1 :restype 700 :reslen 4 :resname "sum" ({TLE :resdom {RESDOM :resno 1 :restype 700 :restypmod 4 :resname "sum"
:reskey 0 :reskeyop 0 :resjunk 0} :reskey 0 :reskeyop 0 :resjunk 0}
:expr {AGGREG :aggname "sum" :basetype 700 :aggtype 700 :aggno 0 :expr {AGGREG :aggname "sum" :basetype 700 :aggtype 700 :aggno 0
:target {VAR :varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno 1}}}) :target {VAR :varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno 1}}})
:qpqual <> :lefttree {SEQSCAN :cost 0 :size 0 :width 4 :state <> :qpqual <> :lefttree {SEQSCAN :cost 0 :size 0 :width 4 :state <>
:qptargetlist ({TLE :resdom {RESDOM :resno 1 :restype 700 :reslen 4 :qptargetlist ({TLE :resdom {RESDOM :resno 1 :restype 700 :restypmod 4
:resname "null" :reskey 0 :reskeyop 0 :resjunk 0} :resname "null" :reskey 0 :reskeyop 0 :resjunk 0}
:expr {VAR :varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno 1}}) :expr {VAR :varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno 1}})
:qpqual <> :lefttree <> :righttree <> :scanrelid 1} :righttree <> :numagg 1 } :qpqual <> :lefttree <> :righttree <> :scanrelid 1} :righttree <> :numagg 1 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment