1. 12 Mar, 2014 4 commits
    • Robert Haas's avatar
      Fix incorrect assertion about historical snapshots. · 336a578b
      Robert Haas authored
      Also fix some nearby comments.
      
      Andres Freund
      336a578b
    • Robert Haas's avatar
      Comment fixes related to logical decoding. · 890194f1
      Robert Haas authored
      Andres Freund, per complaints by Peter Eisentraut.
      890194f1
    • Heikki Linnakangas's avatar
      Allow opclasses to provide tri-valued GIN consistent functions. · c5608ea2
      Heikki Linnakangas authored
      With the GIN "fast scan" feature, GIN can skip items without fetching all
      the keys for them, if it can prove that they don't match regardless of
      those keys. So far, it has done the proving by calling the boolean
      consistent function with all combinations of TRUE/FALSE for the unfetched
      keys, but since that's O(n^2), it becomes unfeasible with more than a few
      keys. We can avoid calling consistent with all the combinations, if we can
      tell the operator class implementation directly which keys are unknown.
      
      This commit includes a triConsistent function for the built-in array and
      tsvector opclasses.
      
      Alexander Korotkov, with some changes by me.
      c5608ea2
    • Heikki Linnakangas's avatar
      In WAL replay, restore GIN metapage unconditionally to avoid torn page. · fecfc2b9
      Heikki Linnakangas authored
      We don't take a full-page image of the GIN metapage; instead, the WAL record
      contains all the information required to reconstruct it from scratch. But
      to avoid torn page hazards, we must re-initialize it from the WAL record
      every time, even if it already has a greater LSN, similar to how normal full
      page images are restored.
      
      This was highly unlikely to cause any problems in practice, because the GIN
      metapage is small. We rely on an update smaller than a 512 byte disk sector
      to be atomic elsewhere, at least in pg_control. But better safe than sorry,
      and this would be easy to overlook if more fields are added to the metapage
      so that it's no longer small.
      
      Reported by Noah Misch. Backpatch to all supported versions.
      fecfc2b9
  2. 10 Mar, 2014 4 commits
    • Tom Lane's avatar
      Fix tracking of psql script line numbers during \copy from another place. · e85a5ffb
      Tom Lane authored
      Commit 08146775 changed do_copy() to
      temporarily scribble on pset.cur_cmd_source.  That was a mighty ugly bit of
      code in any case, but in particular it broke handleCopyIn's ability to tell
      whether it was reading from the current script source file (in which case
      pset.lineno should be incremented for each line of COPY data), or from
      someplace else (in which case it shouldn't).  The former case still worked,
      the latter not so much.  The visible effect was that line numbers reported
      for errors in a script file would be wrong if there were an earlier \copy
      that was reading anything other than inline-in-the-script-file data.
      
      To fix, introduce another pset field that holds the file do_copy wants the
      COPY code to use.  This is a little bit ugly, but less so than passing the
      file down explicitly through several layers that aren't COPY-specific.
      
      Extracted from a larger patch by Kumar Rajeev Rastogi; that patch also
      changes printing of COPY command tags, which is not a bug fix and shouldn't
      get back-patched.  This particular idea was from a suggestion by Amit
      Khandekar, if I'm reading the thread correctly.
      
      Back-patch to 9.2 where the faulty code was introduced.
      e85a5ffb
    • Robert Haas's avatar
      Allow dynamic shared memory segments to be kept until shutdown. · 8722017b
      Robert Haas authored
      Amit Kapila, reviewed by Kyotaro Horiguchi, with some further
      changes by me.
      8722017b
    • Robert Haas's avatar
      Allow logical decoding via the walsender interface. · 5a991ef8
      Robert Haas authored
      In order for this to work, walsenders need the optional ability to
      connect to a database, so the "replication" keyword now allows true
      or false, for backward-compatibility, and the new value "database"
      (which causes the "dbname" parameter to be respected).
      
      walsender needs to loop not only when idle but also when sending
      decoded data to the user and when waiting for more xlog data to decode.
      This means that there are now three separate loops inside walsender.c;
      although some refactoring has been done here, this is still a bit ugly.
      
      Andres Freund, with contributions from Álvaro Herrera, and further
      review by me.
      5a991ef8
    • Robert Haas's avatar
      Teach on_exit_reset() to discard pending cleanups for dsm. · cb9a0c79
      Robert Haas authored
      If a postmaster child invokes fork() and then calls on_exit_reset, that
      should be sufficient to let it exit() without breaking anything, but
      dynamic shared memory broke that by not updating on_exit_reset() to
      discard callbacks registered with dynamic shared memory segments.
      
      Per investigation of a complaint from Tom Lane.
      cb9a0c79
  3. 09 Mar, 2014 1 commit
  4. 08 Mar, 2014 7 commits
  5. 07 Mar, 2014 8 commits
    • Tom Lane's avatar
      Remove unportable use of anonymous unions from reorderbuffer.h. · ea177a3b
      Tom Lane authored
      In b89e1510 I had assumed it was ok to use anonymous unions as
      struct members, but while a longstanding extension in many compilers,
      it's only been standardized in C11.
      
      To fix, remove one of the anonymous unions which tried to hide some
      implementation specific enum values and give the other a name. The
      latter unfortunately requires changes in output plugins, but since the
      feature has only been added a few days ago...
      
      Andres Freund
      ea177a3b
    • Tom Lane's avatar
      Fix contrib/postgres_fdw to handle multiple join conditions properly. · 83204e10
      Tom Lane authored
      The previous coding supposed that it could consider just a single join
      condition in any one parameterized path for the foreign table.  But in
      reality, the parameterized-path machinery forces all join clauses that are
      "movable to" the foreign table to be evaluated at that node; including
      clauses that we might not consider safe to send across.  Such cases would
      result in an Assert failure in an assert-enabled build, and otherwise in
      sending an unsafe clause to the foreign server, which might result in
      errors or silently-wrong answers.  A lesser problem was that the
      cost/rowcount estimates generated for the parameterized path failed to
      account for any additional join quals that get assigned to the scan.
      
      To fix, rewrite postgresGetForeignPaths so that it correctly collects all
      the movable quals for any one outer relation when generating parameterized
      paths; we'll now generate just one path per outer relation not one per join
      qual.  Also fix bogus assumptions in postgresGetForeignPlan and
      estimate_path_cost_size that only safe-to-send join quals will be
      presented.
      
      Based on complaint from Etsuro Fujita that the path costs were being
      miscalculated, though this is significantly different from his proposed
      patch.
      83204e10
    • Bruce Momjian's avatar
      release notes: add item missed in 9.2.5 release · 4ea2e2d4
      Bruce Momjian authored
      Item is "Prevent errors in WAL replay due to references to uninitialized
      empty pages".
      
      Report and text by Andres Freund
      
      Backpatch through 9.2.
      4ea2e2d4
    • Bruce Momjian's avatar
      fix ReplicationSlotsCountDBSlots for dropping unrelated databases · 91d9de97
      Bruce Momjian authored
      YAMAMOTO Takashi
      91d9de97
    • Heikki Linnakangas's avatar
      Fix dangling smgr_owner pointer when a fake relcache entry is freed. · 55566c9a
      Heikki Linnakangas authored
      A fake relcache entry can "own" a SmgrRelation object, like a regular
      relcache entry. But when it was free'd, the owner field in SmgrRelation
      was not cleared, so it was left pointing to free'd memory.
      
      Amazingly this apparently hasn't caused crashes in practice, or we would've
      heard about it earlier. Andres found this with Valgrind.
      
      Report and fix by Andres Freund, with minor modifications by me. Backpatch
      to all supported versions.
      55566c9a
    • Heikki Linnakangas's avatar
      Avoid memcpy() with same source and destination address. · ad7b48ea
      Heikki Linnakangas authored
      The behavior of that is undefined, although unlikely to lead to problems in
      practice.
      
      Found by running regression tests with Valgrind.
      ad7b48ea
    • Heikki Linnakangas's avatar
      Fix name of syslog_ident GUC in docs. · 2b8483d6
      Heikki Linnakangas authored
      Michael Paquier
      2b8483d6
    • Tom Lane's avatar
      Avoid getting more than AccessShareLock when deparsing a query. · 7c318749
      Tom Lane authored
      In make_ruledef and get_query_def, we have long used AcquireRewriteLocks
      to ensure that the querytree we are about to deparse is up-to-date and
      the schemas of the underlying relations aren't changing.  Howwever, that
      function thinks the query is about to be executed, so it acquires locks
      that are stronger than necessary for the purpose of deparsing.  Thus for
      example, if pg_dump asks to deparse a rule that includes "INSERT INTO t",
      we'd acquire RowExclusiveLock on t.  That results in interference with
      concurrent transactions that might for example ask for ShareLock on t.
      Since pg_dump is documented as being purely read-only, this is unexpected.
      (Worse, it used to actually be read-only; this behavior dates back only
      to 8.1, cf commit ba420024.)
      
      Fix this by adding a parameter to AcquireRewriteLocks to tell it whether
      we want the "real" execution locks or only AccessShareLock.
      
      Report, diagnosis, and patch by Dean Rasheed.  Back-patch to all supported
      branches.
      7c318749
  6. 06 Mar, 2014 5 commits
    • Heikki Linnakangas's avatar
      isdigit() needs an unsigned char argument. · a0c2fa9b
      Heikki Linnakangas authored
      Per the C standard, the routine should be passed an int, with a value that's
      representable as an unsigned char or EOF. Passing a signed char is wrong,
      because a negative value is not representable as an unsigned char.
      Unfortunately no compiler warns about that.
      a0c2fa9b
    • Heikki Linnakangas's avatar
      Send keepalives from walsender even when busy sending WAL. · 94ae6ba7
      Heikki Linnakangas authored
      If walsender doesn't hear from the client for the time specified by
      wal_sender_timeout, it will conclude the connection or client is dead, and
      disconnect. When half of wal_sender_timeout has elapsed, it sends a ping
      to the client, leaving it the remainig half of wal_sender_timeout to
      respond. However, it only checked if half of wal_sender_timeout had elapsed
      when it was about to sleep, so if it was busy sending WAL to the client for
      long enough, it would not send the ping request in time. Then the client
      would not know it needs to send a reply, and the walsender will disconnect
      even though the client is still alive. Fix that.
      
      Andres Freund, reviewed by Robert Haas, and some further changes by me.
      Backpatch to 9.3. Earlier versions relied on the client to send the
      keepalives on its own, and hence didn't have this problem.
      94ae6ba7
    • Tom Lane's avatar
      Don't reject ROW_MARK_REFERENCE rowmarks for materialized views. · bf4052fa
      Tom Lane authored
      We should allow this so that matviews can be referenced in UPDATE/DELETE
      statements in READ COMMITTED isolation level.  The requirement for that
      is that a re-fetch by TID will see the same row version the query saw
      earlier, which is true of matviews, so there's no reason for the
      restriction.  Per bug #9398.
      
      Michael Paquier, after a suggestion by me
      bf4052fa
    • Bruce Momjian's avatar
      C comment update: relfilenode is only unique with a tablespace · 0024a3a3
      Bruce Momjian authored
      Report from Antonin Houska
      0024a3a3
    • Bruce Momjian's avatar
      docs: to_timestamp and to_date do minimal range checking · e2224faf
      Bruce Momjian authored
      Initial patch from Steve Crawford
      e2224faf
  7. 05 Mar, 2014 11 commits