-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
…rective. thanks Ingo Struck for the original patch in #29.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -440,6 +440,17 @@ ngx_postgres_conf_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
return NGX_CONF_ERROR; | ||
} | ||
|
||
#if defined(nginx_version) && (nginx_version <= 1003000) | ||
if (u.naddrs == 0) { | ||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | ||
"postgres: IPv6 addresses not supported in " | ||
"this version of nginx"); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
return NGX_CONF_ERROR; | ||
} | ||
#endif | ||
|
||
dd("naddrs: %d", (int) u.naddrs); | ||
This comment has been minimized.
Sorry, something went wrong.
PiotrSikora
Contributor
|
||
|
||
pgs->addrs = u.addrs; | ||
pgs->naddrs = u.naddrs; | ||
pgs->port = u.port; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
# vi:filetype= | ||
|
||
use lib 'lib'; | ||
use Test::Nginx::Socket; | ||
|
||
repeat_each(2); | ||
|
||
plan tests => repeat_each() * (blocks() * 5); | ||
|
||
$ENV{TEST_NGINX_POSTGRESQL_HOST_IPV6} ||= '[::1]'; | ||
This comment has been minimized.
Sorry, something went wrong.
PiotrSikora
Contributor
|
||
$ENV{TEST_NGINX_POSTGRESQL_PORT} ||= 5432; | ||
|
||
our $http_config = <<'_EOC_'; | ||
upstream database { | ||
postgres_server $TEST_NGINX_POSTGRESQL_HOST_IPV6:$TEST_NGINX_POSTGRESQL_PORT | ||
dbname=ngx_test user=ngx_test password=ngx_test; | ||
} | ||
_EOC_ | ||
run_tests(); | ||
__DATA__ | ||
=== TEST 1: no keep-alive | ||
--- http_config | ||
upstream database { | ||
postgres_server $TEST_NGINX_POSTGRESQL_HOST_IPV6:$TEST_NGINX_POSTGRESQL_PORT | ||
dbname=ngx_test user=ngx_test password=ngx_test; | ||
postgres_keepalive off; | ||
} | ||
--- config | ||
location /postgres { | ||
postgres_pass database; | ||
postgres_query "select * from cats"; | ||
} | ||
--- request | ||
GET /postgres | ||
--- error_code: 200 | ||
--- response_headers | ||
Content-Type: application/x-resty-dbd-stream | ||
--- response_body eval | ||
"\x{00}". # endian | ||
"\x{03}\x{00}\x{00}\x{00}". # format version 0.0.3 | ||
"\x{00}". # result type | ||
"\x{00}\x{00}". # std errcode | ||
"\x{02}\x{00}". # driver errcode | ||
"\x{00}\x{00}". # driver errstr len | ||
"". # driver errstr data | ||
"\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}". # rows affected | ||
"\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}". # insert id | ||
"\x{02}\x{00}". # col count | ||
"\x{09}\x{00}". # std col type (integer/int) | ||
"\x{17}\x{00}". # driver col type | ||
"\x{02}\x{00}". # col name len | ||
"id". # col name data | ||
"\x{06}\x{80}". # std col type (varchar/str) | ||
"\x{19}\x{00}". # driver col type | ||
"\x{04}\x{00}". # col name len | ||
"name". # col name data | ||
"\x{01}". # valid row flag | ||
"\x{01}\x{00}\x{00}\x{00}". # field len | ||
"2". # field data | ||
"\x{ff}\x{ff}\x{ff}\x{ff}". # field len | ||
"". # field data | ||
"\x{01}". # valid row flag | ||
"\x{01}\x{00}\x{00}\x{00}". # field len | ||
"3". # field data | ||
"\x{03}\x{00}\x{00}\x{00}". # field len | ||
"bob". # field data | ||
"\x{00}" # row list terminator | ||
--- timeout: 10 | ||
--- no_error_log | ||
[alert] | ||
[error] | ||
=== TEST 2: keep-alive (single) | ||
--- http_config | ||
upstream database { | ||
postgres_server $TEST_NGINX_POSTGRESQL_HOST_IPV6:$TEST_NGINX_POSTGRESQL_PORT | ||
dbname=ngx_test user=ngx_test password=ngx_test; | ||
postgres_keepalive max=10 mode=single; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
--- config | ||
location /postgres { | ||
postgres_pass database; | ||
postgres_query "select * from cats"; | ||
} | ||
location /t { | ||
echo_location /postgres; | ||
echo_location /postgres; | ||
echo_location /postgres; | ||
} | ||
--- request | ||
GET /t | ||
--- error_code: 200 | ||
--- response_headers | ||
Content-Type: text/plain | ||
--- response_body eval | ||
my $s="\x{00}". # endian | ||
"\x{03}\x{00}\x{00}\x{00}". # format version 0.0.3 | ||
"\x{00}". # result type | ||
"\x{00}\x{00}". # std errcode | ||
"\x{02}\x{00}". # driver errcode | ||
"\x{00}\x{00}". # driver errstr len | ||
"". # driver errstr data | ||
"\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}". # rows affected | ||
"\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}". # insert id | ||
"\x{02}\x{00}". # col count | ||
"\x{09}\x{00}". # std col type (integer/int) | ||
"\x{17}\x{00}". # driver col type | ||
"\x{02}\x{00}". # col name len | ||
"id". # col name data | ||
"\x{06}\x{80}". # std col type (varchar/str) | ||
"\x{19}\x{00}". # driver col type | ||
"\x{04}\x{00}". # col name len | ||
"name". # col name data | ||
"\x{01}". # valid row flag | ||
"\x{01}\x{00}\x{00}\x{00}". # field len | ||
"2". # field data | ||
"\x{ff}\x{ff}\x{ff}\x{ff}". # field len | ||
"". # field data | ||
"\x{01}". # valid row flag | ||
"\x{01}\x{00}\x{00}\x{00}". # field len | ||
"3". # field data | ||
"\x{03}\x{00}\x{00}\x{00}". # field len | ||
"bob". # field data | ||
"\x{00}"; # row list terminator | ||
This comment has been minimized.
Sorry, something went wrong. |
||
$s x 3; | ||
--- timeout: 10 | ||
--- no_error_log | ||
[alert] | ||
[error] | ||
=== TEST 3: keep-alive (multi) | ||
--- http_config | ||
upstream database { | ||
postgres_server $TEST_NGINX_POSTGRESQL_HOST_IPV6:$TEST_NGINX_POSTGRESQL_PORT | ||
dbname=ngx_test user=ngx_test password=ngx_test; | ||
postgres_keepalive max=10 mode=multi; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
--- config | ||
location /postgres { | ||
postgres_pass database; | ||
postgres_query "select * from cats"; | ||
} | ||
location /t { | ||
echo_location /postgres; | ||
echo_location /postgres; | ||
echo_location /postgres; | ||
} | ||
--- request | ||
GET /t | ||
--- error_code: 200 | ||
--- response_headers | ||
Content-Type: text/plain | ||
--- response_body eval | ||
my $s="\x{00}". # endian | ||
"\x{03}\x{00}\x{00}\x{00}". # format version 0.0.3 | ||
"\x{00}". # result type | ||
"\x{00}\x{00}". # std errcode | ||
"\x{02}\x{00}". # driver errcode | ||
"\x{00}\x{00}". # driver errstr len | ||
"". # driver errstr data | ||
"\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}". # rows affected | ||
"\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}". # insert id | ||
"\x{02}\x{00}". # col count | ||
"\x{09}\x{00}". # std col type (integer/int) | ||
"\x{17}\x{00}". # driver col type | ||
"\x{02}\x{00}". # col name len | ||
"id". # col name data | ||
"\x{06}\x{80}". # std col type (varchar/str) | ||
"\x{19}\x{00}". # driver col type | ||
"\x{04}\x{00}". # col name len | ||
"name". # col name data | ||
"\x{01}". # valid row flag | ||
"\x{01}\x{00}\x{00}\x{00}". # field len | ||
"2". # field data | ||
"\x{ff}\x{ff}\x{ff}\x{ff}". # field len | ||
"". # field data | ||
"\x{01}". # valid row flag | ||
"\x{01}\x{00}\x{00}\x{00}". # field len | ||
"3". # field data | ||
"\x{03}\x{00}\x{00}\x{00}". # field len | ||
"bob". # field data | ||
"\x{00}"; # row list terminator | ||
$s x 3; | ||
--- timeout: 10 | ||
--- no_error_log | ||
[alert] | ||
[error] | ||
This comment has been minimized.
Sorry, something went wrong. |
Could you change this to:
otherwise it's hard for users to figure out which version they need to upgrade to in order to fix the error.