MCPcopy Create free account
hub / github.com/apecloud/myduckserver / Build

Method Build

backend/executor.go:54–169  ·  view source on GitHub ↗
(ctx *sql.Context, root sql.Node, r sql.Row)

Source from the content-addressed store, hash-verified

52
53func (*mysqlOkResultNode) Schema(*sql.Context) sql.Schema {
54 return types.OkResultSchema
55}
56
57func withMySQLOkResultSchema(node sql.Node) sql.Node {
58 if _, ok := node.(*mysqlOkResultNode); ok {
59 return node
60 }
61 return &mysqlOkResultNode{Node: node}
62}
63
64func NewDuckBuilder(base *rowexec.BaseBuilder, provider *catalog.DatabaseProvider) *DuckBuilder {
65 fallback := *base
66 fallback.PriorityBuilder = nil
67 return &DuckBuilder{
68 base: &fallback,
69 provider: provider,
70 }
71}
72
73func (b *DuckBuilder) Provider() *catalog.DatabaseProvider {
74 return b.provider
75}
76
77func (b *DuckBuilder) Build(ctx *sql.Context, root sql.Node, r sql.Row) (iter sql.RowIter, err error) {
78 topLevel := r == nil
79 var snapshotRelease, operationRelease func()
80 var physicalTx *stdsql.Tx
81 defer func() {
82 // Query-row limiting is a top-level concern. Keep the two lifecycle leases
83 // outside that wrapper so an early limit/error closes the child before the
84 // snapshot is released, while an admitted operation can remain held until
85 // transaction finalization.
86 if topLevel && err == nil && iter != nil {
87 iter = ApplyQueryRowLimit(ctx, root.Schema(ctx), iter)
88 if snapshotRelease != nil || operationRelease != nil {
89 iter = wrapDuckLakeOperationIterWithLeasesAndTx(ctx, iter, physicalTx, snapshotRelease, operationRelease)
90 snapshotRelease = nil
91 operationRelease = nil
92 }
93 }
94 if snapshotRelease != nil {
95 snapshotRelease()
96 }
97 if operationRelease != nil {
98 operationRelease()
99 }
100 }()
101
102 // The engine passes a nil input row for the top-level result iterator.
103 // Subquery iterators must not count intermediate rows against the limit.
104 // Flush the delta buffer before executing the query. Replication controller
105 // commands must remain able to stop an applier while it is connecting and
106 // therefore cannot wait on the applier-owned query barrier.
107 // TODO(fan): Be fine-grained and flush only when the replicated tables are touched.
108 if err := b.flushDeltaBuffer(ctx, root); err != nil {
109 return nil, err
110 }
111

Callers

nothing calls this directly

Calls 15

buildLoadDataMethod · 0.95
executeQueryMethod · 0.95
executeDMLMethod · 0.95
executeExpressionerMethod · 0.95
FullSchemaNameFunction · 0.92
GetCurrentCatalogFunction · 0.92
isRewritableLoadDataFunction · 0.85
containsVariableFunction · 0.85
IsPureDataQueryFunction · 0.85
GetChecksMethod · 0.80
GetConnForSchemaMethod · 0.80

Tested by

no test coverage detected