Fix ecpg's mechanism for detecting unsupported cases in the grammar.
ecpg wants to emit a warning if it parses a SQL construct that the backend can parse but will immediately throw a FEATURE_NOT_SUPPORTED error for. The way it was testing for this was to see if the string ERRCODE_FEATURE_NOT_SUPPORTED appeared anywhere in the gram.y code. This is, of course, not nearly good enough, as there are plenty of rules in gram.y that throw that error only conditionally. There was a hack dating to 2008 to suppress the warning in one rule that doesn't even exist anymore, but nothing for other cases we've created since then. End result was that you could get "unsupported feature will be passed to server" warnings while compiling perfectly good SQL code in ecpg. Somehow we'd not heard complaints about this, but it was exposed by the recent addition of an ecpg test for a SQL/JSON construct. To fix, suppress the warning if the rule contains any "if" statement. Manual comparison of gram.y with the generated preproc.y file shows that the warning is now emitted only in rules where it's sensible. This problem has existed for a long time, so back-patch to all supported branches. Discussion: https://postgr.es/m/603615.1712245382@sss.pgh.pa.us
This commit is contained in:
parent
68044d15b7
commit
5ba29e9454
@ -24,7 +24,8 @@ my $brace_indent = 0;
|
||||
my $yaccmode = 0;
|
||||
my $in_rule = 0;
|
||||
my $header_included = 0;
|
||||
my $feature_not_supported = 0;
|
||||
my $has_feature_not_supported = 0;
|
||||
my $has_if_command = 0;
|
||||
my $tokenmode = 0;
|
||||
|
||||
my (%buff, $infield, $comment, %tokens, %addons);
|
||||
@ -131,12 +132,6 @@ sub main
|
||||
{
|
||||
line: while (<>)
|
||||
{
|
||||
if (/ERRCODE_FEATURE_NOT_SUPPORTED/)
|
||||
{
|
||||
$feature_not_supported = 1;
|
||||
next line;
|
||||
}
|
||||
|
||||
chomp;
|
||||
|
||||
# comment out the line below to make the result file match (blank line wise)
|
||||
@ -162,6 +157,13 @@ sub main
|
||||
$infield = 0;
|
||||
}
|
||||
|
||||
if ($yaccmode == 1)
|
||||
{
|
||||
# Check for rules that throw FEATURE_NOT_SUPPORTED
|
||||
$has_feature_not_supported = 1 if /ERRCODE_FEATURE_NOT_SUPPORTED/;
|
||||
$has_if_command = 1 if /^\s*if/;
|
||||
}
|
||||
|
||||
my $prec = 0;
|
||||
|
||||
# Make sure any braces are split
|
||||
@ -507,20 +509,17 @@ sub dump_fields
|
||||
|
||||
#Normal
|
||||
add_to_buffer('rules', $ln);
|
||||
if ($feature_not_supported == 1)
|
||||
if ($has_feature_not_supported and not $has_if_command)
|
||||
{
|
||||
|
||||
# we found an unsupported feature, but we have to
|
||||
# filter out ExecuteStmt: CREATE OptTemp TABLE ...
|
||||
# because the warning there is only valid in some situations
|
||||
if ($flds->[0] ne 'create' || $flds->[2] ne 'table')
|
||||
{
|
||||
add_to_buffer('rules',
|
||||
'mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");'
|
||||
);
|
||||
}
|
||||
$feature_not_supported = 0;
|
||||
# The backend unconditionally reports
|
||||
# FEATURE_NOT_SUPPORTED in this rule, so let's emit
|
||||
# a warning on the ecpg side.
|
||||
add_to_buffer('rules',
|
||||
'mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");'
|
||||
);
|
||||
}
|
||||
$has_feature_not_supported = 0;
|
||||
$has_if_command = 0;
|
||||
|
||||
if ($len == 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user