Skip to content

PostgreSQL: Support DROP and COMMENT ON FOREIGN TABLE - #2746

Merged
LucaCappelletti94 merged 4 commits into
mainfrom
upstream/drop-comment-foreign-table
Oct 29, 2026
Merged

LucaCappelletti94 merged 4 commits into
mainfrom
upstream/drop-comment-foreign-table

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

DROP FOREIGN TABLE IF EXISTS ft, other CASCADE and COMMENT ON FOREIGN TABLE ft IS 'remote orders' failed at FOREIGN. Both now parse, with ObjectType::ForeignTable and CommentObject::ForeignTable of their own, because PostgreSQL refuses DROP TABLE and COMMENT ON TABLE on a foreign table.

https://www.postgresql.org/docs/current/sql-dropforeigntable.html
https://www.postgresql.org/docs/current/sql-comment.html

@codecov-commenter

codecov-commenter commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.42%. Comparing base (5989f9c) to head (248056b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2746      +/-   ##
==========================================
+ Coverage   82.41%   82.42%   +0.01%     
==========================================
  Files          42       42              
  Lines       35361    35371      +10     
  Branches    35361    35371      +10     
==========================================
+ Hits        29143    29156      +13     
+ Misses       2681     2678       -3     
  Partials     3537     3537              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/parser/mod.rs
Some(self.parse_object_name(false)?)
} else {
None
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostgreSQL DROP FOREIGN TABLE synopsis, DROP FOREIGN TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ] (no TEMPORARY, PURGE or ON):

https://www.postgresql.org/docs/current/sql-dropforeigntable.html

    if object_type == ObjectType::ForeignTable && (temporary || purge || table.is_some()) {
          return parser_err!(
              "Cannot specify TEMPORARY, PURGE, or ON in DROP FOREIGN TABLE",
              loc
          );
      }

and red tests

 #[test]
  fn parse_drop_foreign_table_rejects_modifiers() {
      for sql in [
          "DROP TEMPORARY FOREIGN TABLE ft",
          "DROP FOREIGN TABLE ft PURGE",
          "DROP FOREIGN TABLE ft ON t",
      ] {
          assert!(all_dialects().parse_sql_statements(sql).is_err(), "{sql}");
      }
  }

@LucaCappelletti94 LucaCappelletti94 added enhancement New feature or request api change labels Oct 28, 2026
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/drop-comment-foreign-table branch from 5533880 to 14f6259 Compare October 28, 2026 14:51
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/drop-comment-foreign-table branch from 14f6259 to 248056b Compare October 28, 2026 20:12

@s5dsn-eqee s5dsn-eqee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@LucaCappelletti94

Copy link
Copy Markdown
Contributor Author

Thanks @s5dsn-eqee for the review, I will be merging this now.

cc @alamb

@LucaCappelletti94
LucaCappelletti94 added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit a9c0767 Oct 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants