summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2006-02-02 23:27:06 +0300
committerunknown <konstantin@mysql.com>2006-02-02 23:27:06 +0300
commitd297a221fe57486f0fd82e0cf3e7b0e923adee93 (patch)
tree8b23d2acce88a26d289057d5119ca3944903d88f /sql
parent5610e9ab8296f661b144bc64702bb612d2038050 (diff)
parent333b1f8594922647278808a4c114c16695551343 (diff)
downloadmariadb-git-d297a221fe57486f0fd82e0cf3e7b0e923adee93.tar.gz
Merge mysql.com:/home/kostja/mysql/tmp_merge
into mysql.com:/home/kostja/mysql/mysql-5.1-merge BitKeeper/etc/ignore: auto-union configure.in: Auto merged libmysql/libmysql.c: Auto merged mysql-test/ndb/ndbcluster.sh: Auto merged mysql-test/r/rpl_sp.result: Auto merged mysql-test/r/sp-error.result: Auto merged mysql-test/r/sp.result: Auto merged mysql-test/r/type_float.result: Auto merged mysql-test/t/rpl_sp.test: Auto merged mysql-test/t/sp-error.test: Auto merged mysql-test/t/sp.test: Auto merged sql/field.cc: Auto merged sql/item_func.cc: Auto merged sql/mysqld.cc: Auto merged sql/protocol.cc: Auto merged sql/sp_head.cc: Auto merged sql/sp_head.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged storage/myisam/ft_update.c: Auto merged storage/ndb/include/logger/LogHandler.hpp: Auto merged storage/ndb/include/logger/Logger.hpp: Auto merged storage/ndb/include/mgmapi/mgmapi.h: Auto merged storage/ndb/include/mgmcommon/ConfigRetriever.hpp: Auto merged storage/ndb/src/common/logger/FileLogHandler.cpp: Auto merged storage/ndb/src/common/logger/LogHandler.cpp: Auto merged storage/ndb/src/common/logger/Logger.cpp: Auto merged storage/ndb/src/common/logger/SysLogHandler.cpp: Auto merged storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp: Auto merged storage/ndb/src/common/util/SocketServer.cpp: Auto merged storage/ndb/src/kernel/main.cpp: Auto merged storage/ndb/src/kernel/vm/Configuration.cpp: Auto merged storage/ndb/src/kernel/vm/Configuration.hpp: Auto merged storage/ndb/src/mgmapi/mgmapi.cpp: Auto merged storage/ndb/src/mgmclient/CommandInterpreter.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.hpp: Auto merged storage/ndb/src/mgmsrv/Services.cpp: Auto merged storage/ndb/src/mgmsrv/Services.hpp: Auto merged storage/ndb/src/mgmsrv/main.cpp: Auto merged storage/ndb/tools/ndb_size.pl: Auto merged zlib/Makefile.am: Auto merged mysql-test/r/information_schema.result: SCCS merged mysql-test/t/information_schema.test: Manual merge. sql/ha_archive.cc: Manual merge. sql/share/errmsg.txt: SCCS merged tests/mysql_client_test.c: Manual merge.
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc4
-rw-r--r--sql/ha_archive.cc7
-rw-r--r--sql/item_func.cc13
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/protocol.cc18
-rw-r--r--sql/share/errmsg.txt2
-rw-r--r--sql/sp_head.cc54
-rw-r--r--sql/sp_head.h2
-rw-r--r--sql/spatial.h2
-rw-r--r--sql/sql_acl.cc2
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_select.cc8
-rw-r--r--sql/sql_show.cc12
-rw-r--r--sql/sql_yacc.yy15
-rw-r--r--sql/table.h1
15 files changed, 119 insertions, 25 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 48f8f7f8f32..3d983bb4d12 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5877,7 +5877,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
field_length/
field_charset->mbmaxlen,
&well_formed_error);
- memcpy(ptr,from,copy_length);
+ memmove(ptr, from, copy_length);
/* Append spaces if the string was shorter than the field. */
if (copy_length < field_length)
@@ -6293,7 +6293,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
field_length/
field_charset->mbmaxlen,
&well_formed_error);
- memcpy(ptr + length_bytes, from, copy_length);
+ memmove(ptr + length_bytes, from, copy_length);
if (length_bytes == 1)
*ptr= (uchar) copy_length;
else
diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc
index 65049bac135..2a2ac475c0b 100644
--- a/sql/ha_archive.cc
+++ b/sql/ha_archive.cc
@@ -139,6 +139,10 @@ static HASH archive_open_tables;
/* Static declarations for handerton */
static handler *archive_create_handler(TABLE_SHARE *table);
+/*
+ Number of rows that will force a bulk insert.
+*/
+#define ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT 2
/* dummy handlerton - only to have something to return from archive_db_init */
@@ -1302,7 +1306,8 @@ void ha_archive::info(uint flag)
void ha_archive::start_bulk_insert(ha_rows rows)
{
DBUG_ENTER("ha_archive::start_bulk_insert");
- bulk_insert= TRUE;
+ if (!rows || rows >= ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT)
+ bulk_insert= TRUE;
DBUG_VOID_RETURN;
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index c4c03e1cbf2..60b0dafefc5 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -431,12 +431,19 @@ my_decimal *Item_real_func::val_decimal(my_decimal *decimal_value)
void Item_func::fix_num_length_and_dec()
{
- decimals= 0;
+ uint fl_length= 0;
+ decimals=0;
for (uint i=0 ; i < arg_count ; i++)
{
- set_if_bigger(decimals, args[i]->decimals);
+ set_if_bigger(decimals,args[i]->decimals);
+ set_if_bigger(fl_length, args[i]->max_length);
+ }
+ max_length=float_length(decimals);
+ if (fl_length > max_length)
+ {
+ decimals= NOT_FIXED_DEC;
+ max_length= float_length(NOT_FIXED_DEC);
}
- max_length= float_length(decimals);
}
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index f5b93e6a5e5..119b75a7fe6 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -5120,7 +5120,7 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
"Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2 (write at commit, flush once per second).",
(gptr*) &innobase_flush_log_at_trx_commit,
(gptr*) &innobase_flush_log_at_trx_commit,
- 0, GET_UINT, OPT_ARG, 1, 0, 2, 0, 0, 0},
+ 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
{"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
"With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
(gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 98cded56871..650bd8fc58f 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -601,9 +601,23 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
else
{
/* With conversion */
+ uint max_char_len;
int2store(pos, thd_charset->number);
- uint char_len= field.length / item->collation.collation->mbmaxlen;
- int4store(pos+2, char_len * thd_charset->mbmaxlen);
+ /*
+ For TEXT/BLOB columns, field_length describes the maximum data
+ length in bytes. There is no limit to the number of characters
+ that a TEXT column can store, as long as the data fits into
+ the designated space.
+ For the rest of textual columns, field_length is evaluated as
+ char_count * mbmaxlen, where character count is taken from the
+ definition of the column. In other words, the maximum number
+ of characters here is limited by the column definition.
+ */
+ max_char_len= (field.type >= (int) MYSQL_TYPE_TINY_BLOB &&
+ field.type <= (int) MYSQL_TYPE_BLOB) ?
+ field.length / item->collation.collation->mbminlen :
+ field.length / item->collation.collation->mbmaxlen;
+ int4store(pos+2, max_char_len * thd_charset->mbmaxlen);
}
pos[6]= field.type;
int2store(pos+7,field.flags);
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 084ab31c459..1099b410290 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5798,3 +5798,5 @@ ER_CANT_WRITE_LOCK_LOG_TABLE
eng "You can't write-lock a log table. Only read access is possible."
ER_CANT_READ_LOCK_LOG_TABLE
eng "You can't use usual read lock with log tables. Try READ LOCAL instead."
+ER_SP_WRONG_NAME 42000
+ eng "Incorrect routine name '%-.64s'"
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index e1af0b7d939..e4e87eb5620 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -105,21 +105,27 @@ sp_get_item_value(Item *item, String *str)
case STRING_RESULT:
{
- char buf_holder[STRING_BUFFER_USUAL_SIZE];
- String buf(buf_holder, sizeof(buf_holder), &my_charset_latin1);
String *result= item->val_str(str);
if (!result)
return NULL;
- buf.append('_');
- buf.append(result->charset()->csname);
- buf.append('\'');
- buf.append(*result);
- buf.append('\'');
- str->copy(buf);
-
- return str;
+ {
+ char buf_holder[STRING_BUFFER_USUAL_SIZE];
+ String buf(buf_holder, sizeof(buf_holder), result->charset());
+
+ /* We must reset length of the buffer, because of String specificity. */
+ buf.length(0);
+
+ buf.append('_');
+ buf.append(result->charset()->csname);
+ buf.append('\'');
+ buf.append(*result);
+ buf.append('\'');
+ str->copy(buf);
+
+ return str;
+ }
}
case ROW_RESULT:
@@ -389,6 +395,23 @@ sp_name_current_db_new(THD *thd, LEX_STRING name)
return qname;
}
+/*
+ Check that the name 'ident' is ok. It's assumed to be an 'ident'
+ from the parser, so we only have to check length and trailing spaces.
+ The former is a standard requirement (and 'show status' assumes a
+ non-empty name), the latter is a mysql:ism as trailing spaces are
+ removed by get_field().
+
+ RETURN
+ TRUE - bad name
+ FALSE - name is ok
+*/
+
+bool
+check_routine_name(LEX_STRING ident)
+{
+ return (!ident.str || !ident.str[0] || ident.str[ident.length-1] == ' ');
+}
/* ------------------------------------------------------------------ */
@@ -3083,9 +3106,16 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp)
void
sp_instr_set_case_expr::print(String *str)
{
- str->append(STRING_WITH_LEN("set_case_expr "));
+ const char CASE_EXPR_TAG[]= "set_case_expr ";
+ const int CASE_EXPR_TAG_LEN= sizeof(CASE_EXPR_TAG) - 1;
+ const int INT_STRING_MAX_LEN= 10;
+
+ /* We must call reserve(), because qs_append() doesn't care about memory. */
+ str->reserve(CASE_EXPR_TAG_LEN + INT_STRING_MAX_LEN + 2);
+
+ str->qs_append(CASE_EXPR_TAG, CASE_EXPR_TAG_LEN);
str->qs_append(m_case_expr_id);
- str->append(' ');
+ str->qs_append(' ');
m_case_expr->print(str);
}
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 37ab486c6f3..c4b6cb36090 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -103,6 +103,8 @@ public:
sp_name *
sp_name_current_db_new(THD *thd, LEX_STRING name);
+bool
+check_routine_name(LEX_STRING name);
class sp_head :private Query_arena
{
diff --git a/sql/spatial.h b/sql/spatial.h
index 4253689c078..527dc750bdc 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -142,7 +142,7 @@ struct MBR
bool inner_point(double x, double y) const
{
/* The following should be safe, even if we compare doubles */
- return (xmin<x) && (xmax>x) && (ymin<y) && (ymax>x);
+ return (xmin<x) && (xmax>x) && (ymin<y) && (ymax>y);
}
int overlaps(const MBR *mbr)
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 10599729672..cfcdd6d9e61 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1001,7 +1001,7 @@ bool acl_getroot_no_password(Security_context *sctx, char *user, char *host,
{
if (compare_hostname(&acl_db->host, host, ip))
{
- if (!acl_db->db || (db && !strcmp(acl_db->db, db)))
+ if (!acl_db->db || (db && !wild_compare(db, acl_db->db, 0)))
{
sctx->db_access= acl_db->access;
break;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index b66e617c06e..cb080ba68e0 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2120,6 +2120,8 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
were closed in the end of previous prepare or execute call.
*/
tables->table= 0;
+ /* Reset is_schema_table_processed value(needed for I_S tables */
+ tables->is_schema_table_processed= FALSE;
if (tables->prep_on_expr)
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 47f970a4f82..47aa53d25e2 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -9117,7 +9117,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list)
field++;
}
- *field= NULL; /* mark the end of the list */
+ *field= NULL; /* mark the end of the list */
share->blob_field[blob_count]= 0; /* mark the end of the list */
share->blob_fields= blob_count;
@@ -11659,6 +11659,12 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
goto err;
}
}
+
+ /* Fill schema tables with data before filesort if it's necessary */
+ if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&
+ get_schema_tables_result(join))
+ goto err;
+
if (table->s->tmp_table)
table->file->info(HA_STATUS_VARIABLE); // Get record count
table->sort.found_records=filesort(thd, table,sortorder, length,
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index b381c6198c0..d30ce8d6b59 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4550,7 +4550,16 @@ bool get_schema_tables_result(JOIN *join)
TABLE_LIST *table_list= tab->table->pos_in_table_list;
if (table_list->schema_table && thd->fill_derived_tables())
{
- if (&lex->unit != lex->current_select->master_unit()) // is subselect
+ bool is_subselect= (&lex->unit != lex->current_select->master_unit());
+ /*
+ The schema table is already processed and
+ the statement is not a subselect.
+ So we don't need to handle this table again.
+ */
+ if (table_list->is_schema_table_processed && !is_subselect)
+ continue;
+
+ if (is_subselect) // is subselect
{
table_list->table->file->extra(HA_EXTRA_RESET_STATE);
table_list->table->file->delete_all_rows();
@@ -4563,6 +4572,7 @@ bool get_schema_tables_result(JOIN *join)
if (table_list->schema_table->fill_table(thd, table_list,
tab->select_cond))
result= 1;
+ table_list->is_schema_table_processed= TRUE;
}
}
thd->no_warnings_for_error= 0;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a116dc27891..f83d7b28d6f 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1642,11 +1642,26 @@ clear_privileges:
sp_name:
ident '.' ident
{
+ if (!$1.str || check_db_name($1.str))
+ {
+ my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
+ YYABORT;
+ }
+ if (check_routine_name($3))
+ {
+ my_error(ER_SP_WRONG_NAME, MYF(0), $3.str);
+ YYABORT;
+ }
$$= new sp_name($1, $3);
$$->init_qname(YYTHD);
}
| ident
{
+ if (check_routine_name($1))
+ {
+ my_error(ER_SP_WRONG_NAME, MYF(0), $1.str);
+ YYABORT;
+ }
$$= sp_name_current_db_new(YYTHD, $1);
}
;
diff --git a/sql/table.h b/sql/table.h
index bcc2f89655b..a799d4389fb 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -560,6 +560,7 @@ typedef struct st_table_list
st_select_lex_unit *derived; /* SELECT_LEX_UNIT of derived table */
ST_SCHEMA_TABLE *schema_table; /* Information_schema table */
st_select_lex *schema_select_lex;
+ bool is_schema_table_processed;
/*
True when the view field translation table is used to convert
schema table fields for backwards compatibility with SHOW command.