@@ -814,7 +814,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
814814%type <str> ViewStmt LoadStmt CreatedbStmt opt_database1 opt_database2 location
815815%type <str> DestroydbStmt ClusterStmt grantee RevokeStmt encoding
816816%type <str> GrantStmt privileges operation_commalist operation
817- %type <str> cursor_clause opt_cursor opt_readonly opt_of opt_lmode
817+ %type <str> opt_cursor opt_lmode
818818%type <str> case_expr when_clause_list case_default case_arg when_clause
819819%type <str> select_clause opt_select_limit select_limit_value
820820%type <str> select_offset_value table_list using_expr join_expr
@@ -2724,7 +2724,9 @@ UpdateStmt: UPDATE relation_name
27242724 *CURSOR STATEMENTS
27252725 *
27262726 *****************************************************************************/
2727- CursorStmt :DECLARE name opt_cursor CURSOR FOR SelectStmt cursor_clause
2727+ CursorStmt :DECLARE name opt_cursor CURSOR FOR
2728+ { ForUpdateNotAllowed =1 ; }
2729+ SelectStmt
27282730{
27292731struct cursor *ptr, *this ;
27302732
@@ -2744,7 +2746,7 @@ CursorStmt: DECLARE name opt_cursor CURSOR FOR SelectStmt cursor_clause
27442746this ->next = cur;
27452747this ->name =$2 ;
27462748this ->connection = connection;
2747- this ->command =cat2_str( cat5_str(make1_str(" declare" ), mm_strdup($2 ),$3 , make1_str(" cursor for" ), $6 ),$7 );
2749+ this ->command = cat5_str(make1_str(" declare" ), mm_strdup($2 ),$3 , make1_str(" cursor for" ),$7 );
27482750this ->argsinsert = argsinsert;
27492751this ->argsresult = argsresult;
27502752argsinsert = argsresult =NULL ;
@@ -2762,20 +2764,6 @@ opt_cursor: BINARY { $$ = make1_str("binary"); }
27622764| /* EMPTY*/ {$$ = make1_str(" " ); }
27632765 ;
27642766
2765- cursor_clause :FOR opt_readonly {$$ = cat2_str(make1_str(" for" ),$2 ); }
2766- | /* EMPTY*/ {$$ = make1_str(" " ); }
2767-
2768- ;
2769-
2770- opt_readonly :READ ONLY {$$ = make1_str(" read only" ); }
2771- | UPDATE opt_of
2772- {
2773- yyerror (" DECLARE/UPDATE not supported; Cursors must be READ ONLY." );
2774- }
2775- ;
2776-
2777- opt_of :OF columnList {$$ = make2_str(make1_str(" of" ),$2 ); }
2778-
27792767/* ****************************************************************************
27802768 *
27812769 *QUERY:
@@ -2793,7 +2781,7 @@ opt_of: OF columnList { $$ = make2_str(make1_str("of"), $2); }
27932781SelectStmt :select_clause sort_clause for_update_clause opt_select_limit
27942782{
27952783if (strlen($3 ) >0 && ForUpdateNotAllowed !=0 )
2796- yyerror (" SELECT FOR UPDATE is not allowed in this context" );
2784+ yyerror (" FOR UPDATE is not allowed in this context" );
27972785
27982786ForUpdateNotAllowed =0 ;
27992787$$ = cat4_str($1 ,$2 ,$3 ,$4 );
@@ -2941,6 +2929,10 @@ for_update_clause: FOR UPDATE update_list
29412929{
29422930$$ = make1_str(" for update" );
29432931}
2932+ | FOR READ ONLY
2933+ {
2934+ $$ = make1_str(" for read only" );
2935+ }
29442936| /* EMPTY*/
29452937 {
29462938$$ = make1_str(" " );
@@ -3356,11 +3348,7 @@ Character: character '(' Iconst ')'
33563348yyerror (errortext);
33573349}
33583350else if (atol($3 ) > BLCKSZ -128 ) {
3359- /* we can store a char() of length up to the size
3360- * of a page (8KB) - page headers and friends but
3361- * just to be safe here...- ay 6/95
3362- */
3363- sprintf (errortext," length for type '%s' cannot exceed %d" ,BLCKSZ-128 );
3351+ sprintf (errortext," length for type '%s' cannot exceed %d" ,$1 ,BLCKSZ -128 );
33643352yyerror (errortext);
33653353}
33663354
@@ -4721,7 +4709,7 @@ opt_options: Op ColId
47214709 * Declare a prepared cursor. The syntax is different from the standard
47224710 * declare statement, so we create a new rule.
47234711*/
4724- ECPGCursorStmt :DECLARE name opt_cursor CURSOR FOR ident cursor_clause
4712+ ECPGCursorStmt :DECLARE name opt_cursor CURSOR FOR ident
47254713{
47264714struct cursor *ptr, *this ;
47274715struct variable *thisquery = (struct variable *)mm_alloc(sizeof (struct variable ));
@@ -4742,7 +4730,7 @@ ECPGCursorStmt: DECLARE name opt_cursor CURSOR FOR ident cursor_clause
47424730this ->next = cur;
47434731this ->name =$2 ;
47444732this ->connection = connection;
4745- this ->command =cat5_str (make1_str(" declare" ), mm_strdup($2 ),$3 , make1_str(" cursor for ?" ), $7 );
4733+ this ->command =cat4_str (make1_str(" declare" ), mm_strdup($2 ),$3 , make1_str(" cursor for ?" ));
47464734this ->argsresult =NULL ;
47474735
47484736thisquery->type = &ecpg_query;