static inline ibool check_constraints(rec_t *rec, table_def_t* table, ulint* offsets) { int i; if (debug) { printf("\nChecking constraints for a row (%s) at %p:", table->name, rec); ut_print_buf(stdout, rec, 100); } // Check every field for(i = 0; i < table->fields_count; i++) { // Get field value pointer and field length ulint len; byte *field = rec_get_nth_field(rec, offsets, i, &len); if (debug) printf("\n - field %s(addr = %p, len = %lu):", table->fields[i].name, field, len); // Skip null fields from type checks and fail if null is not allowed by data limits if (len == UNIV_SQL_NULL) { if (table->fields[i].has_limits && !table->fields[i].limits.can_be_null) { if (debug) printf("data can't be NULL"); return FALSE; } continue; } // Check limits if (!table->fields[i].has_limits) continue; if (!check_field_limits(&(table->fields[i]), field, len)) { if (debug) printf("LIMITS check failed(field = %p, len = %ld)!\n", field, len); return FALSE; } } if (debug) printf("\nRow looks OK!\n"); return TRUE; }
static inline ibool check_constraints(rec_t *rec, table_def_t* table, ulint* offsets) { int i; ulint len_sum = 0; if (debug) { printf("\nChecking constraints for a row (%s) at %p:", table->name, rec); ut_print_buf(stdout, rec, 100); } // Check every field for(i = 0; i < table->fields_count; i++) { // Get field value pointer and field length ulint len; byte *field = rec_get_nth_field(rec, offsets, i, &len); if (debug) printf("\n - field %s(addr = %p, len = %lu):", table->fields[i].name, field, len); if (len != UNIV_SQL_NULL) { len_sum += len; } else { if (!rec_offs_comp(offsets)) { len_sum += rec_get_nth_field_size(rec, i); } } // Skip null fields from type checks and fail if null is not allowed by data limits if (len == UNIV_SQL_NULL) { if (table->fields[i].has_limits && !table->fields[i].limits.can_be_null) { if (debug) printf("data can't be NULL"); return FALSE; } continue; } // Check limits if (!table->fields[i].has_limits) continue; if (!check_field_limits(&(table->fields[i]), field, len)) { if (debug) printf("LIMITS check failed(field = %p, len = %ld)!\n", field, len); return FALSE; } } // Why do we need this check? /* if (len_sum != rec_offs_data_size(offsets)) { fprintf(stderr, "\nInnoDB: Error: record len should be %lu, len %lu\n", (ulong) len_sum, (ulong) rec_offs_data_size(offsets)); return FALSE; } */ if (debug) printf("\nRow looks OK!\n"); return TRUE; }