Closed Allam76 closed 2 years ago
Thanks for the report! Can you include a little bit more info on how to reproduce this? Here are a couple questions:
When working on that metadata reader I was copying the queries from psql
but I don't remember if I skipped any conditions. We'll probably add what you suggested but I need to be able to reproduce the issue to verify any fixes.
1) How to install the debugger: https://qtibia.com/how-to-install-the-pl-pgsql-debugger-and-use-it-in-pgadmin/
2) Programatically, note no type filter:
3) Error in scan of result set:
sql: Scan error on column index 2, name "Type": converting NULL to string is unsupported
This is rather obvious since the database table looks like:
and case has no handling of c:
WHEN 'r' THEN 'table'
WHEN 'v' THEN 'view'
WHEN 'm' THEN 'materialized view'
WHEN 'i' THEN 'index'
WHEN 'S' THEN 'sequence'
WHEN 's' THEN 'special'
WHEN 'f' THEN 'foreign table'
WHEN 'p' THEN 'partitioned table'
WHEN 'I' THEN 'partitioned index'
END as "Type"
This could be fixed with either relkind <> 'c'
in where or "Type::text"
type cast.
4) The database is fine, the error is in the usql api.
Cheers Martin
Hello and thanks for a great piece of software!
I have an edge case for the metadata reader for postgres.
When the debugger is installed, postgres adds some entries in the pg_class table with relkind = 'c'. This is not supported in the metadata table reader query as the type becomes null whereas the scan expects string. This of course only happens when the filter for type is empty.
Workaround is to set the type filter.
Probably a good idea to add a
where c.reltype <> 'c'
to the query.