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

Panic in stored procedure #4980

Closed
bheni opened this issue Dec 13, 2022 · 1 comment
Closed

Panic in stored procedure #4980

bheni opened this issue Dec 13, 2022 · 1 comment
Labels
bug Something isn't working good repro Easily reproducible bugs panic

Comments

@bheni
Copy link
Contributor

bheni commented Dec 13, 2022

If I take the following SQL which works:

MySQL [palilax/dev]> SET @event_id='cb8ba301-6c27-4bf8-b99b-617082d72621';
Query OK, 1 row affected (0.058 sec)
MySQL [palilax/dev]>     INSERT INTO person_cal_entries (id, cal_entry_id_fk, person_id_fk)
    ->     SELECT uuid() as id, @event_id as cal_entry_id_fk, id as person_id_fk
    ->     FROM personnel
    ->     WHERE id IN (
    ->         SELECT person_id_fk
    ->         FROM season_participants
    ->         WHERE season_id_fk = (
    ->             SELECT season_id_fk
    ->             FROM cal_entries
    ->             WHERE id = @event_id
    ->         )
    ->     );
Query OK, 23 rows affected (0.051 sec)

and try to turn it into a stored procedure:

MySQL [palilax/dev]> DELIMITER // ;
MySQL [palilax/dev]> CREATE PROCEDURE create_cal_entries_for_event(IN event_id VARCHAR(36))
    -> BEGIN
    ->     INSERT INTO person_cal_entries (id, cal_entry_id_fk, person_id_fk)
    ->     SELECT uuid() as id, event_id as cal_entry_id_fk, id as person_id_fk
    ->     FROM personnel
    ->     WHERE id IN (
    ->         SELECT person_id_fk
    ->         FROM season_participants
    ->         WHERE season_id_fk = (
    ->             SELECT season_id_fk
    ->             FROM cal_entries
    ->             WHERE id = event_id
    ->         )
    ->     );
    -> END //
Query OK, 0 rows affected (0.051 sec)

MySQL [palilax/dev]> DELIMITER ; //

and then attempt to call the stored procedure:

MySQL [palilax/dev]> call create_cal_entries_for_event('cb8ba301-6c27-4bf8-b99b-617082d72621');
ERROR 2013 (HY000): Lost connection to server during query

I get the following panic in the sql server logs:

2022-12-13T01:24:27Z INFO [conn 247] NewConnection {DisableClientMultiStatements=true}
2022-12-13T01:24:28Z INFO [no conn] kill query: pid 5619 {}
2022-12-13T01:24:28Z INFO [conn 247] ConnectionClosed {}
2022-12-13T01:24:28Z ERROR [no conn] mysql_server caught panic:
runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:260 (0x44e655)
/usr/local/go/src/runtime/signal_unix.go:835 (0x44e625)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/expression/procedureparam.go:54 (0x137503c)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/expression/procedureparam.go:150 (0x1375546)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/expression/comparison.go:148 (0x1367bd8)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/expression/comparison.go:77 (0x136755a)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/expression/comparison.go:266 (0x1368ca4)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/core.go:1102 (0xd2659b)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/filter.go:118 (0x14ce71c)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/project.go:153 (0x15000ee)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/subquery.go:133 (0x152236d)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/subquery.go:306 (0x1523704)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/subquery.go:195 (0x1522b06)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/indexed_in_subquery_filter.go:100 (0x14e1845)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/project.go:69 (0x14ff59c)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/subquery.go:156 (0x15226f1)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/subquery.go:295 (0x1523663)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/subquery.go:271 (0x1523456)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/indexed_in_subquery_filter.go:106 (0x14e1935)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/project.go:69 (0x14ff59c)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/project.go:69 (0x14ff59c)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/insert.go:281 (0x14e7bf2)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/insert.go:663 (0x14eaa2c)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/row_update_accumulator.go:388 (0x150a775)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/block.go:109 (0x14ae0e8)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/block.go:149 (0x14adf6a)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/procedure.go:170 (0x14b0674)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/call.go:156 (0x14b065c)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/transaction_committing_iter.go:59 (0x1529ad1)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/sql/plan/process.go:66 (0x14fbcf7)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/engine.go:226 (0x17471f9)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/server/handler.go:351 (0x18432a9)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/server/handler.go:615 (0x1845f27)
/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.12.1-0.20221028185331-adb56cc0306f/server/handler.go:175 (0x1841425)
/go/pkg/mod/github.com/dolthub/vitess@v0.0.0-20221004165409-08281765376f/go/mysql/conn.go:1288 (0xc57c6f)
/go/pkg/mod/github.com/dolthub/vitess@v0.0.0-20221004165409-08281765376f/go/mysql/conn.go:930 (0xc54a38)
/go/pkg/mod/github.com/dolthub/vitess@v0.0.0-20221004165409-08281765376f/go/mysql/server.go:481 (0xc6df72)
/usr/local/go/src/runtime/asm_amd64.s:1594 (0x46bf40) {}
@timsehn timsehn added bug Something isn't working panic good repro Easily reproducible bugs labels Dec 13, 2022
@Hydrocharged
Copy link
Contributor

This is fixed in dolthub/go-mysql-server#1475
I guessed the schemas of the tables that were mentioned, along with some dummy data for them, to create a test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good repro Easily reproducible bugs panic
Projects
None yet
Development

No branches or pull requests

3 participants