Commit 5e2d2a1
committed
Address Onder's amazing comprehensive review
Harden catalog server security, configuration, and cross-catalog safety
Refactor GetRestCatalogOptionsFromCatalog into a clean dispatcher
(ResolveRestCatalogOptions) with two explicit builders:
BuildRestCatalogOptionsFromGUCs for the built-in 'rest' path and
BuildRestCatalogOptionsFromServer for user-created servers, plus shared
helpers ApplyGUCDefaults, ApplyServerOptionOverrides, and
ValidateRestCatalogOptions. Add CopyRestCatalogOptions for safe
deep-copy into a target memory context.
Unify the three separate server option lists (whitelist array, errhint
string, applier chain) into a single IcebergCatalogOptionDesc descriptor
table with type, offsetof, and validation flags. Adding or removing an
option is now a one-line change.
Add DDL-time value validation: reject empty strings for client_id,
client_secret, scope, catalog_name; require a URI scheme for
rest_endpoint, oauth_endpoint, location_prefix.
Require ACL_USAGE on user-created iceberg_catalog servers at CREATE TABLE
time, matching core's CREATE FOREIGN TABLE semantics. Record a
DEPENDENCY_NORMAL from iceberg tables to their catalog server in
pg_depend so DROP SERVER is blocked (and CASCADE drops them).
Block ALTER SERVER RENAME for iceberg_catalog servers since dependent
tables store the server name as a string in ftoptions.
Block ALTER SERVER SET rest_endpoint when dependent writable tables exist
to prevent silently redirecting them to a different REST catalog.
Make GetRestCatalogName always return get_database_name(MyDatabaseId) for
writable tables so ALTER SERVER ADD catalog_name cannot re-route an
existing table to a different namespace.
Fix token cache hash key regression: zero the key buffer with MemSet
before strlcpy in BuildTokenCacheKey. Add syscache invalidation callback
on FOREIGNSERVEROID to reset the token cache on ALTER/DROP SERVER, using
CacheMemoryContext as parent. Add NULL guard on opts in
GetRestCatalogAccessToken.
Fix default_catalog GUC check hook to accept values outside a transaction
(ALTER SYSTEM + pg_reload_conf path), mirroring how PostgreSQL handles
check_default_tablespace.
Introduce ValidateXactRestCatalog as a fail-fast guard that checks
cross-catalog DML at statement time rather than at XACT_EVENT_PRE_COMMIT.
Planted in postgresBeginForeignModify and AddQueryResultToTable. The
existing pre-commit check is retained as a belt-and-suspenders fallback.
Parametrize test_writable_rest_iceberg_table over built-in 'rest' and
user-created server paths. Add tests for USAGE enforcement, dependency
tracking, server rename blocking, rest_endpoint blocking, catalog_name
re-routing, token cache invalidation, ALTER SYSTEM deferred validation,
option value validation, multi-table same-server transactions, and
cross-catalog rejection cleanup.
Signed-off-by: sfc-gh-npuka <naisila.puka@snowflake.com>1 parent e82da75 commit 5e2d2a1
12 files changed
Lines changed: 1399 additions & 157 deletions
File tree
- pg_lake_iceberg
- include/pg_lake/rest_catalog
- src
- rest_catalog
- test
- pg_lake_table
- include/pg_lake/transaction
- src
- ddl
- fdw
- transaction
- tests/pytests
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
379 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
380 | 383 | | |
381 | | - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
382 | 388 | | |
383 | 389 | | |
384 | 390 | | |
| |||
0 commit comments