aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-03-25 11:57:36 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-03-25 11:57:36 -0400
commitbda6dedbea599209048bc51115ecb2062ceb976c (patch)
tree978a9e7efd646601f82780c6dcd41eb274f29acc /src/backend/parser
parentf5817595a7f194d25bc9be5b035eb1f7f60cd1fa (diff)
downloadpostgresql-bda6dedbea599209048bc51115ecb2062ceb976c.tar.gz
postgresql-bda6dedbea599209048bc51115ecb2062ceb976c.zip
Go back to returning int from ereport auxiliary functions.
This reverts the parts of commit 17a28b03645e27d73bf69a95d7569b61e58f06eb 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
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/parse_coerce.c6
-rw-r--r--src/backend/parser/parse_node.c8
-rw-r--r--src/backend/parser/scan.l6
3 files changed, 10 insertions, 10 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 91d4e99d345..645e4aa4ceb 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -1246,15 +1246,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));
}
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
index 9a2fd924b67..6e98fe55fc4 100644
--- a/src/backend/parser/parse_node.c
+++ b/src/backend/parser/parse_node.c
@@ -106,21 +106,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);
}
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index 50ba68abd4f..b1ea0cb5384 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -1076,18 +1076,18 @@ other .
* (essentially, scan.l, parser.c, and gram.y), since it requires the
* yyscanner struct to still be available.
*/
-void
+int
scanner_errposition(int location, core_yyscan_t yyscanner)
{
int pos;
if (location < 0)
- return; /* no-op if location is unknown */
+ return 0; /* no-op if location is unknown */
/* Convert byte offset to character number */
pos = pg_mbstrlen_with_len(yyextra->scanbuf, location) + 1;
/* And pass it to the ereport mechanism */
- errposition(pos);
+ return errposition(pos);
}
/*