Thread: ECPG - Keywords as variable names (7.4 regression)

ECPG - Keywords as variable names (7.4 regression)

From
Gavin Scott
Date:
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name        :    Gavin Scott
Your email address    :    gavin@ipalsoftware.com


System Configuration
---------------------
  Architecture (example: Intel Pentium)      : Intel Pentium

  Operating System (example: Linux 2.0.26 ELF)     : Linux 2.4.20

  PostgreSQL version (example: PostgreSQL-7.3):   PostgreSQL-7.4beta4

  Compiler used (example:  gcc 2.95.2)        : gcc 2.96


Please enter a FULL description of your problem:
------------------------------------------------

Certain keywords (specifically unreserved_keyword, reserved_keyword,
and ECPGkeywords_rest in preproc.y) produce a syntax error when used
as variable names in sql struct definitions.

These keywords are accepted as variable names in declare sections.
The difference appears to be that the lexer is in C mode within
declare sections which causes the keywords to be returned as IDENT
tokens.  Within sql struct sections the lexer is in SQL mode and
returns them as keyword tokens (i.e. INDEX for index, etc).

This is a regression; ecpg has no problems processing the sample code
below in PostgreSQL version 7.3.4. and under.






Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

int main()
{
  /* no problem with keywords as variable names in declare section */
  exec sql begin declare section;
  int index;
  int explain;
  exec sql end declare section;

  /* keywords here cause ecpg syntax error (worked in PostgreSQL
     version 7.3.4 and under) */
  exec sql type struct_t is struct
  {
    int index;
    int explain;
  };

  return 0;
}




If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------