mirror of
https://github.com/postgres/postgres.git
synced 2025-06-05 23:56:58 +03:00
Fix psql \d commands to behave properly when a pattern using regex | is given.
Formerly they'd emit '^foo|bar$' which is wrong because the anchors are parsed as part of the alternatives; must emit '^(foo|bar)$' to get expected behavior. Same as bug found previously in similar_escape(). Already fixed in HEAD, this is just back-porting the part of that patch that was a bug fix.
This commit is contained in:
parent
61c91fd2d2
commit
9c2b6ec695
@ -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.3 2006/10/07 22:21:44 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.129.2.4 2006/10/10 16:15:22 tgl Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#include "describe.h"
|
#include "describe.h"
|
||||||
@ -1876,24 +1876,19 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
|
|||||||
{
|
{
|
||||||
/* We have a name pattern, so constrain the namevar(s) */
|
/* We have a name pattern, so constrain the namevar(s) */
|
||||||
|
|
||||||
appendPQExpBufferChar(&namebuf, '$');
|
/* Optimize away a "*" pattern */
|
||||||
/* Optimize away ".*$", and possibly the whole pattern */
|
if (strcmp(namebuf.data, ".*") != 0)
|
||||||
if (namebuf.len >= 3 &&
|
|
||||||
strcmp(namebuf.data + (namebuf.len - 3), ".*$") == 0)
|
|
||||||
namebuf.data[namebuf.len - 3] = '\0';
|
|
||||||
|
|
||||||
if (namebuf.data[0])
|
|
||||||
{
|
{
|
||||||
WHEREAND();
|
WHEREAND();
|
||||||
if (altnamevar)
|
if (altnamevar)
|
||||||
appendPQExpBuffer(buf,
|
appendPQExpBuffer(buf,
|
||||||
"(%s ~ '^%s'\n"
|
"(%s ~ '^(%s)$'\n"
|
||||||
" OR %s ~ '^%s')\n",
|
" OR %s ~ '^(%s)$')\n",
|
||||||
namevar, namebuf.data,
|
namevar, namebuf.data,
|
||||||
altnamevar, namebuf.data);
|
altnamevar, namebuf.data);
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(buf,
|
appendPQExpBuffer(buf,
|
||||||
"%s ~ '^%s'\n",
|
"%s ~ '^(%s)$'\n",
|
||||||
namevar, namebuf.data);
|
namevar, namebuf.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1902,16 +1897,11 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
|
|||||||
{
|
{
|
||||||
/* We have a schema pattern, so constrain the schemavar */
|
/* We have a schema pattern, so constrain the schemavar */
|
||||||
|
|
||||||
appendPQExpBufferChar(&schemabuf, '$');
|
/* Optimize away a "*" pattern */
|
||||||
/* Optimize away ".*$", and possibly the whole pattern */
|
if (strcmp(schemabuf.data, ".*") != 0 && schemavar)
|
||||||
if (schemabuf.len >= 3 &&
|
|
||||||
strcmp(schemabuf.data + (schemabuf.len - 3), ".*$") == 0)
|
|
||||||
schemabuf.data[schemabuf.len - 3] = '\0';
|
|
||||||
|
|
||||||
if (schemabuf.data[0] && schemavar)
|
|
||||||
{
|
{
|
||||||
WHEREAND();
|
WHEREAND();
|
||||||
appendPQExpBuffer(buf, "%s ~ '^%s'\n",
|
appendPQExpBuffer(buf, "%s ~ '^(%s)$'\n",
|
||||||
schemavar, schemabuf.data);
|
schemavar, schemabuf.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user