diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-04-08 14:55:14 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-04-08 14:55:14 -0400 |
commit | 9a374b77fb53e4cfbca121e4fa278a7d71bde7c4 (patch) | |
tree | 6591af757bd9df12549279b4b87f01e0ce98bd79 /src/bin/pg_dump/common.c | |
parent | 5c431c7fb327e1abc70b7a197650f8d45fd5bede (diff) |
Improve frontend error logging style.
Get rid of the separate "FATAL" log level, as it was applied
so inconsistently as to be meaningless. This mostly involves
s/pg_log_fatal/pg_log_error/g.
Create a macro pg_fatal() to handle the common use-case of
pg_log_error() immediately followed by exit(1). Various
modules had already invented either this or equivalent macros;
standardize on pg_fatal() and apply it where possible.
Invent the ability to add "detail" and "hint" messages to a
frontend message, much as we have long had in the backend.
Except where rewording was needed to convert existing coding
to detail/hint style, I have (mostly) resisted the temptation
to change existing message wording.
Patch by me. Design and patch reviewed at various stages by
Robert Haas, Kyotaro Horiguchi, Peter Eisentraut and
Daniel Gustafsson.
Discussion: https://postgr.es/m/1363732.1636496441@sss.pgh.pa.us
Diffstat (limited to 'src/bin/pg_dump/common.c')
-rw-r--r-- | src/bin/pg_dump/common.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b9a25442f5f..794e6e7ce99 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -340,9 +340,9 @@ flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables, /* With partitions there can only be one parent */ if (tblinfo[i].numParents != 1) - fatal("invalid number of parents %d for table \"%s\"", - tblinfo[i].numParents, - tblinfo[i].dobj.name); + pg_fatal("invalid number of parents %d for table \"%s\"", + tblinfo[i].numParents, + tblinfo[i].dobj.name); attachinfo = (TableAttachInfo *) palloc(sizeof(TableAttachInfo)); attachinfo->dobj.objType = DO_TABLE_ATTACH; @@ -1001,13 +1001,10 @@ findParentsByOid(TableInfo *self, parent = findTableByOid(inhinfo[i].inhparent); if (parent == NULL) - { - pg_log_error("failed sanity check, parent OID %u of table \"%s\" (OID %u) not found", - inhinfo[i].inhparent, - self->dobj.name, - oid); - exit_nicely(1); - } + pg_fatal("failed sanity check, parent OID %u of table \"%s\" (OID %u) not found", + inhinfo[i].inhparent, + self->dobj.name, + oid); self->parents[j++] = parent; } } @@ -1043,10 +1040,7 @@ parseOidArray(const char *str, Oid *array, int arraysize) if (j > 0) { if (argNum >= arraysize) - { - pg_log_error("could not parse numeric array \"%s\": too many numbers", str); - exit_nicely(1); - } + pg_fatal("could not parse numeric array \"%s\": too many numbers", str); temp[j] = '\0'; array[argNum++] = atooid(temp); j = 0; @@ -1058,10 +1052,7 @@ parseOidArray(const char *str, Oid *array, int arraysize) { if (!(isdigit((unsigned char) s) || s == '-') || j >= sizeof(temp) - 1) - { - pg_log_error("could not parse numeric array \"%s\": invalid character in number", str); - exit_nicely(1); - } + pg_fatal("could not parse numeric array \"%s\": invalid character in number", str); temp[j++] = s; } } |