Problem with oids for table names getting out of sync?

From: Omar Eljumaily <omar2(at)omnicode(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Problem with oids for table names getting out of sync?
Date: 2007-04-05 00:14:04
Message-ID: 46143F4C.7080105@omnicode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This is with 8.1.8, but I don't see any mention of any bug fixes that
cover this.

I've run into this sort of obscure problem. I'm using libpq with a
front end database api where I need to track column names and how
they're returned in libpq queries. What's happening is that I start out
with a set of table names when I open my database with a query:

SELECT relfilenode, relname FROM pg_class WHERE relname !~ '^(pg_|sql_)'
AND relkind = 'r'

But these don't agree with the oids when I subsequently fetch my rows
and use the following:

Oid o = PQftable(_res, i);
std::string s1 = _con->_oidTableNames[o];

_con->_oidTableNames is my own array that I've created with the above
select query. The reason I need to get table names after queries is
that queries often return with multiple cases of a single column name,
but with different table names. I need to be able to decifer the
table.column combination when people refer to a column in that way.

My problem is that the Oids returned by PQftable sometimes do not return
from the select query. For instance

Oid returned from PQftable = 654989
select relname from FROM pg_class WHERE relfilenode = 654989
returns empty.

The way I can solve this problem is by dumping and restoring the
database. That's the only way I can fix it.

I don't know how to reproduce the problem. Has anybody heard of this?
I'm going to update to the latest version this weekened. Maybe that
will fix it.

Is there any other way to get table names from libpq queries without
using the oid method I use above?

One other thing I just remembered. The next time it happens I'm going
to try a postgresql java driver with similar queries to see if the
table.column combinations in ResultSet.getString() get messed up as
well. That will tell me something. I suppose I can look and see how
they get tablename information.

Thanks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Guido Neitzer 2007-04-05 00:15:16 Re: OS X Kernel settings
Previous Message Ed L. 2007-04-05 00:11:26 Re: dropping role w/dependent objects