diff -u -r postgresql-7.2.1/doc/src/sgml/ref/delete.sgml bpostgres/doc/src/sgml/ref/delete.sgml
--- postgresql-7.2.1/doc/src/sgml/ref/delete.sgml 2001-12-08 04:24:35.000000000 +0100
+++ bpostgres/doc/src/sgml/ref/delete.sgml 2002-09-20 20:20:34.000000000 +0200
@@ -23,6 +23,7 @@
DELETE FROM [ ONLY ] table [ WHERE condition ]
+ [ LIMIT { count | ALL } ]
@@ -127,6 +128,15 @@
it, as well as read access to any table whose values are
read in the condition.
+
+
+ The LIMIT clause allows a limited number of rows produced by the query
+ to be deleted (in random order). This allows for faster DELETE
+ queries using LIMIT 1 when appropriate, and also allows for
+ a selective delete in the case of multiple identical entries of which
+ you do not want to delete all.
+ (See .)
+
diff -u -r postgresql-7.2.1/doc/src/sgml/ref/update.sgml bpostgres/doc/src/sgml/ref/update.sgml
--- postgresql-7.2.1/doc/src/sgml/ref/update.sgml 2001-12-08 04:24:39.000000000 +0100
+++ bpostgres/doc/src/sgml/ref/update.sgml 2002-09-20 20:20:19.000000000 +0200
@@ -24,6 +24,7 @@
UPDATE [ ONLY ] table SET col = expression [, ...]
[ FROM fromlist ]
[ WHERE condition ]
+ [ LIMIT { count | ALL } ]
@@ -140,6 +141,15 @@
+ The LIMIT clause allows a limited number of rows produced by the query
+ to be updated (in random order). This allows for faster UPDATE
+ queries using LIMIT 1 when appropriate, and also allows for
+ a selective update in the case of multiple identical entries of which
+ you do not want to update all.
+ (See .)
+
+
+
By default UPDATE will update tuples in the table specified
and all its sub-tables. If you wish to only update the
specific table mentioned, you should use the ONLY clause.
diff -u -r postgresql-7.2.1/src/backend/parser/analyze.c bpostgres/src/backend/parser/analyze.c
--- postgresql-7.2.1/src/backend/parser/analyze.c 2002-09-20 03:13:29.000000000 +0200
+++ bpostgres/src/backend/parser/analyze.c 2002-09-20 03:19:42.000000000 +0200
@@ -329,6 +329,7 @@
true);
qry->distinctClause = NIL;
+ qry->limitCount = stmt->limitCount;
/* fix where clause */
qual = transformWhereClause(pstate, stmt->whereClause);
@@ -2440,6 +2441,7 @@
qry->resultRelation = setTargetTable(pstate, stmt->relname,
interpretInhOption(stmt->inhOpt),
true);
+ qry->limitCount = stmt->limitCount;
/*
* the FROM clause is non-standard SQL syntax. We used to be able to
Only in bpostgres/src/backend/parser: analyze.cold
diff -u -r postgresql-7.2.1/src/backend/parser/gram.y bpostgres/src/backend/parser/gram.y
--- postgresql-7.2.1/src/backend/parser/gram.y 2002-09-20 02:50:32.000000000 +0200
+++ bpostgres/src/backend/parser/gram.y 2002-09-20 03:35:49.000000000 +0200
@@ -197,7 +197,7 @@
from_clause, from_list, opt_array_bounds,
expr_list, attrs, target_list, update_target_list,
def_list, opt_indirection, group_clause, TriggerFuncArgs,
- select_limit, opt_select_limit
+ select_limit, opt_select_limit, opt_other_limit
%type func_arg, func_return, func_type, aggr_argtype
@@ -3369,12 +3369,13 @@
*
*****************************************************************************/
-DeleteStmt: DELETE FROM relation_expr where_clause
+DeleteStmt: DELETE FROM relation_expr where_clause opt_other_limit
{
DeleteStmt *n = makeNode(DeleteStmt);
n->relname = $3->relname;
n->inhOpt = $3->inhOpt;
n->whereClause = $4;
+ n->limitCount = $5;
$$ = (Node *)n;
}
;
@@ -3415,6 +3416,7 @@
SET update_target_list
from_clause
where_clause
+ opt_other_limit
{
UpdateStmt *n = makeNode(UpdateStmt);
n->relname = $2->relname;
@@ -3422,6 +3424,7 @@
n->targetList = $4;
n->fromClause = $5;
n->whereClause = $6;
+ n->limitCount = $7;
$$ = (Node *)n;
}
;
@@ -3663,6 +3666,10 @@
| /*EMPTY*/ { $$ = "<"; /*default*/ }
;
+opt_other_limit: LIMIT select_limit_value { $$ = $2; }
+ | /* EMPTY */ { $$ = NULL; }
+ ;
+
select_limit: LIMIT select_limit_value OFFSET select_offset_value
{ $$ = makeList2($4, $2); }
Only in bpostgres/src/backend/parser: gram.yold
diff -u -r postgresql-7.2.1/src/include/nodes/parsenodes.h bpostgres/src/include/nodes/parsenodes.h
--- postgresql-7.2.1/src/include/nodes/parsenodes.h 2002-09-20 19:40:29.000000000 +0200
+++ bpostgres/src/include/nodes/parsenodes.h 2002-09-20 03:29:00.000000000 +0200
@@ -833,6 +833,7 @@
NodeTag type;
char *relname; /* relation to delete from */
Node *whereClause; /* qualifications */
+ Node *limitCount; /* # of result tuples to return */
InhOption inhOpt; /* recursively act on children? */
} DeleteStmt;
@@ -847,6 +848,7 @@
List *targetList; /* the target list (of ResTarget) */
Node *whereClause; /* qualifications */
List *fromClause; /* the from clause */
+ Node *limitCount; /* # of result tuples to return */
InhOption inhOpt; /* recursively act on children? */
} UpdateStmt;