Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

readfuncs.c

  • Tom Lane's avatar
    46e3a16b
    When FOR UPDATE/SHARE is used with LIMIT, put the LockRows plan node · 46e3a16b
    Tom Lane authored
    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.
    46e3a16b
    History
    When FOR UPDATE/SHARE is used with LIMIT, put the LockRows plan node
    Tom Lane authored
    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.