@@ -27,7 +27,6 @@ static char *connection = NULL;
27
27
static int QueryIsRule = 0 , ForUpdateNotAllowed = 0 , FoundInto = 0 ;
28
28
static struct this_type actual_type[STRUCT_DEPTH];
29
29
static char *actual_storage[STRUCT_DEPTH];
30
- static char *actual_startline[STRUCT_DEPTH];
31
30
32
31
/* temporarily store struct members while creating the data structure */
33
32
struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL };
70
69
output_line_number ()
71
70
{
72
71
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);
74
73
}
75
74
76
75
static void
@@ -480,20 +479,6 @@ make_name(void)
480
479
return (name);
481
480
}
482
481
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
-
497
482
static void
498
483
output_statement (char * stmt, int mode)
499
484
{
@@ -772,7 +757,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
772
757
%type <str> columnList DeleteStmt LockStmt UpdateStmt CursorStmt
773
758
%type <str> NotifyStmt columnElem copy_dirn UnlistenStmt copy_null
774
759
%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
776
761
%type <str> ClosePortalStmt DropStmt VacuumStmt opt_verbose
777
762
%type <str> opt_analyze opt_va_list va_list ExplainStmt index_params
778
763
%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
803
788
%type <str> select_offset_value table_list using_expr join_expr
804
789
%type <str> using_list from_expr table_expr join_clause join_type
805
790
%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
807
792
%type <str> OptConstrFromTable comment_op ConstraintAttributeSpec
808
793
%type <str> constraints_set_list constraints_set_namelist comment_fn
809
794
%type <str> constraints_set_mode comment_type comment_cl comment_ag
810
795
%type <str> ConstraintDeferrabilitySpec ConstraintTimeSpec
796
+ %type <str> CreateGroupStmt , AlterGroupStmt , DropGroupStmt
811
797
812
798
%type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen
813
799
%type <str> indicator ECPGExecute ECPGPrepare ecpg_using
@@ -822,7 +808,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
822
808
%type <str> enum_type civariableonly ECPGCursorStmt ECPGDeallocate
823
809
%type <str> ECPGFree ECPGDeclare ECPGVar sql_variable_declarations
824
810
%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
826
812
%type <str> s_struct s_union union_type ECPGSetAutocommit on_off
827
813
828
814
%type <type_enum> simple_type varchar_type
@@ -851,12 +837,14 @@ statement: ecpgstart opt_at stmt ';' { connection = NULL; }
851
837
opt_at : SQL_AT connection_target { connection = $2 ; }
852
838
853
839
stmt : AddAttrStmt { output_statement($1 , 0 ); }
840
+ | AlterGroupStmt { output_statement($1 , 0 ); }
854
841
| AlterUserStmt { output_statement($1 , 0 ); }
855
842
| ClosePortalStmt { output_statement($1 , 0 ); }
856
843
| CommentStmt { output_statement($1 , 0 ); }
857
844
| CopyStmt { output_statement($1 , 0 ); }
858
845
| CreateStmt { output_statement($1 , 0 ); }
859
846
| CreateAsStmt { output_statement($1 , 0 ); }
847
+ | CreateGroupStmt { output_statement($1 , 0 ); }
860
848
| CreateSeqStmt { output_statement($1 , 0 ); }
861
849
| CreatePLangStmt { output_statement($1 , 0 ); }
862
850
| CreateTrigStmt { output_statement($1 , 0 ); }
@@ -865,6 +853,7 @@ stmt: AddAttrStmt { output_statement($1, 0); }
865
853
| DefineStmt { output_statement($1 , 0 ); }
866
854
| DropStmt { output_statement($1 , 0 ); }
867
855
| TruncateStmt { output_statement($1 , 0 ); }
856
+ | DropGroupStmt { output_statement($1 , 0 ); }
868
857
| DropPLangStmt { output_statement($1 , 0 ); }
869
858
| DropTrigStmt { output_statement($1 , 0 ); }
870
859
| DropUserStmt { output_statement($1 , 0 ); }
@@ -1111,10 +1100,6 @@ user_group_list: user_group_list ',' UserId
1111
1100
1112
1101
user_group_clause : IN GROUP user_group_list
1113
1102
{
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
-
1118
1103
$$ = cat2_str(make_str(" in group" ), $3 );
1119
1104
}
1120
1105
| /* EMPTY*/ { $$ = EMPTY; }
@@ -1124,6 +1109,63 @@ user_valid_clause: VALID UNTIL Sconst { $$ = cat2_str(make_str("valid until")
1124
1109
| /* EMPTY*/ { $$ = EMPTY; }
1125
1110
;
1126
1111
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
+
1127
1169
/* ****************************************************************************
1128
1170
*
1129
1171
* Set PG internal variable
@@ -1885,55 +1927,42 @@ TruncateStmt: TRUNCATE TABLE relation_name
1885
1927
*
1886
1928
*****************************************************************************/
1887
1929
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
1889
1931
{
1890
1932
if (strcmp($2 , " relative" ) == 0 && atol($3 ) == 0L )
1891
1933
mmerror (ET_ERROR, " FETCH/RELATIVE at current position is not supported" );
1892
1934
1893
1935
$$ = cat_str(4 , make_str(" fetch" ), $2 , $3 , $4 );
1894
1936
}
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
1900
1938
{
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 );
1914
1940
}
1915
1941
;
1916
1942
1917
- direction : FORWARD { $$ = make_str(" forward" ); }
1943
+ opt_direction : FORWARD { $$ = make_str(" forward" ); }
1918
1944
| BACKWARD { $$ = make_str(" backward" ); }
1919
1945
| RELATIVE { $$ = make_str(" relative" ); }
1920
1946
| ABSOLUTE
1921
1947
{
1922
1948
mmerror (ET_WARN, " FETCH/ABSOLUTE not supported, backend will use RELATIVE" );
1923
1949
$$ = make_str(" absolute" );
1924
1950
}
1951
+ | /* EMPTY*/ { $$ = EMPTY; /* default */ }
1925
1952
;
1926
1953
1927
1954
fetch_how_many : Iconst { $$ = $1 ; }
1928
1955
| ' -' Iconst { $$ = cat2_str(make_str(" -" ), $2 ); }
1929
1956
| ALL { $$ = make_str(" all" ); }
1930
1957
| NEXT { $$ = make_str(" next" ); }
1931
1958
| PRIOR { $$ = make_str(" prior" ); }
1959
+ | /* EMPTY*/ { $$ = EMPTY; /* default*/ }
1932
1960
;
1933
1961
1934
- portal_name : IN name { $$ = cat2_str(make_str(" in" ), $2 ); }
1962
+ opt_portal_name : IN name { $$ = cat2_str(make_str(" in" ), $2 ); }
1935
1963
| 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; }
1937
1966
;
1938
1967
1939
1968
/* ****************************************************************************
@@ -4503,6 +4532,7 @@ ECPGDeallocate: SQL_DEALLOCATE SQL_PREPARE ident { $$ = cat_str(3, make_str("ECP
4503
4532
ECPGDeclaration : sql_startdeclare
4504
4533
{
4505
4534
fputs (" /* exec sql begin declare section */" , yyout);
4535
+ output_line_number ();
4506
4536
}
4507
4537
variable_declarations sql_enddeclare
4508
4538
{
@@ -4515,16 +4545,18 @@ sql_startdeclare : ecpgstart BEGIN_TRANS DECLARE SQL_SECTION ';' {}
4515
4545
4516
4546
sql_enddeclare : ecpgstart END_TRANS DECLARE SQL_SECTION ' ;' {}
4517
4547
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
+ }
4523
4556
4524
4557
declaration : storage_clause
4525
4558
{
4526
4559
actual_storage[struct_level] = mm_strdup($1 );
4527
- actual_startline[struct_level] = hashline_number();
4528
4560
}
4529
4561
type
4530
4562
{
@@ -4534,7 +4566,7 @@ declaration: storage_clause
4534
4566
}
4535
4567
variable_list ' ;'
4536
4568
{
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 " ));
4538
4570
}
4539
4571
4540
4572
storage_clause : S_EXTERN { $$ = make_str(" extern" ); }
@@ -5441,7 +5473,7 @@ c_stuff: c_anything { $$ = $1; }
5441
5473
}
5442
5474
5443
5475
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 ); }
5445
5477
5446
5478
c_term : c_stuff { $$ = $1 ; }
5447
5479
| ' {' c_list ' }' { $$ = cat_str(3 , make_str(" {" ), $2 , make_str(" }" )); }
0 commit comments