Commit 731cf774 authored by unknown's avatar unknown

Applied innodb-5.1-ss660 snapshot.

 Changes in SQL parser:
 * Change default mode of SELECT from "lock in share mode"
   to "consistent read".
 * Remove support from SELECT for specifying "consistent read".
 * Add support in SELECT for specifying "lock in share mode".
 * Change all uses of SQL parser to specify "lock in share mode".
 * Modify syntax so that the only valid top-level statement is
   a procedure definition, since it's the only one that actually
   works.
 * Add support for lock waits.


sql/ha_innodb.cc:
  Applied innodb-5.1-ss660 snapshot.
   Document better the "bool table_id" flag.
storage/innobase/btr/btr0cur.c:
  Applied innodb-5.1-ss660 snapshot.
   btr_cur_search_to_nth_level(): Reacquire btr_search_latch after
   inserting to the insert buffer. This was noticed while analysing
   Bug#19801, but this should not fix this bug since, according to
   Heikki, btr_search_latch is not reserved during an insert.
storage/innobase/configure.in:
  Applied innodb-5.1-ss660 snapshot.
   Add -Wpointer-arith to CFLAGS when using GCC.
storage/innobase/data/data0type.c:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/dict/dict0crea.c:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/dict/dict0dict.c:
  Applied innodb-5.1-ss660 snapshot.
   Make dict_remove_db_name() non-static.
storage/innobase/ibuf/ibuf0ibuf.c:
  Applied innodb-5.1-ss660 snapshot.
   ibuf_fixed_addr_page(): Add parameter space. As the insert buffer
   B-tree is only located in the system tablespace (space 0),
   IBUF_TREE_ROOT_PAGE_NO is only special in space 0.
storage/innobase/include/data0type.h:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/include/dict0dict.h:
  Applied innodb-5.1-ss660 snapshot.
   Make dict_remove_db_name() non-static.
storage/innobase/include/pars0grm.h:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/include/pars0pars.h:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/include/que0que.h:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/include/sync0rw.ic:
  Applied innodb-5.1-ss660 snapshot.
   rw_lock_s_unlock_func(): Change a debug assertion to a
   production assertion in order to track down Bug#19081.
storage/innobase/include/trx0trx.h:
  Applied innodb-5.1-ss660 snapshot.
   trx_sig_send() always succeeds or asserts.
storage/innobase/include/ut0ut.h:
  Applied innodb-5.1-ss660 snapshot.
   Document better the "bool table_id" flags.
storage/innobase/mem/mem0mem.c:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/pars/lexyy.c:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/pars/pars0grm.c:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/pars/pars0grm.h:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/pars/pars0grm.y:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/pars/pars0lex.l:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/pars/pars0pars.c:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/que/que0que.c:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/row/row0mysql.c:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/row/row0sel.c:
  Applied innodb-5.1-ss660 snapshot.
   * Disable prefetch and adaptive hash index for tables
     with rows over 1024 bytes in InnoDB's SQL parser.
   * row_sel_try_search_shortcut(): Do not return SEL_FOUND
     when the record was not found. This bug was introduced
     in MySQL/InnoDB 5.0.3, but luckily it should never
     manifest itself, given that existing InnoDB SQL code
     never makes use of consistent reads.
   * Don't take unnecesary locks on supremum records when the
     srv_locks_unsafe_for_binlog option is enabled. Fixes an
     assertion failure in the innodb_unsafe_binlog testcase
     when compiled with UNIV_DEBUG.
storage/innobase/row/row0upd.c:
  Applied innodb-5.1-ss660 snapshot.
storage/innobase/trx/trx0roll.c:
  Applied innodb-5.1-ss660 snapshot.
   trx_sig_send() always succeeds or asserts.
storage/innobase/trx/trx0trx.c:
  Applied innodb-5.1-ss660 snapshot.
   trx_sig_send() always succeeds or asserts.
storage/innobase/ut/ut0ut.c:
  Applied innodb-5.1-ss660 snapshot.
   Document better the "bool table_id" flags.
parent 3f037796
......@@ -1174,7 +1174,8 @@ innobase_print_identifier(
/*======================*/
FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction */
ibool table_id,/* in: TRUE=decode table name */
ibool table_id,/* in: TRUE=print a table name,
FALSE=print other identifier */
const char* name, /* in: name to print */
ulint namelen)/* in: length of name */
{
......
......@@ -455,7 +455,7 @@ btr_cur_search_to_nth_level(
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
return;
goto func_exit;
}
/* Insert to the insert buffer did not succeed:
......@@ -571,6 +571,7 @@ btr_cur_search_to_nth_level(
|| mode != PAGE_CUR_LE);
}
func_exit:
if (has_search_latch) {
rw_lock_s_lock(&btr_search_latch);
......
......@@ -105,7 +105,7 @@ fi
# If using gcc, add some extra warning flags.
if test "$ac_cv_prog_gcc" = "yes"
then
CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
CFLAGS="$CFLAGS -Werror-implicit-function-declaration -Wpointer-arith"
fi
case "$target_os" in
......
......@@ -297,6 +297,7 @@ dtype_print(
/***************************************************************************
Returns the maximum size of a data type. Note: types in system tables may be
incomplete and return incorrect information. */
ulint
dtype_get_max_size(
/*===============*/
......
......@@ -1193,7 +1193,7 @@ dict_create_or_check_foreign_constraint_tables(void)
"CREATE UNIQUE CLUSTERED INDEX ID_IND ON SYS_FOREIGN_COLS (ID, POS);\n"
"COMMIT WORK;\n"
"END;\n"
, trx);
, FALSE, trx);
if (error != DB_SUCCESS) {
fprintf(stderr, "InnoDB: error %lu in creation\n",
......@@ -1242,7 +1242,7 @@ dict_foreign_eval_sql(
ulint error;
FILE* ef = dict_foreign_err_file;
error = que_eval_sql(info, sql, trx);
error = que_eval_sql(info, sql, FALSE, trx);
if (error == DB_DUPLICATE_KEY) {
mutex_enter(&dict_foreign_err_mutex);
......
......@@ -285,7 +285,7 @@ dict_tables_have_same_db(
/************************************************************************
Return the end of table name where we have removed dbname and '/'. */
static
const char*
dict_remove_db_name(
/*================*/
......
......@@ -952,14 +952,11 @@ ibool
ibuf_fixed_addr_page(
/*=================*/
/* out: TRUE if a fixed address ibuf i/o page */
ulint space, /* in: space id */
ulint page_no)/* in: page number */
{
if ((ibuf_bitmap_page(page_no))
|| (page_no == IBUF_TREE_ROOT_PAGE_NO)) {
return(TRUE);
}
return(FALSE);
return((space == 0 && page_no == IBUF_TREE_ROOT_PAGE_NO)
|| ibuf_bitmap_page(page_no));
}
/***************************************************************************
......@@ -983,7 +980,7 @@ ibuf_page(
return(FALSE);
}
if (ibuf_fixed_addr_page(page_no)) {
if (ibuf_fixed_addr_page(space, page_no)) {
return(TRUE);
}
......@@ -1031,7 +1028,7 @@ ibuf_page_low(
return(FALSE);
}
#endif
if (ibuf_fixed_addr_page(page_no)) {
if (ibuf_fixed_addr_page(space, page_no)) {
return(TRUE);
}
......@@ -3070,7 +3067,7 @@ ibuf_merge_or_delete_for_page(
return;
}
#endif
if (ibuf_fixed_addr_page(page_no) || fsp_descr_page(page_no)
if (ibuf_fixed_addr_page(space, page_no) || fsp_descr_page(page_no)
|| trx_sys_hdr_page(space, page_no)) {
return;
}
......
......@@ -332,6 +332,7 @@ dtype_get_min_size(
/***************************************************************************
Returns the maximum size of a data type. Note: types in system tables may be
incomplete and return incorrect information. */
ulint
dtype_get_max_size(
/*===============*/
......
......@@ -45,6 +45,15 @@ dict_get_db_name_len(
const char* name); /* in: table name in the form
dbname '/' tablename */
/************************************************************************
Return the end of table name where we have removed dbname and '/'. */
const char*
dict_remove_db_name(
/*================*/
/* out: table name */
const char* name); /* in: table name in the form
dbname '/' tablename */
/************************************************************************
Decrements the count of open MySQL handles to a table. */
void
......
......@@ -69,57 +69,59 @@
PARS_WHERE_TOKEN = 295,
PARS_FOR_TOKEN = 296,
PARS_DDOT_TOKEN = 297,
PARS_CONSISTENT_TOKEN = 298,
PARS_READ_TOKEN = 299,
PARS_ORDER_TOKEN = 300,
PARS_BY_TOKEN = 301,
PARS_ASC_TOKEN = 302,
PARS_DESC_TOKEN = 303,
PARS_INSERT_TOKEN = 304,
PARS_INTO_TOKEN = 305,
PARS_VALUES_TOKEN = 306,
PARS_UPDATE_TOKEN = 307,
PARS_SET_TOKEN = 308,
PARS_DELETE_TOKEN = 309,
PARS_CURRENT_TOKEN = 310,
PARS_OF_TOKEN = 311,
PARS_CREATE_TOKEN = 312,
PARS_TABLE_TOKEN = 313,
PARS_INDEX_TOKEN = 314,
PARS_UNIQUE_TOKEN = 315,
PARS_CLUSTERED_TOKEN = 316,
PARS_DOES_NOT_FIT_IN_MEM_TOKEN = 317,
PARS_ON_TOKEN = 318,
PARS_ASSIGN_TOKEN = 319,
PARS_DECLARE_TOKEN = 320,
PARS_CURSOR_TOKEN = 321,
PARS_SQL_TOKEN = 322,
PARS_OPEN_TOKEN = 323,
PARS_FETCH_TOKEN = 324,
PARS_CLOSE_TOKEN = 325,
PARS_NOTFOUND_TOKEN = 326,
PARS_TO_CHAR_TOKEN = 327,
PARS_TO_NUMBER_TOKEN = 328,
PARS_TO_BINARY_TOKEN = 329,
PARS_BINARY_TO_NUMBER_TOKEN = 330,
PARS_SUBSTR_TOKEN = 331,
PARS_REPLSTR_TOKEN = 332,
PARS_CONCAT_TOKEN = 333,
PARS_INSTR_TOKEN = 334,
PARS_LENGTH_TOKEN = 335,
PARS_SYSDATE_TOKEN = 336,
PARS_PRINTF_TOKEN = 337,
PARS_ASSERT_TOKEN = 338,
PARS_RND_TOKEN = 339,
PARS_RND_STR_TOKEN = 340,
PARS_ROW_PRINTF_TOKEN = 341,
PARS_COMMIT_TOKEN = 342,
PARS_ROLLBACK_TOKEN = 343,
PARS_WORK_TOKEN = 344,
PARS_UNSIGNED_TOKEN = 345,
PARS_EXIT_TOKEN = 346,
PARS_FUNCTION_TOKEN = 347,
NEG = 348
PARS_READ_TOKEN = 298,
PARS_ORDER_TOKEN = 299,
PARS_BY_TOKEN = 300,
PARS_ASC_TOKEN = 301,
PARS_DESC_TOKEN = 302,
PARS_INSERT_TOKEN = 303,
PARS_INTO_TOKEN = 304,
PARS_VALUES_TOKEN = 305,
PARS_UPDATE_TOKEN = 306,
PARS_SET_TOKEN = 307,
PARS_DELETE_TOKEN = 308,
PARS_CURRENT_TOKEN = 309,
PARS_OF_TOKEN = 310,
PARS_CREATE_TOKEN = 311,
PARS_TABLE_TOKEN = 312,
PARS_INDEX_TOKEN = 313,
PARS_UNIQUE_TOKEN = 314,
PARS_CLUSTERED_TOKEN = 315,
PARS_DOES_NOT_FIT_IN_MEM_TOKEN = 316,
PARS_ON_TOKEN = 317,
PARS_ASSIGN_TOKEN = 318,
PARS_DECLARE_TOKEN = 319,
PARS_CURSOR_TOKEN = 320,
PARS_SQL_TOKEN = 321,
PARS_OPEN_TOKEN = 322,
PARS_FETCH_TOKEN = 323,
PARS_CLOSE_TOKEN = 324,
PARS_NOTFOUND_TOKEN = 325,
PARS_TO_CHAR_TOKEN = 326,
PARS_TO_NUMBER_TOKEN = 327,
PARS_TO_BINARY_TOKEN = 328,
PARS_BINARY_TO_NUMBER_TOKEN = 329,
PARS_SUBSTR_TOKEN = 330,
PARS_REPLSTR_TOKEN = 331,
PARS_CONCAT_TOKEN = 332,
PARS_INSTR_TOKEN = 333,
PARS_LENGTH_TOKEN = 334,
PARS_SYSDATE_TOKEN = 335,
PARS_PRINTF_TOKEN = 336,
PARS_ASSERT_TOKEN = 337,
PARS_RND_TOKEN = 338,
PARS_RND_STR_TOKEN = 339,
PARS_ROW_PRINTF_TOKEN = 340,
PARS_COMMIT_TOKEN = 341,
PARS_ROLLBACK_TOKEN = 342,
PARS_WORK_TOKEN = 343,
PARS_UNSIGNED_TOKEN = 344,
PARS_EXIT_TOKEN = 345,
PARS_FUNCTION_TOKEN = 346,
PARS_LOCK_TOKEN = 347,
PARS_SHARE_TOKEN = 348,
PARS_MODE_TOKEN = 349,
NEG = 350
};
#endif
#define PARS_INT_LIT 258
......@@ -162,57 +164,59 @@
#define PARS_WHERE_TOKEN 295
#define PARS_FOR_TOKEN 296
#define PARS_DDOT_TOKEN 297
#define PARS_CONSISTENT_TOKEN 298
#define PARS_READ_TOKEN 299
#define PARS_ORDER_TOKEN 300
#define PARS_BY_TOKEN 301
#define PARS_ASC_TOKEN 302
#define PARS_DESC_TOKEN 303
#define PARS_INSERT_TOKEN 304
#define PARS_INTO_TOKEN 305
#define PARS_VALUES_TOKEN 306
#define PARS_UPDATE_TOKEN 307
#define PARS_SET_TOKEN 308
#define PARS_DELETE_TOKEN 309
#define PARS_CURRENT_TOKEN 310
#define PARS_OF_TOKEN 311
#define PARS_CREATE_TOKEN 312
#define PARS_TABLE_TOKEN 313
#define PARS_INDEX_TOKEN 314
#define PARS_UNIQUE_TOKEN 315
#define PARS_CLUSTERED_TOKEN 316
#define PARS_DOES_NOT_FIT_IN_MEM_TOKEN 317
#define PARS_ON_TOKEN 318
#define PARS_ASSIGN_TOKEN 319
#define PARS_DECLARE_TOKEN 320
#define PARS_CURSOR_TOKEN 321
#define PARS_SQL_TOKEN 322
#define PARS_OPEN_TOKEN 323
#define PARS_FETCH_TOKEN 324
#define PARS_CLOSE_TOKEN 325
#define PARS_NOTFOUND_TOKEN 326
#define PARS_TO_CHAR_TOKEN 327
#define PARS_TO_NUMBER_TOKEN 328
#define PARS_TO_BINARY_TOKEN 329
#define PARS_BINARY_TO_NUMBER_TOKEN 330
#define PARS_SUBSTR_TOKEN 331
#define PARS_REPLSTR_TOKEN 332
#define PARS_CONCAT_TOKEN 333
#define PARS_INSTR_TOKEN 334
#define PARS_LENGTH_TOKEN 335
#define PARS_SYSDATE_TOKEN 336
#define PARS_PRINTF_TOKEN 337
#define PARS_ASSERT_TOKEN 338
#define PARS_RND_TOKEN 339
#define PARS_RND_STR_TOKEN 340
#define PARS_ROW_PRINTF_TOKEN 341
#define PARS_COMMIT_TOKEN 342
#define PARS_ROLLBACK_TOKEN 343
#define PARS_WORK_TOKEN 344
#define PARS_UNSIGNED_TOKEN 345
#define PARS_EXIT_TOKEN 346
#define PARS_FUNCTION_TOKEN 347
#define NEG 348
#define PARS_READ_TOKEN 298
#define PARS_ORDER_TOKEN 299
#define PARS_BY_TOKEN 300
#define PARS_ASC_TOKEN 301
#define PARS_DESC_TOKEN 302
#define PARS_INSERT_TOKEN 303
#define PARS_INTO_TOKEN 304
#define PARS_VALUES_TOKEN 305
#define PARS_UPDATE_TOKEN 306
#define PARS_SET_TOKEN 307
#define PARS_DELETE_TOKEN 308
#define PARS_CURRENT_TOKEN 309
#define PARS_OF_TOKEN 310
#define PARS_CREATE_TOKEN 311
#define PARS_TABLE_TOKEN 312
#define PARS_INDEX_TOKEN 313
#define PARS_UNIQUE_TOKEN 314
#define PARS_CLUSTERED_TOKEN 315
#define PARS_DOES_NOT_FIT_IN_MEM_TOKEN 316
#define PARS_ON_TOKEN 317
#define PARS_ASSIGN_TOKEN 318
#define PARS_DECLARE_TOKEN 319
#define PARS_CURSOR_TOKEN 320
#define PARS_SQL_TOKEN 321
#define PARS_OPEN_TOKEN 322
#define PARS_FETCH_TOKEN 323
#define PARS_CLOSE_TOKEN 324
#define PARS_NOTFOUND_TOKEN 325
#define PARS_TO_CHAR_TOKEN 326
#define PARS_TO_NUMBER_TOKEN 327
#define PARS_TO_BINARY_TOKEN 328
#define PARS_BINARY_TO_NUMBER_TOKEN 329
#define PARS_SUBSTR_TOKEN 330
#define PARS_REPLSTR_TOKEN 331
#define PARS_CONCAT_TOKEN 332
#define PARS_INSTR_TOKEN 333
#define PARS_LENGTH_TOKEN 334
#define PARS_SYSDATE_TOKEN 335
#define PARS_PRINTF_TOKEN 336
#define PARS_ASSERT_TOKEN 337
#define PARS_RND_TOKEN 338
#define PARS_RND_STR_TOKEN 339
#define PARS_ROW_PRINTF_TOKEN 340
#define PARS_COMMIT_TOKEN 341
#define PARS_ROLLBACK_TOKEN 342
#define PARS_WORK_TOKEN 343
#define PARS_UNSIGNED_TOKEN 344
#define PARS_EXIT_TOKEN 345
#define PARS_FUNCTION_TOKEN 346
#define PARS_LOCK_TOKEN 347
#define PARS_SHARE_TOKEN 348
#define PARS_MODE_TOKEN 349
#define NEG 350
......
......@@ -63,7 +63,7 @@ extern pars_res_word_t pars_asc_token;
extern pars_res_word_t pars_desc_token;
extern pars_res_word_t pars_open_token;
extern pars_res_word_t pars_close_token;
extern pars_res_word_t pars_consistent_token;
extern pars_res_word_t pars_share_token;
extern pars_res_word_t pars_unique_token;
extern pars_res_word_t pars_clustered_token;
......
......@@ -143,14 +143,12 @@ que_thr_stop_for_mysql(
/*===================*/
que_thr_t* thr); /* in: query thread */
/**************************************************************************
Runs query threads. Note that the individual query thread which is run
within this function may change if, e.g., the OS thread executing this
function uses a threshold amount of resources. */
Run a query thread. Handles lock waits. */
void
que_run_threads(
/*============*/
que_thr_t* thr); /* in: query thread which is run initially */
que_thr_t* thr); /* in: query thread */
/**************************************************************************
After signal handling is finished, returns control to a query graph error
handling routine. (Currently, just returns the control to the root of the
......@@ -163,19 +161,6 @@ que_fork_error_handle(
que_t* fork); /* in: query graph which was run before signal
handling started, NULL not allowed */
/**************************************************************************
Handles an SQL error noticed during query thread execution. At the moment,
does nothing! */
void
que_thr_handle_error(
/*=================*/
que_thr_t* thr, /* in: query thread */
ulint err_no, /* in: error number */
byte* err_str,/* in, own: error string or NULL; NOTE: the
function will take care of freeing of the
string! */
ulint err_len);/* in: error string length */
/**************************************************************************
Moves a suspended query thread to the QUE_THR_RUNNING state and releases
a single worker thread to execute it. This function should be used to end
the wait state of a query thread waiting for a lock or a stored procedure
......@@ -337,9 +322,14 @@ Evaluate the given SQL */
ulint
que_eval_sql(
/*=========*/
pars_info_t* info, /* out: error code or DB_SUCCESS */
const char* sql, /* in: info struct, or NULL */
/* out: error code or DB_SUCCESS */
pars_info_t* info, /* in: info struct, or NULL */
const char* sql, /* in: SQL string */
ibool reserve_dict_mutex,
/* in: if TRUE, acquire/release
dict_sys->mutex around call to pars_sql. */
trx_t* trx); /* in: trx */
/* Query graph query thread node: the fields are protected by the kernel
mutex with the exceptions named below */
......
......@@ -362,7 +362,7 @@ rw_lock_s_unlock_func(
/* Reset the shared lock by decrementing the reader count */
ut_ad(lock->reader_count > 0);
ut_a(lock->reader_count > 0);
lock->reader_count--;
#ifdef UNIV_SYNC_DEBUG
......
......@@ -266,11 +266,9 @@ trx_end_lock_wait(
/********************************************************************
Sends a signal to a trx object. */
ibool
void
trx_sig_send(
/*=========*/
/* out: TRUE if the signal was
successfully delivered */
trx_t* trx, /* in: trx handle */
ulint type, /* in: signal type */
ulint sender, /* in: TRX_SIG_SELF or
......
......@@ -214,17 +214,19 @@ ut_print_filename(
FILE* f, /* in: output stream */
const char* name); /* in: name to print */
/* Forward declaration of transaction handle */
struct trx_struct;
/**************************************************************************
Outputs a NUL-terminated string, quoted as an SQL identifier. */
struct trx_struct;
void
ut_print_name(
/*==========*/
FILE* f, /* in: output stream */
struct trx_struct*trx, /* in: transaction */
ibool table_id,/* in: TRUE=decode table name */
ibool table_id,/* in: TRUE=print a table name,
FALSE=print other identifier */
const char* name); /* in: name to print */
/**************************************************************************
......@@ -235,7 +237,8 @@ ut_print_namel(
/*===========*/
FILE* f, /* in: output stream */
struct trx_struct*trx, /* in: transaction (NULL=no quotes) */
ibool table_id,/* in: TRUE=decode table name */
ibool table_id,/* in: TRUE=print a table name,
FALSE=print other identifier */
const char* name, /* in: name to print */
ulint namelen);/* in: length of name */
......
......@@ -144,7 +144,7 @@ mem_heap_cat(
void* res = mem_heap_alloc(heap, len1 + len2);
memcpy(res, b1, len1);
memcpy((char *)res + len1, b2, len2);
memcpy((char*)res + len1, b2, len2);
return(res);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -69,57 +69,59 @@
PARS_WHERE_TOKEN = 295,
PARS_FOR_TOKEN = 296,
PARS_DDOT_TOKEN = 297,
PARS_CONSISTENT_TOKEN = 298,
PARS_READ_TOKEN = 299,
PARS_ORDER_TOKEN = 300,
PARS_BY_TOKEN = 301,
PARS_ASC_TOKEN = 302,
PARS_DESC_TOKEN = 303,
PARS_INSERT_TOKEN = 304,
PARS_INTO_TOKEN = 305,
PARS_VALUES_TOKEN = 306,
PARS_UPDATE_TOKEN = 307,
PARS_SET_TOKEN = 308,
PARS_DELETE_TOKEN = 309,
PARS_CURRENT_TOKEN = 310,
PARS_OF_TOKEN = 311,
PARS_CREATE_TOKEN = 312,
PARS_TABLE_TOKEN = 313,
PARS_INDEX_TOKEN = 314,
PARS_UNIQUE_TOKEN = 315,
PARS_CLUSTERED_TOKEN = 316,
PARS_DOES_NOT_FIT_IN_MEM_TOKEN = 317,
PARS_ON_TOKEN = 318,
PARS_ASSIGN_TOKEN = 319,
PARS_DECLARE_TOKEN = 320,
PARS_CURSOR_TOKEN = 321,
PARS_SQL_TOKEN = 322,
PARS_OPEN_TOKEN = 323,
PARS_FETCH_TOKEN = 324,
PARS_CLOSE_TOKEN = 325,
PARS_NOTFOUND_TOKEN = 326,
PARS_TO_CHAR_TOKEN = 327,
PARS_TO_NUMBER_TOKEN = 328,
PARS_TO_BINARY_TOKEN = 329,
PARS_BINARY_TO_NUMBER_TOKEN = 330,
PARS_SUBSTR_TOKEN = 331,
PARS_REPLSTR_TOKEN = 332,
PARS_CONCAT_TOKEN = 333,
PARS_INSTR_TOKEN = 334,
PARS_LENGTH_TOKEN = 335,
PARS_SYSDATE_TOKEN = 336,
PARS_PRINTF_TOKEN = 337,
PARS_ASSERT_TOKEN = 338,
PARS_RND_TOKEN = 339,
PARS_RND_STR_TOKEN = 340,
PARS_ROW_PRINTF_TOKEN = 341,
PARS_COMMIT_TOKEN = 342,
PARS_ROLLBACK_TOKEN = 343,
PARS_WORK_TOKEN = 344,
PARS_UNSIGNED_TOKEN = 345,
PARS_EXIT_TOKEN = 346,
PARS_FUNCTION_TOKEN = 347,
NEG = 348
PARS_READ_TOKEN = 298,
PARS_ORDER_TOKEN = 299,
PARS_BY_TOKEN = 300,
PARS_ASC_TOKEN = 301,
PARS_DESC_TOKEN = 302,
PARS_INSERT_TOKEN = 303,
PARS_INTO_TOKEN = 304,
PARS_VALUES_TOKEN = 305,
PARS_UPDATE_TOKEN = 306,
PARS_SET_TOKEN = 307,
PARS_DELETE_TOKEN = 308,
PARS_CURRENT_TOKEN = 309,
PARS_OF_TOKEN = 310,
PARS_CREATE_TOKEN = 311,
PARS_TABLE_TOKEN = 312,
PARS_INDEX_TOKEN = 313,
PARS_UNIQUE_TOKEN = 314,
PARS_CLUSTERED_TOKEN = 315,
PARS_DOES_NOT_FIT_IN_MEM_TOKEN = 316,
PARS_ON_TOKEN = 317,
PARS_ASSIGN_TOKEN = 318,
PARS_DECLARE_TOKEN = 319,
PARS_CURSOR_TOKEN = 320,
PARS_SQL_TOKEN = 321,
PARS_OPEN_TOKEN = 322,
PARS_FETCH_TOKEN = 323,
PARS_CLOSE_TOKEN = 324,
PARS_NOTFOUND_TOKEN = 325,
PARS_TO_CHAR_TOKEN = 326,
PARS_TO_NUMBER_TOKEN = 327,
PARS_TO_BINARY_TOKEN = 328,
PARS_BINARY_TO_NUMBER_TOKEN = 329,
PARS_SUBSTR_TOKEN = 330,
PARS_REPLSTR_TOKEN = 331,
PARS_CONCAT_TOKEN = 332,
PARS_INSTR_TOKEN = 333,
PARS_LENGTH_TOKEN = 334,
PARS_SYSDATE_TOKEN = 335,
PARS_PRINTF_TOKEN = 336,
PARS_ASSERT_TOKEN = 337,
PARS_RND_TOKEN = 338,
PARS_RND_STR_TOKEN = 339,
PARS_ROW_PRINTF_TOKEN = 340,
PARS_COMMIT_TOKEN = 341,
PARS_ROLLBACK_TOKEN = 342,
PARS_WORK_TOKEN = 343,
PARS_UNSIGNED_TOKEN = 344,
PARS_EXIT_TOKEN = 345,
PARS_FUNCTION_TOKEN = 346,
PARS_LOCK_TOKEN = 347,
PARS_SHARE_TOKEN = 348,
PARS_MODE_TOKEN = 349,
NEG = 350
};
#endif
#define PARS_INT_LIT 258
......@@ -162,57 +164,59 @@
#define PARS_WHERE_TOKEN 295
#define PARS_FOR_TOKEN 296
#define PARS_DDOT_TOKEN 297
#define PARS_CONSISTENT_TOKEN 298
#define PARS_READ_TOKEN 299
#define PARS_ORDER_TOKEN 300
#define PARS_BY_TOKEN 301
#define PARS_ASC_TOKEN 302
#define PARS_DESC_TOKEN 303
#define PARS_INSERT_TOKEN 304
#define PARS_INTO_TOKEN 305
#define PARS_VALUES_TOKEN 306
#define PARS_UPDATE_TOKEN 307
#define PARS_SET_TOKEN 308
#define PARS_DELETE_TOKEN 309
#define PARS_CURRENT_TOKEN 310
#define PARS_OF_TOKEN 311
#define PARS_CREATE_TOKEN 312
#define PARS_TABLE_TOKEN 313
#define PARS_INDEX_TOKEN 314
#define PARS_UNIQUE_TOKEN 315
#define PARS_CLUSTERED_TOKEN 316
#define PARS_DOES_NOT_FIT_IN_MEM_TOKEN 317
#define PARS_ON_TOKEN 318
#define PARS_ASSIGN_TOKEN 319
#define PARS_DECLARE_TOKEN 320
#define PARS_CURSOR_TOKEN 321
#define PARS_SQL_TOKEN 322
#define PARS_OPEN_TOKEN 323
#define PARS_FETCH_TOKEN 324
#define PARS_CLOSE_TOKEN 325
#define PARS_NOTFOUND_TOKEN 326
#define PARS_TO_CHAR_TOKEN 327
#define PARS_TO_NUMBER_TOKEN 328
#define PARS_TO_BINARY_TOKEN 329
#define PARS_BINARY_TO_NUMBER_TOKEN 330
#define PARS_SUBSTR_TOKEN 331
#define PARS_REPLSTR_TOKEN 332
#define PARS_CONCAT_TOKEN 333
#define PARS_INSTR_TOKEN 334
#define PARS_LENGTH_TOKEN 335
#define PARS_SYSDATE_TOKEN 336
#define PARS_PRINTF_TOKEN 337
#define PARS_ASSERT_TOKEN 338
#define PARS_RND_TOKEN 339
#define PARS_RND_STR_TOKEN 340
#define PARS_ROW_PRINTF_TOKEN 341
#define PARS_COMMIT_TOKEN 342
#define PARS_ROLLBACK_TOKEN 343
#define PARS_WORK_TOKEN 344
#define PARS_UNSIGNED_TOKEN 345
#define PARS_EXIT_TOKEN 346
#define PARS_FUNCTION_TOKEN 347
#define NEG 348
#define PARS_READ_TOKEN 298
#define PARS_ORDER_TOKEN 299
#define PARS_BY_TOKEN 300
#define PARS_ASC_TOKEN 301
#define PARS_DESC_TOKEN 302
#define PARS_INSERT_TOKEN 303
#define PARS_INTO_TOKEN 304
#define PARS_VALUES_TOKEN 305
#define PARS_UPDATE_TOKEN 306
#define PARS_SET_TOKEN 307
#define PARS_DELETE_TOKEN 308
#define PARS_CURRENT_TOKEN 309
#define PARS_OF_TOKEN 310
#define PARS_CREATE_TOKEN 311
#define PARS_TABLE_TOKEN 312
#define PARS_INDEX_TOKEN 313
#define PARS_UNIQUE_TOKEN 314
#define PARS_CLUSTERED_TOKEN 315
#define PARS_DOES_NOT_FIT_IN_MEM_TOKEN 316
#define PARS_ON_TOKEN 317
#define PARS_ASSIGN_TOKEN 318
#define PARS_DECLARE_TOKEN 319
#define PARS_CURSOR_TOKEN 320
#define PARS_SQL_TOKEN 321
#define PARS_OPEN_TOKEN 322
#define PARS_FETCH_TOKEN 323
#define PARS_CLOSE_TOKEN 324
#define PARS_NOTFOUND_TOKEN 325
#define PARS_TO_CHAR_TOKEN 326
#define PARS_TO_NUMBER_TOKEN 327
#define PARS_TO_BINARY_TOKEN 328
#define PARS_BINARY_TO_NUMBER_TOKEN 329
#define PARS_SUBSTR_TOKEN 330
#define PARS_REPLSTR_TOKEN 331
#define PARS_CONCAT_TOKEN 332
#define PARS_INSTR_TOKEN 333
#define PARS_LENGTH_TOKEN 334
#define PARS_SYSDATE_TOKEN 335
#define PARS_PRINTF_TOKEN 336
#define PARS_ASSERT_TOKEN 337
#define PARS_RND_TOKEN 338
#define PARS_RND_STR_TOKEN 339
#define PARS_ROW_PRINTF_TOKEN 340
#define PARS_COMMIT_TOKEN 341
#define PARS_ROLLBACK_TOKEN 342
#define PARS_WORK_TOKEN 343
#define PARS_UNSIGNED_TOKEN 344
#define PARS_EXIT_TOKEN 345
#define PARS_FUNCTION_TOKEN 346
#define PARS_LOCK_TOKEN 347
#define PARS_SHARE_TOKEN 348
#define PARS_MODE_TOKEN 349
#define NEG 350
......
......@@ -70,7 +70,6 @@ yylex(void);
%token PARS_WHERE_TOKEN
%token PARS_FOR_TOKEN
%token PARS_DDOT_TOKEN
%token PARS_CONSISTENT_TOKEN
%token PARS_READ_TOKEN
%token PARS_ORDER_TOKEN
%token PARS_BY_TOKEN
......@@ -120,6 +119,9 @@ yylex(void);
%token PARS_UNSIGNED_TOKEN
%token PARS_EXIT_TOKEN
%token PARS_FUNCTION_TOKEN
%token PARS_LOCK_TOKEN
%token PARS_SHARE_TOKEN
%token PARS_MODE_TOKEN
%left PARS_AND_TOKEN PARS_OR_TOKEN
%left PARS_NOT_TOKEN
......@@ -132,9 +134,11 @@ yylex(void);
/* Grammar follows */
%%
top_statement:
procedure_definition ';'
statement:
procedure_definition ';'
| stored_procedure_call
stored_procedure_call
| predefined_procedure_call ';'
| while_statement ';'
| for_statement ';'
......@@ -301,10 +305,10 @@ for_update_clause:
{ $$ = &pars_update_token; }
;
consistent_read_clause:
lock_shared_clause:
/* Nothing */ { $$ = NULL; }
| PARS_CONSISTENT_TOKEN PARS_READ_TOKEN
{ $$ = &pars_consistent_token; }
| PARS_LOCK_TOKEN PARS_IN_TOKEN PARS_SHARE_TOKEN PARS_MODE_TOKEN
{ $$ = &pars_share_token; }
;
order_direction:
......@@ -324,7 +328,7 @@ select_statement:
PARS_FROM_TOKEN table_list
search_condition
for_update_clause
consistent_read_clause
lock_shared_clause
order_by_clause { $$ = pars_select_statement($2, $4, $5,
$6, $7, $8); }
;
......
......@@ -325,10 +325,6 @@ In the state 'id', only two actions are possible (defined below). */
return(PARS_FOR_TOKEN);
}
"CONSISTENT" {
return(PARS_CONSISTENT_TOKEN);
}
"READ" {
return(PARS_READ_TOKEN);
}
......@@ -517,6 +513,18 @@ In the state 'id', only two actions are possible (defined below). */
return(PARS_FUNCTION_TOKEN);
}
"LOCK" {
return(PARS_LOCK_TOKEN);
}
"SHARE" {
return(PARS_SHARE_TOKEN);
}
"MODE" {
return(PARS_MODE_TOKEN);
}
{ID} {
yylval = sym_tab_add_id(pars_sym_tab_global,
(byte*)yytext,
......
......@@ -72,7 +72,7 @@ pars_res_word_t pars_asc_token = {PARS_ASC_TOKEN};
pars_res_word_t pars_desc_token = {PARS_DESC_TOKEN};
pars_res_word_t pars_open_token = {PARS_OPEN_TOKEN};
pars_res_word_t pars_close_token = {PARS_CLOSE_TOKEN};
pars_res_word_t pars_consistent_token = {PARS_CONSISTENT_TOKEN};
pars_res_word_t pars_share_token = {PARS_SHARE_TOKEN};
pars_res_word_t pars_unique_token = {PARS_UNIQUE_TOKEN};
pars_res_word_t pars_clustered_token = {PARS_CLUSTERED_TOKEN};
......@@ -699,8 +699,7 @@ pars_select_statement(
sym_node_t* table_list, /* in: table list */
que_node_t* search_cond, /* in: search condition or NULL */
pars_res_word_t* for_update, /* in: NULL or &pars_update_token */
pars_res_word_t* consistent_read,/* in: NULL or
&pars_consistent_token */
pars_res_word_t* lock_shared, /* in: NULL or &pars_share_token */
order_node_t* order_by) /* in: NULL or an order-by node */
{
select_node->state = SEL_NODE_OPEN;
......@@ -734,19 +733,24 @@ pars_select_statement(
}
if (for_update) {
ut_a(!consistent_read);
ut_a(!lock_shared);
select_node->set_x_locks = TRUE;
select_node->row_lock_mode = LOCK_X;
} else {
select_node->consistent_read = FALSE;
select_node->read_view = NULL;
} else if (lock_shared){
select_node->set_x_locks = FALSE;
select_node->row_lock_mode = LOCK_S;
}
if (consistent_read) {
select_node->consistent_read = TRUE;
} else {
select_node->consistent_read = FALSE;
select_node->read_view = NULL;
} else {
select_node->set_x_locks = FALSE;
select_node->row_lock_mode = LOCK_S;
select_node->consistent_read = TRUE;
}
select_node->order_by = order_by;
......@@ -976,7 +980,7 @@ pars_update_statement(
sel_node = pars_select_list(NULL, NULL);
pars_select_statement(sel_node, table_sym, search_cond, NULL,
NULL, NULL);
&pars_share_token, NULL);
node->searched_update = TRUE;
sel_node->common.parent = node;
}
......@@ -1857,8 +1861,9 @@ pars_sql(
#endif /* UNIV_SYNC_DEBUG */
pars_sym_tab_global = sym_tab_create(heap);
pars_sym_tab_global->sql_string = mem_heap_strdup(heap, str);
pars_sym_tab_global->string_len = strlen(str);
pars_sym_tab_global->sql_string = mem_heap_dup(heap, str,
pars_sym_tab_global->string_len + 1);
pars_sym_tab_global->next_char_pos = 0;
pars_sym_tab_global->info = info;
......
......@@ -715,27 +715,6 @@ que_graph_try_free(
return(FALSE);
}
/**************************************************************************
Handles an SQL error noticed during query thread execution. Currently,
does nothing! */
void
que_thr_handle_error(
/*=================*/
que_thr_t* thr __attribute__((unused)),
/* in: query thread */
ulint err_no __attribute__((unused)),
/* in: error number */
byte* err_str __attribute__((unused)),
/* in, own: error string or NULL; NOTE: the
function will take care of freeing of the
string! */
ulint err_len __attribute__((unused)))
/* in: error string length */
{
/* Does nothing */
}
/********************************************************************
Performs an execution step on a thr node. */
static
......@@ -813,11 +792,10 @@ que_thr_move_to_run_state(
Decrements the query thread reference counts in the query graph and the
transaction. May start signal handling, e.g., a rollback.
*** NOTE ***:
This and que_thr_stop_for_mysql are
the only functions where the reference count can be decremented and
this function may only be called from inside que_run_threads or
que_thr_check_if_switch! These restrictions exist to make the rollback code
easier to maintain. */
This and que_thr_stop_for_mysql are the only functions where the reference
count can be decremented and this function may only be called from inside
que_run_threads or que_thr_check_if_switch! These restrictions exist to make
the rollback code easier to maintain. */
static
void
que_thr_dec_refer_count(
......@@ -836,7 +814,7 @@ que_thr_dec_refer_count(
ibool stopped;
fork = thr->common.parent;
trx = thr->graph->trx;
trx = thr_get_trx(thr);
sess = trx->sess;
mutex_enter(&kernel_mutex);
......@@ -856,6 +834,12 @@ que_thr_dec_refer_count(
stderr); */
if (next_thr && *next_thr == NULL) {
/* Normally srv_suspend_mysql_thread resets
the state to DB_SUCCESS before waiting, but
in this case we have to do it here,
otherwise nobody does it. */
trx->error_state = DB_SUCCESS;
*next_thr = thr;
} else {
ut_a(0);
......@@ -1200,7 +1184,10 @@ que_thr_step(
trx_t* trx;
ulint type;
trx = thr_get_trx(thr);
ut_ad(thr->state == QUE_THR_RUNNING);
ut_a(trx->error_state == DB_SUCCESS);
thr->resource++;
......@@ -1236,7 +1223,6 @@ que_thr_step(
threads doing updating or inserting at the moment! */
if (thr->prev_node == que_node_get_parent(node)) {
trx = thr_get_trx(thr);
trx->last_sql_stat_start.least_undo_no
= trx->undo_no;
}
......@@ -1298,24 +1284,28 @@ que_thr_step(
old_thr->prev_node = node;
}
if (thr) {
ut_a(thr_get_trx(thr)->error_state == DB_SUCCESS);
}
return(thr);
}
/**************************************************************************
Runs query threads. Note that the individual query thread which is run
within this function may change if, e.g., the OS thread executing this
function uses a threshold amount of resources. */
Run a query thread until it finishes or encounters e.g. a lock wait. */
static
void
que_run_threads(
/*============*/
que_thr_t* thr) /* in: query thread which is run initially */
que_run_threads_low(
/*================*/
que_thr_t* thr) /* in: query thread */
{
que_thr_t* next_thr;
ulint cumul_resource;
ulint loop_count;
ut_ad(thr->state == QUE_THR_RUNNING);
ut_a(thr_get_trx(thr)->error_state == DB_SUCCESS);
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
......@@ -1340,10 +1330,15 @@ que_run_threads(
next_thr = que_thr_step(thr);
/*-------------------------*/
ut_a(!next_thr || (thr_get_trx(next_thr)->error_state == DB_SUCCESS));
loop_count++;
if (next_thr != thr) {
ut_a(next_thr == NULL);
/* This can change next_thr to a non-NULL value if there was
a lock wait that already completed. */
que_thr_dec_refer_count(thr, &next_thr);
if (next_thr == NULL) {
......@@ -1359,20 +1354,89 @@ que_run_threads(
goto loop;
}
/**************************************************************************
Run a query thread. Handles lock waits. */
void
que_run_threads(
/*============*/
que_thr_t* thr) /* in: query thread */
{
loop:
ut_a(thr_get_trx(thr)->error_state == DB_SUCCESS);
que_run_threads_low(thr);
mutex_enter(&kernel_mutex);
switch (thr->state) {
case QUE_THR_RUNNING:
/* There probably was a lock wait, but it already ended
before we came here: continue running thr */
mutex_exit(&kernel_mutex);
goto loop;
case QUE_THR_LOCK_WAIT:
mutex_exit(&kernel_mutex);
/* The ..._mysql_... function works also for InnoDB's
internal threads. Let us wait that the lock wait ends. */
srv_suspend_mysql_thread(thr);
if (thr_get_trx(thr)->error_state != DB_SUCCESS) {
/* thr was chosen as a deadlock victim or there was
a lock wait timeout */
que_thr_dec_refer_count(thr, NULL);
return;
}
goto loop;
case QUE_THR_COMPLETED:
case QUE_THR_COMMAND_WAIT:
/* Do nothing */
break;
default:
ut_error;
}
mutex_exit(&kernel_mutex);
}
/*************************************************************************
Evaluate the given SQL */
Evaluate the given SQL. */
ulint
que_eval_sql(
/*=========*/
pars_info_t* info, /* out: error code or DB_SUCCESS */
const char* sql, /* in: info struct, or NULL */
/* out: error code or DB_SUCCESS */
pars_info_t* info, /* in: info struct, or NULL */
const char* sql, /* in: SQL string */
ibool reserve_dict_mutex,
/* in: if TRUE, acquire/release
dict_sys->mutex around call to pars_sql. */
trx_t* trx) /* in: trx */
{
que_thr_t* thr;
que_t* graph;
ut_a(trx->error_state == DB_SUCCESS);
if (reserve_dict_mutex) {
mutex_enter(&dict_sys->mutex);
}
graph = pars_sql(info, sql);
if (reserve_dict_mutex) {
mutex_exit(&dict_sys->mutex);
}
ut_a(graph);
graph->trx = trx;
......
......@@ -2503,7 +2503,8 @@ do not allow the discard. We also reserve the data dictionary latch. */
"BEGIN\n"
"SELECT ID INTO old_id\n"
"FROM SYS_TABLES\n"
"WHERE NAME = :table_name;\n"
"WHERE NAME = :table_name\n"
"LOCK IN SHARE MODE;\n"
"IF (SQL % NOTFOUND) THEN\n"
" COMMIT WORK;\n"
" RETURN;\n"
......@@ -2516,7 +2517,7 @@ do not allow the discard. We also reserve the data dictionary latch. */
" WHERE TABLE_ID = old_id;\n"
"COMMIT WORK;\n"
"END;\n"
, trx);
, FALSE, trx);
if (err != DB_SUCCESS) {
trx->error_state = DB_SUCCESS;
......@@ -2912,7 +2913,7 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */
" WHERE TABLE_ID = :old_id;\n"
"COMMIT WORK;\n"
"END;\n"
, trx);
, FALSE, trx);
if (err != DB_SUCCESS) {
trx->error_state = DB_SUCCESS;
......@@ -3182,7 +3183,8 @@ fputs(" InnoDB: You are trying to drop table ", stderr);
"BEGIN\n"
"SELECT ID INTO table_id\n"
"FROM SYS_TABLES\n"
"WHERE NAME = :table_name;\n"
"WHERE NAME = :table_name\n"
"LOCK IN SHARE MODE;\n"
"IF (SQL % NOTFOUND) THEN\n"
" COMMIT WORK;\n"
" RETURN;\n"
......@@ -3190,7 +3192,8 @@ fputs(" InnoDB: You are trying to drop table ", stderr);
"found := 1;\n"
"SELECT ID INTO sys_foreign_id\n"
"FROM SYS_TABLES\n"
"WHERE NAME = 'SYS_FOREIGN';\n"
"WHERE NAME = 'SYS_FOREIGN'\n"
"LOCK IN SHARE MODE;\n"
"IF (SQL % NOTFOUND) THEN\n"
" found := 0;\n"
"END IF;\n"
......@@ -3204,7 +3207,8 @@ fputs(" InnoDB: You are trying to drop table ", stderr);
" SELECT ID INTO foreign_id\n"
" FROM SYS_FOREIGN\n"
" WHERE FOR_NAME = :table_name\n"
" AND TO_BINARY(FOR_NAME) = TO_BINARY(:table_name);\n"
" AND TO_BINARY(FOR_NAME) = TO_BINARY(:table_name)\n"
" LOCK IN SHARE MODE;\n"
" IF (SQL % NOTFOUND) THEN\n"
" found := 0;\n"
" ELSE"
......@@ -3216,7 +3220,8 @@ fputs(" InnoDB: You are trying to drop table ", stderr);
"WHILE found = 1 LOOP\n"
" SELECT ID INTO index_id\n"
" FROM SYS_INDEXES\n"
" WHERE TABLE_ID = table_id;\n"
" WHERE TABLE_ID = table_id\n"
" LOCK IN SHARE MODE;\n"
" IF (SQL % NOTFOUND) THEN\n"
" found := 0;\n"
" ELSE"
......@@ -3229,7 +3234,7 @@ fputs(" InnoDB: You are trying to drop table ", stderr);
"DELETE FROM SYS_TABLES WHERE ID = table_id;\n"
"COMMIT WORK;\n"
"END;\n"
, trx);
, FALSE, trx);
if (err != DB_SUCCESS) {
ut_a(err == DB_OUT_OF_FILE_SPACE);
......@@ -3438,7 +3443,7 @@ row_delete_constraint_low(
"DELETE FROM SYS_FOREIGN_COLS WHERE ID = :id;\n"
"DELETE FROM SYS_FOREIGN WHERE ID = :id;\n"
"END;\n"
, trx));
, FALSE, trx));
}
/********************************************************************
......@@ -3604,7 +3609,7 @@ row_rename_table_for_mysql(
"UPDATE SYS_TABLES SET NAME = :new_table_name\n"
" WHERE NAME = :old_table_name;\n"
"END;\n"
, trx);
, FALSE, trx);
if (err != DB_SUCCESS) {
......@@ -3641,7 +3646,8 @@ row_rename_table_for_mysql(
" SELECT ID INTO foreign_id\n"
" FROM SYS_FOREIGN\n"
" WHERE FOR_NAME = :old_table_name\n"
" AND TO_BINARY(FOR_NAME) = TO_BINARY(:old_table_name);\n"
" AND TO_BINARY(FOR_NAME) = TO_BINARY(:old_table_name)\n"
" LOCK IN SHARE MODE;\n"
" IF (SQL % NOTFOUND) THEN\n"
" found := 0;\n"
" ELSE\n"
......@@ -3677,7 +3683,7 @@ row_rename_table_for_mysql(
"WHERE REF_NAME = :old_table_name\n"
" AND TO_BINARY(REF_NAME) = TO_BINARY(:old_table_name);\n"
"END;\n"
, trx);
, FALSE, trx);
} else if (n_constraints_to_drop > 0) {
/* Drop some constraints of tmp tables. */
......
......@@ -45,6 +45,9 @@ to que_run_threads: this is to allow canceling runaway queries */
#define SEL_COST_LIMIT 100
/* The lower limit for what we consider a "big" row */
#define BIG_ROW_SIZE 1024
/* Flags for search shortcut */
#define SEL_FOUND 0
#define SEL_EXHAUSTED 1
......@@ -1132,11 +1135,12 @@ row_sel_try_search_shortcut(
ut_ad(plan->pcur.latch_mode == node->latch_mode);
plan->n_rows_fetched++;
ret = SEL_FOUND;
func_exit:
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
return(SEL_FOUND);
return(ret);
}
/*************************************************************************
......@@ -1240,7 +1244,8 @@ row_sel(
mtr_start(&mtr);
if (consistent_read && plan->unique_search && !plan->pcur_is_open
&& !plan->must_get_clust) {
&& !plan->must_get_clust
&& (plan->table->max_row_size < BIG_ROW_SIZE)) {
if (!search_latch_locked) {
rw_lock_s_lock(&btr_search_latch);
......@@ -1354,6 +1359,12 @@ row_sel(
if (srv_locks_unsafe_for_binlog
|| trx->isolation_level == TRX_ISO_READ_COMMITTED) {
if (page_rec_is_supremum(next_rec)) {
goto skip_lock;
}
lock_type = LOCK_REC_NOT_GAP;
} else {
lock_type = LOCK_ORDINARY;
......@@ -1372,6 +1383,7 @@ row_sel(
}
}
skip_lock:
if (page_rec_is_infimum(rec)) {
/* The infimum record on a page cannot be in the result set,
......@@ -1402,6 +1414,12 @@ row_sel(
if (srv_locks_unsafe_for_binlog
|| trx->isolation_level == TRX_ISO_READ_COMMITTED) {
if (page_rec_is_supremum(rec)) {
goto next_rec;
}
lock_type = LOCK_REC_NOT_GAP;
} else {
lock_type = LOCK_ORDINARY;
......@@ -1628,7 +1646,8 @@ row_sel(
}
if ((plan->n_rows_fetched <= SEL_PREFETCH_LIMIT)
|| plan->unique_search || plan->no_prefetch) {
|| plan->unique_search || plan->no_prefetch
|| (plan->table->max_row_size >= BIG_ROW_SIZE)) {
/* No prefetch in operation: go to the next table */
......@@ -1914,9 +1933,8 @@ row_sel_step(
err = lock_table(0, table_node->table,
i_lock_mode, thr);
if (err != DB_SUCCESS) {
thr_get_trx(thr)->error_state = err;
que_thr_handle_error(thr, DB_ERROR,
NULL, 0);
return(NULL);
}
......@@ -1952,17 +1970,8 @@ row_sel_step(
thr->graph->last_sel_node = node;
if (err == DB_SUCCESS) {
/* Ok: do nothing */
} else if (err == DB_LOCK_WAIT) {
return(NULL);
} else {
/* SQL error detected */
fprintf(stderr, "SQL error %lu\n", (ulong) err);
que_thr_handle_error(thr, DB_ERROR, NULL, 0);
if (err != DB_SUCCESS) {
thr_get_trx(thr)->error_state = err;
return(NULL);
}
......@@ -2023,7 +2032,7 @@ fetch_step(
fprintf(stderr,
"InnoDB: Error: fetch called on a closed cursor\n");
que_thr_handle_error(thr, DB_ERROR, NULL, 0);
thr_get_trx(thr)->error_state = DB_ERROR;
return(NULL);
}
......
......@@ -1984,12 +1984,7 @@ row_upd_step(
error_handling:
trx->error_state = err;
if (err == DB_SUCCESS) {
/* Ok: do nothing */
} else if (err == DB_LOCK_WAIT) {
return(NULL);
} else {
if (err != DB_SUCCESS) {
return(NULL);
}
......
......@@ -1286,7 +1286,6 @@ trx_rollback_step(
que_thr_t* thr) /* in: query thread */
{
roll_node_t* node;
ibool success;
ulint sig_no;
trx_savept_t* savept;
......@@ -1313,19 +1312,13 @@ trx_rollback_step(
/* Send a rollback signal to the transaction */
success = trx_sig_send(thr_get_trx(thr),
sig_no, TRX_SIG_SELF,
thr, savept, NULL);
trx_sig_send(thr_get_trx(thr), sig_no, TRX_SIG_SELF, thr,
savept, NULL);
thr->state = QUE_THR_SIG_REPLY_WAIT;
mutex_exit(&kernel_mutex);
if (!success) {
/* Error in delivering the rollback signal */
que_thr_handle_error(thr, DB_ERROR, NULL, 0);
}
return(NULL);
}
......
......@@ -1223,11 +1223,9 @@ trx_sig_is_compatible(
/********************************************************************
Sends a signal to a trx object. */
ibool
void
trx_sig_send(
/*=========*/
/* out: TRUE if the signal was
successfully delivered */
trx_t* trx, /* in: trx handle */
ulint type, /* in: signal type */
ulint sender, /* in: TRX_SIG_SELF or
......@@ -1254,11 +1252,9 @@ trx_sig_send(
if (!trx_sig_is_compatible(trx, type, sender)) {
/* The signal is not compatible with the other signals in
the queue: do nothing */
the queue: die */
ut_error;
return(FALSE);
}
/* Queue the signal object */
......@@ -1299,11 +1295,6 @@ trx_sig_send(
}
if ((sender != TRX_SIG_SELF) || (type == TRX_SIG_BREAK_EXECUTION)) {
/* The following call will add a TRX_SIG_ERROR_OCCURRED
signal to the end of the queue, if the session is not yet
in the error state: */
ut_error;
}
......@@ -1314,8 +1305,6 @@ trx_sig_send(
trx_sig_start_handle(trx, next_thr);
}
return(TRUE);
}
/********************************************************************
......@@ -1541,7 +1530,6 @@ trx_commit_step(
{
commit_node_t* node;
que_thr_t* next_thr;
ibool success;
node = thr->run_node;
......@@ -1562,16 +1550,11 @@ trx_commit_step(
/* Send the commit signal to the transaction */
success = trx_sig_send(thr_get_trx(thr), TRX_SIG_COMMIT,
TRX_SIG_SELF, thr, NULL, &next_thr);
trx_sig_send(thr_get_trx(thr), TRX_SIG_COMMIT, TRX_SIG_SELF,
thr, NULL, &next_thr);
mutex_exit(&kernel_mutex);
if (!success) {
/* Error in delivering the commit signal */
que_thr_handle_error(thr, DB_ERROR, NULL, 0);
}
return(next_thr);
}
......
......@@ -30,7 +30,8 @@ innobase_print_identifier(
/*======================*/
FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction */
ibool table_id,/* in: TRUE=decode table name */
ibool table_id,/* in: TRUE=print a table name,
FALSE=print other identifier */
const char* name, /* in: name to print */
ulint namelen);/* in: length of name */
#endif /* !UNIV_HOTBACKUP */
......@@ -400,7 +401,8 @@ ut_print_name(
/*==========*/
FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction */
ibool table_id,/* in: TRUE=decode table name */
ibool table_id,/* in: TRUE=print a table name,
FALSE=print other identifier */
const char* name) /* in: name to print */
{
ut_print_namel(f, trx, table_id, name, strlen(name));
......@@ -414,7 +416,8 @@ ut_print_namel(
/*===========*/
FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction (NULL=no quotes) */
ibool table_id,/* in: TRUE=decode table name */
ibool table_id,/* in: TRUE=print a table name,
FALSE=print other identifier */
const char* name, /* in: name to print */
ulint namelen)/* in: length of name */
{
......
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