aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/tidpath.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-06-11 01:16:30 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-06-11 01:16:30 +0000
commit6808f1b1de0ebcd4af558ba84c3226b2027f55ea (patch)
treeebd12580d3aaca6ec79b5d99563a1eff02451e88 /src/backend/optimizer/path/tidpath.c
parent85d72f05167b87bc44464b2eabea8538f1fd1e45 (diff)
downloadpostgresql-6808f1b1de0ebcd4af558ba84c3226b2027f55ea.tar.gz
postgresql-6808f1b1de0ebcd4af558ba84c3226b2027f55ea.zip
Support UPDATE/DELETE WHERE CURRENT OF cursor_name, per SQL standard.
Along the way, allow FOR UPDATE in non-WITH-HOLD cursors; there may once have been a reason to disallow that, but it seems to work now, and it's really rather necessary if you want to select a row via a cursor and then update it in a concurrent-safe fashion. Original patch by Arul Shaji, rather heavily editorialized by Tom Lane.
Diffstat (limited to 'src/backend/optimizer/path/tidpath.c')
-rw-r--r--src/backend/optimizer/path/tidpath.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/optimizer/path/tidpath.c b/src/backend/optimizer/path/tidpath.c
index 2470493708a..84564dde734 100644
--- a/src/backend/optimizer/path/tidpath.c
+++ b/src/backend/optimizer/path/tidpath.c
@@ -12,6 +12,12 @@
* this allows
* WHERE ctid IN (tid1, tid2, ...)
*
+ * We also support "WHERE CURRENT OF cursor" conditions (CurrentOfExpr),
+ * which amount to "CTID = run-time-determined-TID". These could in
+ * theory be translated to a simple comparison of CTID to the result of
+ * a function, but in practice it works better to keep the special node
+ * representation all the way through to execution.
+ *
* There is currently no special support for joins involving CTID; in
* particular nothing corresponding to best_inner_indexscan(). Since it's
* not very useful to store TIDs of one table in another table, there
@@ -24,7 +30,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.29 2007/01/05 22:19:31 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.30 2007/06/11 01:16:22 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -174,6 +180,12 @@ TidQualFromExpr(Node *expr, int varno)
if (IsTidEqualAnyClause((ScalarArrayOpExpr *) expr, varno))
rlst = list_make1(expr);
}
+ else if (expr && IsA(expr, CurrentOfExpr))
+ {
+ /* another base case: check for CURRENT OF on this rel */
+ if (((CurrentOfExpr *) expr)->cvarno == varno)
+ rlst = list_make1(expr);
+ }
else if (and_clause(expr))
{
foreach(l, ((BoolExpr *) expr)->args)