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

Commitea0d494

Browse files
committed
Make the to_reg*() functions accept text not cstring.
Using cstring as the input type was a poor decision, because that's notreally a full-fledged type. In particular, it lacks implicit coercionsfrom text or varchar, meaning that usages like to_regproc('foo'||'bar')wouldn't work; basically the only case that did work without explicitcasting was a simple literal constant argument.The lack of field complaints about this suggests that hardly anyoneis using these functions, so hopefully fixing it won't cause much ofa compatibility problem. They've only been there since 9.4, anyway.Petr Korobeinikov
1 parentefa318b commitea0d494

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16173,7 +16173,7 @@ SELECT collation for ('foo' COLLATE "de_DE");
1617316173
<function>to_regoperator</function>, <function>to_regtype</function>,
1617416174
<function>to_regnamespace</function>, and <function>to_regrole</function>
1617516175
functions translate relation, function, operator, type, schema, and role
16176-
names to objects of
16176+
names(given as <type>text</>)to objects of
1617716177
type <type>regclass</>, <type>regproc</>, <type>regprocedure</type>,
1617816178
<type>regoper</>, <type>regoperator</type>, <type>regtype</>,
1617916179
<type>regnamespace</>, and <type>regrole</>

‎src/backend/utils/adt/regproc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ regprocin(PG_FUNCTION_ARGS)
161161
Datum
162162
to_regproc(PG_FUNCTION_ARGS)
163163
{
164-
char*pro_name=PG_GETARG_CSTRING(0);
164+
char*pro_name=text_to_cstring(PG_GETARG_TEXT_PP(0));
165165
List*names;
166166
FuncCandidateListclist;
167167

@@ -331,7 +331,7 @@ regprocedurein(PG_FUNCTION_ARGS)
331331
Datum
332332
to_regprocedure(PG_FUNCTION_ARGS)
333333
{
334-
char*pro_name=PG_GETARG_CSTRING(0);
334+
char*pro_name=text_to_cstring(PG_GETARG_TEXT_PP(0));
335335
List*names;
336336
intnargs;
337337
Oidargtypes[FUNC_MAX_ARGS];
@@ -620,7 +620,7 @@ regoperin(PG_FUNCTION_ARGS)
620620
Datum
621621
to_regoper(PG_FUNCTION_ARGS)
622622
{
623-
char*opr_name=PG_GETARG_CSTRING(0);
623+
char*opr_name=text_to_cstring(PG_GETARG_TEXT_PP(0));
624624
List*names;
625625
FuncCandidateListclist;
626626

@@ -797,7 +797,7 @@ regoperatorin(PG_FUNCTION_ARGS)
797797
Datum
798798
to_regoperator(PG_FUNCTION_ARGS)
799799
{
800-
char*opr_name_or_oid=PG_GETARG_CSTRING(0);
800+
char*opr_name_or_oid=text_to_cstring(PG_GETARG_TEXT_PP(0));
801801
Oidresult;
802802
List*names;
803803
intnargs;
@@ -1061,7 +1061,7 @@ regclassin(PG_FUNCTION_ARGS)
10611061
Datum
10621062
to_regclass(PG_FUNCTION_ARGS)
10631063
{
1064-
char*class_name=PG_GETARG_CSTRING(0);
1064+
char*class_name=text_to_cstring(PG_GETARG_TEXT_PP(0));
10651065
Oidresult;
10661066
List*names;
10671067

@@ -1249,7 +1249,7 @@ regtypein(PG_FUNCTION_ARGS)
12491249
Datum
12501250
to_regtype(PG_FUNCTION_ARGS)
12511251
{
1252-
char*typ_name=PG_GETARG_CSTRING(0);
1252+
char*typ_name=text_to_cstring(PG_GETARG_TEXT_PP(0));
12531253
Oidresult;
12541254
int32typmod;
12551255

@@ -1606,7 +1606,7 @@ regrolein(PG_FUNCTION_ARGS)
16061606
Datum
16071607
to_regrole(PG_FUNCTION_ARGS)
16081608
{
1609-
char*role_name=PG_GETARG_CSTRING(0);
1609+
char*role_name=text_to_cstring(PG_GETARG_TEXT_PP(0));
16101610
Oidresult;
16111611
List*names;
16121612

@@ -1727,7 +1727,7 @@ regnamespacein(PG_FUNCTION_ARGS)
17271727
Datum
17281728
to_regnamespace(PG_FUNCTION_ARGS)
17291729
{
1730-
char*nsp_name=PG_GETARG_CSTRING(0);
1730+
char*nsp_name=text_to_cstring(PG_GETARG_TEXT_PP(0));
17311731
Oidresult;
17321732
List*names;
17331733

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201601041
56+
#defineCATALOG_VERSION_NO201601051
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ DATA(insert OID = 44 ( regprocin PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1
177177
DESCR("I/O");
178178
DATA(insert OID = 45 ( regprocout PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2275 "24" _null_ _null_ _null_ _null_ _null_ regprocout _null_ _null_ _null_ ));
179179
DESCR("I/O");
180-
DATA(insert OID = 3494 ( to_regprocPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 24 "2275" _null_ _null_ _null_ _null_ _null_ to_regproc _null_ _null_ _null_ ));
180+
DATA(insert OID = 3494 ( to_regprocPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 24 "25" _null_ _null_ _null_ _null_ _null_ to_regproc _null_ _null_ _null_ ));
181181
DESCR("convert proname to regproc");
182-
DATA(insert OID = 3479 ( to_regprocedurePGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2202 "2275" _null_ _null_ _null_ _null_ _null_ to_regprocedure _null_ _null_ _null_ ));
182+
DATA(insert OID = 3479 ( to_regprocedurePGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2202 "25" _null_ _null_ _null_ _null_ _null_ to_regprocedure _null_ _null_ _null_ ));
183183
DESCR("convert proname to regprocedure");
184184
DATA(insert OID = 46 ( textin PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 25 "2275" _null_ _null_ _null_ _null_ _null_ textin _null_ _null_ _null_ ));
185185
DESCR("I/O");
@@ -3483,9 +3483,9 @@ DATA(insert OID = 2214 ( regoperinPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0
34833483
DESCR("I/O");
34843484
DATA(insert OID = 2215 ( regoperoutPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2275 "2203" _null_ _null_ _null_ _null_ _null_ regoperout _null_ _null_ _null_ ));
34853485
DESCR("I/O");
3486-
DATA(insert OID = 3492 ( to_regoperPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2203 "2275" _null_ _null_ _null_ _null_ _null_ to_regoper _null_ _null_ _null_ ));
3486+
DATA(insert OID = 3492 ( to_regoperPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2203 "25" _null_ _null_ _null_ _null_ _null_ to_regoper _null_ _null_ _null_ ));
34873487
DESCR("convert operator name to regoper");
3488-
DATA(insert OID = 3476 ( to_regoperatorPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2204 "2275" _null_ _null_ _null_ _null_ _null_ to_regoperator _null_ _null_ _null_ ));
3488+
DATA(insert OID = 3476 ( to_regoperatorPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2204 "25" _null_ _null_ _null_ _null_ _null_ to_regoperator _null_ _null_ _null_ ));
34893489
DESCR("convert operator name to regoperator");
34903490
DATA(insert OID = 2216 ( regoperatorinPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2204 "2275" _null_ _null_ _null_ _null_ _null_ regoperatorin _null_ _null_ _null_ ));
34913491
DESCR("I/O");
@@ -3495,13 +3495,13 @@ DATA(insert OID = 2218 ( regclassinPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0
34953495
DESCR("I/O");
34963496
DATA(insert OID = 2219 ( regclassoutPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2275 "2205" _null_ _null_ _null_ _null_ _null_ regclassout _null_ _null_ _null_ ));
34973497
DESCR("I/O");
3498-
DATA(insert OID = 3495 ( to_regclassPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2205 "2275" _null_ _null_ _null_ _null_ _null_ to_regclass _null_ _null_ _null_ ));
3498+
DATA(insert OID = 3495 ( to_regclassPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2205 "25" _null_ _null_ _null_ _null_ _null_ to_regclass _null_ _null_ _null_ ));
34993499
DESCR("convert classname to regclass");
35003500
DATA(insert OID = 2220 ( regtypeinPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2206 "2275" _null_ _null_ _null_ _null_ _null_ regtypein _null_ _null_ _null_ ));
35013501
DESCR("I/O");
35023502
DATA(insert OID = 2221 ( regtypeoutPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2275 "2206" _null_ _null_ _null_ _null_ _null_ regtypeout _null_ _null_ _null_ ));
35033503
DESCR("I/O");
3504-
DATA(insert OID = 3493 ( to_regtypePGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2206 "2275" _null_ _null_ _null_ _null_ _null_ to_regtype _null_ _null_ _null_ ));
3504+
DATA(insert OID = 3493 ( to_regtypePGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2206 "25" _null_ _null_ _null_ _null_ _null_ to_regtype _null_ _null_ _null_ ));
35053505
DESCR("convert type name to regtype");
35063506
DATA(insert OID = 1079 ( regclassPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2205 "25" _null_ _null_ _null_ _null_ _null_text_regclass _null_ _null_ _null_ ));
35073507
DESCR("convert text to regclass");
@@ -3510,14 +3510,14 @@ DATA(insert OID = 4098 ( regroleinPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0
35103510
DESCR("I/O");
35113511
DATA(insert OID = 4092 ( regroleoutPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2275 "4096" _null_ _null_ _null_ _null_ _null_ regroleout _null_ _null_ _null_ ));
35123512
DESCR("I/O");
3513-
DATA(insert OID = 4093 ( to_regrolePGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 4096 "2275" _null_ _null_ _null_ _null_ _null_ to_regrole _null_ _null_ _null_ ));
3513+
DATA(insert OID = 4093 ( to_regrolePGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 4096 "25" _null_ _null_ _null_ _null_ _null_ to_regrole _null_ _null_ _null_ ));
35143514
DESCR("convert role name to regrole");
35153515

35163516
DATA(insert OID = 4084 ( regnamespaceinPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 4089 "2275" _null_ _null_ _null_ _null_ _null_ regnamespacein _null_ _null_ _null_ ));
35173517
DESCR("I/O");
35183518
DATA(insert OID = 4085 ( regnamespaceoutPGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2275 "4089" _null_ _null_ _null_ _null_ _null_ regnamespaceout _null_ _null_ _null_ ));
35193519
DESCR("I/O");
3520-
DATA(insert OID = 4086 ( to_regnamespacePGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 4089 "2275" _null_ _null_ _null_ _null_ _null_ to_regnamespace _null_ _null_ _null_ ));
3520+
DATA(insert OID = 4086 ( to_regnamespacePGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 4089 "25" _null_ _null_ _null_ _null_ _null_ to_regnamespace _null_ _null_ _null_ ));
35213521
DESCR("convert namespace name to regnamespace");
35223522

35233523
DATA(insert OID = 2246 ( fmgr_internal_validator PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2278 "26" _null_ _null_ _null_ _null_ _null_ fmgr_internal_validator _null_ _null_ _null_ ));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp