Ticket #3636 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

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

Changed 3 years ago by rouault

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to 1.7.3

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

Note: See TracTickets for help on using tickets.