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

Update mysql schema #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Update mysql schema #2

wants to merge 2 commits into from

Conversation

wolsen
Copy link

@wolsen wolsen commented Aug 14, 2023

The groups keyword is reserved in mysql but can still have tables using this name if they are quoted with backticks (`). Additionally, default values cannot be specified for TEXT types unless wrapped in parentheses.

This change updates the schema. Without this, glauth will crash immediately with a stack trace similar to:

Aug 14 16:06:18 violet glauth.glauth[1792776]: Mon, 14 Aug 2023 16:06:18 -0700 INF AP start
Aug 14 16:06:18 violet glauth.glauth[1792776]: panic: runtime error: invalid memory address or nil pointer dereference
Aug 14 16:06:18 violet glauth.glauth[1792776]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x7f744540aa82]
Aug 14 16:06:18 violet glauth.glauth[1792776]: goroutine 1 [running]:
Aug 14 16:06:18 violet glauth.glauth[1792776]: database/sql.(*Stmt).ExecContext(0x0, {0x1664e00, 0xc000028090}, {0x0, 0x0, 0x0})
Aug 14 16:06:18 violet glauth.glauth[1792776]:         /snap/go/10029/src/database/sql/sql.go:2619 +0x82
Aug 14 16:06:18 violet glauth.glauth[1792776]: database/sql.(*Stmt).Exec(...)
Aug 14 16:06:18 violet glauth.glauth[1792776]:         /snap/go/10029/src/database/sql/sql.go:2651
Aug 14 16:06:18 violet glauth.glauth[1792776]: plugin/unnamed-a4a88b6e149fb894e2d6a86bf6dd94628b70c962.MysqlBackend.CreateSchema({}, 0xc0002e6090?)
Aug 14 16:06:18 violet glauth.glauth[1792776]:         /root/parts/glauth/src/v2/pkg/plugins/glauth-mysql/mysql.go:50 +0x5d
Aug 14 16:06:18 violet glauth.glauth[1792776]: github.com/glauth/glauth/v2/pkg/plugins.NewDatabaseHandler({0x7f7445800270, 0x1e1e088}, {0xc0003746c0, 0x5, 0xc000380e01?})
Aug 14 16:06:18 violet glauth.glauth[1792776]:         /root/parts/glauth/src/v2/pkg/plugins/basesqlhandler.go:83 +0x3b1
Aug 14 16:06:18 violet glauth.glauth[1792776]: plugin/unnamed-a4a88b6e149fb894e2d6a86bf6dd94628b70c962.NewMySQLHandler({0xc0003746c0?, 0x28?, 0xc000140558?})
Aug 14 16:06:18 violet glauth.glauth[1792776]:         /root/parts/glauth/src/v2/pkg/plugins/glauth-mysql/mysql.go:17 +0x35
Aug 14 16:06:18 violet glauth.glauth[1792776]: github.com/glauth/glauth/v2/pkg/server.NewServer({0xc00031fd60, 0x2, 0x7?})
Aug 14 16:06:18 violet glauth.glauth[1792776]:         /root/parts/glauth/src/v2/pkg/server/server.go:127 +0x125c
Aug 14 16:06:18 violet glauth.glauth[1792776]: main.startService()
Aug 14 16:06:18 violet glauth.glauth[1792776]:         /root/parts/glauth/src/v2/glauth.go:160 +0x34f
Aug 14 16:06:18 violet glauth.glauth[1792776]: main.main()
Aug 14 16:06:18 violet glauth.glauth[1792776]:         /root/parts/glauth/src/v2/glauth.go:133 +0x225

The groups keyword is reserved in mysql but can still have tables
using this name if they are quoted with backticks (`). Additionally,
default values cannot be specified for TEXT types unless wrapped in
parentheses.

Signed-off-by: Billy Olsen <[email protected]>
@wolsen
Copy link
Author

wolsen commented Aug 14, 2023

Ah I didn't see PR#1, which partially covers this. The problem with the table name of groups will still be a problem here since mysql reserves the groups keyword. Potentially altering the table name will be the path of least resistance here. I'll take a look and see options.

@wolsen wolsen marked this pull request as draft August 15, 2023 02:01
@wolsen wolsen force-pushed the main branch 2 times, most recently from f72ae1b to e1fd6ad Compare August 15, 2023 02:18
Update the schema to rename groups to ldapgroups. This allows for the
table name and means to access it to be consistent across all databases.
This is due to mysql reserving the name groups as a keyword.

Signed-off-by: Billy Olsen <[email protected]>
@wolsen
Copy link
Author

wolsen commented Aug 15, 2023

Closing this PR and cleaning it up. Will submit another one with changes.

Nevermind, I'm just going to re-use this. Sorry for the mess in the PR - you get to see my thought process.

@wolsen wolsen closed this Aug 15, 2023
@wolsen wolsen reopened this Aug 15, 2023
@wolsen wolsen marked this pull request as ready for review August 15, 2023 03:34
@wolsen
Copy link
Author

wolsen commented Aug 15, 2023

Note: this is the plugin change for PR#326 on the glauth repo.

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

Successfully merging this pull request may close these issues.

1 participant