// Code generated by gtrace. DO NOT EDIT.

package gtrace

import (
	"context"
	"database/sql/driver"

	"github.com/ydb-platform/ydb-go-sdk/v3/trace"
)

// databaseSQLComposeOptions is a holder of options
type databaseSQLComposeOptions struct {
	panicCallback func(e interface{})
}

// DatabaseSQLOption specified DatabaseSQL compose option
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
type DatabaseSQLComposeOption func(o *databaseSQLComposeOptions)

// WithDatabaseSQLPanicCallback specified behavior on panic
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func WithDatabaseSQLPanicCallback(cb func(e interface{})) DatabaseSQLComposeOption {
	return func(o *databaseSQLComposeOptions) {
		o.panicCallback = cb
	}
}

// Compose returns a new DatabaseSQL which has functional fields composed both from lhs and rhs.
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func Compose(lhs *trace.DatabaseSQL, rhs *trace.DatabaseSQL, opts ...DatabaseSQLComposeOption) *trace.DatabaseSQL {
	if lhs == nil {
		return rhs
	}
	var ret trace.DatabaseSQL
	options := databaseSQLComposeOptions{}
	for _, opt := range opts {
		if opt != nil {
			opt(&options)
		}
	}
	{
		h1 := lhs.OnConnectorConnect
		h2 := rhs.OnConnectorConnect
		ret.OnConnectorConnect = func(d trace.DatabaseSQLConnectorConnectStartInfo) func(trace.DatabaseSQLConnectorConnectDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnectorConnectDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnectorConnectDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnPing
		h2 := rhs.OnConnPing
		ret.OnConnPing = func(d trace.DatabaseSQLConnPingStartInfo) func(trace.DatabaseSQLConnPingDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnPingDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnPingDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnPrepare
		h2 := rhs.OnConnPrepare
		ret.OnConnPrepare = func(d trace.DatabaseSQLConnPrepareStartInfo) func(trace.DatabaseSQLConnPrepareDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnPrepareDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnPrepareDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnClose
		h2 := rhs.OnConnClose
		ret.OnConnClose = func(d trace.DatabaseSQLConnCloseStartInfo) func(trace.DatabaseSQLConnCloseDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnCloseDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnCloseDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnBegin
		h2 := rhs.OnConnBegin
		ret.OnConnBegin = func(d trace.DatabaseSQLConnBeginStartInfo) func(trace.DatabaseSQLConnBeginDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnBeginDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnBeginDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnBeginTx
		h2 := rhs.OnConnBeginTx
		ret.OnConnBeginTx = func(d trace.DatabaseSQLConnBeginTxStartInfo) func(trace.DatabaseSQLConnBeginTxDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnBeginTxDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnBeginTxDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnCheckNamedValue
		h2 := rhs.OnConnCheckNamedValue
		ret.OnConnCheckNamedValue = func(d trace.DatabaseSQLConnCheckNamedValueStartInfo) func(trace.DatabaseSQLConnCheckNamedValueDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnCheckNamedValueDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnCheckNamedValueDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnQuery
		h2 := rhs.OnConnQuery
		ret.OnConnQuery = func(d trace.DatabaseSQLConnQueryStartInfo) func(trace.DatabaseSQLConnQueryDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnQueryDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnQueryDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnExec
		h2 := rhs.OnConnExec
		ret.OnConnExec = func(d trace.DatabaseSQLConnExecStartInfo) func(trace.DatabaseSQLConnExecDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnExecDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnExecDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnIsTableExists
		h2 := rhs.OnConnIsTableExists
		ret.OnConnIsTableExists = func(d trace.DatabaseSQLConnIsTableExistsStartInfo) func(trace.DatabaseSQLConnIsTableExistsDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnIsTableExistsDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLConnIsTableExistsDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnIsColumnExists
		h2 := rhs.OnConnIsColumnExists
		ret.OnConnIsColumnExists = func(info trace.DatabaseSQLConnIsColumnExistsStartInfo) func(trace.DatabaseSQLConnIsColumnExistsDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnIsColumnExistsDoneInfo)
			if h1 != nil {
				r = h1(info)
			}
			if h2 != nil {
				r1 = h2(info)
			}
			return func(d trace.DatabaseSQLConnIsColumnExistsDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnGetIndexColumns
		h2 := rhs.OnConnGetIndexColumns
		ret.OnConnGetIndexColumns = func(info trace.DatabaseSQLConnGetIndexColumnsStartInfo) func(trace.DatabaseSQLConnGetIndexColumnsDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLConnGetIndexColumnsDoneInfo)
			if h1 != nil {
				r = h1(info)
			}
			if h2 != nil {
				r1 = h2(info)
			}
			return func(d trace.DatabaseSQLConnGetIndexColumnsDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnTxQuery
		h2 := rhs.OnTxQuery
		ret.OnTxQuery = func(d trace.DatabaseSQLTxQueryStartInfo) func(trace.DatabaseSQLTxQueryDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLTxQueryDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLTxQueryDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnTxExec
		h2 := rhs.OnTxExec
		ret.OnTxExec = func(d trace.DatabaseSQLTxExecStartInfo) func(trace.DatabaseSQLTxExecDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLTxExecDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLTxExecDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnTxPrepare
		h2 := rhs.OnTxPrepare
		ret.OnTxPrepare = func(d trace.DatabaseSQLTxPrepareStartInfo) func(trace.DatabaseSQLTxPrepareDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLTxPrepareDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLTxPrepareDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnTxCommit
		h2 := rhs.OnTxCommit
		ret.OnTxCommit = func(d trace.DatabaseSQLTxCommitStartInfo) func(trace.DatabaseSQLTxCommitDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLTxCommitDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLTxCommitDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnTxRollback
		h2 := rhs.OnTxRollback
		ret.OnTxRollback = func(d trace.DatabaseSQLTxRollbackStartInfo) func(trace.DatabaseSQLTxRollbackDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLTxRollbackDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLTxRollbackDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnStmtQuery
		h2 := rhs.OnStmtQuery
		ret.OnStmtQuery = func(d trace.DatabaseSQLStmtQueryStartInfo) func(trace.DatabaseSQLStmtQueryDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLStmtQueryDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLStmtQueryDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnStmtExec
		h2 := rhs.OnStmtExec
		ret.OnStmtExec = func(d trace.DatabaseSQLStmtExecStartInfo) func(trace.DatabaseSQLStmtExecDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLStmtExecDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLStmtExecDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnStmtClose
		h2 := rhs.OnStmtClose
		ret.OnStmtClose = func(d trace.DatabaseSQLStmtCloseStartInfo) func(trace.DatabaseSQLStmtCloseDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLStmtCloseDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLStmtCloseDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnDoTx
		h2 := rhs.OnDoTx
		ret.OnDoTx = func(d trace.DatabaseSQLDoTxStartInfo) func(trace.DatabaseSQLDoTxIntermediateInfo) func(trace.DatabaseSQLDoTxDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DatabaseSQLDoTxIntermediateInfo) func(trace.DatabaseSQLDoTxDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DatabaseSQLDoTxIntermediateInfo) func(trace.DatabaseSQLDoTxDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				var r2, r3 func(trace.DatabaseSQLDoTxDoneInfo)
				if r != nil {
					r2 = r(d)
				}
				if r1 != nil {
					r3 = r1(d)
				}
				return func(d trace.DatabaseSQLDoTxDoneInfo) {
					if options.panicCallback != nil {
						defer func() {
							if e := recover(); e != nil {
								options.panicCallback(e)
							}
						}()
					}
					if r2 != nil {
						r2(d)
					}
					if r3 != nil {
						r3(d)
					}
				}
			}
		}
	}
	return &ret
}
func onConnectorConnect(t *trace.DatabaseSQL, d trace.DatabaseSQLConnectorConnectStartInfo) func(trace.DatabaseSQLConnectorConnectDoneInfo) {
	fn := t.OnConnectorConnect
	if fn == nil {
		return func(trace.DatabaseSQLConnectorConnectDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnectorConnectDoneInfo) {
			return
		}
	}
	return res
}
func onConnPing(t *trace.DatabaseSQL, d trace.DatabaseSQLConnPingStartInfo) func(trace.DatabaseSQLConnPingDoneInfo) {
	fn := t.OnConnPing
	if fn == nil {
		return func(trace.DatabaseSQLConnPingDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnPingDoneInfo) {
			return
		}
	}
	return res
}
func onConnPrepare(t *trace.DatabaseSQL, d trace.DatabaseSQLConnPrepareStartInfo) func(trace.DatabaseSQLConnPrepareDoneInfo) {
	fn := t.OnConnPrepare
	if fn == nil {
		return func(trace.DatabaseSQLConnPrepareDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnPrepareDoneInfo) {
			return
		}
	}
	return res
}
func onConnClose(t *trace.DatabaseSQL, d trace.DatabaseSQLConnCloseStartInfo) func(trace.DatabaseSQLConnCloseDoneInfo) {
	fn := t.OnConnClose
	if fn == nil {
		return func(trace.DatabaseSQLConnCloseDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnCloseDoneInfo) {
			return
		}
	}
	return res
}
func onConnBegin(t *trace.DatabaseSQL, d trace.DatabaseSQLConnBeginStartInfo) func(trace.DatabaseSQLConnBeginDoneInfo) {
	fn := t.OnConnBegin
	if fn == nil {
		return func(trace.DatabaseSQLConnBeginDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnBeginDoneInfo) {
			return
		}
	}
	return res
}
func onConnBeginTx(t *trace.DatabaseSQL, d trace.DatabaseSQLConnBeginTxStartInfo) func(trace.DatabaseSQLConnBeginTxDoneInfo) {
	fn := t.OnConnBeginTx
	if fn == nil {
		return func(trace.DatabaseSQLConnBeginTxDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnBeginTxDoneInfo) {
			return
		}
	}
	return res
}
func onConnCheckNamedValue(t *trace.DatabaseSQL, d trace.DatabaseSQLConnCheckNamedValueStartInfo) func(trace.DatabaseSQLConnCheckNamedValueDoneInfo) {
	fn := t.OnConnCheckNamedValue
	if fn == nil {
		return func(trace.DatabaseSQLConnCheckNamedValueDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnCheckNamedValueDoneInfo) {
			return
		}
	}
	return res
}
func onConnQuery(t *trace.DatabaseSQL, d trace.DatabaseSQLConnQueryStartInfo) func(trace.DatabaseSQLConnQueryDoneInfo) {
	fn := t.OnConnQuery
	if fn == nil {
		return func(trace.DatabaseSQLConnQueryDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnQueryDoneInfo) {
			return
		}
	}
	return res
}
func onConnExec(t *trace.DatabaseSQL, d trace.DatabaseSQLConnExecStartInfo) func(trace.DatabaseSQLConnExecDoneInfo) {
	fn := t.OnConnExec
	if fn == nil {
		return func(trace.DatabaseSQLConnExecDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnExecDoneInfo) {
			return
		}
	}
	return res
}
func onConnIsTableExists(t *trace.DatabaseSQL, d trace.DatabaseSQLConnIsTableExistsStartInfo) func(trace.DatabaseSQLConnIsTableExistsDoneInfo) {
	fn := t.OnConnIsTableExists
	if fn == nil {
		return func(trace.DatabaseSQLConnIsTableExistsDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLConnIsTableExistsDoneInfo) {
			return
		}
	}
	return res
}
func onConnIsColumnExists(t *trace.DatabaseSQL, info trace.DatabaseSQLConnIsColumnExistsStartInfo) func(trace.DatabaseSQLConnIsColumnExistsDoneInfo) {
	fn := t.OnConnIsColumnExists
	if fn == nil {
		return func(trace.DatabaseSQLConnIsColumnExistsDoneInfo) {
			return
		}
	}
	res := fn(info)
	if res == nil {
		return func(trace.DatabaseSQLConnIsColumnExistsDoneInfo) {
			return
		}
	}
	return res
}
func onConnGetIndexColumns(t *trace.DatabaseSQL, info trace.DatabaseSQLConnGetIndexColumnsStartInfo) func(trace.DatabaseSQLConnGetIndexColumnsDoneInfo) {
	fn := t.OnConnGetIndexColumns
	if fn == nil {
		return func(trace.DatabaseSQLConnGetIndexColumnsDoneInfo) {
			return
		}
	}
	res := fn(info)
	if res == nil {
		return func(trace.DatabaseSQLConnGetIndexColumnsDoneInfo) {
			return
		}
	}
	return res
}
func onTxQuery(t *trace.DatabaseSQL, d trace.DatabaseSQLTxQueryStartInfo) func(trace.DatabaseSQLTxQueryDoneInfo) {
	fn := t.OnTxQuery
	if fn == nil {
		return func(trace.DatabaseSQLTxQueryDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLTxQueryDoneInfo) {
			return
		}
	}
	return res
}
func onTxExec(t *trace.DatabaseSQL, d trace.DatabaseSQLTxExecStartInfo) func(trace.DatabaseSQLTxExecDoneInfo) {
	fn := t.OnTxExec
	if fn == nil {
		return func(trace.DatabaseSQLTxExecDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLTxExecDoneInfo) {
			return
		}
	}
	return res
}
func onTxPrepare(t *trace.DatabaseSQL, d trace.DatabaseSQLTxPrepareStartInfo) func(trace.DatabaseSQLTxPrepareDoneInfo) {
	fn := t.OnTxPrepare
	if fn == nil {
		return func(trace.DatabaseSQLTxPrepareDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLTxPrepareDoneInfo) {
			return
		}
	}
	return res
}
func onTxCommit(t *trace.DatabaseSQL, d trace.DatabaseSQLTxCommitStartInfo) func(trace.DatabaseSQLTxCommitDoneInfo) {
	fn := t.OnTxCommit
	if fn == nil {
		return func(trace.DatabaseSQLTxCommitDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLTxCommitDoneInfo) {
			return
		}
	}
	return res
}
func onTxRollback(t *trace.DatabaseSQL, d trace.DatabaseSQLTxRollbackStartInfo) func(trace.DatabaseSQLTxRollbackDoneInfo) {
	fn := t.OnTxRollback
	if fn == nil {
		return func(trace.DatabaseSQLTxRollbackDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLTxRollbackDoneInfo) {
			return
		}
	}
	return res
}
func onStmtQuery(t *trace.DatabaseSQL, d trace.DatabaseSQLStmtQueryStartInfo) func(trace.DatabaseSQLStmtQueryDoneInfo) {
	fn := t.OnStmtQuery
	if fn == nil {
		return func(trace.DatabaseSQLStmtQueryDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLStmtQueryDoneInfo) {
			return
		}
	}
	return res
}
func onStmtExec(t *trace.DatabaseSQL, d trace.DatabaseSQLStmtExecStartInfo) func(trace.DatabaseSQLStmtExecDoneInfo) {
	fn := t.OnStmtExec
	if fn == nil {
		return func(trace.DatabaseSQLStmtExecDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLStmtExecDoneInfo) {
			return
		}
	}
	return res
}
func onStmtClose(t *trace.DatabaseSQL, d trace.DatabaseSQLStmtCloseStartInfo) func(trace.DatabaseSQLStmtCloseDoneInfo) {
	fn := t.OnStmtClose
	if fn == nil {
		return func(trace.DatabaseSQLStmtCloseDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLStmtCloseDoneInfo) {
			return
		}
	}
	return res
}
func onDoTx(t *trace.DatabaseSQL, d trace.DatabaseSQLDoTxStartInfo) func(trace.DatabaseSQLDoTxIntermediateInfo) func(trace.DatabaseSQLDoTxDoneInfo) {
	fn := t.OnDoTx
	if fn == nil {
		return func(trace.DatabaseSQLDoTxIntermediateInfo) func(trace.DatabaseSQLDoTxDoneInfo) {
			return func(trace.DatabaseSQLDoTxDoneInfo) {
				return
			}
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DatabaseSQLDoTxIntermediateInfo) func(trace.DatabaseSQLDoTxDoneInfo) {
			return func(trace.DatabaseSQLDoTxDoneInfo) {
				return
			}
		}
	}
	return func(d trace.DatabaseSQLDoTxIntermediateInfo) func(trace.DatabaseSQLDoTxDoneInfo) {
		res := res(d)
		if res == nil {
			return func(trace.DatabaseSQLDoTxDoneInfo) {
				return
			}
		}
		return res
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnectorConnect(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call) func(session trace.SessionInfo, _ error) {
	var p trace.DatabaseSQLConnectorConnectStartInfo
	p.Context = c
	p.Call = c1
	res := onConnectorConnect(t, p)
	return func(session trace.SessionInfo, e error) {
		var p trace.DatabaseSQLConnectorConnectDoneInfo
		p.Session = session
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnPing(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call) func(error) {
	var p trace.DatabaseSQLConnPingStartInfo
	p.Context = c
	p.Call = c1
	res := onConnPing(t, p)
	return func(e error) {
		var p trace.DatabaseSQLConnPingDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnPrepare(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, query string) func(error) {
	var p trace.DatabaseSQLConnPrepareStartInfo
	p.Context = c
	p.Call = c1
	p.Query = query
	res := onConnPrepare(t, p)
	return func(e error) {
		var p trace.DatabaseSQLConnPrepareDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnClose(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call) func(error) {
	var p trace.DatabaseSQLConnCloseStartInfo
	p.Context = c
	p.Call = c1
	res := onConnClose(t, p)
	return func(e error) {
		var p trace.DatabaseSQLConnCloseDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnBegin(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call) func(tx trace.TxInfo, _ error) {
	var p trace.DatabaseSQLConnBeginStartInfo
	p.Context = c
	p.Call = c1
	res := onConnBegin(t, p)
	return func(tx trace.TxInfo, e error) {
		var p trace.DatabaseSQLConnBeginDoneInfo
		p.Tx = tx
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnBeginTx(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call) func(tx trace.TxInfo, _ error) {
	var p trace.DatabaseSQLConnBeginTxStartInfo
	p.Context = c
	p.Call = c1
	res := onConnBeginTx(t, p)
	return func(tx trace.TxInfo, e error) {
		var p trace.DatabaseSQLConnBeginTxDoneInfo
		p.Tx = tx
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnCheckNamedValue(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, value *driver.NamedValue) func(error) {
	var p trace.DatabaseSQLConnCheckNamedValueStartInfo
	p.Context = c
	p.Call = c1
	p.Value = value
	res := onConnCheckNamedValue(t, p)
	return func(e error) {
		var p trace.DatabaseSQLConnCheckNamedValueDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnQuery(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, query string, mode string, idempotent bool) func(error) {
	var p trace.DatabaseSQLConnQueryStartInfo
	p.Context = c
	p.Call = c1
	p.Query = query
	p.Mode = mode
	p.Idempotent = idempotent
	res := onConnQuery(t, p)
	return func(e error) {
		var p trace.DatabaseSQLConnQueryDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnExec(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, query string, mode string, idempotent bool) func(error) {
	var p trace.DatabaseSQLConnExecStartInfo
	p.Context = c
	p.Call = c1
	p.Query = query
	p.Mode = mode
	p.Idempotent = idempotent
	res := onConnExec(t, p)
	return func(e error) {
		var p trace.DatabaseSQLConnExecDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnIsTableExists(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, tableName string) func(exists bool, _ error) {
	var p trace.DatabaseSQLConnIsTableExistsStartInfo
	p.Context = c
	p.Call = c1
	p.TableName = tableName
	res := onConnIsTableExists(t, p)
	return func(exists bool, e error) {
		var p trace.DatabaseSQLConnIsTableExistsDoneInfo
		p.Exists = exists
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnIsColumnExists(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, tableName string, columnName string) func(exists bool, _ error) {
	var p trace.DatabaseSQLConnIsColumnExistsStartInfo
	p.Context = c
	p.Call = c1
	p.TableName = tableName
	p.ColumnName = columnName
	res := onConnIsColumnExists(t, p)
	return func(exists bool, e error) {
		var p trace.DatabaseSQLConnIsColumnExistsDoneInfo
		p.Exists = exists
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnConnGetIndexColumns(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, tableName string, indexName string) func(columns []string, _ error) {
	var p trace.DatabaseSQLConnGetIndexColumnsStartInfo
	p.Context = c
	p.Call = c1
	p.TableName = tableName
	p.IndexName = indexName
	res := onConnGetIndexColumns(t, p)
	return func(columns []string, e error) {
		var p trace.DatabaseSQLConnGetIndexColumnsDoneInfo
		p.Columns = columns
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnTxQuery(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, txContext context.Context, tx trace.TxInfo, query string) func(error) {
	var p trace.DatabaseSQLTxQueryStartInfo
	p.Context = c
	p.Call = c1
	p.TxContext = txContext
	p.Tx = tx
	p.Query = query
	res := onTxQuery(t, p)
	return func(e error) {
		var p trace.DatabaseSQLTxQueryDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnTxExec(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, txContext context.Context, tx trace.TxInfo, query string) func(error) {
	var p trace.DatabaseSQLTxExecStartInfo
	p.Context = c
	p.Call = c1
	p.TxContext = txContext
	p.Tx = tx
	p.Query = query
	res := onTxExec(t, p)
	return func(e error) {
		var p trace.DatabaseSQLTxExecDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnTxPrepare(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, txContext context.Context, tx trace.TxInfo, query string) func(error) {
	var p trace.DatabaseSQLTxPrepareStartInfo
	p.Context = c
	p.Call = c1
	p.TxContext = txContext
	p.Tx = tx
	p.Query = query
	res := onTxPrepare(t, p)
	return func(e error) {
		var p trace.DatabaseSQLTxPrepareDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnTxCommit(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, tx trace.TxInfo) func(error) {
	var p trace.DatabaseSQLTxCommitStartInfo
	p.Context = c
	p.Call = c1
	p.Tx = tx
	res := onTxCommit(t, p)
	return func(e error) {
		var p trace.DatabaseSQLTxCommitDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnTxRollback(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, tx trace.TxInfo) func(error) {
	var p trace.DatabaseSQLTxRollbackStartInfo
	p.Context = c
	p.Call = c1
	p.Tx = tx
	res := onTxRollback(t, p)
	return func(e error) {
		var p trace.DatabaseSQLTxRollbackDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnStmtQuery(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, stmtContext context.Context, query string) func(error) {
	var p trace.DatabaseSQLStmtQueryStartInfo
	p.Context = c
	p.Call = c1
	p.StmtContext = stmtContext
	p.Query = query
	res := onStmtQuery(t, p)
	return func(e error) {
		var p trace.DatabaseSQLStmtQueryDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnStmtExec(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, stmtContext context.Context, query string) func(error) {
	var p trace.DatabaseSQLStmtExecStartInfo
	p.Context = c
	p.Call = c1
	p.StmtContext = stmtContext
	p.Query = query
	res := onStmtExec(t, p)
	return func(e error) {
		var p trace.DatabaseSQLStmtExecDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnStmtClose(t *trace.DatabaseSQL, stmtContext *context.Context, c trace.Call) func(error) {
	var p trace.DatabaseSQLStmtCloseStartInfo
	p.StmtContext = stmtContext
	p.Call = c
	res := onStmtClose(t, p)
	return func(e error) {
		var p trace.DatabaseSQLStmtCloseDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DatabaseSQLOnDoTx(t *trace.DatabaseSQL, c *context.Context, c1 trace.Call, iD string, idempotent bool) func(error) func(attempts int, _ error) {
	var p trace.DatabaseSQLDoTxStartInfo
	p.Context = c
	p.Call = c1
	p.ID = iD
	p.Idempotent = idempotent
	res := onDoTx(t, p)
	return func(e error) func(int, error) {
		var p trace.DatabaseSQLDoTxIntermediateInfo
		p.Error = e
		res := res(p)
		return func(attempts int, e error) {
			var p trace.DatabaseSQLDoTxDoneInfo
			p.Attempts = attempts
			p.Error = e
			res(p)
		}
	}
}
