* Run a query, return the results, exit program on failure. */
| 2718 | * Run a query, return the results, exit program on failure. |
| 2719 | */ |
| 2720 | static PGresult * |
| 2721 | executeQuery(PGconn *conn, const char *query) |
| 2722 | { |
| 2723 | PGresult *res; |
| 2724 | |
| 2725 | pg_log_info("executing %s", query); |
| 2726 | |
| 2727 | res = PQexec(conn, query); |
| 2728 | if (!res || |
| 2729 | PQresultStatus(res) != PGRES_TUPLES_OK) |
| 2730 | { |
| 2731 | pg_log_error("query failed: %s", PQerrorMessage(conn)); |
| 2732 | pg_log_error("query was: %s", query); |
| 2733 | PQfinish(conn); |
| 2734 | exit_nicely(1); |
| 2735 | } |
| 2736 | |
| 2737 | return res; |
| 2738 | } |
| 2739 | |
| 2740 | /* |
| 2741 | * As above for a SQL command (which returns nothing). |
no test coverage detected