Skip to content

Commit 2644034

Browse files
zhangyue1818tuhaihe
authored andcommitted
Fix assertion failure when running \dit+.
The translate_columns array had 9 elements but the query returned 10 columns when both tables and indexes were shown. Fixed by: 1. Expanding translate_columns array to 10 elements 2. Properly tracking cols_so_far when Storage column is added
1 parent e51dd08 commit 2644034

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/bin/psql/describe.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5091,7 +5091,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
50915091
PGresult *res;
50925092
printQueryOpt myopt = pset.popt;
50935093
int cols_so_far;
5094-
bool translate_columns[] = {false, false, true, false, false, false, false, false, false};
5094+
bool translate_columns[] = {false, false, true, false, false, false, false, false, false, false};
50955095

50965096
/* If tabtypes is empty, we default to \dtvmsE (but see also command.c) */
50975097
if (!(showTables || showIndexes || showViews || showMatViews || showSeq || showForeign || showDirectory))
@@ -5164,6 +5164,8 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
51645164
appendPQExpBuffer(&buf, " WHEN 'f' THEN '%s'", gettext_noop("foreign"));
51655165
appendPQExpBuffer(&buf, " END as \"%s\"\n", gettext_noop("Storage"));
51665166
}
5167+
translate_columns[cols_so_far] = true;
5168+
cols_so_far++;
51675169
}
51685170

51695171
if (showIndexes)

src/test/regress/expected/psql.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,6 +2864,13 @@ Access method: heap_psql
28642864
f2 | character(100) | | | | extended | |
28652865
Access method: heap
28662866

2867+
\dit+ tbl_heap
2868+
List of relations
2869+
Schema | Name | Type | Owner | Storage | Table | Persistence | Access method | Size | Description
2870+
-----------------+----------+-------+----------------------+---------+-------+-------------+---------------+---------+-------------
2871+
tableam_display | tbl_heap | table | regress_display_role | heap | | permanent | heap | 0 bytes |
2872+
(1 row)
2873+
28672874
-- AM is displayed for tables, indexes and materialized views.
28682875
\d+
28692876
List of relations

src/test/regress/sql/psql.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ CREATE MATERIALIZED VIEW mat_view_heap_psql USING heap_psql AS SELECT f1 from tb
477477
\set HIDE_TABLEAM off
478478
\d+ tbl_heap_psql
479479
\d+ tbl_heap
480+
\dit+ tbl_heap
480481
-- AM is displayed for tables, indexes and materialized views.
481482
\d+
482483
\dt+

0 commit comments

Comments
 (0)