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

Commit360d007

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 parent3858554 commit360d007

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);
@@ -130,12 +131,6 @@ sub main
130131
{
131132
line:while (<>)
132133
{
133-
if (/ERRCODE_FEATURE_NOT_SUPPORTED/)
134-
{
135-
$feature_not_supported = 1;
136-
next line;
137-
}
138-
139134
chomp;
140135

141136
# comment out the line below to make the result file match (blank line wise)
@@ -161,6 +156,13 @@ sub main
161156
$infield = 0;
162157
}
163158

159+
if ($yaccmode == 1)
160+
{
161+
# Check for rules that throw FEATURE_NOT_SUPPORTED
162+
$has_feature_not_supported = 1if/ERRCODE_FEATURE_NOT_SUPPORTED/;
163+
$has_if_command = 1if/^\s*if/;
164+
}
165+
164166
my$prec = 0;
165167

166168
# Make sure any braces are split
@@ -506,20 +508,17 @@ sub dump_fields
506508

507509
#Normal
508510
add_to_buffer('rules',$ln);
509-
if ($feature_not_supported == 1)
511+
if ($has_feature_not_supportedandnot$has_if_command)
510512
{
511-
512-
# we found an unsupported feature, but we have to
513-
# filter out ExecuteStmt: CREATE OptTemp TABLE ...
514-
# because the warning there is only valid in some situations
515-
if ($flds->[0]ne'create' ||$flds->[2]ne'table')
516-
{
517-
add_to_buffer('rules',
518-
'mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");'
519-
);
520-
}
521-
$feature_not_supported = 0;
513+
# The backend unconditionally reports
514+
# FEATURE_NOT_SUPPORTED in this rule, so let's emit
515+
# a warning on the ecpg side.
516+
add_to_buffer('rules',
517+
'mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");'
518+
);
522519
}
520+
$has_feature_not_supported = 0;
521+
$has_if_command = 0;
523522

524523
if ($len == 0)
525524
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp