1. 12 9月, 2011 1 次提交
    • P
      Remove many -Wcast-qual warnings · 1b81c2fe
      Peter Eisentraut 提交于
      This addresses only those cases that are easy to fix by adding or
      moving a const qualifier or removing an unnecessary cast.  There are
      many more complicated cases remaining.
      1b81c2fe
  2. 10 9月, 2011 2 次提交
    • T
      Simplify handling of the timezone GUC by making initdb choose the default. · ca4af308
      Tom Lane 提交于
      We were doing some amazingly complicated things in order to avoid running
      the very expensive identify_system_timezone() procedure during GUC
      initialization.  But there is an obvious fix for that, which is to do it
      once during initdb and have initdb install the system-specific default into
      postgresql.conf, as it already does for most other GUC variables that need
      system-environment-dependent defaults.  This means that the timezone (and
      log_timezone) settings no longer have any magic behavior in the server.
      Per discussion.
      ca4af308
    • T
      Move Timestamp/Interval typedefs and basic macros into datatype/timestamp.h. · a7801b62
      Tom Lane 提交于
      As per my recent proposal, this refactors things so that these typedefs and
      macros are available in a header that can be included in frontend-ish code.
      I also changed various headers that were undesirably including
      utils/timestamp.h to include datatype/timestamp.h instead.  Unsurprisingly,
      this showed that half the system was getting utils/timestamp.h by way of
      xlog.h.
      
      No actual code changes here, just header refactoring.
      a7801b62
  3. 09 9月, 2011 2 次提交
  4. 08 9月, 2011 4 次提交
    • H
      Buffering GiST index build algorithm. · 5edb24a8
      Heikki Linnakangas 提交于
      When building a GiST index that doesn't fit in cache, buffers are attached
      to some internal nodes in the index. This speeds up the build by avoiding
      random I/O that would otherwise be needed to traverse all the way down the
      tree to the find right leaf page for tuple.
      
      Alexander Korotkov
      5edb24a8
    • T
      Fix corner case bug in numeric to_char(). · f0bedf3e
      Tom Lane 提交于
      Trailing-zero stripping applied by the FM specifier could strip zeroes
      to the left of the decimal point, for a format with no digit positions
      after the decimal point (such as "FM999.").
      
      Reported and diagnosed by Marti Raudsepp, though I didn't use his patch.
      f0bedf3e
    • T
      Fix typo in error message. · 99155aaa
      Tom Lane 提交于
      Per Euler Taveira de Oliveira.
      99155aaa
    • T
      Fix get_name_for_var_field() to deal with RECORD Params. · a7d9203c
      Tom Lane 提交于
      With 9.1's use of Params to pass down values from NestLoop join nodes
      to their inner plans, it is possible for a Param to have type RECORD, in
      which case the set of fields comprising the value isn't determinable by
      inspection of the Param alone.  However, just as with a Var of type RECORD,
      we can find out what we need to know if we can locate the expression that
      the Param represents.  We already knew how to do this in get_parameter(),
      but I'd overlooked the need to be able to cope in get_name_for_var_field(),
      which led to EXPLAIN failing with "record type has not been registered".
      
      To fix, refactor the search code in get_parameter() so it can be used by
      both functions.
      
      Per report from Marti Raudsepp.
      a7d9203c
  5. 07 9月, 2011 7 次提交
  6. 06 9月, 2011 4 次提交
  7. 05 9月, 2011 3 次提交
    • T
      Change get_variable_numdistinct's API to flag default estimates explicitly. · 4c2777d0
      Tom Lane 提交于
      Formerly, callers tested for DEFAULT_NUM_DISTINCT, which had the problem
      that a perfectly solid estimate might be mistaken for a content-free
      default.
      4c2777d0
    • T
      Dig down into sub-selects to look for column statistics. · 1cb108ef
      Tom Lane 提交于
      If a sub-select's output column is a simple Var, recursively look for
      statistics applying to that Var, and use them if available.  The need for
      this was foreseen ages ago, but we didn't have enough infrastructure to do
      it with reasonable speed until just now.
      
      We punt and stick with default estimates if the subquery uses set
      operations, GROUP BY, or DISTINCT, since those operations would change the
      underlying column statistics (particularly, the relative frequencies of
      different values) beyond recognition.  This means that the types of
      sub-selects for which this improvement applies are fairly limited, since
      most subqueries satisfying those restrictions would have gotten flattened
      into the parent query anyway.  But it does help for some cases, such as
      subqueries with ORDER BY or LIMIT.
      1cb108ef
    • T
      Can't print PlannerGlobal's subroots list in outfuncs. · 698df335
      Tom Lane 提交于
      Since the subroots will surely link back to the same glob struct, this
      necessarily leads to infinite recursion.  Doh.  Found while trying to
      debug some other code.
      698df335
  8. 04 9月, 2011 2 次提交
    • T
      Clean up the #include mess a little. · 1609797c
      Tom Lane 提交于
      walsender.h should depend on xlog.h, not vice versa.  (Actually, the
      inclusion was circular until a couple hours ago, which was even sillier;
      but Bruce broke it in the expedient rather than logically correct
      direction.)  Because of that poor decision, plus blind application of
      pgrminclude, we had a situation where half the system was depending on
      xlog.h to include such unrelated stuff as array.h and guc.h.  Clean up
      the header inclusion, and manually revert a lot of what pgrminclude had
      done so things build again.
      
      This episode reinforces my feeling that pgrminclude should not be run
      without adult supervision.  Inclusion changes in header files in particular
      need to be reviewed with great care.  More generally, it'd be good if we
      had a clearer notion of module layering to dictate which headers can sanely
      include which others ... but that's a big task for another day.
      1609797c
    • T
      Rearrange planner to save the whole PlannerInfo (subroot) for a subquery. · b3aaf908
      Tom Lane 提交于
      Formerly, set_subquery_pathlist and other creators of plans for subqueries
      saved only the rangetable and rowMarks lists from the lower-level
      PlannerInfo.  But there's no reason not to remember the whole PlannerInfo,
      and indeed this turns out to simplify matters in a number of places.
      
      The immediate reason for doing this was so that the subroot will still be
      accessible when we're trying to extract column statistics out of an
      already-planned subquery.  But now that I've done it, it seems like a good
      code-beautification effort in its own right.
      
      I also chose to get rid of the transient subrtable and subrowmark fields in
      SubqueryScan nodes, in favor of having setrefs.c look up the subquery's
      RelOptInfo.  That required changing all the APIs in setrefs.c to pass
      PlannerInfo not PlannerGlobal, which was a large but quite mechanical
      transformation.
      
      One side-effect not foreseen at the beginning is that this finally broke
      inheritance_planner's assumption that replanning the same subquery RTE N
      times would necessarily give interchangeable results each time.  That
      assumption was always pretty risky, but now we really have to make a
      separate RTE for each instance so that there's a place to carry the
      separate subroots.
      b3aaf908
  9. 03 9月, 2011 3 次提交
    • P
      Add archive_command example · 42ad992f
      Peter Eisentraut 提交于
      42ad992f
    • P
      f1e4f3d4
    • T
      Teach ANALYZE to clear pg_class.relhassubclass when appropriate. · 5b562644
      Tom Lane 提交于
      In the past, relhassubclass always remained true if a relation had ever had
      child relations, even if the last subclass was long gone.  While this had
      only marginal performance implications in most cases, it was annoying, and
      I'm now considering some planner changes that would raise the cost of a
      false positive.  It was previously impractical to fix this because of race
      condition concerns.  However, given the recent change that made tablecmds.c
      take ShareExclusiveLock on relations that are gaining a child (commit
      fbcf4b92), we can now allow ANALYZE to
      clear the flag when it's no longer relevant.  There is no additional
      locking cost to do so, since ANALYZE takes ShareExclusiveLock anyway.
      5b562644
  10. 02 9月, 2011 1 次提交
  11. 01 9月, 2011 5 次提交
    • T
      Put back improperly removed #include. · e5b012b7
      Tom Lane 提交于
      e5b012b7
    • B
      6416a82a
    • H
      setlocale() on Windows doesn't work correctly if the locale name contains · a88b6e4c
      Heikki Linnakangas 提交于
      dots. I previously worked around this in initdb, mapping the known
      problematic locale names to aliases that work, but Hiroshi Inoue pointed
      out that that's not enough because even if you use one of the aliases, like
      "Chinese_HKG", setlocale(LC_CTYPE, NULL) returns back the long form, ie.
      "Chinese_Hong Kong S.A.R.". When we try to restore an old locale value by
      passing that value back to setlocale(), it fails. Note that you are affected
      by this bug also if you use one of those short-form names manually, so just
      reverting the hack in initdb won't fix it.
      
      To work around that, move the locale name mapping from initdb to a wrapper
      around setlocale(), so that the mapping is invoked on every setlocale() call.
      
      Also, add a few checks for failed setlocale() calls in the backend. These
      calls shouldn't fail, and if they do there isn't much we can do about it,
      but at least you'll get a warning.
      
      Backpatch to 9.1, where the initdb hack was introduced. The Windows bug
      affects older versions too if you set locale manually to one of the aliases,
      but given the lack of complaints from the field, I'm hesitent to backpatch.
      a88b6e4c
    • T
      Further repair of eqjoinsel ndistinct-clamping logic. · 0d3b231e
      Tom Lane 提交于
      Examination of examples provided by Mark Kirkwood and others has convinced
      me that actually commit 7f3eba30 was quite
      a few bricks shy of a load.  The useful part of that patch was clamping
      ndistinct for the inner side of a semi or anti join, and the reason why
      that's needed is that it's the only way that restriction clauses
      eliminating rows from the inner relation can affect the estimated size of
      the join result.  I had not clearly understood why the clamping was
      appropriate, and so mis-extrapolated to conclude that we should clamp
      ndistinct for the outer side too, as well as for both sides of regular
      joins.  These latter actions were all wrong, and are reverted with this
      patch.  In addition, the clamping logic is now made to affect the behavior
      of both paths in eqjoinsel_semi, with or without MCV lists to compare.
      When we have MCVs, we suppose that the most common values are the ones
      that are most likely to survive the decimation resulting from a lower
      restriction clause, so we think of the clamping as eliminating non-MCV
      values, or potentially even the least-common MCVs for the inner relation.
      
      Back-patch to 8.4, same as previous fixes in this area.
      0d3b231e
    • T
      Improve eqjoinsel's ndistinct clamping to work for multiple levels of join. · 97930cf5
      Tom Lane 提交于
      This patch fixes an oversight in my commit
      7f3eba30 of 2008-10-23.  That patch
      accounted for baserel restriction clauses that reduced the number of rows
      coming out of a table (and hence the number of possibly-distinct values of
      a join variable), but not for join restriction clauses that might have been
      applied at a lower level of join.  To account for the latter, look up the
      sizes of the min_lefthand and min_righthand inputs of the current join,
      and clamp with those in the same way as for the base relations.
      
      Noted while investigating a complaint from Ben Chobot, although this in
      itself doesn't seem to explain his report.
      
      Back-patch to 8.4; previous versions used different estimation methods
      for which this heuristic isn't relevant.
      97930cf5
  12. 31 8月, 2011 1 次提交
    • T
      Fix a missed case in code for "moving average" estimate of reltuples. · 5bba65de
      Tom Lane 提交于
      It is possible for VACUUM to scan no pages at all, if the visibility map
      shows that all pages are all-visible.  In this situation VACUUM has no new
      information to report about the relation's tuple density, so it wasn't
      changing pg_class.reltuples ... but it updated pg_class.relpages anyway.
      That's wrong in general, since there is no evidence to justify changing the
      density ratio reltuples/relpages, but it's particularly bad if the previous
      state was relpages=reltuples=0, which means "unknown tuple density".
      We just replaced "unknown" with "zero".  ANALYZE would eventually recover
      from this, but it could take a lot of repetitions of ANALYZE to do so if
      the relation size is much larger than the maximum number of pages ANALYZE
      will scan, because of the moving-average behavior introduced by commit
      b4b6923e.
      
      The only known situation where we could have relpages=reltuples=0 and yet
      the visibility map asserts everything's visible is immediately following
      a pg_upgrade.  It might be advisable for pg_upgrade to try to preserve the
      relpages/reltuples statistics; but in any case this code is wrong on its
      own terms, so fix it.  Per report from Sergey Koposov.
      
      Back-patch to 8.4, where the visibility map was introduced, same as the
      previous change.
      5bba65de
  13. 30 8月, 2011 3 次提交
  14. 29 8月, 2011 1 次提交
    • R
      Improve spinlock performance for HP-UX, ia64, non-gcc. · c01c25fb
      Robert Haas 提交于
      At least on this architecture, it's very important to spin on a
      non-atomic instruction and only retry the atomic once it appears
      that it will succeed.  To fix this, split TAS() into two macros:
      TAS(), for trying to grab the lock the first time, and TAS_SPIN(),
      for spinning until we get it.  TAS_SPIN() defaults to same as TAS(),
      but we can override it when we know there's a better way.
      
      It's likely that some of the other cases in s_lock.h require
      similar treatment, but this is the only one we've got conclusive
      evidence for at present.
      c01c25fb
  15. 27 8月, 2011 1 次提交