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

Driver improvements for Dolt #364

Merged
merged 3 commits into from Apr 14, 2021

Conversation

firelizzard18
Copy link
Contributor

@firelizzard18 firelizzard18 commented Apr 9, 2021

It turns out Dolt needs to have control over how sql.Sessions are created, and it needs to modify the *sql.Context prior to query execution. This MR adds two interfaces:

  • driver.SessionBuilder
  • driver.ContextBuilder

When a driver is created, with driver.New, if the provider implements either of these interfaces, then the provider's implementation will be used for creating sessions/contexts. Otherwise, a default implementation is used. The Dolt provider can then implement those two interfaces and do the necessary work to setup the session/context:

  • New SQL session
    • Create a dolt session (wrapping a sql session)
    • For each Dolt database in the SQL catalog:
      • Call doltSession.AddDB
  • New SQL context
    • Create a sql context
    • For each Dolt database in the SQL catalog:
      • Get the working root of the corresponding Dolt env
      • Call doltDatabase.SetRoot
      • Call sqle.RegisterSchemaFragments

Prior to adding SessionBuilder, attempting to execute a query would panic, when Dolt attempts to coerce the session into a Dolt session. Prior to adding ContextBuilder, some features would not work - for example, queries had no access to uncommitted changes.

For reference, this is the Dolt driver implementation I'm working on.

Support for using Dolt as a driver.Provider
Support for using Dolt as a driver.Provider
@oscarbatori oscarbatori requested a review from zachmu April 9, 2021 14:12
Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

LG, thanks for the contribution!

@zachmu zachmu merged commit 39e7402 into dolthub:master Apr 14, 2021
@firelizzard18 firelizzard18 deleted the feature/driver-session-provider branch April 14, 2021 23:30
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.

None yet

2 participants