Skip to content

ext/pgsql: db metadata simplification for table names. #15036

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

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -4442,7 +4442,7 @@ PHP_PGSQL_API zend_result php_pgsql_meta_data(PGconn *pg_link, const zend_string
char *src, *tmp_name, *tmp_name2 = NULL;
char *escaped;
smart_str querystr = {0};
size_t new_len;
size_t new_len, len;
int i, num_rows;
zval elem;

Expand Down Expand Up @@ -4480,16 +4480,18 @@ PHP_PGSQL_API zend_result php_pgsql_meta_data(PGconn *pg_link, const zend_string
" JOIN pg_namespace n ON (c.relnamespace = n.oid) "
"WHERE a.attnum > 0 AND c.relname = '");
}
escaped = (char *)safe_emalloc(strlen(tmp_name2), 2, 1);
new_len = PQescapeStringConn(pg_link, escaped, tmp_name2, strlen(tmp_name2), NULL);
len = strlen(tmp_name2);
escaped = (char *)safe_emalloc(len, 2, 1);
new_len = PQescapeStringConn(pg_link, escaped, tmp_name2, len, NULL);
if (new_len) {
smart_str_appendl(&querystr, escaped, new_len);
}
efree(escaped);

smart_str_appends(&querystr, "' AND n.nspname = '");
escaped = (char *)safe_emalloc(strlen(tmp_name), 2, 1);
new_len = PQescapeStringConn(pg_link, escaped, tmp_name, strlen(tmp_name), NULL);
len = strlen(tmp_name);
escaped = (char *)safe_emalloc(len, 2, 1);
new_len = PQescapeStringConn(pg_link, escaped, tmp_name, len, NULL);
if (new_len) {
smart_str_appendl(&querystr, escaped, new_len);
}
Expand Down
Loading