Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/backend/parser/parse_coerce.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,15 +1317,15 @@ coerce_to_specific_type(ParseState *pstate, Node *node,
* XXX possibly this is more generally useful than coercion errors;
* if so, should rename and place with parser_errposition.
*/
void
int
parser_coercion_errposition(ParseState *pstate,
int coerce_location,
Node *input_expr)
{
if (coerce_location >= 0)
parser_errposition(pstate, coerce_location);
return parser_errposition(pstate, coerce_location);
else
parser_errposition(pstate, exprLocation(input_expr));
return parser_errposition(pstate, exprLocation(input_expr));
}


Expand Down
8 changes: 4 additions & 4 deletions src/backend/parser/parse_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@ free_parsestate(ParseState *pstate)
* normal non-error case: computing character indexes would be much more
* expensive than storing token offsets.)
*/
void
int
parser_errposition(ParseState *pstate, int location)
{
int pos;

/* No-op if location was not provided */
if (location < 0)
return;
return 0;
/* Can't do anything if source text is not available */
if (pstate == NULL || pstate->p_sourcetext == NULL)
return;
return 0;
/* Convert offset to character number */
pos = pg_mbstrlen_with_len(pstate->p_sourcetext, location) + 1;
/* And pass it to the ereport mechanism */
errposition(pos);
return errposition(pos);
}


Expand Down
8 changes: 4 additions & 4 deletions src/backend/storage/ipc/dsm_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static bool dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
void **impl_private, void **mapped_address,
Size *mapped_size, int elevel);
#endif
static void errcode_for_dynamic_shared_memory(void);
static int errcode_for_dynamic_shared_memory(void);

const struct config_enum_entry dynamic_shared_memory_options[] = {
#ifdef USE_DSM_POSIX
Expand Down Expand Up @@ -1048,11 +1048,11 @@ dsm_impl_unpin_segment(dsm_handle handle, void **impl_private)
}
}

static void
static int
errcode_for_dynamic_shared_memory(void)
{
if (errno == EFBIG || errno == ENOMEM)
errcode(ERRCODE_OUT_OF_MEMORY);
return errcode(ERRCODE_OUT_OF_MEMORY);
else
errcode_for_file_access();
return errcode_for_file_access();
}
60 changes: 42 additions & 18 deletions src/backend/utils/error/elog.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ errfinish_and_return(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];
Expand All @@ -913,6 +913,7 @@ errcode(int sqlerrcode)
edata->omit_location = false;
else
edata->omit_location = true;
return 0; /* return value does not matter */
}


Expand All @@ -925,7 +926,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];
Expand Down Expand Up @@ -984,6 +985,8 @@ errcode_for_file_access(void)
edata->omit_location = false;
break;
}

return 0; /* return value does not matter */
}

/*
Expand All @@ -995,7 +998,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];
Expand All @@ -1016,6 +1019,8 @@ errcode_for_socket_access(void)
edata->omit_location = false;
break;
}

return 0; /* return value does not matter */
}

/*
Expand Down Expand Up @@ -1137,7 +1142,7 @@ sqlstate_to_errcode(const char *sqlstate)
* 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];
Expand All @@ -1153,6 +1158,7 @@ errmsg(const char *fmt,...)
MemoryContextSwitchTo(oldcontext);
recursion_depth--;
errno = edata->saved_errno; /*CDB*/
return 0; /* return value does not matter */
}

/*
Expand Down Expand Up @@ -1224,7 +1230,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];
Expand All @@ -1240,14 +1246,15 @@ errmsg_internal(const char *fmt,...)
MemoryContextSwitchTo(oldcontext);
recursion_depth--;
errno = edata->saved_errno; /*CDB*/
return 0; /* return value does not matter */
}


/*
* 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, ...)
{
Expand All @@ -1264,13 +1271,14 @@ errmsg_plural(const char *fmt_singular, const char *fmt_plural,
MemoryContextSwitchTo(oldcontext);
recursion_depth--;
errno = edata->saved_errno; /*CDB*/
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];
Expand All @@ -1285,6 +1293,7 @@ errdetail(const char *fmt,...)
MemoryContextSwitchTo(oldcontext);
recursion_depth--;
errno = edata->saved_errno; /*CDB*/
return 0; /* return value does not matter */
}


Expand All @@ -1297,7 +1306,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];
Expand All @@ -1311,13 +1320,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];
Expand All @@ -1332,13 +1342,14 @@ errdetail_log(const char *fmt,...)
MemoryContextSwitchTo(oldcontext);
recursion_depth--;
errno = edata->saved_errno; /*CDB*/
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,...)
{
Expand All @@ -1353,14 +1364,15 @@ errdetail_log_plural(const char *fmt_singular, const char *fmt_plural,

MemoryContextSwitchTo(oldcontext);
recursion_depth--;
return 0; /* return value does not matter */
}


/*
* 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, ...)
{
Expand All @@ -1376,13 +1388,14 @@ errdetail_plural(const char *fmt_singular, const char *fmt_plural,
MemoryContextSwitchTo(oldcontext);
recursion_depth--;
errno = edata->saved_errno; /*CDB*/
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];
Expand All @@ -1397,6 +1410,7 @@ errhint(const char *fmt,...)
MemoryContextSwitchTo(oldcontext);
recursion_depth--;
errno = edata->saved_errno; /*CDB*/
return 0; /* return value does not matter */
}


Expand Down Expand Up @@ -1477,7 +1491,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];
Expand All @@ -1486,6 +1500,8 @@ errhidestmt(bool hide_stmt)
CHECK_STACK_DEPTH();

edata->hide_stmt = hide_stmt;

return 0; /* return value does not matter */
}

/*
Expand All @@ -1494,7 +1510,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];
Expand All @@ -1503,6 +1519,8 @@ errhidecontext(bool hide_ctx)
CHECK_STACK_DEPTH();

edata->hide_ctx = hide_ctx;

return 0; /* return value does not matter */
}


Expand All @@ -1519,7 +1537,7 @@ errposition(int cursorpos)

edata->cursorpos = cursorpos;

return 0;
return 0; /* return value does not matter */
}

/*
Expand All @@ -1538,7 +1556,7 @@ errprintstack(bool printstack)
/*
* internalerrposition --- add internal cursor position to the current error
*/
void
int
internalerrposition(int cursorpos)
{
ErrorData *edata = &errordata[errordata_stack_depth];
Expand All @@ -1547,6 +1565,8 @@ internalerrposition(int cursorpos)
CHECK_STACK_DEPTH();

edata->internalpos = cursorpos;

return 0; /* return value does not matter */
}

/*
Expand All @@ -1556,7 +1576,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];
Expand All @@ -1573,6 +1593,8 @@ internalerrquery(const char *query)
if (query)
edata->internalquery = MemoryContextStrdup(edata->assoc_context, query);
errno = edata->saved_errno; /*CDB*/

return 0; /* return value does not matter */
}

/*
Expand All @@ -1585,7 +1607,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];
Expand Down Expand Up @@ -1614,6 +1636,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 */
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/include/executor/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
extern void ExecInitResultRelation(EState *estate, ResultRelInfo *resultRelInfo,
Index rti);

extern int executor_errposition(EState *estate, int location);
extern int executor_errposition(EState *estate, int location);

extern void RegisterExprContextCallback(ExprContext *econtext,
ExprContextCallbackFunction function,
Expand Down
2 changes: 1 addition & 1 deletion src/include/parser/parse_coerce.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extern Node *coerce_to_specific_type_typmod(ParseState *pstate, Node *node,
Oid targetTypeId, int32 targetTypmod,
const char *constructName);

extern void parser_coercion_errposition(ParseState *pstate,
extern int parser_coercion_errposition(ParseState *pstate,
int coerce_location,
Node *input_expr);

Expand Down
2 changes: 1 addition & 1 deletion src/include/parser/parse_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ typedef struct ParseCallbackState
extern ParseState *make_parsestate(ParseState *parentParseState);
extern void free_parsestate(ParseState *pstate);
extern struct HTAB *parser_get_namecache(ParseState *pstate);
extern void parser_errposition(ParseState *pstate, int location);
extern int parser_errposition(ParseState *pstate, int location);

extern void setup_parser_errposition_callback(ParseCallbackState *pcbstate,
ParseState *pstate, int location);
Expand Down
Loading
Loading