mariadb/sql/sql_test.cc
unknown f01f49916b Lots of code fixes to the replication code (especially the binary logging and index log file handling)
Fixed bugs in my last changeset that made MySQL hard to compile.
Added mutex around some data that could cause table cache corruptions when using OPTIMIZE TABLE / REPAIR TABLE or automatic repair of MyISAM tables.
Added mutex around some data in the slave start/stop code that could cause THD linked list corruptions
Extended my_chsize() to allow one to specify a filler character.
Extend vio_blocking to return the old state (This made some usage of this function much simpler)
Added testing for some functions that they caller have got the required mutexes before calling the function.
Use setrlimit() to ensure that we can write core file if one specifies --core-file.
Added --slave-compressed-protocol
Made 2 the minimum length for ft_min_word_len
Added variables foreign_key_checks & unique_checks.
Less logging from replication code (if not started with --log-warnings)
Changed that SHOW INNODB STATUS requre the SUPER privilege
More DBUG statements and a lot of new code comments


BitKeeper/deleted/.del-rpl_compat.result~c950bc346b12c61a:
  Delete: mysql-test/r/rpl_compat.result
BitKeeper/deleted/.del-rpl_compat.test~5f6ba955e02aa95f:
  Delete: mysql-test/t/rpl_compat.test
Docs/manual.texi:
  Updated manual with fixes in this changeset
client/mysqltest.c:
  Indentation cleanup
  Better error messages for some error conditions.
include/my_pthread.h:
  Added 'safe_mutex_assert_owner()' to check that the thread really owns the mutex.
include/my_sys.h:
  Extended my_chsize() to allow one to specify a filler character.
  (For MySQL index logs)
include/raid.h:
  New my_chsize()
include/violite.h:
  Extend vio_blocking to return the old state
innobase/include/dyn0dyn.h:
  Merge with 3.23 (AIX DYN_ARRAY_DATA_SIZE)
innobase/include/dyn0dyn.ic:
  Merge with 3.23
isam/create.c:
  Fix for new my_chsize()
isam/isamchk.c:
  Fix for new my_chsize()
isam/pack_isam.c:
  Fix for new my_chsize()
libmysql/manager.c:
  Fix for new vio_blocking()
libmysqld/lib_sql.cc:
  Fix for new open_log()
myisam/mi_cache.c:
  Fix typo from previous checking
myisam/mi_check.c:
  Fix for new my_chsize()
myisam/mi_create.c:
  Fix for new my_chsize()
myisam/mi_delete_all.c:
  Fix for new my_chsize()
myisam/myisampack.c:
  Fix for new my_chsize()
mysql-test/include/master-slave.inc:
  Better initialization for replication tests
mysql-test/mysql-test-run.sh:
  Added option --log-warnings
mysql-test/r/insert.result:
  More tests if INSERT ...(DEFAULT)
mysql-test/r/rpl000001.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000002.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000003.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000004.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000005.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000006.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000007.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000008.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000009.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000010.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000011.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000012.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000013.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl000014.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl_alter.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl_empty_master_crash.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl_get_lock.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl_log.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl_magic.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl_mystery22.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl_skip_error.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/r/rpl_sporadic_master.result:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/insert.test:
  More tests if INSERT ...(DEFAULT)
mysql-test/t/rpl000001.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000002.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000003.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000004.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000005.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000006.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000007.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000009.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000011.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000013.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl000014.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl_alter.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl_empty_master_crash.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl_get_lock.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl_magic.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl_mystery22.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl_skip_error.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysql-test/t/rpl_sporadic_master.test:
  Clean up tests for new master-slave.inc
  Remove 'use database'
mysys/mf_iocache.c:
  More debug info
  Force seek after reinit_io_cache()
mysys/mf_iocache2.c:
  Added my_b_filelength()
mysys/my_chsize.c:
  Extended my_chsize() to allow one to specify a filler character.
  (For MySQL index logs)
mysys/raid.cc:
  Extended my_chsize() to allow one to specify a filler character.
  (For MySQL index logs)
sql/field.h:
  Fix for INSERT ... (DEFAULT)
sql/ha_berkeley.h:
  Fix for dynamic variables
sql/ha_innodb.cc:
  Change sprintf() to my_sprintf() to make code portable.
  Fix after sync with 3.23
  (We still need to fix the storage of the replication position in innodb)
sql/ha_innodb.h:
  Fix for dynamic variables
sql/handler.cc:
  Remove writting of COMMIT to the binary log.
  (Now done in MYSQL_LOG::write())
sql/item_func.cc:
  Query_log_event() now always takes query length.
sql/item_func.h:
  Indentation cleanup
sql/item_strfunc.h:
  Indentation cleanup
sql/item_timefunc.h:
  Indentation cleanup
sql/lock.cc:
  Check that we own critical mutexes.
sql/log.cc:
  Big code cleanup / rewrite / optimize.
  - The index log file has its own IO_CACHE object.
  - Many functions totally rewritten to make them smaller and faster.
  - New handling of index log files
  - Lots of new comments
sql/log_event.cc:
  Code cleanup
  New comments
sql/log_event.h:
  Query_log_event() now always takes query length.
sql/mini_client.cc:
  Better error messages on reconnect.
  Fixed wrong variable usage from last commit.
sql/mysql_priv.h:
  New arguments to open_log()
sql/mysqld.cc:
  Use setrlimit() to ensure that we can write core file if one specifies --core-file
  Added index file name as parameter to openlog().
  Added --slave-compressed-protocol
  Made 2 the minimum length for ft_min_word_len
sql/net_serv.cc:
  Use new vio_blocking()
  (The vio_blocking() change was done to make this code more readable)
sql/repl_failsafe.cc:
  Minor code cleanup
sql/set_var.cc:
  Added variables slave_compressed_protocol, foreign_key_checks & unique_checks.
sql/set_var.h:
  Generalization
sql/slave.cc:
  Code cleanup & rewrite.
  Dont call SELECT VERSION() on check_master_version()
  New init_slave() code.
  Ensure that all threads create a THD early.
  Add locks around manipulation of critical structures
  Don't retry a command more than master_retry_count times.
  Write less warnings to the log file (if not started with --log-warnings)
  Faster flush_relay_log_info()
sql/slave.h:
  More comments
  Added new arguments to some functions.
sql/sql_acl.cc:
  More DBUG info
  New parameter to Query_log_event()
sql/sql_base.cc:
  Added some mutex checking.
sql/sql_cache.cc:
  Less not critical debug info
sql/sql_class.h:
  Fix for new log handling.
sql/sql_db.cc:
  Added mutex around remove_db_from_cache()
sql/sql_delete.cc:
  Added missing parameters to changed functions
sql/sql_insert.cc:
  Added missing parameters to changed functions
sql/sql_parse.cc:
  Do an 'end_active_trans()' before 'load_master_data'
  Changed that SHOW INNODB STATUS requre the SUPER privilege
  Added new function parameters to new functions
sql/sql_rename.cc:
  Added missing parameters to changed functions
sql/sql_repl.cc:
  Code cleanups / new comments
  Fix for new find_first_log() calling standard.
  More DBUG statements.
  Show binlogs updated to use new IO_CACHE:d index log file.
sql/sql_repl.h:
  New function arguments
sql/sql_select.cc:
  Indentation changes
sql/sql_table.cc:
  Added missing parameters to changed functions
  Added checking of mutex
  Added mutex around critical regions.
sql/sql_test.cc:
  Don't use THR_ALARM if the configuration doesn't support it.
sql/sql_update.cc:
  Added missing parameters to changed functions
sql/table.cc:
  Added missing parameters to changed functions
vio/vio.c:
  Extend vio_blocking to return the old state
vio/viosocket.c:
  Extend vio_blocking to return the old state
vio/viossl.c:
  Extend vio_blocking to return the old state
2002-08-08 03:12:02 +03:00

262 lines
6.8 KiB
C++

/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Write some debug info */
#include "mysql_priv.h"
#include "sql_select.h"
#include <hash.h>
#include <thr_alarm.h>
/* Intern key cache variables */
extern "C" pthread_mutex_t THR_LOCK_keycache;
#ifndef DBUG_OFF
void
print_where(COND *cond,const char *info)
{
if (cond)
{
char buff[256];
String str(buff,(uint32) sizeof(buff));
str.length(0);
cond->print(&str);
str.append('\0');
DBUG_LOCK_FILE;
(void) fprintf(DBUG_FILE,"\nWHERE:(%s) ",info);
(void) fputs(str.ptr(),DBUG_FILE);
(void) fputc('\n',DBUG_FILE);
DBUG_UNLOCK_FILE;
}
}
/* This is for debugging purposes */
extern HASH open_cache;
extern TABLE *unused_tables;
void print_cached_tables(void)
{
uint idx,count,unused;
TABLE *start_link,*lnk;
VOID(pthread_mutex_lock(&LOCK_open));
puts("DB Table Version Thread L.thread Open");
for (idx=unused=0 ; idx < open_cache.records ; idx++)
{
TABLE *entry=(TABLE*) hash_element(&open_cache,idx);
printf("%-14.14s %-32s%6ld%8ld%10ld%6d\n",
entry->table_cache_key,entry->real_name,entry->version,
entry->in_use ? entry->in_use->thread_id : 0L,
entry->in_use ? entry->in_use->dbug_thread_id : 0L,
entry->db_stat ? 1 : 0);
if (!entry->in_use)
unused++;
}
count=0;
if ((start_link=lnk=unused_tables))
{
do
{
if (lnk != lnk->next->prev || lnk != lnk->prev->next)
{
printf("unused_links isn't linked properly\n");
return;
}
} while (count++ < open_cache.records && (lnk=lnk->next) != start_link);
if (lnk != start_link)
{
printf("Unused_links aren't connected\n");
}
}
if (count != unused)
printf("Unused_links (%d) doesn't match open_cache: %d\n", count,unused);
printf("\nCurrent refresh version: %ld\n",refresh_version);
if (hash_check(&open_cache))
printf("Error: File hash table is corrupted\n");
fflush(stdout);
VOID(pthread_mutex_unlock(&LOCK_open));
return;
}
void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special)
{
char buff[256],buff2[256];
String str(buff,sizeof(buff)),out(buff2,sizeof(buff2));
const char *sep;
DBUG_ENTER("TEST_filesort");
out.length(0);
for (sep=""; s_length-- ; sortorder++, sep=" ")
{
out.append(sep);
if (sortorder->reverse)
out.append('-');
if (sortorder->field)
{
if (sortorder->field->table_name)
{
out.append(sortorder->field->table_name);
out.append('.');
}
out.append(sortorder->field->field_name ? sortorder->field->field_name:
"tmp_table_column");
}
else
{
str.length(0);
sortorder->item->print(&str);
out.append(str);
}
}
out.append('\0'); // Purify doesn't like c_ptr()
DBUG_LOCK_FILE;
VOID(fputs("\nInfo about FILESORT\n",DBUG_FILE));
if (special)
fprintf(DBUG_FILE,"Records to sort: %ld\n",special);
fprintf(DBUG_FILE,"Sortorder: %s\n",out.ptr());
DBUG_UNLOCK_FILE;
DBUG_VOID_RETURN;
}
void
TEST_join(JOIN *join)
{
uint i,ref;
DBUG_ENTER("TEST_join");
DBUG_LOCK_FILE;
VOID(fputs("\nInfo about JOIN\n",DBUG_FILE));
for (i=0 ; i < join->tables ; i++)
{
JOIN_TAB *tab=join->join_tab+i;
TABLE *form=tab->table;
fprintf(DBUG_FILE,"%-16.16s type: %-7s q_keys: %4d refs: %d key: %d len: %d\n",
form->table_name,
join_type_str[tab->type],
tab->keys,
tab->ref.key_parts,
tab->ref.key,
tab->ref.key_length);
if (tab->select)
{
if (tab->use_quick == 2)
fprintf(DBUG_FILE,
" quick select checked for each record (keys: %d)\n",
(int) tab->select->quick_keys);
else if (tab->select->quick)
fprintf(DBUG_FILE," quick select used on key %s, length: %d\n",
form->key_info[tab->select->quick->index].name,
tab->select->quick->max_used_key_length);
else
VOID(fputs(" select used\n",DBUG_FILE));
}
if (tab->ref.key_parts)
{
VOID(fputs(" refs: ",DBUG_FILE));
for (ref=0 ; ref < tab->ref.key_parts ; ref++)
{
Item *item=tab->ref.items[ref];
fprintf(DBUG_FILE,"%s ", item->full_name());
}
VOID(fputc('\n',DBUG_FILE));
}
}
DBUG_UNLOCK_FILE;
DBUG_VOID_RETURN;
}
#endif
void mysql_print_status(THD *thd)
{
char current_dir[FN_REFLEN];
printf("\nStatus information:\n\n");
my_getwd(current_dir, sizeof(current_dir),MYF(0));
printf("Current dir: %s\n", current_dir);
if (thd)
thd->proc_info="locks";
thr_print_locks(); // Write some debug info
#ifndef DBUG_OFF
if (thd)
thd->proc_info="table cache";
print_cached_tables();
#endif
/* Print key cache status */
if (thd)
thd->proc_info="key cache";
pthread_mutex_lock(&THR_LOCK_keycache);
printf("key_cache status:\n\
blocks used:%10lu\n\
not flushed:%10lu\n\
w_requests: %10lu\n\
writes: %10lu\n\
r_requests: %10lu\n\
reads: %10lu\n",
_my_blocks_used,_my_blocks_changed,_my_cache_w_requests,
_my_cache_write,_my_cache_r_requests,_my_cache_read);
pthread_mutex_unlock(&THR_LOCK_keycache);
if (thd)
thd->proc_info="status";
pthread_mutex_lock(&LOCK_status);
printf("\nhandler status:\n\
read_key: %10lu\n\
read_next: %10lu\n\
read_rnd %10lu\n\
read_first: %10lu\n\
write: %10lu\n\
delete %10lu\n\
update: %10lu\n",
ha_read_key_count, ha_read_next_count,
ha_read_rnd_count, ha_read_first_count,
ha_write_count, ha_delete_count, ha_update_count);
pthread_mutex_unlock(&LOCK_status);
printf("\nTable status:\n\
Opened tables: %10lu\n\
Open tables: %10lu\n\
Open files: %10lu\n\
Open streams: %10lu\n",
opened_tables,
(ulong) cached_tables(),
(ulong) my_file_opened,
(ulong) my_stream_opened);
ALARM_INFO alarm_info;
#ifndef DONT_USE_THR_ALARM
thr_alarm_info(&alarm_info);
printf("\nAlarm status:\n\
Active alarms: %u\n\
Max used alarms: %u\n\
Next alarm time: %lu\n",
alarm_info.active_alarms,
alarm_info.max_used_alarms,
alarm_info.next_alarm_time);
#endif
fflush(stdout);
if (thd)
thd->proc_info="malloc";
my_checkmalloc();
TERMINATE(stdout); // Write malloc information
if (thd)
thd->proc_info=0;
}