Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: cannot insert with default UUID() as primary key #18895

Closed
1 task done
cpegeric opened this issue Sep 20, 2024 · 4 comments
Closed
1 task done

[Bug]: cannot insert with default UUID() as primary key #18895

cpegeric opened this issue Sep 20, 2024 · 4 comments
Assignees
Labels
kind/bug Something isn't working phase/testing severity/s0 Extreme impact: Cause the application to break down and seriously affect the use
Milestone

Comments

@cpegeric
Copy link
Contributor

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

f9b2b29

Other Environment Information

- Hardware parameters:
- OS type: macos
- Others:

Actual Behavior

mysql> CREATE TABLE namelists (
-> id UUID DEFAULT uuid() PRIMARY KEY, -- the id field is of UUID type, and the default value is the UUID value generated by the uuid() function as the primary key
-> name VARCHAR NOT NULL -- the name field is of type VARCHAR and cannot be empty
-> );
Query OK, 0 rows affected (0.04 sec)

mysql> INSERT INTO namelists (name) VALUES ('Tom'), ('Jane'), ('Bob');
ERROR 20101 (HY000): internal error: panic runtime error: invalid memory address or nil pointer dereference:
runtime.panicmem
/usr/local/go/src/runtime/panic.go:262
runtime.sigpanic
/usr/local/go/src/runtime/signal_unix.go:900
github.com/matrixorigin/matrixone/pkg/sql/plan.ConstantFold
/Users/eric/github/matrixone/pkg/sql/plan/utils.go:1109
github.com/matrixorigin/matrixone/pkg/sql/plan.getPkValueExpr
/Users/eric/github/matrixone/pkg/sql/plan/build_insert.go:872
github.com/matrixorigin/matrixone/pkg/sql/plan.buildInsertPl

Expected Behavior

The test case is the example from official document. https://docs.matrixorigin.cn/en/1.1.0/MatrixOne/Reference/Data-Types/uuid-type/#examples

-- Create a table named namelists with two fields, id and name
CREATE TABLE namelists (
id UUID DEFAULT uuid() PRIMARY KEY, -- the id field is of UUID type, and the default value is the UUID value generated by the uuid() function as the primary key
name VARCHAR NOT NULL -- the name field is of type VARCHAR and cannot be empty
);
INSERT INTO namelists (name) VALUES ('Tom'), ('Jane'), ('Bob');
mysql> select * from namelists;
+--------------------------------------+--------+
| id | name |
+--------------------------------------+--------+
| 61400e9c-1bbc-11ee-b512-5ad2460dea50 | Tom |
| 61400ea6-1bbc-11ee-b512-5ad2460dea50 | Jane |
| 61400ea6-1bbc-11ee-b513-5ad2460dea50 | Bob |
+--------------------------------------+--------+
3 rows in set (0.00 sec)

Steps to Reproduce

CREATE TABLE namelists (
    id UUID DEFAULT uuid() PRIMARY KEY, -- the id field is of UUID type, and the default value is the UUID value generated by the uuid() function as the primary key
    name VARCHAR NOT NULL -- the name field is of type VARCHAR and cannot be empty
);
INSERT INTO namelists (name) VALUES ('Tom'), ('Jane'), ('Bob');
mysql> select * from namelists;

Additional information

No response

@cpegeric cpegeric added kind/bug Something isn't working needs-triage labels Sep 20, 2024
@matrix-meow matrix-meow added this to the 1.3.0 milestone Sep 20, 2024
@daviszhen daviszhen assigned YANGGMM and unassigned matrix-meow Sep 21, 2024
@YANGGMM YANGGMM added the severity/s0 Extreme impact: Cause the application to break down and seriously affect the use label Sep 21, 2024
@YANGGMM
Copy link
Contributor

YANGGMM commented Sep 21, 2024

image image

是因为bind出来的filterExpr 为nil

@YANGGMM
Copy link
Contributor

YANGGMM commented Sep 24, 2024

merge, plz test @aressu1985

@aressu1985
Copy link
Contributor

fixed

@aressu1985
Copy link
Contributor

mysql> CREATE TABLE namelists (
-> id UUID DEFAULT uuid() PRIMARY KEY, -- the id field is of UUID type, and the default value is the UUID value generated by the uuid() function as the primary key
-> name VARCHAR NOT NULL -- the name field is of type VARCHAR and cannot be empty
-> );
Query OK, 0 rows affected (0.03 sec)

mysql> INSERT INTO namelists (name) VALUES ('Tom'), ('Jane'), ('Bob');
Query OK, 3 rows affected (0.04 sec)

mysql> select * from namelists;
+--------------------------------------+------+
| id | name |
+--------------------------------------+------+
| 019223e8-1a4c-7e09-a224-e3be03b91d31 | Tom |
| 019223e8-1a4c-7e0a-8b3b-a0661a3354a1 | Jane |
| 019223e8-1a4c-7e0d-b07e-b6cfc181f0a7 | Bob |
+--------------------------------------+------+
3 rows in set (0.00 sec)

mysql> insert into namelists values(uuid(),'Jhon');
Query OK, 1 row affected (0.02 sec)

mysql> select * from namelists;
+--------------------------------------+------+
| id | name |
+--------------------------------------+------+
| 019223e8-1a4c-7e09-a224-e3be03b91d31 | Tom |
| 019223e8-1a4c-7e0a-8b3b-a0661a3354a1 | Jane |
| 019223e8-1a4c-7e0d-b07e-b6cfc181f0a7 | Bob |
| 019223e8-9cd2-738a-b7e1-13b492c1a676 | Jhon |
+--------------------------------------+------+
4 rows in set (0.00 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working phase/testing severity/s0 Extreme impact: Cause the application to break down and seriously affect the use
Projects
None yet
Development

No branches or pull requests

5 participants