File: sql_facade.h

package info (click to toggle)
mysql-workbench 5.2.40%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 53,880 kB
  • sloc: cpp: 419,850; yacc: 74,784; xml: 54,510; python: 31,455; sh: 9,423; ansic: 4,736; makefile: 2,442; php: 529; java: 237
file content (96 lines) | stat: -rw-r--r-- 4,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* 
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of the
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */


#ifndef _SQL_FACADE_H_
#define _SQL_FACADE_H_


#include <memory>
#include "wbpublic_public_interface.h"
#include "grtsqlparser/sql_parser.h"
#include "grtsqlparser/sql_syntax_check.h"
#include "grtsqlparser/sql_semantic_check.h"
#include "grtsqlparser/sql_specifics.h"
#include "grtsqlparser/sql_normalizer.h"
#include "grtsqlparser/sql_inserts_loader.h"
#include "grtsqlparser/invalid_sql_parser.h"
#include "grtsqlparser/sql_statement_decomposer.h"
#include "grtsqlparser/sql_schema_rename.h"
#include "grts/structs.db.mgmt.h"


/** Serves as a single point of access to all functionality related to SQL processing.
 * Provides helper methods to perform most of the tasks.
 * Singleton.
 * 
 * @ingroup sqlparser
 */
class WBPUBLICBACKEND_PUBLIC_FUNC SqlFacade
{
public:
  typedef SqlFacade * Ref;
  typedef std::list<std::pair<std::string, std::string> > Column_name_list;
  
public:
  static SqlFacade::Ref instance_for_db_obj(db_DatabaseObjectRef db_obj);
  static SqlFacade::Ref instance_for_rdbms(db_mgmt_RdbmsRef rdbms);
  static SqlFacade::Ref instance_for_rdbms_name(grt::GRT *grt, const std::string &name);

  virtual int splitSqlScript(const std::string &sql, std::list<std::string> &statements)= 0;

  virtual Sql_parser::Ref sqlParser()= 0;
  virtual int parseSqlScriptString(grt::Ref<db_Catalog> catalog, const std::string sql)= 0;
  virtual int parseSqlScriptStringEx(grt::Ref<db_Catalog> catalog, const std::string sql, const grt::DictRef options)= 0;
  virtual int parseSqlScriptFile(grt::Ref<db_Catalog> catalog, const std::string filename)= 0;
  virtual int parseSqlScriptFileEx(grt::Ref<db_Catalog> catalog, const std::string filename, const grt::DictRef options)= 0;

  virtual Invalid_sql_parser::Ref invalidSqlParser()= 0;
  virtual int parseInserts(grt::Ref<db_Table> table, const std::string sql)= 0;
  virtual int parseTriggers(grt::Ref<db_Table> table, const std::string sql)= 0;
  virtual int parseRoutine(grt::Ref<db_Routine> routine, const std::string sql)= 0;
  virtual int parseRoutines(grt::Ref<db_RoutineGroup> routineGroup, const std::string sql)= 0;
  virtual int parseView(grt::Ref<db_View> view, const std::string sql)= 0;

  virtual Sql_syntax_check::Ref sqlSyntaxCheck()= 0;
  virtual int checkSqlSyntax(const std::string sql)= 0;
  virtual int checkTriggerSyntax(const std::string sql)= 0;
  virtual int checkViewSyntax(const std::string sql)= 0;
  virtual int checkRoutineSyntax(const std::string sql)= 0;

  virtual Sql_semantic_check::Ref sqlSemanticCheck()= 0;

  virtual Sql_specifics::Ref sqlSpecifics()= 0;

  virtual Sql_normalizer::Ref sqlNormalizer()= 0;
  virtual std::string normalizeSqlStatement(const std::string sql, const std::string schema_name)= 0;
  virtual std::string removeInterTokenSpaces(const std::string sql) = 0;

  virtual Sql_inserts_loader::Ref sqlInsertsLoader()= 0;

  virtual Sql_schema_rename::Ref sqlSchemaRenamer()= 0;
  virtual int renameSchemaReferences(grt::Ref<db_Catalog> catalog, const std::string old_schema_name, const std::string new_schema_name)= 0;

  virtual Sql_statement_decomposer::Ref sqlStatementDecomposer()= 0;

  virtual bool parseSelectStatementForEdit(const std::string &sql, std::string &schema_name, std::string &table_name, Column_name_list &column_names)= 0;
};


#endif /* _SQL_FACADE_H_ */