Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.3.3, 1.3.4
-
None
-
'org.mariadb.jdbc:mariadb-java-client:1.3.4'
MariaDB 10.0.22
Description
ResultSet.getString() returns "1" for BOOLEAN/TINYINT fields with '0' value.
Statement stmt = con.createStatement();
|
stmt.executeUpdate("drop table if exists tt");
|
stmt.executeUpdate("create table tt(t1 BOOLEAN)");
|
stmt.executeUpdate("insert into tt(t1) values(FALSE)");
|
ResultSet q = stmt.executeQuery("select t1 from tt");
|
while (q.next())
|
{
|
String res = q.getString(1);
|
boolean b = q.getBoolean(1);
|
System.out.println(res + "/" + b);
|
}
|
This code prints
1/false
|
in version 1.3.4 and
0/false
|
in version 1.2.3
The problem seems to be in MariaDbValueObject, isBinaryEncoded=false, but the value 48='0' is evaluated as binary.
Code-Snippet:
case TINYINT:
|
if (options.tinyInt1isBit && columnInfo.getLength() == 1) {
|
return (rawBytes[0] == 0) ? "0" : "1";
|
}
|
if (this.isBinaryEncoded) {
|
return String.valueOf(getTinyInt());
|
}
|
break;
|
Values in debugger:
this MariaDbValueObject (id=21)
|
columnInfo ColumnInformation (id=23)
|
buffer HeapByteBuffer (id=34)
|
charsetNumber 63
|
decimals 0
|
flags 0
|
length 1
|
type MariaDbType (id=25)
|
dataType MariaDbType (id=25)
|
isBinaryEncoded false
|
options Options (id=30)
|
allowLocalInfile true
|
allowMultiQueries false
|
alwaysAutoGeneratedKeys false
|
assureReadOnly false
|
autoReconnect false
|
cachePrepStmts true
|
clientCertificateKeyStorePassword null
|
clientCertificateKeyStoreUrl null
|
connectTimeout null
|
createDatabaseIfNotExist false
|
dumpQueriesOnException false
|
failOnReadOnly false
|
failoverLoopRetries 120
|
interactiveClient false
|
loadBalanceBlacklistTimeout 50
|
localSocket null
|
localSocketAddress null
|
maximizeMysqlCompatibility false
|
nullCatalogMeansCurrent true
|
password "" (id=40)
|
pinGlobalTxToPhysicalConnection false
|
pipe null
|
prepStmtCacheSize Integer (id=43)
|
prepStmtCacheSqlLimit Integer (id=46)
|
retriesAllDown 120
|
rewriteBatchedStatements false
|
serverSslCert null
|
serverTimezone null
|
sessionVariables null
|
sharedMemory null
|
socketFactory null
|
socketTimeout null
|
tcpAbortiveClose false
|
tcpKeepAlive false
|
tcpNoDelay false
|
tcpRcvBuf null
|
tcpSndBuf null
|
tinyInt1isBit true
|
trustCertificateKeyStorePassword null
|
trustCertificateKeyStoreUrl null
|
trustServerCertificate false
|
useCompression false
|
useFractionalSeconds true
|
useLegacyDatetimeCode true
|
useOldAliasMetadataBehavior false
|
user "root" (id=107)
|
useServerPrepStmts true
|
useSsl false
|
validConnectionTimeout 120
|
yearIsDateType true
|
rawBytes (id=32)
|
[0] 48
|
cal null
|
Attachments
Issue Links
- is caused by
-
CONJ-225 limit cause `getString` from int column error.
- Closed