#ifndef _MYSQL_SQL_SYNTAX_CHECK_H_
#define _MYSQL_SQL_SYNTAX_CHECK_H_


#include "mysql_sql_parser_base.h"
#include "grtsqlparser/sql_syntax_check.h"


/** Implements DBMS specifics.
 * 
 * @ingroup sqlparser
 */
class MYSQL_SQL_PARSER_PUBLIC_FUNC Mysql_sql_syntax_check
  : virtual protected Mysql_sql_parser_base, virtual public Sql_syntax_check
{
public:
  Mysql_sql_syntax_check(grt::GRT *grt);

  int check_sql(const std::string &sql);
  int check_trigger(const std::string &sql);
  int check_view(const std::string &sql);
  int check_routine(const std::string &sql);

protected:
  typedef sigc::slot<Parse_result, const MyxSQLTreeItem *> Check_sql_statement;

  Check_sql_statement _check_sql_statement;

  int process_sql_statement(const MyxSQLTreeItem *tree);
  int check_sql_statement(const std::string &sql, Check_sql_statement check_sql_statement);

  Parse_result do_check_sql(const MyxSQLTreeItem *tree);
  Parse_result do_check_trigger(const MyxSQLTreeItem *tree);
  Parse_result do_check_view(const MyxSQLTreeItem *tree);
  Parse_result do_check_routine(const MyxSQLTreeItem *tree);

  virtual Parse_result check_sql(const MyxSQLTreeItem *tree);
  virtual Parse_result check_trigger(const MyxSQLTreeItem *tree, const MyxSQLTreeItem *trigger_tail);
  virtual Parse_result check_view(const MyxSQLTreeItem *tree, const MyxSQLTreeItem *view_tail);
  virtual Parse_result check_routine(const MyxSQLTreeItem *tree, const MyxSQLTreeItem *routine_tail);

  bool _use_delimiter;

  class Null_state_keeper : Mysql_sql_parser_base::Null_state_keeper
  {
  public:
    Null_state_keeper(Mysql_sql_syntax_check *sql_parser)
      : Mysql_sql_parser_base::Null_state_keeper(sql_parser), _sql_parser(sql_parser) {}
    ~Null_state_keeper();
  private:
    Mysql_sql_syntax_check *_sql_parser;
  };
};


#endif // _MYSQL_SQL_SYNTAX_CHECK_H_
