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

   ## Bug Report 
   
   ### Which version of ShardingSphere did you use? 
   5.3.0
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   proxy
   
   ### Expected behavior
   insert success using go orm 
   
   ### Actual behavior
   
[org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask][,,,,][,,]
 - Exception occur:
   java.lang.NullPointerException: null
   at 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.describe.PostgreSQLComDescribeExecutor.describeInsertStatementByDatabaseMetaData(PostgreSQLComDescribeExecutor.java
 137)
   
   ### Reason analyze (If you can)
   this is the payload from gorm insert 
   
   +-------------------------------------------------+
            |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
   +--------+-------------------------------------------------+----------------+
   |00000000| 50 00 00 00 63 73 74 6d 74 63 61 63 68 65 5f 31 |P...cstmtcache_1|
   |00000010| 00 49 4e 53 45 52 54 20 49 4e 54 4f 20 22 74 5f |.INSERT INTO "t_|
   |00000020| 73 74 75 64 65 6e 74 5f 69 6e 66 6f 22 20 28 22 |student_info" ("|
   |00000030| 73 74 75 64 65 6e 74 5f 6e 61 6d 65 22 2c 22 69 |student_name","i|
   |00000040| 64 22 29 20 56 41 4c 55 45 53 20 28 24 31 2c 24 |d") VALUES ($1,$|
   |00000050| 32 29 20 52 45 54 55 52 4e 49 4e 47 20 22 69 64 |2) RETURNING "id|
   |00000060| 22 00 00 00 44 00 00 00 11 53 73 74 6d 74 63 61 |"...D....Sstmtca|
   |00000070| 63 68 65 5f 31 00 53 00 00 00 04                |che_1.S....     |
   +--------+-------------------------------------------------+----------------+
   
   [DEBUG] 2023-03-15 10:39:50.958 [Connection-4-ThreadExecutor] 
o.a.s.p.f.p.c.PostgreSQLCommandExecutorFactory - Execute packet type: 
PARSE_COMMAND, value: 
PostgreSQLAggregatedCommandPacket(packets=[PostgreSQLComParsePacket(payload=org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload@3e6ee0b9,
 statementId=stmtcache_1, sql=INSERT INTO "t_student_info" 
("student_name","id") VALUES ($1,$2) RETURNING "id"), 
PostgreSQLComDescribePacket(type=S, name=stmtcache_1), 
PostgreSQLComSyncPacket()], containsBatchedStatements=false, firstBindIndex=-1, 
lastExecuteIndex=-1)
   
   
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.describe.PostgreSQLComDescribeExecutor#describeInsertStatementByDatabaseMetaData
   insertStatement.getTable().getOwner() is null ,  then it gets the default 
schema "public" , that cause  the meta of table[t_student_info]  empty
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   proxy deployed with cluster mode; 
   insert with gorm
    
   
   ### Example codes for reproduce this issue (such as a github link).
   
    
   go code 
   ```
   
   package main
   
   import (
        "fmt"
        "gorm.io/driver/postgres"
        "gorm.io/gorm"
   )
   
   func main() {
        dsn := "host=127.0.0.1 user=AppRunesHbdlTest 
password=11709462e04a45e08d5b70d279874f76 dbname=fat_druid_extend_demo_proxy 
port=3309 sslmode=disable TimeZone=Asia/Shanghai"
        db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
   
        if err == nil {
                student := Student{ID: 11, StudentName: "hello go"}
                fmt.Println(db.Create(student))
        }
   }
   
   type Student struct {
        ID          int64
        StudentName string
   }
   
   func (Student) TableName() string {
        return "t_student_info"
   } 
   ```
   


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