Commit 205cf804 authored by unknown's avatar unknown
Browse files

Merge: manual resolve


sql/sql_class.h:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_class.cc:
  Manual resolve of the merge
parents 6b20f46a 49bd559e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -226,3 +226,18 @@ a b
execute stmt1;
a	b
deallocate prepare stmt1;
drop table t1;
prepare stmt1 from "select 1 into @var";
execute stmt1;
execute stmt1;
prepare stmt1 from "create table t1 select 1 as i";
execute stmt1;
drop table t1;
execute stmt1;
prepare stmt1 from "insert into t1 select i from t1";
execute stmt1;
execute stmt1;
prepare stmt1 from "select * from t1 into outfile 'f1.txt'";
execute stmt1;
deallocate prepare stmt1;
drop table t1;
+23 −1
Original line number Diff line number Diff line
@@ -209,7 +209,7 @@ drop table t1;

#
# Bug#4912 "mysqld crashs in case a statement is executed a second time":
# negation elimination should and prepared statemens
# negation elimination should work once and not break prepared statements
# 

create table t1(a varchar(2), b varchar(3));
@@ -217,4 +217,26 @@ prepare stmt1 from "select a, b from t1 where (not (a='aa' and b < 'zzz'))";
execute stmt1;
execute stmt1;
deallocate prepare stmt1;
drop table t1;

#
# Bug#5034 "prepared "select 1 into @arg15", second execute crashes
# server".
# Check that descendands of select_result can be reused in prepared 
# statements or are correctly created and deleted on each execute
#

prepare stmt1 from "select 1 into @var";
execute stmt1;
execute stmt1;
prepare stmt1 from "create table t1 select 1 as i";
execute stmt1;
drop table t1;
execute stmt1;
prepare stmt1 from "insert into t1 select i from t1";
execute stmt1;
execute stmt1;
prepare stmt1 from "select * from t1 into outfile 'f1.txt'";
execute stmt1;
deallocate prepare stmt1;
drop table t1;
+54 −24
Original line number Diff line number Diff line
@@ -708,6 +708,12 @@ void select_result::send_error(uint errcode,const char *err)
  ::send_error(thd, errcode, err);
}


void select_result::cleanup()
{
  /* do nothing */
}

static String default_line_term("\n",default_charset_info);
static String default_escaped("\\",default_charset_info);
static String default_field_term("\t",default_charset_info);
@@ -813,6 +819,32 @@ void select_to_file::send_error(uint errcode,const char *err)
}


bool select_to_file::send_eof()
{
  int error= test(end_io_cache(&cache));
  if (my_close(file,MYF(MY_WME)))
    error= 1;
  if (!error)
    ::send_ok(thd,row_count);
  file= -1;
  return error;
}


void select_to_file::cleanup()
{
  /* In case of error send_eof() may be not called: close the file here. */
  if (file >= 0)
  {
    (void) end_io_cache(&cache);
    (void) my_close(file,MYF(0));
    file= -1;
  }
  path[0]= '\0';
  row_count= 0;
}


select_to_file::~select_to_file()
{
  if (file >= 0)
@@ -1063,18 +1095,6 @@ bool select_export::send_data(List<Item> &items)
}


bool select_export::send_eof()
{
  int error=test(end_io_cache(&cache));
  if (my_close(file,MYF(MY_WME)))
    error=1;
  if (!error)
    ::send_ok(thd,row_count);
  file= -1;
  return error;
}


/***************************************************************************
** Dump  of select to a binary file
***************************************************************************/
@@ -1128,18 +1148,6 @@ bool select_dump::send_data(List<Item> &items)
}


bool select_dump::send_eof()
{
  int error=test(end_io_cache(&cache));
  if (my_close(file,MYF(MY_WME)))
    error=1;
  if (!error)
    ::send_ok(thd,row_count);
  file= -1;
  return error;
}


select_subselect::select_subselect(Item_subselect *item_arg)
{
  item= item_arg;
@@ -1306,6 +1314,13 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
}


void select_dumpvar::cleanup()
{
  vars.empty();
  row_count=0;
}


Item_arena::Item_arena(THD* thd)
  :free_list(0),
  state((int)INITIALIZED)
@@ -1410,6 +1425,21 @@ void Statement::restore_backup_statement(Statement *stmt, Statement *backup)
}


void Statement::end_statement()
{
  /* Cleanup SQL processing state to resuse this statement in next query. */
  lex_end(lex);
  delete lex->result;
  lex->result= 0;
  free_items(free_list);
  free_list= 0;
  /*
    Don't free mem_root, as mem_root is freed in the end of dispatch_command
    (once for any command).
  */
}


void Item_arena::set_n_backup_item_arena(Item_arena *set, Item_arena *backup)
{
  backup->set_item_arena(this);
+19 −3
Original line number Diff line number Diff line
@@ -551,6 +551,12 @@ class Statement: public Item_arena
  void restore_backup_statement(Statement *stmt, Statement *backup);
  /* return class type */
  virtual Type type() const;

  /*
    Cleanup statement parse state (parse tree, lex) after execution of
    a non-prepared SQL statement.
  */
  void end_statement();
};


@@ -1033,10 +1039,13 @@ class Disable_binlog {
  ~Disable_binlog();
};


/*
  Used to hold information about file and file structure in exchainge 
  via non-DB file (...INTO OUTFILE..., ...LOAD DATA...)
  XXX: We never call destructor for objects of this class.
*/

class sql_exchange :public Sql_alloc
{
public:
@@ -1046,7 +1055,6 @@ class sql_exchange :public Sql_alloc
  bool dumpfile;
  ulong skip_lines;
  sql_exchange(char *name,bool dumpfile_flag);
  ~sql_exchange() {}
};

#include "log_event.h"
@@ -1077,6 +1085,11 @@ class select_result :public Sql_alloc {
  virtual void send_error(uint errcode,const char *err);
  virtual bool send_eof()=0;
  virtual void abort() {}
  /*
    Cleanup instance of this class for next execution of a prepared
    statement/stored procedure.
  */
  virtual void cleanup();
};


@@ -1103,6 +1116,8 @@ class select_to_file :public select_result {
  ~select_to_file();
  bool send_fields(List<Item> &list, uint flag) { return 0; }
  void send_error(uint errcode,const char *err);
  bool send_eof();
  void cleanup();
};


@@ -1115,7 +1130,6 @@ class select_export :public select_to_file {
  ~select_export();
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
  bool send_data(List<Item> &items);
  bool send_eof();
};


@@ -1124,7 +1138,6 @@ class select_dump :public select_to_file {
  select_dump(sql_exchange *ex) :select_to_file(ex) {}
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
  bool send_data(List<Item> &items);
  bool send_eof();
};


@@ -1149,6 +1162,8 @@ class select_insert :public select_result {
  bool send_data(List<Item> &items);
  void send_error(uint errcode,const char *err);
  bool send_eof();
  /* not implemented: select_insert is never re-used in prepared statements */
  void cleanup();
};


@@ -1449,4 +1464,5 @@ class select_dumpvar :public select_result {
  bool send_fields(List<Item> &list, uint flag) {return 0;}
  bool send_data(List<Item> &items);
  bool send_eof();
  void cleanup();
};
+7 −0
Original line number Diff line number Diff line
@@ -1465,6 +1465,13 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
  DBUG_RETURN(0);
}


void select_insert::cleanup()
{
  /* select_insert/select_create are never re-used in prepared statement */
  DBUG_ASSERT(0);
}

select_insert::~select_insert()
{
  if (table)
Loading