Repository navigation
feat: real table and column names, and a DuckDB session that opens no file - #20
Merged
Merged
Conversation
… file
A table and its columns keep the names the database gives them; the
predicate declared over them is what rules use:
OrderItems(id:, unit_price:) :- `public.Order Items`(Id: id, `Prix unitaire (€)`: unit_price);
- A quoted table name takes any letter, spaces and -'&#@+%:() next to
digits and '_'. Each part is quoted for the engine, so a sign in it is
part of the name. What could end the quoting (", `, \), make a path or
a URL (/, *, ?) or name a variable ($) stays refused.
- A column name with an uppercase letter is quoted: an engine that folds
unquoted names (PostgreSQL) did not find `createdAt`.
- A field in backticks names the column between them when a table is
read: `Order Note` was written with its backticks.
- The DuckDB session of `execute` is locked once its files are loaded:
no external access, no extension installed or loaded on demand, no
Python variable taken for a table, configuration locked. DuckDB
otherwise opens the file a table name designates (`secret.csv`,
"secret"."parquet", also .tsv, .json, .jsonl, .ndjson, .db, .csv.gz).
Tests: 16 more attempts in tests/programs/injection (a new
`# Expect: run-error` runs one on every engine), tests/cli/test_file_access.py
for the file formats, and the unit tests of the names.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spark reads `format.path` as a file when no table has that name: `text.secret` (bare or in backticks) returned the lines of a file of the server's working directory, `csv.secret` opened it as CSV. On the databricks dialect, a two-part name whose first part is a file format (text, csv, json, parquet, orc, avro, xml, binaryfile, delta, jdbc, ...) is refused: such a table is named with its catalog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mark goes from 86.5% to 76% of its square canvas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Synalog fences are named `synalog` and left to javascripts/synalog-highlight.js: Synalemma's tokenizer and colours, and lines wider than 80 characters formatted along the code. The other languages take the same colours through the theme's variables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
axioms.ttl, axioms.l and axioms.log presented a synalog import command that no longer exists; no page linked them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
A table and its columns keep the names the database gives them; the predicate declared over them is what rules use.
-'&#@+%:()next to digits and_. Each part is quoted for the engine, so a sign in it is part of the name.", a backtick,\), make a path or a URL (/,*,?) or name a variable ($), plus;,,, control characters and leading or trailing spaces.createdAtwas not found.`Order Note`used to be written with its backticks.executeis locked once its files are loaded: no external access, no extension installed or loaded on demand, no Python variable taken for a table, configuration locked.Why the DuckDB lock
DuckDB opens the file a table name designates. On 1.5.3, with a
secret.<ext>file in the working directory,SELECT * FROM "secret"."csv"returns its rows; the same holds for.tsv,.json,.jsonl,.ndjson,.parquet,.dband.csv.gz..xlsxand.avrotrigger an extension download. A name matching a Python variable of the caller is scanned too. This was reachable before this change through a baresecret.csv(x:).Behaviour changes to review
`(SELECT 1 AS x)`and`a'b`are now table names (quoted identifiers the engine does not find) instead of verifier errors. Three tests were changed for this:injection/table_name_subquery.l,verifier2/error_table_name_quote.l,verifier2/error_table_name_sql.l, and the unit testsql_as_a_table_name_is_refused.executeon DuckDB can no longer read a file other than theloadsgiven to it.Tests
tests/programs/injection, with a new# Expect: run-error <Pred> <text>kind that runs one on DuckDB and SQLite.tests/cli/test_file_access.py: 46 cases over the file formats, bare and quoted names, a caller's variable, and a control showing plain DuckDB does read the file.cargo test --lib: 861 passed. Golden compiler, parser, verifier and search suites pass (run with--no-default-features; the integration tests do not link with the Python feature on macOS here).pytest tests/cli: 5961 passed, 34 skipped.tests/e2eon live engines: the whole suite on SQLite, DuckDB and PostgreSQL (40,982 passed); the injection programs on Trino, Presto and Spark (all passed); a 1-in-25 sample of the rest on Trino and Presto (1,256 passed) and on Spark (628 passed). The full suite on Trino, Presto and Spark was not run (about five hours here), nor anything on BigQuery or a real Databricks.Databricks: a table name reads no file
Spark reads
format.pathas a file when no table has that name. On Spark 3.5.3,text.secret(bare or in backticks) returned the lines of a file in the server's working directory, andcsv.secretopened it as CSV; this was reachable before this change. On the databricks dialect, a two-part name whose first part is a file format (text,csv,json,parquet,orc,avro,xml,binaryfile,delta,jdbc, ...) is now refused at compile time, with a message asking to name the table with its catalog. A schema that is really calledtextorcsvis therefore only reachable ascatalog.schema.table.Not covered
compileand run on a caller's own DuckDB connection is not protected by the session lock; Lemma locks its own connections in SynaLinks/lemma#3.tests/programs(those run on DuckDB and SQLite).🤖 Generated with Claude Code