Skip to content

[Bug]: PREPARE/EXECUTE corrupts JSON NULL on 2nd+ execution #23859

@XuPeng-SH

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

3.0-dev, main

Commit ID

latest

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

Actual Behavior

From 2nd execution onward, NULL values stored as empty ByteJson (IS NULL=false, 0 bytes). Reads panic: "ByteJson.Unmarshal index out of range [0] with length 0"

Expected Behavior

No response

Steps to Reproduce

## Steps to Reproduce

CREATE TABLE test_ps (id INT, meta JSON);
PREPARE stmt FROM 'INSERT INTO test_ps (id, meta) VALUES (?, ?)';
SET @a=1, @b=NULL; EXECUTE stmt USING @a, @b;
SET @a=2, @b=NULL; EXECUTE stmt USING @a, @b;
DEALLOCATE PREPARE stmt;

SELECT id, meta IS NULL FROM test_ps;
-- 1=true, 2=false (corrupted)

SELECT CAST(meta AS CHAR) FROM test_ps;
-- ERROR: ByteJson.Unmarshal panic

Additional information

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions