Skip to content
Snippets Groups Projects
  1. Mar 17, 2014
    • Tom Lane's avatar
      Fix unportable shell-script syntax in pg_upgrade's test.sh. · 0268d21e
      Tom Lane authored
      I discovered the hard way that on some old shells, the locution
          FOO=""   unset FOO
      does not behave the same as
          FOO="";  unset FOO
      and in fact leaves FOO set to an empty string.  test.sh was inconsistently
      spelling it different ways on adjacent lines.
      
      This got broken relatively recently, in commit c737a2e5, so the lack of
      field reports to date doesn't represent a lot of evidence that the problem
      is rare.
      0268d21e
  2. Mar 12, 2014
  3. Mar 07, 2014
    • Tom Lane's avatar
      Remove unportable use of anonymous unions from reorderbuffer.h. · ea177a3b
      Tom Lane authored
      In b89e1510 I had assumed it was ok to use anonymous unions as
      struct members, but while a longstanding extension in many compilers,
      it's only been standardized in C11.
      
      To fix, remove one of the anonymous unions which tried to hide some
      implementation specific enum values and give the other a name. The
      latter unfortunately requires changes in output plugins, but since the
      feature has only been added a few days ago...
      
      Andres Freund
      ea177a3b
    • Tom Lane's avatar
      Fix contrib/postgres_fdw to handle multiple join conditions properly. · 83204e10
      Tom Lane authored
      The previous coding supposed that it could consider just a single join
      condition in any one parameterized path for the foreign table.  But in
      reality, the parameterized-path machinery forces all join clauses that are
      "movable to" the foreign table to be evaluated at that node; including
      clauses that we might not consider safe to send across.  Such cases would
      result in an Assert failure in an assert-enabled build, and otherwise in
      sending an unsafe clause to the foreign server, which might result in
      errors or silently-wrong answers.  A lesser problem was that the
      cost/rowcount estimates generated for the parameterized path failed to
      account for any additional join quals that get assigned to the scan.
      
      To fix, rewrite postgresGetForeignPaths so that it correctly collects all
      the movable quals for any one outer relation when generating parameterized
      paths; we'll now generate just one path per outer relation not one per join
      qual.  Also fix bogus assumptions in postgresGetForeignPlan and
      estimate_path_cost_size that only safe-to-send join quals will be
      presented.
      
      Based on complaint from Etsuro Fujita that the path costs were being
      miscalculated, though this is significantly different from his proposed
      patch.
      83204e10
  4. Mar 05, 2014
  5. Mar 04, 2014
    • Andrew Dunstan's avatar
      Provide a FORCE NULL option to COPY in CSV mode. · 3b5e03dc
      Andrew Dunstan authored
      This forces an input field containing the quoted null string to be
      returned as a NULL. Without this option, only unquoted null strings
      behave this way. This helps where some CSV producers insist on quoting
      every field, whether or not it is needed. The option takes a list of
      fields, and only applies to those columns. There is an equivalent
      column-level option added to file_fdw.
      
      Ian Barwick, with some tweaking by Andrew Dunstan, reviewed by Payal
      Singh.
      3b5e03dc
    • Alvaro Herrera's avatar
      auto_explain: Add logging of trigger execution · e2a0fc53
      Alvaro Herrera authored
      Author: Kyotaro HORIGUCHI
      Reviewed-by: Jaime Casanova
      e2a0fc53
  6. Mar 03, 2014
    • Robert Haas's avatar
      Introduce logical decoding. · b89e1510
      Robert Haas authored
      This feature, building on previous commits, allows the write-ahead log
      stream to be decoded into a series of logical changes; that is,
      inserts, updates, and deletes and the transactions which contain them.
      It is capable of handling decoding even across changes to the schema
      of the effected tables.  The output format is controlled by a
      so-called "output plugin"; an example is included.  To make use of
      this in a real replication system, the output plugin will need to be
      modified to produce output in the format appropriate to that system,
      and to perform filtering.
      
      Currently, information can be extracted from the logical decoding
      system only via SQL; future commits will add the ability to stream
      changes via walsender.
      
      Andres Freund, with review and other contributions from many other
      people, including Álvaro Herrera, Abhijit Menon-Sen, Peter Gheogegan,
      Kevin Grittner, Robert Haas, Heikki Linnakangas, Fujii Masao, Abhijit
      Menon-Sen, Michael Paquier, Simon Riggs, Craig Ringer, and Steve
      Singer.
      b89e1510
    • Robert Haas's avatar
      pageinspect: Use new pg_lsn datatype. · 45ffeb7e
      Robert Haas authored
      Michael Paquier, with slight comment changes by me
      45ffeb7e
  7. Feb 28, 2014
  8. Feb 27, 2014
    • Tom Lane's avatar
      Remove dependency on database encoding in citext regression test. · 1161d895
      Tom Lane authored
      Testing convert_to(..., 'ISO-8859-1') fails if there isn't a conversion
      function available from the database encoding to ISO-8859-1.  This has
      been broken since day one, but the breakage was hidden by
      pg_do_encoding_conversion's failure to complain, up till commit
      49c817ea.
      
      Since the data being converted in this test is plain ASCII, no actual
      conversion need happen (and if it did, it would prove little about citext
      anyway).  So that we still have some code coverage of the convert() family
      of functions, let's switch to using convert_from, with SQL_ASCII as the
      specified source encoding.  Per buildfarm.
      1161d895
  9. Feb 23, 2014
    • Tom Lane's avatar
      Prefer pg_any_to_server/pg_server_to_any over pg_do_encoding_conversion. · 769065c1
      Tom Lane authored
      A large majority of the callers of pg_do_encoding_conversion were
      specifying the database encoding as either source or target of the
      conversion, meaning that we can use the less general functions
      pg_any_to_server/pg_server_to_any instead.
      
      The main advantage of using the latter functions is that they can make use
      of a cached conversion-function lookup in the common case that the other
      encoding is the current client_encoding.  It's notationally cleaner too in
      most cases, not least because of the historical artifact that the latter
      functions use "char *" rather than "unsigned char *" in their APIs.
      
      Note that pg_any_to_server will apply an encoding verification step in
      some cases where pg_do_encoding_conversion would have just done nothing.
      This seems to me to be a good idea at most of these call sites, though
      it partially negates the performance benefit.
      
      Per discussion of bug #9210.
      769065c1
  10. Feb 21, 2014
    • Heikki Linnakangas's avatar
      Avoid integer overflow in hstore_to_json(). · 0c5783ff
      Heikki Linnakangas authored
      The length of the output buffer was calculated based on the size of the
      argument hstore. On a sizeof(int) == 4 platform and a huge argument, it
      could overflow, causing a too small buffer to be allocated.
      
      Refactor the function to use a StringInfo instead of pre-allocating the
      buffer. Makes it shorter and more readable, too.
      0c5783ff
  11. Feb 17, 2014
    • Tom Lane's avatar
      Prevent potential overruns of fixed-size buffers. · 01824385
      Tom Lane authored
      Coverity identified a number of places in which it couldn't prove that a
      string being copied into a fixed-size buffer would fit.  We believe that
      most, perhaps all of these are in fact safe, or are copying data that is
      coming from a trusted source so that any overrun is not really a security
      issue.  Nonetheless it seems prudent to forestall any risk by using
      strlcpy() and similar functions.
      
      Fixes by Peter Eisentraut and Jozef Mlich based on Coverity reports.
      
      In addition, fix a potential null-pointer-dereference crash in
      contrib/chkpass.  The crypt(3) function is defined to return NULL on
      failure, but chkpass.c didn't check for that before using the result.
      The main practical case in which this could be an issue is if libc is
      configured to refuse to execute unapproved hashing algorithms (e.g.,
      "FIPS mode").  This ideally should've been a separate commit, but
      since it touches code adjacent to one of the buffer overrun changes,
      I included it in this commit to avoid last-minute merge issues.
      This issue was reported by Honza Horak.
      
      Security: CVE-2014-0065 for buffer overruns, CVE-2014-0066 for crypt()
      01824385
    • Noah Misch's avatar
      Predict integer overflow to avoid buffer overruns. · 31400a67
      Noah Misch authored
      Several functions, mostly type input functions, calculated an allocation
      size such that the calculation wrapped to a small positive value when
      arguments implied a sufficiently-large requirement.  Writes past the end
      of the inadvertent small allocation followed shortly thereafter.
      Coverity identified the path_in() vulnerability; code inspection led to
      the rest.  In passing, add check_stack_depth() to prevent stack overflow
      in related functions.
      
      Back-patch to 8.4 (all supported versions).  The non-comment hstore
      changes touch code that did not exist in 8.4, so that part stops at 9.0.
      
      Noah Misch and Heikki Linnakangas, reviewed by Tom Lane.
      
      Security: CVE-2014-0064
      31400a67
  12. Feb 15, 2014
  13. Feb 12, 2014
  14. Feb 04, 2014
    • Tom Lane's avatar
      Improve connection-failure error handling in contrib/postgres_fdw. · 00d4f2af
      Tom Lane authored
      postgres_fdw tended to say "unknown error" if it tried to execute a command
      on an already-dead connection, because some paths in libpq just return a
      null PGresult for such cases.  Out-of-memory might result in that, too.
      To fix, pass the PGconn to pgfdw_report_error, and look at its
      PQerrorMessage() string if we can't get anything out of the PGresult.
      
      Also, fix the transaction-exit logic to reliably drop a dead connection.
      It was attempting to do that already, but it assumed that only connection
      cache entries with xact_depth > 0 needed to be examined.  The folly in that
      is that if we fail while issuing START TRANSACTION, we'll not have bumped
      xact_depth.  (At least for the case I was testing, this fix masks the
      other problem; but it still seems like a good idea to have the PGconn
      fallback logic.)
      
      Per investigation of bug #9087 from Craig Lucas.  Backpatch to 9.3 where
      this code was introduced.
      00d4f2af
  15. Feb 03, 2014
    • Fujii Masao's avatar
      Make pg_basebackup skip temporary statistics files. · 3e8554a5
      Fujii Masao authored
      The temporary statistics files don't need to be included in the backup
      because they are always reset at the beginning of the archive recovery.
      This patch changes pg_basebackup so that it skips all files located in
      $PGDATA/pg_stat_tmp or the directory specified by stats_temp_directory
      parameter.
      3e8554a5
  16. Feb 01, 2014
    • Tom Lane's avatar
      Fix some more bugs in signal handlers and process shutdown logic. · 214c7a4f
      Tom Lane authored
      WalSndKill was doing things exactly backwards: it should first clear
      MyWalSnd (to stop signal handlers from touching MyWalSnd->latch),
      then disown the latch, and only then mark the WalSnd struct unused by
      clearing its pid field.
      
      Also, WalRcvSigUsr1Handler and worker_spi_sighup failed to preserve
      errno, which is surely a requirement for any signal handler.
      
      Per discussion of recent buildfarm failures.  Back-patch as far
      as the relevant code exists.
      214c7a4f
    • Bruce Momjian's avatar
      chkpass: check for NULL return value from crypt() · 6afe200c
      Bruce Momjian authored
      Report from Jozef Mlich using Coverity
      6afe200c
  17. Jan 31, 2014
    • Tom Lane's avatar
      Allow unrecognized encoding names in locales, as long as they're the same. · cd3e0071
      Tom Lane authored
      The buildfarm says commit 58274728 doesn't
      work so well on Windows.  This is because the encoding part of Windows
      locale names can be just a code page number, eg "1252", which we don't
      consider to be a valid encoding name.  Add a check to accept encoding
      parts that are case-insensitively string equal; this at least ensures
      that the new code doesn't reject any cases that the old code allowed.
      cd3e0071
    • Tom Lane's avatar
      Be forgiving of variant spellings of locale names in pg_upgrade. · 58274728
      Tom Lane authored
      Even though the server tries to canonicalize stored locale names, the
      platform often doesn't cooperate, so it's entirely possible that one DB
      thinks its locale is, say, "en_US.UTF-8" while the other has "en_US.utf8".
      Rather than failing, we should try to allow this where it's clearly OK.
      
      There is already pretty robust encoding lookup in encnames.c, so make
      use of that to compare the encoding parts of the names.  The locale
      identifier parts are just compared case-insensitively, which we were
      already doing.  The major problem known to exist in the field is variant
      encoding-name spellings, so hopefully this will be Good Enough.  If not,
      we can try being even laxer.
      
      Pavel Raiskup, reviewed by Rushabh Lathia
      58274728
    • Tom Lane's avatar
      Fix potential coredump on bad locale value in pg_upgrade. · 41e364ec
      Tom Lane authored
      Thinko in error report (and a typo in the message text, too).  We're
      failing anyway, but it would be good to print something useful first.
      Noted while reviewing a patch to make pg_upgrade's locale code laxer.
      41e364ec
  18. Jan 28, 2014
    • Tom Lane's avatar
      Update comment. · 98d62c28
      Tom Lane authored
      generate_normalized_query() no longer needs to truncate text, but this
      one comment didn't get the memo.  Per Peter Geoghegan.
      98d62c28
  19. Jan 27, 2014
    • Tom Lane's avatar
      Keep pg_stat_statements' query texts in a file, not in shared memory. · f0d6f202
      Tom Lane authored
      This change allows us to eliminate the previous limit on stored query
      length, and it makes the shared-memory hash table very much smaller,
      allowing more statements to be tracked.  (The default value of
      pg_stat_statements.max is therefore increased from 1000 to 5000.)
      In typical scenarios, the hash table can be large enough to hold all the
      statements commonly issued by an application, so that there is little
      "churn" in the set of tracked statements, and thus little need to do I/O
      to the file.
      
      To further reduce the need for I/O to the query-texts file, add a way
      to retrieve all the columns of the pg_stat_statements view except for
      the query text column.  This is probably not of much interest for human
      use but it could be exploited by programs, which will prefer using the
      queryid anyway.
      
      Ordinarily, we'd need to bump the extension version number for the latter
      change.  But since we already advanced pg_stat_statements' version number
      from 1.1 to 1.2 in the 9.4 development cycle, it seems all right to just
      redefine what 1.2 means.
      
      Peter Geoghegan, reviewed by Pavel Stehule
      f0d6f202
    • Robert Haas's avatar
      Relax the requirement that all lwlocks be stored in a single array. · ea9df812
      Robert Haas authored
      This makes it possible to store lwlocks as part of some other data
      structure in the main shared memory segment, or in a dynamic shared
      memory segment.  There is still a main LWLock array and this patch does
      not move anything out of it, but it provides necessary infrastructure
      for doing that in the future.
      
      This change is likely to increase the size of LWLockPadded on some
      platforms, especially 32-bit platforms where it was previously only
      16 bytes.
      
      Patch by me.  Review by Andres Freund and KaiGai Kohei.
      ea9df812
  20. Jan 22, 2014
    • Heikki Linnakangas's avatar
      Compress GIN posting lists, for smaller index size. · 36a35c55
      Heikki Linnakangas authored
      GIN posting lists are now encoded using varbyte-encoding, which allows them
      to fit in much smaller space than the straight ItemPointer array format used
      before. The new encoding is used for both the lists stored in-line in entry
      tree items, and in posting tree leaf pages.
      
      To maintain backwards-compatibility and keep pg_upgrade working, the code
      can still read old-style pages and tuples. Posting tree leaf pages in the
      new format are flagged with GIN_COMPRESSED flag, to distinguish old and new
      format pages. Likewise, entry tree tuples in the new format have a
      GIN_ITUP_COMPRESSED flag set in a bit that was previously unused.
      
      This patch bumps GIN_CURRENT_VERSION from 1 to 2. New indexes created with
      version 9.4 will therefore have version number 2 in the metapage, while old
      pg_upgraded indexes will have version 1. The code treats them the same, but
      it might be come handy in the future, if we want to drop support for the
      uncompressed format.
      
      Alexander Korotkov and me. Reviewed by Tomas Vondra and Amit Langote.
      36a35c55
  21. Jan 20, 2014
  22. Jan 18, 2014
  23. Jan 17, 2014
    • Tom Lane's avatar
      Add gen_random_uuid() to contrib/pgcrypto. · e6170126
      Tom Lane authored
      This function provides a way of generating version 4 (pseudorandom) UUIDs
      based on pgcrypto's PRNG.  The main reason for doing this is that the
      OSSP UUID library depended on by contrib/uuid-ossp is becoming more and
      more of a porting headache, so we need an alternative for people who can't
      install that.  A nice side benefit though is that this implementation is
      noticeably faster than uuid-ossp's uuid_generate_v4() function.
      
      Oskari Saarenmaa, reviewed by Emre Hasegeli
      e6170126
    • Heikki Linnakangas's avatar
      Prevent integer overflow with --progress >= 2148 · 27727998
      Heikki Linnakangas authored
      If --progress=2148 or higher was given, the calculation of the next time
      to report overflowed, and pgbench would print a progress report very
      frequently.
      
      Kingter Wang
      27727998
  24. Jan 16, 2014
  25. Jan 15, 2014
Loading