You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "congzhou2603 (via GitHub)" <gi...@apache.org> on 2023/04/11 07:52:39 UTC

[GitHub] [shardingsphere] congzhou2603 opened a new issue, #25104: Shardingsphere support foreign table syntax for openGauss

congzhou2603 opened a new issue, #25104:
URL: https://github.com/apache/shardingsphere/issues/25104

   ## Feature Request
   
   **For English only**, other languages will not be accepted.
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot make decision by current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Is your feature request related to a problem?
   #25103
   ### Describe the feature you would like.
   ShardingSphere doesn't support foreigin table syntax for openGauss now, syntax format is as fellow.
   ![image](https://user-images.githubusercontent.com/27768675/231092948-3312fb23-b832-43ac-8713-77d12c3b9237.png)
   ![image](https://user-images.githubusercontent.com/27768675/231092994-9d4ed542-9488-4474-b1fd-49dc69de40b4.png)
   https://docs.opengauss.org/zh/docs/5.0.0/docs/SQLReference/DROP-FOREIGN-TABLE.html
   https://docs.opengauss.org/zh/docs/5.0.0/docs/SQLReference/CREATE-FOREIGN-TABLE.html


-- 
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.apache.org

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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1511108425

   Hi, @strongduanmu , I add `createForeignTable` into `schemaStmt` (I am not sure if it is necessary). I have a check, and it seems work correctly.
   ![image](https://user-images.githubusercontent.com/47752565/232461645-5406b440-6941-4eb8-9c9f-64f1105cefcc.png)
   


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1512607018

   Is this what you mean?
   ![image](https://user-images.githubusercontent.com/47752565/232706873-46e65207-b57a-48b9-9fc8-087c7da440e8.png)
   


-- 
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


[GitHub] [shardingsphere] strongduanmu commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1504404919

   @Netter99 Assigned, good luck for you.


-- 
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


[GitHub] [shardingsphere] congzhou2603 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "congzhou2603 (via GitHub)" <gi...@apache.org>.
congzhou2603 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1514418755

   > > Hi, @strongduanmu , I check again about this question. This is the official description about the parameter in GaussDB. ![image](https://user-images.githubusercontent.com/47752565/232693017-5dd8baa6-007b-4682-9d10-f643a28aeed7.png) [https://support.huaweicloud.com/intl/zh-cn/distributed-devg-v2-opengauss/devg_02_0507.html](url)
   > > Here are some test cases for createForeignTable statement from `openGauss-server-master` - source code. ![image](https://user-images.githubusercontent.com/47752565/232694339-bde7b76d-fe0c-404d-baf4-fbcb50889c81.png)
   > > If we input `create foreign table`sql without the parameter, the parse tree is generated like this. ![image](https://user-images.githubusercontent.com/47752565/232695092-a941eca2-da84-40ad-a923-483b7104a80a.png) So I don't think `SERVER server_name` is an optional parameter.
   > 
   > Hi @congzhou2603, can you help check whether `server name` is an optional segement or not?
   
   Hi @strongduanmu @Netter99 I test this syntax by openGauss 5.0.0, `server name` is optional segment,here is the test result.
   ![image](https://user-images.githubusercontent.com/27768675/233031311-f13abbe3-e105-4792-a60a-a8dce94fc86e.png)
   And Here is the developer guide of creating foreign table.
   ![image](https://user-images.githubusercontent.com/27768675/233031910-1568d8c6-a4c5-477b-a9ef-63458069fe94.png)
   
   https://docs.opengauss.org/zh/docs/5.0.0/docs/SQLReference/CREATE-FOREIGN-TABLE.html
   


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1503174985

   Hi, @congzhou2603 , I'm a newcomer for shardingsphere, and I'm interested in this problem. But I am not sure whether can I solve this question or not. How can I start about this problem?


-- 
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


[GitHub] [shardingsphere] congzhou2603 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "congzhou2603 (via GitHub)" <gi...@apache.org>.
congzhou2603 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1511011944

   Here is an exmaple for creating and dropping foreigin table.  “SERVER 'mot_server’” corresponeds to "SERVER gsmpp_server" in syntax, among which "gsmpp_server" indicates the server name of foreign table. "FOREIGN " and "SERVER gsmpp_server" both can be transparently transmitted to openGauss.
   ``` sql
   CREATE FOREIGN TABLE t_order (
   user_id int,
   order_name varchar(30),
   order_value varchar(50),
   order_id int default 0
   )
   SERVER mot_server;
   
   DROP FOREIGN TABLE t_order;
   ```


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1511083497

   `CREATE FOREIGN TABLE t_order (
   user_id int,
   order_name varchar(30),
   order_value varchar(50),
   order_id int default 0
   )
   SERVER mot_server;`
   Here is the result. It seem work?
   ![image](https://user-images.githubusercontent.com/47752565/232457163-d07ea822-4824-482b-9b9e-2ce889e6d3ed.png)
   


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1511174155

   Hi @strongduanmu , I have a review of the input caused error.
   ![image](https://user-images.githubusercontent.com/47752565/232471947-0f63d600-5246-4728-8fbe-d6a2c315422c.png)
   Maybe it throw error because it miss `SEVER server_name` which should be not null?
   ![image](https://user-images.githubusercontent.com/47752565/232472602-8ac6a474-c71f-4469-8b92-24e5370c7d2c.png)
   


-- 
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


[GitHub] [shardingsphere] strongduanmu commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1511031611

   <img width="1774" alt="imag" src="https://user-images.githubusercontent.com/10829171/232448395-39f31a35-b84d-4174-a030-b1cc278c960b.png">
   
   Hi @Netter99, can you try to test openGauss `create foreign table sytax` via IDEA antlr plugin? We need to first determine which part of the parse is reporting the error.
   


-- 
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


[GitHub] [shardingsphere] strongduanmu commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1511128886

   Hi @Netter99, this change is not reasonable. Can you add `createForeignTable` to `OpenGaussStatement.g4` file? And add some test case for createForeignTable statement.


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1510933131

   Hello, @strongduanmu , since I don't know how to start. I try to imitate other contributor from here [https://github.com/apache/shardingsphere/pull/17861/files](url).
   I am not sure whether it is a right start or not, please have a check and give me some suggestions.


-- 
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


[GitHub] [shardingsphere] strongduanmu commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1504364644

   Hi @Netter99, welcome to develop this feature. First, you can complete the adaptation of CREATE FOREIGN TABLE syntax parsing, which has many cases in the PR list, implement syntax parsing based on ANTLR, and turn AST visit into SQLStatement. 
   
   In the second step, we need to consider supporting this SQL in the sharding scenario, which is not a simple task. I suggest that you can investigate other distributed databases, such as CockroachDB and Citus, and refer to their mature solutions.


-- 
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


[GitHub] [shardingsphere] strongduanmu commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1512702192

   > Hi, @strongduanmu , I check again about this question. This is the official description about the parameter in GaussDB. ![image](https://user-images.githubusercontent.com/47752565/232693017-5dd8baa6-007b-4682-9d10-f643a28aeed7.png) [https://support.huaweicloud.com/intl/zh-cn/distributed-devg-v2-opengauss/devg_02_0507.html](url)
   > 
   > Here are some test cases for createForeignTable statement from `openGauss-server-master` - source code. ![image](https://user-images.githubusercontent.com/47752565/232694339-bde7b76d-fe0c-404d-baf4-fbcb50889c81.png)
   > 
   > If we input `create foreign table`sql without the parameter, the parse tree is generated like this. ![image](https://user-images.githubusercontent.com/47752565/232695092-a941eca2-da84-40ad-a923-483b7104a80a.png) So I don't think `SERVER server_name` is an optional parameter.
   
   Hi @congzhou2603, can you help check whether `server name` is an optional segement or not?


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1512539784

   Hi, @strongduanmu , I check again about this question.
   This is the official description about the parameter in GaussDB. 
   ![image](https://user-images.githubusercontent.com/47752565/232693017-5dd8baa6-007b-4682-9d10-f643a28aeed7.png)
   [https://support.huaweicloud.com/intl/zh-cn/distributed-devg-v2-opengauss/devg_02_0507.html](url)
   
   Here are some test cases for createForeignTable statement from `openGauss-server-master` - source code. 
   ![image](https://user-images.githubusercontent.com/47752565/232694339-bde7b76d-fe0c-404d-baf4-fbcb50889c81.png)
   
   If we input `create foreign table`sql without the parameter, the parse tree is generated like this.
   ![image](https://user-images.githubusercontent.com/47752565/232695092-a941eca2-da84-40ad-a923-483b7104a80a.png)
   So I don't think `SERVER server_name` is an optional parameter.
   


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1504883623

   Hi, @strongduanmu , sorry for bothering you. Counld you give me more detail advice?(Maybe the link to others PR) 
   After several hours of finding information, I''m still confused about how to start and think maybe this issue can be divided into some small issues?


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1512628871

   It has the same `createForeignTable` code design in opengauss and postgresql's DDLStatement. 
   ![image](https://user-images.githubusercontent.com/47752565/232707718-7c4e2a69-8b64-4555-8135-6b35f5716307.png)
   If we test the same sql in postgresql\DDLStatement.g4, the parse tree also has the same error.
   


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1514449598

   > 
   Hi @congzhou2603 @strongduanmu  , I know it has a default value and I don't know about how openGauss deals with this situation. But to Shardingsphere currently, this kind of input is invalid (according to `DDLStatement.g4` which make a check about the sql and generate the corresponding syntax tree). 
   If we make a null value checks on the input parameter and add default value when the parameter is null, I think the syntax tree can be generated correctly.


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1517174719

   Sorry @strongduanmu , I try but can't understand `gram.y` source code in openGauss.
   Since I have,'t use Shardingsphere before, I have a question about it. Does it support foreign syntax(sql without server name) for postgresql? 
   Shardingsphere source codes have the same `create Foreign Table` code in opengauss and postgresql's `DDLStatement.g4`. If the sql doesn't work for postgresql, it should be too for openGauss.
   If it works, I think maybe this issue is too hard for me and sorry for wasting your time.


-- 
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


[GitHub] [shardingsphere] Netter99 commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "Netter99 (via GitHub)" <gi...@apache.org>.
Netter99 commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1504384828

   Thanks for your advice, @strongduanmu , I want to have a try. Please assign to me.


-- 
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


[GitHub] [shardingsphere] strongduanmu commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1502951031

   This looks like a nice feature, let's see if any contributors want to support it.
   


-- 
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


[GitHub] [shardingsphere] strongduanmu commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1512600223

   Can you test this sql without semicolon? It is dealt with uniformly in OpenGaussStatement.g4 file.


-- 
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


[GitHub] [shardingsphere] strongduanmu commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1514502987

   > Hi @Netter99, maybe we need to take a look at the openGauss source code, I guess `server_name` is an optional parameter. Following is openGauss `gram.y` source code:
   > 
   > ```sql
   > /*****************************************************************************
   >  *
   >  *		QUERY:
   >  *             CREATE FOREIGN TABLE relname (...) SERVER name (...)
   >  *
   >  *****************************************************************************/
   > 
   > CreateForeignTableStmt:
   > 		CREATE FOREIGN TABLE qualified_name
   > 			OptForeignTableElementList
   > 			SERVER name create_generic_options ForeignTblWritable
   > 			OptForeignTableLogError OptForeignTableLogRemote OptPerNodeRejectLimit OptDistributeBy
   > /* PGXC_BEGIN */
   > 			OptSubCluster
   > /* PGXC_END */
   > 			OptForeignPartBy
   > 				{
   > 					CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
   > 					$4->relpersistence = RELPERSISTENCE_PERMANENT;
   > 					n->base.relation = $4;
   > 					n->base.tableElts = $5;
   > 					n->base.inhRelations = NIL;
   > 					n->base.if_not_exists = false;
   > 					/* FDW-specific data */
   > 					n->servername = $7;
   > 					n->options = $8;
   > 
   > 					n->write_only = $9;
   > 					n->error_relation = (Node*)$10;
   > 					if ($11 != NULL)
   > 						n->extOptions = lappend(n->extOptions, $11);
   > 					if ($12 != NULL)
   > 						n->extOptions = lappend(n->extOptions, $12);
   > 					n->base.distributeby = $13;
   > /* PGXC_BEGIN */
   > 					n->base.subcluster = $14;
   > /* PGXC_END */
   > 					if ($15 != NULL)
   > 						n->part_state = $15;
   > 
   > 					$$ = (Node *) n;
   > 				}
   > 		| CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name
   > 			OptForeignTableElementList
   > 			SERVER name create_generic_options ForeignTblWritable
   > 			OptForeignTableLogError OptForeignTableLogRemote OptPerNodeRejectLimit OptDistributeBy
   > /* PGXC_BEGIN */
   > 			OptSubCluster
   > /* PGXC_END */
   > 			OptForeignPartBy
   > 				{
   > 					CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
   > 					$7->relpersistence = RELPERSISTENCE_PERMANENT;
   > 					n->base.relation = $7;
   > 					n->base.tableElts = $8;
   > 					n->base.inhRelations = NIL;
   > 					n->base.if_not_exists = true;
   > 					/* FDW-specific data */
   > 					n->servername = $10;
   > 					n->options = $11;
   > 
   > 					n->write_only = $12;
   > 					n->error_relation = (Node*)$13;
   > 					if ($14 != NULL)
   > 						n->extOptions = lappend(n->extOptions, $14);
   > 					if ($15 != NULL)
   > 						n->extOptions = lappend(n->extOptions, $15);
   > 					n->base.distributeby = $16;
   > /* PGXC_BEGIN */
   > 					n->base.subcluster = $17;
   > /* PGXC_END */
   > 					if ($18 != NULL)
   > 						n->part_state = $18;
   > 
   > 					$$ = (Node *) n;
   > 				}
   > /* ENABLE_MOT BEGIN */
   >                 | CREATE FOREIGN TABLE qualified_name
   > 			OptForeignTableElementList
   > 			create_generic_options ForeignTblWritable
   > 			OptForeignTableLogError OptForeignTableLogRemote OptPerNodeRejectLimit OptDistributeBy
   > /* PGXC_BEGIN */
   > 			OptSubCluster
   > /* PGXC_END */
   > 			OptForeignPartBy
   > 				{
   > 					CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
   > 					$4->relpersistence = RELPERSISTENCE_PERMANENT;
   > 					n->base.relation = $4;
   > 					n->base.tableElts = $5;
   > 					n->base.inhRelations = NIL;
   > 					n->base.if_not_exists = false;
   > 					/* FDW-specific data */
   > #ifdef ENABLE_MOT
   > 					n->servername = pstrdup("mot_server");
   > #else
   >         			const char* message = "Foreign server is not specified";
   >     				InsertErrorMessage(message, u_sess->plsql_cxt.plpgsql_yylloc);
   >                     ereport(errstate,
   >                         (errcode(ERRCODE_SYNTAX_ERROR),
   >                             errmsg("Foreign server is not specified")));
   > #endif
   > 					n->options = $6;
   > 
   > 					n->write_only = $7;
   > 					n->error_relation = (Node*)$8;
   > 					if ($9 != NULL)
   > 						n->extOptions = lappend(n->extOptions, $9);
   > 					if ($10 != NULL)
   > 						n->extOptions = lappend(n->extOptions, $10);
   > 					n->base.distributeby = $11;
   > /* PGXC_BEGIN */
   > 					n->base.subcluster = $12;
   > /* PGXC_END */
   > 					if ($13 != NULL)
   > 						n->part_state = $13;
   > 
   > 					$$ = (Node *) n;
   > 				}
   >                | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name
   > 			OptForeignTableElementList
   > 			create_generic_options ForeignTblWritable
   > 			OptForeignTableLogError OptForeignTableLogRemote OptPerNodeRejectLimit OptDistributeBy
   > /* PGXC_BEGIN */
   > 			OptSubCluster
   > /* PGXC_END */
   > 			OptForeignPartBy
   > 				{
   > 					CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
   > 					$7->relpersistence = RELPERSISTENCE_PERMANENT;
   > 					n->base.relation = $7;
   > 					n->base.tableElts = $8;
   > 					n->base.inhRelations = NIL;
   > 					n->base.if_not_exists = true;
   > 					/* FDW-specific data */
   > #ifdef ENABLE_MOT
   > 					n->servername = pstrdup("mot_server");
   > #else
   >         			const char* message = "Foreign server is not specified";
   >     				InsertErrorMessage(message, u_sess->plsql_cxt.plpgsql_yylloc);
   >                     ereport(errstate,
   >                         (errcode(ERRCODE_SYNTAX_ERROR),
   >                             errmsg("Foreign server is not specified")));
   > #endif
   > 					n->options = $9;
   > 
   > 					n->write_only = $10;
   > 					n->error_relation = (Node*)$11;
   > 					if ($12 != NULL)
   > 						n->extOptions = lappend(n->extOptions, $12);
   > 					if ($13 != NULL)
   > 						n->extOptions = lappend(n->extOptions, $13);
   > 					n->base.distributeby = $14;
   > /* PGXC_BEGIN */
   > 					n->base.subcluster = $15;
   > /* PGXC_END */
   > 					if ($16 != NULL)
   > 						n->part_state = $16;
   > 
   > 					$$ = (Node *) n;
   > 				}
   > /* ENABLE_MOT END */
   > 		;
   > ```
   
   Hi @Netter99, can you take a look at this file, from @congzhou2603 tests and the openGauss source code, the server name is optional, but it is not show in the openGauss documentation.
   


-- 
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


[GitHub] [shardingsphere] strongduanmu commented on issue #25104: Shardingsphere support foreign table syntax for openGauss

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #25104:
URL: https://github.com/apache/shardingsphere/issues/25104#issuecomment-1511295515

   Hi @Netter99, maybe we need to take a look at the openGauss source code, I guess `server_name` is an optional parameter. Following is openGauss `gram.y` source code: 
   
   
   ```sql
   /*****************************************************************************
    *
    *		QUERY:
    *             CREATE FOREIGN TABLE relname (...) SERVER name (...)
    *
    *****************************************************************************/
   
   CreateForeignTableStmt:
   		CREATE FOREIGN TABLE qualified_name
   			OptForeignTableElementList
   			SERVER name create_generic_options ForeignTblWritable
   			OptForeignTableLogError OptForeignTableLogRemote OptPerNodeRejectLimit OptDistributeBy
   /* PGXC_BEGIN */
   			OptSubCluster
   /* PGXC_END */
   			OptForeignPartBy
   				{
   					CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
   					$4->relpersistence = RELPERSISTENCE_PERMANENT;
   					n->base.relation = $4;
   					n->base.tableElts = $5;
   					n->base.inhRelations = NIL;
   					n->base.if_not_exists = false;
   					/* FDW-specific data */
   					n->servername = $7;
   					n->options = $8;
   
   					n->write_only = $9;
   					n->error_relation = (Node*)$10;
   					if ($11 != NULL)
   						n->extOptions = lappend(n->extOptions, $11);
   					if ($12 != NULL)
   						n->extOptions = lappend(n->extOptions, $12);
   					n->base.distributeby = $13;
   /* PGXC_BEGIN */
   					n->base.subcluster = $14;
   /* PGXC_END */
   					if ($15 != NULL)
   						n->part_state = $15;
   
   					$$ = (Node *) n;
   				}
   		| CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name
   			OptForeignTableElementList
   			SERVER name create_generic_options ForeignTblWritable
   			OptForeignTableLogError OptForeignTableLogRemote OptPerNodeRejectLimit OptDistributeBy
   /* PGXC_BEGIN */
   			OptSubCluster
   /* PGXC_END */
   			OptForeignPartBy
   				{
   					CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
   					$7->relpersistence = RELPERSISTENCE_PERMANENT;
   					n->base.relation = $7;
   					n->base.tableElts = $8;
   					n->base.inhRelations = NIL;
   					n->base.if_not_exists = true;
   					/* FDW-specific data */
   					n->servername = $10;
   					n->options = $11;
   
   					n->write_only = $12;
   					n->error_relation = (Node*)$13;
   					if ($14 != NULL)
   						n->extOptions = lappend(n->extOptions, $14);
   					if ($15 != NULL)
   						n->extOptions = lappend(n->extOptions, $15);
   					n->base.distributeby = $16;
   /* PGXC_BEGIN */
   					n->base.subcluster = $17;
   /* PGXC_END */
   					if ($18 != NULL)
   						n->part_state = $18;
   
   					$$ = (Node *) n;
   				}
   /* ENABLE_MOT BEGIN */
                   | CREATE FOREIGN TABLE qualified_name
   			OptForeignTableElementList
   			create_generic_options ForeignTblWritable
   			OptForeignTableLogError OptForeignTableLogRemote OptPerNodeRejectLimit OptDistributeBy
   /* PGXC_BEGIN */
   			OptSubCluster
   /* PGXC_END */
   			OptForeignPartBy
   				{
   					CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
   					$4->relpersistence = RELPERSISTENCE_PERMANENT;
   					n->base.relation = $4;
   					n->base.tableElts = $5;
   					n->base.inhRelations = NIL;
   					n->base.if_not_exists = false;
   					/* FDW-specific data */
   #ifdef ENABLE_MOT
   					n->servername = pstrdup("mot_server");
   #else
           			const char* message = "Foreign server is not specified";
       				InsertErrorMessage(message, u_sess->plsql_cxt.plpgsql_yylloc);
                       ereport(errstate,
                           (errcode(ERRCODE_SYNTAX_ERROR),
                               errmsg("Foreign server is not specified")));
   #endif
   					n->options = $6;
   
   					n->write_only = $7;
   					n->error_relation = (Node*)$8;
   					if ($9 != NULL)
   						n->extOptions = lappend(n->extOptions, $9);
   					if ($10 != NULL)
   						n->extOptions = lappend(n->extOptions, $10);
   					n->base.distributeby = $11;
   /* PGXC_BEGIN */
   					n->base.subcluster = $12;
   /* PGXC_END */
   					if ($13 != NULL)
   						n->part_state = $13;
   
   					$$ = (Node *) n;
   				}
                  | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name
   			OptForeignTableElementList
   			create_generic_options ForeignTblWritable
   			OptForeignTableLogError OptForeignTableLogRemote OptPerNodeRejectLimit OptDistributeBy
   /* PGXC_BEGIN */
   			OptSubCluster
   /* PGXC_END */
   			OptForeignPartBy
   				{
   					CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
   					$7->relpersistence = RELPERSISTENCE_PERMANENT;
   					n->base.relation = $7;
   					n->base.tableElts = $8;
   					n->base.inhRelations = NIL;
   					n->base.if_not_exists = true;
   					/* FDW-specific data */
   #ifdef ENABLE_MOT
   					n->servername = pstrdup("mot_server");
   #else
           			const char* message = "Foreign server is not specified";
       				InsertErrorMessage(message, u_sess->plsql_cxt.plpgsql_yylloc);
                       ereport(errstate,
                           (errcode(ERRCODE_SYNTAX_ERROR),
                               errmsg("Foreign server is not specified")));
   #endif
   					n->options = $9;
   
   					n->write_only = $10;
   					n->error_relation = (Node*)$11;
   					if ($12 != NULL)
   						n->extOptions = lappend(n->extOptions, $12);
   					if ($13 != NULL)
   						n->extOptions = lappend(n->extOptions, $13);
   					n->base.distributeby = $14;
   /* PGXC_BEGIN */
   					n->base.subcluster = $15;
   /* PGXC_END */
   					if ($16 != NULL)
   						n->part_state = $16;
   
   					$$ = (Node *) n;
   				}
   /* ENABLE_MOT END */
   		;
   ```


-- 
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