Skip to content

[Bug]: multi-row prepared INSERT with UUID string parameters can be parsed as column identifiers #24727

Closed

Description

@zhangxu19830126

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main / current MatrixOne build used by Matrixflow deployment

Commit ID

Unknown from the deployment logs.

Other Environment Information

Observed from a Matrixflow moi-catalog service writing to MatrixOne through Go database/sql.

The failing request log timestamp was 2026-05-31T08:14:47.066Z.

Actual Behavior

A multi-row parameterized INSERT failed with:

Error 20301 (HY000): invalid input: column ad027c8b does not exist

The application SQL shape was:

INSERT INTO volume_files (volume_id, file_id, file_name, file_path, created_by, updated_by)
VALUES (?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?)

The bound file_id values are UUID strings, for example one started with ad027c8b-....

MatrixOne appears to parse the first UUID segment (ad027c8b) as an identifier instead of treating the bound parameter as a string value. The application received a 500 because the insert failed.

Relevant application log evidence:

{"level":"error","timestamp":"2026-05-31T08:14:47.066Z","caller":"handlers/volume_file.go:804","message":"failed to add files to volume","request_id":"7922527f-4ddd-48b7-85ec-84c3915ca3f8","trace_id":"7922527f-4ddd-48b7-85ec-84c3915ca3f8","error":"failed to batch create volume file associations: Error 20301 (HY000): invalid input: column ad027c8b does not exist"}

Expected Behavior

MatrixOne should execute the prepared statement using the supplied string parameters as string values. A UUID string parameter such as ad027c8b-... should not be parsed as a column identifier in a multi-row INSERT ... VALUES statement.

Steps to Reproduce

The failure was observed from Go database/sql with a multi-row parameterized insert. A reduced reproduction should be similar to:

CREATE TABLE volume_files (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    volume_id BIGINT NOT NULL,
    file_id VARCHAR(36) NOT NULL,
    file_name VARCHAR(255) NOT NULL,
    file_path VARCHAR(1024) NOT NULL DEFAULT '',
    created_by VARCHAR(64) NOT NULL,
    updated_by VARCHAR(64) NOT NULL,
    UNIQUE KEY uk_volume_file (volume_id, file_id)
);

Then execute through the Go MatrixOne/MySQL driver path using placeholders:

_, err := db.ExecContext(ctx, `
    INSERT INTO volume_files (volume_id, file_id, file_name, file_path, created_by, updated_by)
    VALUES (?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?)
`,
    int64(180001), "ad027c8b-1111-4111-8111-111111111111", "a.txt", "", "user1", "user1",
    int64(180001), "b4027c8b-2222-4222-8222-222222222222", "b.txt", "", "user1", "user1",
)

Observed production error:

Error 20301 (HY000): invalid input: column ad027c8b does not exist

As a workaround, changing the application to execute the same single-row parameterized INSERT once per row inside the same transaction avoids the error.

Additional information

The Matrixflow-side workaround is intentionally narrow: it keeps the same transaction and API behavior, but avoids multi-row prepared insert for this table. The underlying issue still looks like MatrixOne incorrectly handling multi-row prepared statement parameter substitution or parsing for UUID-like string values.

Activity

  1. zhangxu19830126 commented on May 31, 2026

    @zhangxu19830126
    ContributorAuthor

    Additional local verification from the Matrixflow side:

    Environment:

    MatrixOne: 127.0.0.1:6001
    user/password: dump/111
    version(): 8.0.30-MatrixOne-v
    git_version(): 46039477b5
    Go driver: github.com/go-sql-driver/mysql v1.9.3
    

    I tried to reproduce the original multi-row parameterized INSERT locally with these DSN variants:

    ?parseTime=true&multiStatements=true&loc=Local
    ?charset=utf8mb4&parseTime=True&loc=Local
    ?charset=utf8mb4&parseTime=True&loc=Local&interpolateParams=true
    

    For each DSN, I tested:

    • db.ExecContext with the multi-row placeholder INSERT
    • tx.ExecContext inside an explicit transaction
    • db.PrepareContext followed by stmt.ExecContext

    All of them returned <nil> locally. The Matrixflow workaround path, single-row parameterized INSERTs inside the same transaction, also returned <nil>.

    I also ran a control SQL where the UUID-like value is intentionally unquoted:

    INSERT INTO volume_files (volume_id, file_id, file_name, file_path, created_by, updated_by)
    VALUES (180001, ad027c8b-1111-4111-8111-111111111111, 'a.txt', '', 'user1', 'user1');

    That produced a similar MatrixOne 20301 error locally:

    ERROR 20301 (HY000): invalid input: ambiguous column reference 'ad027c8b'
    

    So with the current local build I cannot prove that multi-row prepared INSERT itself is sufficient to trigger the production error. The production log is still real evidence that MatrixOne received/evaluated something leading to column ad027c8b does not exist, but we likely need the exact MatrixOne build and perhaps SQL trace from that deployment to isolate whether this is a server version difference, driver/interpolation difference, or a malformed final SQL path.

    Matrixflow PR with the narrow workaround and verification notes: https://github.com/matrixorigin/matrixflow/pull/10815

  2. zhangxu19830126 commented on May 31, 2026

    @zhangxu19830126
    ContributorAuthor

    Additional verification using the fin-data-agent dev MatrixOne configuration:

    Environment:

    Config source: ~/Projects/go/fin-data-agent/backend/etc/config-dev.toml [database]
    Host: freetier-01.cn-hangzhou.cluster.cn-dev.matrixone.tech:6001
    User: ws_bf2d347f#moi_core_system#accountadmin
    Database used for repro: temporary zz_mo_uuid_insert_repro
    version(): 8.0.30-MatrixOne-v3.0.0
    git_version(): 5e4210029
    Go driver from fin-data-agent/backend/go.mod: github.com/go-sql-driver/mysql v1.8.1
    

    I created a temporary table with the same relevant shape and tested the old multi-row parameterized INSERT with UUID string parameters using these DSNs:

    config-dev style: ?charset=utf8mb4&parseTime=True&loc=Local
    multiStatements: ?charset=utf8mb4&parseTime=True&loc=Local&multiStatements=true
    interpolateParams: ?charset=utf8mb4&parseTime=True&loc=Local&interpolateParams=true
    

    For each DSN, I tested:

    • db.ExecContext
    • tx.ExecContext inside a transaction
    • db.PrepareContext + stmt.ExecContext

    All returned <nil> on this dev MatrixOne. The workaround path, two single-row parameterized INSERTs inside one transaction, also returned <nil>.

    Control test on the same dev MatrixOne, with an intentionally unquoted UUID-like value:

    INSERT INTO volume_files (volume_id, file_id, file_name, file_path, created_by, updated_by)
    VALUES (180001, ad027c8b-1111-4111-8111-111111111111, 'a.txt', '', 'user1', 'user1');

    This produced:

    ERROR 20301 (HY000): invalid input: ambiguous column reference 'ad027c8b'
    

    The temporary databases used for this verification were dropped afterwards.

    Conclusion update: the issue still matches the class of errors where ad027c8b is parsed as an identifier, but I still cannot reproduce the production failure using normal Go parameter binding on either local MO (git_version()=46039477b5) or fin-data-agent dev MO (git_version()=5e4210029). We need the production MatrixOne build and/or SQL trace to prove where the parameter value becomes an unquoted expression.

  3. added
    severity/s0
    on Jun 4, 2026
  4. added theissue type on Jun 4, 2026
  5. added this to the MO-202606 milestone on Jun 4, 2026
  6. modified the milestones: MO-202606, MO-202607 on Jun 30, 2026
  7. added
    ai-light
    and removed
    severity/s0
    on Jul 1, 2026
  8. ck89119 commented on Aug 23, 2026

    @ck89119
    Contributor

    Verified against the latest mo/main at commit cdf7888344df65136f6d0c9c35ead4940d69a793 using an embedded MatrixOne cluster and github.com/go-sql-driver/mysql v1.8.1.

    The test used the table shape and two-row UUID-string insert from this issue and covered:

    • interpolateParams=false (server-side binary COM_STMT_PREPARE / COM_STMT_EXECUTE)
    • interpolateParams=true (client-side interpolation)
    • db.ExecContext
    • tx.ExecContext in an explicit transaction
    • db.PrepareContext followed by stmt.ExecContext

    All variants succeeded, and a follow-up query confirmed that both UUID strings were stored correctly. Test result:

    PASS: TestIssue24727MultiRowPreparedInsertUUIDStrings
    PASS: interpolateParams=false
    PASS: interpolateParams=true
    ok github.com/matrixorigin/matrixone/pkg/tests/issues
    

    Conclusion: I could not reproduce this issue on the latest main. The original production failure likely depends on the exact deployed MatrixOne version or on a client/application path that produced an unquoted final value before it reached normal parameter binding.

  9. Ariznawlll commented on Aug 23, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • MatrixOne main @ 11a1301a5
    • 使用 go-sql-driver/mysql 的二进制协议与插值协议分别验证。

    验证内容

    • 对两行不同 UUID 执行单条多行 INSERT,分别覆盖 db.Exec、事务内 Exec 和显式 Prepare。
    • 分别以 interpolateParams=false(服务端预处理)和 interpolateParams=true(客户端插值)执行,写入后的两个 UUID 与输入值逐一一致。
    • 将未加引号 UUID 作为原始 SQL 表达式执行会返回错误,且表中保持 0 行,确认失败请求不会部分写入。

    回归用例

    结论:在最新 main 上未复现原问题,正常与异常路径均符合预期。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-light

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions