Skip to content

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

Closed
wants to merge 5 commits into from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Dec 28, 2020

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* and size_t elements. I've also added a couple more known strings for recurring values which can possibly be used outside of PDO.

@Girgias
Copy link
Member Author

Girgias commented Dec 29, 2020

@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.

@adambaratz
Copy link
Contributor

Thanks for flagging me! Still looking through this. Will try to wrap up my review today or tomorrow.

Copy link
Contributor

@adambaratz adambaratz left a 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.

@Girgias Girgias force-pushed the pdo-quoter-refactoring branch from a680530 to 1fb8429 Compare January 6, 2021 01:21
}
q = *quoted = emalloc(*quotedlen + 1); /* Add byte for terminal null */
q = quoted = emalloc(quotedlen + 1); /* Add byte for terminal null */
Copy link
Member

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?

Copy link
Member Author

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.

*quotedlen = unquotedlen + qcount + 2;
*quoted = c = emalloc(*quotedlen+1);
quotedlen = ZSTR_LEN(unquoted) + qcount + 2;
quoted = c = emalloc(quotedlen+1);
Copy link
Member

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?

@Girgias Girgias force-pushed the pdo-quoter-refactoring branch 2 times, most recently from 095f622 to 03e8115 Compare January 7, 2021 01:16
*q++ = '\'';

*q = 0;
*q = '\'';
Copy link
Member

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.

@Girgias Girgias force-pushed the pdo-quoter-refactoring branch from e08d2dc to 1c86358 Compare January 7, 2021 14:56
@Girgias
Copy link
Member Author

Girgias commented Jan 7, 2021

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.

@php-pulls php-pulls closed this in 63cda0f Jan 7, 2021
@Girgias Girgias deleted the pdo-quoter-refactoring branch January 7, 2021 15:55
@nikic
Copy link
Member

nikic commented Jan 18, 2021

It would be nice to switch the doer to use zend_string as well. It's less directly useful there, but it will make it consistent with preparer and quoter.

@Girgias
Copy link
Member Author

Girgias commented Jan 18, 2021

It would be nice to switch the doer to use zend_string as well. It's less directly useful there, but it will make it consistent with preparer and quoter.

ACK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants