risingwavelabs / risingwave

Best-in-class stream processing, analytics, and management. Perform continuous analytics, or build event-driven applications, real-time ETL pipelines, and feature stores in minutes. Unified streaming and batch. PostgreSQL compatible.
https://go.risingwave.com/slack
Apache License 2.0
7.02k stars 577 forks source link

getting ` Data insertion failed: ERROR: unnamed portal not found (SQLSTATE XX000)` while inserting array using pgx #11365

Open abhyuday26 opened 1 year ago

abhyuday26 commented 1 year ago

Describe the bug

While inserting array in risingwave using golang (pgx) this issue was faced.

Error message/log

frontend-node-0  |   2023-08-01T09:32:09.064419164Z ERROR pgwire::pg_protocol: error when process message, error: Not supported: param type: varchar[]
frontend-node-0  | HINT: 
frontend-node-0  |     at src/utils/pgwire/src/pg_protocol.rs:175
frontend-node-0  | 
frontend-node-0  |   2023-08-01T09:32:09.064490145Z ERROR pgwire::pg_protocol: error when process message, error: unnamed portal not found
frontend-node-0  |     at src/utils/pgwire/src/pg_protocol.rs:175
frontend-node-0  | 
frontend-node-0  |   2023-08-01T09:32:09.064530464Z ERROR pgwire::pg_protocol: error when process message, error: unnamed portal not found
frontend-node-0  |     at src/utils/pgwire/src/pg_protocol.rs:175
frontend-node-0  |

To Reproduce

Create table using below query

        CREATE TABLE IF NOT EXISTS taxi (
            taxi_id VARCHAR PRIMARY KEY,
            passengers VARCHAR[],
            license_plate VARCHAR,
            company VARCHAR,
            expiration_date DATE,
            driver VARCHAR
        )

Insert the following values into the table using golang (pgx)

        taxiID := "FAST0001"
    passengers := []string{"ABCD1234", "ABCD1235", "ABCD1236", "ABCD1237"}
    licensePlate := "N5432N"
    company := "FAST TAXI"
    expirationDate := "2030-12-31"
    driver := "DAVID WANG"
    insertTaxiQuery := `
        INSERT INTO taxi (taxi_id, passengers, license_plate, company, expiration_date, driver)
        VALUES ($1, $2, $3, $4, $5, $6)```

Expected behavior

No response

How did you deploy RisingWave?

No response

The version of RisingWave

dev=> select version();
                                  version                                   
----------------------------------------------------------------------------
 PostgreSQL 8.3-RisingWave-1.0.0 (c320675ef628c0c8d6bab7d60b90141d9c41adf2)
(1 row)

Additional context

No response

fuyufjh commented 1 year ago

@xiangjinwu We seemed to have discussed on this? Please help to take a look ❤️

xiangjinwu commented 1 year ago

Not supported: param type: varchar[]

Workaround: set pgx to QueryExecModeExec so that array is sent in text mode rather than binary mode. Solution: #7949 support binary mode for 1d array

neverchanje commented 1 year ago
    cfg, err := pgx.ParseConfig("postgres://root@localhost:4566/dev")
    if err != nil {
        log.Fatalf("Failed to parse config: %v", err)
    }
    // TODO: Investigate into why simple protocol is required
    cfg.DefaultQueryExecMode = pgx.QueryExecModeSimpleProtocol

Setting it to the QueryExecModeSimpleProtocol should work. But this issue is still what we need to resolve later. Because the extended protocol is theoriotically more efficient.