public class MysqlProcedureSourceTab extends FormattedSourceTab { /** SQL that retrieves the source of a stored procedure. */ private static String SQL = "select routine_definition " + "from information_schema.ROUTINES " + "where ROUTINE_SCHEMA = ? " + "and ROUTINE_NAME = ? "; /** Logger for this class. */ private final static ILogger s_log = LoggerController.createLogger(MysqlProcedureSourceTab.class); public MysqlProcedureSourceTab(String hint) { super(hint); super.setCompressWhitespace(false); } protected PreparedStatement createStatement() throws SQLException { final ISession session = getSession(); final IDatabaseObjectInfo doi = getDatabaseObjectInfo(); if (s_log.isDebugEnabled()) { s_log.debug("Running SQL for procedure source: "+SQL); s_log.debug("schema="+doi.getCatalogName()); s_log.debug("procedure name="+doi.getSimpleName()); } ISQLConnection conn = session.getSQLConnection(); PreparedStatement pstmt = conn.prepareStatement(SQL); pstmt.setString(1, doi.getCatalogName()); pstmt.setString(2, doi.getSimpleName()); return pstmt;
public class ProcedureSourceTab extends FormattedSourceTab { /** SQL that retrieves the source of a stored procedure. */ private static String SQL = "SELECT p.prosrc FROM pg_proc p, pg_namespace n " + "where p.pronamespace = n.oid " + "and n.nspname = ? " + "and p.proname = ? "; /** Logger for this class. */ private final static ILogger s_log = LoggerController.createLogger(ProcedureSourceTab.class); public ProcedureSourceTab(String hint) { super(hint); super.setCompressWhitespace(false); } protected PreparedStatement createStatement() throws SQLException { final ISession session = getSession(); final IDatabaseObjectInfo doi = getDatabaseObjectInfo(); if (s_log.isDebugEnabled()) { s_log.debug("Running SQL for procedure source: "+SQL); s_log.debug("schema="+doi.getSchemaName()); s_log.debug("procedure name="+doi.getSimpleName()); } ISQLConnection conn = session.getSQLConnection(); PreparedStatement pstmt = conn.prepareStatement(SQL); // Postgres pg_proc table doesn't appear to have schema. I couldn't // locate another table to join with to get this info either. pstmt.setString(1, doi.getSchemaName()); pstmt.setString(2, doi.getSimpleName()); return pstmt;
Clone fragments detected by clone detection tool
File path: /sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/tab/MysqlProcedureSourceTab.java File path: /sql12/plugins/postgres/src/net/sourceforge/squirrel_sql/plugins/postgres/tab/ProcedureSourceTab.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
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
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0