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

Commit1460c82

Browse files
author
Michael Meskes
committed
Set valid return values even in case of an error to prevent segfaults.
1 parentb775d93 commit1460c82

File tree

2 files changed

+56
-23
lines changed

2 files changed

+56
-23
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,11 @@ Sun, 13 Jan 2008 12:52:15 +0100
22882288

22892289
- Changed prototype for ECPGdo because some compilers don't like
22902290
int/enum aliasing in there.
2291+
2292+
Mon, 14 Jan 2008 10:42:23 +0100
2293+
2294+
- Set valid return values even in case of an error to prevent
2295+
segfaults.
22912296
- Set pgtypes library version to 3.0.
22922297
- Set compat library version to 3.0.
22932298
- Set ecpg library version to 6.0.

‎src/interfaces/ecpg/preproc/preproc.y

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.357 2007/12/28 11:25:21 meskes Exp $*/
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.358 2008/01/14 09:43:42 meskes Exp $*/
22

33
/* Copyright comment*/
44
%{
@@ -1288,7 +1288,10 @@ VariableShowStmt: SHOW var_name ecpg_into
12881288
|SHOWSESSIONAUTHORIZATIONecpg_into
12891289
{$$ = make_str("show session authorization"); }
12901290
|SHOWALL
1291-
{ mmerror(PARSE_ERROR, ET_ERROR,"SHOW ALL not implemented"); }
1291+
{
1292+
mmerror(PARSE_ERROR, ET_ERROR,"SHOW ALL not implemented");
1293+
$$ = EMPTY;
1294+
}
12921295
;
12931296

12941297
VariableResetStmt:RESETvar_name
@@ -2300,22 +2303,22 @@ FetchStmt: FETCH fetch_direction from_in name ecpg_into
23002303
}
23012304
|FETCHfrom_innameecpg_into
23022305
{
2303-
add_additional_variables($3,false);
2306+
add_additional_variables($3,false);
23042307
$$ = cat_str(3, make_str("fetch"),$2,$3);
23052308
}
23062309
|FETCHnameecpg_into
23072310
{
2308-
add_additional_variables($2,false);
2311+
add_additional_variables($2,false);
23092312
$$ = cat2_str(make_str("fetch"),$2);
23102313
}
23112314
|FETCHfetch_directionfrom_inname
23122315
{
2313-
add_additional_variables($4,false);
2316+
add_additional_variables($4,false);
23142317
$$ = cat_str(4, make_str("fetch"),$2,$3,$4);
23152318
}
23162319
|FETCHfetch_directionname
23172320
{
2318-
add_additional_variables($3,false);
2321+
add_additional_variables($3,false);
23192322
$$ = cat_str(4, make_str("fetch"),$2, make_str("from"),$3);
23202323
}
23212324
|FETCHfrom_inname
@@ -2325,7 +2328,7 @@ FetchStmt: FETCH fetch_direction from_in name ecpg_into
23252328
}
23262329
|FETCHname
23272330
{
2328-
add_additional_variables($2,false);
2331+
add_additional_variables($2,false);
23292332
$$ = cat2_str(make_str("fetch"),$2);
23302333
}
23312334
|MOVEfetch_directionfrom_inname
@@ -2340,42 +2343,57 @@ fetch_direction: NEXT{ $$ = make_str("next"); }
23402343
|LAST_P{$$ = make_str("last"); }
23412344
|ABSOLUTE_PIntConst{
23422345
if ($2[1] =='$')
2343-
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variable.\n");
2346+
{
2347+
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variable, ignoring it.\n");
2348+
$$ = make_str("absolute");
2349+
}
23442350
else
23452351
$$ = cat2_str(make_str("absolute"),$2);
23462352
}
23472353
|RELATIVE_PIntConst{
23482354
if ($2[1] =='$')
2349-
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variable.\n");
2355+
{
2356+
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variable, ignoring it.\n");
2357+
$$ = make_str("relative");
2358+
}
23502359
else
23512360
$$ = cat2_str(make_str("relative"),$2);
23522361
}
23532362
|IntConst{
23542363
if ($1[1] =='$')
2355-
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variable.\n");
2364+
{
2365+
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variablei, ignoring it.\n");
2366+
$$ = EMPTY;
2367+
}
23562368
else
23572369
$$ =$1;
23582370
}
23592371
|ALL{$$ = make_str("all"); }
23602372
|FORWARD{$$ = make_str("forward"); }
23612373
|FORWARDIntConst{
23622374
if ($2[1] =='$')
2363-
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variable.\n");
2375+
{
2376+
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variable, ignoring it.\n");
2377+
$$ = make_str("forward");
2378+
}
23642379
else
23652380
$$ = cat2_str(make_str("forward"),$2);
23662381
}
23672382
|FORWARDALL{$$ = make_str("forward all"); }
23682383
|BACKWARD{$$ = make_str("backward"); }
23692384
|BACKWARDIntConst{
23702385
if ($2[1] =='$')
2371-
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variable.\n");
2386+
{
2387+
mmerror(PARSE_ERROR, ET_ERROR,"fetch/move count must not be a variable, ignoring it.\n");
2388+
$$ = make_str("backward");
2389+
}
23722390
else
23732391
$$ = cat2_str(make_str("backward"),$2);
23742392
}
23752393
|BACKWARDALL{$$ = make_str("backward all"); }
23762394
;
23772395

2378-
from_in:IN_P{$$ = make_str("in"); }
2396+
from_in:IN_P{$$ = make_str("in"); }
23792397
|FROM{$$ = make_str("from"); }
23802398
;
23812399

@@ -2744,7 +2762,10 @@ RemoveOperStmt: DROP OPERATOR all_Op '(' oper_argtypes ')' opt_drop_behavior
27442762
;
27452763

27462764
oper_argtypes:Typename
2747-
{ mmerror(PARSE_ERROR, ET_ERROR,"parser: argument type missing (use NONE for unary operators)"); }
2765+
{
2766+
mmerror(PARSE_ERROR, ET_ERROR,"parser: argument type missing (use NONE for unary operators)");
2767+
$$ = make_str("none");
2768+
}
27482769
|Typename','Typename
27492770
{$$ = cat_str(3,$1, make_str(","),$3); }
27502771
|NONE','Typename/* left unary*/
@@ -3665,7 +3686,10 @@ select_limit:LIMIT select_limit_value OFFSET select_offset_value
36653686
|OFFSETselect_offset_value
36663687
{$$ = cat2_str(make_str("offset"),$2); }
36673688
|LIMITselect_limit_value','select_offset_value
3668-
{ mmerror(PARSE_ERROR, ET_WARNING,"No longer supported LIMIT #,# syntax passed to backend."); }
3689+
{
3690+
mmerror(PARSE_ERROR, ET_WARNING,"No longer supported LIMIT #,# syntax passed to backend.");
3691+
$$ = cat_str(4, make_str("limit"),$2, make_str(","),$4);
3692+
}
36693693
;
36703694

36713695
opt_select_limit:select_limit{$$ =$1; }
@@ -3757,25 +3781,28 @@ from_list:from_list ',' table_ref { $$ = cat_str(3, $1, make_str(","), $3); }
37573781
table_ref:relation_expr
37583782
{$$ =$1; }
37593783
|relation_expralias_clause
3760-
{$$= cat2_str($1,$2); }
3784+
{$$= cat2_str($1,$2); }
37613785
|func_table
37623786
{$$ =$1; }
37633787
|func_tablealias_clause
3764-
{$$= cat2_str($1,$2); }
3788+
{$$= cat2_str($1,$2); }
37653789
|func_tableAS'('TableFuncElementList')'
3766-
{$$=cat_str(4,$1, make_str("as ("),$4, make_str(")")); }
3790+
{$$ =cat_str(4,$1, make_str("as ("),$4, make_str(")")); }
37673791
|func_tableASColId'('TableFuncElementList')'
3768-
{$$=cat_str(6,$1, make_str("as"),$3, make_str("("),$5, make_str(")"));}
3792+
{$$ =cat_str(6,$1, make_str("as"),$3, make_str("("),$5, make_str(")"));}
37693793
|func_tableColId'('TableFuncElementList')'
3770-
{$$=cat_str(5,$1,$2, make_str("("),$4, make_str(")")); }
3794+
{$$ =cat_str(5,$1,$2, make_str("("),$4, make_str(")")); }
37713795
|select_with_parens
3772-
{mmerror(PARSE_ERROR, ET_ERROR,"sub-SELECT in FROM must have an alias");}
3796+
{
3797+
mmerror(PARSE_ERROR, ET_ERROR,"sub-SELECT in FROM must have an alias");
3798+
$$ =$1;
3799+
}
37733800
|select_with_parensalias_clause
3774-
{$$=cat2_str($1,$2); }
3801+
{$$ =cat2_str($1,$2); }
37753802
|joined_table
37763803
{$$ =$1; }
37773804
|'('joined_table')'alias_clause
3778-
{$$=cat_str(4, make_str("("),$2, make_str(")"),$4); }
3805+
{$$ =cat_str(4, make_str("("),$2, make_str(")"),$4); }
37793806
;
37803807

37813808
/*
@@ -5159,6 +5186,7 @@ char_variable: cvariable
51595186
break;
51605187
default:
51615188
mmerror(PARSE_ERROR, ET_ERROR,"invalid datatype");
5189+
$$ =$1;
51625190
break;
51635191
}
51645192
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp