@@ -17,7 +17,7 @@ import (
17
17
"github.com/ydb-platform/ydb-go-sdk/v3/internal/table/config"
18
18
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
19
19
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xslices"
20
- "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/iface "
20
+ "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/conn "
21
21
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsync"
22
22
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
23
23
"github.com/ydb-platform/ydb-go-sdk/v3/scheme"
@@ -26,14 +26,14 @@ import (
26
26
)
27
27
28
28
var (
29
- _ driver.ConnBeginTx = (* conn )(nil )
30
- _ driver.NamedValueChecker = (* conn )(nil )
31
- _ driver.Pinger = (* conn )(nil )
29
+ _ driver.ConnBeginTx = (* connWrapper )(nil )
30
+ _ driver.NamedValueChecker = (* connWrapper )(nil )
31
+ _ driver.Pinger = (* connWrapper )(nil )
32
32
)
33
33
34
34
type (
35
- conn struct {
36
- cc iface .Conn
35
+ connWrapper struct {
36
+ cc conn .Conn
37
37
38
38
connector * Connector
39
39
lastUsage xsync.LastUsage
@@ -44,16 +44,16 @@ type (
44
44
}
45
45
)
46
46
47
- func (c * conn ) Ping (ctx context.Context ) error {
47
+ func (c * connWrapper ) Ping (ctx context.Context ) error {
48
48
return c .cc .Ping (ctx )
49
49
}
50
50
51
- func (c * conn ) CheckNamedValue (value * driver.NamedValue ) error {
51
+ func (c * connWrapper ) CheckNamedValue (value * driver.NamedValue ) error {
52
52
// on this stage allows all values
53
53
return nil
54
54
}
55
55
56
- func (c * conn ) BeginTx (ctx context.Context , opts driver.TxOptions ) (driver.Tx , error ) {
56
+ func (c * connWrapper ) BeginTx (ctx context.Context , opts driver.TxOptions ) (driver.Tx , error ) {
57
57
tx , err := c .cc .BeginTx (ctx , opts )
58
58
if err != nil {
59
59
return nil , xerrors .WithStackTrace (err )
@@ -66,7 +66,7 @@ func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, e
66
66
}, nil
67
67
}
68
68
69
- func (c * conn ) Close () error {
69
+ func (c * connWrapper ) Close () error {
70
70
err := c .cc .Close ()
71
71
if err != nil {
72
72
return xerrors .WithStackTrace (err )
@@ -75,7 +75,7 @@ func (c *conn) Close() error {
75
75
return nil
76
76
}
77
77
78
- func (c * conn ) Begin () (driver.Tx , error ) {
78
+ func (c * connWrapper ) Begin () (driver.Tx , error ) {
79
79
return nil , xerrors .WithStackTrace (errDeprecated )
80
80
}
81
81
@@ -118,13 +118,13 @@ func (r *singleRow) Next(dst []driver.Value) error {
118
118
return nil
119
119
}
120
120
121
- func (c * conn ) Prepare (string ) (driver.Stmt , error ) {
121
+ func (c * connWrapper ) Prepare (string ) (driver.Stmt , error ) {
122
122
return nil , errDeprecated
123
123
}
124
124
125
- func (c * conn ) PrepareContext (ctx context.Context , sql string ) (_ driver.Stmt , finalErr error ) {
125
+ func (c * connWrapper ) PrepareContext (ctx context.Context , sql string ) (_ driver.Stmt , finalErr error ) {
126
126
onDone := trace .DatabaseSQLOnConnPrepare (c .connector .Trace (), & ctx ,
127
- stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*conn ).PrepareContext" ),
127
+ stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*connWrapper ).PrepareContext" ),
128
128
sql ,
129
129
)
130
130
defer func () {
@@ -143,11 +143,11 @@ func (c *conn) PrepareContext(ctx context.Context, sql string) (_ driver.Stmt, f
143
143
}, nil
144
144
}
145
145
146
- func (c * conn ) LastUsage () time.Time {
146
+ func (c * connWrapper ) LastUsage () time.Time {
147
147
return c .lastUsage .Get ()
148
148
}
149
149
150
- func (c * conn ) normalize (q string , args ... driver.NamedValue ) (query string , _ * params.Params , _ error ) {
150
+ func (c * connWrapper ) normalize (q string , args ... driver.NamedValue ) (query string , _ * params.Params , _ error ) {
151
151
queryArgs := make ([]any , len (args ))
152
152
for i := range args {
153
153
queryArgs [i ] = args [i ]
@@ -163,7 +163,7 @@ func (c *conn) normalize(q string, args ...driver.NamedValue) (query string, _ *
163
163
return sql , & params , nil
164
164
}
165
165
166
- func (c * conn ) QueryContext (ctx context.Context , query string , args []driver.NamedValue ) (driver.Rows , error ) {
166
+ func (c * connWrapper ) QueryContext (ctx context.Context , query string , args []driver.NamedValue ) (driver.Rows , error ) {
167
167
done := c .lastUsage .Start ()
168
168
defer done ()
169
169
@@ -184,7 +184,7 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam
184
184
return c .cc .Query (ctx , query , params )
185
185
}
186
186
187
- func (c * conn ) ExecContext (ctx context.Context , query string , args []driver.NamedValue ) (driver.Result , error ) {
187
+ func (c * connWrapper ) ExecContext (ctx context.Context , query string , args []driver.NamedValue ) (driver.Result , error ) {
188
188
done := c .lastUsage .Start ()
189
189
defer done ()
190
190
@@ -196,15 +196,15 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name
196
196
return c .cc .Exec (ctx , query , params )
197
197
}
198
198
199
- func (c * conn ) GetDatabaseName () string {
199
+ func (c * connWrapper ) GetDatabaseName () string {
200
200
return c .connector .Name ()
201
201
}
202
202
203
- func (c * conn ) normalizePath (tableName string ) string {
203
+ func (c * connWrapper ) normalizePath (tableName string ) string {
204
204
return c .connector .pathNormalizer .NormalizePath (tableName )
205
205
}
206
206
207
- func (c * conn ) tableDescription (ctx context.Context , tableName string ) (d options.Description , _ error ) {
207
+ func (c * connWrapper ) tableDescription (ctx context.Context , tableName string ) (d options.Description , _ error ) {
208
208
d , err := retry .RetryWithResult (ctx , func (ctx context.Context ) (options.Description , error ) {
209
209
return internalTable .Session (c .cc .ID (), c .connector .balancer , config .New ()).DescribeTable (ctx , tableName )
210
210
}, retry .WithIdempotent (true ), retry .WithBudget (c .connector .retryBudget ), retry .WithTrace (c .connector .traceRetry ))
@@ -215,7 +215,7 @@ func (c *conn) tableDescription(ctx context.Context, tableName string) (d option
215
215
return d , nil
216
216
}
217
217
218
- func (c * conn ) GetColumns (ctx context.Context , tableName string ) (columns []string , _ error ) {
218
+ func (c * connWrapper ) GetColumns (ctx context.Context , tableName string ) (columns []string , _ error ) {
219
219
d , err := c .tableDescription (ctx , c .normalizePath (tableName ))
220
220
if err != nil {
221
221
return nil , xerrors .WithStackTrace (err )
@@ -228,7 +228,7 @@ func (c *conn) GetColumns(ctx context.Context, tableName string) (columns []stri
228
228
return columns , nil
229
229
}
230
230
231
- func (c * conn ) GetColumnType (ctx context.Context , tableName , columnName string ) (dataType string , _ error ) {
231
+ func (c * connWrapper ) GetColumnType (ctx context.Context , tableName , columnName string ) (dataType string , _ error ) {
232
232
d , err := c .tableDescription (ctx , c .normalizePath (tableName ))
233
233
if err != nil {
234
234
return "" , xerrors .WithStackTrace (err )
@@ -243,7 +243,7 @@ func (c *conn) GetColumnType(ctx context.Context, tableName, columnName string)
243
243
return "" , xerrors .WithStackTrace (fmt .Errorf ("column '%s' not exist in table '%s'" , columnName , tableName ))
244
244
}
245
245
246
- func (c * conn ) GetPrimaryKeys (ctx context.Context , tableName string ) ([]string , error ) {
246
+ func (c * connWrapper ) GetPrimaryKeys (ctx context.Context , tableName string ) ([]string , error ) {
247
247
d , err := c .tableDescription (ctx , c .normalizePath (tableName ))
248
248
if err != nil {
249
249
return nil , xerrors .WithStackTrace (err )
@@ -252,7 +252,7 @@ func (c *conn) GetPrimaryKeys(ctx context.Context, tableName string) ([]string,
252
252
return d .PrimaryKey , nil
253
253
}
254
254
255
- func (c * conn ) IsPrimaryKey (ctx context.Context , tableName , columnName string ) (ok bool , _ error ) {
255
+ func (c * connWrapper ) IsPrimaryKey (ctx context.Context , tableName , columnName string ) (ok bool , _ error ) {
256
256
d , err := c .tableDescription (ctx , c .normalizePath (tableName ))
257
257
if err != nil {
258
258
return false , xerrors .WithStackTrace (err )
@@ -267,7 +267,7 @@ func (c *conn) IsPrimaryKey(ctx context.Context, tableName, columnName string) (
267
267
return false , nil
268
268
}
269
269
270
- func (c * conn ) Version (_ context.Context ) (_ string , _ error ) {
270
+ func (c * connWrapper ) Version (_ context.Context ) (_ string , _ error ) {
271
271
const version = "default"
272
272
273
273
return version , nil
@@ -286,7 +286,7 @@ func isSysDir(databaseName, dirAbsPath string) bool {
286
286
return false
287
287
}
288
288
289
- func (c * conn ) getTables (ctx context.Context , absPath string , recursive , excludeSysDirs bool ) (
289
+ func (c * connWrapper ) getTables (ctx context.Context , absPath string , recursive , excludeSysDirs bool ) (
290
290
tables []string , _ error ,
291
291
) {
292
292
if excludeSysDirs && isSysDir (c .connector .Name (), absPath ) {
@@ -320,7 +320,7 @@ func (c *conn) getTables(ctx context.Context, absPath string, recursive, exclude
320
320
return tables , nil
321
321
}
322
322
323
- func (c * conn ) GetTables (ctx context.Context , folder string , recursive , excludeSysDirs bool ) (
323
+ func (c * connWrapper ) GetTables (ctx context.Context , folder string , recursive , excludeSysDirs bool ) (
324
324
tables []string , _ error ,
325
325
) {
326
326
absPath := c .normalizePath (folder )
@@ -349,7 +349,7 @@ func (c *conn) GetTables(ctx context.Context, folder string, recursive, excludeS
349
349
}
350
350
}
351
351
352
- func (c * conn ) GetIndexes (ctx context.Context , tableName string ) (indexes []string , _ error ) {
352
+ func (c * connWrapper ) GetIndexes (ctx context.Context , tableName string ) (indexes []string , _ error ) {
353
353
d , err := c .tableDescription (ctx , c .normalizePath (tableName ))
354
354
if err != nil {
355
355
return nil , xerrors .WithStackTrace (err )
@@ -360,7 +360,7 @@ func (c *conn) GetIndexes(ctx context.Context, tableName string) (indexes []stri
360
360
}), nil
361
361
}
362
362
363
- func (c * conn ) GetIndexColumns (ctx context.Context , tableName , indexName string ) (columns []string , _ error ) {
363
+ func (c * connWrapper ) GetIndexColumns (ctx context.Context , tableName , indexName string ) (columns []string , _ error ) {
364
364
d , err := c .tableDescription (ctx , c .normalizePath (tableName ))
365
365
if err != nil {
366
366
return nil , xerrors .WithStackTrace (err )
@@ -375,7 +375,7 @@ func (c *conn) GetIndexColumns(ctx context.Context, tableName, indexName string)
375
375
return xslices .Uniq (columns ), nil
376
376
}
377
377
378
- func (c * conn ) IsColumnExists (ctx context.Context , tableName , columnName string ) (columnExists bool , _ error ) {
378
+ func (c * connWrapper ) IsColumnExists (ctx context.Context , tableName , columnName string ) (columnExists bool , _ error ) {
379
379
d , err := c .tableDescription (ctx , c .normalizePath (tableName ))
380
380
if err != nil {
381
381
return false , xerrors .WithStackTrace (err )
@@ -390,10 +390,10 @@ func (c *conn) IsColumnExists(ctx context.Context, tableName, columnName string)
390
390
return false , nil
391
391
}
392
392
393
- func (c * conn ) IsTableExists (ctx context.Context , tableName string ) (tableExists bool , finalErr error ) {
393
+ func (c * connWrapper ) IsTableExists (ctx context.Context , tableName string ) (tableExists bool , finalErr error ) {
394
394
tableName = c .normalizePath (tableName )
395
395
onDone := trace .DatabaseSQLOnConnIsTableExists (c .connector .trace , & ctx ,
396
- stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*conn ).IsTableExists" ),
396
+ stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*connWrapper ).IsTableExists" ),
397
397
tableName ,
398
398
)
399
399
defer func () {
0 commit comments