Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbda6ded

Browse files
committed
Go back to returning int from ereport auxiliary functions.
This reverts the parts of commit17a28b0that changed ereport's auxiliary functions from returning dummy integervalues to returning void. It turns out that a minority of compilerscomplain (not entirely unreasonably) about constructs such as(condition) ? errdetail(...) : 0if errdetail() returns void rather than int. We could update thosecall sites to say "(void) 0" perhaps, but the expectation for thispatch set was that ereport callers would not have to change anything.And this aspect of the patch set was already the most invasive andleast 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
1 parentf581759 commitbda6ded

File tree

14 files changed

+108
-74
lines changed

14 files changed

+108
-74
lines changed

‎src/backend/executor/execUtils.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,21 +832,21 @@ UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
832832
* normal non-error case: computing character indexes would be much more
833833
* expensive than storing token offsets.)
834834
*/
835-
void
835+
int
836836
executor_errposition(EState*estate,intlocation)
837837
{
838838
intpos;
839839

840840
/* No-op if location was not provided */
841841
if (location<0)
842-
return;
842+
return0;
843843
/* Can't do anything if source text is not available */
844844
if (estate==NULL||estate->es_sourceText==NULL)
845-
return;
845+
return0;
846846
/* Convert offset to character number */
847847
pos=pg_mbstrlen_with_len(estate->es_sourceText,location)+1;
848848
/* And pass it to the ereport mechanism */
849-
errposition(pos);
849+
returnerrposition(pos);
850850
}
851851

852852
/*

‎src/backend/parser/parse_coerce.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,15 +1246,15 @@ coerce_to_specific_type(ParseState *pstate, Node *node,
12461246
* XXX possibly this is more generally useful than coercion errors;
12471247
* if so, should rename and place with parser_errposition.
12481248
*/
1249-
void
1249+
int
12501250
parser_coercion_errposition(ParseState*pstate,
12511251
intcoerce_location,
12521252
Node*input_expr)
12531253
{
12541254
if (coerce_location >=0)
1255-
parser_errposition(pstate,coerce_location);
1255+
returnparser_errposition(pstate,coerce_location);
12561256
else
1257-
parser_errposition(pstate,exprLocation(input_expr));
1257+
returnparser_errposition(pstate,exprLocation(input_expr));
12581258
}
12591259

12601260

‎src/backend/parser/parse_node.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,21 @@ free_parsestate(ParseState *pstate)
106106
* normal non-error case: computing character indexes would be much more
107107
* expensive than storing token offsets.)
108108
*/
109-
void
109+
int
110110
parser_errposition(ParseState*pstate,intlocation)
111111
{
112112
intpos;
113113

114114
/* No-op if location was not provided */
115115
if (location<0)
116-
return;
116+
return0;
117117
/* Can't do anything if source text is not available */
118118
if (pstate==NULL||pstate->p_sourcetext==NULL)
119-
return;
119+
return0;
120120
/* Convert offset to character number */
121121
pos=pg_mbstrlen_with_len(pstate->p_sourcetext,location)+1;
122122
/* And pass it to the ereport mechanism */
123-
errposition(pos);
123+
returnerrposition(pos);
124124
}
125125

126126

‎src/backend/parser/scan.l

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,18 +1076,18 @@ other.
10761076
* (essentially, scan.l, parser.c, and gram.y), since it requires the
10771077
* yyscanner struct to still be available.
10781078
*/
1079-
void
1079+
int
10801080
scanner_errposition(int location,core_yyscan_t yyscanner)
10811081
{
10821082
intpos;
10831083

10841084
if (location <0)
1085-
return;/* no-op if location is unknown */
1085+
return0;/* no-op if location is unknown */
10861086

10871087
/* Convert byte offset to character number */
10881088
pos =pg_mbstrlen_with_len(yyextra->scanbuf, location) +1;
10891089
/* And pass it to the ereport mechanism */
1090-
errposition(pos);
1090+
returnerrposition(pos);
10911091
}
10921092

10931093
/*

‎src/backend/storage/ipc/dsm_impl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static bool dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
9292
void**impl_private,void**mapped_address,
9393
Size*mapped_size,intelevel);
9494
#endif
95-
staticvoiderrcode_for_dynamic_shared_memory(void);
95+
staticinterrcode_for_dynamic_shared_memory(void);
9696

9797
conststructconfig_enum_entrydynamic_shared_memory_options[]= {
9898
#ifdefUSE_DSM_POSIX
@@ -1030,11 +1030,11 @@ dsm_impl_unpin_segment(dsm_handle handle, void **impl_private)
10301030
}
10311031
}
10321032

1033-
staticvoid
1033+
staticint
10341034
errcode_for_dynamic_shared_memory(void)
10351035
{
10361036
if (errno==EFBIG||errno==ENOMEM)
1037-
errcode(ERRCODE_OUT_OF_MEMORY);
1037+
returnerrcode(ERRCODE_OUT_OF_MEMORY);
10381038
else
1039-
errcode_for_file_access();
1039+
returnerrcode_for_file_access();
10401040
}

‎src/backend/utils/adt/jsonfuncs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ typedef struct JsObject
329329
hash_destroy((jso)->val.json_hash); \
330330
} while (0)
331331

332-
staticvoidreport_json_context(JsonLexContext*lex);
332+
staticintreport_json_context(JsonLexContext*lex);
333333

334334
/* semantic action functions for json_object_keys */
335335
staticvoidokeys_object_field_start(void*state,char*fname,boolisnull);
@@ -631,7 +631,7 @@ json_ereport_error(JsonParseErrorType error, JsonLexContext *lex)
631631
* The return value isn't meaningful, but we make it non-void so that this
632632
* can be invoked inside ereport().
633633
*/
634-
staticvoid
634+
staticint
635635
report_json_context(JsonLexContext*lex)
636636
{
637637
constchar*context_start;
@@ -689,8 +689,8 @@ report_json_context(JsonLexContext *lex)
689689
prefix= (context_start>line_start) ?"..." :"";
690690
suffix= (lex->token_type!=JSON_TOKEN_END&&context_end-lex->input<lex->input_length&&*context_end!='\n'&&*context_end!='\r') ?"..." :"";
691691

692-
errcontext("JSON data, line %d: %s%s%s",
693-
line_number,prefix,ctxt,suffix);
692+
returnerrcontext("JSON data, line %d: %s%s%s",
693+
line_number,prefix,ctxt,suffix);
694694
}
695695

696696

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp