Skip to content

Commit 17739ea

Browse files
committed
Bug fix for db.Ping(ctx) against a Doltgres server
1 parent c84a300 commit 17739ea

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

postgres/parser/parser/sql/sql_parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (p *PostgresParser) ParseWithOptions(ctx context.Context, query string, del
5656
return nil, "", "", fmt.Errorf("only a single statement at a time is currently supported")
5757
}
5858
if len(stmts) == 0 {
59-
return nil, q, "", nil
59+
return nil, q, "", vitess.ErrEmpty
6060
}
6161

6262
vitessAST, err := ast.Convert(stmts[0])

testing/go/framework.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func RunScript(t *testing.T, script ScriptTest, normalizeRows bool) {
130130
Default: pgxConn,
131131
Current: pgxConn,
132132
}
133+
require.NoError(t, pgxConn.Ping(ctx))
133134
defer func() {
134135
conn.Close(ctx)
135136
}()
@@ -309,6 +310,9 @@ func CreateServer(t *testing.T, database string) (context.Context, *Connection,
309310

310311
conn, err := pgx.Connect(ctx, fmt.Sprintf("postgres://postgres:[email protected]:%d/%s", port, database))
311312
require.NoError(t, err)
313+
314+
// Ping the connection to test that it's alive, and also to test that Doltgres handles empty queries correctly
315+
require.NoError(t, conn.Ping(ctx))
312316
return ctx, &Connection{
313317
Default: conn,
314318
Current: conn,

testing/go/smoke_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ func TestSmokeTests(t *testing.T) {
7171
Query: "SELECT NULL = NULL",
7272
Expected: []sql.Row{{nil}},
7373
},
74+
{
75+
Query: ";",
76+
Expected: []sql.Row{},
77+
},
78+
{
79+
Query: " ; ",
80+
Expected: []sql.Row{},
81+
},
82+
{
83+
Query: "-- this is only a comment",
84+
Expected: []sql.Row{},
85+
},
7486
},
7587
},
7688
{

0 commit comments

Comments
 (0)