mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge work.mysql.com:/home/bk/mysql
into work.mysql.com:/home/bk/mysql-4.0 Docs/manual.texi: Auto merged sql/sql_parse.cc: Auto merged
This commit is contained in:
572
Docs/manual.texi
572
Docs/manual.texi
File diff suppressed because it is too large
Load Diff
@ -235,6 +235,71 @@ dict_table_get_index_noninline(
|
|||||||
return(dict_table_get_index(table, name));
|
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. */
|
Looks for column n in an index. */
|
||||||
|
|
||||||
@ -568,6 +633,8 @@ dict_table_remove_from_cache(
|
|||||||
/* Remove table from LRU list of tables */
|
/* Remove table from LRU list of tables */
|
||||||
UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
|
UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
|
||||||
|
|
||||||
|
mutex_free(&(table->autoinc_mutex));
|
||||||
|
|
||||||
size = mem_heap_get_size(table->heap);
|
size = mem_heap_get_size(table->heap);
|
||||||
|
|
||||||
ut_ad(dict_sys->size >= size);
|
ut_ad(dict_sys->size >= size);
|
||||||
|
@ -71,6 +71,11 @@ dict_mem_table_create(
|
|||||||
|
|
||||||
table->stat_modif_counter = 0;
|
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;
|
table->magic_n = DICT_TABLE_MAGIC_N;
|
||||||
|
|
||||||
return(table);
|
return(table);
|
||||||
|
@ -88,6 +88,32 @@ ulint
|
|||||||
dict_col_get_clust_pos(
|
dict_col_get_clust_pos(
|
||||||
/*===================*/
|
/*===================*/
|
||||||
dict_col_t* col);
|
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. */
|
Adds a table object to the dictionary cache. */
|
||||||
|
|
||||||
|
@ -302,6 +302,16 @@ struct dict_table_struct{
|
|||||||
for MySQL SHOW TABLE STATUS; this counter
|
for MySQL SHOW TABLE STATUS; this counter
|
||||||
is not protected by any latch, because this
|
is not protected by any latch, because this
|
||||||
is only used for heuristics */
|
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 */
|
ulint magic_n;/* magic number */
|
||||||
};
|
};
|
||||||
#define DICT_TABLE_MAGIC_N 76333786
|
#define DICT_TABLE_MAGIC_N 76333786
|
||||||
|
@ -13,12 +13,10 @@ Created 10/21/1995 Heikki Tuuri
|
|||||||
|
|
||||||
#ifdef __WIN__
|
#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
|
#define WIN_ASYNC_IO
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define UNIV_NON_BUFFERED_IO
|
#define UNIV_NON_BUFFERED_IO
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -100,7 +98,17 @@ log. */
|
|||||||
requests in a batch, and only after that
|
requests in a batch, and only after that
|
||||||
wake the i/o-handler thread; this has
|
wake the i/o-handler thread; this has
|
||||||
effect only in simulated aio */
|
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. */
|
Opens an existing file or creates a new. */
|
||||||
|
|
||||||
|
@ -372,6 +372,7 @@ Memory pool mutex */
|
|||||||
latching order checking */
|
latching order checking */
|
||||||
#define SYNC_LEVEL_NONE 2000 /* default: level not defined */
|
#define SYNC_LEVEL_NONE 2000 /* default: level not defined */
|
||||||
#define SYNC_DICT 1000
|
#define SYNC_DICT 1000
|
||||||
|
#define SYNC_DICT_AUTOINC_MUTEX 999
|
||||||
#define SYNC_PURGE_IS_RUNNING 997
|
#define SYNC_PURGE_IS_RUNNING 997
|
||||||
#define SYNC_DICT_HEADER 995
|
#define SYNC_DICT_HEADER 995
|
||||||
#define SYNC_IBUF_HEADER 914
|
#define SYNC_IBUF_HEADER 914
|
||||||
|
@ -155,6 +155,12 @@ typedef unsigned long int ulint;
|
|||||||
|
|
||||||
typedef long int lint;
|
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 */
|
/* The following type should be at least a 64-bit floating point number */
|
||||||
typedef double utfloat;
|
typedef double utfloat;
|
||||||
|
|
||||||
|
@ -103,6 +103,38 @@ os_aio_array_t* os_aio_sync_array = NULL;
|
|||||||
|
|
||||||
ulint os_aio_n_segments = ULINT_UNDEFINED;
|
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.
|
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
|
The number should be retrieved before any other OS calls (because they may
|
||||||
@ -438,13 +470,13 @@ os_file_set_size(
|
|||||||
byte* buf;
|
byte* buf;
|
||||||
|
|
||||||
try_again:
|
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 */
|
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 */
|
/* 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';
|
buf[i] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,10 +488,10 @@ try_again:
|
|||||||
UT_NOT_USED(size_high);
|
UT_NOT_USED(size_high);
|
||||||
#endif
|
#endif
|
||||||
while (offset < low) {
|
while (offset < low) {
|
||||||
if (low - offset < UNIV_PAGE_SIZE * 1024) {
|
if (low - offset < UNIV_PAGE_SIZE * 512) {
|
||||||
n_bytes = low - offset;
|
n_bytes = low - offset;
|
||||||
} else {
|
} else {
|
||||||
n_bytes = UNIV_PAGE_SIZE * 1024;
|
n_bytes = UNIV_PAGE_SIZE * 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_file_write(name, file, buf, offset, 0, n_bytes);
|
ret = os_file_write(name, file, buf, offset, 0, n_bytes);
|
||||||
@ -475,8 +507,6 @@ try_again:
|
|||||||
|
|
||||||
ret = os_file_flush(file);
|
ret = os_file_flush(file);
|
||||||
|
|
||||||
fsync(file);
|
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
@ -549,11 +549,19 @@ innobase_start_or_create_for_mysql(void)
|
|||||||
srv_n_file_io_threads = 4;
|
srv_n_file_io_threads = 4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN_ASYNC_IO
|
#ifdef __WIN__
|
||||||
/* On NT always use aio */
|
if (os_get_os_version() == OS_WIN95
|
||||||
os_aio_use_native_aio = TRUE;
|
|| os_get_os_version() == OS_WIN31) {
|
||||||
#endif
|
/* 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) {
|
if (!os_aio_use_native_aio) {
|
||||||
os_aio_init(4 * SRV_N_PENDING_IOS_PER_THREAD
|
os_aio_init(4 * SRV_N_PENDING_IOS_PER_THREAD
|
||||||
* srv_n_file_io_threads,
|
* srv_n_file_io_threads,
|
||||||
@ -600,6 +608,19 @@ innobase_start_or_create_for_mysql(void)
|
|||||||
return(DB_ERROR);
|
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,
|
err = open_or_create_data_files(&create_new_db,
|
||||||
&min_flushed_lsn, &min_arch_log_no,
|
&min_flushed_lsn, &min_arch_log_no,
|
||||||
&max_flushed_lsn, &max_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_MUTEX)
|
||||||
&& !sync_thread_levels_contain(array,
|
&& !sync_thread_levels_contain(array,
|
||||||
SYNC_IBUF_PESS_INSERT_MUTEX));
|
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) {
|
} else if (level == SYNC_DICT_HEADER) {
|
||||||
ut_a(sync_thread_levels_g(array, SYNC_DICT_HEADER));
|
ut_a(sync_thread_levels_g(array, SYNC_DICT_HEADER));
|
||||||
} else if (level == SYNC_PURGE_IS_RUNNING) {
|
} else if (level == SYNC_PURGE_IS_RUNNING) {
|
||||||
|
@ -87,7 +87,7 @@ my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars)
|
|||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
num=atoll(end); endchar=strend(end)[-1];
|
num=strtoll(end, (char **)NULL, 10); endchar=strend(end)[-1];
|
||||||
if (endchar == 'k' || endchar == 'K')
|
if (endchar == 'k' || endchar == 'K')
|
||||||
num*=1024;
|
num*=1024;
|
||||||
else if (endchar == 'm' || endchar == 'M')
|
else if (endchar == 'm' || endchar == 'M')
|
||||||
|
@ -1242,7 +1242,8 @@ ha_innobase::write_row(
|
|||||||
{
|
{
|
||||||
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
|
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
|
||||||
int error;
|
int error;
|
||||||
|
longlong auto_inc;
|
||||||
|
|
||||||
DBUG_ENTER("ha_innobase::write_row");
|
DBUG_ENTER("ha_innobase::write_row");
|
||||||
|
|
||||||
statistic_increment(ha_write_count, &LOCK_status);
|
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
|
make sure all columns are fetched in the select done by
|
||||||
update_auto_increment */
|
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();
|
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
|
/* We have to set sql_stat_start to TRUE because
|
||||||
update_auto_increment has called a select, and
|
update_auto_increment has called a select, and
|
||||||
has reset that flag; row_insert_for_mysql has to
|
has reset that flag; row_insert_for_mysql has to
|
||||||
|
@ -1864,6 +1864,15 @@ mysql_execute_command(void)
|
|||||||
}
|
}
|
||||||
if (check_db_used(thd,tables) || end_active_trans(thd))
|
if (check_db_used(thd,tables) || end_active_trans(thd))
|
||||||
goto error;
|
goto error;
|
||||||
|
for (TABLE_LIST *tmp = tables; tmp; tmp = tmp->next)
|
||||||
|
{
|
||||||
|
if (!(tmp->lock_type == TL_READ_NO_INSERT ?
|
||||||
|
!check_table_access(thd, SELECT_ACL, tmp) :
|
||||||
|
(!check_table_access(thd, INSERT_ACL, tmp) ||
|
||||||
|
!check_table_access(thd, UPDATE_ACL, tmp) ||
|
||||||
|
!check_table_access(thd, DELETE_ACL, tmp))))
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
thd->in_lock_tables=1;
|
thd->in_lock_tables=1;
|
||||||
if (!(res=open_and_lock_tables(thd,tables)))
|
if (!(res=open_and_lock_tables(thd,tables)))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user