Skip to content

Commit

Permalink
Optimise code, use append(char) instead of append(String)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdvm committed Apr 4, 2024
1 parent 1da9643 commit 571bca8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ public void setBytes(final int parameterIndex, final byte[] x) throws SQLExcepti
hex.append(HEXES[(b & 0xF0) >> 4])
.append(HEXES[(b & 0x0F)]);
}
hex.append("'"); // end of hex string value
hex.append('\''); // end of hex string value
setValue(parameterIndex, hex.toString());
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/monetdb/jdbc/MonetResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2115,9 +2115,9 @@ private final int getJavaDate(final Calendar cal, final int columnIndex, int typ
} else if (epos < monetDate.length()) {
errMsg.append("parsing failed at pos ").append(epos + (negativeYear ? 2 : 1))
.append(" found: '").append(monetDate.charAt(epos))
.append("' in '").append(monetDateStr).append("'");
.append("' in '").append(monetDateStr).append('\'');
} else {
errMsg.append("parsing failed, expected more data after '").append(monetDateStr).append("'");
errMsg.append("parsing failed, expected more data after '").append(monetDateStr).append('\'');
}
throw new SQLException(errMsg.toString(), "01M10");
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/monetdb/util/MDBvalidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private void validateUniqueness(
final StringBuilder sb = new StringBuilder(400);
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"
+ " WHERE k.type = ").append(pkey ? 0 : 1) // 0 = primary keys, 1 = unique keys
.append(" and s.name = '").append(schema).append("'");
.append(" and s.name = '").append(schema).append('\'');
String qry = sb.toString();
final int count = runCountQuery(qry);
if (showValidationInfo)
Expand All @@ -292,7 +292,7 @@ private void validateUniqueness(
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")
.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"
+ " WHERE k.type = ").append(pkey ? 0 : 1) // 0 = primary keys, 1 = unique keys
.append(" and s.name = '").append(schema).append("'")
.append(" and s.name = '").append(schema).append('\'')
.append(" ORDER BY t.name, k.name, o.nr;");
qry = sb.toString();
rs = stmt.executeQuery(qry);
Expand Down Expand Up @@ -407,7 +407,7 @@ private void validateFKs(
final StringBuilder sb = new StringBuilder(400);
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"
+ " WHERE k.type = 2") // 2 = foreign keys
.append(" and s.name = '").append(schema).append("'");
.append(" and s.name = '").append(schema).append('\'');
String qry = sb.toString();
final int count = runCountQuery(qry);
if (showValidationInfo)
Expand All @@ -431,7 +431,7 @@ private void validateFKs(
" JOIN sys.schemas ps ON pt.schema_id = ps.id" +
" WHERE fk.type = 2" + // 2 = foreign keys
" AND fo.nr = po.nr") // important: matching fk-pk column ordering
.append(" AND fs.name = '").append(schema).append("'")
.append(" AND fs.name = '").append(schema).append('\'')
.append(" ORDER BY ft.name, fk.name, fo.nr;");
qry = sb.toString();
rs = stmt.executeQuery(qry);
Expand Down Expand Up @@ -588,7 +588,7 @@ private void validateNotNull(
sb.append(" from sys.columns c join sys.tables t on c.table_id = t.id join sys.schemas s on t.schema_id = s.id"
+ " where t.type in (0, 10, 1, 11) and c.\"null\" = false" // t.type 0 = TABLE, 10 = SYSTEM TABLE, 1 = VIEW, 11 = SYSTEM VIEW
+ " and t.system = ").append(system)
.append(" and s.name = '").append(schema).append("'");
.append(" and s.name = '").append(schema).append('\'');
String qry = sb.toString();
final int count = runCountQuery(qry);
if (showValidationInfo)
Expand Down Expand Up @@ -640,7 +640,7 @@ private void validateMaxCharStrLength(
+ " and c.type_digits >= 1" // only when a positive max length is specified
+ " and t.system = ").append(system)
.append(" and c.type in ('varchar','char','clob','json','url','blob')") // only for variable character/bytes data type columns
.append(" and s.name = '").append(schema).append("'");
.append(" and s.name = '").append(schema).append('\'');
String qry = sb.toString();
final int count = runCountQuery(qry);
if (showValidationInfo)
Expand Down

0 comments on commit 571bca8

Please sign in to comment.