* PSQLexec * * This is the way to send "backdoor" queries (those not directly entered * by the user). It is subject to -E but not -e. * * Caller is responsible for handling the ensuing processing if a COPY * command is sent. * * Note: we don't bother to check PQclientEncoding; it is assumed that no * caller uses this path to issue "SET CLIENT_ENCODING". */
| 537 | * caller uses this path to issue "SET CLIENT_ENCODING". |
| 538 | */ |
| 539 | PGresult * |
| 540 | PSQLexec(const char *query) |
| 541 | { |
| 542 | PGresult *res; |
| 543 | |
| 544 | if (!pset.db) |
| 545 | { |
| 546 | pg_log_error("You are currently not connected to a database."); |
| 547 | return NULL; |
| 548 | } |
| 549 | |
| 550 | if (pset.echo_hidden != PSQL_ECHO_HIDDEN_OFF) |
| 551 | { |
| 552 | printf(_("********* QUERY **********\n" |
| 553 | "%s\n" |
| 554 | "**************************\n\n"), query); |
| 555 | fflush(stdout); |
| 556 | if (pset.logfile) |
| 557 | { |
| 558 | fprintf(pset.logfile, |
| 559 | _("********* QUERY **********\n" |
| 560 | "%s\n" |
| 561 | "**************************\n\n"), query); |
| 562 | fflush(pset.logfile); |
| 563 | } |
| 564 | |
| 565 | if (pset.echo_hidden == PSQL_ECHO_HIDDEN_NOEXEC) |
| 566 | return NULL; |
| 567 | } |
| 568 | |
| 569 | SetCancelConn(pset.db); |
| 570 | |
| 571 | res = PQexec(pset.db, query); |
| 572 | |
| 573 | ResetCancelConn(); |
| 574 | |
| 575 | if (!AcceptResult(res)) |
| 576 | { |
| 577 | ClearOrSaveResult(res); |
| 578 | res = NULL; |
| 579 | } |
| 580 | |
| 581 | return res; |
| 582 | } |
| 583 | |
| 584 | |
| 585 | /* |
no test coverage detected