summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/txid.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-08-02 23:49:19 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-08-02 23:49:19 -0400
commit09cecdf285ea9f51aed669f9ea1ba840197d49d0 (patch)
tree3ae143caf62089b9579acee6b52a92ad2975a6d8 /src/backend/utils/adt/txid.c
parent690ed2b76ab91eb79ea04ee2bfbdc8a2693f2a37 (diff)
Fix a number of places that produced XX000 errors in the regression tests.
It's against project policy to use elog() for user-facing errors, or to omit an errcode() selection for errors that aren't supposed to be "can't happen" cases. Fix all the violations of this policy that result in ERRCODE_INTERNAL_ERROR log entries during the standard regression tests, as errors that can reliably be triggered from SQL surely should be considered user-facing. I also looked through all the files touched by this commit and fixed other nearby problems of the same ilk. I do not claim to have fixed all violations of the policy, just the ones in these files. In a few places I also changed existing ERRCODE choices that didn't seem particularly appropriate; mainly replacing ERRCODE_SYNTAX_ERROR by something more specific. Back-patch to 9.5, but no further; changing ERRCODE assignments in stable branches doesn't seem like a good idea.
Diffstat (limited to 'src/backend/utils/adt/txid.c')
-rw-r--r--src/backend/utils/adt/txid.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/backend/utils/adt/txid.c b/src/backend/utils/adt/txid.c
index ce1d9abddea..ba4b48298fd 100644
--- a/src/backend/utils/adt/txid.c
+++ b/src/backend/utils/adt/txid.c
@@ -334,8 +334,11 @@ parse_snapshot(const char *str)
return buf_finalize(buf);
bad_format:
- elog(ERROR, "invalid input for txid_snapshot: \"%s\"", str_start);
- return NULL;
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+ errmsg("invalid input syntax for type txid_snapshot: \"%s\"",
+ str_start)));
+ return NULL; /* keep compiler quiet */
}
/*
@@ -526,8 +529,10 @@ txid_snapshot_recv(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(snap);
bad_format:
- elog(ERROR, "invalid snapshot data");
- return (Datum) NULL;
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
+ errmsg("invalid external txid_snapshot data")));
+ PG_RETURN_POINTER(NULL); /* keep compiler quiet */
}
/*