Remote 'statement_timeout' config parameter.
authorMarko Kreen <markokr@gmail.com>
Mon, 19 Nov 2007 09:13:53 +0000 (09:13 +0000)
committerMarko Kreen <markokr@gmail.com>
Mon, 19 Nov 2007 09:13:53 +0000 (09:13 +0000)
It did not work in 2.0.2 and although it works now,
it could not work in live env as the SET cannot be combined
with main request, thus likely it will be executed on different
backend.

doc/config.txt
expected/plproxy_test.out
sql/plproxy_test.sql
src/cluster.c
src/execute.c
src/plproxy.h

index 6e2194e23340c1be2540ac1ffe0471a7ca6dd496..9009a7eaf2f45255a1d9583064bb13a6803d5ecc 100644 (file)
@@ -56,11 +56,6 @@ Timeouts/lifetime are given in seconds. If 0 or NULL then disabled.
        Initial connect is canceled, if it takes more that this.
        Duplicated connstring setting (should be just added to connstr?)
 
-  statement_timeout::
-
-       If set, then SET statement_timeout = X command is sent to remote
-       database.
-       
   query_timeout::
 
        If query result does not appear in this time, the connection
index aa1c522a62eb9fc7d8386508c639dbb4fd9ed553..ed35e9e6f4a0b6e50886a389839a25695877b6f1 100644 (file)
@@ -243,50 +243,6 @@ select * from test_connect1();
  test_part
 (1 row)
 
--- test timeout
-create or replace function
-plproxy.get_cluster_config(cluster_name text, out key text, out val text)
-returns setof record as $$
-begin
-    key := 'statement_timeout';
-    val := 10; -- ms
-    return next;
-    return;
-end; $$ language plpgsql;
-create or replace function plproxy.get_cluster_version(cluster_name text)
-returns integer as $$
-begin
-    if cluster_name = 'testcluster' then
-        return 6;
-    end if;
-    raise exception 'no such cluster: %', cluster_name;
-end; $$ language plpgsql;
-create function test_timeout()
-returns text as $$
-    cluster 'testcluster';
-    run on 0;
-    select 'asd' from pg_sleep(3);
-$$ language plproxy;
-select * from test_timeout();
-ERROR:  PL/Proxy function public.test_timeout(0): remote error: ERROR:  canceling statement due to statement timeout
-
-create or replace function
-plproxy.get_cluster_config(cluster_name text, out key text, out val text)
-returns setof record as $$
-begin
-    key := 'statement_timeout';
-    val := 0;
-    return next;
-    return;
-end; $$ language plpgsql;
-create or replace function plproxy.get_cluster_version(cluster_name text)
-returns integer as $$
-begin
-    if cluster_name = 'testcluster' then
-        return 7;
-    end if;
-    raise exception 'no such cluster: %', cluster_name;
-end; $$ language plpgsql;
 -- test quoting function
 create type "RetWeird" as (
     "ColId" int4,
index d86774abb8cd35e863d4fd727fae54bd89fe9444..41dd0ece51f1ccc698611dc6b1981efcbf6000ba 100644 (file)
@@ -143,53 +143,6 @@ create function test_connect1() returns text
 as $$ connect 'dbname=test_part'; select current_database(); $$ language plproxy;
 select * from test_connect1();
 
--- test timeout
-create or replace function
-plproxy.get_cluster_config(cluster_name text, out key text, out val text)
-returns setof record as $$
-begin
-    key := 'statement_timeout';
-    val := 10; -- ms
-    return next;
-    return;
-end; $$ language plpgsql;
-
-create or replace function plproxy.get_cluster_version(cluster_name text)
-returns integer as $$
-begin
-    if cluster_name = 'testcluster' then
-        return 6;
-    end if;
-    raise exception 'no such cluster: %', cluster_name;
-end; $$ language plpgsql;
-
-create function test_timeout()
-returns text as $$
-    cluster 'testcluster';
-    run on 0;
-    select 'asd' from pg_sleep(3);
-$$ language plproxy;
-select * from test_timeout();
-
-create or replace function
-plproxy.get_cluster_config(cluster_name text, out key text, out val text)
-returns setof record as $$
-begin
-    key := 'statement_timeout';
-    val := 0;
-    return next;
-    return;
-end; $$ language plpgsql;
-
-create or replace function plproxy.get_cluster_version(cluster_name text)
-returns integer as $$
-begin
-    if cluster_name = 'testcluster' then
-        return 7;
-    end if;
-    raise exception 'no such cluster: %', cluster_name;
-end; $$ language plpgsql;
-
 
 -- test quoting function
 create type "RetWeird" as (
index 33ec9b91614f00ac8098f31bdf01bd6ea70b7315..0379611735b47348133d719b468f89c571b25f22 100644 (file)
@@ -259,7 +259,7 @@ get_config(ProxyCluster *cluster, Datum dname, ProxyFunction *func)
                        plproxy_error(func, "val must not be NULL");
 
                if (strcasecmp(key, "statement_timeout") == 0)
-                       cf->statement_timeout = atoi(val);
+                       /* ignore */ ;
                else if (strcasecmp("connection_lifetime", key) == 0)
                        cf->connection_lifetime = atoi(val);
                else if (strcasecmp("query_timeout", key) == 0)
@@ -340,8 +340,6 @@ new_cluster(const char *name)
        cluster = palloc0(sizeof(*cluster));
        cluster->name = pstrdup(name);
 
-       cluster->config.statement_timeout = -1;
-
        MemoryContextSwitchTo(old_ctx);
 
        return cluster;
@@ -385,8 +383,6 @@ fake_cluster(ProxyFunction *func)
        conn->connstr = pstrdup(cluster->name);
        conn->state = C_NONE;
 
-       cluster->config.statement_timeout = -1;
-
        MemoryContextSwitchTo(old_ctx);
 
        cluster->next = fake_cluster_list;
index a0d018ecc026499a5634f8aae7877f354db7646a..338b6e3660e5ee3d2024b8b058f23021487a435c 100644 (file)
@@ -95,7 +95,6 @@ flush_connection(ProxyFunction *func, ProxyConnection *conn)
 static int
 tune_connection(ProxyFunction *func, ProxyConnection *conn)
 {
-       ProxyConfig *cf = &func->cur_cluster->config;
        const char *this_enc, *dst_enc;
        const char *dst_ver;
        StringInfo      sql = NULL;
@@ -128,15 +127,6 @@ tune_connection(ProxyFunction *func, ProxyConnection *conn)
                conn_error(func, conn, sql->data);
        }
 
-       /* add statement_timeout to query */
-       if (cf->statement_timeout >= 0 && !conn->tuning)
-       {
-               if (!sql)
-                       sql = makeStringInfo();
-               appendStringInfo(sql, "set statement_timeout = %d; ",
-                                                cf->statement_timeout);
-       }
-
        /*
         * send tuning query
         */
index 4e5d51ef76bccc1a9a4bb5a7afe0d58353c0df07..96b734a9fa9e42990466abc07c1369dceefd2598 100644 (file)
@@ -101,7 +101,6 @@ typedef struct ProxyConfig
        int                     connect_timeout;                /* How long connect may take (secs) */
        int                     query_timeout;                  /* How long query may take (secs) */
        int                     connection_lifetime;    /* How long the connection may live (secs) */
-       int                     statement_timeout;              /* Do remotely: SET statement_timeout */
        int                     disable_binary;                 /* Avoid binary I/O */
 } ProxyConfig;