public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 2/3] Allow composite types in bootstrap
2+ messages / 2 participants
[nested] [flat]

* [PATCH 2/3] Allow composite types in bootstrap
@ 2020-11-17 15:28  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Justin Pryzby @ 2020-11-17 15:28 UTC (permalink / raw)

---
 src/backend/bootstrap/bootstrap.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 18eb62ca47..e4fc75ab84 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -916,6 +916,7 @@ gettype(char *type)
 {
 	if (Typ != NIL)
 	{
+		static bool did_reread PG_USED_FOR_ASSERTS_ONLY = false; /* Already reread pg_types */
 		ListCell *lc;
 
 		foreach (lc, Typ)
@@ -927,6 +928,33 @@ gettype(char *type)
 				return app->am_oid;
 			}
 		}
+
+		/*
+		 * The type wasn't known; check again to handle composite
+		 * types, added since first populating the array.
+		 */
+
+		/*
+		 * Once all the types are populated and we handled composite
+		 * types, shouldn't need to do that again.
+		 */
+		Assert(!did_reread);
+		did_reread = true;
+
+		list_free_deep(Typ);
+		Typ = NULL;
+		populate_typ_array();
+
+		/* Need to avoid infinite recursion... */
+		foreach (lc, Typ)
+		{
+			struct typmap *app = lfirst(lc);
+			if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0)
+			{
+				Ap = app;
+				return app->am_oid;
+			}
+		}
 	}
 	else
 	{
-- 
2.26.2


--------------EED78D4A67CFF327F6B880D2
Content-Type: text/x-patch; charset=UTF-8;
 name="0003-Extended-statistics-on-expressions-20210122b.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0003-Extended-statistics-on-expressions-20210122b.patch"



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* psql: Add verbose option (+) for \dX command
@ 2026-02-19 15:38  Matheus Alcantara <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Matheus Alcantara @ 2026-02-19 15:38 UTC (permalink / raw)
  To: [email protected]

Hi,

While I was reviewing another patch I noticed that we don't have the
verbose option(+) on \dX command to get extended statistics comments.

Althrought comments can be obtained using obj_description() perhaps it
can be useful to have a verbose option on \dX to get this information.

Thoughts?

--
Matheus Alcantara
EDB: https://www.enterprisedb.com

From 9786d573faa048f0ba705a12a249652c704d26a4 Mon Sep 17 00:00:00 2001
From: Matheus Alcantara <[email protected]>
Date: Thu, 19 Feb 2026 10:55:00 -0300
Subject: [PATCH v1] psql: Add verbose option (+) for \dX command

---
 src/bin/psql/command.c  |  2 +-
 src/bin/psql/describe.c | 11 ++++++++---
 src/bin/psql/describe.h |  2 +-
 src/bin/psql/help.c     |  2 +-
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 213d48500de..3412b0e3d28 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1277,7 +1277,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
 					success = listExtensions(pattern);
 				break;
 			case 'X':			/* Extended Statistics */
-				success = listExtendedStats(pattern);
+				success = listExtendedStats(pattern, show_verbose);
 				break;
 			case 'y':			/* Event Triggers */
 				success = listEventTriggers(pattern, show_verbose);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 3584c4e1428..9fc3c5f9ad4 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4890,7 +4890,7 @@ listEventTriggers(const char *pattern, bool verbose)
  * Describes extended statistics.
  */
 bool
-listExtendedStats(const char *pattern)
+listExtendedStats(const char *pattern, bool verbose)
 {
 	PQExpBufferData buf;
 	PGresult   *res;
@@ -4947,12 +4947,17 @@ listExtendedStats(const char *pattern)
 	{
 		appendPQExpBuffer(&buf,
 						  ",\nCASE WHEN " CppAsString2(STATS_EXT_MCV) " = any(es.stxkind) THEN 'defined' \n"
-						  "END AS \"%s\" ",
+						  "END AS \"%s\"",
 						  gettext_noop("MCV"));
 	}
 
+	if (verbose)
+		appendPQExpBuffer(&buf,
+						  ",\npg_catalog.obj_description(es.oid, 'pg_statistic_ext') AS \"%s\"",
+						  gettext_noop("Description"));
+
 	appendPQExpBufferStr(&buf,
-						 " \nFROM pg_catalog.pg_statistic_ext es \n");
+						 "\nFROM pg_catalog.pg_statistic_ext es\n");
 
 	if (!validateSQLNamePattern(&buf, pattern,
 								false, false,
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index b60a2ad0e14..47fae5ceafb 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -114,7 +114,7 @@ extern bool listExtensions(const char *pattern);
 extern bool listExtensionContents(const char *pattern);
 
 /* \dX */
-extern bool listExtendedStats(const char *pattern);
+extern bool listExtendedStats(const char *pattern, bool verbose);
 
 /* \dy */
 extern bool listEventTriggers(const char *pattern, bool verbose);
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index dfd9dd73078..bcfdbbba571 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -267,7 +267,7 @@ slashUsage(unsigned short int pager)
 	HELP0("  \\du[Sx+] [PATTERN]     list roles\n");
 	HELP0("  \\dv[Sx+] [PATTERN]     list views\n");
 	HELP0("  \\dx[x+]  [PATTERN]     list extensions\n");
-	HELP0("  \\dX[x]   [PATTERN]     list extended statistics\n");
+	HELP0("  \\dX[x+]  [PATTERN]     list extended statistics\n");
 	HELP0("  \\dy[x+]  [PATTERN]     list event triggers\n");
 	HELP0("  \\l[x+]   [PATTERN]     list databases\n");
 	HELP0("  \\sf[+]   FUNCNAME      show a function's definition\n");
-- 
2.52.0



Attachments:

  [text/plain] v1-0001-psql-Add-verbose-option-for-dX-command.patch (3.1K, ../../[email protected]/2-v1-0001-psql-Add-verbose-option-for-dX-command.patch)
  download | inline diff:
From 9786d573faa048f0ba705a12a249652c704d26a4 Mon Sep 17 00:00:00 2001
From: Matheus Alcantara <[email protected]>
Date: Thu, 19 Feb 2026 10:55:00 -0300
Subject: [PATCH v1] psql: Add verbose option (+) for \dX command

---
 src/bin/psql/command.c  |  2 +-
 src/bin/psql/describe.c | 11 ++++++++---
 src/bin/psql/describe.h |  2 +-
 src/bin/psql/help.c     |  2 +-
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 213d48500de..3412b0e3d28 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1277,7 +1277,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
 					success = listExtensions(pattern);
 				break;
 			case 'X':			/* Extended Statistics */
-				success = listExtendedStats(pattern);
+				success = listExtendedStats(pattern, show_verbose);
 				break;
 			case 'y':			/* Event Triggers */
 				success = listEventTriggers(pattern, show_verbose);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 3584c4e1428..9fc3c5f9ad4 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4890,7 +4890,7 @@ listEventTriggers(const char *pattern, bool verbose)
  * Describes extended statistics.
  */
 bool
-listExtendedStats(const char *pattern)
+listExtendedStats(const char *pattern, bool verbose)
 {
 	PQExpBufferData buf;
 	PGresult   *res;
@@ -4947,12 +4947,17 @@ listExtendedStats(const char *pattern)
 	{
 		appendPQExpBuffer(&buf,
 						  ",\nCASE WHEN " CppAsString2(STATS_EXT_MCV) " = any(es.stxkind) THEN 'defined' \n"
-						  "END AS \"%s\" ",
+						  "END AS \"%s\"",
 						  gettext_noop("MCV"));
 	}
 
+	if (verbose)
+		appendPQExpBuffer(&buf,
+						  ",\npg_catalog.obj_description(es.oid, 'pg_statistic_ext') AS \"%s\"",
+						  gettext_noop("Description"));
+
 	appendPQExpBufferStr(&buf,
-						 " \nFROM pg_catalog.pg_statistic_ext es \n");
+						 "\nFROM pg_catalog.pg_statistic_ext es\n");
 
 	if (!validateSQLNamePattern(&buf, pattern,
 								false, false,
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index b60a2ad0e14..47fae5ceafb 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -114,7 +114,7 @@ extern bool listExtensions(const char *pattern);
 extern bool listExtensionContents(const char *pattern);
 
 /* \dX */
-extern bool listExtendedStats(const char *pattern);
+extern bool listExtendedStats(const char *pattern, bool verbose);
 
 /* \dy */
 extern bool listEventTriggers(const char *pattern, bool verbose);
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index dfd9dd73078..bcfdbbba571 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -267,7 +267,7 @@ slashUsage(unsigned short int pager)
 	HELP0("  \\du[Sx+] [PATTERN]     list roles\n");
 	HELP0("  \\dv[Sx+] [PATTERN]     list views\n");
 	HELP0("  \\dx[x+]  [PATTERN]     list extensions\n");
-	HELP0("  \\dX[x]   [PATTERN]     list extended statistics\n");
+	HELP0("  \\dX[x+]  [PATTERN]     list extended statistics\n");
 	HELP0("  \\dy[x+]  [PATTERN]     list event triggers\n");
 	HELP0("  \\l[x+]   [PATTERN]     list databases\n");
 	HELP0("  \\sf[+]   FUNCNAME      show a function's definition\n");
-- 
2.52.0



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-02-19 15:38 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 15:28 [PATCH 2/3] Allow composite types in bootstrap Justin Pryzby <[email protected]>
2026-02-19 15:38 psql: Add verbose option (+) for \dX command Matheus Alcantara <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox