PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ pgui_copy_start()

static int pgui_copy_start ( const char *  sql)
static

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

References pg_connection, pgui_logf(), and window::res.

Referenced by pgui_action_import().

340 {
341  PGresult *res = NULL;
342  ExecStatusType status;
343  char sql_trunc[256];
344 
345  /* We need a connection to do anything. */
346  if ( ! pg_connection ) return 0;
347  if ( ! sql ) return 0;
348 
349  res = PQexec(pg_connection, sql);
350  status = PQresultStatus(res);
351  PQclear(res);
352 
353  /* Did something unexpected happen? */
354  if ( status != PGRES_COPY_IN )
355  {
356  /* Log errors and return failure. */
357  snprintf(sql_trunc, 255, "%s", sql);
358  pgui_logf("Failed SQL begins: \"%s\"", sql_trunc);
359  pgui_logf("Failed in pgui_copy_start(): %s", PQerrorMessage(pg_connection));
360  return 0;
361  }
362 
363  return 1;
364 }
tuple res
Definition: window.py:78
static void pgui_logf(const char *fmt,...)
static PGconn * pg_connection
Here is the call graph for this function:
Here is the caller graph for this function: