From: Marko Kreen Date: Fri, 24 Jun 2011 13:28:06 +0000 (+0300) Subject: faq: use nicer code-blocks X-Git-Tag: pgbouncer_1_5_rc1~61 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=359f093b6280190fa5bf977ee2b6f7cf5ec5a2f3;p=pgbouncer faq: use nicer code-blocks --- diff --git a/doc/faq.txt b/doc/faq.txt index ba7e6c6..53a58be 100644 --- a/doc/faq.txt +++ b/doc/faq.txt @@ -42,23 +42,27 @@ easy way to drop prepared statements. Luckily there is system view that shows prepared plans in current session. So as a workaround following function can be created: - CREATE OR REPLACE FUNCTION deallocate_all() - RETURNS void AS $$ - DECLARE - sql text; - BEGIN - FOR sql IN - SELECT 'deallocate ' || quote_ident(name) - FROM pg_catalog.pg_prepared_statements - LOOP - EXECUTE sql; - END LOOP; - END; - $$ LANGUAGE plpgsql; +---------------- +CREATE OR REPLACE FUNCTION deallocate_all() +RETURNS void AS $$ +DECLARE + sql text; +BEGIN + FOR sql IN + SELECT 'deallocate ' || quote_ident(name) + FROM pg_catalog.pg_prepared_statements + LOOP + EXECUTE sql; + END LOOP; +END; +$$ LANGUAGE plpgsql; +---------------- Then the `server_reset_query` can be set to call it: - server_reset_query = RESET ALL; SET SESSION AUTHORIZATION DEFAULT; SELECT deallocate_all(); +---------------- +server_reset_query = RESET ALL; SET SESSION AUTHORIZATION DEFAULT; SELECT deallocate_all(); +---------------- == How to use prepared statements with transaction pooling? == @@ -86,11 +90,15 @@ http://pgfoundry.org/pipermail/pgbouncer-general/2010-February/000507.html[] To disable use of server-side prepared statements, the PDO attribute `PDO::ATTR_EMULATE_PREPARES` must be set to `true`. Either at connect-time: - $db = new PDO("dsn", "user", "pass", array(PDO::ATTR_EMULATE_PREPARES => true)); +---------------- +$db = new PDO("dsn", "user", "pass", array(PDO::ATTR_EMULATE_PREPARES => true)); +---------------- or later: - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); +---------------- +$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); +---------------- @@ -99,15 +107,19 @@ or later: This is as easy as launching new PgBouncer process with `-R` switch and same config: - $ pgbouncer -R -d config.ini +---------------- +$ pgbouncer -R -d config.ini +---------------- The `-R` (reboot) switch makes new process connect to console of the old process (dbname=pgbouncer) via unix socket and issue following commands: - SUSPEND; - SHOW FDS; - SHUTDOWN; +---------------- +SUSPEND; +SHOW FDS; +SHUTDOWN; +---------------- After that if new one notices old one gone it resumes work with old connections. The magic happens during `SHOW FDS` command which @@ -126,13 +138,17 @@ will be simply closed. === Session pooling === - server_reset_query = DISCARD ALL; +---------------- +server_reset_query = DISCARD ALL; +---------------- This will clean everything. === Transaction pooling === - server_reset_query = +---------------- +server_reset_query = +---------------- Yes, empty. In transaction pooling mode the clients should not use any session-based features, so there is no need to clean anything.