You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/06/20 03:23:53 UTC

[GitHub] [shardingsphere] strongduanmu commented on issue #18433: “fetch from cursor1”syntax is not supported

strongduanmu commented on issue #18433:
URL: https://github.com/apache/shardingsphere/issues/18433#issuecomment-1159925746

   @peilinqian Thank you for your feedback. I found that the syntax description in the [openGauss documentation](https://opengauss.org/zh/docs/1.0.1/docs/Developerguide/FETCH.html) is wrong, it is inconsistent with the logic in the openGauss source code.
   
   Following is openGuass fetch syntax in official document.
   
   ```sql
   FETCH [ direction { FROM | IN } ] cursor_name;
   ```
   
   However, the real openGauss syntax is implemented as follows, the user can use the FROM | IN parameter without specifying the direction.
   
   ```
   /*****************************************************************************
    *
    *		QUERY:
    *			fetch/move
    *
    *****************************************************************************/
   
   FetchStmt:	FETCH fetch_args
   				{
   					FetchStmt *n = (FetchStmt *) $2;
   					n->ismove = FALSE;
   					$$ = (Node *)n;
   				}
   			| MOVE fetch_args
   				{
   					FetchStmt *n = (FetchStmt *) $2;
   					n->ismove = TRUE;
   					$$ = (Node *)n;
   				}
   		;
   
   fetch_args:	cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $1;
   					n->direction = FETCH_FORWARD;
   					n->howMany = 1;
   					$$ = (Node *)n;
   				}
   			| from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $2;
   					n->direction = FETCH_FORWARD;
   					n->howMany = 1;
   					$$ = (Node *)n;
   				}
   			| NEXT opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $3;
   					n->direction = FETCH_FORWARD;
   					n->howMany = 1;
   					$$ = (Node *)n;
   				}
   			| PRIOR opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $3;
   					n->direction = FETCH_BACKWARD;
   					n->howMany = 1;
   					$$ = (Node *)n;
   				}
   			| FIRST_P opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $3;
   					n->direction = FETCH_ABSOLUTE;
   					n->howMany = 1;
   					$$ = (Node *)n;
   				}
   			| LAST_P opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $3;
   					n->direction = FETCH_ABSOLUTE;
   					n->howMany = -1;
   					$$ = (Node *)n;
   				}
   			| ABSOLUTE_P SignedIconst opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $4;
   					n->direction = FETCH_ABSOLUTE;
   					n->howMany = $2;
   					$$ = (Node *)n;
   				}
   			| RELATIVE_P SignedIconst opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $4;
   					n->direction = FETCH_RELATIVE;
   					n->howMany = $2;
   					$$ = (Node *)n;
   				}
   			| SignedIconst opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $3;
   					n->direction = FETCH_FORWARD;
   					n->howMany = $1;
   					$$ = (Node *)n;
   				}
   			| ALL opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $3;
   					n->direction = FETCH_FORWARD;
   					n->howMany = FETCH_ALL;
   					$$ = (Node *)n;
   				}
   			| FORWARD opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $3;
   					n->direction = FETCH_FORWARD;
   					n->howMany = 1;
   					$$ = (Node *)n;
   				}
   			| FORWARD SignedIconst opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $4;
   					n->direction = FETCH_FORWARD;
   					n->howMany = $2;
   					$$ = (Node *)n;
   				}
   			| FORWARD ALL opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $4;
   					n->direction = FETCH_FORWARD;
   					n->howMany = FETCH_ALL;
   					$$ = (Node *)n;
   				}
   			| BACKWARD opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $3;
   					n->direction = FETCH_BACKWARD;
   					n->howMany = 1;
   					$$ = (Node *)n;
   				}
   			| BACKWARD SignedIconst opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $4;
   					n->direction = FETCH_BACKWARD;
   					n->howMany = $2;
   					$$ = (Node *)n;
   				}
   			| BACKWARD ALL opt_from_in cursor_name
   				{
   					FetchStmt *n = makeNode(FetchStmt);
   					n->portalname = $4;
   					n->direction = FETCH_BACKWARD;
   					n->howMany = FETCH_ALL;
   					$$ = (Node *)n;
   				}
   		;
   
   from_in:	FROM									{}
   			| IN_P									{}
   		;
   
   opt_from_in:	from_in								{}
   			| /* EMPTY */							{}
   		;
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org