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

Commit096a761

Browse files
committed
Fix ecpg's mechanism for detecting unsupported cases in the grammar.
ecpg wants to emit a warning if it parses a SQL construct that thebackend can parse but will immediately throw a FEATURE_NOT_SUPPORTEDerror for. The way it was testing for this was to see if the stringERRCODE_FEATURE_NOT_SUPPORTED appeared anywhere in the gram.y code.This is, of course, not nearly good enough, as there are plenty ofrules in gram.y that throw that error only conditionally. There wasa hack dating to 2008 to suppress the warning in one rule thatdoesn't even exist anymore, but nothing for other cases we've createdsince then. End result was that you could get "unsupported featurewill be passed to server" warnings while compiling perfectly good SQLcode in ecpg. Somehow we'd not heard complaints about this, butit was exposed by the recent addition of an ecpg test for a SQL/JSONconstruct.To fix, suppress the warning if the rule contains any "if" statement.Manual comparison of gram.y with the generated preproc.y file showsthat the warning is now emitted only in rules where it's sensible.This problem has existed for a long time, so back-patch to allsupported branches.Discussion:https://postgr.es/m/603615.1712245382@sss.pgh.pa.us
1 parent332d406 commit096a761

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

‎src/interfaces/ecpg/preproc/parse.pl

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
my$yaccmode = 0;
3535
my$in_rule = 0;
3636
my$header_included = 0;
37-
my$feature_not_supported = 0;
37+
my$has_feature_not_supported = 0;
38+
my$has_if_command = 0;
3839
my$tokenmode = 0;
3940

4041
my (%buff,$infield,$comment,%tokens,%addons);
@@ -151,12 +152,6 @@ sub main
151152
{
152153
line:while (<$parserfh>)
153154
{
154-
if (/ERRCODE_FEATURE_NOT_SUPPORTED/)
155-
{
156-
$feature_not_supported = 1;
157-
next line;
158-
}
159-
160155
chomp;
161156

162157
# comment out the line below to make the result file match (blank line wise)
@@ -182,6 +177,13 @@ sub main
182177
$infield = 0;
183178
}
184179

180+
if ($yaccmode == 1)
181+
{
182+
# Check for rules that throw FEATURE_NOT_SUPPORTED
183+
$has_feature_not_supported = 1if/ERRCODE_FEATURE_NOT_SUPPORTED/;
184+
$has_if_command = 1if/^\s*if/;
185+
}
186+
185187
my$prec = 0;
186188

187189
# Make sure any braces are split
@@ -541,20 +543,17 @@ sub dump_fields
541543

542544
#Normal
543545
add_to_buffer('rules',$ln);
544-
if ($feature_not_supported == 1)
546+
if ($has_feature_not_supportedandnot$has_if_command)
545547
{
546-
547-
# we found an unsupported feature, but we have to
548-
# filter out ExecuteStmt: CREATE OptTemp TABLE ...
549-
# because the warning there is only valid in some situations
550-
if ($flds->[0]ne'create' ||$flds->[2]ne'table')
551-
{
552-
add_to_buffer('rules',
553-
'mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");'
554-
);
555-
}
556-
$feature_not_supported = 0;
548+
# The backend unconditionally reports
549+
# FEATURE_NOT_SUPPORTED in this rule, so let's emit
550+
# a warning on the ecpg side.
551+
add_to_buffer('rules',
552+
'mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");'
553+
);
557554
}
555+
$has_feature_not_supported = 0;
556+
$has_if_command = 0;
558557

559558
if ($len == 0)
560559
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp