Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b34f6ab

Browse files
committed
psql backward compatibility fix
For servers older than 8.3, sort display of child tables by relname instead of oid::regclass::text, because the cast from regclass to text did not work back then. The older display may be slightly worse when different schemas are involved, but that should be rare enough.
1 parent ba3fb57 commit b34f6ab

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/bin/psql/describe.c

Lines changed: 5 additions & 2 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.222 2009/07/07 19:05:57 petere Exp $
11+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.223 2009/07/07 20:32:20 petere Exp $
1212
*/
1313
#include "postgres_fe.h"
1414

@@ -1821,7 +1821,10 @@ describeOneTableDetails(const char *schemaname,
18211821
PQclear(result);
18221822

18231823
/* print child tables */
1824-
printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND i.inhparent = '%s' ORDER BY c.oid::pg_catalog.regclass::text;", oid);
1824+
if (pset.sversion >= 80300)
1825+
printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND i.inhparent = '%s' ORDER BY c.oid::pg_catalog.regclass::text;", oid);
1826+
else
1827+
printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND i.inhparent = '%s' ORDER BY c.relname;", oid);
18251828

18261829
result = PSQLexec(buf.data, false);
18271830
if (!result)

0 commit comments

Comments
 (0)