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

Commit c1da0ac

Browse files
committed
Test ALIGNOF_DOUBLE==4 compatibility under ALIGNOF_DOUBLE==8.
Today's test case detected alignment problems only when executing on AIX. This change lets popular platforms detect the same problems. Reviewed by Masahiko Sawada. Discussion: https://postgr.es/m/20220415072601.GG862547@rfd.leadboat.com
1 parent a66e722 commit c1da0ac

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

src/test/regress/expected/sanity_check.out

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ WITH check_columns AS (
3939
SELECT t.oid
4040
FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
4141
WHERE pa.attrelid = a.attrelid AND
42-
pa.attnum > 0 AND pa.attnum <= a.attnum
42+
pa.attnum > 0 AND pa.attnum < a.attnum
4343
ORDER BY pa.attnum) AS coltypes
4444
FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
4545
JOIN pg_namespace n ON c.relnamespace = n.oid
4646
WHERE attalign = 'd' AND relkind = 'r' AND
4747
attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog'
4848
)
49-
SELECT relname, attname, coltypes, get_column_offset(coltypes)
49+
SELECT relname, attname, coltypes, get_columns_length(coltypes)
5050
FROM check_columns
51-
WHERE get_column_offset(coltypes) % 8 != 0 OR
51+
WHERE get_columns_length(coltypes) % 8 != 0 OR
5252
'name'::regtype::oid = ANY(coltypes);
53-
relname | attname | coltypes | get_column_offset
54-
---------+---------+----------+-------------------
53+
relname | attname | coltypes | get_columns_length
54+
---------+---------+----------+--------------------
5555
(0 rows)
5656

src/test/regress/expected/test_setup.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ CREATE FUNCTION ttdummy ()
206206
RETURNS trigger
207207
AS :'regresslib'
208208
LANGUAGE C;
209-
CREATE FUNCTION get_column_offset (oid[])
209+
CREATE FUNCTION get_columns_length(oid[])
210210
RETURNS int
211211
AS :'regresslib'
212212
LANGUAGE C STRICT STABLE PARALLEL SAFE;

src/test/regress/regress.c

+6-10
Original file line numberDiff line numberDiff line change
@@ -1219,12 +1219,12 @@ binary_coercible(PG_FUNCTION_ARGS)
12191219
}
12201220

12211221
/*
1222-
* Return the column offset of the last data in the given array of
1223-
* data types. The input data types must be fixed-length data types.
1222+
* Return the length of the portion of a tuple consisting of the given array
1223+
* of data types. The input data types must be fixed-length data types.
12241224
*/
1225-
PG_FUNCTION_INFO_V1(get_column_offset);
1225+
PG_FUNCTION_INFO_V1(get_columns_length);
12261226
Datum
1227-
get_column_offset(PG_FUNCTION_ARGS)
1227+
get_columns_length(PG_FUNCTION_ARGS)
12281228
{
12291229
ArrayType *ta = PG_GETARG_ARRAYTYPE_P(0);
12301230
Oid *type_oids;
@@ -1249,14 +1249,10 @@ get_column_offset(PG_FUNCTION_ARGS)
12491249
get_typlenbyvalalign(typeoid, &typlen, &typbyval, &typalign);
12501250

12511251
/* the data type must be fixed-length */
1252-
if (!(typbyval || (typlen > 0)))
1252+
if (typlen < 0)
12531253
elog(ERROR, "type %u is not fixed-length data type", typeoid);
12541254

1255-
column_offset = att_align_nominal(column_offset, typalign);
1256-
1257-
/* not include the last type size */
1258-
if (i != (ntypes - 1))
1259-
column_offset += typlen;
1255+
column_offset = att_align_nominal(column_offset + typlen, typalign);
12601256
}
12611257

12621258
PG_RETURN_INT32(column_offset);

src/test/regress/sql/sanity_check.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ WITH check_columns AS (
3434
SELECT t.oid
3535
FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
3636
WHERE pa.attrelid = a.attrelid AND
37-
pa.attnum > 0 AND pa.attnum <= a.attnum
37+
pa.attnum > 0 AND pa.attnum < a.attnum
3838
ORDER BY pa.attnum) AS coltypes
3939
FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
4040
JOIN pg_namespace n ON c.relnamespace = n.oid
4141
WHERE attalign = 'd' AND relkind = 'r' AND
4242
attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog'
4343
)
44-
SELECT relname, attname, coltypes, get_column_offset(coltypes)
44+
SELECT relname, attname, coltypes, get_columns_length(coltypes)
4545
FROM check_columns
46-
WHERE get_column_offset(coltypes) % 8 != 0 OR
46+
WHERE get_columns_length(coltypes) % 8 != 0 OR
4747
'name'::regtype::oid = ANY(coltypes);

src/test/regress/sql/test_setup.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ CREATE FUNCTION ttdummy ()
253253
AS :'regresslib'
254254
LANGUAGE C;
255255

256-
CREATE FUNCTION get_column_offset (oid[])
256+
CREATE FUNCTION get_columns_length(oid[])
257257
RETURNS int
258258
AS :'regresslib'
259259
LANGUAGE C STRICT STABLE PARALLEL SAFE;

0 commit comments

Comments
 (0)