Commit 54e36baf authored by tim@threads.polyesthetic.msg's avatar tim@threads.polyesthetic.msg

Merge work.mysql.com:/home/bk/mysql

into threads.polyesthetic.msg:/usr/local/src/my/3
parents a37b9715 2f990484
mwagner@evoq.mwagner.org
tim@threads.polyesthetic.msg
tim@work.mysql.com
heikki@donna.mysql.fi
paul@central.snake.net
monty@donna.mysql.fi
This diff is collapsed.
......@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line!
AM_INIT_AUTOMAKE(mysql, 3.23.38)
AM_INIT_AUTOMAKE(mysql, 3.23.39)
AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10
......@@ -751,8 +751,8 @@ case $SYSTEM_TYPE in
;;
*hpux10.20*)
echo "Enabling snprintf workaround for hpux 10.20"
CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF"
CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG"
CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ"
CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ"
;;
*hpux11.*)
echo "Enabling pread/pwrite workaround for hpux 11"
......@@ -806,8 +806,8 @@ case $SYSTEM_TYPE in
;;
*aix4.3*)
echo "Adding defines for AIX"
CFLAGS="$CFLAGS -Wa,-many -DUNDEF_HAVE_INITGROUPS"
CXXFLAGS="$CXXFLAGS -Wa,-many -DUNDEF_HAVE_INITGROUPS"
CFLAGS="$CFLAGS -Wa,-many -DUNDEF_HAVE_INITGROUPS -DSIGNALS_DONT_BREAK_READ"
CXXFLAGS="$CXXFLAGS -Wa,-many -DUNDEF_HAVE_INITGROUPS -DSIGNALS_DONT_BREAK_READ"
;;
dnl Is this the right match for DEC OSF on alpha?
*dec-osf*)
......
......@@ -235,6 +235,71 @@ dict_table_get_index_noninline(
return(dict_table_get_index(table, name));
}
/************************************************************************
Initializes the autoinc counter. It is not an error to initialize already
initialized counter. */
void
dict_table_autoinc_initialize(
/*==========================*/
dict_table_t* table, /* in: table */
ib_longlong value) /* in: value which was assigned to a row */
{
mutex_enter(&(table->autoinc_mutex));
table->autoinc_inited = TRUE;
table->autoinc = value;
mutex_exit(&(table->autoinc_mutex));
}
/************************************************************************
Gets the next autoinc value, 0 if not yet initialized. */
ib_longlong
dict_table_autoinc_get(
/*===================*/
/* out: value for a new row, or 0 */
dict_table_t* table) /* in: table */
{
ib_longlong value;
mutex_enter(&(table->autoinc_mutex));
if (!table->autoinc_inited) {
value = 0;
} else {
table->autoinc = table->autoinc + 1;
value = table->autoinc;
}
mutex_exit(&(table->autoinc_mutex));
return(value);
}
/************************************************************************
Updates the autoinc counter if the value supplied is bigger than the
current value. If not inited, does nothing. */
void
dict_table_autoinc_update(
/*======================*/
dict_table_t* table, /* in: table */
ib_longlong value) /* in: value which was assigned to a row */
{
mutex_enter(&(table->autoinc_mutex));
if (table->autoinc_inited) {
if (value > table->autoinc) {
table->autoinc = value;
}
}
mutex_exit(&(table->autoinc_mutex));
}
/************************************************************************
Looks for column n in an index. */
......@@ -568,6 +633,8 @@ dict_table_remove_from_cache(
/* Remove table from LRU list of tables */
UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
mutex_free(&(table->autoinc_mutex));
size = mem_heap_get_size(table->heap);
ut_ad(dict_sys->size >= size);
......
......@@ -71,6 +71,11 @@ dict_mem_table_create(
table->stat_modif_counter = 0;
mutex_create(&(table->autoinc_mutex));
mutex_set_level(&(table->autoinc_mutex), SYNC_DICT_AUTOINC_MUTEX);
table->autoinc_inited = FALSE;
table->magic_n = DICT_TABLE_MAGIC_N;
return(table);
......
......@@ -1002,24 +1002,40 @@ ibuf_rec_get_volume(
/*================*/
/* out: size of index record in bytes + an upper
limit of the space taken in the page directory */
rec_t* rec) /* in: ibuf record */
rec_t* ibuf_rec)/* in: ibuf record */
{
dtype_t dtype;
ulint data_size = 0;
ulint n_fields;
byte* field;
byte* types;
byte* data;
ulint len;
ulint data_size;
ulint i;
ut_ad(ibuf_inside());
ut_ad(rec_get_n_fields(rec) > 2);
n_fields = rec_get_n_fields(ibuf_rec) - 2;
n_fields = rec_get_n_fields(rec) - 2;
types = rec_get_nth_field(ibuf_rec, 1, &len);
field = rec_get_nth_field(rec, 2, &len);
ut_ad(len == n_fields * DATA_ORDER_NULL_TYPE_BUF_SIZE);
data_size = rec_get_data_size(rec) - (field - rec);
for (i = 0; i < n_fields; i++) {
data = rec_get_nth_field(ibuf_rec, i + 2, &len);
dtype_read_for_order_and_null_size(&dtype,
types + i * DATA_ORDER_NULL_TYPE_BUF_SIZE);
if (len == UNIV_SQL_NULL) {
data_size += dtype_get_sql_null_size(&dtype);
} else {
data_size += len;
}
}
return(data_size + rec_get_converted_extra_size(data_size, n_fields)
+ page_dir_calc_reserved_space(1));
+ page_dir_calc_reserved_space(1));
}
/*************************************************************************
......
......@@ -88,6 +88,32 @@ ulint
dict_col_get_clust_pos(
/*===================*/
dict_col_t* col);
/************************************************************************
Initializes the autoinc counter. It is not an error to initialize already
initialized counter. */
void
dict_table_autoinc_initialize(
/*==========================*/
dict_table_t* table, /* in: table */
ib_longlong value); /* in: value which was assigned to a row */
/************************************************************************
Gets the next autoinc value, 0 if not yet initialized. */
ib_longlong
dict_table_autoinc_get(
/*===================*/
/* out: value for a new row, or 0 */
dict_table_t* table); /* in: table */
/************************************************************************
Updates the autoinc counter if the value supplied is bigger than the
current value. If not inited, does nothing. */
void
dict_table_autoinc_update(
/*======================*/
dict_table_t* table, /* in: table */
ib_longlong value); /* in: value which was assigned to a row */
/**************************************************************************
Adds a table object to the dictionary cache. */
......
......@@ -302,6 +302,16 @@ struct dict_table_struct{
for MySQL SHOW TABLE STATUS; this counter
is not protected by any latch, because this
is only used for heuristics */
/*----------------------*/
mutex_t autoinc_mutex;
/* mutex protecting the autoincrement
counter */
ibool autoinc_inited;
/* TRUE if the autoinc counter has been
inited; MySQL gets the init value by executing
SELECT MAX(auto inc column) */
ib_longlong autoinc;/* autoinc counter value already given to
a row */
ulint magic_n;/* magic number */
};
#define DICT_TABLE_MAGIC_N 76333786
......
......@@ -13,12 +13,10 @@ Created 10/21/1995 Heikki Tuuri
#ifdef __WIN__
#if (defined(__NT__) || defined(__WIN2000__))
/* We define always WIN_ASYNC_IO, and check at run-time whether
the OS actually supports it: Win 95 does not, NT does. */
#define WIN_ASYNC_IO
#endif
#define UNIV_NON_BUFFERED_IO
#else
......@@ -100,7 +98,17 @@ log. */
requests in a batch, and only after that
wake the i/o-handler thread; this has
effect only in simulated aio */
#define OS_WIN31 1
#define OS_WIN95 2
#define OS_WINNT 3
/***************************************************************************
Gets the operating system version. Currently works only on Windows. */
ulint
os_get_os_version(void);
/*===================*/
/* out: OS_WIN95, OS_WIN31, OS_WINNT (2000 == NT) */
/********************************************************************
Opens an existing file or creates a new. */
......
......@@ -372,6 +372,7 @@ Memory pool mutex */
latching order checking */
#define SYNC_LEVEL_NONE 2000 /* default: level not defined */
#define SYNC_DICT 1000
#define SYNC_DICT_AUTOINC_MUTEX 999
#define SYNC_PURGE_IS_RUNNING 997
#define SYNC_DICT_HEADER 995
#define SYNC_IBUF_HEADER 914
......
......@@ -155,6 +155,12 @@ typedef unsigned long int ulint;
typedef long int lint;
#ifdef __WIN__
typedef __int64 ib_longlong;
#else
typedef longlong ib_longlong;
#endif
/* The following type should be at least a 64-bit floating point number */
typedef double utfloat;
......
......@@ -327,7 +327,8 @@ log_pad_current_log_block(void)
ulint i;
dulint lsn;
log_reserve_and_open(OS_FILE_LOG_BLOCK_SIZE);
/* We retrieve lsn only because otherwise gcc crashed on HP-UX */
lsn = log_reserve_and_open(OS_FILE_LOG_BLOCK_SIZE);
pad_length = OS_FILE_LOG_BLOCK_SIZE
- (log_sys->buf_free % OS_FILE_LOG_BLOCK_SIZE)
......
......@@ -103,6 +103,38 @@ os_aio_array_t* os_aio_sync_array = NULL;
ulint os_aio_n_segments = ULINT_UNDEFINED;
/***************************************************************************
Gets the operating system version. Currently works only on Windows. */
ulint
os_get_os_version(void)
/*===================*/
/* out: OS_WIN95, OS_WIN31, OS_WINNT (2000 == NT) */
{
#ifdef __WIN__
OSVERSIONINFO os_info;
os_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
ut_a(GetVersionEx(&os_info));
if (os_info.dwPlatformId == VER_PLATFORM_WIN32s) {
return(OS_WIN31);
} else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
return(OS_WIN95);
} else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT) {
return(OS_WINNT);
} else {
ut_error;
return(0);
}
#else
ut_error;
return(0);
#endif
}
/***************************************************************************
Retrieves the last error number if an error occurs in a file io function.
The number should be retrieved before any other OS calls (because they may
......@@ -438,13 +470,13 @@ os_file_set_size(
byte* buf;
try_again:
/* We use a very big 16 MB buffer in writing because Linux is
/* We use a very big 8 MB buffer in writing because Linux may be
extremely slow in fdatasync on 1 MB writes */
buf = ut_malloc(UNIV_PAGE_SIZE * 1024);
buf = ut_malloc(UNIV_PAGE_SIZE * 512);
/* Write buffer full of zeros */
for (i = 0; i < UNIV_PAGE_SIZE * 1024; i++) {
for (i = 0; i < UNIV_PAGE_SIZE * 512; i++) {
buf[i] = '\0';
}
......@@ -456,10 +488,10 @@ try_again:
UT_NOT_USED(size_high);
#endif
while (offset < low) {
if (low - offset < UNIV_PAGE_SIZE * 1024) {
if (low - offset < UNIV_PAGE_SIZE * 512) {
n_bytes = low - offset;
} else {
n_bytes = UNIV_PAGE_SIZE * 1024;
n_bytes = UNIV_PAGE_SIZE * 512;
}
ret = os_file_write(name, file, buf, offset, 0, n_bytes);
......@@ -475,8 +507,6 @@ try_again:
ret = os_file_flush(file);
fsync(file);
if (ret) {
return(TRUE);
}
......
......@@ -549,11 +549,19 @@ innobase_start_or_create_for_mysql(void)
srv_n_file_io_threads = 4;
#endif
#ifdef WIN_ASYNC_IO
/* On NT always use aio */
os_aio_use_native_aio = TRUE;
#endif
#ifdef __WIN__
if (os_get_os_version() == OS_WIN95
|| os_get_os_version() == OS_WIN31) {
/* On Win 95, 98, ME, and Win32 subsystem for Windows 3.1 use
simulated aio */
os_aio_use_native_aio = FALSE;
srv_n_file_io_threads = 4;
} else {
/* On NT and Win 2000 always use aio */
os_aio_use_native_aio = TRUE;
}
#endif
if (!os_aio_use_native_aio) {
os_aio_init(4 * SRV_N_PENDING_IOS_PER_THREAD
* srv_n_file_io_threads,
......@@ -600,6 +608,19 @@ innobase_start_or_create_for_mysql(void)
return(DB_ERROR);
}
sum_of_new_sizes = 0;
for (i = 0; i < srv_n_data_files; i++) {
sum_of_new_sizes += srv_data_file_sizes[i];
}
if (sum_of_new_sizes < 640) {
fprintf(stderr,
"InnoDB: Error: tablespace size must be at least 10 MB\n");
return(DB_ERROR);
}
err = open_or_create_data_files(&create_new_db,
&min_flushed_lsn, &min_arch_log_no,
&max_flushed_lsn, &max_arch_log_no,
......
......@@ -1001,6 +1001,8 @@ sync_thread_add_level(
&& !sync_thread_levels_contain(array, SYNC_IBUF_MUTEX)
&& !sync_thread_levels_contain(array,
SYNC_IBUF_PESS_INSERT_MUTEX));
} else if (level == SYNC_DICT_AUTOINC_MUTEX) {
ut_a(sync_thread_levels_g(array, SYNC_DICT_AUTOINC_MUTEX));
} else if (level == SYNC_DICT_HEADER) {
ut_a(sync_thread_levels_g(array, SYNC_DICT_HEADER));
} else if (level == SYNC_PURGE_IS_RUNNING) {
......
......@@ -109,3 +109,4 @@ insert into t1 values (1,2),(2,1),(0,0),(4,4),(5,5),(6,6);
insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6);
flush tables;
select * from t3 where a=1 order by b limit 2;
drop table t1,t2,t3;
......@@ -222,7 +222,7 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
const char *dir, const char *config_file,
const char *ext, TYPELIB *group)
{
char name[FN_REFLEN+10],buff[257],*ptr,*end,*value,*tmp;
char name[FN_REFLEN+10],buff[FN_REFLEN+1],*ptr,*end,*value,*tmp;
FILE *fp;
uint line=0;
my_bool read_values=0,found_group=0;
......
......@@ -381,7 +381,7 @@ static SEC_LINK *find_key_block(int file, my_off_t filepos, int *error)
reg1 SEC_LINK *next,**start;
#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
DBUG_EXECUTE("check_keycache",test_key_cache("start of find_key_block",0););
DBUG_EXECUTE("check_keycache2",test_key_cache("start of find_key_block",0););
#endif
*error=0;
......@@ -459,7 +459,7 @@ static SEC_LINK *find_key_block(int file, my_off_t filepos, int *error)
}
_my_used_last=next;
#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
DBUG_EXECUTE("check_keycache",test_key_cache("end of find_key_block",0););
DBUG_EXECUTE("check_keycache2",test_key_cache("end of find_key_block",0););
#endif
return next;
} /* find_key_block */
......
......@@ -1242,7 +1242,8 @@ ha_innobase::write_row(
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
int error;
longlong auto_inc;
DBUG_ENTER("ha_innobase::write_row");
statistic_increment(ha_write_count, &LOCK_status);
......@@ -1261,10 +1262,43 @@ ha_innobase::write_row(
make sure all columns are fetched in the select done by
update_auto_increment */
prebuilt->in_update_remember_pos = FALSE;
/* Fetch the value the user possibly has set in the
autoincrement field */
auto_inc = table->next_number_field->val_int();
if (auto_inc != 0) {
/* This call will calculate the max of the
current value and the value supplied by the user, if
the auto_inc counter is already initialized
for the table */
dict_table_autoinc_update(prebuilt->table, auto_inc);
} else {
auto_inc = dict_table_autoinc_get(prebuilt->table);
/* If auto_inc is now != 0 the autoinc counter
was already initialized for the table: we can give
the new value for MySQL to place in the field */
if (auto_inc != 0) {
user_thd->next_insert_id = auto_inc;
}
}
prebuilt->in_update_remember_pos = FALSE;
update_auto_increment();
if (auto_inc == 0) {
/* The autoinc counter for our table was not yet
initialized, initialize it now */
auto_inc = table->next_number_field->val_int();
dict_table_autoinc_initialize(prebuilt->table,
auto_inc);
}
/* We have to set sql_stat_start to TRUE because
update_auto_increment has called a select, and
has reset that flag; row_insert_for_mysql has to
......
......@@ -429,7 +429,7 @@ static void close_connections(void)
if (error != 0 && !count++)
sql_print_error("Got error %d from pthread_cond_timedwait",error);
#endif
#if defined(AIX_3_2) || defined(HAVE_DEC_3_2_THREADS)
#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ)
if (ip_sock != INVALID_SOCKET)
{
DBUG_PRINT("error",("closing TCP/IP and socket files"));
......@@ -544,9 +544,9 @@ static void close_connections(void)
(void) pthread_mutex_unlock(&LOCK_thread_count);
mysql_log.close(1);
mysql_slow_log.close(1);
mysql_update_log.close(1);
mysql_bin_log.close(1);
my_free(charsets_list, MYF(0));
DBUG_PRINT("quit",("close_connections thread"));
DBUG_VOID_RETURN;
}
......@@ -680,6 +680,7 @@ void clean_up(bool print_message)
end_raid();
#endif
free_defaults(defaults_argv);
my_free(charsets_list, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql_tmpdir,MYF(0));
x_free(opt_bin_logname);
bitmap_free(&temp_pool);
......@@ -2487,9 +2488,7 @@ static struct option long_options[] = {
{"chroot", required_argument, 0, 'r'},
{"character-sets-dir", required_argument, 0, (int) OPT_CHARSETS_DIR},
{"datadir", required_argument, 0, 'h'},
#ifndef DBUG_OFF
{"debug", optional_argument, 0, '#'},
#endif
{"default-character-set", required_argument, 0, 'C'},
{"default-table-type", required_argument, 0, (int) OPT_TABLE_TYPE},
{"delay-key-write-for-all-tables",
......@@ -2544,10 +2543,8 @@ static struct option long_options[] = {
(int) OPT_DISCONNECT_SLAVE_EVENT_COUNT},
{"abort-slave-event-count", required_argument, 0,
(int) OPT_ABORT_SLAVE_EVENT_COUNT},
#if !defined(DBUG_OFF) && defined(SAFEMALLOC)
{"safemalloc-mem-limit", required_argument, 0, (int)
OPT_SAFEMALLOC_MEM_LIMIT},
#endif
{"new", no_argument, 0, 'n'},
{"old-protocol", no_argument, 0, 'o'},
#ifdef ONE_THREAD
......@@ -3165,12 +3162,12 @@ static void get_options(int argc,char **argv)
long_options, &option_index)) != EOF)
{
switch(c) {
#ifndef DBUG_OFF
case '#':
#ifndef DBUG_OFF
DBUG_PUSH(optarg ? optarg : default_dbug_option);
#endif
opt_endinfo=1; /* unireg: memory allocation */
break;
#endif
case 'a':
opt_ansi_mode=1;
thd_startup_options|=OPTION_ANSI_MODE;
......@@ -3205,11 +3202,11 @@ static void get_options(int argc,char **argv)
case 'P':
mysql_port= (unsigned int) atoi(optarg);
break;
#if !defined(DBUG_OFF) && defined(SAFEMALLOC)
case OPT_SAFEMALLOC_MEM_LIMIT:
#if !defined(DBUG_OFF) && defined(SAFEMALLOC)
safemalloc_mem_limit = atoi(optarg);
break;
#endif
break;
case OPT_SOCKET:
mysql_unix_port= optarg;
break;
......
......@@ -179,7 +179,7 @@ int vio_read(Vio * vio, gptr buf, int size)
#ifndef DBUG_OFF
if (r < 0)
{
DBUG_PRINT("error", ("Got error %d during read",errno));
DBUG_PRINT("vio_error", ("Got error %d during read",errno));
}
#endif /* DBUG_OFF */
DBUG_PRINT("exit", ("%d", r));
......@@ -207,7 +207,7 @@ int vio_write(Vio * vio, const gptr buf, int size)
#ifndef DBUG_OFF
if (r < 0)
{
DBUG_PRINT("error", ("Got error on write: %d",errno));
DBUG_PRINT("vio_error", ("Got error on write: %d",errno));
}
#endif /* DBUG_OFF */
DBUG_PRINT("exit", ("%d", r));
......@@ -346,7 +346,7 @@ int vio_close(Vio * vio)
}
if (r)
{
DBUG_PRINT("error", ("close() failed, error: %d",errno));
DBUG_PRINT("vio_error", ("close() failed, error: %d",errno));
/* FIXME: error handling (not critical for MySQL) */
}
vio->type= VIO_CLOSED;
......
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