This is an automated email from the ASF dual-hosted git repository.
djwang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push:
new 2644034a0d0 Fix assertion failure when running \dit+.
2644034a0d0 is described below
commit 2644034a0d0f51af17271dacaeff9cb6d6a0c681
Author: zhangyue <[email protected]>
AuthorDate: Fri Nov 28 10:26:02 2025 +0800
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
---
src/bin/psql/describe.c | 4 +++-
src/test/regress/expected/psql.out | 7 +++++++
src/test/regress/sql/psql.sql | 1 +
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 9b65b884950..90c8bb777fa 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -5091,7 +5091,7 @@ listTables(const char *tabtypes, const char *pattern,
bool verbose, bool showSys
PGresult *res;
printQueryOpt myopt = pset.popt;
int cols_so_far;
- bool translate_columns[] = {false, false, true, false,
false, false, false, false, false};
+ bool translate_columns[] = {false, false, true, false,
false, false, false, false, false, false};
/* If tabtypes is empty, we default to \dtvmsE (but see also command.c)
*/
if (!(showTables || showIndexes || showViews || showMatViews || showSeq
|| showForeign || showDirectory))
@@ -5164,6 +5164,8 @@ listTables(const char *tabtypes, const char *pattern,
bool verbose, bool showSys
appendPQExpBuffer(&buf, " WHEN 'f' THEN '%s'",
gettext_noop("foreign"));
appendPQExpBuffer(&buf, " END as \"%s\"\n",
gettext_noop("Storage"));
}
+ translate_columns[cols_so_far] = true;
+ cols_so_far++;
}
if (showIndexes)
diff --git a/src/test/regress/expected/psql.out
b/src/test/regress/expected/psql.out
index 49504f1665b..a5951c0c6d1 100644
--- a/src/test/regress/expected/psql.out
+++ b/src/test/regress/expected/psql.out
@@ -2864,6 +2864,13 @@ Access method: heap_psql
f2 | character(100) | | | | extended |
|
Access method: heap
+\dit+ tbl_heap
+ List of relations
+ Schema | Name | Type | Owner | Storage | Table |
Persistence | Access method | Size | Description
+-----------------+----------+-------+----------------------+---------+-------+-------------+---------------+---------+-------------
+ tableam_display | tbl_heap | table | regress_display_role | heap | |
permanent | heap | 0 bytes |
+(1 row)
+
-- AM is displayed for tables, indexes and materialized views.
\d+
List of
relations
diff --git a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
index 1b17536838d..501579f22a8 100644
--- a/src/test/regress/sql/psql.sql
+++ b/src/test/regress/sql/psql.sql
@@ -477,6 +477,7 @@ CREATE MATERIALIZED VIEW mat_view_heap_psql USING heap_psql
AS SELECT f1 from tb
\set HIDE_TABLEAM off
\d+ tbl_heap_psql
\d+ tbl_heap
+\dit+ tbl_heap
-- AM is displayed for tables, indexes and materialized views.
\d+
\dt+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]