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

Commitd3167ed

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 parente10ca95 commitd3167ed

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
@@ -24,7 +24,8 @@
2424
my$yaccmode = 0;
2525
my$in_rule = 0;
2626
my$header_included = 0;
27-
my$feature_not_supported = 0;
27+
my$has_feature_not_supported = 0;
28+
my$has_if_command = 0;
2829
my$tokenmode = 0;
2930

3031
my (%buff,$infield,$comment,%tokens,%addons);
@@ -136,12 +137,6 @@ sub main
136137
{
137138
line:while (<>)
138139
{
139-
if (/ERRCODE_FEATURE_NOT_SUPPORTED/)
140-
{
141-
$feature_not_supported = 1;
142-
next line;
143-
}
144-
145140
chomp;
146141

147142
# comment out the line below to make the result file match (blank line wise)
@@ -167,6 +162,13 @@ sub main
167162
$infield = 0;
168163
}
169164

165+
if ($yaccmode == 1)
166+
{
167+
# Check for rules that throw FEATURE_NOT_SUPPORTED
168+
$has_feature_not_supported = 1if/ERRCODE_FEATURE_NOT_SUPPORTED/;
169+
$has_if_command = 1if/^\s*if/;
170+
}
171+
170172
my$prec = 0;
171173

172174
# Make sure any braces are split
@@ -512,20 +514,17 @@ sub dump_fields
512514

513515
#Normal
514516
add_to_buffer('rules',$ln);
515-
if ($feature_not_supported == 1)
517+
if ($has_feature_not_supportedandnot$has_if_command)
516518
{
517-
518-
# we found an unsupported feature, but we have to
519-
# filter out ExecuteStmt: CREATE OptTemp TABLE ...
520-
# because the warning there is only valid in some situations
521-
if ($flds->[0]ne'create' ||$flds->[2]ne'table')
522-
{
523-
add_to_buffer('rules',
524-
'mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");'
525-
);
526-
}
527-
$feature_not_supported = 0;
519+
# The backend unconditionally reports
520+
# FEATURE_NOT_SUPPORTED in this rule, so let's emit
521+
# a warning on the ecpg side.
522+
add_to_buffer('rules',
523+
'mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");'
524+
);
528525
}
526+
$has_feature_not_supported = 0;
527+
$has_if_command = 0;
529528

530529
if ($len == 0)
531530
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp