Repository navigation
privilege, jdbc: users hold privileges as roles do; a database read as a whole or as its user sees it - #104
Merged
Conversation
stbischof
force-pushed
the
feat/user-privileges
branch
from
December 2, 2026 16:11
8a7b8f7 to
50c97fc
Compare
…s a whole or as its user sees it A database user and a database role hold privileges alike: each owns its own, and a party that is a member of a role holds the role's privileges besides. The stereotypes databaseUser and databaseRole tell them apart; PUBLIC carries neither. The rules of the privilege model stand in the metamodel as OCL invariants of their classes, each named by its code with its sentence and level beside it: P1 the grantee is a party, P2 the table and its columns, P3 the role of a membership is not its member, P4 the procedure, P5 no cycle of memberships, P6 the grantee is a user or a role, not both, and the warning P7 a membership names a role, not a user. The classic Eclipse OCL evaluates them; PrivilegeModelValidator gives their findings and installs, for the check alone, the inverse index through which the invariants read a party's stereotype. The documentation of the model is English only, under the keys documentation and caption. The rule party:<glob> takes the parties of that name with the privileges they own, whether the database tells them as role, as user or not at all, as MySQL does not. It takes nothing else of that name: in Oracle a user is a schema too, which name:<glob> would take as well. The DDL writes a membership that names a user only where the dialect grants a user like a role (supportsUserAsRole: PostgreSQL, MySQL); elsewhere it is a case the dialect cannot write, left out and logged, or, strict, the generation fails naming it. A user's own grant comes after the user is created, its revoke before it is dropped. The privilege loader gives a party whose kind the database does not tell the responsibility "database principal" instead of "database role", and reads a user with the privileges it holds itself beside its memberships. JdbcToCwmConfig names the scope a database is read in: DATABASE, the default, every schema, object, role, membership and grant, or USER, what the connected user may see. CwmJdbcImport.load takes the metadata provider of that scope. A connection that may not read the whole database is read as its user sees it, the whole snapshot, never a mix; withStrictScope(true) fails instead, before anything is read, with the MetadataScopeException that names the right the connection lacks. The catalog says what it holds: the tagged value daanse.jdbc.scope is the scope it was read in, daanse.jdbc.scope.requested the scope it was asked for where the two differ. Both are provenance, written by no DDL and compared by no diff. A database whose metadata provider reads its catalog one way only, as that of H2 does, is read so in either scope, and the catalog names the scope it was read in. The example jdbc.load reads a database with one call of CwmJdbcImport.load: its schemas with all they hold, its roles and users with their privileges, chosen by rules as cwm-jdbc:import takes them, in either scope; Inventory lists what a catalog holds, kind by kind, and the scope it was read in. The same shop, two schemas, three roles and two users, is created in Oracle and PostgreSQL and read by the same code: as a whole, on Oracle by a catalog reader holding just SELECT_CATALOG_ROLE, on PostgreSQL by the user of the container, and by the clerk of the shop, who sees its part. The tests compare both catalogs with what is expected and with each other, show the clerk asking for the whole database falling back to its part or, strictly, failing with the right it lacks before anything is read, and read both back from XMI. Where a database shows the clerk more or less than the shop leads one to expect, the test of that database says so and why: Oracle names every user to every user, without the memberships of others; PostgreSQL shows every user the whole database. The README names the right each database wants for the whole. The goal cwm-jdbc:import takes the parameter scope (cwm-jdbc.scope), database, the default, or user; another value fails the goal before it connects. strictScope (cwm-jdbc.strictScope) fails the goal, before anything is read, where the connection may not read in that scope, naming the right it lacks. The log names the scope the catalog was read in, and the one asked for where they differ. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
stbischof
force-pushed
the
feat/user-privileges
branch
from
December 2, 2026 16:15
50c97fc to
72e243e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A database user holds privileges as a role does, and a database is read into a catalog from one of two points of view. Builds on eclipse-daanse/org.eclipse.daanse.sql#112.
Privilege model
databaseUseranddatabaseRoletell them apart;PUBLICcarries neither.PrivilegeModelValidatorgives their findings.party:<glob>takes the parties of that name with the privileges they own, and nothing else of that name.Scope
JdbcToCwmConfig.withScope:DATABASE, the default, every schema, object, role, membership and grant, orUSER, what the connected user may see.withStrictScope(true)fails instead, before anything is read, with theMetadataScopeExceptionnaming the right the connection lacks.daanse.jdbc.scopeis the scope it was read in,daanse.jdbc.scope.requestedthe scope asked for where the two differ.cwm-jdbc:importtakesscopeandstrictScope.Example
examples/jdbc.loadreads a database with one call: schemas with all they hold, roles and users with their privileges, chosen by rules, in either scope. The same shop is created in Oracle and PostgreSQL and read by the same code, as a whole and as its clerk sees it; the tests compare both catalogs with what is expected and with each other, show the fallback and the strict failure, and read both back from XMI.