From: | Олексій Васильєв <leopard_ne(at)inbox(dot)ru> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Connect from background worker thread to database |
Date: | 2013-11-24 12:27:06 |
Message-ID: | 1385296026.139424158@f325.i.mail.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello everyone.
I am new to writing extensions to PostgreSQL. And I am not familiar with the C language (My professional languages: Ruby, Golang, Java). But still want to write an extension for PostgreSQL.
After articles of Michael Paquier about background workers in PostgreSQL, I realized what I can create what I always want - web interface for this database. This interface will provide some info about database (like in couchbase: http://docs.couchbase.com/couchbase-manual-2.0/images/web-console-cluster-overview.png ) and can be used as REST API.
Right now this server should work as JSON API and I will build on top of this API web interface on some JS framework. My initiative right now is working as web server just with some hello string. But I don't understand how should I connect to database from threads in web server. All source you can find here: https://github.com/le0pard/pg_web
This is part where I try to connect to database: https://github.com/le0pard/pg_web/blob/master/src/pg_web.c#L92-L132 , but SPI functions give error in log (it is commented):
2013-11-24 02:57:43 UTC ERROR: stack depth limit exceeded
2013-11-24 02:57:43 UTC HINT: Increase the configuration parameter "max_stack_depth" (currently 2048kB), after ensuring the platform's stack depth limit is adequate.
2013-11-24 02:57:43 UTC CONTEXT: SQL statement "SELECT COUNT(*) FROM pg_class;"
Because I doing something in wrong way. I will appreciate for any help: where I doing wrong, link to the article how to do it, just a tip, pull request - anything. Google search and PostgreSQL sources reading so far helped me to this point.
Thanks in advance, Alexey
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2013-11-24 13:06:50 | Re: Connect from background worker thread to database |
Previous Message | Peter Geoghegan | 2013-11-24 10:40:02 | Re: review - pg_stat_statements |