Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/MariaDB/mysql-test/main/   (MariaDB Server Version 8.1-8.4©)  Datei vom 1.9.2026 mit Größe 1 kB image not shown  

Quelle  deny_use_db.test  Sprache: unbekannt

 
Spracherkennung für: .test vermutete Sprache: SQL {SQL[100] Lisp[49] Masm[49]} [Methode: maximale Elemente, drei Dimensionen]

--source include/not_embedded.inc

--echo #
--echo # check_grant_db with DENY-only entries
--echo #

CREATE DATABASE db1;
CREATE TABLE db1.t1 (c1 INT, c2 INT);

CREATE USER u1@localhost;
DENY INSERT ON db1.t1 TO u1@localhost;

connect (con1, localhost, u1,,);

# Deny-only entries should not satisfy check_grant_db().
--error ER_DBACCESS_DENIED_ERROR
USE db1;

connection default;
GRANT SELECT (c1) ON db1.t1 TO u1@localhost;

connection con1;
# Column-level grant allows USE.
USE db1;

connection default;
disconnect con1;

DROP USER u1@localhost;

--echo #
--echo # global DENY ALL prevents USE, even with table grants
--echo #

CREATE USER u2@localhost;
GRANT SELECT ON db1.t1 TO u2@localhost;
DENY ALL PRIVILEGES ON *.* TO u2@localhost;

connect (con1, localhost, u2,,);
--error ER_DBACCESS_DENIED_ERROR
USE db1;

connection default;
disconnect con1;
DROP USER u2@localhost;

--echo #
--echo # db-level DENY ALL prevents USE, even with table grants
--echo #

CREATE USER u3@localhost;
GRANT SELECT ON db1.t1 TO u3@localhost;
DENY ALL PRIVILEGES ON db1.* TO u3@localhost;

connect (con1, localhost, u3,,);
--error ER_DBACCESS_DENIED_ERROR
USE db1;

connection default;
disconnect con1;
DROP USER u3@localhost;
DROP TABLE db1.t1;
DROP DATABASE db1;

[Dauer der Verarbeitung: 0.16 Sekunden, vorverarbeitet 2026-10-08]