pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Beginner hacker item: Fix to_reg*() input type
5+ messages / 3 participants
[nested] [flat]

* Beginner hacker item: Fix to_reg*() input type
@ 2016-01-04 20:46  Jim Nasby <Jim.Nasby@BlueTreble.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Jim Nasby @ 2016-01-04 20:46 UTC (permalink / raw)
  To: pgsql-hackers

All the to_reg* functions in src/backend/utils/adt/regproc.c currently 
accept a cstring. Per [1], they should accept text. This should be a 
fairly simple change to make:

- Modify the functions in regproc.c. Take a look at how other text input 
functions work to see what needs to happen here (you'll want to use 
text_to_cstring() as part of that.)

- Modify the appropriate entries in src/include/catalog/pg_proc.h

[1] http://www.postgresql.org/message-id/29618.1451882238@sss.pgh.pa.us. 
Note that I mistakenly referred to reg*in functions in that email; it's 
the to_reg* functions that need to change.
-- 
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Beginner hacker item: Fix to_reg*() input type
@ 2016-01-04 23:55  Petr Korobeinikov <pkorobeinikov@gmail.com>
  parent: Jim Nasby <Jim.Nasby@BlueTreble.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Petr Korobeinikov @ 2016-01-04 23:55 UTC (permalink / raw)
  To: Jim Nasby <Jim.Nasby@bluetreble.com>; +Cc: pgsql-hackers

> - Modify the functions in regproc.c. Take a look at how other text input
> functions work to see what needs to happen here (you'll want to use
> text_to_cstring() as part of that.)
>
> - Modify the appropriate entries in src/include/catalog/pg_proc.h

Let me try.
`make check` says "All 160 tests passed.".

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

pg_proc.diff (text/plain, 7.9K) download diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index 0f17eb8..eed1279 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -161,7 +161,7 @@ regprocin(PG_FUNCTION_ARGS) Datum to_regproc(PG_FUNCTION_ARGS) { - char *pro_name = PG_GETARG_CSTRING(0); + const char *pro_name = text_to_cstring(PG_GETARG_TEXT_P(0)); List *names; FuncCandidateList clist; @@ -331,7 +331,7 @@ regprocedurein(PG_FUNCTION_ARGS) Datum to_regprocedure(PG_FUNCTION_ARGS) { - char *pro_name = PG_GETARG_CSTRING(0); + const char *pro_name = text_to_cstring(PG_GETARG_TEXT_P(0)); List *names; int nargs; Oid argtypes[FUNC_MAX_ARGS]; @@ -620,7 +620,7 @@ regoperin(PG_FUNCTION_ARGS) Datum to_regoper(PG_FUNCTION_ARGS) { - char *opr_name = PG_GETARG_CSTRING(0); + const char *opr_name = text_to_cstring(PG_GETARG_TEXT_P(0)); List *names; FuncCandidateList clist; @@ -797,7 +797,7 @@ regoperatorin(PG_FUNCTION_ARGS) Datum to_regoperator(PG_FUNCTION_ARGS) { - char *opr_name_or_oid = PG_GETARG_CSTRING(0); + const char *opr_name_or_oid = text_to_cstring(PG_GETARG_TEXT_P(0)); Oid result; List *names; int nargs; @@ -1061,7 +1061,7 @@ regclassin(PG_FUNCTION_ARGS) Datum to_regclass(PG_FUNCTION_ARGS) { - char *class_name = PG_GETARG_CSTRING(0); + const char *class_name = text_to_cstring(PG_GETARG_TEXT_P(0)); Oid result; List *names; @@ -1249,7 +1249,7 @@ regtypein(PG_FUNCTION_ARGS) Datum to_regtype(PG_FUNCTION_ARGS) { - char *typ_name = PG_GETARG_CSTRING(0); + const char *typ_name = text_to_cstring(PG_GETARG_TEXT_P(0)); Oid result; int32 typmod; @@ -1606,7 +1606,7 @@ regrolein(PG_FUNCTION_ARGS) Datum to_regrole(PG_FUNCTION_ARGS) { - char *role_name = PG_GETARG_CSTRING(0); + const char *role_name = text_to_cstring(PG_GETARG_TEXT_P(0)); Oid result; List *names; @@ -1727,7 +1727,7 @@ regnamespacein(PG_FUNCTION_ARGS) Datum to_regnamespace(PG_FUNCTION_ARGS) { - char *nsp_name = PG_GETARG_CSTRING(0); + const char *nsp_name = text_to_cstring(PG_GETARG_TEXT_P(0)); Oid result; List *names; diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index e5d6c77..22d9386 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -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 DESCR("I/O"); 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_ )); DESCR("I/O"); -DATA(insert OID = 3494 ( to_regproc PGNSP 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_ )); +DATA(insert OID = 3494 ( to_regproc PGNSP 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_ )); DESCR("convert proname to regproc"); -DATA(insert OID = 3479 ( to_regprocedure PGNSP 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_ )); +DATA(insert OID = 3479 ( to_regprocedure PGNSP 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_ )); DESCR("convert proname to regprocedure"); 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_ )); DESCR("I/O"); @@ -3483,9 +3483,9 @@ DATA(insert OID = 2214 ( regoperin PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 DESCR("I/O"); DATA(insert OID = 2215 ( regoperout PGNSP 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_ )); DESCR("I/O"); -DATA(insert OID = 3492 ( to_regoper PGNSP 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_ )); +DATA(insert OID = 3492 ( to_regoper PGNSP 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_ )); DESCR("convert operator name to regoper"); -DATA(insert OID = 3476 ( to_regoperator PGNSP 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_ )); +DATA(insert OID = 3476 ( to_regoperator PGNSP 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_ )); DESCR("convert operator name to regoperator"); DATA(insert OID = 2216 ( regoperatorin PGNSP 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_ )); DESCR("I/O"); @@ -3495,13 +3495,13 @@ DATA(insert OID = 2218 ( regclassin PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 DESCR("I/O"); DATA(insert OID = 2219 ( regclassout PGNSP 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_ )); DESCR("I/O"); -DATA(insert OID = 3495 ( to_regclass PGNSP 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_ )); +DATA(insert OID = 3495 ( to_regclass PGNSP 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_ )); DESCR("convert classname to regclass"); DATA(insert OID = 2220 ( regtypein PGNSP 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_ )); DESCR("I/O"); DATA(insert OID = 2221 ( regtypeout PGNSP 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_ )); DESCR("I/O"); -DATA(insert OID = 3493 ( to_regtype PGNSP 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_ )); +DATA(insert OID = 3493 ( to_regtype PGNSP 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_ )); DESCR("convert type name to regtype"); DATA(insert OID = 1079 ( regclass PGNSP 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_ )); DESCR("convert text to regclass"); @@ -3510,14 +3510,14 @@ DATA(insert OID = 4098 ( regrolein PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 DESCR("I/O"); DATA(insert OID = 4092 ( regroleout PGNSP 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_ )); DESCR("I/O"); -DATA(insert OID = 4093 ( to_regrole PGNSP 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_ )); +DATA(insert OID = 4093 ( to_regrole PGNSP 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_ )); DESCR("convert role name to regrole"); DATA(insert OID = 4084 ( regnamespacein PGNSP 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_ )); DESCR("I/O"); DATA(insert OID = 4085 ( regnamespaceout PGNSP 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_ )); DESCR("I/O"); -DATA(insert OID = 4086 ( to_regnamespace PGNSP 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_ )); +DATA(insert OID = 4086 ( to_regnamespace PGNSP 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_ )); DESCR("convert namespace name to regnamespace"); 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_ ));
^ permalink raw reply [nested|flat] 5+ messages in thread

* Re: Beginner hacker item: Fix to_reg*() input type
@ 2016-01-05 18:04  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Petr Korobeinikov <pkorobeinikov@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2016-01-05 18:04 UTC (permalink / raw)
  To: Petr Korobeinikov <pkorobeinikov@gmail.com>; +Cc: Jim Nasby <Jim.Nasby@bluetreble.com>; pgsql-hackers

Petr Korobeinikov <pkorobeinikov@gmail.com> writes:
>> - Modify the functions in regproc.c. Take a look at how other text input
>> functions work to see what needs to happen here (you'll want to use
>> text_to_cstring() as part of that.)
>> 
>> - Modify the appropriate entries in src/include/catalog/pg_proc.h

> Let me try.
> `make check` says "All 160 tests passed.".

Pushed, thanks!

(I did make some small adjustments --- in this usage, PG_GETARG_TEXT_PP
is good enough and likely a bit more efficient than PG_GETARG_TEXT_P.)

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Beginner hacker item: Fix to_reg*() input type
@ 2016-01-05 19:03  Petr Korobeinikov <pkorobeinikov@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Petr Korobeinikov @ 2016-01-05 19:03 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jim Nasby <Jim.Nasby@bluetreble.com>; pgsql-hackers

2016-01-05 21:04 GMT+03:00 Tom Lane <tgl@sss.pgh.pa.us>:

> (I did make some small adjustments --- in this usage, PG_GETARG_TEXT_PP
> is good enough and likely a bit more efficient than PG_GETARG_TEXT_P.)
>
Also I forgot to bump catalog version up. My mishit.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Beginner hacker item: Fix to_reg*() input type
@ 2016-01-05 19:44  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Petr Korobeinikov <pkorobeinikov@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2016-01-05 19:44 UTC (permalink / raw)
  To: Petr Korobeinikov <pkorobeinikov@gmail.com>; +Cc: Jim Nasby <Jim.Nasby@bluetreble.com>; pgsql-hackers

Petr Korobeinikov <pkorobeinikov@gmail.com> writes:
> 2016-01-05 21:04 GMT+03:00 Tom Lane <tgl@sss.pgh.pa.us>:
>> (I did make some small adjustments --- in this usage, PG_GETARG_TEXT_PP
>> is good enough and likely a bit more efficient than PG_GETARG_TEXT_P.)

> Also I forgot to bump catalog version up. My mishit.

No, submitted patches generally should not touch catversion (though it's
not a bad idea to mention the need for a bump in the submission message).
If you put in a catversion change, it's generally just going to cause
merge failures, since patches seldom get applied instantly.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2016-01-05 19:44 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-01-04 20:46 Beginner hacker item: Fix to_reg*() input type Jim Nasby <Jim.Nasby@BlueTreble.com>
2016-01-04 23:55 ` Petr Korobeinikov <pkorobeinikov@gmail.com>
2016-01-05 18:04   ` Tom Lane <tgl@sss.pgh.pa.us>
2016-01-05 19:03     ` Petr Korobeinikov <pkorobeinikov@gmail.com>
2016-01-05 19:44       ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox