# ngx\_Postgres + Eval (agentzh version)

**URL:** <https://www.ruby-forum.com/t/ngx-postgres-eval-agentzh-version/210718>\
**Category:** NGINX\
**Created:** [August 15, 2011, 8:19pm UTC](https://www.ruby-forum.com/t/ngx-postgres-eval-agentzh-version/210718 "2011-08-15T20:19:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [August 15, 2011, 8:19pm UTC](https://www.ruby-forum.com/t/ngx-postgres-eval-agentzh-version/210718/1 "2011-08-15T20:19:20Z")

</div>

Hello,

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  
working.  
The value of the $s variable is always empty ou NULL if I use  
postgres\_escape.

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](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…

AM

Posted at Nginx Forum:

> **[ngx\_Postgres + Eval (agentzh version)](https://forum.nginx.org/read.php?2,213829,213829#msg-213829)**
>
> Hello, 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 working. The value of the $s variable is always empty ou NULL if I use postgres\_escape. location ~...
