10
10
*
11
11
*
12
12
* IDENTIFICATION
13
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.79 1999/05/20 12:12:55 wieck Exp $
13
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.80 1999/05/21 04:40:04 momjian Exp $
14
14
*
15
15
* HISTORY
16
16
* AUTHOR DATE MAJOR EVENT
@@ -5347,7 +5347,7 @@ mapTargetColumns(List *src, List *dst)
5347
5347
static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
5348
5348
{
5349
5349
Node *result = NULL;
5350
-
5350
+
5351
5351
/* we do this so indexes can be used */
5352
5352
if (strcmp(opname,"~") == 0 ||
5353
5353
strcmp(opname,"~*") == 0)
@@ -5360,47 +5360,64 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
5360
5360
char *match_least = palloc(strlen(n->val.val.str)+2);
5361
5361
char *match_most = palloc(strlen(n->val.val.str)+2);
5362
5362
int pos, match_pos=0;
5363
+ bool found_pipe = false;
5363
5364
5364
- /* skip leading ^ */
5365
5365
for (pos = 1; n->val.val.str[pos]; pos++)
5366
5366
{
5367
- if (n->val.val.str[pos] == '.' ||
5368
- n->val.val.str[pos] == '?' ||
5369
- n->val.val.str[pos] == '*' ||
5370
- n->val.val.str[pos] == '[' ||
5371
- n->val.val.str[pos] == '$' ||
5372
- (strcmp(opname,"~*") == 0 && isalpha(n->val.val.str[pos])))
5373
- break;
5367
+ if (n->val.val.str[pos] == '|')
5368
+ {
5369
+ found_pipe = true;
5370
+ break;
5371
+ }
5374
5372
if (n->val.val.str[pos] == '\\')
5375
5373
pos++;
5376
- match_least[match_pos] = n->val.val.str[pos];
5377
- match_most[match_pos++] = n->val.val.str[pos];
5378
5374
}
5379
5375
5380
- if (match_pos != 0)
5376
+ /* skip leading ^ */
5377
+ if (!found_pipe)
5381
5378
{
5382
- A_Const *least = makeNode(A_Const);
5383
- A_Const *most = makeNode(A_Const);
5384
-
5385
- /* make strings to be used in index use */
5386
- match_least[match_pos] = '\0';
5387
- match_most[match_pos] = '\377';
5388
- match_most[match_pos+1] = '\0';
5389
- least->val.type = T_String;
5390
- least->val.val.str = match_least;
5391
- most->val.type = T_String;
5392
- most->val.val.str = match_most;
5379
+ for (pos = 1; n->val.val.str[pos]; pos++)
5380
+ {
5381
+ if (n->val.val.str[pos] == '.' ||
5382
+ n->val.val.str[pos] == '?' ||
5383
+ n->val.val.str[pos] == '*' ||
5384
+ n->val.val.str[pos] == '[' ||
5385
+ n->val.val.str[pos] == '$' ||
5386
+ (strcmp(opname,"~*") == 0 && isalpha(n->val.val.str[pos])))
5387
+ break;
5388
+ if (n->val.val.str[pos] == '\\')
5389
+ pos++;
5390
+ if (n->val.val.str[pos] == '\0')
5391
+ break;
5392
+ match_least[match_pos] = n->val.val.str[pos];
5393
+ match_most[match_pos++] = n->val.val.str[pos];
5394
+ }
5395
+
5396
+ if (match_pos != 0)
5397
+ {
5398
+ A_Const *least = makeNode(A_Const);
5399
+ A_Const *most = makeNode(A_Const);
5400
+
5401
+ /* make strings to be used in index use */
5402
+ match_least[match_pos] = '\0';
5403
+ match_most[match_pos] = '\377';
5404
+ match_most[match_pos+1] = '\0';
5405
+ least->val.type = T_String;
5406
+ least->val.val.str = match_least;
5407
+ most->val.type = T_String;
5408
+ most->val.val.str = match_most;
5393
5409
#ifdef USE_LOCALE
5394
- result = makeA_Expr(AND, NULL,
5395
- makeA_Expr(OP, "~", lexpr, rexpr),
5396
- makeA_Expr(OP, ">=", lexpr, (Node *)least));
5410
+ result = makeA_Expr(AND, NULL,
5411
+ makeA_Expr(OP, "~", lexpr, rexpr),
5412
+ makeA_Expr(OP, ">=", lexpr, (Node *)least));
5397
5413
#else
5398
- result = makeA_Expr(AND, NULL,
5399
- makeA_Expr(OP, "~", lexpr, rexpr),
5400
- makeA_Expr(AND, NULL,
5401
- makeA_Expr(OP, ">=", lexpr, (Node *)least),
5402
- makeA_Expr(OP, "<=", lexpr, (Node *)most)));
5414
+ result = makeA_Expr(AND, NULL,
5415
+ makeA_Expr(OP, "~", lexpr, rexpr),
5416
+ makeA_Expr(AND, NULL,
5417
+ makeA_Expr(OP, ">=", lexpr, (Node *)least),
5418
+ makeA_Expr(OP, "<=", lexpr, (Node *)most)));
5403
5419
#endif
5420
+ }
5404
5421
}
5405
5422
}
5406
5423
}
@@ -5420,9 +5437,9 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
5420
5437
n->val.val.str[pos+1] != '%')
5421
5438
break;
5422
5439
if(n->val.val.str[pos] == '_')
5423
- break;
5424
- if (n->val.val.str[pos] == '\\' ||
5425
- n->val.val.str[pos] == '%')
5440
+ break;
5441
+ if (n->val.val.str[pos] == '\\' ||
5442
+ n->val.val.str[pos+1 ] == '%')
5426
5443
pos++;
5427
5444
if (n->val.val.str[pos] == '\0')
5428
5445
break;
0 commit comments