Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on-connected hook for custom query #18

Open
clkao opened this issue Jul 31, 2013 · 3 comments
Open

on-connected hook for custom query #18

clkao opened this issue Jul 31, 2013 · 3 comments

Comments

@clkao
Copy link

clkao commented Jul 31, 2013

It seems there's no such hook in ngx_postgres to allow custom queries to be sent upon upstream connection establishment.

I am trying out ngx_postgres with pgrest (http://github.com/clkao/pgrest). However for each connection, we need to call a postgresql function via select, something like: SELECT pgrest_boot('{...bootstrap_json}').

I also tried calling the bootstrap function along with other queries mapped from GET requests, but ngx_postgres is not handling multiple queries very well.

@agentzh
Copy link
Contributor

agentzh commented Aug 1, 2013

Multiple result sets support is still a TODO.

However, you can use ngx_echo module's echo_location or echo_subrequest directives to do the combinations yourself:

http://wiki.nginx.org/HttpEchoModule#echo_location

@clkao
Copy link
Author

clkao commented Aug 1, 2013

Thanks @agentzh! I gave it a quick try, it seems postgres_pass can't be used with echo_location, so i have to create a wrapper route that contains two echo_location to the to routes for doing bootstrap and the actual query.

I then use postgres_output none for the first location so only the second one is rendered. however it seems I now get a response where the body is flushed before the http headers.

@agentzh
Copy link
Contributor

agentzh commented Aug 1, 2013

@clkao echo_location should work with ngx_postgres but you need separate locations because you're doing Nginx subrequests here. For a single location, you cannot enable two Nginx module's content handlers at the same time, that is, you cannot use echo_location and proxy_pass in a single location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants