1. 14 Jul, 2015 5 commits
    • Heikki Linnakangas's avatar
      Add ALTER OPERATOR command, for changing selectivity estimator functions. · 321eed5f
      Heikki Linnakangas authored
      Other options cannot be changed, as it's not totally clear if cached plans
      would need to be invalidated if one of the other options change. Selectivity
      estimator functions only change plan costs, not correctness of plans, so
      those should be safe.
      
      Original patch by Uriy Zhuravlev, heavily edited by me.
      321eed5f
    • Fujii Masao's avatar
      Prevent pgstattuple() from reporting BRIN as unknown index. · 705d397c
      Fujii Masao authored
      Also this patch removes obsolete comment.
      
      Back-patch to 9.5 where BRIN index was added.
      705d397c
    • Heikki Linnakangas's avatar
      Make regression test output stable. · 1a56498e
      Heikki Linnakangas authored
      In the test query I added for ALTER TABLE retaining comments, the order of
      the result rows was not stable, and varied across systems. Add an ORDER BY
      to make the order predictable. This should fix the buildfarm failures.
      1a56498e
    • Heikki Linnakangas's avatar
      Retain comments on indexes and constraints at ALTER TABLE ... TYPE ... · e42375fc
      Heikki Linnakangas authored
      When a column's datatype is changed, ATExecAlterColumnType() rebuilds all
      the affected indexes and constraints, and the comments from the old
      indexes/constraints were not carried over.
      
      To fix, create a synthetic COMMENT ON command in the work queue, to re-add
      any comments on constraints. For indexes, there's a comment field in
      IndexStmt that is used.
      
      This fixes bug #13126, reported by Kirill Simonov. Original patch by
      Michael Paquier, reviewed by Petr Jelinek and me. This bug is present in
      all versions, but only backpatch to 9.5. Given how minor the issue is, it
      doesn't seem worth the work and risk to backpatch further than that.
      e42375fc
    • Heikki Linnakangas's avatar
      Reformat code in ATPostAlterTypeParse. · 1ab9faae
      Heikki Linnakangas authored
      The code in ATPostAlterTypeParse was very deeply indented, mostly because
      there were two nested switch-case statements, which add a lot of
      indentation. Use if-else blocks instead, to make the code less indented
      and more readable.
      
      This is in preparation for next patch that makes some actualy changes to
      the function. These cosmetic parts have been separated to make it easier
      to see the real changes in the other patch.
      1ab9faae
  2. 12 Jul, 2015 6 commits
  3. 11 Jul, 2015 1 commit
  4. 10 Jul, 2015 1 commit
    • Heikki Linnakangas's avatar
      Copy-edit the docs changes of OWNER TO CURRENT/SESSION_USER additions. · cba045b0
      Heikki Linnakangas authored
      Commit 31eae602 added new syntax to many DDL commands to use CURRENT_USER
      or SESSION_USER instead of role name in ALTER ... OWNER TO, but because
      of a misplaced '{', the syntax in the docs implied that the syntax was
      "ALTER ... CURRENT_USER", instead of "ALTER ... OWNER TO CURRENT_USER".
      Fix that, and also the funny indentation in some of the modified syntax
      blurps.
      cba045b0
  5. 09 Jul, 2015 15 commits
    • Tom Lane's avatar
      Improve documentation about array concat operator vs. underlying functions. · e4f29ce3
      Tom Lane authored
      The documentation implied that there was seldom any reason to use the
      array_append, array_prepend, and array_cat functions directly.  But that's
      not really true, because they can help make it clear which case is meant,
      which the || operator can't do since it's overloaded to represent all three
      cases.  Add some discussion and examples illustrating the potentially
      confusing behavior that can ensue if the parser misinterprets what was
      meant.
      
      Per a complaint from Michael Herold.  Back-patch to 9.2, which is where ||
      started to behave this way.
      e4f29ce3
    • Tom Lane's avatar
      Fix postmaster's handling of a startup-process crash. · 45811be9
      Tom Lane authored
      Ordinarily, a failure (unexpected exit status) of the startup subprocess
      should be considered fatal, so the postmaster should just close up shop
      and quit.  However, if we sent the startup process a SIGQUIT or SIGKILL
      signal, the failure is hardly "unexpected", and we should attempt restart;
      this is necessary for recovery from ordinary backend crashes in hot-standby
      scenarios.  I attempted to implement the latter rule with a two-line patch
      in commit 442231d7, but it now emerges that
      that patch was a few bricks shy of a load: it failed to distinguish the
      case of a signaled startup process from the case where the new startup
      process crashes before reaching database consistency.  That resulted in
      infinitely respawning a new startup process only to have it crash again.
      
      To handle this properly, we really must track whether we have sent the
      *current* startup process a kill signal.  Rather than add yet another
      ad-hoc boolean to the postmaster's state, I chose to unify this with the
      existing RecoveryError flag into an enum tracking the startup process's
      state.  That seems more consistent with the postmaster's general state
      machine design.
      
      Back-patch to 9.0, like the previous patch.
      45811be9
    • Fujii Masao's avatar
      Fix obsolete comment regarding NOTICE message level. · 6ba365aa
      Fujii Masao authored
      By default NOTICE message is not sent to server log because
      the default value of log_min_messages is WARNING since 8.4.
      
      Pavel Stehule
      6ba365aa
    • Fujii Masao's avatar
      Make wal_compression PGC_SUSET rather than PGC_USERSET. · c2e5f4d1
      Fujii Masao authored
      When enabling wal_compression, there is a risk to leak data similarly to
      the BREACH and CRIME attacks on SSL where the compression ratio of
      a full page image gives a hint of what is the existing data of this page.
      This vulnerability is quite cumbersome to exploit in practice, but doable.
      
      So this patch makes wal_compression PGC_SUSET in order to prevent
      non-superusers from enabling it and exploiting the vulnerability while
      DBA thinks the risk very seriously and disables it in postgresql.conf.
      
      Back-patch to 9.5 where wal_compression was introduced.
      c2e5f4d1
    • Heikki Linnakangas's avatar
      Use --debug flag in "remote" pg_rewind regression tests. · 23b89288
      Heikki Linnakangas authored
      Gives more information in the log, to debug possible failures.
      23b89288
    • Heikki Linnakangas's avatar
      Fix another broken link in documentation. · aaec6a6d
      Heikki Linnakangas authored
      Tom fixed another one of these in commit 7f32dbcd, but there was another
      almost identical one in libpq docs. Per his comment:
      
      HP's web server has apparently become case-sensitive sometime recently.
      Per bug #13479 from Daniel Abraham.  Corrected link identified by Alvaro.
      aaec6a6d
    • Heikki Linnakangas's avatar
      Improve logging of TAP tests. · 1ea06203
      Heikki Linnakangas authored
      Create a log file for each test run. Stdout and stderr of the test script,
      as well as any subprocesses run as part of the test, are redirected to
      the log file. This makes it a lot easier to debug test failures. Also print
      the test output (ok 12 - ... messages) to the log file, and the command
      line of any external programs executed with the system_or_bail and run_log
      functions. This makes it a lot easier to debug failing tests.
      
      Modify some of the pg_ctl and other command invocations to not use 'silent'
      or 'quiet' options, and don't redirect output to /dev/null, so that you get
      all the information in the log instead.
      
      In the passing, construct some command lines in a way that works if $tempdir
      contains quote-characters. I haven't systematically gone through all of
      them or tested that, so I don't know if this is enough to make that work.
      
      pg_rewind tests had a custom mechanism for creating a similar log file. Use
      the new generic facility instead.
      
      Michael Paquier and me.
      1ea06203
    • Heikki Linnakangas's avatar
      Use AS_IF rather than plain shell "if" in pthread-check. · 01051a98
      Heikki Linnakangas authored
      Autoconf generates additional code for the first AC_CHECK_HEADERS call in
      the script. If the first call is within an if-block, the additional code is
      put inside the if-block too, even though it is needed by subsequent
      AC_CHECK_HEADERS checks and should always be executed. When I moved the
      pthread-related checks earlier in the script, the pthread.h test inside
      the block became the very first AC_CHECK_HEADERS call in the script,
      triggering that problem.
      
      To fix, use AS_IF instead of plain shell if. AS_IF knows about that issue,
      and makes sure the additional code is always executed. To be completely
      safe from this issue (and others), we should always be using AS_IF instead
      of plain if, but that seems like excessive caution given that this is the
      first time we have trouble like this. Plain if-then is more readable than
      AS_IF.
      
      This should fix compilation with --disable-thread-safety, and hopefully the
      buildfarm failure on forgmouth, related to mingw standard headers, too.
      I backpatched the previous fixes to 9.5, but it's starting to look like
      these changes are too fiddly to backpatch, so commit this to master only,
      and revert all the pthread-related configure changes in 9.5.
      01051a98
    • Noah Misch's avatar
    • Noah Misch's avatar
      Link pg_stat_statements with libm. · 0689cfc3
      Noah Misch authored
      The AIX 7.1 libm is static, and AIX postgres executables do not export
      symbols acquired from libraries.  Back-patch to 9.5, where commit
      cfe12763 added a sqrt() call.
      0689cfc3
    • Noah Misch's avatar
      Given a gcc-compatible xlc compiler, prefer xlc-style atomics. · 1e700e0f
      Noah Misch authored
      This evades a ppc64le "IBM XL C/C++ for Linux" compiler bug.  Back-patch
      to 9.5, where the atomics facility was introduced.
      1e700e0f
    • Noah Misch's avatar
      Finish generic-xlc.h draft atomics implementation. · 0d32d2e6
      Noah Misch authored
      Back-patch to 9.5, where commit b64d92f1
      introduced this file.
      0d32d2e6
    • Noah Misch's avatar
      Revoke support for strxfrm() that write past the specified array length. · be8b06c3
      Noah Misch authored
      This formalizes a decision implicit in commit
      4ea51cdf and adds clean detection of
      affected systems.  Vendor updates are available for each such known bug.
      Back-patch to 9.5, where the aforementioned commit first appeared.
      be8b06c3
    • Noah Misch's avatar
      Replace use of "diff -q". · b28244ab
      Noah Misch authored
      POSIX does not specify the -q option, and many implementations do not
      offer it.  Don't bother changing the MSVC build system, because having
      non-GNU diff on Windows is vanishingly unlikely.  Back-patch to 9.2,
      where this invocation was introduced.
      b28244ab
    • Noah Misch's avatar
      Fix null pointer dereference in "\c" psql command. · e135c3d9
      Noah Misch authored
      The psql crash happened when no current connection existed.  (The second
      new check is optional given today's undocumented NULL argument handling
      in PQhost() etc.)  Back-patch to 9.0 (all supported versions).
      e135c3d9
  6. 08 Jul, 2015 2 commits
    • Heikki Linnakangas's avatar
      Move pthread-tests earlier in the autoconf script. · 3b14a17c
      Heikki Linnakangas authored
      On some Linux systems, "-lrt" exposed pthread-functions, so that linking
      with -lrt was seemingly enough to make a program that uses pthreads to
      work. However, when linking libpq, the dependency to libpthread was not
      marked correctly, so that when an executable was linked with -lpq but
      without -pthread, you got errors about undefined pthread_* functions from
      libpq.
      
      To fix, test for the flags required to use pthreads earlier in the autoconf
      script, before checking any other libraries.
      
      This should fix the failure on buildfarm member shearwater. gharial is also
      failing; hopefully this fixes that too although the failure looks somewhat
      different.
      3b14a17c
    • Heikki Linnakangas's avatar
      Replace our hacked version of ax_pthread.m4 with latest upstream version. · e97af6c8
      Heikki Linnakangas authored
      Our version was different from the upstream version in that we tried to use
      all possible pthread-related flags that the compiler accepts, rather than
      just the first one that works. That change was made in commit
      e48322a6, to work-around a bug affecting GCC
      versions 3.2 and below (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8888),
      although we didn't realize that it was a GCC bug at the time. We hardly care
      about that old GCC versions anymore, so we no longer need that workaround.
      
      This fixes the macro for compilers that print warnings with the chosen
      flags. That's pretty annoying on its own right, but it also inconspicuously
      disabled thread-safety, because we refused to use any pthread-related flags
      if the compiler produced warnings. Max Filippov reported that problem when
      linking with uClibc and OpenSSL. The warnings-check was added because the
      workaround for the GCC bug caused warnings otherwise, so it's no longer
      needed either. We can just use the upstream version as is.
      
      If you really want to compile with GCC version 3.2 or older, you can still
      work-around it manually by setting PTHREAD_CFLAGS="-pthread -lpthread"
      manually on the configure command line.
      
      Backpatch to 9.5. I don't want to unnecessarily rock the boat on stable
      branches, but 9.5 seems like fair game.
      e97af6c8
  7. 07 Jul, 2015 10 commits
    • Joe Conway's avatar
      Improve regression test coverage of table lock modes vs permissions. · e66a4534
      Joe Conway authored
      Test the interactions with permissions and LOCK TABLE. Specifically
      ROW EXCLUSIVE, ACCESS SHARE, and ACCESS EXCLUSIVE modes against
      SELECT, INSERT, UPDATE, DELETE, and TRUNCATE permissions. Discussed
      by Stephen Frost and Michael Paquier, patch by the latter. Backpatch
      to 9.5 where matching behavior was first committed.
      e66a4534
    • Fujii Masao's avatar
      Fix incorrect path in pg_regress log messages. · 61fc420b
      Fujii Masao authored
      Back-patch to 9.5 where the bug was introduced.
      
      David Christensen
      61fc420b
    • Tom Lane's avatar
      Fix portability issue in pg_upgrade test script: avoid $PWD. · 9a8f5833
      Tom Lane authored
      SUSv2-era shells don't set the PWD variable, though anything more modern
      does.  In the buildfarm environment this could lead to test.sh executing
      with PWD pointing to $HOME or another high-level directory, so that there
      were conflicts between concurrent executions of the test in different
      branch subdirectories.  This appears to be the explanation for recent
      intermittent failures on buildfarm members binturong and dingo (and might
      well have something to do with the buildfarm script's failure to capture
      log files from pg_upgrade tests, too).
      
      To fix, just use `pwd` in place of $PWD.  AFAICS test.sh is the only place
      in our source tree that depended on $PWD.  Back-patch to all versions
      containing this script.
      
      Per buildfarm.  Thanks to Oskari Saarenmaa for diagnosing the problem.
      9a8f5833
    • Heikki Linnakangas's avatar
      Improve handling of out-of-memory in libpq. · 414bef30
      Heikki Linnakangas authored
      If an allocation fails in the main message handling loop, pqParseInput3
      or pqParseInput2, it should not be treated as "not enough data available
      yet". Otherwise libpq will wait indefinitely for more data to arrive from
      the server, and gets stuck forever.
      
      This isn't a complete fix - getParamDescriptions and getCopyStart still
      have the same issue, but it's a step in the right direction.
      
      Michael Paquier and me. Backpatch to all supported versions.
      414bef30
    • Fujii Masao's avatar
      Add tab-completion for psql meta-commands. · c81c9564
      Fujii Masao authored
      Based on the original code from David Christensen, modified by me.
      c81c9564
    • Andres Freund's avatar
      Refer to %p in the psql docs as 'process ID' not 'pid'. · 4af04f96
      Andres Freund authored
      Per Tom.
      4af04f96
    • Andres Freund's avatar
      Add psql PROMPT variable showing the pid of the connected to backend. · 275f05c9
      Andres Freund authored
      The substitution for the pid is %p.
      
      Author: Julien Rouhaud
      Discussion: 116262CF971C844FB6E793F8809B51C6E99D48@BPXM02GP.gisp.nec.co.jp
      275f05c9
    • Andres Freund's avatar
      Fix logical decoding bug leading to inefficient reopening of files. · b2f6f749
      Andres Freund authored
      When spilling transaction data to disk a simple typo caused the output
      file to be closed and reopened for every serialized change. That happens
      to not have a huge impact on linux, which is why it probably wasn't
      noticed so far, but on windows that appears to trigger actual disk
      writes after every change. Not fun.
      
      The bug fortunately does not have any impact besides speed. A change
      could end up being in the wrong segment (last instead of next), but
      since we read all files to the end, that's just ugly, not really
      problematic. It's not a problem to upgrade, since transaction spill
      files do not persist across restarts.
      
      Bug: #13484
      Reported-By: Olivier Gosseaume
      Discussion: 20150703090217.1190.63940@wrigleys.postgresql.org
      
      Backpatch to 9.4, where logical decoding was added.
      b2f6f749
    • Andres Freund's avatar
      Fix pg_recvlogical not to fsync output when it's a tty or pipe. · 5c0de384
      Andres Freund authored
      The previous coding tried to handle possible failures when fsyncing a
      tty or pipe fd by accepting EINVAL - but apparently some
      platforms (windows, OSX) don't reliably return that. So instead check
      whether the output fd refers to a pipe or a tty when opening it.
      
      Reported-By: Olivier Gosseaume, Marko Tiikkaja
      Discussion: 559AF98B.3050901@joh.to
      
      Backpatch to 9.4, where pg_recvlogical was added.
      5c0de384
    • Joe Conway's avatar
      Make RLS related error messages more consistent and compliant. · 02eac01f
      Joe Conway authored
      Also updated regression expected output to match. Noted and patch by Daniele Varrazzo.
      02eac01f