PostGIS  2.2.7dev-r@@SVN_REVISION@@
static int pgui_exec ( const char *  sql)
static

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

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

Referenced by pgui_action_import().

302 {
303  PGresult *res = NULL;
304  ExecStatusType status;
305  char sql_trunc[256];
306 
307  /* We need a connection to do anything. */
308  if ( ! pg_connection ) return 0;
309  if ( ! sql ) return 0;
310 
311  res = PQexec(pg_connection, sql);
312  status = PQresultStatus(res);
313  PQclear(res);
314 
315  /* Did something unexpected happen? */
316  if ( ! ( status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK ) )
317  {
318  /* Log notices and return success. */
319  if ( status == PGRES_NONFATAL_ERROR )
320  {
321  pgui_logf("%s", PQerrorMessage(pg_connection));
322  return 1;
323  }
324 
325  /* Log errors and return failure. */
326  snprintf(sql_trunc, 255, "%s", sql);
327  pgui_logf("Failed SQL begins: \"%s\"", sql_trunc);
328  pgui_logf("Failed in pgui_exec(): %s", PQerrorMessage(pg_connection));
329  return 0;
330  }
331 
332  return 1;
333 }
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: