Skip to content

metadata: SQL Server, MySQL and MariaDB read in either scope - #113

Merged
stbischof merged 1 commit into
mainfrom
feat/metadata-scope-other-databases
Dec 2, 2026
Merged

stbischof merged 1 commit into
mainfrom
feat/metadata-scope-other-databases

Conversation

@stbischof

Copy link
Copy Markdown
Contributor

Follows #112, which brought the scopes DATABASE and USER with Oracle and PostgreSQL: the providers of the other databases read in either scope too.

SQL Server

  • DATABASE needs VIEW DEFINITION on the database; without it SQL Server shows a user only what it owns or holds a right on.
  • In USER the schemas are those that hold an object the user sees.
  • Grants on routines and sequences are read as object privileges, no longer as grants on tables.

MySQL and MariaDB

  • DATABASE needs, on every object, the rights with which information_schema shows the whole structure: SELECT, SHOW VIEW and TRIGGER, on MariaDB EXECUTE besides, and the grant tables of the schema mysql must be readable. SHOW GRANTS of the session decides, granted to the account or to an active role. These rights also let their holder read every row.
  • DATABASE reads every grant from the grant tables; USER reads the user and its roles from APPLICABLE_ROLES, its grants from information_schema and SHOW GRANTS, and the grants of its active roles as each database shows them.
  • Grantees and grantors are named without their host.
  • MariaDB reads the keys of a table from KEY_COLUMN_USAGE, which shows them to a reader that may only select.

H2 and DuckDB

They read their catalog one way only; every connection may read in the scope it asks for, and a snapshot names that scope.

Tests and README

The contract of #112 runs on SQL Server, MySQL and MariaDB in a container too; the tests of each database add what it shows differently. The README of the metadata providers says, for each database, what each scope reads, the right DATABASE needs, and where a database shows a user less or more than one might expect.

SQL Server shows a user only the metadata of what it owns or holds a
right on; a connection reads in DATABASE where it holds VIEW DEFINITION
on the database. In USER the schemas are those that hold an object the
user sees. Grants on routines and sequences are read as object
privileges, no longer as grants on tables.

MySQL and MariaDB read in DATABASE where the session holds, on every
object, the rights with which information_schema shows the whole
structure: SELECT, SHOW VIEW and TRIGGER, on MariaDB EXECUTE besides,
as it opens a view to find its columns. SHOW GRANTS of the session
decides, granted to the account or to an active role; the grant tables
of the schema mysql must be readable too. DATABASE reads every grant on
a table, a column and a routine from those grant tables. USER reads the
user and its roles from APPLICABLE_ROLES, its grants from
information_schema and SHOW GRANTS of its own account, and the grants
of its active roles as each database shows them. Grantees and grantors
are named without their host. MariaDB reads the keys of a table from
KEY_COLUMN_USAGE, which shows them to a reader that may only select.

H2 and DuckDB read their catalog one way only, the same in both scopes,
and every connection may read in the scope it asks for. They keep the
scope they are made for, so a snapshot names the scope asked for.

The contract runs on SQL Server, MySQL and MariaDB in a container too,
and the tests of each database add what it shows differently; on MySQL
and MariaDB a reader holding exactly the requirement, directly or
through an active role, reads what the administrator reads, and a
reader of the grant tables alone falls back. Unit tests cover the lines
of SHOW GRANTS and the scope of the provider of each product, and a
snapshot read with the provider of H2 names the scope asked for.

The README of the metadata providers says which provider serves which
product, how a scope is asked for, and for each database what each
scope reads, the right DATABASE needs, and where a database shows a
user less or more than one might expect.

Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
@stbischof
stbischof merged commit 6e173bc into main Dec 2, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant