You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Alexander Belyak (Jira)" <ji...@apache.org> on 2022/04/21 09:59:00 UTC

[jira] [Updated] (IGNITE-16830) Wrong prepared statement type casting

     [ https://issues.apache.org/jira/browse/IGNITE-16830?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexander Belyak updated IGNITE-16830:
--------------------------------------
    Description: 
Apache Ignite ignores numeric parameter types in PreparedStatement. I mean it ignores "long" type of parameter and uses it as an integer, so 
{noformat}
select 912456000000 - ? * 86400000{noformat}
{color:#172b4d}with parameter value (long)220 {color}

 
{noformat}
try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/")) {
//try(Connection conn = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/test","postgres", "postgres")) {
try (PreparedStatement select = conn.prepareStatement("select 912456000000 - ? * 86400000")) {
select.setLong(1, 220);
ResultSet rs = select.executeQuery();
rs.next();
System.out.println("======== " + rs.getLong(1));
}
}
{noformat}
 

{color:#172b4d}leads to {color}
{noformat}
Numeric value out of range: "19008000000"{noformat}
on Ignite, but work great on PGSQL (for example).

And it works if we convert the parameter explicitly:

 
{noformat}
select 912456000000 - cast(? as bigint) * 86400000{noformat}
 

And second related problem is that I can't select row from table with bigint key if I pass int as a parameter in prepared statement. For example:

 

 

 

 

df

 

 

 

  was:
Apache Ignite ignores numeric parameter types in PreparedStatement. I mean it ignores "long" type of parameter and uses it as an integer, so 
{noformat}
select 912456000000 - ? * 86400000{noformat}
{color:#172b4d}with parameter value (long)220 
{color}

 
{noformat}
try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/")) {
//try(Connection conn = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/test","postgres", "postgres")) {
try (PreparedStatement select = conn.prepareStatement("select 912456000000 - ? * 86400000")) {
select.setLong(1, 220);
ResultSet rs = select.executeQuery();
rs.next();
System.out.println("======== " + rs.getLong(1));
}
}
{noformat}
 

{color:#172b4d}leads to 
{color}
{noformat}
Numeric value out of range: "19008000000"{noformat}
on Ignite, but work great on PGSQL (for example).

And it works if we convert the parameter explicitly:
{noformat}
select 912456000000 - cast(? as bigint) * 86400000{noformat}


> Wrong prepared statement type casting
> -------------------------------------
>
>                 Key: IGNITE-16830
>                 URL: https://issues.apache.org/jira/browse/IGNITE-16830
>             Project: Ignite
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.11.1
>            Reporter: Alexander Belyak
>            Priority: Major
>
> Apache Ignite ignores numeric parameter types in PreparedStatement. I mean it ignores "long" type of parameter and uses it as an integer, so 
> {noformat}
> select 912456000000 - ? * 86400000{noformat}
> {color:#172b4d}with parameter value (long)220 {color}
>  
> {noformat}
> try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/")) {
> //try(Connection conn = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/test","postgres", "postgres")) {
> try (PreparedStatement select = conn.prepareStatement("select 912456000000 - ? * 86400000")) {
> select.setLong(1, 220);
> ResultSet rs = select.executeQuery();
> rs.next();
> System.out.println("======== " + rs.getLong(1));
> }
> }
> {noformat}
>  
> {color:#172b4d}leads to {color}
> {noformat}
> Numeric value out of range: "19008000000"{noformat}
> on Ignite, but work great on PGSQL (for example).
> And it works if we convert the parameter explicitly:
>  
> {noformat}
> select 912456000000 - cast(? as bigint) * 86400000{noformat}
>  
> And second related problem is that I can't select row from table with bigint key if I pass int as a parameter in prepared statement. For example:
>  
>  
>  
>  
> df
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)