mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Restructure soft-error handling in formatting.c.
Replace the error trapping scheme introduced in 5bc450629
with our
shiny new errsave/ereturn mechanism. This doesn't have any real
functional impact (although I think that the new coding is able
to report a few more errors softly than v15 did). And I doubt
there's any measurable performance difference either. But this
gets rid of an ad-hoc, one-of-a-kind design in favor of a mechanism
that will be widely used going forward, so it should be a net win
for code readability.
Discussion: https://postgr.es/m/3bbbb0df-7382-bf87-9737-340ba096e034@postgrespro.ru
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1808,7 +1808,7 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
|
|||||||
text *template;
|
text *template;
|
||||||
char *template_str;
|
char *template_str;
|
||||||
int template_len;
|
int template_len;
|
||||||
bool have_error = false;
|
ErrorSaveContext escontext = {T_ErrorSaveContext};
|
||||||
|
|
||||||
jspGetArg(jsp, &elem);
|
jspGetArg(jsp, &elem);
|
||||||
|
|
||||||
@ -1822,9 +1822,9 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
|
|||||||
|
|
||||||
value = parse_datetime(datetime, template, collid, true,
|
value = parse_datetime(datetime, template, collid, true,
|
||||||
&typid, &typmod, &tz,
|
&typid, &typmod, &tz,
|
||||||
jspThrowErrors(cxt) ? NULL : &have_error);
|
jspThrowErrors(cxt) ? NULL : (Node *) &escontext);
|
||||||
|
|
||||||
if (have_error)
|
if (escontext.error_occurred)
|
||||||
res = jperError;
|
res = jperError;
|
||||||
else
|
else
|
||||||
res = jperOk;
|
res = jperOk;
|
||||||
@ -1859,7 +1859,7 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
|
|||||||
/* loop until datetime format fits */
|
/* loop until datetime format fits */
|
||||||
for (i = 0; i < lengthof(fmt_str); i++)
|
for (i = 0; i < lengthof(fmt_str); i++)
|
||||||
{
|
{
|
||||||
bool have_error = false;
|
ErrorSaveContext escontext = {T_ErrorSaveContext};
|
||||||
|
|
||||||
if (!fmt_txt[i])
|
if (!fmt_txt[i])
|
||||||
{
|
{
|
||||||
@ -1872,9 +1872,9 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
|
|||||||
|
|
||||||
value = parse_datetime(datetime, fmt_txt[i], collid, true,
|
value = parse_datetime(datetime, fmt_txt[i], collid, true,
|
||||||
&typid, &typmod, &tz,
|
&typid, &typmod, &tz,
|
||||||
&have_error);
|
(Node *) &escontext);
|
||||||
|
|
||||||
if (!have_error)
|
if (!escontext.error_occurred)
|
||||||
{
|
{
|
||||||
res = jperOk;
|
res = jperOk;
|
||||||
break;
|
break;
|
||||||
|
@ -28,6 +28,6 @@ extern char *asc_initcap(const char *buff, size_t nbytes);
|
|||||||
|
|
||||||
extern Datum parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict,
|
extern Datum parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict,
|
||||||
Oid *typid, int32 *typmod, int *tz,
|
Oid *typid, int32 *typmod, int *tz,
|
||||||
bool *have_error);
|
struct Node *escontext);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user