From ea8172ce75fbd9c815086295c974734fa0aef124 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 14 Nov 2008 02:09:52 +0000 Subject: [PATCH] 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. --- src/backend/utils/adt/array_userfuncs.c | 12 ++++-------- src/bin/initdb/initdb.c | 6 ++++++ src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_type.h | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c index cc368a523a..2fc90cfe43 100644 --- a/src/backend/utils/adt/array_userfuncs.c +++ b/src/backend/utils/adt/array_userfuncs.c @@ -495,14 +495,10 @@ array_agg_transfn(PG_FUNCTION_ARGS) ((AggState *) fcinfo->context)->aggcontext); /* - * We cheat quite a lot here by assuming that a pointer datum will be - * preserved intact when nodeAgg.c thinks it is a value of type "internal". - * This will in fact work because internal is stated to be pass-by-value - * in pg_type.h, and nodeAgg will never do anything with a pass-by-value - * transvalue except pass it around in Datum form. But it's mighty - * shaky seeing that internal is also stated to be 4 bytes wide in - * pg_type.h. If nodeAgg did put the value into a tuple this would - * crash and burn on 64-bit machines. + * The transition type for array_agg() is declared to be "internal", + * which is a pass-by-value type the same size as a pointer. So we + * can safely pass the ArrayBuildState pointer through nodeAgg.c's + * machinations. */ PG_RETURN_POINTER(state); } diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 471fa39762..5760b40f38 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1331,6 +1331,12 @@ bootstrap_template1(char *short_version) sprintf(buf, "%d", NAMEDATALEN); bki_lines = replace_token(bki_lines, "NAMEDATALEN", buf); + sprintf(buf, "%d", (int) sizeof(Pointer)); + bki_lines = replace_token(bki_lines, "SIZEOF_POINTER", buf); + + bki_lines = replace_token(bki_lines, "ALIGNOF_POINTER", + (sizeof(Pointer) == 4) ? "i" : "d"); + bki_lines = replace_token(bki_lines, "FLOAT4PASSBYVAL", FLOAT4PASSBYVAL ? "true" : "false"); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 6e3a0e5983..a9c39b7aef 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200811132 +#define CATALOG_VERSION_NO 200811133 #endif diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 22895f860e..9589a8e840 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -613,7 +613,7 @@ DATA(insert OID = 2279 ( trigger PGNSP PGUID 4 t p P f t \054 0 0 0 trigger_in #define TRIGGEROID 2279 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_ )); #define LANGUAGE_HANDLEROID 2280 -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_ )); +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_ )); #define INTERNALOID 2281 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_ )); #define OPAQUEOID 2282 -- 2.39.5