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

Commitdf38d79

Browse files
committed
Adjust psql describe queries so that any pg_foo_is_visible() condition
is applied last, after other constraints such as name patterns. Thisis useful first because the pg_foo_is_visible() functions are relativelyexpensive, and second because it minimizes the prospects for raceconditions. The change is fragile though since it makes unwarrantedassumptions about planner behavior, ie, that WHERE clauses will beexecuted in the original order if there's not reason to change it.This should fix ... or at least hide ... an intermittent failure in theprepared_xacts regression test, while we think about what else to do.
1 parent24ce143 commitdf38d79

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

‎src/bin/psql/describe.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.120 2005/07/02 17:01:52 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.121 2005/07/18 17:40:14 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"describe.h"
@@ -421,7 +421,7 @@ permissionsList(const char *pattern)
421421
*/
422422
processNamePattern(&buf,pattern, true, false,
423423
"n.nspname","c.relname",NULL,
424-
"pg_catalog.pg_table_is_visible(c.oid) ANDn.nspname !~ '^pg_'");
424+
"n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)");
425425

426426
appendPQExpBuffer(&buf,"ORDER BY 1, 2;");
427427

@@ -1913,6 +1913,32 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
19131913
/*
19141914
* Now decide what we need to emit.
19151915
*/
1916+
if (namebuf.len>0)
1917+
{
1918+
/* We have a name pattern, so constrain the namevar(s) */
1919+
1920+
appendPQExpBufferChar(&namebuf,'$');
1921+
/* Optimize away ".*$", and possibly the whole pattern */
1922+
if (namebuf.len >=3&&
1923+
strcmp(namebuf.data+ (namebuf.len-3),".*$")==0)
1924+
namebuf.data[namebuf.len-3]='\0';
1925+
1926+
if (namebuf.data[0])
1927+
{
1928+
WHEREAND();
1929+
if (altnamevar)
1930+
appendPQExpBuffer(buf,
1931+
"(%s ~ '^%s'\n"
1932+
" OR %s ~ '^%s')\n",
1933+
namevar,namebuf.data,
1934+
altnamevar,namebuf.data);
1935+
else
1936+
appendPQExpBuffer(buf,
1937+
"%s ~ '^%s'\n",
1938+
namevar,namebuf.data);
1939+
}
1940+
}
1941+
19161942
if (schemabuf.len>0)
19171943
{
19181944
/* We have a schema pattern, so constrain the schemavar */
@@ -1940,32 +1966,6 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
19401966
}
19411967
}
19421968

1943-
if (namebuf.len>0)
1944-
{
1945-
/* We have a name pattern, so constrain the namevar(s) */
1946-
1947-
appendPQExpBufferChar(&namebuf,'$');
1948-
/* Optimize away ".*$", and possibly the whole pattern */
1949-
if (namebuf.len >=3&&
1950-
strcmp(namebuf.data+ (namebuf.len-3),".*$")==0)
1951-
namebuf.data[namebuf.len-3]='\0';
1952-
1953-
if (namebuf.data[0])
1954-
{
1955-
WHEREAND();
1956-
if (altnamevar)
1957-
appendPQExpBuffer(buf,
1958-
"(%s ~ '^%s'\n"
1959-
" OR %s ~ '^%s')\n",
1960-
namevar,namebuf.data,
1961-
altnamevar,namebuf.data);
1962-
else
1963-
appendPQExpBuffer(buf,
1964-
"%s ~ '^%s'\n",
1965-
namevar,namebuf.data);
1966-
}
1967-
}
1968-
19691969
termPQExpBuffer(&schemabuf);
19701970
termPQExpBuffer(&namebuf);
19711971

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp