1. 01 Aug, 2015 1 commit
    • Tom Lane's avatar
      Teach predtest.c that "foo" implies "foo IS NOT NULL". · dea1491f
      Tom Lane authored
      Per complaint from Peter Holzer.  It's useful to cover this special case,
      since for a boolean variable "foo", earlier parts of the planner will have
      reduced variants like "foo = true" to just "foo", and thus we may fail
      to recognize the applicability of a partial index with predicate
      "foo IS NOT NULL".
      
      Back-patch to 9.5, but not further; given the lack of previous complaints
      this doesn't seem like behavior to change in stable branches.
      dea1491f
  2. 31 Jul, 2015 3 commits
    • Tom Lane's avatar
      Fix an oversight in checking whether a join with LATERAL refs is legal. · a6492ff8
      Tom Lane authored
      In many cases, we can implement a semijoin as a plain innerjoin by first
      passing the righthand-side relation through a unique-ification step.
      However, one of the cases where this does NOT work is where the RHS has
      a LATERAL reference to the LHS; that makes the RHS dependent on the LHS
      so that unique-ification is meaningless.  joinpath.c understood this,
      and so would not generate any join paths of this kind ... but join_is_legal
      neglected to check for the case, so it would think that we could do it.
      The upshot would be a "could not devise a query plan for the given query"
      failure once we had failed to generate any join paths at all for the bogus
      join pair.
      
      Back-patch to 9.3 where LATERAL was added.
      a6492ff8
    • Noah Misch's avatar
      Clean up Makefile.win32 "-I" flag additions. · 16c4e6d8
      Noah Misch authored
      The PGXS-case directory does not exist in the non-PGXS case, and vice
      versa.  Add one or the other, not both.  This is essentially cosmetic.
      It makes Makefile.win32 more like the similar Makefile.global code.
      16c4e6d8
    • Noah Misch's avatar
      Consolidate makefile code for setting top_srcdir, srcdir and VPATH. · 5da944fb
      Noah Misch authored
      Responsibility was formerly split between Makefile.global and pgxs.mk.
      As a result of commit b58233c7, in the
      PGXS case, these variables were unset while parsing Makefile.global and
      callees.  Inclusion of Makefile.custom did not work from PGXS, and the
      subtle difference seemed like a recipe for future bugs.  Back-patch to
      9.4, where that commit first appeared.
      5da944fb
  3. 30 Jul, 2015 13 commits
    • Alvaro Herrera's avatar
      Fix volatility marking of commit timestamp functions · e8e86fbc
      Alvaro Herrera authored
      They are marked stable, but since they act on instantaneous state and it
      is possible to consult state of transactions as they commit, the results
      could change mid-query.  They need to be marked volatile, and this
      commit does so.
      
      There would normally be a catversion bump here, but this is so much a
      niche feature and I don't believe there's real damage from the incorrect
      marking, that I refrained.
      
      Backpatch to 9.5, where commit timestamps where introduced.
      
      Per note from Fujii Masao.
      e8e86fbc
    • Alvaro Herrera's avatar
      Fix broken assertion in BRIN code · c8127624
      Alvaro Herrera authored
      The code was assuming that any NULL value in scan keys was due to IS
      NULL or IS NOT NULL, but it turns out to be possible to get them with
      other operators too, if they are used in contrived-enough ways.  Easiest
      way out of the problem seems to check explicitely for the IS NOT NULL
      flag, instead of assuming it must be set if the IS NULL flag is not set,
      when a null scan key is found; if neither flag is set, follow the lead
      of other index AMs and assume that all indexable operators must be
      strict, and thus the query is never satisfiable.
      
      Also, add a comment to try and lure some future hacker into improving
      analysis of scan keys in brin.
      
      Per report from Andreas Seltenreich; diagnosis by Tom Lane.
      Backpatch to 9.5.
      
      Discussion: http://www.postgresql.org/message-id/20646.1437919632@sss.pgh.pa.us
      c8127624
    • Joe Conway's avatar
      Improve CREATE FUNCTION doc WRT to LEAKPROOF RLS interaction. · d6314b20
      Joe Conway authored
      Patch by Dean Rasheed. Back-patched to 9.5 where RLS was introduced.
      d6314b20
    • Joe Conway's avatar
      Use appropriate command type when retrieving relation's policies. · 1e15b212
      Joe Conway authored
      When retrieving policies, if not working on the root target relation,
      we actually want the relation's SELECT policies, regardless of
      the top level query command type. For example in UPDATE t1...FROM t2
      we need to apply t1's UPDATE policies and t2's SELECT policies.
      Previously top level query command type was applied to all relations,
      which was wrong. Add some regression coverage to ensure we don't
      violate this principle in the future.
      
      Report and patch by Dean Rasheed. Cherry picked from larger refactoring
      patch and tweaked by me. Back-patched to 9.5 where RLS was introduced.
      1e15b212
    • Tom Lane's avatar
      Avoid some zero-divide hazards in the planner. · 8693ebe3
      Tom Lane authored
      Although I think on all modern machines floating division by zero
      results in Infinity not SIGFPE, we still don't want infinities
      running around in the planner's costing estimates; too much risk
      of that leading to insane behavior.
      
      grouping_planner() failed to consider the possibility that final_rel
      might be known dummy and hence have zero rowcount.  (I wonder if it
      would be better to set a rows estimate of 1 for dummy relations?
      But at least in the back branches, changing this convention seems
      like a bad idea, so I'll leave that for another day.)
      
      Make certain that get_variable_numdistinct() produces a nonzero result.
      The case that can be shown to be broken is with stadistinct < 0.0 and
      small ntuples; we did not prevent the result from rounding to zero.
      For good luck I applied clamp_row_est() to all the nonconstant return
      values.
      
      In ExecChooseHashTableSize(), Assert that we compute positive nbuckets
      and nbatch.  I know of no reason to think this isn't the case, but it
      seems like a good safety check.
      
      Per reports from Piotr Stefaniak.  Back-patch to all active branches.
      8693ebe3
    • Heikki Linnakangas's avatar
      Fix calculation of latency of pgbench backslash commands. · 5515ec0b
      Heikki Linnakangas authored
      When we loop back to the top of doCustom after processing a backslash
      command, we must reset the "now" timestamp, because that's used to
      calculate the time spent executing the previous command.
      
      Report and fix by Fabien Coelho. Backpatch to 9.5, where this was broken.
      5515ec0b
    • Heikki Linnakangas's avatar
      Update ax_pthread.m4 to an experimental draft version from upstream. · a2932283
      Heikki Linnakangas authored
      The current version is adding a spurious -pthread option on some Darwin
      systems that don't need it, which leads to a bunch of "unrecognized option
      '-pthread'" warnings. There is a proposed fix for that in the upstream
      autoconf archive's bug tracker, see https://savannah.gnu.org/patch/?8186.
      This commit updates our version of ax_pthread.m4 to the "draft2" version
      proposed there by Daniel Richard G. I'm using our buildfarm to help Daniel
      to test this, before he commits this to the upstream repository.
      a2932283
    • Noah Misch's avatar
      Blacklist xlc 32-bit inlining. · c53f7387
      Noah Misch authored
      Per a suggestion from Tom Lane.  Back-patch to 9.0 (all supported
      versions).  While only 9.4 and up have code known to elicit this
      compiler bug, we were disabling inlining by accident until commit
      43d89a23.
      c53f7387
    • Noah Misch's avatar
      Remove redundant "make install" from pg_upgrade test suite. · 021a5698
      Noah Misch authored
      A top-level "make install" includes pg_upgrade since commit
      9fa8b0ee.  Back-patch to 9.5, where that
      commit first appeared.
      021a5698
    • Noah Misch's avatar
      MSVC: Revert most 9.5 changes to pre-9.5 vcregress.pl tests. · e6ea46c3
      Noah Misch authored
      The reverted changes did not narrow the semantic gap between the MSVC
      build system and the GNU make build system.  For targets old and new
      that run multiple suites (contribcheck, modulescheck, tapcheck), restore
      vcregress.pl to mimicking "make -k" rather than the "make -S" default.
      Lack of "-k" would be more burdensome than lack of "-S".  Keep changes
      reflecting contemporary changes to the GNU make build system, and keep
      updates to Makefile parsing.  Keep the loss of --psqldir in "check" and
      "ecpgcheck" targets; it had been a no-op when used alongside
      --temp-install.  No log message mentioned any of the reverted changes.
      Based on a germ by Michael Paquier.  Back-patch to 9.5.
      e6ea46c3
    • Noah Misch's avatar
      MSVC: Remove duplicate PATH entry in test harness. · d6ab1467
      Noah Misch authored
      Back-patch to 9.5, where commit 4cb7d671
      introduced it.
      d6ab1467
    • Noah Misch's avatar
      MSVC: Future-proof installation file skip logic. · d6925228
      Noah Misch authored
      This code relied on knowing exactly where in the source tree temporary
      installations might appear.  A reasonable hacker may not think to update
      this code when adding use of a temporary installation, making it
      fragile.  Observe that commit 9fa8b0ee
      broke it unnoticed, and commit dcae5fac
      fixed it unnoticed.  Back-patch to 9.5 only; use of temporary
      installations is unlikely to change in released versions.
      d6925228
    • Andrew Dunstan's avatar
      Add IF NOT EXISTS processing to ALTER TABLE ADD COLUMN · 2cd40adb
      Andrew Dunstan authored
      Fabrízio de Royes Mello, reviewed by Payal Singh, Alvaro Herrera and
      Michael Paquier.
      2cd40adb
  4. 29 Jul, 2015 14 commits
  5. 28 Jul, 2015 9 commits
    • Tom Lane's avatar
      Suppress "variable may be used uninitialized" warning. · 2c698f43
      Tom Lane authored
      Also re-pgindent, just because I'm a neatnik.
      2c698f43
    • Joe Conway's avatar
      Disallow converting a table to a view if row security is present. · d824e280
      Joe Conway authored
      When DefineQueryRewrite() is about to convert a table to a view, it checks
      the table for features unavailable to views.  For example, it rejects tables
      having triggers.  It omits to reject tables having relrowsecurity or a
      pg_policy record. Fix that. To faciliate the repair, invent
      relation_has_policies() which indicates the presence of policies on a
      relation even when row security is disabled for that relation.
      
      Reported by Noah Misch. Patch by me, review by Stephen Frost. Back-patch
      to 9.5 where RLS was introduced.
      d824e280
    • Joe Conway's avatar
      Create a pg_shdepend entry for each role in TO clause of policies. · f781a0f1
      Joe Conway authored
      CreatePolicy() and AlterPolicy() omit to create a pg_shdepend entry for
      each role in the TO clause. Fix this by creating a new shared dependency
      type called SHARED_DEPENDENCY_POLICY and assigning it to each role.
      
      Reported by Noah Misch. Patch by me, reviewed by Alvaro Herrera.
      Back-patch to 9.5 where RLS was introduced.
      f781a0f1
    • Tom Lane's avatar
      Update our documentation concerning where to create data directories. · 8c72a7fa
      Tom Lane authored
      Although initdb has long discouraged use of a filesystem mount-point
      directory as a PG data directory, this point was covered nowhere in the
      user-facing documentation.  Also, with the popularity of pg_upgrade,
      we really need to recommend that the PG user own not only the data
      directory but its parent directory too.  (Without a writable parent
      directory, operations such as "mv data data.old" fail immediately.
      pg_upgrade itself doesn't do that, but wrapper scripts for it often do.)
      
      Hence, adjust the "Creating a Database Cluster" section to address
      these points.  I also took the liberty of wordsmithing the discussion
      of NFS a bit.
      
      These considerations aren't by any means new, so back-patch to all
      supported branches.
      8c72a7fa
    • Andrew Dunstan's avatar
      Only adjust negative indexes in json_get up to the length of the path. · 6d10f4e9
      Andrew Dunstan authored
      The previous code resulted in memory access beyond the path bounds. The
      cure is to move it into a code branch that checks the value of lex_level
      is within the correct bounds.
      
      Bug reported and diagnosed by Piotr Stefaniak.
      6d10f4e9
    • Tom Lane's avatar
      Reduce chatter from signaling of autovacuum workers. · d8f15c95
      Tom Lane authored
      Don't print a WARNING if we get ESRCH from a kill() that's attempting
      to cancel an autovacuum worker.  It's possible (and has been seen in the
      buildfarm) that the worker is already gone by the time we are able to
      execute the kill, in which case the failure is harmless.  About the only
      plausible reason for reporting such cases would be to help debug corrupted
      lock table contents, but this is hardly likely to be the most important
      symptom if that happens.  Moreover issuing a WARNING might scare users
      more than is warranted.
      
      Also, since sending a signal to an autovacuum worker is now entirely a
      routine thing, and the worker will log the query cancel on its end anyway,
      reduce the message saying we're doing that from LOG to DEBUG1 level.
      
      Very minor cosmetic cleanup as well.
      
      Since the main practical reason for doing this is to avoid unnecessary
      buildfarm failures, back-patch to all active branches.
      d8f15c95
    • Joe Conway's avatar
      Bump catversion so that HEAD is beyond 9.5 · 1e2bd43b
      Joe Conway authored
      As pointed out by Tom, since HEAD has progressed beyond 9.5 in terms of
      its catalog, we need to be sure catversion of HEAD is advanced beyond
      that of 9.5. Corrects my mistake in the pg_stats view commit cfa928ff.
      1e2bd43b
    • Joe Conway's avatar
      Plug RLS related information leak in pg_stats view. · 7b4bfc87
      Joe Conway authored
      The pg_stats view is supposed to be restricted to only show rows
      about tables the user can read. However, it sometimes can leak
      information which could not otherwise be seen when row level security
      is enabled. Fix that by not showing pg_stats rows to users that would
      be subject to RLS on the table the row is related to. This is done
      by creating/using the newly introduced SQL visible function,
      row_security_active().
      
      Along the way, clean up three call sites of check_enable_rls(). The second
      argument of that function should only be specified as other than
      InvalidOid when we are checking as a different user than the current one,
      as in when querying through a view. These sites were passing GetUserId()
      instead of InvalidOid, which can cause the function to return incorrect
      results if the current user has the BYPASSRLS privilege and row_security
      has been set to OFF.
      
      Additionally fix a bug causing RI Trigger error messages to unintentionally
      leak information when RLS is enabled, and other minor cleanup and
      improvements. Also add WITH (security_barrier) to the definition of pg_stats.
      
      Bumped CATVERSION due to new SQL functions and pg_stats view definition.
      
      Back-patch to 9.5 where RLS was introduced. Reported by Yaroslav.
      Patch by Joe Conway and Dean Rasheed with review and input by
      Michael Paquier and Stephen Frost.
      7b4bfc87
    • Andres Freund's avatar
      Remove ssl renegotiation support. · 426746b9
      Andres Freund authored
      While postgres' use of SSL renegotiation is a good idea in theory, it
      turned out to not work well in practice. The specification and openssl's
      implementation of it have lead to several security issues. Postgres' use
      of renegotiation also had its share of bugs.
      
      Additionally OpenSSL has a bunch of bugs around renegotiation, reported
      and open for years, that regularly lead to connections breaking with
      obscure error messages. We tried increasingly complex workarounds to get
      around these bugs, but we didn't find anything complete.
      
      Since these connection breakages often lead to hard to debug problems,
      e.g. spuriously failing base backups and significant latency spikes when
      synchronous replication is used, we have decided to change the default
      setting for ssl renegotiation to 0 (disabled) in the released
      backbranches and remove it entirely in 9.5 and master.
      
      Author: Andres Freund
      Discussion: 20150624144148.GQ4797@alap3.anarazel.de
      Backpatch: 9.5 and master, 9.0-9.4 get a different patch
      426746b9