This project is archived and is in readonly mode.
Postgres data corruption for hexadecimal strings composed of zeros and ones destined for bitstring columns
-
Bruce Burdick
Credit goes to Kurt Stephens for identifying this bug.
-
CancelProfileIsBroken
- Tag set to bugmash
-
Santiago Pastorino
- State changed from new to open
- Importance changed from to
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
-
Alex Shulgin
Hello,
Attached is a patch against current master to fix this issue.
I've decided to go with the option two proposed by the reporter: "support either binary or hexadecimal, make no warranty for the other, and fix the driver code." I think it's best to keep only support for binary strings and drop support for hexadecimal, and here's why:
- as pointed out in this issue the hexadecimal notation cannot be
used reliably to put the data into a bit-string column;
- when the data is read from a bit-string column it is always returned as a binary string, so sticking to binary representation helps consistency and avoids surprises;
Now, this change might break some existing code, but since the nature of the issue, this is going to affect only instances of (relatively) short hard-coded hexadecimal strings being put into bit-string columns. Problematic application code will manifest itself with a database error exception, rather than putting incorrect data into column.
-- Alex
- as pointed out in this issue the hexadecimal notation cannot be
used reliably to put the data into a bit-string column;
-
Bruce Burdick
+1 Alex!
I'm amazed that no one from Rails core has thought that this is important for ~18 months. C'est la vie. Thanks for fixing.
-
Xavier Noria
- State changed from stale to open
- Assigned user set to Xavier Noria
