Tom Lane wrote:
> Alvaro Herrera <[email protected]> writes:
> > This version should fix these issues. I refrained from adding more ? :
> > expressions because it starts getting ugly for my taste.
>
> I think you might as well just introduce two separate code paths to
> produce the 8.4 and pre-8.4 queries, so that you don't need the LEFT
> JOIN in the pre-8.4 path.
Right, see attached. (Separating the last two cases is probably
overkill ...?) I tested with HEAD, 8.2 and 8.0, seems to work fine.
> IMHO the cut-and-paste way that we usually
> do it in pg_dump is a whole lot easier to read and maintain than this
> sort of ?: spaghetti.
Hmm, so should we try to get rid of them in a more consistent fashion?
Index: src/bin/psql/describe.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.198
diff -c -p -r1.198 describe.c
*** src/bin/psql/describe.c 22 Jan 2009 20:16:08 -0000 1.198
--- src/bin/psql/describe.c 11 Feb 2009 17:57:03 -0000
***************
*** 8,14 ****
*
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
*
! * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.198 2009-01-22 20:16:08 tgl Exp $
*/
#include "postgres_fe.h"
--- 8,14 ----
*
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
*
! * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.197 2009/01/20 02:13:42 momjian Exp $
*/
#include "postgres_fe.h"
*************** describeOneTableDetails(const char *sche
*** 909,924 ****
initPQExpBuffer(&tmpbuf);
/* Get general table info */
! printfPQExpBuffer(&buf,
! "SELECT relchecks, relkind, relhasindex, relhasrules, %s, "
! "relhasoids"
! "%s%s\n"
! "FROM pg_catalog.pg_class WHERE oid = '%s'",
! (pset.sversion >= 80400 ? "relhastriggers" : "reltriggers <> 0"),
! (pset.sversion >= 80200 && verbose ?
! ", pg_catalog.array_to_string(reloptions, E', ')" : ",''"),
! (pset.sversion >= 80000 ? ", reltablespace" : ""),
! oid);
res = PSQLexec(buf.data, false);
if (!res)
goto error_return;
--- 909,959 ----
initPQExpBuffer(&tmpbuf);
/* Get general table info */
! if (pset.sversion >= 80400)
! {
! printfPQExpBuffer(&buf,
! "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
! "c.relhastriggers, c.relhasoids, "
! "%s, c.reltablespace\n"
! "FROM pg_catalog.pg_class c\n "
! "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
! "WHERE c.oid = '%s'\n",
! (verbose ?
! "pg_catalog.array_to_string(c.reloptions || "
! "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
! : "''"),
! oid);
! }
! else if (pset.sversion >= 80200)
! {
! printfPQExpBuffer(&buf,
! "SELECT relchecks, relkind, relhasindex, relhasrules, "
! "reltriggers <> 0, relhasoids, "
! "%s, reltablespace\n"
! "FROM pg_catalog.pg_class WHERE oid = '%s'",
! (verbose ?
! "pg_catalog.array_to_string(reloptions, E', ')" : ",''"),
! oid);
! }
! else if (pset.sversion >= 80000)
! {
! printfPQExpBuffer(&buf,
! "SELECT relchecks, relkind, relhasindex, relhasrules, "
! "reltriggers <> 0, relhasoids, "
! "'', reltablespace\n"
! "FROM pg_catalog.pg_class WHERE oid = '%s'",
! oid);
! }
! else
! {
! printfPQExpBuffer(&buf,
! "SELECT relchecks, relkind, relhasindex, relhasrules, "
! "reltriggers <> 0, relhasoids, "
! "'', ''\n"
! "FROM pg_catalog.pg_class WHERE oid = '%s'",
! oid);
! }
!
res = PSQLexec(buf.data, false);
if (!res)
goto error_return;
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers