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

Commit2a2bdca

Browse files
committed
Add object_address tests for publications and subscriptions
Add test cases to object_address.sql to test the new logical replicationrelated object classes, and fix some small bugs discovered by that.
1 parentec4b975 commit2a2bdca

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

‎src/backend/catalog/objectaddress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3841,7 +3841,7 @@ getObjectTypeDescription(const ObjectAddress *object)
38413841
break;
38423842

38433843
caseOCLASS_PUBLICATION_REL:
3844-
appendStringInfoString(&buffer,"publicationtable");
3844+
appendStringInfoString(&buffer,"publicationrelation");
38453845
break;
38463846

38473847
caseOCLASS_SUBSCRIPTION:
@@ -4846,7 +4846,7 @@ getObjectIdentityParts(const ObjectAddress *object,
48464846
prform= (Form_pg_publication_rel)GETSTRUCT(tup);
48474847
pubname=get_publication_name(prform->prpubid);
48484848

4849-
appendStringInfo(&buffer,_("publication table%s in publication %s"),
4849+
appendStringInfo(&buffer,_("%s in publication %s"),
48504850
get_rel_name(prform->prrelid),pubname);
48514851

48524852
if (objname)

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM
3636
CREATE TRANSFORM FOR int LANGUAGE SQL (
3737
FROM SQL WITH FUNCTION varchar_transform(internal),
3838
TO SQL WITH FUNCTION int4recv(internal));
39+
CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable;
40+
CREATE SUBSCRIPTION addr_sub CONNECTION '' PUBLICATION bar WITH (DISABLED, NOCREATE SLOT);
3941
-- test some error cases
4042
SELECT pg_get_object_address('stone', '{}', '{}');
4143
ERROR: unrecognized object type "stone"
@@ -81,7 +83,8 @@ BEGIN
8183
('text search parser'), ('text search dictionary'),
8284
('text search template'), ('text search configuration'),
8385
('policy'), ('user mapping'), ('default acl'), ('transform'),
84-
('operator of access method'), ('function of access method')
86+
('operator of access method'), ('function of access method'),
87+
('publication relation')
8588
LOOP
8689
FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
8790
LOOP
@@ -283,6 +286,12 @@ WARNING: error for function of access method,{addr_nsp,zwei},{}: name list leng
283286
WARNING: error for function of access method,{addr_nsp,zwei},{integer}: name list length must be at least 3
284287
WARNING: error for function of access method,{eins,zwei,drei},{}: argument list length must be exactly 2
285288
WARNING: error for function of access method,{eins,zwei,drei},{integer}: argument list length must be exactly 2
289+
WARNING: error for publication relation,{eins},{}: argument list length must be exactly 1
290+
WARNING: error for publication relation,{eins},{integer}: relation "eins" does not exist
291+
WARNING: error for publication relation,{addr_nsp,zwei},{}: argument list length must be exactly 1
292+
WARNING: error for publication relation,{addr_nsp,zwei},{integer}: relation "addr_nsp.zwei" does not exist
293+
WARNING: error for publication relation,{eins,zwei,drei},{}: argument list length must be exactly 1
294+
WARNING: error for publication relation,{eins,zwei,drei},{integer}: cross-database references are not implemented: "eins.zwei.drei"
286295
-- these object types cannot be qualified names
287296
SELECT pg_get_object_address('language', '{one}', '{}');
288297
ERROR: language "one" does not exist
@@ -330,6 +339,14 @@ SELECT pg_get_object_address('access method', '{one}', '{}');
330339
ERROR: access method "one" does not exist
331340
SELECT pg_get_object_address('access method', '{one,two}', '{}');
332341
ERROR: access method name cannot be qualified
342+
SELECT pg_get_object_address('publication', '{one}', '{}');
343+
ERROR: publication "one" does not exist
344+
SELECT pg_get_object_address('publication', '{one,two}', '{}');
345+
ERROR: publication name cannot be qualified
346+
SELECT pg_get_object_address('subscription', '{one}', '{}');
347+
ERROR: subscription "one" does not exist
348+
SELECT pg_get_object_address('subscription', '{one,two}', '{}');
349+
ERROR: subscription name cannot be qualified
333350
-- test successful cases
334351
WITH objects (type, name, args) AS (VALUES
335352
('table', '{addr_nsp, gentable}'::text[], '{}'::text[]),
@@ -379,7 +396,10 @@ WITH objects (type, name, args) AS (VALUES
379396
-- event trigger
380397
('policy', '{addr_nsp, gentable, genpol}', '{}'),
381398
('transform', '{int}', '{sql}'),
382-
('access method', '{btree}', '{}')
399+
('access method', '{btree}', '{}'),
400+
('publication', '{addr_pub}', '{}'),
401+
('publication relation', '{addr_nsp, gentable}', '{addr_pub}'),
402+
('subscription', '{addr_sub}', '{}')
383403
)
384404
SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.subobjid)).*,
385405
-- test roundtrip through pg_identify_object_as_address
@@ -433,13 +453,18 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.subobjid)).*,
433453
text search parser | addr_nsp | addr_ts_prs | addr_nsp.addr_ts_prs | t
434454
text search configuration | addr_nsp | addr_ts_conf | addr_nsp.addr_ts_conf | t
435455
text search template | addr_nsp | addr_ts_temp | addr_nsp.addr_ts_temp | t
436-
(42 rows)
456+
subscription | | addr_sub | addr_sub | t
457+
publication | | addr_pub | addr_pub | t
458+
publication relation | | | gentable in publication addr_pub | t
459+
(45 rows)
437460

438461
---
439462
--- Cleanup resources
440463
---
441464
SET client_min_messages TO 'warning';
442465
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
466+
DROP PUBLICATION addr_pub;
467+
DROP SUBSCRIPTION addr_sub NODROP SLOT;
443468
DROP SCHEMA addr_nsp CASCADE;
444469
DROP OWNED BY regress_addr_user;
445470
DROP USER regress_addr_user;

‎src/test/regress/sql/object_address.sql

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM
3939
CREATE TRANSFORM FORint LANGUAGE SQL (
4040
FROM SQL WITH FUNCTION varchar_transform(internal),
4141
TO SQL WITH FUNCTION int4recv(internal));
42+
CREATE PUBLICATION addr_pub FOR TABLEaddr_nsp.gentable;
43+
CREATE SUBSCRIPTION addr_sub CONNECTION'' PUBLICATION bar WITH (DISABLED, NOCREATE SLOT);
4244

4345
-- test some error cases
4446
SELECT pg_get_object_address('stone','{}','{}');
@@ -78,7 +80,8 @@ BEGIN
7880
('text search parser'), ('text search dictionary'),
7981
('text search template'), ('text search configuration'),
8082
('policy'), ('user mapping'), ('default acl'), ('transform'),
81-
('operator of access method'), ('function of access method')
83+
('operator of access method'), ('function of access method'),
84+
('publication relation')
8285
LOOP
8386
FOR namesINVALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
8487
LOOP
@@ -119,6 +122,10 @@ SELECT pg_get_object_address('event trigger', '{one}', '{}');
119122
SELECT pg_get_object_address('event trigger','{one,two}','{}');
120123
SELECT pg_get_object_address('access method','{one}','{}');
121124
SELECT pg_get_object_address('access method','{one,two}','{}');
125+
SELECT pg_get_object_address('publication','{one}','{}');
126+
SELECT pg_get_object_address('publication','{one,two}','{}');
127+
SELECT pg_get_object_address('subscription','{one}','{}');
128+
SELECT pg_get_object_address('subscription','{one,two}','{}');
122129

123130
-- test successful cases
124131
WITH objects (type, name, args)AS (VALUES
@@ -169,7 +176,10 @@ WITH objects (type, name, args) AS (VALUES
169176
-- event trigger
170177
('policy','{addr_nsp, gentable, genpol}','{}'),
171178
('transform','{int}','{sql}'),
172-
('access method','{btree}','{}')
179+
('access method','{btree}','{}'),
180+
('publication','{addr_pub}','{}'),
181+
('publication relation','{addr_nsp, gentable}','{addr_pub}'),
182+
('subscription','{addr_sub}','{}')
173183
)
174184
SELECT (pg_identify_object(addr1.classid,addr1.objid,addr1.subobjid)).*,
175185
-- test roundtrip through pg_identify_object_as_address
@@ -186,6 +196,8 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.subobjid)).*,
186196
SET client_min_messages TO'warning';
187197

188198
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
199+
DROP PUBLICATION addr_pub;
200+
DROP SUBSCRIPTION addr_sub NODROP SLOT;
189201

190202
DROPSCHEMA addr_nsp CASCADE;
191203

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp