@@ -452,7 +452,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
452
452
%type <list> extract_list overlay_list position_list
453
453
%type <list> substr_list trim_list
454
454
%type <list> opt_interval interval_second
455
- %type <node> overlay_placing substr_from substr_for
456
455
%type <str> unicode_normal_form
457
456
458
457
%type <boolean> opt_instead
@@ -13797,11 +13796,6 @@ func_expr_common_subexpr:
13797
13796
}
13798
13797
| OVERLAY ' (' overlay_list ' )'
13799
13798
{
13800
- /* overlay(A PLACING B FROM C FOR D) is converted to
13801
- * overlay(A, B, C, D)
13802
- * overlay(A PLACING B FROM C) is converted to
13803
- * overlay(A, B, C)
13804
- */
13805
13799
$$ = (Node *) makeFuncCall(SystemFuncName(" overlay" ), $3 , @1 );
13806
13800
}
13807
13801
| POSITION ' (' position_list ' )'
@@ -14437,63 +14431,45 @@ unicode_normal_form:
14437
14431
| NFKD { $$ = " nfkd" ; }
14438
14432
;
14439
14433
14440
- /* OVERLAY() arguments
14441
- * SQL99 defines the OVERLAY() function:
14442
- * o overlay(text placing text from int for int)
14443
- * o overlay(text placing text from int)
14444
- * and similarly for binary strings
14445
- */
14434
+ /* OVERLAY() arguments */
14446
14435
overlay_list :
14447
- a_expr overlay_placing substr_from substr_for
14436
+ a_expr PLACING a_expr FROM a_expr FOR a_expr
14448
14437
{
14449
- $$ = list_make4($1 , $2 , $3 , $4 );
14438
+ /* overlay(A PLACING B FROM C FOR D) is converted to overlay(A, B, C, D) */
14439
+ $$ = list_make4($1 , $3 , $5 , $7 );
14450
14440
}
14451
- | a_expr overlay_placing substr_from
14441
+ | a_expr PLACING a_expr FROM a_expr
14452
14442
{
14453
- $$ = list_make3($1 , $2 , $3 );
14443
+ /* overlay(A PLACING B FROM C) is converted to overlay(A, B, C) */
14444
+ $$ = list_make3($1 , $3 , $5 );
14454
14445
}
14455
14446
;
14456
14447
14457
- overlay_placing :
14458
- PLACING a_expr
14459
- { $$ = $2 ; }
14460
- ;
14461
-
14462
14448
/* position_list uses b_expr not a_expr to avoid conflict with general IN */
14463
-
14464
14449
position_list :
14465
14450
b_expr IN_P b_expr { $$ = list_make2($3 , $1 ); }
14466
14451
| /* EMPTY*/ { $$ = NIL; }
14467
14452
;
14468
14453
14469
- /* SUBSTRING() arguments
14470
- * SQL9x defines a specific syntax for arguments to SUBSTRING():
14471
- * o substring(text from int for int)
14472
- * o substring(text from int) get entire string from starting point "int"
14473
- * o substring(text for int) get first "int" characters of string
14474
- * o substring(text from pattern) get entire string matching pattern
14475
- * o substring(text from pattern for escape) same with specified escape char
14476
- * We also want to support generic substring functions which accept
14477
- * the usual generic list of arguments. So we will accept both styles
14478
- * here, and convert the SQL9x style to the generic list for further
14479
- * processing. - thomas 2000-11-28
14480
- */
14454
+ /* SUBSTRING() arguments */
14481
14455
substr_list :
14482
- a_expr substr_from substr_for
14456
+ a_expr FROM a_expr FOR a_expr
14483
14457
{
14484
- $$ = list_make3($1 , $2 , $3 );
14458
+ $$ = list_make3($1 , $3 , $5 );
14485
14459
}
14486
- | a_expr substr_for substr_from
14460
+ | a_expr FOR a_expr FROM a_expr
14487
14461
{
14488
- /* not legal per SQL99 , but might as well allow it */
14489
- $$ = list_make3($1 , $3 , $2 );
14462
+ /* not legal per SQL , but might as well allow it */
14463
+ $$ = list_make3($1 , $5 , $3 );
14490
14464
}
14491
- | a_expr substr_from
14465
+ | a_expr FROM a_expr
14492
14466
{
14493
- $$ = list_make2($1 , $2 );
14467
+ $$ = list_make2($1 , $3 );
14494
14468
}
14495
- | a_expr substr_for
14469
+ | a_expr FOR a_expr
14496
14470
{
14471
+ /* not legal per SQL */
14472
+
14497
14473
/*
14498
14474
* Since there are no cases where this syntax allows
14499
14475
* a textual FOR value, we forcibly cast the argument
@@ -14504,9 +14480,13 @@ substr_list:
14504
14480
* is unknown or doesn't have an implicit cast to int4.
14505
14481
*/
14506
14482
$$ = list_make3($1 , makeIntConst(1 , -1 ),
14507
- makeTypeCast ($2 ,
14483
+ makeTypeCast ($3 ,
14508
14484
SystemTypeName (" int4" ), -1));
14509
14485
}
14486
+ /*
14487
+ * We also want to support generic substring functions that
14488
+ * accept the usual generic list of arguments.
14489
+ */
14510
14490
| expr_list
14511
14491
{
14512
14492
$$ = $1 ;
@@ -14515,13 +14495,6 @@ substr_list:
14515
14495
{ $$ = NIL; }
14516
14496
;
14517
14497
14518
- substr_from:
14519
- FROM a_expr { $$ = $2 ; }
14520
- ;
14521
-
14522
- substr_for: FOR a_expr { $$ = $2 ; }
14523
- ;
14524
-
14525
14498
trim_list: a_expr FROM expr_list { $$ = lappend ($3 , $1 ); }
14526
14499
| FROM expr_list { $$ = $2 ; }
14527
14500
| expr_list { $$ = $1 ; }
0 commit comments