Hi, 

I found wrong message output when ECPG preprocessed some SQL commands . 
For example, ECPG application has following command, ECPG outputs "unsupported 
feature will be passed to server". 
-----------
EXEC SQL CREATE SCHEMA IF NOT EXISTS hollywood;
-----------
I attached sample code to reproduce this problem. 

[Investigation]
I think parse.pl has some problem. The following filters do not seem to work 
properly: 
 src/interfaces/ecpg/preproc/parse.pl
                if ($feature_not_supported == 1)
                {

                        # 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;
                }

[Solution]
I have two solutions for this. 
1) This problem occurs because filter does not work properly. 
   So, by setting the filter conditions properly, wrong warning should not be 
output. 
   However, we have to modify the conditions when the syntax in gram.y is 
changed. 

2) This problem occurs when a syntax is not supported under certain conditions 
like following: 
   So, when "if sentence" is found inside rule, the warning should not be 
output. 

CreateSchemaStmt:
         | CREATE SCHEMA IF_P NOT EXISTS OptSchemaName AUTHORIZATION RoleSpec 
OptSchemaEltList
                 {
                         CreateSchemaStmt *n = makeNode(CreateSchemaStmt);

                         if ($9 != NIL)
                                 ereport(ERROR,
                                                 
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                                  errmsg("CREATE SCHEMA IF NOT 
EXISTS cannot include schema elements"),
                                                  parser_errposition(@9)));

I attached a draft patch of the solution 2). 

Regards, 
Daisuke, Higuchi

Attachment: ECPG_unsupported_messages_fix_v1.patch
Description: ECPG_unsupported_messages_fix_v1.patch

Attachment: test.pgc
Description: test.pgc

Reply via email to