1 | public class IndexSourceTab extends FormattedSourceTab↵ | | 1 | public class MysqlViewSourceTab extends FormattedSourceTab↵
|
2 | {↵ | | 2 | {↵
|
3 | /** SQL that retrieves the source of an index. */↵ | | 3 | /** SQL that retrieves the source of a view. */↵
|
4 | private static String SQL =↵ | | 4 | private static String SQL =↵
|
5 | "select " +↵ | | 5 | "↵
|
6 | "'create '||index_type_name||' '||index_name||' ON '||table_name||'('||column_name||')' " +↵ | | 6 | SELECT VIEW_DEFINITION " +↵
|
7 | "from INFORMATION_SCHEMA.INDEXES " +↵ | | 7 | "FROM INFORMATION_SCHEMA.VIEWS " +↵
|
8 | "where table_schema = ? " +↵ | | 8 | "WHERE TABLE_SCHEMA = ? " +↵
|
9 | "and index_name = ? ";↵ | | 9 | "AND TABLE_NAME = ? ";↵
|
10 | ↵ | | 10 | ↵
|
11 | /** Logger for this class. */↵ | | 11 | /** Logger for this class. */↵
|
12 | private final static ILogger s_log =↵ | | 12 | private final static ILogger s_log =↵
|
13 | LoggerController.createLogger(ViewSourceTab.class);↵ | | 13 | LoggerController.createLogger(MysqlViewSourceTab.class);↵
|
|
14 | public IndexSourceTab(String hint, String stmtSep)↵ | | 14 | public MysqlViewSourceTab(String hint, String stmtSep)↵
|
15 | {↵ | | 15 | {↵
|
16 | super(hint);↵ | | 16 | super(hint);↵
|
17 | super.setCompressWhitespace(true);↵ | | 17 | super.set↵
|
18 | super.setupFormatter(stmtSep, null); ↵ | | 18 | upFormatter(stmtSep, null);↵
|
| | | 19 | super.setCompressWhitespace(true);↵
|
19 | }↵ | | 20 | }↵
|
|
20 | protected PreparedStatement createStatement() throws SQLException↵ | | 21 | protected PreparedStatement createStatement() throws SQLException↵
|
21 | {↵ | | 22 | {↵
|
22 | final ISession session = getSession();↵ | | 23 | final ISession session = getSession();↵
|
23 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵ | | 24 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵
|
|
24 | ISQLConnection conn = session.getSQLConnection();↵ | | 25 | ISQLConnection conn = session.getSQLConnection();↵
|
25 | if (s_log.isDebugEnabled()) {↵ | | 26 | if (s_log.isDebugEnabled()) {↵
|
26 | s_log.debug("Running SQL for index source tab: "+SQL);↵ | | 27 | s_log.debug("Running SQL for View source tab: "+SQL);↵
|
27 | s_log.debug("schema name: "+doi.getSchemaName()↵ | | 28 | s_log.debug("Binding catalog name "+doi.getCatalogName()+↵
|
28 | );↵ | | 29 | " as first bind value");↵
|
29 | s_log.debug("index name: "+doi.getSimpleName());↵ | | 30 | s_log.debug("Binding table name "+doi.getSimpleName()+↵
|
| | | 31 | " as second bind value"); ↵
|
| | | 32 | ↵
|
30 | }↵ | | 33 | }↵
|
31 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵ | | 34 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵
|
32 | ↵ | | 35 | ↵
|
33 | pstmt.setString(1, doi.getSchemaName());↵ | | 36 | pstmt.setString(1, doi.getCatalogName());↵
|
34 | pstmt.setString(2, doi.getSimpleName());↵ | | 37 | pstmt.setString(2, doi.getSimpleName());↵
|
35 | return pstmt | | 38 | return pstmt
|