Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/fe_utils/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 1 kB image not shown  

Quelle  query_utils.c

  Sprache: C
 

/*-------------------------------------------------------------------------
 *
 * Facilities for frontend code to query a databases.
 *
 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/fe_utils/query_utils.c
 *
 *-------------------------------------------------------------------------
 */

#include "postgres_fe.h"

#include "common/logging.h"
#include "fe_utils/cancel.h"
#include "fe_utils/query_utils.h"

/*
 * Run a query, return the results, exit program on failure.
 */

PGresult *
executeQuery(PGconn *conn, const char *query, bool echo)
{
 PGresult   *res;

 if (echo)
  printf("%s\n", query);

 res = PQexec(conn, query);
 if (!res ||
  PQresultStatus(res) != PGRES_TUPLES_OK)
 {
  pg_log_error("query failed: %s", PQerrorMessage(conn));
  pg_log_error_detail("Query was: %s", query);
  PQfinish(conn);
  exit(1);
 }

 return res;
}


/*
 * As above for a SQL command (which returns nothing).
 */

void
executeCommand(PGconn *conn, const char *query, bool echo)
{
 PGresult   *res;

 if (echo)
  printf("%s\n", query);

 res = PQexec(conn, query);
 if (!res ||
  PQresultStatus(res) != PGRES_COMMAND_OK)
 {
  pg_log_error("query failed: %s", PQerrorMessage(conn));
  pg_log_error_detail("Query was: %s", query);
  PQfinish(conn);
  exit(1);
 }

 PQclear(res);
}


/*
 * As above for a SQL maintenance command (returns command success).
 * Command is executed with a cancel handler set, so Ctrl-C can
 * interrupt it.
 */

bool
executeMaintenanceCommand(PGconn *conn, const char *query, bool echo)
{
 PGresult   *res;
 bool  r;

 if (echo)
  printf("%s\n", query);

 SetCancelConn(conn);
 res = PQexec(conn, query);
 ResetCancelConn();

 r = (res && PQresultStatus(res) == PGRES_COMMAND_OK);

 PQclear(res);

 return r;
}

Messung V0.5 in Prozent
C=96 H=100 G=97

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-08-06) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.