Repository navigation
Make \d <table> of the interactive client describe the table - #118281
Conversation
The `psql`-style `\d` is a textual alias of `SHOW TABLES`, so `\d hits` became `SHOW TABLES hits`, which is a syntax error. In `psql`, a bare `\d` lists the relations and `\d <name>` describes one, and that is what it does here now: given a table name it expands to `DESCRIBE TABLE`, while a bare `\d` still lists the tables. An argument that continues the listing query instead - `\d FROM system`, `\d LIKE 'hits%'` - keeps the listing. A table whose name is spelled as one of these clauses has to be quoted, which is also what tells it apart from the clause. The alias can now be followed by a `;` as well, so `\d;` and `\l;` are no longer syntax errors. Closes: #118180 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Workflow [PR], commit [2a7ccd7] Summary: ✅
AI ReviewSummaryThis PR changes the interactive client's Findings
Tests
Final Verdict
LLVM Coverage ReportMeasured on commit 2a7ccd7.
Changed lines: Changed C/C++ lines covered: 31/31 (100.00%) · Uncovered code |
| || !(isValidIdentifierBegin(argument.front()) || argument.front() == '`' || argument.front() == '"')) | ||
| return false; | ||
|
|
||
| const std::string_view first_word(argument.begin(), std::ranges::find_if(argument, isWhitespaceASCII)); |
There was a problem hiding this comment.
Valid SHOW TABLES continuations are tokenized on SQL token boundaries, not whitespace. Here first_word becomes WHERE(name, LIKE'd%', or FROM/*x*/system, so inputs like \d WHERE(name LIKE 'd%'), \d LIKE'd%', and \d FROM/*x*/system get routed to DESCRIBE TABLE ... instead of staying on the listing path. Since the new contract is that any argument continuing the SHOW TABLES query keeps the listing, this needs to split on the first SQL token boundary (or reuse the lexer/parser) rather than only on isWhitespaceASCII.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 17 s compile time in total, 7 of them have a recent master baseline. |
The
psql-style\dof the interactive client is a textual alias ofSHOW TABLES, so\d hitsbecameSHOW TABLES hits, which is a syntax error. Inpsqla bare\dlists the relations and\d <name>describes one, and that is what it does here now: given a table name it expands toDESCRIBE TABLE, while a bare\dstill lists the tables.An argument that continues the listing query instead -
\d FROM system,\d LIKE 'hits%'- keeps the listing, as it does today. A table whose name is spelled as one of the clauses thatSHOW TABLESaccepts (FROM,IN,NOT,LIKE,ILIKE,WHERE,LIMIT,INTO,FORMAT,SETTINGS,PARALLEL) has to be quoted, which is also what tells it apart from the clause.The alias can now be followed by a
;as well, so\d;and\l;are no longer syntax errors.Closes: #118180
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
psql-style\dof the interactive client now describes a table when a table name is given (\d hits), like it does inpsql; without an argument it still lists the tables.Workflow [PR]
Sync PR [sync-upstream/pr/118281]