New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YSQL] DELETE doesn't work when specifying a float key via JDBC #18461
Comments
@komamitsu what version of postgresql did you use to test? Did you try with 11.x ? |
@ddorian I used PostgreSQL 15.1. |
I don't have a permission to the JIRA ticket, so could you tell me if there is any updates? Thanks. |
The JIRA ticket is created automatically. I've asked a developer to take a look at this. I couldn't reproduce on python though. |
@ddorian Thanks for taking care of this issue. BTW, I used Java 11 (Temurin) and PostgreSQL JDBC |
Due to internal precision errors in rounding up floating-point numbers it is always incorrect to test floats for exact equality. |
@andrei-mart Thanks for replying on this issue. What I'm wondering is as follow
And I didn't get what you mean by "randomly" while this issue doesn't happen at all in PostgreSQL. I'm evaluating YugabyteDB for some reasons as a scalable PostgreSQL compatible database. But are you saying it's not compatible...? |
This is a typical computer science problem.
Read https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT , specifically this section:::
I can find the same thing in MYSQL docs https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html
So this is compatible with PostgreSQL. You just didn't hit it yet in PostgreSQL with your exact float-number above, but you will hit it, guaranteed, randomly. |
@ddorian Thanks for pointing the documents. I agree with the difficulty in handling floating point types.
So I guess YugabyteDB uses different ways to look up with float type key in SELECT and DELETE. But I think we don't need to discuss on this issue anymore. |
Are you guaranteed this won't happen in postgresql/mysql? |
@ddorian No. I don't guarantee that as I've not looked into the implementations yet. https://gist.github.com/komamitsu/6df9fd53312c33b46b4bb0c9018652b9 I tried to reproduce this issue with PostgreSQL, MySQL and YugabyteDB some times (n = 10000) using the code on the Gist, but the results were significantly different.
So this issue might happen randomly in PostgreSQL and MySQL as well, but I would conclude that how often the issue occurs is significantly different with YugabyteDB. |
I still don't understand how you'd expect for this to work in production. Can you explain more your use-case? Along with the failure modes of float-keys not working correctly? |
Yeah. We've developed some products that works with underlying databases (e.g., PostgreSQL, MySQL, Oracle, SQL Server.) Our users can perform CRUD operations including floating point type key lookup through them. As you said, using float key may fail randomly, but we've not seen this issue over a lot of tests and our users might expect their float key lookup works with "supported database". We're interested in this scalable PostgreSQL compatible database YugabyteDB supporting multi-region replication as a candidate. We can say that our products support YugabyteDB as an underlying database once this issue is resolved. But I don't want to push you on this issue so hard. |
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
The text was updated successfully, but these errors were encountered: