Skip to content

Commit d7018ab

Browse files
committed
Make record_out and record_send extract type information from the passed
record object itself, rather than relying on a second OID argument to be correct. This patch just changes the function behavior and not the catalogs, so it's OK to back-patch to 8.0. Will remove the now-redundant second argument in pg_proc in a separate patch in HEAD only.
1 parent 93b2477 commit d7018ab

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

src/backend/utils/adt/rowtypes.c

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.9 2005/04/18 17:11:05 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.10 2005/04/30 20:04:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -268,7 +268,7 @@ Datum
268268
record_out(PG_FUNCTION_ARGS)
269269
{
270270
HeapTupleHeader rec = PG_GETARG_HEAPTUPLEHEADER(0);
271-
Oid tupType = PG_GETARG_OID(1);
271+
Oid tupType;
272272
int32 tupTypmod;
273273
TupleDesc tupdesc;
274274
HeapTupleData tuple;
@@ -280,18 +280,9 @@ record_out(PG_FUNCTION_ARGS)
280280
char *nulls;
281281
StringInfoData buf;
282282

283-
/*
284-
* Use the passed type unless it's RECORD; in that case, we'd better
285-
* get the type info out of the datum itself. Note that for RECORD,
286-
* what we'll probably actually get is RECORD's typelem, ie, zero.
287-
*/
288-
if (tupType == InvalidOid || tupType == RECORDOID)
289-
{
290-
tupType = HeapTupleHeaderGetTypeId(rec);
291-
tupTypmod = HeapTupleHeaderGetTypMod(rec);
292-
}
293-
else
294-
tupTypmod = -1;
283+
/* Extract type info from the tuple itself */
284+
tupType = HeapTupleHeaderGetTypeId(rec);
285+
tupTypmod = HeapTupleHeaderGetTypMod(rec);
295286
tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
296287
ncolumns = tupdesc->natts;
297288

@@ -613,7 +604,7 @@ Datum
613604
record_send(PG_FUNCTION_ARGS)
614605
{
615606
HeapTupleHeader rec = PG_GETARG_HEAPTUPLEHEADER(0);
616-
Oid tupType = PG_GETARG_OID(1);
607+
Oid tupType;
617608
int32 tupTypmod;
618609
TupleDesc tupdesc;
619610
HeapTupleData tuple;
@@ -625,18 +616,9 @@ record_send(PG_FUNCTION_ARGS)
625616
char *nulls;
626617
StringInfoData buf;
627618

628-
/*
629-
* Use the passed type unless it's RECORD; in that case, we'd better
630-
* get the type info out of the datum itself. Note that for RECORD,
631-
* what we'll probably actually get is RECORD's typelem, ie, zero.
632-
*/
633-
if (tupType == InvalidOid || tupType == RECORDOID)
634-
{
635-
tupType = HeapTupleHeaderGetTypeId(rec);
636-
tupTypmod = HeapTupleHeaderGetTypMod(rec);
637-
}
638-
else
639-
tupTypmod = -1;
619+
/* Extract type info from the tuple itself */
620+
tupType = HeapTupleHeaderGetTypeId(rec);
621+
tupTypmod = HeapTupleHeaderGetTypMod(rec);
640622
tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
641623
ncolumns = tupdesc->natts;
642624

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