PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ pgui_exec()

static int pgui_exec ( const char *  sql)
static

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

305 {
306  PGresult *res = NULL;
307  ExecStatusType status;
308  char sql_trunc[256];
309 
310  /* We need a connection to do anything. */
311  if ( ! pg_connection ) return 0;
312  if ( ! sql ) return 0;
313 
314  res = PQexec(pg_connection, sql);
315  status = PQresultStatus(res);
316  PQclear(res);
317 
318  /* Did something unexpected happen? */
319  if ( ! ( status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK ) )
320  {
321  /* Log notices and return success. */
322  if ( status == PGRES_NONFATAL_ERROR )
323  {
324  pgui_logf("%s", PQerrorMessage(pg_connection));
325  return 1;
326  }
327 
328  /* Log errors and return failure. */
329  snprintf(sql_trunc, 255, "%s", sql);
330  pgui_logf("Failed SQL begins: \"%s\"", sql_trunc);
331  pgui_logf("Failed in pgui_exec(): %s", PQerrorMessage(pg_connection));
332  return 0;
333  }
334 
335  return 1;
336 }
tuple res
Definition: window.py:79
static void static void static void pgui_logf(const char *fmt,...) __attribute__((format(printf
static PGconn * pg_connection

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

Referenced by pgui_action_import().

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