Skip to content

Use the table's own database in ALTER TABLE RENAME TO and SHOW CREATE TABLE - #2704

Merged
mathiasrw merged 2 commits into
developfrom
fix/qualified-table-db
Oct 20, 2026
Merged

mathiasrw merged 2 commits into
developfrom
fix/qualified-table-db

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Two more statements looked up the current database instead of the one in a db.table name, as #2185 (CREATE INDEX) and #2201 (SHOW COLUMNS, SHOW INDEX) fixed for others:

alasql('SHOW CREATE TABLE q2.t');           // was: There is no such table "t"
alasql('ALTER TABLE q2.t RENAME TO t2');    // was: 1, but q2.t was not renamed and the
                                            // current database got a key t2 holding undefined
  • ALTER TABLE takes the table's database at the start, so RENAME TO (and the schema-change bookkeeping before it) use it, like the rest of ALTER TABLE already did.
  • RENAME TO on a table that does not exist is unchanged (returns 1 and adds an undefined entry); making it throw is breaking and goes to 5.0 (ALTER TABLE RENAME TO on a missing table throws instead of returning 1 #2706).
  • SHOW CREATE TABLE uses the table's database.

Test: test/test2201-B.js. Found while reviewing #2201.

@mathiasrw
mathiasrw merged commit 4e630de into develop Oct 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant