summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <tim@work.mysql.com>2001-05-22 22:29:30 +0200
committerunknown <tim@work.mysql.com>2001-05-22 22:29:30 +0200
commit52f473903a6293958d446d6aaa6de5cdbe4ac246 (patch)
treee9b2ecc763a5ce48f0b8e0fb0d871520f1cf63aa /sql
parenta81daac3a6305c7835ea66bfcc92fdb8444c5c61 (diff)
parent2cc87b411f8226e8bd0ca3daa556c1e22fb295b8 (diff)
downloadmariadb-git-52f473903a6293958d446d6aaa6de5cdbe4ac246.tar.gz
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
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_innobase.cc38
-rw-r--r--sql/sql_parse.cc9
2 files changed, 45 insertions, 2 deletions
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index 8af9de0eaba..3e86d0da6f1 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -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
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3dda8d1cff7..d92852adb89 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1864,6 +1864,15 @@ mysql_execute_command(void)
}
if (check_db_used(thd,tables) || end_active_trans(thd))
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;
if (!(res=open_and_lock_tables(thd,tables)))
{