[libgda] PostgreSQL: handle the "connect_timeout" option, see bug #682043



commit fba1734117602483916f310cc51f5c5ab9646b0d
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sat Aug 18 13:00:30 2012 +0200

    PostgreSQL: handle the "connect_timeout" option, see bug #682043

 providers/postgres/gda-postgres-provider.c   |    5 ++++-
 providers/postgres/postgres_specs_dsn.xml.in |    1 +
 2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/providers/postgres/gda-postgres-provider.c b/providers/postgres/gda-postgres-provider.c
index f94ab94..8c4b65f 100644
--- a/providers/postgres/gda-postgres-provider.c
+++ b/providers/postgres/gda-postgres-provider.c
@@ -420,6 +420,7 @@ gda_postgres_provider_open_connection (GdaServerProvider *provider, GdaConnectio
         const gchar *pq_pwd = NULL;
         const gchar *pq_hostaddr;
         const gchar *pq_requiressl;
+	const gchar *pq_connect_timeout;
         gchar *conn_string;
 	pq_host = gda_quark_list_find (params, "HOST");
         pq_hostaddr = gda_quark_list_find (params, "HOSTADDR");
@@ -454,7 +455,7 @@ gda_postgres_provider_open_connection (GdaServerProvider *provider, GdaConnectio
         pq_requiressl = gda_quark_list_find (params, "USE_SSL");
 	if (pq_requiressl && (*pq_requiressl != 'T') && (*pq_requiressl != 't'))
 		pq_requiressl = NULL;
-
+	pq_connect_timeout = gda_quark_list_find (params, "CONNECT_TIMEOUT");
 
 	/* TODO: Escape single quotes and backslashes in the user name and password: */
         conn_string = g_strconcat ("",
@@ -489,6 +490,8 @@ gda_postgres_provider_open_connection (GdaServerProvider *provider, GdaConnectio
                                    (pq_pwd && *pq_pwd) ? "'" : "",
                                    pq_requiressl ? " requiressl=" : "",
                                    pq_requiressl ? pq_requiressl : "",
+				   pq_connect_timeout ? " connect_timeout=" : "",
+				   pq_connect_timeout ? pq_connect_timeout : "",
                                    NULL);
 
 	/* open the real connection to the database */
diff --git a/providers/postgres/postgres_specs_dsn.xml.in b/providers/postgres/postgres_specs_dsn.xml.in
index b396f85..35945c2 100644
--- a/providers/postgres/postgres_specs_dsn.xml.in
+++ b/providers/postgres/postgres_specs_dsn.xml.in
@@ -7,5 +7,6 @@
     <parameter id="PORT" _name="Port" _descr="Database server port (for servers running on unix domain sockets, enter the socket's file name extension (usually 5432), or leave this field empty)" gdatype="gint"/>
     <parameter id="OPTIONS" _name="Options" _descr="Extra connection options" gdatype="gchararray"/>
     <parameter id="USE_SSL" _name="Require SSL" _descr="Whether or not to use SSL to establish the connection" gdatype="gboolean"/>
+    <parameter id="CONNECT_TIMEOUT" _name="Connection timeout" _descr="Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely. It is not recommended to use a timeout of less than 2 seconds" gdatype="gint"/>
   </parameters>
 </data-set-spec>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]