Skip to content

Commit 40f6406

Browse files
committed
Update textin() and textout() to new fmgr style. This is just phase
one of updating the whole text datatype, but there are so dang many calls of these two routines that it seems worth a separate commit.
1 parent 282713a commit 40f6406

39 files changed

+286
-271
lines changed

contrib/spi/autoinc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ autoinc(PG_FUNCTION_ARGS)
5353

5454
for (i = 0; i < nargs;)
5555
{
56-
text *seqname;
5756
int attnum = SPI_fnumber(tupdesc, args[i]);
5857
int32 val;
58+
Datum seqname;
5959

6060
if (attnum < 0)
61-
elog(ERROR, "autoinc (%s): there is no attribute %s", relname, args[i]);
61+
elog(ERROR, "autoinc (%s): there is no attribute %s",
62+
relname, args[i]);
6263
if (SPI_gettypeid(tupdesc, attnum) != INT4OID)
6364
elog(ERROR, "autoinc (%s): attribute %s must be of INT4 type",
6465
relname, args[i]);
@@ -73,13 +74,12 @@ autoinc(PG_FUNCTION_ARGS)
7374

7475
i++;
7576
chattrs[chnattrs] = attnum;
76-
seqname = textin(args[i]);
77-
newvals[chnattrs] = DirectFunctionCall1(nextval,
78-
PointerGetDatum(seqname));
77+
seqname = DirectFunctionCall1(textin,
78+
CStringGetDatum(args[i]));
79+
newvals[chnattrs] = DirectFunctionCall1(nextval, seqname);
7980
if (DatumGetInt32(newvals[chnattrs]) == 0)
80-
newvals[chnattrs] = DirectFunctionCall1(nextval,
81-
PointerGetDatum(seqname));
82-
pfree(seqname);
81+
newvals[chnattrs] = DirectFunctionCall1(nextval, seqname);
82+
pfree(DatumGetTextP(seqname));
8383
chnattrs++;
8484
i++;
8585
}

contrib/spi/insert_username.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ insert_username(PG_FUNCTION_ARGS)
6262
relname, args[0]);
6363

6464
/* create fields containing name */
65-
newval = PointerGetDatum(textin(GetPgUserName()));
65+
newval = DirectFunctionCall1(textin, CStringGetDatum(GetPgUserName()));
6666

6767
/* construct new tuple */
6868
rettuple = SPI_modifytuple(rel, rettuple, 1, &attnum, &newval, NULL);

src/backend/catalog/heap.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.138 2000/07/04 06:11:23 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.139 2000/07/05 23:11:06 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1121,7 +1121,8 @@ RelationTruncateIndexes(Relation heapRelation)
11211121
/* If a valid where predicate, compute predicate Node */
11221122
if (VARSIZE(&index->indpred) != 0)
11231123
{
1124-
predString = textout(&index->indpred);
1124+
predString = DatumGetCString(DirectFunctionCall1(textout,
1125+
PointerGetDatum(&index->indpred)));
11251126
oldPred = stringToNode(predString);
11261127
pfree(predString);
11271128
}
@@ -1602,8 +1603,10 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
16021603

16031604
values[Anum_pg_attrdef_adrelid - 1] = RelationGetRelid(rel);
16041605
values[Anum_pg_attrdef_adnum - 1] = attnum;
1605-
values[Anum_pg_attrdef_adbin - 1] = PointerGetDatum(textin(adbin));
1606-
values[Anum_pg_attrdef_adsrc - 1] = PointerGetDatum(textin(adsrc));
1606+
values[Anum_pg_attrdef_adbin - 1] = DirectFunctionCall1(textin,
1607+
CStringGetDatum(adbin));
1608+
values[Anum_pg_attrdef_adsrc - 1] = DirectFunctionCall1(textin,
1609+
CStringGetDatum(adsrc));
16071610
adrel = heap_openr(AttrDefaultRelationName, RowExclusiveLock);
16081611
tuple = heap_formtuple(adrel->rd_att, values, nulls);
16091612
heap_insert(adrel, tuple);
@@ -1685,8 +1688,10 @@ StoreRelCheck(Relation rel, char *ccname, char *ccbin)
16851688

16861689
values[Anum_pg_relcheck_rcrelid - 1] = RelationGetRelid(rel);
16871690
values[Anum_pg_relcheck_rcname - 1] = PointerGetDatum(namein(ccname));
1688-
values[Anum_pg_relcheck_rcbin - 1] = PointerGetDatum(textin(ccbin));
1689-
values[Anum_pg_relcheck_rcsrc - 1] = PointerGetDatum(textin(ccsrc));
1691+
values[Anum_pg_relcheck_rcbin - 1] = DirectFunctionCall1(textin,
1692+
CStringGetDatum(ccbin));
1693+
values[Anum_pg_relcheck_rcsrc - 1] = DirectFunctionCall1(textin,
1694+
CStringGetDatum(ccsrc));
16901695
rcrel = heap_openr(RelCheckRelationName, RowExclusiveLock);
16911696
tuple = heap_formtuple(rcrel->rd_att, values, nulls);
16921697
heap_insert(rcrel, tuple);

src/backend/catalog/index.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.123 2000/07/05 16:17:37 wieck Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.124 2000/07/05 23:11:06 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -680,11 +680,13 @@ UpdateIndexRelation(Oid indexoid,
680680
if (predicate != NULL)
681681
{
682682
predString = nodeToString(predicate);
683-
predText = textin(predString);
683+
predText = DatumGetTextP(DirectFunctionCall1(textin,
684+
CStringGetDatum(predString)));
684685
pfree(predString);
685686
}
686687
else
687-
predText = textin("");
688+
predText = DatumGetTextP(DirectFunctionCall1(textin,
689+
CStringGetDatum("")));
688690

689691
predLen = VARSIZE(predText);
690692
itupLen = predLen + sizeof(FormData_pg_index);
@@ -824,11 +826,13 @@ UpdateIndexPredicate(Oid indexoid, Node *oldPred, Node *predicate)
824826
if (newPred != NULL)
825827
{
826828
predString = nodeToString(newPred);
827-
predText = textin(predString);
829+
predText = DatumGetTextP(DirectFunctionCall1(textin,
830+
CStringGetDatum(predString)));
828831
pfree(predString);
829832
}
830833
else
831-
predText = textin("");
834+
predText = DatumGetTextP(DirectFunctionCall1(textin,
835+
CStringGetDatum("")));
832836

833837
/* open the index system catalog relation */
834838
pg_index = heap_openr(IndexRelationName, RowExclusiveLock);
@@ -1337,7 +1341,7 @@ IndexesAreActive(Oid relid, bool confirmCommitted)
13371341
elog(ERROR, "IndexesAreActive couldn't lock %u", relid);
13381342
if (((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_RELATION &&
13391343
((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_TOASTVALUE)
1340-
elog(ERROR, "relation %u isn't an relation", relid);
1344+
elog(ERROR, "relation %u isn't an indexable relation", relid);
13411345
isactive = ((Form_pg_class) GETSTRUCT(&tuple))->relhasindex;
13421346
ReleaseBuffer(buffer);
13431347
if (isactive)
@@ -2080,7 +2084,8 @@ reindex_index(Oid indexId, bool force)
20802084
/* If a valid where predicate, compute predicate Node */
20812085
if (VARSIZE(&index->indpred) != 0)
20822086
{
2083-
predString = textout(&index->indpred);
2087+
predString = DatumGetCString(DirectFunctionCall1(textout,
2088+
PointerGetDatum(&index->indpred)));
20842089
oldPred = stringToNode(predString);
20852090
pfree(predString);
20862091
}

src/backend/catalog/pg_aggregate.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.33 2000/05/30 04:24:36 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.34 2000/07/05 23:11:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -238,12 +238,14 @@ AggregateCreate(char *aggName,
238238
values[Anum_pg_aggregate_aggfinaltype - 1] = ObjectIdGetDatum(fret);
239239

240240
if (agginitval1)
241-
values[Anum_pg_aggregate_agginitval1 - 1] = PointerGetDatum(textin(agginitval1));
241+
values[Anum_pg_aggregate_agginitval1 - 1] =
242+
DirectFunctionCall1(textin, CStringGetDatum(agginitval1));
242243
else
243244
nulls[Anum_pg_aggregate_agginitval1 - 1] = 'n';
244245

245246
if (agginitval2)
246-
values[Anum_pg_aggregate_agginitval2 - 1] = PointerGetDatum(textin(agginitval2));
247+
values[Anum_pg_aggregate_agginitval2 - 1] =
248+
DirectFunctionCall1(textin, CStringGetDatum(agginitval2));
247249
else
248250
nulls[Anum_pg_aggregate_agginitval2 - 1] = 'n';
249251

@@ -277,7 +279,7 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull)
277279
Oid transtype,
278280
typinput,
279281
typelem;
280-
text *textInitVal;
282+
Datum textInitVal;
281283
char *strInitVal;
282284
Datum initVal;
283285

@@ -312,17 +314,15 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull)
312314
initValAttno = Anum_pg_aggregate_agginitval2;
313315
}
314316

315-
textInitVal = (text *) fastgetattr(tup, initValAttno,
316-
RelationGetDescr(aggRel),
317-
isNull);
318-
if (!PointerIsValid(textInitVal))
319-
*isNull = true;
317+
textInitVal = fastgetattr(tup, initValAttno,
318+
RelationGetDescr(aggRel),
319+
isNull);
320320
if (*isNull)
321321
{
322322
heap_close(aggRel, AccessShareLock);
323323
return PointerGetDatum(NULL);
324324
}
325-
strInitVal = textout(textInitVal);
325+
strInitVal = DatumGetCString(DirectFunctionCall1(textout, textInitVal));
326326

327327
heap_close(aggRel, AccessShareLock);
328328

src/backend/catalog/pg_proc.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.45 2000/06/28 03:31:23 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.46 2000/07/05 23:11:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -156,7 +156,8 @@ ProcedureCreate(char *procedureName,
156156
*/
157157
text *prosrctext;
158158

159-
prosrctext = textin(prosrc);
159+
prosrctext = DatumGetTextP(DirectFunctionCall1(textin,
160+
CStringGetDatum(prosrc)));
160161
tup = SearchSysCacheTuple(PROSRC,
161162
PointerGetDatum(prosrctext),
162163
0, 0, 0);
@@ -306,8 +307,10 @@ ProcedureCreate(char *procedureName,
306307
values[i++] = Int32GetDatum(perbyte_cpu); /* properbyte_cpu */
307308
values[i++] = Int32GetDatum(percall_cpu); /* propercall_cpu */
308309
values[i++] = Int32GetDatum(outin_ratio); /* prooutin_ratio */
309-
values[i++] = (Datum) textin(prosrc); /* prosrc */
310-
values[i++] = (Datum) textin(probin); /* probin */
310+
values[i++] = DirectFunctionCall1(textin, /* prosrc */
311+
CStringGetDatum(prosrc));
312+
values[i++] = DirectFunctionCall1(textin, /* probin */
313+
CStringGetDatum(probin));
311314

312315
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
313316

src/backend/catalog/pg_type.c

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.53 2000/07/03 23:09:28 wieck Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.54 2000/07/05 23:11:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -167,32 +167,29 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
167167
}
168168

169169
/* ----------------
170-
* initialize *values with the type name and
170+
* initialize *values with the type name and dummy values
171171
* ----------------
172172
*/
173173
i = 0;
174174
namestrcpy(&name, typeName);
175-
values[i++] = NameGetDatum(&name); /* 1 */
176-
values[i++] = (Datum) InvalidOid; /* 2 */
177-
values[i++] = (Datum) (int16) 0; /* 3 */
178-
values[i++] = (Datum) (int16) 0; /* 4 */
179-
values[i++] = (Datum) (bool) 0; /* 5 */
180-
values[i++] = (Datum) (bool) 0; /* 6 */
181-
values[i++] = (Datum) (bool) 0; /* 7 */
182-
values[i++] = (Datum) (bool) 0; /* 8 */
183-
values[i++] = (Datum) InvalidOid; /* 9 */
184-
values[i++] = (Datum) InvalidOid; /* 10 */
185-
values[i++] = (Datum) InvalidOid; /* 11 */
186-
values[i++] = (Datum) InvalidOid; /* 12 */
187-
values[i++] = (Datum) InvalidOid; /* 13 */
188-
values[i++] = (Datum) InvalidOid; /* 14 */
189-
values[i++] = (Datum) 'p'; /* 15 */
190-
values[i++] = (Datum) 'i'; /* 16 */
191-
192-
/*
193-
* ... and fill typdefault with a bogus value
194-
*/
195-
values[i++] = (Datum) textin(typeName); /* 15 */
175+
values[i++] = NameGetDatum(&name); /* 1 */
176+
values[i++] = ObjectIdGetDatum(InvalidOid); /* 2 */
177+
values[i++] = Int16GetDatum(0); /* 3 */
178+
values[i++] = Int16GetDatum(0); /* 4 */
179+
values[i++] = BoolGetDatum(false); /* 5 */
180+
values[i++] = BoolGetDatum(false); /* 6 */
181+
values[i++] = BoolGetDatum(false); /* 7 */
182+
values[i++] = BoolGetDatum(false); /* 8 */
183+
values[i++] = ObjectIdGetDatum(InvalidOid); /* 9 */
184+
values[i++] = ObjectIdGetDatum(InvalidOid); /* 10 */
185+
values[i++] = ObjectIdGetDatum(InvalidOid); /* 11 */
186+
values[i++] = ObjectIdGetDatum(InvalidOid); /* 12 */
187+
values[i++] = ObjectIdGetDatum(InvalidOid); /* 13 */
188+
values[i++] = ObjectIdGetDatum(InvalidOid); /* 14 */
189+
values[i++] = CharGetDatum('p'); /* 15 */
190+
values[i++] = CharGetDatum('i'); /* 16 */
191+
values[i++] = DirectFunctionCall1(textin,
192+
CStringGetDatum(typeName)); /* 17 */
196193

197194
/* ----------------
198195
* create a new type tuple with FormHeapTuple
@@ -460,9 +457,8 @@ TypeCreate(char *typeName,
460457
* initialize the default value for this type.
461458
* ----------------
462459
*/
463-
values[i] = (Datum) textin(PointerIsValid(defaultTypeValue) /* 17 */
464-
? defaultTypeValue : "-"); /* XXX default
465-
* typdefault */
460+
values[i] = DirectFunctionCall1(textin, /* 17 */
461+
CStringGetDatum(defaultTypeValue ? defaultTypeValue : "-"));
466462

467463
/* ----------------
468464
* open pg_type and begin a scan for the type name.

src/backend/commands/analyze.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.2 2000/05/30 04:25:00 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.3 2000/07/05 23:11:08 tgl Exp $
1212
*
1313
1414
*-------------------------------------------------------------------------
@@ -515,8 +515,8 @@ update_attstats(Oid relid, int natts, VacAttrStats *vacattrstats)
515515
*/
516516
if (VacAttrStatsLtGtValid(stats) && stats->initialized)
517517
{
518-
float32data nullratio;
519-
float32data bestratio;
518+
float4 nullratio;
519+
float4 bestratio;
520520
FmgrInfo out_function;
521521
char *out_string;
522522
double best_cnt_d = stats->best_cnt,
@@ -541,26 +541,28 @@ update_attstats(Oid relid, int natts, VacAttrStats *vacattrstats)
541541
values[i++] = ObjectIdGetDatum(relid); /* starelid */
542542
values[i++] = Int16GetDatum(attp->attnum); /* staattnum */
543543
values[i++] = ObjectIdGetDatum(stats->op_cmplt); /* staop */
544-
/* hack: this code knows float4 is pass-by-ref */
545-
values[i++] = Float32GetDatum(&nullratio); /* stanullfrac */
546-
values[i++] = Float32GetDatum(&bestratio); /* stacommonfrac */
544+
values[i++] = Float4GetDatum(nullratio); /* stanullfrac */
545+
values[i++] = Float4GetDatum(bestratio); /* stacommonfrac */
547546
out_string = DatumGetCString(FunctionCall3(&out_function,
548547
stats->best,
549548
ObjectIdGetDatum(stats->typelem),
550549
Int32GetDatum(stats->attr->atttypmod)));
551-
values[i++] = PointerGetDatum(textin(out_string)); /* stacommonval */
550+
values[i++] = DirectFunctionCall1(textin, /* stacommonval */
551+
CStringGetDatum(out_string));
552552
pfree(out_string);
553553
out_string = DatumGetCString(FunctionCall3(&out_function,
554554
stats->min,
555555
ObjectIdGetDatum(stats->typelem),
556556
Int32GetDatum(stats->attr->atttypmod)));
557-
values[i++] = PointerGetDatum(textin(out_string)); /* staloval */
557+
values[i++] = DirectFunctionCall1(textin, /* staloval */
558+
CStringGetDatum(out_string));
558559
pfree(out_string);
559560
out_string = DatumGetCString(FunctionCall3(&out_function,
560561
stats->max,
561562
ObjectIdGetDatum(stats->typelem),
562563
Int32GetDatum(stats->attr->atttypmod)));
563-
values[i++] = PointerGetDatum(textin(out_string)); /* stahival */
564+
values[i++] = DirectFunctionCall1(textin, /* stahival */
565+
CStringGetDatum(out_string));
564566
pfree(out_string);
565567

566568
stup = heap_formtuple(sd->rd_att, values, nulls);

0 commit comments

Comments
 (0)