interpreterintup.cpp
来自「MySQL数据库开发源码 值得一看哦」· C++ 代码 · 共 1,519 行 · 第 1/3 页
CPP
1,519 行
pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); break ; case 6: // exit_ok of the value matches pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 2); pOp->branch_eq(1, 2, 0); pOp->interpret_exit_nok(); pOp->def_label(0); if (opType == 3) { // For update transactions use incValue to update the tuple Uint32 val32 = 5; pOp->incValue("COL2", val32); } pOp->interpret_exit_ok(); break; case 7: // exit_nok if the value matches pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 6); pOp->branch_eq(1, 2, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); break; case 8: // exit_ok if the value matches pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 6); pOp->branch_ne(1, 2, 0); pOp->interpret_exit_nok(); pOp->def_label(0); if (opType == 3) { // For update transactions use incValue to update the tuple Uint32 val32 = 5; pOp->incValue("COL2", val32); } pOp->interpret_exit_ok(); break ; case 9: // exit_nok if the value matches pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 8); pOp->branch_eq(1, 2, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); break; case 10: // exit_ok if the value matches pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 8); pOp->branch_eq(1, 2, 0); pOp->interpret_exit_nok(); pOp->def_label(0); if (opType == 3) { // For update transactions use incValue to update the tuple Uint32 val32 = 5; pOp->incValue("COL2", val32); } pOp->interpret_exit_ok(); break; case 11: // exit_nok if the value matches pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 10); pOp->branch_eq(1, 2, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); break; case 12: pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 10); pOp->branch_eq(1, 2, 0); pOp->interpret_exit_nok(); pOp->def_label(0); if (opType == 3) { // For update transactions use incValue to update the tuple Uint32 val32 = 5; pOp->incValue("COL2", val32); } pOp->interpret_exit_ok(); break; case 13: pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 10); pOp->branch_eq(1, 2, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); break; case 14: // exit_nok if the value matches pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 12); pOp->branch_eq(1, 2, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); break; case 15: // exit_ok if the value matches pOp->read_attr("COL1", 1); pOp->load_const_u32(2, 12); pOp->branch_eq(1, 2, 0); pOp->interpret_exit_nok(); pOp->def_label(0); if (opType == 3) { // For update transactions use incValue to update the tuple Uint32 val32 = 5; pOp->incValue("COL2", val32); } pOp->interpret_exit_ok(); case 16: pOp->interpret_exit_nok(); ret_val = FAIL ; break; case 17: pOp->interpret_exit_ok(); break ; case 18: pOp->interpret_exit_nok(); ret_val = FAIL ; break ; default: break ; } return ret_val;}TTYPE t_incValue(int nCalls, NdbOperation* pOp) { ndbout << "Defining incValue test " << nCalls << ": "; TTYPE ret_val = NO_FAIL; Uint32 val32 = 5; Uint64 val64 = 5; Uint32 attr0 = 0; Uint32 attr1 = 1; Uint32 attr20 = 20; switch(nCalls) { case 1: pOp->incValue(attrName[1], val32); break; case 2: pOp->incValue(attr1, val32); break; case 3: pOp->incValue(attrName[1], val64); break; case 4: pOp->incValue(attr1, val64); break; case 5: pOp->incValue(attrName[0], val32); ret_val = FAIL ; break; case 6: pOp->incValue(attrName[0], val64); ret_val = FAIL ; break; case 7: pOp->incValue(attr0, val32); ret_val = FAIL ; break; case 8: pOp->incValue(attr0, val64); ret_val = FAIL ; break; case 9: pOp->incValue("COL20", val32); ret_val = FAIL ; break; case 10: pOp->incValue("COL20", val64); ret_val = FAIL ; break; case 11: pOp->incValue(attr20, val32); ret_val = FAIL ; break; case 12: pOp->incValue(attr20, val64); ret_val = FAIL ; break; default: break ; } return ret_val;}TTYPE t_subValue(int nCalls, NdbOperation* pOp) { ndbout << "Defining subValue test " << nCalls << ": "; Uint32 val32 = 5; Uint64 val64 = 5; Uint32 attr0 = 0; Uint32 attr1 = 1; Uint32 attr20 = 20; TTYPE ret_val = NO_FAIL; switch(nCalls) { case 1: pOp->subValue("COL2", val32); break; case 2: pOp->subValue(attr1, val32); break; case 3: pOp->subValue("COL0", val32); ret_val = FAIL ; break; case 4: pOp->subValue(attr0, val32); ret_val = FAIL ; break; case 5: pOp->subValue("COL20", val32); ret_val = FAIL ; break; case 6: pOp->subValue(attr20, val32); ret_val = FAIL ; break; case 7: // Missing implementation //pOp->subValue("COL20", val64); ndbout << "Missing implementation" << endl; break; case 8: // Missing implementation //pOp->subValue("COL2", val64); ndbout << "Missing implementation" << endl; break; case 9: // Missing implementation //pOp->subValue("COL0", val64); ndbout << "Missing implementation" << endl; break; case 10: // Missing implementation //pOp->subValue(attr1, val64); ndbout << "Missing implementation" << endl; break; case 11: // Missing implementation //pOp->subValue(attr0, val64); ndbout << "Missing implementation" << endl; break; case 12: // Missing implementation //pOp->subValue(attr20, val64); ndbout << "Missing implementation" << endl; break; default: break ; } return ret_val ;}TTYPE t_readAttr(int nCalls, NdbOperation* pOp) { ndbout << "Defining readAttr test " << nCalls << ": "; Uint32 attr0 = 0; Uint32 attr1 = 1; Uint32 attr20 = 20; TTYPE ret_val = NO_FAIL; switch(nCalls) { case 1: pOp->read_attr("COL1", 1); break; case 2: pOp->read_attr(attr1, 1); ret_val = NO_FAIL ; break; case 3: pOp->read_attr("COL0", 1); ret_val = NO_FAIL ; break; case 4: pOp->read_attr(attr0, 1); ret_val = NO_FAIL ; break; case 5: pOp->read_attr("COL20", 1); ret_val = FAIL ; break; case 6: pOp->read_attr(20, 1); ret_val = FAIL ; break; case 7: pOp->read_attr("COL1", 8); ret_val = FAIL ; break; case 8: pOp->read_attr(attr1, 8); ret_val = FAIL ; break; default: break ; } return ret_val;}TTYPE t_writeAttr(int nCalls, NdbOperation* pOp) { ndbout << "Defining writeAttr test " << nCalls << ": "; pOp->load_const_u32(1, 5); Uint32 attr0 = 0; Uint32 attr1 = 1; Uint32 attr20 = 20; TTYPE ret_val = NO_FAIL ; switch(nCalls) { case 1: pOp->write_attr("COL1", 1); break; case 2: pOp->write_attr(attr1, 1); break; case 3: pOp->write_attr("COL0", 1); ret_val = FAIL ; break; case 4: pOp->write_attr(attr0, 1); ret_val = FAIL ; break; case 5: pOp->write_attr("COL20", 1); ret_val = FAIL ; break; case 6: pOp->write_attr(20, 1); ret_val = FAIL ; break; case 7: pOp->write_attr("COL1", 2); ret_val = FAIL ; break; case 8: pOp->write_attr(attr1, 2); ret_val = FAIL ; break; case 9: pOp->write_attr("COL1", 8); ret_val = FAIL ; break; case 10: pOp->write_attr(attr1, 8); ret_val = FAIL ; break; default: break ; } return ret_val ;}TTYPE t_loadConst(int nCalls, NdbOperation* pOp, int opType) { ndbout << "Defining loadConst test " << nCalls << " : "; TTYPE ret_val = NO_FAIL ; switch(nCalls) { case 1: // Loading null into a valid register pOp->load_const_null(1); break; case 2: // Loading null into an invalid register pOp->load_const_null(8); ret_val = FAIL ; break; case 3: // Test loading a 32-bit value (>65536) pOp->load_const_u32(1, 65600); break; case 4: // Test loading a 16-bit value (<65536) pOp->load_const_u32(1, 65500); break; case 5: // Test by loading to a non-valid register pOp->load_const_u32(8, 2); ret_val = FAIL ; break; case 6: // Test by loading a 64-bit value pOp->load_const_u64(1, 65600); break; case 7: // Test by loading a non-valid register pOp->load_const_u64(8, 2); ret_val = FAIL ; break; case 8: // Test by loading a valid register with -1 pOp->load_const_u64(1, -1); ret_val = FAIL ; break; default: break ; } if (opType == 3 && FAIL != ret_val) pOp->write_attr("COL1", 1); return ret_val;}TTYPE t_branch(int nCalls, NdbOperation* pOp) { ndbout << "Defining branch test " << nCalls << ": " ; TTYPE ret_val = NO_FAIL ; Uint32 val32=5; pOp->read_attr("COL1", 1); pOp->load_const_u32(2, val32); switch(nCalls) { case 1: pOp->branch_eq(1, 2, 0); pOp->interpret_exit_nok(); pOp->def_label(0); pOp->interpret_exit_ok(); break; case 2: pOp->branch_eq(2, 1, 0); pOp->interpret_exit_nok(); pOp->def_label(0); pOp->interpret_exit_ok(); break; case 3: pOp->branch_eq(1, 1, 0); pOp->interpret_exit_nok(); pOp->def_label(0); pOp->interpret_exit_ok(); break; default: //ndbout << "t_branch: default case (no test case)" << endl ; //return ret_val = NO_FAIL ; break ; } return ret_val;}TTYPE t_branchIfNull(int nCalls, NdbOperation* pOp) { TTYPE ret_val = NO_FAIL; ndbout << "Defining branchIfNull test " << nCalls << ": " << endl ; switch(nCalls) { case 1: pOp->load_const_u32(1, 1); pOp->branch_ne_null(1, 0); pOp->interpret_exit_nok(); pOp->def_label(0); pOp->interpret_exit_ok(); break; case 2: pOp->load_const_null(1); pOp->branch_ne_null(1, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); break; case 3: pOp->load_const_u32(1, 1); pOp->branch_eq_null(1, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); break; case 4: pOp->load_const_null(1); pOp->branch_ne_null(1, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); break; case 5: // Test with a non-initialized register pOp->branch_ne_null(3, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); ret_val = FAIL ; break; case 6: // Test with a non-existing register pOp->branch_ne_null(8, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); ret_val = FAIL ; break; case 7: // Test with a non-initialized register pOp->branch_eq_null(3, 0); pOp->interpret_exit_ok(); pOp->def_label(0); pOp->interpret_exit_nok(); ret_val = FAIL ;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?