Skip to content

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

Open
LucaCappelletti94 wants to merge 3 commits into
mainfrom
upstream/drop-comment-foreign-table
Open

LucaCappelletti94 wants to merge 3 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.36%. Comparing base (4c82c3a) to head (6471584).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2746      +/-   ##
==========================================
+ Coverage   82.34%   82.36%   +0.01%     
==========================================
  Files          42       42              
  Lines       35263    35270       +7     
  Branches    35263    35270       +7     
==========================================
+ Hits        29039    29049      +10     
+ Misses       2677     2674       -3     
  Partials     3547     3547              

☔ 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}");
      }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants