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

Commit 8609d4a

Browse files
committed
Fix portability problems recently exposed by regression tests on Alphas.
1. Distinguish cases where a Datum representing a tuple datatype is an OID from cases where it is a pointer to TupleTableSlot, and make sure we use the right typlen in each case. 2. Make fetchatt() and related code support 8-byte by-value datatypes on machines where Datum is 8 bytes. Centralize knowledge of the available by-value datatype sizes in two macros in tupmacs.h, so that this will be easier if we ever have to do it again.
1 parent 97799fc commit 8609d4a

File tree

23 files changed

+492
-655
lines changed

23 files changed

+492
-655
lines changed

configure

Lines changed: 71 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7206,16 +7206,61 @@ done
72067206

72077207

72087208

7209+
echo $ac_n "checking size of unsigned long""... $ac_c" 1>&6
7210+
echo "configure:7211: checking size of unsigned long" >&5
7211+
if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_long'+set}'`\" = set"; then
7212+
echo $ac_n "(cached) $ac_c" 1>&6
7213+
else
7214+
if test "$cross_compiling" = yes; then
7215+
ac_cv_sizeof_unsigned_long=4
7216+
else
7217+
cat > conftest.$ac_ext <<EOF
7218+
#line 7219 "configure"
7219+
#include "confdefs.h"
7220+
#include <stdio.h>
7221+
main()
7222+
{
7223+
FILE *f=fopen("conftestval", "w");
7224+
if (!f) exit(1);
7225+
fprintf(f, "%d\n", sizeof(unsigned long));
7226+
exit(0);
7227+
}
7228+
EOF
7229+
if { (eval echo configure:7230: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
7230+
then
7231+
ac_cv_sizeof_unsigned_long=`cat conftestval`
7232+
else
7233+
echo "configure: failed program was:" >&5
7234+
cat conftest.$ac_ext >&5
7235+
rm -fr conftest*
7236+
ac_cv_sizeof_unsigned_long=0
7237+
fi
7238+
rm -fr conftest*
7239+
fi
7240+
7241+
fi
7242+
echo "$ac_t""$ac_cv_sizeof_unsigned_long" 1>&6
7243+
cat >> confdefs.h <<EOF
7244+
#define SIZEOF_UNSIGNED_LONG $ac_cv_sizeof_unsigned_long
7245+
EOF
7246+
7247+
7248+
cat >> confdefs.h <<EOF
7249+
#define SIZEOF_DATUM $ac_cv_sizeof_unsigned_long
7250+
EOF
7251+
7252+
7253+
72097254
echo $ac_n "checking alignment of short""... $ac_c" 1>&6
7210-
echo "configure:7211: checking alignment of short" >&5
7255+
echo "configure:7256: checking alignment of short" >&5
72117256
if eval "test \"`echo '$''{'pgac_cv_alignof_short'+set}'`\" = set"; then
72127257
echo $ac_n "(cached) $ac_c" 1>&6
72137258
else
72147259
if test "$cross_compiling" = yes; then
72157260
pgac_cv_alignof_short='sizeof(short)'
72167261
else
72177262
cat > conftest.$ac_ext <<EOF
7218-
#line 7219 "configure"
7263+
#line 7264 "configure"
72197264
#include "confdefs.h"
72207265
#include <stdio.h>
72217266
struct { char filler; short field; } mystruct;
@@ -7227,7 +7272,7 @@ main()
72277272
exit(0);
72287273
}
72297274
EOF
7230-
if { (eval echo configure:7231: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
7275+
if { (eval echo configure:7276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
72317276
then
72327277
pgac_cv_alignof_short=`cat conftestval`
72337278
else
@@ -7247,15 +7292,15 @@ EOF
72477292

72487293

72497294
echo $ac_n "checking alignment of int""... $ac_c" 1>&6
7250-
echo "configure:7251: checking alignment of int" >&5
7295+
echo "configure:7296: checking alignment of int" >&5
72517296
if eval "test \"`echo '$''{'pgac_cv_alignof_int'+set}'`\" = set"; then
72527297
echo $ac_n "(cached) $ac_c" 1>&6
72537298
else
72547299
if test "$cross_compiling" = yes; then
72557300
pgac_cv_alignof_int='sizeof(int)'
72567301
else
72577302
cat > conftest.$ac_ext <<EOF
7258-
#line 7259 "configure"
7303+
#line 7304 "configure"
72597304
#include "confdefs.h"
72607305
#include <stdio.h>
72617306
struct { char filler; int field; } mystruct;
@@ -7267,7 +7312,7 @@ main()
72677312
exit(0);
72687313
}
72697314
EOF
7270-
if { (eval echo configure:7271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
7315+
if { (eval echo configure:7316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
72717316
then
72727317
pgac_cv_alignof_int=`cat conftestval`
72737318
else
@@ -7287,15 +7332,15 @@ EOF
72877332

72887333

72897334
echo $ac_n "checking alignment of long""... $ac_c" 1>&6
7290-
echo "configure:7291: checking alignment of long" >&5
7335+
echo "configure:7336: checking alignment of long" >&5
72917336
if eval "test \"`echo '$''{'pgac_cv_alignof_long'+set}'`\" = set"; then
72927337
echo $ac_n "(cached) $ac_c" 1>&6
72937338
else
72947339
if test "$cross_compiling" = yes; then
72957340
pgac_cv_alignof_long='sizeof(long)'
72967341
else
72977342
cat > conftest.$ac_ext <<EOF
7298-
#line 7299 "configure"
7343+
#line 7344 "configure"
72997344
#include "confdefs.h"
73007345
#include <stdio.h>
73017346
struct { char filler; long field; } mystruct;
@@ -7307,7 +7352,7 @@ main()
73077352
exit(0);
73087353
}
73097354
EOF
7310-
if { (eval echo configure:7311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
7355+
if { (eval echo configure:7356: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
73117356
then
73127357
pgac_cv_alignof_long=`cat conftestval`
73137358
else
@@ -7328,15 +7373,15 @@ EOF
73287373

73297374
if [ x"$HAVE_LONG_LONG_INT_64" = xyes ] ; then
73307375
echo $ac_n "checking alignment of long long int""... $ac_c" 1>&6
7331-
echo "configure:7332: checking alignment of long long int" >&5
7376+
echo "configure:7377: checking alignment of long long int" >&5
73327377
if eval "test \"`echo '$''{'pgac_cv_alignof_long_long_int'+set}'`\" = set"; then
73337378
echo $ac_n "(cached) $ac_c" 1>&6
73347379
else
73357380
if test "$cross_compiling" = yes; then
73367381
pgac_cv_alignof_long_long_int='sizeof(long long int)'
73377382
else
73387383
cat > conftest.$ac_ext <<EOF
7339-
#line 7340 "configure"
7384+
#line 7385 "configure"
73407385
#include "confdefs.h"
73417386
#include <stdio.h>
73427387
struct { char filler; long long int field; } mystruct;
@@ -7348,7 +7393,7 @@ main()
73487393
exit(0);
73497394
}
73507395
EOF
7351-
if { (eval echo configure:7352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
7396+
if { (eval echo configure:7397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
73527397
then
73537398
pgac_cv_alignof_long_long_int=`cat conftestval`
73547399
else
@@ -7369,15 +7414,15 @@ EOF
73697414

73707415
fi
73717416
echo $ac_n "checking alignment of double""... $ac_c" 1>&6
7372-
echo "configure:7373: checking alignment of double" >&5
7417+
echo "configure:7418: checking alignment of double" >&5
73737418
if eval "test \"`echo '$''{'pgac_cv_alignof_double'+set}'`\" = set"; then
73747419
echo $ac_n "(cached) $ac_c" 1>&6
73757420
else
73767421
if test "$cross_compiling" = yes; then
73777422
pgac_cv_alignof_double='sizeof(double)'
73787423
else
73797424
cat > conftest.$ac_ext <<EOF
7380-
#line 7381 "configure"
7425+
#line 7426 "configure"
73817426
#include "confdefs.h"
73827427
#include <stdio.h>
73837428
struct { char filler; double field; } mystruct;
@@ -7389,7 +7434,7 @@ main()
73897434
exit(0);
73907435
}
73917436
EOF
7392-
if { (eval echo configure:7393: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
7437+
if { (eval echo configure:7438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
73937438
then
73947439
pgac_cv_alignof_double=`cat conftestval`
73957440
else
@@ -7427,12 +7472,12 @@ EOF
74277472

74287473

74297474
echo $ac_n "checking for POSIX signal interface""... $ac_c" 1>&6
7430-
echo "configure:7431: checking for POSIX signal interface" >&5
7475+
echo "configure:7476: checking for POSIX signal interface" >&5
74317476
if eval "test \"`echo '$''{'pgac_cv_func_posix_signals'+set}'`\" = set"; then
74327477
echo $ac_n "(cached) $ac_c" 1>&6
74337478
else
74347479
cat > conftest.$ac_ext <<EOF
7435-
#line 7436 "configure"
7480+
#line 7481 "configure"
74367481
#include "confdefs.h"
74377482
#include <signal.h>
74387483
@@ -7443,7 +7488,7 @@ act.sa_flags = SA_RESTART;
74437488
sigaction(0, &act, &oact);
74447489
; return 0; }
74457490
EOF
7446-
if { (eval echo configure:7447: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
7491+
if { (eval echo configure:7492: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
74477492
rm -rf conftest*
74487493
pgac_cv_func_posix_signals=yes
74497494
else
@@ -7473,7 +7518,7 @@ do
74737518
# Extract the first word of "$ac_prog", so it can be a program name with args.
74747519
set dummy $ac_prog; ac_word=$2
74757520
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
7476-
echo "configure:7477: checking for $ac_word" >&5
7521+
echo "configure:7522: checking for $ac_word" >&5
74777522
if eval "test \"`echo '$''{'ac_cv_path_TCLSH'+set}'`\" = set"; then
74787523
echo $ac_n "(cached) $ac_c" 1>&6
74797524
else
@@ -7509,7 +7554,7 @@ test -n "$TCLSH" && break
75097554
done
75107555

75117556
echo $ac_n "checking for tclConfig.sh""... $ac_c" 1>&6
7512-
echo "configure:7513: checking for tclConfig.sh" >&5
7557+
echo "configure:7558: checking for tclConfig.sh" >&5
75137558
# Let user override test
75147559
if test -z "$TCL_CONFIG_SH"; then
75157560
pgac_test_dirs="$with_tclconfig"
@@ -7542,7 +7587,7 @@ fi
75427587
# Check for Tk configuration script tkConfig.sh
75437588
if test "$with_tk" = yes; then
75447589
echo $ac_n "checking for tkConfig.sh""... $ac_c" 1>&6
7545-
echo "configure:7546: checking for tkConfig.sh" >&5
7590+
echo "configure:7591: checking for tkConfig.sh" >&5
75467591
# Let user override test
75477592
if test -z "$TK_CONFIG_SH"; then
75487593
pgac_test_dirs="$with_tkconfig $with_tclconfig"
@@ -7581,7 +7626,7 @@ do
75817626
# Extract the first word of "$ac_prog", so it can be a program name with args.
75827627
set dummy $ac_prog; ac_word=$2
75837628
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
7584-
echo "configure:7585: checking for $ac_word" >&5
7629+
echo "configure:7630: checking for $ac_word" >&5
75857630
if eval "test \"`echo '$''{'ac_cv_prog_NSGMLS'+set}'`\" = set"; then
75867631
echo $ac_n "(cached) $ac_c" 1>&6
75877632
else
@@ -7617,7 +7662,7 @@ do
76177662
# Extract the first word of "$ac_prog", so it can be a program name with args.
76187663
set dummy $ac_prog; ac_word=$2
76197664
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
7620-
echo "configure:7621: checking for $ac_word" >&5
7665+
echo "configure:7666: checking for $ac_word" >&5
76217666
if eval "test \"`echo '$''{'ac_cv_prog_JADE'+set}'`\" = set"; then
76227667
echo $ac_n "(cached) $ac_c" 1>&6
76237668
else
@@ -7648,7 +7693,7 @@ done
76487693

76497694

76507695
echo $ac_n "checking for DocBook V3.1""... $ac_c" 1>&6
7651-
echo "configure:7652: checking for DocBook V3.1" >&5
7696+
echo "configure:7697: checking for DocBook V3.1" >&5
76527697
if eval "test \"`echo '$''{'pgac_cv_check_docbook'+set}'`\" = set"; then
76537698
echo $ac_n "(cached) $ac_c" 1>&6
76547699
else
@@ -7681,7 +7726,7 @@ have_docbook=$pgac_cv_check_docbook
76817726

76827727

76837728
echo $ac_n "checking for DocBook stylesheets""... $ac_c" 1>&6
7684-
echo "configure:7685: checking for DocBook stylesheets" >&5
7729+
echo "configure:7730: checking for DocBook stylesheets" >&5
76857730
if eval "test \"`echo '$''{'pgac_cv_path_stylesheets'+set}'`\" = set"; then
76867731
echo $ac_n "(cached) $ac_c" 1>&6
76877732
else
@@ -7720,7 +7765,7 @@ do
77207765
# Extract the first word of "$ac_prog", so it can be a program name with args.
77217766
set dummy $ac_prog; ac_word=$2
77227767
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
7723-
echo "configure:7724: checking for $ac_word" >&5
7768+
echo "configure:7769: checking for $ac_word" >&5
77247769
if eval "test \"`echo '$''{'ac_cv_prog_SGMLSPL'+set}'`\" = set"; then
77257770
echo $ac_n "(cached) $ac_c" 1>&6
77267771
else

configure.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,11 @@ AC_CHECK_FUNCS([strtoll strtoq], [break])
10591059
AC_CHECK_FUNCS([strtoull strtouq], [break])
10601060

10611061

1062+
dnl Need a #define for the size of Datum (unsigned long)
1063+
1064+
AC_CHECK_SIZEOF(unsigned long, 4)
1065+
AC_DEFINE_UNQUOTED(SIZEOF_DATUM, $ac_cv_sizeof_unsigned_long)
1066+
10621067
dnl Determine memory alignment requirements for the basic C datatypes.
10631068

10641069
PGAC_CHECK_ALIGNOF(short)

contrib/array/array_iterator.c

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <sys/types.h>
2222
#include <string.h>
2323

24+
#include "access/tupmacs.h"
2425
#include "access/xact.h"
2526
#include "fmgr.h"
2627
#include "miscadmin.h"
@@ -80,37 +81,17 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
8081
p = ARR_DATA_PTR(array);
8182
for (i = 0; i < nitems; i++)
8283
{
83-
if (typbyval)
84-
{
85-
switch (typlen)
86-
{
87-
case 1:
88-
result = FunctionCall2(&finfo,
89-
CharGetDatum(*p),
90-
value);
91-
break;
92-
case 2:
93-
result = FunctionCall2(&finfo,
94-
Int16GetDatum(*(int16 *) p),
95-
value);
96-
break;
97-
case 3:
98-
case 4:
99-
result = FunctionCall2(&finfo,
100-
Int32GetDatum(*(int32 *) p),
101-
value);
102-
break;
103-
}
84+
Datum itemvalue;
85+
86+
itemvalue = fetch_att(p, typbyval, typlen);
87+
88+
if (typlen > 0)
10489
p += typlen;
105-
}
10690
else
107-
{
108-
result = FunctionCall2(&finfo, PointerGetDatum(p), value);
109-
if (typlen > 0)
110-
p += typlen;
111-
else
112-
p += INTALIGN(*(int32 *) p);
113-
}
91+
p += INTALIGN(*(int32 *) p);
92+
93+
result = FunctionCall2(&finfo, itemvalue, value);
94+
11495
if (DatumGetBool(result))
11596
{
11697
if (!and)

0 commit comments

Comments
 (0)