1. 25 Jun, 2013 1 commit
    • Fujii Masao's avatar
      Support clean switchover. · 985bd7d4
      Fujii Masao authored
      In replication, when we shutdown the master, walsender tries to send
      all the outstanding WAL records to the standby, and then to exit. This
      basically means that all the WAL records are fully synced between
      two servers after the clean shutdown of the master. So, after
      promoting the standby to new master, we can restart the stopped
      master as new standby without the need for a fresh backup from
      new master.
      
      But there was one problem so far: though walsender tries to send all
      the outstanding WAL records, it doesn't wait for them to be replicated
      to the standby. Then, before receiving all the WAL records,
      walreceiver can detect the closure of connection and exit. We cannot
      guarantee that there is no missing WAL in the standby after clean
      shutdown of the master. In this case, backup from new master is
      required when restarting the stopped master as new standby.
      
      This patch fixes this problem. It just changes walsender so that it
      waits for all the outstanding WAL records to be replicated to the
      standby before closing the replication connection.
      
      Per discussion, this is a fix that needs to get backpatched rather than
      new feature. So, back-patch to 9.1 where enough infrastructure for
      this exists.
      
      Patch by me, reviewed by Andres Freund.
      985bd7d4
  2. 24 Jun, 2013 3 commits
  3. 23 Jun, 2013 2 commits
  4. 22 Jun, 2013 1 commit
    • Peter Eisentraut's avatar
      doc: Fix date in EPUB manifest · dab1603e
      Peter Eisentraut authored
      If there is no <date> element, the publication date for the EPUB
      manifest is taken from the copyright year.  But something like
      "1996-2013" is not a legal date specification.  So the EPUB output
      currently fails epubcheck.
      
      Put in a separate <date> element with the current year.  Put it in
      legal.sgml, because copyright.pl already instructs to update that
      manually, so it hopefully won't be missed.
      dab1603e
  5. 21 Jun, 2013 1 commit
  6. 20 Jun, 2013 2 commits
  7. 19 Jun, 2013 3 commits
  8. 18 Jun, 2013 2 commits
  9. 17 Jun, 2013 1 commit
    • Jeff Davis's avatar
      Add buffer_std flag to MarkBufferDirtyHint(). · b8fd1a09
      Jeff Davis authored
      MarkBufferDirtyHint() writes WAL, and should know if it's got a
      standard buffer or not. Currently, the only callers where buffer_std
      is false are related to the FSM.
      
      In passing, rename XLOG_HINT to XLOG_FPI, which is more descriptive.
      
      Back-patch to 9.3.
      b8fd1a09
  10. 16 Jun, 2013 1 commit
  11. 15 Jun, 2013 4 commits
    • Tom Lane's avatar
      Use WaitLatch, not pg_usleep, for delaying in pg_sleep(). · a64ca63e
      Tom Lane authored
      This avoids platform-dependent behavior wherein pg_sleep() might fail to be
      interrupted by statement timeout, query cancel, SIGTERM, etc.  Also, since
      there's no reason to wake up once a second any more, we can reduce the
      power consumption of a sleeping backend a tad.
      
      Back-patch to 9.3, since use of SA_RESTART for SIGALRM makes this a bigger
      issue than it used to be.
      a64ca63e
    • Fujii Masao's avatar
      Fix pg_restore -l with the directory archive to display the correct format name. · f69aece6
      Fujii Masao authored
      Back-patch to 9.1 where the directory archive was introduced.
      f69aece6
    • Tom Lane's avatar
      Use SA_RESTART for all signals, including SIGALRM. · 873ab972
      Tom Lane authored
      The exclusion of SIGALRM dates back to Berkeley days, when Postgres used
      SIGALRM in only one very short stretch of code.  Nowadays, allowing it to
      interrupt kernel calls doesn't seem like a very good idea, since its use
      for statement_timeout means SIGALRM could occur anyplace in the code, and
      there are far too many call sites where we aren't prepared to deal with
      EINTR failures.  When third-party code is taken into consideration, it
      seems impossible that we ever could be fully EINTR-proof, so better to
      use SA_RESTART always and deal with the implications of that.  One such
      implication is that we should not assume pg_usleep() will be terminated
      early by a signal.  Therefore, long sleeps should probably be replaced
      by WaitLatch operations where practical.
      
      Back-patch to 9.3 so we can get some beta testing on this change.
      873ab972
    • Tom Lane's avatar
      Be consistent about #define'ing configure symbols as "1" not empty. · 5242fefb
      Tom Lane authored
      This is just neatnik-ism, since all the tests in the code are #ifdefs,
      but we shouldn't specify symbols as "Define to 1 ..." and then not
      actually define them that way.
      5242fefb
  12. 14 Jun, 2013 8 commits
    • Heikki Linnakangas's avatar
      Add :client_id automatic variable for custom pgbench scripts. · b2316088
      Heikki Linnakangas authored
      This makes it easier to write custom scripts that have different logic for
      each client.
      
      Gurjeet Singh, with some changes by me.
      b2316088
    • Tom Lane's avatar
    • Tom Lane's avatar
      8a3f0894
    • Tom Lane's avatar
      Stamp HEAD as 9.4devel. · 58ae1f45
      Tom Lane authored
      Let the hacking begin ...
      58ae1f45
    • Tom Lane's avatar
      Avoid deadlocks during insertion into SP-GiST indexes. · e472b921
      Tom Lane authored
      SP-GiST's original scheme for avoiding deadlocks during concurrent index
      insertions doesn't work, as per report from Hailong Li, and there isn't any
      evident way to make it work completely.  We could possibly lock individual
      inner tuples instead of their whole pages, but preliminary experimentation
      suggests that the performance penalty would be huge.  Instead, if we fail
      to get a buffer lock while descending the tree, just restart the tree
      descent altogether.  We keep the old tuple positioning rules, though, in
      hopes of reducing the number of cases where this can happen.
      
      Teodor Sigaev, somewhat edited by Tom Lane
      e472b921
    • Tom Lane's avatar
      Remove special-case treatment of LOG severity level in standalone mode. · c62866ee
      Tom Lane authored
      elog.c has historically treated LOG messages as low-priority during
      bootstrap and standalone operation.  This has led to confusion and even
      masked a bug, because the normal expectation of code authors is that
      elog(LOG) will put something into the postmaster log, and that wasn't
      happening during initdb.  So get rid of the special-case rule and make
      the priority order the same as it is in normal operation.  To keep from
      cluttering initdb's output and the behavior of a standalone backend,
      tweak the severity level of three messages routinely issued by xlog.c
      during startup and shutdown so that they won't appear in these cases.
      Per my proposal back in December.
      c62866ee
    • Tom Lane's avatar
      Refactor checksumming code to make it easier to use externally. · f0421634
      Tom Lane authored
      pg_filedump and other external utility programs are likely to want to be
      able to check Postgres page checksums.  To avoid messy duplication of code,
      move the checksumming functionality into an exported header file, much as
      we did awhile back for the CRC code.
      
      In passing, get rid of an unportable assumption that a static char[] array
      will be word-aligned, and do some other minor code beautification.
      f0421634
    • Peter Eisentraut's avatar
      PL/Python: Fix type mixup · fa2fc066
      Peter Eisentraut authored
      Memory was allocated based on the sizeof a type that was not the type of
      the pointer that the result was being assigned to.  The types happen to
      be of the same size, but it's still wrong.
      fa2fc066
  13. 13 Jun, 2013 1 commit
    • Tom Lane's avatar
      Only install a portal's ResourceOwner if it actually has one. · 629b3e96
      Tom Lane authored
      In most scenarios a portal without a ResourceOwner is dead and not subject
      to any further execution, but a portal for a cursor WITH HOLD remains in
      existence with no ResourceOwner after the creating transaction is over.
      In this situation, if we attempt to "execute" the portal directly to fetch
      data from it, we were setting CurrentResourceOwner to NULL, leading to a
      segfault if the datatype output code did anything that required a resource
      owner (such as trying to fetch system catalog entries that weren't already
      cached).  The case appears to be impossible to provoke with stock libpq,
      but psqlODBC at least is able to cause it when working with held cursors.
      
      Simplest fix is to just skip the assignment to CurrentResourceOwner, so
      that any resources used by the data output operations will be managed by
      the transaction-level resource owner instead.  For consistency I changed
      all the places that install a portal's resowner as current, even though
      some of them are probably not reachable with a held cursor's portal.
      
      Per report from Joshua Berry (with thanks to Hiroshi Inoue for developing
      a self-contained test case).  Back-patch to all supported versions.
      629b3e96
  14. 12 Jun, 2013 8 commits
    • Noah Misch's avatar
      Avoid reading past datum end when parsing JSON. · 66008564
      Noah Misch authored
      Several loops in the JSON parser examined a byte in memory just before
      checking whether its address was in-bounds, so they could read one byte
      beyond the datum's allocation.  A SIGSEGV is possible.  New in 9.3, so
      no back-patch.
      66008564
    • Noah Misch's avatar
      Avoid reading below the start of a stack variable in tokenize_file(). · 3a5d0c55
      Noah Misch authored
      We would wrongly overwrite the prior stack byte if it happened to
      contain '\n' or '\r'.  New in 9.3, so no back-patch.
      3a5d0c55
    • Noah Misch's avatar
      Don't pass oidvector by value. · 813895e4
      Noah Misch authored
      Since the structure ends with a flexible array, doing so truncates any
      vector having more than one element.  New in 9.3, so no back-patch.
      813895e4
    • Noah Misch's avatar
      Observe array length in HaveVirtualXIDsDelayingChkpt(). · fb435f40
      Noah Misch authored
      Since commit f21bb9cf, this function
      ignores the caller-provided length and loops until it finds a
      terminator, which GetVirtualXIDsDelayingChkpt() never adds.  Restore the
      previous loop control logic.  In passing, revert the addition of an
      unused variable by the same commit, presumably a debugging relic.
      fb435f40
    • Noah Misch's avatar
      Don't use ordinary NULL-terminated strings as Name datums. · ff53890f
      Noah Misch authored
      Consumers are entitled to read the full 64 bytes pertaining to a Name;
      using a shorter NULL-terminated string leads to reading beyond the end
      its allocation; a SIGSEGV is possible.  Use the frequent idiom of
      copying to a NameData on the stack.  New in 9.3, so no back-patch.
      ff53890f
    • Tom Lane's avatar
      Improve updatability checking for views and foreign tables. · dc3eb563
      Tom Lane authored
      Extend the FDW API (which we already changed for 9.3) so that an FDW can
      report whether specific foreign tables are insertable/updatable/deletable.
      The default assumption continues to be that they're updatable if the
      relevant executor callback function is supplied by the FDW, but finer
      granularity is now possible.  As a test case, add an "updatable" option to
      contrib/postgres_fdw.
      
      This patch also fixes the information_schema views, which previously did
      not think that foreign tables were ever updatable, and fixes
      view_is_auto_updatable() so that a view on a foreign table can be
      auto-updatable.
      
      initdb forced due to changes in information_schema views and the functions
      they rely on.  This is a bit unfortunate to do post-beta1, but if we don't
      change this now then we'll have another API break for FDWs when we do
      change it.
      
      Dean Rasheed, somewhat editorialized on by Tom Lane
      dc3eb563
    • Andrew Dunstan's avatar
      Fix unescaping of JSON Unicode escapes, especially for non-UTF8. · 78ed8e03
      Andrew Dunstan authored
      Per discussion  on -hackers. We treat Unicode escapes when unescaping
      them similarly to the way we treat them in PostgreSQL string literals.
      Escapes in the ASCII range are always accepted, no matter what the
      database encoding. Escapes for higher code points are only processed in
      UTF8 databases, and attempts to process them in other databases will
      result in an error. \u0000 is never unescaped, since it would result in
      an impermissible null byte.
      78ed8e03
    • Robert Haas's avatar
      Improve description of loread/lowrite. · c1d729b4
      Robert Haas authored
      Patch by me, reviewed by Tatsuo Ishii.
      c1d729b4
  15. 11 Jun, 2013 2 commits
    • Tom Lane's avatar
      Fix cache flush hazard in cache_record_field_properties(). · e262755b
      Tom Lane authored
      We need to increment the refcount on the composite type's cached tuple
      descriptor while we do lookups of its column types.  Otherwise a cache
      flush could occur and release the tuple descriptor before we're done with
      it.  This fails reliably with -DCLOBBER_CACHE_ALWAYS, but the odds of a
      failure in a production build seem rather low (since the pfree'd descriptor
      typically wouldn't get scribbled on immediately).  That may explain the
      lack of any previous reports.  Buildfarm issue noted by Christian Ullrich.
      
      Back-patch to 9.1 where the bogus code was added.
      e262755b
    • Tatsuo Ishii's avatar
      Add description that loread()/lowrite() are corresponding to · ecdec470
      Tatsuo Ishii authored
      lo_read()/lo_write() in libpq to avoid confusion.
      ecdec470