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

Commite845adf

Browse files
author
Michael Meskes
committed
- Fixed bug in adjust_informix that treated arrays as simple variables.
- Synced parser again.- Synced lexer.
1 parenta4ab5ba commite845adf

File tree

5 files changed

+126
-53
lines changed

5 files changed

+126
-53
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,13 @@ Thu Apr 22 14:13:57 CEST 2004
17771777
Thu Apr 29 16:06:37 CEST 2004
17781778

17791779
- Synced parser and keyword list.
1780+
1781+
Wed May 5 11:51:47 CEST 2004
1782+
1783+
- Fixed bug in adjust_informix that treated arrays as simple
1784+
variables.
1785+
- Synced parser again.
1786+
- Synced lexer.
17801787
- Set pgtypes library version to 1.2.
17811788
- Set ecpg version to 3.2.0.
17821789
- Set compat library version to 1.2.

‎src/interfaces/ecpg/ecpglib/data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.22 2003/11/29 19:52:08 pgsql Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.23 2004/05/05 15:03:04 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -44,7 +44,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
4444
char*pval= (char*)PQgetvalue(results,act_tuple,act_field);
4545
intvalue_for_indicator=0;
4646

47-
ECPGlog("ECPGget_data line %d: RESULT: %s offset: %ld array: %d\n",lineno,pval ?pval :"",offset,isarray);
47+
ECPGlog("ECPGget_data line %d: RESULT: %s offset: %ld array: %s\n",lineno,pval ?pval :"",offset,isarray?"Yes":"No");
4848

4949
/* pval is a pointer to the value */
5050
/* let's check if it really is an array if it should be one */

‎src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.32 2004/01/28 09:52:14 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.33 2004/05/05 15:03:04 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -333,7 +333,7 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia
333333
}
334334
PQclear(query);
335335
ECPGtypeinfocache_push(&(stmt->connection->cache_head),type,isarray,stmt->lineno);
336-
ECPGlog("ECPGis_type_an_array line %d: TYPE database: %d C: %d array: %d\n",stmt->lineno,type,var->type,isarray);
336+
ECPGlog("ECPGis_type_an_array line %d: TYPE database: %d C: %d array: %s\n",stmt->lineno,type,var->type,isarray?"Yes":"No");
337337
returnisarray;
338338
}
339339

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

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.127 2004/03/02 06:45:05 meskes Exp $
15+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.128 2004/05/05 15:03:04 meskes Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -28,6 +28,7 @@
2828
extern YYSTYPE yylval;
2929

3030
staticintxcdepth =0;/* depth of nesting in slash-star comments*/
31+
staticchar *dolqstart;/* current $foo$ quote start string*/
3132

3233
/*
3334
* literalbuf is used to accumulate literal values when multiple rules
@@ -93,6 +94,7 @@ static struct _if_value
9394
*<xd> delimited identifiers (double-quoted identifiers) - thomas 1997-10-27
9495
*<xh> hexadecimal numeric string - thomas 1997-11-16
9596
*<xq> quoted strings - thomas 1997-07-30
97+
* <xdolq> $foo$ quoted strings
9698
*/
9799

98100
%xxb
@@ -101,6 +103,7 @@ static struct _if_value
101103
%xxdc
102104
%xxh
103105
%xxq
106+
%xxdolq
104107
%xxpre
105108
%xxcond
106109
%xxskip
@@ -128,7 +131,7 @@ xnstart [nN]{quote}
128131
xch0[xX][0-9A-Fa-f]*
129132

130133
/* Extended quote
131-
* xqdouble implementsSQL92embedded quote
134+
* xqdouble implements embedded quote
132135
* xqcat allows strings to cross input lines
133136
*/
134137
quote'
@@ -140,6 +143,17 @@ xqescape [\\][^0-7]
140143
xqoctesc [\\][0-7]{1,3}
141144
xqcat{quote}{whitespace_with_newline}{quote}
142145

146+
/* $foo$ style quotes ("dollar quoting")
147+
* The quoted string starts with $foo$ where "foo" is an optional string
148+
* in the form of an identifier, except that it may not contain "$",
149+
* and extends to the first occurrence of an identical string.
150+
* There is *no* processing of the quoted text.
151+
*/
152+
dolq_start [A-Za-z\200-\377_]
153+
dolq_cont [A-Za-z\200-\377_0-9]
154+
dolqdelim\$({dolq_start}{dolq_cont}*)?\$
155+
dolqinside [^$]+
156+
143157
/* Double quote
144158
* Allows embedded spaces and other special characters into identifiers.
145159
*/
@@ -171,8 +185,7 @@ xdcinside({xdcqq}|{xdcqdq}|{xdcother})
171185
* 2. In the operator rule, check for slash-star within the operator, and
172186
* if found throw it back with yyless(). This handles the plus-slash-star
173187
* problem.
174-
* SQL92-style comments, which start with dash-dash, have similar interactions
175-
* with the operator rule.
188+
* Dash-dash comments have similar interactions with the operator rule.
176189
*/
177190
xcstart\/\*{op_chars}*
178191
xcstop\*+\/
@@ -279,9 +292,10 @@ cppinclude {space}*#{include}{space}*
279292
cppline{space}*#(.*\\{space})+.*
280293

281294
/*
282-
* Quoted strings must allow some special characters such as single-quote
295+
* Dollar quoted strings are totally opaque, and no escaping is done on them.
296+
* Other quoted strings must allow some special characters such as single-quote
283297
*and newline.
284-
* Embedded single-quotes are implemented both in theSQL92-standard
298+
* Embedded single-quotes are implemented both in theSQLstandard
285299
*style of two adjacent single quotes "''" and in the Postgres/Java style
286300
*of escaped-quote "\'".
287301
* Other embedded escaped characters are matched explicitly and the leading
@@ -341,7 +355,7 @@ cppline{space}*#(.*\\{space})+.*
341355
BEGIN(SQL);
342356
if (literalbuf[strspn(literalbuf,"01") +1] !='\0')
343357
mmerror(PARSE_ERROR, ET_ERROR,"invalid bit string input.");
344-
yylval.str = literalbuf;
358+
yylval.str =mm_strdup(literalbuf);
345359
return BCONST;
346360
}
347361

@@ -358,7 +372,7 @@ cppline{space}*#(.*\\{space})+.*
358372
addlitchar('x');
359373
}
360374
<xh>{xhstop}{
361-
yylval.str = literalbuf;
375+
yylval.str =mm_strdup(literalbuf);
362376
return XCONST;
363377
}
364378

@@ -388,8 +402,44 @@ cppline{space}*#(.*\\{space})+.*
388402
<xq>{xqescape} {addlit(yytext, yyleng); }
389403
<xq>{xqoctesc} {addlit(yytext, yyleng); }
390404
<xq>{xqcat}{/* ignore */ }
391-
405+
<xq>. {
406+
/* This is only needed for \ just before EOF */
407+
addlitchar(yytext[0]);
408+
}
392409
<xq><<EOF>>{mmerror(PARSE_ERROR, ET_FATAL,"Unterminated quoted string"); }
410+
<SQL>{dolqdelim} {
411+
token_start = yytext;
412+
dolqstart =mm_strdup(yytext);
413+
BEGIN(xdolq);
414+
startlit();
415+
}
416+
<xdolq>{dolqdelim} {
417+
if (strcmp(yytext, dolqstart) ==0)
418+
{
419+
free(dolqstart);
420+
BEGIN(SQL);
421+
yylval.str =mm_strdup(literalbuf);
422+
return SCONST;
423+
}
424+
else
425+
{
426+
/*
427+
* When we fail to match $...$ to dolqstart, transfer
428+
* the $... part to the output, but put back the final
429+
* $ for rescanning. Consider $delim$...$junk$delim$
430+
*/
431+
addlit(yytext, yyleng-1);
432+
yyless(yyleng-1);
433+
}
434+
}
435+
<xdolq>{dolqinside} {
436+
addlit(yytext, yyleng);
437+
}
438+
<xdolq>.{
439+
/* This is only needed for $ inside the quoted text */
440+
addlitchar(yytext[0]);
441+
}
442+
<xdolq><<EOF>> {yyerror("unterminated dollar-quoted string"); }
393443

394444
<SQL>{xdstart}{
395445
state_before = YYSTATE;
@@ -400,6 +450,7 @@ cppline{space}*#(.*\\{space})+.*
400450
BEGIN(state_before);
401451
if (literallen ==0)
402452
mmerror(PARSE_ERROR, ET_ERROR,"zero-length delimited identifier");
453+
/* The backend will truncate the idnetifier here. We do not as it does not change the result. */
403454
yylval.str =mm_strdup(literalbuf);
404455
return CSTRING;
405456
}
@@ -459,12 +510,12 @@ cppline{space}*#(.*\\{space})+.*
459510
nchars = slashstar - yytext;
460511

461512
/*
462-
* ForSQL92 compatibility, '+' and '-' cannot be the
513+
* ForSQL compatibility, '+' and '-' cannot be the
463514
* last char of a multi-char operator unless the operator
464-
* contains chars that are not inSQL92 operators.
515+
* contains chars that are not inSQL operators.
465516
* The idea is to lex '=-' as two operators, but not
466517
* to forbid operator names like '?-' that could not be
467-
* sequences ofSQL92 operators.
518+
* sequences ofSQL operators.
468519
*/
469520
while (nchars >1 &&
470521
(yytext[nchars-1] =='+' ||

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

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.278 2004/04/29 14:08:10 meskes Exp $*/
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.279 2004/05/05 15:03:04 meskes Exp $*/
22

33
/* Copyright comment*/
44
%{
@@ -211,7 +211,7 @@ adjust_informix(struct arguments *list)
211211

212212
if (atoi(ptr->variable->type->size) >1)
213213
{
214-
ptr->variable =new_variable(cat_str(4,make_str("("),mm_strdup(ECPGtype_name(ptr->variable->type->type)),make_str(" *)(ECPG_informix_get_var("),mm_strdup(temp)),ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size),0);
214+
ptr->variable =new_variable(cat_str(4,make_str("("),mm_strdup(ECPGtype_name(ptr->variable->type->u.element->type)),make_str(" *)(ECPG_informix_get_var("),mm_strdup(temp)),ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,make_str("1")), ptr->variable->type->size),0);
215215
sprintf(temp,"%d, (", ecpg_informix_var++);
216216
}
217217
else
@@ -442,7 +442,7 @@ add_additional_variables(char *name, bool insert)
442442
%type<str>TableConstraintOptTableElementListXconstopt_transaction
443443
%type<str>ConstraintElemkey_actionsColQualListtype_name
444444
%type<str>target_listtarget_elupdate_target_listalias_clause
445-
%type<str>update_target_elqualified_namedatabase_name
445+
%type<str>update_target_elqualified_namedatabase_namealter_using
446446
%type<str>access_methodattr_nameindex_namenamefunc_name
447447
%type<str>file_nameAexprConstc_exprConstTypenamevar_list
448448
%type<str>a_exprb_exprTruncateStmtCommentStmtOnCommitOptionopt_by
@@ -464,15 +464,15 @@ add_additional_variables(char *name, bool insert)
464464
%type<str>copy_delimiterListenStmtCopyStmtcopy_file_nameopt_binary
465465
%type<str>FetchStmtfrom_inCreateOpClassStmtlike_including_defaults
466466
%type<str>ClosePortalStmtDropStmtVacuumStmtAnalyzeStmtopt_verbose
467-
%type<str>opt_fullfunc_argOptWithOidsopt_freeze
467+
%type<str>opt_fullfunc_argOptWithOidsopt_freezealter_table_cmd
468468
%type<str>analyze_keywordopt_name_listExplainStmtindex_params
469-
%type<str>index_elemopt_classaccess_method_clause
469+
%type<str>index_elemopt_classaccess_method_clausealter_table_cmds
470470
%type<str>index_opt_uniqueIndexStmtfunc_returnConstInterval
471471
%type<str>func_args_listfunc_argsopt_withdef_argoverlay_placing
472472
%type<str>def_elemdef_listdefinitionDefineStmtselect_with_parens
473473
%type<str>opt_insteadeventRuleActionListopt_usingCreateAssertStmt
474474
%type<str>RuleActionStmtOrEmptyRuleActionMultifunc_asreindex_type
475-
%type<str>RuleStmtopt_columnopt_nameoper_argtypesNumConst
475+
%type<str>RuleStmtopt_columnoper_argtypesNumConst
476476
%type<str>MathOpRemoveFuncStmtaggr_argtypefor_update_clause
477477
%type<str>RemoveAggrStmtopt_proceduralselect_no_parensCreateCastStmt
478478
%type<str>RemoveOperStmtRenameStmtall_Opopt_Trustedopt_lancompiler
@@ -1140,45 +1140,58 @@ CheckPointStmt: CHECKPOINT { $$= make_str("checkpoint"); }
11401140
*****************************************************************************/
11411141

11421142
AlterTableStmt:
1143+
ALTERTABLErelation_expralter_table_cmds
1144+
{$$ = cat_str(3, make_str("alter table"),$3,$4); }
1145+
;
1146+
1147+
alter_table_cmds:
1148+
alter_table_cmd {$$ =$1; }
1149+
|alter_table_cmds','alter_table_cmd{$$ = cat_str(3,$1, make_str(","),$3); }
1150+
;
1151+
1152+
alter_table_cmd:
1153+
ADDopt_columncolumnDef
11431154
/* ALTER TABLE <relation> ADD [COLUMN] <coldef>*/
1144-
ALTERTABLErelation_exprADDopt_columncolumnDef
1145-
{$$ = cat_str(5, make_str("alter table"),$3, make_str("add"),$5,$6); }
1155+
{$$ = cat_str(3, make_str("add"),$2,$3); }
11461156
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> {SET DEFAULT <expr>|DROP DEFAULT}*/
1147-
|ALTERTABLErelation_exprALTERopt_columnColIdalter_column_default
1148-
{$$ = cat_str(6, make_str("alter table"),$3, make_str("alter"),$5,$6,$7); }
1157+
|ALTERopt_columnColIdalter_column_default
1158+
{$$ = cat_str(4, make_str("alter"),$2,$3,$4); }
11491159
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> DROP NOT NULL*/
1150-
|ALTERTABLErelation_exprALTERopt_columnColIdDROPNOTNULL_P
1151-
{$$ = cat_str(6, make_str("alter table"),$3, make_str("alter"),$5,$6, make_str("drop not null")); }
1160+
|ALTERopt_columnColIdDROPNOTNULL_P
1161+
{$$ = cat_str(4, make_str("alter"),$2,$3, make_str("drop not null")); }
11521162
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> SET NOT NULL*/
1153-
|ALTERTABLErelation_exprALTERopt_columnColIdSETNOTNULL_P
1154-
{$$ = cat_str(6, make_str("alter table"),$3, make_str("alter"),$5,$6, make_str("set not null")); }
1163+
|ALTERopt_columnColIdSETNOTNULL_P
1164+
{$$ = cat_str(4, make_str("alter"),$2,$3, make_str("set not null")); }
11551165
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> SET STATISTICS <IntegerOnly>*/
1156-
|ALTERTABLErelation_exprALTERopt_columnColIdSETSTATISTICSPosIntConst
1157-
{$$ = cat_str(7, make_str("alter table"),$3, make_str("alter"),$5,$6,make_str("set statistics"),$9); }
1166+
|ALTERopt_columnColIdSETSTATISTICSPosIntConst
1167+
{$$ = cat_str(5, make_str("alter"),$2,$3,make_str("set statistics"),$6); }
11581168
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> SET STORAGE <storagemode>*/
1159-
|ALTERTABLErelation_exprALTERopt_columnColIdSETSTORAGEColId
1160-
{$$ = cat_str(7, make_str("alter table"),$3, make_str("alter"),$5,$6,make_str("set storage"),$9); }
1169+
|ALTERopt_columnColIdSETSTORAGEColId
1170+
{$$ = cat_str(5, make_str("alter"),$2,$3,make_str("set storage"),$6); }
11611171
/* ALTER TABLE <relation> DROP [COLUMN] <colname> {RESTRICT|CASCADE}*/
1162-
|ALTERTABLErelation_exprDROPopt_columnColIdopt_drop_behavior
1163-
{$$ = cat_str(6, make_str("alter table"),$3, make_str("drop"),$5,$6,$7); }
1172+
|DROPopt_columnColIdopt_drop_behavior
1173+
{$$ = cat_str(4, make_str("drop"),$2,$3,$4); }
1174+
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> TYPE <typename> [ USING <expression> ]*/
1175+
|ALTERopt_columnColIdTYPE_PTypenamealter_using
1176+
{$$ = cat_str(6, make_str("alter"),$2,$3, make_str("type"),$5,$6); }
11641177
/* ALTER TABLE <relation> ADD CONSTRAINT ...*/
1165-
|ALTERTABLErelation_exprADDTableConstraint
1166-
{$$ = cat_str(4, make_str("alter table"),$3, make_str("add"),$5); }
1178+
|ADDTableConstraint
1179+
{$$ = cat_str(2, make_str("add"),$2); }
11671180
/* ALTER TABLE <relation> DROP CONSTRAINT ...*/
1168-
|ALTERTABLErelation_exprDROPCONSTRAINTnameopt_drop_behavior
1169-
{$$ = cat_str(5, make_str("alter table"),$3, make_str("drop constraint"),$6,$7); }
1181+
|DROPCONSTRAINTnameopt_drop_behavior
1182+
{$$ = cat_str(3, make_str("drop constraint"),$3,$4); }
11701183
/* ALTER TABLE <relation> SET WITHOUT OIDS*/
1171-
|ALTERTABLErelation_exprSETWITHOUTOIDS
1172-
{$$ =cat_str(3,make_str("alter table"),$3, make_str("set without oids")); }
1184+
|SETWITHOUTOIDS
1185+
{$$ = make_str("set without oids"); }
11731186
/* ALTER TABLE <name> CREATE TOAST TABLE*/
1174-
|ALTERTABLEqualified_nameCREATETOASTTABLE
1175-
{$$ =cat_str(3,make_str("alter table"),$3, make_str("create toast table")); }
1187+
|CREATETOASTTABLE
1188+
{$$ = make_str("create toast table"); }
11761189
/* ALTER TABLE <name> OWNER TO UserId*/
1177-
|ALTERTABLEqualified_nameOWNERTOUserId
1178-
{$$ = cat_str(4, make_str("alter table"),$3, make_str("owner to"),$6); }
1190+
|OWNERTOUserId
1191+
{$$ = cat_str(2, make_str("owner to"),$3); }
11791192
/* ALTER TABLE <name> CLUSTER ON <indexname>*/
1180-
|ALTERTABLEqualified_nameCLUSTERONname
1181-
{$$ = cat_str(4, make_str("alter table"),$3, make_str("cluster on"),$6); }
1193+
|CLUSTERONname
1194+
{$$ = cat_str(2, make_str("cluster on"),$3); }
11821195
;
11831196

11841197
alter_column_default:
@@ -1191,6 +1204,10 @@ opt_drop_behavior: CASCADE { $$ = make_str("cascade"); }
11911204
|/* EMPTY*/ {$$ = EMPTY; }
11921205
;
11931206

1207+
alter_using:USINGa_expr{$$ = cat2_str(make_str("using"),$2); }
1208+
|/* EMPTY*/ {$$ = EMPTY; }
1209+
;
1210+
11941211
/*****************************************************************************
11951212
*
11961213
*QUERY :
@@ -2310,18 +2327,16 @@ RenameStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' RENAME TO name
23102327
{$$ = cat_str(6, make_str("alter operator class"),$4, make_str("using"),$6, make_str("rename to"),$9); }
23112328
|ALTERSCHEMAnameRENAMETOname
23122329
{$$ = cat_str(4, make_str("alter schema"),$3, make_str("rename to"),$6); }
2313-
|ALTERTABLErelation_exprRENAMEopt_columnopt_nameTOname
2330+
|ALTERTABLErelation_exprRENAMETOname
2331+
{$$ = cat_str(4, make_str("alter table"),$3, make_str("rename to"),$6); }
2332+
|ALTERTABLErelation_exprRENAMEopt_columnnameTOname
23142333
{$$ = cat_str(7, make_str("alter table"),$3, make_str("rename"),$5,$6, make_str("to"),$8); }
23152334
|ALTERTRIGGERnameONrelation_exprRENAMETOname
23162335
{$$ = cat_str(6, make_str("alter trigger"),$3, make_str("on"),$5, make_str("rename to"),$8); }
23172336
|ALTERUSERUserIdRENAMETOUserId
23182337
{$$ = cat_str(4, make_str("alter user"),$3, make_str("rename to"),$6); }
23192338
;
23202339

2321-
opt_name:name{$$ =$1; }
2322-
|/*EMPTY*/{$$ = EMPTY; }
2323-
;
2324-
23252340
opt_column:COLUMN{$$ = make_str("column"); }
23262341
|/*EMPTY*/{$$ = EMPTY; }
23272342
;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp