How do I use a schema-qualified name in obj_description?  Or is this a 
nsty little bug?

Chris

test2=# create schema myschema;
CREATE SCHEMA
test2=# create table myschema.pg_class (a int4);
CREATE TABLE
test2=# select oid from pg_catalog.pg_class where 
oid='myschema.pg_class'::regclass;
    oid
---------
  1475161
(1 row)

test2=# select obj_description('1475161', 'pg_class');
  obj_description
-----------------

(1 row)

test2=# select obj_description('1475161', 'pg_catalog.pg_class');
  obj_description
-----------------

(1 row)

test2=# set search_path to myschema, pg_catalog;
SET
test2=# select obj_description('1475161', 'pg_class');
ERROR:  Attribute "relname" not found
test2=# select obj_description('1475161', 'pg_catalog.pg_class');
ERROR:  Attribute "relname" not found



Tue, 21 Oct 2003 13:20:57 +0800
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
obj_description problems?
Ooer - it is a nasty bug.  From pg_proc.h, the definition of 
obj_description is:

select description from pg_description where objoid = $1 and classoid = 
(select oid from pg_class where relname = $2 and relnamespace = PGNSP) 
and objsubid = 0

And what's more, none of the SQL functions in pg_proc.h are properly 
qualified.  I have attached a patch that may or may not be the solution 
- please check.

I didn't know how to handle 'timestamp without time zone' types and 
'overlaps'.

I realise now that there's no need to schema-qualify names - you can 
only do names from pg_catalog.

Chris


Christopher Kings-Lynne wrote:

> How do I use a schema-qualified name in obj_description?  Or is this a 
> nsty little bug?
> 
> Chris
> 
> test2=# create schema myschema;
> CREATE SCHEMA
> test2=# create table myschema.pg_class (a int4);
> CREATE TABLE
> test2=# select oid from pg_catalog.pg_class where 
> oid='myschema.pg_class'::regclass;
>    oid
> ---------
>  1475161
> (1 row)
> 
> test2=# select obj_description('1475161', 'pg_class');
>  obj_description
> -----------------
> 
> (1 row)
> 
> test2=# select obj_description('1475161', 'pg_catalog.pg_class');
>  obj_description
> -----------------
> 
> (1 row)
> 
> test2=# set search_path to myschema, pg_catalog;
> SET
> test2=# select obj_description('1475161', 'pg_class');
> ERROR:  Attribute "relname" not found
> test2=# select obj_description('1475161', 'pg_catalog.pg_class');
> ERROR:  Attribute "relname" not found
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>               http://archives.postgresql.org
Tue, 21 Oct 2003 13:42:16 +0800
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Re: obj_description problems?
*sigh* - it's really not my day today.  Attached is patch that actually 
compiles and fixes the problem.  We will need to bump CATVERSION, and 
maybe should test all the other qualified functions?

Chris
Tue, 21 Oct 2003 13:51:28 +0800
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Re: [HACKERS] obj_description problems?
Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
> *sigh* - it's really not my day today.  Attached is patch that actually 
> compiles and fixes the problem.  We will need to bump CATVERSION, and 
> maybe should test all the other qualified functions?

I think you've identified a real issue, but how many of these modified
functions did you actually test?  I thought SUBSTRING was a reserved
word, for example ...

			regards, tom lane

Tue, 21 Oct 2003 10:13:00 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] obj_description problems? 
Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
> *sigh* - it's really not my day today.  Attached is patch that actually 
> compiles and fixes the problem.  We will need to bump CATVERSION, and 

Reviewed, tested, applied.

> maybe should test all the other qualified functions?

What other qualified functions?  There might possibly be some issues in
contrib stuff, but there are no other SQL-language functions defined in
the main system (except information_schema, which we already checked).

			regards, tom lane

Tue, 21 Oct 2003 12:27:45 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] obj_description problems? 

>>*sigh* - it's really not my day today.  Attached is patch that actually 
>>compiles and fixes the problem.  We will need to bump CATVERSION, and 
>>maybe should test all the other qualified functions?
> 
> I think you've identified a real issue, but how many of these modified
> functions did you actually test?  I thought SUBSTRING was a reserved
> word, for example ...

Well, some...  I did run the regression tests and they passed, but I 
assumed that they would call all of the functions.

OK, I will test them all today and get back to you.

Chris



Wed, 22 Oct 2003 09:27:39 +0800
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Re: [HACKERS] obj_description problems?

> Reviewed, tested, applied.

Thanks.

>>maybe should test all the other qualified functions?
> 
> 
> What other qualified functions?  There might possibly be some issues in
> contrib stuff, but there are no other SQL-language functions defined in
> the main system (except information_schema, which we already checked).

Sorry - I meant "other functions that are now properly qualified in my 
patch".  ie, you have already tested them.

Chris


Wed, 22 Oct 2003 09:34:51 +0800
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Re: [HACKERS] obj_description problems?
Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
> OK, I will test them all today and get back to you.

I checked them all before applying, but please do cross-check.  We're
close enough to release that double- and triple-checking patches is
called for.

			regards, tom lane

Tue, 21 Oct 2003 22:49:47 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] obj_description problems? 
> I checked them all before applying, but please do cross-check.  We're
> close enough to release that double- and triple-checking patches is
> called for.

Checked them a bit - nothing too exhaustive.

Chris



Wed, 22 Oct 2003 15:39:11 +0800
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Re: [HACKERS] obj_description problems?