2011-04-15 14:02:22 +02:00
|
|
|
/* Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
|
2002-06-12 23:13:12 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2002-06-12 23:13:12 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2003-03-25 13:46:10 +01:00
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
2002-06-12 23:13:12 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
This file contains the implementation of error and warnings related
|
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
- Whenever an error or warning occurred, it pushes it to a warning list
|
|
|
|
that the user can retrieve with SHOW WARNINGS or SHOW ERRORS.
|
|
|
|
|
|
|
|
- For each statement, we return the number of warnings generated from this
|
|
|
|
command. Note that this can be different from @@warning_count as
|
|
|
|
we reset the warning list only for questions that uses a table.
|
|
|
|
This is done to allow on to do:
|
|
|
|
INSERT ...;
|
|
|
|
SELECT @@warning_count;
|
|
|
|
SHOW WARNINGS;
|
|
|
|
(If we would reset after each command, we could not retrieve the number
|
|
|
|
of warnings)
|
2002-06-12 23:13:12 +02:00
|
|
|
|
|
|
|
- When client requests the information using SHOW command, then
|
|
|
|
server processes from this list and returns back in the form of
|
|
|
|
resultset.
|
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
Supported syntaxes:
|
|
|
|
|
|
|
|
SHOW [COUNT(*)] ERRORS [LIMIT [offset,] rows]
|
|
|
|
SHOW [COUNT(*)] WARNINGS [LIMIT [offset,] rows]
|
|
|
|
SELECT @@warning_count, @@error_count;
|
2002-06-12 23:13:12 +02:00
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_priv.h"
|
|
|
|
#include "unireg.h"
|
2009-09-10 11:18:29 +02:00
|
|
|
#include "sql_error.h"
|
2005-02-22 22:42:49 +01:00
|
|
|
#include "sp_rcontext.h"
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2003-04-03 20:19:14 +02:00
|
|
|
/*
|
2009-09-10 11:18:29 +02:00
|
|
|
Design notes about MYSQL_ERROR::m_message_text.
|
|
|
|
|
|
|
|
The member MYSQL_ERROR::m_message_text contains the text associated with
|
|
|
|
an error, warning or note (which are all SQL 'conditions')
|
|
|
|
|
|
|
|
Producer of MYSQL_ERROR::m_message_text:
|
|
|
|
----------------------------------------
|
|
|
|
|
|
|
|
(#1) the server implementation itself, when invoking functions like
|
|
|
|
my_error() or push_warning()
|
|
|
|
|
|
|
|
(#2) user code in stored programs, when using the SIGNAL statement.
|
|
|
|
|
|
|
|
(#3) user code in stored programs, when using the RESIGNAL statement.
|
|
|
|
|
|
|
|
When invoking my_error(), the error number and message is typically
|
|
|
|
provided like this:
|
|
|
|
- my_error(ER_WRONG_DB_NAME, MYF(0), ...);
|
|
|
|
- my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
|
|
|
|
|
|
|
|
In both cases, the message is retrieved from ER(ER_XXX), which in turn
|
|
|
|
is read from the resource file errmsg.sys at server startup.
|
|
|
|
The strings stored in the errmsg.sys file are expressed in the character set
|
|
|
|
that corresponds to the server --language start option
|
|
|
|
(see error_message_charset_info).
|
|
|
|
|
|
|
|
When executing:
|
|
|
|
- a SIGNAL statement,
|
|
|
|
- a RESIGNAL statement,
|
|
|
|
the message text is provided by the user logic, and is expressed in UTF8.
|
|
|
|
|
|
|
|
Storage of MYSQL_ERROR::m_message_text:
|
|
|
|
---------------------------------------
|
|
|
|
|
|
|
|
(#4) The class MYSQL_ERROR is used to hold the message text member.
|
|
|
|
This class represents a single SQL condition.
|
|
|
|
|
|
|
|
(#5) The class Warning_info represents a SQL condition area, and contains
|
|
|
|
a collection of SQL conditions in the Warning_info::m_warn_list
|
|
|
|
|
|
|
|
Consumer of MYSQL_ERROR::m_message_text:
|
|
|
|
----------------------------------------
|
|
|
|
|
|
|
|
(#6) The statements SHOW WARNINGS and SHOW ERRORS display the content of
|
|
|
|
the warning list.
|
|
|
|
|
|
|
|
(#7) The GET DIAGNOSTICS statement (planned, not implemented yet) will
|
|
|
|
also read the content of:
|
|
|
|
- the top level statement condition area (when executed in a query),
|
|
|
|
- a sub statement (when executed in a stored program)
|
|
|
|
and return the data stored in a MYSQL_ERROR.
|
|
|
|
|
|
|
|
(#8) The RESIGNAL statement reads the MYSQL_ERROR caught by an exception
|
|
|
|
handler, to raise a new or modified condition (in #3).
|
|
|
|
|
|
|
|
The big picture
|
|
|
|
---------------
|
|
|
|
--------------
|
|
|
|
| ^
|
|
|
|
V |
|
|
|
|
my_error(#1) SIGNAL(#2) RESIGNAL(#3) |
|
|
|
|
|(#A) |(#B) |(#C) |
|
|
|
|
| | | |
|
|
|
|
----------------------------|---------------------------- |
|
|
|
|
| |
|
|
|
|
V |
|
|
|
|
MYSQL_ERROR(#4) |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
V |
|
|
|
|
Warning_info(#5) |
|
|
|
|
| |
|
|
|
|
----------------------------------------------------- |
|
|
|
|
| | | |
|
|
|
|
| | | |
|
|
|
|
| | | |
|
|
|
|
V V V |
|
|
|
|
SHOW WARNINGS(#6) GET DIAGNOSTICS(#7) RESIGNAL(#8) |
|
|
|
|
| | | | |
|
|
|
|
| -------- | V |
|
|
|
|
| | | --------------
|
|
|
|
V | |
|
|
|
|
Connectors | |
|
|
|
|
| | |
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
|
V
|
|
|
|
Client application
|
|
|
|
|
|
|
|
Current implementation status
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
(#1) (my_error) produces data in the 'error_message_charset_info' CHARSET
|
|
|
|
|
|
|
|
(#2) and (#3) (SIGNAL, RESIGNAL) produces data internally in UTF8
|
|
|
|
|
|
|
|
(#6) (SHOW WARNINGS) produces data in the 'error_message_charset_info' CHARSET
|
|
|
|
|
|
|
|
(#7) (GET DIAGNOSTICS) is not implemented.
|
|
|
|
|
|
|
|
(#8) (RESIGNAL) produces data internally in UTF8 (see #3)
|
|
|
|
|
|
|
|
As a result, the design choice for (#4) and (#5) is to store data in
|
|
|
|
the 'error_message_charset_info' CHARSET, to minimize impact on the code base.
|
|
|
|
This is implemented by using 'String MYSQL_ERROR::m_message_text'.
|
|
|
|
|
|
|
|
The UTF8 -> error_message_charset_info conversion is implemented in
|
|
|
|
Signal_common::eval_signal_informations() (for path #B and #C).
|
|
|
|
|
|
|
|
Future work
|
|
|
|
-----------
|
|
|
|
|
|
|
|
- Change (#1) (my_error) to generate errors in UTF8.
|
|
|
|
See WL#751 (Recoding of error messages)
|
|
|
|
|
|
|
|
- Change (#4 and #5) to store message text in UTF8 natively.
|
|
|
|
In practice, this means changing the type of the message text to
|
|
|
|
'<UTF8 String 128 class> MYSQL_ERROR::m_message_text', and is a direct
|
|
|
|
consequence of WL#751.
|
|
|
|
|
|
|
|
- Implement (#9) (GET DIAGNOSTICS).
|
|
|
|
See WL#2111 (Stored Procedures: Implement GET DIAGNOSTICS)
|
2003-04-03 20:19:14 +02:00
|
|
|
*/
|
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
MYSQL_ERROR::MYSQL_ERROR()
|
|
|
|
: Sql_alloc(),
|
|
|
|
m_class_origin((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_subclass_origin((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_constraint_catalog((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_constraint_schema((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_constraint_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_catalog_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_schema_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_table_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_column_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_cursor_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_message_text(),
|
|
|
|
m_sql_errno(0),
|
|
|
|
m_level(MYSQL_ERROR::WARN_LEVEL_ERROR),
|
|
|
|
m_mem_root(NULL)
|
2003-04-03 20:19:14 +02:00
|
|
|
{
|
2009-09-10 11:18:29 +02:00
|
|
|
memset(m_returned_sqlstate, 0, sizeof(m_returned_sqlstate));
|
2003-04-03 20:19:14 +02:00
|
|
|
}
|
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
void MYSQL_ERROR::init(MEM_ROOT *mem_root)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(mem_root != NULL);
|
|
|
|
DBUG_ASSERT(m_mem_root == NULL);
|
|
|
|
m_mem_root= mem_root;
|
|
|
|
}
|
2003-04-03 20:19:14 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
void MYSQL_ERROR::clear()
|
|
|
|
{
|
|
|
|
m_class_origin.length(0);
|
|
|
|
m_subclass_origin.length(0);
|
|
|
|
m_constraint_catalog.length(0);
|
|
|
|
m_constraint_schema.length(0);
|
|
|
|
m_constraint_name.length(0);
|
|
|
|
m_catalog_name.length(0);
|
|
|
|
m_schema_name.length(0);
|
|
|
|
m_table_name.length(0);
|
|
|
|
m_column_name.length(0);
|
|
|
|
m_cursor_name.length(0);
|
|
|
|
m_message_text.length(0);
|
|
|
|
m_sql_errno= 0;
|
|
|
|
m_level= MYSQL_ERROR::WARN_LEVEL_ERROR;
|
|
|
|
}
|
2002-11-21 01:07:14 +01:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
MYSQL_ERROR::MYSQL_ERROR(MEM_ROOT *mem_root)
|
|
|
|
: Sql_alloc(),
|
|
|
|
m_class_origin((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_subclass_origin((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_constraint_catalog((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_constraint_schema((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_constraint_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_catalog_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_schema_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_table_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_column_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_cursor_name((const char*) NULL, 0, & my_charset_utf8_bin),
|
|
|
|
m_message_text(),
|
|
|
|
m_sql_errno(0),
|
|
|
|
m_level(MYSQL_ERROR::WARN_LEVEL_ERROR),
|
|
|
|
m_mem_root(mem_root)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(mem_root != NULL);
|
|
|
|
memset(m_returned_sqlstate, 0, sizeof(m_returned_sqlstate));
|
|
|
|
}
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
static void copy_string(MEM_ROOT *mem_root, String* dst, const String* src)
|
2002-10-02 12:33:08 +02:00
|
|
|
{
|
2009-09-10 11:18:29 +02:00
|
|
|
size_t len= src->length();
|
|
|
|
if (len)
|
2002-11-21 01:07:14 +01:00
|
|
|
{
|
2009-09-10 11:18:29 +02:00
|
|
|
char* copy= (char*) alloc_root(mem_root, len + 1);
|
|
|
|
if (copy)
|
|
|
|
{
|
|
|
|
memcpy(copy, src->ptr(), len);
|
|
|
|
copy[len]= '\0';
|
|
|
|
dst->set(copy, len, src->charset());
|
|
|
|
}
|
2002-11-21 01:07:14 +01:00
|
|
|
}
|
2009-09-10 11:18:29 +02:00
|
|
|
else
|
|
|
|
dst->length(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MYSQL_ERROR::copy_opt_attributes(const MYSQL_ERROR *cond)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(this != cond);
|
|
|
|
copy_string(m_mem_root, & m_class_origin, & cond->m_class_origin);
|
|
|
|
copy_string(m_mem_root, & m_subclass_origin, & cond->m_subclass_origin);
|
|
|
|
copy_string(m_mem_root, & m_constraint_catalog, & cond->m_constraint_catalog);
|
|
|
|
copy_string(m_mem_root, & m_constraint_schema, & cond->m_constraint_schema);
|
|
|
|
copy_string(m_mem_root, & m_constraint_name, & cond->m_constraint_name);
|
|
|
|
copy_string(m_mem_root, & m_catalog_name, & cond->m_catalog_name);
|
|
|
|
copy_string(m_mem_root, & m_schema_name, & cond->m_schema_name);
|
|
|
|
copy_string(m_mem_root, & m_table_name, & cond->m_table_name);
|
|
|
|
copy_string(m_mem_root, & m_column_name, & cond->m_column_name);
|
|
|
|
copy_string(m_mem_root, & m_cursor_name, & cond->m_cursor_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MYSQL_ERROR::set(uint sql_errno, const char* sqlstate,
|
|
|
|
MYSQL_ERROR::enum_warning_level level, const char* msg)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(sql_errno != 0);
|
|
|
|
DBUG_ASSERT(sqlstate != NULL);
|
|
|
|
DBUG_ASSERT(msg != NULL);
|
|
|
|
|
|
|
|
m_sql_errno= sql_errno;
|
|
|
|
memcpy(m_returned_sqlstate, sqlstate, SQLSTATE_LENGTH);
|
|
|
|
m_returned_sqlstate[SQLSTATE_LENGTH]= '\0';
|
|
|
|
|
|
|
|
set_builtin_message_text(msg);
|
|
|
|
m_level= level;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MYSQL_ERROR::set_builtin_message_text(const char* str)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
See the comments
|
|
|
|
"Design notes about MYSQL_ERROR::m_message_text."
|
|
|
|
*/
|
|
|
|
const char* copy;
|
|
|
|
|
|
|
|
copy= strdup_root(m_mem_root, str);
|
|
|
|
m_message_text.set(copy, strlen(copy), error_message_charset_info);
|
|
|
|
DBUG_ASSERT(! m_message_text.is_alloced());
|
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
MYSQL_ERROR::get_message_text() const
|
|
|
|
{
|
|
|
|
return m_message_text.ptr();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
MYSQL_ERROR::get_message_octet_length() const
|
|
|
|
{
|
|
|
|
return m_message_text.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MYSQL_ERROR::set_sqlstate(const char* sqlstate)
|
|
|
|
{
|
|
|
|
memcpy(m_returned_sqlstate, sqlstate, SQLSTATE_LENGTH);
|
|
|
|
m_returned_sqlstate[SQLSTATE_LENGTH]= '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Clear this diagnostics area.
|
|
|
|
|
|
|
|
Normally called at the end of a statement.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
Diagnostics_area::reset_diagnostics_area()
|
|
|
|
{
|
|
|
|
DBUG_ENTER("reset_diagnostics_area");
|
|
|
|
#ifdef DBUG_OFF
|
|
|
|
can_overwrite_status= FALSE;
|
|
|
|
/** Don't take chances in production */
|
|
|
|
m_message[0]= '\0';
|
|
|
|
m_sql_errno= 0;
|
|
|
|
m_affected_rows= 0;
|
|
|
|
m_last_insert_id= 0;
|
|
|
|
m_statement_warn_count= 0;
|
|
|
|
#endif
|
|
|
|
is_sent= FALSE;
|
|
|
|
/** Tiny reset in debug mode to see garbage right away */
|
|
|
|
m_status= DA_EMPTY;
|
2003-03-19 20:23:13 +01:00
|
|
|
DBUG_VOID_RETURN;
|
2002-06-12 23:13:12 +02:00
|
|
|
}
|
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
/**
|
|
|
|
Set OK status -- ends commands that do not return a
|
|
|
|
result set, e.g. INSERT/UPDATE/DELETE.
|
|
|
|
*/
|
2002-10-02 12:33:08 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
void
|
|
|
|
Diagnostics_area::set_ok_status(THD *thd, ulonglong affected_rows_arg,
|
|
|
|
ulonglong last_insert_id_arg,
|
|
|
|
const char *message_arg)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("set_ok_status");
|
|
|
|
DBUG_ASSERT(! is_set());
|
|
|
|
/*
|
|
|
|
In production, refuse to overwrite an error or a custom response
|
|
|
|
with an OK packet.
|
|
|
|
*/
|
|
|
|
if (is_error() || is_disabled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_statement_warn_count= thd->warning_info->statement_warn_count();
|
|
|
|
m_affected_rows= affected_rows_arg;
|
|
|
|
m_last_insert_id= last_insert_id_arg;
|
|
|
|
if (message_arg)
|
|
|
|
strmake(m_message, message_arg, sizeof(m_message) - 1);
|
|
|
|
else
|
|
|
|
m_message[0]= '\0';
|
|
|
|
m_status= DA_OK;
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set EOF status.
|
2002-06-12 23:13:12 +02:00
|
|
|
*/
|
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
void
|
|
|
|
Diagnostics_area::set_eof_status(THD *thd)
|
2002-10-02 12:33:08 +02:00
|
|
|
{
|
2009-09-10 11:18:29 +02:00
|
|
|
DBUG_ENTER("set_eof_status");
|
|
|
|
/* Only allowed to report eof if has not yet reported an error */
|
|
|
|
DBUG_ASSERT(! is_set());
|
|
|
|
/*
|
|
|
|
In production, refuse to overwrite an error or a custom response
|
|
|
|
with an EOF packet.
|
|
|
|
*/
|
|
|
|
if (is_error() || is_disabled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
If inside a stored procedure, do not return the total
|
|
|
|
number of warnings, since they are not available to the client
|
|
|
|
anyway.
|
|
|
|
*/
|
|
|
|
m_statement_warn_count= (thd->spcont ?
|
|
|
|
0 : thd->warning_info->statement_warn_count());
|
|
|
|
|
|
|
|
m_status= DA_EOF;
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
2005-02-21 18:40:28 +01:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
/**
|
|
|
|
Set ERROR status.
|
|
|
|
*/
|
2008-10-06 22:36:15 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
void
|
|
|
|
Diagnostics_area::set_error_status(THD *thd, uint sql_errno_arg,
|
|
|
|
const char *message_arg,
|
|
|
|
const char *sqlstate)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("set_error_status");
|
|
|
|
/*
|
|
|
|
Only allowed to report error if has not yet reported a success
|
|
|
|
The only exception is when we flush the message to the client,
|
|
|
|
an error can happen during the flush.
|
|
|
|
*/
|
|
|
|
DBUG_ASSERT(! is_set() || can_overwrite_status);
|
|
|
|
#ifdef DBUG_OFF
|
|
|
|
/*
|
|
|
|
In production, refuse to overwrite a custom response with an
|
|
|
|
ERROR packet.
|
|
|
|
*/
|
|
|
|
if (is_disabled())
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (sqlstate == NULL)
|
|
|
|
sqlstate= mysql_errno_to_sqlstate(sql_errno_arg);
|
|
|
|
|
|
|
|
m_sql_errno= sql_errno_arg;
|
|
|
|
memcpy(m_sqlstate, sqlstate, SQLSTATE_LENGTH);
|
|
|
|
m_sqlstate[SQLSTATE_LENGTH]= '\0';
|
|
|
|
strmake(m_message, message_arg, sizeof(m_message)-1);
|
|
|
|
|
|
|
|
m_status= DA_ERROR;
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
2005-02-21 18:40:28 +01:00
|
|
|
|
2005-02-22 22:42:49 +01:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
/**
|
|
|
|
Mark the diagnostics area as 'DISABLED'.
|
|
|
|
|
|
|
|
This is used in rare cases when the COM_ command at hand sends a response
|
|
|
|
in a custom format. One example is the query cache, another is
|
|
|
|
COM_STMT_PREPARE.
|
|
|
|
*/
|
2005-04-04 23:32:48 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
void
|
|
|
|
Diagnostics_area::disable_status()
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(! is_set());
|
|
|
|
m_status= DA_DISABLED;
|
|
|
|
}
|
2005-04-04 23:32:48 +02:00
|
|
|
|
2011-04-15 14:02:22 +02:00
|
|
|
Warning_info::Warning_info(ulonglong warn_id_arg, bool allow_unlimited_warnings)
|
2009-09-10 11:18:29 +02:00
|
|
|
:m_statement_warn_count(0),
|
|
|
|
m_current_row_for_warning(1),
|
|
|
|
m_warn_id(warn_id_arg),
|
2011-04-15 14:02:22 +02:00
|
|
|
m_allow_unlimited_warnings(allow_unlimited_warnings),
|
2009-09-10 11:18:29 +02:00
|
|
|
m_read_only(FALSE)
|
|
|
|
{
|
|
|
|
/* Initialize sub structures */
|
|
|
|
init_sql_alloc(&m_warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
|
|
|
|
m_warn_list.empty();
|
|
|
|
bzero((char*) m_warn_count, sizeof(m_warn_count));
|
|
|
|
}
|
2005-04-04 23:32:48 +02:00
|
|
|
|
2002-11-21 01:07:14 +01:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
Warning_info::~Warning_info()
|
|
|
|
{
|
|
|
|
free_root(&m_warn_root,MYF(0));
|
|
|
|
}
|
WL#3984 (Revise locking of mysql.general_log and mysql.slow_log)
Bug#25422 (Hang with log tables)
Bug 17876 (Truncating mysql.slow_log in a SP after using cursor locks the
thread)
Bug 23044 (Warnings on flush of a log table)
Bug 29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
a deadlock)
Prior to this fix, the server would hang when performing concurrent
ALTER TABLE or TRUNCATE TABLE statements against the LOG TABLES,
which are mysql.general_log and mysql.slow_log.
The root cause traces to the following code:
in sql_base.cc, open_table()
if (table->in_use != thd)
{
/* wait_for_condition will unlock LOCK_open for us */
wait_for_condition(thd, &LOCK_open, &COND_refresh);
}
The problem with this code is that the current implementation of the
LOGGER creates 'fake' THD objects, like
- Log_to_csv_event_handler::general_log_thd
- Log_to_csv_event_handler::slow_log_thd
which are not associated to a real thread running in the server,
so that waiting for these non-existing threads to release table locks
cause the dead lock.
In general, the design of Log_to_csv_event_handler does not fit into the
general architecture of the server, so that the concept of general_log_thd
and slow_log_thd has to be abandoned:
- this implementation does not work with table locking
- it will not work with commands like SHOW PROCESSLIST
- having the log tables always opened does not integrate well with DDL
operations / FLUSH TABLES / SET GLOBAL READ_ONLY
With this patch, the fundamental design of the LOGGER has been changed to:
- always open and close a log table when writing a log
- remove totally the usage of fake THD objects
- clarify how locking of log tables is implemented in general.
See WL#3984 for details related to the new locking design.
Additional changes (misc bugs exposed and fixed):
1)
mysqldump which would ignore some tables in dump_all_tables_in_db(),
but forget to ignore the same in dump_all_views_in_db().
2)
mysqldump would also issue an empty "LOCK TABLE" command when all the tables
to lock are to be ignored (numrows == 0), instead of not issuing the query.
3)
Internal errors handlers could intercept errors but not warnings
(see sql_error.cc).
4)
Implementing a nested call to open tables, for the performance schema tables,
exposed an existing bug in remove_table_from_cache(), which would perform:
in_use->some_tables_deleted=1;
against another thread, without any consideration about thread locking.
This call inside remove_table_from_cache() was not required anyway,
since calling mysql_lock_abort() takes care of aborting -- cleanly -- threads
that might hold a lock on a table.
This line (in_use->some_tables_deleted=1) has been removed.
sql/handler.cc:
Moved logic for system / log tables in the SQL layer.
sql/handler.h:
Moved logic for system / log tables in the SQL layer.
sql/lock.cc:
Revised locking of log tables
sql/log.cc:
Major cleanup: changed how log tables are locked / written to.
sql/log.h:
Major cleanup: changed how log tables are locked / written to.
sql/mysql_priv.h:
performance schema helpers
sql/slave.cc:
open_ltable() lock flags
sql/sp.cc:
open_ltable() lock flags
sql/sql_acl.cc:
open_ltable() lock flags
sql/sql_class.h:
performance schema helpers
sql/sql_delete.cc:
log tables cleanup in TRUNCATE
sql/sql_error.cc:
Internal handlers can also intercept warnings
sql/sql_insert.cc:
open_ltable() lock flags
sql/sql_parse.cc:
performance schema helpers
sql/sql_plugin.cc:
open_ltable() lock flags
sql/sql_rename.cc:
log tables cleanup in RENAME
sql/sql_servers.cc:
open_ltable() lock flags
sql/sql_show.cc:
Move INFORMATION_SCHEMA_NAME to table.cc
sql/sql_table.cc:
log tables cleanup (admin operations, ALTER TABLE)
sql/sql_udf.cc:
open_ltable() lock flags
sql/table.cc:
Implemented TABLE_CATEGORY.
sql/share/errmsg.txt:
Changed the wording and name of ER_CANT_READ_LOCK_LOG_TABLE
sql/table.h:
Implemented TABLE_CATEGORY.
storage/csv/ha_tina.cc:
Moved logic for system / log tables in the SQL layer.
storage/csv/ha_tina.h:
Moved logic for system / log tables in the SQL layer.
storage/myisam/ha_myisam.cc:
Moved logic for system / log tables in the SQL layer.
storage/myisam/ha_myisam.h:
Moved logic for system / log tables in the SQL layer.
client/mysqldump.c:
Don't lock tables in the ignore list.
Don't issue empty LOCK TABLES queries.
sql/sql_base.cc:
log tables cleanup
performance schema helpers
mysql-test/r/ps.result:
Adjust test results
mysql-test/r/show_check.result:
Adjust test results
mysql-test/r/status.result:
Adjust test results
mysql-test/t/log_state.test:
Added tests for Bug#29129
mysql-test/t/ps.test:
Make the test output deterministic
mysql-test/t/show_check.test:
Make the test output deterministic
mysql-test/r/log_state.result:
Changed the default location of the log output to LOG_FILE,
for backward compatibility with MySQL 5.0
---
Adjust test results
mysql-test/r/log_tables.result:
cleanup for -ps-protocol
mysql-test/t/log_tables.test:
cleanup for -ps-protocol
sql/set_var.cc:
Changed the default location of the log output to LOG_FILE,
for backward compatibility with MySQL 5.0
---
log tables cleanup
2007-07-27 08:31:06 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Reset the warning information of this connection.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void Warning_info::clear_warning_info(ulonglong warn_id_arg)
|
|
|
|
{
|
|
|
|
m_warn_id= warn_id_arg;
|
|
|
|
free_root(&m_warn_root, MYF(0));
|
|
|
|
bzero((char*) m_warn_count, sizeof(m_warn_count));
|
|
|
|
m_warn_list.empty();
|
|
|
|
m_statement_warn_count= 0;
|
|
|
|
m_current_row_for_warning= 1; /* Start counting from the first row */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Append warnings only if the original contents of the routine
|
|
|
|
warning info was replaced.
|
|
|
|
*/
|
|
|
|
void Warning_info::merge_with_routine_info(THD *thd, Warning_info *source)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
If a routine body is empty or if a routine did not
|
|
|
|
generate any warnings (thus m_warn_id didn't change),
|
|
|
|
do not duplicate our own contents by appending the
|
|
|
|
contents of the called routine. We know that the called
|
|
|
|
routine did not change its warning info.
|
|
|
|
|
|
|
|
On the other hand, if the routine body is not empty and
|
|
|
|
some statement in the routine generates a warning or
|
|
|
|
uses tables, m_warn_id is guaranteed to have changed.
|
|
|
|
In this case we know that the routine warning info
|
|
|
|
contains only new warnings, and thus we perform a copy.
|
|
|
|
*/
|
|
|
|
if (m_warn_id != source->m_warn_id)
|
2005-04-04 23:32:48 +02:00
|
|
|
{
|
2009-09-10 11:18:29 +02:00
|
|
|
/*
|
|
|
|
If the invocation of the routine was a standalone statement,
|
|
|
|
rather than a sub-statement, in other words, if it's a CALL
|
|
|
|
of a procedure, rather than invocation of a function or a
|
|
|
|
trigger, we need to clear the current contents of the caller's
|
|
|
|
warning info.
|
|
|
|
|
|
|
|
This is per MySQL rules: if a statement generates a warning,
|
|
|
|
warnings from the previous statement are flushed. Normally
|
|
|
|
it's done in push_warning(). However, here we don't use
|
|
|
|
push_warning() to avoid invocation of condition handlers or
|
|
|
|
escalation of warnings to errors.
|
|
|
|
*/
|
|
|
|
opt_clear_warning_info(thd->query_id);
|
|
|
|
append_warning_info(thd, source);
|
2005-04-04 23:32:48 +02:00
|
|
|
}
|
2009-09-10 11:18:29 +02:00
|
|
|
}
|
2005-06-27 23:52:21 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
/**
|
|
|
|
Add a warning to the list of warnings. Increment the respective
|
|
|
|
counters.
|
|
|
|
*/
|
|
|
|
MYSQL_ERROR *Warning_info::push_warning(THD *thd,
|
|
|
|
uint sql_errno, const char* sqlstate,
|
|
|
|
MYSQL_ERROR::enum_warning_level level,
|
|
|
|
const char *msg)
|
|
|
|
{
|
|
|
|
MYSQL_ERROR *cond= NULL;
|
2005-04-04 23:32:48 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
if (! m_read_only)
|
2002-06-12 23:13:12 +02:00
|
|
|
{
|
2011-04-15 14:02:22 +02:00
|
|
|
if (m_allow_unlimited_warnings ||
|
|
|
|
m_warn_list.elements < thd->variables.max_error_count)
|
2009-09-10 11:18:29 +02:00
|
|
|
{
|
|
|
|
cond= new (& m_warn_root) MYSQL_ERROR(& m_warn_root);
|
|
|
|
if (cond)
|
|
|
|
{
|
|
|
|
cond->set(sql_errno, sqlstate, level, msg);
|
|
|
|
m_warn_list.push_back(cond, &m_warn_root);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_warn_count[(uint) level]++;
|
2002-06-12 23:13:12 +02:00
|
|
|
}
|
2009-09-10 11:18:29 +02:00
|
|
|
|
|
|
|
m_statement_warn_count++;
|
|
|
|
return cond;
|
2002-06-12 23:13:12 +02:00
|
|
|
}
|
|
|
|
|
2011-04-15 14:02:22 +02:00
|
|
|
MYSQL_ERROR *Warning_info::push_warning(THD *thd, const MYSQL_ERROR *sql_condition)
|
|
|
|
{
|
|
|
|
MYSQL_ERROR *new_condition= push_warning(thd,
|
|
|
|
sql_condition->get_sql_errno(),
|
|
|
|
sql_condition->get_sqlstate(),
|
|
|
|
sql_condition->get_level(),
|
|
|
|
sql_condition->get_message_text());
|
|
|
|
|
|
|
|
if (new_condition)
|
|
|
|
new_condition->copy_opt_attributes(sql_condition);
|
|
|
|
|
|
|
|
return new_condition;
|
|
|
|
}
|
|
|
|
|
2002-12-04 12:19:08 +01:00
|
|
|
/*
|
2009-09-10 11:18:29 +02:00
|
|
|
Push the warning to error list if there is still room in the list
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
push_warning()
|
|
|
|
thd Thread handle
|
|
|
|
level Severity of warning (note, warning)
|
|
|
|
code Error number
|
|
|
|
msg Clear error message
|
|
|
|
*/
|
|
|
|
|
|
|
|
void push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
|
|
|
|
uint code, const char *msg)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("push_warning");
|
|
|
|
DBUG_PRINT("enter", ("code: %d, msg: %s", code, msg));
|
|
|
|
|
|
|
|
/*
|
2010-07-20 13:57:02 +02:00
|
|
|
Calling push_warning/push_warning_printf with a level of
|
|
|
|
WARN_LEVEL_ERROR *is* a bug. Either use my_printf_error(),
|
|
|
|
my_error(), or WARN_LEVEL_WARN.
|
2009-09-10 11:18:29 +02:00
|
|
|
*/
|
2010-07-20 13:57:02 +02:00
|
|
|
DBUG_ASSERT(level != MYSQL_ERROR::WARN_LEVEL_ERROR);
|
2009-09-10 11:18:29 +02:00
|
|
|
|
|
|
|
if (level == MYSQL_ERROR::WARN_LEVEL_ERROR)
|
|
|
|
level= MYSQL_ERROR::WARN_LEVEL_WARN;
|
|
|
|
|
|
|
|
(void) thd->raise_condition(code, NULL, level, msg);
|
|
|
|
|
2010-11-03 22:40:53 +01:00
|
|
|
/* Make sure we also count warnings pushed after calling set_ok_status(). */
|
2010-11-25 18:17:28 +01:00
|
|
|
thd->stmt_da->increment_warning();
|
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Push the warning to error list if there is still room in the list
|
2003-01-06 00:48:59 +01:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
push_warning_printf()
|
|
|
|
thd Thread handle
|
2009-09-10 11:18:29 +02:00
|
|
|
level Severity of warning (note, warning)
|
2003-01-06 00:48:59 +01:00
|
|
|
code Error number
|
|
|
|
msg Clear error message
|
2002-12-04 12:19:08 +01:00
|
|
|
*/
|
|
|
|
|
2003-01-06 00:48:59 +01:00
|
|
|
void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
|
|
|
|
uint code, const char *format, ...)
|
2002-12-04 12:19:08 +01:00
|
|
|
{
|
|
|
|
va_list args;
|
2009-02-05 07:16:00 +01:00
|
|
|
char warning[MYSQL_ERRMSG_SIZE];
|
2003-01-06 00:48:59 +01:00
|
|
|
DBUG_ENTER("push_warning_printf");
|
|
|
|
DBUG_PRINT("enter",("warning: %u", code));
|
2008-10-06 22:36:15 +02:00
|
|
|
|
|
|
|
DBUG_ASSERT(code != 0);
|
|
|
|
DBUG_ASSERT(format != NULL);
|
|
|
|
|
2003-01-06 00:48:59 +01:00
|
|
|
va_start(args,format);
|
2009-10-15 14:23:43 +02:00
|
|
|
my_vsnprintf_ex(&my_charset_utf8_general_ci, warning,
|
|
|
|
sizeof(warning), format, args);
|
2002-12-04 12:19:08 +01:00
|
|
|
va_end(args);
|
2003-01-06 00:48:59 +01:00
|
|
|
push_warning(thd, level, code, warning);
|
2002-12-04 12:19:08 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
/*
|
|
|
|
Send all notes, errors or warnings to the client in a result set
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
SYNOPSIS
|
|
|
|
mysqld_show_warnings()
|
|
|
|
thd Thread handler
|
|
|
|
levels_to_show Bitmap for which levels to show
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
DESCRIPTION
|
|
|
|
Takes into account the current LIMIT
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
RETURN VALUES
|
2005-02-22 22:42:49 +01:00
|
|
|
FALSE ok
|
|
|
|
TRUE Error sending data to client
|
2002-10-02 12:33:08 +02:00
|
|
|
*/
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2006-08-17 18:13:45 +02:00
|
|
|
const LEX_STRING warning_level_names[]=
|
2006-02-10 15:02:57 +01:00
|
|
|
{
|
2006-08-17 18:13:45 +02:00
|
|
|
{ C_STRING_WITH_LEN("Note") },
|
|
|
|
{ C_STRING_WITH_LEN("Warning") },
|
|
|
|
{ C_STRING_WITH_LEN("Error") },
|
|
|
|
{ C_STRING_WITH_LEN("?") }
|
2006-02-10 15:02:57 +01:00
|
|
|
};
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2005-02-22 22:42:49 +01:00
|
|
|
bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
|
2009-09-10 11:18:29 +02:00
|
|
|
{
|
2002-06-12 23:13:12 +02:00
|
|
|
List<Item> field_list;
|
2002-11-22 19:04:42 +01:00
|
|
|
DBUG_ENTER("mysqld_show_warnings");
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
DBUG_ASSERT(thd->warning_info->is_read_only());
|
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
field_list.push_back(new Item_empty_string("Level", 7));
|
2002-12-14 16:43:01 +01:00
|
|
|
field_list.push_back(new Item_return_int("Code",4, MYSQL_TYPE_LONG));
|
2002-10-02 12:33:08 +02:00
|
|
|
field_list.push_back(new Item_empty_string("Message",MYSQL_ERRMSG_SIZE));
|
2002-06-12 23:13:12 +02:00
|
|
|
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
if (thd->protocol->send_result_set_metadata(&field_list,
|
2005-02-22 22:42:49 +01:00
|
|
|
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
|
|
|
|
DBUG_RETURN(TRUE);
|
2002-06-12 23:13:12 +02:00
|
|
|
|
2002-10-02 12:33:08 +02:00
|
|
|
MYSQL_ERROR *err;
|
2003-12-19 18:52:13 +01:00
|
|
|
SELECT_LEX *sel= &thd->lex->select_lex;
|
Patch two (the final one) for Bug#7306 "the server side preparedStatement
error for LIMIT placeholder".
The patch adds grammar support for LIMIT ?, ? and changes the
type of ST_SELECT_LEX::select_limit,offset_limit from ha_rows to Item*,
so that it can point to Item_param.
mysql-test/include/ps_modify.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/include/ps_query.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/r/ps.result:
Add basic test coverage for LIMIT ?, ? and fix test results.
mysql-test/r/ps_2myisam.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_3innodb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_4heap.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_5merge.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_6bdb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_7ndb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/t/ps.test:
Add basic test coverage for LIMIT ?, ?.
sql/item.h:
Add a short-cut for (ulonglong) val_int() to Item.
Add a constructor to Item_int() that accepts ulonglong.
Simplify Item_uint constructor by using the c-tor above.
sql/item_subselect.cc:
Now select_limit has type Item *.
We can safely create an Item in Item_exists_subselect::fix_length_and_dec():
it will be allocated in runtime memory root and freed in the end of
execution.
sql/sp_head.cc:
Add a special initalization state for stored procedures to
be able to easily distinguish the first execution of a stored procedure
from prepared statement prepare.
sql/sql_class.h:
Introduce new state 'INITIALIZED_FOR_SP' to be able to easily distinguish
the first execution of a stored procedure from prepared statement prepare.
sql/sql_derived.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace. Add a warning about use of set_limit in
mysql_derived_filling.
sql/sql_error.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace.
- this change is also aware of bug#11095 "show warnings limit 0 returns
all rows instead of zero rows", so the one who merges the bugfix from
4.1 can use local version of sql_error.cc.
sql/sql_handler.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
sql/sql_lex.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_lex.h:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_parse.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
- we can create an Item_int to set global limit of a statement:
it will be created in the runtime mem root and freed in the end of
execution.
sql/sql_repl.cc:
Use unit->set_limit to initialize limits.
sql/sql_select.cc:
- select_limit is now Item* so the proper way to check for default value
is to compare it with NULL.
sql/sql_union.cc:
Evaluate offset_limit_cnt using the new type of ST_SELECT_LEX::offset_limit
sql/sql_view.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_yacc.yy:
Add grammar support for LIMIT ?, ? clause.
2005-06-07 12:11:36 +02:00
|
|
|
SELECT_LEX_UNIT *unit= &thd->lex->unit;
|
2009-09-10 11:18:29 +02:00
|
|
|
ulonglong idx= 0;
|
2002-12-11 08:17:51 +01:00
|
|
|
Protocol *protocol=thd->protocol;
|
Patch two (the final one) for Bug#7306 "the server side preparedStatement
error for LIMIT placeholder".
The patch adds grammar support for LIMIT ?, ? and changes the
type of ST_SELECT_LEX::select_limit,offset_limit from ha_rows to Item*,
so that it can point to Item_param.
mysql-test/include/ps_modify.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/include/ps_query.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/r/ps.result:
Add basic test coverage for LIMIT ?, ? and fix test results.
mysql-test/r/ps_2myisam.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_3innodb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_4heap.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_5merge.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_6bdb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_7ndb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/t/ps.test:
Add basic test coverage for LIMIT ?, ?.
sql/item.h:
Add a short-cut for (ulonglong) val_int() to Item.
Add a constructor to Item_int() that accepts ulonglong.
Simplify Item_uint constructor by using the c-tor above.
sql/item_subselect.cc:
Now select_limit has type Item *.
We can safely create an Item in Item_exists_subselect::fix_length_and_dec():
it will be allocated in runtime memory root and freed in the end of
execution.
sql/sp_head.cc:
Add a special initalization state for stored procedures to
be able to easily distinguish the first execution of a stored procedure
from prepared statement prepare.
sql/sql_class.h:
Introduce new state 'INITIALIZED_FOR_SP' to be able to easily distinguish
the first execution of a stored procedure from prepared statement prepare.
sql/sql_derived.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace. Add a warning about use of set_limit in
mysql_derived_filling.
sql/sql_error.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace.
- this change is also aware of bug#11095 "show warnings limit 0 returns
all rows instead of zero rows", so the one who merges the bugfix from
4.1 can use local version of sql_error.cc.
sql/sql_handler.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
sql/sql_lex.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_lex.h:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_parse.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
- we can create an Item_int to set global limit of a statement:
it will be created in the runtime mem root and freed in the end of
execution.
sql/sql_repl.cc:
Use unit->set_limit to initialize limits.
sql/sql_select.cc:
- select_limit is now Item* so the proper way to check for default value
is to compare it with NULL.
sql/sql_union.cc:
Evaluate offset_limit_cnt using the new type of ST_SELECT_LEX::offset_limit
sql/sql_view.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_yacc.yy:
Add grammar support for LIMIT ?, ? clause.
2005-06-07 12:11:36 +02:00
|
|
|
|
|
|
|
unit->set_limit(sel);
|
|
|
|
|
2009-09-10 11:18:29 +02:00
|
|
|
List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
|
2002-10-02 12:33:08 +02:00
|
|
|
while ((err= it++))
|
2002-06-12 23:13:12 +02:00
|
|
|
{
|
2002-10-02 12:33:08 +02:00
|
|
|
/* Skip levels that the user is not interested in */
|
2009-09-10 11:18:29 +02:00
|
|
|
if (!(levels_to_show & ((ulong) 1 << err->get_level())))
|
2002-10-02 12:33:08 +02:00
|
|
|
continue;
|
Patch two (the final one) for Bug#7306 "the server side preparedStatement
error for LIMIT placeholder".
The patch adds grammar support for LIMIT ?, ? and changes the
type of ST_SELECT_LEX::select_limit,offset_limit from ha_rows to Item*,
so that it can point to Item_param.
mysql-test/include/ps_modify.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/include/ps_query.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/r/ps.result:
Add basic test coverage for LIMIT ?, ? and fix test results.
mysql-test/r/ps_2myisam.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_3innodb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_4heap.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_5merge.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_6bdb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_7ndb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/t/ps.test:
Add basic test coverage for LIMIT ?, ?.
sql/item.h:
Add a short-cut for (ulonglong) val_int() to Item.
Add a constructor to Item_int() that accepts ulonglong.
Simplify Item_uint constructor by using the c-tor above.
sql/item_subselect.cc:
Now select_limit has type Item *.
We can safely create an Item in Item_exists_subselect::fix_length_and_dec():
it will be allocated in runtime memory root and freed in the end of
execution.
sql/sp_head.cc:
Add a special initalization state for stored procedures to
be able to easily distinguish the first execution of a stored procedure
from prepared statement prepare.
sql/sql_class.h:
Introduce new state 'INITIALIZED_FOR_SP' to be able to easily distinguish
the first execution of a stored procedure from prepared statement prepare.
sql/sql_derived.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace. Add a warning about use of set_limit in
mysql_derived_filling.
sql/sql_error.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace.
- this change is also aware of bug#11095 "show warnings limit 0 returns
all rows instead of zero rows", so the one who merges the bugfix from
4.1 can use local version of sql_error.cc.
sql/sql_handler.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
sql/sql_lex.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_lex.h:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_parse.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
- we can create an Item_int to set global limit of a statement:
it will be created in the runtime mem root and freed in the end of
execution.
sql/sql_repl.cc:
Use unit->set_limit to initialize limits.
sql/sql_select.cc:
- select_limit is now Item* so the proper way to check for default value
is to compare it with NULL.
sql/sql_union.cc:
Evaluate offset_limit_cnt using the new type of ST_SELECT_LEX::offset_limit
sql/sql_view.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_yacc.yy:
Add grammar support for LIMIT ?, ? clause.
2005-06-07 12:11:36 +02:00
|
|
|
if (++idx <= unit->offset_limit_cnt)
|
2002-10-02 12:33:08 +02:00
|
|
|
continue;
|
Patch two (the final one) for Bug#7306 "the server side preparedStatement
error for LIMIT placeholder".
The patch adds grammar support for LIMIT ?, ? and changes the
type of ST_SELECT_LEX::select_limit,offset_limit from ha_rows to Item*,
so that it can point to Item_param.
mysql-test/include/ps_modify.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/include/ps_query.inc:
Fix existing tests: now LIMIT can contain placeholders.
mysql-test/r/ps.result:
Add basic test coverage for LIMIT ?, ? and fix test results.
mysql-test/r/ps_2myisam.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_3innodb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_4heap.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_5merge.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_6bdb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/r/ps_7ndb.result:
Fix test results: now LIMIT can contain placeholders.
mysql-test/t/ps.test:
Add basic test coverage for LIMIT ?, ?.
sql/item.h:
Add a short-cut for (ulonglong) val_int() to Item.
Add a constructor to Item_int() that accepts ulonglong.
Simplify Item_uint constructor by using the c-tor above.
sql/item_subselect.cc:
Now select_limit has type Item *.
We can safely create an Item in Item_exists_subselect::fix_length_and_dec():
it will be allocated in runtime memory root and freed in the end of
execution.
sql/sp_head.cc:
Add a special initalization state for stored procedures to
be able to easily distinguish the first execution of a stored procedure
from prepared statement prepare.
sql/sql_class.h:
Introduce new state 'INITIALIZED_FOR_SP' to be able to easily distinguish
the first execution of a stored procedure from prepared statement prepare.
sql/sql_derived.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace. Add a warning about use of set_limit in
mysql_derived_filling.
sql/sql_error.cc:
- use unit->set_limit() to set unit->select_limit_cnt, offset_limit_cnt
evreryplace.
- this change is also aware of bug#11095 "show warnings limit 0 returns
all rows instead of zero rows", so the one who merges the bugfix from
4.1 can use local version of sql_error.cc.
sql/sql_handler.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
sql/sql_lex.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_lex.h:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_parse.cc:
- use unit->set_limit() to initalize
unit->select_limit_cnt,offset_limit_cnt everyplace.
- we can create an Item_int to set global limit of a statement:
it will be created in the runtime mem root and freed in the end of
execution.
sql/sql_repl.cc:
Use unit->set_limit to initialize limits.
sql/sql_select.cc:
- select_limit is now Item* so the proper way to check for default value
is to compare it with NULL.
sql/sql_union.cc:
Evaluate offset_limit_cnt using the new type of ST_SELECT_LEX::offset_limit
sql/sql_view.cc:
Now ST_SELECT_LEX::select_limit, offset_limit have type Item *
sql/sql_yacc.yy:
Add grammar support for LIMIT ?, ? clause.
2005-06-07 12:11:36 +02:00
|
|
|
if (idx > unit->select_limit_cnt)
|
|
|
|
break;
|
2002-12-11 08:17:51 +01:00
|
|
|
protocol->prepare_for_resend();
|
2009-09-10 11:18:29 +02:00
|
|
|
protocol->store(warning_level_names[err->get_level()].str,
|
|
|
|
warning_level_names[err->get_level()].length,
|
|
|
|
system_charset_info);
|
|
|
|
protocol->store((uint32) err->get_sql_errno());
|
|
|
|
protocol->store(err->get_message_text(),
|
|
|
|
err->get_message_octet_length(),
|
|
|
|
system_charset_info);
|
2002-12-11 08:17:51 +01:00
|
|
|
if (protocol->write())
|
2005-02-22 22:42:49 +01:00
|
|
|
DBUG_RETURN(TRUE);
|
2002-06-12 23:13:12 +02:00
|
|
|
}
|
2008-02-19 13:58:08 +01:00
|
|
|
my_eof(thd);
|
2009-09-10 11:18:29 +02:00
|
|
|
|
|
|
|
thd->warning_info->set_read_only(FALSE);
|
|
|
|
|
2005-02-22 22:42:49 +01:00
|
|
|
DBUG_RETURN(FALSE);
|
2002-06-12 23:13:12 +02:00
|
|
|
}
|
2009-09-10 11:18:29 +02:00
|
|
|
|
2009-10-15 14:23:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Convert value for dispatch to error message(see WL#751).
|
|
|
|
|
|
|
|
@param to buffer for converted string
|
|
|
|
@param to_length size of the buffer
|
|
|
|
@param from string which should be converted
|
|
|
|
@param from_length string length
|
|
|
|
@param from_cs charset from convert
|
|
|
|
|
|
|
|
@retval
|
|
|
|
result string
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *err_conv(char *buff, uint to_length, const char *from,
|
|
|
|
uint from_length, CHARSET_INFO *from_cs)
|
|
|
|
{
|
|
|
|
char *to= buff;
|
|
|
|
const char *from_start= from;
|
|
|
|
size_t res;
|
|
|
|
|
|
|
|
DBUG_ASSERT(to_length > 0);
|
|
|
|
to_length--;
|
|
|
|
if (from_cs == &my_charset_bin)
|
|
|
|
{
|
|
|
|
uchar char_code;
|
|
|
|
res= 0;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if ((uint)(from - from_start) >= from_length ||
|
|
|
|
res >= to_length)
|
|
|
|
{
|
|
|
|
*to= 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
char_code= ((uchar) *from);
|
|
|
|
if (char_code >= 0x20 && char_code <= 0x7E)
|
|
|
|
{
|
|
|
|
*to++= char_code;
|
|
|
|
from++;
|
|
|
|
res++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (res + 4 >= to_length)
|
|
|
|
{
|
|
|
|
*to= 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
res+= my_snprintf(to, 5, "\\x%02X", (uint) char_code);
|
|
|
|
to+=4;
|
|
|
|
from++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
uint errors;
|
|
|
|
res= copy_and_convert(to, to_length, system_charset_info,
|
|
|
|
from, from_length, from_cs, &errors);
|
|
|
|
to[res]= 0;
|
|
|
|
}
|
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Convert string for dispatch to client(see WL#751).
|
|
|
|
|
|
|
|
@param to buffer to convert
|
|
|
|
@param to_length buffer length
|
|
|
|
@param to_cs chraset to convert
|
|
|
|
@param from string from convert
|
|
|
|
@param from_length string length
|
|
|
|
@param from_cs charset from convert
|
|
|
|
@param errors count of errors during convertion
|
|
|
|
|
|
|
|
@retval
|
|
|
|
length of converted string
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint32 convert_error_message(char *to, uint32 to_length, CHARSET_INFO *to_cs,
|
|
|
|
const char *from, uint32 from_length,
|
|
|
|
CHARSET_INFO *from_cs, uint *errors)
|
|
|
|
{
|
|
|
|
int cnvres;
|
|
|
|
my_wc_t wc;
|
|
|
|
const uchar *from_end= (const uchar*) from+from_length;
|
|
|
|
char *to_start= to;
|
2011-07-15 13:05:30 +02:00
|
|
|
uchar *to_end;
|
2009-10-15 14:23:43 +02:00
|
|
|
my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc;
|
|
|
|
my_charset_conv_wc_mb wc_mb;
|
|
|
|
uint error_count= 0;
|
|
|
|
uint length;
|
|
|
|
|
|
|
|
DBUG_ASSERT(to_length > 0);
|
2011-07-15 13:05:30 +02:00
|
|
|
/* Make room for the null terminator. */
|
2009-10-15 14:23:43 +02:00
|
|
|
to_length--;
|
2011-07-15 13:05:30 +02:00
|
|
|
to_end= (uchar*) (to + to_length);
|
2009-10-15 14:23:43 +02:00
|
|
|
|
|
|
|
if (!to_cs || from_cs == to_cs || to_cs == &my_charset_bin)
|
|
|
|
{
|
|
|
|
length= min(to_length, from_length);
|
|
|
|
memmove(to, from, length);
|
|
|
|
to[length]= 0;
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
wc_mb= to_cs->cset->wc_mb;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if ((cnvres= (*mb_wc)(from_cs, &wc, (uchar*) from, from_end)) > 0)
|
|
|
|
{
|
|
|
|
if (!wc)
|
|
|
|
break;
|
|
|
|
from+= cnvres;
|
|
|
|
}
|
|
|
|
else if (cnvres == MY_CS_ILSEQ)
|
|
|
|
{
|
|
|
|
wc= (ulong) (uchar) *from;
|
|
|
|
from+=1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ((cnvres= (*wc_mb)(to_cs, wc, (uchar*) to, to_end)) > 0)
|
|
|
|
to+= cnvres;
|
|
|
|
else if (cnvres == MY_CS_ILUNI)
|
|
|
|
{
|
|
|
|
length= (wc <= 0xFFFF) ? 6/* '\1234' format*/ : 9 /* '\+123456' format*/;
|
|
|
|
if ((uchar*)(to + length) >= to_end)
|
|
|
|
break;
|
|
|
|
cnvres= my_snprintf(to, 9,
|
|
|
|
(wc <= 0xFFFF) ? "\\%04X" : "\\+%06X", (uint) wc);
|
|
|
|
to+= cnvres;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*to= 0;
|
|
|
|
*errors= error_count;
|
|
|
|
return (uint32) (to - to_start);
|
|
|
|
}
|