Skip to content

Commit 2c482cd

Browse files
committed
Pass attypmod through to executor by adding to Var and Resdom.
1 parent 2535fcd commit 2c482cd

40 files changed

+212
-201
lines changed

src/backend/access/common/printtup.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.23 1998/01/31 04:38:03 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.24 1998/02/10 04:00:12 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -123,7 +123,8 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
123123
if (!isnull && OidIsValid(typoutput))
124124
{
125125
outputstr = fmgr(typoutput, attr,
126-
gettypelem(typeinfo->attrs[i]->atttypid));
126+
gettypelem(typeinfo->attrs[i]->atttypid),
127+
(int)typeinfo->attrs[i]->atttypmod);
127128
pq_putint(strlen(outputstr) + VARHDRSZ, VARHDRSZ);
128129
pq_putnchar(outputstr, strlen(outputstr));
129130
pfree(outputstr);
@@ -189,7 +190,8 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo)
189190
if (!isnull && OidIsValid(typoutput))
190191
{
191192
value = fmgr(typoutput, attr,
192-
gettypelem(typeinfo->attrs[i]->atttypid));
193+
gettypelem(typeinfo->attrs[i]->atttypid),
194+
(int)typeinfo->attrs[i]->atttypmod);
193195
printatt((unsigned) i + 1, typeinfo->attrs[i], value);
194196
pfree(value);
195197
}

src/backend/access/common/tupdesc.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.33 1998/02/07 06:10:30 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.34 1998/02/10 04:00:14 momjian Exp $
1111
*
1212
* NOTES
1313
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -254,7 +254,8 @@ bool
254254
TupleDescInitEntry(TupleDesc desc,
255255
AttrNumber attributeNumber,
256256
char *attributeName,
257-
char *typeName,
257+
Oid typeid,
258+
int typmod,
258259
int attdim,
259260
bool attisset)
260261
{
@@ -274,7 +275,6 @@ TupleDescInitEntry(TupleDesc desc,
274275
* why that is, though -- Jolly
275276
*/
276277
/* AssertArg(NameIsValid(attributeName));*/
277-
/* AssertArg(NameIsValid(typeName));*/
278278

279279
AssertArg(!PointerIsValid(desc->attrs[attributeNumber - 1]));
280280

@@ -301,7 +301,7 @@ TupleDescInitEntry(TupleDesc desc,
301301

302302
att->attdisbursion = 0; /* dummy value */
303303
att->attcacheoff = -1;
304-
att->atttypmod = -1;
304+
att->atttypmod = typmod;
305305

306306
att->attnum = attributeNumber;
307307
att->attnelems = attdim;
@@ -327,7 +327,7 @@ TupleDescInitEntry(TupleDesc desc,
327327
* -cim 6/14/90
328328
* ----------------
329329
*/
330-
tuple = SearchSysCacheTuple(TYPNAME, PointerGetDatum(typeName),
330+
tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(typeid),
331331
0, 0, 0);
332332
if (!HeapTupleIsValid(tuple))
333333
{
@@ -448,6 +448,7 @@ BuildDescForRelation(List *schema, char *relname)
448448
TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
449449
char *attname;
450450
char *typename;
451+
int atttypmod;
451452
int attdim;
452453
int ndef = 0;
453454
bool attisset;
@@ -481,6 +482,7 @@ BuildDescForRelation(List *schema, char *relname)
481482
attname = entry->colname;
482483
arry = entry->typename->arrayBounds;
483484
attisset = entry->typename->setof;
485+
atttypmod = entry->typename->typmod;
484486

485487
if (arry != NIL)
486488
{
@@ -495,7 +497,8 @@ BuildDescForRelation(List *schema, char *relname)
495497
}
496498

497499
if (!TupleDescInitEntry(desc, attnum, attname,
498-
typename, attdim, attisset))
500+
typeTypeId(typenameType(typename)),
501+
atttypmod, attdim, attisset))
499502
{
500503
/* ----------------
501504
* if TupleDescInitEntry() fails, it means there is

src/backend/commands/creatinh.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.24 1998/01/05 16:38:49 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.25 1998/02/10 04:00:18 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -304,6 +304,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
304304
typename = makeNode(TypeName);
305305
def->colname = pstrdup(attributeName);
306306
typename->name = pstrdup(attributeType);
307+
typename->typmod = attribute->atttypmod;
307308
def->typename = typename;
308309
def->is_not_null = attribute->attnotnull;
309310
def->defval = NULL;

src/backend/commands/recipe.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.18 1998/01/20 22:10:53 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.19 1998/02/10 04:00:24 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -493,7 +493,8 @@ tg_replaceNumberedParam(Node *expression,
493493
{
494494
newVar = makeVar(rt_ind,
495495
0, /* the whole tuple */
496-
TypeGet(teeRelName, &defined),
496+
TypeGet(teeRelName, &defined),
497+
-1,
497498
0,
498499
rt_ind,
499500
0);
@@ -503,7 +504,8 @@ tg_replaceNumberedParam(Node *expression,
503504
newVar = makeVar(rt_ind,
504505
1, /* just the first field,
505506
* which is 'result' */
506-
TypeGet(teeRelName, &defined),
507+
TypeGet(teeRelName, &defined),
508+
-1,
507509
0,
508510
rt_ind,
509511
0);
@@ -1067,8 +1069,8 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
10671069

10681070
if (!TupleDescInitEntry(tupdesc, 1,
10691071
"result",
1070-
NULL,
1071-
0, false))
1072+
InvalidOid,
1073+
-1, 0, false))
10721074
{
10731075
elog(NOTICE, "tg_parseSubQuery: unexpected result from TupleDescInitEntry");
10741076
}

src/backend/commands/view.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.19 1998/01/05 16:39:08 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.20 1998/02/10 04:00:32 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -77,6 +77,8 @@ DefineVirtualRelation(char *relname, List *tlist)
7777
typename = makeNode(TypeName);
7878

7979
typename->name = pstrdup(restypename);
80+
typename->typmod = res->restypmod;
81+
8082
def->colname = pstrdup(resname);
8183

8284
def->typename = typename;

src/backend/executor/execMain.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.40 1998/01/19 02:37:32 momjian Exp $
29+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.41 1998/02/10 04:00:45 momjian Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -563,8 +563,6 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
563563
*/
564564
tupdesc = CreateTupleDescCopy(tupType);
565565

566-
setAtttypmodForCreateTable(tupdesc, targetList, rangeTable);
567-
568566
intoRelationId = heap_create_with_catalog(intoName, tupdesc);
569567

570568
FreeTupleDesc(tupdesc);

src/backend/executor/execTuples.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.15 1998/01/07 21:02:48 momjian Exp $
17+
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.16 1998/02/10 04:00:50 momjian Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -986,7 +986,8 @@ ExecTypeFromTL(List *targetList)
986986
resdom->resno,
987987
resdom->resname,
988988
/* fix for SELECT NULL ... */
989-
typeidTypeName(restype ? restype : UNKNOWNOID),
989+
(restype ? restype : UNKNOWNOID),
990+
resdom->restypmod,
990991
0,
991992
false);
992993

@@ -1019,7 +1020,8 @@ ExecTypeFromTL(List *targetList)
10191020
TupleDescInitEntry(typeInfo,
10201021
fjRes->resno,
10211022
fjRes->resname,
1022-
typeidTypeName(restype),
1023+
restype,
1024+
fjRes->restypmod,
10231025
0,
10241026
false);
10251027
/*
@@ -1042,7 +1044,8 @@ ExecTypeFromTL(List *targetList)
10421044
TupleDescInitEntry(typeInfo,
10431045
fjRes->resno,
10441046
fjRes->resname,
1045-
typeidTypeName(restype),
1047+
restype,
1048+
fjRes->restypmod,
10461049
0,
10471050
false);
10481051

src/backend/executor/execUtils.c

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.27 1998/02/07 06:11:21 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.28 1998/02/10 04:00:52 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1179,46 +1179,3 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
11791179
if (econtext != NULL)
11801180
pfree(econtext);
11811181
}
1182-
1183-
/* ----------------------------------------------------------------
1184-
* setAtttyplenForCreateTable -
1185-
* called when we do a SELECT * INTO TABLE tab
1186-
* needed for attributes that have atttypmod like bpchar and
1187-
* varchar
1188-
* ----------------------------------------------------------------
1189-
*/
1190-
void
1191-
setAtttypmodForCreateTable(TupleDesc tupType, List *targetList,
1192-
List *rangeTable)
1193-
{
1194-
List *tl;
1195-
TargetEntry *tle;
1196-
Node *expr;
1197-
int varno;
1198-
1199-
tl = targetList;
1200-
1201-
for (varno = 0; varno < tupType->natts; varno++)
1202-
{
1203-
tle = lfirst(tl);
1204-
1205-
if (USE_ATTTYPMOD(tupType->attrs[varno]->atttypid))
1206-
{
1207-
expr = tle->expr;
1208-
if (expr && IsA(expr, Var))
1209-
{
1210-
Var *var;
1211-
RangeTblEntry *rtentry;
1212-
1213-
var = (Var *) expr;
1214-
rtentry = rt_fetch(var->varnoold, rangeTable);
1215-
tupType->attrs[varno]->atttypmod =
1216-
get_atttypmod(rtentry->relid, var->varoattno);
1217-
}
1218-
else
1219-
elog(ERROR, "setAtttypmodForCreateTable: can't get atttypmod for field (for length, etc.)");
1220-
}
1221-
tl = lnext(tl);
1222-
}
1223-
}
1224-

src/backend/executor/nodeGroup.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* columns. (ie. tuples from the same group are consecutive)
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.14 1998/01/31 04:38:29 momjian Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.15 1998/02/10 04:00:53 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -417,9 +417,11 @@ sameGroup(TupleTableSlot *oldslot,
417417
continue;
418418

419419
val1 = fmgr(typoutput, attr1,
420-
gettypelem(tupdesc->attrs[att - 1]->atttypid));
420+
gettypelem(tupdesc->attrs[att - 1]->atttypid),
421+
(int)tupdesc->attrs[att - 1]->atttypmod);
421422
val2 = fmgr(typoutput, attr2,
422-
gettypelem(tupdesc->attrs[att - 1]->atttypid));
423+
gettypelem(tupdesc->attrs[att - 1]->atttypid),
424+
(int)tupdesc->attrs[att - 1]->atttypmod);
423425

424426
/*
425427
* now, val1 and val2 are ascii representations so we can use

src/backend/executor/nodeUnique.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.12 1998/01/31 04:38:31 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.13 1998/02/10 04:00:55 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -196,8 +196,12 @@ ExecUnique(Unique *node)
196196
{
197197
if (isNull1) /* both are null, they are equal */
198198
continue;
199-
val1 = fmgr(typoutput, attr1, gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid));
200-
val2 = fmgr(typoutput, attr2, gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid));
199+
val1 = fmgr(typoutput, attr1,
200+
gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid),
201+
(int)tupDesc->attrs[uniqueAttrNum - 1]->atttypmod);
202+
val2 = fmgr(typoutput, attr2,
203+
gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid),
204+
(int)tupDesc->attrs[uniqueAttrNum - 1]->atttypmod);
201205

202206
/*
203207
* now, val1 and val2 are ascii representations so we can

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy