Hi, 2013-08-17 13:02 keltezéssel, Boszormenyi Zoltan írta: [snip, discussion of WHERE CURRENT OF in the ECPG client lib]
I had a second thought about it and the client side caching and parser behind the application's back seems to be an overkill. Instead, I propose a different solution, which is a logical extension of FETCH { FORWARD | BACKWARD } N, which is a PostgreSQL extension. The proposed solution would be: UPDATE / DELETE ... WHERE OFFSET SignedIconst OF cursor_name I imagine that FETCH would keep the array of TIDs/ItemPointerDatas of the last FETCH statement. The argument to OFFSET would be mostly in negative terms, with 0 being equivalent of WHERE CURRENT OF. E.g.: FETCH 2 FROM mycur; -- fetches two rows UPDATE mytab SET ... WHERE OFFSET -1 OF mycur; -- updates the first row UPDATE mytab SET ... WHERE OFFSET 0 OF mycur; -- updates current row or FETCH 3 FROM mycur; -- fetches two rows, reaches end of the cursor UPDATE mytab SET ... WHERE OFFSET -2 OF mycur; -- updates the first row UPDATE mytab SET ... WHERE OFFSET -1 OF mycur; -- updates the second row UPDATE mytab SET ... WHERE OFFSET 0 OF mycur; -- throws an error like WHERE CURRENT OF or FETCH 3 FROM mycur; -- fetches two rows, reaches end of the cursor MOVE BACKWARD 2 IN mycur; UPDATE mytab SET ... WHERE OFFSET 0 OF mycur; -- updates the first row (now current) UPDATE mytab SET ... WHERE OFFSET 1 OF mycur; -- updates the second row The cached array can be kept valid until the next FETCH statement, even if moves out of the interval of the array, except in case the application changes the sign of the cursor position, e.g. previously it used MOVE ABSOLUTE with positive numbers and suddenly it switches to backward scanning with MOVE ABSOLUTE <negative number> or vice-versa. This would solve the only source of slowdown in the client side cursor caching in ECPG present in my current ECPG cursor readahead patch, there would be no more MOVE + UPDATE/DELETE WHERE CURRENT OF. On the other hand, exploiting this proposed feature in ECPG would make it incompatible with older servers unless it detects the server version it connects to and uses the current method. Comments? Best regards, Zoltán Böszörményi -- ---------------------------------- Zoltán Böszörményi Cybertec Schönig & Schönig GmbH Gröhrmühlgasse 26 A-2700 Wiener Neustadt, Austria Web: http://www.postgresql-support.de http://www.postgresql.at/ -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers