Commit 41155195 authored by joreland@mysql.com's avatar joreland@mysql.com

Merge

parents 41e5d310 ff294177
Branches unavailable
Tags unavailable
No related merge requests found
......@@ -538,6 +538,7 @@ myisam/test2.MYD
myisam/test2.MYI
mysql-4.0.2-alpha-pc-linux-gnu-i686.tar.gz
mysql-4.0.2-alpha.tar.gz
mysql-5.0.2-alpha.tar.gz
mysql-max-4.0.2-alpha-pc-linux-gnu-i686.tar.gz
mysql-test/gmon.out
mysql-test/install_test_db
......@@ -816,7 +817,11 @@ scripts/mysqldumpslow
scripts/mysqlhotcopy
scripts/safe_mysqld
select_test
server-tools/instance-manager/client.c
server-tools/instance-manager/client_settings.h
server-tools/instance-manager/errmsg.c
server-tools/instance-manager/mysqlmanager
server-tools/instance-manager/thr_alarm.c
sql-bench/Results-linux/ATIS-mysql_bdb-Linux_2.2.14_my_SMP_i686
sql-bench/bench-count-distinct
sql-bench/bench-init.pl
......
......@@ -155,6 +155,7 @@ mysqldev@mysql.com
mysqldev@o2k.irixworld.net
ndbdev@eel.hemma.oreland.se
ndbdev@ndbmaster.mysql.com
ndbdev@shark.
nick@mysql.com
nick@nick.leippe.com
papa@gbichot.local
......@@ -200,6 +201,7 @@ serg@sergbook.mylan
serg@sergbook.mysql.com
sergefp@mysql.com
sinisa@rhols221.adsl.netsonic.fi
stewart@mysql.com
tfr@beta.frontier86.ee
tfr@indrek.tfr.cafe.ee
tfr@sarvik.tfr.cafe.ee
......
......@@ -91,6 +91,7 @@ main( int argc, char * argv[] )
mysql_real_connect( myData, NULL, NULL, NULL, NULL, MYSQL_PORT,
NULL, 0 ) )
{
myData->reconnect= 1;
if ( mysql_select_db( myData, szDB ) < 0 ) {
printf( "Can't select the %s database !\n", szDB ) ;
mysql_close( myData ) ;
......
......@@ -551,6 +551,7 @@ void CMySqlManagerView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
PostMessage(WM_COMMAND,IDM_TOOLS_SERVER_PROPERTIES);
return;
}
mysql.reconnect= 1;
if (!(result=mysql_list_processes(&mysql)))
{
return;
......@@ -576,6 +577,7 @@ void CMySqlManagerView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
);
return;
}
mysql.reconnect= 1;
if (!(result=mysql_list_dbs(&mysql,0)))
{
}
......@@ -603,6 +605,7 @@ void CMySqlManagerView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
);
return;
}
mysql.reconnect= 1;
CResourceDatabase* pRes = (CResourceDatabase*) pResource;
CString strDB = pResource->GetDisplayName();
strDB.TrimRight();
......@@ -641,6 +644,7 @@ void CMySqlManagerView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
);
return;
}
mysql.reconnect= 1;
HTREEITEM hParent = m_pTree->GetParentItem(hItem);
memset( &item, 0, sizeof(TV_ITEM) );
item.hItem = hParent;
......@@ -714,6 +718,7 @@ void CMySqlManagerView::OnRefresh()
{
return;
}
mysql.reconnect= 1;
memset( &item, 0, sizeof(TV_ITEM) );
item.hItem = hParent;
item.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_CHILDREN | TVIF_PARAM ;
......
......@@ -167,6 +167,7 @@ pthread_handler_decl(test_thread,arg)
perror("");
goto end;
}
mysql.reconnect= 1;
if (mysql_query(&mysql,"select 1") < 0)
{
fprintf(stderr,"Query failed (%s)\n",mysql_error(&mysql));
......
......@@ -1337,6 +1337,7 @@ void __fastcall TForm1::IsMySQLInit(void)
}
}
MySQL->reconnect= 1;
}
......@@ -1348,6 +1349,7 @@ void __fastcall TForm1::IsMySQLInit(void)
MySQL = mysql_init(MySQL);
if(mysql_real_connect(MySQL,host,user,password , 0, 0, NULL, 0))
IsConnect = true;
MySQL->reconnect= 1;
}
}
}
......
......@@ -2792,6 +2792,8 @@ sql_real_connect(char *host,char *database,char *user,char *password,
connected=1;
#ifndef EMBEDDED_LIBRARY
mysql.reconnect=info_flag ? 1 : 0; // We want to know if this happens
#else
mysql.reconnect= 1;
#endif
#ifdef HAVE_READLINE
build_completion_hash(rehash, 1);
......
......@@ -425,6 +425,7 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
if (mysql_real_connect(mysql,host,user,opt_password,NullS,tcp_port,
unix_port, 0))
{
mysql->reconnect= 1;
if (info)
{
fputs("\n",stderr);
......
......@@ -753,6 +753,7 @@ static MYSQL* safe_connect()
mysql_options(local_mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0))
die("failed on connect: %s", mysql_error(local_mysql));
local_mysql->reconnect= 1;
return local_mysql;
}
......
......@@ -628,6 +628,7 @@ static int dbConnect(char *host, char *user, char *passwd)
DBerror(&mysql_connection, "when trying to connect");
return 1;
}
mysql_connection.reconnect= 1;
return 0;
} /* dbConnect */
......
......@@ -1935,6 +1935,10 @@ static int dump_databases(char **db_names)
static int init_dumping(char *database)
{
if (mysql_get_server_version(sock) >= 50003 &&
!my_strcasecmp(&my_charset_latin1, database, "information_schema"))
return 1;
if (mysql_select_db(sock, database))
{
DBerror(sock, "when selecting the database");
......
......@@ -388,6 +388,7 @@ static MYSQL *db_connect(char *host, char *database, char *user, char *passwd)
ignore_errors=0; /* NO RETURN FROM db_error */
db_error(&mysql_connection);
}
mysql_connection.reconnect= 0;
if (verbose)
fprintf(stdout, "Selecting database %s\n", database);
if (mysql_select_db(sock, database))
......
......@@ -125,6 +125,7 @@ int main(int argc, char **argv)
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
exit(1);
}
mysql.reconnect= 1;
switch (argc)
{
......
......@@ -540,7 +540,6 @@ static void free_used_memory()
mysql_server_end();
if (ps_protocol)
ps_free_reg();
my_end(MY_CHECK_ERROR);
DBUG_VOID_RETURN;
}
......@@ -558,6 +557,7 @@ static void die(const char* fmt, ...)
}
va_end(args);
free_used_memory();
my_end(MY_CHECK_ERROR);
exit(1);
}
......@@ -570,6 +570,7 @@ static void abort_not_supported_test()
if (!silent)
printf("skipped\n");
free_used_memory();
my_end(MY_CHECK_ERROR);
exit(2);
}
......@@ -668,6 +669,7 @@ static int check_result(DYNAMIC_STRING* ds, const char* fname,
{
int error = 0;
int res=dyn_string_cmp(ds, fname);
DBUG_ENTER("check_result");
if (res && require_option)
abort_not_supported_test();
......@@ -687,7 +689,7 @@ static int check_result(DYNAMIC_STRING* ds, const char* fname,
}
if (error)
reject_dump(fname, ds->str, ds->length);
return error;
DBUG_RETURN(error);
}
......@@ -1627,6 +1629,7 @@ int safe_connect(MYSQL* con, const char* host, const char* user,
}
sleep(CON_RETRY_SLEEP);
}
con->reconnect= 1; /* TODO: change this to 0 in future versions */
return con_error;
}
......@@ -1841,7 +1844,10 @@ int read_line(char* buf, int size)
cur_file--;
lineno--;
if (cur_file == file_stack)
{
DBUG_PRINT("info", ("end of file"));
DBUG_RETURN(1);
}
continue;
}
......@@ -2011,7 +2017,6 @@ int read_query(struct st_query** q_ptr)
q->query_buf= q->query= 0;
if (read_line(read_query_buf, sizeof(read_query_buf)))
{
DBUG_PRINT("warning",("too long query"));
DBUG_RETURN(1);
}
DBUG_PRINT("info", ("query: %s", read_query_buf));
......@@ -3366,8 +3371,6 @@ int main(int argc, char **argv)
my_bool require_file=0, q_send_flag=0, abort_flag= 0;
char save_file[FN_REFLEN];
MY_INIT(argv[0]);
{
DBUG_ENTER("main");
/* Use all time until exit if no explicit 'start_timer' */
timer_start= timer_now();
......@@ -3394,6 +3397,8 @@ int main(int argc, char **argv)
*block_ok = 1;
init_dynamic_string(&ds_res, "", 0, 65536);
parse_args(argc, argv);
DBUG_PRINT("info",("result_file: '%s'", result_file ? result_file : ""));
if (mysql_server_init(embedded_server_arg_count,
embedded_server_args,
(char**) embedded_server_groups))
......@@ -3659,9 +3664,9 @@ int main(int argc, char **argv)
if (!got_end_timer)
timer_output(); /* No end_timer cmd, end it */
free_used_memory();
my_end(MY_CHECK_ERROR);
exit(error ? 1 : 0);
return error ? 1 : 0; /* Keep compiler happy */
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -262,9 +262,10 @@ btr_pcur_restore_position(
heap = mem_heap_create(256);
offsets1 = rec_get_offsets(cursor->old_rec,
index, ULINT_UNDEFINED, heap);
offsets2 = rec_get_offsets(rec,
index, ULINT_UNDEFINED, heap);
index, NULL,
cursor->old_n_fields, &heap);
offsets2 = rec_get_offsets(rec, index, NULL,
cursor->old_n_fields, &heap);
ut_ad(cmp_rec_rec(cursor->old_rec,
rec, offsets1, offsets2,
......@@ -310,7 +311,7 @@ btr_pcur_restore_position(
&& 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor),
rec_get_offsets(btr_pcur_get_rec(cursor),
btr_pcur_get_btr_cur(cursor)->index,
ULINT_UNDEFINED, heap))) {
NULL, ULINT_UNDEFINED, &heap))) {
/* We have to store the NEW value for the modify clock, since
the cursor can now be on a different page! But we can retain
......
This diff is collapsed.
......@@ -460,12 +460,12 @@ buf_block_init(
block->file_page_was_freed = FALSE;
block->check_index_page_at_flush = FALSE;
block->index = NULL;
block->in_free_list = FALSE;
block->in_LRU_list = FALSE;
block->n_pointers = 0;
block->hash_nodes = NULL;
rw_lock_create(&(block->lock));
ut_ad(rw_lock_validate(&(block->lock)));
......@@ -1536,6 +1536,7 @@ buf_page_init(
block->offset = offset;
block->check_index_page_at_flush = FALSE;
block->index = NULL;
block->lock_hash_val = lock_rec_hash(space, offset);
block->lock_mutex = NULL;
......
......@@ -823,7 +823,6 @@ buf_LRU_block_free_non_file_page(
|| (block->state == BUF_BLOCK_READY_FOR_USE));
ut_a(block->n_pointers == 0);
ut_a(block->hash_nodes == NULL);
ut_a(!block->in_free_list);
block->state = BUF_BLOCK_NOT_USED;
......
......@@ -65,53 +65,10 @@ ha_create(
return(table);
}
/*****************************************************************
Removes an adaptive hash index node from the doubly linked list of hash nodes
for the buffer block. */
UNIV_INLINE
void
ha_remove_buf_block_node(
/*=====================*/
buf_block_t* block, /* in: buffer block */
ha_node_t* node) /* in: an adaptive hash index node */
{
if (node == block->hash_nodes) {
block->hash_nodes = node->next_for_block;
}
if (node->prev_for_block != NULL) {
(node->prev_for_block)->next_for_block = node->next_for_block;
}
if (node->next_for_block != NULL) {
(node->next_for_block)->prev_for_block = node->prev_for_block;
}
}
/*****************************************************************
Adds an adaptive hash index node to the start of the doubly linked list of
hash nodes for the buffer block. */
UNIV_INLINE
void
ha_add_buf_block_node(
/*==================*/
buf_block_t* block, /* in: buffer block */
ha_node_t* node) /* in: an adaptive hash index node */
{
node->next_for_block = block->hash_nodes;
node->prev_for_block = NULL;
block->hash_nodes = node;
if (node->next_for_block != NULL) {
(node->next_for_block)->prev_for_block = node;
}
}
/*****************************************************************
Inserts an entry into a hash table. If an entry with the same fold number
is found, its node is updated to point to the new data, and no new node
is inserted. This function is only used in the adaptive hash index. */
is inserted. */
ibool
ha_insert_for_fold(
......@@ -127,7 +84,6 @@ ha_insert_for_fold(
{
hash_cell_t* cell;
ha_node_t* node;
buf_block_t* block;
ha_node_t* prev_node;
buf_block_t* prev_block;
ulint hash;
......@@ -136,9 +92,6 @@ ha_insert_for_fold(
#ifdef UNIV_SYNC_DEBUG
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
#endif /* UNIV_SYNC_DEBUG */
block = buf_block_align(data);
hash = hash_calc_hash(fold, table);
cell = hash_get_nth_cell(table, hash);
......@@ -151,15 +104,7 @@ ha_insert_for_fold(
prev_block = buf_block_align(prev_node->data);
ut_a(prev_block->n_pointers > 0);
prev_block->n_pointers--;
block->n_pointers++;
if (prev_block != block) {
ha_remove_buf_block_node(prev_block,
prev_node);
ha_add_buf_block_node(block,
prev_node);
}
buf_block_align(data)->n_pointers++;
}
prev_node->data = data;
......@@ -186,9 +131,7 @@ ha_insert_for_fold(
ha_node_set_data(node, data);
if (table->adaptive) {
block->n_pointers++;
ha_add_buf_block_node(block, node);
buf_block_align(data)->n_pointers++;
}
node->fold = fold;
......@@ -223,15 +166,9 @@ ha_delete_hash_node(
hash_table_t* table, /* in: hash table */
ha_node_t* del_node) /* in: node to be deleted */
{
buf_block_t* block;
if (table->adaptive) {
block = buf_block_align(del_node->data);
ut_a(block->n_pointers > 0);
block->n_pointers--;
ha_remove_buf_block_node(block, del_node);
ut_a(buf_block_align(del_node->data)->n_pointers > 0);
buf_block_align(del_node->data)->n_pointers--;
}
HASH_DELETE_AND_COMPACT(ha_node_t, next, table, del_node);
......@@ -272,8 +209,6 @@ ha_search_and_update_if_found(
void* data, /* in: pointer to the data */
void* new_data)/* in: new pointer to the data */
{
buf_block_t* old_block;
buf_block_t* block;
ha_node_t* node;
#ifdef UNIV_SYNC_DEBUG
......@@ -285,15 +220,8 @@ ha_search_and_update_if_found(
if (node) {
if (table->adaptive) {
ut_a(buf_block_align(node->data)->n_pointers > 0);
old_block = buf_block_align(node->data);
ut_a(old_block->n_pointers > 0);
old_block->n_pointers--;
ha_remove_buf_block_node(old_block, node);
block = buf_block_align(new_data);
block->n_pointers++;
ha_add_buf_block_node(block, node);
buf_block_align(node->data)->n_pointers--;
buf_block_align(new_data)->n_pointers++;
}
node->data = new_data;
......@@ -308,25 +236,43 @@ void
ha_remove_all_nodes_to_page(
/*========================*/
hash_table_t* table, /* in: hash table */
ulint fold, /* in: fold value */
page_t* page) /* in: buffer page */
{
buf_block_t* block;
ha_node_t* node;
block = buf_block_align(page);
node = block->hash_nodes;
#ifdef UNIV_SYNC_DEBUG
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
#endif /* UNIV_SYNC_DEBUG */
node = ha_chain_get_first(table, fold);
while (node) {
/* Remove the hash node */
if (buf_frame_align(ha_node_get_data(node)) == page) {
/* Remove the hash node */
ha_delete_hash_node(table, node);
ha_delete_hash_node(table, node);
/* Start again from the first node in the chain
because the deletion may compact the heap of
nodes and move other nodes! */
node = block->hash_nodes;
node = ha_chain_get_first(table, fold);
} else {
node = ha_chain_get_next(node);
}
}
#ifdef UNIV_DEBUG
/* Check that all nodes really got deleted */
ut_a(block->n_pointers == 0);
ut_a(block->hash_nodes == NULL);
node = ha_chain_get_first(table, fold);
while (node) {
ut_a(buf_frame_align(ha_node_get_data(node)) != page);
node = ha_chain_get_next(node);
}
#endif
}
/*****************************************************************
......@@ -406,7 +352,6 @@ ha_print_info(
n_bufs++;
}
fprintf(file, ", node heap has %lu buffer(s)\n",
(ulong) n_bufs);
fprintf(file, ", node heap has %lu buffer(s)\n", (ulong) n_bufs);
}
}
......@@ -2812,7 +2812,6 @@ ibuf_insert_to_index_page(
rec_t* rec;
page_t* bitmap_page;
ulint old_bits;
mem_heap_t* heap;
ut_ad(ibuf_inside());
ut_ad(dtuple_check_typed(entry));
......@@ -2824,12 +2823,9 @@ ibuf_insert_to_index_page(
goto dump;
}
heap = mem_heap_create(100);
rec = page_rec_get_next(page_get_infimum_rec(page));
if (rec_offs_n_fields(rec_get_offsets(rec, index, ULINT_UNDEFINED,
heap)) != dtuple_get_n_fields(entry)) {
mem_heap_free(heap);
if (rec_get_n_fields(rec, index) != dtuple_get_n_fields(entry)) {
fputs(
"InnoDB: Trying to insert a record from the insert buffer to an index page\n"
"InnoDB: but the number of fields does not match!\n", stderr);
......@@ -2847,7 +2843,6 @@ ibuf_insert_to_index_page(
return;
}
mem_heap_free(heap);
low_match = page_cur_search(page, index, entry,
PAGE_CUR_LE, &page_cur);
......
......@@ -130,10 +130,9 @@ btr_search_update_hash_on_delete(
Validates the search system. */
ibool
btr_search_validate(
/*================*/
btr_search_validate(void);
/*======================*/
/* out: TRUE if ok */
dict_index_t* index); /* in: record descriptor */
/* Search info directions */
#define BTR_SEA_NO_DIRECTION 1
......
......@@ -29,7 +29,6 @@ Created 11/5/1995 Heikki Tuuri
#include "buf0types.h"
#include "sync0rw.h"
#include "hash0hash.h"
#include "ha0ha.h"
#include "ut0byte.h"
#include "os0proc.h"
......@@ -740,6 +739,8 @@ struct buf_block_struct{
buffer pool which are index pages,
but this flag is not set because
we do not keep track of all pages */
dict_index_t* index; /* index for which the adaptive
hash index has been created */
/* 2. Page flushing fields */
UT_LIST_NODE_T(buf_block_t) flush_list;
......@@ -826,7 +827,7 @@ struct buf_block_struct{
records with the same prefix should be
indexed in the hash index */
/* The following 6 fields are protected by btr_search_latch: */
/* The following 4 fields are protected by btr_search_latch: */
ibool is_hashed; /* TRUE if hash index has already been
built on this page; note that it does
......@@ -843,11 +844,6 @@ struct buf_block_struct{
ulint curr_side; /* BTR_SEARCH_LEFT_SIDE or
BTR_SEARCH_RIGHT_SIDE in hash
indexing */
ha_node_t* hash_nodes; /* a doubly linked list of hash nodes
for this buffer block; this points to
the first node in the list if any;
note that we do not use UT_LST_ macros
to manipulate this list */
/* 6. Debug fields */
#ifdef UNIV_SYNC_DEBUG
rw_lock_t debug_latch; /* in the debug version, each thread
......
......@@ -54,7 +54,7 @@ ha_create(
/*****************************************************************
Inserts an entry into a hash table. If an entry with the same fold number
is found, its node is updated to point to the new data, and no new node
is inserted. This function is only used in the adaptive hash index. */
is inserted. */
ibool
ha_insert_for_fold(
......@@ -111,6 +111,7 @@ void
ha_remove_all_nodes_to_page(
/*========================*/
hash_table_t* table, /* in: hash table */
ulint fold, /* in: fold value */
page_t* page); /* in: buffer page */
/*****************************************************************
Validates a hash table. */
......@@ -133,18 +134,9 @@ ha_print_info(
typedef struct ha_node_struct ha_node_t;
struct ha_node_struct {
ha_node_t* next; /* next chain node; NULL if none */
void* data; /* pointer to the data */
ulint fold; /* fold value for the data */
ha_node_t* next_for_block;/* in an adaptive hash index
(btr0sea.c), a doubly linked list of hash
nodes for the buffer block; these nodes
contain pointers to index records on the
page; in the last node this field is NULL;
note that we do not use UT_LST_ macros
to manipulate this list */
ha_node_t* prev_for_block;/* pointer to the previous node; in the
first node NULL */
ha_node_t* next; /* next chain node or NULL if none */
void* data; /* pointer to the data */
ulint fold; /* fold value for the data */
};
#ifndef UNIV_NONINL
......
......@@ -166,7 +166,7 @@ hash_get_n_cells(
/***********************************************************************
Deletes a struct which is stored in the heap of the hash table, and compacts
the heap. The fold value must be stored in the struct NODE in a field named
'fold'. This macro is only used for the adaptive hash index. */
'fold'. */
#define HASH_DELETE_AND_COMPACT(TYPE, NAME, TABLE, NODE)\
do {\
......@@ -191,23 +191,11 @@ do {\
/* Copy the top node in place of NODE */\
\
*(NODE) = *top_node111;\
\
/* Update the adaptive hash list of the buffer block that\
corresponds to the top node */\
if (top_node111->next_for_block != NULL) {\
(top_node111->next_for_block)->prev_for_block = NODE;\
}\
\
if (top_node111->prev_for_block != NULL) {\
(top_node111->prev_for_block)->next_for_block = NODE;\
} else {\
buf_block_align(top_node111->data)->hash_nodes = NODE;\
}\
\
/* Look for the hash pointer to the top node, to update it */\
\
cell111 = hash_get_nth_cell(TABLE,\
hash_calc_hash(top_node111->fold, TABLE));\
\
/* Look for the pointer to the top node, to update it */\
\
if (cell111->node == top_node111) {\
/* The top node is the first in the chain */\
......
......@@ -345,6 +345,33 @@ lock_clust_rec_read_check_and_lock(
LOCK_REC_NOT_GAP */
que_thr_t* thr); /* in: query thread */
/*************************************************************************
Checks if locks of other transactions prevent an immediate read, or passing
over by a read cursor, of a clustered index record. If they do, first tests
if the query thread should anyway be suspended for some reason; if not, then
puts the transaction and the query thread to the lock wait state and inserts a
waiting request for a record lock to the lock queue. Sets the requested mode
lock on the record. This is an alternative version of
lock_clust_rec_read_check_and_lock() that does not require the parameter
"offsets". */
ulint
lock_clust_rec_read_check_and_lock_alt(
/*===================================*/
/* out: DB_SUCCESS, DB_LOCK_WAIT,
DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
does nothing */
rec_t* rec, /* in: user record or page supremum record
which should be read or passed over by a read
cursor */
dict_index_t* index, /* in: clustered index */
ulint mode, /* in: mode of the lock which the read cursor
should set on records: LOCK_S or LOCK_X; the
latter is possible in SELECT FOR UPDATE */
ulint gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
LOCK_REC_NOT_GAP */
que_thr_t* thr); /* in: query thread */
/*************************************************************************
Checks that a record is seen in a consistent read. */
ibool
......
......@@ -67,6 +67,16 @@ rec_get_n_fields_old(
/* out: number of data fields */
rec_t* rec); /* in: physical record */
/**********************************************************
The following function is used to get the number of fields
in a record. */
UNIV_INLINE
ulint
rec_get_n_fields(
/*=============*/
/* out: number of data fields */
rec_t* rec, /* in: physical record */
dict_index_t* index); /* in: record descriptor */
/**********************************************************
The following function is used to get the number of records
owned by the previous directory record. */
UNIV_INLINE
......@@ -188,45 +198,28 @@ rec_get_1byte_offs_flag(
rec_t* rec); /* in: physical record */
/**********************************************************
The following function determines the offsets to each field
in the record. The offsets are returned in an array of
ulint, with [0] being the number of fields (n), [1] being the
extra size (if REC_OFFS_COMPACT is set, the record is in the new
format), and [2]..[n+1] being the offsets past the end of
fields 0..n, or to the beginning of fields 1..n+1. When the
high-order bit of the offset at [n+1] is set (REC_OFFS_SQL_NULL),
the field n is NULL. When the second high-order bit of the offset
at [n+1] is set (REC_OFFS_EXTERNAL), the field n is being stored
externally. */
ulint*
rec_get_offsets(
/*============*/
/* out: the offsets */
rec_t* rec, /* in: physical record */
dict_index_t* index, /* in: record descriptor */
ulint n_fields,/* in: maximum number of initialized fields
(ULINT_UNDEFINED if all fields) */
mem_heap_t* heap); /* in: memory heap */
/**********************************************************
The following function determines the offsets to each field
in the record. It differs from rec_get_offsets() by trying to
reuse a previously returned array. */
in the record. It can reuse a previously allocated array. */
ulint*
rec_reget_offsets(
/*==============*/
rec_get_offsets_func(
/*=================*/
/* out: the new offsets */
rec_t* rec, /* in: physical record */
dict_index_t* index, /* in: record descriptor */
ulint* offsets,/* in: array of offsets
from rec_get_offsets()
or rec_reget_offsets(), or NULL */
ulint* offsets,/* in: array consisting of offsets[0]
allocated elements, or an array from
rec_get_offsets(), or NULL */
ulint n_fields,/* in: maximum number of initialized fields
(ULINT_UNDEFINED if all fields) */
mem_heap_t* heap); /* in: memory heap */
mem_heap_t** heap, /* in/out: memory heap */
const char* file, /* in: file name where called */
ulint line); /* in: line number where called */
#define rec_get_offsets(rec,index,offsets,n,heap) \
rec_get_offsets_func(rec,index,offsets,n,heap,__FILE__,__LINE__)
/****************************************************************
Validates offsets returned by rec_get_offsets() or rec_reget_offsets(). */
Validates offsets returned by rec_get_offsets(). */
UNIV_INLINE
ibool
rec_offs_validate(
......@@ -234,8 +227,7 @@ rec_offs_validate(
/* out: TRUE if valid */
rec_t* rec, /* in: record or NULL */
dict_index_t* index, /* in: record descriptor or NULL */
const ulint* offsets);/* in: array returned by rec_get_offsets()
or rec_reget_offsets() */
const ulint* offsets);/* in: array returned by rec_get_offsets() */
/****************************************************************
Updates debug data in offsets, in order to avoid bogus
rec_offs_validate() failures. */
......@@ -243,10 +235,9 @@ UNIV_INLINE
void
rec_offs_make_valid(
/*================*/
const rec_t* rec, /* in: record */
const dict_index_t* index,/* in: record descriptor */
ulint* offsets);/* in: array returned by rec_get_offsets()
or rec_reget_offsets() */
rec_t* rec, /* in: record */
dict_index_t* index,/* in: record descriptor */
ulint* offsets);/* in: array returned by rec_get_offsets() */
/****************************************************************
The following function is used to get a pointer to the nth
......@@ -551,7 +542,15 @@ rec_print_old(
/*==========*/
FILE* file, /* in: file where to print */
rec_t* rec); /* in: physical record */
/*******************************************************************
Prints a physical record. */
void
rec_print_new(
/*==========*/
FILE* file, /* in: file where to print */
rec_t* rec, /* in: physical record */
const ulint* offsets);/* in: array returned by rec_get_offsets() */
/*******************************************************************
Prints a physical record. */
......@@ -560,7 +559,7 @@ rec_print(
/*======*/
FILE* file, /* in: file where to print */
rec_t* rec, /* in: physical record */
const ulint* offsets);/* in: array returned by rec_get_offsets() */
dict_index_t* index); /* in: record descriptor */
#define REC_INFO_BITS 6 /* This is single byte bit-field */
......
......@@ -681,9 +681,11 @@ rec_2_get_field_end_info(
}
#ifdef UNIV_DEBUG
# define REC_OFFS_HEADER_SIZE 3
/* Length of the rec_get_offsets() header */
# define REC_OFFS_HEADER_SIZE 4
#else /* UNIV_DEBUG */
# define REC_OFFS_HEADER_SIZE 1
/* Length of the rec_get_offsets() header */
# define REC_OFFS_HEADER_SIZE 2
#endif /* UNIV_DEBUG */
/* Get the base address of offsets. The extra_size is stored at
......@@ -691,8 +693,40 @@ this position, and following positions hold the end offsets of
the fields. */
#define rec_offs_base(offsets) (offsets + REC_OFFS_HEADER_SIZE)
/**************************************************************
The following function returns the number of allocated elements
for an array of offsets. */
UNIV_INLINE
ulint
rec_offs_get_n_alloc(
/*=================*/
/* out: number of elements */
const ulint* offsets)/* in: array for rec_get_offsets() */
{
ulint n_alloc;
ut_ad(offsets);
n_alloc = offsets[0];
ut_ad(n_alloc > 0);
return(n_alloc);
}
/**************************************************************
The following function sets the number of allocated elements
for an array of offsets. */
UNIV_INLINE
void
rec_offs_set_n_alloc(
/*=================*/
ulint* offsets, /* in: array for rec_get_offsets() */
ulint n_alloc) /* in: number of elements */
{
ut_ad(offsets);
ut_ad(n_alloc > 0);
offsets[0] = n_alloc;
}
/****************************************************************
Validates offsets returned by rec_get_offsets() or rec_reget_offsets(). */
Validates offsets returned by rec_get_offsets(). */
UNIV_INLINE
ibool
rec_offs_validate(
......@@ -705,16 +739,16 @@ rec_offs_validate(
ulint i = rec_offs_n_fields(offsets);
ulint last = ULINT_MAX;
ibool comp = (*rec_offs_base(offsets) & REC_OFFS_COMPACT) != 0;
ut_a(offsets);
if (rec) {
ut_ad((ulint) rec == offsets[1]);
ut_ad((ulint) rec == offsets[2]);
if (!comp) {
ut_a(rec_get_n_fields_old(rec) >= i);
}
}
if (index) {
ulint max_n_fields;
ut_ad((ulint) index == offsets[2]);
ut_ad((ulint) index == offsets[3]);
max_n_fields = ut_max(
dict_index_get_n_fields(index),
dict_index_get_n_unique_in_tree(index) + 1);
......@@ -734,7 +768,9 @@ rec_offs_validate(
ut_error;
}
}
ut_a(i <= max_n_fields);
/* index->n_def == 0 for dummy indexes if !comp */
ut_a(!comp || index->n_def);
ut_a(!index->n_def || i <= max_n_fields);
}
while (i--) {
ulint curr = rec_offs_base(offsets)[1 + i] & REC_OFFS_MASK;
......@@ -750,17 +786,17 @@ UNIV_INLINE
void
rec_offs_make_valid(
/*================*/
const rec_t* rec __attribute__((unused)),
rec_t* rec __attribute__((unused)),
/* in: record */
const dict_index_t* index __attribute__((unused)),
dict_index_t* index __attribute__((unused)),
/* in: record descriptor */
ulint* offsets __attribute__((unused)))
/* in: array returned by rec_get_offsets()
or rec_reget_offsets() */
/* in: array returned by rec_get_offsets() */
{
#ifdef UNIV_DEBUG
offsets[1] = (ulint) rec;
offsets[2] = (ulint) index;
ut_ad(rec_get_n_fields(rec, index) >= rec_offs_n_fields(offsets));
offsets[2] = (ulint) rec;
offsets[3] = (ulint) index;
#endif /* UNIV_DEBUG */
}
......@@ -1146,12 +1182,31 @@ rec_offs_n_fields(
{
ulint n_fields;
ut_ad(offsets);
n_fields = offsets[0];
n_fields = offsets[1];
ut_ad(n_fields > 0);
ut_ad(n_fields <= REC_MAX_N_FIELDS);
ut_ad(n_fields + REC_OFFS_HEADER_SIZE
<= rec_offs_get_n_alloc(offsets));
return(n_fields);
}
/**************************************************************
The following function sets the number of fields in offsets. */
UNIV_INLINE
void
rec_offs_set_n_fields(
/*==================*/
ulint* offsets, /* in: array returned by rec_get_offsets() */
ulint n_fields) /* in: number of fields */
{
ut_ad(offsets);
ut_ad(n_fields > 0);
ut_ad(n_fields <= REC_MAX_N_FIELDS);
ut_ad(n_fields + REC_OFFS_HEADER_SIZE
<= rec_offs_get_n_alloc(offsets));
offsets[1] = n_fields;
}
/**************************************************************
The following function returns the data size of a physical
record, that is the sum of field lengths. SQL null fields
......
......@@ -424,7 +424,7 @@ lock_check_trx_id_sanity(
/* out: TRUE if ok */
dulint trx_id, /* in: trx id */
rec_t* rec, /* in: user record */
dict_index_t* index, /* in: clustered index */
dict_index_t* index, /* in: index */
const ulint* offsets, /* in: rec_get_offsets(rec, index) */
ibool has_kernel_mutex)/* in: TRUE if the caller owns the
kernel mutex */
......@@ -445,7 +445,7 @@ lock_check_trx_id_sanity(
fputs(" InnoDB: Error: transaction id associated"
" with record\n",
stderr);
rec_print(stderr, rec, offsets);
rec_print_new(stderr, rec, offsets);
fputs("InnoDB: in ", stderr);
dict_index_name_print(stderr, NULL, index);
fprintf(stderr, "\n"
......@@ -4073,10 +4073,9 @@ lock_rec_print(
ulint page_no;
ulint i;
mtr_t mtr;
mem_heap_t* heap;
ulint* offsets = NULL;
heap = mem_heap_create(100);
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
......@@ -4157,9 +4156,9 @@ lock_rec_print(
if (page) {
rec_t* rec
= page_find_rec_with_heap_no(page, i);
offsets = rec_reget_offsets(rec, lock->index,
offsets, ULINT_UNDEFINED, heap);
rec_print(file, rec, offsets);
offsets = rec_get_offsets(rec, lock->index,
offsets, ULINT_UNDEFINED, &heap);
rec_print_new(file, rec, offsets);
}
putc('\n', file);
......@@ -4167,9 +4166,11 @@ lock_rec_print(
}
mtr_commit(&mtr);
mem_heap_free(heap);
}
if (heap) {
mem_heap_free(heap);
}
}
/*************************************************************************
Calculates the number of record lock structs in the record lock hash table. */
static
......@@ -4562,12 +4563,13 @@ lock_rec_validate_page(
page_t* page;
lock_t* lock;
rec_t* rec;
ulint nth_lock = 0;
ulint nth_bit = 0;
ulint nth_lock = 0;
ulint nth_bit = 0;
ulint i;
mtr_t mtr;
mem_heap_t* heap = mem_heap_create(100);
ulint* offsets = NULL;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex));
......@@ -4607,8 +4609,8 @@ lock_rec_validate_page(
index = lock->index;
rec = page_find_rec_with_heap_no(page, i);
offsets = rec_reget_offsets(rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
fprintf(stderr,
"Validating %lu %lu\n", (ulong) space, (ulong) page_no);
......@@ -4635,7 +4637,9 @@ lock_rec_validate_page(
mtr_commit(&mtr);
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
return(TRUE);
}
......@@ -4811,11 +4815,15 @@ lock_rec_insert_check_and_lock(
#ifdef UNIV_DEBUG
{
mem_heap_t* heap = mem_heap_create(100);
const ulint* offsets = rec_get_offsets(next_rec, index,
ULINT_UNDEFINED, heap);
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
const ulint* offsets = rec_get_offsets(
next_rec, index, offsets_,
ULINT_UNDEFINED, &heap);
ut_ad(lock_rec_queue_validate(next_rec, index, offsets));
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
}
#endif /* UNIV_DEBUG */
......@@ -4954,11 +4962,14 @@ lock_sec_rec_modify_check_and_lock(
#ifdef UNIV_DEBUG
{
mem_heap_t* heap = mem_heap_create(100);
const ulint* offsets = rec_get_offsets(rec, index,
ULINT_UNDEFINED, heap);
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
const ulint* offsets = rec_get_offsets(
rec, index, offsets_, ULINT_UNDEFINED, &heap);
ut_ad(lock_rec_queue_validate(rec, index, offsets));
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
}
#endif /* UNIV_DEBUG */
......@@ -5067,7 +5078,6 @@ lock_clust_rec_read_check_and_lock(
ut_ad(page_rec_is_user_rec(rec) || page_rec_is_supremum(rec));
ut_ad(gap_mode == LOCK_ORDINARY || gap_mode == LOCK_GAP
|| gap_mode == LOCK_REC_NOT_GAP);
ut_ad(index->type & DICT_CLUSTERED);
ut_ad(rec_offs_validate(rec, index, offsets));
if (flags & BTR_NO_LOCKING_FLAG) {
......@@ -5095,3 +5105,45 @@ lock_clust_rec_read_check_and_lock(
return(err);
}
/*************************************************************************
Checks if locks of other transactions prevent an immediate read, or passing
over by a read cursor, of a clustered index record. If they do, first tests
if the query thread should anyway be suspended for some reason; if not, then
puts the transaction and the query thread to the lock wait state and inserts a
waiting request for a record lock to the lock queue. Sets the requested mode
lock on the record. This is an alternative version of
lock_clust_rec_read_check_and_lock() that does not require the parameter
"offsets". */
ulint
lock_clust_rec_read_check_and_lock_alt(
/*===================================*/
/* out: DB_SUCCESS, DB_LOCK_WAIT,
DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
does nothing */
rec_t* rec, /* in: user record or page supremum record
which should be read or passed over by a read
cursor */
dict_index_t* index, /* in: clustered index */
ulint mode, /* in: mode of the lock which the read cursor
should set on records: LOCK_S or LOCK_X; the
latter is possible in SELECT FOR UPDATE */
ulint gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
LOCK_REC_NOT_GAP */
que_thr_t* thr) /* in: query thread */
{
mem_heap_t* tmp_heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ulint ret;
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &tmp_heap);
ret = lock_clust_rec_read_check_and_lock(flags, rec, index,
offsets, mode, gap_mode, thr);
if (tmp_heap) {
mem_heap_free(tmp_heap);
}
return(ret);
}
......@@ -29,6 +29,7 @@ UNIV_INLINE
ibool
page_cur_try_search_shortcut(
/*=========================*/
/* out: TRUE on success */
page_t* page, /* in: index page */
dict_index_t* index, /* in: record descriptor */
dtuple_t* tuple, /* in: data tuple */
......@@ -56,14 +57,15 @@ page_cur_try_search_shortcut(
#ifdef UNIV_SEARCH_DEBUG
page_cur_t cursor2;
#endif
mem_heap_t* heap;
ulint* offsets;
ibool success = FALSE;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ut_ad(dtuple_check_typed(tuple));
rec = page_header_get_ptr(page, PAGE_LAST_INSERT);
heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, index,
dtuple_get_n_fields(tuple), heap);
offsets = rec_get_offsets(rec, index, offsets,
dtuple_get_n_fields(tuple), &heap);
ut_ad(rec);
ut_ad(page_rec_is_user_rec(rec));
......@@ -78,21 +80,17 @@ page_cur_try_search_shortcut(
cmp = page_cmp_dtuple_rec_with_match(tuple, rec, offsets, &low_match,
&low_bytes);
if (cmp == -1) {
mem_heap_free(heap);
return(FALSE);
goto exit_func;
}
next_rec = page_rec_get_next(rec);
offsets = rec_reget_offsets(next_rec, index, offsets,
dtuple_get_n_fields(tuple), heap);
offsets = rec_get_offsets(next_rec, index, offsets,
dtuple_get_n_fields(tuple), &heap);
cmp = page_cmp_dtuple_rec_with_match(tuple, next_rec, offsets,
&up_match, &up_bytes);
if (cmp != -1) {
mem_heap_free(heap);
return(FALSE);
goto exit_func;
}
cursor->rec = rec;
......@@ -127,8 +125,12 @@ page_cur_try_search_shortcut(
#ifdef UNIV_SEARCH_PERF_STAT
page_cur_short_succ++;
#endif
mem_heap_free(heap);
return(TRUE);
success = TRUE;
exit_func:
if (heap) {
mem_heap_free(heap);
}
return(success);
}
#endif
......@@ -226,8 +228,9 @@ page_cur_search_with_match(
ulint dbg_matched_fields;
ulint dbg_matched_bytes;
#endif
mem_heap_t* heap;
ulint* offsets = NULL;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ut_ad(page && tuple && iup_matched_fields && iup_matched_bytes
&& ilow_matched_fields && ilow_matched_bytes && cursor);
......@@ -262,8 +265,6 @@ page_cur_search_with_match(
/*#endif */
#endif
heap = mem_heap_create(100);
/* The following flag does not work for non-latin1 char sets because
cmp_full_field does not tell how many bytes matched */
ut_a(mode != PAGE_CUR_LE_OR_EXTENDS);
......@@ -298,8 +299,8 @@ page_cur_search_with_match(
low_matched_fields, low_matched_bytes,
up_matched_fields, up_matched_bytes);
offsets = rec_reget_offsets(mid_rec, index, offsets,
dtuple_get_n_fields_cmp(tuple), heap);
offsets = rec_get_offsets(mid_rec, index, offsets,
dtuple_get_n_fields_cmp(tuple), &heap);
cmp = cmp_dtuple_rec_with_match(tuple, mid_rec, offsets,
&cur_matched_fields,
......@@ -310,8 +311,8 @@ page_cur_search_with_match(
low_matched_bytes = cur_matched_bytes;
} else if (cmp == -1) {
offsets = rec_reget_offsets(mid_rec, index,
offsets, dtuple_get_n_fields_cmp(tuple), heap);
offsets = rec_get_offsets(mid_rec, index, offsets,
dtuple_get_n_fields_cmp(tuple), &heap);
if (mode == PAGE_CUR_LE_OR_EXTENDS
&& page_cur_rec_field_extends(tuple, mid_rec,
......@@ -353,8 +354,8 @@ page_cur_search_with_match(
low_matched_fields, low_matched_bytes,
up_matched_fields, up_matched_bytes);
offsets = rec_reget_offsets(mid_rec, index,
offsets, dtuple_get_n_fields_cmp(tuple), heap);
offsets = rec_get_offsets(mid_rec, index, offsets,
dtuple_get_n_fields_cmp(tuple), &heap);
cmp = cmp_dtuple_rec_with_match(tuple, mid_rec, offsets,
&cur_matched_fields,
......@@ -365,8 +366,8 @@ page_cur_search_with_match(
low_matched_bytes = cur_matched_bytes;
} else if (cmp == -1) {
offsets = rec_reget_offsets(mid_rec, index,
offsets, dtuple_get_n_fields_cmp(tuple), heap);
offsets = rec_get_offsets(mid_rec, index, offsets,
dtuple_get_n_fields_cmp(tuple), &heap);
if (mode == PAGE_CUR_LE_OR_EXTENDS
&& page_cur_rec_field_extends(tuple, mid_rec,
......@@ -398,8 +399,8 @@ page_cur_search_with_match(
dbg_matched_fields = 0;
dbg_matched_bytes = 0;
offsets = rec_reget_offsets(low_rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(low_rec, index, offsets,
ULINT_UNDEFINED, &heap);
dbg_cmp = page_cmp_dtuple_rec_with_match(tuple, low_rec, offsets,
&dbg_matched_fields,
&dbg_matched_bytes);
......@@ -422,8 +423,8 @@ page_cur_search_with_match(
dbg_matched_fields = 0;
dbg_matched_bytes = 0;
offsets = rec_reget_offsets(up_rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(up_rec, index, offsets,
ULINT_UNDEFINED, &heap);
dbg_cmp = page_cmp_dtuple_rec_with_match(tuple, up_rec, offsets,
&dbg_matched_fields,
&dbg_matched_bytes);
......@@ -453,7 +454,9 @@ page_cur_search_with_match(
*iup_matched_bytes = up_matched_bytes;
*ilow_matched_fields = low_matched_fields;
*ilow_matched_bytes = low_matched_bytes;
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
}
/***************************************************************
......@@ -519,22 +522,26 @@ page_cur_insert_rec_write_log(
ut_a(rec_size < UNIV_PAGE_SIZE);
{
mem_heap_t* heap;
mem_heap_t* heap = NULL;
ulint cur_offs_[100] = { 100, };
ulint ins_offs_[100] = { 100, };
ulint* cur_offs;
ulint* ins_offs;
heap = mem_heap_create(100);
cur_offs = rec_get_offsets(cursor_rec, index,
ULINT_UNDEFINED, heap);
ins_offs = rec_get_offsets(insert_rec, index,
ULINT_UNDEFINED, heap);
cur_offs = rec_get_offsets(cursor_rec, index, cur_offs_,
ULINT_UNDEFINED, &heap);
ins_offs = rec_get_offsets(insert_rec, index, ins_offs_,
ULINT_UNDEFINED, &heap);
extra_size = rec_offs_extra_size(ins_offs);
cur_extra_size = rec_offs_extra_size(cur_offs);
ut_ad(rec_size == rec_offs_size(ins_offs));
cur_rec_size = rec_offs_size(cur_offs);
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
}
ins_ptr = insert_rec - extra_size;
......@@ -668,8 +675,9 @@ page_cur_parse_insert_rec(
byte* ptr2 = ptr;
ulint info_bits = 0; /* remove warning */
page_cur_t cursor;
mem_heap_t* heap;
ulint* offsets;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
if (!is_short) {
/* Read the cursor rec offset as a 2-byte ulint */
......@@ -756,8 +764,8 @@ page_cur_parse_insert_rec(
cursor_rec = page + offset;
}
heap = mem_heap_create(100);
offsets = rec_get_offsets(cursor_rec, index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(cursor_rec, index, offsets,
ULINT_UNDEFINED, &heap);
if (extra_info_yes == 0) {
info_bits = rec_get_info_bits(cursor_rec, index->table->comp);
......@@ -816,6 +824,10 @@ page_cur_parse_insert_rec(
mem_free(buf);
}
if (heap) {
mem_heap_free(heap);
}
return(ptr + end_seg_len);
}
......@@ -850,8 +862,9 @@ page_cur_insert_rec_low(
inserted record */
rec_t* owner_rec;
ulint n_owned;
mem_heap_t* heap;
ulint* offsets;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ibool comp = index->table->comp;
ut_ad(cursor && mtr);
......@@ -865,14 +878,12 @@ page_cur_insert_rec_low(
ut_ad(cursor->rec != page_get_supremum_rec(page));
heap = mem_heap_create(100);
/* 1. Get the size of the physical record in the page */
if (tuple != NULL) {
offsets = NULL;
rec_size = rec_get_converted_size(index, tuple);
} else {
offsets = rec_get_offsets(rec, index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
rec_size = rec_offs_size(offsets);
}
......@@ -880,7 +891,9 @@ page_cur_insert_rec_low(
insert_buf = page_mem_alloc(page, rec_size, index, &heap_no);
if (insert_buf == NULL) {
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
return(NULL);
}
......@@ -888,13 +901,15 @@ page_cur_insert_rec_low(
if (tuple != NULL) {
insert_rec = rec_convert_dtuple_to_rec(insert_buf,
index, tuple);
offsets = rec_get_offsets(insert_rec, index, offsets,
ULINT_UNDEFINED, &heap);
} else {
insert_rec = rec_copy(insert_buf, rec, offsets);
ut_ad(rec_offs_validate(rec, index, offsets));
rec_offs_make_valid(insert_rec, index, offsets);
}
ut_ad(insert_rec);
offsets = rec_reget_offsets(insert_rec, index,
offsets, ULINT_UNDEFINED, heap);
ut_ad(rec_size == rec_offs_size(offsets));
/* 4. Insert the record in the linked list of records */
......@@ -966,7 +981,9 @@ page_cur_insert_rec_low(
page_cur_insert_rec_write_log(insert_rec, rec_size, current_rec,
index, mtr);
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
return(insert_rec);
}
......@@ -1068,9 +1085,10 @@ page_copy_rec_list_end_to_created_page(
ulint log_mode;
byte* log_ptr;
ulint log_data_len;
ibool comp = page_is_comp(page);
mem_heap_t* heap;
ulint* offsets = NULL;
ibool comp = page_is_comp(page);
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ut_ad(page_dir_get_n_heap(new_page) == 2);
ut_ad(page != new_page);
......@@ -1117,8 +1135,8 @@ page_copy_rec_list_end_to_created_page(
/* should be do ... until, comment by Jani */
while (rec != page_get_supremum_rec(page)) {
offsets = rec_reget_offsets(rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
insert_rec = rec_copy(heap_top, rec, offsets);
rec_set_next_offs(prev_rec, comp, insert_rec - new_page);
......@@ -1170,7 +1188,9 @@ page_copy_rec_list_end_to_created_page(
slot_index--;
}
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
log_data_len = dyn_array_get_data_size(&(mtr->log)) - log_data_len;
......
......@@ -227,10 +227,12 @@ page_mem_alloc(
rec = page_header_get_ptr(page, PAGE_FREE);
if (rec) {
mem_heap_t* heap
= mem_heap_create(100);
const ulint* offsets
= rec_get_offsets(rec, index, ULINT_UNDEFINED, heap);
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
if (rec_offs_size(offsets) >= need) {
page_header_set_ptr(page, PAGE_FREE,
......@@ -245,11 +247,15 @@ page_mem_alloc(
*heap_no = rec_get_heap_no(rec, page_is_comp(page));
block = rec_get_start(rec, offsets);
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
return(block);
}
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
}
/* Could not find space from the free list, try top of heap */
......@@ -374,7 +380,8 @@ page_create(
rec_set_n_owned(infimum_rec, comp, 1);
rec_set_heap_no(infimum_rec, comp, 0);
offsets = rec_get_offsets(infimum_rec, index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(infimum_rec, index, NULL,
ULINT_UNDEFINED, &heap);
heap_top = rec_get_end(infimum_rec, offsets);
......@@ -396,8 +403,8 @@ page_create(
rec_set_n_owned(supremum_rec, comp, 1);
rec_set_heap_no(supremum_rec, comp, 1);
offsets = rec_reget_offsets(supremum_rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(supremum_rec, index, offsets,
ULINT_UNDEFINED, &heap);
heap_top = rec_get_end(supremum_rec, offsets);
ut_ad(heap_top ==
......@@ -711,8 +718,9 @@ page_delete_rec_list_end(
last_rec = page_rec_get_prev(sup);
if ((size == ULINT_UNDEFINED) || (n_recs == ULINT_UNDEFINED)) {
mem_heap_t* heap = mem_heap_create(100);
ulint* offsets = NULL;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
/* Calculate the sum of sizes and the number of records */
size = 0;
n_recs = 0;
......@@ -720,8 +728,8 @@ page_delete_rec_list_end(
while (rec2 != sup) {
ulint s;
offsets = rec_reget_offsets(rec2, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec2, index, offsets,
ULINT_UNDEFINED, &heap);
s = rec_offs_size(offsets);
ut_ad(rec2 - page + s - rec_offs_extra_size(offsets)
< UNIV_PAGE_SIZE);
......@@ -732,7 +740,9 @@ page_delete_rec_list_end(
rec2 = page_rec_get_next(rec2);
}
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
}
ut_ad(size < UNIV_PAGE_SIZE);
......@@ -1213,7 +1223,7 @@ page_rec_print(
ibool comp = page_is_comp(buf_frame_align(rec));
ut_a(comp == rec_offs_comp(offsets));
rec_print(stderr, rec, offsets);
rec_print_new(stderr, rec, offsets);
fprintf(stderr,
" n_owned: %lu; heap_no: %lu; next rec: %lu\n",
(ulong) rec_get_n_owned(rec, comp),
......@@ -1276,11 +1286,11 @@ page_print_list(
page_cur_t cur;
ulint count;
ulint n_recs;
mem_heap_t* heap;
ulint* offsets = NULL;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ut_a(page_is_comp(page) == index->table->comp);
heap = mem_heap_create(100);
fprintf(stderr,
"--------------------------------\n"
......@@ -1292,8 +1302,8 @@ page_print_list(
page_cur_set_before_first(page, &cur);
count = 0;
for (;;) {
offsets = rec_reget_offsets(cur.rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(cur.rec, index, offsets,
ULINT_UNDEFINED, &heap);
page_rec_print(cur.rec, offsets);
if (count == pr_n) {
......@@ -1314,8 +1324,8 @@ page_print_list(
page_cur_move_to_next(&cur);
if (count + pr_n >= n_recs) {
offsets = rec_reget_offsets(cur.rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(cur.rec, index, offsets,
ULINT_UNDEFINED, &heap);
page_rec_print(cur.rec, offsets);
}
count++;
......@@ -1326,7 +1336,9 @@ page_print_list(
"--------------------------------\n",
(ulong) (count + 1));
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
}
/*******************************************************************
......@@ -1680,7 +1692,7 @@ page_validate(
goto func_exit2;
}
heap = mem_heap_create(UNIV_PAGE_SIZE);
heap = mem_heap_create(UNIV_PAGE_SIZE + 200);
/* The following buffer is used to check that the
records in the page record heap do not overlap */
......@@ -1720,8 +1732,8 @@ page_validate(
for (;;) {
rec = cur.rec;
offsets = rec_reget_offsets(rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
if (comp && page_rec_is_user_rec(rec)
&& rec_get_node_ptr_flag(rec)
......@@ -1744,9 +1756,9 @@ page_validate(
(ulong) buf_frame_get_page_no(page));
dict_index_name_print(stderr, NULL, index);
fputs("\nInnoDB: previous record ", stderr);
rec_print(stderr, old_rec, old_offsets);
rec_print_new(stderr, old_rec, old_offsets);
fputs("\nInnoDB: record ", stderr);
rec_print(stderr, rec, offsets);
rec_print_new(stderr, rec, offsets);
putc('\n', stderr);
goto func_exit;
......@@ -1852,8 +1864,8 @@ page_validate(
rec = page_header_get_ptr(page, PAGE_FREE);
while (rec != NULL) {
offsets = rec_reget_offsets(rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
if (!page_rec_validate(rec, offsets)) {
goto func_exit;
......
......@@ -284,28 +284,25 @@ rec_init_offsets(
/**********************************************************
The following function determines the offsets to each field
in the record. The offsets are returned in an array of
ulint, with [0] being the number of fields (n), [1] being the
extra size (if REC_OFFS_COMPACT is set, the record is in the new
format), and [2]..[n+1] being the offsets past the end of
fields 0..n, or to the beginning of fields 1..n+1. When the
high-order bit of the offset at [n+1] is set (REC_OFFS_SQL_NULL),
the field n is NULL. When the second high-order bit of the offset
at [n+1] is set (REC_OFFS_EXTERNAL), the field n is being stored
externally. */
in the record. It can reuse a previously returned array. */
ulint*
rec_get_offsets(
/*============*/
/* out: the offsets */
rec_get_offsets_func(
/*=================*/
/* out: the new offsets */
rec_t* rec, /* in: physical record */
dict_index_t* index, /* in: record descriptor */
ulint* offsets,/* in: array consisting of offsets[0]
allocated elements, or an array from
rec_get_offsets(), or NULL */
ulint n_fields,/* in: maximum number of initialized fields
(ULINT_UNDEFINED if all fields) */
mem_heap_t* heap) /* in: memory heap */
mem_heap_t** heap, /* in/out: memory heap */
const char* file, /* in: file name where called */
ulint line) /* in: line number where called */
{
ulint* offsets;
ulint n;
ulint size;
ut_ad(rec);
ut_ad(index);
......@@ -336,71 +333,18 @@ rec_get_offsets(
n = n_fields;
}
offsets = mem_heap_alloc(heap,
(n + (1 + REC_OFFS_HEADER_SIZE)) * sizeof(ulint));
offsets[0] = n;
rec_init_offsets(rec, index, offsets);
return(offsets);
}
/**********************************************************
The following function determines the offsets to each field
in the record. It differs from rec_get_offsets() by trying to
reuse a previously returned array. */
ulint*
rec_reget_offsets(
/*==============*/
/* out: the new offsets */
rec_t* rec, /* in: physical record */
dict_index_t* index, /* in: record descriptor */
ulint* offsets,/* in: array of offsets
from rec_get_offsets()
or rec_reget_offsets(), or NULL */
ulint n_fields,/* in: maximum number of initialized fields
(ULINT_UNDEFINED if all fields) */
mem_heap_t* heap) /* in: memory heap */
{
ulint n;
ut_ad(rec);
ut_ad(index);
ut_ad(heap);
size = (n + (1 + REC_OFFS_HEADER_SIZE)) * sizeof(ulint);
if (index->table->comp) {
switch (rec_get_status(rec)) {
case REC_STATUS_ORDINARY:
n = dict_index_get_n_fields(index);
break;
case REC_STATUS_NODE_PTR:
n = dict_index_get_n_unique_in_tree(index) + 1;
break;
case REC_STATUS_INFIMUM:
case REC_STATUS_SUPREMUM:
/* infimum or supremum record */
n = 1;
break;
default:
ut_error;
return(NULL);
if (!offsets || rec_offs_get_n_alloc(offsets) < size) {
if (!*heap) {
*heap = mem_heap_create_func(size,
NULL, MEM_HEAP_DYNAMIC, file, line);
}
} else {
n = rec_get_n_fields_old(rec);
offsets = mem_heap_alloc(*heap, size);
rec_offs_set_n_alloc(offsets, size);
}
if (n_fields < n) {
n = n_fields;
}
if (!offsets || rec_offs_n_fields(offsets) < n) {
offsets = mem_heap_alloc(heap,
(n + (1 + REC_OFFS_HEADER_SIZE)) * sizeof(ulint));
}
offsets[0] = n;
rec_offs_set_n_fields(offsets, n);
rec_init_offsets(rec, index, offsets);
return(offsets);
}
......@@ -722,14 +666,16 @@ rec_get_size(
rec_t* rec, /* in: physical record */
dict_index_t* index) /* in: record descriptor */
{
mem_heap_t* heap
= mem_heap_create(100);
ulint* offsets
= rec_get_offsets(rec, index, ULINT_UNDEFINED, heap);
ulint size
= rec_offs_size(offsets);
mem_heap_free(heap);
mem_heap_t* heap = NULL;
ulint offsets_[100 + REC_OFFS_HEADER_SIZE]
= { 100, };
ulint* offsets = rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap);
ulint size = rec_offs_size(offsets);
if (heap) {
mem_heap_free(heap);
}
return(size);
}
......@@ -1032,10 +978,15 @@ rec_convert_dtuple_to_rec(
#ifdef UNIV_DEBUG
{
mem_heap_t* heap = mem_heap_create(100);
ut_ad(rec_validate(rec,
rec_get_offsets(rec, index, ULINT_UNDEFINED, heap)));
mem_heap_free(heap);
mem_heap_t* heap = NULL;
ulint offsets_[100 + REC_OFFS_HEADER_SIZE]
= { 100, };
const ulint* offsets = rec_get_offsets(rec, index,
offsets_, ULINT_UNDEFINED, &heap);
ut_ad(rec_validate(rec, offsets));
if (heap) {
mem_heap_free(heap);
}
}
#endif /* UNIV_DEBUG */
return(rec);
......@@ -1059,9 +1010,11 @@ rec_copy_prefix_to_dtuple(
ulint len;
byte* buf = NULL;
ulint i;
ulint* offsets;
ulint offsets_[100 + REC_OFFS_HEADER_SIZE]
= { 100, };
ulint* offsets = offsets_;
offsets = rec_get_offsets(rec, index, n_fields, heap);
offsets = rec_get_offsets(rec, index, offsets, n_fields, &heap);
ut_ad(rec_validate(rec, offsets));
ut_ad(dtuple_check_typed(tuple));
......@@ -1406,8 +1359,8 @@ rec_print_old(
Prints a physical record. */
void
rec_print(
/*======*/
rec_print_new(
/*==========*/
FILE* file, /* in: file where to print */
rec_t* rec, /* in: physical record */
const ulint* offsets)/* in: array returned by rec_get_offsets() */
......@@ -1416,6 +1369,8 @@ rec_print(
ulint len;
ulint i;
ut_ad(rec_offs_validate(rec, NULL, offsets));
if (!rec_offs_comp(offsets)) {
rec_print_old(file, rec);
return;
......@@ -1453,3 +1408,30 @@ rec_print(
rec_validate(rec, offsets);
}
/*******************************************************************
Prints a physical record. */
void
rec_print(
/*======*/
FILE* file, /* in: file where to print */
rec_t* rec, /* in: physical record */
dict_index_t* index) /* in: record descriptor */
{
ut_ad(index);
if (!index->table->comp) {
rec_print_old(file, rec);
return;
} else {
mem_heap_t* heap = NULL;
ulint offsets_[100 + REC_OFFS_HEADER_SIZE]
= { 100, };
rec_print_new(file, rec, rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap));
if (heap) {
mem_heap_free(heap);
}
}
}
......@@ -590,16 +590,8 @@ row_ins_foreign_report_err(
fputs(", in index ", ef);
ut_print_name(ef, trx, foreign->foreign_index->name);
if (rec) {
mem_heap_t* heap;
ulint* offsets;
heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, foreign->foreign_index,
ULINT_UNDEFINED, heap);
fputs(", there is a record:\n", ef);
rec_print(ef, rec, offsets);
mem_heap_free(heap);
rec_print(ef, rec, foreign->foreign_index);
} else {
fputs(", the record is not available\n", ef);
}
......@@ -654,16 +646,7 @@ row_ins_foreign_report_add_err(
}
if (rec) {
mem_heap_t* heap;
ulint* offsets;
heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, foreign->foreign_index,
ULINT_UNDEFINED, heap);
rec_print(ef, rec, offsets);
mem_heap_free(heap);
rec_print(ef, rec, foreign->foreign_index);
}
putc('\n', ef);
......@@ -734,7 +717,6 @@ row_ins_foreign_check_on_constraint(
ulint i;
trx_t* trx;
mem_heap_t* tmp_heap = NULL;
ulint* offsets;
ut_a(thr && foreign && pcur && mtr);
......@@ -880,14 +862,10 @@ row_ins_foreign_check_on_constraint(
fputs("\n"
"InnoDB: record ", stderr);
offsets = rec_get_offsets(rec, index,
ULINT_UNDEFINED, tmp_heap);
rec_print(stderr, rec, offsets);
rec_print(stderr, rec, index);
fputs("\n"
"InnoDB: clustered record ", stderr);
offsets = rec_reget_offsets(clust_rec, clust_index,
offsets, ULINT_UNDEFINED, tmp_heap);
rec_print(stderr, clust_rec, offsets);
rec_print(stderr, clust_rec, clust_index);
fputs("\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
......@@ -906,13 +884,8 @@ row_ins_foreign_check_on_constraint(
we already have a normal shared lock on the appropriate
gap if the search criterion was not unique */
if (!tmp_heap) {
tmp_heap = mem_heap_create(256);
}
offsets = rec_get_offsets(clust_rec, clust_index,
ULINT_UNDEFINED, tmp_heap);
err = lock_clust_rec_read_check_and_lock(0, clust_rec,
clust_index, offsets, LOCK_X, LOCK_REC_NOT_GAP, thr);
err = lock_clust_rec_read_check_and_lock_alt(0, clust_rec,
clust_index, LOCK_X, LOCK_REC_NOT_GAP, thr);
}
if (err != DB_SUCCESS) {
......@@ -1152,11 +1125,10 @@ row_ins_check_foreign_constraint(
ulint err;
ulint i;
mtr_t mtr;
trx_t* trx = thr_get_trx(thr);
mem_heap_t* heap;
ulint* offsets = NULL;
heap = mem_heap_create(100);
trx_t* trx = thr_get_trx(thr);
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
run_again:
#ifdef UNIV_SYNC_DEBUG
......@@ -1168,8 +1140,7 @@ row_ins_check_foreign_constraint(
if (trx->check_foreigns == FALSE) {
/* The user has suppressed foreign key checks currently for
this session */
mem_heap_free(heap);
return(DB_SUCCESS);
goto exit_func;
}
/* If any of the foreign key fields in entry is SQL NULL, we
......@@ -1180,8 +1151,7 @@ row_ins_check_foreign_constraint(
if (UNIV_SQL_NULL == dfield_get_len(
dtuple_get_nth_field(entry, i))) {
mem_heap_free(heap);
return(DB_SUCCESS);
goto exit_func;
}
}
......@@ -1205,8 +1175,7 @@ row_ins_check_foreign_constraint(
another, and the user has problems predicting in
which order they are performed. */
mem_heap_free(heap);
return(DB_SUCCESS);
goto exit_func;
}
}
......@@ -1219,8 +1188,6 @@ row_ins_check_foreign_constraint(
}
if (check_table == NULL) {
mem_heap_free(heap);
if (check_ref) {
FILE* ef = dict_foreign_err_file;
mutex_enter(&dict_foreign_err_mutex);
......@@ -1242,10 +1209,10 @@ row_ins_check_foreign_constraint(
fputs(" does not currently exist!\n", ef);
mutex_exit(&dict_foreign_err_mutex);
return(DB_NO_REFERENCED_ROW);
err = DB_NO_REFERENCED_ROW;
}
return(DB_SUCCESS);
goto exit_func;
}
ut_a(check_table && check_index);
......@@ -1291,8 +1258,8 @@ row_ins_check_foreign_constraint(
goto next_rec;
}
offsets = rec_reget_offsets(rec, check_index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, check_index,
offsets, ULINT_UNDEFINED, &heap);
if (rec == page_get_supremum_rec(buf_frame_align(rec))) {
......@@ -1424,7 +1391,10 @@ row_ins_check_foreign_constraint(
err = trx->error_state;
}
mem_heap_free(heap);
exit_func:
if (heap) {
mem_heap_free(heap);
}
return(err);
}
......@@ -1565,8 +1535,9 @@ row_ins_scan_sec_index_for_duplicate(
ibool moved;
mtr_t mtr;
trx_t* trx;
mem_heap_t* heap;
ulint* offsets = NULL;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
n_unique = dict_index_get_n_unique(index);
......@@ -1582,7 +1553,6 @@ row_ins_scan_sec_index_for_duplicate(
}
}
heap = mem_heap_create(100);
mtr_start(&mtr);
/* Store old value on n_fields_cmp */
......@@ -1608,8 +1578,8 @@ row_ins_scan_sec_index_for_duplicate(
trx = thr_get_trx(thr);
ut_ad(trx);
offsets = rec_reget_offsets(rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
if (innobase_query_is_replace()) {
......@@ -1662,7 +1632,9 @@ row_ins_scan_sec_index_for_duplicate(
}
}
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
mtr_commit(&mtr);
/* Restore old value */
......@@ -1692,7 +1664,11 @@ row_ins_duplicate_error_in_clust(
rec_t* rec;
page_t* page;
ulint n_unique;
trx_t* trx = thr_get_trx(thr);
trx_t* trx = thr_get_trx(thr);
mem_heap_t*heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
UT_NOT_USED(mtr);
......@@ -1720,12 +1696,8 @@ row_ins_duplicate_error_in_clust(
page = buf_frame_align(rec);
if (rec != page_get_infimum_rec(page)) {
mem_heap_t* heap;
ulint* offsets;
heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, cursor->index,
ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, cursor->index, offsets,
ULINT_UNDEFINED, &heap);
/* We set a lock on the possible duplicate: this
is needed in logical logging of MySQL to make
......@@ -1750,17 +1722,15 @@ row_ins_duplicate_error_in_clust(
}
if (err != DB_SUCCESS) {
mem_heap_free(heap);
return(err);
goto func_exit;
}
if (row_ins_dupl_error_with_rec(rec, entry,
cursor->index, offsets)) {
trx->error_info = cursor->index;
mem_heap_free(heap);
return(DB_DUPLICATE_KEY);
err = DB_DUPLICATE_KEY;
goto func_exit;
}
mem_heap_free(heap);
}
}
......@@ -1770,12 +1740,8 @@ row_ins_duplicate_error_in_clust(
page = buf_frame_align(rec);
if (rec != page_get_supremum_rec(page)) {
mem_heap_t* heap;
ulint* offsets;
heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, cursor->index,
ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, cursor->index, offsets,
ULINT_UNDEFINED, &heap);
/* The manual defines the REPLACE semantics that it
is either an INSERT or DELETE(s) for duplicate key
......@@ -1795,15 +1761,14 @@ row_ins_duplicate_error_in_clust(
}
if (err != DB_SUCCESS) {
mem_heap_free(heap);
return(err);
goto func_exit;
}
if (row_ins_dupl_error_with_rec(rec, entry,
cursor->index, offsets)) {
trx->error_info = cursor->index;
mem_heap_free(heap);
return(DB_DUPLICATE_KEY);
err = DB_DUPLICATE_KEY;
goto func_exit;
}
mem_heap_free(heap);
}
......@@ -1812,7 +1777,9 @@ row_ins_duplicate_error_in_clust(
/* This should never happen */
}
return(DB_SUCCESS);
err = DB_SUCCESS;
func_exit:
return(err);
}
/*******************************************************************
......@@ -1894,8 +1861,9 @@ row_ins_index_entry_low(
ulint n_unique;
big_rec_t* big_rec = NULL;
mtr_t mtr;
mem_heap_t* heap = mem_heap_create(100);
ulint* offsets = NULL;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
log_free_check();
......@@ -1928,9 +1896,8 @@ row_ins_index_entry_low(
buf_frame_align(btr_cur_get_rec(&cursor))));
if (!page_rec_is_supremum(first_rec)) {
offsets = rec_get_offsets(first_rec, index,
ULINT_UNDEFINED, heap);
ut_a(rec_offs_n_fields(offsets) == dtuple_get_n_fields(entry));
ut_a(rec_get_n_fields(first_rec, index)
== dtuple_get_n_fields(entry));
}
n_unique = dict_index_get_n_unique(index);
......@@ -2024,8 +1991,8 @@ row_ins_index_entry_low(
btr_cur_search_to_nth_level(index, 0, entry, PAGE_CUR_LE,
BTR_MODIFY_TREE, &cursor, 0, &mtr);
rec = btr_cur_get_rec(&cursor);
offsets = rec_reget_offsets(rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
err = btr_store_big_rec_extern_fields(index, rec,
offsets, big_rec, &mtr);
......@@ -2039,7 +2006,9 @@ row_ins_index_entry_low(
mtr_commit(&mtr);
}
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
return(err);
}
......
......@@ -3215,18 +3215,19 @@ row_scan_and_check_index(
ulint* n_rows) /* out: number of entries seen in the
current consistent read */
{
mem_heap_t* heap;
dtuple_t* prev_entry = NULL;
dtuple_t* prev_entry = NULL;
ulint matched_fields;
ulint matched_bytes;
byte* buf;
ulint ret;
rec_t* rec;
ibool is_ok = TRUE;
ibool is_ok = TRUE;
int cmp;
ibool contains_null;
ulint i;
ulint* offsets = NULL;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
*n_rows = 0;
......@@ -3268,8 +3269,8 @@ row_scan_and_check_index(
matched_fields = 0;
matched_bytes = 0;
offsets = rec_reget_offsets(rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
cmp = cmp_dtuple_rec_with_match(prev_entry, rec, offsets,
&matched_fields,
&matched_bytes);
......@@ -3299,7 +3300,7 @@ row_scan_and_check_index(
dtuple_print(stderr, prev_entry);
fputs("\n"
"InnoDB: record ", stderr);
rec_print(stderr, rec, offsets);
rec_print_new(stderr, rec, offsets);
putc('\n', stderr);
is_ok = FALSE;
} else if ((index->type & DICT_UNIQUE)
......@@ -3313,7 +3314,7 @@ row_scan_and_check_index(
}
mem_heap_empty(heap);
offsets = NULL;
offsets = offsets_;
prev_entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec, heap);
......@@ -3398,7 +3399,7 @@ row_check_table_for_mysql(
/* We validate also the whole adaptive hash index for all tables
at every CHECK TABLE */
if (!btr_search_validate(index)) {
if (!btr_search_validate()) {
ret = DB_ERROR;
}
......
......@@ -100,7 +100,8 @@ row_purge_remove_clust_if_poss_low(
ulint err;
mtr_t mtr;
rec_t* rec;
mem_heap_t* heap;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
index = dict_table_get_first_index(node->table);
......@@ -120,19 +121,22 @@ row_purge_remove_clust_if_poss_low(
}
rec = btr_pcur_get_rec(pcur);
heap = mem_heap_create(100);
if (0 != ut_dulint_cmp(node->roll_ptr,
row_get_rec_roll_ptr(rec, index, rec_get_offsets(
rec, index, ULINT_UNDEFINED, heap)))) {
mem_heap_free(heap);
rec, index, offsets_, ULINT_UNDEFINED, &heap)))) {
if (heap) {
mem_heap_free(heap);
}
/* Someone else has modified the record later: do not remove */
btr_pcur_commit_specify_mtr(pcur, &mtr);
return(TRUE);
}
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
if (mode == BTR_MODIFY_LEAF) {
success = btr_cur_optimistic_delete(btr_cur, &mtr);
......
......@@ -202,17 +202,16 @@ row_build(
ulint row_len;
byte* buf;
ulint i;
mem_heap_t* tmp_heap;
mem_heap_t* tmp_heap = NULL;
ulint offsets_[100] = { 100, };
ut_ad(index && rec && heap);
ut_ad(index->type & DICT_CLUSTERED);
if (!offsets) {
tmp_heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, index,
ULINT_UNDEFINED, tmp_heap);
offsets = rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &tmp_heap);
} else {
tmp_heap = NULL;
ut_ad(rec_offs_validate(rec, index, offsets));
}
......@@ -296,13 +295,14 @@ row_rec_to_index_entry(
ulint len;
ulint rec_len;
byte* buf;
mem_heap_t* tmp_heap;
ulint* offsets;
mem_heap_t* tmp_heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ut_ad(rec && heap && index);
tmp_heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, index, ULINT_UNDEFINED, tmp_heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &tmp_heap);
if (type == ROW_COPY_DATA) {
/* Take a copy of rec to heap */
......@@ -334,7 +334,9 @@ row_rec_to_index_entry(
}
ut_ad(dtuple_check_typed(entry));
mem_heap_free(tmp_heap);
if (tmp_heap) {
mem_heap_free(tmp_heap);
}
return(entry);
}
......@@ -374,13 +376,14 @@ row_build_row_ref(
byte* buf;
ulint clust_col_prefix_len;
ulint i;
mem_heap_t* tmp_heap;
ulint* offsets;
mem_heap_t* tmp_heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ut_ad(index && rec && heap);
tmp_heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, index, ULINT_UNDEFINED, tmp_heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &tmp_heap);
if (type == ROW_COPY_DATA) {
/* Take a copy of rec to heap */
......@@ -433,7 +436,9 @@ row_build_row_ref(
}
ut_ad(dtuple_check_typed(ref));
mem_heap_free(tmp_heap);
if (tmp_heap) {
mem_heap_free(tmp_heap);
}
return(ref);
}
......@@ -464,8 +469,9 @@ row_build_row_ref_in_tuple(
ulint pos;
ulint clust_col_prefix_len;
ulint i;
mem_heap_t* heap;
ulint* offsets;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ut_a(ref && index && rec);
......@@ -486,8 +492,7 @@ row_build_row_ref_in_tuple(
goto notfound;
}
heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
ref_len = dict_index_get_n_unique(clust_index);
......@@ -526,7 +531,9 @@ row_build_row_ref_in_tuple(
}
ut_ad(dtuple_check_typed(ref));
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
}
/***********************************************************************
......
This diff is collapsed.
......@@ -430,7 +430,6 @@ row_undo_mod_del_unmark_sec_and_undo_update(
found = row_search_index_entry(index, entry, mode, &pcur, &mtr);
if (!found) {
heap = mem_heap_create(100);
fputs("InnoDB: error in sec index entry del undo in\n"
"InnoDB: ", stderr);
dict_index_name_print(stderr, trx, index);
......@@ -439,14 +438,11 @@ row_undo_mod_del_unmark_sec_and_undo_update(
dtuple_print(stderr, entry);
fputs("\n"
"InnoDB: record ", stderr);
rec_print(stderr, btr_pcur_get_rec(&pcur),
rec_get_offsets(btr_pcur_get_rec(&pcur),
index, ULINT_UNDEFINED, heap));
rec_print(stderr, btr_pcur_get_rec(&pcur), index);
putc('\n', stderr);
trx_print(stderr, trx);
fputs("\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
mem_heap_free(heap);
} else {
btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&pcur);
......
......@@ -151,8 +151,9 @@ row_undo_search_clust_to_pcur(
mtr_t mtr;
ibool ret;
rec_t* rec;
mem_heap_t* heap;
const ulint* offsets;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
mtr_start(&mtr);
......@@ -163,8 +164,8 @@ row_undo_search_clust_to_pcur(
rec = btr_pcur_get_rec(&(node->pcur));
heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, clust_index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, clust_index, offsets,
ULINT_UNDEFINED, &heap);
if (!found || 0 != ut_dulint_cmp(node->roll_ptr,
row_get_rec_roll_ptr(rec, clust_index, offsets))) {
......@@ -188,6 +189,9 @@ row_undo_search_clust_to_pcur(
btr_pcur_commit_specify_mtr(&(node->pcur), &mtr);
if (heap) {
mem_heap_free(heap);
}
return(ret);
}
......
......@@ -700,6 +700,7 @@ row_upd_build_sec_rec_difference_binary(
upd_t* update;
ulint n_diff;
ulint i;
ulint offsets_[10] = { 10, };
const ulint* offsets;
/* This function is used only for a secondary index */
......@@ -708,7 +709,8 @@ row_upd_build_sec_rec_difference_binary(
update = upd_create(dtuple_get_n_fields(entry), heap);
n_diff = 0;
offsets = rec_get_offsets(rec, index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap);
for (i = 0; i < dtuple_get_n_fields(entry); i++) {
......@@ -775,6 +777,7 @@ row_upd_build_difference_binary(
ulint trx_id_pos;
ibool extern_bit;
ulint i;
ulint offsets_[100] = { 100, };
const ulint* offsets;
/* This function is used only for a clustered index */
......@@ -787,7 +790,8 @@ row_upd_build_difference_binary(
roll_ptr_pos = dict_index_get_sys_col_pos(index, DATA_ROLL_PTR);
trx_id_pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
offsets = rec_get_offsets(rec, index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap);
for (i = 0; i < dtuple_get_n_fields(entry); i++) {
......@@ -1182,7 +1186,8 @@ row_upd_store_row(
dict_index_t* clust_index;
upd_t* update;
rec_t* rec;
mem_heap_t* heap;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
const ulint* offsets;
ut_ad(node->pcur->latch_mode != BTR_NO_LATCHES);
......@@ -1196,8 +1201,8 @@ row_upd_store_row(
rec = btr_pcur_get_rec(node->pcur);
heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, clust_index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, clust_index, offsets_,
ULINT_UNDEFINED, &heap);
node->row = row_build(ROW_COPY_DATA, clust_index, rec, offsets,
node->heap);
node->ext_vec = mem_heap_alloc(node->heap, sizeof(ulint)
......@@ -1210,7 +1215,9 @@ row_upd_store_row(
node->n_ext_vec = btr_push_update_extern_fields(node->ext_vec,
offsets, update);
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
}
/***************************************************************
......@@ -1263,8 +1270,7 @@ row_upd_sec_index_entry(
dtuple_print(stderr, entry);
fputs("\n"
"InnoDB: record ", stderr);
rec_print(stderr, rec,
rec_get_offsets(rec, index, ULINT_UNDEFINED, heap));
rec_print(stderr, rec, index);
putc('\n', stderr);
trx_print(stderr, trx);
......@@ -1364,7 +1370,7 @@ row_upd_clust_rec_by_insert(
a foreign key constraint */
mtr_t* mtr) /* in: mtr; gets committed here */
{
mem_heap_t* heap;
mem_heap_t* heap = NULL;
btr_pcur_t* pcur;
btr_cur_t* btr_cur;
trx_t* trx;
......@@ -1379,15 +1385,14 @@ row_upd_clust_rec_by_insert(
table = node->table;
pcur = node->pcur;
btr_cur = btr_pcur_get_btr_cur(pcur);
heap = mem_heap_create(500);
if (node->state != UPD_NODE_INSERT_CLUSTERED) {
ulint offsets_[100] = { 100, };
err = btr_cur_del_mark_set_clust_rec(BTR_NO_LOCKING_FLAG,
btr_cur, TRUE, thr, mtr);
if (err != DB_SUCCESS) {
mtr_commit(mtr);
mem_heap_free(heap);
return(err);
}
......@@ -1398,8 +1403,8 @@ row_upd_clust_rec_by_insert(
btr_cur_mark_extern_inherited_fields(btr_cur_get_rec(btr_cur),
rec_get_offsets(btr_cur_get_rec(btr_cur),
dict_table_get_first_index(table),
ULINT_UNDEFINED, heap), node->update, mtr);
dict_table_get_first_index(table), offsets_,
ULINT_UNDEFINED, &heap), node->update, mtr);
if (check_ref) {
/* NOTE that the following call loses
the position of pcur ! */
......@@ -1408,7 +1413,9 @@ row_upd_clust_rec_by_insert(
index, thr, mtr);
if (err != DB_SUCCESS) {
mtr_commit(mtr);
if (heap) {
mem_heap_free(heap);
}
return(err);
}
}
......@@ -1417,6 +1424,9 @@ row_upd_clust_rec_by_insert(
mtr_commit(mtr);
if (!heap) {
heap = mem_heap_create(500);
}
node->state = UPD_NODE_INSERT_CLUSTERED;
entry = row_build_index_entry(node->row, index, heap);
......@@ -1516,17 +1526,20 @@ row_upd_clust_rec(
mtr_commit(mtr);
if (err == DB_SUCCESS && big_rec) {
mem_heap_t* heap;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
rec_t* rec;
mtr_start(mtr);
heap = mem_heap_create(100);
rec = btr_cur_get_rec(btr_cur);
ut_a(btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr));
err = btr_store_big_rec_extern_fields(index, rec,
rec_get_offsets(rec, index, ULINT_UNDEFINED, heap),
rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap),
big_rec, mtr);
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
mtr_commit(mtr);
}
......@@ -1611,7 +1624,8 @@ row_upd_clust_step(
mtr_t* mtr;
mtr_t mtr_buf;
rec_t* rec;
mem_heap_t* heap;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
const ulint* offsets;
index = dict_table_get_first_index(node->table);
......@@ -1670,33 +1684,31 @@ row_upd_clust_step(
}
rec = btr_pcur_get_rec(pcur);
heap = mem_heap_create(100);
offsets = rec_get_offsets(rec, index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap);
if (!node->has_clust_rec_x_lock) {
err = lock_clust_rec_modify_check_and_lock(0,
rec, index, offsets, thr);
if (err != DB_SUCCESS) {
mtr_commit(mtr);
mem_heap_free(heap);
return(err);
goto exit_func;
}
}
/* NOTE: the following function calls will also commit mtr */
if (node->is_delete) {
mem_heap_free(heap);
err = row_upd_del_mark_clust_rec(node, index, thr, check_ref,
mtr);
if (err != DB_SUCCESS) {
return(err);
if (err == DB_SUCCESS) {
node->state = UPD_NODE_UPDATE_ALL_SEC;
node->index = dict_table_get_next_index(index);
}
exit_func:
if (heap) {
mem_heap_free(heap);
}
node->state = UPD_NODE_UPDATE_ALL_SEC;
node->index = dict_table_get_next_index(index);
return(err);
}
......@@ -1710,13 +1722,14 @@ row_upd_clust_step(
UT_LIST_GET_FIRST(node->columns));
row_upd_eval_new_vals(node->update);
}
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
if (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE) {
err = row_upd_clust_rec(node, index, thr, mtr);
return(err);
}
......@@ -1968,7 +1981,8 @@ row_upd_in_place_in_select(
btr_pcur_t* pcur;
btr_cur_t* btr_cur;
ulint err;
mem_heap_t* heap;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ut_ad(sel_node->select_will_do_update);
ut_ad(sel_node->latch_mode == BTR_MODIFY_LEAF);
......@@ -1984,11 +1998,13 @@ row_upd_in_place_in_select(
/* Copy the necessary columns from clust_rec and calculate the new
values to set */
heap = mem_heap_create(100);
row_upd_copy_columns(btr_pcur_get_rec(pcur), rec_get_offsets(
btr_pcur_get_rec(pcur), btr_cur->index, ULINT_UNDEFINED, heap),
btr_pcur_get_rec(pcur), btr_cur->index, offsets_,
ULINT_UNDEFINED, &heap),
UT_LIST_GET_FIRST(node->columns));
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
row_upd_eval_new_vals(node->update);
ut_ad(!rec_get_deleted_flag(btr_pcur_get_rec(pcur),
......
......@@ -100,32 +100,25 @@ row_vers_impl_x_locked_off_kernel(
}
heap = mem_heap_create(1024);
clust_offsets = rec_get_offsets(clust_rec, clust_index,
ULINT_UNDEFINED, heap);
clust_offsets = rec_get_offsets(clust_rec, clust_index, NULL,
ULINT_UNDEFINED, &heap);
trx_id = row_get_rec_trx_id(clust_rec, clust_index, clust_offsets);
mtr_s_lock(&(purge_sys->latch), &mtr);
mutex_enter(&kernel_mutex);
trx = NULL;
if (!trx_is_active(trx_id)) {
/* The transaction that modified or inserted clust_rec is no
longer active: no implicit lock on rec */
mem_heap_free(heap);
mtr_commit(&mtr);
return(NULL);
goto exit_func;
}
if (!lock_check_trx_id_sanity(trx_id, clust_rec, clust_index,
clust_offsets, TRUE)) {
/* Corruption noticed: try to avoid a crash by returning */
mem_heap_free(heap);
mtr_commit(&mtr);
return(NULL);
goto exit_func;
}
comp = index->table->comp;
......@@ -166,7 +159,8 @@ row_vers_impl_x_locked_off_kernel(
if (prev_version) {
clust_offsets = rec_get_offsets(prev_version,
clust_index, ULINT_UNDEFINED, heap);
clust_index, NULL,
ULINT_UNDEFINED, &heap);
row = row_build(ROW_COPY_POINTERS, clust_index,
prev_version, clust_offsets, heap);
entry = row_build_index_entry(row, index, heap);
......@@ -250,6 +244,7 @@ row_vers_impl_x_locked_off_kernel(
version = prev_version;
}/* for (;;) */
exit_func:
mtr_commit(&mtr);
mem_heap_free(heap);
......@@ -330,8 +325,8 @@ row_vers_old_has_index_entry(
comp = index->table->comp;
ut_ad(comp == page_is_comp(buf_frame_align(rec)));
heap = mem_heap_create(1024);
clust_offsets = rec_get_offsets(rec, clust_index,
ULINT_UNDEFINED, heap);
clust_offsets = rec_get_offsets(rec, clust_index, NULL,
ULINT_UNDEFINED, &heap);
if (also_curr && !rec_get_deleted_flag(rec, comp)) {
row = row_build(ROW_COPY_POINTERS, clust_index,
......@@ -371,7 +366,7 @@ row_vers_old_has_index_entry(
}
clust_offsets = rec_get_offsets(prev_version, clust_index,
ULINT_UNDEFINED, heap);
NULL, ULINT_UNDEFINED, &heap);
if (!rec_get_deleted_flag(prev_version, comp)) {
row = row_build(ROW_COPY_POINTERS, clust_index,
......@@ -438,7 +433,7 @@ row_vers_build_for_consistent_read(
#endif /* UNIV_SYNC_DEBUG */
heap = mem_heap_create(1024);
offsets = rec_get_offsets(rec, index, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
ut_ad(!read_view_sees_trx_id(view,
row_get_rec_trx_id(rec, index, offsets)));
......@@ -466,8 +461,8 @@ row_vers_build_for_consistent_read(
break;
}
offsets = rec_get_offsets(prev_version, index,
ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(prev_version, index, NULL,
ULINT_UNDEFINED, &heap);
prev_trx_id = row_get_rec_trx_id(prev_version, index, offsets);
if (read_view_sees_trx_id(view, prev_trx_id)) {
......
......@@ -1010,8 +1010,9 @@ trx_undo_report_row_operation(
ibool is_insert;
trx_rseg_t* rseg;
mtr_t mtr;
mem_heap_t* heap;
ulint* offsets = NULL;
mem_heap_t* heap = NULL;
ulint offsets_[100] = { 100, };
ulint* offsets = offsets_;
ut_a(index->type & DICT_CLUSTERED);
......@@ -1066,8 +1067,6 @@ trx_undo_report_row_operation(
mtr_start(&mtr);
heap = mem_heap_create(100);
for (;;) {
undo_page = buf_page_get_gen(undo->space, page_no,
RW_X_LATCH, undo->guess_page,
......@@ -1084,8 +1083,8 @@ trx_undo_report_row_operation(
index, clust_entry,
&mtr);
} else {
offsets = rec_reget_offsets(rec, index,
offsets, ULINT_UNDEFINED, heap);
offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap);
offset = trx_undo_page_report_modify(undo_page, trx,
index, rec, offsets, update, cmpl_info, &mtr);
}
......@@ -1129,7 +1128,9 @@ trx_undo_report_row_operation(
mutex_exit(&(trx->undo_mutex));
mtr_commit(&mtr);
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
return(DB_OUT_OF_FILE_SPACE);
}
}
......@@ -1146,7 +1147,9 @@ trx_undo_report_row_operation(
*roll_ptr = trx_undo_build_roll_ptr(is_insert, rseg->id, page_no,
offset);
mem_heap_free(heap);
if (heap) {
mem_heap_free(heap);
}
return(DB_SUCCESS);
}
......@@ -1266,7 +1269,6 @@ trx_undo_prev_version_build(
ibool dummy_extern;
byte* buf;
ulint err;
ulint* index_offsets = NULL;
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
#endif /* UNIV_SYNC_DEBUG */
......@@ -1282,12 +1284,10 @@ trx_undo_prev_version_build(
"InnoDB: Submit a detailed bug report to"
" http://bugs.mysql.com\n"
"InnoDB: index record ", index->name);
index_offsets = rec_get_offsets(index_rec, index,
ULINT_UNDEFINED, heap);
rec_print(stderr, index_rec, index_offsets);
rec_print(stderr, index_rec, index);
fputs("\n"
"InnoDB: record version ", stderr);
rec_print(stderr, rec, offsets);
rec_print_new(stderr, rec, offsets);
putc('\n', stderr);
return(DB_ERROR);
}
......@@ -1353,12 +1353,10 @@ trx_undo_prev_version_build(
ut_print_buf(stderr, undo_rec, 150);
fputs("\n"
"InnoDB: index record ", stderr);
index_offsets = rec_get_offsets(index_rec, index,
ULINT_UNDEFINED, heap);
rec_print(stderr, index_rec, index_offsets);
rec_print(stderr, index_rec, index);
fputs("\n"
"InnoDB: record version ", stderr);
rec_print(stderr, rec, offsets);
rec_print_new(stderr, rec, offsets);
fprintf(stderr, "\n"
"InnoDB: Record trx id %lu %lu, update rec trx id %lu %lu\n"
"InnoDB: Roll ptr in rec %lu %lu, in update rec %lu %lu\n",
......
......@@ -317,6 +317,7 @@ my_bool STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
DBUG_ENTER("mysql_master_send_query");
if (!master->net.vio && !mysql_real_connect(master,0,0,0,0,0,0,0))
DBUG_RETURN(1);
master->reconnect= 1;
mysql->last_used_con = master;
DBUG_RETURN(simple_command(master, COM_QUERY, q, length, 1));
}
......@@ -351,6 +352,7 @@ my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
if (!slave_to_use->net.vio && !mysql_real_connect(slave_to_use, 0,0,0,
0,0,0,0))
DBUG_RETURN(1);
slave_to_use->reconnect= 1;
DBUG_RETURN(simple_command(slave_to_use, COM_QUERY, q, length, 1));
}
......@@ -448,6 +450,7 @@ static my_bool get_slaves_from_master(MYSQL* mysql)
expand_error(mysql, CR_PROBE_MASTER_CONNECT);
DBUG_RETURN(1);
}
mysql->reconnect= 1;
if (mysql_query(mysql, "SHOW SLAVE HOSTS") ||
!(res = mysql_store_result(mysql)))
......@@ -615,6 +618,7 @@ mysql_connect(MYSQL *mysql,const char *host,
if (mysql->free_me)
my_free((gptr) mysql,MYF(0));
}
mysql->reconnect= 1;
DBUG_RETURN(res);
}
}
......
......@@ -109,6 +109,7 @@ bool __fastcall TForm1::connect_server()
ret_value = true;
is_server_started = true;
}
MySQL->reconnect= 1;
return ret_value;
}
//---------------------------------------------------------------------------
......
......@@ -52,9 +52,9 @@ KEY NAME (NAME));
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
SHOW FULL COLUMNS FROM t1;
Field Type Collation Null Key Default Extra Privileges Comment
GROUP_ID int(10) unsigned NULL PRI 0 select,insert,update,references
LANG_ID smallint(5) unsigned NULL PRI 0 select,insert,update,references
NAME char(80) latin1_swedish_ci MUL select,insert,update,references
GROUP_ID int(10) unsigned NULL NO PRI 0 select,insert,update,references
LANG_ID smallint(5) unsigned NULL NO PRI 0 select,insert,update,references
NAME char(80) latin1_swedish_ci NO MUL select,insert,update,references
DROP TABLE t1;
create table t1 (n int);
insert into t1 values(9),(3),(12),(10);
......@@ -187,7 +187,7 @@ alter table t1 rename t2;
alter table t2 rename t1, add c char(10) comment "no comment";
show columns from t1;
Field Type Null Key Default Extra
i int(10) unsigned PRI NULL auto_increment
i int(10) unsigned NO PRI NULL auto_increment
c char(10) YES NULL
drop table t1;
create table t1 (a int, b int);
......
......@@ -91,11 +91,11 @@ ab a ab a a
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` varchar(2) NOT NULL default '',
`c2` varchar(2) NOT NULL default '',
`c3` varchar(2) NOT NULL default '',
`c4` varchar(2) NOT NULL default '',
`c5` varchar(2) NOT NULL default ''
`c1` varbinary(2) NOT NULL default '',
`c2` varbinary(2) NOT NULL default '',
`c3` varbinary(2) NOT NULL default '',
`c4` varbinary(2) NOT NULL default '',
`c5` varbinary(2) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select
......
......@@ -100,12 +100,12 @@ drop table t2;
create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
describe t2;
Field Type Null Key Default Extra
a datetime 0000-00-00 00:00:00
b time 00:00:00
c date 0000-00-00
d bigint(17) 0
e double(18,1) 0.0
f bigint(17) 0
a datetime NO 0000-00-00 00:00:00
b time NO 00:00:00
c date NO 0000-00-00
d bigint(17) NO 0
e double(18,1) NO 0.0
f bigint(17) NO 0
drop table t2;
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt;
describe t2;
......@@ -412,13 +412,13 @@ from t1;
explain t2;
Field Type Null Key Default Extra
a int(11) YES NULL
b bigint(11) 0
c bigint(10) 0
b bigint(11) NO 0
c bigint(10) NO 0
d date YES NULL
e varchar(1)
e varchar(1) NO
f datetime YES NULL
g time YES NULL
h longblob
h longblob NO
dd time YES NULL
select * from t2;
a b c d e f g h dd
......
......@@ -488,7 +488,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
latin1_f char(32)
latin1_f char(32) NO
ALTER TABLE t1 CHANGE latin1_f
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1;
......
......@@ -54,7 +54,7 @@ Table Create Table
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' '
SHOW FIELDS FROM ;
Field Type Null Key Default Extra
char(32)
char(32) NO
SET CHARACTER SET cp1251;
SHOW TABLES;
Tables_in_test
......@@ -66,7 +66,7 @@ Table Create Table
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=' '
SHOW FIELDS FROM ;
Field Type Null Key Default Extra
char(32)
char(32) NO
SET CHARACTER SET utf8;
SHOW TABLES;
Tables_in_test
......@@ -78,7 +78,7 @@ Table Create Table
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='комментарий таблицы'
SHOW FIELDS FROM таблица;
Field Type Null Key Default Extra
поле char(32)
поле char(32) NO
SET CHARACTER SET koi8r;
DROP TABLE ;
SET CHARACTER SET default;
......
......@@ -123,7 +123,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=ujis
SHOW COLUMNS FROM t1;
Field Type Null Key Default Extra
a char(1)
a char(1) NO
b enum('あ','い') YES NULL
DROP TABLE t1;
CREATE TABLE t1
......
......@@ -124,7 +124,7 @@ create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`date_format("2004-01-19 10:10:10", "%Y-%m-%d")` binary(10) default NULL
`date_format("2004-01-19 10:10:10", "%Y-%m-%d")` varbinary(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
date_format("2004-01-19 10:10:10", "%Y-%m-%d")
......
......@@ -32,6 +32,7 @@ unlock tables;
create database mysqltest;
show databases;
Database
information_schema
mysql
mysqltest
test
......@@ -42,6 +43,7 @@ unlock tables;
drop database mysqltest;
show databases;
Database
information_schema
mysql
test
drop database mysqltest;
......
......@@ -174,12 +174,12 @@ date("1997-12-31 23:59:59.000001") as f8,
time("1997-12-31 23:59:59.000001") as f9;
describe t1;
Field Type Null Key Default Extra
f1 date 0000-00-00
f1 date NO 0000-00-00
f2 datetime YES NULL
f3 time YES NULL
f4 time 00:00:00
f5 time 00:00:00
f6 time 00:00:00
f4 time NO 00:00:00
f5 time NO 00:00:00
f6 time NO 00:00:00
f7 datetime YES NULL
f8 date YES NULL
f9 time YES NULL
......
......@@ -611,7 +611,7 @@ t1 CREATE TABLE `t1` (
`substring(_latin2'ab',1)` varchar(2) character set latin2 NOT NULL default '',
`insert(_latin2'abcd',2,3,_latin2'ef')` varchar(6) character set latin2 NOT NULL default '',
`replace(_latin2'abcd',_latin2'b',_latin2'B')` varchar(4) character set latin2 NOT NULL default '',
`encode('abcd','ab')` binary(4) NOT NULL default ''
`encode('abcd','ab')` varbinary(4) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select SUBSTR('abcdefg',3,2);
......
......@@ -611,7 +611,7 @@ create table t1 select last_day('2000-02-05') as a,
from_days(to_days("960101")) as b;
describe t1;
Field Type Null Key Default Extra
a date 0000-00-00
a date NO 0000-00-00
b date YES NULL
select * from t1;
a b
......
......@@ -9,35 +9,35 @@ CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMET
CREATE TABLE gis_geometry (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY);
SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra
fid int(11) PRI
fid int(11) NO PRI
g point YES NULL
SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra
fid int(11) PRI
fid int(11) NO PRI
g linestring YES NULL
SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra
fid int(11) PRI
fid int(11) NO PRI
g polygon YES NULL
SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra
fid int(11) PRI
fid int(11) NO PRI
g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra
fid int(11) PRI
fid int(11) NO PRI
g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra
fid int(11) PRI
fid int(11) NO PRI
g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra
fid int(11) PRI
fid int(11) NO PRI
g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra
fid int(11) PRI
fid int(11) NO PRI
g geometry YES NULL
INSERT INTO gis_point VALUES
(101, PointFromText('POINT(10 10)')),
......@@ -430,7 +430,7 @@ mln multilinestring YES NULL
mpg multipolygon YES NULL
gc geometrycollection YES NULL
gm geometry YES NULL
fid int(11)
fid int(11) NO
DROP TABLE t1;
SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))));
AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))))
......
......@@ -622,7 +622,7 @@ qq
*a *a*a *
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 13 const 7 Using where
1 SIMPLE t1 ref v v 13 const # Using where
drop table t1;
create table t1 (a char(10), unique using btree (a)) engine=heap;
insert into t1 values ('a');
......
This diff is collapsed.
......@@ -4,16 +4,16 @@ FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE CONSTRAINT_METHOD
NULL test PRIMARY test t1 PRIMARY KEY NULL
NULL test PRIMARY test t2 PRIMARY KEY NULL
NULL test t2_ibfk_1 test t2 FOREIGN KEY ON DELETE CASCADE
NULL test t2_ibfk_2 test t2 FOREIGN KEY ON UPDATE CASCADE
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
NULL test PRIMARY test t1 PRIMARY KEY
NULL test PRIMARY test t2 PRIMARY KEY
NULL test t2_ibfk_1 test t2 FOREIGN KEY
NULL test t2_ibfk_2 test t2 FOREIGN KEY
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
NULL test PRIMARY NULL test t1 id 1 NULL NULL NULL
NULL test PRIMARY NULL test t2 id 1 NULL NULL NULL
NULL test t2_ibfk_1 NULL test t2 t1_id 1 NULL id
NULL test t2_ibfk_2 NULL test t2 t1_id 1 NULL id
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
NULL test PRIMARY NULL test t1 id 1 NULL NULL NULL NULL
NULL test PRIMARY NULL test t2 id 1 NULL NULL NULL NULL
NULL test t2_ibfk_1 NULL test t2 t1_id 1 1 test t1 id
NULL test t2_ibfk_2 NULL test t2 t1_id 1 1 test t1 id
drop table t2, t1;
......@@ -931,7 +931,7 @@ drop table t1;
create table t1 (t int not null default 1, key (t)) engine=innodb;
desc t1;
Field Type Null Key Default Extra
t int(11) MUL 1
t int(11) NO MUL 1
drop table t1;
CREATE TABLE t1 (
number bigint(20) NOT NULL default '0',
......
......@@ -355,6 +355,7 @@ drop table t2;
drop database test2;
show databases;
Database
information_schema
mysql
test
use test;
......
This diff is collapsed.
......@@ -1775,7 +1775,7 @@ t5 CREATE TABLE `t5` (
`param03` double default NULL,
`const04` varchar(3) NOT NULL default '',
`param04` longtext,
`const05` binary(3) NOT NULL default '',
`const05` varbinary(3) NOT NULL default '',
`param05` longblob,
`const06` varchar(10) NOT NULL default '',
`param06` longtext,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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