File path: /sql12/plugins/dbcopy/src/net/sourceforge/squirrel_sql/plugins/dbcopy/util/DBUtil.java | File path: /sql12/plugins/dbdiff/src/net/sourceforge/squirrel_sql/plugins/dbdiff/util/DBUtil.java | |||
Method name: boolean tableHasForeignKey(String, String, String, ForeignKeyInfo, SessionInfoProvider)
|
Method name: boolean tableHasForeignKey(String, String, String, ForeignKeyInfo, SessionInfoProvider)
|
|||
Number of AST nodes: 12 | Number of AST nodes: 12 | |||
1 | boolean result = false;↵ | 1 | boolean result = false;↵ | |
2 | try↵ | 2 | try↵ | |
3 | {↵ | 3 | {↵ | |
4 | SQLDatabaseMetaData md = prov.getCopyDestSession().getSQLConnection().getSQLMetaData();↵ | 4 | SQLDatabaseMetaData md = prov.getDiffDestSession().getSQLConnection().getSQLMetaData();↵ | |
5 | ITableInfo[] tables = ↵ | 5 | ITableInfo[] tables =↵ | |
6 | md.getTables(destCatalog, destSchema, destTableName, new String[]↵ | 6 | md.getTables(destCatalog, destSchema, destTableName, new String[]↵ | |
7 | { "TABLE" }, null);↵ | 7 | { "TABLE" }, null);↵ | |
8 | if (tables != null && tables.length == 1)↵ | 8 | if (tables != null && tables.length == 1)↵ | |
9 | {↵ | 9 | {↵ | |
10 | ForeignKeyInfo[] fks = SQLUtilities.getImportedKeys(tables[0], md);↵ | 10 | ForeignKeyInfo[] fks = SQLUtilities.getImportedKeys(tables[0], md);↵ | |
11 | for (ForeignKeyInfo existingKey : fks)↵ | 11 | for (ForeignKeyInfo existingKey : fks)↵ | |
12 | {↵ | 12 | {↵ | |
13 | if (areEqual(existingKey, fkInfo))↵ | 13 | if (areEqual(existingKey, fkInfo))↵ | |
14 | {↵ | 14 | {↵ | |
15 | result = true;↵ | 15 | result = true;↵ | |
16 | break;↵ | 16 | break;↵ | |
17 | }↵ | 17 | }↵ | |
18 | }↵ | 18 | }↵ | |
19 | } ↵ | 19 | }↵ | |
20 | else↵ | 20 | else↵ | |
21 | {↵ | 21 | {↵ | |
22 | log.error("Couldn't find an exact match for destination table " + destTableName + " in schema "↵ | 22 | log.error("Couldn't find an exact match for destination table " + destTableName + " in schema "↵ | |
23 | + destSchema + " and catalog " + destCatalog + ". Skipping FK constraint");↵ | 23 | + destSchema + " and catalog " + destCatalog + ". Skipping FK constraint");↵ | |
24 | }↵ | 24 | }↵ | |
25 | } ↵ | 25 | }↵ | |
26 | catch (SQLException e)↵ | 26 | catch (SQLException e)↵ | |
27 | {↵ | 27 | {↵ | |
28 | log.error("Unexpected exception while attempting to determine if " + "a table (" + destTableName↵ | 28 | log.error("Unexpected exception while attempting to determine if " + "a table (" + destTableName↵ | |
29 | + ") has a particular foreign " + "key");↵ | 29 | + ") has a particular foreign " + "key");↵ | |
30 | }↵ | 30 | }↵ | |
31 | return result; | 31 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 1.7 |
Clones location | Clones are in different classes |
Number of node comparisons | 32 |
Number of mapped statements | 12 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 12.3 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | boolean result = false; | 1 | boolean result = false; | |||||||||||||||
2 | try | 2 | try | |||||||||||||||
3 | SQLDatabaseMetaData md = prov.getCopyDestSession().getSQLConnection().getSQLMetaData(); |
| 3 | SQLDatabaseMetaData md = prov.getDiffDestSession().getSQLConnection().getSQLMetaData(); | ||||||||||||||
4 | ITableInfo[] tables = md.getTables(destCatalog, destSchema, destTableName, new String[] {"TABLE"}, null); | 4 | ITableInfo[] tables = md.getTables(destCatalog, destSchema, destTableName, new String[] {"TABLE"}, null); | |||||||||||||||
5 | if (tables != null && tables.length == 1) | 5 | if (tables != null && tables.length == 1) | |||||||||||||||
6 | ForeignKeyInfo[] fks = SQLUtilities.getImportedKeys(tables[0], md); | 6 | ForeignKeyInfo[] fks = SQLUtilities.getImportedKeys(tables[0], md); | |||||||||||||||
7 | for (ForeignKeyInfo existingKey : fks) | 7 | for (ForeignKeyInfo existingKey : fks) | |||||||||||||||
8 | if (areEqual(existingKey, fkInfo)) | 8 | if (areEqual(existingKey, fkInfo)) | |||||||||||||||
9 | result = true; | 9 | result = true; | |||||||||||||||
10 | break; | 10 | break; | |||||||||||||||
else | else | |||||||||||||||||
11 | log.error("Couldn't find an exact match for destination table " + destTableName + " in schema " + destSchema + " and catalog " + destCatalog + ". Skipping FK constraint"); | 11 | log.error("Couldn't find an exact match for destination table " + destTableName + " in schema " + destSchema + " and catalog " + destCatalog + ". Skipping FK constraint"); | |||||||||||||||
12 | return result; | 12 | return result; |
Row | Violation |
---|---|
1 | Type net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider of variable prov does not match with type net.sourceforge.squirrel_sql.plugins.dbdiff.SessionInfoProvider of variable prov |