Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97b88f1

Browse files
committed
Sorry for posting it here again, but I haven't corrected my
subscriptionsyet. It's just a small patch to ecpg to keep it in sync with gram.y.Michael
1 parent8887602 commit97b88f1

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_elemdef_listdefinitiondef_namedef_typeDefineStmt
649650
%type<str>opt_insteadeventevent_objectOptStmtMultiOptStmtBlock
650651
%type<str>OptStmtListRuleStmtopt_columnopt_nameoper_argtypes
651-
%type<str>MathOpRemoveFuncStmtaggr_argtype
652+
%type<str>MathOpRemoveFuncStmtaggr_argtypefor_update_clause
652653
%type<str>RemoveAggrStmtremove_typeRemoveStmtExtendStmtRecipeStmt
653654
%type<str>RemoveOperStmtRenameStmtall_Opuser_valid_clause
654655
%type<str>VariableSetStmtvar_valuezone_valueVariableShowStmt
@@ -2611,9 +2612,18 @@ opt_of: OF columnList { $$ = make2_str(make1_str("of"), $2); }
26112612
SelectStmt:SELECTopt_uniqueres_target_list2
26122613
resultfrom_clausewhere_clause
26132614
group_clausehaving_clause
2614-
union_clausesort_clause
2615+
union_clausesort_clausefor_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+
FORUPDATE
2736+
{
2737+
$$ = make1_str("for update");
2738+
}
2739+
|FORUPDATEOFva_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:FLOATopt_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 be9"), $2);
2971+
if (atol($2)<1 || atol($2) > NUMERIC_MAX_PRECISION) {
2972+
sprintf(errortext,"NUMERIC precision %s must bebetween 1 and %d", $2, NUMERIC_MAX_PRECISION);
29502973
yyerror(errortext);
29512974
}
2952-
if (atol($4)!=0) {
2953-
sprintf(errortext,"NUMERIC scale %s must bezero", $4);
2975+
if (atol($4)<0 || atol($4) >atol($2)) {
2976+
sprintf(errortext,"NUMERIC scale %s must bebetween 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 be9",$2);
2983+
if (atol($2)<1 || atol($2) > NUMERIC_MAX_PRECISION) {
2984+
sprintf(errortext,"NUMERIC precision %s must bebetween 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 %sexceeds implementation limit of 9",$2);
2988-
yyerror(errortext);
2989-
}
3009+
if (atol($2)<1 || atol($2) > NUMERIC_MAX_PRECISION) {
3010+
sprintf(errortext,"NUMERIC precision %smust 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)

[8]ページ先頭

©2009-2025 Movatter.jp