Giter Site home page Giter Site logo

Comments (7)

dvilaverde avatar dvilaverde commented on July 19, 2024

I'm seeing the same. For some reason I can no longer use s, err := server.NewDefaultServer(config, engine) and need to use server.NewServer, specifically to set the SessionBuilder in order to avoid using the server.DefaultSessionBuilder.

Here is an example that works:

pro := sql.NewDatabaseProvider(dbs...)
	engine := sqle.NewDefault(
		pro,
	)

config := server.Config{
		Protocol: "tcp",
		Address:  fmt.Sprintf("localhost:%d", port),
	}

s, err := server.NewServer(config, engine, func(ctx context.Context, conn *mysql.Conn, addr string) (sql.Session, error) {
		builder, err := server.DefaultSessionBuilder(ctx, conn, addr)
		if err != nil {
			return nil, err
		}
		return memory.NewSession(builder.(*sql.BaseSession), pro), nil
	}, nil)

from go-mysql-server.

fulghum avatar fulghum commented on July 19, 2024

@cold-runner and @dvilaverde – thank you for taking the time to report this one to us. 🙏 The most recent release of go-mysql-server contains several correctness fixes to the memory database implementation and also includes support for the in-memory implementation to integrate with the table rewrite hook in the engine. As part of that work, the way to instantiate an in-memory server changed so that the session provider function must now be specified.

As part of that work, it looks like we updated the example in the _example folder, but we didn't update the main project README. Apologies that we missed that! I've just fixed the main project README with the correct, updated code for instantiating an in-memory test server.

I'll go ahead and resolve this issue, since these changes were intended and the README was out of date, but please feel free to comment if you have any problems moving to the new instantiation code and we'll be more than happy to help. Apologies for the snag and thank you for letting us know the README was out of sync with the latest release.

from go-mysql-server.

twhiteman avatar twhiteman commented on July 19, 2024

Can the NewDefaultServer method be updated to create a valid session builder!? As right now it results in the above panic, otherwise, what is the purpose of NewDefaultServer anymore?

from go-mysql-server.

fulghum avatar fulghum commented on July 19, 2024

Good question about NewDefaultServer. It looks like the default session builder that is used in NewDefaultServer now uses BaseSession, but code in the in-memory engine requires memory.Session. We might be able to change the in-memory engine to work with that default session builder somehow, but I haven't looked at it deeply.

Tagging @zachmu for his opinion here, since he's got some context form being on the commits that changed the sample code to this new interface.

from go-mysql-server.

zachmu avatar zachmu commented on July 19, 2024

Thanks for the feedback. The NewDefaultServer() method is pretty useless now, because the memory implementation now requires its own Session type for the server to work correctly. I'll do a pass on this and either fix or remove NewDefaultServer.

from go-mysql-server.

zachmu avatar zachmu commented on July 19, 2024

The tip of main fixes this issue, but I'll leave this open until we do a patch release.

from go-mysql-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.