Re: schema_to_xmlschema() seems a bit less than finished - Mailing list pgsql-hackers

From Sibte Abbas
Subject Re: schema_to_xmlschema() seems a bit less than finished
Date
Msg-id bd6a35510707122123w64f3f6fdqc809b5d3b886c555@mail.gmail.com
Whole thread Raw
In response to schema_to_xmlschema() seems a bit less than finished  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: schema_to_xmlschema() seems a bit less than finished  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 7/12/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> In the regression database:
>
> regression=# select schema_to_xmlschema('public',false,false,'foo');
> ERROR:  cache lookup failed for type 0
>
> I have no idea what this function should produce, but surely not that?
>
>                         regards, tom lane
>

The following test case reproduces the problem:

create domain domtxt as text;
create table dom_tab(col1 domtxt);
drop domain domtxt cascade;
select schema_to_xmlschema('public',false,false,'foo');

Since domtxt domain is being dropped dom_tab should not contain any columns now.

However It appears that the tuple descriptor which
map_sql_typecoll_to_xmlschema_types() (in xml.c) gets for dom_tab
still shows one column (tupdesc->natts = 1). Subsequently when
SPI_gettypeid() is invoked it returns 0, which gets inserted in the
uniquetypes list.

Since the following foreach statement simply traverses the uniquetypes
list and invokes getBaseType() on its oid values, therefore 0 gets
passed to getBaseType()  which results in the "cache lookup failed
..." error.

Considering the above fact, perhaps the actual problem is that when a
column gets removed from a table as a result of drop  <column
type/domain> cascade, the tuple descriptor (more specifically
rel->rd_att field) for that relation is not updated properly?

regards,
-- 
Sibte Abbas
EnterpriseDB http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: compiler warnings on the buildfarm
Next
From: Tom Lane
Date:
Subject: Re: schema_to_xmlschema() seems a bit less than finished