SQL File Access¶
Any SQL statement that names a server-side file path can only open that path when the
sysaccount runs the statement with themoadminrole active in the session. Table privileges such asSELECTorINSERTnever grant access to files on the MatrixOne host server, and no permissive fallback mode exists.
Which file paths are restricted¶
A restricted path is any path that the MatrixOne service opens on the server host or in server-side storage, including:
A local file path with no service name, which resolves against the MatrixOne host filesystem.
A stage reference created by
CREATE STAGE.A path resolved against a named object-storage service or an object-storage-backed dynamic provider.
The following statements read or write such paths and are covered by the admission check:
LOAD DATA ... INFILEon a server-side path.SELECT ... INTO OUTFILEand other server-side export paths.load_file()andsave_file().File-oriented table functions such as
parse_jsonl_file().External reads, including external tables, Hive-format readers, and other readers backed by server-side files or object storage.
Table dump/load operations.
CREATE SNAPSHOTand other backup SQL that names server-side locations.Datalink consumers that resolve a server-side path indirectly.
The following paths are not restricted, because the file is read or written on the client side and never opens a server resource:
LOAD DATA LOCAL INFILE, whose file is read by the client and pushed to the server.INLINEdata and inline table functions, such asparse_jsonl_data(), where the data is inlined in the statement text.
Admission requirement¶
The check runs per statement on the statement’s session identity:
The session must be authenticated as the
sysaccount, and themoadminrole must be active in the session when the statement runs.The identity is re-evaluated on every statement and is not cached. After
set role public, a previously prepared or previously successful statement is denied; afterset role moadmin, the same statement is admitted again.Object privileges on a table, such as
SELECTorINSERT, never substitute for this check. A user granted full table privileges still cannot read or write server files.There is no permissive fallback mode: if the active identity does not satisfy the check, the statement fails with
only the sys account moadmin role can access SQL file paths.
Syntax¶
set role moadmin;
set role public;
Arguments¶
The check evaluates the session’s account and the role active for the current statement only; neither the login account nor the active role is cached across statements.
Object privileges granted on the target table cannot substitute for the account and role requirement.
The check does not rely on
secure_file_priv, which is not enforced for this boundary.
Examples¶
The example below shows the shape of the check on a session whose active role is not moadmin. The session prepares a small table, switches to the public role, and the SELECT ... INTO OUTFILE statement is denied with only the sys account moadmin role can access SQL file paths. The example uses a short-lived scratch database and a local export path; in a real deployment you would replace the path with the server-side path or stage that you intend to write.
DROP DATABASE IF EXISTS sql_file_access_demo_db;
CREATE DATABASE sql_file_access_demo_db;
USE sql_file_access_demo_db;
CREATE TABLE demo_src(id INT PRIMARY KEY, note VARCHAR(100));
INSERT INTO demo_src VALUES(1,'first'),(2,'second');
SET ROLE public;
-- Expected-Success: false
SELECT id, note FROM demo_src INTO OUTFILE '/tmp/demo_src.csv';
SET ROLE moadmin;
DROP DATABASE sql_file_access_demo_db;
The SELECT ... INTO OUTFILE is denied by the identity check while the public role is active. Running the same statement again after SET ROLE moadmin is admitted, because the identity is re-evaluated on every statement rather than cached. Note that changing the active role with set role moadmin or set role public changes the outcome of the very next statement, including for statements prepared before the switch.
Dynamic providers and credentials¶
For dynamic object-storage providers used by SQL statements, the provider description is validated in addition to the identity check:
A dynamic provider must not rely on server-local auxiliary files:
cert-files,kerberos-keytab-path, and similar certificate and keytab parameters are rejected withSQL dynamic providers cannot use server-local auxiliary files.Server credential discovery mechanisms such as
shared-config-profileare rejected withSQL dynamic providers cannot use server credential discovery.Explicit credentials are required: a provider without usable credentials is rejected with
SQL dynamic object storage requires explicit credentials.The
MO_NO_DEFAULT_CREDENTIALSenvironment variable and theNoDefaultCredentialsForETLsetting do not select SQL credential behavior; credentials for dynamic providers must be stated explicitly in the provider description.HDFS with simple authentication, Aliyun OSS with
BearerToken, and MinIO with explicit anonymous credentials remain usable when stated explicitly in the provider description.
Deployment precautions¶
The boundary is enforced only after every SQL-serving CN in the cluster has been upgraded. A CN still running an older version can admit a statement that the upgraded version denies, so complete the upgrade before relying on the restriction.
Asynchronous indexed Datalink sources backed by local files become remote-only under this boundary. To migrate, repoint an existing local-file source to a remote service and rebuild the index, or materialize the local content into a
TEXTcolumn using a foregroundload_textload before the upgrade.Existing archives written before v4.2.7 do not carry the table-ID history objects introduced for physical restore, so the improved table-ID history check cannot be retrofitted to them; see Backup and Recovery Overview for the restore behavior that uses this history.