BUG #2016: query working with 8.0 fails with 8.1

Started by Pit M.over 20 years ago2 messagesbugs
Jump to latest
#1Pit M.
fmi-soft@gmx.de

The following bug has been logged online:

Bug reference: 2016
Logged by: Pit Mueller
Email address: fmi-soft@gmx.de
PostgreSQL version: 8.1 BETA4
Operating system: WinXP
Description: query working with 8.0 fails with 8.1
Details:

Using this query to get the primary key for a certain table:

SELECT p.conname AS constraint_name FROM pg_constraint p WHERE p.contype =
'p' AND p.conrelid = pg_class.oid AND pg_class.relname = 'mytablename'

leads to an error:

ERROR: missing FROM-clause entry for table "pg_class"

This query worked fine with 8.0.3.

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Pit M. (#1)
Re: BUG #2016: query working with 8.0 fails with 8.1

Pit Mueller wrote:

SELECT p.conname AS constraint_name FROM pg_constraint p WHERE
p.contype = 'p' AND p.conrelid = pg_class.oid AND pg_class.relname =
'mytablename'

leads to an error:

ERROR: missing FROM-clause entry for table "pg_class"

You need to mention pg_class in the FROM clause.

This query worked fine with 8.0.3.

The query was always incorrect, and 8.1 is now stricter in that regard.
To get bugward-compatible behavior, look up the configuration parameter
add_missing_from.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/