Skip to content

Commit

Permalink
Merge branch 'PHP-5.6'
Browse files Browse the repository at this point in the history
* PHP-5.6:
  Always initialize pg_version() result array elements to prevent failed test with older postgresql servers. Add missing client_encoding element.
  • Loading branch information
Yasuo Ohgaki committed Jan 15, 2014
2 parents ee4e5ce + c58329f commit a92c5b1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 34 deletions.
51 changes: 21 additions & 30 deletions ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1504,38 +1504,29 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type
add_assoc_long(return_value, "protocol", PQprotocolVersion(pgsql));
#if HAVE_PQPARAMETERSTATUS
if (PQprotocolVersion(pgsql) >= 3) {
/* 8.0 or grater supports protorol version 3 */
char *tmp;
add_assoc_string(return_value, "server", (char*)PQparameterStatus(pgsql, "server_version"), 1);
if ((tmp = (char*)PQparameterStatus(pgsql, "server_encoding"))) {
add_assoc_string(return_value, "server_encoding", tmp, 1);
}
if ((tmp = (char*)PQparameterStatus(pgsql, "application_name"))) {
add_assoc_string(return_value, "application_name", tmp, 1);
}
if ((tmp = (char*)PQparameterStatus(pgsql, "is_superuser"))) {
add_assoc_string(return_value, "is_superuser", tmp, 1);
}
if ((tmp = (char*)PQparameterStatus(pgsql, "session_authorization"))) {
add_assoc_string(return_value, "session_authorization", tmp, 1);
}
if ((tmp = (char*)PQparameterStatus(pgsql, "DateStyle"))) {
add_assoc_string(return_value, "DateStyle", tmp, 1);
}
if ((tmp = (char*)PQparameterStatus(pgsql, "IntervalStyle"))) {
add_assoc_string(return_value, "IntervalStyle", tmp, 1);
}
if ((tmp = (char*)PQparameterStatus(pgsql, "TimeZone"))) {
add_assoc_string(return_value, "TimeZone", tmp, 1);
}
if ((tmp = (char*)PQparameterStatus(pgsql, "integer_datetimes"))) {
add_assoc_string(return_value, "integer_datetimes", tmp, 1);
}
if ((tmp = (char*)PQparameterStatus(pgsql, "standard_conforming_strings"))) {
add_assoc_string(return_value, "standard_conforming_strings", tmp, 1);
}
if ((tmp = (char*)PQparameterStatus(pgsql, "server_encoding"))) {
add_assoc_string(return_value, "server_encoding", tmp, 1);
}
tmp = (char*)PQparameterStatus(pgsql, "server_encoding");
add_assoc_string(return_value, "server_encoding", tmp, 1);
tmp = (char*)PQparameterStatus(pgsql, "client_encoding");
add_assoc_string(return_value, "client_encoding", tmp, 1);
tmp = (char*)PQparameterStatus(pgsql, "is_superuser");
add_assoc_string(return_value, "is_superuser", tmp, 1);
tmp = (char*)PQparameterStatus(pgsql, "session_authorization");
add_assoc_string(return_value, "session_authorization", tmp, 1);
tmp = (char*)PQparameterStatus(pgsql, "DateStyle");
add_assoc_string(return_value, "DateStyle", tmp, 1);
tmp = (char*)PQparameterStatus(pgsql, "IntervalStyle");
add_assoc_string(return_value, "IntervalStyle", tmp ? tmp : "", 1);
tmp = (char*)PQparameterStatus(pgsql, "TimeZone");
add_assoc_string(return_value, "TimeZone", tmp ? tmp : "", 1);
tmp = (char*)PQparameterStatus(pgsql, "integer_datetimes");
add_assoc_string(return_value, "integer_datetimes", tmp ? tmp : "", 1);
tmp = (char*)PQparameterStatus(pgsql, "standard_conforming_strings");
add_assoc_string(return_value, "standard_conforming_strings", tmp ? tmp : "", 1);
tmp = (char*)PQparameterStatus(pgsql, "application_name");
add_assoc_string(return_value, "application_name", tmp ? tmp : "", 1);
}
#endif
#endif
Expand Down
10 changes: 6 additions & 4 deletions ext/pgsql/tests/00version.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var_dump(serialize($_ENV));
echo "OK";
?>
--EXPECTF--
array(12) {
array(13) {
["client"]=>
string(%d) "%s"
["protocol"]=>
Expand All @@ -27,22 +27,24 @@ array(12) {
string(%d) "%s"
["server_encoding"]=>
string(%d) "%s"
["application_name"]=>
string(0) ""
["client_encoding"]=>
string(%d) "%s"
["is_superuser"]=>
string(%d) "%s"
["session_authorization"]=>
string(%d) "%s"
["DateStyle"]=>
string(%d) "%s"
["IntervalStyle"]=>
string(%d) "%s"
string(%d) %s
["TimeZone"]=>
string(%d) "%s"
["integer_datetimes"]=>
string(%d) "%s"
["standard_conforming_strings"]=>
string(%d) "%s"
["application_name"]=>
string(%d) %s
}
string(%d) "%s"
OK

0 comments on commit a92c5b1

Please sign in to comment.