schema_to_xmlschema() seems a bit less than finished

Started by Tom Laneover 18 years ago3 messages
#1Tom Lane
tgl@sss.pgh.pa.us

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

#2Sibte Abbas
sibtay@gmail.com
In reply to: Tom Lane (#1)
Re: schema_to_xmlschema() seems a bit less than finished

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

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Sibte Abbas (#2)
Re: schema_to_xmlschema() seems a bit less than finished

"Sibte Abbas" <sibtay@gmail.com> writes:

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?

No, the problem is that map_sql_typecoll_to_xmlschema_types is unaware
that it must ignore dropped columns :-(. I committed a fix a few
minutes ago.

regards, tom lane