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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to