@@ -17,10 +17,11 @@ CREATE TEXT SEARCH TEMPLATE addr_ts_temp (lexize=dsimple_lexize);
17
17
CREATE TEXT SEARCH PARSER addr_ts_prs
18
18
(start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype);
19
19
CREATE TABLE addr_nsp.gentable (
20
- a serial primary key CONSTRAINT a_chk CHECK (a > 0),
21
- b text DEFAULT 'hello');
20
+ a serial primary key CONSTRAINT a_chk CHECK (a > 0),
21
+ b text DEFAULT 'hello'
22
+ );
22
23
CREATE TABLE addr_nsp.parttable (
23
- a int PRIMARY KEY
24
+ a int PRIMARY KEY
24
25
) PARTITION BY RANGE (a);
25
26
CREATE VIEW addr_nsp.genview AS SELECT * from addr_nsp.gentable;
26
27
CREATE MATERIALIZED VIEW addr_nsp.genmatview AS SELECT * FROM addr_nsp.gentable;
@@ -40,8 +41,8 @@ ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM
40
41
-- this transform would be quite unsafe to leave lying around,
41
42
-- except that the SQL language pays no attention to transforms:
42
43
CREATE TRANSFORM FOR int LANGUAGE SQL (
43
- FROM SQL WITH FUNCTION prsd_lextype(internal),
44
- TO SQL WITH FUNCTION int4recv(internal));
44
+ FROM SQL WITH FUNCTION prsd_lextype(internal),
45
+ TO SQL WITH FUNCTION int4recv(internal));
45
46
-- suppress warning that depends on wal_level
46
47
SET client_min_messages = 'ERROR';
47
48
CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable;
@@ -61,17 +62,17 @@ ERROR: name or argument lists may not contain nulls
61
62
-- unrecognized object types
62
63
DO $$
63
64
DECLARE
64
- objtype text;
65
+ objtype text;
65
66
BEGIN
66
- FOR objtype IN VALUES ('toast table'), ('index column'), ('sequence column'),
67
- ('toast table column'), ('view column'), ('materialized view column')
68
- LOOP
69
- BEGIN
70
- PERFORM pg_get_object_address(objtype, '{one}', '{}');
71
- EXCEPTION WHEN invalid_parameter_value THEN
72
- RAISE WARNING 'error for %: %', objtype, sqlerrm;
73
- END;
74
- END LOOP;
67
+ FOR objtype IN VALUES ('toast table'), ('index column'), ('sequence column'),
68
+ ('toast table column'), ('view column'), ('materialized view column')
69
+ LOOP
70
+ BEGIN
71
+ PERFORM pg_get_object_address(objtype, '{one}', '{}');
72
+ EXCEPTION WHEN invalid_parameter_value THEN
73
+ RAISE WARNING 'error for %: %', objtype, sqlerrm;
74
+ END;
75
+ END LOOP;
75
76
END;
76
77
$$;
77
78
WARNING: error for toast table: unsupported object type "toast table"
@@ -91,35 +92,35 @@ select * from pg_get_object_address('function of access method', '{btree,integer
91
92
ERROR: function 99 (int4, int4) of operator family integer_ops for access method btree does not exist
92
93
DO $$
93
94
DECLARE
94
- objtype text;
95
- names text[];
96
- args text[];
95
+ objtype text;
96
+ names text[];
97
+ args text[];
97
98
BEGIN
98
- FOR objtype IN VALUES
99
- ('table'), ('index'), ('sequence'), ('view'),
100
- ('materialized view'), ('foreign table'),
101
- ('table column'), ('foreign table column'),
102
- ('aggregate'), ('function'), ('procedure'), ('type'), ('cast'),
103
- ('table constraint'), ('domain constraint'), ('conversion'), ('default value'),
104
- ('operator'), ('operator class'), ('operator family'), ('rule'), ('trigger'),
105
- ('text search parser'), ('text search dictionary'),
106
- ('text search template'), ('text search configuration'),
107
- ('policy'), ('user mapping'), ('default acl'), ('transform'),
108
- ('operator of access method'), ('function of access method'),
109
- ('publication namespace'), ('publication relation')
110
- LOOP
111
- FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
112
- LOOP
113
- FOR args IN VALUES ('{}'), ('{integer}')
114
- LOOP
115
- BEGIN
116
- PERFORM pg_get_object_address(objtype, names, args);
117
- EXCEPTION WHEN OTHERS THEN
118
- RAISE WARNING 'error for %,%,%: %', objtype, names, args, sqlerrm;
119
- END;
120
- END LOOP;
121
- END LOOP;
122
- END LOOP;
99
+ FOR objtype IN VALUES
100
+ ('table'), ('index'), ('sequence'), ('view'),
101
+ ('materialized view'), ('foreign table'),
102
+ ('table column'), ('foreign table column'),
103
+ ('aggregate'), ('function'), ('procedure'), ('type'), ('cast'),
104
+ ('table constraint'), ('domain constraint'), ('conversion'), ('default value'),
105
+ ('operator'), ('operator class'), ('operator family'), ('rule'), ('trigger'),
106
+ ('text search parser'), ('text search dictionary'),
107
+ ('text search template'), ('text search configuration'),
108
+ ('policy'), ('user mapping'), ('default acl'), ('transform'),
109
+ ('operator of access method'), ('function of access method'),
110
+ ('publication namespace'), ('publication relation')
111
+ LOOP
112
+ FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
113
+ LOOP
114
+ FOR args IN VALUES ('{}'), ('{integer}')
115
+ LOOP
116
+ BEGIN
117
+ PERFORM pg_get_object_address(objtype, names, args);
118
+ EXCEPTION WHEN OTHERS THEN
119
+ RAISE WARNING 'error for %,%,%: %', objtype, names, args, sqlerrm;
120
+ END;
121
+ END LOOP;
122
+ END LOOP;
123
+ END LOOP;
123
124
END;
124
125
$$;
125
126
WARNING: error for table,{eins},{}: relation "eins" does not exist
@@ -383,73 +384,74 @@ SELECT pg_get_object_address('subscription', '{one,two}', '{}');
383
384
ERROR: name list length must be exactly 1
384
385
-- test successful cases
385
386
WITH objects (type, name, args) AS (VALUES
386
- ('table', '{addr_nsp, gentable}'::text[], '{}'::text[]),
387
- ('table', '{addr_nsp, parttable}'::text[], '{}'::text[]),
388
- ('index', '{addr_nsp, gentable_pkey}', '{}'),
389
- ('index', '{addr_nsp, parttable_pkey}', '{}'),
390
- ('sequence', '{addr_nsp, gentable_a_seq}', '{}'),
391
- -- toast table
392
- ('view', '{addr_nsp, genview}', '{}'),
393
- ('materialized view', '{addr_nsp, genmatview}', '{}'),
394
- ('foreign table', '{addr_nsp, genftable}', '{}'),
395
- ('table column', '{addr_nsp, gentable, b}', '{}'),
396
- ('foreign table column', '{addr_nsp, genftable, a}', '{}'),
397
- ('aggregate', '{addr_nsp, genaggr}', '{int4}'),
398
- ('function', '{pg_catalog, pg_identify_object}', '{pg_catalog.oid, pg_catalog.oid, int4}'),
399
- ('procedure', '{addr_nsp, proc}', '{int4}'),
400
- ('type', '{pg_catalog._int4}', '{}'),
401
- ('type', '{addr_nsp.gendomain}', '{}'),
402
- ('type', '{addr_nsp.gencomptype}', '{}'),
403
- ('type', '{addr_nsp.genenum}', '{}'),
404
- ('cast', '{int8}', '{int4}'),
405
- ('collation', '{default}', '{}'),
406
- ('table constraint', '{addr_nsp, gentable, a_chk}', '{}'),
407
- ('domain constraint', '{addr_nsp.gendomain}', '{domconstr}'),
408
- ('conversion', '{pg_catalog, koi8_r_to_mic}', '{}'),
409
- ('default value', '{addr_nsp, gentable, b}', '{}'),
410
- ('language', '{plpgsql}', '{}'),
411
- -- large object
412
- ('operator', '{+}', '{int4, int4}'),
413
- ('operator class', '{btree, int4_ops}', '{}'),
414
- ('operator family', '{btree, integer_ops}', '{}'),
415
- ('operator of access method', '{btree,integer_ops,1}', '{integer,integer}'),
416
- ('function of access method', '{btree,integer_ops,2}', '{integer,integer}'),
417
- ('rule', '{addr_nsp, genview, _RETURN}', '{}'),
418
- ('trigger', '{addr_nsp, gentable, t}', '{}'),
419
- ('schema', '{addr_nsp}', '{}'),
420
- ('text search parser', '{addr_ts_prs}', '{}'),
421
- ('text search dictionary', '{addr_ts_dict}', '{}'),
422
- ('text search template', '{addr_ts_temp}', '{}'),
423
- ('text search configuration', '{addr_ts_conf}', '{}'),
424
- ('role', '{regress_addr_user}', '{}'),
425
- -- database
426
- -- tablespace
427
- ('foreign-data wrapper', '{addr_fdw}', '{}'),
428
- ('server', '{addr_fserv}', '{}'),
429
- ('user mapping', '{regress_addr_user}', '{integer}'),
430
- ('default acl', '{regress_addr_user,public}', '{r}'),
431
- ('default acl', '{regress_addr_user}', '{r}'),
432
- -- extension
433
- -- event trigger
434
- ('policy', '{addr_nsp, gentable, genpol}', '{}'),
435
- ('transform', '{int}', '{sql}'),
436
- ('access method', '{btree}', '{}'),
437
- ('publication', '{addr_pub}', '{}'),
438
- ('publication namespace', '{addr_nsp}', '{addr_pub_schema}'),
439
- ('publication relation', '{addr_nsp, gentable}', '{addr_pub}'),
440
- ('subscription', '{regress_addr_sub}', '{}'),
441
- ('statistics object', '{addr_nsp, gentable_stat}', '{}')
442
- )
387
+ ('table', '{addr_nsp, gentable}'::text[], '{}'::text[]),
388
+ ('table', '{addr_nsp, parttable}'::text[], '{}'::text[]),
389
+ ('index', '{addr_nsp, gentable_pkey}', '{}'),
390
+ ('index', '{addr_nsp, parttable_pkey}', '{}'),
391
+ ('sequence', '{addr_nsp, gentable_a_seq}', '{}'),
392
+ -- toast table
393
+ ('view', '{addr_nsp, genview}', '{}'),
394
+ ('materialized view', '{addr_nsp, genmatview}', '{}'),
395
+ ('foreign table', '{addr_nsp, genftable}', '{}'),
396
+ ('table column', '{addr_nsp, gentable, b}', '{}'),
397
+ ('foreign table column', '{addr_nsp, genftable, a}', '{}'),
398
+ ('aggregate', '{addr_nsp, genaggr}', '{int4}'),
399
+ ('function', '{pg_catalog, pg_identify_object}', '{pg_catalog.oid, pg_catalog.oid, int4}'),
400
+ ('procedure', '{addr_nsp, proc}', '{int4}'),
401
+ ('type', '{pg_catalog._int4}', '{}'),
402
+ ('type', '{addr_nsp.gendomain}', '{}'),
403
+ ('type', '{addr_nsp.gencomptype}', '{}'),
404
+ ('type', '{addr_nsp.genenum}', '{}'),
405
+ ('cast', '{int8}', '{int4}'),
406
+ ('collation', '{default}', '{}'),
407
+ ('table constraint', '{addr_nsp, gentable, a_chk}', '{}'),
408
+ ('domain constraint', '{addr_nsp.gendomain}', '{domconstr}'),
409
+ ('conversion', '{pg_catalog, koi8_r_to_mic}', '{}'),
410
+ ('default value', '{addr_nsp, gentable, b}', '{}'),
411
+ ('language', '{plpgsql}', '{}'),
412
+ -- large object
413
+ ('operator', '{+}', '{int4, int4}'),
414
+ ('operator class', '{btree, int4_ops}', '{}'),
415
+ ('operator family', '{btree, integer_ops}', '{}'),
416
+ ('operator of access method', '{btree,integer_ops,1}', '{integer,integer}'),
417
+ ('function of access method', '{btree,integer_ops,2}', '{integer,integer}'),
418
+ ('rule', '{addr_nsp, genview, _RETURN}', '{}'),
419
+ ('trigger', '{addr_nsp, gentable, t}', '{}'),
420
+ ('schema', '{addr_nsp}', '{}'),
421
+ ('text search parser', '{addr_ts_prs}', '{}'),
422
+ ('text search dictionary', '{addr_ts_dict}', '{}'),
423
+ ('text search template', '{addr_ts_temp}', '{}'),
424
+ ('text search configuration', '{addr_ts_conf}', '{}'),
425
+ ('role', '{regress_addr_user}', '{}'),
426
+ -- database
427
+ -- tablespace
428
+ ('foreign-data wrapper', '{addr_fdw}', '{}'),
429
+ ('server', '{addr_fserv}', '{}'),
430
+ ('user mapping', '{regress_addr_user}', '{integer}'),
431
+ ('default acl', '{regress_addr_user,public}', '{r}'),
432
+ ('default acl', '{regress_addr_user}', '{r}'),
433
+ -- extension
434
+ -- event trigger
435
+ ('policy', '{addr_nsp, gentable, genpol}', '{}'),
436
+ ('transform', '{int}', '{sql}'),
437
+ ('access method', '{btree}', '{}'),
438
+ ('publication', '{addr_pub}', '{}'),
439
+ ('publication namespace', '{addr_nsp}', '{addr_pub_schema}'),
440
+ ('publication relation', '{addr_nsp, gentable}', '{addr_pub}'),
441
+ ('subscription', '{regress_addr_sub}', '{}'),
442
+ ('statistics object', '{addr_nsp, gentable_stat}', '{}')
443
+ )
443
444
SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
444
- -- test roundtrip through pg_identify_object_as_address
445
- ROW(pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)) =
446
- ROW(pg_identify_object(addr2.classid, addr2.objid, addr2.objsubid))
447
- FROM objects, pg_get_object_address(type, name, args) addr1,
448
- pg_identify_object_as_address(classid, objid, objsubid) ioa(typ,nms,args),
449
- pg_get_object_address(typ, nms, ioa.args) as addr2
450
- ORDER BY addr1.classid, addr1.objid, addr1.objsubid;
451
- type | schema | name | identity | ?column?
452
- ---------------------------+------------+-------------------+----------------------------------------------------------------------+----------
445
+ -- test roundtrip through pg_identify_object_as_address
446
+ ROW(pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)) =
447
+ ROW(pg_identify_object(addr2.classid, addr2.objid, addr2.objsubid)) AS roundtrip
448
+ FROM objects,
449
+ pg_get_object_address(type, name, args) AS addr1,
450
+ pg_identify_object_as_address(classid, objid, objsubid) AS ioa (typ, nms, args),
451
+ pg_get_object_address(typ, nms, ioa.args) AS addr2
452
+ ORDER BY addr1.classid, addr1.objid, addr1.objsubid;
453
+ type | schema | name | identity | roundtrip
454
+ ---------------------------+------------+-------------------+----------------------------------------------------------------------+-----------
453
455
default acl | | | for role regress_addr_user in schema public on tables | t
454
456
default acl | | | for role regress_addr_user on tables | t
455
457
type | pg_catalog | _int4 | integer[] | t
0 commit comments