mirror of
https://github.com/postgres/postgres.git
synced 2025-05-31 03:21:24 +03:00
Make parseNodeString() C idiom compatible with Visual Studio 2015.
Between v15 and now, this function's "else if" chain grew from 252 lines to 592 lines, exceeding a compiler limit that manifests as "fatal error C1026: parser stack overflow, program too complex (compiling source file src/backend/nodes/readfuncs.c)". Use "if (...) return ...;" instead. Reviewed by Tom Lane, Peter Eisentraut and Michael Paquier. Not all reviewers endorse this. Discussion: https://postgr.es/m/20230607185458.GA1334487@rfd.leadboat.com
This commit is contained in:
parent
4327f6c748
commit
f9f31aa91f
@ -924,9 +924,9 @@ foreach my $n (@node_types)
|
|||||||
. "\t\t\t\t_out${n}(str, obj);\n"
|
. "\t\t\t\t_out${n}(str, obj);\n"
|
||||||
. "\t\t\t\tbreak;\n";
|
. "\t\t\t\tbreak;\n";
|
||||||
|
|
||||||
print $rfs "\telse if (MATCH(\"$N\", "
|
print $rfs "\tif (MATCH(\"$N\", "
|
||||||
. length($N) . "))\n"
|
. length($N) . "))\n"
|
||||||
. "\t\treturn_value = _read${n}();\n"
|
. "\t\treturn (Node *) _read${n}();\n"
|
||||||
unless $no_read;
|
unless $no_read;
|
||||||
|
|
||||||
next if elem $n, @custom_read_write;
|
next if elem $n, @custom_read_write;
|
||||||
|
@ -697,8 +697,6 @@ _readExtensibleNode(void)
|
|||||||
Node *
|
Node *
|
||||||
parseNodeString(void)
|
parseNodeString(void)
|
||||||
{
|
{
|
||||||
void *return_value;
|
|
||||||
|
|
||||||
READ_TEMP_LOCALS();
|
READ_TEMP_LOCALS();
|
||||||
|
|
||||||
/* Guard against stack overflow due to overly complex expressions */
|
/* Guard against stack overflow due to overly complex expressions */
|
||||||
@ -709,16 +707,10 @@ parseNodeString(void)
|
|||||||
#define MATCH(tokname, namelen) \
|
#define MATCH(tokname, namelen) \
|
||||||
(length == namelen && memcmp(token, tokname, namelen) == 0)
|
(length == namelen && memcmp(token, tokname, namelen) == 0)
|
||||||
|
|
||||||
if (false)
|
|
||||||
;
|
|
||||||
#include "readfuncs.switch.c"
|
#include "readfuncs.switch.c"
|
||||||
else
|
|
||||||
{
|
|
||||||
elog(ERROR, "badly formatted node string \"%.32s\"...", token);
|
|
||||||
return_value = NULL; /* keep compiler quiet */
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Node *) return_value;
|
elog(ERROR, "badly formatted node string \"%.32s\"...", token);
|
||||||
|
return NULL; /* keep compiler quiet */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user