You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 894fcc0
Browse filesBrowse the repository at this point in the historyBrowse files
Writable tables and transactions on a descriptor catalog, with public API
A worker ported from TypeScript (an UPDATE-able table whose changes are staged
in DuckDB transactions) needed private fixture code and dataclasses.replace on
the attach result. Each gap now has a public, documented API:
- vgi.write_results: write_options() decodes the write_options argument
(WriteOptions: result_mode, on_conflict, on_conflict_columns) from
BindParams, ProcessParams or a BindRequest; row_id_field(),
ROW_ID_METADATA_KEY, is_row_id_field(), row_id_column() and user_columns()
for the row-id column; write_count_batch(), write_rows_batch() and
write_result_batch() alongside write_changes_batch(). write_result_schema()
and the batch helpers drop the row-id column, which never belongs in a
write result (it used to leak into "rows" when given a table's columns).
- Table rejects an update/delete function whose scan has no row-id column or
lacks projection_pushdown, and Catalog rejects one whose scan is not listed
in the table's schema functions, instead of DuckDB's opaque "Virtual columns
require projection pushdown" at UPDATE time. Documented on Table.
- ReadOnlyCatalogInterface: attach_opaque_data_for() and
attach_supports_transactions() hooks decide the attach bytes and
supports_transactions per ATTACH; overriding catalog_transaction_* is the
documented way to add transactions (an attach that reports them without a
begin hook is refused). attach_opaque_data_required now follows the bytes:
False for the fixed default id (re-attaching is equivalent), True for
custom bytes.
- pack_attach_options()/unpack_attach_options() carry ATTACH options to every
function and hook. Secret options never enter the bytes (sealing rule 5):
they are kept in the shared function storage under a random handle.
- Attach options may be typed `T | None` / Optional[T]; the AttachOption
docstring no longer claims that omitting the default makes an option
required (only required=True does).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/catalog-interface.md
+101-1Lines changed: 101 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ Returned by `catalog_attach()` with attachment metadata:
65
65
|`supports_time_travel`|`bool`| Whether time travel queries work |
66
66
|`catalog_version_frozen`|`bool`| Whether metadata will change |
67
67
|`catalog_version`|`int`| Current version (increments on changes) |
68
-
|`attach_opaque_data_required`|`bool`|Whether attach_opaque_data must be persisted|
68
+
|`attach_opaque_data_required`|`bool`|`True`: the bytes name per-attach state, so the client must keep them. `False`: re-attaching yields an equivalent attach, so a client may attach per command|
69
69
|`default_schema`|`str`| Name of the default schema (usually "main") |
70
70
71
71
> **`attach_opaque_data` / `transaction_opaque_data` are opaque, implementation-owned, and may carry secrets.**
@@ -367,6 +367,16 @@ class MyWorker(Worker):
367
367
|`required=True`| The caller must supply the option. Declare it with no class-level default; `required` plus a default is rejected. |
368
368
|`secret=True`| The option carries a credential. |
369
369
370
+
The class-level assignment is the option's default. Leaving it out makes the option optional with no
371
+
default (it is simply absent from `options` when the caller omits it); only `required=True` makes it
372
+
mandatory. The type may be written `T | None` (or `Optional[T]`) to say the value can be absent; it
**Credential options (API keys, tokens, passwords) MUST be declared `secret=True`.** The caller passes them inline as attach options. Clients mask secret options, and the DuckDB extension redacts them from `duckdb_databases()`, keeps only a salted hash of them in its result-cache key, and never logs them. To keep a credential out of the SQL text (shell history, scripts, shared links), write the option as an expression:
371
381
372
382
```sql
@@ -423,6 +433,60 @@ class MyFunctionCatalog(ReadOnlyCatalogInterface):
423
433
# SELECT * FROM my_funcs.main.my_scalar_function(args);
424
434
```
425
435
436
+
### Per-attach options and transactions
437
+
438
+
"Read-only" means no DDL: a `ReadOnlyCatalogInterface` can still serve writable tables (see
439
+
[Writable tables](#writable-tables)) and take part in DuckDB transactions. Override hooks rather than
440
+
`catalog_attach`:
441
+
442
+
| Hook | Default | Purpose |
443
+
|------|---------|---------|
444
+
|`attach_opaque_data_for(name=, options=)`| a fixed id | The bytes every function and hook of this attach receives as `attach_opaque_data`. |
445
+
|`attach_supports_transactions(name=, options=, attach_opaque_data=)`| the `supports_transactions` class attribute |`CatalogAttachResult.supports_transactions`, decided per attach. |
446
+
|`catalog_transaction_begin` / `_commit` / `_rollback`| raise `CatalogReadOnlyError`| Mint the transaction id; apply or discard the transaction's work. |
447
+
448
+
`pack_attach_options(options, specs)` turns the ATTACH options into attach bytes and
449
+
`unpack_attach_options(params.attach_opaque_data)` reads them back in any function or hook, in any
450
+
worker process. Options declared `secret=True` never enter the bytes: they are kept in the shared
451
+
function storage (`VGI_WORKER_SHARED_STORAGE`) under a random handle, so pass the specs.
0 commit comments