Skip to content

Commit 33d71e3

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent 5633e22 commit 33d71e3

File tree

5 files changed

+95
-58
lines changed

5 files changed

+95
-58
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,3 +755,8 @@ Thu Dec 23 13:25:05 CET 1999
755755
- Fixed command line parsing.
756756
- Set ecpg version to 2.6.13.
757757

758+
Thu Jan 6 09:52:27 CET 2000
759+
760+
- Synced preproc.y with gram.y.
761+
- Made sure Bruce's additions also make it into my source tree.
762+
- Set ecpg version to 2.6.14.

src/interfaces/ecpg/preproc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
33

44
MAJOR_VERSION=2
55
MINOR_VERSION=6
6-
PATCHLEVEL=13
6+
PATCHLEVEL=14
77

88
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
99
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 85 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ static char *connection = NULL;
2727
static int QueryIsRule = 0, ForUpdateNotAllowed = 0, FoundInto = 0;
2828
static struct this_type actual_type[STRUCT_DEPTH];
2929
static char *actual_storage[STRUCT_DEPTH];
30-
static char *actual_startline[STRUCT_DEPTH];
3130

3231
/* temporarily store struct members while creating the data structure */
3332
struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL };
@@ -70,7 +69,7 @@ void
7069
output_line_number()
7170
{
7271
if (input_filename)
73-
fprintf(yyout, "\n#line %d \"%s\"\n", yylineno, input_filename);
72+
fprintf(yyout, "\n#line %d \"%s\"\n", yylineno + 1, input_filename);
7473
}
7574

7675
static void
@@ -480,20 +479,6 @@ make_name(void)
480479
return(name);
481480
}
482481

483-
static char *
484-
hashline_number()
485-
{
486-
if (input_filename)
487-
{
488-
char* line = mm_alloc(strlen("\n#line %d \"%s\"\n") + 21 + strlen(input_filename));
489-
sprintf(line, "\n#line %d \"%s\"\n", yylineno, input_filename);
490-
491-
return line;
492-
}
493-
494-
return EMPTY;
495-
}
496-
497482
static void
498483
output_statement(char * stmt, int mode)
499484
{
@@ -772,7 +757,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
772757
%type <str> columnList DeleteStmt LockStmt UpdateStmt CursorStmt
773758
%type <str> NotifyStmt columnElem copy_dirn UnlistenStmt copy_null
774759
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
775-
%type <str> opt_with_copy FetchStmt direction fetch_how_many portal_name
760+
%type <str> opt_with_copy FetchStmt opt_direction fetch_how_many opt_portal_name
776761
%type <str> ClosePortalStmt DropStmt VacuumStmt opt_verbose
777762
%type <str> opt_analyze opt_va_list va_list ExplainStmt index_params
778763
%type <str> index_list func_index index_elem opt_type opt_class access_method_clause
@@ -803,11 +788,12 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
803788
%type <str> select_offset_value table_list using_expr join_expr
804789
%type <str> using_list from_expr table_expr join_clause join_type
805790
%type <str> join_qual update_list join_clause join_clause_with_union
806-
%type <str> opt_level opt_lock lock_type,
791+
%type <str> opt_level opt_lock lock_type users_in_new_group_clause
807792
%type <str> OptConstrFromTable comment_op ConstraintAttributeSpec
808793
%type <str> constraints_set_list constraints_set_namelist comment_fn
809794
%type <str> constraints_set_mode comment_type comment_cl comment_ag
810795
%type <str> ConstraintDeferrabilitySpec ConstraintTimeSpec
796+
%type <str> CreateGroupStmt, AlterGroupStmt, DropGroupStmt
811797

812798
%type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen
813799
%type <str> indicator ECPGExecute ECPGPrepare ecpg_using
@@ -822,7 +808,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
822808
%type <str> enum_type civariableonly ECPGCursorStmt ECPGDeallocate
823809
%type <str> ECPGFree ECPGDeclare ECPGVar sql_variable_declarations
824810
%type <str> sql_declaration sql_variable_list sql_variable opt_at
825-
%type <str> struct_type s_struct declaration declarations variable_declarations
811+
%type <str> struct_type s_struct declaration variable_declarations
826812
%type <str> s_struct s_union union_type ECPGSetAutocommit on_off
827813

828814
%type <type_enum> simple_type varchar_type
@@ -851,12 +837,14 @@ statement: ecpgstart opt_at stmt ';' { connection = NULL; }
851837
opt_at: SQL_AT connection_target { connection = $2; }
852838

853839
stmt: AddAttrStmt { output_statement($1, 0); }
840+
| AlterGroupStmt { output_statement($1, 0); }
854841
| AlterUserStmt { output_statement($1, 0); }
855842
| ClosePortalStmt { output_statement($1, 0); }
856843
| CommentStmt { output_statement($1, 0); }
857844
| CopyStmt { output_statement($1, 0); }
858845
| CreateStmt { output_statement($1, 0); }
859846
| CreateAsStmt { output_statement($1, 0); }
847+
| CreateGroupStmt { output_statement($1, 0); }
860848
| CreateSeqStmt { output_statement($1, 0); }
861849
| CreatePLangStmt { output_statement($1, 0); }
862850
| CreateTrigStmt { output_statement($1, 0); }
@@ -865,6 +853,7 @@ stmt: AddAttrStmt { output_statement($1, 0); }
865853
| DefineStmt { output_statement($1, 0); }
866854
| DropStmt { output_statement($1, 0); }
867855
| TruncateStmt { output_statement($1, 0); }
856+
| DropGroupStmt { output_statement($1, 0); }
868857
| DropPLangStmt { output_statement($1, 0); }
869858
| DropTrigStmt { output_statement($1, 0); }
870859
| DropUserStmt { output_statement($1, 0); }
@@ -1111,10 +1100,6 @@ user_group_list: user_group_list ',' UserId
11111100

11121101
user_group_clause: IN GROUP user_group_list
11131102
{
1114-
/* the backend doesn't actually process this,
1115-
* so an warning message is probably fairer */
1116-
mmerror(ET_WARN, "IN GROUP is not implemented");
1117-
11181103
$$ = cat2_str(make_str("in group"), $3);
11191104
}
11201105
| /*EMPTY*/ { $$ = EMPTY; }
@@ -1124,6 +1109,63 @@ user_valid_clause: VALID UNTIL Sconst { $$ = cat2_str(make_str("valid until")
11241109
| /*EMPTY*/ { $$ = EMPTY; }
11251110
;
11261111

1112+
1113+
/*****************************************************************************
1114+
*
1115+
* Create a postresql group
1116+
*
1117+
*
1118+
****************************************************************************/
1119+
CreateGroupStmt: CREATE GROUP UserId
1120+
{
1121+
$$ = cat2_str(make_str("create group"), $3);
1122+
}
1123+
| CREATE GROUP UserId WITH sysid_clause users_in_new_group_clause
1124+
{
1125+
$$ = cat_str(5, make_str("create group"), $3, make_str("with"), $5, $6);
1126+
}
1127+
;
1128+
1129+
users_in_new_group_clause: USER user_group_list { $$ = cat2_str(make_str("user"), $2); }
1130+
| /* EMPTY */ { $$ = EMPTY; }
1131+
;
1132+
1133+
1134+
/*****************************************************************************
1135+
*
1136+
* Alter a postresql group
1137+
*
1138+
*
1139+
*****************************************************************************/
1140+
AlterGroupStmt: ALTER GROUP UserId WITH SYSID Iconst
1141+
{
1142+
$$ = cat_str(4, make_str("alter group"), $3, make_str("with sysid"), $6);
1143+
}
1144+
|
1145+
ALTER GROUP UserId ADD USER user_group_list
1146+
{
1147+
$$ = cat_str(4, make_str("alter group"), $3, make_str("add user"), $6);
1148+
}
1149+
|
1150+
ALTER GROUP UserId DROP USER user_group_list
1151+
{
1152+
$$ = cat_str(4, make_str("alter group"), $3, make_str("drop user"), $6);
1153+
}
1154+
;
1155+
1156+
/*****************************************************************************
1157+
*
1158+
* Drop a postresql group
1159+
*
1160+
*
1161+
*****************************************************************************/
1162+
DropGroupStmt: DROP GROUP UserId
1163+
{
1164+
$$ = cat2_str(make_str("drop group"), $3);
1165+
}
1166+
;
1167+
1168+
11271169
/*****************************************************************************
11281170
*
11291171
* Set PG internal variable
@@ -1885,55 +1927,42 @@ TruncateStmt: TRUNCATE TABLE relation_name
18851927
*
18861928
*****************************************************************************/
18871929

1888-
FetchStmt: FETCH direction fetch_how_many portal_name INTO into_list
1930+
FetchStmt: FETCH opt_direction fetch_how_many opt_portal_name INTO into_list
18891931
{
18901932
if (strcmp($2, "relative") == 0 && atol($3) == 0L)
18911933
mmerror(ET_ERROR, "FETCH/RELATIVE at current position is not supported");
18921934

18931935
$$ = cat_str(4, make_str("fetch"), $2, $3, $4);
18941936
}
1895-
| FETCH fetch_how_many portal_name INTO into_list
1896-
{
1897-
$$ = cat_str(3, make_str("fetch"), $2, $3);
1898-
}
1899-
| FETCH portal_name INTO into_list
1937+
| MOVE opt_direction fetch_how_many opt_portal_name
19001938
{
1901-
$$ = cat_str(2, make_str("fetch"), $2);
1902-
}
1903-
| MOVE direction fetch_how_many portal_name
1904-
{
1905-
$$ = cat_str(4, make_str("move"), $2, $3, $4);
1906-
}
1907-
| MOVE fetch_how_many portal_name
1908-
{
1909-
$$ = cat_str(3, make_str("move"), $2, $3);
1910-
}
1911-
| MOVE portal_name
1912-
{
1913-
$$ = cat_str(2, make_str("move"), $2);
1939+
$$ = cat_str(4, make_str("fetch"), $2, $3, $4);
19141940
}
19151941
;
19161942

1917-
direction: FORWARD { $$ = make_str("forward"); }
1943+
opt_direction: FORWARD { $$ = make_str("forward"); }
19181944
| BACKWARD { $$ = make_str("backward"); }
19191945
| RELATIVE { $$ = make_str("relative"); }
19201946
| ABSOLUTE
19211947
{
19221948
mmerror(ET_WARN, "FETCH/ABSOLUTE not supported, backend will use RELATIVE");
19231949
$$ = make_str("absolute");
19241950
}
1951+
| /*EMPTY*/ { $$ = EMPTY; /* default */ }
19251952
;
19261953

19271954
fetch_how_many: Iconst { $$ = $1; }
19281955
| '-' Iconst { $$ = cat2_str(make_str("-"), $2); }
19291956
| ALL { $$ = make_str("all"); }
19301957
| NEXT { $$ = make_str("next"); }
19311958
| PRIOR { $$ = make_str("prior"); }
1959+
| /*EMPTY*/ { $$ = EMPTY; /*default*/ }
19321960
;
19331961

1934-
portal_name: IN name { $$ = cat2_str(make_str("in"), $2); }
1962+
opt_portal_name: IN name { $$ = cat2_str(make_str("in"), $2); }
19351963
| FROM name { $$ = cat2_str(make_str("from"), $2); }
1936-
| name { $$ = cat2_str(make_str("in"), $1); }
1964+
/* | name { $$ = cat2_str(make_str("in"), $1); }*/
1965+
| /*EMPTY*/ { $$ = EMPTY; }
19371966
;
19381967

19391968
/*****************************************************************************
@@ -4503,6 +4532,7 @@ ECPGDeallocate: SQL_DEALLOCATE SQL_PREPARE ident { $$ = cat_str(3, make_str("ECP
45034532
ECPGDeclaration: sql_startdeclare
45044533
{
45054534
fputs("/* exec sql begin declare section */", yyout);
4535+
output_line_number();
45064536
}
45074537
variable_declarations sql_enddeclare
45084538
{
@@ -4515,16 +4545,18 @@ sql_startdeclare : ecpgstart BEGIN_TRANS DECLARE SQL_SECTION ';' {}
45154545

45164546
sql_enddeclare: ecpgstart END_TRANS DECLARE SQL_SECTION ';' {}
45174547

4518-
variable_declarations: /* empty */ { $$ = EMPTY; }
4519-
| declarations { $$ = $1; }
4520-
4521-
declarations: declaration { $$ = $1; }
4522-
| declarations declaration { $$ = cat2_str($1, $2); }
4548+
variable_declarations: /* empty */
4549+
{
4550+
$$ = EMPTY;
4551+
}
4552+
| declaration variable_declarations
4553+
{
4554+
$$ = cat2_str($1, $2);
4555+
}
45234556

45244557
declaration: storage_clause
45254558
{
45264559
actual_storage[struct_level] = mm_strdup($1);
4527-
actual_startline[struct_level] = hashline_number();
45284560
}
45294561
type
45304562
{
@@ -4534,7 +4566,7 @@ declaration: storage_clause
45344566
}
45354567
variable_list ';'
45364568
{
4537-
$$ = cat_str(5, actual_startline[struct_level], $1, $3.type_str, $5, make_str(";\n"));
4569+
$$ = cat_str(4, $1, $3.type_str, $5, make_str(";\n"));
45384570
}
45394571

45404572
storage_clause : S_EXTERN { $$ = make_str("extern"); }
@@ -5441,7 +5473,7 @@ c_stuff: c_anything { $$ = $1; }
54415473
}
54425474

54435475
c_list: c_term { $$ = $1; }
5444-
| c_list ',' c_term { $$ = cat_str(3, $1, make_str(","), $3); }
5476+
| c_term ',' c_list { $$ = cat_str(3, $1, make_str(","), $3); }
54455477

54465478
c_term: c_stuff { $$ = $1; }
54475479
| '{' c_list '}' { $$ = cat_str(3, make_str("{"), $2, make_str("}")); }

src/interfaces/ecpg/test/test1.pgc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ exec sql end declare section;
8282
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
8383
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
8484

85-
exec sql at pm select name, amount, letter into :name, :amount, :letter from "Test";
85+
exec sql at pm select * into :name, :amount, :letter from "Test";
8686

8787
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
8888
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);

src/interfaces/ecpg/test/test3.pgc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ exec sql begin declare section;
1919
int ind_children;
2020
str *married = NULL;
2121
char *wifesname="Petra";
22-
char *query="select name, born, age, married, children from meskes where name = :var1";
22+
char *query="select * from meskes where name = :var1";
2323
exec sql end declare section;
2424

2525
exec sql declare cur cursor for
@@ -41,8 +41,8 @@ exec sql end declare section;
4141
exec sql insert into meskes(name, married, children) values (:wifesname, '19900404', 3);
4242
exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 33, '19900404', 3);
4343
exec sql insert into meskes(name, born, age) values ('Carsten', 19910103, 8);
44-
exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 5);
45-
exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 1);
44+
exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 6);
45+
exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 2);
4646

4747
strcpy(msg, "commit");
4848
exec sql commit;

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