(ctx *sql.Context, root sql.Node, r sql.Row)
| 52 | |
| 53 | func (*mysqlOkResultNode) Schema(*sql.Context) sql.Schema { |
| 54 | return types.OkResultSchema |
| 55 | } |
| 56 | |
| 57 | func withMySQLOkResultSchema(node sql.Node) sql.Node { |
| 58 | if _, ok := node.(*mysqlOkResultNode); ok { |
| 59 | return node |
| 60 | } |
| 61 | return &mysqlOkResultNode{Node: node} |
| 62 | } |
| 63 | |
| 64 | func 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 | |
| 73 | func (b *DuckBuilder) Provider() *catalog.DatabaseProvider { |
| 74 | return b.provider |
| 75 | } |
| 76 | |
| 77 | func (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 |
nothing calls this directly
no test coverage detected