Skip to content

Commit 888d333

Browse files
committed
Remove unnecessary and version-sensitive dependence on the exact set of
column names to be found in a sequence. Per gripe from Bruce.
1 parent e73131a commit 888d333

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/bin/psql/describe.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
1010
*
11-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.224 2009/07/07 21:45:05 tgl Exp $
11+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.225 2009/07/20 03:46:45 tgl Exp $
1212
*/
1313
#include "postgres_fe.h"
1414

@@ -1131,29 +1131,22 @@ describeOneTableDetails(const char *schemaname,
11311131
*/
11321132
if (tableinfo.relkind == 'S')
11331133
{
1134-
PGresult *result;
1135-
1136-
#define SEQ_NUM_COLS 10
1137-
printfPQExpBuffer(&buf,
1138-
"SELECT sequence_name, last_value,\n"
1139-
" start_value, increment_by,\n"
1140-
" max_value, min_value, cache_value,\n"
1141-
" log_cnt, is_cycled, is_called\n"
1142-
"FROM %s",
1143-
fmtId(schemaname));
1134+
printfPQExpBuffer(&buf, "SELECT * FROM %s", fmtId(schemaname));
11441135
/* must be separate because fmtId isn't reentrant */
11451136
appendPQExpBuffer(&buf, ".%s", fmtId(relationname));
11461137

1147-
result = PSQLexec(buf.data, false);
1148-
if (!result)
1138+
res = PSQLexec(buf.data, false);
1139+
if (!res)
11491140
goto error_return;
11501141

1151-
seq_values = pg_malloc_zero((SEQ_NUM_COLS + 1) * sizeof(*seq_values));
1142+
seq_values = pg_malloc((PQnfields(res) + 1) * sizeof(*seq_values));
11521143

1153-
for (i = 0; i < SEQ_NUM_COLS; i++)
1154-
seq_values[i] = pg_strdup(PQgetvalue(result, 0, i));
1144+
for (i = 0; i < PQnfields(res); i++)
1145+
seq_values[i] = pg_strdup(PQgetvalue(res, 0, i));
1146+
seq_values[i] = NULL;
11551147

1156-
PQclear(result);
1148+
PQclear(res);
1149+
res = NULL;
11571150
}
11581151

11591152
/* Get column info */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy