Skip to content

Commit 0386a50

Browse files
committed
Pass around typmod as int16.
1 parent 2a3c589 commit 0386a50

File tree

27 files changed

+81
-74
lines changed

27 files changed

+81
-74
lines changed

src/backend/access/common/printtup.c

Lines changed: 3 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.24 1998/02/10 04:00:12 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.25 1998/02/10 16:02:44 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -124,7 +124,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
124124
{
125125
outputstr = fmgr(typoutput, attr,
126126
gettypelem(typeinfo->attrs[i]->atttypid),
127-
(int)typeinfo->attrs[i]->atttypmod);
127+
typeinfo->attrs[i]->atttypmod);
128128
pq_putint(strlen(outputstr) + VARHDRSZ, VARHDRSZ);
129129
pq_putnchar(outputstr, strlen(outputstr));
130130
pfree(outputstr);
@@ -191,7 +191,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo)
191191
{
192192
value = fmgr(typoutput, attr,
193193
gettypelem(typeinfo->attrs[i]->atttypid),
194-
(int)typeinfo->attrs[i]->atttypmod);
194+
typeinfo->attrs[i]->atttypmod);
195195
printatt((unsigned) i + 1, typeinfo->attrs[i], value);
196196
pfree(value);
197197
}

src/backend/access/common/tupdesc.c

Lines changed: 3 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/access/common/tupdesc.c,v 1.34 1998/02/10 04:00:14 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.35 1998/02/10 16:02:46 momjian Exp $
1111
*
1212
* NOTES
1313
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -255,7 +255,7 @@ TupleDescInitEntry(TupleDesc desc,
255255
AttrNumber attributeNumber,
256256
char *attributeName,
257257
Oid typeid,
258-
int typmod,
258+
int16 typmod,
259259
int attdim,
260260
bool attisset)
261261
{
@@ -448,7 +448,7 @@ BuildDescForRelation(List *schema, char *relname)
448448
TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
449449
char *attname;
450450
char *typename;
451-
int atttypmod;
451+
int16 atttypmod;
452452
int attdim;
453453
int ndef = 0;
454454
bool attisset;

src/backend/commands/copy.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.40 1998/01/31 04:38:18 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.41 1998/02/10 16:02:51 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -65,7 +65,7 @@ static void CopyAttributeOut(FILE *fp, char *string, char *delim);
6565
static int CountTuples(Relation relation);
6666

6767
extern FILE *Pfout,
68-
*Pfin;
68+
*Pfin;
6969

7070
static int lineno;
7171

@@ -205,6 +205,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
205205
FmgrInfo *out_functions;
206206
Oid out_func_oid;
207207
Oid *elements;
208+
int16 *typmod;
208209
Datum value;
209210
bool isnull; /* The attribute we are copying is null */
210211
char *nulls;
@@ -230,18 +231,21 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
230231
{
231232
out_functions = (FmgrInfo *) palloc(attr_count * sizeof(FmgrInfo));
232233
elements = (Oid *) palloc(attr_count * sizeof(Oid));
234+
typmod = (int16 *) palloc(attr_count * sizeof(int16));
233235
for (i = 0; i < attr_count; i++)
234236
{
235237
out_func_oid = (Oid) GetOutputFunction(attr[i]->atttypid);
236238
fmgr_info(out_func_oid, &out_functions[i]);
237239
elements[i] = GetTypeElement(attr[i]->atttypid);
240+
typmod[i] = attr[i]->atttypmod;
238241
}
239242
nulls = NULL; /* meaningless, but compiler doesn't know
240243
* that */
241244
}
242245
else
243246
{
244247
elements = NULL;
248+
typmod = NULL;
245249
out_functions = NULL;
246250
nulls = (char *) palloc(attr_count);
247251
for (i = 0; i < attr_count; i++)
@@ -271,7 +275,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
271275
{
272276
if (!isnull)
273277
{
274-
string = (char *) (*fmgr_faddr(&out_functions[i])) (value, elements[i]);
278+
string = (char *) (*fmgr_faddr(&out_functions[i]))
279+
(value, elements[i], typmod[i]);
275280
CopyAttributeOut(fp, string, delim);
276281
pfree(string);
277282
}
@@ -345,6 +350,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
345350
{
346351
pfree(out_functions);
347352
pfree(elements);
353+
pfree(typmod);
348354
}
349355

350356
heap_close(rel);
@@ -376,6 +382,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
376382
tuples_read = 0;
377383
bool reading_to_eof = true;
378384
Oid *elements;
385+
int16 *typmod;
379386
FuncIndexInfo *finfo,
380387
**finfoP = NULL;
381388
TupleDesc *itupdescArr;
@@ -498,17 +505,20 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
498505
{
499506
in_functions = (FmgrInfo *) palloc(attr_count * sizeof(FmgrInfo));
500507
elements = (Oid *) palloc(attr_count * sizeof(Oid));
508+
typmod = (int16 *) palloc(attr_count * sizeof(int16));
501509
for (i = 0; i < attr_count; i++)
502510
{
503511
in_func_oid = (Oid) GetInputFunction(attr[i]->atttypid);
504512
fmgr_info(in_func_oid, &in_functions[i]);
505513
elements[i] = GetTypeElement(attr[i]->atttypid);
514+
typmod[i] = attr[i]->atttypmod;
506515
}
507516
}
508517
else
509518
{
510519
in_functions = NULL;
511520
elements = NULL;
521+
typmod = NULL;
512522
fread(&ntuples, sizeof(int32), 1, fp);
513523
if (ntuples != 0)
514524
reading_to_eof = false;
@@ -574,7 +584,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
574584
values[i] =
575585
(Datum) (*fmgr_faddr(&in_functions[i])) (string,
576586
elements[i],
577-
attr[i]->atttypmod);
587+
typmod[i]);
578588

579589
/*
580590
* Sanity check - by reference attributes cannot
@@ -801,9 +811,13 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
801811
done = true;
802812
}
803813
pfree(values);
814+
pfree(nulls);
804815
if (!binary)
816+
{
805817
pfree(in_functions);
806-
pfree(nulls);
818+
pfree(elements);
819+
pfree(typmod);
820+
}
807821
pfree(byval);
808822
heap_close(rel);
809823
}

src/backend/executor/nodeGroup.c

Lines changed: 3 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.15 1998/02/10 04:00:53 momjian Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.16 1998/02/10 16:02:58 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -418,10 +418,10 @@ sameGroup(TupleTableSlot *oldslot,
418418

419419
val1 = fmgr(typoutput, attr1,
420420
gettypelem(tupdesc->attrs[att - 1]->atttypid),
421-
(int)tupdesc->attrs[att - 1]->atttypmod);
421+
tupdesc->attrs[att - 1]->atttypmod);
422422
val2 = fmgr(typoutput, attr2,
423423
gettypelem(tupdesc->attrs[att - 1]->atttypid),
424-
(int)tupdesc->attrs[att - 1]->atttypmod);
424+
tupdesc->attrs[att - 1]->atttypmod);
425425

426426
/*
427427
* now, val1 and val2 are ascii representations so we can use

src/backend/executor/nodeUnique.c

Lines changed: 3 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.13 1998/02/10 04:00:55 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.14 1998/02/10 16:03:03 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -198,10 +198,10 @@ ExecUnique(Unique *node)
198198
continue;
199199
val1 = fmgr(typoutput, attr1,
200200
gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid),
201-
(int)tupDesc->attrs[uniqueAttrNum - 1]->atttypmod);
201+
tupDesc->attrs[uniqueAttrNum - 1]->atttypmod);
202202
val2 = fmgr(typoutput, attr2,
203203
gettypelem(tupDesc->attrs[uniqueAttrNum - 1]->atttypid),
204-
(int)tupDesc->attrs[uniqueAttrNum - 1]->atttypmod);
204+
tupDesc->attrs[uniqueAttrNum - 1]->atttypmod);
205205

206206
/*
207207
* now, val1 and val2 are ascii representations so we can

src/backend/executor/spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
432432

433433
return (fmgr(foutoid, val,
434434
gettypelem(tupdesc->attrs[fnumber - 1]->atttypid),
435-
(int)tupdesc->attrs[fnumber - 1]->atttypmod));
435+
tupdesc->attrs[fnumber - 1]->atttypmod));
436436
}
437437

438438
Datum

src/backend/libpq/be-dumpdata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.12 1998/02/10 04:00:58 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.13 1998/02/10 16:03:12 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -314,7 +314,7 @@ be_printtup(HeapTuple tuple, TupleDesc typeinfo)
314314
{
315315
values[i] = fmgr(typoutput, attr,
316316
gettypelem(typeinfo->attrs[i]->atttypid),
317-
(int)typeinfo->attrs[i]->atttypmod);
317+
typeinfo->attrs[i]->atttypmod);
318318
}
319319
else
320320
values[i] = NULL;

src/backend/nodes/makefuncs.c

Lines changed: 3 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/nodes/makefuncs.c,v 1.6 1998/02/10 04:00:50 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.7 1998/02/10 16:03:17 momjian Exp $
1111
*
1212
* NOTES
1313
* Creator functions in POSTGRES 4.2 are generated automatically. Most of
@@ -53,7 +53,7 @@ Var *
5353
makeVar(Index varno,
5454
AttrNumber varattno,
5555
Oid vartype,
56-
int vartypmod,
56+
int16 vartypmod,
5757
Index varlevelsup,
5858
Index varnoold,
5959
AttrNumber varoattno)
@@ -78,7 +78,7 @@ makeVar(Index varno,
7878
Resdom *
7979
makeResdom(AttrNumber resno,
8080
Oid restype,
81-
int restypmod,
81+
int16 restypmod,
8282
char *resname,
8383
Index reskey,
8484
Oid reskeyop,

src/backend/nodes/outfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.28 1998/02/10 04:00:57 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.29 1998/02/10 16:03:21 momjian Exp $
1111
*
1212
* NOTES
1313
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -698,7 +698,7 @@ _outVar(StringInfo str, Var *node)
698698
appendStringInfo(str, buf);
699699
sprintf(buf, " :vartype %u ", node->vartype);
700700
appendStringInfo(str, buf);
701-
sprintf(buf, " :vartypmod %u ", node->vartypmod);
701+
sprintf(buf, " :vartypmod %d ", node->vartypmod);
702702
appendStringInfo(str, buf);
703703
sprintf(buf, " :varlevelsup %u ", node->varlevelsup);
704704
appendStringInfo(str, buf);

src/backend/nodes/readfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.23 1998/02/10 04:01:03 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.24 1998/02/10 16:03:23 momjian Exp $
1111
*
1212
* NOTES
1313
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -816,7 +816,7 @@ _readVar()
816816

817817
token = lsptok(NULL, &length); /* eat :vartypmod */
818818
token = lsptok(NULL, &length); /* get vartypmod */
819-
local_node->vartypmod = (Oid) atol(token);
819+
local_node->vartypmod = atoi(token);
820820

821821
token = lsptok(NULL, &length); /* eat :varlevelsup */
822822
token = lsptok(NULL, &length); /* get varlevelsup */

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