1. 20 5月, 2015 2 次提交
    • A
      Refactor ON CONFLICT index inference parse tree representation. · 0740cbd7
      Andres Freund 提交于
      Defer lookup of opfamily and input type of a of a user specified opclass
      until the optimizer selects among available unique indexes; and store
      the opclass in the parse analyzed tree instead.  The primary reason for
      doing this is that for rule deparsing it's easier to use the opclass
      than the previous representation.
      
      While at it also rename a variable in the inference code to better fit
      it's purpose.
      
      This is separate from the actual fixes for deparsing to make review
      easier.
      0740cbd7
    • H
      Fix off-by-one error in Assertion. · b48437d1
      Heikki Linnakangas 提交于
      The point of the assertion is to ensure that the arrays allocated in stack
      are large enough, but the check was one item short.
      
      This won't matter in practice because MaxIndexTuplesPerPage is an
      overestimate, so you can't have that many items on a page in reality.
      But let's be tidy.
      
      Spotted by Anastasia Lubennikova. Backpatch to all supported versions, like
      the patch that added the assertion.
      b48437d1
  2. 19 5月, 2015 10 次提交
    • T
      Avoid collation dependence in indexes of system catalogs. · 0b28ea79
      Tom Lane 提交于
      No index in template0 should have collation-dependent ordering, especially
      not indexes on shared catalogs.  For most textual columns we avoid this
      issue by using type "name" (which sorts per strcmp()).  However there are a
      few indexed columns that we'd prefer to use "text" for, and for that, the
      default opclass text_ops is unsafe.  Fortunately, text_pattern_ops is safe
      (it sorts per memcmp()), and it has no real functional disadvantage for our
      purposes.  So change the indexes on pg_seclabel.provider and
      pg_shseclabel.provider to use text_pattern_ops.
      
      In passing, also mark pg_replication_origin.roname as using
      text_pattern_ops --- for some reason it was labeled varchar_pattern_ops
      which is just wrong, even though it accidentally worked.
      
      Add regression test queries to catch future errors of these kinds.
      
      We still can't do anything about the misdeclared pg_seclabel and
      pg_shseclabel indexes in back branches :-(
      0b28ea79
    • T
      Revert "Change pg_seclabel.provider and pg_shseclabel.provider to type "name"." · afee0435
      Tom Lane 提交于
      This reverts commit b82a7be6.  There
      is a better (less invasive) way to fix it, which I will commit next.
      afee0435
    • P
      Message string improvements · 55c0da38
      Peter Eisentraut 提交于
      55c0da38
    • P
      Fix parse tree of DROP TRANSFORM and COMMENT ON TRANSFORM · 0779f2ba
      Peter Eisentraut 提交于
      The plain C string language name needs to be wrapped in makeString() so
      that the parse tree is copyable.  This is detectable by
      -DCOPY_PARSE_PLAN_TREES.  Add a test case for the COMMENT case.
      
      Also make the quoting in the error messages more consistent.
      
      discovered by Tom Lane
      0779f2ba
    • T
      Change pg_seclabel.provider and pg_shseclabel.provider to type "name". · b82a7be6
      Tom Lane 提交于
      These were "text", but that's a bad idea because it has collation-dependent
      ordering.  No index in template0 should have collation-dependent ordering,
      especially not indexes on shared catalogs.  There was general agreement
      that provider names don't need to be longer than other identifiers, so we
      can fix this at a small waste of table space by changing from text to name.
      
      There's no way to fix the problem in the back branches, but we can hope
      that security labels don't yet have widespread-enough usage to make it
      urgent to fix.
      
      There needs to be a regression sanity test to prevent us from making this
      same mistake again; but before putting that in, we'll need to get rid of
      similar brain fade in the recently-added pg_replication_origin catalog.
      
      Note: for lack of a suitable testing environment, I've not really exercised
      this change.  I trust the buildfarm will show up any mistakes.
      b82a7be6
    • A
      Attach ON CONFLICT SET ... WHERE to the correct planstate. · e4942f7a
      Andres Freund 提交于
      The previous coding was a leftover from attempting to hang all the on
      conflict logic onto modify table's child nodes. It appears to not have
      actually caused problems except for explain.
      
      Add test exercising the broken and some other code paths.
      
      Author: Peter Geoghegan and Andres Freund
      e4942f7a
    • T
      Put back a backwards-compatible version of sampling support functions. · 4db485e7
      Tom Lane 提交于
      Commit 83e176ec removed the longstanding
      support functions for block sampling without any consideration of the
      impact this would have on third-party FDWs.  The new API is not notably
      more functional for FDWs than the old, so forcing them to change doesn't
      seem like a good thing.  We can provide the old API as a wrapper (more
      or less) around the new one for a minimal amount of extra code.
      4db485e7
    • T
      Recognize "REGRESS_OPTS += ..." syntax in MSVC build scripts. · f5916bb7
      Tom Lane 提交于
      Necessitated by commit b14cf229.
      Per buildfarm.
      f5916bb7
    • R
      Fix error message in pre_sync_fname. · 922de19e
      Robert Haas 提交于
      The old one didn't include %m anywhere, and required extra
      translation.
      
      Report by Peter Eisentraut. Fix by me. Review by Tom Lane.
      922de19e
    • T
      Last-minute updates for release notes. · 19d47ed2
      Tom Lane 提交于
      Add entries for security issues.
      
      Security: CVE-2015-3165 through CVE-2015-3167
      19d47ed2
  3. 18 5月, 2015 13 次提交
    • N
      pgcrypto: Report errant decryption as "Wrong key or corrupt data". · 85270ac7
      Noah Misch 提交于
      This has been the predominant outcome.  When the output of decrypting
      with a wrong key coincidentally resembled an OpenPGP packet header,
      pgcrypto could instead report "Corrupt data", "Not text data" or
      "Unsupported compression algorithm".  The distinct "Corrupt data"
      message added no value.  The latter two error messages misled when the
      decrypted payload also exhibited fundamental integrity problems.  Worse,
      error message variance in other systems has enabled cryptologic attacks;
      see RFC 4880 section "14. Security Considerations".  Whether these
      pgcrypto behaviors are likewise exploitable is unknown.
      
      In passing, document that pgcrypto does not resist side-channel attacks.
      Back-patch to 9.0 (all supported versions).
      
      Security: CVE-2015-3167
      85270ac7
    • N
      Check return values of sensitive system library calls. · fd97bd41
      Noah Misch 提交于
      PostgreSQL already checked the vast majority of these, missing this
      handful that nearly cannot fail.  If putenv() failed with ENOMEM in
      pg_GSS_recvauth(), authentication would proceed with the wrong keytab
      file.  If strftime() returned zero in cache_locale_time(), using the
      unspecified buffer contents could lead to information exposure or a
      crash.  Back-patch to 9.0 (all supported versions).
      
      Other unchecked calls to these functions, especially those in frontend
      code, pose negligible security concern.  This patch does not address
      them.  Nonetheless, it is always better to check return values whose
      specification provides for indicating an error.
      
      In passing, fix an off-by-one error in strftime_win32()'s invocation of
      WideCharToMultiByte().  Upon retrieving a value of exactly MAX_L10N_DATA
      bytes, strftime_win32() would overrun the caller's buffer by one byte.
      MAX_L10N_DATA is chosen to exceed the length of every possible value, so
      the vulnerable scenario probably does not arise.
      
      Security: CVE-2015-3166
      fd97bd41
    • N
      Add error-throwing wrappers for the printf family of functions. · 16304a01
      Noah Misch 提交于
      All known standard library implementations of these functions can fail
      with ENOMEM.  A caller neglecting to check for failure would experience
      missing output, information exposure, or a crash.  Check return values
      within wrappers and code, currently just snprintf.c, that bypasses the
      wrappers.  The wrappers do not return after an error, so their callers
      need not check.  Back-patch to 9.0 (all supported versions).
      
      Popular free software standard library implementations do take pains to
      bypass malloc() in simple cases, but they risk ENOMEM for floating point
      numbers, positional arguments, large field widths, and large precisions.
      No specification demands such caution, so this commit regards every call
      to a printf family function as a potential threat.
      
      Injecting the wrappers implicitly is a compromise between patch scope
      and design goals.  I would prefer to edit each call site to name a
      wrapper explicitly.  libpq and the ECPG libraries would, ideally, convey
      errors to the caller rather than abort().  All that would be painfully
      invasive for a back-patched security fix, hence this compromise.
      
      Security: CVE-2015-3166
      16304a01
    • N
      Permit use of vsprintf() in PostgreSQL code. · cac18a76
      Noah Misch 提交于
      The next commit needs it.  Back-patch to 9.0 (all supported versions).
      cac18a76
    • N
      Prevent a double free by not reentering be_tls_close(). · b0ce3850
      Noah Misch 提交于
      Reentering this function with the right timing caused a double free,
      typically crashing the backend.  By synchronizing a disconnection with
      the authentication timeout, an unauthenticated attacker could achieve
      this somewhat consistently.  Call be_tls_close() solely from within
      proc_exit_prepare().  Back-patch to 9.0 (all supported versions).
      
      Benkocs Norbert Attila
      
      Security: CVE-2015-3165
      b0ce3850
    • H
      Fix typo in comment. · 8cc7a4c5
      Heikki Linnakangas 提交于
      Jim Nasby
      8cc7a4c5
    • H
      Put back stats-collector restarting code, removed accidentally. · 4df13289
      Heikki Linnakangas 提交于
      Removed that code snippet accidentally in the archive_mode='always' patch.
      
      Also, use varname-tags for archive_command in the docs.
      
      Fujii Masao
      4df13289
    • F
      Don't classify REINDEX command as DDL in the pg_audit doc. · d773b557
      Fujii Masao 提交于
      The commit a936743b changed the class of REINDEX but forgot to update the doc.
      d773b557
    • P
      Add new files to nls.mk · 382b479a
      Peter Eisentraut 提交于
      382b479a
    • T
      Fix failure to copy IndexScan.indexorderbyops in copyfuncs.c. · 42466191
      Tom Lane 提交于
      This oversight results in a crash at executor startup if the plan has
      been copied.  outfuncs.c was missed as well.
      
      While we could probably have taught both those files to cope with the
      originally chosen representation of an Oid array, it would have been
      painful, not least because there'd be no easy way to verify the array
      length.  An Oid List is far easier to work with.  And AFAICS, there is
      no particular notational benefit to using an array rather than a list
      in the existing parts of the patch either.  So just change it to a list.
      
      Error in commit 35fcb1b3, which is new,
      so no need for back-patch.
      42466191
    • T
      Use += not = to set makefile variables after including base makefiles. · b14cf229
      Tom Lane 提交于
      The previous coding in hstore_plpython and ltree_plpython wiped out any
      values set by the base makefiles.  This at least had the effect of running
      the tests in "regression" not "contrib_regression" as expected.  These
      being pretty new modules, there might be other bad effects we'd not
      noticed yet.
      b14cf229
    • T
      Release notes for 9.4.2, 9.3.7, 9.2.11, 9.1.16, 9.0.20. · a0891d2d
      Tom Lane 提交于
      a0891d2d
    • M
      Fix wording error caused by recent typo fixes · de6109b8
      Magnus Hagander 提交于
      It wasn't just a typo, but bad wording. This should make it
      more clear. Pointed out by Tom Lane.
      de6109b8
  4. 17 5月, 2015 8 次提交
  5. 16 5月, 2015 7 次提交
    • T
      More portability fixing for bipartite_match.c. · 26058bf0
      Tom Lane 提交于
      <float.h> is required for isinf() on some platforms.  Per buildfarm.
      26058bf0
    • B
      pg_upgrade: force timeline 1 in the new cluster · 4c5e0600
      Bruce Momjian 提交于
      Previously, this prevented promoted standby servers from being upgraded
      because of a missing WAL history file.  (Timeline 1 doesn't need a
      history file, and we don't copy WAL files anyway.)
      
      Report by Christian Echerer(?), Alexey Klyukin
      
      Backpatch through 9.0
      4c5e0600
    • B
      pg_upgrade: only allow template0 to be non-connectable · fb694d95
      Bruce Momjian 提交于
      This patch causes pg_upgrade to error out during its check phase if:
      
      (1) template0 is marked connectable
      or
      (2) any other database is marked non-connectable
      
      This is done because, in the first case, pg_upgrade would fail because
      the pg_dumpall --globals restore would fail, and in the second case, the
      database would not be restored, leading to data loss.
      
      Report by Matt Landry (1), Stephen Frost (2)
      
      Backpatch through 9.0
      fb694d95
    • T
      Avoid direct use of INFINITY. · 12cc299c
      Tom Lane 提交于
      It's not very portable.  Per buildfarm.
      12cc299c
    • S
      Add docs for tablesample system_time() · f941d033
      Simon Riggs 提交于
      f941d033
    • A
      Support GROUPING SETS, CUBE and ROLLUP. · f3d31185
      Andres Freund 提交于
      This SQL standard functionality allows to aggregate data by different
      GROUP BY clauses at once. Each grouping set returns rows with columns
      grouped by in other sets set to NULL.
      
      This could previously be achieved by doing each grouping as a separate
      query, conjoined by UNION ALLs. Besides being considerably more concise,
      grouping sets will in many cases be faster, requiring only one scan over
      the underlying data.
      
      The current implementation of grouping sets only supports using sorting
      for input. Individual sets that share a sort order are computed in one
      pass. If there are sets that don't share a sort order, additional sort &
      aggregation steps are performed. These additional passes are sourced by
      the previous sort step; thus avoiding repeated scans of the source data.
      
      The code is structured in a way that adding support for purely using
      hash aggregation or a mix of hashing and sorting is possible. Sorting
      was chosen to be supported first, as it is the most generic method of
      implementation.
      
      Instead of, as in an earlier versions of the patch, representing the
      chain of sort and aggregation steps as full blown planner and executor
      nodes, all but the first sort are performed inside the aggregation node
      itself. This avoids the need to do some unusual gymnastics to handle
      having to return aggregated and non-aggregated tuples from underlying
      nodes, as well as having to shut down underlying nodes early to limit
      memory usage.  The optimizer still builds Sort/Agg node to describe each
      phase, but they're not part of the plan tree, but instead additional
      data for the aggregation node. They're a convenient and preexisting way
      to describe aggregation and sorting.  The first (and possibly only) sort
      step is still performed as a separate execution step. That retains
      similarity with existing group by plans, makes rescans fairly simple,
      avoids very deep plans (leading to slow explains) and easily allows to
      avoid the sorting step if the underlying data is sorted by other means.
      
      A somewhat ugly side of this patch is having to deal with a grammar
      ambiguity between the new CUBE keyword and the cube extension/functions
      named cube (and rollup). To avoid breaking existing deployments of the
      cube extension it has not been renamed, neither has cube been made a
      reserved keyword. Instead precedence hacking is used to make GROUP BY
      cube(..) refer to the CUBE grouping sets feature, and not the function
      cube(). To actually group by a function cube(), unlikely as that might
      be, the function name has to be quoted.
      
      Needs a catversion bump because stored rules may change.
      
      Author: Andrew Gierth and Atri Sharma, with contributions from Andres Freund
      Reviewed-By: Andres Freund, Noah Misch, Tom Lane, Svenne Krap, Tomas
          Vondra, Erik Rijkers, Marti Raudsepp, Pavel Stehule
      Discussion: CAOeZVidmVRe2jU6aMk_5qkxnB7dfmPROzM7Ur8JPW5j8Y5X-Lw@mail.gmail.com
      f3d31185
    • S
      Add docs for tablesample system_rows() · 6e4415c6
      Simon Riggs 提交于
      6e4415c6