Skip to content

vtgate: Handle SET for sql_auto_is_null#3611

Merged
sougou merged 2 commits intovitessio:masterfrom
vmg:vmg/auto-is-null
Jan 31, 2018
Merged

vtgate: Handle SET for sql_auto_is_null#3611
sougou merged 2 commits intovitessio:masterfrom
vmg:vmg/auto-is-null

Conversation

@vmg
Copy link
Copy Markdown
Collaborator

@vmg vmg commented Jan 31, 2018

Hi @sougou! Here's a small patch to improve compatibility with Ruby on Rails for the MySQL layer. I know you discussed this briefly with @arthurnn in chat.

I would also love it if there was a way for Vitess (probably the vttablets) to ensure that sql_auto_is_null has not been enabled manually by the user (i.e. in the MySQL configs), because the feature is insane and it's gonna break stuff. I haven't found the right place to add the check tho.


Many ORMs (most notably Rails' ActiveRecord and Django) start their
MySQL connections with a SET sql_auto_is_null=0.

This setting is superfluous in all MySQL engines that are supported by
Vitess, where sql_auto_is_null is always disabled by default.
Furthermore, it doesn't seem feasible to actually implement this feature
in Vitess because of sharded queries.

Because of this, we propose handling the case where the feature is set
to 0 (i.e. a no-op), and returning an explicit error when somebody tries
to actually enable the feature.

This improves the compatibility of Vitess' MySQL layer with these ORMs,
and improves the UX for users attempting to enable sql_auto_is_null in
a connection.

@sougou
Copy link
Copy Markdown
Contributor

sougou commented Jan 31, 2018

Wow. Nasty feature. We should disable it. To make vttablet enforce this, you can add the check in the VerifyMode function: https://github.com/youtube/vitess/blob/master/go/vt/vttablet/tabletserver/connpool/dbconn.go#L225.

PS: The test has a minor compilation error.

Many ORMs (most notably Rails' ActiveRecord and Django) start their
MySQL connections with a `SET sql_auto_is_null=0`.

This setting is superfluous in all MySQL engines that are supported by
Vitess, where `sql_auto_is_null` is always disabled by default.
Furthermore, it doesn't seem feasible to actually implement this feature
in Vitess because of sharded queries.

Because of this, we propose handling the case where the feature is set
to 0 (i.e. a no-op), and returning an explicit error when somebody tries
to actually enable the feature.

This improves the compatibility of Vitess' MySQL layer with these ORMs,
and improves the UX for users attempting to enable `sql_auto_is_null` in
a connection.
@vmg vmg force-pushed the vmg/auto-is-null branch from 598a070 to ab3be3f Compare January 31, 2018 13:43
@vmg
Copy link
Copy Markdown
Collaborator Author

vmg commented Jan 31, 2018

Ah yes, that's the perfect spot. Updated the PR!

@sougou
Copy link
Copy Markdown
Contributor

sougou commented Jan 31, 2018

Some new tests are failing. Looks like you need to add that query to fakesqldb.

@vmg vmg force-pushed the vmg/auto-is-null branch from ab3be3f to 22976e5 Compare January 31, 2018 14:18
@vmg vmg force-pushed the vmg/auto-is-null branch from 22976e5 to 740aa88 Compare January 31, 2018 14:46
@vmg
Copy link
Copy Markdown
Collaborator Author

vmg commented Jan 31, 2018

phew! Took me a while to get the fakesqldb queries wired up everywhere. Finally got it right.

Ready to review!

@sougou
Copy link
Copy Markdown
Contributor

sougou commented Jan 31, 2018

LGTM
Yeah. Those are a pain. But they pay off because we don't have to bring up real mysql servers for them. We should look at unifying that framework to make maintenance easier.

Approved with PullApprove

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.

3 participants