1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Fix problem with | in ~ comparison using index.

This commit is contained in:
Bruce Momjian
1999-05-21 04:40:04 +00:00
parent a1d9186067
commit 56b9a549c7

View File

@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.79 1999/05/20 12:12:55 wieck Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.80 1999/05/21 04:40:04 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
@ -5360,8 +5360,22 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
char *match_least = palloc(strlen(n->val.val.str)+2); char *match_least = palloc(strlen(n->val.val.str)+2);
char *match_most = palloc(strlen(n->val.val.str)+2); char *match_most = palloc(strlen(n->val.val.str)+2);
int pos, match_pos=0; int pos, match_pos=0;
bool found_pipe = false;
for (pos = 1; n->val.val.str[pos]; pos++)
{
if (n->val.val.str[pos] == '|')
{
found_pipe = true;
break;
}
if (n->val.val.str[pos] == '\\')
pos++;
}
/* skip leading ^ */ /* skip leading ^ */
if (!found_pipe)
{
for (pos = 1; n->val.val.str[pos]; pos++) for (pos = 1; n->val.val.str[pos]; pos++)
{ {
if (n->val.val.str[pos] == '.' || if (n->val.val.str[pos] == '.' ||
@ -5373,6 +5387,8 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
break; break;
if (n->val.val.str[pos] == '\\') if (n->val.val.str[pos] == '\\')
pos++; pos++;
if (n->val.val.str[pos] == '\0')
break;
match_least[match_pos] = n->val.val.str[pos]; match_least[match_pos] = n->val.val.str[pos];
match_most[match_pos++] = n->val.val.str[pos]; match_most[match_pos++] = n->val.val.str[pos];
} }
@ -5404,6 +5420,7 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
} }
} }
} }
}
else if (strcmp(opname,"~~") == 0) else if (strcmp(opname,"~~") == 0)
{ {
if (nodeTag(rexpr) == T_A_Const && if (nodeTag(rexpr) == T_A_Const &&
@ -5422,7 +5439,7 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
if(n->val.val.str[pos] == '_') if(n->val.val.str[pos] == '_')
break; break;
if (n->val.val.str[pos] == '\\' || if (n->val.val.str[pos] == '\\' ||
n->val.val.str[pos] == '%') n->val.val.str[pos+1] == '%')
pos++; pos++;
if (n->val.val.str[pos] == '\0') if (n->val.val.str[pos] == '\0')
break; break;