Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-168

orm:schema-tool:update will fail if if public scheme has a domains table (PostgreSQL)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.5
    • Fix Version/s: 2.1.5
    • Component/s: Platforms
    • Security Level: All
    • Labels:
      None

      Description

      If I create a table 'domains' in the default scheme and execute the update procedure of the schema tool, it will throw a PDOException (SQLSTATE[21000]: Cardinality violation: 7 ERROR: more than one row returned by a subquery used as an expression)

      I've traced the error to the following statement, which is created by Doctrine\DBAL\Platforms\PostgreSqlPlatform->getListTableForeignKeysSQL():

      SELECT r.conname, pg_catalog.pg_get_constraintdef(r.oid, true) as condef
                        FROM pg_catalog.pg_constraint r
                        WHERE r.conrelid =
                        (
                            SELECT c.oid
                            FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
                            WHERE c.relname = 'domains'
                              AND n.oid = c.relnamespace
                        )
                        AND r.contype = 'f'
      

      This returns two oids because there are two relations with the name domains. One is my table and the other is a view in the information_scheme scheme.

      The same problem should occur with the other information_scheme relations.

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Hm the domains entry doesnt seems to pop up for me in pgadmin when executing your query. Can you help me a bit with details on how to reproduce this?

        Show
        Benjamin Eberlei added a comment - Hm the domains entry doesnt seems to pop up for me in pgadmin when executing your query. Can you help me a bit with details on how to reproduce this?
        Hide
        Martin Prebio added a comment -

        montbook:~ postgres$ createdb -E UTF8 -T template0 -l de_AT.UTF-8 foo
        montbook:~ postgres$ psql foo
        foo=# create table domains (id int8 not null);

        Now I have a table domains in the default schema and a domains table in the information_schema schema which is created and maintained by postgres. Now executing the query above will produce the mentioned exception.

        It was necessary to create a table in the fresh database to create the information_schema. It is a meta schema from where you can select information of the database and it is afaik a sql standard (also mysql has it but as a seperate database).

        pgAdmin may hide this schema (and the pg_catalog): http://www.mail-archive.com/pgadmin-support@postgresql.org/msg09332.html

        Show
        Martin Prebio added a comment - montbook:~ postgres$ createdb -E UTF8 -T template0 -l de_AT.UTF-8 foo montbook:~ postgres$ psql foo foo=# create table domains (id int8 not null); Now I have a table domains in the default schema and a domains table in the information_schema schema which is created and maintained by postgres. Now executing the query above will produce the mentioned exception. It was necessary to create a table in the fresh database to create the information_schema. It is a meta schema from where you can select information of the database and it is afaik a sql standard (also mysql has it but as a seperate database). pgAdmin may hide this schema (and the pg_catalog): http://www.mail-archive.com/pgadmin-support@postgresql.org/msg09332.html
        Hide
        Benjamin Eberlei added a comment -

        Fixed and merged into 2.1.x

        Show
        Benjamin Eberlei added a comment - Fixed and merged into 2.1.x

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Martin Prebio
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: