1. 27 Feb, 2014 1 commit
    • Alvaro Herrera's avatar
      Fix WAL replay of locking an updated tuple · 6bfa88ac
      Alvaro Herrera authored
      We were resetting the tuple's HEAP_HOT_UPDATED flag as well as t_ctid on
      WAL replay of a tuple-lock operation, which is incorrect when the tuple
      is already updated.
      
      Back-patch to 9.3.  The clearing of both header elements was there
      previously, but since no update could be present on a tuple that was
      being locked, it was harmless.
      
      Bug reported by Peter Geoghegan and Greg Stark in
      CAM3SWZTMQiCi5PV5OWHb+bYkUcnCk=O67w0cSswPvV7XfUcU5g@mail.gmail.com and
      CAM-w4HPTOeMT4KP0OJK+mGgzgcTOtLRTvFZyvD0O4aH-7dxo3Q@mail.gmail.com
      respectively; diagnosis by Andres Freund.
      6bfa88ac
  2. 26 Feb, 2014 2 commits
    • Heikki Linnakangas's avatar
      btbuild no longer calls _bt_doinsert(), update comment. · 00976f20
      Heikki Linnakangas authored
      Peter Geoghegan
      00976f20
    • Jeff Davis's avatar
      Fix crash in json_to_record(). · 486ea0b1
      Jeff Davis authored
      json_to_record() depends on get_call_result_type() for the tuple
      descriptor of the record that should be returned, but in some cases
      that cannot be determined. Add a guard to check if the tuple
      descriptor has been properly resolved, similar to other callers of
      get_call_result_type().
      
      Also add guard for two other callers of get_call_result_type() in
      jsonfuncs.c. Although json_to_record() is the only actual bug, it's a
      good idea to follow convention.
      486ea0b1
  3. 25 Feb, 2014 5 commits
    • Tom Lane's avatar
      Use SnapshotDirty rather than an active snapshot to probe index endpoints. · fccebe42
      Tom Lane authored
      If there are lots of uncommitted tuples at the end of the index range,
      get_actual_variable_range() ends up fetching each one and doing an MVCC
      visibility check on it, until it finally hits a visible tuple.  This is
      bad enough in isolation, considering that we don't need an exact answer
      only an approximate one.  But because the tuples are not yet committed,
      each visibility check does a TransactionIdIsInProgress() test, which
      involves scanning the ProcArray.  When multiple sessions do this
      concurrently, the ensuing contention results in horrid performance loss.
      20X overall throughput loss on not-too-complicated queries is easy to
      demonstrate in the back branches (though someone's made it noticeably
      less bad in HEAD).
      
      We can dodge the problem fairly effectively by using SnapshotDirty rather
      than a normal MVCC snapshot.  This will cause the index probe to take
      uncommitted tuples as good, so that we incur only one tuple fetch and test
      even if there are many such tuples.  The extent to which this degrades the
      estimate is debatable: it's possible the result is actually a more accurate
      prediction than before, if the endmost tuple has become committed by the
      time we actually execute the query being planned.  In any case, it's not
      very likely that it makes the estimate a lot worse.
      
      SnapshotDirty will still reject tuples that are known committed dead, so
      we won't give bogus answers if an invalid outlier has been deleted but not
      yet vacuumed from the index.  (Because btrees know how to mark such tuples
      dead in the index, we shouldn't have a big performance problem in the case
      that there are many of them at the end of the range.)  This consideration
      motivates not using SnapshotAny, which was also considered as a fix.
      
      Note: the back branches were using SnapshotNow instead of an MVCC snapshot,
      but the problem and solution are the same.
      
      Per performance complaints from Bartlomiej Romanski, Josh Berkus, and
      others.  Back-patch to 9.0, where the issue was introduced (by commit
      40608e7f).
      fccebe42
    • Robert Haas's avatar
      Update a few comments to mention materialized views. · cf6aa68b
      Robert Haas authored
      Etsuro Fujita
      cf6aa68b
    • Robert Haas's avatar
      Show xid and xmin in pg_stat_activity and pg_stat_replication. · dd1a3bcc
      Robert Haas authored
      Christian Kruse, reviewed by Andres Freund and myself, with further
      minor adjustments by me.
      dd1a3bcc
    • Robert Haas's avatar
      pg_basebackup: Skip only the *contents* of pg_replslot. · 278c9420
      Robert Haas authored
      Include the directory itself.
      
      Fujii Masao
      278c9420
    • Peter Eisentraut's avatar
      Update and clarify ssl_ciphers default · 32001ab0
      Peter Eisentraut authored
      - Write HIGH:MEDIUM instead of DEFAULT:!LOW:!EXP for clarity.
      - Order 3DES last to work around inappropriate OpenSSL default.
      - Remove !MD5 and @STRENGTH, because they are irrelevant.
      - Add clarifying documentation.
      
      Effectively, the new default is almost the same as the old one, but it
      is arguably easier to understand and modify.
      
      Author: Marko Kreen <markokr@gmail.com>
      32001ab0
  4. 24 Feb, 2014 10 commits
  5. 23 Feb, 2014 3 commits
    • Tom Lane's avatar
      Prefer pg_any_to_server/pg_server_to_any over pg_do_encoding_conversion. · 769065c1
      Tom Lane authored
      A large majority of the callers of pg_do_encoding_conversion were
      specifying the database encoding as either source or target of the
      conversion, meaning that we can use the less general functions
      pg_any_to_server/pg_server_to_any instead.
      
      The main advantage of using the latter functions is that they can make use
      of a cached conversion-function lookup in the common case that the other
      encoding is the current client_encoding.  It's notationally cleaner too in
      most cases, not least because of the historical artifact that the latter
      functions use "char *" rather than "unsigned char *" in their APIs.
      
      Note that pg_any_to_server will apply an encoding verification step in
      some cases where pg_do_encoding_conversion would have just done nothing.
      This seems to me to be a good idea at most of these call sites, though
      it partially negates the performance benefit.
      
      Per discussion of bug #9210.
      769065c1
    • Tom Lane's avatar
      Plug some more holes in encoding conversion. · 49c817ea
      Tom Lane authored
      Various places assume that pg_do_encoding_conversion() and
      pg_server_to_any() will ensure encoding validity of their results;
      but they failed to do so in the case that the source encoding is SQL_ASCII
      while the destination is not.  We cannot perform any actual "conversion"
      in that scenario, but we should still validate the string according to the
      destination encoding.  Per bug #9210 from Digoal Zhou.
      
      Arguably this is a back-patchable bug fix, but on the other hand adding
      more enforcing of encoding checks might break existing applications that
      were being sloppy.  On balance there doesn't seem to be much enthusiasm
      for a back-patch, so fix in HEAD only.
      
      While at it, remove some apparently-no-longer-needed provisions for
      letting pg_do_encoding_conversion() "work" outside a transaction ---
      if you consider it "working" to silently fail to do the requested
      conversion.
      
      Also, make a few cosmetic improvements in mbutils.c, notably removing
      some Asserts that are certainly dead code since the variables they
      assert aren't null are never null, even at process start.  (I think
      this wasn't true at one time, but it is now.)
      49c817ea
    • Peter Eisentraut's avatar
      configure.in: Use dnl in place of # where appropriate · 2c65856b
      Peter Eisentraut authored
      The comment added by ed011d97 used #,
      which means it gets copied into configure, but it doesn't make sense
      there.  So use dnl, which gets dropped when creating configure.
      2c65856b
  6. 22 Feb, 2014 1 commit
  7. 21 Feb, 2014 3 commits
    • Tom Lane's avatar
      Do ScalarArrayOp estimation correctly when array is a stable expression. · 77585bce
      Tom Lane authored
      Most estimation functions apply estimate_expression_value to see if they
      can reduce an expression to a constant; the key difference is that it
      allows evaluation of stable as well as immutable functions in hopes of
      ending up with a simple Const node.  scalararraysel didn't get the memo
      though, and neither did gincost_opexpr/gincost_scalararrayopexpr.  Fix
      that, and remove a now-unnecessary estimate_expression_value step in the
      subsidiary function scalararraysel_containment.
      
      Per complaint from Alexey Klyukin.  Back-patch to 9.3.  The problem
      goes back further, but I'm hesitant to change estimation behavior in
      long-stable release branches.
      77585bce
    • Heikki Linnakangas's avatar
      Avoid integer overflow in hstore_to_json(). · 0c5783ff
      Heikki Linnakangas authored
      The length of the output buffer was calculated based on the size of the
      argument hstore. On a sizeof(int) == 4 platform and a huge argument, it
      could overflow, causing a too small buffer to be allocated.
      
      Refactor the function to use a StringInfo instead of pre-allocating the
      buffer. Makes it shorter and more readable, too.
      0c5783ff
    • Peter Eisentraut's avatar
      doc: Clarify documentation page header customization code · 8c059dff
      Peter Eisentraut authored
      The customization overrode the fast-forward code with its custom Up
      link.  So this is no longer really the fast-forward feature, so we might
      as well turn that off and override the non-ff template instead, thus
      removing one mental indirection.
      
      Fix the wrong column span declaration.
      
      Clarify and update the documentation.
      8c059dff
  8. 20 Feb, 2014 3 commits
  9. 19 Feb, 2014 6 commits
    • Tom Lane's avatar
      Fix some missing .gitignore and "make clean" items in ecpg. · 52acfd27
      Tom Lane authored
      Some of the files we optionally link in from elsewhere weren't ignored
      and/or weren't cleaned up at "make clean".  Noted while testing on a
      machine that needs our version of snprintf.c.
      52acfd27
    • Robert Haas's avatar
      Document pg_replslot in storage.sgml. · 7b3cf9ba
      Robert Haas authored
      Per an observation from Amit Kapila.
      7b3cf9ba
    • Robert Haas's avatar
      Switch various builtin functions to use pg_lsn instead of text. · 6f289c2b
      Robert Haas authored
      The functions in slotfuncs.c don't exist in any released version,
      but the changes to xlogfuncs.c represent backward-incompatibilities.
      Per discussion, we're hoping that the queries using these functions
      are few enough and simple enough that this won't cause too much
      breakage for users.
      
      Michael Paquier, reviewed by Andres Freund and further modified
      by me.
      6f289c2b
    • Robert Haas's avatar
      Further code review for pg_lsn data type. · 694e3d13
      Robert Haas authored
      Change input function error messages to be more consistent with what is
      done elsewhere.  Remove a bunch of redundant type casts, so that the
      compiler will warn us if we screw up.  Don't pass LSNs by value on
      platforms where a Datum is only 32 bytes, per buildfarm.  Move macros
      for packing and unpacking LSNs to pg_lsn.h so that we can include
      access/xlogdefs.h, to avoid an unsatisfied dependency on XLogRecPtr.
      694e3d13
    • Robert Haas's avatar
      pg_lsn macro naming and type behavior revisions. · 844a28a9
      Robert Haas authored
      Change pg_lsn_mi so that it can return negative values when subtracting
      LSNs, and clean up some perhaps ill-considered macro names.
      844a28a9
    • Robert Haas's avatar
      Add a pg_lsn data type, to represent an LSN. · 7d03a83f
      Robert Haas authored
      Robert Haas and Michael Paquier
      7d03a83f
  10. 18 Feb, 2014 3 commits
    • Tom Lane's avatar
      Remove broken code that tried to handle OVERLAPS with a single argument. · a222f7fd
      Tom Lane authored
      The SQL standard says that OVERLAPS should have a two-element row
      constructor on each side.  The original coding of OVERLAPS support in
      our grammar attempted to extend that by allowing a single-element row
      constructor, which it internally duplicated ... or tried to, anyway.
      But that code has certainly not worked since our List infrastructure was
      rewritten in 2004, and I'm none too sure it worked before that.  As it
      stands, it ends up building a List that includes itself, leading to
      assorted undesirable behaviors later in the parser.
      
      Even if it worked as intended, it'd be a bit evil because of the
      possibility of duplicate evaluation of a volatile function that the user
      had written only once.  Given the lack of documentation, test cases, or
      complaints, let's just get rid of the idea and only support the standard
      syntax.
      
      While we're at it, improve the error cursor positioning for the
      wrong-number-of-arguments errors, and inline the makeOverlaps() function
      since it's only called in one place anyway.
      
      Per bug #9227 from Joshua Yanovski.  Initial patch by Joshua Yanovski,
      extended a bit by me.
      a222f7fd
    • Magnus Hagander's avatar
      Disable RandomizedBaseAddress on MSVC builds · 7f3e17b4
      Magnus Hagander authored
      The ASLR in Windows 8/Windows 2012 can break PostgreSQL's shared memory. It
      doesn't fail every time (which is explained by the Random part in ASLR), but
      can fail with errors abut failing to reserve shared memory region.
      
      MauMau, reviewed by Craig Ringer
      7f3e17b4
    • Heikki Linnakangas's avatar
  11. 17 Feb, 2014 3 commits