1. 27 Jun, 2013 6 commits
    • Tom Lane's avatar
      Expect EWOULDBLOCK from a non-blocking connect() call only on Windows. · a099482c
      Tom Lane authored
      On Unix-ish platforms, EWOULDBLOCK may be the same as EAGAIN, which is
      *not* a success return, at least not on Linux.  We need to treat it as a
      failure to avoid giving a misleading error message.  Per the Single Unix
      Spec, only EINPROGRESS and EINTR returns indicate that the connection
      attempt is in progress.
      
      On Windows, on the other hand, EWOULDBLOCK (WSAEWOULDBLOCK) is the expected
      case.  We must accept EINPROGRESS as well because Cygwin will return that,
      and it doesn't seem worth distinguishing Cygwin from native Windows here.
      It's not very clear whether EINTR can occur on Windows, but let's leave
      that part of the logic alone in the absence of concrete trouble reports.
      
      Also, remove the test for errno == 0, effectively reverting commit
      da9501bd, which AFAICS was just a thinko;
      or at best it might have been a workaround for a platform-specific bug,
      which we can hope is gone now thirteen years later.  In any case, since
      libpq makes no effort to reset errno to zero before calling connect(),
      it seems unlikely that that test has ever reliably done anything useful.
      
      Andres Freund and Tom Lane
      a099482c
    • Michael Meskes's avatar
      Fixed incorrect description of EXEC SQL VAR command. · a2769a4e
      Michael Meskes authored
      Thanks to MauMau <maumau307@gmail.com> for finding and fixing this.
      a2769a4e
    • Robert Haas's avatar
      pgbench: Fix inadvertent inconsistency in help message. · 682d977f
      Robert Haas authored
      Per report from Fujii Masao.
      682d977f
    • Robert Haas's avatar
      pgbench: Add long options for all existing short options. · 79cddb18
      Robert Haas authored
      Fabien Coelho, reviewed by Fabrízio de Royes Mello, with some further
      changes by me
      79cddb18
    • Tom Lane's avatar
      Tweak wording in sequence-function docs to avoid PDF build failures. · a03ae56e
      Tom Lane authored
      Adjust the wording in the first para of "Sequence Manipulation Functions"
      so that neither of the link phrases in it break across line boundaries,
      in either A4- or US-page-size PDF output.  This fixes a reported build
      failure for the 9.3beta2 A4 PDF docs, and future-proofs this particular
      para against causing similar problems in future.  (Perhaps somebody will
      fix this issue in the SGML/TeX documentation tool chain someday, but I'm
      not holding my breath.)
      
      Back-patch to all supported branches, since the same problem could rise up
      to bite us in future updates if anyone changes anything earlier than this
      in func.sgml.
      a03ae56e
    • Noah Misch's avatar
      Cooperate with the Valgrind instrumentation framework. · 19085116
      Noah Misch authored
      Valgrind "client requests" in aset.c and mcxt.c teach Valgrind and its
      Memcheck tool about the PostgreSQL allocator.  This makes Valgrind
      roughly as sensitive to memory errors involving palloc chunks as it is
      to memory errors involving malloc chunks.  Further client requests in
      PageAddItem() and printtup() verify that all bits being added to a
      buffer page or furnished to an output function are predictably-defined.
      Those tests catch failures of C-language functions to fully initialize
      the bits of a Datum, which in turn stymie optimizations that rely on
      _equalConst().  Define the USE_VALGRIND symbol in pg_config_manual.h to
      enable these additions.  An included "suppression file" silences nominal
      errors we don't plan to fix.
      
      Reviewed in earlier versions by Peter Geoghegan and Korry Douglas.
      19085116
  2. 26 Jun, 2013 5 commits
    • Noah Misch's avatar
      Refactor aset.c and mcxt.c in preparation for Valgrind cooperation. · a855148a
      Noah Misch authored
      Move some repeated debugging code into functions and store intermediates
      in variables where not presently necessary.  No code-generation changes
      in a production build, and no functional changes.  This simplifies and
      focuses the main patch.
      a855148a
    • Noah Misch's avatar
      Initialize pad bytes in GinFormTuple(). · 1d96bb96
      Noah Misch authored
      Every other core buffer page consumer initializes the bytes it furnishes
      to PageAddItem().  For consistency, do the same here.  No back-patch;
      regardless, we couldn't count on the fix so long as binary upgrade can
      carry forward affected index builds.
      1d96bb96
    • Noah Misch's avatar
      Document effect of constant folding on CASE. · d53f7cf1
      Noah Misch authored
      Back-patch to all supported versions.
      
      Laurenz Albe
      d53f7cf1
    • Noah Misch's avatar
      Renovate display of non-ASCII messages on Windows. · 5f538ad0
      Noah Misch authored
      GNU gettext selects a default encoding for the messages it emits in a
      platform-specific manner; it uses the Windows ANSI code page on Windows
      and follows LC_CTYPE on other platforms.  This is inconvenient for
      PostgreSQL server processes, so realize consistent cross-platform
      behavior by calling bind_textdomain_codeset() on Windows each time we
      permanently change LC_CTYPE.  This primarily affects SQL_ASCII databases
      and processes like the postmaster that do not attach to a database,
      making their behavior consistent with PostgreSQL on non-Windows
      platforms.  Messages from SQL_ASCII databases use the encoding implied
      by the database LC_CTYPE, and messages from non-database processes use
      LC_CTYPE from the postmaster system environment.  PlatformEncoding
      becomes unused, so remove it.
      
      Make write_console() prefer WriteConsoleW() to write() regardless of the
      encodings in use.  In this situation, write() will invariably mishandle
      non-ASCII characters.
      
      elog.c has assumed that messages conform to the database encoding.
      While usually true, this does not hold for SQL_ASCII and MULE_INTERNAL.
      Introduce MessageEncoding to track the actual encoding of message text.
      The present consumers are Windows-specific code for converting messages
      to UTF16 for use in system interfaces.  This fixes the appearance in
      Windows event logs and consoles of translated messages from SQL_ASCII
      processes like the postmaster.  Note that SQL_ASCII inherently disclaims
      a strong notion of encoding, so non-ASCII byte sequences interpolated
      into messages by %s may yet yield a nonsensical message.  MULE_INTERNAL
      has similar problems at present, albeit for a different reason: its lack
      of libiconv support or a conversion to UTF8.
      
      Consequently, one need no longer restart Windows with a different
      Windows ANSI code page to broadly test backend logging under a given
      language.  Changing the user's locale ("Format") is enough.  Several
      accounts can simultaneously run postmasters under different locales, all
      correctly logging localized messages to Windows event logs and consoles.
      
      Alexander Law and Noah Misch
      5f538ad0
    • Peter Eisentraut's avatar
      pg_receivexlog: Fix logic error · 2c1031bd
      Peter Eisentraut authored
      The code checking the WAL file name contained a logic error and wouldn't
      actually catch some bad names.
      2c1031bd
  3. 25 Jun, 2013 3 commits
    • Alvaro Herrera's avatar
      Avoid inconsistent type declaration · 4ca50e07
      Alvaro Herrera authored
      Clang 3.3 correctly complains that a variable of type enum
      MultiXactStatus cannot hold a value of -1, which makes sense.  Change
      the declared type of the variable to int instead, and apply casting as
      necessary to avoid the warning.
      
      Per notice from Andres Freund
      4ca50e07
    • Andrew Dunstan's avatar
      Properly dump dropped foreign table cols in binary-upgrade mode. · 81166a2f
      Andrew Dunstan authored
      In binary upgrade mode, we need to recreate and then drop dropped
      columns so that all the columns get the right attribute number. This is
      true for foreign tables as well as for native tables. For foreign
      tables we have been getting the first part right but not the second,
      leading to bogus columns in the upgraded database. Fix this all the way
      back to 9.1, where foreign tables were introduced.
      81166a2f
    • 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
  4. 24 Jun, 2013 3 commits
  5. 23 Jun, 2013 2 commits
  6. 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
  7. 21 Jun, 2013 1 commit
  8. 20 Jun, 2013 2 commits
  9. 19 Jun, 2013 3 commits
  10. 18 Jun, 2013 2 commits
  11. 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
  12. 16 Jun, 2013 1 commit
  13. 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
  14. 14 Jun, 2013 6 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