/ Data Base indexed read routine for MYSQL access method. */ /
| 1075 | /* Data Base indexed read routine for MYSQL access method. */ |
| 1076 | /***********************************************************************/ |
| 1077 | bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr) |
| 1078 | { |
| 1079 | int oldlen = Query->GetLength(); |
| 1080 | PHC hc = To_Def->GetHandler(); |
| 1081 | |
| 1082 | if (!(kr || hc->end_range) || op == OP_NEXT || |
| 1083 | Mode == MODE_UPDATE || Mode == MODE_DELETE) { |
| 1084 | if (!kr && Mode == MODE_READX) { |
| 1085 | // This is a false indexed read |
| 1086 | m_Rc = Myc.ExecSQL(g, Query->GetStr()); |
| 1087 | Mode = MODE_READ; |
| 1088 | return (m_Rc == RC_FX) ? true : false; |
| 1089 | } // endif key |
| 1090 | |
| 1091 | return false; |
| 1092 | } else { |
| 1093 | if (Myc.m_Res) |
| 1094 | Myc.FreeResult(); |
| 1095 | |
| 1096 | if (hc->MakeKeyWhere(g, Query, op, '`', kr)) |
| 1097 | return true; |
| 1098 | |
| 1099 | if (To_CondFil) { |
| 1100 | if (To_CondFil->Idx != hc->active_index) { |
| 1101 | To_CondFil->Idx = hc->active_index; |
| 1102 | To_CondFil->Body= (char*)PlugSubAlloc(g, NULL, 0); |
| 1103 | *To_CondFil->Body= 0; |
| 1104 | |
| 1105 | if ((To_CondFil = hc->CheckCond(g, To_CondFil, Cond))) |
| 1106 | PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1); |
| 1107 | |
| 1108 | } // endif active_index |
| 1109 | |
| 1110 | if (To_CondFil) |
| 1111 | if (Query->Append(" AND ") || Query->Append(To_CondFil->Body)) { |
| 1112 | snprintf(g->Message, sizeof(g->Message), "Readkey: Out of memory"); |
| 1113 | return true; |
| 1114 | } // endif Append |
| 1115 | |
| 1116 | } // endif To_Condfil |
| 1117 | |
| 1118 | Mode = MODE_READ; |
| 1119 | } // endif's op |
| 1120 | |
| 1121 | if (trace(33)) |
| 1122 | htrc("MYSQL ReadKey: Query=%s\n", Query->GetStr()); |
| 1123 | |
| 1124 | m_Rc = Myc.ExecSQL(g, Query->GetStr()); |
| 1125 | Query->Truncate(oldlen); |
| 1126 | return (m_Rc == RC_FX) ? true : false; |
| 1127 | } // end of ReadKey |
| 1128 | |
| 1129 | /***********************************************************************/ |
| 1130 | /* Data Base read routine for MYSQL access method. */ |
nothing calls this directly
no test coverage detected