Repository navigation
Record CREATE FOREIGN TABLE in a pool of its own and resolve grants on it - #161
Open
LucaCappelletti94 wants to merge 9 commits into
Open
LucaCappelletti94 wants to merge 9 commits into
LucaCappelletti94 wants to merge 9 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
LucaCappelletti94
force-pushed
the
upstream/create-foreign-table
branch
3 times, most recently
from
October 31, 2026 12:44
08312d8 to
36b5dcd
Compare
LucaCappelletti94
force-pushed
the
upstream/create-foreign-table
branch
from
November 1, 2026 11:49
36b5dcd to
9e5659b
Compare
There was a problem hiding this comment.
These duplicates are not on lines GitHub shows in this pull request diff, the inline comment cannot attach there. The links point at the copies on the head commit.
- group context
tests/function_referenced_tables.rs:507-517function_referenced_tables::named_by
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.
sql-traits dropped
CREATE FOREIGN TABLEwithout recording anything, so a schema that also granted on the foreign table failed to load withTableNotFoundForGrant. A foreign table is a relation in PostgreSQL (relkindf) that never carries row-level security, which makes a grant on it a full read of the remote relation, so a linter needs to see both the table and its grants.The foreign table now goes into its own
foreign_tables()pool besidetables(), which keeps answering only for relations that store their own rows, so callers asking about primary keys or row-level security on tables do not start seeing foreign tables. It uses the same node type as a table, so its columns, checks, owner, triggers and grants come from the existing table machinery.TableLike::foreign_sourcereturns itsSERVERandOPTIONS, andColumnLike::foreign_optionsreturns a column's ownOPTIONSwith keys folded as PostgreSQL stores them inattfdwoptions.Relationgains aForeignTablevariant, so grants, relation lookups and the relations a statement reads name it as its own kind, andALL TABLES IN SCHEMAcovers foreign tables as it does in PostgreSQL.Ingestion follows what PostgreSQL 17 and 18 accept and refuse on a foreign table.
ALTER TABLEcolumn, rename and owner actions, triggers,LIKE,INHERITSin either direction,DROP FOREIGN TABLEandATTACH PARTITIONwork on it, andpartitions()andinheritors()list it. Column options stay with the column that declares them, so an inheriting table or a column added through a parent gets none. Key constraints, indexes, references to it, policies, row-level security and persistence changes, rules,DROP TABLE, and a unique index reaching it through a partitioned table are refused with the relation named as a foreign table, as are columnOPTIONSon an ordinary table and an option list naming the same key twice.RuleOnMaterializedViewandRuleOnSequencebecomeRuleOnUnsupportedRelationso the rule refusal can name any of these kinds.ALTER FOREIGN TABLEandCREATE FOREIGN TABLE ... PARTITION OFstill wait on apache/datafusion-sqlparser-rs#2745 and #2753.