FRiCKLE / ngx_postgres

upstream module that allows nginx to communicate directly with PostgreSQL database.
http://labs.frickle.com/nginx_ngx_postgres/
BSD 2-Clause "Simplified" License
545 stars 122 forks source link

ngx_postgres generates bogus "duplicate variable" error #6

Closed cwells closed 14 years ago

cwells commented 14 years ago

A config like the following config fails:

location /x {  postgres_escape $data $arg_data; }
location /y {  postgres_escape $data $arg_data; }

result is error such as:

[emerg]: the duplicate "data" variable in /etc/nginx/nginx.conf:31
configuration file /etc/nginx/nginx.conf test failed

Replacing "postgres_escape" with "set" does not result in similar error.

cwells commented 14 years ago

I should also point out that the following seemingly equivalent config works:

location /x {
    set $data $arg_data;
    set_quote_sql_str for=pg $data;
}

location /y {
    set $data $arg_data;
    set_quote_sql_str for=pg $data;
}
PiotrSikora commented 14 years ago

Again, this is done by design to avoid "stupid accidents" that happen when same variable is re-used in number of locations.

PiotrSikora commented 14 years ago

Hey Cliff, I've just committed major rewrite of postgres_escape directive which adds ability to re-use variable names... It solves your original issue, so I'm closing this.

cwells commented 14 years ago

great, thanks!