Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f9f31aa

Browse files
committed
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
1 parent 4327f6c commit f9f31aa

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/backend/nodes/gen_node_support.pl

+2-2
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,9 @@ sub elem
924924
. "\t\t\t\t_out${n}(str, obj);\n"
925925
. "\t\t\t\tbreak;\n";
926926

927-
print $rfs "\telse if (MATCH(\"$N\", "
927+
print $rfs "\tif (MATCH(\"$N\", "
928928
. length($N) . "))\n"
929-
. "\t\treturn_value = _read${n}();\n"
929+
. "\t\treturn (Node *) _read${n}();\n"
930930
unless $no_read;
931931

932932
next if elem $n, @custom_read_write;

src/backend/nodes/readfuncs.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,6 @@ _readExtensibleNode(void)
697697
Node *
698698
parseNodeString(void)
699699
{
700-
void *return_value;
701-
702700
READ_TEMP_LOCALS();
703701

704702
/* Guard against stack overflow due to overly complex expressions */
@@ -709,16 +707,10 @@ parseNodeString(void)
709707
#define MATCH(tokname, namelen) \
710708
(length == namelen && memcmp(token, tokname, namelen) == 0)
711709

712-
if (false)
713-
;
714710
#include "readfuncs.switch.c"
715-
else
716-
{
717-
elog(ERROR, "badly formatted node string \"%.32s\"...", token);
718-
return_value = NULL; /* keep compiler quiet */
719-
}
720711

721-
return (Node *) return_value;
712+
elog(ERROR, "badly formatted node string \"%.32s\"...", token);
713+
return NULL; /* keep compiler quiet */
722714
}
723715

724716

0 commit comments

Comments
 (0)