1. 11 Aug, 2011 2 commits
    • Robert Haas's avatar
      Unbreak legacy syntax "COMMENT ON RULE x IS y", with no relation name. · 5057366e
      Robert Haas authored
      check_object_ownership() isn't happy about the null relation pointer.
      We could fix it there, but this seems more future-proof.
      5057366e
    • Robert Haas's avatar
      Change psql's \dd command to do something more useful. · 59414cde
      Robert Haas authored
      Instead of displaying comments on an arbitrary subset of the object
      types which support them, make \dd display comments on exactly those
      object types which don't have their own backlash commands.  We now
      regard the display of comments as properly the job of the relevant
      backslash command (though many of them do so only in verbose mode)
      rather than something that \dd should be responsible for.  However,
      a handful of object types have no backlash command, so make \dd
      give information about those.
      
      Josh Kupershmidt
      59414cde
  2. 10 Aug, 2011 5 commits
    • Tom Lane's avatar
      Remove wal_sender_delay GUC, because it's no longer useful. · cff75130
      Tom Lane authored
      The latch infrastructure is now capable of detecting all cases where the
      walsender loop needs to wake up, so there is no reason to have an arbitrary
      timeout.
      
      Also, modify the walsender loop logic to follow the standard pattern of
      ResetLatch, test for work to do, WaitLatch.  The previous coding was both
      hard to follow and buggy: it would sometimes busy-loop despite having
      nothing available to do, eg between receipt of a signal and the next time
      it was caught up with new WAL, and it also had interesting choices like
      deciding to update to WALSNDSTATE_STREAMING on the strength of information
      known to be obsolete.
      cff75130
    • Tom Lane's avatar
      Add a bit of debug logging to backend_read_statsfile(). · 79b2ee20
      Tom Lane authored
      This is in hopes of learning more about what causes "pgstat wait timeout"
      warnings in the buildfarm.  This patch should probably be reverted once
      we've learned what we can.  As coded, it will result in regression test
      "failures" at half the delay that the existing code does, so I expect
      to see a few more than before.
      79b2ee20
    • Tom Lane's avatar
      Change the autovacuum launcher to use WaitLatch instead of a poll loop. · 4dab3d5a
      Tom Lane authored
      In pursuit of this (and with the expectation that WaitLatch will be needed
      in more places), convert the latch field that was already added to PGPROC
      for sync rep into a generic latch that is activated for all PGPROC-owning
      processes, and change many of the standard backend signal handlers to set
      that latch when a signal happens.  This will allow WaitLatch callers to be
      wakened properly by these signals.
      
      In passing, fix a whole bunch of signal handlers that had been hacked to do
      things that might change errno, without adding the necessary save/restore
      logic for errno.  Also make some minor fixes in unix_latch.c, and clean
      up bizarre and unsafe scheme for disowning the process's latch.  Much of
      this has to be back-patched into 9.1.
      
      Peter Geoghegan, with additional work by Tom
      4dab3d5a
    • Heikki Linnakangas's avatar
      Oops, we're working on version 9.2 already, not 9.1. Update the · 1f1b70a7
      Heikki Linnakangas authored
      PG_CONTROL_VERSION accordingly; I updated it wrong in previous commit.
      1f1b70a7
    • Heikki Linnakangas's avatar
      If backup-end record is not seen, and we reach end of recovery from a · 41f9ffd9
      Heikki Linnakangas authored
      streamed backup, throw an error and refuse to start up. The restore has not
      finished correctly in that case and the data directory is possibly corrupt.
      We already errored out in case of archive recovery, but could not during
      crash recovery because we couldn't distinguish between the case that
      pg_start_backup() was called and the database then crashed (must not error,
      data is OK), and the case that we're restoring from a backup and not all
      the needed WAL was replayed (data can be corrupt).
      
      To distinguish those cases, add a line to backup_label to indicate
      whether the backup was taken with pg_start/stop_backup(), or by streaming
      (ie. pg_basebackup).
      
      This requires re-initdb, because of a new field added to the control file.
      41f9ffd9
  3. 09 Aug, 2011 7 commits
    • Tom Lane's avatar
      Measure WaitLatch's timeout parameter in milliseconds, not microseconds. · 9f17ffd8
      Tom Lane authored
      The original definition had the problem that timeouts exceeding about 2100
      seconds couldn't be specified on 32-bit machines.  Milliseconds seem like
      sufficient resolution, and finer grain than that would be fantasy anyway
      on many platforms.
      
      Back-patch to 9.1 so that this aspect of the latch API won't change between
      9.1 and later releases.
      
      Peter Geoghegan
      9f17ffd8
    • Tom Lane's avatar
      Documentation improvement and minor code cleanups for the latch facility. · 4e15a4db
      Tom Lane authored
      Improve the documentation around weak-memory-ordering risks, and do a pass
      of general editorialization on the comments in the latch code.  Make the
      Windows latch code more like the Unix latch code where feasible; in
      particular provide the same Assert checks in both implementations.
      Fix poorly-placed WaitLatch call in syncrep.c.
      
      This patch resolves, for the moment, concerns around weak-memory-ordering
      bugs in latch-related code: we have documented the restrictions and checked
      that existing calls meet them.  In 9.2 I hope that we will install suitable
      memory barrier instructions in SetLatch/ResetLatch, so that their callers
      don't need to be quite so careful.
      4e15a4db
    • Tom Lane's avatar
      Avoid creating PlaceHolderVars immediately within PlaceHolderVars. · cff60f2d
      Tom Lane authored
      Such a construction is useless since the lower PlaceHolderVar is already
      nullable; no need to make it more so.  Noted while pursuing bug #6154.
      
      This is just a minor planner efficiency improvement, since the final plan
      will come out the same anyway after PHVs are flattened.  So not worth the
      risk of back-patching.
      cff60f2d
    • Peter Eisentraut's avatar
      Use clearer notation for getnameinfo() return handling · f4a9da0a
      Peter Eisentraut authored
      Writing
      
          if (getnameinfo(...))
              handle_error();
      
      reads quite strangely, so use something like
      
          if (getnameinfo(...) != 0)
              handle_error();
      
      instead.
      f4a9da0a
    • Heikki Linnakangas's avatar
      Change the way string relopts are allocated. · 77949a29
      Heikki Linnakangas authored
      Don't try to allocate the default value for a string relopt in the same
      palloc chunk as the relopt_string struct. That didn't work too well if you
      added a built-in string relopt in the stringRelOpts array, as it's not
      possible to have an initializer for a variable length struct in C. This
      makes the code slightly simpler too.
      
      While we're at it, move the call to validator function in
      add_string_reloption to before the allocation, so that if someone does pass
      a bogus default value, we don't leak memory.
      77949a29
    • Heikki Linnakangas's avatar
      5b6c8436
    • Tom Lane's avatar
      Fix nested PlaceHolderVar expressions that appear only in targetlists. · 77ba2325
      Tom Lane authored
      A PlaceHolderVar's expression might contain another, lower-level
      PlaceHolderVar.  If the outer PlaceHolderVar is used, the inner one
      certainly will be also, and so we have to make sure that both of them get
      into the placeholder_list with correct ph_may_need values during the
      initial pre-scan of the query (before deconstruct_jointree starts).
      We did this correctly for PlaceHolderVars appearing in the query quals,
      but overlooked the issue for those appearing in the top-level targetlist;
      with the result that nested placeholders referenced only in the targetlist
      did not work correctly, as illustrated in bug #6154.
      
      While at it, add some error checking to find_placeholder_info to ensure
      that we don't try to create new placeholders after it's too late to do so;
      they have to all be created before deconstruct_jointree starts.
      
      Back-patch to 8.4 where the PlaceHolderVar mechanism was introduced.
      77ba2325
  4. 08 Aug, 2011 4 commits
  5. 07 Aug, 2011 4 commits
  6. 06 Aug, 2011 3 commits
    • Tom Lane's avatar
      Clean up ill-advised attempt to invent a private set of Node tags. · 05e83968
      Tom Lane authored
      Somebody thought it'd be cute to invent a set of Node tag numbers that were
      defined independently of, and indeed conflicting with, the main tag-number
      list.  While this accidentally failed to fail so far, it would certainly
      lead to trouble as soon as anyone wanted to, say, apply copyObject to these
      node types.  Clang was already complaining about the use of makeNode on
      these tags, and I think quite rightly so.  Fix by pushing these node
      definitions into the mainstream, including putting replnodes.h where it
      belongs.
      05e83968
    • Tom Lane's avatar
      Fix thinko in documentation of local_preload_libraries. · ffcf5a6c
      Tom Lane authored
      Somebody added a cross-reference to shared_preload_libraries, but wrote the
      wrong variable name when they did it (and didn't bother to make it a link
      either).
      
      Spotted by Christoph Anton Mitterer.
      ffcf5a6c
    • Tom Lane's avatar
      Reduce PG_SYSLOG_LIMIT to 900 bytes. · 375aa7b3
      Tom Lane authored
      The previous limit of 1024 was set on the assumption that all modern syslog
      implementations have line length limits of 2KB or so.  However, this is
      false, as at least Solaris and sysklogd truncate at only 1KB.  900 seems
      to leave enough room for the max likely length of the tacked-on prefixes,
      so let's go with that.
      
      As with the previous change, it doesn't seem wise to back-patch this into
      already-released branches; but it should be OK to sneak it into 9.1.
      
      Noah Misch
      375aa7b3
  7. 05 Aug, 2011 3 commits
    • Robert Haas's avatar
      Allow per-column foreign data wrapper options. · c4096c76
      Robert Haas authored
      Shigeru Hanada, with fairly minor editing by me.
      c4096c76
    • Robert Haas's avatar
      Modestly improve pgbench's checking for invalid ranges. · 68cbb9f4
      Robert Haas authored
      The old check against MAX_RANDOM_VALUE is clearly irrelevant since
      getrand() no longer calls random().  Instead, check whether min and max
      are close enough together to avoid an overflow inside getrand(), as
      suggested by Tom Lane.  This is still somewhat silly, because we're
      using atoi(), which doesn't check for overflow anyway and (at least on
      my system) will cheerfully return 0 when given "4294967296".  But that's
      a problem for another commit.
      68cbb9f4
    • Robert Haas's avatar
      Tweak PQresStatus() to avoid a clang compiler warning. · b43bf617
      Robert Haas authored
      The previous test for status < 0 test is in fact testing nothing if the
      compiler considers an enum to be an unsigned data type.  clang doesn't
      like tautologies, so do this instead.
      
      Report by Peter Geoghegan, fix as suggested by Tom Lane.
      b43bf617
  8. 04 Aug, 2011 5 commits
    • Bruce Momjian's avatar
      Fix markup for recent wal_level clarification. · 4262e61d
      Bruce Momjian authored
      Backpatch to 9.1 and 9.0.
      4262e61d
    • Andrew Dunstan's avatar
      Restore the primacy of postgres.h in plpython.c. · a11cf433
      Andrew Dunstan authored
      To avoid having the python headers hijack various definitions,
      we now include them after all the system headers we want, having
      first undefined some of the things they want to define. After that's
      done we restore the things they scribbled on that matter, namely our
      snprintf and vsnprintf macros, if we're using them.
      a11cf433
    • Robert Haas's avatar
      Create VXID locks "lazily" in the main lock table. · 84e37126
      Robert Haas authored
      Instead of entering them on transaction startup, we materialize them
      only when someone wants to wait, which will occur only during CREATE
      INDEX CONCURRENTLY.  In Hot Standby mode, the startup process must also
      be able to probe for conflicting VXID locks, but the lock need never be
      fully materialized, because the startup process does not use the normal
      lock wait mechanism.  Since most VXID locks never need to touch the
      lock manager partition locks, this can significantly reduce blocking
      contention on read-heavy workloads.
      
      Patch by me.  Review by Jeff Davis.
      84e37126
    • Robert Haas's avatar
      Teach psql to display comments on languages and casts. · 3b17efdf
      Robert Haas authored
      The output of \dL (list languages) is fairly narrow, so we just always
      display the comment.  \dC (list casts) can get fairly wide, so we only
      display comments if the new \dC+ option is specified.
      
      Josh Kupershmidt
      3b17efdf
    • Bruce Momjian's avatar
      In documentaiton, clarify which commands have reduced WAL volume for · 38de5aad
      Bruce Momjian authored
      wal_level = minimum.
      
      Backpatch to 9.1 and 9.0.
      38de5aad
  9. 03 Aug, 2011 1 commit
    • Robert Haas's avatar
      Make pgbench use erand48() rather than random(). · 4af43ee3
      Robert Haas authored
      glibc renders random() thread-safe by wrapping a futex lock around it;
      testing reveals that this limits the performance of pgbench on machines
      with many CPU cores.  Rather than switching to random_r(), which is
      only available on GNU systems and crashes unless you use undocumented
      alchemy to initialize the random state properly, switch to our built-in
      implementation of erand48(), which is both thread-safe and concurrent.
      
      Since the list of reasons not to use the operating system's erand48()
      is getting rather long, rename ours to pg_erand48() (and similarly
      for our implementations of lrand48() and srand48()) and just always
      use those.  We were already doing this on Cygwin anyway, and the
      glibc implementation is not quite thread-safe, so pgbench wouldn't
      be able to use that either.
      
      Per discussion with Tom Lane.
      4af43ee3
  10. 02 Aug, 2011 3 commits
    • Tom Lane's avatar
      Move CheckRecoveryConflictDeadlock() call to a safer place. · ac36e6f7
      Tom Lane authored
      This kluge was inserted in a spot apparently chosen at random: the lock
      manager's state is not yet fully set up for the wait, and in particular
      LockWaitCancel hasn't been armed by setting lockAwaited, so the ProcLock
      will not get cleaned up if the ereport is thrown.  This seems to not cause
      any observable problem in trivial test cases, because LockReleaseAll will
      silently clean up the debris; but I was able to cause failures with tests
      involving subtransactions.
      
      Fixes breakage induced by commit c85c9414.
      Back-patch to all affected branches.
      ac36e6f7
    • Tom Lane's avatar
      Fix incorrect initialization of ProcGlobal->startupBufferPinWaitBufId. · 2e53bd55
      Tom Lane authored
      It was initialized in the wrong place and to the wrong value.  With bad
      luck this could result in incorrect query-cancellation failures in hot
      standby sessions, should a HS backend be holding pin on buffer number 1
      while trying to acquire a lock.
      2e53bd55
    • Heikki Linnakangas's avatar
      Avoid integer overflow when LIMIT + OFFSET >= 2^63. · 89df948e
      Heikki Linnakangas authored
      This fixes bug #6139 reported by Hitoshi Harada.
      89df948e
  11. 01 Aug, 2011 1 commit
  12. 31 Jul, 2011 1 commit
  13. 30 Jul, 2011 1 commit