~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to modules/db.mysql.sqlparser/src/mysql_sql_inserts_loader.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License as
 
6
 * published by the Free Software Foundation; version 2 of the
 
7
 * License.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
12
 * GNU General Public License for more details.
 
13
 * 
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
17
 * 02110-1301  USA
 
18
 */
 
19
 
 
20
 
 
21
#ifndef _MYSQL_SQL_INSERTS_LOADER_H_
 
22
#define _MYSQL_SQL_INSERTS_LOADER_H_
 
23
 
 
24
 
 
25
#include "mysql_sql_parser_base.h"
 
26
#include "grtsqlparser/sql_inserts_loader.h"
 
27
 
 
28
 
 
29
/** Implements DBMS specifics.
 
30
 * 
 
31
 * @ingroup sqlparser
 
32
 */
 
33
class MYSQL_SQL_PARSER_PUBLIC_FUNC Mysql_sql_inserts_loader : protected Mysql_sql_parser_base, public Sql_inserts_loader
 
34
{
 
35
public:
 
36
  typedef boost::shared_ptr<Mysql_sql_inserts_loader> Ref;
 
37
  static Ref create(grt::GRT *grt) { return Ref(new Mysql_sql_inserts_loader(grt)); }
 
38
  virtual ~Mysql_sql_inserts_loader() {}
 
39
protected:
 
40
  Mysql_sql_inserts_loader(grt::GRT *grt);
 
41
 
 
42
public:
 
43
  void load(const std::string &sql, const std::string &schema_name);
 
44
 
 
45
protected:
 
46
  // higher level
 
47
  int process_sql_statement(const SqlAstNode *tree);
 
48
 
 
49
  // parse tree core
 
50
  Parse_result process_insert_statement(const SqlAstNode *tree);
 
51
 
 
52
  // context
 
53
  std::string _schema_name;
 
54
 
 
55
  class Null_state_keeper : Mysql_sql_parser_base::Null_state_keeper
 
56
  {
 
57
  public:
 
58
    Null_state_keeper(Mysql_sql_inserts_loader *sql_parser)
 
59
      : Mysql_sql_parser_base::Null_state_keeper(sql_parser),
 
60
        _sql_parser(sql_parser)
 
61
    {}
 
62
    ~Null_state_keeper()
 
63
    {
 
64
      _sql_parser->_schema_name= std::string();
 
65
    }
 
66
  private:
 
67
    Mysql_sql_inserts_loader *_sql_parser;
 
68
  };
 
69
  friend class Null_state_keeper;
 
70
};
 
71
 
 
72
 
 
73
#endif // _MYSQL_SQL_INSERTS_LOADER_H_