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

Commit196d0dd

Browse files
author
Michael Meskes
committed
Changed variable parsing so struct[n].attr works.
1 parentbbe9902 commit196d0dd

File tree

9 files changed

+121
-159
lines changed

9 files changed

+121
-159
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,11 @@ Tue May 27 16:33:36 CEST 2003
14531453
Thu May 29 13:58:25 CEST 2003
14541454

14551455
- ecpg should now be able to parse forward struct definition.
1456+
1457+
Thu May 29 15:45:57 CEST 2003
1458+
1459+
- Changed parsing of variables to be able to reference one attribute
1460+
of the n-th entry in an array of structs.
14561461
- Set ecpg version to 2.12.0.
14571462
- Set ecpg library to 3.4.2.
14581463
- Set pgtypes library to 1.0.0

‎src/interfaces/ecpg/preproc/descriptor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ output_get_descr(char *desc_name, char *index)
192192
break;
193193
}
194194
fprintf(yyout,"%s,",get_dtype(results->value));
195-
ECPGdump_a_type(yyout,v->name,v->type,NULL,NULL,NULL,NULL,NULL,NULL,make_str("0"),NULL,NULL);
195+
ECPGdump_a_type(yyout,v->name,v->type,NULL,NULL,NULL,NULL,make_str("0"),NULL,NULL);
196196
}
197197
drop_assignments();
198198
fputs("ECPGd_EODT);\n",yyout);

‎src/interfaces/ecpg/preproc/extern.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ extern void add_descriptor(char *, char *);
7373
externvoiddrop_descriptor(char*,char*);
7474
externstructdescriptor*lookup_descriptor(char*,char*);
7575
externstructvariable*descriptor_variable(constchar*name,intinput);
76-
externvoidadd_variable(structarguments**,structvariable*,char*i,structvariable*,char*);
77-
externvoidappend_variable(structarguments**,structvariable*,char*,structvariable*,char*);
76+
externvoidadd_variable(structarguments**,structvariable*,structvariable*);
77+
externvoidappend_variable(structarguments**,structvariable*,structvariable*);
7878
externvoiddump_variables(structarguments*,int);
7979
externstructtypedefs*get_typedef(char*);
8080
externvoidadjust_array(enumECPGttype,char**,char**,char*,char*,int);

‎src/interfaces/ecpg/preproc/pgc.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.112 2003/05/2912:00:21 meskes Exp $
15+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.113 2003/05/2913:59:26 meskes Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -540,7 +540,7 @@ cppline{space}*#(.*\\{space})+.*
540540
yylval.str =mm_strdup(yytext);
541541
return FCONST;
542542
}
543-
<SQL>:{identifier}(("->"|\.){identifier})*{
543+
<SQL>:{identifier}((("->"|\.){identifier})|(\[{array}\]))*{
544544
yylval.str =mm_strdup(yytext+1);
545545
return(CVARIABLE);
546546
}

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

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.224 2003/05/2912:00:21 meskes Exp $*/
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.225 2003/05/2913:59:26 meskes Exp $*/
22

33
/* Copyright comment*/
44
%{
@@ -668,10 +668,10 @@ stmt: AlterDatabaseSetStmt{ output_statement($1, 0, connection); }
668668
{
669669
/* merge variables given in prepare statement with those given here*/
670670
for (p = ptr->argsinsert; p; p = p->next)
671-
append_variable(&argsinsert, p->variable, p->var_array_element, p->indicator, p->ind_array_element);
671+
append_variable(&argsinsert, p->variable, p->indicator);
672672

673673
for (p = ptr->argsresult; p; p = p->next)
674-
add_variable(&argsresult, p->variable, p->var_array_element, p->indicator, p->ind_array_element);
674+
add_variable(&argsresult, p->variable, p->indicator);
675675

676676
output_statement(mm_strdup(ptr->command), 0, ptr->connection ? mm_strdup(ptr->connection) : NULL);
677677
}
@@ -4234,7 +4234,7 @@ ECPGCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR ident
42344234
sprintf(thisquery->name,"ECPGprepared_statement(\"%s\")", $7);
42354235

42364236
this->argsinsert =NULL;
4237-
add_variable(&(this->argsinsert), thisquery,NULL,&no_indicator, NULL);
4237+
add_variable(&(this->argsinsert), thisquery, &no_indicator);
42384238

42394239
cur =this;
42404240

@@ -5095,7 +5095,7 @@ ECPGExecute : EXECUTE IMMEDIATE execstring
50955095
thisquery->next =NULL;
50965096
thisquery->name =$3;
50975097

5098-
add_variable(&argsinsert, thisquery,NULL,&no_indicator,NULL);
5098+
add_variable(&argsinsert, thisquery, &no_indicator);
50995099

51005100
$$ = make_str("?");
51015101
}
@@ -5109,7 +5109,7 @@ ECPGExecute : EXECUTE IMMEDIATE execstring
51095109
thisquery->name = (char *) mm_alloc(sizeof("ECPGprepared_statement(\"\")") + strlen($2));
51105110
sprintf(thisquery->name,"ECPGprepared_statement(\"%s\")", $2);
51115111

5112-
add_variable(&argsinsert, thisquery,NULL,&no_indicator,NULL);
5112+
add_variable(&argsinsert, thisquery, &no_indicator);
51135113
}
51145114
opt_ecpg_usingopt_ecpg_into
51155115
{
@@ -5150,7 +5150,7 @@ ecpg_into: INTO into_list
51505150
}
51515151
|INTOopt_sqlSQL_DESCRIPTORquoted_ident_stringvar
51525152
{
5153-
add_variable(&argsresult, descriptor_variable($4,0),NULL,&no_indicator, NULL);
5153+
add_variable(&argsresult, descriptor_variable($4,0), &no_indicator);
51545154
$$ = EMPTY;
51555155
}
51565156
;
@@ -5970,57 +5970,26 @@ c_args: /*EMPTY*/{ $$ = EMPTY; }
59705970
|c_list{$$ =$1; }
59715971
;
59725972

5973-
coutputvariable:CVARIABLE'['Iresult']'indicator'['Iresult']'
5974-
{ add_variable(&argsresult, find_variable($1),$3, find_variable($5),$7); }
5975-
|CVARIABLEindicator'['Iresult']'
5976-
{ add_variable(&argsresult, find_variable($1),NULL, find_variable($2),$4); }
5977-
|CVARIABLE'['Iresult']'indicator
5978-
{ add_variable(&argsresult, find_variable($1),$3, find_variable($5),NULL); }
5979-
|CVARIABLEindicator
5980-
{ add_variable(&argsresult, find_variable($1),NULL, find_variable($2),NULL); }
5981-
|CVARIABLE'['Iresult']'
5982-
{ add_variable(&argsresult, find_variable($1),$3, &no_indicator,NULL); }
5973+
coutputvariable:CVARIABLEindicator
5974+
{ add_variable(&argsresult, find_variable($1), find_variable($2)); }
59835975
|CVARIABLE
5984-
{ add_variable(&argsresult, find_variable($1),NULL,&no_indicator,NULL); }
5976+
{ add_variable(&argsresult, find_variable($1), &no_indicator); }
59855977
;
59865978

59875979

5988-
civarind:CVARIABLE'['Iresult']'indicator'['Iresult']'
5989-
{
5990-
add_variable(&argsinsert, find_variable($1), $3, find_variable($5), $7);
5991-
$$ = create_questionmarks($1,true);
5992-
}
5993-
|CVARIABLEindicator'['Iresult']'
5994-
{
5995-
add_variable(&argsinsert, find_variable($1), NULL, find_variable($2), $4);
5996-
$$ = create_questionmarks($1,false);
5997-
}
5998-
|CVARIABLE'['Iresult']'indicator
5999-
{
6000-
if (find_variable($5)->type->type == ECPGt_array)
6001-
mmerror(PARSE_ERROR, ET_ERROR,"arrays of indicators are not allowed on input");
6002-
6003-
add_variable(&argsinsert, find_variable($1), $3, find_variable($5), NULL);
6004-
$$ = create_questionmarks($1,true);
6005-
}
6006-
|CVARIABLEindicator
5980+
civarind:CVARIABLEindicator
60075981
{
60085982
if (find_variable($2)->type->type == ECPGt_array)
60095983
mmerror(PARSE_ERROR, ET_ERROR,"arrays of indicators are not allowed on input");
60105984

6011-
add_variable(&argsinsert, find_variable($1),NULL,find_variable($2), NULL);
5985+
add_variable(&argsinsert, find_variable($1), find_variable($2));
60125986
$$ = create_questionmarks($1,false);
60135987
}
60145988
;
60155989

6016-
civar:CVARIABLE'['Iresult']'
6017-
{
6018-
add_variable(&argsinsert, find_variable($1), mm_strdup($3), &no_indicator, NULL);
6019-
$$ = create_questionmarks($1,true);
6020-
}
6021-
|CVARIABLE
5990+
civar:CVARIABLE
60225991
{
6023-
add_variable(&argsinsert, find_variable($1),NULL,&no_indicator, NULL);
5992+
add_variable(&argsinsert, find_variable($1), &no_indicator);
60245993
$$ = create_questionmarks($1,false);
60255994
}
60265995
;

‎src/interfaces/ecpg/preproc/type.c

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, c
214214

215215
void
216216
ECPGdump_a_type(FILE*o,constchar*name,structECPGtype*type,
217-
constchar*var_array_element,constchar*ind_name,
218-
structECPGtype*ind_type,constchar*ind_array_element,
217+
constchar*ind_name,structECPGtype*ind_type,
219218
constchar*prefix,constchar*ind_prefix,
220219
char*arr_str_siz,constchar*struct_sizeof,
221220
constchar*ind_struct_sizeof)
@@ -232,86 +231,29 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
232231
break;
233232
caseECPGt_struct:
234233
caseECPGt_union:
235-
/* If var_array_element is not equal
236-
* NULL, we have to use the
237-
* <var_array_element>th entry and
238-
* not the whole array */
239-
if (var_array_element==NULL)
240-
ECPGdump_a_struct(o,name,
241-
ind_name,
242-
type->size,
243-
type->u.element,
244-
(ind_type->type==ECPGt_NO_INDICATOR) ?ind_type :ind_type->u.element,
245-
NULL,prefix,ind_prefix);
246-
else
247-
{
248-
char*array_element= (char*)mm_alloc(strlen(name)+strlen(var_array_element)+sizeof("[]\0")),*ind_array_element;
249-
250-
sprintf(array_element,"%s[%s]",name,var_array_element);
251-
252-
if (ind_type->type!=ECPGt_NO_INDICATOR)
253-
{
254-
ind_array_element= (char*)mm_alloc(strlen(ind_name)+strlen(ind_array_element)+sizeof("+\0"));
255-
sprintf(ind_array_element,"%s[%s]",ind_name,ind_array_element);
256-
257-
ECPGdump_a_struct(o,array_element,ind_array_element,make_str("1"),
258-
type->u.element,ind_type->u.element,
259-
NULL,prefix,ind_prefix);
260-
free(ind_array_element);
261-
}
262-
else
263-
ECPGdump_a_struct(o,array_element,ind_name,make_str("1"),
264-
type->u.element,ind_type,
265-
NULL,prefix,ind_prefix);
266-
267-
free (array_element);
268-
}
234+
ECPGdump_a_struct(o,name,
235+
ind_name,
236+
type->size,
237+
type->u.element,
238+
(ind_type->type==ECPGt_NO_INDICATOR) ?ind_type :ind_type->u.element,
239+
NULL,prefix,ind_prefix);
269240
break;
270241
default:
271242
if (!IS_SIMPLE_TYPE(type->u.element->type))
272243
yyerror("Internal error: unknown datatype, please inform pgsql-bugs@postgresql.org");
273244

274-
/* If var_array_element is not equal
275-
* NULL, we have to use the
276-
* <var_array_element>th entry and not
277-
* the whole array */
278-
if (var_array_element==NULL)
279-
ECPGdump_a_simple(o,name,
280-
type->u.element->type,
245+
ECPGdump_a_simple(o,name,
246+
type->u.element->type,
281247
type->u.element->size,type->size,NULL,prefix);
282-
else
283-
{
284-
char*array_element= (char*)mm_alloc(strlen(name)+strlen(var_array_element)+sizeof("+\0"));
285-
286-
sprintf(array_element,"%s+%s",name,var_array_element);
287-
ECPGdump_a_simple(o,array_element,
288-
type->u.element->type,
289-
type->u.element->size,make_str("1"),NULL,prefix);
290-
free(array_element);
291-
292-
293-
}
294248

295249
if (ind_type!=NULL)
296250
{
297251
if (ind_type->type==ECPGt_NO_INDICATOR)
298252
ECPGdump_a_simple(o,ind_name,ind_type->type,ind_type->size,make_str("-1"),NULL,ind_prefix);
299253
else
300254
{
301-
if (ind_array_element==NULL)
302-
ECPGdump_a_simple(o,ind_name,ind_type->u.element->type,
303-
ind_type->u.element->size,ind_type->size,NULL,prefix);
304-
else
305-
{
306-
char*array_element= (char*)mm_alloc(strlen(ind_name)+strlen(ind_array_element)+sizeof("+\0"));
307-
308-
sprintf(array_element,"%s+%s",ind_name,ind_array_element);
309-
ECPGdump_a_simple(o,array_element,
310-
ind_type->u.element->type,
311-
ind_type->u.element->size,
312-
make_str("1"),NULL,prefix);
313-
free(array_element);
314-
}
255+
ECPGdump_a_simple(o,ind_name,ind_type->u.element->type,
256+
ind_type->u.element->size,ind_type->size,NULL,prefix);
315257
}
316258
}
317259
}
@@ -516,9 +458,9 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz,
516458

517459
for (p=type->u.members;p;p=p->next)
518460
{
519-
ECPGdump_a_type(o,p->name,p->type,NULL,
461+
ECPGdump_a_type(o,p->name,p->type,
520462
(ind_p!=NULL) ?ind_p->name :NULL,
521-
(ind_p!=NULL) ?ind_p->type :NULL,NULL,
463+
(ind_p!=NULL) ?ind_p->type :NULL,
522464
prefix,ind_prefix,arrsiz,type->struct_sizeof,
523465
(ind_p!=NULL) ?ind_type->struct_sizeof :NULL);
524466
if (ind_p!=NULL&&ind_p!=&struct_no_indicator)

‎src/interfaces/ecpg/preproc/type.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ voidECPGfree_type(struct ECPGtype *);
4949
size is the maxsize in case it is a varchar. Otherwise it is the size of
5050
the variable (required to do array fetches of structs).
5151
*/
52-
voidECPGdump_a_type(FILE*,constchar*,structECPGtype*,constchar*,
53-
constchar*,structECPGtype*,constchar*,constchar*,
52+
voidECPGdump_a_type(FILE*,constchar*,structECPGtype*,
53+
constchar*,structECPGtype*,constchar*,
5454
constchar*,char*,constchar*,constchar*);
5555

5656
/* A simple struct to keep a variable and its type. */
@@ -147,9 +147,7 @@ struct variable
147147
structarguments
148148
{
149149
structvariable*variable;
150-
char*var_array_element;
151150
structvariable*indicator;
152-
char*ind_array_element;
153151
structarguments*next;
154152
};
155153

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp