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

Commit2ea179f

Browse files
committed
Support optional FROM/IN in FETCH and MOVE
The main motivation for this is that it's required for Informix compatibilityin ECPG.This patch makes the ECPG and core grammars a bit closer to one another forthese productions.Author: Zoltan Boszormenyi
1 parent90bfe99 commit2ea179f

File tree

4 files changed

+77
-85
lines changed

4 files changed

+77
-85
lines changed

‎src/backend/parser/gram.y

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.690 2009/11/09 18:38:48 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.691 2009/11/11 19:25:40 alvherre Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -332,7 +332,7 @@ static TypeName *TableFuncTypeName(List *columns);
332332
%type<ival>opt_columneventcursor_optionsopt_holdopt_set_data
333333
%type<objtype>reindex_typedrop_typecomment_type
334334

335-
%type<node>fetch_directionlimit_clauseselect_limit_value
335+
%type<node>fetch_argslimit_clauseselect_limit_value
336336
offset_clauseselect_offset_value
337337
select_offset_value2opt_select_fetch_first_value
338338
%type<ival>row_or_rowsfirst_or_next
@@ -4180,142 +4180,144 @@ comment_text:
41804180
*
41814181
*****************************************************************************/
41824182

4183-
FetchStmt:FETCHfetch_direction from_in name
4183+
FetchStmt:FETCHfetch_args
41844184
{
41854185
FetchStmt *n = (FetchStmt *)$2;
4186-
n->portalname =$4;
4187-
n->ismove =FALSE;
4188-
$$ = (Node *)n;
4189-
}
4190-
| FETCH name
4191-
{
4192-
FetchStmt *n = makeNode(FetchStmt);
4193-
n->direction = FETCH_FORWARD;
4194-
n->howMany =1;
4195-
n->portalname =$2;
41964186
n->ismove =FALSE;
41974187
$$ = (Node *)n;
41984188
}
4199-
| MOVEfetch_direction from_in name
4189+
| MOVEfetch_args
42004190
{
42014191
FetchStmt *n = (FetchStmt *)$2;
4202-
n->portalname =$4;
42034192
n->ismove =TRUE;
42044193
$$ = (Node *)n;
42054194
}
4206-
| MOVE name
4195+
;
4196+
4197+
fetch_args:name
42074198
{
42084199
FetchStmt *n = makeNode(FetchStmt);
4200+
n->portalname =$1;
42094201
n->direction = FETCH_FORWARD;
42104202
n->howMany =1;
4211-
n->portalname =$2;
4212-
n->ismove =TRUE;
42134203
$$ = (Node *)n;
42144204
}
4215-
;
4216-
4217-
fetch_direction:
4218-
/*EMPTY*/
4205+
| from_in name
42194206
{
42204207
FetchStmt *n = makeNode(FetchStmt);
4208+
n->portalname =$2;
42214209
n->direction = FETCH_FORWARD;
42224210
n->howMany =1;
42234211
$$ = (Node *)n;
42244212
}
4225-
| NEXT
4213+
| NEXT opt_from_in name
42264214
{
42274215
FetchStmt *n = makeNode(FetchStmt);
4216+
n->portalname =$3;
42284217
n->direction = FETCH_FORWARD;
42294218
n->howMany =1;
42304219
$$ = (Node *)n;
42314220
}
4232-
| PRIOR
4221+
| PRIOR opt_from_in name
42334222
{
42344223
FetchStmt *n = makeNode(FetchStmt);
4224+
n->portalname =$3;
42354225
n->direction = FETCH_BACKWARD;
42364226
n->howMany =1;
42374227
$$ = (Node *)n;
42384228
}
4239-
| FIRST_P
4229+
| FIRST_P opt_from_in name
42404230
{
42414231
FetchStmt *n = makeNode(FetchStmt);
4232+
n->portalname =$3;
42424233
n->direction = FETCH_ABSOLUTE;
42434234
n->howMany =1;
42444235
$$ = (Node *)n;
42454236
}
4246-
| LAST_P
4237+
| LAST_P opt_from_in name
42474238
{
42484239
FetchStmt *n = makeNode(FetchStmt);
4240+
n->portalname =$3;
42494241
n->direction = FETCH_ABSOLUTE;
42504242
n->howMany = -1;
42514243
$$ = (Node *)n;
42524244
}
4253-
| ABSOLUTE_P SignedIconst
4245+
| ABSOLUTE_P SignedIconst opt_from_in name
42544246
{
42554247
FetchStmt *n = makeNode(FetchStmt);
4248+
n->portalname =$4;
42564249
n->direction = FETCH_ABSOLUTE;
42574250
n->howMany =$2;
42584251
$$ = (Node *)n;
42594252
}
4260-
| RELATIVE_P SignedIconst
4253+
| RELATIVE_P SignedIconst opt_from_in name
42614254
{
42624255
FetchStmt *n = makeNode(FetchStmt);
4256+
n->portalname =$4;
42634257
n->direction = FETCH_RELATIVE;
42644258
n->howMany =$2;
42654259
$$ = (Node *)n;
42664260
}
4267-
| SignedIconst
4261+
| SignedIconst opt_from_in name
42684262
{
42694263
FetchStmt *n = makeNode(FetchStmt);
4264+
n->portalname =$3;
42704265
n->direction = FETCH_FORWARD;
42714266
n->howMany =$1;
42724267
$$ = (Node *)n;
42734268
}
4274-
| ALL
4269+
| ALL opt_from_in name
42754270
{
42764271
FetchStmt *n = makeNode(FetchStmt);
4272+
n->portalname =$3;
42774273
n->direction = FETCH_FORWARD;
42784274
n->howMany = FETCH_ALL;
42794275
$$ = (Node *)n;
42804276
}
4281-
| FORWARD
4277+
| FORWARD opt_from_in name
42824278
{
42834279
FetchStmt *n = makeNode(FetchStmt);
4280+
n->portalname =$3;
42844281
n->direction = FETCH_FORWARD;
42854282
n->howMany =1;
42864283
$$ = (Node *)n;
42874284
}
4288-
| FORWARD SignedIconst
4285+
| FORWARD SignedIconst opt_from_in name
42894286
{
42904287
FetchStmt *n = makeNode(FetchStmt);
4288+
n->portalname =$4;
42914289
n->direction = FETCH_FORWARD;
42924290
n->howMany =$2;
42934291
$$ = (Node *)n;
42944292
}
4295-
| FORWARD ALL
4293+
| FORWARD ALL opt_from_in name
42964294
{
42974295
FetchStmt *n = makeNode(FetchStmt);
4296+
n->portalname =$4;
42984297
n->direction = FETCH_FORWARD;
42994298
n->howMany = FETCH_ALL;
43004299
$$ = (Node *)n;
43014300
}
4302-
| BACKWARD
4301+
| BACKWARD opt_from_in name
43034302
{
43044303
FetchStmt *n = makeNode(FetchStmt);
4304+
n->portalname =$3;
43054305
n->direction = FETCH_BACKWARD;
43064306
n->howMany =1;
43074307
$$ = (Node *)n;
43084308
}
4309-
| BACKWARD SignedIconst
4309+
| BACKWARD SignedIconst opt_from_in name
43104310
{
43114311
FetchStmt *n = makeNode(FetchStmt);
4312+
n->portalname =$4;
43124313
n->direction = FETCH_BACKWARD;
43134314
n->howMany =$2;
43144315
$$ = (Node *)n;
43154316
}
4316-
| BACKWARD ALL
4317+
| BACKWARD ALL opt_from_in name
43174318
{
43184319
FetchStmt *n = makeNode(FetchStmt);
4320+
n->portalname =$4;
43194321
n->direction = FETCH_BACKWARD;
43204322
n->howMany = FETCH_ALL;
43214323
$$ = (Node *)n;
@@ -4326,6 +4328,10 @@ from_in:FROM{}
43264328
| IN_P{}
43274329
;
43284330

4331+
opt_from_in:from_in{}
4332+
|/* EMPTY*/{}
4333+
;
4334+
43294335

43304336
/*****************************************************************************
43314337
*

‎src/interfaces/ecpg/preproc/ecpg.addons

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.6 2009/11/05 23:24:27 tgl Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.7 2009/11/11 19:25:40 alvherre Exp $ */
22

33
ECPG: stmtClosePortalStmt block
44
{
@@ -206,16 +206,38 @@ ECPG: ConstraintAttributeSpecConstraintTimeSpecConstraintDeferrabilitySpec addon
206206
if (strcmp($2, "deferrable") != 0 && strcmp($1, "initially deferrable") == 0 )
207207
mmerror(PARSE_ERROR, ET_ERROR, "constraint declared INITIALLY DEFERRED must be DEFERRABLE");
208208
ECPG: var_valueNumericOnly addon
209-
ECPG: fetch_directionSignedIconst addon
210209
if ($1[0] == '$')
211210
{
212211
free($1);
213212
$1 = make_str("$0");
214213
}
215-
ECPG: fetch_directionABSOLUTE_PSignedIconst addon
216-
ECPG: fetch_directionRELATIVE_PSignedIconst addon
217-
ECPG: fetch_directionFORWARDSignedIconst addon
218-
ECPG: fetch_directionBACKWARDSignedIconst addon
214+
ECPG: fetch_argsname addon
215+
add_additional_variables($1, false);
216+
ECPG: fetch_argsfrom_inname addon
217+
add_additional_variables($2, false);
218+
ECPG: fetch_argsNEXTopt_from_inname addon
219+
ECPG: fetch_argsPRIORopt_from_inname addon
220+
ECPG: fetch_argsFIRST_Popt_from_inname addon
221+
ECPG: fetch_argsLAST_Popt_from_inname addon
222+
ECPG: fetch_argsALLopt_from_inname addon
223+
ECPG: fetch_argsFORWARDopt_from_inname addon
224+
ECPG: fetch_argsBACKWARDopt_from_inname addon
225+
add_additional_variables($3, false);
226+
ECPG: fetch_argsSignedIconstopt_from_inname addon
227+
add_additional_variables($3, false);
228+
if ($1[0] == '$')
229+
{
230+
free($1);
231+
$1 = make_str("$0");
232+
}
233+
ECPG: fetch_argsFORWARDALLopt_from_inname addon
234+
ECPG: fetch_argsBACKWARDALLopt_from_inname addon
235+
add_additional_variables($4, false);
236+
ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_inname addon
237+
ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_inname addon
238+
ECPG: fetch_argsFORWARDSignedIconstopt_from_inname addon
239+
ECPG: fetch_argsBACKWARDSignedIconstopt_from_inname addon
240+
add_additional_variables($4, false);
219241
if ($2[0] == '$')
220242
{
221243
free($2);
@@ -336,47 +358,11 @@ ECPG: VariableShowStmtSHOWALL block
336358
mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
337359
$$ = EMPTY;
338360
}
339-
ECPG: FetchStmtFETCHfetch_directionfrom_inname block
340-
{
341-
add_additional_variables($4, false);
342-
$$ = cat_str(4, make_str("fetch"), $2, $3, $4);
343-
}
344-
ECPG: FetchStmtFETCHname block
361+
ECPG: FetchStmtMOVEfetch_args rule
362+
| FETCH fetch_args ecpg_into
345363
{
346-
add_additional_variables($2, false);
347-
$$ = cat_str(2, make_str("fetch"), $2);
364+
$$ = cat2_str(make_str("fetch"), $2);
348365
}
349-
ECPG: FetchStmtMOVEname rule
350-
| FETCH fetch_direction from_in name ecpg_into
351-
{
352-
add_additional_variables($4, false);
353-
$$ = cat_str(4, make_str("fetch"), $2, $3, $4);
354-
}
355-
| FETCH fetch_direction name ecpg_into
356-
{
357-
add_additional_variables($3, false);
358-
$$ = cat_str(4, make_str("fetch"), $2, make_str("from"), $3);
359-
}
360-
| FETCH from_in name ecpg_into
361-
{
362-
add_additional_variables($3, false);
363-
$$ = cat_str(3, make_str("fetch"), $2, $3);
364-
}
365-
| FETCH name ecpg_into
366-
{
367-
add_additional_variables($2, false);
368-
$$ = cat2_str(make_str("fetch"), $2);
369-
}
370-
| FETCH fetch_direction name
371-
{
372-
add_additional_variables($3, false);
373-
$$ = cat_str(4, make_str("fetch"), $2, make_str("from"), $3);
374-
}
375-
| FETCH from_in name
376-
{
377-
add_additional_variables($3, false);
378-
$$ = cat_str(3, make_str("fetch"), $2, $3);
379-
}
380366
ECPG: select_limitLIMITselect_limit_value','select_offset_value block
381367
{
382368
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");

‎src/interfaces/ecpg/test/expected/compat_informix-test_informix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
158158

159159
while (1)
160160
{
161-
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"fetch forwardfromc",ECPGt_EOIT,
161+
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"fetch forward c",ECPGt_EOIT,
162162
ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
163163
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
164164
ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal),

‎src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ DETAIL: Key (i)=(7) already exists.
6363
[NO_PID]: sqlca: code: 0, state: 00000
6464
[NO_PID]: ecpg_execute on line 95: OK: DECLARE CURSOR
6565
[NO_PID]: sqlca: code: 0, state: 00000
66-
[NO_PID]: ecpg_execute on line 57: query: fetch forwardfromc; with 0 parameter(s) on connection regress1
66+
[NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
6767
[NO_PID]: sqlca: code: 0, state: 00000
6868
[NO_PID]: ecpg_execute on line 57: using PQexec
6969
[NO_PID]: sqlca: code: 0, state: 00000
@@ -75,7 +75,7 @@ DETAIL: Key (i)=(7) already exists.
7575
[NO_PID]: sqlca: code: 0, state: 00000
7676
[NO_PID]: ecpg_get_data on line 57: RESULT: test offset: -1; array: yes
7777
[NO_PID]: sqlca: code: 0, state: 00000
78-
[NO_PID]: ecpg_execute on line 57: query: fetch forwardfromc; with 0 parameter(s) on connection regress1
78+
[NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
7979
[NO_PID]: sqlca: code: 0, state: 00000
8080
[NO_PID]: ecpg_execute on line 57: using PQexec
8181
[NO_PID]: sqlca: code: 0, state: 00000
@@ -87,7 +87,7 @@ DETAIL: Key (i)=(7) already exists.
8787
[NO_PID]: sqlca: code: 0, state: 00000
8888
[NO_PID]: ecpg_get_data on line 57: RESULT: a offset: -1; array: yes
8989
[NO_PID]: sqlca: code: 0, state: 00000
90-
[NO_PID]: ecpg_execute on line 57: query: fetch forwardfromc; with 0 parameter(s) on connection regress1
90+
[NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
9191
[NO_PID]: sqlca: code: 0, state: 00000
9292
[NO_PID]: ecpg_execute on line 57: using PQexec
9393
[NO_PID]: sqlca: code: 0, state: 00000

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp