mirror of
https://github.com/postgres/postgres.git
synced 2026-02-18 18:25:17 -05:00
underneath the Limit node, not atop it. This fixes the old problem that such a query might unexpectedly return fewer rows than the LIMIT says, due to LockRows discarding updated rows. There is a related problem that LockRows might destroy the sort ordering produced by earlier steps; but fixing that by pushing LockRows below Sort would create serious performance problems that are unjustified in many real-world applications, as well as potential deadlock problems from locking many more rows than expected. Instead, keep the present semantics of applying FOR UPDATE after ORDER BY within a single query level; but allow the user to specify the other way by writing FOR UPDATE in a sub-select. To make that work, track whether FOR UPDATE appeared explicitly in sub-selects or got pushed down from the parent, and don't flatten a sub-select that contained an explicit FOR UPDATE.
36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* analyze.h
|
|
* parse analysis for optimizable statements
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* $PostgreSQL: pgsql/src/include/parser/analyze.h,v 1.43 2009/10/28 14:55:47 tgl Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef ANALYZE_H
|
|
#define ANALYZE_H
|
|
|
|
#include "parser/parse_node.h"
|
|
|
|
|
|
extern Query *parse_analyze(Node *parseTree, const char *sourceText,
|
|
Oid *paramTypes, int numParams);
|
|
extern Query *parse_analyze_varparams(Node *parseTree, const char *sourceText,
|
|
Oid **paramTypes, int *numParams);
|
|
|
|
extern Query *parse_sub_analyze(Node *parseTree, ParseState *parentParseState,
|
|
CommonTableExpr *parentCTE,
|
|
bool locked_from_parent);
|
|
extern Query *transformStmt(ParseState *pstate, Node *parseTree);
|
|
|
|
extern bool analyze_requires_snapshot(Node *parseTree);
|
|
|
|
extern void CheckSelectLocking(Query *qry);
|
|
extern void applyLockingClause(Query *qry, Index rtindex,
|
|
bool forUpdate, bool noWait, bool pushedDown);
|
|
|
|
#endif /* ANALYZE_H */
|