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

Commite339ed5

Browse files
author
Michael Meskes
committed
Added files containing changes between gram.y and preproc.y.
1 parent4607c5c commite339ed5

File tree

5 files changed

+2946
-0
lines changed

5 files changed

+2946
-0
lines changed
Lines changed: 382 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,382 @@
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.1 2008/11/14 10:03:33 meskes Exp $ */
2+
3+
ECPG: stmtClosePortalStmt block
4+
{
5+
if (INFORMIX_MODE)
6+
{
7+
if (pg_strcasecmp($1+strlen("close "), "database") == 0)
8+
{
9+
if (connection)
10+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for close database statement\n");
11+
12+
fprintf(yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
13+
whenever_action(2);
14+
free($1);
15+
break;
16+
}
17+
}
18+
19+
output_statement($1, 0, ECPGst_normal);
20+
}
21+
ECPG: stmtDeallocateStmt block
22+
{
23+
if (connection)
24+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for deallocate statement\n");
25+
26+
output_deallocate_prepare_statement($1);
27+
}
28+
ECPG: stmtDeclareCursorStmt block
29+
{ output_simple_statement($1); }
30+
ECPG: stmtDeleteStmt block
31+
ECPG: stmtDiscardStmt block
32+
ECPG: stmtFetchStmt block
33+
ECPG: stmtInsertStmt block
34+
ECPG: stmtSelectStmt block
35+
ECPG: stmtUpdateStmt block
36+
{ output_statement($1, 1, ECPGst_normal); }
37+
ECPG: stmtExecuteStmt block
38+
{ output_statement($1, 1, ECPGst_execute); }
39+
ECPG: stmtPrepareStmt block
40+
{
41+
if ($1.type == NULL || strlen($1.type) == 0)
42+
output_prepare_statement($1.name, $1.stmt);
43+
else
44+
output_statement(cat_str(5, make_str("prepare"), $1.name, $1.type, make_str("as"), $1.stmt), 0, ECPGst_normal);
45+
}
46+
ECPG: stmtTransactionStmt block
47+
{
48+
fprintf(yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
49+
whenever_action(2);
50+
free($1);
51+
}
52+
ECPG: stmtViewStmt rule
53+
| ECPGAllocateDescr
54+
{
55+
fprintf(yyout,"ECPGallocate_desc(__LINE__, %s);",$1);
56+
whenever_action(0);
57+
free($1);
58+
}
59+
| ECPGConnect
60+
{
61+
if (connection)
62+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for connect statement\n");
63+
64+
fprintf(yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit);
65+
reset_variables();
66+
whenever_action(2);
67+
free($1);
68+
}
69+
| ECPGCursorStmt
70+
{
71+
output_simple_statement($1);
72+
}
73+
| ECPGDeallocateDescr
74+
{
75+
if (connection)
76+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for deallocate statement\n");
77+
fprintf(yyout,"ECPGdeallocate_desc(__LINE__, %s);",$1);
78+
whenever_action(0);
79+
free($1);
80+
}
81+
| ECPGDeclare
82+
{
83+
output_simple_statement($1);
84+
}
85+
| ECPGDescribe
86+
{
87+
fprintf(yyout, "{ ECPGdescribe(__LINE__, %s,", $1);
88+
dump_variables(argsresult, 1);
89+
fputs("ECPGt_EORT);", yyout);
90+
fprintf(yyout, "}");
91+
output_line_number();
92+
93+
free($1);
94+
}
95+
| ECPGDisconnect
96+
{
97+
if (connection)
98+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for disconnect statement\n");
99+
100+
fprintf(yyout, "{ ECPGdisconnect(__LINE__, %s);",
101+
$1 ? $1 : "\"CURRENT\"");
102+
whenever_action(2);
103+
free($1);
104+
}
105+
| ECPGExecuteImmediateStmt{ output_statement($1, 0, ECPGst_exec_immediate); }
106+
| ECPGFree
107+
{
108+
const char *con = connection ? connection : "NULL";
109+
if (strcmp($1, "all"))
110+
fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, %s, \"%s\");", compat, con, $1);
111+
else
112+
fprintf(yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
113+
114+
whenever_action(2);
115+
free($1);
116+
}
117+
| ECPGGetDescriptor
118+
{
119+
lookup_descriptor($1.name, connection);
120+
output_get_descr($1.name, $1.str);
121+
free($1.name);
122+
free($1.str);
123+
}
124+
| ECPGGetDescriptorHeader
125+
{
126+
lookup_descriptor($1, connection);
127+
output_get_descr_header($1);
128+
free($1);
129+
}
130+
| ECPGOpen
131+
{
132+
struct cursor *ptr;
133+
134+
if ((ptr = add_additional_variables($1, true)) != NULL)
135+
{
136+
connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
137+
output_statement(mm_strdup(ptr->command), 0, 0);
138+
ptr->opened = true;
139+
}
140+
}
141+
| ECPGSetAutocommit
142+
{
143+
fprintf(yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
144+
whenever_action(2);
145+
free($1);
146+
}
147+
| ECPGSetConnection
148+
{
149+
if (connection)
150+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for set connection statement\n");
151+
152+
fprintf(yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
153+
whenever_action(2);
154+
free($1);
155+
}
156+
| ECPGSetDescriptor
157+
{
158+
lookup_descriptor($1.name, connection);
159+
output_set_descr($1.name, $1.str);
160+
free($1.name);
161+
free($1.str);
162+
}
163+
| ECPGSetDescriptorHeader
164+
{
165+
lookup_descriptor($1, connection);
166+
output_set_descr_header($1);
167+
free($1);
168+
}
169+
| ECPGTypedef
170+
{
171+
if (connection)
172+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for typedef statement\n");
173+
174+
fprintf(yyout, "%s", $1);
175+
free($1);
176+
output_line_number();
177+
}
178+
| ECPGVar
179+
{
180+
if (connection)
181+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for var statement\n");
182+
183+
output_simple_statement($1);
184+
}
185+
| ECPGWhenever
186+
{
187+
if (connection)
188+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for whenever statement\n");
189+
190+
output_simple_statement($1);
191+
}
192+
ECPG: CopyStmtCOPYopt_binaryqualified_nameopt_column_listopt_oidscopy_fromcopy_file_namecopy_delimiteropt_withcopy_opt_list addon
193+
if (strcmp($6, "to") == 0 && strcmp($7, "stdin") == 0)
194+
mmerror(PARSE_ERROR, ET_ERROR, "copy to stdin not possible\n");
195+
else if (strcmp($6, "from") == 0 && strcmp($7, "stdout") == 0)
196+
mmerror(PARSE_ERROR, ET_ERROR, "copy from stdout not possible\n");
197+
else if (strcmp($6, "from") == 0 && strcmp($7, "stdin") == 0)
198+
mmerror(PARSE_ERROR, ET_WARNING, "copy from stdin not implemented\n");
199+
ECPG: CopyStmtCOPYselect_with_parensTOcopy_file_nameopt_withcopy_opt_list addon
200+
if (strcmp($4, "stdin") == 0)
201+
mmerror(PARSE_ERROR, ET_ERROR, "copy to stdin not possible\n");
202+
ECPG: ConstraintAttributeSpecConstraintDeferrabilitySpecConstraintTimeSpec addon
203+
if (strcmp($1, "deferrable") != 0 && strcmp($2, "initially deferrable") == 0 )
204+
mmerror(PARSE_ERROR, ET_ERROR, "INITIALLY DEFERRED constraint must be DEFERRABLE\n");
205+
ECPG: ConstraintAttributeSpecConstraintTimeSpecConstraintDeferrabilitySpec addon
206+
if (strcmp($2, "deferrable") != 0 && strcmp($1, "initially deferrable") == 0 )
207+
mmerror(PARSE_ERROR, ET_ERROR, "INITIALLY DEFERRED constraint must be DEFERRABLE\n");
208+
ECPG: var_valueNumericOnly addon
209+
ECPG: fetch_directionSignedIconst addon
210+
if ($1[1] == '$')
211+
{
212+
free($1);
213+
$1 = make_str("$0");
214+
}
215+
ECPG: fetch_directionABSOLUTE_PSignedIconst addon
216+
ECPG: fetch_directionRELATIVE_PSignedIconst addon
217+
ECPG: fetch_directionFORWARDSignedIconst addon
218+
ECPG: fetch_directionBACKWARDSignedIconst addon
219+
if ($2[1] == '$')
220+
{
221+
free($2);
222+
$2 = make_str("$0");
223+
}
224+
ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
225+
{
226+
$$.name = $2;
227+
$$.type = $3;
228+
$$.stmt = cat_str(3, make_str("\""), $5, make_str("\""));
229+
}
230+
| PREPARE prepared_name FROM execstring
231+
{
232+
$$.name = $2;
233+
$$.type = NULL;
234+
$$.stmt = $4;
235+
}
236+
ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
237+
{ $$ = $2; }
238+
ECPG: DeclareCursorStmtDECLAREnamecursor_optionsCURSORopt_holdFORSelectStmt block
239+
{
240+
struct cursor *ptr, *this;
241+
242+
for (ptr = cur; ptr != NULL; ptr = ptr->next)
243+
{
244+
if (strcmp($2, ptr->name) == 0)
245+
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" already defined\n", $2);
246+
}
247+
248+
this = (struct cursor *) mm_alloc(sizeof(struct cursor));
249+
250+
this->next = cur;
251+
this->name = $2;
252+
this->connection = connection;
253+
this->opened = false;
254+
this->command = cat_str(7, make_str("declare"), mm_strdup($2), $3, make_str("cursor"), $5, make_str("for"), $7);
255+
this->argsinsert = argsinsert;
256+
this->argsresult = argsresult;
257+
argsinsert = argsresult = NULL;
258+
cur = this;
259+
260+
if (INFORMIX_MODE)
261+
$$ = cat_str(5, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("/*"), mm_strdup(this->command), make_str("*/"));
262+
else
263+
$$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
264+
}
265+
ECPG: opt_hold block
266+
{
267+
if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit == true)
268+
$$ = make_str("with hold");
269+
else
270+
$$ = EMPTY;
271+
}
272+
ECPG: into_clauseINTOOptTempTableName block
273+
{
274+
FoundInto = 1;
275+
$$= cat2_str(make_str("into"), $2);
276+
}
277+
| ecpg_into { $$ = EMPTY; }
278+
ECPG: table_refselect_with_parens addon
279+
mmerror(PARSE_ERROR, ET_ERROR, "sub-SELECT in FROM must have an alias\n");
280+
ECPG: TypenameSimpleTypenameopt_array_bounds block
281+
{$$ = cat2_str($1, $2.str); }
282+
ECPG: TypenameSETOFSimpleTypenameopt_array_bounds block
283+
{$$ = $$ = cat_str(3, make_str("setof"), $2, $3.str); }
284+
ECPG: opt_array_boundsopt_array_bounds'['']' block
285+
{
286+
$$.index1 = $1.index1;
287+
$$.index2 = $1.index2;
288+
if (strcmp($$.index1, "-1") == 0)
289+
$$.index1 = make_str("0");
290+
else if (strcmp($1.index2, "-1") == 0)
291+
$$.index2 = make_str("0");
292+
$$.str = cat_str(2, $1.str, make_str("[]"));
293+
}
294+
| opt_array_bounds '[' Iresult ']'
295+
{
296+
$$.index1 = $1.index1;
297+
$$.index2 = $1.index2;
298+
if (strcmp($1.index1, "-1") == 0)
299+
$$.index1 = strdup($3);
300+
else if (strcmp($1.index2, "-1") == 0)
301+
$$.index2 = strdup($3);
302+
$$.str = cat_str(4, $1.str, make_str("["), $3, make_str("]"));
303+
}
304+
ECPG: opt_array_bounds
305+
{
306+
$$.index1 = make_str("-1");
307+
$$.index2 = make_str("-1");
308+
$$.str= EMPTY;
309+
}
310+
ECPG: IconstICONST block
311+
{ $$ = make_name(); }
312+
ECPG: AexprConstNULL_P rule
313+
| civar{ $$ = $1; }
314+
| civarind{ $$ = $1; }
315+
ECPG: ColIdcol_name_keyword rule
316+
| ECPGKeywords { $$ = $1; }
317+
| ECPGCKeywords { $$ = $1; }
318+
| CHAR_P { $$ = make_str("char"); }
319+
| VALUES { $$ = make_str("values"); }
320+
ECPG: type_function_nametype_func_name_keyword rule
321+
| ECPGKeywords { $$ = $1; }
322+
| ECPGTypeName { $$ = $1; }
323+
| ECPGCKeywords { $$ = $1; }
324+
ECPG: VariableShowStmtSHOWALL block
325+
{
326+
mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL not implemented\n");
327+
$$ = EMPTY;
328+
}
329+
ECPG: FetchStmtFETCHfetch_directionfrom_inname block
330+
{
331+
add_additional_variables($4, false);
332+
$$ = cat_str(4, make_str("fetch"), $2, $3, $4);
333+
}
334+
ECPG: FetchStmtFETCHname block
335+
{
336+
add_additional_variables($2, false);
337+
$$ = cat_str(2, make_str("fetch"), $2);
338+
}
339+
ECPG: FetchStmtMOVEname rule
340+
| FETCH fetch_direction from_in name ecpg_into
341+
{
342+
add_additional_variables($4, false);
343+
$$ = cat_str(4, make_str("fetch"), $2, $3, $4);
344+
}
345+
| FETCH fetch_direction name ecpg_into
346+
{
347+
add_additional_variables($3, false);
348+
$$ = cat_str(4, make_str("fetch"), $2, make_str("from"), $3);
349+
}
350+
| FETCH from_in name ecpg_into
351+
{
352+
add_additional_variables($3, false);
353+
$$ = cat_str(3, make_str("fetch"), $2, $3);
354+
}
355+
| FETCH name ecpg_into
356+
{
357+
add_additional_variables($2, false);
358+
$$ = cat2_str(make_str("fetch"), $2);
359+
}
360+
| FETCH fetch_direction name
361+
{
362+
add_additional_variables($3, false);
363+
$$ = cat_str(4, make_str("fetch"), $2, make_str("from"), $3);
364+
}
365+
| FETCH from_in name
366+
{
367+
add_additional_variables($3, false);
368+
$$ = cat_str(3, make_str("fetch"), $2, $3);
369+
}
370+
ECPG: SpecialRuleRelationOLD addon
371+
if (!QueryIsRule)
372+
mmerror(PARSE_ERROR, ET_ERROR, "OLD used in non-rule query\n");
373+
ECPG: SpecialRuleRelationNEW addon
374+
if (!QueryIsRule)
375+
mmerror(PARSE_ERROR, ET_ERROR, "NEW used in non-rule query\n");
376+
ECPG: select_limitLIMITselect_limit_value','select_offset_value block
377+
{
378+
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to backend");
379+
$$ = cat_str(4, make_str("limit"), $2, make_str(","), $4);
380+
}
381+
ECPG: SignedIconstIconst rule
382+
| civar{ $$ = $1; }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp