[BUGS] ecpg Oracle compatibility issue

2002-12-09 Thread Roland Karch
Hello together,

While porting my TPC-C implementation from Oracle, I discovered the
attached problem with the EXEC SQL COMMIT RELEASE statement.

Bye,
Roland



POSTGRESQL BUG REPORT TEMPLATE



Your name   :   Roland Karch
Your email address  :   [EMAIL PROTECTED]


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

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

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

  Compiler used (example:  gcc 2.95.2)  : gcc 2.95.4


Please enter a FULL description of your problem:

The Embedded SQL parser ecpg produces corrupt code for the statement
COMMIT RELEASE;
It results in the error code -220 - no such connection.





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

---
EXEC SQL INCLUDE sqlca;

int
main(int argc, char** argv) {
EXEC SQL CONNECT TO test USER test IDENTIFIED BY test;
EXEC SQL COMMIT RELEASE;
EXEC SQL DISCONNECT;
}
---

This results in this C file (excerpt):

---
int
main(int argc, char** argv) {
{ ECPGconnect(__LINE__, "test" , "test" , "test" , NULL, 0); }
#line 5 "tst.pc"

ECPGtrans(__LINE__, NULL, "commit");
#line 6 "tst.pc"
ECPGdisconnect(__LINE__, "");
#line 6 "tst.pc"

{ ECPGdisconnect(__LINE__, "CURRENT");}
#line 7 "tst.pc"

}





If you know how this problem might be fixed, list the solution below:
-
Maybe the following patch helps - unfortunately, I wasn't able to get bison to
run with your makefile in my environment, so it is totally untested:

--- postgresql-7.3/src/interfaces/ecpg/preproc/preproc.y.orig   Fri Nov  1 23:52:33 
2002
+++ postgresql-7.3/src/interfaces/ecpg/preproc/preproc.yMon Dec  9 17:41:30 
+2002
@@ -4709,7 +4709,9 @@
fprintf(yyout, "ECPGtrans(__LINE__, %s, \"%s\");",
connection ? connection : "NULL", $1);
whenever_action(0);
-   fprintf(yyout, "ECPGdisconnect(__LINE__, \"\");");
+   fprintf(yyout, "ECPGdisconnect(__LINE__, \"%s\");",
+   connection ?
+   connection : "\"CURRENT\"");
whenever_action(0);
free($1);
}


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [BUGS] ecpg Oracle compatibility issue

2002-12-13 Thread Roland Karch
On Thu, Dec 12, 2002 at 04:49:30PM -0500, Bruce Momjian wrote:
> I applied the attached patch. Your version looked like it would have
> doubled the double-quotes.

Oops - yes, I got that wrong.

> As you mentioned, you couldn't get bison to
> work, so you weren't able to test it.  Please look over this patch and
> make sure it is correct.

It works fine, just got bison to work on my other computer.

> Also check the other use of ECPGdisconnect(). 
> Is that correct?  Does it need "CURRENT"?

Yes, it's needed. Supplying a NULL pointer instead results in a segfault
for me. However, it would work if src/interfaces/ecpg/lib/connect.c line
468 was patched - checking for NULL before dereferencing a user-supplied
pointer is generally a good idea.

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])