Thread: Slightly inconsistent behaviour in regproc?

Slightly inconsistent behaviour in regproc?

From
Christopher Kings-Lynne
Date:
When you do this query:

SET SEARCH_PATH TO pg_catalog;

SELECT castsource::pg_catalog.regtype AS castsource, 
casttarget::pg_catalog.regtype AS casttarget, 
castfunc::pg_catalog.regprocedure AS castfunc, 
castfunc::pg_catalog.regproc AS castfunc2 FROM pg_catalog.pg_cast ORDER 
BY 1, 2;

Only regproc adds the unnecessary pg_catalog. qualification, why is that?

Results:

-[ RECORD 1 ]----------------------------------------
castsource | "char"
casttarget | text
castfunc   | text("char")
castfunc2  | pg_catalog.text
-[ RECORD 2 ]----------------------------------------
castsource | "char"
casttarget | character
castfunc   | bpchar("char")
castfunc2  | pg_catalog.bpchar
-[ RECORD 3 ]----------------------------------------
castsource | name
casttarget | text
castfunc   | text(name)
castfunc2  | pg_catalog.text
-[ RECORD 4 ]----------------------------------------
castsource | name
casttarget | character
castfunc   | bpchar(name)
castfunc2  | pg_catalog.bpchar
-[ RECORD 5 ]----------------------------------------
castsource | name
casttarget | character varying
castfunc   | "varchar"(name)
castfunc2  | pg_catalog."varchar"
-[ RECORD 6 ]----------------------------------------
castsource | bigint
casttarget | smallint
castfunc   | int2(bigint)
castfunc2  | pg_catalog.int2
-[ RECORD 7 ]----------------------------------------
castsource | bigint
casttarget | integer
castfunc   | int4(bigint)
castfunc2  | pg_catalog.int4
...




Re: Slightly inconsistent behaviour in regproc?

From
Tom Lane
Date:
Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
> Only regproc adds the unnecessary pg_catalog. qualification, why is that?

Er, I couldn't see the part of your example where that happened?
        regards, tom lane


Re: Slightly inconsistent behaviour in regproc?

From
Christopher Kings-Lynne
Date:
>>Only regproc adds the unnecessary pg_catalog. qualification, why is that?
> 
> 
> Er, I couldn't see the part of your example where that happened?

Basically, my question is why ::regproc alone always addes the catalogue 
qualification in this case?

Rows below correspond to:

::regtype
::regtype
::regprocedure
::regproc

-[ RECORD 1 ]----------------------------------------
castsource | "char"
casttarget | text
castfunc   | text("char")
castfunc2  | pg_catalog.text

eg. Why is it not:

-[ RECORD 1 ]----------------------------------------
castsource | "char"
casttarget | text
castfunc   | text("char")
castfunc2  | text

Or even:

-[ RECORD 1 ]----------------------------------------
castsource | pg_catalog."char"
casttarget | pg_catalog.text
castfunc   | pg_catalog.text("char")
castfunc2  | pg_catalog.text

Chris




Re: Slightly inconsistent behaviour in regproc?

From
Tom Lane
Date:
Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
> Basically, my question is why ::regproc alone always addes the catalogue 
> qualification in this case?

regproc adds the schema if the name would be ambiguous without it (or
not visible at all).  In these cases, the function name is still
ambiguous with the schema :-( ... but there's nothing regproc can do
about that, since it's not chartered to emit function arguments.
Use regprocedure instead if you don't want to see schema names.
        regards, tom lane