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

support READ-ONLY transactions #618

Merged

Conversation

shogo82148
Copy link
Contributor

@shogo82148 shogo82148 commented Jun 11, 2017

Description

support READ-ONLY transactions.
separated from #608.

Checklist

  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary
  • Added myself / the copyright holder to the AUTHORS file

@shogo82148
Copy link
Contributor Author

We need to discuss about error handling. Which implementation is best?

Option 1: Do not check errors in the driver (now implementation).
Most users know that whether their MySQL servers support READ-ONLY transactions.
So, the driver needs not to take care about it.

@shogo82148
Copy link
Contributor Author

Option 2: Check errors in the driver (implementation: shogo82148@371a560)

@shogo82148
Copy link
Contributor Author

Option 3: Check more carefully (implementation: shogo82148@b437c9d)

@shogo82148
Copy link
Contributor Author

TestContextCancelStmtExec fails https://travis-ci.org/go-sql-driver/mysql/jobs/241696327#L237.
It is not related to this pull request, so I'll check #608 again...

@julienschmidt
Copy link
Member

This PR needs an update since #619 was merged

@shogo82148
Copy link
Contributor Author

I updated, and all tests passing!
Do you have any opinions on error handling?

@jeeyoungk
Copy link

Do we want to merge this?

return mc.Begin()
}

func (mc *mysqlConn) beginReadOnly() (driver.Tx, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just add a parameter to mc.Begin and reuse it.
The implementation is already inconsistent between the two functions.

@julienschmidt julienschmidt added this to the v1.4 milestone Sep 9, 2017
@shogo82148
Copy link
Contributor Author

@julienschmidt Thank you for your review. I fixed it. please review it again.

The tests fail, while I think that its cause is not my pull request.
The tests also fail on the master branch https://travis-ci.org/shogo82148/mysql/builds/274139026 .

@julienschmidt
Copy link
Member

It seems like there was a change to the MySQL server on Travis causing an old test to fail. Unrelated to this PR, but we marked Travis as a required check on Github, so we can't merge before it is fixed.

See #660

Copy link
Member

@julienschmidt julienschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also rebase this PR onto the current master branch when #661 is merged.

connection.go Outdated
err := mc.exec("START TRANSACTION")
var err error
if readOnly {
err = mc.exec("START TRANSACTION READ ONLY")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's likely better if the if-else just changes the query string, e.g. it should result in a bit less generated code.

@julienschmidt
Copy link
Member

#661 was merged. If you rebase it on current master, then the tests should pass again

@shogo82148
Copy link
Contributor Author

I rebased and squashed it. All tests are passed, thanks :)

@julienschmidt julienschmidt merged commit 1548d61 into go-sql-driver:master Sep 15, 2017
@julienschmidt
Copy link
Member

thanks for your patience!

@shogo82148 shogo82148 deleted the support-read-only-transaction branch September 15, 2017 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants