Commit b6b2546c authored by unknown's avatar unknown

row0ins.c:

  Do not perform ON DELETE action for a FOREIGN KEY constraint if we are doing an UPDATE, not a DELETE
dict0dict.c:
  test


innobase/dict/dict0dict.c:
  test
innobase/row/row0ins.c:
  Do not perform ON DELETE action for a FOREIGN KEY constraint if we are doing an UPDATE, not a DELETE
parent a9c52ff7
...@@ -270,7 +270,7 @@ void ...@@ -270,7 +270,7 @@ void
dict_table_autoinc_initialize( dict_table_autoinc_initialize(
/*==========================*/ /*==========================*/
dict_table_t* table, /* in: table */ dict_table_t* table, /* in: table */
ib_longlong value) /* in: value which was assigned to a row */ ib_longlong value) /* in: next value to assign to a row */
{ {
mutex_enter(&(table->autoinc_mutex)); mutex_enter(&(table->autoinc_mutex));
...@@ -281,8 +281,8 @@ dict_table_autoinc_initialize( ...@@ -281,8 +281,8 @@ dict_table_autoinc_initialize(
} }
/************************************************************************ /************************************************************************
Gets the next autoinc value, 0 if not yet initialized. If initialized, Gets the next autoinc value (== autoinc counter value), 0 if not yet
increments the counter by 1. */ initialized. If initialized, increments the counter by 1. */
ib_longlong ib_longlong
dict_table_autoinc_get( dict_table_autoinc_get(
...@@ -298,8 +298,8 @@ dict_table_autoinc_get( ...@@ -298,8 +298,8 @@ dict_table_autoinc_get(
value = 0; value = 0;
} else { } else {
table->autoinc = table->autoinc + 1;
value = table->autoinc; value = table->autoinc;
table->autoinc = table->autoinc + 1;
} }
mutex_exit(&(table->autoinc_mutex)); mutex_exit(&(table->autoinc_mutex));
...@@ -334,20 +334,43 @@ dict_table_autoinc_read( ...@@ -334,20 +334,43 @@ dict_table_autoinc_read(
} }
/************************************************************************ /************************************************************************
Updates the autoinc counter if the value supplied is bigger than the Peeks the autoinc counter value, 0 if not yet initialized. Does not
increment the counter. The read not protected by any mutex! */
ib_longlong
dict_table_autoinc_peek(
/*====================*/
/* out: value of the counter */
dict_table_t* table) /* in: table */
{
ib_longlong value;
if (!table->autoinc_inited) {
value = 0;
} else {
value = table->autoinc;
}
return(value);
}
/************************************************************************
Updates the autoinc counter if the value supplied is equal or bigger than the
current value. If not inited, does nothing. */ current value. If not inited, does nothing. */
void void
dict_table_autoinc_update( dict_table_autoinc_update(
/*======================*/ /*======================*/
dict_table_t* table, /* in: table */ dict_table_t* table, /* in: table */
ib_longlong value) /* in: value which was assigned to a row */ ib_longlong value) /* in: value which was assigned to a row */
{ {
mutex_enter(&(table->autoinc_mutex)); mutex_enter(&(table->autoinc_mutex));
if (table->autoinc_inited) { if (table->autoinc_inited) {
if (value > table->autoinc) { if (value >= table->autoinc) {
table->autoinc = value; table->autoinc = value + 1;
} }
} }
......
...@@ -389,9 +389,21 @@ row_ins_foreign_delete_or_set_null( ...@@ -389,9 +389,21 @@ row_ins_foreign_delete_or_set_null(
char err_buf[1000]; char err_buf[1000];
ut_a(thr && foreign && pcur && mtr); ut_a(thr && foreign && pcur && mtr);
ut_a(que_node_get_type(node) == QUE_NODE_UPDATE);
node = thr->run_node; node = thr->run_node;
if (!node->is_delete) {
/* According to SQL-92 an UPDATE with respect to FOREIGN
KEY constraints is not semantically equivalent to a
DELETE + INSERT. Therefore we do not perform any action
here and consequently the child rows would be left
orphaned if we would let the UPDATE happen. Thus we return
an error. */
return(DB_ROW_IS_REFERENCED);
}
if (node->cascade_node == NULL) { if (node->cascade_node == NULL) {
/* Extend our query graph by creating a child to current /* Extend our query graph by creating a child to current
update node. The child is used in the cascade or set null update node. The child is used in the cascade or set null
......
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