Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit787020f

Browse files
committed
Improve psql \d+ to show TOAST reloptions too. Per complaint from
ITAGAKI Takahiro.
1 parent20a43b1 commit787020f

File tree

1 file changed

+46
-11
lines changed

1 file changed

+46
-11
lines changed

‎src/bin/psql/describe.c

Lines changed: 46 additions & 11 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.198 2009/01/22 20:16:08 tgl Exp $
11+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.199 2009/02/11 19:12:04 alvherre Exp $
1212
*/
1313
#include"postgres_fe.h"
1414

@@ -909,16 +909,51 @@ describeOneTableDetails(const char *schemaname,
909909
initPQExpBuffer(&tmpbuf);
910910

911911
/* Get general table info */
912-
printfPQExpBuffer(&buf,
913-
"SELECT relchecks, relkind, relhasindex, relhasrules, %s, "
914-
"relhasoids"
915-
"%s%s\n"
916-
"FROM pg_catalog.pg_class WHERE oid = '%s'",
917-
(pset.sversion >=80400 ?"relhastriggers" :"reltriggers <> 0"),
918-
(pset.sversion >=80200&&verbose ?
919-
", pg_catalog.array_to_string(reloptions, E', ')" :",''"),
920-
(pset.sversion >=80000 ?", reltablespace" :""),
921-
oid);
912+
if (pset.sversion >=80400)
913+
{
914+
printfPQExpBuffer(&buf,
915+
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
916+
"c.relhastriggers, c.relhasoids, "
917+
"%s, c.reltablespace\n"
918+
"FROM pg_catalog.pg_class c\n "
919+
"LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
920+
"WHERE c.oid = '%s'\n",
921+
(verbose ?
922+
"pg_catalog.array_to_string(c.reloptions || "
923+
"array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
924+
:"''"),
925+
oid);
926+
}
927+
elseif (pset.sversion >=80200)
928+
{
929+
printfPQExpBuffer(&buf,
930+
"SELECT relchecks, relkind, relhasindex, relhasrules, "
931+
"reltriggers <> 0, relhasoids, "
932+
"%s, reltablespace\n"
933+
"FROM pg_catalog.pg_class WHERE oid = '%s'",
934+
(verbose ?
935+
"pg_catalog.array_to_string(reloptions, E', ')" :",''"),
936+
oid);
937+
}
938+
elseif (pset.sversion >=80000)
939+
{
940+
printfPQExpBuffer(&buf,
941+
"SELECT relchecks, relkind, relhasindex, relhasrules, "
942+
"reltriggers <> 0, relhasoids, "
943+
"'', reltablespace\n"
944+
"FROM pg_catalog.pg_class WHERE oid = '%s'",
945+
oid);
946+
}
947+
else
948+
{
949+
printfPQExpBuffer(&buf,
950+
"SELECT relchecks, relkind, relhasindex, relhasrules, "
951+
"reltriggers <> 0, relhasoids, "
952+
"'', ''\n"
953+
"FROM pg_catalog.pg_class WHERE oid = '%s'",
954+
oid);
955+
}
956+
922957
res=PSQLexec(buf.data, false);
923958
if (!res)
924959
gotoerror_return;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp