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

Commita3eac98

Browse files
committed
Fix ancient get_object_address_opf_member bug
The original coding was trying to use a TypeName as a string Value,which doesn't work; an oversight in my commita61fd53. Repair.Also, make sure we cover the broken case in the relevant test script.Backpatch to 9.5.Discussion:https://postgr.es/m/20170315151829.bhxsvrp75xdxhm3n@alvherre.pgsql
1 parentcccbdde commita3eac98

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

‎src/backend/catalog/objectaddress.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ get_object_address_opf_member(ObjectType objtype,
15521552
ObjectAddressaddress;
15531553
ListCell*cell;
15541554
List*copy;
1555-
char*typenames[2];
1555+
TypeName*typenames[2];
15561556
Oidtypeoids[2];
15571557
intmembernum;
15581558
inti;
@@ -1574,8 +1574,8 @@ get_object_address_opf_member(ObjectType objtype,
15741574
{
15751575
ObjectAddresstypaddr;
15761576

1577-
typenames[i]=strVal(lfirst(cell));
1578-
typaddr=get_object_address_type(OBJECT_TYPE,castNode(TypeName,lfirst(cell)),missing_ok);
1577+
typenames[i]=castNode(TypeName,lfirst(cell));
1578+
typaddr=get_object_address_type(OBJECT_TYPE,typenames[i],missing_ok);
15791579
typeoids[i]=typaddr.objectId;
15801580
if (++i >=2)
15811581
break;
@@ -1601,7 +1601,9 @@ get_object_address_opf_member(ObjectType objtype,
16011601
ereport(ERROR,
16021602
(errcode(ERRCODE_UNDEFINED_OBJECT),
16031603
errmsg("operator %d (%s, %s) of %s does not exist",
1604-
membernum,typenames[0],typenames[1],
1604+
membernum,
1605+
TypeNameToString(typenames[0]),
1606+
TypeNameToString(typenames[1]),
16051607
getObjectDescription(&famaddr))));
16061608
}
16071609
else
@@ -1630,7 +1632,9 @@ get_object_address_opf_member(ObjectType objtype,
16301632
ereport(ERROR,
16311633
(errcode(ERRCODE_UNDEFINED_OBJECT),
16321634
errmsg("function %d (%s, %s) of %s does not exist",
1633-
membernum,typenames[0],typenames[1],
1635+
membernum,
1636+
TypeNameToString(typenames[0]),
1637+
TypeNameToString(typenames[1]),
16341638
getObjectDescription(&famaddr))));
16351639
}
16361640
else
@@ -2023,7 +2027,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
20232027
}
20242028

20252029
/*
2026-
*get_object_name is pretty sensitive to the length its input lists;
2030+
*get_object_address is pretty sensitive to the length its input lists;
20272031
* check that they're what it wants.
20282032
*/
20292033
switch (type)
@@ -2064,7 +2068,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
20642068
}
20652069

20662070
/*
2067-
* Now build the Node type thatget_object_name() expects for the given
2071+
* Now build the Node type thatget_object_address() expects for the given
20682072
* type.
20692073
*/
20702074
switch (type)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ WARNING: error for sequence column: unsupported object type "sequence column"
6767
WARNING: error for toast table column: unsupported object type "toast table column"
6868
WARNING: error for view column: unsupported object type "view column"
6969
WARNING: error for materialized view column: unsupported object type "materialized view column"
70+
-- miscellaneous other errors
71+
select * from pg_get_object_address('operator of access method', '{btree,integer_ops,1}', '{int4,bool}');
72+
ERROR: operator 1 (int4, bool) of operator family integer_ops for access method btree does not exist
73+
select * from pg_get_object_address('operator of access method', '{btree,integer_ops,99}', '{int4,int4}');
74+
ERROR: operator 99 (int4, int4) of operator family integer_ops for access method btree does not exist
75+
select * from pg_get_object_address('function of access method', '{btree,integer_ops,1}', '{int4,bool}');
76+
ERROR: function 1 (int4, bool) of operator family integer_ops for access method btree does not exist
77+
select * from pg_get_object_address('function of access method', '{btree,integer_ops,99}', '{int4,int4}');
78+
ERROR: function 99 (int4, int4) of operator family integer_ops for access method btree does not exist
7079
DO $$
7180
DECLARE
7281
objtype text;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ BEGIN
6464
END;
6565
$$;
6666

67+
-- miscellaneous other errors
68+
select*from pg_get_object_address('operator of access method','{btree,integer_ops,1}','{int4,bool}');
69+
select*from pg_get_object_address('operator of access method','{btree,integer_ops,99}','{int4,int4}');
70+
select*from pg_get_object_address('function of access method','{btree,integer_ops,1}','{int4,bool}');
71+
select*from pg_get_object_address('function of access method','{btree,integer_ops,99}','{int4,int4}');
72+
6773
DO $$
6874
DECLARE
6975
objtypetext;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp