1 | public class MysqlProcedureSourceTab extends FormattedSourceTab ↵ | | 1 | public class ProcedureSourceTab extends FormattedSourceTab↵
|
2 | {↵ | | 2 | {↵
|
3 | /** SQL that retrieves the source of a stored procedure. */↵ | | 3 | /** SQL that retrieves the source of a stored procedure. */↵
|
4 | private static String SQL =↵ | | 4 | private static String SQL =↵
|
5 | "select routine_definition " +↵ | | 5 | "↵
|
6 | "from information_schema.ROUTINES " +↵ | | |
|
7 | "where ROUTINE_SCHEMA↵ | | 6 | SELECT p.prosrc FROM pg_proc p, pg_namespace n " +↵
|
| | | 7 | "where p.pronamespace = n.oid " +↵
|
8 | = ? " +↵ | | 8 | "and n.nspname = ? " +↵
|
9 | "and ROUTINE_NAME = ? ";↵ | | 9 | "and p.proname = ? ";↵
|
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(MysqlProcedureSourceTab.class);↵ | | 13 | LoggerController.createLogger(ProcedureSourceTab.class);↵
|
|
14 | public MysqlProcedureSourceTab(String hint)↵ | | 14 | public ProcedureSourceTab(String hint)↵
|
15 | {↵ | | 15 | {↵
|
16 | super(hint);↵ | | 16 | super(hint);↵
|
17 | super.setCompressWhitespace(false);↵ | | 17 | super.setCompressWhitespace(false);↵
|
18 | }↵ | | 18 | }↵
|
|
19 | protected PreparedStatement createStatement() throws SQLException↵ | | 19 | protected PreparedStatement createStatement() throws SQLException↵
|
20 | {↵ | | 20 | {↵
|
21 | final ISession session = getSession();↵ | | 21 | final ISession session = getSession();↵
|
22 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵ | | 22 | final IDatabaseObjectInfo doi = getDatabaseObjectInfo();↵
|
|
23 | if (s_log.isDebugEnabled()) {↵ | | 23 | if (s_log.isDebugEnabled()) {↵
|
24 | s_log.debug("Running SQL for procedure source: "+SQL);↵ | | 24 | s_log.debug("Running SQL for procedure source: "+SQL);↵
|
25 | s_log.debug("schema="+doi.getCatalogName());↵ | | 25 | s_log.debug("schema="+doi.getSchemaName());↵
|
26 | s_log.debug("procedure name="+doi.getSimpleName());↵ | | 26 | s_log.debug("procedure name="+doi.getSimpleName());↵
|
27 | }↵ | | 27 | }↵
|
28 | ↵ | | 28 | ↵
|
29 | ISQLConnection conn = session.getSQLConnection();↵ | | 29 | ISQLConnection conn = session.getSQLConnection();↵
|
30 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵ | | 30 | PreparedStatement pstmt = conn.prepareStatement(SQL);↵
|
| | | 31 | // Postgres pg_proc table doesn't appear to have schema. I couldn't↵
|
| | | 32 | // locate another table to join with to get this info either.↵
|
31 | pstmt.setString(1, doi.getCatalogName());↵ | | 33 | pstmt.setString(1, doi.getSchemaName());↵
|
32 | pstmt.setString(2, doi.getSimpleName());↵ | | 34 | pstmt.setString(2, doi.getSimpleName());↵
|
33 | return pstmt;↵ | | 35 | return pstmt;↵
|
34 | | | 36 |
|