Skip to content

Commit b94cfa5

Browse files
fixes #12 - Context menu is slow bug
use dba_synonyms instead of all_synonyms when possible
1 parent f8e700a commit b94cfa5

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

sqldev/src/main/java/org/utplsql/sqldev/dal/UtplsqlDao.xtend

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.sql.Connection
1919
import java.util.List
20+
import org.springframework.dao.DataAccessException
2021
import org.springframework.dao.EmptyResultDataAccessException
2122
import org.springframework.jdbc.core.BeanPropertyRowMapper
2223
import org.springframework.jdbc.core.JdbcTemplate
@@ -33,6 +34,20 @@ class UtplsqlDao {
3334
this.jdbcTemplate = new JdbcTemplate(new SingleConnectionDataSource(conn, true))
3435
}
3536

37+
def boolean isDbaViewAccessible() {
38+
try {
39+
val sql = '''
40+
SELECT 1
41+
FROM dba_objects
42+
WHERE 1=2
43+
'''
44+
jdbcTemplate.execute(sql)
45+
return true
46+
} catch (DataAccessException e) {
47+
return false
48+
}
49+
}
50+
3651
/**
3752
* Gets the schema name of the utPLSQL installation.
3853
*
@@ -42,7 +57,7 @@ class UtplsqlDao {
4257
def String getUtplsqlSchema() {
4358
val sql = '''
4459
SELECT table_owner
45-
FROM all_synonyms
60+
FROM «IF dbaViewAccessible»dba«ELSE»all«ENDIF»_synonyms
4661
WHERE owner = 'PUBLIC'
4762
AND synonym_name = '«UTPLSQL_PACKAGE_NAME»'
4863
AND table_name = '«UTPLSQL_PACKAGE_NAME»'

sqldev/src/test/java/org/utplsql/sqldev/tests/DalTest.xtend

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ class DalTest extends AbstractJdbcTest {
3535
} catch (BadSqlGrammarException e) {
3636
// ignore
3737
}
38-
}
38+
}
39+
40+
@Test
41+
def void isDbaViewAccessible() {
42+
val dao = new UtplsqlDao(dataSource.connection)
43+
Assert.assertFalse(dao.dbaViewAccessible)
44+
val sysDao = new UtplsqlDao(sysDataSource.connection)
45+
Assert.assertTrue(sysDao.dbaViewAccessible)
46+
}
3947

4048
@Test
4149
def void utplsqlSchema() {

0 commit comments

Comments
 (0)