You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2010/11/06 02:08:56 UTC

[jira] Created: (DERBY-4889) Different byte to boolean conversion on embedded and client

Different byte to boolean conversion on embedded and client
-----------------------------------------------------------

                 Key: DERBY-4889
                 URL: https://issues.apache.org/jira/browse/DERBY-4889
             Project: Derby
          Issue Type: Bug
          Components: JDBC
    Affects Versions: 10.7.1.0
            Reporter: Knut Anders Hatlen


The following code prints "true" with the embedded driver and "false" with the client driver:

        PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
        ps.setByte(1, (byte) 32);
        ResultSet rs = ps.executeQuery();
        rs.next();
        System.out.println(rs.getBoolean(1));

If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928910#action_12928910 ] 

Knut Anders Hatlen commented on DERBY-4889:
-------------------------------------------

Same issue exists for getShort().

> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-4889:
--------------------------------------

    Fix Version/s: 10.7.1.0

> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Rick Hillegas
>             Fix For: 10.7.1.0
>
>         Attachments: derby-4889-01-aa-removeSpecialCase.diff
>
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Hillegas reassigned DERBY-4889:
------------------------------------

    Assignee: Rick Hillegas

> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Rick Hillegas
>         Attachments: derby-4889-01-aa-removeSpecialCase.diff
>
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12929599#action_12929599 ] 

Rick Hillegas commented on DERBY-4889:
--------------------------------------

Thanks for finding this bug, Knut. I can confirm this behavior also with the following INSERT statement where column A has type BOOLEAN:

insert into t( a ) values ( ? )

For the client, the following calls insert TRUE:

ps.setInt( 1, 32 );
ps.setLong( 1, 32 );
ps.setObject( 1, new Integer( 32 ) );
ps.setObject( 1, new Long( 32L ) );

but the following calls insert FALSE:

ps.setByte( 1, (byte) 32 );
ps.setByte( 1, (short) 32 );
ps.setObject( 1, new Byte( (byte) 32 ) );
ps.setObject( 1, new Short( (short) 32 ) );

All calls insert TRUE in the embedded case.

> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928915#action_12928915 ] 

Knut Anders Hatlen commented on DERBY-4889:
-------------------------------------------

Also an issue for setObject() with a java.lang.Byte or java.lang.Short object.

> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Hillegas updated DERBY-4889:
---------------------------------

    Attachment: derby-4889-01-aa-removeSpecialCase.diff

Attaching derby-4889-01-aa-removeSpecialCase.diff. This patch removes a piece of defensive coding which caused this error. The regression tests passed for me on this patch. In addition, I ran the compabitility tests using two versions of Derby: 10.6.1.0 and the trunk. Those tests ran cleanly too. Committed at subversion revision 1032667.

There was a piece of defensive coding in the server-side network code which really didn't do anything except cause this bug. I removed that code. Now the test cases run correctly.

Touches the following files:

-------------

M      java/drda/org/apache/derby/impl/drda/DRDAConnThread.java

Removed the defensive code which caused the bug.

-------------

Removed a special case which Knut added in order to enable some boolean tests. The special case canonized wrong results for the network run.

M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java


> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>         Attachments: derby-4889-01-aa-removeSpecialCase.diff
>
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928910#action_12928910 ] 

Knut Anders Hatlen edited comment on DERBY-4889 at 11/5/10 10:07 PM:
---------------------------------------------------------------------

Same issue exists for setShort().

      was (Author: knutanders):
    Same issue exists for getShort().
  
> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-4889:
--------------------------------------

    Bug behavior facts: [Embedded/Client difference]

> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12929494#action_12929494 ] 

Knut Anders Hatlen commented on DERBY-4889:
-------------------------------------------

ParameterMappingTest contains a workaround for this issue. Search for a comment with this issue number in the source file.

> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen closed DERBY-4889.
-------------------------------------


I've verified that the code in the bug description produces the expected result for all valid short and byte values now. Thanks for fixing it, Rick.

> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Rick Hillegas
>             Fix For: 10.7.1.0
>
>         Attachments: derby-4889-01-aa-removeSpecialCase.diff
>
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DERBY-4889) Different byte to boolean conversion on embedded and client

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4889?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Hillegas resolved DERBY-4889.
----------------------------------

    Resolution: Fixed

> Different byte to boolean conversion on embedded and client
> -----------------------------------------------------------
>
>                 Key: DERBY-4889
>                 URL: https://issues.apache.org/jira/browse/DERBY-4889
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.7.1.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Rick Hillegas
>         Attachments: derby-4889-01-aa-removeSpecialCase.diff
>
>
> The following code prints "true" with the embedded driver and "false" with the client driver:
>         PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
>         ps.setByte(1, (byte) 32);
>         ResultSet rs = ps.executeQuery();
>         rs.next();
>         System.out.println(rs.getBoolean(1));
> If setByte() is replaced with setInt(), they both print "true".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.