-
Notifications
You must be signed in to change notification settings - Fork 7.9k
PDO refactor quoter hook to return zend_string* #6547
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
@adambaratz and @sim1984 could you test DBLIB and FireBird respectively to check I haven't messed it up? As we currently have no CI testing enabled for them. |
Thanks for flagging me! Still looking through this. Will try to wrap up my review today or tomorrow. |
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.
Found one compile error, but otherwise looks good! Tests pass and didn't uncover any memory leaks.
a680530
to
1fb8429
Compare
ext/pdo_dblib/dblib_driver.c
Outdated
} | ||
q = *quoted = emalloc(*quotedlen + 1); /* Add byte for terminal null */ | ||
q = quoted = emalloc(quotedlen + 1); /* Add byte for terminal null */ |
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.
Why not zend_string_alloc?
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.
As I haven't tried to set up dblib nor firebird locally I went with the most minimal change, although not doing stuff on a zend_string is rather stupid I agree, will look into this.
ext/pdo_firebird/firebird_driver.c
Outdated
*quotedlen = unquotedlen + qcount + 2; | ||
*quoted = c = emalloc(*quotedlen+1); | ||
quotedlen = ZSTR_LEN(unquoted) + qcount + 2; | ||
quoted = c = emalloc(quotedlen+1); |
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.
Same here, why not directly zend_string_alloc?
095f622
to
03e8115
Compare
ext/pdo_dblib/dblib_driver.c
Outdated
*q++ = '\''; | ||
|
||
*q = 0; | ||
*q = '\''; |
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.
It's still necessary to null terminate the string.
e08d2dc
to
1c86358
Compare
Thanks for taking care of the bits I didn't manage. I've squashed everything related into the first two commits and added an entry into UPGRADING.INTERNALS. |
It would be nice to switch the |
ACK |
This PR refactors the quoter hook to return a zend_string* instead of using out params as the drivers bundled in php-src always return true.
This in turn made some refactoring in the sql parser possible to also use zend_strings instead of a combination of
char*
andsize_t
elements. I've also added a couple more known strings for recurring values which can possibly be used outside of PDO.