Jira Link: DB-7435
Description
I noticed DELETE statement in YugabyteDB can't delete records when specifying a float key via JDBC.
I think you can reproduce this issue using the following code.
package org.example;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.function.Supplier;
public class Main {
public static void main(String[] args) throws SQLException {
// Supplier<Connection> connFactory = ConnectionUtils.forPg();
Supplier<Connection> connFactory = ConnectionUtils.forYugabyte();
float key = 3.141592f;
try (Connection conn = connFactory.get();
Statement stmt = conn.createStatement()) {
stmt.execute("CREATE TABLE IF NOT EXISTS float_tbl (pk double precision PRIMARY KEY)");
}
try (Connection conn = connFactory.get();
PreparedStatement ps = conn.prepareStatement("INSERT INTO float_tbl (pk) VALUES (?)")) {
ps.setFloat(1, key);
System.out.println("inserted: " + ps.executeUpdate());
}
try (Connection conn = connFactory.get();
PreparedStatement ps = conn.prepareStatement("DELETE FROM float_tbl WHERE pk = ?")) {
ps.setFloat(1, key);
System.out.println("deleted: " + ps.executeUpdate());
}
try (Connection conn = connFactory.get();
PreparedStatement ps = conn.prepareStatement("SELECT pk FROM float_tbl WHERE pk = ?")) {
ps.setFloat(1, key);
ResultSet resultSet = ps.executeQuery();
if (resultSet.next()) {
System.out.println("selected value: " + resultSet.getFloat(1));
}
else {
System.out.println("no selected value");
}
}
}
}
This code creates a table that has a float primary key column, inserts a record and tries to delete the record. But the DELETE statement doesn't delete the record, while it works with PostgreSQL.
> Task :Main.main()
inserted: 1
deleted: 0
selected value: 3.141592
> Task :Main.main()
inserted: 1
deleted: 1
no selected value
I'm using YugabyteDB v2.19.0.0-b190.
Warning: Please confirm that this issue does not contain any sensitive information
Jira Link: DB-7435
Description
I noticed DELETE statement in YugabyteDB can't delete records when specifying a float key via JDBC.
I think you can reproduce this issue using the following code.
This code creates a table that has a float primary key column, inserts a record and tries to delete the record. But the DELETE statement doesn't delete the record, while it works with PostgreSQL.
I'm using YugabyteDB v2.19.0.0-b190.
Warning: Please confirm that this issue does not contain any sensitive information