84         node->ins_type = ins_type;
 
   86         node->
state = INS_NODE_SET_IX_LOCK;
 
   97         node->magic_n = INS_NODE_MAGIC_N;
 
  106 ins_node_create_entry_list(
 
  113         ut_ad(node->entry_sys_heap);
 
  121         for (index = dict_table_get_first_index(node->
table);
 
  123              index = dict_table_get_next_index(index)) {
 
  126                         node->
row, NULL, index, node->entry_sys_heap);
 
  136 row_ins_alloc_sys_fields(
 
  149         heap = node->entry_sys_heap;
 
  151         ut_ad(row && table && heap);
 
  156         col = dict_table_get_sys_col(table, DATA_ROW_ID);
 
  164         node->row_id_buf = ptr;
 
  168         col = dict_table_get_sys_col(table, DATA_TRX_ID);
 
  175         node->trx_id_buf = ptr;
 
  179         col = dict_table_get_sys_col(table, DATA_ROLL_PTR);
 
  198         node->
state = INS_NODE_SET_IX_LOCK;
 
  208         ins_node_create_entry_list(node);
 
  212         row_ins_alloc_sys_fields(node);
 
  225 static __attribute__((nonnull, warn_unused_result))
 
  227 row_ins_sec_index_entry_by_modify(
 
  248         rec = btr_cur_get_rec(cursor);
 
  251         ut_ad(rec_offs_validate(rec, cursor->index, *offsets));
 
  252         ut_ad(!entry->info_bits);
 
  260                 rec, cursor->index, *offsets, entry, heap);
 
  287                         offsets, &offsets_heap, update, 0, thr,
 
  292                 case DB_ZIP_OVERFLOW:
 
  306                         offsets, &offsets_heap,
 
  307                         heap, &dummy_big_rec, update, 0,
 
  309                 ut_ad(!dummy_big_rec);
 
  320 static __attribute__((nonnull, warn_unused_result))
 
  322 row_ins_clust_index_entry_by_modify(
 
  350         rec = btr_cur_get_rec(cursor);
 
  360                 cursor->index, entry, rec, NULL, 
true,
 
  369                         flags, cursor, offsets, offsets_heap, update, 0, thr,
 
  374                 case DB_ZIP_OVERFLOW:
 
  387                         cursor, offsets, offsets_heap, heap,
 
  388                         big_rec, update, 0, thr, 
thr_get_trx(thr)->
id, mtr);
 
  400 row_ins_cascade_ancestor_updates_table(
 
  415                 if (upd_node->
table == table && upd_node->is_delete == FALSE) {
 
  428 static __attribute__((nonnull, warn_unused_result))
 
  430 row_ins_cascade_n_ancestors(
 
  435         ulint           n_ancestors = 0;
 
  454 static __attribute__((nonnull, warn_unused_result))
 
  456 row_ins_cascade_calc_update_vec(
 
  465         ibool*          fts_col_affected)
 
  473         upd_t*          parent_update;
 
  474         ulint           n_fields_updated;
 
  475         ulint           parent_field_no;
 
  478         ibool           doc_id_updated = FALSE;
 
  479         ulint           doc_id_pos = 0;
 
  493         parent_table = node->table;
 
  494         ut_a(parent_table == foreign->referenced_table);
 
  495         parent_index = foreign->referenced_index;
 
  496         parent_update = node->update;
 
  501         update->
n_fields = foreign->n_fields;
 
  503         n_fields_updated = 0;
 
  505         *fts_col_affected = FALSE;
 
  512         for (i = 0; i < foreign->n_fields; i++) {
 
  518                 for (j = 0; j < parent_update->
n_fields; j++) {
 
  520                                 = &parent_update->
fields[j];
 
  522                         if (parent_ufield->
field_no == parent_field_no) {
 
  535                                 ufield = update->
fields + n_fields_updated;
 
  554                                     && (col->
prtype & DATA_NOT_NULL)) {
 
  556                                         return(ULINT_UNDEFINED);
 
  572                                         return(ULINT_UNDEFINED);
 
  587                                 if (min_size > ufield_len) {
 
  594                                         padded_data = 
static_cast<byte*
>(
 
  598                                         pad = padded_data + ufield_len;
 
  599                                         pad_len = min_size - ufield_len;
 
  602                                                dfield_get_data(&ufield
 
  608                                         ut_ad(!(ufield_len % mbminlen));
 
  609                                         ut_ad(!(min_size % mbminlen));
 
  614                                             == DATA_MYSQL_BINARY_CHARSET_COLL) {
 
  616                                                 return(ULINT_UNDEFINED);
 
  622                                                         padded_data, min_size);
 
  628                                     && dict_table_is_fts_column(
 
  631                                         != ULINT_UNDEFINED) {
 
  632                                         *fts_col_affected = TRUE;
 
  638                                     && ufield->
field_no == doc_id_pos) {
 
  645                                                 static_cast<const byte*>(
 
  649                                         if (new_doc_id <= 0) {
 
  651                                                         "InnoDB: FTS Doc ID " 
  652                                                         "must be larger than " 
  654                                                 return(ULINT_UNDEFINED);
 
  657                                         if (new_doc_id < n_doc_id) {
 
  659                                                        "InnoDB: FTS Doc ID " 
  660                                                        "must be larger than " 
  661                                                        IB_ID_FMT
" for table",
 
  669                                                 return(ULINT_UNDEFINED);
 
  672                                         *fts_col_affected = TRUE;
 
  673                                         doc_id_updated = TRUE;
 
  682         if (table->fts && *fts_col_affected) {
 
  687                         ut_ad(!doc_id_updated);
 
  688                         ufield = update->
fields + n_fields_updated;
 
  691                                                    &trx->fts_next_doc_id);
 
  695                         if (doc_id_updated) {
 
  700                                 fprintf(stderr, 
"InnoDB: FTS Doc ID must be " 
  701                                         "updated along with FTS indexed " 
  702                                         "column for table ");
 
  705                                 return(ULINT_UNDEFINED);
 
  710         update->
n_fields = n_fields_updated;
 
  712         return(n_fields_updated);
 
  720 row_ins_set_detailed(
 
  749 row_ins_foreign_trx_print(
 
  769         mutex_enter(&dict_foreign_err_mutex);
 
  770         rewind(dict_foreign_err_file);
 
  772         fputs(
" Transaction:\n", dict_foreign_err_file);
 
  775                       n_rec_locks, n_trx_locks, heap_size);
 
  779         ut_ad(mutex_own(&dict_foreign_err_mutex));
 
  787 row_ins_foreign_report_err(
 
  803         FILE*   ef      = dict_foreign_err_file;
 
  806         row_ins_set_detailed(trx, foreign);
 
  808         row_ins_foreign_trx_print(trx);
 
  810         fputs(
"Foreign key constraint fails for table ", ef);
 
  817         fputs(
" in parent table, in index ", ef);
 
  820                 fputs(
" tuple:\n", ef);
 
  823         fputs(
"\nBut in child table ", ef);
 
  825         fputs(
", in index ", ef);
 
  828                 fputs(
", there is a record:\n", ef);
 
  831                 fputs(
", the record is not available\n", ef);
 
  835         mutex_exit(&dict_foreign_err_mutex);
 
  844 row_ins_foreign_report_add_err(
 
  858         FILE*   ef      = dict_foreign_err_file;
 
  860         row_ins_set_detailed(trx, foreign);
 
  862         row_ins_foreign_trx_print(trx);
 
  864         fputs(
"Foreign key constraint fails for table ", ef);
 
  869         fputs(
"\nTrying to add in child table, in index ", ef);
 
  872                 fputs(
" tuple:\n", ef);
 
  877         fputs(
"\nBut in parent table ", ef);
 
  879         fputs(
", in index ", ef);
 
  881         fputs(
",\nthe closest match we can find is record:\n", ef);
 
  894         mutex_exit(&dict_foreign_err_mutex);
 
  901 row_ins_invalidate_query_cache(
 
  910         ulint   len = strlen(name) + 1;
 
  914         ptr = strchr(buf, 
'/');
 
  927 static __attribute__((nonnull, warn_unused_result))
 
  929 row_ins_foreign_check_on_constraint(
 
  950         const rec_t*    clust_rec;
 
  959         ibool           fts_col_affacted = FALSE;
 
  974         row_ins_invalidate_query_cache(thr, table->
name);
 
  976         node = 
static_cast<upd_node_t*
>(thr->run_node);
 
  978         if (node->is_delete && 0 == (foreign->type
 
  982                 row_ins_foreign_report_err(
"Trying to delete",
 
  984                                            btr_pcur_get_rec(pcur), entry);
 
  989         if (!node->is_delete && 0 == (foreign->type
 
  995                 row_ins_foreign_report_err(
"Trying to update",
 
  997                                            btr_pcur_get_rec(pcur), entry);
 
 1002         if (node->cascade_node == NULL) {
 
 1009                         table, node->cascade_heap);
 
 1018         cascade = node->cascade_node;
 
 1022         cascade->foreign = foreign;
 
 1026                 cascade->is_delete = TRUE;
 
 1028                 cascade->is_delete = FALSE;
 
 1030                 if (foreign->n_fields > cascade->update_n_fields) {
 
 1034                                                      node->cascade_heap);
 
 1035                         cascade->update_n_fields = foreign->n_fields;
 
 1047         if (!cascade->is_delete
 
 1048             && row_ins_cascade_ancestor_updates_table(cascade, table)) {
 
 1055                 row_ins_foreign_report_err(
 
 1056                         "Trying an update, possibly causing a cyclic" 
 1057                         " cascaded update\n" 
 1058                         "in the child table,", thr, foreign,
 
 1059                         btr_pcur_get_rec(pcur), entry);
 
 1061                 goto nonstandard_exit_func;
 
 1064         if (row_ins_cascade_n_ancestors(cascade) >= 15) {
 
 1067                 row_ins_foreign_report_err(
 
 1068                         "Trying a too deep cascaded delete or update\n",
 
 1069                         thr, foreign, btr_pcur_get_rec(pcur), entry);
 
 1071                 goto nonstandard_exit_func;
 
 1074         index = btr_pcur_get_btr_cur(pcur)->index;
 
 1076         ut_a(index == foreign->foreign_index);
 
 1078         rec = btr_pcur_get_rec(pcur);
 
 1086                 clust_index = 
index;
 
 1088                 clust_block = btr_pcur_get_block(pcur);
 
 1093                 clust_index = dict_table_get_first_index(table);
 
 1097                 btr_pcur_open_with_no_init(clust_index, ref,
 
 1099                                            cascade->
pcur, 0, mtr);
 
 1101                 clust_rec = btr_pcur_get_rec(cascade->
pcur);
 
 1102                 clust_block = btr_pcur_get_block(cascade->
pcur);
 
 1108                         fputs(
"InnoDB: error in cascade of a foreign key op\n" 
 1109                               "InnoDB: ", stderr);
 
 1113                               "InnoDB: record ", stderr);
 
 1116                               "InnoDB: clustered record ", stderr);
 
 1117                         rec_print(stderr, clust_rec, clust_index);
 
 1119                               "InnoDB: Submit a detailed bug report to" 
 1120                               " http://bugs.mysql.com\n", stderr);
 
 1124                         goto nonstandard_exit_func;
 
 1132         if (err == DB_SUCCESS) {
 
 1138                         0, clust_block, clust_rec, clust_index,
 
 1142         if (err != DB_SUCCESS) {
 
 1144                 goto nonstandard_exit_func;
 
 1153                 goto nonstandard_exit_func;
 
 1167                 update = cascade->
update;
 
 1170                 update->
n_fields = foreign->n_fields;
 
 1171                 UNIV_MEM_INVALID(update->
fields,
 
 1174                 for (i = 0; i < foreign->n_fields; i++) {
 
 1184                         if (table->fts && dict_table_is_fts_column(
 
 1187                                 != ULINT_UNDEFINED) {
 
 1188                                 fts_col_affacted = TRUE;
 
 1192                 if (fts_col_affacted) {
 
 1195         } 
else if (table->fts && cascade->is_delete) {
 
 1197                 for (i = 0; i < foreign->n_fields; i++) {
 
 1198                         if (table->fts && dict_table_is_fts_column(
 
 1201                                 != ULINT_UNDEFINED) {
 
 1202                                 fts_col_affacted = TRUE;
 
 1206                 if (fts_col_affacted) {
 
 1211         if (!node->is_delete
 
 1219                 n_to_update = row_ins_cascade_calc_update_vec(
 
 1220                         node, foreign, upd_vec_heap, trx, &fts_col_affacted);
 
 1222                 if (n_to_update == ULINT_UNDEFINED) {
 
 1225                         row_ins_foreign_report_err(
 
 1226                                 "Trying a cascaded update where the" 
 1227                                 " updated value in the child\n" 
 1228                                 "table would not fit in the length" 
 1229                                 " of the column, or the value would\n" 
 1230                                 "be NULL and the column is" 
 1231                                 " declared as not NULL in the child table,",
 
 1232                                 thr, foreign, btr_pcur_get_rec(pcur), entry);
 
 1234                         goto nonstandard_exit_func;
 
 1245                         goto nonstandard_exit_func;
 
 1249                 if (fts_col_affacted) {
 
 1260         if (index == clust_index) {
 
 1270         cascade->
state = UPD_NODE_UPDATE_CLUSTERED;
 
 1273                                            foreign->foreign_table);
 
 1275         if (foreign->foreign_table->n_foreign_key_checks_running == 0) {
 
 1277                         "InnoDB: error: table %s has the counter 0" 
 1278                         " though there is\n" 
 1279                         "InnoDB: a FOREIGN KEY check running on it.\n",
 
 1280                         foreign->foreign_table->name);
 
 1291         DEBUG_SYNC_C(
"innodb_dml_cascade_dict_unfreeze");
 
 1293         row_mysql_freeze_data_dictionary(
thr_get_trx(thr));
 
 1311 nonstandard_exit_func:
 
 1336 row_ins_set_shared_rec_lock(
 
 1343         const ulint*            offsets,
 
 1348         ut_ad(rec_offs_validate(rec, index, offsets));
 
 1352                         0, block, rec, index, offsets, LOCK_S, type, thr);
 
 1355                         0, block, rec, index, offsets, LOCK_S, type, thr);
 
 1367 row_ins_set_exclusive_rec_lock(
 
 1374         const ulint*            offsets,
 
 1379         ut_ad(rec_offs_validate(rec, index, offsets));
 
 1383                         0, block, rec, index, offsets, LOCK_X, type, thr);
 
 1386                         0, block, rec, index, offsets, LOCK_X, type, thr);
 
 1423         ulint           offsets_[REC_OFFS_NORMAL_SIZE];
 
 1424         ulint*          offsets         = offsets_;
 
 1425         rec_offs_init(offsets_);
 
 1428 #ifdef UNIV_SYNC_DEBUG 
 1444         for (i = 0; i < foreign->
n_fields; i++) {
 
 1446                             dtuple_get_nth_field(entry, i))) {
 
 1455                 if (!(upd_node->is_delete) && upd_node->foreign == foreign) {
 
 1484         if (check_table == NULL
 
 1486             || check_index == NULL) {
 
 1489                         FILE*   ef = dict_foreign_err_file;
 
 1491                         row_ins_set_detailed(trx, foreign);
 
 1493                         row_ins_foreign_trx_print(trx);
 
 1495                         fputs(
"Foreign key constraint fails for table ", ef);
 
 1500                                 ef, trx, foreign, TRUE);
 
 1501                         fputs(
"\nTrying to add to index ", ef);
 
 1504                         fputs(
" tuple:\n", ef);
 
 1506                         fputs(
"\nBut the parent table ", ef);
 
 1509                         fputs(
"\nor its .ibd file does" 
 1510                               " not currently exist!\n", ef);
 
 1511                         mutex_exit(&dict_foreign_err_mutex);
 
 1519         if (check_table != table) {
 
 1523                 err = 
lock_table(0, check_table, LOCK_IS, thr);
 
 1525                 if (err != DB_SUCCESS) {
 
 1527                         goto do_possible_lock_wait;
 
 1539         btr_pcur_open(check_index, entry, PAGE_CUR_GE,
 
 1545                 const rec_t*            rec = btr_pcur_get_rec(&pcur);
 
 1546                 const buf_block_t*      block = btr_pcur_get_block(&pcur);
 
 1553                 offsets = rec_get_offsets(rec, check_index,
 
 1554                                           offsets, ULINT_UNDEFINED, &heap);
 
 1575                                 err = row_ins_set_shared_rec_lock(
 
 1577                                         rec, check_index, offsets, thr);
 
 1590                                 err = row_ins_set_shared_rec_lock(
 
 1592                                         rec, check_index, offsets, thr);
 
 1606                                 } 
else if (foreign->
type != 0) {
 
 1611                                         err = row_ins_foreign_check_on_constraint(
 
 1612                                                 thr, foreign, &pcur, entry,
 
 1614                                         if (err != DB_SUCCESS) {
 
 1627                                                 if (err == DB_DUPLICATE_KEY) {
 
 1637                                         block = btr_pcur_get_block(&pcur);
 
 1639                                         row_ins_foreign_report_err(
 
 1640                                                 "Trying to delete or update",
 
 1641                                                 thr, foreign, rec, entry);
 
 1650                         err = row_ins_set_shared_rec_lock(
 
 1652                                 rec, check_index, offsets, thr);
 
 1659                                         row_ins_foreign_report_add_err(
 
 1660                                                 trx, foreign, rec, entry);
 
 1673                 row_ins_foreign_report_add_err(
 
 1674                         trx, foreign, btr_pcur_get_rec(&pcur), entry);
 
 1688 do_possible_lock_wait:
 
 1689         if (err == DB_LOCK_WAIT) {
 
 1690                 bool            verified = 
false;
 
 1716                                         referenced_list, check_foreign)) {
 
 1717                                 if (check_foreign == foreign) {
 
 1736         if (UNIV_LIKELY_NULL(heap)) {
 
 1749 static __attribute__((nonnull, warn_unused_result))
 
 1751 row_ins_check_foreign_constraints(
 
 1761         ibool           got_s_lock      = FALSE;
 
 1768                             "foreign_constraint_check_for_ins");
 
 1777                         if (referenced_table == NULL) {
 
 1787                                 row_mysql_freeze_data_dictionary(trx);
 
 1790                         if (referenced_table) {
 
 1802                                 TRUE, foreign, table, entry, thr);
 
 1804                         DBUG_EXECUTE_IF(
"row_ins_dict_change_err",
 
 1807                         if (referenced_table) {
 
 1817                         if (ref_table != NULL) {
 
 1821                         if (err != DB_SUCCESS) {
 
 1839 row_ins_dupl_error_with_rec(
 
 1846         const ulint*    offsets)
 
 1848         ulint   matched_fields;
 
 1849         ulint   matched_bytes;
 
 1853         ut_ad(rec_offs_validate(rec, index, offsets));
 
 1860         cmp_dtuple_rec_with_match(entry, rec, offsets,
 
 1861                                   &matched_fields, &matched_bytes);
 
 1863         if (matched_fields < n_unique) {
 
 1873                 for (i = 0; i < n_unique; i++) {
 
 1889 static __attribute__((nonnull, warn_unused_result))
 
 1891 row_ins_scan_sec_index_for_duplicate(
 
 1907         ulint           allow_duplicates;
 
 1908         ulint*          offsets         = NULL;
 
 1910 #ifdef UNIV_SYNC_DEBUG 
 1911         ut_ad(s_latch == rw_lock_own(&index->lock, RW_LOCK_SHARED));
 
 1920         for (ulint i = 0; i < n_unique; i++) {
 
 1922                             dtuple_get_nth_field(entry, i))) {
 
 1934         btr_pcur_open(index, entry, PAGE_CUR_GE,
 
 1945                 const rec_t*            rec     = btr_pcur_get_rec(&pcur);
 
 1946                 const buf_block_t*      block   = btr_pcur_get_block(&pcur);
 
 1954                 offsets = rec_get_offsets(rec, index, offsets,
 
 1955                                           ULINT_UNDEFINED, &offsets_heap);
 
 1961                                         <= TRX_ISO_READ_COMMITTED) {
 
 1970                 } 
else if (allow_duplicates) {
 
 1977                         err = row_ins_set_exclusive_rec_lock(
 
 1978                                 lock_type, block, rec, index, offsets, thr);
 
 1981                         err = row_ins_set_shared_rec_lock(
 
 1982                                 lock_type, block, rec, index, offsets, thr);
 
 2002                         if (row_ins_dupl_error_with_rec(rec, entry,
 
 2004                                 err = DB_DUPLICATE_KEY;
 
 2010                                 if (DICT_TF2_FLAG_IS_SET(
 
 2013                                     && strcmp(index->name,
 
 2016                                                 "Duplicate FTS_DOC_ID value" 
 2018                                                 index->table->name);
 
 2041 static __attribute__((nonnull, warn_unused_result))
 
 2043 row_ins_duplicate_online(
 
 2061                 entry, rec, offsets, n_uniq + 2, &fields, &bytes);
 
 2063         if (fields < n_uniq) {
 
 2068         if (fields == n_uniq + 2) {
 
 2074         return(DB_DUPLICATE_KEY);
 
 2082 static __attribute__((nonnull, warn_unused_result))
 
 2084 row_ins_duplicate_error_in_clust_online(
 
 2093         const rec_t*    rec     = btr_cur_get_rec(cursor);
 
 2096                 *offsets = rec_get_offsets(rec, cursor->index, *offsets,
 
 2097                                            ULINT_UNDEFINED, heap);
 
 2098                 err = row_ins_duplicate_online(n_uniq, entry, rec, *offsets);
 
 2099                 if (err != DB_SUCCESS) {
 
 2107                 *offsets = rec_get_offsets(rec, cursor->index, *offsets,
 
 2108                                            ULINT_UNDEFINED, heap);
 
 2109                 err = row_ins_duplicate_online(n_uniq, entry, rec, *offsets);
 
 2125 static __attribute__((nonnull, warn_unused_result))
 
 2127 row_ins_duplicate_error_in_clust(
 
 2140         ulint   offsets_[REC_OFFS_NORMAL_SIZE];
 
 2141         ulint*  offsets         = offsets_;
 
 2142         rec_offs_init(offsets_);
 
 2163         if (cursor->low_match >= n_unique) {
 
 2165                 rec = btr_cur_get_rec(cursor);
 
 2168                         offsets = rec_get_offsets(rec, cursor->index, offsets,
 
 2169                                                   ULINT_UNDEFINED, &heap);
 
 2183                                 err = row_ins_set_exclusive_rec_lock(
 
 2185                                         btr_cur_get_block(cursor),
 
 2186                                         rec, cursor->index, offsets, thr);
 
 2189                                 err = row_ins_set_shared_rec_lock(
 
 2191                                         btr_cur_get_block(cursor), rec,
 
 2192                                         cursor->index, offsets, thr);
 
 2203                         if (row_ins_dupl_error_with_rec(
 
 2204                                     rec, entry, cursor->index, offsets)) {
 
 2207                                 err = DB_DUPLICATE_KEY;
 
 2213         if (cursor->up_match >= n_unique) {
 
 2218                         offsets = rec_get_offsets(rec, cursor->index, offsets,
 
 2219                                                   ULINT_UNDEFINED, &heap);
 
 2228                                 err = row_ins_set_exclusive_rec_lock(
 
 2230                                         btr_cur_get_block(cursor),
 
 2231                                         rec, cursor->index, offsets, thr);
 
 2234                                 err = row_ins_set_shared_rec_lock(
 
 2236                                         btr_cur_get_block(cursor),
 
 2237                                         rec, cursor->index, offsets, thr);
 
 2248                         if (row_ins_dupl_error_with_rec(
 
 2249                                     rec, entry, cursor->index, offsets)) {
 
 2260         if (UNIV_LIKELY_NULL(heap)) {
 
 2279 row_ins_must_modify_rec(
 
 2321         ulint*          offsets         = NULL;
 
 2346                                     &cursor, 0, __FILE__, __LINE__, &mtr);
 
 2352                         page_get_infimum_rec(page));
 
 2360         if (n_uniq && (cursor.
up_match >= n_uniq
 
 2368                         err = row_ins_duplicate_error_in_clust_online(
 
 2369                                 n_uniq, entry, &cursor,
 
 2370                                 &offsets, &offsets_heap);
 
 2379                         case DB_DUPLICATE_KEY:
 
 2386                         err = row_ins_duplicate_error_in_clust(
 
 2387                                 flags, &cursor, entry, thr, &mtr);
 
 2390                 if (err != DB_SUCCESS) {
 
 2397         if (row_ins_must_modify_rec(&cursor)) {
 
 2403                 err = row_ins_clust_index_entry_by_modify(
 
 2404                         flags, mode, &cursor, &offsets, &offsets_heap,
 
 2405                         entry_heap, &big_rec, entry, thr, &mtr);
 
 2407                 rec_t*          rec             = btr_cur_get_rec(&cursor);
 
 2410                         ut_a(err == DB_SUCCESS);
 
 2435                         DEBUG_SYNC_C_IF_THD(
 
 2437                                 "before_row_ins_upd_extern");
 
 2439                                 index, btr_cur_get_block(&cursor),
 
 2440                                 rec, offsets, big_rec, &mtr,
 
 2442                         DEBUG_SYNC_C_IF_THD(
 
 2444                                 "after_row_ins_upd_extern");
 
 2462                         ut_a(err == DB_SUCCESS);
 
 2479                                 flags, &cursor, &offsets, &offsets_heap,
 
 2480                                 entry, &insert_rec, &big_rec,
 
 2491                                 &offsets, &offsets_heap,
 
 2492                                 entry, &insert_rec, &big_rec,
 
 2495                         if (err == DB_FAIL) {
 
 2498                                         &offsets, &offsets_heap,
 
 2499                                         entry, &insert_rec, &big_rec,
 
 2504                 if (UNIV_LIKELY_NULL(big_rec)) {
 
 2513                                 "row_ins_extern_checkpoint",
 
 2516                         err = row_ins_index_entry_big_rec(
 
 2517                                 entry, big_rec, offsets, &offsets_heap, index,
 
 2519                                 __FILE__, __LINE__);
 
 2522                         if (err == DB_SUCCESS
 
 2525                                         insert_rec, index, offsets);
 
 2543 static __attribute__((nonnull, warn_unused_result))
 
 2545 row_ins_sec_mtr_start_and_check_if_aborted(
 
 2567         switch (index->online_status) {
 
 2612         ulint*          offsets = NULL;
 
 2629                 DEBUG_SYNC_C(
"row_ins_sec_index_enter");
 
 2653                                     &cursor, 0, __FILE__, __LINE__, &mtr);
 
 2664                         page_get_infimum_rec(page));
 
 2678                 DEBUG_SYNC_C(
"row_ins_sec_index_unique");
 
 2680                 if (row_ins_sec_mtr_start_and_check_if_aborted(
 
 2681                             &mtr, index, check, search_mode)) {
 
 2685                 err = row_ins_scan_sec_index_for_duplicate(
 
 2686                         flags, index, entry, thr, check, &mtr, offsets_heap);
 
 2693                 case DB_DUPLICATE_KEY:
 
 2696                                       ->dict_operation_lock_mode);
 
 2699                                         index, index->
table);
 
 2715                 if (row_ins_sec_mtr_start_and_check_if_aborted(
 
 2716                             &mtr, index, check, search_mode)) {
 
 2727                         index, 0, entry, PAGE_CUR_LE,
 
 2729                         &cursor, 0, __FILE__, __LINE__, &mtr);
 
 2732         if (row_ins_must_modify_rec(&cursor)) {
 
 2736                 offsets = rec_get_offsets(
 
 2737                         btr_cur_get_rec(&cursor), index, offsets,
 
 2738                         ULINT_UNDEFINED, &offsets_heap);
 
 2740                 err = row_ins_sec_index_entry_by_modify(
 
 2741                         flags, mode, &cursor, &offsets,
 
 2742                         offsets_heap, heap, entry, thr, &mtr);
 
 2749                                 flags, &cursor, &offsets, &offsets_heap,
 
 2751                                 &big_rec, 0, thr, &mtr);
 
 2762                                 &offsets, &offsets_heap,
 
 2764                                 &big_rec, 0, thr, &mtr);
 
 2765                         if (err == DB_FAIL) {
 
 2768                                         &offsets, &offsets_heap,
 
 2770                                         &big_rec, 0, thr, &mtr);
 
 2774                 if (err == DB_SUCCESS && trx_id) {
 
 2776                                 btr_cur_get_block(&cursor),
 
 2815         DEBUG_SYNC_C_IF_THD(thd, 
"before_row_ins_extern_latch");
 
 2821         rec = btr_cur_get_rec(&cursor);
 
 2822         offsets = rec_get_offsets(rec, index, offsets,
 
 2823                                   ULINT_UNDEFINED, heap);
 
 2825         DEBUG_SYNC_C_IF_THD(thd, 
"before_row_ins_extern");
 
 2827                 index, btr_cur_get_block(&cursor),
 
 2829         DEBUG_SYNC_C_IF_THD(thd, 
"after_row_ins_extern");
 
 2831         if (error == DB_SUCCESS
 
 2860                 err = row_ins_check_foreign_constraints(
 
 2861                         index->
table, index, entry, thr);
 
 2862                 if (err != DB_SUCCESS) {
 
 2882                                     "after_row_ins_clust_index_entry_leaf");
 
 2886         if (err != DB_FAIL) {
 
 2887                 DEBUG_SYNC_C(
"row_ins_clust_index_entry_leaf_after");
 
 2918                 err = row_ins_check_foreign_constraints(index->
table, index,
 
 2920                 if (err != DB_SUCCESS) {
 
 2937         if (err == DB_FAIL) {
 
 2946                         offsets_heap, heap, entry, 0, thr);
 
 2962 row_ins_index_entry(
 
 2978 static __attribute__((nonnull))
 
 2980 row_ins_index_entry_set_vals(
 
 2991         for (i = 0; i < n_fields; i++) {
 
 2997                 field = dtuple_get_nth_field(entry, i);
 
 2998                 ind_field = dict_index_get_nth_field(index, i);
 
 2999                 row_field = dtuple_get_nth_field(row, ind_field->
col->
ind);
 
 3013                                 static_cast<const char*>(
 
 3014                                         dfield_get_data(row_field)));
 
 3031 static __attribute__((nonnull, warn_unused_result))
 
 3033 row_ins_index_entry_step(
 
 3042         row_ins_index_entry_set_vals(node->index, node->entry, node->row);
 
 3046         err = row_ins_index_entry(node->index, node->entry, thr);
 
 3053                                     "after_row_ins_index_entry_step");
 
 3064 row_ins_alloc_row_id_step(
 
 3090 row_ins_get_row_from_values(
 
 3106         list_node = node->values_list;
 
 3111                 dfield = dtuple_get_nth_field(row, i);
 
 3123 row_ins_get_row_from_select(
 
 3127         que_node_t*     list_node;
 
 3142                 dfield = dtuple_get_nth_field(row, i);
 
 3154 static __attribute__((nonnull, warn_unused_result))
 
 3163         if (node->state == INS_NODE_ALLOC_ROW_ID) {
 
 3165                 row_ins_alloc_row_id_step(node);
 
 3167                 node->index = dict_table_get_first_index(node->table);
 
 3170                 if (node->ins_type == INS_SEARCHED) {
 
 3172                         row_ins_get_row_from_select(node);
 
 3174                 } 
else if (node->ins_type == INS_VALUES) {
 
 3176                         row_ins_get_row_from_values(node);
 
 3179                 node->state = INS_NODE_INSERT_ENTRIES;
 
 3182         ut_ad(node->state == INS_NODE_INSERT_ENTRIES);
 
 3184         while (node->index != NULL) {
 
 3185                 if (node->index->type != DICT_FTS) {
 
 3186                         err = row_ins_index_entry_step(node, thr);
 
 3188                         if (err != DB_SUCCESS) {
 
 3194                 node->index = dict_table_get_next_index(node->index);
 
 3199                         node->index = NULL; node->entry = NULL; 
break;);
 
 3204                         node->index = dict_table_get_next_index(node->index);
 
 3209         ut_ad(node->entry == NULL);
 
 3211         node->state = INS_NODE_ALLOC_ROW_ID;
 
 3236         trx_start_if_not_started_xa(trx);
 
 3246                 node->
state = INS_NODE_SET_IX_LOCK;
 
 3261         if (node->
state == INS_NODE_SET_IX_LOCK) {
 
 3263                 node->
state = INS_NODE_ALLOC_ROW_ID;
 
 3276                 DBUG_EXECUTE_IF(
"ib_row_ins_ix_lock_wait",
 
 3277                                 err = DB_LOCK_WAIT;);
 
 3279                 if (err != DB_SUCCESS) {
 
 3281                         goto error_handling;
 
 3286                 if (node->ins_type == INS_SEARCHED) {
 
 3298         if ((node->ins_type == INS_SEARCHED)
 
 3311         err = row_ins(node, thr);
 
 3316         if (err != DB_SUCCESS) {
 
 3323         if (node->ins_type == INS_SEARCHED) {