Skip to content

Partially refactor PgSql extension #6792

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 15 commits into from
Closed

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Mar 22, 2021

Mostly to use zend_string* more often and a couple of performance improvements by using interned strings.

@Girgias Girgias force-pushed the pgsql-refactor branch 2 times, most recently from e9e36ad to 47e5687 Compare March 22, 2021 07:13
@@ -973,23 +972,22 @@ PHP_FUNCTION(pg_ping)
PHP_FUNCTION(pg_query)
{
zval *pgsql_link = NULL;
char *query;
zend_string *query;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the zend_string changes don't make sense to me. Using zend_string makes sense if you actually use it as such, e.g. pass it around as zend_string, copy it, etc. Here you are just accepting the zend_string and then always using ZSTR_VAL, which imho is worse than the previous code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going on a top-down approach to start pass zend_strings to more internal functions, will continue to work on that and revisit the cases where that doesn't occur then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. It's mostly about cases like this, where a string is only used to talk to some 3rd-party C API (libpq), which is never going to accept zend_strings, so it just adds extra friction.

@Girgias Girgias force-pushed the pgsql-refactor branch 2 times, most recently from 7a588ee to 7a3f971 Compare March 23, 2021 13:27
@nikic
Copy link
Member

nikic commented Apr 13, 2021

Looks okay, though I still think some of the zend_string changes aren't really improvements...

if (strchr(mode_string, '+') == mode_string+1) {
pgsql_mode |= INV_READ;
}
create = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't you still missing create=true for the w+ case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this does make this whole block still as messy as before but probably still clearer

@Girgias
Copy link
Member Author

Girgias commented Apr 17, 2021

I already was in the middle of a rebase trying to squash and reorganize the commits, so apologies for that.
Or should I just squash the whole PR into one commit?

@Girgias Girgias closed this in 612609e Apr 19, 2021
@Girgias Girgias deleted the pgsql-refactor branch July 17, 2023 15:23
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.

2 participants