Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/util/MDBvalidator.java @ 936:e9d65d746c80
When querying unique constraints metadata include new type 3 (= Unique Key With Nulls Not Distinct).
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 12 Dec 2024 19:00:34 +0100 (4 months ago) |
parents | 540d8b5944b1 |
children | d416e9b6b3d0 |
comparison
equal
deleted
inserted
replaced
935:540d8b5944b1 | 936:e9d65d746c80 |
---|---|
276 return; | 276 return; |
277 | 277 |
278 // fetch the primary or unique key info from the MonetDB system tables | 278 // fetch the primary or unique key info from the MonetDB system tables |
279 final StringBuilder sb = new StringBuilder(400); | 279 final StringBuilder sb = new StringBuilder(400); |
280 sb.append(" FROM sys.keys k JOIN sys.tables t ON k.table_id = t.id JOIN sys.schemas s ON t.schema_id = s.id" | 280 sb.append(" FROM sys.keys k JOIN sys.tables t ON k.table_id = t.id JOIN sys.schemas s ON t.schema_id = s.id" |
281 + " WHERE k.\"type\" = ").append(pkey ? 0 : 1) // 0 = primary keys, 1 = unique keys | 281 + " WHERE k.\"type\" ").append(pkey ? "= 0" : "IN (1,3)") // 0 = Primary Key, 1 = Unique Key, 3 = Unique Key With Nulls Not Distinct |
282 .append(" and s.name = '").append(schema).append('\''); | 282 .append(" and s.name = '").append(schema).append('\''); |
283 String qry = sb.toString(); | 283 String qry = sb.toString(); |
284 final int count = runCountQuery(qry); | 284 final int count = runCountQuery(qry); |
285 if (showValidationInfo) | 285 if (showValidationInfo) |
286 System.out.println("Checking " + minimumWidth(count,6) + " keys in schema " + schema + " for " + checkType + " violations."); | 286 System.out.println("Checking " + minimumWidth(count,6) + " keys in schema " + schema + " for " + checkType + " violations."); |
289 try { | 289 try { |
290 sb.setLength(0); // empty previous usage of sb | 290 sb.setLength(0); // empty previous usage of sb |
291 // fetch the primary or unique key info including columns from the MonetDB system tables | 291 // fetch the primary or unique key info including columns from the MonetDB system tables |
292 sb.append("SELECT s.name as sch_nm, t.name as tbl_nm, k.name as key_nm, o.name as col_nm, o.nr") | 292 sb.append("SELECT s.name as sch_nm, t.name as tbl_nm, k.name as key_nm, o.name as col_nm, o.nr") |
293 .append(" FROM sys.keys k JOIN sys.objects o ON k.id = o.id JOIN sys.tables t ON k.table_id = t.id JOIN sys.schemas s ON t.schema_id = s.id" | 293 .append(" FROM sys.keys k JOIN sys.objects o ON k.id = o.id JOIN sys.tables t ON k.table_id = t.id JOIN sys.schemas s ON t.schema_id = s.id" |
294 + " WHERE k.\"type\" = ").append(pkey ? 0 : 1) // 0 = primary keys, 1 = unique keys | 294 + " WHERE k.\"type\" ").append(pkey ? "= 0" : "IN (1,3)") // 0 = Primary Key, 1 = Unique Key, 3 = Unique Key With Nulls Not Distinct |
295 .append(" and s.name = '").append(schema).append('\'') | 295 .append(" and s.name = '").append(schema).append('\'') |
296 .append(" ORDER BY t.name, k.name, o.nr;"); | 296 .append(" ORDER BY t.name, k.name, o.nr;"); |
297 qry = sb.toString(); | 297 qry = sb.toString(); |
298 rs = stmt.executeQuery(qry); | 298 rs = stmt.executeQuery(qry); |
299 if (rs != null) { | 299 if (rs != null) { |