PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ connection_test()

static int connection_test ( void  )
static

Definition at line 461 of file shp2pgsql-gui.c.

462 {
463  char *connection_string = NULL;
464  char *connection_sanitized = NULL;
465 
466  if (!(connection_string = ShpDumperGetConnectionStringFromConn(conn)))
467  {
469  valid_connection = 0;
470  return 0;
471  }
472 
473  connection_sanitized = strdup(connection_string);
474  pgui_sanitize_connection_string(connection_sanitized);
475  pgui_logf("Connecting: %s", connection_sanitized);
476  free(connection_sanitized);
477 
478  pg_connection = PQconnectdb(connection_string);
479  if (PQstatus(pg_connection) == CONNECTION_BAD)
480  {
481  pgui_logf( _("Database connection failed: %s"), PQerrorMessage(pg_connection));
482  free(connection_string);
483  PQfinish(pg_connection);
484  pg_connection = NULL;
485  valid_connection = 0;
486  return 0;
487  }
488  PQfinish(pg_connection);
489  pg_connection = NULL;
490  free(connection_string);
491 
492  valid_connection = 1;
493  return 1;
494 }
void free(void *)
char * ShpDumperGetConnectionStringFromConn(SHPCONNECTIONCONFIG *conn)
static PGconn * pg_connection
static void pgui_raise_error_dialogue(void)
static int valid_connection
static void pgui_sanitize_connection_string(char *connection_string)
static SHPCONNECTIONCONFIG * conn
static void pgui_logf(const char *fmt,...)
#define _(String)
Definition: shpcommon.h:24

References _, conn, free(), pg_connection, pgui_logf(), pgui_raise_error_dialogue(), pgui_sanitize_connection_string(), ShpDumperGetConnectionStringFromConn(), and valid_connection.

Referenced by pgui_action_connection_okay(), pgui_action_export(), pgui_action_import(), and pgui_action_open_table_dialog().

Here is the call graph for this function:
Here is the caller graph for this function: