PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ connection_test()

static int connection_test ( void  )
static

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

464 {
465  char *connection_string = NULL;
466  char *connection_sanitized = NULL;
467 
468  if (!(connection_string = ShpDumperGetConnectionStringFromConn(conn)))
469  {
471  valid_connection = 0;
472  return 0;
473  }
474 
475  connection_sanitized = strdup(connection_string);
476  pgui_sanitize_connection_string(connection_sanitized);
477  pgui_logf("Connecting: %s", connection_sanitized);
478  free(connection_sanitized);
479 
480  pg_connection = PQconnectdb(connection_string);
481  if (PQstatus(pg_connection) == CONNECTION_BAD)
482  {
483  pgui_logf( _("Database connection failed: %s"), PQerrorMessage(pg_connection));
484  free(connection_string);
485  PQfinish(pg_connection);
486  pg_connection = NULL;
487  valid_connection = 0;
488  return 0;
489  }
490  PQfinish(pg_connection);
491  pg_connection = NULL;
492  free(connection_string);
493 
494  valid_connection = 1;
495  return 1;
496 }
void free(void *)
char * ShpDumperGetConnectionStringFromConn(SHPCONNECTIONCONFIG *conn)
static void static void static void pgui_logf(const char *fmt,...) __attribute__((format(printf
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
#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: