Prev: reducing NUMERIC size for 9.1, take two
Next: tracking inherited columns (was: patch for check constraintsusing multiple inheritance)
From: Boszormenyi Zoltan on 3 Aug 2010 13:01 Hi, attached is a patch that adds the missing feature to use "WHERE CURRENT OF :curname" in UPDATE and DELETE statements via ECPG. I used the current CVS MAIN but also applies almost cleanly to 9.0beta4. I certainly feel that this should be applied to 9.0 as a bugfix. The execute.c changes were required because 1. The statement UPDATE table SET fld1 = :input1 WHERE CURRENT OF :curname RETURNING id + :input2; is transformed into UPDATE table SET fld1 = $1 WHERE CURRENT OF $0 RETURNING id + $2; and the $0 is past $1. The current code cannot deal with such a messed up order, and scanning the original query twice is needed, once for $0 substitution, once for mapping $1, etc. to the other input variables. 2. With such a statement and auto-prepare turned on, I always got SQL error: there is no parameter $0 on line X It turned out that the statement was prepared by the auto-prepare machinery before the $0 substitution. PostgreSQL allows PREPARE mystmt AS UPDATE ... WHERE CURRENT OF mycur even if "mycur" is currently unknown to the system. It's resolved upon executing the prepared query, so we should allow it in ECPG even with dynamic cursorname. The code survives "make check" and I also went through all the regression tests manually to check them with valgrind to see that there's no leak. As a result, another patch is attached that fixes two memory leaks in PGTYPESnumeric_from_asc() and PGTYPESnumeric_to_long() and quite some leaks in the regression tests themselves. Best regards, Zolt�n B�sz�rm�nyi |