You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot list indexes of a table if schema is not in search path #2562
CREATE SCHEMA new_schema;
CREATE TABLE new_schema.new_table (dummy_column text);
CREATE INDEX new_idx
ON new_schema.new_table (dummy_column);
Then call the GetIndexes request :
select current_database() as table_catalog,
n.nspname as table_schema,
t.relname as table_name,
i.relname as index_name
from
pg_catalog.pg_class i join
pg_catalog.pg_index ix ON ix.indexrelid = i.oid join
pg_catalog.pg_class t ON ix.indrelid = t.oid join
pg_attribute a on t.oid = a.attrelid left join
pg_catalog.pg_user u ON u.usesysid = i.relowner left join
pg_catalog.pg_namespace n ON n.oid = i.relnamespace
where
i.relkind = 'i'
and n.nspname not in ('pg_catalog', 'pg_toast')
and pg_catalog.pg_table_is_visible(i.oid)
and a.attnum = ANY(ix.indkey)
and t.relkind = 'r' AND current_database() = 'new_db' AND n.nspname = 'new_schema' AND t.relname = 'new_table'
The issue
The GetIndexes method returns 0 results. I'm expecting my indexes to be listed.
I've just checked and SqlClient does show all indexes in all schemas (SQL Server doesn't have search_path), I don't see any reason for us to do otherwise. This code is extremely old, we should just fix it.
Activity
YohDeadfall commentedon Aug 21, 2019
@roji What is the correct behavior? Should we respect visibility everywhere?
roji commentedon Aug 21, 2019
I've just checked and SqlClient does show all indexes in all schemas (SQL Server doesn't have search_path), I don't see any reason for us to do otherwise. This code is extremely old, we should just fix it.
roji commentedon Aug 21, 2019
Have approved for merge, @YohDeadfall unless you have any other thoughts we can merge and backport.
Update NpgsqlSchema.cs
Update NpgsqlSchema.cs