mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
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.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.85 2007/04/21 21:01:44 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.86 2007/06/11 01:16:22 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/cost.h"
|
||||
#include "optimizer/pathnode.h"
|
||||
#include "optimizer/plancat.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "utils/fmgroids.h"
|
||||
@@ -712,6 +713,15 @@ clause_selectivity(PlannerInfo *root,
|
||||
varRelid,
|
||||
jointype);
|
||||
}
|
||||
else if (IsA(clause, CurrentOfExpr))
|
||||
{
|
||||
/* CURRENT OF selects at most one row of its table */
|
||||
CurrentOfExpr *cexpr = (CurrentOfExpr *) clause;
|
||||
RelOptInfo *crel = find_base_rel(root, cexpr->cvarno);
|
||||
|
||||
if (crel->tuples > 0)
|
||||
s1 = 1.0 / crel->tuples;
|
||||
}
|
||||
else if (IsA(clause, RelabelType))
|
||||
{
|
||||
/* Not sure this case is needed, but it can't hurt */
|
||||
|
||||
Reference in New Issue
Block a user