diff --git a/pkg/sql/delegate/show_schemas.go b/pkg/sql/delegate/show_schemas.go index 247b09da42e0..e26a66cd128f 100644 --- a/pkg/sql/delegate/show_schemas.go +++ b/pkg/sql/delegate/show_schemas.go @@ -30,8 +30,8 @@ func (d *delegator) delegateShowSchemas(n *tree.ShowSchemas) (tree.Statement, er getSchemasQuery := fmt.Sprintf(` SELECT nspname AS schema_name, rolname AS owner FROM %[1]s.information_schema.schemata i - INNER JOIN pg_catalog.pg_namespace n ON (n.nspname = i.schema_name) - LEFT JOIN pg_catalog.pg_roles r ON (n.nspowner = r.oid) + INNER JOIN %[1]s.pg_catalog.pg_namespace n ON (n.nspname = i.schema_name) + LEFT JOIN %[1]s.pg_catalog.pg_roles r ON (n.nspowner = r.oid) WHERE catalog_name = %[2]s ORDER BY schema_name`, name.String(), // note: (tree.Name).String() != string(name) diff --git a/pkg/sql/logictest/testdata/logic_test/database b/pkg/sql/logictest/testdata/logic_test/database index e90bc18c86cd..b1f314aada67 100644 --- a/pkg/sql/logictest/testdata/logic_test/database +++ b/pkg/sql/logictest/testdata/logic_test/database @@ -41,6 +41,10 @@ postgres root NULL {} NULL NULL system node NULL {} NULL NULL test root NULL {} NULL NULL +# Verify that SHOW SCHEMAS FROM a includes user-defined schemas. +statement ok +CREATE SCHEMA a.s + query TT colnames SHOW SCHEMAS FROM a ---- @@ -50,6 +54,7 @@ information_schema NULL pg_catalog NULL pg_extension NULL public admin +s root statement ok CREATE DATABASE b TEMPLATE=template0