mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
sql/sql_class.h
Bug #6284 - report truncation warnings in INSERT ... SELECT only for "INSERT" part sql/sql_insert.cc Bug #6284 - report truncation warnings in INSERT ... SELECT only for "INSERT" part
This commit is contained in:
@ -1235,6 +1235,7 @@ class select_insert :public select_result_interceptor {
|
|||||||
~select_insert();
|
~select_insert();
|
||||||
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
||||||
bool send_data(List<Item> &items);
|
bool send_data(List<Item> &items);
|
||||||
|
virtual void store_values(List<Item> &values);
|
||||||
void send_error(uint errcode,const char *err);
|
void send_error(uint errcode,const char *err);
|
||||||
bool send_eof();
|
bool send_eof();
|
||||||
/* not implemented: select_insert is never re-used in prepared statements */
|
/* not implemented: select_insert is never re-used in prepared statements */
|
||||||
@ -1262,7 +1263,7 @@ public:
|
|||||||
create_info(create_info_par), lock(0)
|
create_info(create_info_par), lock(0)
|
||||||
{}
|
{}
|
||||||
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
||||||
bool send_data(List<Item> &values);
|
void store_values(List<Item> &values);
|
||||||
bool send_eof();
|
bool send_eof();
|
||||||
void abort();
|
void abort();
|
||||||
};
|
};
|
||||||
|
@ -1457,7 +1457,6 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
|||||||
|
|
||||||
restore_record(table,default_values); // Get empty record
|
restore_record(table,default_values); // Get empty record
|
||||||
table->next_number_field=table->found_next_number_field;
|
table->next_number_field=table->found_next_number_field;
|
||||||
thd->count_cuted_fields= CHECK_FIELD_WARN; // calc cuted fields
|
|
||||||
thd->cuted_fields=0;
|
thd->cuted_fields=0;
|
||||||
if (info.handle_duplicates == DUP_IGNORE ||
|
if (info.handle_duplicates == DUP_IGNORE ||
|
||||||
info.handle_duplicates == DUP_REPLACE)
|
info.handle_duplicates == DUP_REPLACE)
|
||||||
@ -1487,27 +1486,34 @@ select_insert::~select_insert()
|
|||||||
bool select_insert::send_data(List<Item> &values)
|
bool select_insert::send_data(List<Item> &values)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("select_insert::send_data");
|
DBUG_ENTER("select_insert::send_data");
|
||||||
|
bool error=0;
|
||||||
if (unit->offset_limit_cnt)
|
if (unit->offset_limit_cnt)
|
||||||
{ // using limit offset,count
|
{ // using limit offset,count
|
||||||
unit->offset_limit_cnt--;
|
unit->offset_limit_cnt--;
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
if (fields->elements)
|
thd->count_cuted_fields= CHECK_FIELD_WARN; // calc cuted fields
|
||||||
fill_record(*fields, values, 1);
|
store_values(values);
|
||||||
else
|
error=thd->net.report_error || write_record(table,&info);
|
||||||
fill_record(table->field, values, 1);
|
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
|
||||||
if (thd->net.report_error || write_record(table,&info))
|
if (!error && table->next_number_field) // Clear for next record
|
||||||
DBUG_RETURN(1);
|
|
||||||
if (table->next_number_field) // Clear for next record
|
|
||||||
{
|
{
|
||||||
table->next_number_field->reset();
|
table->next_number_field->reset();
|
||||||
if (! last_insert_id && thd->insert_id_used)
|
if (! last_insert_id && thd->insert_id_used)
|
||||||
last_insert_id=thd->insert_id();
|
last_insert_id=thd->insert_id();
|
||||||
}
|
}
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void select_insert::store_values(List<Item> &values)
|
||||||
|
{
|
||||||
|
if (fields->elements)
|
||||||
|
fill_record(*fields, values, 1);
|
||||||
|
else
|
||||||
|
fill_record(table->field, values, 1);
|
||||||
|
}
|
||||||
|
|
||||||
void select_insert::send_error(uint errcode,const char *err)
|
void select_insert::send_error(uint errcode,const char *err)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("select_insert::send_error");
|
DBUG_ENTER("select_insert::send_error");
|
||||||
@ -1637,7 +1643,6 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
|||||||
table->next_number_field=table->found_next_number_field;
|
table->next_number_field=table->found_next_number_field;
|
||||||
|
|
||||||
restore_record(table,default_values); // Get empty record
|
restore_record(table,default_values); // Get empty record
|
||||||
thd->count_cuted_fields= CHECK_FIELD_WARN; // count warnings
|
|
||||||
thd->cuted_fields=0;
|
thd->cuted_fields=0;
|
||||||
if (info.handle_duplicates == DUP_IGNORE ||
|
if (info.handle_duplicates == DUP_IGNORE ||
|
||||||
info.handle_duplicates == DUP_REPLACE)
|
info.handle_duplicates == DUP_REPLACE)
|
||||||
@ -1647,23 +1652,9 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool select_create::send_data(List<Item> &values)
|
void select_create::store_values(List<Item> &values)
|
||||||
{
|
{
|
||||||
if (unit->offset_limit_cnt)
|
|
||||||
{ // using limit offset,count
|
|
||||||
unit->offset_limit_cnt--;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
fill_record(field, values, 1);
|
fill_record(field, values, 1);
|
||||||
if (thd->net.report_error ||write_record(table,&info))
|
|
||||||
return 1;
|
|
||||||
if (table->next_number_field) // Clear for next record
|
|
||||||
{
|
|
||||||
table->next_number_field->reset();
|
|
||||||
if (! last_insert_id && thd->insert_id_used)
|
|
||||||
last_insert_id=thd->insert_id();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1711,7 +1702,7 @@ void select_create::abort()
|
|||||||
enum db_type table_type=table->db_type;
|
enum db_type table_type=table->db_type;
|
||||||
if (!table->tmp_table)
|
if (!table->tmp_table)
|
||||||
{
|
{
|
||||||
ulong version= table->version;
|
ulong version= table->version;
|
||||||
hash_delete(&open_cache,(byte*) table);
|
hash_delete(&open_cache,(byte*) table);
|
||||||
if (!create_info->table_existed)
|
if (!create_info->table_existed)
|
||||||
quick_rm_table(table_type, db, name);
|
quick_rm_table(table_type, db, name);
|
||||||
|
Reference in New Issue
Block a user