diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/arrays.out | 8 | ||||
-rw-r--r-- | src/test/regress/expected/opr_sanity.out | 6 | ||||
-rw-r--r-- | src/test/regress/expected/type_sanity.out | 43 | ||||
-rw-r--r-- | src/test/regress/sql/arrays.sql | 2 | ||||
-rw-r--r-- | src/test/regress/sql/opr_sanity.sql | 6 | ||||
-rw-r--r-- | src/test/regress/sql/type_sanity.sql | 32 |
6 files changed, 76 insertions, 21 deletions
diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out index c03ac65ff89..0254fac8011 100644 --- a/src/test/regress/expected/arrays.out +++ b/src/test/regress/expected/arrays.out @@ -27,12 +27,12 @@ INSERT INTO arrtest (a, b[1:2][1:2], c, d, e, f, g) INSERT INTO arrtest (a, b[1:2], c, d[1:2]) VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}'); INSERT INTO arrtest (b[2]) VALUES(now()); -- error, type mismatch -ERROR: array assignment to "b" requires type integer but expression is of type timestamp with time zone +ERROR: subscripted assignment to "b" requires type integer but expression is of type timestamp with time zone LINE 1: INSERT INTO arrtest (b[2]) VALUES(now()); ^ HINT: You will need to rewrite or cast the expression. INSERT INTO arrtest (b[1:2]) VALUES(now()); -- error, type mismatch -ERROR: array assignment to "b" requires type integer[] but expression is of type timestamp with time zone +ERROR: subscripted assignment to "b" requires type integer[] but expression is of type timestamp with time zone LINE 1: INSERT INTO arrtest (b[1:2]) VALUES(now()); ^ HINT: You will need to rewrite or cast the expression. @@ -200,7 +200,7 @@ select ('[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2]; -- -- check subscription corner cases -- --- More subscripts than MAXDIMS(6) +-- More subscripts than MAXDIM (6) SELECT ('{}'::int[])[1][2][3][4][5][6][7]; ERROR: number of array dimensions (7) exceeds the maximum allowed (6) -- NULL index yields NULL when selecting @@ -237,7 +237,7 @@ UPDATE arrtest ERROR: array subscript in assignment must not be null -- Un-subscriptable type SELECT (now())[1]; -ERROR: cannot subscript type timestamp with time zone because it is not an array +ERROR: cannot subscript type timestamp with time zone because it does not support subscripting -- test slices with empty lower and/or upper index CREATE TEMP TABLE arrtest_s ( a int2[], diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out index 3b39137400f..507b474b1bb 100644 --- a/src/test/regress/expected/opr_sanity.out +++ b/src/test/regress/expected/opr_sanity.out @@ -31,7 +31,8 @@ begin if $2 = 'pg_catalog.any'::pg_catalog.regtype then return true; end if; if $2 = 'pg_catalog.anyarray'::pg_catalog.regtype then if EXISTS(select 1 from pg_catalog.pg_type where - oid = $1 and typelem != 0 and typlen = -1) + oid = $1 and typelem != 0 and + typsubscript = 'pg_catalog.array_subscript_handler'::pg_catalog.regproc) then return true; end if; end if; if $2 = 'pg_catalog.anyrange'::pg_catalog.regtype then @@ -55,7 +56,8 @@ begin if $2 = 'pg_catalog.any'::pg_catalog.regtype then return true; end if; if $2 = 'pg_catalog.anyarray'::pg_catalog.regtype then if EXISTS(select 1 from pg_catalog.pg_type where - oid = $1 and typelem != 0 and typlen = -1) + oid = $1 and typelem != 0 and + typsubscript = 'pg_catalog.array_subscript_handler'::pg_catalog.regproc) then return true; end if; end if; if $2 = 'pg_catalog.anyrange'::pg_catalog.regtype then diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out index ec1cd47623e..13567ddf84b 100644 --- a/src/test/regress/expected/type_sanity.out +++ b/src/test/regress/expected/type_sanity.out @@ -75,14 +75,15 @@ ORDER BY p1.oid; 5017 | pg_mcv_list (4 rows) --- Make sure typarray points to a varlena array type of our own base +-- Make sure typarray points to a "true" array type of our own base SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype, - p2.typelem, p2.typlen + p2.typsubscript FROM pg_type p1 LEFT JOIN pg_type p2 ON (p1.typarray = p2.oid) WHERE p1.typarray <> 0 AND - (p2.oid IS NULL OR p2.typelem <> p1.oid OR p2.typlen <> -1); - oid | basetype | arraytype | typelem | typlen ------+----------+-----------+---------+-------- + (p2.oid IS NULL OR + p2.typsubscript <> 'array_subscript_handler'::regproc); + oid | basetype | arraytype | typsubscript +-----+----------+-----------+-------------- (0 rows) -- Look for range types that do not have a pg_range entry @@ -448,6 +449,33 @@ WHERE p1.typarray = p2.oid AND -----+---------+----------+---------+---------- (0 rows) +-- Check for typelem set without a handler +SELECT p1.oid, p1.typname, p1.typelem +FROM pg_type AS p1 +WHERE p1.typelem != 0 AND p1.typsubscript = 0; + oid | typname | typelem +-----+---------+--------- +(0 rows) + +-- Check for misuse of standard subscript handlers +SELECT p1.oid, p1.typname, + p1.typelem, p1.typlen, p1.typbyval +FROM pg_type AS p1 +WHERE p1.typsubscript = 'array_subscript_handler'::regproc AND NOT + (p1.typelem != 0 AND p1.typlen = -1 AND NOT p1.typbyval); + oid | typname | typelem | typlen | typbyval +-----+---------+---------+--------+---------- +(0 rows) + +SELECT p1.oid, p1.typname, + p1.typelem, p1.typlen, p1.typbyval +FROM pg_type AS p1 +WHERE p1.typsubscript = 'raw_array_subscript_handler'::regproc AND NOT + (p1.typelem != 0 AND p1.typlen > 0 AND NOT p1.typbyval); + oid | typname | typelem | typlen | typbyval +-----+---------+---------+--------+---------- +(0 rows) + -- Check for bogus typanalyze routines SELECT p1.oid, p1.typname, p2.oid, p2.proname FROM pg_type AS p1, pg_proc AS p2 @@ -485,7 +513,7 @@ SELECT t.oid, t.typname, t.typanalyze FROM pg_type t WHERE t.typbasetype = 0 AND (t.typanalyze = 'array_typanalyze'::regproc) != - (typelem != 0 AND typlen < 0) + (t.typsubscript = 'array_subscript_handler'::regproc) ORDER BY 1; oid | typname | typanalyze -----+------------+------------ @@ -608,7 +636,8 @@ WHERE o.opcmethod != 403 OR ((o.opcintype != p1.rngsubtype) AND NOT (o.opcintype = 'pg_catalog.anyarray'::regtype AND EXISTS(select 1 from pg_catalog.pg_type where - oid = p1.rngsubtype and typelem != 0 and typlen = -1))); + oid = p1.rngsubtype and typelem != 0 and + typsubscript = 'array_subscript_handler'::regproc))); rngtypid | rngsubtype | opcmethod | opcname ----------+------------+-----------+--------- (0 rows) diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql index 891491e0466..c40619a8d5d 100644 --- a/src/test/regress/sql/arrays.sql +++ b/src/test/regress/sql/arrays.sql @@ -109,7 +109,7 @@ select ('[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2]; -- -- check subscription corner cases -- --- More subscripts than MAXDIMS(6) +-- More subscripts than MAXDIM (6) SELECT ('{}'::int[])[1][2][3][4][5][6][7]; -- NULL index yields NULL when selecting SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL][1]; diff --git a/src/test/regress/sql/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql index 307aab1deb7..4189a5a4e09 100644 --- a/src/test/regress/sql/opr_sanity.sql +++ b/src/test/regress/sql/opr_sanity.sql @@ -34,7 +34,8 @@ begin if $2 = 'pg_catalog.any'::pg_catalog.regtype then return true; end if; if $2 = 'pg_catalog.anyarray'::pg_catalog.regtype then if EXISTS(select 1 from pg_catalog.pg_type where - oid = $1 and typelem != 0 and typlen = -1) + oid = $1 and typelem != 0 and + typsubscript = 'pg_catalog.array_subscript_handler'::pg_catalog.regproc) then return true; end if; end if; if $2 = 'pg_catalog.anyrange'::pg_catalog.regtype then @@ -59,7 +60,8 @@ begin if $2 = 'pg_catalog.any'::pg_catalog.regtype then return true; end if; if $2 = 'pg_catalog.anyarray'::pg_catalog.regtype then if EXISTS(select 1 from pg_catalog.pg_type where - oid = $1 and typelem != 0 and typlen = -1) + oid = $1 and typelem != 0 and + typsubscript = 'pg_catalog.array_subscript_handler'::pg_catalog.regproc) then return true; end if; end if; if $2 = 'pg_catalog.anyrange'::pg_catalog.regtype then diff --git a/src/test/regress/sql/type_sanity.sql b/src/test/regress/sql/type_sanity.sql index 5e433388cdc..8c6e614f20a 100644 --- a/src/test/regress/sql/type_sanity.sql +++ b/src/test/regress/sql/type_sanity.sql @@ -63,12 +63,13 @@ WHERE p1.typtype not in ('p') AND p1.typname NOT LIKE E'\\_%' p2.typelem = p1.oid and p1.typarray = p2.oid) ORDER BY p1.oid; --- Make sure typarray points to a varlena array type of our own base +-- Make sure typarray points to a "true" array type of our own base SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype, - p2.typelem, p2.typlen + p2.typsubscript FROM pg_type p1 LEFT JOIN pg_type p2 ON (p1.typarray = p2.oid) WHERE p1.typarray <> 0 AND - (p2.oid IS NULL OR p2.typelem <> p1.oid OR p2.typlen <> -1); + (p2.oid IS NULL OR + p2.typsubscript <> 'array_subscript_handler'::regproc); -- Look for range types that do not have a pg_range entry SELECT p1.oid, p1.typname @@ -323,6 +324,26 @@ WHERE p1.typarray = p2.oid AND p2.typalign != (CASE WHEN p1.typalign = 'd' THEN 'd'::"char" ELSE 'i'::"char" END); +-- Check for typelem set without a handler + +SELECT p1.oid, p1.typname, p1.typelem +FROM pg_type AS p1 +WHERE p1.typelem != 0 AND p1.typsubscript = 0; + +-- Check for misuse of standard subscript handlers + +SELECT p1.oid, p1.typname, + p1.typelem, p1.typlen, p1.typbyval +FROM pg_type AS p1 +WHERE p1.typsubscript = 'array_subscript_handler'::regproc AND NOT + (p1.typelem != 0 AND p1.typlen = -1 AND NOT p1.typbyval); + +SELECT p1.oid, p1.typname, + p1.typelem, p1.typlen, p1.typbyval +FROM pg_type AS p1 +WHERE p1.typsubscript = 'raw_array_subscript_handler'::regproc AND NOT + (p1.typelem != 0 AND p1.typlen > 0 AND NOT p1.typbyval); + -- Check for bogus typanalyze routines SELECT p1.oid, p1.typname, p2.oid, p2.proname @@ -356,7 +377,7 @@ SELECT t.oid, t.typname, t.typanalyze FROM pg_type t WHERE t.typbasetype = 0 AND (t.typanalyze = 'array_typanalyze'::regproc) != - (typelem != 0 AND typlen < 0) + (t.typsubscript = 'array_subscript_handler'::regproc) ORDER BY 1; -- **************** pg_class **************** @@ -452,7 +473,8 @@ WHERE o.opcmethod != 403 OR ((o.opcintype != p1.rngsubtype) AND NOT (o.opcintype = 'pg_catalog.anyarray'::regtype AND EXISTS(select 1 from pg_catalog.pg_type where - oid = p1.rngsubtype and typelem != 0 and typlen = -1))); + oid = p1.rngsubtype and typelem != 0 and + typsubscript = 'array_subscript_handler'::regproc))); -- canonical function, if any, had better match the range type |