Eric Ridge wrote:Why must a cursor be defined in an open transaction? Obviously there's a good reason, but I can't figure it out. On a high level, what would be involved in allowing a cursor to outlive the transaction that created it?
Historically I think it was because the memory was released at the end of the current transaction (i.e. allocations were made in TopTransactionContext). But as of 7.4, cursors *can* outlive transactions:
http://www.postgresql.org/docs/current/interactive/sql-declare.html
WITH HOLD WITHOUT HOLD
holy cow! This is fantastic. I had no idea. <short pause> ooh, and I see FETCH, in 7.4, supports absolute positioning. Must upgrade.
thanks!
eric
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match