Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit835bcba

Browse files
committed
Add table to regression tests for binary-compatibility checks in pg_upgrade
This commit adds to the main regression test suite a table with allthe in-core data types (some exceptions apply). This table is notdropped, so as pg_upgrade would be able to check the binarycompatibility of the types tracked in the table. If a new type is addedin core, this part of the tests would need a refresh but the tests aredesigned to fail if that were to happen.As this is useful for upgrades and that these rely on the objectscreated in the regression test suite of the old version upgraded from,a backpatch down to 12 is done, which is the last point where a binaryincompatible change has been done (7c15cef). This will hopefully beenough to find out if something gets broken during the development of anew version of Postgres, so as it is possible to take actions inpg_upgrade itself in this case (like0ccfc28 for sql_identifier).An area that is not covered yet is related to external modules, whichmay create their own types. The testing infrastructure of pg_upgrade isnot integrated yet with the external modules stored in core(src/test/modules/ or contrib/, all use the same database name for theirtests so there would be an overlap). This could be improved in thefuture.Author: Justin PryzbyReviewed-by: Jacob Champion, Peter Eisentraut, Tom Lane, Michael PaquierDiscussion:https://postgr.es/m/20201206180248.GI24052@telsasoft.comBackpatch-through: 12
1 parent5f11482 commit835bcba

File tree

3 files changed

+203
-0
lines changed

3 files changed

+203
-0
lines changed

‎src/test/regress/expected/sanity_check.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ sql_parts|f
185185
sql_sizing|f
186186
stud_emp|f
187187
student|f
188+
tab_core_types|f
188189
tableam_parted_a_heap2|f
189190
tableam_parted_b_heap2|f
190191
tableam_parted_c_heap2|f

‎src/test/regress/expected/type_sanity.out

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,3 +674,105 @@ WHERE p1.rngmultitypid IS NULL OR p1.rngmultitypid = 0;
674674
----------+------------+---------------
675675
(0 rows)
676676

677+
-- Create a table that holds all the known in-core data types and leave it
678+
-- around so as pg_upgrade is able to test their binary compatibility.
679+
CREATE TABLE tab_core_types AS SELECT
680+
'(11,12)'::point,
681+
'(1,1),(2,2)'::line,
682+
'((11,11),(12,12))'::lseg,
683+
'((11,11),(13,13))'::box,
684+
'((11,12),(13,13),(14,14))'::path AS openedpath,
685+
'[(11,12),(13,13),(14,14)]'::path AS closedpath,
686+
'((11,12),(13,13),(14,14))'::polygon,
687+
'1,1,1'::circle,
688+
'today'::date,
689+
'now'::time,
690+
'now'::timestamp,
691+
'now'::timetz,
692+
'now'::timestamptz,
693+
'12 seconds'::interval,
694+
'{"reason":"because"}'::json,
695+
'{"when":"now"}'::jsonb,
696+
'$.a[*] ? (@ > 2)'::jsonpath,
697+
'127.0.0.1'::inet,
698+
'127.0.0.0/8'::cidr,
699+
'00:01:03:86:1c:ba'::macaddr8,
700+
'00:01:03:86:1c:ba'::macaddr,
701+
2::int2, 4::int4, 8::int8,
702+
4::float4, '8'::float8, pi()::numeric,
703+
'foo'::"char",
704+
'c'::bpchar,
705+
'abc'::varchar,
706+
'name'::name,
707+
'txt'::text,
708+
true::bool,
709+
E'\\xDEADBEEF'::bytea,
710+
B'10001'::bit,
711+
B'10001'::varbit AS varbit,
712+
'12.34'::money,
713+
'abc'::refcursor,
714+
'1 2'::int2vector,
715+
'1 2'::oidvector,
716+
format('%s=UC/%s', USER, USER)::aclitem,
717+
'a fat cat sat on a mat and ate a fat rat'::tsvector,
718+
'fat & rat'::tsquery,
719+
'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid,
720+
'11'::xid8,
721+
'pg_class'::regclass,
722+
'regtype'::regtype type,
723+
'pg_monitor'::regrole,
724+
'pg_class'::regclass::oid,
725+
'(1,1)'::tid, '2'::xid, '3'::cid,
726+
'10:20:10,14,15'::txid_snapshot,
727+
'10:20:10,14,15'::pg_snapshot,
728+
'16/B374D848'::pg_lsn,
729+
1::information_schema.cardinal_number,
730+
'l'::information_schema.character_data,
731+
'n'::information_schema.sql_identifier,
732+
'now'::information_schema.time_stamp,
733+
'YES'::information_schema.yes_or_no,
734+
'venus'::planets,
735+
'i16'::insenum,
736+
'(1,2)'::int4range, '{(1,2)}'::int4multirange,
737+
'(3,4)'::int8range, '{(3,4)}'::int8multirange,
738+
'(1,2)'::float8range, '{(1,2)}'::float8multirange,
739+
'(3,4)'::numrange, '{(3,4)}'::nummultirange,
740+
'(a,b)'::textrange, '{(a,b)}'::textmultirange,
741+
'(12.34, 56.78)'::cashrange, '{(12.34, 56.78)}'::cashmultirange,
742+
'(2020-01-02, 2021-02-03)'::daterange,
743+
'{(2020-01-02, 2021-02-03)}'::datemultirange,
744+
'(2020-01-02 03:04:05, 2021-02-03 06:07:08)'::tsrange,
745+
'{(2020-01-02 03:04:05, 2021-02-03 06:07:08)}'::tsmultirange,
746+
'(2020-01-02 03:04:05, 2021-02-03 06:07:08)'::tstzrange,
747+
'{(2020-01-02 03:04:05, 2021-02-03 06:07:08)}'::tstzmultirange,
748+
arrayrange(ARRAY[1,2], ARRAY[2,1]),
749+
arraymultirange(arrayrange(ARRAY[1,2], ARRAY[2,1]));
750+
-- Sanity check on the previous table, checking that all core types are
751+
-- included in this table.
752+
SELECT oid, typname, typtype, typelem, typarray, typarray
753+
FROM pg_type t
754+
WHERE typtype NOT IN ('p', 'c') AND
755+
-- reg* types cannot be pg_upgraded, so discard them.
756+
oid != ALL(ARRAY['regproc', 'regprocedure', 'regoper',
757+
'regoperator', 'regconfig', 'regdictionary',
758+
'regnamespace', 'regcollation']::regtype[]) AND
759+
-- Discard types that do not accept input values as these cannot be
760+
-- tested easily.
761+
-- Note: XML might be disabled at compile-time.
762+
oid != ALL(ARRAY['gtsvector', 'pg_node_tree',
763+
'pg_ndistinct', 'pg_dependencies', 'pg_mcv_list',
764+
'pg_brin_bloom_summary',
765+
'pg_brin_minmax_multi_summary', 'xml']::regtype[]) AND
766+
-- Discard arrays.
767+
NOT EXISTS (SELECT 1 FROM pg_type u WHERE u.typarray = t.oid)
768+
-- Exclude everything from the table created above. This checks
769+
-- that no in-core types are missing in tab_core_types.
770+
AND NOT EXISTS (SELECT 1
771+
FROM pg_attribute a
772+
WHERE a.atttypid=t.oid AND
773+
a.attnum > 0 AND
774+
a.attrelid='tab_core_types'::regclass);
775+
oid | typname | typtype | typelem | typarray | typarray
776+
-----+---------+---------+---------+----------+----------
777+
(0 rows)
778+

‎src/test/regress/sql/type_sanity.sql

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,3 +495,103 @@ WHERE pronargs != 2
495495
SELECTp1.rngtypid,p1.rngsubtype,p1.rngmultitypid
496496
FROM pg_range p1
497497
WHEREp1.rngmultitypid ISNULLORp1.rngmultitypid=0;
498+
499+
-- Create a table that holds all the known in-core data types and leave it
500+
-- around so as pg_upgrade is able to test their binary compatibility.
501+
CREATETABLEtab_core_typesASSELECT
502+
'(11,12)'::point,
503+
'(1,1),(2,2)'::line,
504+
'((11,11),(12,12))'::lseg,
505+
'((11,11),(13,13))'::box,
506+
'((11,12),(13,13),(14,14))'::pathAS openedpath,
507+
'[(11,12),(13,13),(14,14)]'::pathAS closedpath,
508+
'((11,12),(13,13),(14,14))'::polygon,
509+
'1,1,1'::circle,
510+
'today'::date,
511+
'now'::time,
512+
'now'::timestamp,
513+
'now'::timetz,
514+
'now'::timestamptz,
515+
'12 seconds'::interval,
516+
'{"reason":"because"}'::json,
517+
'{"when":"now"}'::jsonb,
518+
'$.a[*] ? (@ > 2)'::jsonpath,
519+
'127.0.0.1'::inet,
520+
'127.0.0.0/8'::cidr,
521+
'00:01:03:86:1c:ba'::macaddr8,
522+
'00:01:03:86:1c:ba'::macaddr,
523+
2::int2,4::int4,8::int8,
524+
4::float4,'8'::float8, pi()::numeric,
525+
'foo'::"char",
526+
'c'::bpchar,
527+
'abc'::varchar,
528+
'name'::name,
529+
'txt'::text,
530+
true::bool,
531+
E'\\xDEADBEEF'::bytea,
532+
B'10001'::bit,
533+
B'10001'::varbitAS varbit,
534+
'12.34'::money,
535+
'abc'::refcursor,
536+
'1 2'::int2vector,
537+
'1 2'::oidvector,
538+
format('%s=UC/%s', USER, USER)::aclitem,
539+
'a fat cat sat on a mat and ate a fat rat'::tsvector,
540+
'fat & rat'::tsquery,
541+
'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid,
542+
'11'::xid8,
543+
'pg_class'::regclass,
544+
'regtype'::regtype type,
545+
'pg_monitor'::regrole,
546+
'pg_class'::regclass::oid,
547+
'(1,1)'::tid,'2'::xid,'3'::cid,
548+
'10:20:10,14,15'::txid_snapshot,
549+
'10:20:10,14,15'::pg_snapshot,
550+
'16/B374D848'::pg_lsn,
551+
1::information_schema.cardinal_number,
552+
'l'::information_schema.character_data,
553+
'n'::information_schema.sql_identifier,
554+
'now'::information_schema.time_stamp,
555+
'YES'::information_schema.yes_or_no,
556+
'venus'::planets,
557+
'i16'::insenum,
558+
'(1,2)'::int4range,'{(1,2)}'::int4multirange,
559+
'(3,4)'::int8range,'{(3,4)}'::int8multirange,
560+
'(1,2)'::float8range,'{(1,2)}'::float8multirange,
561+
'(3,4)'::numrange,'{(3,4)}'::nummultirange,
562+
'(a,b)'::textrange,'{(a,b)}'::textmultirange,
563+
'(12.34, 56.78)'::cashrange,'{(12.34, 56.78)}'::cashmultirange,
564+
'(2020-01-02, 2021-02-03)'::daterange,
565+
'{(2020-01-02, 2021-02-03)}'::datemultirange,
566+
'(2020-01-02 03:04:05, 2021-02-03 06:07:08)'::tsrange,
567+
'{(2020-01-02 03:04:05, 2021-02-03 06:07:08)}'::tsmultirange,
568+
'(2020-01-02 03:04:05, 2021-02-03 06:07:08)'::tstzrange,
569+
'{(2020-01-02 03:04:05, 2021-02-03 06:07:08)}'::tstzmultirange,
570+
arrayrange(ARRAY[1,2], ARRAY[2,1]),
571+
arraymultirange(arrayrange(ARRAY[1,2], ARRAY[2,1]));
572+
573+
-- Sanity check on the previous table, checking that all core types are
574+
-- included in this table.
575+
SELECToid, typname, typtype, typelem, typarray, typarray
576+
FROM pg_type t
577+
WHERE typtype NOTIN ('p','c')AND
578+
-- reg* types cannot be pg_upgraded, so discard them.
579+
oid!= ALL(ARRAY['regproc','regprocedure','regoper',
580+
'regoperator','regconfig','regdictionary',
581+
'regnamespace','regcollation']::regtype[])AND
582+
-- Discard types that do not accept input values as these cannot be
583+
-- tested easily.
584+
-- Note: XML might be disabled at compile-time.
585+
oid!= ALL(ARRAY['gtsvector','pg_node_tree',
586+
'pg_ndistinct','pg_dependencies','pg_mcv_list',
587+
'pg_brin_bloom_summary',
588+
'pg_brin_minmax_multi_summary','xml']::regtype[])AND
589+
-- Discard arrays.
590+
NOT EXISTS (SELECT1FROM pg_type uWHEREu.typarray=t.oid)
591+
-- Exclude everything from the table created above. This checks
592+
-- that no in-core types are missing in tab_core_types.
593+
AND NOT EXISTS (SELECT1
594+
FROM pg_attribute a
595+
WHEREa.atttypid=t.oidAND
596+
a.attnum>0AND
597+
a.attrelid='tab_core_types'::regclass);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp