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

Commit2da8c4c

Browse files
committed
Tighten pg_get_object_address argument checking
For publication schemas (OBJECT_PUBLICATION_NAMESPACE) and usermappings (OBJECT_USER_MAPPING), pg_get_object_address() checked thearray length of the second argument, but not of the first argument.If the first argument was too long, it would just silently ignoreeverything but the first argument. Fix that by checking the length ofthe first argument as well.Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/caaef70b-a874-1088-92ef-5ac38269c33b%40enterprisedb.com
1 parent3d4e841 commit2da8c4c

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

‎src/backend/catalog/objectaddress.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,10 +2254,16 @@ pg_get_object_address(PG_FUNCTION_ARGS)
22542254
*/
22552255
switch (type)
22562256
{
2257+
caseOBJECT_PUBLICATION_NAMESPACE:
2258+
caseOBJECT_USER_MAPPING:
2259+
if (list_length(name)!=1)
2260+
ereport(ERROR,
2261+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2262+
errmsg("name list length must be exactly %d",1)));
2263+
/* fall through to check args length */
2264+
/* FALLTHROUGH */
22572265
caseOBJECT_DOMCONSTRAINT:
22582266
caseOBJECT_CAST:
2259-
caseOBJECT_USER_MAPPING:
2260-
caseOBJECT_PUBLICATION_NAMESPACE:
22612267
caseOBJECT_PUBLICATION_REL:
22622268
caseOBJECT_DEFACL:
22632269
caseOBJECT_TRANSFORM:

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ BEGIN
105105
('text search template'), ('text search configuration'),
106106
('policy'), ('user mapping'), ('default acl'), ('transform'),
107107
('operator of access method'), ('function of access method'),
108-
('publication relation')
108+
('publicationnamespace'), ('publicationrelation')
109109
LOOP
110110
FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
111111
LOOP
@@ -285,10 +285,10 @@ WARNING: error for policy,{eins,zwei,drei},{}: schema "eins" does not exist
285285
WARNING: error for policy,{eins,zwei,drei},{integer}: schema "eins" does not exist
286286
WARNING: error for user mapping,{eins},{}: argument list length must be exactly 1
287287
WARNING: error for user mapping,{eins},{integer}: user mapping for user "eins" on server "integer" does not exist
288-
WARNING: error for user mapping,{addr_nsp,zwei},{}:argument list length must be exactly 1
289-
WARNING: error for user mapping,{addr_nsp,zwei},{integer}:user mapping for user "addr_nsp" on server "integer" does not exist
290-
WARNING: error for user mapping,{eins,zwei,drei},{}:argument list length must be exactly 1
291-
WARNING: error for user mapping,{eins,zwei,drei},{integer}:user mapping for user "eins" on server "integer" does not exist
288+
WARNING: error for user mapping,{addr_nsp,zwei},{}:name list length must be exactly 1
289+
WARNING: error for user mapping,{addr_nsp,zwei},{integer}:name list length must be exactly 1
290+
WARNING: error for user mapping,{eins,zwei,drei},{}:name list length must be exactly 1
291+
WARNING: error for user mapping,{eins,zwei,drei},{integer}:name list length must be exactly 1
292292
WARNING: error for default acl,{eins},{}: argument list length must be exactly 1
293293
WARNING: error for default acl,{eins},{integer}: unrecognized default ACL object type "i"
294294
WARNING: error for default acl,{addr_nsp,zwei},{}: argument list length must be exactly 1
@@ -313,6 +313,12 @@ WARNING: error for function of access method,{addr_nsp,zwei},{}: name list leng
313313
WARNING: error for function of access method,{addr_nsp,zwei},{integer}: name list length must be at least 3
314314
WARNING: error for function of access method,{eins,zwei,drei},{}: argument list length must be exactly 2
315315
WARNING: error for function of access method,{eins,zwei,drei},{integer}: argument list length must be exactly 2
316+
WARNING: error for publication namespace,{eins},{}: argument list length must be exactly 1
317+
WARNING: error for publication namespace,{eins},{integer}: schema "eins" does not exist
318+
WARNING: error for publication namespace,{addr_nsp,zwei},{}: name list length must be exactly 1
319+
WARNING: error for publication namespace,{addr_nsp,zwei},{integer}: name list length must be exactly 1
320+
WARNING: error for publication namespace,{eins,zwei,drei},{}: name list length must be exactly 1
321+
WARNING: error for publication namespace,{eins,zwei,drei},{integer}: name list length must be exactly 1
316322
WARNING: error for publication relation,{eins},{}: argument list length must be exactly 1
317323
WARNING: error for publication relation,{eins},{integer}: relation "eins" does not exist
318324
WARNING: error for publication relation,{addr_nsp,zwei},{}: argument list length must be exactly 1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ BEGIN
9898
('text search template'), ('text search configuration'),
9999
('policy'), ('user mapping'), ('default acl'), ('transform'),
100100
('operator of access method'), ('function of access method'),
101-
('publication relation')
101+
('publicationnamespace'), ('publicationrelation')
102102
LOOP
103103
FOR namesINVALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}')
104104
LOOP

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp