-
Notifications
You must be signed in to change notification settings - Fork 874
Fix #217 double NaN regression #257
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
Fix #217 double NaN regression #257
Conversation
|
@glenebob , would mind to review this patch and tell me if it is ok, please. Thanks in advance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to quote selectively in the conversion function. It would be a tad more efficient, and of course you would usually not quote at all.
|
I think you could call StringToTextText() if quoting is needed (after doing the conversion to string). That would insulate you from all the quoting complexity. Now that I think about it, I don't think that makes quoting more efficient, but selective quoting is still a Very Good Thing here. |
After commit 854862a Npgsql wasn't adding quotes around float4 and float8 values. But according to documentation, NaN values need to be quoted. Separated handling of float4 and float8 conversion routines.
|
Hi, @glenebob ! Thanks for reviewing. I made some more changes based in your feedback. Now the quote is only added when handling the NaN case. Please, have a look at the new patch and let me know if your think it is ok now. Thanks in advance. |
|
Hi Francisco, Did you test with an array of NaN, and with prepare? I think you need double quotes for arrays, and no quotes ever for extended. It's a little fuzzy now :) Look at NpgsqlNativeTypeInfo.QuoteASCIIString(). That's the logic you need. Maybe you can make it internal and use that? Or, look at StringToTextText(), specifically at how it gets a StringEncodingInfo object. That object contains a field for quote, and it will be ASCIIBytes.SingleQuote, ASCIIBytes.DoubleQuote, or zero, depending on what the backend expects. Look how it's used; if quote == 0, you just return the unquoted string (byte[]), otherwise put on the quote byte at each end. -Glen |
Hi, Glen!
I didn't test with an array of NaN. This patch doesn't change prepared statements because in the current master, they are working ok. The bug only appears when using non prepared statements. But I'll add more tests to confirm that.
Yes, I saw this method. I'll check it. Off topic: I noticed that QuoteASCIIString uses another byte[] in order to add the quotes. I was thinking that in the future we could optimize that to not create a new buffer. Maybe we could defer this quoting until we are sending the data to the stream and then we would make (pseudo code): Thanks for reviewing my patch! |
…heads up. Add tests for Float array.
|
Hi, @glenebob ! You were right about array values. They were broken. But as before, only non prepared statements were affected. Now everything is ok. I checked Please, have a look at it and let me know what you think. Thanks in advance. |
|
@glenebob, @franciscojunior, this is currently marked for the 2.2 release, do you think we'll have time to complete it, or should I move it to 2.3? |
|
Em 27/07/2014 09:39, "Shay Rojansky" notifications@github.com escreveu:
|
|
Hi Francisco, I'm finally able to look at this again. I had some ideas that were way beyond explaining briefly, so I grabbed your branch and added to it, and sent up a new PR, #306. Please have a look :) -Glen |
|
Turns out this PR works great. PG does not use double quotes on NaN values in arrays. |
…sion Fix #217 double NaN regression
|
Great! I'll apply it to release-2.2.0 branch. |
Fix #217
After commit 854862a Npgsql wasn't adding quotes to float4 and float8 values anymore.
But according to documentation, NaN values need to be quoted.
This patch reverts quote handling of float4 and float8 values.