Skip to content

Commit a97d994

Browse files
author
James Cor
committed
removing transaction committing node
1 parent 9aafbeb commit a97d994

File tree

9 files changed

+10
-136
lines changed

9 files changed

+10
-136
lines changed

engine.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ func (e *Engine) QueryWithBindings(ctx *sql.Context, query string, parsed sqlpar
446446

447447
return nil, nil, nil, err
448448
}
449+
450+
iter = rowexec.AddTransactionCommittingIter(iter, qFlags)
449451
iter = rowexec.AddExpressionCloser(analyzed, iter)
450452

451453
return analyzed.Schema(), iter, qFlags, nil
@@ -722,31 +724,6 @@ func (e *Engine) CloseSession(connID uint32) {
722724
e.PreparedDataCache.DeleteSessionData(connID)
723725
}
724726

725-
// Count number of BindVars in given tree
726-
func countBindVars(node sql.Node) int {
727-
var bindVars map[string]bool
728-
bindCntFunc := func(e sql.Expression) bool {
729-
if bv, ok := e.(*expression.BindVar); ok {
730-
if bindVars == nil {
731-
bindVars = make(map[string]bool)
732-
}
733-
bindVars[bv.Name] = true
734-
}
735-
return true
736-
}
737-
transform.InspectExpressions(node, bindCntFunc)
738-
739-
// InsertInto.Source not a child of InsertInto, so also need to traverse those
740-
transform.Inspect(node, func(n sql.Node) bool {
741-
if in, ok := n.(*plan.InsertInto); ok {
742-
transform.InspectExpressions(in.Source, bindCntFunc)
743-
return false
744-
}
745-
return true
746-
})
747-
return len(bindVars)
748-
}
749-
750727
func (e *Engine) beginTransaction(ctx *sql.Context) error {
751728
beginNewTransaction := ctx.GetTransaction() == nil || plan.ReadCommitted(ctx)
752729
if beginNewTransaction {

sql/analyzer/autocommit.go

Lines changed: 0 additions & 34 deletions
This file was deleted.

sql/analyzer/parallelize.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ func shouldParallelize(node sql.Node, scope *plan.Scope) bool {
5454
return false
5555
}
5656

57-
if tc, ok := node.(*plan.TransactionCommittingNode); ok {
58-
return shouldParallelize(tc.Child(), scope)
59-
}
60-
6157
// Do not try to parallelize DDL or descriptive operations
6258
return !plan.IsNoRowNode(node)
6359
}

sql/analyzer/resolve_subqueries.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,6 @@ func StripPassthroughNodes(n sql.Node) sql.Node {
296296
switch tn := n.(type) {
297297
case *plan.QueryProcess:
298298
n = tn.Child()
299-
case *plan.TransactionCommittingNode:
300-
n = tn.Child()
301299
default:
302300
nodeIsPassthrough = false
303301
}

sql/analyzer/rules.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func init() {
2626
{inlineSubqueryAliasRefsId, inlineSubqueryAliasRefs},
2727
{cacheSubqueryAliasesInJoinsId, cacheSubqueryAliasesInJoins},
2828
{backtickDefaulColumnValueNamesId, backtickDefaultColumnValueNames},
29-
{AutocommitId, addAutocommit},
3029
{TrackProcessId, trackProcess},
3130
{parallelizeId, parallelize},
3231
}

sql/plan/transaction_committing_iter.go

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package plan
1616

1717
import (
18-
"fmt"
1918
"os"
2019

2120
"github.com/dolthub/go-mysql-server/sql"
@@ -34,65 +33,6 @@ func init() {
3433
}
3534
}
3635

37-
// TransactionCommittingNode implements autocommit logic. It wraps relevant queries and ensures the database commits
38-
// the transaction.
39-
type TransactionCommittingNode struct {
40-
UnaryNode
41-
}
42-
43-
var _ sql.Node = (*TransactionCommittingNode)(nil)
44-
var _ sql.CollationCoercible = (*TransactionCommittingNode)(nil)
45-
46-
// NewTransactionCommittingNode returns a TransactionCommittingNode.
47-
func NewTransactionCommittingNode(child sql.Node) *TransactionCommittingNode {
48-
return &TransactionCommittingNode{UnaryNode: UnaryNode{Child: child}}
49-
}
50-
51-
// String implements the sql.Node interface.
52-
func (t *TransactionCommittingNode) String() string {
53-
return t.Child().String()
54-
}
55-
56-
// DebugString implements the sql.DebugStringer interface.
57-
func (t *TransactionCommittingNode) DebugString() string {
58-
return sql.DebugString(t.Child())
59-
}
60-
61-
// Describe implements the sql.Describable interface.
62-
func (t *TransactionCommittingNode) Describe(options sql.DescribeOptions) string {
63-
return sql.Describe(t.Child(), options)
64-
}
65-
66-
func (t *TransactionCommittingNode) IsReadOnly() bool {
67-
return t.Child().IsReadOnly()
68-
}
69-
70-
// WithChildren implements the sql.Node interface.
71-
func (t *TransactionCommittingNode) WithChildren(children ...sql.Node) (sql.Node, error) {
72-
if len(children) != 1 {
73-
return nil, fmt.Errorf("ds")
74-
}
75-
76-
t2 := *t
77-
t2.UnaryNode = UnaryNode{Child: children[0]}
78-
return &t2, nil
79-
}
80-
81-
// CheckPrivileges implements the sql.Node interface.
82-
func (t *TransactionCommittingNode) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool {
83-
return t.Child().CheckPrivileges(ctx, opChecker)
84-
}
85-
86-
// CollationCoercibility implements the interface sql.CollationCoercible.
87-
func (*TransactionCommittingNode) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) {
88-
return sql.Collation_binary, 7
89-
}
90-
91-
// Child implements the sql.UnaryNode interface.
92-
func (t *TransactionCommittingNode) Child() sql.Node {
93-
return t.UnaryNode.Child
94-
}
95-
9636
// IsSessionAutocommit returns true if the current session is using implicit transaction management
9737
// through autocommit.
9838
func IsSessionAutocommit(ctx *sql.Context) (bool, error) {

sql/rowexec/node_builder.gen.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ func (b *BaseBuilder) buildNodeExecNoAnalyze(ctx *sql.Context, n sql.Node, row s
5454
return b.buildCreateRole(ctx, n, row)
5555
case *plan.Loop:
5656
return b.buildLoop(ctx, n, row)
57-
case *plan.TransactionCommittingNode:
58-
return b.buildTransactionCommittingNode(ctx, n, row)
5957
case *plan.DropColumn:
6058
return b.buildDropColumn(ctx, n, row)
6159
case *plan.AnalyzeTable:

sql/rowexec/transaction.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,3 @@ func (b *BaseBuilder) buildExecuteQuery(ctx *sql.Context, n *plan.ExecuteQuery,
300300
func (b *BaseBuilder) buildUse(ctx *sql.Context, n *plan.Use, row sql.Row) (sql.RowIter, error) {
301301
return n.RowIter(ctx, row)
302302
}
303-
304-
func (b *BaseBuilder) buildTransactionCommittingNode(ctx *sql.Context, n *plan.TransactionCommittingNode, row sql.Row) (sql.RowIter, error) {
305-
iter, err := b.Build(ctx, n.Child(), row)
306-
if err != nil {
307-
return nil, err
308-
}
309-
return &TransactionCommittingIter{childIter: iter}, nil
310-
}

sql/rowexec/transaction_iters.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ type TransactionCommittingIter struct {
7474
transactionDatabase string
7575
}
7676

77+
func AddTransactionCommittingIter(child sql.RowIter, qFlags *sql.QueryFlags) sql.RowIter {
78+
// TODO: This is a bit of a hack. Need to figure out better relationship between new transaction node and warnings.
79+
if qFlags != nil && qFlags.IsSet(sql.QFlagShowWarnings) {
80+
return child
81+
}
82+
return &TransactionCommittingIter{childIter: child}
83+
}
84+
7785
func (t *TransactionCommittingIter) Next(ctx *sql.Context) (sql.Row, error) {
7886
return t.childIter.Next(ctx)
7987
}

0 commit comments

Comments
 (0)