summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Misch2023-06-14 12:31:54 +0000
committerNoah Misch2023-06-14 12:31:54 +0000
commitf9f31aa91f82df863a35354893978e1937863d7c (patch)
treebd9df41f2490bb74f63c54158dc91feea7cdfaf7
parent4327f6c7480fea9348ea6825a9d38a71b2ef8785 (diff)
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/[email protected]
-rw-r--r--src/backend/nodes/gen_node_support.pl4
-rw-r--r--src/backend/nodes/readfuncs.c12
2 files changed, 4 insertions, 12 deletions
diff --git a/src/backend/nodes/gen_node_support.pl b/src/backend/nodes/gen_node_support.pl
index b89b491d35..72c7963578 100644
--- a/src/backend/nodes/gen_node_support.pl
+++ b/src/backend/nodes/gen_node_support.pl
@@ -924,9 +924,9 @@ foreach my $n (@node_types)
. "\t\t\t\t_out${n}(str, obj);\n"
. "\t\t\t\tbreak;\n";
- print $rfs "\telse if (MATCH(\"$N\", "
+ print $rfs "\tif (MATCH(\"$N\", "
. length($N) . "))\n"
- . "\t\treturn_value = _read${n}();\n"
+ . "\t\treturn (Node *) _read${n}();\n"
unless $no_read;
next if elem $n, @custom_read_write;
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index a136ae1d60..97e43cbb49 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -697,8 +697,6 @@ _readExtensibleNode(void)
Node *
parseNodeString(void)
{
- void *return_value;
-
READ_TEMP_LOCALS();
/* Guard against stack overflow due to overly complex expressions */
@@ -709,16 +707,10 @@ parseNodeString(void)
#define MATCH(tokname, namelen) \
(length == namelen && memcmp(token, tokname, namelen) == 0)
- if (false)
- ;
#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 */
}