Repository navigation
Conversation
9c2cc79 to
12fc53b
Compare
pdo_firebirdpdo_firebird
12fc53b to
7bfb5e6
Compare
|
Sorry for the change in order, but first, I would like to ask you to review this PR. |
|
I found some unnecessary parts, so I'll edit them. |
5d5b183 to
c252527
Compare
|
done |
Girgias
left a comment
There was a problem hiding this comment.
Looks reasonable to me and only have some suggestions
There was a problem hiding this comment.
Won't this duplicate 512 bytes every time?
There was a problem hiding this comment.
Judging from the implementation of pestrdup, it looks fine.
Line 2684 in a35a69f
However, considering the balance with other changes, it seemed better to use pestrndup, so I changed it.
There was a problem hiding this comment.
This has nothing to do with this change, but I'm a little concerned that it haven't given +1 here.
Line 2706 in a35a69f
There was a problem hiding this comment.
No, it's the opposite. +1 to potentially lost the terminating null
Here, _estrdup is getting the length, so there seems to be no problem. Excuse me, I understand.
There was a problem hiding this comment.
Maybe add the length component so that we don't need to recompute known lengths when converting this to zend_string ?
| typedef struct { | |
| int sqlcode; | |
| char *errmsg; | |
| } pdo_firebird_error_info; | |
| typedef struct { | |
| int sqlcode; | |
| char *errmsg; | |
| size_t errmsg_length; | |
| } pdo_firebird_error_info; |
There was a problem hiding this comment.
That's a good idea. Changed pdo_firebird_fetch_error_func to use add_next_index_stringl.
c252527 to
9a435f3
Compare
|
@Girgias |
9a435f3 to
2ca4077
Compare
Girgias
left a comment
There was a problem hiding this comment.
Sorry for being slow, but possibly some more improvements (but they could also be left for later)
There was a problem hiding this comment.
It seems that the msg argument is always constant at the call site. Precomputing the length at call site and passing it as an argument should allow the compiler to precompute it instead of needing a runtime strlen() in the function.
There was a problem hiding this comment.
Changed to require length in argument
There was a problem hiding this comment.
Maybe you meant writing the numbers directly in the code without using strlen at all? I may have misunderstood something.
There was a problem hiding this comment.
Ditto here, we can precompute the length of the strings and potentially use memcpy() instead.
There was a problem hiding this comment.
Changed to require length in argument, and to explicitly pass HY000 where NULL was passed to state
2ca4077 to
9ae039c
Compare
|
@Girgias My changes may be inappropriate to save runtime overhead. |
9ae039c to
4810a72
Compare
|
I fixed, I think I've eliminated runtime overhead as much as possible. |
There was a problem hiding this comment.
This should be better AFAIK
| memcpy(*error_code, "HY000", 6); | |
| memcpy(*error_code, "HY000", sizeof("HY000"); |
There was a problem hiding this comment.
Using sizeof of strlen is better, the compiler will fill in the integer constant by itself
4810a72 to
700f92a
Compare
|
Thank you, I didn't even consider the behavior of the compiler. I'm looking into it while studying while looking at the assembly code. |
| we won't know what to do with it */ | ||
| H->last_app_error = "Cannot enable auto-commit while a transaction is already open"; | ||
| const char *msg = "Cannot enable auto-commit while a transaction is already open"; | ||
| firebird_error_with_info(dbh, "HY000", strlen("HY000"), msg, strlen(msg)); |
There was a problem hiding this comment.
@nielsdos just to sanity check, but this is sensible right? The compiler will replace at compile time the strlen call by the actual value
There was a problem hiding this comment.
Thank you both! I was able to understand it a little. I'll learn some more.
What I wanted to say was a little different.
Although I understand the content, I am still not very good at reading the differences in assembly code, so I will learn to read assembly code better.
There was a problem hiding this comment.
I tried various things. I understand that strlen("HY000") will be replaced, but strlen(msg) will not be replaced, is this correct?
There was a problem hiding this comment.
Yes, because msg is a variable, where the content is only known at runtime.
There was a problem hiding this comment.
I see, thank you. Should msg be replaced as well? I feel the msg is a little too long for that.
There was a problem hiding this comment.
I didn't look at this specific case, but in this one the compiler should be smart enough :)
|
Thank you! |
The current implementation does not retrieve
sqlstatusfrom the DB, and any errors will be treated as General errors.So I changed it to get the SQL state and error messages from the vendor driver.
I also used the same naming conventions as other PDO drivers for function names, etc.
Other changes require error handling, so I'd be happy if I could merge them from this PR.