Commit c0ac96d9 authored by marko's avatar marko

branches/zip: Prepare for upcoming implementation of page_zip_compress()

that will require complete index information.

dict_create_index_step(): invoke dict_index_add_to_cache() before btr_create()

dict_index_remove_from_cache(): make public

dict_index_get_if_in_cache_low(): new function, for holding dict_sys->mutex

buf_flush_init_for_writing(): remove the temporary hook to page_zip_compress()

page_create(): add temporary hook to page_zip_compress()
parent 05fbb8ca
...@@ -16,9 +16,6 @@ Created 11/11/1995 Heikki Tuuri ...@@ -16,9 +16,6 @@ Created 11/11/1995 Heikki Tuuri
#include "ut0byte.h" #include "ut0byte.h"
#include "ut0lst.h" #include "ut0lst.h"
#include "page0page.h" #include "page0page.h"
#if 1 /* testing */
# include "page0zip.h"
#endif
#include "fil0fil.h" #include "fil0fil.h"
#include "buf0buf.h" #include "buf0buf.h"
#include "buf0lru.h" #include "buf0lru.h"
...@@ -478,36 +475,6 @@ buf_flush_init_for_writing( ...@@ -478,36 +475,6 @@ buf_flush_init_for_writing(
mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
srv_use_checksums ? srv_use_checksums ?
buf_calc_page_old_checksum(page) : BUF_NO_CHECKSUM_MAGIC); buf_calc_page_old_checksum(page) : BUF_NO_CHECKSUM_MAGIC);
#if 1 /* testing */
if (space /* skip the system tablespace */
&& page_no != FSP_FIRST_INODE_PAGE_NO
&& page_no % XDES_DESCRIBED_PER_PAGE > FSP_IBUF_BITMAP_OFFSET) {
if (memcmp(page + PAGE_NEW_INFIMUM, "infimum", 8)) {
fprintf(stderr, "page %lu:%lu: cannot compress\n",
(ulong) space, (ulong) page_no);
} else {
byte zip_data[16384];
page_zip_des_t* page_zip =
&buf_block_align(page)->page_zip;
page_zip->data = zip_data;
page_zip->size = sizeof zip_data;
page_zip->m_start = page_zip->m_end = 0;
ut_a(page_zip_compress(page_zip, page));
fprintf(stderr,
"page %lu:%lu (%lu): zip size==%lu+%lu\n",
(ulong) space, (ulong) page_no,
(ulong) mach_read_from_2(page
+ (PAGE_HEADER + PAGE_LEVEL)),
(ulong) page_zip->m_start,
(ulong) 2
* (page_dir_get_n_heap(page_zip->data) - 2));
page_zip->data = NULL;
}
}
#endif /* testing */
} }
/************************************************************************ /************************************************************************
......
...@@ -1084,19 +1084,39 @@ dict_create_index_step( ...@@ -1084,19 +1084,39 @@ dict_create_index_step(
return(thr); return(thr);
} else { } else {
node->state = INDEX_CREATE_INDEX_TREE; node->state = INDEX_ADD_TO_CACHE;
} }
} }
if (node->state == INDEX_ADD_TO_CACHE) {
dulint index_id = node->index->id;
success = dict_index_add_to_cache(node->table, node->index,
FIL_NULL);
ut_a(success);
node->index = dict_index_get_if_in_cache_low(index_id);
ut_a(node->index);
err = DB_SUCCESS;
node->state = INDEX_CREATE_INDEX_TREE;
}
if (node->state == INDEX_CREATE_INDEX_TREE) { if (node->state == INDEX_CREATE_INDEX_TREE) {
err = dict_create_index_tree_step(node); err = dict_create_index_tree_step(node);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
dict_index_remove_from_cache(node->table, node->index);
node->index = NULL;
goto function_exit; goto function_exit;
} }
node->index->tree->page = node->page_no;
node->state = INDEX_COMMIT_WORK; node->state = INDEX_COMMIT_WORK;
} }
...@@ -1106,23 +1126,13 @@ dict_create_index_step( ...@@ -1106,23 +1126,13 @@ dict_create_index_step(
(CREATE INDEX does NOT currently do an implicit commit of (CREATE INDEX does NOT currently do an implicit commit of
the current transaction) */ the current transaction) */
node->state = INDEX_ADD_TO_CACHE; node->state = INDEX_CREATE_INDEX_TREE;
/* thr->run_node = node->commit_node; /* thr->run_node = node->commit_node;
return(thr); */ return(thr); */
} }
if (node->state == INDEX_ADD_TO_CACHE) {
success = dict_index_add_to_cache(node->table, node->index,
node->page_no);
ut_a(success);
err = DB_SUCCESS;
}
function_exit: function_exit:
trx->error_state = err; trx->error_state = err;
......
...@@ -105,14 +105,6 @@ dict_col_remove_from_cache( ...@@ -105,14 +105,6 @@ dict_col_remove_from_cache(
/*=======================*/ /*=======================*/
dict_table_t* table, /* in: table */ dict_table_t* table, /* in: table */
dict_col_t* col); /* in: column */ dict_col_t* col); /* in: column */
/**************************************************************************
Removes an index from the dictionary cache. */
static
void
dict_index_remove_from_cache(
/*=========================*/
dict_table_t* table, /* in: table */
dict_index_t* index); /* in, own: index */
/*********************************************************************** /***********************************************************************
Copies fields contained in index2 to index1. */ Copies fields contained in index2 to index1. */
static static
...@@ -1512,7 +1504,7 @@ dict_index_add_to_cache( ...@@ -1512,7 +1504,7 @@ dict_index_add_to_cache(
/************************************************************************** /**************************************************************************
Removes an index from the dictionary cache. */ Removes an index from the dictionary cache. */
static
void void
dict_index_remove_from_cache( dict_index_remove_from_cache(
/*=========================*/ /*=========================*/
...@@ -3582,23 +3574,22 @@ dict_foreign_parse_drop_constraints( ...@@ -3582,23 +3574,22 @@ dict_foreign_parse_drop_constraints(
/*==================== END OF FOREIGN KEY PROCESSING ====================*/ /*==================== END OF FOREIGN KEY PROCESSING ====================*/
/************************************************************************** /**************************************************************************
Returns an index object if it is found in the dictionary cache. */ Returns an index object if it is found in the dictionary cache.
Assumes that dict_sys->mutex is already being held. */
dict_index_t* dict_index_t*
dict_index_get_if_in_cache( dict_index_get_if_in_cache_low(
/*=======================*/ /*===========================*/
/* out: index, NULL if not found */ /* out: index, NULL if not found */
dulint index_id) /* in: index id */ dulint index_id) /* in: index id */
{ {
dict_table_t* table; dict_table_t* table;
dict_index_t* index; dict_index_t* index;
if (dict_sys == NULL) { #ifdef UNIV_SYNC_DEBUG
return(NULL); ut_ad(mutex_own(&(dict_sys->mutex)));
} #endif /* UNIV_SYNC_DEBUG */
mutex_enter(&(dict_sys->mutex));
table = UT_LIST_GET_FIRST(dict_sys->table_LRU); table = UT_LIST_GET_FIRST(dict_sys->table_LRU);
while (table) { while (table) {
...@@ -3607,7 +3598,7 @@ dict_index_get_if_in_cache( ...@@ -3607,7 +3598,7 @@ dict_index_get_if_in_cache(
while (index) { while (index) {
if (0 == ut_dulint_cmp(index->id, index_id)) { if (0 == ut_dulint_cmp(index->id, index_id)) {
goto found; return(index);
} }
index = UT_LIST_GET_NEXT(indexes, index); index = UT_LIST_GET_NEXT(indexes, index);
...@@ -3616,8 +3607,28 @@ dict_index_get_if_in_cache( ...@@ -3616,8 +3607,28 @@ dict_index_get_if_in_cache(
table = UT_LIST_GET_NEXT(table_LRU, table); table = UT_LIST_GET_NEXT(table_LRU, table);
} }
index = NULL; return(NULL);
found: }
/**************************************************************************
Returns an index object if it is found in the dictionary cache. */
dict_index_t*
dict_index_get_if_in_cache(
/*=======================*/
/* out: index, NULL if not found */
dulint index_id) /* in: index id */
{
dict_index_t* index;
if (dict_sys == NULL) {
return(NULL);
}
mutex_enter(&(dict_sys->mutex));
index = dict_index_get_if_in_cache_low(index_id);
mutex_exit(&(dict_sys->mutex)); mutex_exit(&(dict_sys->mutex));
return(index); return(index);
......
...@@ -524,6 +524,14 @@ dict_index_add_to_cache( ...@@ -524,6 +524,14 @@ dict_index_add_to_cache(
dict_index_t* index, /* in, own: index; NOTE! The index memory dict_index_t* index, /* in, own: index; NOTE! The index memory
object is freed in this function! */ object is freed in this function! */
ulint page_no);/* in: root page number of the index */ ulint page_no);/* in: root page number of the index */
/**************************************************************************
Removes an index from the dictionary cache. */
void
dict_index_remove_from_cache(
/*=========================*/
dict_table_t* table, /* in: table */
dict_index_t* index); /* in, own: index */
/************************************************************************ /************************************************************************
Gets the number of fields in the internal representation of an index, Gets the number of fields in the internal representation of an index,
including fields added by the dictionary system. */ including fields added by the dictionary system. */
...@@ -742,6 +750,15 @@ dict_is_mixed_table_rec( ...@@ -742,6 +750,15 @@ dict_is_mixed_table_rec(
dict_table_t* table, /* in: table in a mixed cluster */ dict_table_t* table, /* in: table in a mixed cluster */
rec_t* rec); /* in: user record in the clustered index */ rec_t* rec); /* in: user record in the clustered index */
/************************************************************************** /**************************************************************************
Returns an index object if it is found in the dictionary cache.
Assumes that dict_sys->mutex is already being held. */
dict_index_t*
dict_index_get_if_in_cache_low(
/*===========================*/
/* out: index, NULL if not found */
dulint index_id); /* in: index id */
/**************************************************************************
Returns an index object if it is found in the dictionary cache. */ Returns an index object if it is found in the dictionary cache. */
dict_index_t* dict_index_t*
......
...@@ -378,6 +378,9 @@ page_create( ...@@ -378,6 +378,9 @@ page_create(
page_t* page; page_t* page;
dict_index_t* index; dict_index_t* index;
ulint* offsets; ulint* offsets;
#if 1 /* testing */
byte zip_data[512];
#endif
if (UNIV_LIKELY(comp)) { if (UNIV_LIKELY(comp)) {
index = srv_sys->dummy_ind2; index = srv_sys->dummy_ind2;
...@@ -392,6 +395,13 @@ page_create( ...@@ -392,6 +395,13 @@ page_create(
ut_ad(PAGE_BTR_IBUF_FREE_LIST_NODE + FLST_NODE_SIZE ut_ad(PAGE_BTR_IBUF_FREE_LIST_NODE + FLST_NODE_SIZE
<= PAGE_DATA); <= PAGE_DATA);
/* The infimum and supremum records use a dummy index. */
if (UNIV_LIKELY(comp)) {
index = srv_sys->dummy_ind2;
} else {
index = srv_sys->dummy_ind1;
}
/* 1. INCREMENT MODIFY CLOCK */ /* 1. INCREMENT MODIFY CLOCK */
buf_frame_modify_clock_inc(frame); buf_frame_modify_clock_inc(frame);
...@@ -506,6 +516,14 @@ page_create( ...@@ -506,6 +516,14 @@ page_create(
rec_set_next_offs_old(supremum_rec, 0); rec_set_next_offs_old(supremum_rec, 0);
} }
#if 1 /* testing */
if (UNIV_LIKELY(comp)) {
page_zip = &buf_block_align(page)->page_zip;
page_zip->data = zip_data;
page_zip->size = sizeof zip_data;
page_zip->m_start = page_zip->m_end = 0;
}
#endif
if (UNIV_LIKELY_NULL(page_zip)) { if (UNIV_LIKELY_NULL(page_zip)) {
ut_ad(comp); ut_ad(comp);
...@@ -515,6 +533,9 @@ page_create( ...@@ -515,6 +533,9 @@ page_create(
ut_error; ut_error;
} }
} }
#if 1 /* testing */
buf_block_align(page)->page_zip.data = 0;
#endif
return(page); return(page);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment