@@ -10,16 +10,19 @@ import (
10
10
11
11
"github.com/google/uuid"
12
12
"github.com/jonboulle/clockwork"
13
+ "github.com/ydb-platform/ydb-go-genproto/Ydb_Query_V1"
13
14
"google.golang.org/grpc"
14
15
15
16
"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"
17
19
"github.com/ydb-platform/ydb-go-sdk/v3/internal/stack"
18
20
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xcontext"
19
21
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
20
22
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/xquery"
21
23
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/xtable"
22
24
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsync"
25
+ "github.com/ydb-platform/ydb-go-sdk/v3/query"
23
26
"github.com/ydb-platform/ydb-go-sdk/v3/retry/budget"
24
27
"github.com/ydb-platform/ydb-go-sdk/v3/scheme"
25
28
"github.com/ydb-platform/ydb-go-sdk/v3/scripting"
35
38
type (
36
39
Engine uint8
37
40
Connector struct {
38
- parent ydbDriver
39
- balancer grpc.ClientConnInterface
41
+ parent ydbDriver
42
+ balancer grpc.ClientConnInterface
43
+ queryConfig * config.Config
40
44
41
45
processor Engine
42
46
58
62
ydbDriver interface {
59
63
Name () string
60
64
Table () table.Client
61
- Query () * query.Client
65
+ Query () query.Client
62
66
Scripting () scripting.Client
63
67
Scheme () scheme.Client
64
68
}
@@ -75,6 +79,10 @@ func (e Engine) String() string {
75
79
}
76
80
}
77
81
82
+ func (c * Connector ) Parent () ydbDriver {
83
+ return c .parent
84
+ }
85
+
78
86
func (c * Connector ) RetryBudget () budget.Budget {
79
87
return c .retryBudget
80
88
}
@@ -95,26 +103,6 @@ func (c *Connector) TraceRetry() *trace.Retry {
95
103
return c .traceRetry
96
104
}
97
105
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
-
118
106
const (
119
107
QUERY = iota + 1
120
108
TABLE
@@ -131,7 +119,7 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, finalErr error)
131
119
132
120
switch c .processor {
133
121
case QUERY :
134
- s , err := query .CreateSession (ctx , c . Query () )
122
+ s , err := internalQuery .CreateSession (ctx , Ydb_Query_V1 . NewQueryServiceClient ( c . balancer ), c . queryConfig )
135
123
defer func () {
136
124
onDone (s , finalErr )
137
125
}()
@@ -143,7 +131,7 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, finalErr error)
143
131
144
132
conn := & Conn {
145
133
processor : QUERY ,
146
- cc : xquery .New (ctx , c , s , append (
134
+ cc : xquery .New (ctx , s , append (
147
135
c .QueryOpts ,
148
136
xquery .WithOnClose (func () {
149
137
c .conns .Delete (id )
@@ -159,7 +147,7 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, finalErr error)
159
147
return conn , nil
160
148
161
149
case TABLE :
162
- s , err := c .Table ().CreateSession (ctx ) //nolint:staticcheck
150
+ s , err := c .parent . Table ().CreateSession (ctx ) //nolint:staticcheck
163
151
defer func () {
164
152
onDone (s , finalErr )
165
153
}()
@@ -171,7 +159,7 @@ func (c *Connector) Connect(ctx context.Context) (_ driver.Conn, finalErr error)
171
159
172
160
conn := & Conn {
173
161
processor : TABLE ,
174
- cc : xtable .New (ctx , c , s , append (c .TableOpts ,
162
+ cc : xtable .New (ctx , c . parent . Scripting () , s , append (c .TableOpts ,
175
163
xtable .WithOnClose (func () {
176
164
c .conns .Delete (id )
177
165
}))... ,
@@ -193,10 +181,6 @@ func (c *Connector) Driver() driver.Driver {
193
181
return c
194
182
}
195
183
196
- func (c * Connector ) Parent () ydbDriver {
197
- return c .parent
198
- }
199
-
200
184
func (c * Connector ) Close () error {
201
185
select {
202
186
case <- c .done :
@@ -212,10 +196,16 @@ func (c *Connector) Close() error {
212
196
}
213
197
}
214
198
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 ) {
216
205
c := & Connector {
217
- parent : parent ,
218
- balancer : balancer ,
206
+ parent : parent ,
207
+ balancer : balancer ,
208
+ queryConfig : queryConfig ,
219
209
processor : func () Engine {
220
210
if overQueryService , _ := strconv .ParseBool (os .Getenv ("YDB_DATABASE_SQL_OVER_QUERY_SERVICE" )); overQueryService {
221
211
return QUERY
0 commit comments