Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 97b88f1

Browse files
committed
Sorry for posting it here again, but I haven't corrected my
subscriptions yet. It's just a small patch to ecpg to keep it in sync with gram.y. Michael
1 parent 8887602 commit 97b88f1

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,9 @@ Tue Dec 22 14:16:11 CET 1998
366366

367367
- Synced preproc.y with gram.y for locking statements.
368368
- Set version to 2.4.5
369+
370+
Tue Jan 7 15:19:34 CET 1999
371+
372+
- Synced preproc.y with gram.y for for-update clause and changes in
373+
handling of numerics
374+
- Set version to 2.4.6

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <string.h>
55
#include <stdlib.h>
66
#include "catalog/catname.h"
7+
#include "utils/numeric.h"
78

89
#include "type.h"
910
#include "extern.h"
@@ -648,7 +649,7 @@ output_statement(char * stmt, int mode)
648649
%type <str> def_elem def_list definition def_name def_type DefineStmt
649650
%type <str> opt_instead event event_object OptStmtMulti OptStmtBlock
650651
%type <str> OptStmtList RuleStmt opt_column opt_name oper_argtypes
651-
%type <str> MathOp RemoveFuncStmt aggr_argtype
652+
%type <str> MathOp RemoveFuncStmt aggr_argtype for_update_clause
652653
%type <str> RemoveAggrStmt remove_type RemoveStmt ExtendStmt RecipeStmt
653654
%type <str> RemoveOperStmt RenameStmt all_Op user_valid_clause
654655
%type <str> VariableSetStmt var_value zone_value VariableShowStmt
@@ -2611,9 +2612,18 @@ opt_of: OF columnList { $$ = make2_str(make1_str("of"), $2); }
26112612
SelectStmt: SELECT opt_unique res_target_list2
26122613
result from_clause where_clause
26132614
group_clause having_clause
2614-
union_clause sort_clause
2615+
union_clause sort_clause for_update_clause
26152616
{
2616-
$$ = cat2_str(cat5_str(cat5_str(make1_str("select"), $2, $3, $4, $5), $6, $7, $8, $9), $10);
2617+
$$ = cat3_str(cat5_str(cat5_str(make1_str("select"), $2, $3, $4, $5), $6, $7, $8, $9), $10, $11);
2618+
if (strlen($11) > 0)
2619+
{
2620+
if (strlen($9) > 0)
2621+
yyerror("SELECT FOR UPDATE is not allowed with UNION clause");
2622+
if (strlen($7) > 0)
2623+
yyerror("SELECT FOR UPDATE is not allowed with GROUP BY clause");
2624+
if (strlen($6) > 0)
2625+
yyerror("SELECT FOR UPDATE is not allowed with HAVING clause");
2626+
}
26172627
}
26182628
;
26192629

@@ -2721,6 +2731,20 @@ having_clause: HAVING a_expr
27212731
| /*EMPTY*/ { $$ = make1_str(""); }
27222732
;
27232733

2734+
for_update_clause:
2735+
FOR UPDATE
2736+
{
2737+
$$ = make1_str("for update");
2738+
}
2739+
| FOR UPDATE OF va_list
2740+
{
2741+
$$ = cat2_str(make1_str("for update of"), $4);
2742+
}
2743+
| /* EMPTY */
2744+
{
2745+
$$ = make1_str("");
2746+
}
2747+
;
27242748

27252749
/*****************************************************************************
27262750
*
@@ -2897,8 +2921,7 @@ generic: ident { $$ = $1; }
28972921

28982922
/* SQL92 numeric data types
28992923
* Check FLOAT() precision limits assuming IEEE floating types.
2900-
* Provide rudimentary DECIMAL() and NUMERIC() implementations
2901-
* by checking parameters and making sure they match what is possible with INTEGER.
2924+
* Provide real DECIMAL() and NUMERIC() implementations now - Jan 1998-12-30
29022925
* - thomas 1997-09-18
29032926
*/
29042927
Numeric: FLOAT opt_float
@@ -2945,20 +2968,20 @@ opt_float: '(' Iconst ')'
29452968

29462969
opt_numeric: '(' Iconst ',' Iconst ')'
29472970
{
2948-
if (atol($2) != 9) {
2949-
sprintf(errortext, make1_str("NUMERIC precision %s must be 9"), $2);
2971+
if (atol($2) < 1 || atol($2) > NUMERIC_MAX_PRECISION) {
2972+
sprintf(errortext, "NUMERIC precision %s must be between 1 and %d", $2, NUMERIC_MAX_PRECISION);
29502973
yyerror(errortext);
29512974
}
2952-
if (atol($4) != 0) {
2953-
sprintf(errortext, "NUMERIC scale %s must be zero", $4);
2975+
if (atol($4) < 0 || atol($4) > atol($2)) {
2976+
sprintf(errortext, "NUMERIC scale %s must be between 0 and precision %s", $4, $2);
29542977
yyerror(errortext);
29552978
}
29562979
$$ = cat3_str(make2_str(make1_str("("), $2), make1_str(","), make2_str($4, make1_str(")")));
29572980
}
29582981
| '(' Iconst ')'
29592982
{
2960-
if (atol($2) != 9) {
2961-
sprintf("NUMERIC precision %s must be 9",$2);
2983+
if (atol($2) < 1 || atol($2) > NUMERIC_MAX_PRECISION) {
2984+
sprintf(errortext, "NUMERIC precision %s must be between 1 and %d", $2, NUMERIC_MAX_PRECISION);
29622985
yyerror(errortext);
29632986
}
29642987
$$ = make3_str(make1_str("("), $2, make1_str(")"));
@@ -2971,22 +2994,22 @@ opt_numeric: '(' Iconst ',' Iconst ')'
29712994

29722995
opt_decimal: '(' Iconst ',' Iconst ')'
29732996
{
2974-
if (atol($2) != 9) {
2975-
sprintf(errortext, "DECIMAL precision %s exceeds implementation limit of 9", $2);
2997+
if (atol($2) < 1 || atol($2) > NUMERIC_MAX_PRECISION) {
2998+
sprintf(errortext, "NUMERIC precision %s must be between 1 and %d", $2, NUMERIC_MAX_PRECISION);
2999+
yyerror(errortext);
3000+
}
3001+
if (atol($4) < 0 || atol($4) > atol($2)) {
3002+
sprintf(errortext, "NUMERIC scale %s must be between 0 and precision %s", $4, $2);
29763003
yyerror(errortext);
29773004
}
2978-
if (atol($4) != 0) {
2979-
sprintf(errortext, "DECIMAL scale %s must be zero",$4);
2980-
yyerror(errortext);
2981-
}
29823005
$$ = cat3_str(make2_str(make1_str("("), $2), make1_str(","), make2_str($4, make1_str(")")));
29833006
}
29843007
| '(' Iconst ')'
29853008
{
2986-
if (atol($2) != 9) {
2987-
sprintf(errortext, "DECIMAL precision %s exceeds implementation limit of 9",$2);
2988-
yyerror(errortext);
2989-
}
3009+
if (atol($2) < 1 || atol($2) > NUMERIC_MAX_PRECISION) {
3010+
sprintf(errortext, "NUMERIC precision %s must be between 1 and %d", $2, NUMERIC_MAX_PRECISION);
3011+
yyerror(errortext);
3012+
}
29903013
$$ = make3_str(make1_str("("), $2, make1_str(")"));
29913014
}
29923015
| /*EMPTY*/

0 commit comments

Comments
 (0)