mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
Go back to returning int from ereport auxiliary functions.
This reverts the parts of commit 17a28b0364
that changed ereport's auxiliary functions from returning dummy integer
values to returning void. It turns out that a minority of compilers
complain (not entirely unreasonably) about constructs such as
(condition) ? errdetail(...) : 0
if errdetail() returns void rather than int. We could update those
call sites to say "(void) 0" perhaps, but the expectation for this
patch set was that ereport callers would not have to change anything.
And this aspect of the patch set was already the most invasive and
least compelling part of it, so let's just drop it.
Per buildfarm.
Discussion: https://postgr.es/m/CA+fd4k6N8EjNvZpM8nme+y+05mz-SM8Z_BgkixzkA34R+ej0Kw@mail.gmail.com
This commit is contained in:
@@ -329,7 +329,7 @@ typedef struct JsObject
|
||||
hash_destroy((jso)->val.json_hash); \
|
||||
} while (0)
|
||||
|
||||
static void report_json_context(JsonLexContext *lex);
|
||||
static int report_json_context(JsonLexContext *lex);
|
||||
|
||||
/* semantic action functions for json_object_keys */
|
||||
static void okeys_object_field_start(void *state, char *fname, bool isnull);
|
||||
@@ -631,7 +631,7 @@ json_ereport_error(JsonParseErrorType error, JsonLexContext *lex)
|
||||
* The return value isn't meaningful, but we make it non-void so that this
|
||||
* can be invoked inside ereport().
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
report_json_context(JsonLexContext *lex)
|
||||
{
|
||||
const char *context_start;
|
||||
@@ -689,8 +689,8 @@ report_json_context(JsonLexContext *lex)
|
||||
prefix = (context_start > line_start) ? "..." : "";
|
||||
suffix = (lex->token_type != JSON_TOKEN_END && context_end - lex->input < lex->input_length && *context_end != '\n' && *context_end != '\r') ? "..." : "";
|
||||
|
||||
errcontext("JSON data, line %d: %s%s%s",
|
||||
line_number, prefix, ctxt, suffix);
|
||||
return errcontext("JSON data, line %d: %s%s%s",
|
||||
line_number, prefix, ctxt, suffix);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -606,7 +606,7 @@ errfinish(const char *filename, int lineno, const char *funcname)
|
||||
*
|
||||
* The code is expected to be represented as per MAKE_SQLSTATE().
|
||||
*/
|
||||
void
|
||||
int
|
||||
errcode(int sqlerrcode)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -615,6 +615,8 @@ errcode(int sqlerrcode)
|
||||
CHECK_STACK_DEPTH();
|
||||
|
||||
edata->sqlerrcode = sqlerrcode;
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
@@ -627,7 +629,7 @@ errcode(int sqlerrcode)
|
||||
* NOTE: the primary error message string should generally include %m
|
||||
* when this is used.
|
||||
*/
|
||||
void
|
||||
int
|
||||
errcode_for_file_access(void)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -685,6 +687,8 @@ errcode_for_file_access(void)
|
||||
edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -696,7 +700,7 @@ errcode_for_file_access(void)
|
||||
* NOTE: the primary error message string should generally include %m
|
||||
* when this is used.
|
||||
*/
|
||||
void
|
||||
int
|
||||
errcode_for_socket_access(void)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -719,6 +723,8 @@ errcode_for_socket_access(void)
|
||||
edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
@@ -814,7 +820,7 @@ errcode_for_socket_access(void)
|
||||
* Note: no newline is needed at the end of the fmt string, since
|
||||
* ereport will provide one for the output methods that need it.
|
||||
*/
|
||||
void
|
||||
int
|
||||
errmsg(const char *fmt,...)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -829,13 +835,14 @@ errmsg(const char *fmt,...)
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a backtrace to the containing ereport() call. This is intended to be
|
||||
* added temporarily during debugging.
|
||||
*/
|
||||
void
|
||||
int
|
||||
errbacktrace(void)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -849,6 +856,8 @@ errbacktrace(void)
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -898,7 +907,7 @@ set_backtrace(ErrorData *edata, int num_skip)
|
||||
* the message because the translation would fail and result in infinite
|
||||
* error recursion.
|
||||
*/
|
||||
void
|
||||
int
|
||||
errmsg_internal(const char *fmt,...)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -913,6 +922,7 @@ errmsg_internal(const char *fmt,...)
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
@@ -920,7 +930,7 @@ errmsg_internal(const char *fmt,...)
|
||||
* errmsg_plural --- add a primary error message text to the current error,
|
||||
* with support for pluralization of the message text
|
||||
*/
|
||||
void
|
||||
int
|
||||
errmsg_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
unsigned long n,...)
|
||||
{
|
||||
@@ -936,13 +946,14 @@ errmsg_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* errdetail --- add a detail error message text to the current error
|
||||
*/
|
||||
void
|
||||
int
|
||||
errdetail(const char *fmt,...)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -956,6 +967,7 @@ errdetail(const char *fmt,...)
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
@@ -968,7 +980,7 @@ errdetail(const char *fmt,...)
|
||||
* messages that seem not worth translating for one reason or another
|
||||
* (typically, that they don't seem to be useful to average users).
|
||||
*/
|
||||
void
|
||||
int
|
||||
errdetail_internal(const char *fmt,...)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -982,13 +994,14 @@ errdetail_internal(const char *fmt,...)
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* errdetail_log --- add a detail_log error message text to the current error
|
||||
*/
|
||||
void
|
||||
int
|
||||
errdetail_log(const char *fmt,...)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1002,13 +1015,14 @@ errdetail_log(const char *fmt,...)
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
* errdetail_log_plural --- add a detail_log error message text to the current error
|
||||
* with support for pluralization of the message text
|
||||
*/
|
||||
void
|
||||
int
|
||||
errdetail_log_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
unsigned long n,...)
|
||||
{
|
||||
@@ -1023,6 +1037,7 @@ errdetail_log_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
@@ -1030,7 +1045,7 @@ errdetail_log_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
* errdetail_plural --- add a detail error message text to the current error,
|
||||
* with support for pluralization of the message text
|
||||
*/
|
||||
void
|
||||
int
|
||||
errdetail_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
unsigned long n,...)
|
||||
{
|
||||
@@ -1045,13 +1060,14 @@ errdetail_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* errhint --- add a hint error message text to the current error
|
||||
*/
|
||||
void
|
||||
int
|
||||
errhint(const char *fmt,...)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1065,6 +1081,7 @@ errhint(const char *fmt,...)
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
@@ -1075,7 +1092,7 @@ errhint(const char *fmt,...)
|
||||
* context information. We assume earlier calls represent more-closely-nested
|
||||
* states.
|
||||
*/
|
||||
void
|
||||
int
|
||||
errcontext_msg(const char *fmt,...)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1089,6 +1106,7 @@ errcontext_msg(const char *fmt,...)
|
||||
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
recursion_depth--;
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1100,7 +1118,7 @@ errcontext_msg(const char *fmt,...)
|
||||
* a set_errcontext_domain() call to specify the domain. This is usually
|
||||
* done transparently by the errcontext() macro.
|
||||
*/
|
||||
void
|
||||
int
|
||||
set_errcontext_domain(const char *domain)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1110,6 +1128,8 @@ set_errcontext_domain(const char *domain)
|
||||
|
||||
/* the default text domain is the backend's */
|
||||
edata->context_domain = domain ? domain : PG_TEXTDOMAIN("postgres");
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
@@ -1118,7 +1138,7 @@ set_errcontext_domain(const char *domain)
|
||||
*
|
||||
* This should be called if the message text already includes the statement.
|
||||
*/
|
||||
void
|
||||
int
|
||||
errhidestmt(bool hide_stmt)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1127,6 +1147,8 @@ errhidestmt(bool hide_stmt)
|
||||
CHECK_STACK_DEPTH();
|
||||
|
||||
edata->hide_stmt = hide_stmt;
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1135,7 +1157,7 @@ errhidestmt(bool hide_stmt)
|
||||
* This should only be used for verbose debugging messages where the repeated
|
||||
* inclusion of context would bloat the log volume too much.
|
||||
*/
|
||||
void
|
||||
int
|
||||
errhidecontext(bool hide_ctx)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1144,6 +1166,8 @@ errhidecontext(bool hide_ctx)
|
||||
CHECK_STACK_DEPTH();
|
||||
|
||||
edata->hide_ctx = hide_ctx;
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
@@ -1154,7 +1178,7 @@ errhidecontext(bool hide_ctx)
|
||||
* name appear in messages sent to old-protocol clients. Note that the
|
||||
* passed string is expected to be a non-freeable constant string.
|
||||
*/
|
||||
void
|
||||
int
|
||||
errfunction(const char *funcname)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1164,12 +1188,14 @@ errfunction(const char *funcname)
|
||||
|
||||
edata->funcname = funcname;
|
||||
edata->show_funcname = true;
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
* errposition --- add cursor position to the current error
|
||||
*/
|
||||
void
|
||||
int
|
||||
errposition(int cursorpos)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1178,12 +1204,14 @@ errposition(int cursorpos)
|
||||
CHECK_STACK_DEPTH();
|
||||
|
||||
edata->cursorpos = cursorpos;
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
* internalerrposition --- add internal cursor position to the current error
|
||||
*/
|
||||
void
|
||||
int
|
||||
internalerrposition(int cursorpos)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1192,6 +1220,8 @@ internalerrposition(int cursorpos)
|
||||
CHECK_STACK_DEPTH();
|
||||
|
||||
edata->internalpos = cursorpos;
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1201,7 +1231,7 @@ internalerrposition(int cursorpos)
|
||||
* is intended for use in error callback subroutines that are editorializing
|
||||
* on the layout of the error report.
|
||||
*/
|
||||
void
|
||||
int
|
||||
internalerrquery(const char *query)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1217,6 +1247,8 @@ internalerrquery(const char *query)
|
||||
|
||||
if (query)
|
||||
edata->internalquery = MemoryContextStrdup(edata->assoc_context, query);
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1229,7 +1261,7 @@ internalerrquery(const char *query)
|
||||
* Most potential callers should not use this directly, but instead prefer
|
||||
* higher-level abstractions, such as errtablecol() (see relcache.c).
|
||||
*/
|
||||
void
|
||||
int
|
||||
err_generic_string(int field, const char *str)
|
||||
{
|
||||
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||
@@ -1258,6 +1290,8 @@ err_generic_string(int field, const char *str)
|
||||
elog(ERROR, "unsupported ErrorData field id: %d", field);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user