MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
interpreterInTup.cpp
1 /*
2  Copyright (C) 2003-2006 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 /* ***************************************************
20  TEST OF INTERPRETER IN TUP
21  Verify that the interpreter in TUP is able to
22  handle and execute all the commands that the
23  NdbApi can isssue
24 
25  Arguments:
26 
27  operationType 1 openScanRead,
28  2 openScanExclusive,
29  3 interpretedUpdateTuple,
30  4 interpretedDirtyUpdate,
31  5 interpretedDeleteTuple
32  6 deleteTuple
33  7 insertTuple
34  8 updateTuple
35  9 writeTuple
36  10 readTuple
37  11 readTupleExclusive
38  12 simpleRead
39  13 dirtyRead
40  14 dirtyUpdate
41  15 dirtyWrite
42 
43  tupTest 1 exitMethods
44  2 incValue
45  3 subValue
46  4 readAttr
47  5 writeAttr
48  6 loadConst
49  7 branch
50  8 branchIfNull
51  9 addReg
52  10 subReg
53  11 subroutineWithBranchLabel
54 
55  scanTest Number of the test within each tupTest
56 
57 * *************************************************** */
58 
59 #include <NdbOut.hpp>
60 #include <NdbThread.h>
61 #include <NdbMutex.h>
62 #include <NdbApi.hpp>
63 #include <NdbSchemaCon.hpp>
64 #include <NDBT.hpp>
65 
66 #define MAXATTR 3
67 #define MAXTABLES 12
68 #define MAXSTRLEN 8
69 #define NUMBEROFRECORDS 1000
70 
71 typedef enum {
72  FAIL = 0,
73  NO_FAIL,
74  UNDEF
75 } TTYPE;
76 
77 inline void setAttrNames() ;
78 inline void setTableNames() ;
79 void error_handler(const NdbError & err, TTYPE);
80 void create_table(Ndb*);
81 void write_rows(Ndb*);
82 void update_rows(Ndb*, int, int);
83 void delete_rows(Ndb*, int, int);
84 void verify_deleted(Ndb*);
85 void read_and_verify_rows(Ndb*, bool pre);
86 void scan_rows(Ndb*, int, int, int);
87 TTYPE t_exitMethods(int, NdbOperation*, int);
88 TTYPE t_incValue(int, NdbOperation*);
89 TTYPE t_subValue(int, NdbOperation*);
90 TTYPE t_readAttr(int, NdbOperation*);
91 TTYPE t_writeAttr(int, NdbOperation*);
92 TTYPE t_loadConst(int, NdbOperation*, int);
93 TTYPE t_branch(int, NdbOperation*);
94 TTYPE t_branchIfNull(int, NdbOperation*);
95 TTYPE t_addReg(int, NdbOperation*);
96 TTYPE t_subReg(int, NdbOperation*);
97 TTYPE t_subroutineWithBranchLabel(int, NdbOperation*);
98 
99 char tableName[MAXSTRLEN+1];
100 char attrName[MAXATTR][MAXSTRLEN+1];
101 int attrValue[NUMBEROFRECORDS] = {0};
102 int pkValue[NUMBEROFRECORDS] = {0};
103 const int tAttributeSize = 1 ;
104 const int nRecords = 20 ;
105 int bTestPassed = 0;
106 
107 
108 
109 int main(int argc, const char** argv) {
110  ndb_init();
111 
112  int operationType = 0;
113  int tupTest = 0;
114  int scanTest = 0;
115 
116  Ndb* pNdb = new Ndb("TEST_DB");
117  pNdb->init();
118 
119  if (argc != 4 || sscanf(argv[1],"%d", &operationType) != 1) {
120  operationType = 1 ;
121  }
122  if (argc != 4 || sscanf(argv[2],"%d", &tupTest) != 1) {
123  tupTest = 1 ;
124  }
125  if (argc != 4 || sscanf(argv[3],"%d", &scanTest) != 1) {
126  scanTest = 1 ;
127  }
128 
129  ndbout << endl
130  << "Test the interpreter in TUP using SimpleTable with\n"
131  << nRecords << " records" << endl << endl ;
132 
133  if (pNdb->waitUntilReady(30) != 0) {
134  ndbout << "NDB is not ready" << endl;
135  return -1;
136  }
137 
138  // Init the pk and attr values.
139  for (int i = 0; i < NUMBEROFRECORDS; i ++)
140  pkValue[i] = attrValue[i] = i ;
141 
142  setAttrNames() ;
143  setTableNames() ;
144 
145  const void * p = NDBT_Table::discoverTableFromDb(pNdb, tableName);
146  if (p != 0){
147  create_table(pNdb);
148  }
149 
150  write_rows(pNdb);
151 
152  ndbout << endl << "Starting interpreter in TUP test." << endl << "Operation type: " ;
153 
154  switch(operationType) {
155  case 1:
156  ndbout << "openScanRead" << endl;
157  scan_rows(pNdb, operationType, tupTest, scanTest);
158  break;
159  case 2:
160  ndbout << "openScanExclusive" << endl;
161  scan_rows(pNdb, operationType, tupTest, scanTest);
162  break;
163  case 3:
164  ndbout << "interpretedUpdateTuple" << endl;
165  update_rows(pNdb, tupTest, operationType);
166  break;
167  case 4:
168  ndbout << "interpretedDirtyUpdate" << endl;
169  update_rows(pNdb, tupTest, operationType);
170  break;
171  case 5:
172  ndbout << "interpretedDeleteTuple" << endl;
173  delete_rows(pNdb, tupTest, operationType);
174  break;
175  case 6:
176  ndbout << "deleteTuple" << endl;
177  break;
178  case 7:
179  ndbout << "insertTuple" << endl;
180  break;
181  case 8:
182  ndbout << "updateTuple" << endl;
183  break;
184  case 9:
185  ndbout << "writeTuple" << endl;
186  break;
187  case 10:
188  ndbout << "readTuple" << endl;
189  break;
190  case 11:
191  ndbout << "readTupleExclusive" << endl;
192  break;
193  case 12:
194  ndbout << "simpleRead" << endl;
195  break;
196  case 13:
197  ndbout << "dirtyRead" << endl;
198  break;
199  case 14:
200  ndbout << "dirtyUpdate" << endl;
201  break;
202  case 15:
203  ndbout << "dirtyWrite" << endl;
204  break;
205  default:
206  break ;
207 
208  }
209 
210 // read_and_verify_rows(pNdb, false);
211 
212 // delete_rows(pNdb, 0, 0) ;
213  delete pNdb ;
214 
215  if (bTestPassed == 0) {
216  ndbout << "OK: test passed" << endl;
217  exit(0);
218  }else{
219  ndbout << "FAIL: test failed" << endl;
220  exit(-1);
221  }
222 }
223 
224 void error_handler(const NdbError & err, TTYPE type_expected) {
225 
226  ndbout << err << endl ;
227 
228  switch (type_expected){
229  case NO_FAIL:
230  bTestPassed = -1 ;
231  break ;
232  case FAIL:
233  ndbout << "OK: error is expected" << endl;
234  break ;
235  case UNDEF:
236  ndbout << "assumed OK: expected result undefined" << endl ;
237  break ;
238  default:
239  break ;
240  }
241 }
242 
243 void create_table(Ndb* pMyNdb) {
244 
245  /****************************************************************
246  * Create SimpleTable and Attributes.
247  *
248  * create table SimpleTable1(
249  * col0 int,
250  * col1 int not null,
251  * col2 int not null,
252  * col3 int not null ... 129)
253  *
254  ***************************************************************/
255 
256  int check = -1 ;
257  NdbSchemaOp *MySchemaOp = NULL ;
258 
259  ndbout << endl << "Creating " << tableName << " ... " << endl;
260 
261  NdbSchemaCon* MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pMyNdb);
262  if(!MySchemaTransaction) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL);
263 
264  MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
265  if( !MySchemaOp ) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL);
266  // Create table
267  check = MySchemaOp->createTable( tableName,
268  8, // Table size
269  TupleKey, // Key Type
270  40 // Nr of Pages
271  );
272 
273  if( check == -1 ) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL);
274 
275  ndbout << "Creating attributes ... " << flush;
276 
277  // Create first column, primary key
278  check = MySchemaOp->createAttribute( attrName[0],
279  TupleKey,
280  32,
281  1/*3, tAttributeSize */,
282  UnSigned,
283  MMBased,
284  NotNullAttribute );
285 
286  if( check == -1 ) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL);
287 
288  // create the 2 .. n columns.
289  for ( int i = 1; i < MAXATTR; i++ ){
290  check = MySchemaOp->createAttribute( attrName[i],
291  NoKey,
292  32,
293  tAttributeSize,
294  UnSigned,
295  MMBased,
296  NotNullAttribute );
297 
298  if( check == -1 ) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL);
299  }
300 
301  ndbout << "OK" << endl;
302 
303  if( MySchemaTransaction->execute() == -1 ) {
304  ndbout << MySchemaTransaction->getNdbError() << endl;
305  }else{
306  ndbout << tableName[0] << " created" << endl;
307  }
308 
309 
310  NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
311 
312  return;
313 
314 }
315 
316 
317 
318 void write_rows (Ndb* pMyNdb) {
319 
320  /****************************************************************
321  * Insert rows into SimpleTable
322  *
323  ***************************************************************/
324 
325  int check = -1 ;
326  int loop_count_ops = nRecords ;
327  NdbOperation *MyOperation = NULL ;
328  NdbConnection *MyTransaction = NULL ;
329 
330  ndbout << endl << "Writing records ..." << flush;
331 
332  for (int count=0 ; count < loop_count_ops ; count++){
333  MyTransaction = pMyNdb->startTransaction();
334  if (!MyTransaction) {
335  error_handler(pMyNdb->getNdbError(), NO_FAIL);
336  }//if
337 
338  MyOperation = MyTransaction->getNdbOperation(tableName);
339  if (!MyOperation) {
340  error_handler(pMyNdb->getNdbError(), NO_FAIL);
341  }//if
342 
343  check = MyOperation->writeTuple();
344  if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
345 
346  check = MyOperation->equal( attrName[0],(char*)&pkValue[count] );
347  if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
348 
349  // Update the columns, index column already ok.
350  for (int i = 1 ; i < MAXATTR; i++){
351  if ((i == 2) && (count > 4)){
352  check = MyOperation->setValue(attrName[i], (char*)&attrValue[count + 1]);
353  }else{
354  check = MyOperation->setValue(attrName[i], (char*)&attrValue[count]);
355  }
356  if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
357  }
358  check = MyTransaction->execute( Commit );
359  if(check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
360 
361  pMyNdb->closeTransaction(MyTransaction);
362  }
363  ndbout <<" \tOK" << endl;
364  return;
365 }
366 
367 void verify_deleted(Ndb* pMyNdb) {
368 
369  int check = -1 ;
370  int loop_count_ops = nRecords;
371  NdbOperation* pMyOperation = NULL ;
372 
373  ndbout << "Verifying deleted records..."<< flush;
374 
375  for (int count=0 ; count < loop_count_ops ; count++){
376 
377  NdbConnection* pMyTransaction = pMyNdb->startTransaction();
378  if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);
379 
380  pMyOperation = pMyTransaction->getNdbOperation(tableName);
381  if (!pMyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL);
382 
383  check = pMyOperation->readTuple();
384  if( check == -1 ) error_handler( pMyTransaction->getNdbError(), NO_FAIL);
385 
386  check = pMyOperation->equal( attrName[0],(char*)&pkValue[count] );
387  if( check == -1 ) error_handler( pMyTransaction->getNdbError(), NO_FAIL);
388 
389  // Exepect to receive an error
390  if(pMyTransaction->execute(Commit) != -1)
391  if( 626 == pMyTransaction->getNdbError().code){
392  ndbout << pMyTransaction->getNdbError() << endl ;
393  ndbout << "OK" << endl ;
394  }else{
395  error_handler(pMyTransaction->getNdbError(), NO_FAIL) ;
396  }
397 
398  pMyNdb->closeTransaction(pMyTransaction);
399  }
400 
401  ndbout << "OK" << endl;
402  return;
403 };
404 
405 void read_and_verify_rows(Ndb* pMyNdb, bool pre) {
406 
407  int check = -1 ;
408  int loop_count_ops = nRecords;
409  char expectedCOL1[NUMBEROFRECORDS] = {0} ;
410  char expectedCOL2[NUMBEROFRECORDS] = {0} ;
411  NdbConnection *pMyTransaction = NULL ;
412  NdbOperation *MyOp = NULL ;
413  NdbRecAttr* tTmp = NULL ;
414  int readValue[MAXATTR] = {0} ;
415 
416  ndbout << "Verifying records...\n"<< endl;
417 
418  for (int count=0 ; count < loop_count_ops ; count++){
419 
420  pMyTransaction = pMyNdb->startTransaction();
421  if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);
422 
423  MyOp = pMyTransaction->getNdbOperation(tableName);
424  if (!MyOp) error_handler( pMyTransaction->getNdbError(), NO_FAIL);
425 
426 
427  check = MyOp->readTuple();
428  if( check == -1 ) error_handler( MyOp->getNdbError(), NO_FAIL);
429 
430  check = MyOp->equal( attrName[0],(char*)&pkValue[count] );
431  if( check == -1 ) error_handler( MyOp->getNdbError(), NO_FAIL);
432 
433  for (int count_attributes = 1; count_attributes < MAXATTR; count_attributes++){
434 
435  tTmp = MyOp->getValue( (char*)attrName[count_attributes], (char*)&readValue[count_attributes] );
436  if(!tTmp) error_handler( MyOp->getNdbError(), NO_FAIL);
437  }
438 
439  if( pMyTransaction->execute( Commit ) == -1 ) {
440  error_handler(pMyTransaction->getNdbError(), NO_FAIL);
441  } else {
442  if (pre) {
443  expectedCOL1[count] = readValue[1];
444  expectedCOL2[count] = readValue[2];
445  }
446 
447  ndbout << attrName[1] << "\t " << readValue[1] << "\t "
448  << attrName[2] << "\t " << readValue[2] << endl;
449  }
450 
451  pMyNdb->closeTransaction(pMyTransaction);
452 
453  }
454 
455  ndbout << "\nOK\n" << endl;
456 
457  return;
458 
459 };
460 
461 TTYPE t_exitMethods(int nCalls, NdbOperation * pOp, int opType) {
462 
463  ndbout << "Defining exitMethods test " << nCalls << ": " << endl ;;
464  TTYPE ret_val = NO_FAIL ;
465 
466  switch(nCalls){
467  case 1: // exit_nok if attr value matches
468  pOp->read_attr("COL1", 1);
469  pOp->load_const_u32(2, 14);
470  pOp->branch_eq(1, 2, 0);
471  pOp->interpret_exit_ok() ;
472  pOp->def_label(0);
473  pOp->interpret_exit_nok();
474  break;
475  case 2: // exit_ok if attr value doesn't match
476  pOp->read_attr("COL1", 1);
477  pOp->load_const_u32(2, 14);
478  pOp->branch_eq(1, 2, 0);
479  pOp->interpret_exit_nok() ;
480  pOp->def_label(0);
481  if (opType == 3) {
482  // For update transactions use incValue to update the tuple
483  Uint32 val32 = 5;
484  pOp->incValue("COL2", val32);
485  }
486  pOp->interpret_exit_ok();
487  break ;
488  case 3: // Non-existent value (128): exit_ok if if the value matches
489  pOp->read_attr("COL1", 1);
490  pOp->load_const_u32(2, 128);
491  pOp->branch_eq(1, 2, 0);
492  pOp->interpret_exit_nok();
493  pOp->def_label(0);
494  pOp->interpret_exit_ok();
495  ret_val = FAIL ;
496  break;
497  case 4: // Non-existent value (128): exit_nok if the value matches
498  pOp->read_attr("COL1", 1);
499  pOp->load_const_u32(2, 128);
500  pOp->branch_eq(1, 2, 0);
501  pOp->interpret_exit_ok();
502  pOp->def_label(0);
503  pOp->interpret_exit_nok();
504  ret_val = FAIL ;
505  break;
506  case 5: // exit_nok of the value matches
507  pOp->read_attr("COL1", 1);
508  pOp->load_const_u32(2, 2);
509  pOp->branch_eq(1, 2, 0);
510  pOp->interpret_exit_ok();
511  pOp->def_label(0);
512  pOp->interpret_exit_nok();
513  break ;
514  case 6: // exit_ok of the value matches
515  pOp->read_attr("COL1", 1);
516  pOp->load_const_u32(2, 2);
517  pOp->branch_eq(1, 2, 0);
518  pOp->interpret_exit_nok();
519  pOp->def_label(0);
520  if (opType == 3) {
521  // For update transactions use incValue to update the tuple
522  Uint32 val32 = 5;
523  pOp->incValue("COL2", val32);
524  }
525  pOp->interpret_exit_ok();
526  break;
527  case 7: // exit_nok if the value matches
528  pOp->read_attr("COL1", 1);
529  pOp->load_const_u32(2, 6);
530  pOp->branch_eq(1, 2, 0);
531  pOp->interpret_exit_ok();
532  pOp->def_label(0);
533  pOp->interpret_exit_nok();
534  break;
535  case 8: // exit_ok if the value matches
536  pOp->read_attr("COL1", 1);
537  pOp->load_const_u32(2, 6);
538  pOp->branch_ne(1, 2, 0);
539  pOp->interpret_exit_nok();
540  pOp->def_label(0);
541  if (opType == 3) {
542  // For update transactions use incValue to update the tuple
543  Uint32 val32 = 5;
544  pOp->incValue("COL2", val32);
545  }
546  pOp->interpret_exit_ok();
547  break ;
548  case 9: // exit_nok if the value matches
549  pOp->read_attr("COL1", 1);
550  pOp->load_const_u32(2, 8);
551  pOp->branch_eq(1, 2, 0);
552  pOp->interpret_exit_ok();
553  pOp->def_label(0);
554  pOp->interpret_exit_nok();
555  break;
556  case 10: // exit_ok if the value matches
557  pOp->read_attr("COL1", 1);
558  pOp->load_const_u32(2, 8);
559  pOp->branch_eq(1, 2, 0);
560  pOp->interpret_exit_nok();
561  pOp->def_label(0);
562  if (opType == 3) {
563  // For update transactions use incValue to update the tuple
564  Uint32 val32 = 5;
565  pOp->incValue("COL2", val32);
566  }
567  pOp->interpret_exit_ok();
568  break;
569  case 11: // exit_nok if the value matches
570  pOp->read_attr("COL1", 1);
571  pOp->load_const_u32(2, 10);
572  pOp->branch_eq(1, 2, 0);
573  pOp->interpret_exit_ok();
574  pOp->def_label(0);
575  pOp->interpret_exit_nok();
576  break;
577  case 12:
578  pOp->read_attr("COL1", 1);
579  pOp->load_const_u32(2, 10);
580  pOp->branch_eq(1, 2, 0);
581  pOp->interpret_exit_nok();
582  pOp->def_label(0);
583  if (opType == 3) {
584  // For update transactions use incValue to update the tuple
585  Uint32 val32 = 5;
586  pOp->incValue("COL2", val32);
587  }
588  pOp->interpret_exit_ok();
589  break;
590  case 13:
591  pOp->read_attr("COL1", 1);
592  pOp->load_const_u32(2, 10);
593  pOp->branch_eq(1, 2, 0);
594  pOp->interpret_exit_ok();
595  pOp->def_label(0);
596  pOp->interpret_exit_nok();
597  break;
598  case 14: // exit_nok if the value matches
599  pOp->read_attr("COL1", 1);
600  pOp->load_const_u32(2, 12);
601  pOp->branch_eq(1, 2, 0);
602  pOp->interpret_exit_ok();
603  pOp->def_label(0);
604  pOp->interpret_exit_nok();
605  break;
606  case 15: // exit_ok if the value matches
607  pOp->read_attr("COL1", 1);
608  pOp->load_const_u32(2, 12);
609  pOp->branch_eq(1, 2, 0);
610  pOp->interpret_exit_nok();
611  pOp->def_label(0);
612  if (opType == 3) {
613  // For update transactions use incValue to update the tuple
614  Uint32 val32 = 5;
615  pOp->incValue("COL2", val32);
616  }
617  pOp->interpret_exit_ok();
618  case 16:
619  pOp->interpret_exit_nok();
620  ret_val = FAIL ;
621  break;
622  case 17:
623  pOp->interpret_exit_ok();
624  break ;
625  case 18:
626  pOp->interpret_exit_nok();
627  ret_val = FAIL ;
628  break ;
629  default:
630  break ;
631  }
632  return ret_val;
633 }
634 
635 TTYPE t_incValue(int nCalls, NdbOperation* pOp) {
636 
637  ndbout << "Defining incValue test " << nCalls << ": ";
638  TTYPE ret_val = NO_FAIL;
639 
640  Uint32 val32 = 5;
641  Uint64 val64 = 5;
642  Uint32 attr0 = 0;
643  Uint32 attr1 = 1;
644  Uint32 attr20 = 20;
645 
646  switch(nCalls) {
647  case 1:
648  pOp->incValue(attrName[1], val32);
649  break;
650  case 2:
651  pOp->incValue(attr1, val32);
652  break;
653  case 3:
654  pOp->incValue(attrName[1], val64);
655  break;
656  case 4:
657  pOp->incValue(attr1, val64);
658  break;
659  case 5:
660  pOp->incValue(attrName[0], val32);
661  ret_val = FAIL ;
662  break;
663  case 6:
664  pOp->incValue(attrName[0], val64);
665  ret_val = FAIL ;
666  break;
667  case 7:
668  pOp->incValue(attr0, val32);
669  ret_val = FAIL ;
670  break;
671  case 8:
672  pOp->incValue(attr0, val64);
673  ret_val = FAIL ;
674  break;
675  case 9:
676  pOp->incValue("COL20", val32);
677  ret_val = FAIL ;
678  break;
679  case 10:
680  pOp->incValue("COL20", val64);
681  ret_val = FAIL ;
682  break;
683  case 11:
684  pOp->incValue(attr20, val32);
685  ret_val = FAIL ;
686  break;
687  case 12:
688  pOp->incValue(attr20, val64);
689  ret_val = FAIL ;
690  break;
691  default:
692  break ;
693  }
694  return ret_val;
695 }
696 
697 TTYPE t_subValue(int nCalls, NdbOperation* pOp) {
698 
699  ndbout << "Defining subValue test " << nCalls << ": ";
700 
701  Uint32 val32 = 5;
702  Uint64 val64 = 5;
703  Uint32 attr0 = 0;
704  Uint32 attr1 = 1;
705  Uint32 attr20 = 20;
706 
707  TTYPE ret_val = NO_FAIL;
708 
709  switch(nCalls) {
710  case 1:
711  pOp->subValue("COL2", val32);
712  break;
713  case 2:
714  pOp->subValue(attr1, val32);
715  break;
716  case 3:
717  pOp->subValue("COL0", val32);
718  ret_val = FAIL ;
719  break;
720  case 4:
721  pOp->subValue(attr0, val32);
722  ret_val = FAIL ;
723  break;
724  case 5:
725  pOp->subValue("COL20", val32);
726  ret_val = FAIL ;
727  break;
728  case 6:
729  pOp->subValue(attr20, val32);
730  ret_val = FAIL ;
731  break;
732  case 7:
733  // Missing implementation
734  //pOp->subValue("COL20", val64);
735  ndbout << "Missing implementation" << endl;
736  break;
737  case 8:
738  // Missing implementation
739  //pOp->subValue("COL2", val64);
740  ndbout << "Missing implementation" << endl;
741  break;
742  case 9:
743  // Missing implementation
744  //pOp->subValue("COL0", val64);
745  ndbout << "Missing implementation" << endl;
746  break;
747  case 10:
748  // Missing implementation
749  //pOp->subValue(attr1, val64);
750  ndbout << "Missing implementation" << endl;
751  break;
752  case 11:
753  // Missing implementation
754  //pOp->subValue(attr0, val64);
755  ndbout << "Missing implementation" << endl;
756  break;
757  case 12:
758  // Missing implementation
759  //pOp->subValue(attr20, val64);
760  ndbout << "Missing implementation" << endl;
761  break;
762  default:
763  break ;
764  }
765  return ret_val ;
766 }
767 
768 TTYPE t_readAttr(int nCalls, NdbOperation* pOp) {
769 
770  ndbout << "Defining readAttr test " << nCalls << ": ";
771 
772  Uint32 attr0 = 0;
773  Uint32 attr1 = 1;
774  Uint32 attr20 = 20;
775  TTYPE ret_val = NO_FAIL;
776 
777  switch(nCalls) {
778  case 1:
779  pOp->read_attr("COL1", 1);
780  break;
781  case 2:
782  pOp->read_attr(attr1, 1);
783  ret_val = NO_FAIL ;
784  break;
785  case 3:
786  pOp->read_attr("COL0", 1);
787  ret_val = NO_FAIL ;
788  break;
789  case 4:
790  pOp->read_attr(attr0, 1);
791  ret_val = NO_FAIL ;
792  break;
793  case 5:
794  pOp->read_attr("COL20", 1);
795  ret_val = FAIL ;
796  break;
797  case 6:
798  pOp->read_attr(20, 1);
799  ret_val = FAIL ;
800  break;
801  case 7:
802  pOp->read_attr("COL1", 8);
803  ret_val = FAIL ;
804  break;
805  case 8:
806  pOp->read_attr(attr1, 8);
807  ret_val = FAIL ;
808  break;
809  default:
810  break ;
811  }
812  return ret_val;
813 }
814 
815 TTYPE t_writeAttr(int nCalls, NdbOperation* pOp) {
816 
817  ndbout << "Defining writeAttr test " << nCalls << ": ";
818 
819  pOp->load_const_u32(1, 5);
820 
821  Uint32 attr0 = 0;
822  Uint32 attr1 = 1;
823  Uint32 attr20 = 20;
824  TTYPE ret_val = NO_FAIL ;
825 
826  switch(nCalls) {
827  case 1:
828  pOp->write_attr("COL1", 1);
829  break;
830  case 2:
831  pOp->write_attr(attr1, 1);
832  break;
833  case 3:
834  pOp->write_attr("COL0", 1);
835  ret_val = FAIL ;
836  break;
837  case 4:
838  pOp->write_attr(attr0, 1);
839  ret_val = FAIL ;
840  break;
841  case 5:
842  pOp->write_attr("COL20", 1);
843  ret_val = FAIL ;
844  break;
845  case 6:
846  pOp->write_attr(20, 1);
847  ret_val = FAIL ;
848  break;
849  case 7:
850  pOp->write_attr("COL1", 2);
851  ret_val = FAIL ;
852  break;
853  case 8:
854  pOp->write_attr(attr1, 2);
855  ret_val = FAIL ;
856  break;
857  case 9:
858  pOp->write_attr("COL1", 8);
859  ret_val = FAIL ;
860  break;
861  case 10:
862  pOp->write_attr(attr1, 8);
863  ret_val = FAIL ;
864  break;
865  default:
866  break ;
867  }
868  return ret_val ;
869 }
870 
871 TTYPE t_loadConst(int nCalls, NdbOperation* pOp, int opType) {
872 
873  ndbout << "Defining loadConst test " << nCalls << " : ";
874  TTYPE ret_val = NO_FAIL ;
875 
876  switch(nCalls) {
877  case 1:
878  // Loading null into a valid register
879  pOp->load_const_null(1);
880  break;
881  case 2:
882  // Loading null into an invalid register
883  pOp->load_const_null(8);
884  ret_val = FAIL ;
885  break;
886  case 3:
887  // Test loading a 32-bit value (>65536)
888  pOp->load_const_u32(1, 65600);
889  break;
890  case 4:
891  // Test loading a 16-bit value (<65536)
892  pOp->load_const_u32(1, 65500);
893  break;
894  case 5:
895  // Test by loading to a non-valid register
896  pOp->load_const_u32(8, 2);
897  ret_val = FAIL ;
898  break;
899  case 6:
900  // Test by loading a 64-bit value
901  pOp->load_const_u64(1, 65600);
902  break;
903  case 7:
904  // Test by loading a non-valid register
905  pOp->load_const_u64(8, 2);
906  ret_val = FAIL ;
907  break;
908  case 8:
909  // Test by loading a valid register with -1
910  pOp->load_const_u64(1, -1);
911  ret_val = FAIL ;
912  break;
913 
914  default:
915  break ;
916  }
917 
918  if (opType == 3 && FAIL != ret_val)
919  pOp->write_attr("COL1", 1);
920  return ret_val;
921 }
922 
923 TTYPE t_branch(int nCalls, NdbOperation* pOp) {
924 
925  ndbout << "Defining branch test " << nCalls << ": " ;
926 
927  TTYPE ret_val = NO_FAIL ;
928  Uint32 val32=5;
929 
930  pOp->read_attr("COL1", 1);
931  pOp->load_const_u32(2, val32);
932 
933  switch(nCalls) {
934  case 1:
935  pOp->branch_eq(1, 2, 0);
936  pOp->interpret_exit_nok();
937  pOp->def_label(0);
938  pOp->interpret_exit_ok();
939  break;
940  case 2:
941  pOp->branch_eq(2, 1, 0);
942  pOp->interpret_exit_nok();
943  pOp->def_label(0);
944  pOp->interpret_exit_ok();
945  break;
946  case 3:
947  pOp->branch_eq(1, 1, 0);
948  pOp->interpret_exit_nok();
949  pOp->def_label(0);
950  pOp->interpret_exit_ok();
951  break;
952  default:
953  //ndbout << "t_branch: default case (no test case)" << endl ;
954  //return ret_val = NO_FAIL ;
955  break ;
956  }
957  return ret_val;
958 }
959 
960 TTYPE t_branchIfNull(int nCalls, NdbOperation* pOp) {
961 
962  TTYPE ret_val = NO_FAIL;
963  ndbout << "Defining branchIfNull test " << nCalls << ": " << endl ;
964 
965  switch(nCalls) {
966  case 1:
967  pOp->load_const_u32(1, 1);
968  pOp->branch_ne_null(1, 0);
969  pOp->interpret_exit_nok();
970  pOp->def_label(0);
971  pOp->interpret_exit_ok();
972  break;
973  case 2:
974  pOp->load_const_null(1);
975  pOp->branch_ne_null(1, 0);
976  pOp->interpret_exit_ok();
977  pOp->def_label(0);
978  pOp->interpret_exit_nok();
979  break;
980  case 3:
981  pOp->load_const_u32(1, 1);
982  pOp->branch_eq_null(1, 0);
983  pOp->interpret_exit_ok();
984  pOp->def_label(0);
985  pOp->interpret_exit_nok();
986  break;
987  case 4:
988  pOp->load_const_null(1);
989  pOp->branch_ne_null(1, 0);
990  pOp->interpret_exit_ok();
991  pOp->def_label(0);
992  pOp->interpret_exit_nok();
993  break;
994  case 5:
995  // Test with a non-initialized register
996  pOp->branch_ne_null(3, 0);
997  pOp->interpret_exit_ok();
998  pOp->def_label(0);
999  pOp->interpret_exit_nok();
1000  ret_val = FAIL ;
1001  break;
1002  case 6:
1003  // Test with a non-existing register
1004  pOp->branch_ne_null(8, 0);
1005  pOp->interpret_exit_ok();
1006  pOp->def_label(0);
1007  pOp->interpret_exit_nok();
1008  ret_val = FAIL ;
1009  break;
1010  case 7:
1011  // Test with a non-initialized register
1012  pOp->branch_eq_null(3, 0);
1013  pOp->interpret_exit_ok();
1014  pOp->def_label(0);
1015  pOp->interpret_exit_nok();
1016  ret_val = FAIL ;
1017  break;
1018  case 8:
1019  // Test with a non-existing register
1020  pOp->branch_ne_null(8, 0);
1021  pOp->interpret_exit_ok();
1022  pOp->def_label(0);
1023  pOp->interpret_exit_nok();
1024  ret_val = FAIL ;
1025  break;
1026  default:
1027  break ;
1028  }
1029 
1030  return ret_val;
1031 }
1032 
1033 TTYPE t_addReg(int nCalls, NdbOperation* pOp) {
1034 
1035  TTYPE ret_val = NO_FAIL ;
1036 
1037  ndbout << "Defining addReg test " << nCalls << ": ";
1038 
1039  pOp->load_const_u32(1, 65500);
1040  pOp->load_const_u32(2, 500);
1041  pOp->load_const_u64(3, 65600);
1042  pOp->load_const_u64(4, 95600);
1043 
1044  switch(nCalls) {
1045  case 1:
1046  pOp->add_reg(1, 2, 5);
1047  break;
1048  case 2:
1049  pOp->add_reg(1, 3, 5);
1050  break;
1051  case 3:
1052  pOp->add_reg(3, 1, 5);
1053  break;
1054  case 4:
1055  pOp->add_reg(3, 4, 5);
1056  break;
1057  case 5:
1058  pOp->add_reg(1, 6, 5);
1059  break;
1060  case 6:
1061  pOp->add_reg(6, 1, 5);
1062  break;
1063  case 7: // illegal register
1064  pOp->add_reg(1, 8, 5);
1065  ret_val = FAIL ;
1066  break;
1067  case 8: // another illegal register
1068  pOp->add_reg(8, 1, 5);
1069  ret_val = FAIL ;
1070  break;
1071  case 9: // and another one
1072  pOp->add_reg(1, 2, 8);
1073  ret_val = FAIL ;
1074  break;
1075  default:
1076  break ;
1077  }
1078  pOp->load_const_u32(7, 65000);
1079  pOp->branch_eq(5, 7, 0);
1080  pOp->interpret_exit_nok();
1081  pOp->def_label(0);
1082  pOp->interpret_exit_ok();
1083 
1084  return ret_val ;
1085 }
1086 
1087 TTYPE t_subReg(int nCalls, NdbOperation* pOp) {
1088 
1089  TTYPE ret_val = NO_FAIL ;
1090  ndbout << "Defining subReg test: " << nCalls << endl;
1091 
1092  pOp->load_const_u32(1, 65500);
1093  pOp->load_const_u32(2, 500);
1094  pOp->load_const_u64(3, 65600);
1095  pOp->load_const_u64(4, 95600);
1096 
1097  switch(nCalls) {
1098  case 1:
1099  pOp->sub_reg(1, 2, 5);
1100  pOp->load_const_u32(7, 65000);
1101  break;
1102  case 2:
1103  pOp->sub_reg(1, 3, 5);
1104  pOp->load_const_u64(7, (Uint64)-100);
1105  break;
1106  case 3:
1107  pOp->sub_reg(3, 1, 5);
1108  pOp->load_const_u64(7, (Uint64)100);
1109  break;
1110  case 4:
1111  pOp->sub_reg(3, 4, 5);
1112  pOp->load_const_u64(7, (Uint64)-30000);
1113  break;
1114  case 5:
1115  pOp->sub_reg(1, 6, 5);
1116  pOp->load_const_u64(7, 0);
1117  ret_val = FAIL ;
1118  break;
1119  case 6:
1120  pOp->sub_reg(6, 1, 5);
1121  pOp->load_const_u64(7, 0);
1122  ret_val = FAIL ;
1123  break;
1124  case 7:
1125  pOp->sub_reg(1, 8, 5);
1126  pOp->load_const_u64(7, 0);
1127  ret_val = FAIL ;
1128  break;
1129  case 8:
1130  pOp->sub_reg(8, 1, 5);
1131  pOp->load_const_u64(7, 0);
1132  ret_val = FAIL ;
1133  break;
1134  case 9:
1135  pOp->sub_reg(1, 2, 8);
1136  pOp->load_const_u32(7, (Uint32)65000);
1137  ret_val = FAIL;
1138  break;
1139  default:
1140  //ndbout << "t_subReg: default case (no test case)" << endl ;
1141  //return ret_val = NO_FAIL ;
1142  break ;
1143  }
1144  pOp->branch_eq(5, 7, 0);
1145  pOp->interpret_exit_nok() ;
1146  pOp->def_label(0);
1147  pOp->interpret_exit_ok() ;
1148 
1149  return ret_val;
1150 }
1151 
1152 TTYPE t_subroutineWithBranchLabel(int nCalls, NdbOperation* pOp) {
1153 
1154  TTYPE ret_val = NO_FAIL ;
1155  ndbout << "Defining subroutineWithBranchLabel test:" << nCalls << endl;
1156 
1157  pOp->load_const_u32(1, 65500);
1158  pOp->load_const_u32(2, 500);
1159  pOp->load_const_u64(3, 65600);
1160  pOp->load_const_u64(4, 95600);
1161  pOp->load_const_u32(7, 65000);
1162  pOp->call_sub(0) ;
1163 
1164  switch(nCalls) {
1165  case 1:
1166  pOp->def_subroutine(0) ;
1167  pOp->add_reg(1, 2, 5);
1168  break;
1169  case 2:
1170  pOp->def_subroutine(0) ;
1171  pOp->add_reg(1, 3, 5);
1172  break;
1173  case 3:
1174  pOp->def_subroutine(0) ;
1175  pOp->add_reg(3, 1, 5);
1176  break;
1177  case 4:
1178  pOp->def_subroutine(0) ;
1179  pOp->add_reg(3, 4, 5);
1180  break;
1181  case 5:
1182  pOp->def_subroutine(0) ;
1183  pOp->add_reg(1, 6, 5);
1184  break;
1185  case 6:
1186  pOp->def_subroutine(0) ;
1187  pOp->add_reg(6, 1, 5);
1188  break;
1189  case 7: // illegal register
1190  pOp->def_subroutine(0) ;
1191  pOp->add_reg(1, 8, 5);
1192  ret_val = FAIL ;
1193  break;
1194  case 8: // another illegal register
1195  pOp->def_subroutine(0) ;
1196  pOp->add_reg(8, 1, 5);
1197  ret_val = FAIL ;
1198  break;
1199  case 9: // and another one
1200  pOp->def_subroutine(0) ;
1201  pOp->add_reg(1, 2, 8);
1202  ret_val = FAIL ;
1203  break;
1204  case 10: // test subroutine nesting
1205  for(int sub = 0; sub < 25 ; ++sub){
1206  pOp->call_sub(sub) ;
1207  pOp->def_subroutine(sub + 1) ;
1208  pOp->interpret_exit_ok() ;
1209  pOp->ret_sub() ;
1210  }
1211  ret_val = FAIL ;
1212  default:
1213  break ;
1214  }
1215 
1216  pOp->branch_label(0) ;
1217  pOp->interpret_exit_nok() ;
1218  pOp->def_label(0) ;
1219  pOp->interpret_exit_ok() ;
1220  pOp->ret_sub() ;
1221 
1222  return ret_val ;
1223 }
1224 
1225 
1226 void scan_rows(Ndb* pMyNdb, int opType, int tupleType, int scanType) {
1227 
1228  int check = -1 ;
1229  int loop_count_ops = nRecords ;
1230  int eOf = -1 ;
1231  int readValue = 0 ;
1232  int readValue2 = 0 ;
1233  int scanCount = 0 ;
1234  TTYPE fail = NO_FAIL ;
1235 
1236  for (int count=0 ; count < loop_count_ops ; count++) {
1237  NdbConnection* MyTransaction = pMyNdb->startTransaction();
1238  if (!MyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);
1239 
1240  NdbOperation* MyOperation = MyTransaction->getNdbOperation(tableName);
1241  if (!MyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL);
1242 
1243  if (opType == 1)
1244  // Open for scan read, Creates the SCAN_TABREQ and if needed
1245  // SCAN_TABINFO signals.
1246  check = MyOperation->openScanRead(1);
1247  else if (opType == 2)
1248  // Open for scan with update of rows.
1249  check = MyOperation->openScanExclusive(1);
1250 
1251  // Create ATTRINFO signal(s) for interpreted program used for
1252  // defining search criteria and column values that should be returned.
1253 
1254  scanCount = count+1 ;
1255 
1256  switch(tupleType) {
1257  case 1:
1258  fail = t_exitMethods(scanCount, MyOperation, opType);
1259  break;
1260  case 2:
1261  fail = t_incValue(scanCount, MyOperation);
1262  break;
1263  case 3:
1264  fail = t_subValue(scanCount, MyOperation);
1265  break;
1266  case 4:
1267  fail = t_readAttr(scanCount, MyOperation);
1268  break;
1269  case 5:
1270  fail = t_writeAttr(scanCount, MyOperation);
1271  break;
1272  case 6:
1273  fail = t_loadConst(scanCount, MyOperation, opType);
1274  break;
1275  case 7:
1276  fail = t_branch(scanCount, MyOperation);
1277  break;
1278  case 8:
1279  fail = t_branchIfNull(scanCount, MyOperation);
1280  break;
1281  case 9:
1282  fail = t_addReg(scanCount, MyOperation);
1283  break;
1284  case 10:
1285  fail = t_subReg(scanCount, MyOperation);
1286  break;
1287  case 11:
1288  fail = t_subroutineWithBranchLabel(scanCount, MyOperation);
1289  break;
1290  default:
1291  break ;
1292  }
1293 
1294  if(11 != tupleType) MyOperation->getValue(attrName[1], (char*)&readValue);
1295 
1296  // Sends the SCAN_TABREQ, (SCAN_TABINFO) and ATTRINFO signals and then
1297  // reads the answer in TRANSID_AI. Confirmation is received through SCAN_TABCONF or
1298  // SCAN_TABREF if failure.
1299  check = MyTransaction->executeScan();
1300  if (check == -1) {
1301  //ndbout << endl << "executeScan returned: " << MyTransaction->getNdbError() << endl;
1302  error_handler(MyTransaction->getNdbError(), fail) ;
1303  pMyNdb->closeTransaction(MyTransaction);
1304  }else{
1305  // Sends the SCAN_NEXTREQ signal(s) and reads the answer in TRANS_ID signals.
1306  // SCAN_TABCONF or SCAN_TABREF is the confirmation.
1307  while ((eOf = MyTransaction->nextScanResult()) == 0) {
1308  ndbout << readValue <<"; ";
1309  // Here we call takeOverScanOp for update of the tuple.
1310  }
1311  ndbout << endl ;
1312 
1313  pMyNdb->closeTransaction(MyTransaction);
1314  if (eOf == -1) {
1315  ndbout << endl << "nextScanResult returned: "<< MyTransaction->getNdbError() << endl;
1316  } else {
1317  ndbout << "OK" << endl;
1318  }
1319  }
1320  }
1321  return;
1322 
1323 };
1324 
1325 
1326 void update_rows(Ndb* pMyNdb, int tupleType, int opType) {
1327  /****************************************************************
1328  * Update rows in SimpleTable
1329  * Only updates the first 3 cols.
1330  ***************************************************************/
1331 
1332  int check = -1 ;
1333  int loop_count_ops = nRecords ;
1334  int readValue[MAXATTR] = {0} ;
1335  TTYPE ret_val = NO_FAIL ;
1336  NdbConnection *MyTransaction = NULL ;
1337  NdbOperation *MyOperation = NULL ;
1338 
1339  ndbout << "Updating records ..." << endl << endl;
1340 
1341  for (int count=0 ; count < loop_count_ops ; count++){
1342 
1343  MyTransaction = pMyNdb->startTransaction();
1344  if (!MyTransaction) {
1345  error_handler(pMyNdb->getNdbError(), NO_FAIL);
1346  return;
1347  }//if
1348 
1349  MyOperation = MyTransaction->getNdbOperation(tableName);
1350  if (MyOperation == NULL) {
1351  error_handler(pMyNdb->getNdbError(), NO_FAIL);
1352  return;
1353  }//if
1354 
1355  // if (operationType == 3)
1356  check = MyOperation->interpretedUpdateTuple();
1357  // else if (operationType == 4)
1358  // check = MyOperation->interpretedDirtyUpdate();
1359  if( check == -1 )
1360  error_handler(MyTransaction->getNdbError(), NO_FAIL);
1361 
1362  check = MyOperation->equal( attrName[0], (char*)&pkValue[count] );
1363  if( check == -1 )
1364  error_handler(MyTransaction->getNdbError(), NO_FAIL);
1365 
1366  switch(tupleType) {
1367  case 1:
1368  ret_val = t_exitMethods(count+1, MyOperation, opType);
1369  break;
1370  case 2:
1371  ret_val = t_incValue(count+1, MyOperation);
1372  break;
1373  case 3:
1374  ret_val = t_subValue(count+1, MyOperation);
1375  break;
1376  case 4:
1377  ret_val = t_readAttr(count+1, MyOperation);
1378  break;
1379  case 5:
1380  ret_val = t_writeAttr(count+1, MyOperation);
1381  break;
1382  case 6:
1383  ret_val = t_loadConst(count+1, MyOperation, opType);
1384  break;
1385  case 7:
1386  ret_val = t_branch(count+1, MyOperation);
1387  break;
1388  case 8:
1389  ret_val = t_branchIfNull(count+1, MyOperation);
1390  break;
1391  case 9:
1392  ret_val = t_addReg(count+1, MyOperation);
1393  break;
1394  case 10:
1395  ret_val = t_subReg(count+1, MyOperation);
1396  break;
1397  case 11:
1398  ret_val = t_subroutineWithBranchLabel(count+1, MyOperation);
1399  break;
1400  default:
1401  break ;
1402  }
1403 
1404  MyOperation->getValue("COL1", (char*)&readValue);
1405 
1406  if (MyTransaction->execute( Commit ) == -1 ) {
1407  error_handler(MyTransaction->getNdbError(), ret_val);
1408  }else if (NO_FAIL == ret_val ) {
1409  ndbout << "OK" << endl;
1410  } else {
1411  bTestPassed = -1;
1412  ndbout << "Test passed when expected to fail" << endl;
1413  }//if
1414  pMyNdb->closeTransaction(MyTransaction);
1415 
1416  }
1417 
1418  ndbout << "Finished updating records" << endl;
1419  return;
1420 };
1421 
1422 void delete_rows(Ndb* pMyNdb, int tupleTest, int opType) {
1423 
1424  /****************************************************************
1425  * Delete rows from SimpleTable
1426  *
1427  ***************************************************************/
1428 
1429  int check = 1 ;
1430  int loop_count_ops = nRecords ;
1431  int readValue[MAXATTR] = {0};
1432  NdbConnection *MyTransaction = NULL ;
1433  NdbOperation *MyOperation = NULL ;
1434  TTYPE ret_val = NO_FAIL ;
1435 
1436  ndbout << "Deleting records ..."<< endl << endl;
1437 
1438  for (int count=0 ; count < loop_count_ops ; count++) {
1439 
1440  MyTransaction = pMyNdb->startTransaction();
1441  if (!MyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL) ;
1442 
1443  MyOperation = MyTransaction->getNdbOperation(tableName);
1444  if (!MyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL) ;
1445 
1446  check = MyOperation->interpretedDeleteTuple();
1447  if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL) ;
1448 
1449  check = MyOperation->equal( attrName[0], (char*)&pkValue[count] );
1450  if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL) ;
1451 
1452  switch(tupleTest) {
1453  case 1:
1454  ret_val = t_exitMethods(count+1, MyOperation, opType);
1455  break;
1456  case 2:
1457  ret_val = t_incValue(count+1, MyOperation);
1458  break;
1459  case 3:
1460  ret_val = t_subValue(count+1, MyOperation);
1461  break;
1462  case 4:
1463  ret_val = t_readAttr(count+1, MyOperation);
1464  break;
1465  case 5:
1466  ret_val = t_writeAttr(count+1, MyOperation);
1467  break;
1468  case 6:
1469  ret_val = t_loadConst(count+1, MyOperation, opType);
1470  break;
1471  case 7:
1472  ret_val = t_branch(count+1, MyOperation);
1473  break;
1474  case 8:
1475  ret_val = t_branchIfNull(count+1, MyOperation);
1476  break;
1477  case 9:
1478  ret_val = t_addReg(count+1, MyOperation);
1479  break;
1480  case 10:
1481  ret_val = t_subReg(count+1, MyOperation);
1482  break;
1483  case 11:
1484  ret_val = t_subroutineWithBranchLabel(count+1, MyOperation);
1485  break;
1486  default:
1487  break ;
1488  }
1489 
1490  if(11 != tupleTest)MyOperation->getValue(attrName[1], (char*)&readValue) ;
1491 
1492  if (MyTransaction->execute( Commit ) == -1 ) {
1493  error_handler(MyTransaction->getNdbError(), ret_val);
1494  } else if (NO_FAIL == ret_val /*|| UNDEF == ret_val*/ ) {
1495  ndbout << "OK" << endl;
1496  } else {
1497  bTestPassed = -1;
1498  ndbout << "Test passed when expected to fail" << endl;
1499  }//if
1500  ndbout << endl;
1501  pMyNdb->closeTransaction(MyTransaction);
1502  }
1503 
1504  ndbout << "Finished deleting records" << endl;
1505  return;
1506 
1507 };
1508 
1509 
1510 inline void setAttrNames(){
1511  for (int i = 0; i < MAXATTR; i++){
1512  BaseString::snprintf(attrName[i], MAXSTRLEN, "COL%d", i);
1513  }
1514 }
1515 
1516 
1517 inline void setTableNames(){
1518  BaseString::snprintf(tableName, MAXSTRLEN, "TAB1");
1519 }
1520