1. 29 3月, 2007 1 次提交
  2. 26 3月, 2007 1 次提交
    • T
      Clean up the representation of special snapshots by including a "method · e85a01df
      Tom Lane 提交于
      pointer" in every Snapshot struct.  This allows removal of the case-by-case
      tests in HeapTupleSatisfiesVisibility, which should make it a bit faster
      (I didn't try any performance tests though).  More importantly, we are no
      longer violating portable C practices by assuming that small integers are
      distinct from all pointer values, and HeapTupleSatisfiesDirty no longer
      has a non-reentrant API involving side-effects on a global variable.
      
      There were a couple of places calling HeapTupleSatisfiesXXX routines
      directly rather than through the HeapTupleSatisfiesVisibility macro.
      Since these places had to be changed anyway, I chose to make them go
      through the macro for uniformity.
      
      Along the way I renamed HeapTupleSatisfiesSnapshot to HeapTupleSatisfiesMVCC
      to emphasize that it's only used with MVCC-type snapshots.  I was sorely
      tempted to rename HeapTupleSatisfiesVisibility to HeapTupleSatisfiesSnapshot,
      but forebore for the moment to avoid confusion and reduce the likelihood that
      this patch breaks some of the pending patches.  Might want to reconsider
      doing that later.
      e85a01df
  3. 06 3月, 2007 1 次提交
  4. 27 2月, 2007 1 次提交
    • T
      Get rid of the separate EState for subplans, and just let them share the · c7ff7663
      Tom Lane 提交于
      parent query's EState.  Now that there's a single flat rangetable for both
      the main plan and subplans, there's no need anymore for a separate EState,
      and removing it allows cleaning up some crufty code in nodeSubplan.c and
      nodeSubqueryscan.c.  Should be a tad faster too, although any difference
      will probably be hard to measure.  This is the last bit of subsidiary
      mop-up work from changing to a flat rangetable.
      c7ff7663
  5. 23 2月, 2007 1 次提交
    • T
      Turn the rangetable used by the executor into a flat list, and avoid storing · eab6b8b2
      Tom Lane 提交于
      useless substructure for its RangeTblEntry nodes.  (I chose to keep using the
      same struct node type and just zero out the link fields for unneeded info,
      rather than making a separate ExecRangeTblEntry type --- it seemed too
      fragile to have two different rangetable representations.)
      
      Along the way, put subplans into a list in the toplevel PlannedStmt node,
      and have SubPlan nodes refer to them by list index instead of direct pointers.
      Vadim wanted to do that years ago, but I never understood what he was on about
      until now.  It makes things a *whole* lot more robust, because we can stop
      worrying about duplicate processing of subplans during expression tree
      traversals.  That's been a constant source of bugs, and it's finally gone.
      
      There are some consequent simplifications yet to be made, like not using
      a separate EState for subplans in the executor, but I'll tackle that later.
      eab6b8b2
  6. 21 2月, 2007 1 次提交
    • T
      Remove the Query structure from the executor's API. This allows us to stop · 9cbd0c15
      Tom Lane 提交于
      storing mostly-redundant Query trees in prepared statements, portals, etc.
      To replace Query, a new node type called PlannedStmt is inserted by the
      planner at the top of a completed plan tree; this carries just the fields of
      Query that are still needed at runtime.  The statement lists kept in portals
      etc. now consist of intermixed PlannedStmt and bare utility-statement nodes
      --- no Query.  This incidentally allows us to remove some fields from Query
      and Plan nodes that shouldn't have been there in the first place.
      
      Still to do: simplify the execution-time range table; at the moment the
      range table passed to the executor still contains Query trees for subqueries.
      
      initdb forced due to change of stored rules.
      9cbd0c15
  7. 02 2月, 2007 1 次提交
    • T
      Repair failure to check that a table is still compatible with a previously · 5413eef8
      Tom Lane 提交于
      made query plan.  Use of ALTER COLUMN TYPE creates a hazard for cached
      query plans: they could contain Vars that claim a column has a different
      type than it now has.  Fix this by checking during plan startup that Vars
      at relation scan level match the current relation tuple descriptor.  Since
      at that point we already have at least AccessShareLock, we can be sure the
      column type will not change underneath us later in the query.  However,
      since a backend's locks do not conflict against itself, there is still a
      hole for an attacker to exploit: he could try to execute ALTER COLUMN TYPE
      while a query is in progress in the current backend.  Seal that hole by
      rejecting ALTER TABLE whenever the target relation is already open in
      the current backend.
      
      This is a significant security hole: not only can one trivially crash the
      backend, but with appropriate misuse of pass-by-reference datatypes it is
      possible to read out arbitrary locations in the server process's memory,
      which could allow retrieving database content the user should not be able
      to see.  Our thanks to Jeff Trout for the initial report.
      
      Security: CVE-2007-0556
      5413eef8
  8. 25 1月, 2007 2 次提交
  9. 06 1月, 2007 1 次提交
  10. 27 12月, 2006 1 次提交
    • T
      Fix failure due to accessing an already-freed tuple descriptor in a plan · 0cbc5b1e
      Tom Lane 提交于
      involving HashAggregate over SubqueryScan (this is the known case, there
      may well be more).  The bug is only latent in releases before 8.2 since they
      didn't try to access tupletable slots' descriptors during ExecDropTupleTable.
      The least bogus fix seems to be to make subqueries share the parent query's
      memory context, so that tupdescs they create will have the same lifespan as
      those of the parent query.  There are comments in the code envisioning going
      even further by not having a separate child EState at all, but that will
      require rethinking executor access to range tables, which I don't want to
      tackle right now.  Per bug report from Jean-Pierre Pelletier.
      0cbc5b1e
  11. 04 12月, 2006 1 次提交
  12. 04 10月, 2006 1 次提交
  13. 13 8月, 2006 1 次提交
    • T
      Tweak SPI_cursor_open to allow INSERT/UPDATE/DELETE RETURNING; this was · 3f8db37c
      Tom Lane 提交于
      merely a matter of fixing the error check, since the underlying Portal
      infrastructure already handles it.  This in turn allows these statements
      to be used in some existing plpgsql and plperl contexts, such as a
      plpgsql FOR loop.  Also, do some marginal code cleanup in places that
      were being sloppy about distinguishing SELECT from SELECT INTO.
      3f8db37c
  14. 12 8月, 2006 1 次提交
  15. 31 7月, 2006 1 次提交
    • T
      Change the bootstrap sequence so that toast tables for system catalogs are · 6e38e34d
      Tom Lane 提交于
      created in the bootstrap phase proper, rather than added after-the-fact
      by initdb.  This is cleaner than before because it allows us to retire the
      undocumented ALTER TABLE ... CREATE TOAST TABLE command, but the real reason
      I'm doing it is so that toast tables of shared catalogs will now have
      predetermined OIDs.  This will allow a reasonably clean solution to the
      problem of locking tables before we load their relcache entries, to appear
      in a forthcoming patch.
      6e38e34d
  16. 14 7月, 2006 2 次提交
  17. 12 7月, 2006 1 次提交
  18. 04 7月, 2006 1 次提交
    • T
      Code review for FILLFACTOR patch. Change WITH grammar as per earlier · b7b78d24
      Tom Lane 提交于
      discussion (including making def_arg allow reserved words), add missed
      opt_definition for UNIQUE case.  Put the reloptions support code in a less
      random place (I chose to make a new file access/common/reloptions.c).
      Eliminate header inclusion creep.  Make the index options functions safely
      user-callable (seems like client apps might like to be able to test validity
      of options before trying to make an index).  Reduce overhead for normal case
      with no options by allowing rd_options to be NULL.  Fix some unmaintainably
      klugy code, including getting rid of Natts_pg_class_fixed at long last.
      Some stylistic cleanup too, and pay attention to keeping comments in sync
      with code.
      
      Documentation still needs work, though I did fix the omissions in
      catalogs.sgml and indexam.sgml.
      b7b78d24
  19. 02 7月, 2006 1 次提交
  20. 17 6月, 2006 1 次提交
    • T
      Fix problems with cached tuple descriptors disappearing while still in use · 06e10abc
      Tom Lane 提交于
      by creating a reference-count mechanism, similar to what we did a long time
      ago for catcache entries.  The back branches have an ugly solution involving
      lots of extra copies, but this way is more efficient.  Reference counting is
      only applied to tupdescs that are actually in caches --- there seems no need
      to use it for tupdescs that are generated in the executor, since they'll go
      away during plan shutdown by virtue of being in the per-query memory context.
      Neil Conway and Tom Lane
      06e10abc
  21. 01 5月, 2006 1 次提交
  22. 05 3月, 2006 1 次提交
  23. 28 2月, 2006 1 次提交
    • T
      Extend the ExecInitNode API so that plan nodes receive a set of flag · 2c0ef977
      Tom Lane 提交于
      bits indicating which optional capabilities can actually be exercised
      at runtime.  This will allow Sort and Material nodes, and perhaps later
      other nodes, to avoid unnecessary overhead in common cases.
      This commit just adds the infrastructure and arranges to pass the correct
      flag values down to plan nodes; none of the actual optimizations are here
      yet.  I'm committing this separately in case anyone wants to measure the
      added overhead.  (It should be negligible.)
      
      Simon Riggs and Tom Lane
      2c0ef977
  24. 22 2月, 2006 1 次提交
    • N
      Cleanup the usage of ScanDirection: use the symbolic names for the · 737651f6
      Neil Conway 提交于
      possible ScanDirection alternatives rather than magic numbers
      (-1, 0, 1).  Also, use the ScanDirection macros in a few places
      rather than directly checking whether `dir == ForwardScanDirection'
      and the like. Per patch from James William Pye. His patch also
      changed ScanDirection to be a "char" rather than an enum, which
      I haven't applied.
      737651f6
  25. 19 2月, 2006 1 次提交
  26. 13 1月, 2006 1 次提交
    • T
      Repair "Halloween problem" in EvalPlanQual: a tuple that's been inserted by · 25b9b1b0
      Tom Lane 提交于
      our own command (or more generally, xmin = our xact and cmin >= current
      command ID) should not be seen as good.  Else we may try to update rows
      we already updated.  This error was inserted last August while fixing the
      even bigger problem that the old coding wouldn't see *any* tuples inserted
      by our own transaction as good.  Per report from Euler Taveira de Oliveira.
      25b9b1b0
  27. 11 1月, 2006 1 次提交
  28. 08 1月, 2006 1 次提交
  29. 03 12月, 2005 1 次提交
  30. 23 11月, 2005 1 次提交
  31. 21 11月, 2005 1 次提交
    • T
      Modify tuptoaster's API so that it does not try to modify the passed · 40314f2d
      Tom Lane 提交于
      tuple in-place, but instead passes back an all-new tuple structure if
      any changes are needed.  This is a much cleaner and more robust solution
      for the bug discovered by Alexey Beschiokov; accordingly, revert the
      quick hack I installed yesterday.
      With this change, HeapTupleData.t_datamcxt is no longer needed; will
      remove it in a separate commit in HEAD only.
      40314f2d
  32. 20 11月, 2005 1 次提交
    • T
      Stopgap solution for problem reported by Alexey Beschiokov: after · 33a9af73
      Tom Lane 提交于
      doing heap_insert or heap_update, wipe out any extracted fields in
      the TupleTableSlot containing the tuple, because they might not be valid
      anymore if tuptoaster.c changed the tuple.  Safe because slot must be
      in the materialized state, but mighty ugly --- find a better answer!
      33a9af73
  33. 18 11月, 2005 1 次提交
  34. 15 11月, 2005 1 次提交
    • T
      Prevent ExecInsert() and ExecUpdate() from scribbling on the result tuple · 76ce39e3
      Tom Lane 提交于
      slot of the topmost plan node when a trigger returns a modified tuple.
      These appear to be the only places where a plan node's caller did not
      treat the result slot as read-only, which is an assumption that nodeUnique
      makes as of 8.1.  Fixes trigger-vs-DISTINCT bug reported by Frank van Vugt.
      76ce39e3
  35. 15 10月, 2005 1 次提交
  36. 26 8月, 2005 1 次提交
  37. 20 8月, 2005 1 次提交
    • T
      Repair problems with VACUUM destroying t_ctid chains too soon, and with · f57e3f4c
      Tom Lane 提交于
      insufficient paranoia in code that follows t_ctid links.  (We must do both
      because even with VACUUM doing it properly, the intermediate state with
      a dangling t_ctid link is visible concurrently during lazy VACUUM, and
      could be seen afterwards if either type of VACUUM crashes partway through.)
      Also try to improve documentation about what's going on.  Patch is a bit
      bulky because passing the XMAX information around required changing the
      APIs of some low-level heapam.c routines, but it's not conceptually very
      complicated.  Per trouble report from Teodor and subsequent analysis.
      This needs to be back-patched, but I'll do that after 8.1 beta is out.
      f57e3f4c
  38. 19 8月, 2005 1 次提交