1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-24 14:22:24 +03:00

Backpatch to 8.1.X. Already applied to CVS HEAD.

---------------------------------------------------------------------------

> True, but they're not being used where you'd expect. This seems to be
> something to do with the fact that it's not pg_authid which is being
> accessed, but rather the view pg_roles.

I looked into this and it seems the problem is that the view doesn't
get flattened into the main query because of the has_nullable_targetlist
limitation in prepjointree.c.  That's triggered because pg_roles has
        '********'::text AS rolpassword
which isn't nullable, meaning it would produce wrong behavior if
referenced above the outer join.

Ultimately, the reason this is a problem is that the planner deals only
in simple Vars while processing joins; it doesn't want to think about
expressions.  I'm starting to think that it may be time to fix this,
because I've run into several related restrictions lately, but it seems
like a nontrivial project.

In the meantime, reducing the LEFT JOIN to pg_roles to a JOIN as per
Peter's suggestion seems like the best short-term workaround.
This commit is contained in:
Bruce Momjian
2006-03-02 19:40:29 +00:00
parent 006bd450fe
commit 3fb582c3bc

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2005, PostgreSQL Global Development Group * Copyright (c) 2000-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.129.2.1 2005/11/22 18:23:27 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.129.2.2 2006/03/02 19:40:29 momjian Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "describe.h" #include "describe.h"
@ -193,7 +193,7 @@ describeFunctions(const char *pattern, bool verbose)
"\nFROM pg_catalog.pg_proc p" "\nFROM pg_catalog.pg_proc p"
"\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace" "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace"
"\n LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang" "\n LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang"
"\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = p.proowner\n"); "\n JOIN pg_catalog.pg_roles r ON r.oid = p.proowner\n");
/* /*
* we skip in/out funcs by excluding functions that take or return cstring * we skip in/out funcs by excluding functions that take or return cstring
@ -366,7 +366,7 @@ listAllDbs(bool verbose)
_("Description")); _("Description"));
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_database d" "\nFROM pg_catalog.pg_database d"
"\n LEFT JOIN pg_catalog.pg_roles r ON d.datdba = r.oid\n" "\n JOIN pg_catalog.pg_roles r ON d.datdba = r.oid\n"
"ORDER BY 1;"); "ORDER BY 1;");
res = PSQLexec(buf.data, false); res = PSQLexec(buf.data, false);
@ -1479,7 +1479,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_class c" "\nFROM pg_catalog.pg_class c"
"\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = c.relowner" "\n JOIN pg_catalog.pg_roles r ON r.oid = c.relowner"
"\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace"); "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace");
if (showIndexes) if (showIndexes)
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
@ -1721,7 +1721,7 @@ listSchemas(const char *pattern, bool verbose)
_("Access privileges"), _("Description")); _("Access privileges"), _("Description"));
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_roles r\n" "\nFROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_roles r\n"
" ON n.nspowner=r.oid\n" " ON n.nspowner=r.oid\n"
"WHERE (n.nspname !~ '^pg_temp_' OR\n" "WHERE (n.nspname !~ '^pg_temp_' OR\n"
" n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */ " n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */