@@ -27,7 +27,6 @@ static char*connection = NULL;
2727static int QueryIsRule =0 , ForUpdateNotAllowed =0 , FoundInto =0 ;
2828static struct this_type actual_type[STRUCT_DEPTH];
2929static char *actual_storage[STRUCT_DEPTH];
30- static char *actual_startline[STRUCT_DEPTH];
3130
3231/* temporarily store struct members while creating the data structure*/
3332struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = {NULL };
7069output_line_number ()
7170{
7271if (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
7675static void
@@ -480,20 +479,6 @@ make_name(void)
480479return (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-
497482static void
498483output_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; }
851837opt_at :SQL_AT connection_target { connection =$2 ; }
852838
853839stmt :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
11121101user_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{
18901932if (strcmp($2 ," relative" ) ==0 && atol($3 ) ==0L )
18911933mmerror (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 {
19221948mmerror (ET_WARN," FETCH/ABSOLUTE not supported, backend will use RELATIVE" );
19231949$$ = make_str(" absolute" );
19241950}
1951+ | /* EMPTY*/ {$$ = EMPTY;/* default*/ }
19251952;
19261953
19271954fetch_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
45034532ECPGDeclaration :sql_startdeclare
45044533{
45054534fputs (" /* exec sql begin declare section */" , yyout);
4535+ output_line_number ();
45064536}
45074537variable_declarations sql_enddeclare
45084538{
@@ -4515,16 +4545,18 @@ sql_startdeclare : ecpgstart BEGIN_TRANS DECLARE SQL_SECTION ';' {}
45154545
45164546sql_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
45244557declaration :storage_clause
45254558{
45264559actual_storage[struct_level] = mm_strdup($1 );
4527- actual_startline[struct_level] = hashline_number();
45284560}
45294561type
45304562{
@@ -4534,7 +4566,7 @@ declaration: storage_clause
45344566}
45354567variable_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
45404572storage_clause :S_EXTERN {$$ = make_str(" extern" ); }
@@ -5441,7 +5473,7 @@ c_stuff: c_anything { $$ = $1; }
54415473}
54425474
54435475c_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
54465478c_term :c_stuff {$$ =$1 ; }
54475479| ' {' c_list ' }' {$$ = cat_str(3 , make_str(" {" ),$2 , make_str(" }" )); }