~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/dict/dict0load.c

  • Committer: Lee Bieber
  • Date: 2010-12-03 01:16:19 UTC
  • mfrom: (1819.9.81 update-innobase)
  • Revision ID: kalebral@gmail.com-20101203011619-n6v584rijwdet05b
Merge Stewart - update Innobase plugin based on InnoDB 1.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
369
369
        mem_heap_t*     heap,           /*!< in/out: heap memory */
370
370
        const rec_t*    rec,            /*!< in: current SYS_INDEXES rec */
371
371
        dict_index_t*   index,          /*!< out: index to be filled */
372
 
        dulint*         table_id)       /*!< out: index table id */
 
372
        table_id_t*     table_id)       /*!< out: index table id */
373
373
{
374
374
        const char*     err_msg;
375
375
        byte*           buf;
395
395
        mem_heap_t*     heap,           /*!< in/out: heap memory */
396
396
        const rec_t*    rec,            /*!< in: current SYS_COLUMNS rec */
397
397
        dict_col_t*     column,         /*!< out: dict_col_t to be filled */
398
 
        dulint*         table_id,       /*!< out: table id */
 
398
        table_id_t*     table_id,       /*!< out: table id */
399
399
        const char**    col_name)       /*!< out: column name */
400
400
{
401
401
        const char*     err_msg;
419
419
        dict_field_t*   sys_field,      /*!< out: dict_field_t to be
420
420
                                        filled */
421
421
        ulint*          pos,            /*!< out: Field position */
422
 
        dulint*         index_id,       /*!< out: current index id */
423
 
        dulint          last_id)        /*!< in: previous index id */
 
422
        index_id_t*     index_id,       /*!< out: current index id */
 
423
        index_id_t      last_id)        /*!< in: previous index id */
424
424
{
425
425
        byte*           buf;
426
426
        byte*           last_index_id;
725
725
        dict_index_t*   sys_index;
726
726
        btr_pcur_t      pcur;
727
727
        const rec_t*    rec;
728
 
        ulint           max_space_id    = 0;
 
728
        ulint           max_space_id;
729
729
        mtr_t           mtr;
730
730
 
731
731
        mutex_enter(&(dict_sys->mutex));
736
736
        sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
737
737
        ut_a(!dict_table_is_comp(sys_tables));
738
738
 
 
739
        max_space_id = mtr_read_ulint(dict_hdr_get(&mtr)
 
740
                                      + DICT_HDR_MAX_SPACE_ID,
 
741
                                      MLOG_4BYTES, &mtr);
 
742
        fil_set_max_space_id_if_bigger(max_space_id);
 
743
 
739
744
        btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur,
740
745
                                    TRUE, &mtr);
741
746
loop:
858
863
dict_load_column_low(
859
864
/*=================*/
860
865
        dict_table_t*   table,          /*!< in/out: table, could be NULL
861
 
                                        if we just polulate a dict_column_t
 
866
                                        if we just populate a dict_column_t
862
867
                                        struct with information from
863
868
                                        a SYS_COLUMNS record */
864
869
        mem_heap_t*     heap,           /*!< in/out: memory heap
865
870
                                        for temporary storage */
866
 
        dict_col_t*     column,         /*!< out: dict_column_t to fill */
867
 
        dulint*         table_id,       /*!< out: table id */
 
871
        dict_col_t*     column,         /*!< out: dict_column_t to fill,
 
872
                                        or NULL if table != NULL */
 
873
        table_id_t*     table_id,       /*!< out: table id */
868
874
        const char**    col_name,       /*!< out: column name */
869
875
        const rec_t*    rec)            /*!< in: SYS_COLUMNS record */
870
876
{
876
882
        ulint           col_len;
877
883
        ulint           pos = 0;
878
884
 
 
885
        ut_ad(table || column);
 
886
 
879
887
        if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {
880
888
                return("delete-marked record in SYS_COLUMNS");
881
889
        }
892
900
 
893
901
        if (table_id) {
894
902
                *table_id = mach_read_from_8(field);
895
 
        } else if (UNIV_UNLIKELY(ut_dulint_cmp(table->id,
896
 
                                 mach_read_from_8(field)))) {
 
903
        } else if (UNIV_UNLIKELY(table->id != mach_read_from_8(field))) {
897
904
                return("SYS_COLUMNS.TABLE_ID mismatch");
898
905
        }
899
906
 
903
910
                goto err_len;
904
911
        }
905
912
 
906
 
        if (!table) {
907
 
                pos = mach_read_from_4(field);
908
 
        } else if (UNIV_UNLIKELY(table->n_def != mach_read_from_4(field))) {
 
913
        pos = mach_read_from_4(field);
 
914
 
 
915
        if (UNIV_UNLIKELY(table && table->n_def != pos)) {
909
916
                return("SYS_COLUMNS.POS mismatch");
910
917
        }
911
918
 
1249
1256
 
1250
1257
/********************************************************************//**
1251
1258
Loads an index definition from a SYS_INDEXES record to dict_index_t.
1252
 
If "cached" is set to "TRUE", we will create a dict_index_t structure
1253
 
and fill it accordingly. Otherwise, the dict_index_t will
1254
 
be supplied by the caller and filled with information read from
1255
 
the record.
1256
 
@return error message, or NULL on success */
 
1259
If allocate=TRUE, we will create a dict_index_t structure and fill it
 
1260
accordingly. If allocated=FALSE, the dict_index_t will be supplied by
 
1261
the caller and filled with information read from the record.  @return
 
1262
error message, or NULL on success */
1257
1263
UNIV_INTERN
1258
1264
const char*
1259
1265
dict_load_index_low(
1260
1266
/*================*/
1261
1267
        byte*           table_id,       /*!< in/out: table id (8 bytes),
1262
 
                                        an "in" value if cached=TRUE
1263
 
                                        and "out" when cached=FALSE */
 
1268
                                        an "in" value if allocate=TRUE
 
1269
                                        and "out" when allocate=FALSE */
1264
1270
        const char*     table_name,     /*!< in: table name */
1265
1271
        mem_heap_t*     heap,           /*!< in/out: temporary memory heap */
1266
1272
        const rec_t*    rec,            /*!< in: SYS_INDEXES record */
1267
 
        ibool           cached,         /*!< in: TRUE = add to cache,
1268
 
                                        FALSE = do not */
 
1273
        ibool           allocate,       /*!< in: TRUE=allocate *index,
 
1274
                                        FALSE=fill in a pre-allocated
 
1275
                                        *index */
1269
1276
        dict_index_t**  index)          /*!< out,own: index, or NULL */
1270
1277
{
1271
1278
        const byte*     field;
1272
1279
        ulint           len;
1273
1280
        ulint           name_len;
1274
1281
        char*           name_buf;
1275
 
        dulint          id;
 
1282
        index_id_t      id;
1276
1283
        ulint           n_fields;
1277
1284
        ulint           type;
1278
1285
        ulint           space;
1279
1286
 
1280
 
        if (cached) {
1281
 
                /* If "cached" is set to TRUE, no dict_index_t will
 
1287
        if (allocate) {
 
1288
                /* If allocate=TRUE, no dict_index_t will
1282
1289
                be supplied. Initialize "*index" to NULL */
1283
1290
                *index = NULL;
1284
1291
        }
1297
1304
                return("incorrect column length in SYS_INDEXES");
1298
1305
        }
1299
1306
 
1300
 
        if (!cached) {
 
1307
        if (!allocate) {
1301
1308
                /* We are reading a SYS_INDEXES record. Copy the table_id */
1302
1309
                memcpy(table_id, (const char*)field, 8);
1303
1310
        } else if (memcmp(field, table_id, 8)) {
1353
1360
                goto err_len;
1354
1361
        }
1355
1362
 
1356
 
        if (cached) {
 
1363
        if (allocate) {
1357
1364
                *index = dict_mem_index_create(table_name, name_buf,
1358
1365
                                               space, type, n_fields);
1359
1366
        } else {
1389
1396
        dfield_t*       dfield;
1390
1397
        const rec_t*    rec;
1391
1398
        byte*           buf;
1392
 
        ibool           is_sys_table;
1393
1399
        mtr_t           mtr;
1394
1400
        ulint           error = DB_SUCCESS;
1395
1401
 
1396
1402
        ut_ad(mutex_own(&(dict_sys->mutex)));
1397
1403
 
1398
 
        if ((ut_dulint_get_high(table->id) == 0)
1399
 
            && (ut_dulint_get_low(table->id) < DICT_HDR_FIRST_ID)) {
1400
 
                is_sys_table = TRUE;
1401
 
        } else {
1402
 
                is_sys_table = FALSE;
1403
 
        }
1404
 
 
1405
1404
        mtr_start(&mtr);
1406
1405
 
1407
1406
        sys_indexes = dict_table_get_low("SYS_INDEXES");
1487
1486
                              " is not clustered!\n", stderr);
1488
1487
 
1489
1488
                        goto corrupted;
1490
 
                } else if (is_sys_table
 
1489
                } else if (table->id < DICT_HDR_FIRST_ID
1491
1490
                           && (dict_index_is_clust(index)
1492
1491
                               || ((table == dict_sys->sys_tables)
1493
1492
                                   && !strcmp("ID_IND", index->name)))) {
1847
1846
dict_table_t*
1848
1847
dict_load_table_on_id(
1849
1848
/*==================*/
1850
 
        dulint  table_id)       /*!< in: table id */
 
1849
        table_id_t      table_id)       /*!< in: table id */
1851
1850
{
1852
1851
        byte            id_buf[8];
1853
1852
        btr_pcur_t      pcur;
1910
1909
        ut_ad(len == 8);
1911
1910
 
1912
1911
        /* Check if the table id in record is the one searched for */
1913
 
        if (ut_dulint_cmp(table_id, mach_read_from_8(field)) != 0) {
 
1912
        if (table_id != mach_read_from_8(field)) {
1914
1913
 
1915
1914
                btr_pcur_close(&pcur);
1916
1915
                mtr_commit(&mtr);