Skip site navigation (1) Skip section navigation (2)

Problem with ecpg

From: Bernard ISAMBERT <isambert(at)sib(dot)fr>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Problem with ecpg
Date: 2000-04-14 10:31:34
Message-ID: 38F6F386.F40F2D35@sib.fr (view raw or flat)
Thread:
Lists: pgsql-bugs
============================================================================

                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================



Your name               :  Bernard Isambert
Your email address      : isambert(at)sib(dot)fr


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

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

  PostgreSQL version (example: PostgreSQL-6.5.3):   PostgreSQL-7.0beta5
(and previous)

  Compiler used (example:  gcc 2.8.0)           : any...



Please enter a FULL description of your problem:
------------------------------------------------
The problem is in the parsing of operators by ecpg (details below).
As a result, good or bad precompile depends on usage of spaces
in the source, where it should not.


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

Source file:

EXEC SQL BEGIN DECLARE SECTION;
VARCHAR hostvar[32];
EXEC SQL END DECLARE SECTION;

strcpy(hostvar.arr, "something");

EXEC SQL SELECT column2 FROM table1 WHERE column1 = :hostvar;

strcpy(hostvar.arr, "anything");

EXEC SQL SELECT column2 FROM table1 WHERE column1=:hostvar;


Ecpg parsing gives:

for the first select, with spaces around the = sign:

{ ECPGdo(__LINE__, NULL, "select  column2   from table1 where column1  =
?  ",
  ECPGt_varchar,&(hostvar),32L,1L,sizeof(struct varchar_hostvar),
  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}

for the second select, without spaces around (after) the = sign:

{ ECPGdo(__LINE__, NULL, "select  column2   from table1 where column1 
=: hostvar    ",
   ECPGt_EOIT, ECPGt_EORT);}

which is clearly different from the expected result
and yields a run-time error ...


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

I suggest a workaround in the ecpg source "pgc.l"
(src/interfaces/ecpg/preproc/pgc.l):

diff pgc.l.orig pgc.l
192c192,194
< operator		{op_chars}+
---
> /* op_mchars = op_chars but the ':' */
> op_mchars		[\~\!\(at)\#\^\&\|\`\?\$\+\-\*\\/\%\<\>\=]
> operator		{op_chars}{op_mchars}*

This forbids ":" to be the second (or above) char in an operator.
Is there any situation where it should be?
Or maybe the rule should be a bit more complex?

-- 
__________________________________________________

Bernard ISAMBERT (isambert(at)sib(dot)fr)
Syndicat Interhospitalier de Bretagne (www.sib.fr)
__________________________________________________

Responses

pgsql-bugs by date

Next:From: Ronald KuczekDate: 2000-04-14 11:51:54
Subject: Single backend crashes if postmaster running
Previous:From: Denis N. StepanovDate: 2000-04-13 16:59:14
Subject: Beta5 on Linux Alpha

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group