Comments (6)
Hey @abbnaseri, can you provide a little more detail? Are you trying to implement a sql.RowUpdater?
from go-mysql-server.
Hey @zachmu, Thanks for your response. In our project we want to parse the sql queries that we are receiving and extract its components and then use those components to build a request and send it to another service for database updates. there is a legacy service which we are trying to detach it from real database. for example if this is the query we are receiving:
UPDATE users SET email = "[email protected]" WHERE id = 1;
we want to know that this is an 'update' query and it tries to update 'email' column based on id = 1 condition. I read the BACKEND.md but i didn't get which interface i should implement. I'll be grateful if you help me with that.
from go-mysql-server.
I think what you really want is the Vitess. This is our fork;
https://github.com/dolthub/vitess
That handles query parsing in go-mysql-server.
from go-mysql-server.
Yeah I came across this project earlier but i didn't understand how it can solve my problem. What we want is all MySQL functionality with this exception that for queries we need all their components for building the requests and for response we must return valid MySQL responses/errors so that the legacy project doesn't feel it isn't a real MySQL.
from go-mysql-server.
Based on this, you probably don't want to implement a custom backend. You probably want just want the parser capability.
You need to:
- Call sqlparser.Parse() to parse the statement from the client
- Determine if it's an UpdateStatement
- If so, dig into the AST produced by Parse to see if the conditions you want to trigger on obtain to that query
- Trigger your alternate business logic if so
Here's an example of walking the AST produced by the Parse function, should get you started:
https://github.com/dolthub/go-mysql-server/blob/main/sql/parse/parse.go#L185
from go-mysql-server.
Going to cvlose this as I think we answered your question.
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
- Panic when executing sql statements from external command line tool after startup HOT 7
- 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.