Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a
github.com/cockroachdb/errors v1.7.5
github.com/dolthub/dolt/go v0.40.5-0.20250520172729-f53346406459
github.com/dolthub/dolt/go v0.40.5-0.20250521162506-c6ea8c2b8100
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad
github.com/dolthub/go-mysql-server v0.20.1-0.20250520164330-094c26d756a3
github.com/dolthub/go-mysql-server v0.20.1-0.20250521012141-b56c7c6eb677
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216
github.com/dolthub/vitess v0.0.0-20250512224608-8fb9c6ea092c
github.com/fatih/color v1.13.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:IdqX7J8vi/Kn3T3Ee0VzqnLqwFmgA2hr8WZETPcQjfM=
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo=
github.com/dolthub/dolt/go v0.40.5-0.20250520172729-f53346406459 h1:mFO2ikky1GeQpmzJqwHo4gtqYdUWny87jPt/e0vns+Q=
github.com/dolthub/dolt/go v0.40.5-0.20250520172729-f53346406459/go.mod h1:yfrZxLTPXDKTp8GFILkkaDqpQODcOaZZ+14Y6+h2gkc=
github.com/dolthub/dolt/go v0.40.5-0.20250521162506-c6ea8c2b8100 h1:DTETzc2InAOP0ZDNGLaXxaQ0+VeUlKDf+XJdlAvpsko=
github.com/dolthub/dolt/go v0.40.5-0.20250521162506-c6ea8c2b8100/go.mod h1:0Fh/6GdGFk37fejDIap/23XSdv6vMUwoqv99g4sr8O8=
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d h1:gO9+wrmNHXukPNCO1tpfCcXIdMlW/qppbUStfLvqz/U=
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d/go.mod h1:L5RDYZbC9BBWmoU2+TjTekeqqhFXX5EqH9ln00O0stY=
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=
Expand All @@ -266,8 +266,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad h1:66ZPawHszNu37VPQckdhX1BPPVzREsGgNxQeefnlm3g=
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA=
github.com/dolthub/go-mysql-server v0.20.1-0.20250520164330-094c26d756a3 h1:rFkHy4L/GfVQh7KxwFPI/QmkPcBpT/PjnHLp+zde0xA=
github.com/dolthub/go-mysql-server v0.20.1-0.20250520164330-094c26d756a3/go.mod h1:5ZdrW0fHZbz+8CngT9gksqSX4H3y+7v1pns7tJCEpu0=
github.com/dolthub/go-mysql-server v0.20.1-0.20250521012141-b56c7c6eb677 h1:Wn0v7xBxkdzYqDN/4ksI34jstZOskMccT2SYFrvUw4c=
github.com/dolthub/go-mysql-server v0.20.1-0.20250521012141-b56c7c6eb677/go.mod h1:5ZdrW0fHZbz+8CngT9gksqSX4H3y+7v1pns7tJCEpu0=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
Expand Down
13 changes: 12 additions & 1 deletion server/connection_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type ConnectionHandler struct {
// copyFromStdinState is set when this connection is in the COPY FROM STDIN mode, meaning it is waiting on
// COPY DATA messages from the client to import data into tables.
copyFromStdinState *copyFromStdinState
// inTransaction is set to true with BEGIN query and false with COMMIT query.
inTransaction bool
}

// Set this env var to disable panic handling in the connection, which is useful when debugging a panic
Expand Down Expand Up @@ -448,6 +450,10 @@ func (h *ConnectionHandler) handleQuery(message *pgproto3.Query) (endOfMessages
// and any error that occurred while handling the query.
func (h *ConnectionHandler) handleQueryOutsideEngine(query ConvertedQuery) (handled bool, endOfMessages bool, err error) {
switch stmt := query.AST.(type) {
case *sqlparser.Begin:
h.inTransaction = true
case *sqlparser.Commit:
h.inTransaction = false
case *sqlparser.Deallocate:
// TODO: handle ALL keyword
return true, true, h.deallocatePreparedStatement(stmt.Name, h.preparedStatements, query, h.Conn())
Expand Down Expand Up @@ -1032,10 +1038,15 @@ func (h *ConnectionHandler) handledPSQLCommands(statement string) (bool, error)
// query. A nil error should be provided if this is being called naturally.
func (h *ConnectionHandler) endOfMessages(err error) {
if err != nil {
// TODO: is ReadyForQueryTransactionIndicator_FailedTransactionBlock used here?
h.sendError(err)
}
ti := ReadyForQueryTransactionIndicator_Idle
if h.inTransaction {
ti = ReadyForQueryTransactionIndicator_TransactionBlock
}
if sendErr := h.send(&pgproto3.ReadyForQuery{
TxStatus: byte(ReadyForQueryTransactionIndicator_Idle),
TxStatus: byte(ti),
}); sendErr != nil {
// We panic here for the same reason as above.
panic(sendErr)
Expand Down
13 changes: 13 additions & 0 deletions testing/go/prepared_statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,19 @@ var preparedStatementTests = []ScriptTest{
},
},
},
{
Name: "insert returning",
SetUpScript: []string{
"CREATE TABLE test (id serial, name text)",
},
Assertions: []ScriptTestAssertion{
{
Query: `INSERT INTO test (name) VALUES ($1) RETURNING id;`,
BindVars: []any{"test_name"},
Expected: []sql.Row{{1}},
},
},
},
}

var pgCatalogTests = []ScriptTest{
Expand Down