| 1103 | |
| 1104 | |
| 1105 | Validation::RTN Validation::corrupt(int err_code, const jrd_rel* relation, ...) |
| 1106 | { |
| 1107 | /************************************** |
| 1108 | * |
| 1109 | * c o r r u p t |
| 1110 | * |
| 1111 | ************************************** |
| 1112 | * |
| 1113 | * Functional description |
| 1114 | * Corruption has been detected. |
| 1115 | * |
| 1116 | **************************************/ |
| 1117 | fb_assert(sizeof(vdr_msg_table) / sizeof(vdr_msg_table[0]) == VAL_MAX_ERROR); |
| 1118 | |
| 1119 | Attachment* att = vdr_tdbb->getAttachment(); |
| 1120 | if (err_code < VAL_MAX_ERROR) |
| 1121 | vdr_err_counts[err_code]++; |
| 1122 | |
| 1123 | const TEXT* err_string = err_code < VAL_MAX_ERROR ? vdr_msg_table[err_code].msg: "Unknown error code"; |
| 1124 | |
| 1125 | string s; |
| 1126 | va_list ptr; |
| 1127 | const char* fn = att->att_filename.c_str(); |
| 1128 | |
| 1129 | va_start(ptr, relation); |
| 1130 | s.vprintf(err_string, ptr); |
| 1131 | va_end(ptr); |
| 1132 | |
| 1133 | #ifdef DEBUG_VAL_VERBOSE |
| 1134 | if (VAL_debug_level >= 0) |
| 1135 | { |
| 1136 | if (relation) |
| 1137 | { |
| 1138 | fprintf(stdout, "LOG:\tDatabase: %s\n\t%s in table %s (%d)\n", |
| 1139 | fn, s.c_str(), relation->rel_name.c_str(), relation->rel_id); |
| 1140 | } |
| 1141 | else |
| 1142 | fprintf(stdout, "LOG:\tDatabase: %s\n\t%s\n", fn, s.c_str()); |
| 1143 | } |
| 1144 | #endif |
| 1145 | if (vdr_msg_table[err_code].error) |
| 1146 | { |
| 1147 | ++vdr_errors; |
| 1148 | s.insert(0, "Error: "); |
| 1149 | } |
| 1150 | else |
| 1151 | { |
| 1152 | ++vdr_warns; |
| 1153 | s.insert(0, "Warning: "); |
| 1154 | } |
| 1155 | |
| 1156 | if (relation) |
| 1157 | { |
| 1158 | gds__log("Database: %s\n\t%s in table %s (%d)", |
| 1159 | fn, s.c_str(), relation->rel_name.c_str(), relation->rel_id); |
| 1160 | } |
| 1161 | else |
| 1162 | gds__log("Database: %s\n\t%s", fn, s.c_str()); |