]> granicus.if.org Git - postgresql/commitdiff
Pass attypmod through to executor by adding to Var and Resdom.
authorBruce Momjian <bruce@momjian.us>
Tue, 10 Feb 1998 04:02:59 +0000 (04:02 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 10 Feb 1998 04:02:59 +0000 (04:02 +0000)
40 files changed:
src/backend/access/common/printtup.c
src/backend/access/common/tupdesc.c
src/backend/commands/creatinh.c
src/backend/commands/recipe.c
src/backend/commands/view.c
src/backend/executor/execMain.c
src/backend/executor/execTuples.c
src/backend/executor/execUtils.c
src/backend/executor/nodeGroup.c
src/backend/executor/nodeUnique.c
src/backend/executor/spi.c
src/backend/libpq/be-dumpdata.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/makefuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planmain.c
src/backend/optimizer/plan/setrefs.c
src/backend/optimizer/prep/preptlist.c
src/backend/optimizer/util/tlist.c
src/backend/optimizer/util/var.c
src/backend/parser/analyze.c
src/backend/parser/gram.y
src/backend/parser/parse_func.c
src/backend/parser/parse_node.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_target.c
src/backend/rewrite/rewriteManip.c
src/backend/storage/large_object/inv_api.c
src/include/access/tupdesc.h
src/include/catalog/pg_attribute.h
src/include/catalog/pg_type.h
src/include/executor/executor.h
src/include/nodes/makefuncs.h
src/include/nodes/primnodes.h
src/include/parser/parse_node.h
src/man/explain.l

index fcedc3adf2986129a1576074c524b83ad677de53..8181b17401abe110c32b3efe6c3717f46c85b75e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * 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)
                if (!isnull && OidIsValid(typoutput))
                {
                        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_putnchar(outputstr, strlen(outputstr));
                        pfree(outputstr);
@@ -189,7 +190,8 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo)
                if (!isnull && OidIsValid(typoutput))
                {
                        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);
                        pfree(value);
                }
index e3f719a0f3b3ed3ac10112adb64dd83fc8a8dd83..440084062b66c46a1c7bd0c689eb71ee657e18bc 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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
  *       some of the executor utility code such as "ExecTypeFromTL" should be
@@ -254,7 +254,8 @@ bool
 TupleDescInitEntry(TupleDesc desc,
                                   AttrNumber attributeNumber,
                                   char *attributeName,
-                                  char *typeName,
+                                  Oid typeid,
+                                  int typmod,
                                   int attdim,
                                   bool attisset)
 {
@@ -274,7 +275,6 @@ TupleDescInitEntry(TupleDesc desc,
         * why that is, though -- Jolly
         */
 /*       AssertArg(NameIsValid(attributeName));*/
-/*       AssertArg(NameIsValid(typeName));*/
 
        AssertArg(!PointerIsValid(desc->attrs[attributeNumber - 1]));
 
@@ -301,7 +301,7 @@ TupleDescInitEntry(TupleDesc desc,
 
        att->attdisbursion = 0;         /* dummy value */
        att->attcacheoff = -1;
-       att->atttypmod = -1;
+       att->atttypmod = typmod;
 
        att->attnum = attributeNumber;
        att->attnelems = attdim;
@@ -327,7 +327,7 @@ TupleDescInitEntry(TupleDesc desc,
         *      -cim 6/14/90
         * ----------------
         */
-       tuple = SearchSysCacheTuple(TYPNAME, PointerGetDatum(typeName),
+       tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(typeid),
                                                                0, 0, 0);
        if (!HeapTupleIsValid(tuple))
        {
@@ -448,6 +448,7 @@ BuildDescForRelation(List *schema, char *relname)
        TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
        char       *attname;
        char       *typename;
+       int                     atttypmod;
        int                     attdim;
        int                     ndef = 0;
        bool            attisset;
@@ -481,6 +482,7 @@ BuildDescForRelation(List *schema, char *relname)
                attname = entry->colname;
                arry = entry->typename->arrayBounds;
                attisset = entry->typename->setof;
+               atttypmod = entry->typename->typmod;
 
                if (arry != NIL)
                {
@@ -495,7 +497,8 @@ BuildDescForRelation(List *schema, char *relname)
                }
 
                if (!TupleDescInitEntry(desc, attnum, attname,
-                                                               typename, attdim, attisset))
+                                                               typeTypeId(typenameType(typename)),
+                                                               atttypmod, attdim, attisset))
                {
                        /* ----------------
                         *      if TupleDescInitEntry() fails, it means there is
index 8e60f2b450bb008fe67645dd79136e34efd37ecd..13f43d7a75c963dc1193a53939ff24a65dffaf7b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
                        typename = makeNode(TypeName);
                        def->colname = pstrdup(attributeName);
                        typename->name = pstrdup(attributeType);
+                       typename->typmod = attribute->atttypmod;
                        def->typename = typename;
                        def->is_not_null = attribute->attnotnull;
                        def->defval = NULL;
index 96808a6e3115f8003f2917ddc18a4ebb24ccdb9c..a95913392ca2cadeb758d46ee5d2ee73f69a693a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -493,7 +493,8 @@ tg_replaceNumberedParam(Node *expression,
                                                {
                                                        newVar = makeVar(rt_ind,
                                                                                         0, /* the whole tuple */
-                                                                                  TypeGet(teeRelName, &defined),
+                                                                                        TypeGet(teeRelName, &defined),
+                                                                                        -1,
                                                                                     0,
                                                                                         rt_ind,
                                                                                         0);
@@ -503,7 +504,8 @@ tg_replaceNumberedParam(Node *expression,
                                                        newVar = makeVar(rt_ind,
                                                                                         1, /* just the first field,
                                                                                                 * which is 'result' */
-                                                                                  TypeGet(teeRelName, &defined),
+                                                                                        TypeGet(teeRelName, &defined),
+                                                                                        -1,
                                                                                     0,
                                                                                         rt_ind,
                                                                                         0);
@@ -1067,8 +1069,8 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
 
                                if (!TupleDescInitEntry(tupdesc, 1,
                                                                                "result",
-                                                                               NULL,
-                                                                               0, false))
+                                                                               InvalidOid,
+                                                                               -1, 0, false))
                                {
                                        elog(NOTICE, "tg_parseSubQuery: unexpected result from TupleDescInitEntry");
                                }
index c7f54749883ab85b82fb9a795639b81d94f742d5..38a39ed3923e7014dc59cd54c471b26a52ea5b99 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
                        typename = makeNode(TypeName);
 
                        typename->name = pstrdup(restypename);
+                       typename->typmod = res->restypmod;
+
                        def->colname = pstrdup(resname);
 
                        def->typename = typename;
index ba3275f346a369035a047a3733adcdfec01144ae..c4bea118db67e71bc976597c96effe102ef2cde0 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * 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)
                                 */
                                tupdesc = CreateTupleDescCopy(tupType);
 
-                               setAtttypmodForCreateTable(tupdesc, targetList, rangeTable);
-
                                intoRelationId = heap_create_with_catalog(intoName, tupdesc);
 
                                FreeTupleDesc(tupdesc);
index e8787efd6ced440e1bae95c48ac370ce2b3ef3cd..5f2336ce19dd85cbe1975c4489da47c20b9b5787 100644 (file)
@@ -14,7 +14,7 @@
  *
  *
  * 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)
                                                           resdom->resno,
                                                           resdom->resname,
                        /* fix for SELECT NULL ... */
-                                                 typeidTypeName(restype ? restype : UNKNOWNOID),
+                                                          (restype ? restype : UNKNOWNOID),
+                                                          resdom->restypmod,
                                                           0,
                                                           false);
 
@@ -1019,7 +1020,8 @@ ExecTypeFromTL(List *targetList)
                        TupleDescInitEntry(typeInfo,
                                                           fjRes->resno,
                                                           fjRes->resname,
-                                                          typeidTypeName(restype),
+                                                          restype,
+                                                          fjRes->restypmod,
                                                           0,
                                                           false);
 /*
@@ -1042,7 +1044,8 @@ ExecTypeFromTL(List *targetList)
                                TupleDescInitEntry(typeInfo,
                                                                   fjRes->resno,
                                                                   fjRes->resname,
-                                                                  typeidTypeName(restype),
+                                                                  restype,
+                                                                  fjRes->restypmod,
                                                                   0,
                                                                   false);
 
index 244bfdaa4010ce43e65f829e0e6e96f7ca5478cc..e02205828aeb91b05b3b032c8c55984f99f57022 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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,
        if (econtext != NULL)
                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);
-       }
-}
-
index 516cd624bfc94b56164edd45ccd9748334c52883..da9f8c06a1aea05b5a19fe6603a50e2a0d2db710 100644 (file)
@@ -13,7 +13,7 @@
  *       columns. (ie. tuples from the same group are consecutive)
  *
  * 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,
                                continue;
 
                        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,
-                                               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
index ddb8d6ea66097ab517367b53183f6e8d8f12bf3b..52f3f247c9b29bb2c7225f9aba696b2fbbe214a2 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
                        {
                                if (isNull1)    /* both are null, they are equal */
                                        continue;
-                               val1 = fmgr(typoutput, attr1, gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid));
-                               val2 = fmgr(typoutput, attr2, gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid));
+                               val1 = fmgr(typoutput, attr1,
+                                       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
index cd898a1c2094c9311e5d8251caa1d6d67ae2c8b2..103f40ac9f23a708b9fc834f83a8aa6209b9749e 100644 (file)
@@ -430,7 +430,9 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
                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
index 13c826cb078b7d01c72ad604237285630d6390ba..212ec397a964ecebae8207652d2023369cf2ef75 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * 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)
 
                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
                        values[i] = NULL;
index ce3ffb9f3350fdd3e4490bbcb7d15a8dc4879ca5..7cd00218c0a559a0ed6946fb7688d243b5dcb396 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
 
        newnode->resno = from->resno;
        newnode->restype = from->restype;
-       newnode->reslen = from->reslen;
+       newnode->restypmod = from->restypmod;
 
        if (from->resname != NULL)
                newnode->resname = pstrdup(from->resname);
@@ -671,6 +671,7 @@ _copyVar(Var *from)
        newnode->varno = from->varno;
        newnode->varattno = from->varattno;
        newnode->vartype = from->vartype;
+       newnode->vartypmod = from->vartypmod;
        newnode->varlevelsup = from->varlevelsup;
 
        newnode->varnoold = from->varnoold;
index bfed02b5e568a30ed1142f22aba46c696142326c..254b62c9fd6d4556c89af8ff33f6a98d86fba7cf 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
                return (false);
        if (a->restype != b->restype)
                return (false);
-       if (a->reslen != b->reslen)
+       if (a->restypmod != b->restypmod)
                return (false);
        if (strcmp(a->resname, b->resname) != 0)
                return (false);
@@ -129,6 +129,8 @@ _equalVar(Var *a, Var *b)
                return (false);
        if (a->vartype != b->vartype)
                return (false);
+       if (a->vartypmod != b->vartypmod)
+               return (false);
        if (a->varlevelsup != b->varlevelsup)
                return (false);
        if (a->varnoold != b->varnoold)
index af5003e87732271c0e93c216bafb098493dc2e9d..8dcfdd8e364b8fea442a1e272cb308427dd8e72d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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
  *       Creator functions in POSTGRES 4.2 are generated automatically. Most of
@@ -53,6 +53,7 @@ Var              *
 makeVar(Index varno,
                AttrNumber varattno,
                Oid vartype,
+               int vartypmod,
                Index varlevelsup,
                Index varnoold,
                AttrNumber varoattno)
@@ -62,6 +63,7 @@ makeVar(Index varno,
        var->varno = varno;
        var->varattno = varattno;
        var->vartype = vartype;
+       var->vartypmod = vartypmod;
        var->varlevelsup = varlevelsup;
        var->varnoold = varnoold;
        var->varoattno = varoattno;
@@ -76,7 +78,7 @@ makeVar(Index varno,
 Resdom    *
 makeResdom(AttrNumber resno,
                   Oid restype,
-                  int reslen,
+                  int restypmod,
                   char *resname,
                   Index reskey,
                   Oid reskeyop,
@@ -86,7 +88,7 @@ makeResdom(AttrNumber resno,
 
        resdom->resno = resno;
        resdom->restype = restype;
-       resdom->reslen = reslen;
+       resdom->restypmod = restypmod;
        resdom->resname = resname;
        resdom->reskey = reskey;
        resdom->reskeyop = reskeyop;
index 2f72b2de66e82c2820bd4f18d01444bc13fd915a..48ed8cfd3834dbac4f407a3337dd5035f2d99fcd 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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
  *       Every (plan) node in POSTGRES has an associated "out" routine which
@@ -606,7 +606,7 @@ _outResdom(StringInfo str, Resdom *node)
        appendStringInfo(str, buf);
        sprintf(buf, " :restype %u ", node->restype);
        appendStringInfo(str, buf);
-       sprintf(buf, " :reslen %d ", node->reslen);
+       sprintf(buf, " :restypmod %d ", node->restypmod);
        appendStringInfo(str, buf);
        appendStringInfo(str, " :resname ");
        appendStringInfo(str, node->resname);
@@ -698,6 +698,8 @@ _outVar(StringInfo str, Var *node)
        appendStringInfo(str, buf);
        sprintf(buf, " :vartype %u ", node->vartype);
        appendStringInfo(str, buf);
+       sprintf(buf, " :vartypmod %u ", node->vartypmod);
+       appendStringInfo(str, buf);
        sprintf(buf, " :varlevelsup %u ", node->varlevelsup);
        appendStringInfo(str, buf);
        sprintf(buf, " :varnoold %d ", node->varnoold);
index d0bcf13875fed190d5cce4340b219b7620a05835..4406d9e89d8606bde966931b0d5b7dabdce95530 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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
  *       Most of the read functions for plan nodes are tested. (In fact, they
@@ -706,9 +706,9 @@ _readResdom()
        token = lsptok(NULL, &length);          /* get restype */
        local_node->restype = atol(token);
 
-       token = lsptok(NULL, &length);          /* eat :reslen */
-       token = lsptok(NULL, &length);          /* get reslen */
-       local_node->reslen = atoi(token);
+       token = lsptok(NULL, &length);          /* eat :restypmod */
+       token = lsptok(NULL, &length);          /* get restypmod */
+       local_node->restypmod = atoi(token);
 
        token = lsptok(NULL, &length);          /* eat :resname */
        token = lsptok(NULL, &length);          /* get the name */
@@ -814,6 +814,10 @@ _readVar()
        token = lsptok(NULL, &length);          /* get vartype */
        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);          /* get varlevelsup */
        local_node->varlevelsup = (Oid) atol(token);
index 2b53f1875fe6d1d76d2ba3e4a323219dfd0a8fa7..f6a1470be8e9a21e5b21bd7b007546d9e17952c1 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
                makeVar((Index) lfirsti(index_path->parent->relids),
                                1,                              /* func indices have one key */
                                ((Func *) ((Expr *) clause)->oper)->functype,
+                               -1,
                                0,
                                (Index) lfirsti(index_path->parent->relids),
                                0);
index cb0bd085875ac2fdaffdba3bbf955d706252ae83..322c272e752dd1dee5466fef6bb6a1107e6503a5 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
                        !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_ */
                        result = get_base_rel(root, varno);
                        add_tl_element(result, var);
index 1c59f64a4c84293893cd23f4acc271b7960253dd..10e67b76cd2f3103a352cee65737a3564ba30cd6 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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,
                else
                        te->expr = (Node *) makeVar(1, resdom->resno,
                                                                                resdom->restype,
+                                                                               resdom->restypmod,
                                                                                0, -1, resdom->resno);
        }
 
index 284ac836f63603b0176b0f4d32503a811266aa3c..16fd96aae1b316dc2988645c12c2739226e1665b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
                return (makeVar(OUTER,
                                                outer_resdom->resno,
                                                var->vartype,
+                                               var->vartypmod,
                                                0,
                                                var->varnoold,
                                                var->varoattno));
@@ -454,6 +455,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist)
                        return (makeVar(INNER,
                                                        inner_resdom->resno,
                                                        var->vartype,
+                                                       var->vartypmod,
                                                        0,
                                                        var->varnoold,
                                                        var->varoattno));
@@ -499,6 +501,7 @@ tlist_temp_references(Oid tempid,
                                           (Node *) makeVar(tempid,
                                                                                xtl->resdom->resno,
                                                                                xtl->resdom->restype,
+                                                                               xtl->resdom->restypmod,
                                                                                0,
                                                                                tempid,
                                                                                oattno));
index ad2c697db5a4533bed2851e2a21eb8bb1de3f541..43ba76ff54a02cc8af463665c5a185da1d0ab572 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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,
 
                resdom = makeResdom(length(t_list) + 1,
                                                        27,
-                                                       6,
+                                                       -1,
                                                        "ctid",
                                                        0,
                                                        0,
                                                        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->resdom = resdom;
@@ -260,23 +260,20 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
        AttrNumber      attno;
        List       *t_list = NIL;
        char       *attname;
+       int                     typlen;
        Oid                     atttype = 0;
-       int16           typlen = 0;
        bool            attisset = false;
 
-/*       Oid type_id; */
-/*       type_id = RelationIdGetTypeId(relid); */
-
        for (attno = 1; attno <= get_relnatts(relid); attno++)
        {
-               attname = get_attname( /* type_id, */ relid, attno);
-               atttype = get_atttype( /* type_id, */ relid, attno);
+               attname = get_attname(relid, attno);
+               atttype = get_atttype(relid, attno);
 
                /*
                 * Since this is an append or replace, the size of any set
                 * 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)
                        typlen = typeLen(typeidType(OIDOID));
                else
@@ -300,14 +297,14 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
                                                                          temp,
                                                                          (Datum) typedefault,
                                                                (typedefault == (struct varlena *) NULL),
-                                       /* XXX this is bullshit */
+                                                                       /* XXX ? */
                                                                          false,
                                                                          false,        /* not a set */
                                                                          false);
 
                                        temp3 = MakeTLE(makeResdom(attno,
                                                                                           atttype,
-                                                                                          typlen,
+                                                                                          -1,
                                                                                           attname,
                                                                                           0,
                                                                                           (Oid) 0,
@@ -322,11 +319,13 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
                                        TargetEntry *temp_list = NULL;
 
                                        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,
                                                                                                   atttype,
-                                                                                                  typlen,
+                                                                                                  get_atttypmod(relid, attno),
                                                                                                   attname,
                                                                                                   0,
                                                                                                   (Oid) 0,
index edac3e8bf4bd0b13acf8ba893cd75a5c37b00752..805ac38b902f3dc962abe390bc017fe646a899f6 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
                Var                *newvar = makeVar(var->varno,
                                                                         var->varattno,
                                                                         var->vartype,
+                                                                        var->vartypmod,
                                                                         var->varlevelsup,
                                                                         var->varno,
                                                                         var->varoattno);
@@ -137,7 +138,7 @@ create_tl_element(Var *var, int resdomno)
        tlelement->resdom =
                makeResdom(resdomno,
                                   var->vartype,
-                                  get_typlen(var->vartype),
+                                  var->vartypmod,
                                   NULL,
                                   (Index) 0,
                                   (Oid) 0,
@@ -398,7 +399,7 @@ flatten_tlist(List *tlist)
 
                        r = makeResdom(last_resdomno,
                                                   var->vartype,
-                                                  get_typlen(var->vartype),
+                                                  var->vartypmod,
                                                   NULL,
                                                   (Index) 0,
                                                   (Oid) 0,
@@ -591,7 +592,7 @@ AddGroupAttrToTlist(List *tlist, List *grpCl)
 
                        r = makeResdom(last_resdomno,
                                                   var->vartype,
-                                                  get_typlen(var->vartype),
+                                                  var->vartypmod,
                                                   NULL,
                                                   (Index) 0,
                                                   (Oid) 0,
index e3ed305ed88ebce158a91dc5d6432f7b0c6f61e3..41624a171077979da1acba2241b547601f208672 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
        if (IsA(var1, Var) &&IsA(var2, Var) &&
                (((Var *) var1)->varno == ((Var *) var2)->varno) &&
                (((Var *) var1)->vartype == ((Var *) var2)->vartype) &&
+               (((Var *) var1)->vartypmod == ((Var *) var2)->vartypmod) &&
                (((Var *) var1)->varlevelsup == ((Var *) var2)->varlevelsup) &&
                (((Var *) var1)->varattno == ((Var *) var2)->varattno))
        {
index 64069bfa2b7b733ddc0692319a3289cc6b8cd232..fc5ce5736e51cc6aa951a77f6ef061874f7e7afc 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
                        te = makeNode(TargetEntry);
                        te->resdom = makeResdom(defval[ndef].adnum,
                                                                        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))),
                                                                        0, 0, 0);
                        te->fjoin = NULL;
index 0100081a4a103e558124b812438f7984f79850d9..fdf0a4419a5179e37a73205ab1b1a6955400f9a8 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * 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
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -1314,6 +1314,7 @@ def_arg:  ColId                                                   {  $$ = (Node *)makeString($1); }
                                        n->name = $2;
                                        n->setof = TRUE;
                                        n->arrayBounds = NULL;
+                                       n->typmod = -1;
                                        $$ = (Node *)n;
                                }
                | DOUBLE                                                {  $$ = (Node *)makeString("double"); }
@@ -2218,6 +2219,7 @@ LockStmt:  LOCK_P relation_name
                                        c->val.val.str = "f";
                                        c->typename = makeNode(TypeName);
                                        c->typename->name = xlateSqlType("bool");
+                                       c->typename->typmod = -1;
 
                                        n->relname = $2;
                                        n->whereClause = (Node *)c;
@@ -2656,6 +2658,7 @@ Generic:  generic
                                {
                                        $$ = makeNode(TypeName);
                                        $$->name = xlateSqlType($1);
+                                       $$->typmod = -1;
                                }
                ;
 
@@ -2674,16 +2677,19 @@ Numeric:  FLOAT opt_float
                                {
                                        $$ = makeNode(TypeName);
                                        $$->name = xlateSqlType($2);
+                                       $$->typmod = -1;
                                }
                | DECIMAL opt_decimal
                                {
                                        $$ = makeNode(TypeName);
                                        $$->name = xlateSqlType("integer");
+                                       $$->typmod = -1;
                                }
                | NUMERIC opt_numeric
                                {
                                        $$ = makeNode(TypeName);
                                        $$->name = xlateSqlType("integer");
+                                       $$->typmod = -1;
                                }
                ;
 
@@ -2779,6 +2785,7 @@ Character:  character '(' Iconst ')'
                                {
                                        $$ = makeNode(TypeName);
                                        $$->name = xlateSqlType($1);
+                                       $$->typmod = -1;
                                }
                ;
 
@@ -2824,22 +2831,26 @@ Datetime:  datetime
                                {
                                        $$ = makeNode(TypeName);
                                        $$->name = xlateSqlType($1);
+                                       $$->typmod = -1;
                                }
                | TIMESTAMP opt_timezone
                                {
                                        $$ = makeNode(TypeName);
                                        $$->name = xlateSqlType("timestamp");
                                        $$->timezone = $2;
+                                       $$->typmod = -1;
                                }
                | TIME
                                {
                                        $$ = makeNode(TypeName);
                                        $$->name = xlateSqlType("time");
+                                       $$->typmod = -1;
                                }
                | INTERVAL opt_interval
                                {
                                        $$ = makeNode(TypeName);
                                        $$->name = xlateSqlType("interval");
+                                       $$->typmod = -1;
                                }
                ;
 
@@ -3327,7 +3338,8 @@ a_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("date");
                                        t->setof = FALSE;
-
+                                       t->typmod = -1;
                                        $$ = (Node *)n;
                                }
                | CURRENT_TIME
@@ -3341,6 +3353,7 @@ a_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("time");
                                        t->setof = FALSE;
+                                       t->typmod = -1;
 
                                        $$ = (Node *)n;
                                }
@@ -3359,6 +3372,7 @@ a_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("time");
                                        t->setof = FALSE;
+                                       t->typmod = -1;
 
                                        if ($3 != 0)
                                                elog(NOTICE,"CURRENT_TIME(%d) precision not implemented; zero used instead",$3);
@@ -3376,6 +3390,7 @@ a_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("timestamp");
                                        t->setof = FALSE;
+                                       t->typmod = -1;
 
                                        $$ = (Node *)n;
                                }
@@ -3394,6 +3409,7 @@ a_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("timestamp");
                                        t->setof = FALSE;
+                                       t->typmod = -1;
 
                                        if ($3 != 0)
                                                elog(NOTICE,"CURRENT_TIMESTAMP(%d) precision not implemented; zero used instead",$3);
@@ -3487,6 +3503,7 @@ a_expr:  attr opt_indirection
                                        n->val.val.str = "t";
                                        n->typename = makeNode(TypeName);
                                        n->typename->name = xlateSqlType("bool");
+                                       n->typename->typmod = -1;
                                        $$ = makeA_Expr(OP, "=", $1,(Node *)n);
                                }
                | a_expr IS NOT FALSE_P
@@ -3496,6 +3513,7 @@ a_expr:  attr opt_indirection
                                        n->val.val.str = "t";
                                        n->typename = makeNode(TypeName);
                                        n->typename->name = xlateSqlType("bool");
+                                       n->typename->typmod = -1;
                                        $$ = makeA_Expr(OP, "=", $1,(Node *)n);
                                }
                | a_expr IS FALSE_P
@@ -3505,6 +3523,7 @@ a_expr:  attr opt_indirection
                                        n->val.val.str = "f";
                                        n->typename = makeNode(TypeName);
                                        n->typename->name = xlateSqlType("bool");
+                                       n->typename->typmod = -1;
                                        $$ = makeA_Expr(OP, "=", $1,(Node *)n);
                                }
                | a_expr IS NOT TRUE_P
@@ -3514,6 +3533,7 @@ a_expr:  attr opt_indirection
                                        n->val.val.str = "f";
                                        n->typename = makeNode(TypeName);
                                        n->typename->name = xlateSqlType("bool");
+                                       n->typename->typmod = -1;
                                        $$ = makeA_Expr(OP, "=", $1,(Node *)n);
                                }
                | a_expr BETWEEN b_expr AND b_expr
@@ -3906,6 +3926,7 @@ b_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("date");
                                        t->setof = FALSE;
+                                       t->typmod = -1;
 
                                        $$ = (Node *)n;
                                }
@@ -3920,6 +3941,7 @@ b_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("time");
                                        t->setof = FALSE;
+                                       t->typmod = -1;
 
                                        $$ = (Node *)n;
                                }
@@ -3938,6 +3960,7 @@ b_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("time");
                                        t->setof = FALSE;
+                                       t->typmod = -1;
 
                                        if ($3 != 0)
                                                elog(NOTICE,"CURRENT_TIME(%d) precision not implemented; zero used instead",$3);
@@ -3955,6 +3978,7 @@ b_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("timestamp");
                                        t->setof = FALSE;
+                                       t->typmod = -1;
 
                                        $$ = (Node *)n;
                                }
@@ -3973,6 +3997,7 @@ b_expr:  attr opt_indirection
 
                                        t->name = xlateSqlType("timestamp");
                                        t->setof = FALSE;
+                                       t->typmod = -1;
 
                                        if ($3 != 0)
                                                elog(NOTICE,"CURRENT_TIMESTAMP(%d) precision not implemented; zero used instead",$3);
@@ -4478,6 +4503,7 @@ AexprConst:  Iconst
                                        n->val.val.str = "t";
                                        n->typename = makeNode(TypeName);
                                        n->typename->name = xlateSqlType("bool");
+                                       n->typename->typmod = -1;
                                        $$ = (Node *)n;
                                }
                | FALSE_P
@@ -4487,6 +4513,7 @@ AexprConst:  Iconst
                                        n->val.val.str = "f";
                                        n->typename = makeNode(TypeName);
                                        n->typename->name = xlateSqlType("bool");
+                                       n->typename->typmod = -1;
                                        $$ = (Node *)n;
                                }
                ;
index 2325251ade3ef83c3f19a24d34d6e6cfa27ef173..79a97826409c51763339171c7c0b8e9816110a0b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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,
                         */
                        if (get_attnum(relid, funcname) != InvalidAttrNumber)
                        {
-                               Oid                     dummyTypeId;
-
-                               return ((Node *) make_var(pstate,
+                               return (Node *) make_var(pstate,
                                                                           relid,
                                                                           refname,
-                                                                          funcname,
-                                                                          &dummyTypeId));
+                                                                          funcname);
                        }
                        else
                        {
@@ -311,7 +308,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
                        toid = typeTypeId(typenameType(relname));
                        /* replace it in the arg list */
                        lfirst(fargs) =
-                               makeVar(vnum, 0, toid, 0, vnum, 0);
+                               makeVar(vnum, 0, toid, -1, 0, vnum, 0);
                }
                else if (!attisset)
                {                                               /* set functions don't have parameters */
@@ -1059,6 +1056,7 @@ setup_tlist(char *attname, Oid relid)
        Resdom     *resnode;
        Var                *varnode;
        Oid                     typeid;
+       int                     type_mod;
        int                     attno;
 
        attno = get_attnum(relid, attname);
@@ -1066,14 +1064,16 @@ setup_tlist(char *attname, Oid relid)
                elog(ERROR, "cannot reference attribute '%s' of tuple params/return values for functions", attname);
 
        typeid = get_atttype(relid, attno);
+       type_mod = get_atttypmod(relid, attno);
+       
        resnode = makeResdom(1,
                                                 typeid,
-                                                typeLen(typeidType(typeid)),
+                                                type_mod,
                                                 get_attname(relid, attno),
                                                 0,
                                                 (Oid) 0,
                                                 0);
-       varnode = makeVar(-1, attno, typeid, 0, -1, attno);
+       varnode = makeVar(-1, attno, typeid, type_mod, 0, -1, attno);
 
        tle = makeNode(TargetEntry);
        tle->resdom = resnode;
@@ -1095,12 +1095,12 @@ setup_base_tlist(Oid typeid)
 
        resnode = makeResdom(1,
                                                 typeid,
-                                                typeLen(typeidType(typeid)),
+                                                -1,
                                                 "<noname>",
                                                 0,
                                                 (Oid) 0,
                                                 0);
-       varnode = makeVar(-1, 1, typeid, 0, -1, 1);
+       varnode = makeVar(-1, 1, typeid, -1, 0, -1, 1);
        tle = makeNode(TargetEntry);
        tle->resdom = resnode;
        tle->expr = (Node *) varnode;
index 02e5108752643947577754a6198f3d3512426d8c..3b46ae212aab6ae8d568856cb6371ed53d585a70 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
 
 Var               *
 make_var(ParseState *pstate, Oid relid, char *refname,
-                               char *attrname, Oid *type_id)
+                               char *attrname)
 {
        Var                *varnode;
        int                     vnum,
                                attid;
        Oid                     vartypeid;
+       int                     type_mod;
        int                     sublevels_up;
 
        vnum = refnameRangeTablePosn(pstate, refname, &sublevels_up);
@@ -255,9 +256,10 @@ make_var(ParseState *pstate, Oid relid, char *refname,
                elog(ERROR, "Relation %s does not have attribute %s",
                         refname, attrname);
        vartypeid = get_atttype(relid, attid);
+       type_mod = get_atttypmod(relid, attid);
 
-       varnode = makeVar(vnum, attid, vartypeid, sublevels_up, vnum, attid);
-       *type_id = vartypeid;
+       varnode = makeVar(vnum, attid, vartypeid, type_mod,
+                                         sublevels_up, vnum, attid);
 
        return varnode;
 }
index 9a70613f4a7e50e63381ed3e331543738a0334a2..e5a774dc89457b894e53d076672d6bcb58b6e95b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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)
        Var                *varnode;
        int                     varattno,
                                maxattrs;
-       Oid                     type_id;
-       int                     type_len;
        RangeTblEntry *rte;
 
        rte = refnameRangeTableEntry(pstate, refname);
@@ -257,9 +255,7 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
                TargetEntry *te = makeNode(TargetEntry);
 
                attrname = pstrdup((rdesc->rd_att->attrs[varattno]->attname).data);
-               varnode = (Var *) make_var(pstate, rte->relid, refname,
-                                                                                                       attrname, &type_id);
-               type_len = (int) typeLen(typeidType(type_id));
+               varnode = (Var *) make_var(pstate, rte->relid, refname, attrname);
 
                handleTargetColname(pstate, &resname, refname, attrname);
                if (resname != NULL)
@@ -271,8 +267,8 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
                 */
 
                te->resdom = makeResdom((AttrNumber) (*this_resno)++,
-                                                               type_id,
-                                                               (Size) type_len,
+                                                               varnode->vartype,
+                                                               varnode->vartypmod,
                                                                attrname,
                                                                (Index) 0,
                                                                (Oid) 0,
index 4aa961ed45611cddabb7097dd891fa147afb9ffe..271645573e0f04401c259136a592d5312481d93b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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 @@
 #include "parser/parse_relation.h"
 #include "parser/parse_target.h"
 #include "utils/builtins.h"
+#include "utils/lsyscache.h"
 
 static List *expandAllTables(ParseState *pstate);
 static char *figureColname(Node *expr, Node *resval);
@@ -54,7 +55,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
                                {
                                        Node       *expr;
                                        Oid                     type_id;
-                                       int                     type_len;
+                                       int                     type_mod;
                                        char       *identname;
                                        char       *resname;
 
@@ -67,11 +68,14 @@ transformTargetList(ParseState *pstate, List *targetlist)
                                         */
                                        expr = transformIdent(pstate, (Node *) res->val, EXPR_COLUMN_FIRST);
                                        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;
                                        tent->resdom = makeResdom((AttrNumber) pstate->p_last_resno++,
                                                                                          (Oid) type_id,
-                                                                                         (Size) type_len,
+                                                                                         type_mod,
                                                                                          resname,
                                                                                          (Index) 0,
                                                                                          (Oid) 0,
@@ -190,7 +194,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
                        case T_Attr:
                                {
                                        Oid                     type_id;
-                                       int                     type_len;
+                                       int                     type_mod;
                                        Attr       *att = (Attr *) res->val;
                                        Node       *result;
                                        char       *attrname;
@@ -253,8 +257,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
 
 
                                        /*
-                                        * Target item is fully specified: ie.
-                                        * relation.attribute
+                                        * Target item is fully specified: ie. relation.attribute
                                         */
                                        result = ParseNestedFuncOrColumn(pstate, att, &pstate->p_last_resno,EXPR_COLUMN_FIRST);
                                        handleTargetColname(pstate, &res->name, att->relname, attrname);
@@ -273,14 +276,17 @@ transformTargetList(ParseState *pstate, List *targetlist)
                                                result = (Node *) make_array_ref(result, att->indirection);
                                        }
                                        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 */
                                        while (lnext(attrs) != NIL)
                                                attrs = lnext(attrs);
                                        resname = (res->name) ? res->name : strVal(lfirst(attrs));
                                        resnode = makeResdom((AttrNumber) pstate->p_last_resno++,
                                                                                 (Oid) type_id,
-                                                                                (Size) type_len,
+                                                                                type_mod,
                                                                                 resname,
                                                                                 (Index) 0,
                                                                                 (Oid) 0,
@@ -326,8 +332,7 @@ make_targetlist_expr(ParseState *pstate,
 {
        Oid                     type_id,
                                attrtype;
-       int                     type_len,
-                               attrlen,
+       int                     type_mod,
                                attrtypmod;
        int                     resdomno;
        Relation        rd;
@@ -339,12 +344,10 @@ make_targetlist_expr(ParseState *pstate,
                elog(ERROR, "make_targetlist_expr: invalid use of NULL expression");
 
        type_id = exprType(expr);
-       if (type_id == InvalidOid)
-       {
-               type_len = 0;
-       }
+       if (nodeTag(expr) == T_Var)
+               type_mod = ((Var *)expr)->vartypmod;
        else
-               type_len = typeLen(typeidType(type_id));
+               type_mod = -1;
 
        /* Processes target columns that will be receiving results */
        if (pstate->p_is_insert || pstate->p_is_update)
@@ -361,7 +364,6 @@ make_targetlist_expr(ParseState *pstate,
                attrtype = attnumTypeId(rd, resdomno);
                if ((arrayRef != NIL) && (lfirst(arrayRef) == NIL))
                        attrtype = GetArrayElementType(attrtype);
-               attrlen = typeLen(typeidType(attrtype));
                attrtypmod = rd->rd_att->attrs[resdomno - 1]->atttypmod;
 #if 0
                if (Input_is_string && Typecast_ok)
@@ -438,7 +440,7 @@ make_targetlist_expr(ParseState *pstate,
                                else
                                        expr = (Node *) parser_typecast2(expr,
                                                                                                         type_id,
-                                                                                                  typeidType(attrtype),
+                                                                                                        typeidType(attrtype),
                                                                                                         attrtypmod);
                        }
                        else
@@ -486,20 +488,20 @@ make_targetlist_expr(ParseState *pstate,
                                                                                   lowerIndexpr,
                                                                                   (Expr *) expr);
                        attrtype = attnumTypeId(rd, resdomno);
-                       attrlen = typeLen(typeidType(attrtype));
+                       attrtypmod = get_atttypmod(rd->rd_id, resdomno);
                }
        }
        else
        {
                resdomno = pstate->p_last_resno++;
                attrtype = type_id;
-               attrlen = type_len;
+               attrtypmod = type_mod;
        }
        tent = makeNode(TargetEntry);
 
        resnode = makeResdom((AttrNumber) resdomno,
                                                 (Oid) attrtype,
-                                                (Size) attrlen,
+                                                attrtypmod,
                                                 colname,
                                                 (Index) 0,
                                                 (Oid) 0,
index 493e0c4c4aebcfb853231537f54f93aa4df5de15..be8fa5d075de5911f88c430313bbf7b811d36fe7 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * 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)
                        Var                *var = (Var *) tle->expr;
 
                        tle->resdom->restype = var->vartype;
-                       tle->resdom->reslen = get_typlen(var->vartype);
+                       tle->resdom->restypmod = var->vartypmod;
                }
        }
 }
index 93f581807d654d5ed23d28120b75c5b5a6ee4715..04d7d8b35d6299471a33085fb65ba3782e2bc323 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * 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 @@
 #include "catalog/index.h"             /* for index_create() */
 #include "catalog/catalog.h"   /* for newoid() */
 #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_proc.h"   /* for INT4GE_PROC_OID */
 #include "storage/itemptr.h"
@@ -127,12 +128,12 @@ inv_create(int flags)
        tupdesc = CreateTemplateTupleDesc(2);
        TupleDescInitEntry(tupdesc, (AttrNumber) 1,
                                           "olastbye",
-                                          "int4",
-                                          0, false);
+                                          INT4OID,
+                                          -1, 0, false);
        TupleDescInitEntry(tupdesc, (AttrNumber) 2,
                                           "odata",
-                                          "bytea",
-                                          0, false);
+                                          BYTEAOID,
+                                          -1, 0, false);
 
        /*
         * First create the table to hold the inversion large object.  It will
index 812fee562ca21a22389e0f91520dd8fa0652bf41..4871745be04999639509295fde64dddb55bb1587 100644 (file)
@@ -6,7 +6,7 @@
  *
  * 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);
 extern bool TupleDescInitEntry(TupleDesc desc,
                                   AttrNumber attributeNumber,
                                   char *attributeName,
-                                  char *typeName,
+                                  Oid typeid,
+                                  int typmod,
                                   int attdim,
                                   bool attisset);
 
index 98ecb807b5f8b75debe1b27e930ad43a67b586ce..a4a9dc3884e7cb919393e6a2b491687dcb340874 100644 (file)
@@ -7,7 +7,7 @@
  *
  * 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
  *       the genbki.sh script reads this file and generates .bki
@@ -95,8 +95,6 @@ CATALOG(pg_attribute) BOOTSTRAP
         * typed constant associated with a variable.  We also have a hack in
         * execMain.c/execUtils.c that uses atttypmod to properly create tables
         * 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;
index 76e4f52bda067d0edcd3932e2476f6024bc8cf17..56065752a863b042f748da195e2d015d75aa704f 100644 (file)
@@ -7,7 +7,7 @@
  *
  * 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
  *       the genbki.sh script reads this file and generates .bki
@@ -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_ ));
 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_ ));
 DESCR("single character");
 #define CHAROID 18
index 5837b7bf5fef6dd3c90fdc568f9325e1bc82e65a..e5251886bc59b852d9a9dec899938cfc4f6d8cda 100644 (file)
@@ -6,7 +6,7 @@
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
 #include <stdio.h>
 #include <executor/execdesc.h>
 
-/* ----------------------------------------------------------------
- * ----------------------------------------------------------------
- */
-
-
 /*
  * prototypes from functions in execAmi.c
  */
@@ -120,8 +115,6 @@ extern TupleDesc ExecTypeFromTL(List *targetList);
 extern void ResetTupleCount(void);
 extern void ExecAssignNodeBaseInfo(EState *estate, CommonState *basenode,
                                           Plan *parent);
-extern void setAtttypmodForCreateTable(TupleDesc tupType, List *targetList,
-                                                       List *rangeTable);
 extern void ExecAssignExprContext(EState *estate, CommonState *commonstate);
 extern void ExecAssignResultType(CommonState *commonstate,
                                         TupleDesc tupDesc);
@@ -143,14 +136,5 @@ extern void ExecOpenIndices(Oid resultRelationOid,
 extern void ExecCloseIndices(RelationInfo *resultRelationInfo);
 extern void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid,
                                          EState *estate, bool is_update);
-extern void resetVarAttrLenForCreateTable(TupleDesc tupType);
-extern void setVarAttrLenForCreateTable(TupleDesc tupType,
-                                                       List *targetList, List *rangeTable);
-
-
-/* ----------------------------------------------------------------
- *             the end
- * ----------------------------------------------------------------
- */
 
 #endif                                                 /* EXECUTOR_H  */
index f792438701be20fdda713537f1228c5bca75132f..8b7cb299e03e934cdaadd69d06edf0e5b0062654 100644 (file)
@@ -6,7 +6,7 @@
  *
  * 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,
 extern Var * makeVar(Index varno,
                AttrNumber varattno,
                Oid vartype,
+               int vartypmod,
                Index varlevelsup,
                Index varnoold,
                AttrNumber varoattno);
 
 extern Resdom * makeResdom(AttrNumber resno,
                   Oid restype,
-                  int reslen,
+                  int restypmod,
                   char *resname,
                   Index reskey,
                   Oid reskeyop,
index af370b893c705debe594334dd98af7553967ce85..3907e457c3aa536bb5b7a69ccba73126c0eeff2f 100644 (file)
@@ -6,7 +6,7 @@
  *
  * 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 @@
  * Resdom (Result Domain)
  *             resno                   - attribute number
  *             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)
  *             reskey                  - order of key in a sort (for those > 0)
  *             reskeyop                - sort operator Oid
@@ -41,7 +41,7 @@ typedef struct Resdom
        NodeTag         type;
        AttrNumber      resno;
        Oid                     restype;
-       int                     reslen;
+       int                     restypmod;
        char       *resname;
        Index           reskey;
        Oid                     reskeyop;
@@ -104,6 +104,7 @@ typedef struct Expr
  *                                               (could be INNER or OUTER)
  *             varattno                - attribute number of this var, or zero for all
  *             vartype                 - pg_type tuple oid for the type of this var
+ *             vartypmod               - pg_attribute typmod value
  *             varlevelsup             - for subquery variables referencing outer relations
  *             varnoold                - keep varno around in case it got changed to INNER/
  *                                               OUTER (see match_varid)
@@ -123,6 +124,7 @@ typedef struct Var
        Index           varno;
        AttrNumber      varattno;
        Oid                     vartype;
+       int                     vartypmod;
        Index           varlevelsup;    /* erased by upper optimizer */
        Index           varnoold;               /* only used by optimizer */
        AttrNumber      varoattno;              /* only used by optimizer */
index c92c28618168f76ea7fbcc53121a43a50ec593cb..5300db1e86bf52aee5fd85a3a7d581665e4cc3c2 100644 (file)
@@ -5,7 +5,7 @@
  *
  * 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
 extern ParseState *make_parsestate(ParseState *parentParseState);
 extern Expr *make_op(char *opname, Node *ltree, Node *rtree);
 extern Var *make_var(ParseState *pstate, Oid relid, char *refname,
-                                                                               char *attrname, Oid *type_id);
+                                                                               char *attrname);
 extern ArrayRef   *make_array_ref(Node *expr,
                           List *indirection);
 extern ArrayRef   *make_array_set(Expr *target_expr,
index 8a70071d12e990169cf956b91571478d4a4b6c5e..a50912eed10c8dd034af9de48cf4845643fe8ed6 100644 (file)
@@ -1,6 +1,6 @@
 .\" This is -*-nroff-*-
 .\" 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
 .SH NAME
 explain - explains statement execution details
@@ -30,12 +30,12 @@ tgl=> explain verbose select sum(a) from test;
 NOTICE:QUERY PLAN:
 
 {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}
   :expr {AGGREG :aggname "sum" :basetype 700 :aggtype 700 :aggno 0
  :target {VAR :varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno 1}}})
  :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}
   :expr {VAR :varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno 1}})
  :qpqual <> :lefttree <> :righttree <> :scanrelid 1} :righttree <> :numagg 1 }