v2-0001-Print-empty-table-when-a-given-object-is-not-foun.patch
application/octet-stream
Filename: v2-0001-Print-empty-table-when-a-given-object-is-not-foun.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v2-0001
Subject: Print empty table when a given object is not found in a slash command
| File | + | − |
|---|---|---|
| src/bin/psql/describe.c | 1 | 80 |
From 36377dd05b7743a879606bc36c10a9d6c12a7fc5 Mon Sep 17 00:00:00 2001
From: Abhishek Chanda <abhishek.becs@gmail.com>
Date: Sat, 12 Apr 2025 22:30:17 -0500
Subject: [PATCH v2] Print empty table when a given object is not found in a
slash command
Currently, in a few cases we return an error of the form
Did not find any XXXX named YYYY while in some cases we
print a table with no rows. This patch changes a few of
the former to the later so that we have an uniform
interface.
---
src/bin/psql/describe.c | 81 +----------------------------------------
1 file changed, 1 insertion(+), 80 deletions(-)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 1d08268393e..ebb5d3b0c69 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1519,20 +1519,6 @@ describeTableDetails(const char *pattern, bool verbose, bool showSystem)
if (!res)
return false;
- if (PQntuples(res) == 0)
- {
- if (!pset.quiet)
- {
- if (pattern)
- pg_log_error("Did not find any relation named \"%s\".",
- pattern);
- else
- pg_log_error("Did not find any relations.");
- }
- PQclear(res);
- return false;
- }
-
for (i = 0; i < PQntuples(res); i++)
{
const char *oid;
@@ -1719,14 +1705,6 @@ describeOneTableDetails(const char *schemaname,
if (!res)
goto error_return;
- /* Did we get anything? */
- if (PQntuples(res) == 0)
- {
- if (!pset.quiet)
- pg_log_error("Did not find any relation with OID %s.", oid);
- goto error_return;
- }
-
tableinfo.checks = atoi(PQgetvalue(res, 0, 0));
tableinfo.relkind = *(PQgetvalue(res, 0, 1));
tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 2), "t") == 0;
@@ -3762,6 +3740,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
return false;
nrows = PQntuples(res);
+
attr = pg_malloc0((nrows + 1) * sizeof(*attr));
printTableInit(&cont, &myopt, _("List of roles"), ncols, nrows);
@@ -5403,20 +5382,6 @@ listTSParsersVerbose(const char *pattern)
if (!res)
return false;
- if (PQntuples(res) == 0)
- {
- if (!pset.quiet)
- {
- if (pattern)
- pg_log_error("Did not find any text search parser named \"%s\".",
- pattern);
- else
- pg_log_error("Did not find any text search parsers.");
- }
- PQclear(res);
- return false;
- }
-
for (i = 0; i < PQntuples(res); i++)
{
const char *oid;
@@ -5781,20 +5746,6 @@ listTSConfigsVerbose(const char *pattern)
if (!res)
return false;
- if (PQntuples(res) == 0)
- {
- if (!pset.quiet)
- {
- if (pattern)
- pg_log_error("Did not find any text search configuration named \"%s\".",
- pattern);
- else
- pg_log_error("Did not find any text search configurations.");
- }
- PQclear(res);
- return false;
- }
-
for (i = 0; i < PQntuples(res); i++)
{
const char *oid;
@@ -6256,20 +6207,6 @@ listExtensionContents(const char *pattern)
if (!res)
return false;
- if (PQntuples(res) == 0)
- {
- if (!pset.quiet)
- {
- if (pattern)
- pg_log_error("Did not find any extension named \"%s\".",
- pattern);
- else
- pg_log_error("Did not find any extensions.");
- }
- PQclear(res);
- return false;
- }
-
for (i = 0; i < PQntuples(res); i++)
{
const char *extname;
@@ -6603,22 +6540,6 @@ describePublications(const char *pattern)
return false;
}
- if (PQntuples(res) == 0)
- {
- if (!pset.quiet)
- {
- if (pattern)
- pg_log_error("Did not find any publication named \"%s\".",
- pattern);
- else
- pg_log_error("Did not find any publications.");
- }
-
- termPQExpBuffer(&buf);
- PQclear(res);
- return false;
- }
-
for (i = 0; i < PQntuples(res); i++)
{
const char align = 'l';
--
2.49.0