Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/jdbc/MonetResultSetMetaData.java @ 973:32f246853ec4 default tip
Optimisation, call connection.mapClobAsVarChar() and connection.mapBlobAsVarBinary() outside the for-loop, as it does not change.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 10 Apr 2025 19:26:59 +0200 (4 hours ago) |
parents | ff075ed5ce81 |
children |
comparison
equal
deleted
inserted
replaced
972:f19623e0f527 | 973:32f246853ec4 |
---|---|
119 colCount = columns.length; | 119 colCount = columns.length; |
120 if (columns.length != tables.length || columns.length != types.length ) { | 120 if (columns.length != tables.length || columns.length != types.length ) { |
121 throw new IllegalArgumentException("Inconsistent Header metadata"); | 121 throw new IllegalArgumentException("Inconsistent Header metadata"); |
122 } | 122 } |
123 | 123 |
124 final boolean mapClobAsVarChar = connection.mapClobAsVarChar(); | |
125 final boolean mapBlobAsVarBinary = connection.mapBlobAsVarBinary(); | |
124 // derive the JDBC SQL type codes from the types[] names once | 126 // derive the JDBC SQL type codes from the types[] names once |
125 JdbcSQLTypes = new int[types.length]; | 127 JdbcSQLTypes = new int[types.length]; |
126 for (int i = 0; i < types.length; i++) { | 128 for (int i = 0; i < types.length; i++) { |
127 int javaSQLtype = MonetDriver.getJdbcSQLType(types[i]); | 129 int javaSQLtype = MonetDriver.getJdbcSQLType(types[i]); |
128 if (javaSQLtype == Types.CLOB) { | 130 if (javaSQLtype == Types.CLOB && mapClobAsVarChar) { |
129 if (connection.mapClobAsVarChar()) | 131 javaSQLtype = Types.VARCHAR; |
130 javaSQLtype = Types.VARCHAR; | |
131 } else | 132 } else |
132 if (javaSQLtype == Types.BLOB) { | 133 if (javaSQLtype == Types.BLOB && mapBlobAsVarBinary) { |
133 if (connection.mapBlobAsVarBinary()) | 134 javaSQLtype = Types.VARBINARY; |
134 javaSQLtype = Types.VARBINARY; | |
135 } | 135 } |
136 JdbcSQLTypes[i] = javaSQLtype; | 136 JdbcSQLTypes[i] = javaSQLtype; |
137 } | 137 } |
138 | 138 |
139 // initialize structures for storing columns info on nullability and autoincrement | 139 // initialize structures for storing columns info on nullability and autoincrement |