获取cluster index的space和page no的一个路径

600阅读 0评论2013-03-21 gladness
分类:Mysql/postgreSQL




/** Error message for a delete-marked record in dict_load_index_low() */

static const char* dict_load_index_del = "delete-marked record in SYS_INDEXES";

/** Error message for table->id mismatch in dict_load_index_low() */

static const char* dict_load_index_id_err = "SYS_INDEXES.TABLE_ID mismatch";

 

/********************************************************************//**

Loads an index definition from a SYS_INDEXES record to dict_index_t.

If allocate=TRUE, we will create a dict_index_t structure and fill it

accordingly. If allocated=FALSE, the dict_index_t will be supplied by

the caller and filled with information read from the record.  @return

error message, or NULL on success */

UNIV_INTERN

const char*

dict_load_index_low(

/*================*/

    byte*        table_id,    /*!< in/out: table id (8 bytes),

                     an "in" value if allocate=TRUE

                     and "out" when allocate=FALSE */

    const char*  table_name,  /*!< in: table name */

    mem_heap_t*  heap,        /*!< in/out: temporary memory heap */

    const rec_t* rec,         /*!< in: SYS_INDEXES record */

    ibool        allocate,    /*!< in: TRUE=allocate *index,

                     FALSE=fill in a pre-allocated

                     *index */

    dict_index_t**   index)       /*!< out,own: index, or NULL */

{

    const byte*  field;

    ulint        len;

    ulint        name_len;

    char*        name_buf;

    index_id_t   id;

    ulint        n_fields;

    ulint        type;

    ulint        space;

 

    if (allocate) {

        /* If allocate=TRUE, no dict_index_t will

        be supplied. Initialize "*index" to NULL */

        *index = NULL;

    }

 

    if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) {

        return(dict_load_index_del);

    }

 

    if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 9)) {

        return("wrong number of columns in SYS_INDEXES record");

    }

 

    field = rec_get_nth_field_old(rec, 0/*TABLE_ID*/, &len);

    if (UNIV_UNLIKELY(len != 8)) {

err_len:

        return("incorrect column length in SYS_INDEXES");

    }

 

    if (!allocate) {

        /* We are reading a SYS_INDEXES record. Copy the table_id */

        memcpy(table_id, (const char*)field, 8);

    } else if (memcmp(field, table_id, 8)) {

        /* Caller supplied table_id, verify it is the same

        id as on the index record */

        return(dict_load_index_id_err);

    }

 

    field = rec_get_nth_field_old(rec, 1/*ID*/, &len);

    if (UNIV_UNLIKELY(len != 8)) {

        goto err_len;

    }

 

    id = mach_read_from_8(field);

 

    rec_get_nth_field_offs_old(rec, 2/*DB_TRX_ID*/, &len);

    if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {

        goto err_len;

    }

    rec_get_nth_field_offs_old(rec, 3/*DB_ROLL_PTR*/, &len);

    if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {

        goto err_len;

    }

 

    field = rec_get_nth_field_old(rec, 4/*NAME*/, &name_len);

    if (UNIV_UNLIKELY(name_len == UNIV_SQL_NULL)) {

        goto err_len;

    }

 

    name_buf = mem_heap_strdupl(heap, (const char*) field,

                     name_len);

 

    field = rec_get_nth_field_old(rec, 5/*N_FIELDS*/, &len);

    if (UNIV_UNLIKELY(len != 4)) {

        goto err_len;

    }

    n_fields = mach_read_from_4(field);

 

    field = rec_get_nth_field_old(rec, 6/*TYPE*/, &len);

    if (UNIV_UNLIKELY(len != 4)) {

        goto err_len;

    }

    type = mach_read_from_4(field);

    if (UNIV_UNLIKELY(type & (~0 << DICT_IT_BITS))) {

        return("unknown SYS_INDEXES.TYPE bits");

    }

 

    field = rec_get_nth_field_old(rec, 7/*SPACE*/, &len);

    if (UNIV_UNLIKELY(len != 4)) {

        goto err_len;

    }

    space = mach_read_from_4(field);

 

    field = rec_get_nth_field_old(rec, 8/*PAGE_NO*/, &len);

    if (UNIV_UNLIKELY(len != 4)) {

        goto err_len;

    }

 

    if (allocate) {

        *index = dict_mem_index_create(table_name, name_buf,

                            space, type, n_fields);

    } else {

        ut_a(*index);

 

        dict_mem_fill_index_struct(*index, NULL, NULL, name_buf,

                        space, type, n_fields);

    }

 

    (*index)->id = id;

    (*index)->page = mach_read_from_4(field);

    ut_ad((*index)->page);

 

    return(NULL);

}

 

> mysqld.exe!dict_load_index_low(unsigned char * table_id=0x1fc2d078, const char * table_name=0x1fc2cf08, mem_block_info_struct * heap=0x1fc2d008, const unsigned char * rec=0x17804224, unsigned long allocate=1, dict_index_struct * * index=0x21efe4cc)  Line 1359 C
  mysqld.exe!dict_load_indexes(dict_table_struct * table=0x1fc2cd78, mem_block_info_struct * heap=0x1fc2d008, dict_err_ignore ignore_err=DICT_ERR_IGNORE_NONE)  Line 1422 + 0x27 bytes C
  mysqld.exe!dict_load_table(const char * name=0x005081c8, unsigned long cached=1, dict_err_ignore ignore_err=DICT_ERR_IGNORE_NONE)  Line 1858 + 0x14 bytes C
  mysqld.exe!dict_load_table_on_id(unsigned __int64 table_id=15)  Line 2033 + 0x27 bytes C
  mysqld.exe!dict_table_get_on_id_low(unsigned __int64 table_id=15)  Line 905 + 0xd bytes C
  mysqld.exe!row_purge_parse_undo_rec(purge_node_struct * node=0x1fc221c0, unsigned long * updated_extern=0x21eff570, que_thr_struct * thr=0x1fc22158)  Line 684 + 0xd bytes C
  mysqld.exe!row_purge(purge_node_struct * node=0x1fc221c0, que_thr_struct * thr=0x1fc22158)  Line 758 + 0x21 bytes C
  mysqld.exe!row_purge_step(que_thr_struct * thr=0x1fc22158)  Line 805 + 0xd bytes C
  mysqld.exe!que_thr_step(que_thr_struct * thr=0x1fc22158)  Line 1247 + 0x9 bytes C
  mysqld.exe!que_run_threads_low(que_thr_struct * thr=0x1fc22158)  Line 1305 + 0x9 bytes C
  mysqld.exe!que_run_threads(que_thr_struct * thr=0x1fc22158)  Line 1342 + 0x9 bytes C
  mysqld.exe!trx_purge(unsigned long limit=20)  Line 1196 + 0x9 bytes C
  mysqld.exe!srv_master_do_purge()  Line 2687 + 0xc bytes C
  mysqld.exe!srv_master_thread(void * arg=0x00000000)  Line 3002 C
  kernel32.dll!764333aa()
  [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
  ntdll.dll!77009ef2()
  ntdll.dll!77009ec5()

上一篇:mysql open table创建table内存对象
下一篇:mysql计算具体某一行记录中,每列数据占的字节数。