@@ -150,6 +150,47 @@ func BenchmarkClientSerialSQL(b *testing.B) {
150
150
}
151
151
}
152
152
153
+ func BenchmarkClientSerialSQLPrepared (b * testing.B ) {
154
+ // Tarantool supports SQL since version 2.0.0
155
+ isLess , err := test_helpers .IsTarantoolVersionLess (2 , 0 , 0 )
156
+ if err != nil {
157
+ b .Fatal ("Could not check the Tarantool version" )
158
+ }
159
+ if isLess {
160
+ b .Skip ()
161
+ }
162
+
163
+ conn , err := Connect (server , opts )
164
+ if err != nil {
165
+ b .Errorf ("Failed to connect: %s" , err )
166
+ return
167
+ }
168
+ defer conn .Close ()
169
+
170
+ spaceNo := 519
171
+ _ , err = conn .Replace (spaceNo , []interface {}{uint (1111 ), "hello" , "world" })
172
+ if err != nil {
173
+ b .Errorf ("Failed to replace: %s" , err )
174
+ }
175
+
176
+ res , err := conn .Prepare ("SELECT NAME0,NAME1,NAME2 FROM SQL_TEST WHERE NAME0=?" )
177
+ if err != nil {
178
+ b .Fatalf ("failed to prepare statement: %s" , err )
179
+ }
180
+ if res .Code != 0 {
181
+ b .Fatalf ("failed to prepare statement: %s" , err )
182
+ }
183
+
184
+ b .ResetTimer ()
185
+ for i := 0 ; i < b .N ; i ++ {
186
+ _ , err := conn .Execute (res .StmtID , []interface {}{uint (1111 )})
187
+ if err != nil {
188
+ b .Errorf ("Select failed: %s" , err .Error ())
189
+ break
190
+ }
191
+ }
192
+ }
193
+
153
194
func BenchmarkClientFuture (b * testing.B ) {
154
195
var err error
155
196
@@ -483,6 +524,49 @@ func BenchmarkClientParallelSQL(b *testing.B) {
483
524
})
484
525
}
485
526
527
+ func BenchmarkClientParallelSQLPrepared (b * testing.B ) {
528
+ // Tarantool supports SQL since version 2.0.0
529
+ isLess , err := test_helpers .IsTarantoolVersionLess (2 , 0 , 0 )
530
+ if err != nil {
531
+ b .Fatal ("Could not check the Tarantool version" )
532
+ }
533
+ if isLess {
534
+ b .Skip ()
535
+ }
536
+
537
+ conn , err := Connect (server , opts )
538
+ if err != nil {
539
+ b .Errorf ("No connection available" )
540
+ return
541
+ }
542
+ defer conn .Close ()
543
+
544
+ spaceNo := 519
545
+ _ , err = conn .Replace (spaceNo , []interface {}{uint (1111 ), "hello" , "world" })
546
+ if err != nil {
547
+ b .Errorf ("No connection available" )
548
+ }
549
+
550
+ res , err := conn .Prepare ("SELECT NAME0,NAME1,NAME2 FROM SQL_TEST WHERE NAME0=?" )
551
+ if err != nil {
552
+ b .Fatalf ("failed to prepare statement: %s" , err )
553
+ }
554
+ if res .Code != 0 {
555
+ b .Fatalf ("failed to prepare statement: %s" , err )
556
+ }
557
+
558
+ b .ResetTimer ()
559
+ b .RunParallel (func (pb * testing.PB ) {
560
+ for pb .Next () {
561
+ _ , err := conn .Execute (res .StmtID , []interface {}{uint (1111 )})
562
+ if err != nil {
563
+ b .Errorf ("Select failed: %s" , err .Error ())
564
+ break
565
+ }
566
+ }
567
+ })
568
+ }
569
+
486
570
///////////////////
487
571
488
572
func TestClient (t * testing.T ) {
@@ -1271,6 +1355,41 @@ func TestStressSQL(t *testing.T) {
1271
1355
}
1272
1356
}
1273
1357
1358
+ func TestPreparedStmt (t * testing.T ) {
1359
+ // Tarantool supports SQL since version 2.0.0
1360
+ isLess , err := test_helpers .IsTarantoolVersionLess (2 , 0 , 0 )
1361
+ if err != nil {
1362
+ t .Fatal ("Could not check the Tarantool version" )
1363
+ }
1364
+ if isLess {
1365
+ t .Skip ()
1366
+ }
1367
+
1368
+ var conn * Connection
1369
+
1370
+ conn , err = Connect (server , opts )
1371
+ if err != nil {
1372
+ t .Fatalf ("Failed to connect: %s" , err .Error ())
1373
+ }
1374
+ if conn == nil {
1375
+ t .Fatal ("conn is nil after Connect" )
1376
+ }
1377
+ defer conn .Close ()
1378
+
1379
+ res , err := conn .Prepare (selectPosQuery2 )
1380
+ if err != nil {
1381
+ t .Fatalf ("failed to prepare request: %s" , err )
1382
+ }
1383
+
1384
+ res2 , err := conn .Execute (res .StmtID , []interface {}{1 , "test" })
1385
+ if err != nil {
1386
+ t .Fatalf ("failed to execute with prepared statement: %s" , err )
1387
+ }
1388
+ if res2 .Code != 0 {
1389
+ t .Fatalf ("Failed to execute: code error %d" , res .Code )
1390
+ }
1391
+ }
1392
+
1274
1393
func TestSchema (t * testing.T ) {
1275
1394
var err error
1276
1395
var conn * Connection
0 commit comments