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 on dolt_diff_* with generated column #8665

Closed
senuphtyz opened this issue Dec 11, 2024 · 3 comments · Fixed by #8673
Closed

Panic on dolt_diff_* with generated column #8665

senuphtyz opened this issue Dec 11, 2024 · 3 comments · Fixed by #8673
Assignees

Comments

@senuphtyz
Copy link

Using a table with a generated column panics trying to diff inserted data.
I used version 1.44.1 to produce this error.

Steps to produce:

  1. Create a table with a generated column
CREATE TABLE `users` (
  `id` int NOT NULL AUTO_INCREMENT,
  `login` varchar(255) NOT NULL,
  `title` varchar(255),
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `full_name` varchar(255) GENERATED ALWAYS AS (lower(concat(`first_name`,' ',`last_name`))),
  PRIMARY KEY (`id`)
);
  1. Commit schema changes
call dolt_commit('-A', '-m', 'a commit message');
  1. Insert data into table
insert into users SET id=1, login="login", title="title",first_name="first_name", last_name="last_name";
  1. Try generating a diff
select * from dolt_diff_users;

Results in:

panic: runtime error: index out of range [4] with length 4

goroutine 39 [running]:
github.com/dolthub/dolt/go/store/prolly/tree.GetField({0x36ec990?, 0xc000f9e820?}, {{0xc000660a70, 0x4, 0x4}, {0xc00091e800, 0x4, 0x4}, {0x36f3bc0, 0xc00132c420}, ...}, ...)
        github.com/dolthub/dolt/go/store/prolly/tree/prolly_fields.go:41 +0x3a75
github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables.ProllyRowConverter.putFields({{0x378a420, 0xc000a8e780}, {0x378a420, 0xc000a8e080}, {0xc000660a50, 0x1, 0x1}, {0xc00012cb10, 0x5, 0x5}, ...}, ...)
        github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables/prolly_row_conv.go:119 +0xe5
github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables.ProllyRowConverter.PutConverted({{0x378a420, 0xc000a8e780}, {0x378a420, 0xc000a8e080}, {0xc000660a50, 0x1, 0x1}, {0xc00012cb10, 0x5, 0x5}, ...}, ...)
        github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables/prolly_row_conv.go:111 +0x268
github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables.prollyDiffIter.getDiffTableRow({{{{{...}, {...}, 0x0, 0x0, 0x0, {...}}, {0x36fe490, 0xc000b8d040}, {{...}, {...}, ...}}, ...}, ...}, ...)
        github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables/diff_iter.go:429 +0x1c9
github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables.prollyDiffIter.makeDiffRowItr({{{{{...}, {...}, 0x0, 0x0, 0x0, {...}}, {0x36fe490, 0xc000b8d040}, {{...}, {...}, ...}}, ...}, ...}, ...)
        github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables/diff_iter.go:372 +0x15a
github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables.prollyDiffIter.queueRows.func1({0x36ec990, 0xc000f9e820}, {{0xc000234394, 0x6, 0x20}, {0x0, 0x0, 0x0}, {0xc00023436c, 0x1b, ...}, ...})
        github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables/diff_iter.go:338 +0x78
github.com/dolthub/dolt/go/store/prolly.DiffMaps.makeDiffCallBack.func1({0x36ec990?, 0xc000f9e820?}, {{0xc000234394, 0x6, 0x20}, {0x0, 0x0, 0x0}, {0xc00023436c, 0x1b, ...}, ...})
        github.com/dolthub/dolt/go/store/prolly/tuple_map.go:165 +0x103
github.com/dolthub/dolt/go/store/prolly/tree.DiffOrderedTrees[...]({_, _}, {{{0x4c, 0x0, 0x44, 0x2, 0x0}, {0x40, 0x0, 0x38, ...}, ...}, ...}, ...)
        github.com/dolthub/dolt/go/store/prolly/tree/map.go:70 +0x2a5
github.com/dolthub/dolt/go/store/prolly.DiffMaps({_, _}, {{{{0x4c, 0x0, 0x44, 0x2, 0x0}, {0x40, 0x0, 0x38, ...}, ...}, ...}, ...}, ...)
        github.com/dolthub/dolt/go/store/prolly/tuple_map.go:115 +0x176
github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables.prollyDiffIter.queueRows({{{{{...}, {...}, 0x0, 0x0, 0x0, {...}}, {0x36fe490, 0xc000b8d040}, {{...}, {...}, ...}}, ...}, ...}, ...)
        github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables/diff_iter.go:337 +0xa5
github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables.newProllyDiffIter.func1()
        github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables/diff_iter.go:309 +0x35
created by github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables.newProllyDiffIter in goroutine 1
        github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables/diff_iter.go:308 +0xb2d
@timsehn
Copy link
Contributor

timsehn commented Dec 11, 2024

Oooo. Good bug that generated column is causing issues for us. We'll at least make it not panic today. Hopefully, we'll be able to produce teh proper diff tables as well today but that may be a bit harder.

@jycor
Copy link
Contributor

jycor commented Dec 12, 2024

Hey @senuphtyz, thanks for reporting this issue! We have merged the fix to dolt main to make this not panic.
Currently, the diff for virtual generated columns will just be NULL. Ideally, we'd be able to show the value but that isn't near at hand. As a workaround, having the generated columns be stored will produce a diff.

A release with the fix will be out later this week!
Please let us know how it works for you, and if there are any other issues!

@bpf120
Copy link

bpf120 commented Dec 16, 2024

@senuphtyz , thanks for using Dolt and reporting this issue. We'd love to learn about your use case. If want to share, you can email me or swing by our Discord.

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

Successfully merging a pull request may close this issue.

5 participants