-
Notifications
You must be signed in to change notification settings - Fork 821
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
Array text encoding #80
Conversation
Encode text arrays using the '{"", ""}' syntax, rather than the array['', ''] syntax.
There is a caveat above. Tests TestBug1010488ArrayParameterWithNullValue and TestBug1010675ArrayParameterWithNullValue() now fail on < 8.2. On < 8.2, using the syntax array[1, 2, NULL]::int4[] silently produces an empty array. Using the syntax '{1, 2, NULL}' produces an error. On 8.2+, either syntax produces the expected array. It was a Postgres bug, not an Npgsql bug. The tests are not complete. If they compared the output to the input, rather than simply looking for an error, the tests would have failed with the old array syntax, too. Of course, Npgsql still can't handle null array elements on arrays of primitive types. That's a design flaw that appears to be particularly nasty to resolve without breaking existing code. -Glen |
… a big nested if/then construct.
…g the need for hash key comparisons in lookup operations.
That's excellent, Glen! Do you think the array[] construct is easier to understand? Or has a better performance? I know you already fixed in this PR to work on pre array[] construct, but I'm asking that because if the new syntax has some advantages, maybe we could add an exception to the case of servers below 7.4? This way we wouldn't need to support a lower performance format. I don't know how many people use below 7.4 postgresql version, but I think it may be few compared to the number of 7.4+ installations. What do you think? Sorry to add even more considerations to the mix of so many changes to array text value encoding code :) |
Ah, and please, don't get me wrong. I'm ok with your approach of using old style array syntax. I just added the comment because maybe there would be benefits from using the new syntax instead of the old one and I'd like to say that I'm ok with adding an exceptional handling of the old syntax for servers below 7.4 only. |
Hi Francisco, Welcome back! It didn't occur to me to compare performance between the two formats. I've master: Elapsed: 00:10.02, CPU: 00:09.188458, Queries: 177; 17.66/second, 19.26/CPU PR #80: Elapsed: 00:10.02, CPU: 00:09.094858, Queries: 179; 17.86/second, 19.68/CPU I'd call that a wash :) As far as understandability goes, I don't really see a big difference. You can also see that, while the text and bytea encoders got a little more -Glen On Thu, Oct 24, 2013 at 7:53 AM, Francisco Figueiredo Jr. <
|
Hi. Glen! Thanks! The vacation was very nice. Now I'm refilled to work more on Npgsql :) Excellent to know the new representation doesn't add any negative performance effects and in fact, as you are saying, it seems to be easier to understand as now we are dealing with only one format :) Excellent work, Glen! |
Expand use of the hash table to control all aspects of string and bytea quoting and escaping. Optimize the hash function to make as few decisions as possible on current PG version.
This last commit seems to run a little faster, since there are now less decisions being made when encoding strings and bytea data to text. |
Excellent, Glen! |
Array text encoding I ran the test suite against 7.3.21, and discovered that array text encoding did not work, because the array[] construct was new in 7.4. So, I re-wrote the array text value encoding code, yet again. What is that, 37 times now? Now it uses the more universal '{"", ""}' syntax. The result is that the array tests run cleanly on all final revisions back to 7.3.21. The different quoting and escaping combinations with plain text encoding will drive a person crazy. -Glen
Fix encoding bug caused by PR #80
Francisco,
I ran the test suite against 7.3.21, and discovered that array text encoding did not work, because the array[] construct was new in 7.4. So, I re-wrote the array text value encoding code, yet again. What is that, 37 times now? Now it uses the more universal '{"", ""}' syntax. The result is that the array tests run cleanly on all final revisions back to 7.3.21.
The different quoting and escaping combinations with plain text encoding will drive a person crazy.
-Glen