Comments (7)
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.
@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.
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.
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.
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.
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)
- go mod tidy error
- VSCode debug Build Error
- GolangCI does not work
- UPDATE statements are Noop HOT 4
- any plan to build new release? HOT 1
- go mod tidy error HOT 2
- add create table comment on table clause to table spec HOT 1
- Can't turn on multiStatements when using memory driver HOT 2
- Does it support `Functional Key Parts` index ? HOT 2
- Server error message compatibility when doing INSERT HOT 3
- Foreign key constraints break auto-incrementing ids in memory mode HOT 3
- Self-referencing foreign key constraint breaks auto-incrementing ids in memory mode HOT 2
- Potential regression: number cast to JSON no longer read as float HOT 2
- Running multiple migrations in a transaction HOT 2
- Primary key column order changes column order on insert HOT 1
- Consistent usage of variables in the example
- MemoryDB: Deleting rows silently fails if there are multiple CASCADING constraints pointing to the same parent HOT 1
- MemoryDB: UPDATE succeeds but is not reflected in subsequent SELECT
- Feature request: persistent database store HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-mysql-server.