-
Notifications
You must be signed in to change notification settings - Fork 874
Fix bugs #240 and #296, parameter substituion troubles #307
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
Conversation
This is about as simple as I can make it.
Properly handle escaped single quote character ('') in a quoted section during query parameter substitution.
|
Excellent, Glen! I have a question: This parameter substitution method seems more and more to me like a mini syntactic sql parser, is that right? |
|
One suggestion: I think you could simplify your tests by using TestCase attributes: http://nunit.org/index.php?p=testCase&r=2.5 Your test could be something like: Nunit would take care of calling your test method with the provided values as parameter. I learned this awesome trick from Shay's test I hope it helps. |
|
Yes. Unfortunately. That is the reality of doing client side parameter On Sat, Aug 2, 2014 at 10:15 PM, Francisco Figueiredo Jr. <
|
|
Oh, that is interesting, and I had no idea. I'll look at using that -Glen On Sat, Aug 2, 2014 at 10:29 PM, Francisco Figueiredo Jr. <
|
I see. I asked that because I was a little worried about its complexity :) Regarding the all parameter substitution at the backend, I think this wouldn't be possible as we have to send at least the query with the parameter markers $1, $2 etc.
Yes. It is very nice and very powerful! Based on that, I also used the Values attribute http://nunit.org/index.php?p=values&r=2.5 to handle preparing inside the tests. Check the tests in #257 |
|
On Sat, Aug 2, 2014 at 10:42 PM, Francisco Figueiredo Jr. <
Yep, that's a big part of the breaking change. The actual syntax would -Glen —
|
|
Oh wow, I really was out of my depth. I didn't even really internalize the fact that we do parameter parsing in Npgsql itself... Thanks for all the explanations. It's obviously clear this isn't a discusson for the upcoming 2.2 beta, but it's worth having for the version after that. Here are some quick thoughts...
|
|
On Sun, Aug 3, 2014 at 12:25 AM, Shay Rojansky notifications@github.com
Well, but let's be clear. This is a bug fix (and a fairly simple one), and
Francisco will have to answer this with authority, since client side
I don't have answers here, except that I don't think implicit prepare is a
Thank you sir :)
Implicit prepare is probly a bad thing, and the syntax changes. If we
I agree here. But, I think we would need to offer a fairly lengthy life .
|
|
@glenebob, I pretty much agree with everything you say. And of course your bugfix for 2.2 has nothing to do with this discussion. There's one possible good outcome here. If:
Then we can silently get rid of the client-side sub under the hood and nobody will be the wiser. But I'm really not sure about any of the above, of course. I suggest we do our research, IMHO this is a pretty important subject. I've opened #309 to continue the conversation on this, in the meantime I suggest we merge this and go ahead with 2.2 ASAP. |
|
Note that the build server shows test ConnectionStringWithInvalidParameterValue failing: http://build.npgsql.org/viewLog.html?buildId=1790&tab=buildResultsDiv&buildTypeId=npgsql_net45 |
|
On Sun, Aug 3, 2014 at 1:49 AM, Shay Rojansky notifications@github.com
Not sure on these.
But this is a big problem. Npgsql parameters are named. PG parameters are ordinal. -Glen |
I think the idea of Prepare method in the ADO.Net api was to provide a way for the provider to optimize the query processing. Be it using server side support or doing some client side optimization. To me, when the developer decided to call Prepare() it was signalizing to the provider that she would reuse that query and would just change the parameters. So, the provider could make some type of caching or something like that. I remember I've seen a provider which had a connection string called preparebydefault, which would make all the commands be prepared by default. I think that the fact this isn't on by default is because Prepare()'ing a query for reuse could mean more resources being used whose costs would be explained by the reutilization of the query. I think that in the case of Npgsql and postgresql, doing a single query in the simple query path of the protocol has a better performance than doing this same single query in the extended query path. |
In the case of Sql server, when the query is prepared, the provider use sql server support for prepred statements through sp_prepare http://technet.microsoft.com/en-us/library/ff946077%28v=sql.100%29.aspx and sp_execute http://technet.microsoft.com/pt-br/library/ff946038%28v=sql.100%29.aspx When the developer doesn't call Prepare, I think sqlclient does client side parameter subsitution like Npgsql. |
Agreed. I think we need a thoroughly analysis of prepared statements only and its impact (performance and support wise) if we decide to change. |
I noticed that. The last time this error pop up was when we enabled logging. I couldn't reproduce it in my dev machine at the time. |
I just started a build with the "clean all files in the checkout directory before the build" option checked. |
|
I looked at doing this, but with all comments explaining the different -Glen On Sat, Aug 2, 2014 at 10:29 PM, Francisco Figueiredo Jr. <
|
|
Guys, this is my bad - I left two statements to turn on logging in the unit test. @glenebob, just remove the two offending lines here and this PR should pass all tests: https://github.com/glenebob/Npgsql2/commit/d45f620955d02bd04b263d04cfa77db53fbeec0d#diff-d00d89f70ac53244e7449ab9e43ec7c2R3938 |
|
Done, Take a look please :) -Glen On Mon, Aug 4, 2014 at 8:03 AM, Shay Rojansky notifications@github.com
|
|
Just look at that nice green checkmark from the build server... Merge away! |
Ahh, ok! You are right. It wouldn't be worthwhile. Thanks for having a look at it. |
Hey guys,
Here's the fix for bugs #240 and #296.
I somehow managed to overlook single quote escaping in quoted sections when I re-wrote the query parameter substitution logic, Luckily it was a straight forward fix.
No regressions found when running the tests.
-Glen