summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2013-06-15 18:32:08 +0300
committerMichael Widenius <monty@askmonty.org>2013-06-15 18:32:08 +0300
commit5f1f2fc0e443f098af24d21f7d1ec1a8166a4030 (patch)
tree7b870d0c390c05d6629f4813966e740ea073fcef /sql/unireg.cc
parent3143ad589a24ac7581e2195ba0dc13576cb3c9da (diff)
downloadmariadb-git-5f1f2fc0e443f098af24d21f7d1ec1a8166a4030.tar.gz
Applied all changes from Igor and Sanja
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc76
1 files changed, 42 insertions, 34 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 4596bb52747..a546fb769b3 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -67,9 +67,9 @@ struct Pack_header_error_handler: public Internal_error_handler
virtual bool handle_condition(THD *thd,
uint sql_errno,
const char* sqlstate,
- MYSQL_ERROR::enum_warning_level level,
+ Sql_condition::enum_warning_level level,
const char* msg,
- MYSQL_ERROR ** cond_hdl);
+ Sql_condition ** cond_hdl);
bool is_handled;
Pack_header_error_handler() :is_handled(FALSE) {}
};
@@ -80,9 +80,9 @@ Pack_header_error_handler::
handle_condition(THD *,
uint sql_errno,
const char*,
- MYSQL_ERROR::enum_warning_level,
+ Sql_condition::enum_warning_level,
const char*,
- MYSQL_ERROR ** cond_hdl)
+ Sql_condition ** cond_hdl)
{
*cond_hdl= NULL;
is_handled= (sql_errno == ER_TOO_MANY_FIELDS);
@@ -252,8 +252,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_TABLE_COMMENT),
real_table_name, static_cast<ulong>(TABLE_COMMENT_MAXLEN));
/* do not push duplicate warnings */
- if (!check_duplicate_warning(current_thd, warn_buff, strlen(warn_buff)))
- push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ if (!thd->get_stmt_da()->has_sql_condition(warn_buff, strlen(warn_buff)))
+ push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
ER_TOO_LONG_TABLE_COMMENT, warn_buff);
create_info->comment.length= tmp_len;
}
@@ -457,31 +457,32 @@ err3:
} /* mysql_create_frm */
-/*
+/**
Create a frm (table definition) file and the tables
- SYNOPSIS
- rea_create_table()
- thd Thread handler
- path Name of file (including database, without .frm)
- db Data base name
- table_name Table name
- create_info create info parameters
- create_fields Fields to create
- keys number of keys to create
- key_info Keys to create
- file Handler to use
-
- RETURN
- 0 ok
- 1 error
+ @param thd Thread handler
+ @param path Name of file (including database, without .frm)
+ @param db Data base name
+ @param table_name Table name
+ @param create_info create info parameters
+ @param create_fields Fields to create
+ @param keys number of keys to create
+ @param key_info Keys to create
+ @param file Handler to use
+ @param no_ha_table Indicates that only .FRM file (and PAR file if table
+ is partitioned) needs to be created and not a table
+ in the storage engine.
+
+ @retval 0 ok
+ @retval 1 error
*/
int rea_create_table(THD *thd, const char *path,
const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
List<Create_field> &create_fields,
- uint keys, KEY *key_info, handler *file)
+ uint keys, KEY *key_info, handler *file,
+ bool no_ha_table)
{
DBUG_ENTER("rea_create_table");
@@ -496,15 +497,20 @@ int rea_create_table(THD *thd, const char *path,
DBUG_ASSERT(*fn_rext(frm_name));
if (thd->variables.keep_files_on_create)
create_info->options|= HA_CREATE_KEEP_FILES;
- if (!create_info->frm_only &&
- (file->ha_create_handler_files(path, NULL, CHF_CREATE_FLAG,
- create_info) ||
- ha_create_table(thd, path, db, table_name, create_info, 0)))
+
+ if (file->ha_create_handler_files(path, NULL, CHF_CREATE_FLAG,
+ create_info))
+ goto err_handler_frm;
+
+ if (!no_ha_table &&
+ ha_create_table(thd, path, db, table_name, create_info, 0))
goto err_handler;
DBUG_RETURN(0);
err_handler:
(void) file->ha_create_handler_files(path, NULL, CHF_DELETE_FLAG, create_info);
+
+err_handler_frm:
mysql_file_delete(key_file_frm, frm_name, MYF(0));
DBUG_RETURN(1);
} /* rea_create_table */
@@ -603,15 +609,15 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
{
int2store(pos, (key->flags ^ HA_NOSAME));
int2store(pos+2,key->key_length);
- pos[4]= (uchar) key->key_parts;
+ pos[4]= (uchar) key->user_defined_key_parts;
pos[5]= (uchar) key->algorithm;
int2store(pos+6, key->block_size);
pos+=8;
- key_parts+=key->key_parts;
+ key_parts+=key->user_defined_key_parts;
DBUG_PRINT("loop", ("flags: %lu key_parts: %d key_part: 0x%lx",
- key->flags, key->key_parts,
+ key->flags, key->user_defined_key_parts,
(long) key->key_part));
- for (key_part=key->key_part,key_part_end=key_part+key->key_parts ;
+ for (key_part=key->key_part,key_part_end=key_part+key->user_defined_key_parts ;
key_part != key_part_end ;
key_part++)
@@ -706,7 +712,9 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
COLUMN_COMMENT_MAXLEN);
if (tmp_len < field->comment.length)
{
- if (current_thd->is_strict_mode())
+ THD *thd= current_thd;
+
+ if (thd->is_strict_mode())
{
my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name,
static_cast<ulong>(COLUMN_COMMENT_MAXLEN));
@@ -717,8 +725,8 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
field->field_name,
static_cast<ulong>(COLUMN_COMMENT_MAXLEN));
/* do not push duplicate warnings */
- if (!check_duplicate_warning(current_thd, warn_buff, strlen(warn_buff)))
- push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ if (!thd->get_stmt_da()->has_sql_condition(warn_buff, strlen(warn_buff)))
+ push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
ER_TOO_LONG_FIELD_COMMENT, warn_buff);
field->comment.length= tmp_len;
}