1. 25 5月, 2015 4 次提交
    • T
      Manual cleanup of pgindent results. · 2aa0476d
      Tom Lane 提交于
      Fix some places where pgindent did silly stuff, often because project
      style wasn't followed to begin with.  (I've not touched the atomics
      headers, though.)
      2aa0476d
    • T
      Rename pg_shdepend.c's typedef "objectType" to SharedDependencyObjectType. · 17b48a1a
      Tom Lane 提交于
      The name objectType is widely used as a field name, and it's pure luck that
      this conflict has not caused pgindent to go crazy before.  It messed up
      pg_audit.c pretty good though.  Since pg_shdepend.c doesn't export this
      typedef and only uses it in three places, changing that seems saner than
      changing the field usages.
      
      Back-patch because we're contemplating using the union of all branch
      typedefs for future pgindent runs, so this won't fix anything if it
      stays the same in back branches.
      17b48a1a
    • T
      Add a bit more commentary about regex's colormap tree data structure. · 23116d54
      Tom Lane 提交于
      Per an off-list question from Piotr Stefaniak.
      23116d54
    • T
      Remove no-longer-required function declarations. · 91e79260
      Tom Lane 提交于
      Remove a bunch of "extern Datum foo(PG_FUNCTION_ARGS);" declarations that
      are no longer needed now that PG_FUNCTION_INFO_V1(foo) provides that.
      
      Some of these were evidently missed in commit e7128e8d, but others
      were cargo-culted in in code added since then.  Possibly that can be blamed
      in part on the fact that we'd not fixed relevant documentation examples,
      which I've now done.
      91e79260
  2. 24 5月, 2015 6 次提交
  3. 23 5月, 2015 3 次提交
    • A
      Fix yet another bug in ON CONFLICT rule deparsing. · 284bef29
      Andres Freund 提交于
      Expand testing of rule deparsing a good bit, it's evidently needed.
      
      Author: Peter Geoghegan, Andres Freund
      Discussion: CAM3SWZQmXxZhQC32QVEOTYfNXJBJ_Q2SDENL7BV14Cq-zL0FLg@mail.gmail.com
      284bef29
    • A
      Remove the new UPSERT command tag and use INSERT instead. · 631d7490
      Andres Freund 提交于
      Previously, INSERT with ON CONFLICT DO UPDATE specified used a new
      command tag -- UPSERT.  It was introduced out of concern that INSERT as
      a command tag would be a misrepresentation for ON CONFLICT DO UPDATE, as
      some affected rows may actually have been updated.
      
      Alvaro Herrera noticed that the implementation of that new command tag
      was incomplete; in subsequent discussion we concluded that having it
      doesn't provide benefits that are in line with the compatibility breaks
      it requires.
      
      Catversion bump due to the removal of PlannedStmt->isUpsert.
      
      Author: Peter Geoghegan
      Discussion: 20150520215816.GI5885@postgresql.org
      631d7490
    • T
      Fix recently-introduced crash in array_contain_compare(). · 49ad32d5
      Tom Lane 提交于
      Silly oversight in commit 1dc5ebc9:
      when array2 is an expanded array, it might have array2->xpn.dnulls equal
      to NULL, indicating the array is known null-free.  The code wasn't
      expecting that, because it formerly always used deconstruct_array() which
      always delivers a nulls array.
      
      Per bug #13334 from Regina Obe.
      49ad32d5
  4. 22 5月, 2015 5 次提交
    • A
      Unpack jbvBinary objects passed to pushJsonbValue · 5302760a
      Andrew Dunstan 提交于
      pushJsonbValue was accepting jbvBinary objects passed as WJB_ELEM or
      WJB_VALUE data. While this succeeded, when those objects were later
      encountered in attempting to convert the result to Jsonb, errors
      occurred. With this change we ghuarantee that a JSonbValue constructed
      from calls to pushJsonbValue does not contain any jbvBinary objects.
      This cures a problem observed with jsonb_delete.
      
      This means callers of pushJsonbValue no longer need to perform this
      unpacking themselves. A subsequent patch will perform some cleanup in
      that area.
      
      The error was not triggered by any 9.4 code, but this is a publicly
      visible routine, and so the error could be exercised by third party
      code, therefore backpatch to 9.4.
      
      Bug report from Peter Geoghegan, fix by me.
      5302760a
    • F
      Minor enhancement of readability of ALTER TABLE syntax in the doc. · 6d1733fa
      Fujii Masao 提交于
      Fabrízio Mello
      6d1733fa
    • H
      At promotion, don't leave behind a partial segment on the old timeline. · 7cbee7c0
      Heikki Linnakangas 提交于
      With commit de768844, a copy of the partial segment was archived with the
      .partial suffix, but the original file was still left in pg_xlog, so it
      didn't actually solve the problems with archiving the partial segment that
      it was supposed to solve. With this patch, the partial segment is renamed
      rather than copied, so we only archive it with the .partial suffix.
      
      Also be more robust in detecting if the last segment is already being
      archived. Previously I used XLogArchiveIsBusy() for that, but that's not
      quite right. With archive_mode='always', there might be a .ready file for
      it, and we don't want to rename it to .partial in that case.
      
      The old segment is needed until we're fully committed to the new timeline,
      i.e. until we've written the end-of-recovery WAL record and updated the
      min recovery point and timeline in the control file. So move the renaming
      later in the startup sequence, after all that's been done.
      7cbee7c0
    • T
      More fixes for lossy-GiST-distance-functions patch. · c5dd8ead
      Tom Lane 提交于
      Paul Ramsey reported that commit 35fcb1b3
      induced a core dump on commuted ORDER BY expressions, because it was
      assuming that the indexorderby expression could be found verbatim in the
      relevant equivalence class, but it wasn't there.  We really don't need
      anything that complicated anyway; for the data types likely to be used for
      index ORDER BY operators in the foreseeable future, the exprType() of the
      ORDER BY expression will serve fine.  (The case where we'd have to work
      harder is where the ORDER BY expression's result is only binary-compatible
      with the declared input type of the ordering operator; long before worrying
      about that, one would need to get rid of GiST's hard-wired assumption that
      said datatype is float8.)
      
      Aside from fixing that crash and adding a regression test for the case,
      I did some desultory code review:
      
      nodeIndexscan.c was likewise overthinking how hard it ought to work to
      identify the datatype of the ORDER BY expressions.
      
      Add comments explaining how come nodeIndexscan.c can get away with
      simplifying assumptions about NULLS LAST ordering and no backward scan.
      
      Revert no-longer-needed changes of find_ec_member_for_tle(); while the
      new definition was no worse than the old, it wasn't better either, and
      it might cause back-patching pain.
      
      Revert entirely bogus additions to genam.h.
      c5dd8ead
    • T
      Improve packing/alignment annotation for ItemPointerData. · d4b538ea
      Tom Lane 提交于
      We want this struct to be exactly a series of 3 int16 words, no more
      and no less.  Historically, at least, some ARM compilers preferred to
      pad it to 8 bytes unless coerced.  Our old way of doing that was just
      to use __attribute__((packed)), but as pointed out by Piotr Stefaniak,
      that does too much: it also licenses the compiler to give the struct
      only byte-alignment.  We don't want that because it adds access overhead,
      possibly quite significant overhead.  According to the GCC manual, what
      we want requires also specifying __attribute__((align(2))).  It's not
      entirely clear if all the relevant compilers accept this pragma as well,
      but we can hope the buildfarm will tell us if not.  We can also add a
      static assertion that should fire if the compiler padded the struct.
      
      Since the combination of these pragmas should define exactly what we
      want on any compiler that accepts them, let's try using them wherever
      we think they exist, not only for __arm__.  (This is likely to expose
      that the conditional definitions in c.h are inadequate, but finding
      that out would be a good thing.)
      
      The immediate motivation for this is that the current definition of
      ExecRowMark allows its curCtid field to be misaligned.  It is not clear
      whether there are any other uses of ItemPointerData with a similar hazard.
      We could change the definition of ExecRowMark if this doesn't work, but
      it would be far better to have a future-proof fix.
      
      Piotr Stefaniak, some further hacking by me
      d4b538ea
  5. 21 5月, 2015 5 次提交
  6. 20 5月, 2015 7 次提交
    • H
      Collection of typo fixes. · 4fc72cc7
      Heikki Linnakangas 提交于
      Use "a" and "an" correctly, mostly in comments. Two error messages were
      also fixed (they were just elogs, so no translation work required). Two
      function comments in pg_proc.h were also fixed. Etsuro Fujita reported one
      of these, but I found a lot more with grep.
      
      Also fix a few other typos spotted while grepping for the a/an typos.
      For example, "consists out of ..." -> "consists of ...". Plus a "though"/
      "through" mixup reported by Euler Taveira.
      
      Many of these typos were in old code, which would be nice to backpatch to
      make future backpatching easier. But much of the code was new, and I didn't
      feel like crafting separate patches for each branch. So no backpatching.
      4fc72cc7
    • S
      Fix spelling in comment · f6a54fef
      Simon Riggs 提交于
      f6a54fef
    • T
      Last-minute updates for release notes. · 5cb8519c
      Tom Lane 提交于
      Revise description of CVE-2015-3166, in line with scaled-back patch.
      Change release date.
      
      Security: CVE-2015-3166
      5cb8519c
    • T
      Revert error-throwing wrappers for the printf family of functions. · 0c071936
      Tom Lane 提交于
      This reverts commit 16304a01, except
      for its changes in src/port/snprintf.c; as well as commit
      cac18a76 which is no longer needed.
      
      Fujii Masao reported that the previous commit caused failures in psql on
      OS X, since if one exits the pager program early while viewing a query
      result, psql sees an EPIPE error from fprintf --- and the wrapper function
      thought that was reason to panic.  (It's a bit surprising that the same
      does not happen on Linux.)  Further discussion among the security list
      concluded that the risk of other such failures was far too great, and
      that the one-size-fits-all approach to error handling embodied in the
      previous patch is unlikely to be workable.
      
      This leaves us again exposed to the possibility of the type of failure
      envisioned in CVE-2015-3166.  However, that failure mode is strictly
      hypothetical at this point: there is no concrete reason to believe that
      an attacker could trigger information disclosure through the supposed
      mechanism.  In the first place, the attack surface is fairly limited,
      since so much of what the backend does with format strings goes through
      stringinfo.c or psprintf(), and those already had adequate defenses.
      In the second place, even granting that an unprivileged attacker could
      control the occurrence of ENOMEM with some precision, it's a stretch to
      believe that he could induce it just where the target buffer contains some
      valuable information.  So we concluded that the risk of non-hypothetical
      problems induced by the patch greatly outweighs the security risks.
      We will therefore revert, and instead undertake closer analysis to
      identify specific calls that may need hardening, rather than attempt a
      universal solution.
      
      We have kept the portion of the previous patch that improved snprintf.c's
      handling of errors when it calls the platform's sprintf().  That seems to
      be an unalloyed improvement.
      
      Security: CVE-2015-3166
      0c071936
    • A
      Various fixes around ON CONFLICT for rule deparsing. · 9bc77c45
      Andres Freund 提交于
      Neither the deparsing of the new alias for INSERT's target table, nor of
      the inference clause was supported. Also fixup a typo in an error
      message.
      
      Add regression tests to test those code paths.
      
      Author: Peter Geoghegan
      9bc77c45
    • 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
  7. 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