Bug fix: Make db.Ping(ctx) work correctly with Doltgres
#887
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementations of
db.Ping(ctx)from Go'sdatabase/sqlpackage typically send some sort of empty query to test the liveness of a database connection. For example, thepqlibrary sends;and the pgx library sends-- ping.Before this change, Doltgres' parser would return an empty statement, instead of Vitess'
ErrEmptyerror, which caused GMS to try and execute a nil analyzed plan for these statements, return an error, and the ping check would fail. This change makes the Doltgres parser return the same VitessErrEmptyerror that the Vitess parser throws, sending the same signal to GMS to handle an empty statement without returning an error to the client. The related PR dolthub/go-mysql-server#2716 updates theParserinterface documentation to explicitly call out the requirement to returnErrEmptyin order for empty statements to be handled correctly.For testing, I've added some no-op statements to the smoke tests, but since these tests go through as prepared statements, they don't follow the exact code path as
db.Ping(ctx), so I've also added calls todb.Ping(ctx)in the test framework, which do reproduce this error. I've also added a unit test for Doltgres'Parserimplementation that explicitly tests empty statement parsing.Fixes: #884
Related to: dolthub/go-mysql-server#2716