Skip to content

Commit e845adf

Browse files
author
Michael Meskes
committed
- Fixed bug in adjust_informix that treated arrays as simple variables.
- Synced parser again. - Synced lexer.
1 parent a4ab5ba commit e845adf

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
#define POSTGRES_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
int value_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
return isarray;
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
static int xcdepth = 0; /* depth of nesting in slash-star comments */
31+
static char *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
%x xb
@@ -101,6 +103,7 @@ static struct _if_value
101103
%x xdc
102104
%x xh
103105
%x xq
106+
%x xdolq
104107
%x xpre
105108
%x xcond
106109
%x xskip
@@ -128,7 +131,7 @@ xnstart [nN]{quote}
128131
xch 0[xX][0-9A-Fa-f]*
129132

130133
/* Extended quote
131-
* xqdouble implements SQL92 embedded 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 the SQL92-standard
298+
* Embedded single-quotes are implemented both in the SQL standard
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-
* For SQL92 compatibility, '+' and '-' cannot be the
513+
* For SQL compatibility, '+' and '-' cannot be the
463514
* last char of a multi-char operator unless the operator
464-
* contains chars that are not in SQL92 operators.
515+
* contains chars that are not in SQL operators.
465516
* The idea is to lex '=-' as two operators, but not
466517
* to forbid operator names like '?-' that could not be
467-
* sequences of SQL92 operators.
518+
* sequences of SQL 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> TableConstraint OptTableElementList Xconst opt_transaction
443443
%type <str> ConstraintElem key_actions ColQualList type_name
444444
%type <str> target_list target_el update_target_list alias_clause
445-
%type <str> update_target_el qualified_name database_name
445+
%type <str> update_target_el qualified_name database_name alter_using
446446
%type <str> access_method attr_name index_name name func_name
447447
%type <str> file_name AexprConst c_expr ConstTypename var_list
448448
%type <str> a_expr b_expr TruncateStmt CommentStmt OnCommitOption opt_by
@@ -464,15 +464,15 @@ add_additional_variables(char *name, bool insert)
464464
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
465465
%type <str> FetchStmt from_in CreateOpClassStmt like_including_defaults
466466
%type <str> ClosePortalStmt DropStmt VacuumStmt AnalyzeStmt opt_verbose
467-
%type <str> opt_full func_arg OptWithOids opt_freeze
467+
%type <str> opt_full func_arg OptWithOids opt_freeze alter_table_cmd
468468
%type <str> analyze_keyword opt_name_list ExplainStmt index_params
469-
%type <str> index_elem opt_class access_method_clause
469+
%type <str> index_elem opt_class access_method_clause alter_table_cmds
470470
%type <str> index_opt_unique IndexStmt func_return ConstInterval
471471
%type <str> func_args_list func_args opt_with def_arg overlay_placing
472472
%type <str> def_elem def_list definition DefineStmt select_with_parens
473473
%type <str> opt_instead event RuleActionList opt_using CreateAssertStmt
474474
%type <str> RuleActionStmtOrEmpty RuleActionMulti func_as reindex_type
475-
%type <str> RuleStmt opt_column opt_name oper_argtypes NumConst
475+
%type <str> RuleStmt opt_column oper_argtypes NumConst
476476
%type <str> MathOp RemoveFuncStmt aggr_argtype for_update_clause
477477
%type <str> RemoveAggrStmt opt_procedural select_no_parens CreateCastStmt
478478
%type <str> RemoveOperStmt RenameStmt all_Op opt_Trusted opt_lancompiler
@@ -1140,45 +1140,58 @@ CheckPointStmt: CHECKPOINT { $$= make_str("checkpoint"); }
11401140
*****************************************************************************/
11411141

11421142
AlterTableStmt:
1143+
ALTER TABLE relation_expr alter_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+
ADD opt_column columnDef
11431154
/* ALTER TABLE <relation> ADD [COLUMN] <coldef> */
1144-
ALTER TABLE relation_expr ADD opt_column columnDef
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-
| ALTER TABLE relation_expr ALTER opt_column ColId alter_column_default
1148-
{ $$ = cat_str(6, make_str("alter table"), $3, make_str("alter"), $5, $6, $7); }
1157+
| ALTER opt_column ColId alter_column_default
1158+
{ $$ = cat_str(4, make_str("alter"), $2, $3, $4); }
11491159
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> DROP NOT NULL */
1150-
| ALTER TABLE relation_expr ALTER opt_column ColId DROP NOT NULL_P
1151-
{ $$ = cat_str(6, make_str("alter table"), $3, make_str("alter"), $5, $6, make_str("drop not null")); }
1160+
| ALTER opt_column ColId DROP NOT NULL_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-
| ALTER TABLE relation_expr ALTER opt_column ColId SET NOT NULL_P
1154-
{ $$ = cat_str(6, make_str("alter table"), $3, make_str("alter"), $5, $6, make_str("set not null")); }
1163+
| ALTER opt_column ColId SET NOT NULL_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-
| ALTER TABLE relation_expr ALTER opt_column ColId SET STATISTICS PosIntConst
1157-
{ $$ = cat_str(7, make_str("alter table"), $3, make_str("alter"), $5, $6, make_str("set statistics"), $9); }
1166+
| ALTER opt_column ColId SET STATISTICS PosIntConst
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-
| ALTER TABLE relation_expr ALTER opt_column ColId SET STORAGE ColId
1160-
{ $$ = cat_str(7, make_str("alter table"), $3, make_str("alter"), $5, $6, make_str("set storage"), $9); }
1169+
| ALTER opt_column ColId SET STORAGE ColId
1170+
{ $$ = cat_str(5, make_str("alter"), $2, $3, make_str("set storage"), $6); }
11611171
/* ALTER TABLE <relation> DROP [COLUMN] <colname> {RESTRICT|CASCADE} */
1162-
| ALTER TABLE relation_expr DROP opt_column ColId opt_drop_behavior
1163-
{ $$ = cat_str(6, make_str("alter table"), $3, make_str("drop"), $5, $6, $7); }
1172+
| DROP opt_column ColId opt_drop_behavior
1173+
{ $$ = cat_str(4, make_str("drop"), $2, $3, $4); }
1174+
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> TYPE <typename> [ USING <expression> ] */
1175+
| ALTER opt_column ColId TYPE_P Typename alter_using
1176+
{ $$ = cat_str(6, make_str("alter"), $2, $3, make_str("type"), $5, $6); }
11641177
/* ALTER TABLE <relation> ADD CONSTRAINT ... */
1165-
| ALTER TABLE relation_expr ADD TableConstraint
1166-
{ $$ = cat_str(4, make_str("alter table"), $3, make_str("add"), $5); }
1178+
| ADD TableConstraint
1179+
{ $$ = cat_str(2, make_str("add"), $2); }
11671180
/* ALTER TABLE <relation> DROP CONSTRAINT ... */
1168-
| ALTER TABLE relation_expr DROP CONSTRAINT name opt_drop_behavior
1169-
{ $$ = cat_str(5, make_str("alter table"), $3, make_str("drop constraint"), $6, $7); }
1181+
| DROP CONSTRAINT name opt_drop_behavior
1182+
{ $$ = cat_str(3, make_str("drop constraint"), $3, $4); }
11701183
/* ALTER TABLE <relation> SET WITHOUT OIDS */
1171-
| ALTER TABLE relation_expr SET WITHOUT OIDS
1172-
{ $$ = cat_str(3, make_str("alter table"), $3, make_str("set without oids")); }
1184+
| SET WITHOUT OIDS
1185+
{ $$ = make_str("set without oids"); }
11731186
/* ALTER TABLE <name> CREATE TOAST TABLE */
1174-
| ALTER TABLE qualified_name CREATE TOAST TABLE
1175-
{ $$ = cat_str(3, make_str("alter table"), $3, make_str("create toast table")); }
1187+
| CREATE TOAST TABLE
1188+
{ $$ = make_str("create toast table"); }
11761189
/* ALTER TABLE <name> OWNER TO UserId */
1177-
| ALTER TABLE qualified_name OWNER TO UserId
1178-
{ $$ = cat_str(4, make_str("alter table"), $3, make_str("owner to"), $6); }
1190+
| OWNER TO UserId
1191+
{ $$ = cat_str(2, make_str("owner to"), $3); }
11791192
/* ALTER TABLE <name> CLUSTER ON <indexname> */
1180-
| ALTER TABLE qualified_name CLUSTER ON name
1181-
{ $$ = cat_str(4, make_str("alter table"), $3, make_str("cluster on"), $6); }
1193+
| CLUSTER ON name
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: USING a_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
| ALTER SCHEMA name RENAME TO name
23122329
{ $$ = cat_str(4, make_str("alter schema"), $3, make_str("rename to"), $6); }
2313-
| ALTER TABLE relation_expr RENAME opt_column opt_name TO name
2330+
| ALTER TABLE relation_expr RENAME TO name
2331+
{ $$ = cat_str(4, make_str("alter table"), $3, make_str("rename to"), $6); }
2332+
| ALTER TABLE relation_expr RENAME opt_column name TO name
23142333
{ $$ = cat_str(7, make_str("alter table"), $3, make_str("rename"), $5, $6, make_str("to"), $8); }
23152334
| ALTER TRIGGER name ON relation_expr RENAME TO name
23162335
{ $$ = cat_str(6, make_str("alter trigger"), $3, make_str("on"), $5, make_str("rename to"), $8); }
23172336
| ALTER USER UserId RENAME TO UserId
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy