Go back to returning int from ereport auxiliary functions.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 25 Mar 2020 15:57:36 +0000 (11:57 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 25 Mar 2020 15:57:36 +0000 (11:57 -0400)
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

14 files changed:
src/backend/executor/execUtils.c
src/backend/parser/parse_coerce.c
src/backend/parser/parse_node.c
src/backend/parser/scan.l
src/backend/storage/ipc/dsm_impl.c
src/backend/utils/adt/jsonfuncs.c
src/backend/utils/error/elog.c
src/include/executor/executor.h
src/include/parser/parse_coerce.h
src/include/parser/parse_node.h
src/include/parser/scanner.h
src/include/utils/elog.h
src/pl/plpgsql/src/pl_scanner.c
src/pl/plpgsql/src/plpgsql.h

index 6deef1c679a412f12a3aad6c7b2d504c5da66734..cc5177cc2b9f13b0a65c6b1fbb5649457eb451ca 100644 (file)
@@ -832,21 +832,21 @@ UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
  * normal non-error case: computing character indexes would be much more
  * expensive than storing token offsets.)
  */
-void
+int
 executor_errposition(EState *estate, 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 (estate == NULL || estate->es_sourceText == NULL)
-               return;
+               return 0;
        /* Convert offset to character number */
        pos = pg_mbstrlen_with_len(estate->es_sourceText, location) + 1;
        /* And pass it to the ereport mechanism */
-       errposition(pos);
+       return errposition(pos);
 }
 
 /*
index 91d4e99d3457c6ba8fd878ac5e15ee867aaf0fd4..645e4aa4ceb2be8e619a1b25df837bbd7cfd5bca 100644 (file)
@@ -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));
 }
 
 
index 9a2fd924b67c35ed33f196ab0fb22272df93e098..6e98fe55fc471eea005ab881298111958fcd7c0d 100644 (file)
@@ -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);
 }
 
 
index 50ba68abd4f54856ce2ae712b4a04dfde9b124e2..b1ea0cb538467e66f3bb945467af4065577cbb54 100644 (file)
@@ -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);
 }
 
 /*
index 8dc9c0b5cdf37ddcb6ffd192a613b2ced60355de..1972aecbedc1aab7a235558a81e1a16308d01da7 100644 (file)
@@ -92,7 +92,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
@@ -1030,11 +1030,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();
 }
index 321ab9a0db9fa32159611af2ae10aa7f635d09f2..4b5007e0d6fdd8c9c7411fb804190075b1d95ff9 100644 (file)
@@ -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);
 }
 
 
index 6ac2152ddfe4922611212141de4e567913421c9e..b8858b132b86ac9320a1bd46898ae77f7bd460a5 100644 (file)
@@ -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 */
 }
 
 /*
index cd0e6439cdeff8e85e7eda91cdd742d85ad116aa..94890512dc881806aa31c4c2dc9670a3d46314bd 100644 (file)
@@ -546,7 +546,7 @@ exec_rt_fetch(Index rti, EState *estate)
 
 extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
 
-extern void executor_errposition(EState *estate, int location);
+extern int     executor_errposition(EState *estate, int location);
 
 extern void RegisterExprContextCallback(ExprContext *econtext,
                                                                                ExprContextCallbackFunction function,
index a3295b3fa45f72abe452e188d7b510e76b066901..8686eaacbc9bbd9b870157ca8d47d56793e7206d 100644 (file)
@@ -61,7 +61,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);
 
index b223b5954234ffdbe2f833e9045f3b4770c45343..d25819aa28b3855c365ff17f19df1d4b16db7b7e 100644 (file)
@@ -307,7 +307,7 @@ typedef struct ParseCallbackState
 
 extern ParseState *make_parsestate(ParseState *parentParseState);
 extern void free_parsestate(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);
index 02ae10a225005889bbb1740e5b20b4f45a0d7569..a27352afc1453a75677faf7ea12836468838ebe7 100644 (file)
@@ -140,7 +140,7 @@ extern core_yyscan_t scanner_init(const char *str,
 extern void scanner_finish(core_yyscan_t yyscanner);
 extern int     core_yylex(core_YYSTYPE *lvalp, YYLTYPE *llocp,
                                           core_yyscan_t yyscanner);
-extern void scanner_errposition(int location, core_yyscan_t yyscanner);
+extern int     scanner_errposition(int location, core_yyscan_t yyscanner);
 extern void setup_scanner_errposition_callback(ScannerCallbackState *scbstate,
                                                                                           core_yyscan_t yyscanner,
                                                                                           int location);
index d244b1c0ac572e51ea1c2ace20012f6708e4a880..1e09ee05418af8e0fc74960d284cf5609568655c 100644 (file)
 extern bool errstart(int elevel, const char *domain);
 extern void errfinish(const char *filename, int lineno, const char *funcname);
 
-extern void errcode(int sqlerrcode);
+extern int     errcode(int sqlerrcode);
 
-extern void errcode_for_file_access(void);
-extern void errcode_for_socket_access(void);
+extern int     errcode_for_file_access(void);
+extern int     errcode_for_socket_access(void);
 
-extern void errmsg(const char *fmt,...) pg_attribute_printf(1, 2);
-extern void errmsg_internal(const char *fmt,...) pg_attribute_printf(1, 2);
+extern int     errmsg(const char *fmt,...) pg_attribute_printf(1, 2);
+extern int     errmsg_internal(const char *fmt,...) pg_attribute_printf(1, 2);
 
-extern void errmsg_plural(const char *fmt_singular, const char *fmt_plural,
+extern int     errmsg_plural(const char *fmt_singular, const char *fmt_plural,
                                                  unsigned long n,...) pg_attribute_printf(1, 4) pg_attribute_printf(2, 4);
 
-extern void errdetail(const char *fmt,...) pg_attribute_printf(1, 2);
-extern void errdetail_internal(const char *fmt,...) pg_attribute_printf(1, 2);
+extern int     errdetail(const char *fmt,...) pg_attribute_printf(1, 2);
+extern int     errdetail_internal(const char *fmt,...) pg_attribute_printf(1, 2);
 
-extern void errdetail_log(const char *fmt,...) pg_attribute_printf(1, 2);
+extern int     errdetail_log(const char *fmt,...) pg_attribute_printf(1, 2);
 
-extern void errdetail_log_plural(const char *fmt_singular,
+extern int     errdetail_log_plural(const char *fmt_singular,
                                                                 const char *fmt_plural,
                                                                 unsigned long n,...) pg_attribute_printf(1, 4) pg_attribute_printf(2, 4);
 
-extern void errdetail_plural(const char *fmt_singular, const char *fmt_plural,
+extern int     errdetail_plural(const char *fmt_singular, const char *fmt_plural,
                                                         unsigned long n,...) pg_attribute_printf(1, 4) pg_attribute_printf(2, 4);
 
-extern void errhint(const char *fmt,...) pg_attribute_printf(1, 2);
+extern int     errhint(const char *fmt,...) pg_attribute_printf(1, 2);
 
 /*
  * errcontext() is typically called in error context callback functions, not
@@ -184,22 +184,22 @@ extern void errhint(const char *fmt,...) pg_attribute_printf(1, 2);
  */
 #define errcontext     set_errcontext_domain(TEXTDOMAIN),      errcontext_msg
 
-extern void set_errcontext_domain(const char *domain);
+extern int     set_errcontext_domain(const char *domain);
 
-extern void errcontext_msg(const char *fmt,...) pg_attribute_printf(1, 2);
+extern int     errcontext_msg(const char *fmt,...) pg_attribute_printf(1, 2);
 
-extern void errhidestmt(bool hide_stmt);
-extern void errhidecontext(bool hide_ctx);
+extern int     errhidestmt(bool hide_stmt);
+extern int     errhidecontext(bool hide_ctx);
 
-extern void errbacktrace(void);
+extern int     errbacktrace(void);
 
-extern void errfunction(const char *funcname);
-extern void errposition(int cursorpos);
+extern int     errfunction(const char *funcname);
+extern int     errposition(int cursorpos);
 
-extern void internalerrposition(int cursorpos);
-extern void internalerrquery(const char *query);
+extern int     internalerrposition(int cursorpos);
+extern int     internalerrquery(const char *query);
 
-extern void err_generic_string(int field, const char *str);
+extern int     err_generic_string(int field, const char *str);
 
 extern int     geterrcode(void);
 extern int     geterrposition(void);
index 9d81679cc50d8e7c096ba5d51baf02e018ff780a..9cea2e42ac4d39ef3a8e0e5e4967bbf2eb399075 100644 (file)
@@ -468,20 +468,20 @@ plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc, int *tok2_loc)
  * parsing of a plpgsql function, since it requires the scanorig string
  * to still be available.
  */
-void
+int
 plpgsql_scanner_errposition(int location)
 {
        int                     pos;
 
        if (location < 0 || scanorig == NULL)
-               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(scanorig, location) + 1;
        /* And pass it to the ereport mechanism */
        (void) internalerrposition(pos);
        /* Also pass the function body string */
-       internalerrquery(scanorig);
+       return internalerrquery(scanorig);
 }
 
 /*
index 325f4f7fd45dcb236340bff528a66f653017d36d..69df3306fda0733a42d3783ca3267f919e883acb 100644 (file)
@@ -1319,7 +1319,7 @@ extern void plpgsql_append_source_text(StringInfo buf,
 extern int     plpgsql_peek(void);
 extern void plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc,
                                                  int *tok2_loc);
-extern void plpgsql_scanner_errposition(int location);
+extern int     plpgsql_scanner_errposition(int location);
 extern void plpgsql_yyerror(const char *message) pg_attribute_noreturn();
 extern int     plpgsql_location_to_lineno(int location);
 extern int     plpgsql_latest_lineno(void);