Re: schema_to_xmlschema() seems a bit less than finished

From: "Sibte Abbas" <sibtay(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: schema_to_xmlschema() seems a bit less than finished
Date: 2007-07-13 04:23:26
Message-ID: bd6a35510707122123w64f3f6fdqc809b5d3b886c555@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 7/12/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-07-13 04:26:22 Re: schema_to_xmlschema() seems a bit less than finished
Previous Message Tom Lane 2007-07-13 02:56:20 Re: compiler warnings on the buildfarm