git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ec4b975)
Add object_address tests for publications and subscriptions
2017年1月26日 18:10:22 +0000 (13:10 -0500)
2017年1月26日 18:21:22 +0000 (13:21 -0500)
Add test cases to object_address.sql to test the new logical replication
related object classes, and fix some small bugs discovered by that.


diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index e11f656044f9fa39ca5e72fd53d20e30e6997557..2a38792ed6f3f1c7df695e23dbd29f19b0e32830 100644 (file)
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -3841,7 +3841,7 @@ getObjectTypeDescription(const ObjectAddress *object)
break;
case OCLASS_PUBLICATION_REL:
- appendStringInfoString(&buffer, "publication table");
+ appendStringInfoString(&buffer, "publication relation");
break;
case OCLASS_SUBSCRIPTION:
@@ -4846,7 +4846,7 @@ getObjectIdentityParts(const ObjectAddress *object,
prform = (Form_pg_publication_rel) GETSTRUCT(tup);
pubname = get_publication_name(prform->prpubid);
- appendStringInfo(&buffer, _("publication table %s in publication %s"),
+ appendStringInfo(&buffer, _("%s in publication %s"),
get_rel_name(prform->prrelid), pubname);
if (objname)
diff --git a/src/test/regress/expected/object_address.out b/src/test/regress/expected/object_address.out
index 7e81cdd087f4e9b780b5d283b1aa74a8aab39845..ec5ada97ad7e0ef0815107a2b153fff8f9752da9 100644 (file)
--- a/src/test/regress/expected/object_address.out
+++ b/src/test/regress/expected/object_address.out
@@ -36,6 +36,8 @@ ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM
CREATE TRANSFORM FOR int LANGUAGE SQL (
FROM SQL WITH FUNCTION varchar_transform(internal),
TO SQL WITH FUNCTION int4recv(internal));
+CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable;
+CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (DISABLED, NOCREATE SLOT);
-- test some error cases
SELECT pg_get_object_address('stone', '{}', '{}');
ERROR: unrecognized object type "stone"
@@ -81,7 +83,8 @@ BEGIN
('text search parser'), ('text search dictionary'),
('text search template'), ('text search configuration'),
('policy'), ('user mapping'), ('default acl'), ('transform'),
- ('operator of access method'), ('function of access method')
+ ('operator of access method'), ('function of access method'),
+ ('publication relation')
LOOP
FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
LOOP
@@ -283,6 +286,12 @@ WARNING: error for function of access method,{addr_nsp,zwei},{}: name list leng
WARNING: error for function of access method,{addr_nsp,zwei},{integer}: name list length must be at least 3
WARNING: error for function of access method,{eins,zwei,drei},{}: argument list length must be exactly 2
WARNING: error for function of access method,{eins,zwei,drei},{integer}: argument list length must be exactly 2
+WARNING: error for publication relation,{eins},{}: argument list length must be exactly 1
+WARNING: error for publication relation,{eins},{integer}: relation "eins" does not exist
+WARNING: error for publication relation,{addr_nsp,zwei},{}: argument list length must be exactly 1
+WARNING: error for publication relation,{addr_nsp,zwei},{integer}: relation "addr_nsp.zwei" does not exist
+WARNING: error for publication relation,{eins,zwei,drei},{}: argument list length must be exactly 1
+WARNING: error for publication relation,{eins,zwei,drei},{integer}: cross-database references are not implemented: "eins.zwei.drei"
-- these object types cannot be qualified names
SELECT pg_get_object_address('language', '{one}', '{}');
ERROR: language "one" does not exist
@@ -330,6 +339,14 @@ SELECT pg_get_object_address('access method', '{one}', '{}');
ERROR: access method "one" does not exist
SELECT pg_get_object_address('access method', '{one,two}', '{}');
ERROR: access method name cannot be qualified
+SELECT pg_get_object_address('publication', '{one}', '{}');
+ERROR: publication "one" does not exist
+SELECT pg_get_object_address('publication', '{one,two}', '{}');
+ERROR: publication name cannot be qualified
+SELECT pg_get_object_address('subscription', '{one}', '{}');
+ERROR: subscription "one" does not exist
+SELECT pg_get_object_address('subscription', '{one,two}', '{}');
+ERROR: subscription name cannot be qualified
-- test successful cases
WITH objects (type, name, args) AS (VALUES
('table', '{addr_nsp, gentable}'::text[], '{}'::text[]),
@@ -379,7 +396,10 @@ WITH objects (type, name, args) AS (VALUES
-- event trigger
('policy', '{addr_nsp, gentable, genpol}', '{}'),
('transform', '{int}', '{sql}'),
- ('access method', '{btree}', '{}')
+ ('access method', '{btree}', '{}'),
+ ('publication', '{addr_pub}', '{}'),
+ ('publication relation', '{addr_nsp, gentable}', '{addr_pub}'),
+ ('subscription', '{addr_sub}', '{}')
)
SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.subobjid)).*,
-- test roundtrip through pg_identify_object_as_address
@@ -433,13 +453,18 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.subobjid)).*,
text search parser | addr_nsp | addr_ts_prs | addr_nsp.addr_ts_prs | t
text search configuration | addr_nsp | addr_ts_conf | addr_nsp.addr_ts_conf | t
text search template | addr_nsp | addr_ts_temp | addr_nsp.addr_ts_temp | t
-(42 rows)
+ subscription | | addr_sub | addr_sub | t
+ publication | | addr_pub | addr_pub | t
+ publication relation | | | gentable in publication addr_pub | t
+(45 rows)
---
--- Cleanup resources
---
SET client_min_messages TO 'warning';
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
+DROP PUBLICATION addr_pub;
+DROP SUBSCRIPTION addr_sub NODROP SLOT;
DROP SCHEMA addr_nsp CASCADE;
DROP OWNED BY regress_addr_user;
DROP USER regress_addr_user;
diff --git a/src/test/regress/sql/object_address.sql b/src/test/regress/sql/object_address.sql
index 7d1f93f3b2d554df61c8fdf02789573420e0bc2c..e658ea346dd7471fab544a86ebf0ef53c29ecb7f 100644 (file)
--- a/src/test/regress/sql/object_address.sql
+++ b/src/test/regress/sql/object_address.sql
@@ -39,6 +39,8 @@ ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM
CREATE TRANSFORM FOR int LANGUAGE SQL (
FROM SQL WITH FUNCTION varchar_transform(internal),
TO SQL WITH FUNCTION int4recv(internal));
+CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable;
+CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (DISABLED, NOCREATE SLOT);
-- test some error cases
SELECT pg_get_object_address('stone', '{}', '{}');
@@ -78,7 +80,8 @@ BEGIN
('text search parser'), ('text search dictionary'),
('text search template'), ('text search configuration'),
('policy'), ('user mapping'), ('default acl'), ('transform'),
- ('operator of access method'), ('function of access method')
+ ('operator of access method'), ('function of access method'),
+ ('publication relation')
LOOP
FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
LOOP
@@ -119,6 +122,10 @@ SELECT pg_get_object_address('event trigger', '{one}', '{}');
SELECT pg_get_object_address('event trigger', '{one,two}', '{}');
SELECT pg_get_object_address('access method', '{one}', '{}');
SELECT pg_get_object_address('access method', '{one,two}', '{}');
+SELECT pg_get_object_address('publication', '{one}', '{}');
+SELECT pg_get_object_address('publication', '{one,two}', '{}');
+SELECT pg_get_object_address('subscription', '{one}', '{}');
+SELECT pg_get_object_address('subscription', '{one,two}', '{}');
-- test successful cases
WITH objects (type, name, args) AS (VALUES
@@ -169,7 +176,10 @@ WITH objects (type, name, args) AS (VALUES
-- event trigger
('policy', '{addr_nsp, gentable, genpol}', '{}'),
('transform', '{int}', '{sql}'),
- ('access method', '{btree}', '{}')
+ ('access method', '{btree}', '{}'),
+ ('publication', '{addr_pub}', '{}'),
+ ('publication relation', '{addr_nsp, gentable}', '{addr_pub}'),
+ ('subscription', '{addr_sub}', '{}')
)
SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.subobjid)).*,
-- test roundtrip through pg_identify_object_as_address
@@ -186,6 +196,8 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.subobjid)).*,
SET client_min_messages TO 'warning';
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
+DROP PUBLICATION addr_pub;
+DROP SUBSCRIPTION addr_sub NODROP SLOT;
DROP SCHEMA addr_nsp CASCADE;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /