This used to work in the PostgreSQL 8.4 ecpg preprocessor:

EXEC SQL EXECUTE mystmt USING 1.23;

but in 9.0 it throws an error:

floattest.pgc:39: ERROR: variable "1" is not declared

Attached is the full test case, drop it in src/interfaces/ecpg/test/preproc and compile.

I bisected the cause to this commit:

commit b2bddc2ff22f0c3d54671e43c67a2563deed7908
Author: Michael Meskes <mes...@postgresql.org>
Date:   Thu Apr 1 08:41:01 2010 +0000

Applied Zoltan's patch to make ecpg spit out warnings if a local variable hides a global one with the same name.

I don't immediately see why that's causing it, but it doesn't seem intentional.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com
#include <stdio.h>
#include <stdlib.h>

EXEC SQL include ../regression;

int
main (void)
{
  ECPGdebug (1, stderr);

  EXEC SQL BEGIN DECLARE SECTION;

  float f = 4.56;       
  const char *stmt2 = "INSERT INTO floattest VALUES (?);";
        
  EXEC SQL END DECLARE SECTION;
        
  EXEC SQL connect to REGRESSDB1;
  if (sqlca.sqlcode)
    {
      printf ("connect error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }

  EXEC SQL create table floattest (f float);
  if (sqlca.sqlcode)
    {
      printf ("create error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }

  EXEC SQL PREPARE mystmt FROM :stmt2;
  if (sqlca.sqlcode)
    {
      printf ("prepare error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }

  EXEC SQL EXECUTE mystmt USING 1.23;
  if (sqlca.sqlcode)
    {
      printf ("insert error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }

  EXEC SQL COMMIT;

  EXEC SQL disconnect;

  exit (0);
}
-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to