Opened 14 years ago

Closed 14 years ago

#3636 closed defect (fixed)

Incorrect query in ogrpgtablelayer.cpp (more than one row returned by a subquery used as an expression)

Reported by: gabrimonfa Owned by: warmerdam
Priority: normal Milestone: 1.7.3
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

The following query, executed while fetching the name of the parent table is not correct if there exists two (or more) tables with the same name in different schemas:

osCommand.Printf("SELECT pg_class.relname FROM pg_class WHERE oid = "

"(SELECT pg_inherits.inhparent FROM pg_inherits WHERE inhrelid = " "(SELECT pg_class.oid FROM pg_class WHERE relname = '%s'))", (pszSqlGeomParentTableName) ? pszSqlGeomParentTableName : pszTableIn );

The most inner query, "SELECT pg_class.oid FROM pg_class WHERE relname = '%s'" is used as an expression but in that case it returns two or more rows.

Thus postgresql log complains that

CEST ERROR: more than one row returned by a subquery used as an expression

The query should be modified to target only the table in the schema of interest.

This problem applies at least to 1.7.2 and below until 1.5.2

Change History (1)

comment:1 by Even Rouault, 14 years ago

Milestone: 1.7.3
Resolution: fixed
Status: newclosed

Fixed in trunk (r19875) and branches/1.7 (r19876). Test added in r19877

Note: See TracTickets for help on using tickets.