1. 24 Nov, 2017 8 commits
  2. 23 Nov, 2017 4 commits
  3. 22 Nov, 2017 6 commits
  4. 21 Nov, 2017 5 commits
    • Tom Lane's avatar
      pgbench: fix stats reporting when some transactions are skipped. · 16827d44
      Tom Lane authored
      pgbench can skip some transactions when both -R and -L options are used.
      Previously, this resulted in slightly silly statistics both in progress
      reports and final output, because the skipped transactions were counted
      as executed for TPS and related stats.  Discount skipped xacts in TPS
      numbers, and also when figuring the percentage of xacts exceeding the
      latency limit.
      
      Also, don't print per-script skipped-transaction counts when there is
      only one script.  That's redundant with the overall count, and it's
      inconsistent with the fact that we don't print other per-script stats
      when there's only one script.  Clean up some unnecessary interactions
      between what should be independent options that were due to that
      decision.
      
      While at it, avoid division-by-zero in cases where no transactions were
      executed.  While on modern platforms this would generally result in
      printing "NaN" rather than a crash, that isn't spelled consistently
      across platforms and it would confuse many people.  Skip the relevant
      output entirely when practical, else print zeroes.
      
      Fabien Coelho, reviewed by Steve Singer, additional hacking by me
      
      Discussion: https://postgr.es/m/26654.1505232433@sss.pgh.pa.us
      16827d44
    • Tom Lane's avatar
      Doc: fix broken markup. · 41761265
      Tom Lane authored
      41761265
    • Robert Haas's avatar
      Provide for forward compatibility with future minor protocol versions. · ae65f606
      Robert Haas authored
      Previously, any attempt to request a 3.x protocol version other than
      3.0 would lead to a hard connection failure, which made the minor
      protocol version really no different from the major protocol version
      and precluded gentle protocol version breaks.  Instead, when the
      client requests a 3.x protocol version where x is greater than 0, send
      the new NegotiateProtocolVersion message to convey that we support
      only 3.0.  This makes it possible to introduce new minor protocol
      versions without requiring a connection retry when the server is
      older.
      
      In addition, if the startup packet includes name/value pairs where
      the name starts with "_pq_.", assume that those are protocol options,
      not GUCs.  Include those we don't support (i.e. all of them, at
      present) in the NegotiateProtocolVersion message so that the client
      knows they were not understood.  This makes it possible for the
      client to request previously-unsupported features without bumping
      the protocol version at all; the client can tell from the server's
      response whether the option was understood.
      
      It will take some time before servers that support these new
      facilities become common in the wild; to speed things up and make
      things easier for a future 3.1 protocol version, back-patch to all
      supported releases.
      
      Robert Haas and Badrul Chowdhury
      
      Discussion: http://postgr.es/m/BN6PR21MB0772FFA0CBD298B76017744CD1730@BN6PR21MB0772.namprd21.prod.outlook.com
      Discussion: http://postgr.es/m/30788.1498672033@sss.pgh.pa.us
      ae65f606
    • Robert Haas's avatar
      Fix multiple problems with satisfies_hash_partition. · f3b0897a
      Robert Haas authored
      Fix the function header comment to describe the actual behavior.
      Check that table OID, modulus, and remainder arguments are not NULL
      before accessing them.  Check that the modulus and remainder are
      sensible.  If the table OID doesn't exist, return NULL instead of
      emitting an internal error, similar to what we do elsewhere.  Check
      that the actual argument types match, or at least are binary coercible
      to, the expected argument types.  Correctly handle invocation of this
      function using the VARIADIC syntax.  Add regression tests.
      
      Robert Haas and Amul Sul, per a report by Andreas Seltenreich and
      subsequent followup investigation.
      
      Discussion: http://postgr.es/m/871sl4sdrv.fsf@ansel.ydns.eu
      f3b0897a
    • Tom Lane's avatar
      Support index-only scans in contrib/cube and contrib/seg GiST indexes. · de1d042f
      Tom Lane authored
      To do this, we only have to remove the compress and decompress support
      functions, which have never done anything more than detoasting.
      In the wake of commit d3a4f89d, this results in automatically enabling
      index-only scans, since the core code will now know that the stored
      representation is the same as the original data (up to detoasting).
      
      The only exciting part of this is that ALTER OPERATOR FAMILY lacks
      a way to drop a support function that was declared as being part of
      an opclass rather than being loose in the family.  For the moment,
      we'll hack our way to a solution with a manual update of the pg_depend
      entry type, which is what distinguishes the two cases.  Perhaps
      someday it'll be worth providing a cleaner way to do that, but for
      now it seems like a very niche problem.
      
      Note that the underlying C functions remain, to support use of the shared
      libraries with older versions of the modules' SQL declarations.  Someday
      we may be able to remove them, but not soon.
      
      Andrey Borodin, reviewed by me
      
      Discussion: https://postgr.es/m/D0F53A05-4F4A-4DEC-8339-3C069FA0EE11@yandex-team.ru
      de1d042f
  5. 20 Nov, 2017 6 commits
  6. 19 Nov, 2017 1 commit
  7. 18 Nov, 2017 6 commits
    • Tom Lane's avatar
      Fix compiler warning in rangetypes_spgist.c. · 52f63bd9
      Tom Lane authored
      On gcc 7.2.0, comparing pointer to (Datum) 0 produces a warning.
      Treat it as a simple pointer to avoid that; this is more consistent
      with comparable code elsewhere, anyway.
      
      Tomas Vondra
      
      Discussion: https://postgr.es/m/99410021-61ef-9a9a-9bc8-f733ece637ee@2ndquadrant.com
      52f63bd9
    • Tom Lane's avatar
      Merge near-duplicate code in RI triggers. · 4797f9b5
      Tom Lane authored
      Merge ri_restrict_del and ri_restrict_upd into one function ri_restrict.
      Create a function ri_setnull that is the common implementation of
      RI_FKey_setnull_del and RI_FKey_setnull_upd.  Likewise create a function
      ri_setdefault that is the common implementation of RI_FKey_setdefault_del
      and RI_FKey_setdefault_upd.  All of these pairs of functions were identical
      except for needing to check for no-actual-key-change in the UPDATE cases;
      the one extra if-test is a small price to pay for saving so much code.
      
      Aside from removing about 400 lines of essentially duplicate code, this
      allows us to recognize that we were uselessly caching two identical plans
      whenever there were pairs of triggers using these duplicated functions
      (which is likely very common).
      
      Ildar Musin, reviewed by Ildus Kurbangaliev
      
      Discussion: https://postgr.es/m/ca7064a7-6adc-6f22-ca47-8615ba9425a5@postgrespro.ru
      4797f9b5
    • Peter Eisentraut's avatar
      Consistently catch errors from Python _New() functions · d0aa965c
      Peter Eisentraut authored
      Python Py*_New() functions can fail and return NULL in out-of-memory
      conditions.  The previous code handled that inconsistently or not at
      all.  This change organizes that better.  If we are in a function that
      is called from Python, we just check for failure and return NULL
      ourselves, which will cause any exception information to be passed up.
      If we are called from PostgreSQL, we consistently create an "out of
      memory" error.
      Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
      d0aa965c
    • Tom Lane's avatar
      Improve to_date/to_number/to_timestamp behavior with multibyte characters. · 976a1a48
      Tom Lane authored
      The documentation says that these functions skip one input character
      per literal (non-pattern) format character.  Actually, though, they
      skipped one input *byte* per literal *byte*, which could be hugely
      confusing if either data or format contained multibyte characters.
      
      To fix, adjust the FormatNode representation and parse_format() so
      that multibyte format characters are stored as one FormatNode not
      several, and adjust the data-skipping bits to advance by pg_mblen()
      not necessarily one byte.  There's no user-visible behavior change
      on the to_char() side, although the internal representation changes.
      
      Commit e87d4965 had already fixed most places where we skip characters
      on the basis of non-literal format patterns to advance by characters
      not bytes, but this gets one more place, the SKIP_THth macro.  I think
      everything in formatting.c gets that right now.
      
      It'd be nice to have some regression test cases covering this behavior;
      but of course there's no way to do so in an encoding-agnostic way, and
      many of the interesting aspects would also require unportable locale
      selections.  So I've not bothered here.
      
      Discussion: https://postgr.es/m/28186.1510957703@sss.pgh.pa.us
      976a1a48
    • Tom Lane's avatar
      Fix quoted-substring handling in format parsing for to_char/to_number/etc. · 63ca8631
      Tom Lane authored
      This code evidently intended to treat backslash as an escape character
      within double-quoted substrings, but it was sufficiently confused that
      cases like ..."foo\\"... did not work right: the second backslash
      managed to quote the double-quote after it, despite being quoted itself.
      Rewrite to get that right, while preserving the existing behavior
      outside double-quoted substrings, which is that backslash isn't special
      except in the combination \".
      
      Comparing to Oracle, it seems that their version of to_char() for
      timestamps allows literal alphanumerics only within double quotes, while
      non-alphanumerics are allowed outside quotes; backslashes aren't special
      anywhere; there is no way at all to emit a literal double quote.
      (Bizarrely, their to_char() for numbers is different; it doesn't allow
      literal text at all AFAICT.)  The fact that they don't treat backslash
      as special justifies our existing behavior for backslash outside double
      quotes.  I considered making backslash inside double quotes act the same
      way (ie, special only if before "), which in a green field would be a
      more consistent behavior.  But that would likely break more existing SQL
      code than what this patch does.
      
      Add some test cases illustrating this behavior.  (Only the last new
      case actually changes behavior in this commit.)
      
      Little of this behavior was documented, either, so fix that.
      
      Discussion: https://postgr.es/m/3626.1510949486@sss.pgh.pa.us
      63ca8631
    • Peter Eisentraut's avatar
      Support channel binding 'tls-unique' in SCRAM · 9288d62b
      Peter Eisentraut authored
      This is the basic feature set using OpenSSL to support the feature.  In
      order to allow the frontend and the backend to fetch the sent and
      expected TLS Finished messages, a PG-like API is added to be able to
      make the interface pluggable for other SSL implementations.
      
      This commit also adds a infrastructure to facilitate the addition of
      future channel binding types as well as libpq parameters to control the
      SASL mechanism names and channel binding names.  Those will be added by
      upcoming commits.
      
      Some tests are added to the SSL test suite to test SCRAM authentication
      with channel binding.
      
      Author: Michael Paquier <michael@paquier.xyz>
      Reviewed-by: default avatarPeter Eisentraut <peter.eisentraut@2ndquadrant.com>
      9288d62b
  8. 17 Nov, 2017 4 commits
    • Robert Haas's avatar
      611fe7d4
    • Tom Lane's avatar
      Remove contrib/start-scripts/osx/. · 52787863
      Tom Lane authored
      Since those scripts haven't worked at all in macOS releases of 2014
      and later, and aren't the recommended way to do it on any release
      since 2005, there seems little point carrying them into the future.
      It's very unlikely that anyone would be installing PG >= 11 on a
      macOS release where they couldn't use contrib/start-scripts/macos/.
      
      Discussion: https://postgr.es/m/31338.1510763554@sss.pgh.pa.us
      52787863
    • Tom Lane's avatar
      Provide modern examples of how to auto-start Postgres on macOS. · ac3b9626
      Tom Lane authored
      The scripts in contrib/start-scripts/osx don't work at all on macOS
      10.10 (Yosemite) or later, because they depend on SystemStarter which
      Apple deprecated long ago and removed in 10.10.  Add a new subdirectory
      contrib/start-scripts/macos with scripts that use the newer launchd
      infrastructure.
      
      Since this problem is independent of which Postgres version you're using,
      back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/31338.1510763554@sss.pgh.pa.us
      ac3b9626
    • Tom Lane's avatar
      Prevent to_number() from losing data when template doesn't match exactly. · e87d4965
      Tom Lane authored
      Non-data template patterns would consume characters whether or not those
      characters were what the pattern expected, for example
      	SELECT TO_NUMBER('1234', '9,999');
      produced 134 because the '2' got eaten by the comma pattern.  This seems
      undesirable, not least because it doesn't happen in Oracle.  For the ','
      and 'G' template patterns, we can fix this by consuming characters only
      if they match what the pattern would output.  For non-data patterns such
      as 'L' and 'TH', it seems impractical to tighten things up to the point of
      consuming only exact matches to what the pattern would output; but we can
      improve matters quite a lot by redefining the behavior as "consume only
      characters that aren't digits, signs, decimal point, or comma".
      
      Also, fix it so that the behavior is to consume the number of *characters*
      the pattern would output, not the number of *bytes*.  The old coding would
      do surprising things with non-ASCII currency symbols, for example.  (It
      would be good to apply that rule for literal text as well, but this commit
      only fixes it for non-data patterns.)
      
      Oliver Ford, reviewed by Thomas Munro and Nathan Wagner, and whacked around
      a bit more by me
      
      Discussion: https://postgr.es/m/CAGMVOdvpbMqPf9XWNzOwBpzJfErkydr_fEGhmuDGa015z97mwg@mail.gmail.com
      e87d4965