summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-03-16 16:30:54 +0200
committerunknown <monty@mashka.mysql.fi>2003-03-16 16:30:54 +0200
commitbfbb0ad69df21854f2db5fb2b9c708b2a576929e (patch)
treef6d63b9728c1157c31c1f74bbe32bc1e50de79b8
parentf08688c5ee2aed851f92393b06b1b704ef0dd118 (diff)
parent9681f4a8cd242e3828f211e0bed5235e70ee5f4e (diff)
downloadmariadb-git-bfbb0ad69df21854f2db5fb2b9c708b2a576929e.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.0
into mashka.mysql.fi:/home/my/mysql-4.0
-rw-r--r--mysql-test/r/create.result7
-rw-r--r--mysql-test/t/create.test8
-rw-r--r--sql/filesort.cc16
-rw-r--r--sql/sql_insert.cc14
-rw-r--r--sql/sql_parse.cc8
-rw-r--r--sql/sql_table.cc11
-rw-r--r--sql/sql_update.cc13
-rw-r--r--sql/table.cc7
-rw-r--r--tests/grant.pl10
-rw-r--r--tests/grant.res7
10 files changed, 69 insertions, 32 deletions
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index c3083dbfb03..0cc98c38d49 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -58,6 +58,13 @@ a$1 $b c$
create table test_$1.test2$ (a int);
drop table test_$1.test2$;
drop database test_$1;
+create table `` (a int);
+Incorrect table name ''
+drop table if exists ``;
+Incorrect table name ''
+create table t1 (`` int);
+Incorrect column name ''
+drop table if exists t1;
create table t1 (a int auto_increment not null primary key, B CHAR(20));
insert into t1 (b) values ("hello"),("my"),("world");
create table t2 (key (b)) select * from t1;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index bb0d6dc0d64..7d566cb89ac 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -55,6 +55,14 @@ create table test_$1.test2$ (a int);
drop table test_$1.test2$;
drop database test_$1;
+--error 1103
+create table `` (a int);
+--error 1103
+drop table if exists ``;
+--error 1166
+create table t1 (`` int);
+drop table if exists t1;
+
#
# Test of CREATE ... SELECT with indexes
#
diff --git a/sql/filesort.cc b/sql/filesort.cc
index b212e2cb366..86574e4dd57 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -68,7 +68,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
ha_rows *examined_rows)
{
int error;
- ulong memavl;
+ ulong memavl, min_sort_memory;
uint maxbuffer;
BUFFPEK *buffpek;
ha_rows records;
@@ -137,7 +137,8 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
#endif
memavl= thd->variables.sortbuff_size;
- while (memavl >= MIN_SORT_MEMORY)
+ min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
+ while (memavl >= min_sort_memory)
{
ulong old_memavl;
ulong keys= memavl/(param.sort_length+sizeof(char*));
@@ -146,15 +147,10 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
MYF(0))))
break;
old_memavl=memavl;
- if ((memavl=memavl/4*3) < MIN_SORT_MEMORY && old_memavl > MIN_SORT_MEMORY)
- memavl=MIN_SORT_MEMORY;
+ if ((memavl=memavl/4*3) < min_sort_memory && old_memavl > min_sort_memory)
+ memavl= min_sort_memory;
}
- if (memavl < param.sort_length*MERGEBUFF2)
- {
- my_error(ER_OUT_OF_SORTMEMORY,MYF(0));
- goto err;
- }
- if (memavl < MIN_SORT_MEMORY)
+ if (memavl < min_sort_memory)
{
my_error(ER_OUTOFMEMORY,MYF(ME_ERROR+ME_WAITTANG),
thd->variables.sortbuff_size);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 9f1a0e93cb9..ace15771449 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1361,6 +1361,14 @@ bool select_insert::send_eof()
if (!(error=table->file->extra(HA_EXTRA_NO_CACHE)))
error=table->file->activate_all_index(thd);
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
+
+ /* Write to binlog before commiting transaction */
+ if (mysql_bin_log.is_open())
+ {
+ Query_log_event qinfo(thd, thd->query, thd->query_length,
+ table->file->has_transactions());
+ mysql_bin_log.write(&qinfo);
+ }
if ((error2=ha_autocommit_or_rollback(thd,error)) && ! error)
error=error2;
if (info.copied || info.deleted)
@@ -1386,12 +1394,6 @@ bool select_insert::send_eof()
thd->insert_id(last_insert_id); // For update log
::send_ok(&thd->net,info.copied,last_insert_id,buff);
mysql_update_log.write(thd,thd->query,thd->query_length);
- if (mysql_bin_log.is_open())
- {
- Query_log_event qinfo(thd, thd->query, thd->query_length,
- table->file->has_transactions());
- mysql_bin_log.write(&qinfo);
- }
return 0;
}
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 24643f18ac7..dde4b6c5c93 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1521,11 +1521,6 @@ mysql_execute_command(void)
if (error)
goto error;
}
- if (strlen(tables->real_name) > NAME_LEN)
- {
- net_printf(&thd->net,ER_WRONG_TABLE_NAME,tables->real_name);
- break;
- }
LOCK_ACTIVE_MI;
// fetch_master_table will send the error to the client on failure
if (!fetch_master_table(thd, tables->db, tables->real_name,
@@ -3223,8 +3218,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
if (!table)
DBUG_RETURN(0); // End of memory
alias_str= alias ? alias->str : table->table.str;
- if (table->table.length > NAME_LEN ||
- check_table_name(table->table.str,table->table.length) ||
+ if (check_table_name(table->table.str,table->table.length) ||
table->db.str && check_db_name(table->db.str))
{
net_printf(&thd->net,ER_WRONG_TABLE_NAME,table->table.str);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index adaedebfa28..0cdb0a7ff48 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -394,6 +394,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
}
if (!(sql_field->flags & NOT_NULL_FLAG))
null_fields++;
+ if (check_column_name(sql_field->field_name))
+ {
+ my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name);
+ DBUG_RETURN(-1);
+ }
while ((dup_field=it2++) != sql_field)
{
if (my_strcasecmp(sql_field->field_name, dup_field->field_name) == 0)
@@ -830,12 +835,6 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
while ((item=it++))
{
create_field *cr_field;
- if (strlen(item->name) > NAME_LEN ||
- check_column_name(item->name))
- {
- my_error(ER_WRONG_COLUMN_NAME,MYF(0),item->name);
- DBUG_RETURN(0);
- }
Field *field;
if (item->type() == Item::FUNC_ITEM)
field=item->tmp_table_field(&tmp_table);
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index adb60adb7d6..d8842855093 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -618,7 +618,18 @@ bool multi_update::send_data(List<Item> &not_used_values)
for (cur_table= update_tables; cur_table ; cur_table= cur_table->next)
{
TABLE *table= cur_table->table;
- /* Check if we are using outer join and we didn't find the row */
+ /*
+ Check if we are using outer join and we didn't find the row
+ or if we have already updated this row in the previous call to this
+ function.
+
+ The same row may be presented here several times in a join of type
+ UPDATE t1 FROM t1,t2 SET t1.a=t2.a
+
+ In this case we will do the update for the first found row combination.
+ The join algorithm guarantees that we will not find the a row in
+ t1 several times.
+ */
if (table->status & (STATUS_NULL_ROW | STATUS_UPDATED))
continue;
diff --git a/sql/table.cc b/sql/table.cc
index 1635c85eca8..d1e2c86e5ab 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1164,6 +1164,8 @@ bool check_db_name(char *name)
bool check_table_name(const char *name, uint length)
{
const char *end= name+length;
+ if (!length || length > NAME_LEN)
+ return 1;
while (name != end)
{
@@ -1187,6 +1189,8 @@ bool check_table_name(const char *name, uint length)
bool check_column_name(const char *name)
{
+ const char *start= name;
+
while (*name)
{
#if defined(USE_MB) && defined(USE_MB_IDENT)
@@ -1204,7 +1208,8 @@ bool check_column_name(const char *name)
return 1;
name++;
}
- return 0;
+ /* Error if empty or too long column name */
+ return (name == start || (uint) (name - start) > NAME_LEN);
}
/*
diff --git a/tests/grant.pl b/tests/grant.pl
index ba95d78d068..5a24127d79d 100644
--- a/tests/grant.pl
+++ b/tests/grant.pl
@@ -210,6 +210,16 @@ user_query("delete from $opt_database.test where a=1",1);
user_query("update $opt_database.test set b=3 where b=1",1);
user_query("update $opt_database.test set b=b+1",1);
+#
+# Test global SELECT privilege combined with table level privileges
+#
+
+safe_query("grant SELECT on *.* to $user");
+user_connect(0);
+user_query("update $opt_database.test set b=b+1");
+safe_query("revoke SELECT on *.* from $user");
+user_connect(0);
+
# Add one privilege at a time until the user has all privileges
user_query("select * from test",1);
safe_query("grant select on $opt_database.test to $user");
diff --git a/tests/grant.res b/tests/grant.res
index 822e9320f53..92d271cd864 100644
--- a/tests/grant.res
+++ b/tests/grant.res
@@ -195,7 +195,12 @@ update grant_test.test set b=3 where b=1
Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test'
update grant_test.test set b=b+1
Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test'
-select * from test
+grant SELECT on *.* to grant_user@localhost
+Connecting grant_user
+update grant_test.test set b=b+1
+revoke SELECT on *.* from grant_user@localhost
+Connecting grant_user
+lect * from test
Error in execute: select command denied to user: 'grant_user@localhost' for table 'test'
grant select on grant_test.test to grant_user@localhost
delete from grant_test.test where a=1