staticvoid
_check_database_version(ArchiveHandle *AH)
{ constchar *remoteversion_str; int remoteversion;
PGresult *res;
remoteversion_str = PQparameterStatus(AH->connection, "server_version");
remoteversion = PQserverVersion(AH->connection); if (remoteversion == 0 || !remoteversion_str)
pg_fatal("could not get \"server_version\" from libpq");
/* Like pg_fatal(), but with a complaint about a particular query. */ staticvoid
die_on_query_failure(ArchiveHandle *AH, constchar *query)
{
pg_log_error("query failed: %s",
PQerrorMessage(AH->connection));
pg_log_error_detail("Query was: %s", query); exit(1);
}
res = ExecuteSqlQuery(fout, query, PGRES_TUPLES_OK);
/* Expecting a single result only */
ntups = PQntuples(res); if (ntups != 1)
pg_fatal(ngettext("query returned %d row instead of one: %s", "query returned %d rows instead of one: %s",
ntups),
ntups, query);
/* initialize command buffer if first time through */ if (AH->sqlparse.curCmd == NULL)
AH->sqlparse.curCmd = createPQExpBuffer();
for (; qry < eos; qry++)
{ char ch = *qry;
/* For neatness, we skip any newlines between commands */ if (!(ch == '\n' && AH->sqlparse.curCmd->len == 0))
appendPQExpBufferChar(AH->sqlparse.curCmd, ch);
switch (AH->sqlparse.state)
{ case SQL_SCAN: /* Default state == 0, set in _allocAH */ if (ch == ';')
{ /* *We'vefoundtheendofastatement.Senditandreset *thebuffer.
*/
ExecuteSqlCommand(AH, AH->sqlparse.curCmd->data, "could not execute query");
resetPQExpBuffer(AH->sqlparse.curCmd);
} elseif (ch == '\'')
{
AH->sqlparse.state = SQL_IN_SINGLE_QUOTE;
AH->sqlparse.backSlash = false;
} elseif (ch == '"')
{
AH->sqlparse.state = SQL_IN_DOUBLE_QUOTE;
} break;
if (PQputCopyEnd(AH->connection, NULL) <= 0)
pg_fatal("error returned by PQputCopyEnd: %s",
PQerrorMessage(AH->connection));
/* Check command status and return to normal libpq state */
res = PQgetResult(AH->connection); if (PQresultStatus(res) != PGRES_COMMAND_OK)
warn_or_exit_horribly(AH, "COPY failed for table \"%s\": %s",
tocEntryTag, PQerrorMessage(AH->connection));
PQclear(res);
/* Do this to ensure we've pumped libpq back to idle state */ if (PQgetResult(AH->connection) != NULL)
pg_log_warning("unexpected extra results during COPY of table \"%s\"",
tocEntryTag);
if (!blobte)
pg_fatal("could not find entry for ID %d", te->dependencies[0]);
Assert(strcmp(blobte->desc, "BLOB METADATA") == 0);
/* Make a writable copy of the ACL commands string */
buf = pg_strdup(te->defn);
/* *WehavetoparseoutthecommandssufficientlytolocatetheblobOIDs *andfindthecommand-endingsemicolons.Thecommandsshouldnot *containanythinghardtoparseexceptfordouble-quotedrolenames, *whichareeasytoignore.Oncewe'vesplitapartthefirstandsecond *halvesofacommand,applyIssueCommandPerBlob.(Thismeansthe *updatesontheblobsareinterleavedifthere'smultiplecommands,but *thatshouldcausenotrouble.)
*/
inquotes = false;
st = en = buf;
st2 = NULL; while (*en)
{ /* Ignore double-quoted material */ if (*en == '"')
inquotes = !inquotes; if (inquotes)
{
en++; continue;
} /* If we found "LARGE OBJECT", that's the end of the first half */ if (strncmp(en, "LARGE OBJECT ", 13) == 0)
{ /* Terminate the first-half string */
en += 13;
Assert(isdigit((unsignedchar) *en));
*en++ = '\0'; /* Skip the rest of the blob OID */ while (isdigit((unsignedchar) *en))
en++; /* Second half starts here */
Assert(st2 == NULL);
st2 = en;
} /* If we found semicolon, that's the end of the second half */ elseif (*en == ';')
{ /* Terminate the second-half string */
*en++ = '\0';
Assert(st2 != NULL); /* Issue this command for each blob */
IssueCommandPerBlob(AH, blobte, st, st2); /* For neatness, skip whitespace before the next command */ while (isspace((unsignedchar) *en))
en++; /* Reset for new command */
st = en;
st2 = NULL;
} else
en++;
}
pg_free(buf);
}
void
DropLOIfExists(ArchiveHandle *AH, Oid oid)
{
ahprintf(AH, "SELECT pg_catalog.lo_unlink(oid) " "FROM pg_catalog.pg_largeobject_metadata " "WHERE oid = '%u';\n",
oid);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet am 2026-08-07)
¤
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.