mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Add column storage type to psql \d+ display.
Gregory Stark
This commit is contained in:
parent
c9b2591efc
commit
71e0296dbc
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.177 2008/07/14 22:00:04 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.178 2008/07/14 22:51:48 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
|
|
||||||
@ -811,7 +811,7 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
printTableContent cont;
|
printTableContent cont;
|
||||||
int i;
|
int i;
|
||||||
char *view_def = NULL;
|
char *view_def = NULL;
|
||||||
char *headers[4];
|
char *headers[5];
|
||||||
char **modifiers = NULL;
|
char **modifiers = NULL;
|
||||||
char **ptr;
|
char **ptr;
|
||||||
PQExpBufferData title;
|
PQExpBufferData title;
|
||||||
@ -878,7 +878,7 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
"\n WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),"
|
"\n WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),"
|
||||||
"\n a.attnotnull, a.attnum");
|
"\n a.attnotnull, a.attnum");
|
||||||
if (verbose)
|
if (verbose)
|
||||||
appendPQExpBuffer(&buf, ", pg_catalog.col_description(a.attrelid, a.attnum)");
|
appendPQExpBuffer(&buf, ", a.attstorage, pg_catalog.col_description(a.attrelid, a.attnum)");
|
||||||
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a");
|
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a");
|
||||||
if (tableinfo.relkind == 'i')
|
if (tableinfo.relkind == 'i')
|
||||||
appendPQExpBuffer(&buf, ", pg_catalog.pg_index i");
|
appendPQExpBuffer(&buf, ", pg_catalog.pg_index i");
|
||||||
@ -933,18 +933,21 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
|
|
||||||
/* Set the number of columns, and their names */
|
/* Set the number of columns, and their names */
|
||||||
cols = 2;
|
cols = 2;
|
||||||
headers[0] = "Column";
|
headers[0] = gettext_noop("Column");
|
||||||
headers[1] = "Type";
|
headers[1] = gettext_noop("Type");
|
||||||
|
|
||||||
if (tableinfo.relkind == 'r' || tableinfo.relkind == 'v')
|
if (tableinfo.relkind == 'r' || tableinfo.relkind == 'v')
|
||||||
{
|
{
|
||||||
show_modifiers = true;
|
show_modifiers = true;
|
||||||
headers[cols++] = "Modifiers";
|
headers[cols++] = gettext_noop("Modifiers");
|
||||||
modifiers = pg_malloc_zero((numrows + 1) * sizeof(*modifiers));
|
modifiers = pg_malloc_zero((numrows + 1) * sizeof(*modifiers));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
headers[cols++] = "Description";
|
{
|
||||||
|
headers[cols++] = gettext_noop("Storage");
|
||||||
|
headers[cols++] = gettext_noop("Description");
|
||||||
|
}
|
||||||
|
|
||||||
printTableInit(&cont, &myopt, title.data, cols, numrows);
|
printTableInit(&cont, &myopt, title.data, cols, numrows);
|
||||||
|
|
||||||
@ -1000,9 +1003,18 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
printTableAddCell(&cont, modifiers[i], false);
|
printTableAddCell(&cont, modifiers[i], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Description */
|
/* Storage and Description */
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printTableAddCell(&cont, PQgetvalue(res, i, 5), false);
|
{
|
||||||
|
char *storage = PQgetvalue(res, i, 5);
|
||||||
|
printTableAddCell(&cont, (storage[0]=='p' ? "plain" :
|
||||||
|
(storage[0]=='m' ? "main" :
|
||||||
|
(storage[0]=='x' ? "extended" :
|
||||||
|
(storage[0]=='e' ? "external" :
|
||||||
|
"???")))),
|
||||||
|
false);
|
||||||
|
printTableAddCell(&cont, PQgetvalue(res, i, 6), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make footers */
|
/* Make footers */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user