#include "stdafx.h"

#include "mysql_sql_script_splitter.h"
#include "myx_sql_parser_public_interface.h"
#include "sql_lex.h"
#include "my_sys.h"


Mysql_sql_script_splitter::Mysql_sql_script_splitter() 
{
  _cs= get_charset_by_name("utf8_bin", MYF(0));
}


Mysql_sql_script_splitter::~Mysql_sql_script_splitter()
{
}


int Mysql_sql_script_splitter::process(const std::string &sql, std::list<std::string> &statements)
{
  myx_process_sql_statements(sql.c_str(), _cs, &Mysql_sql_script_splitter::process_statement, &statements, MYX_SPM_NORMAL_MODE); 
  return 0;
}


int Mysql_sql_script_splitter::process_statement(const MyxStatementParser *splitter, const char *sql, void *userdata)
{
  std::list<std::string> *statements= static_cast<std::list<std::string>*>(userdata);
  statements->push_back(sql);
  return 0;
}
