@@ -7456,6 +7456,89 @@ int testSlowConnectEnable(NDBT_Context *ctx, NDBT_Step *step) {
7456
7456
return result;
7457
7457
}
7458
7458
7459
+ int testSetVarbinaryWithSetValue (NDBT_Context *ctx, NDBT_Step *step) {
7460
+ // Test for bug#36989337 NDB Varbinary like columns fail with OO_SETVALUE
7461
+ Ndb *pNdb = GETNDB (step);
7462
+ const NdbDictionary::Table *pTab = ctx->getTab ();
7463
+
7464
+ // Run as a 'WIDE_2COL' testcase - do nothing for other tables
7465
+ if (strcmp (pTab->getName (), " WIDE_2COL" ) != 0 ) return NDBT_SKIPPED;
7466
+
7467
+ NdbTransaction *pTrans;
7468
+ NdbOperation *pOp;
7469
+ NdbDictionary::Dictionary *dict = pNdb->getDictionary ();
7470
+ char readbuf[NDB_MAX_TUPLE_SIZE_IN_WORDS << 2 ];
7471
+
7472
+ // Insert the test tuple ['xyz','abc']
7473
+ CHECKE (pTrans = pNdb->startTransaction (), (*pNdb));
7474
+ CHECKE (pOp = pTrans->getNdbOperation (pTab->getName ()), (*pTrans));
7475
+ CHECKE (pOp->insertTuple () == 0 , (*pOp));
7476
+ CHECKE (pOp->setValue (" KEY" , " \003\000 xyz" ) == 0 , (*pOp));
7477
+ CHECKE (pOp->setValue (" ATTR" , " \003\000 abc" ) == 0 , (*pOp));
7478
+ CHECKE (pTrans->execute (Commit) == 0 , (*pTrans));
7479
+ pTrans->close ();
7480
+
7481
+ // Read and verify ATTR value
7482
+ CHECKE (pTrans = pNdb->startTransaction (), (*pNdb));
7483
+ CHECKE (pOp = pTrans->getNdbOperation (pTab->getName ()), (*pTrans));
7484
+ CHECKE (pOp->readTuple () == 0 , (*pOp));
7485
+ CHECKE (pOp->equal (" KEY" , " \003\000 xyz" ) == 0 , (*pOp));
7486
+ CHECKE (pOp->getValue (" ATTR" , readbuf) != nullptr , (*pOp));
7487
+ CHECKE (pTrans->execute (NoCommit) == 0 , (*pTrans));
7488
+ CHECK (memcmp (readbuf, " \003\000 abc" , 5 ) == 0 );
7489
+ CHECKE (pTrans->getNdbError ().code == 0 , (*pTrans));
7490
+ CHECKE (pTrans->execute (Rollback) == 0 , (*pTrans));
7491
+ pTrans->close ();
7492
+
7493
+ // Insert the test tuple ['XYZ','ABC'] using NdbRecord and OO_SETVALUE
7494
+ // Whole key must be in record for writeTuple
7495
+ const NdbRecord *tabRec;
7496
+ NdbDictionary::RecordSpecification spec[1 ];
7497
+ spec->column =
7498
+ pTab->getColumn (" KEY" ); // Whole key must be in record for writeTuple
7499
+ spec->offset = 0 ;
7500
+ spec->nullbit_byte_offset = 0 ;
7501
+ spec->nullbit_bit_in_byte = 0 ;
7502
+ spec->column_flags = 0 ;
7503
+ tabRec = dict->createRecord (
7504
+ pTab, spec, 1 , sizeof (NdbDictionary::RecordSpecification),
7505
+ NdbDictionary::RecMysqldBitfield | NdbDictionary::RecPerColumnFlags);
7506
+ CHECKE (tabRec != nullptr , (*dict));
7507
+
7508
+ const Uint32 rowLen = NDB_MAX_TUPLE_SIZE_IN_WORDS << 2 ;
7509
+ char rowBuf[rowLen] = " \003\000 XYZ" ;
7510
+ unsigned char mask[1 ] = {(1 << 0 ) | (1 << 1 )};
7511
+
7512
+ NdbOperation::SetValueSpec setValueSpec[1 ];
7513
+ setValueSpec[0 ].column = pTab->getColumn (" ATTR" );
7514
+ setValueSpec[0 ].value = " \003\000 ABC" ;
7515
+
7516
+ NdbOperation::OperationOptions opts;
7517
+ opts.optionsPresent = NdbOperation::OperationOptions::OO_SETVALUE;
7518
+ opts.extraSetValues = setValueSpec;
7519
+ opts.numExtraSetValues = 1 ;
7520
+
7521
+ CHECKE (pTrans = pNdb->startTransaction (), (*pNdb));
7522
+ auto writeOp = pTrans->writeTuple (tabRec, rowBuf, tabRec, NULL , mask, &opts,
7523
+ sizeof (opts));
7524
+ CHECKE (writeOp != nullptr , (*pTrans));
7525
+ CHECKE (pTrans->execute (Commit) == 0 , (*pTrans)); // Failed by bug#xyz
7526
+ pTrans->close ();
7527
+
7528
+ // Read and verify ATTR value
7529
+ CHECKE (pTrans = pNdb->startTransaction (), (*pNdb));
7530
+ CHECKE (pOp = pTrans->getNdbOperation (pTab->getName ()), (*pTrans));
7531
+ CHECKE (pOp->readTuple () == 0 , (*pOp));
7532
+ CHECKE (pOp->equal (" KEY" , " \003\000 XYZ" ) == 0 , (*pOp));
7533
+ CHECKE (pOp->getValue (" ATTR" , readbuf) != nullptr , (*pOp));
7534
+ CHECKE (pTrans->execute (NoCommit) == 0 , (*pTrans));
7535
+ CHECK (memcmp (readbuf, " \003\000 ABC" , 5 ) == 0 );
7536
+ CHECKE (pTrans->execute (Rollback) == 0 , (*pTrans));
7537
+ pTrans->close ();
7538
+
7539
+ return NDBT_OK;
7540
+ }
7541
+
7459
7542
NDBT_TESTSUITE (testNdbApi);
7460
7543
TESTCASE (" MaxNdb" , " Create Ndb objects until no more can be created\n " ) {
7461
7544
INITIALIZER (runTestMaxNdb);
@@ -7835,6 +7918,9 @@ TESTCASE("DatabaseAndSchemaName",
7835
7918
TESTCASE (" TestSlowConnectEnable" , " Test behaviour with slow connection enale" ) {
7836
7919
STEP (testSlowConnectEnable);
7837
7920
}
7921
+ TESTCASE (" SetVarbinaryWithSetValue" , " Check OO_SETVALUE works with Varbinary" ) {
7922
+ STEP (testSetVarbinaryWithSetValue);
7923
+ }
7838
7924
7839
7925
NDBT_TESTSUITE_END (testNdbApi)
7840
7926
0 commit comments