summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2009-07-20 03:46:45 +0000
committerTom Lane2009-07-20 03:46:45 +0000
commitd47bee55e1cec455df955b0bdd4b9cf9d81af5a4 (patch)
tree00bea00adaa27fce8728d9f76897ffc3c663ad43
parent128e1916ac53e72e6650686fbbe6b6f64a219807 (diff)
Remove unnecessary and version-sensitive dependence on the exact set of
column names to be found in a sequence. Per gripe from Bruce.
-rw-r--r--src/bin/psql/describe.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index e73d1eab10..41130d01b2 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1131,29 +1131,22 @@ describeOneTableDetails(const char *schemaname,
*/
if (tableinfo.relkind == 'S')
{
- PGresult *result;
-
-#define SEQ_NUM_COLS 10
- printfPQExpBuffer(&buf,
- "SELECT sequence_name, last_value,\n"
- " start_value, increment_by,\n"
- " max_value, min_value, cache_value,\n"
- " log_cnt, is_cycled, is_called\n"
- "FROM %s",
- fmtId(schemaname));
+ printfPQExpBuffer(&buf, "SELECT * FROM %s", fmtId(schemaname));
/* must be separate because fmtId isn't reentrant */
appendPQExpBuffer(&buf, ".%s", fmtId(relationname));
- result = PSQLexec(buf.data, false);
- if (!result)
+ res = PSQLexec(buf.data, false);
+ if (!res)
goto error_return;
- seq_values = pg_malloc_zero((SEQ_NUM_COLS + 1) * sizeof(*seq_values));
+ seq_values = pg_malloc((PQnfields(res) + 1) * sizeof(*seq_values));
- for (i = 0; i < SEQ_NUM_COLS; i++)
- seq_values[i] = pg_strdup(PQgetvalue(result, 0, i));
+ for (i = 0; i < PQnfields(res); i++)
+ seq_values[i] = pg_strdup(PQgetvalue(res, 0, i));
+ seq_values[i] = NULL;
- PQclear(result);
+ PQclear(res);
+ res = NULL;
}
/* Get column info */