ngx_Postgres + Eval (agentzh version)

ainou nginx-forum at
Mon Aug 15 18:19:00 UTC 2011


I have this piece of configuration that is almost copy+pasted from the
ngx_postgres example but that for some unknown reason to me is not
The value of the $s variable is always empty ou NULL if I use

location ~ '^/foo/([a-zA-Z0-9\-\.]+)/(.*)$' {
            set $sid $1; 
            set $url $2 ;

            eval_subrequest_in_memory off;
            eval_override_content_type text/plain;
            eval_buffer_size 1k;

            eval $isValid {
                    postgres_escape   $s $sid;
                    postgres_query    "SELECT session_id FROM
server_sessions WHERE session_id = $s  LIMIT 1";

                    postgres_pass     pg_database;
                    postgres_output  value ;

#echo -n "foo:-> sid = "; echo $sid; 
#echo -n "foo: -> url = "; echo $url;      
#echo -n "isValid = ["; echo $isValid; echo "]";


With this comand 

curl http://istreamer/foo/s9/4554354aseee4/opopo

(and without the # obviously) I get 

foo:-> sid = s9
foo: -> url = 4554354aseee4/opopo
isValid = []

and the query get's logged as 

SELECT session_id FROM server_sessions WHERE session_id = NULL  LIMIT 1

in the Postgres log meaning that $s has no value.

Can someone explain me what I'm doing wrong? This is supposed to be
quite simple....


Posted at Nginx Forum:,213829,213829#msg-213829

More information about the nginx mailing list