PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ pgui_exec()

static int pgui_exec ( const char *  sql)
static

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

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

References pg_connection, and pgui_logf().

Referenced by pgui_action_import().

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