summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.(none)>2007-11-01 18:06:46 +0300
committerunknown <kostja@bodhi.(none)>2007-11-01 18:06:46 +0300
commit3536c5d5f5a404e8872df11caf8f9b3a8b4cc45f (patch)
treebc60702b98a0bf6cfecf2dbd61f0f6b72264dc73
parentecef837931ae10467bb112eb5364051e419521dc (diff)
downloadmariadb-git-3536c5d5f5a404e8872df11caf8f9b3a8b4cc45f.tar.gz
Use Internal_error_handler mechanism to silence ER_TOO_MANY_FIELDS
error in mysql_create_frm instead of direct access to my_error() members. This is a pre-requisite for the patch for Bug#12713. sql/unireg.cc: Use Internal_error_handler mechanism to silence ER_TOO_MANY_FIELDS error in mysql_create_frm instead of direct access to my_error() members.
-rw-r--r--sql/unireg.cc48
1 files changed, 42 insertions, 6 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index f9e8e54439a..f2238d69973 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -47,6 +47,35 @@ static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type,
uint reclength, ulong data_offset,
handler *handler);
+/**
+ An interceptor to hijack ER_TOO_MANY_FIELDS error from
+ pack_screens and retry again without UNIREG screens.
+
+ XXX: what is a UNIREG screen?
+*/
+
+struct Pack_header_error_handler: public Internal_error_handler
+{
+ virtual bool handle_error(uint sql_errno,
+ const char *message,
+ MYSQL_ERROR::enum_warning_level level,
+ THD *thd);
+ bool is_handled;
+ Pack_header_error_handler() :is_handled(FALSE) {}
+};
+
+
+bool
+Pack_header_error_handler::
+handle_error(uint sql_errno,
+ const char * /* message */,
+ MYSQL_ERROR::enum_warning_level /* level */,
+ THD * /* thd */)
+{
+ is_handled= (sql_errno == ER_TOO_MANY_FIELDS);
+ return is_handled;
+}
+
/*
Create a frm (table definition) file
@@ -86,6 +115,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
#ifdef WITH_PARTITION_STORAGE_ENGINE
partition_info *part_info= thd->work_part_info;
#endif
+ Pack_header_error_handler pack_header_error_handler;
+ int error;
DBUG_ENTER("mysql_create_frm");
DBUG_ASSERT(*fn_rext((char*)file_name)); // Check .frm extension
@@ -99,17 +130,22 @@ bool mysql_create_frm(THD *thd, const char *file_name,
create_info->null_bits++;
data_offset= (create_info->null_bits + 7) / 8;
- if (pack_header(forminfo, ha_legacy_type(create_info->db_type),
- create_fields,info_length,
- screens, create_info->table_options,
- data_offset, db_file))
+ thd->push_internal_handler(&pack_header_error_handler);
+
+ error= pack_header(forminfo, ha_legacy_type(create_info->db_type),
+ create_fields,info_length,
+ screens, create_info->table_options,
+ data_offset, db_file);
+
+ thd->pop_internal_handler();
+
+ if (error)
{
my_free(screen_buff, MYF(0));
- if (thd->net.last_errno != ER_TOO_MANY_FIELDS)
+ if (! pack_header_error_handler.is_handled)
DBUG_RETURN(1);
// Try again without UNIREG screens (to get more columns)
- thd->net.last_error[0]=0;
if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,1)))
DBUG_RETURN(1);
if (pack_header(forminfo, ha_legacy_type(create_info->db_type),