|
8 | 8 | *
|
9 | 9 | * Copyright (c) 2000-2009, PostgreSQL Global Development Group
|
10 | 10 | *
|
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 $ |
12 | 12 | */
|
13 | 13 | #include "postgres_fe.h"
|
14 | 14 |
|
@@ -1131,29 +1131,22 @@ describeOneTableDetails(const char *schemaname,
|
1131 | 1131 | */
|
1132 | 1132 | if (tableinfo.relkind == 'S')
|
1133 | 1133 | {
|
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)); |
1144 | 1135 | /* must be separate because fmtId isn't reentrant */
|
1145 | 1136 | appendPQExpBuffer(&buf, ".%s", fmtId(relationname));
|
1146 | 1137 |
|
1147 |
| - result = PSQLexec(buf.data, false); |
1148 |
| - if (!result) |
| 1138 | + res = PSQLexec(buf.data, false); |
| 1139 | + if (!res) |
1149 | 1140 | goto error_return;
|
1150 | 1141 |
|
1151 |
| - seq_values = pg_malloc_zero((SEQ_NUM_COLS + 1) * sizeof(*seq_values)); |
| 1142 | + seq_values = pg_malloc((PQnfields(res) + 1) * sizeof(*seq_values)); |
1152 | 1143 |
|
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; |
1155 | 1147 |
|
1156 |
| - PQclear(result); |
| 1148 | + PQclear(res); |
| 1149 | + res = NULL; |
1157 | 1150 | }
|
1158 | 1151 |
|
1159 | 1152 | /* Get column info */
|
|
0 commit comments