-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
erroneous postgis query when trying to discover relations #39036
Comments
I'm looking into it, the odd thing is that the warning is triggered by empty table and empty schema names. Is there a chance you could share a SQL DB dump (without any data, schema only is ok) and be more precise about the steps to make to reproduce this situation? |
I unfortunately can't share the database schema. I do have multiple schemes in the same database, if that is any help in diagnosing the issue. |
I tested it with multiple schemas but I cannot reproduce. |
Fixes qgis#39036 qgis#39025 (temptative, because I could not reproduce the exact issue without project and data)
I still get this with QGIS Master 7f8c036: WITH foreign_keys AS ( SELECT c.conname, c.conrelid, c.confrelid, unnest(c.conkey) AS conkey, unnest(c.confkey) AS confkey, (SELECT relname FROM pg_catalog.pg_class WHERE oid = c.conrelid) as referencing_table, (SELECT relname FROM pg_catalog.pg_class WHERE oid = c.confrelid) as referenced_table, (SELECT relnamespace::regnamespace::text FROM pg_catalog.pg_class WHERE oid = c.confrelid) as constraint_schema FROM pg_constraint c WHERE contype = 'f' AND c.conrelid::regclass = '"".""'::regclass ) SELECT fk.conname as constraint_name, a.attname as column_name, fk.constraint_schema, referenced_table as table_name, af.attname as column_name, fk.confkey as ordinal_position FROM foreign_keys fk JOIN pg_attribute af ON af.attnum = fk.confkey AND af.attrelid = fk.confrelid JOIN pg_attribute a ON a.attnum = conkey AND a.attrelid = fk.conrelid ORDER BY fk.confrelid, fk.conname ; returned 7 [ERROR: schema "" does not exist |
@beerockxs still cannot reproduce, can you at least share the project without data? |
I did some debugging and removed layers until I could isolate the layer causing the issue, it's an SQL layer that loads features from a postgresql function and joins another table to it. I had to create a function for this because I needed some plpgsql and couldn't just use normal SQL to generate my geometry. |
A query layer was my main suspect too, that's why I asked for the project. I think we can silence the warning by checking if tableName and schemaName are availble for a particular layer. |
When I try to discover relations between my tables, I get this warning in the PostGIS message log:
Erroneous query: WITH foreign_keys AS ( SELECT c.conname, c.conrelid, c.confrelid, unnest(c.conkey) AS conkey, unnest(c.confkey) AS confkey, (SELECT relname FROM pg_catalog.pg_class WHERE oid = c.conrelid) as referencing_table, (SELECT relname FROM pg_catalog.pg_class WHERE oid = c.confrelid) as referenced_table, (SELECT relnamespace::regnamespace::text FROM pg_catalog.pg_class WHERE oid = c.confrelid) as constraint_schema FROM pg_constraint c WHERE contype = 'f' AND c.conrelid::regclass = '.'::regclass ) SELECT fk.conname as constraint_name, a.attname as column_name, fk.constraint_schema, referenced_table as table_name, af.attname as column_name, fk.confkey as ordinal_position FROM foreign_keys fk JOIN pg_attribute af ON af.attnum = fk.confkey AND af.attrelid = fk.confrelid JOIN pg_attribute a ON a.attnum = conkey AND a.attrelid = fk.conrelid ORDER BY fk.confrelid, fk.conname ; returned 7 [ERROR: invalid name syntax
LINE 1: ...ERE contype = 'f' AND c.conrelid::regclass = '.'::regcl...
^
]
The text was updated successfully, but these errors were encountered: