1. 30 12月, 2009 1 次提交
    • H
      Previous fix for temporary file management broke returning a set from · 67d25e5a
      Heikki Linnakangas 提交于
      PL/pgSQL function within an exception handler. Make sure we use the right
      resource owner when we create the tuplestore to hold returned tuples.
      
      Simplify tuplestore API so that the caller doesn't need to be in the right
      memory context when calling tuplestore_put* functions. tuplestore.c
      automatically switches to the memory context used when the tuplestore was
      created. Tuplesort was already modified like this earlier. This patch also
      removes the now useless MemoryContextSwitch calls from callers.
      
      Report by Aleksei on pgsql-bugs on Dec 22 2009. Backpatch to 8.1, like
      the previous patch that broke this.
      67d25e5a
  2. 03 4月, 2008 1 次提交
    • T
      Revert my bad decision of about a year ago to make PortalDefineQuery · ab2071b5
      Tom Lane 提交于
      responsible for copying the query string into the new Portal.  Such copying
      is unnecessary in the common code path through exec_simple_query, and in
      this case it can be enormously expensive because the string might contain
      a large number of individual commands; we were copying the entire, long
      string for each command, resulting in O(N^2) behavior for N commands.
      (This is the cause of bug #4079.)  A second problem with it is that
      PortalDefineQuery really can't risk error, because if it elog's before
      having set up the Portal, we will leak the plancache refcount that the
      caller is trying to hand off to the portal.  So go back to the design in
      which the caller is responsible for making sure everything is copied into
      the portal if necessary.
      ab2071b5
  3. 02 1月, 2008 1 次提交
  4. 16 11月, 2007 1 次提交
  5. 12 11月, 2007 1 次提交
    • T
      Ensure that typmod decoration on a datatype name is validated in all cases, · 0bd4da23
      Tom Lane 提交于
      even in code paths where we don't pay any subsequent attention to the typmod
      value.  This seems needed in view of the fact that 8.3's generalized typmod
      support will accept a lot of bogus syntax, such as "timestamp(foo)" or
      "record(int, 42)" --- if we allow such things to pass without comment,
      users will get confused.  Per a recent example from Greg Stark.
      
      To implement this in a way that's not very vulnerable to future
      bugs-of-omission, refactor the API of parse_type.c's TypeName lookup routines
      so that typmod validation is folded into the base lookup operation.  Callers
      can still choose not to receive the encoded typmod, but we'll check the
      decoration anyway if it's present.
      0bd4da23
  6. 24 6月, 2007 1 次提交
    • T
      Separate parse-analysis for utility commands out of parser/analyze.c · 46379d6e
      Tom Lane 提交于
      (which now deals only in optimizable statements), and put that code
      into a new file parser/parse_utilcmd.c.  This helps clarify and enforce
      the design rule that utility statements shouldn't be processed during
      the regular parse analysis phase; all interpretation of their meaning
      should happen after they are given to ProcessUtility to execute.
      (We need this because we don't retain any locks for a utility statement
      that's in a plan cache, nor have any way to detect that it's stale.)
      
      We are also able to simplify the API for parse_analyze() and related
      routines, because they will now always return exactly one Query structure.
      
      In passing, fix bug #3403 concerning trying to add a serial column to
      an existing temp table (this is largely Heikki's work, but we needed
      all that restructuring to make it safe).
      46379d6e
  7. 26 5月, 2007 1 次提交
    • T
      Create hooks to let a loadable plugin monitor (or even replace) the planner · 604ffd28
      Tom Lane 提交于
      and/or create plans for hypothetical situations; in particular, investigate
      plans that would be generated using hypothetical indexes.  This is a
      heavily-rewritten version of the hooks proposed by Gurjeet Singh for his
      Index Advisor project.  In this formulation, the index advisor can be
      entirely a loadable module instead of requiring a significant part to be
      in the core backend, and plans can be generated for hypothetical indexes
      without requiring the creation and rolling-back of system catalog entries.
      
      The index advisor patch as-submitted is not compatible with these hooks,
      but it needs significant work anyway due to other 8.2-to-8.3 planner
      changes.  With these hooks in the core backend, development of the advisor
      can proceed as a pgfoundry project.
      604ffd28
  8. 28 4月, 2007 1 次提交
    • T
      Modify processing of DECLARE CURSOR and EXPLAIN so that they can resolve the · bbbe825f
      Tom Lane 提交于
      types of unspecified parameters when submitted via extended query protocol.
      This worked in 8.2 but I had broken it during plancache changes.  DECLARE
      CURSOR is now treated almost exactly like a plain SELECT through parse
      analysis, rewrite, and planning; only just before sending to the executor
      do we divert it away to ProcessUtility.  This requires a special-case check
      in a number of places, but practically all of them were already special-casing
      SELECT INTO, so it's not too ugly.  (Maybe it would be a good idea to merge
      the two by treating IntoClause as a form of utility statement?  Not going to
      worry about that now, though.)  That approach doesn't work for EXPLAIN,
      however, so for that I punted and used a klugy solution of running parse
      analysis an extra time if under extended query protocol.
      bbbe825f
  9. 27 4月, 2007 1 次提交
    • T
      Fix dynahash.c to suppress hash bucket splits while a hash_seq_search() scan · a2e923a6
      Tom Lane 提交于
      is in progress on the same hashtable.  This seems the least invasive way to
      fix the recently-recognized problem that a split could cause the scan to
      visit entries twice or (with much lower probability) miss them entirely.
      The only field-reported problem caused by this is the "failed to re-find
      shared lock object" PANIC in COMMIT PREPARED reported by Michel Dorochevsky,
      which was caused by multiply visited entries.  However, it seems certain
      that mdsync() is vulnerable to missing required fsync's due to missed
      entries, and I am fearful that RelationCacheInitializePhase2() might be at
      risk as well.  Because of that and the generalized hazard presented by this
      bug, back-patch all the supported branches.
      
      Along the way, fix pg_prepared_statement() and pg_cursor() to not assume
      that the hashtables they are examining will stay static between calls.
      This is risky regardless of the newly noted dynahash problem, because
      hash_seq_search() has never promised to cope with deletion of table entries
      other than the just-returned one.  There may be no bug here because the only
      supported way to call these functions is via ExecMakeTableFunctionResult()
      which will cycle them to completion before doing anything very interesting,
      but it seems best to get rid of the assumption.  This affects 8.2 and HEAD
      only, since those functions weren't there earlier.
      a2e923a6
  10. 17 4月, 2007 1 次提交
  11. 16 4月, 2007 1 次提交
    • T
      Expose more cursor-related functionality in SPI: specifically, allow · 66888f74
      Tom Lane 提交于
      access to the planner's cursor-related planning options, and provide new
      FETCH/MOVE routines that allow access to the full power of those commands.
      Small refactoring of planner(), pg_plan_query(), and pg_plan_queries()
      APIs to make it convenient to pass the planning options down from SPI.
      
      This is the core-code portion of Pavel Stehule's patch for scrollable
      cursor support in plpgsql; I'll review and apply the plpgsql changes
      separately.
      66888f74
  12. 12 4月, 2007 1 次提交
    • N
      RESET SESSION, plus related new DDL commands. Patch from Marko Kreen, · d13e903b
      Neil Conway 提交于
      reviewed by Neil Conway. This patch adds the following DDL command
      variants: RESET SESSION, RESET TEMP, RESET PLANS, CLOSE ALL, and
      DEALLOCATE ALL. RESET SESSION is intended for use by connection
      pool software and the like, in order to reset a client session
      to something close to its initial state.
      
      Note that while most of these command variants can be executed
      inside a transaction block (but are not transaction-aware!),
      RESET SESSION cannot. While this is inconsistent, it is intended
      to catch programmer mistakes: RESET SESSION in an open transaction
      block is probably unintended.
      d13e903b
  13. 13 3月, 2007 1 次提交
    • T
      First phase of plan-invalidation project: create a plan cache management · b9527e98
      Tom Lane 提交于
      module and teach PREPARE and protocol-level prepared statements to use it.
      In service of this, rearrange utility-statement processing so that parse
      analysis does not assume table schemas can't change before execution for
      utility statements (necessary because we don't attempt to re-acquire locks
      for utility statements when reusing a stored plan).  This requires some
      refactoring of the ProcessUtility API, but it ends up cleaner anyway,
      for instance we can get rid of the QueryContext global.
      
      Still to do: fix up SPI and related code to use the plan cache; I'm tempted to
      try to make SQL functions use it too.  Also, there are at least some aspects
      of system state that we want to ensure remain the same during a replan as in
      the original processing; search_path certainly ought to behave that way for
      instance, and perhaps there are others.
      b9527e98
  14. 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
  15. 29 1月, 2007 1 次提交
  16. 06 1月, 2007 1 次提交
  17. 04 10月, 2006 1 次提交
  18. 28 9月, 2006 1 次提交
  19. 08 9月, 2006 1 次提交
    • T
      Clean up logging for extended-query-protocol operations, as per my recent · 893632be
      Tom Lane 提交于
      proposal.  Parameter logging works even for binary-format parameters, and
      logging overhead is avoided when disabled.
      
      log_statement = all output for the src/test/examples/testlibpq3.c example
      now looks like
      
      LOG:  statement: execute <unnamed>: SELECT * FROM test1 WHERE t = $1
      DETAIL:  parameters: $1 = 'joe''s place'
      LOG:  statement: execute <unnamed>: SELECT * FROM test1 WHERE i = $1::int4
      DETAIL:  parameters: $1 = '2'
      
      and log_min_duration_statement = 0 results in
      
      LOG:  duration: 2.431 ms  parse <unnamed>: SELECT * FROM test1 WHERE t = $1
      LOG:  duration: 2.335 ms  bind <unnamed> to <unnamed>: SELECT * FROM test1 WHERE t = $1
      DETAIL:  parameters: $1 = 'joe''s place'
      LOG:  duration: 0.394 ms  execute <unnamed>: SELECT * FROM test1 WHERE t = $1
      DETAIL:  parameters: $1 = 'joe''s place'
      LOG:  duration: 1.251 ms  parse <unnamed>: SELECT * FROM test1 WHERE i = $1::int4
      LOG:  duration: 0.566 ms  bind <unnamed> to <unnamed>: SELECT * FROM test1 WHERE i = $1::int4
      DETAIL:  parameters: $1 = '2'
      LOG:  duration: 0.173 ms  execute <unnamed>: SELECT * FROM test1 WHERE i = $1::int4
      DETAIL:  parameters: $1 = '2'
      
      (This example demonstrates the folly of ignoring parse/bind steps for duration
      logging purposes, BTW.)
      
      Along the way, create a less ad-hoc mechanism for determining which commands
      are logged by log_statement = mod and log_statement = ddl.  The former coding
      was actually missing quite a few things that look like ddl to me, and it
      did not handle EXECUTE or extended query protocol correctly at all.
      
      This commit does not do anything about the question of whether log_duration
      should be removed or made less redundant with log_min_duration_statement.
      893632be
  20. 07 9月, 2006 1 次提交
    • T
      Change processing of extended-Query mode so that an unnamed statement · 5983a1aa
      Tom Lane 提交于
      that has parameters is always planned afresh for each Bind command,
      treating the parameter values as constants in the planner.  This removes
      the performance penalty formerly often paid for using out-of-line
      parameters --- with this definition, the planner can do constant folding,
      LIKE optimization, etc.  After a suggestion by Andrew@supernews.
      5983a1aa
  21. 29 8月, 2006 1 次提交
    • B
      Now bind displays prepare as detail, and execute displays prepare and · bc24d5b9
      Bruce Momjian 提交于
      optionally bind.  I re-added the "statement:" label so people will
      understand why the line is being printed (it is log_*statement
      behavior).
      
      Use single quotes for bind values, instead of double quotes, and double
      literal single quotes in bind values (and document that).  I also made
      use of the DETAIL line to have much cleaner output.
      bc24d5b9
  22. 15 8月, 2006 1 次提交
    • T
      Fix oversight in initial implementation of PORTAL_ONE_RETURNING mode: we · 65b2f93b
      Tom Lane 提交于
      cannot assume that there's exactly one Query in the Portal, as we can for
      ONE_SELECT mode, because non-SELECT queries might have extra queries added
      during rule rewrites.  Fix things up so that we'll use ONE_RETURNING mode
      when a Portal contains one primary (canSetTag) query and that query has
      a RETURNING list.  This appears to be a second showstopper reason for running
      the Portal to completion before we start to hand anything back --- we want
      to be sure that the rule-added queries get run too.
      65b2f93b
  23. 12 8月, 2006 1 次提交
  24. 08 8月, 2006 1 次提交
    • B
      For protocol-level prepare/bind/execute: · 3716f90c
      Bruce Momjian 提交于
      	o  print user name for all
      	o  print portal name if defined for all
      	o  print query for all
      	o  reduce log_statement header to single keyword
      	o  print bind parameters as DETAIL if text mode
      3716f90c
  25. 14 7月, 2006 2 次提交
  26. 12 7月, 2006 1 次提交
  27. 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
  28. 02 7月, 2006 1 次提交
  29. 21 6月, 2006 1 次提交
    • T
      Remove redundant gettimeofday() calls to the extent practical without · 27c3e3de
      Tom Lane 提交于
      changing semantics too much.  statement_timestamp is now set immediately
      upon receipt of a client command message, and the various places that used
      to do their own gettimeofday() calls to mark command startup are referenced
      to that instead.  I have also made stats_command_string use that same
      value for pg_stat_activity.query_start for both the command itself and
      its eventual replacement by <IDLE> or <idle in transaction>.  There was
      some debate about that, but no argument that seemed convincing enough to
      justify an extra gettimeofday() call.
      27c3e3de
  30. 25 4月, 2006 2 次提交
  31. 22 4月, 2006 1 次提交
  32. 05 3月, 2006 1 次提交
  33. 19 2月, 2006 1 次提交
  34. 18 1月, 2006 1 次提交
    • N
      Add a new system view, pg_cursors, that displays the currently available · 33e06ebc
      Neil Conway 提交于
      cursors. Patch from Joachim Wieland, review and ediorialization by Neil
      Conway. The view lists cursors defined by DECLARE CURSOR, using SPI, or
      via the Bind message of the frontend/backend protocol. This means the
      view does not list the unnamed portal or the portal created to implement
      EXECUTE. Because we do list SPI portals, there might be more rows in
      this view than you might expect if you are using SPI implicitly (e.g.
      via a procedural language).
      
      Per recent discussion on -hackers, the query string included in the
      view for cursors defined by DECLARE CURSOR is based on
      debug_query_string. That means it is not accurate if multiple queries
      separated by semicolons are submitted as one query string. However,
      there doesn't seem a trivial fix for that: debug_query_string
      is better than nothing. I also changed SPI_cursor_open() to include
      the source text for the portal it creates: AFAICS there is no reason
      not to do this.
      
      Update the documentation and regression tests, bump the catversion.
      33e06ebc
  35. 17 1月, 2006 1 次提交
  36. 08 1月, 2006 1 次提交
    • N
      Add a new system view, pg_prepared_statements, that can be used to · 44b928e8
      Neil Conway 提交于
      access information about the prepared statements that are available
      in the current session. Original patch from Joachim Wieland, various
      improvements by Neil Conway.
      
      The "statement" column of the view contains the literal query string
      sent by the client, without any rewriting or pretty printing. This
      means that prepared statements created via SQL will be prefixed with
      "PREPARE ... AS ", whereas those prepared via the FE/BE protocol will
      not. That is unfortunate, but discussion on -patches did not yield an
      efficient way to improve this, and there is some merit in returning
      exactly what the client sent to the backend.
      
      Catalog version bumped, regression tests updated.
      44b928e8
  37. 15 12月, 2005 1 次提交
  38. 29 11月, 2005 1 次提交