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

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

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

Referenced by pgui_action_import().

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