@@ -77,6 +77,7 @@ func TestQueries(t *testing.T) {
77
77
sqltypes .NULL ,
78
78
},
79
79
},
80
+ RowsAffected : 2 ,
80
81
})
81
82
82
83
// Typicall Select with TYPE_AND_NAME.
@@ -179,6 +180,7 @@ func TestQueries(t *testing.T) {
179
180
sqltypes .NULL ,
180
181
},
181
182
},
183
+ RowsAffected : 2 ,
182
184
})
183
185
184
186
// Typicall Select with TYPE_AND_NAME.
@@ -198,6 +200,7 @@ func TestQueries(t *testing.T) {
198
200
sqltypes .MakeTrusted (querypb .Type_VARCHAR , []byte ("nice name" )),
199
201
},
200
202
},
203
+ RowsAffected : 2 ,
201
204
})
202
205
203
206
// Typicall Select with TYPE_ONLY.
@@ -215,6 +218,7 @@ func TestQueries(t *testing.T) {
215
218
sqltypes .MakeTrusted (querypb .Type_INT64 , []byte ("20" )),
216
219
},
217
220
},
221
+ RowsAffected : 2 ,
218
222
})
219
223
220
224
// Typicall Select with ALL.
@@ -230,7 +234,10 @@ func TestQueries(t *testing.T) {
230
234
ColumnLength : 0x80020304 ,
231
235
Charset : 0x1234 ,
232
236
Decimals : 36 ,
233
- Flags : 16387 , // NOT_NULL_FLAG, PRI_KEY_FLAG, PART_KEY_FLAG
237
+ Flags : uint32 (querypb .MySqlFlag_NOT_NULL_FLAG |
238
+ querypb .MySqlFlag_PRI_KEY_FLAG |
239
+ querypb .MySqlFlag_PART_KEY_FLAG |
240
+ querypb .MySqlFlag_NUM_FLAG ),
234
241
},
235
242
},
236
243
Rows : [][]sqltypes.Value {
@@ -244,6 +251,7 @@ func TestQueries(t *testing.T) {
244
251
sqltypes .MakeTrusted (querypb .Type_INT64 , []byte ("30" )),
245
252
},
246
253
},
254
+ RowsAffected : 3 ,
247
255
})
248
256
}
249
257
@@ -313,8 +321,8 @@ func checkQueryInternal(t *testing.T, query string, sConn, cConn *Conn, result *
313
321
if ! reflect .DeepEqual (got , & expected ) {
314
322
for i , f := range got .Fields {
315
323
if ! reflect .DeepEqual (f , expected .Fields [i ]) {
316
- t .Errorf ("Got field(%v) = %v" , i , f )
317
- t .Errorf ("Expected field(%v) = %v" , i , expected .Fields [i ])
324
+ t .Logf ("Got field(%v) = %v" , i , f )
325
+ t .Logf ("Expected field(%v) = %v" , i , expected .Fields [i ])
318
326
}
319
327
}
320
328
t .Fatalf ("ExecuteFetch(wantfields=%v) returned:\n %v\n But was expecting:\n %v" , wantfields , got , expected )
@@ -409,12 +417,16 @@ func testQueriesWithRealDatabase(t *testing.T, params *sqldb.ConnParams) {
409
417
}
410
418
411
419
// Try a simple DDL.
412
- if _ , err := conn .ExecuteFetch ("create table a(id int, name varchar(128), primary key(id))" , 0 , false ); err != nil {
420
+ result , err := conn .ExecuteFetch ("create table a(id int, name varchar(128), primary key(id))" , 0 , false )
421
+ if err != nil {
413
422
t .Fatalf ("create table failed: %v" , err )
414
423
}
424
+ if result .RowsAffected != 0 {
425
+ t .Errorf ("create table returned RowsAffected %v, was expecting 0" , result .RowsAffected )
426
+ }
415
427
416
428
// Try a simple insert.
417
- result , err : = conn .ExecuteFetch ("insert into a(id, name) values(10, 'nice name')" , 1000 , true )
429
+ result , err = conn .ExecuteFetch ("insert into a(id, name) values(10, 'nice name')" , 1000 , true )
418
430
if err != nil {
419
431
t .Fatalf ("insert failed: %v" , err )
420
432
}
@@ -440,7 +452,8 @@ func testQueriesWithRealDatabase(t *testing.T, params *sqldb.ConnParams) {
440
452
Charset : CharacterSetBinary ,
441
453
Flags : uint32 (querypb .MySqlFlag_NOT_NULL_FLAG |
442
454
querypb .MySqlFlag_PRI_KEY_FLAG |
443
- querypb .MySqlFlag_PART_KEY_FLAG ),
455
+ querypb .MySqlFlag_PART_KEY_FLAG |
456
+ querypb .MySqlFlag_NUM_FLAG ),
444
457
},
445
458
{
446
459
Name : "name" ,
@@ -459,6 +472,7 @@ func testQueriesWithRealDatabase(t *testing.T, params *sqldb.ConnParams) {
459
472
sqltypes .MakeTrusted (querypb .Type_VARCHAR , []byte ("nice name" )),
460
473
},
461
474
},
475
+ RowsAffected : 1 ,
462
476
}
463
477
if ! reflect .DeepEqual (result , expectedResult ) {
464
478
// MySQL 5.7 is adding the NO_DEFAULT_VALUE_FLAG to Flags.
@@ -470,10 +484,13 @@ func testQueriesWithRealDatabase(t *testing.T, params *sqldb.ConnParams) {
470
484
471
485
// Insert a few rows.
472
486
for i := 0 ; i < 100 ; i ++ {
473
- _ , err := conn .ExecuteFetch (fmt .Sprintf ("insert into a(id, name) values(%v, 'nice name %v')" , 1000 + i , i ), 1000 , true )
487
+ result , err := conn .ExecuteFetch (fmt .Sprintf ("insert into a(id, name) values(%v, 'nice name %v')" , 1000 + i , i ), 1000 , true )
474
488
if err != nil {
475
489
t .Fatalf ("ExecuteFetch(%v) failed: %v" , i , err )
476
490
}
491
+ if result .RowsAffected != 1 {
492
+ t .Errorf ("insert into returned RowsAffected %v, was expecting 1" , result .RowsAffected )
493
+ }
477
494
}
478
495
479
496
// And use a streaming query to read them back.
@@ -482,9 +499,13 @@ func testQueriesWithRealDatabase(t *testing.T, params *sqldb.ConnParams) {
482
499
readRowsUsingStream (t , conn , 101 )
483
500
484
501
// And drop the table.
485
- if _ , err := conn .ExecuteFetch ("drop table a" , 0 , false ); err != nil {
502
+ result , err = conn .ExecuteFetch ("drop table a" , 0 , false )
503
+ if err != nil {
486
504
t .Fatalf ("drop table failed: %v" , err )
487
505
}
506
+ if result .RowsAffected != 0 {
507
+ t .Errorf ("insert into returned RowsAffected %v, was expecting 0" , result .RowsAffected )
508
+ }
488
509
}
489
510
490
511
func readRowsUsingStream (t * testing.T , conn * Conn , expectedCount int ) {
@@ -506,7 +527,8 @@ func readRowsUsingStream(t *testing.T, conn *Conn, expectedCount int) {
506
527
Charset : CharacterSetBinary ,
507
528
Flags : uint32 (querypb .MySqlFlag_NOT_NULL_FLAG |
508
529
querypb .MySqlFlag_PRI_KEY_FLAG |
509
- querypb .MySqlFlag_PART_KEY_FLAG ),
530
+ querypb .MySqlFlag_PART_KEY_FLAG |
531
+ querypb .MySqlFlag_NUM_FLAG ),
510
532
},
511
533
{
512
534
Name : "name" ,
0 commit comments