@@ -10,16 +10,19 @@ import (
1010
1111 "github.com/google/uuid"
1212 "github.com/jonboulle/clockwork"
13+ "github.com/ydb-platform/ydb-go-genproto/Ydb_Query_V1"
1314 "google.golang.org/grpc"
1415
1516 "github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
16- "github.com/ydb-platform/ydb-go-sdk/v3/internal/query"
17+ internalQuery "github.com/ydb-platform/ydb-go-sdk/v3/internal/query"
18+ "github.com/ydb-platform/ydb-go-sdk/v3/internal/query/config"
1719 "github.com/ydb-platform/ydb-go-sdk/v3/internal/stack"
1820 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xcontext"
1921 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
2022 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/xquery"
2123 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/xtable"
2224 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsync"
25+ "github.com/ydb-platform/ydb-go-sdk/v3/query"
2326 "github.com/ydb-platform/ydb-go-sdk/v3/retry/budget"
2427 "github.com/ydb-platform/ydb-go-sdk/v3/scheme"
2528 "github.com/ydb-platform/ydb-go-sdk/v3/scripting"
3538type (
3639 Engine uint8
3740 Connector struct {
38- parent ydbDriver
39- balancer grpc.ClientConnInterface
41+ parent ydbDriver
42+ balancer grpc.ClientConnInterface
43+ queryConfig * config.Config
4044
4145 processor Engine
4246
5862 ydbDriver interface {
5963 Name () string
6064 Table () table.Client
61- Query () * query.Client
65+ Query () query.Client
6266 Scripting () scripting.Client
6367 Scheme () scheme.Client
6468 }
@@ -75,6 +79,10 @@ func (e Engine) String() string {
7579 }
7680}
7781
82+ func (c * Connector ) Parent () ydbDriver {
83+ return c .parent
84+ }
85+
7886func (c * Connector ) RetryBudget () budget.Budget {
7987 return c .retryBudget
8088}
@@ -95,26 +103,6 @@ func (c *Connector) TraceRetry() *trace.Retry {
95103 return c .traceRetry
96104}
97105
98- func (c * Connector ) Query () * query.Client {
99- return c .parent .Query ()
100- }
101-
102- func (c * Connector ) Name () string {
103- return c .parent .Name ()
104- }
105-
106- func (c * Connector ) Table () table.Client {
107- return c .parent .Table ()
108- }
109-
110- func (c * Connector ) Scripting () scripting.Client {
111- return c .parent .Scripting ()
112- }
113-
114- func (c * Connector ) Scheme () scheme.Client {
115- return c .parent .Scheme ()
116- }
117-
118106const (
119107 QUERY = iota + 1
120108 TABLE
@@ -131,7 +119,7 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, finalErr error)
131119
132120 switch c .processor {
133121 case QUERY :
134- s , err := query .CreateSession (ctx , c . Query () )
122+ s , err := internalQuery .CreateSession (ctx , Ydb_Query_V1 . NewQueryServiceClient ( c . balancer ), c . queryConfig )
135123 defer func () {
136124 onDone (s , finalErr )
137125 }()
@@ -143,7 +131,7 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, finalErr error)
143131
144132 conn := & Conn {
145133 processor : QUERY ,
146- cc : xquery .New (ctx , c , s , append (
134+ cc : xquery .New (ctx , s , append (
147135 c .QueryOpts ,
148136 xquery .WithOnClose (func () {
149137 c .conns .Delete (id )
@@ -159,7 +147,7 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, finalErr error)
159147 return conn , nil
160148
161149 case TABLE :
162- s , err := c .Table ().CreateSession (ctx ) //nolint:staticcheck
150+ s , err := c .parent . Table ().CreateSession (ctx ) //nolint:staticcheck
163151 defer func () {
164152 onDone (s , finalErr )
165153 }()
@@ -171,7 +159,7 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, finalErr error)
171159
172160 conn := & Conn {
173161 processor : TABLE ,
174- cc : xtable .New (ctx , c , s , append (c .TableOpts ,
162+ cc : xtable .New (ctx , c . parent . Scripting () , s , append (c .TableOpts ,
175163 xtable .WithOnClose (func () {
176164 c .conns .Delete (id )
177165 }))... ,
@@ -193,10 +181,6 @@ func (c *Connector) Driver() driver.Driver {
193181 return c
194182}
195183
196- func (c * Connector ) Parent () ydbDriver {
197- return c .parent
198- }
199-
200184func (c * Connector ) Close () error {
201185 select {
202186 case <- c .done :
@@ -212,10 +196,16 @@ func (c *Connector) Close() error {
212196 }
213197}
214198
215- func Open (parent ydbDriver , balancer grpc.ClientConnInterface , opts ... Option ) (_ * Connector , err error ) {
199+ func Open (
200+ parent ydbDriver ,
201+ balancer grpc.ClientConnInterface ,
202+ queryConfig * config.Config ,
203+ opts ... Option ,
204+ ) (_ * Connector , err error ) {
216205 c := & Connector {
217- parent : parent ,
218- balancer : balancer ,
206+ parent : parent ,
207+ balancer : balancer ,
208+ queryConfig : queryConfig ,
219209 processor : func () Engine {
220210 if overQueryService , _ := strconv .ParseBool (os .Getenv ("YDB_DATABASE_SQL_OVER_QUERY_SERVICE" )); overQueryService {
221211 return QUERY
0 commit comments