Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 81e11f2

Browse files
committed
Actually, instead of whining about how type internal might not safely store
a pointer, why don't we just fix that. Every known use of "internal" really means a pointer anyway.
1 parent 03e5248 commit 81e11f2

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/backend/utils/adt/array_userfuncs.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2003-2008, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.25 2008/11/14 00:12:08 tgl Exp $
9+
* $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.26 2008/11/14 02:09:51 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -495,14 +495,10 @@ array_agg_transfn(PG_FUNCTION_ARGS)
495495
((AggState *) fcinfo->context)->aggcontext);
496496

497497
/*
498-
* We cheat quite a lot here by assuming that a pointer datum will be
499-
* preserved intact when nodeAgg.c thinks it is a value of type "internal".
500-
* This will in fact work because internal is stated to be pass-by-value
501-
* in pg_type.h, and nodeAgg will never do anything with a pass-by-value
502-
* transvalue except pass it around in Datum form. But it's mighty
503-
* shaky seeing that internal is also stated to be 4 bytes wide in
504-
* pg_type.h. If nodeAgg did put the value into a tuple this would
505-
* crash and burn on 64-bit machines.
498+
* The transition type for array_agg() is declared to be "internal",
499+
* which is a pass-by-value type the same size as a pointer. So we
500+
* can safely pass the ArrayBuildState pointer through nodeAgg.c's
501+
* machinations.
506502
*/
507503
PG_RETURN_POINTER(state);
508504
}

src/bin/initdb/initdb.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.163 2008/10/31 07:15:11 petere Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.164 2008/11/14 02:09:51 tgl Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1331,6 +1331,12 @@ bootstrap_template1(char *short_version)
13311331
sprintf(buf, "%d", NAMEDATALEN);
13321332
bki_lines = replace_token(bki_lines, "NAMEDATALEN", buf);
13331333

1334+
sprintf(buf, "%d", (int) sizeof(Pointer));
1335+
bki_lines = replace_token(bki_lines, "SIZEOF_POINTER", buf);
1336+
1337+
bki_lines = replace_token(bki_lines, "ALIGNOF_POINTER",
1338+
(sizeof(Pointer) == 4) ? "i" : "d");
1339+
13341340
bki_lines = replace_token(bki_lines, "FLOAT4PASSBYVAL",
13351341
FLOAT4PASSBYVAL ? "true" : "false");
13361342

src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.506 2008/11/14 00:51:46 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.507 2008/11/14 02:09:51 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 200811132
56+
#define CATALOG_VERSION_NO 200811133
5757

5858
#endif

src/include/catalog/pg_type.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.201 2008/10/13 16:25:20 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.202 2008/11/14 02:09:52 tgl Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -613,7 +613,7 @@ DATA(insert OID = 2279 ( trigger PGNSP PGUID 4 t p P f t \054 0 0 0 trigger_in
613613
#define TRIGGEROID 2279
614614
DATA(insert OID = 2280 ( language_handler PGNSP PGUID 4 t p P f t \054 0 0 0 language_handler_in language_handler_out - - - - - i p f 0 -1 0 _null_ _null_ ));
615615
#define LANGUAGE_HANDLEROID 2280
616-
DATA(insert OID = 2281 ( internal PGNSP PGUID 4 t p P f t \054 0 0 0 internal_in internal_out - - - - - i p f 0 -1 0 _null_ _null_ ));
616+
DATA(insert OID = 2281 ( internal PGNSP PGUID SIZEOF_POINTER t p P f t \054 0 0 0 internal_in internal_out - - - - - ALIGNOF_POINTER p f 0 -1 0 _null_ _null_ ));
617617
#define INTERNALOID 2281
618618
DATA(insert OID = 2282 ( opaque PGNSP PGUID 4 t p P f t \054 0 0 0 opaque_in opaque_out - - - - - i p f 0 -1 0 _null_ _null_ ));
619619
#define OPAQUEOID 2282

0 commit comments

Comments
 (0)