Skip to content
Snippets Groups Projects
  1. Jan 05, 2017
  2. Jan 03, 2017
  3. Dec 22, 2016
  4. Dec 18, 2016
    • Tom Lane's avatar
      In contrib/uuid-ossp, #include headers needed for ntohl() and ntohs(). · 4a0a34b5
      Tom Lane authored
      Oversight in commit b8cc8f94.  I just noticed this causes compiler
      warnings on FreeBSD, and it really ought to cause warnings elsewhere too:
      all references I can find say that <arpa/inet.h> is required for these.
      We have a lot of code elsewhere that thinks that both <netinet/in.h>
      and <arpa/inet.h> should be included for these functions, so do it that
      way here too, even though <arpa/inet.h> ought to be sufficient according
      to the references I consulted.
      
      Back-patch to 9.4 where the previous commit landed.
      4a0a34b5
  5. Dec 15, 2016
    • Peter Eisentraut's avatar
      Various temporary slots test improvements · fdf71389
      Peter Eisentraut authored
      Fix the tests on slow machines (per buildfarm).
      
      Add test for dropping on error.  And also try to consume real changes
      from temporary slots.
      
      From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
      fdf71389
  6. Dec 12, 2016
  7. Dec 08, 2016
    • Robert Haas's avatar
      Log the creation of an init fork unconditionally. · fa0f466d
      Robert Haas authored
      Previously, it was thought that this only needed to be done for the
      benefit of possible standbys, so wal_level = minimal skipped it.
      But that's not safe, because during crash recovery we might replay
      XLOG_DBASE_CREATE or XLOG_TBLSPC_CREATE record which recursively
      removes the directory that contains the new init fork.  So log it
      always.
      
      The user-visible effect of this bug is that if you create a database
      or tablespace, then create an unlogged table, then crash without
      checkpointing, then restart, accessing the table will fail, because
      the it won't have been properly reset.  This commit fixes that.
      
      Michael Paquier, per a report from Konstantin Knizhnik.  Wording of
      the comments per a suggestion from me.
      fa0f466d
  8. Dec 05, 2016
    • Heikki Linnakangas's avatar
      Replace PostmasterRandom() with a stronger source, second attempt. · fe0a0b59
      Heikki Linnakangas authored
      This adds a new routine, pg_strong_random() for generating random bytes,
      for use in both frontend and backend. At the moment, it's only used in
      the backend, but the upcoming SCRAM authentication patches need strong
      random numbers in libpq as well.
      
      pg_strong_random() is based on, and replaces, the existing implementation
      in pgcrypto. It can acquire strong random numbers from a number of sources,
      depending on what's available:
      
      - OpenSSL RAND_bytes(), if built with OpenSSL
      - On Windows, the native cryptographic functions are used
      - /dev/urandom
      
      Unlike the current pgcrypto function, the source is chosen by configure.
      That makes it easier to test different implementations, and ensures that
      we don't accidentally fall back to a less secure implementation, if the
      primary source fails. All of those methods are quite reliable, it would be
      pretty surprising for them to fail, so we'd rather find out by failing
      hard.
      
      If no strong random source is available, we fall back to using erand48(),
      seeded from current timestamp, like PostmasterRandom() was. That isn't
      cryptographically secure, but allows us to still work on platforms that
      don't have any of the above stronger sources. Because it's not very secure,
      the built-in implementation is only used if explicitly requested with
      --disable-strong-random.
      
      This replaces the more complicated Fortuna algorithm we used to have in
      pgcrypto, which is unfortunate, but all modern platforms have /dev/urandom,
      so it doesn't seem worth the maintenance effort to keep that. pgcrypto
      functions that require strong random numbers will be disabled with
      --disable-strong-random.
      
      Original patch by Magnus Hagander, tons of further work by Michael Paquier
      and me.
      
      Discussion: https://www.postgresql.org/message-id/CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA@mail.gmail.com
      Discussion: https://www.postgresql.org/message-id/CAB7nPqRWkNYRRPJA7-cF+LfroYV10pvjdz6GNvxk-Eee9FypKA@mail.gmail.com
      fe0a0b59
  9. Nov 30, 2016
    • Heikki Linnakangas's avatar
      Remove dead stuff from pgcrypto. · b2cc748b
      Heikki Linnakangas authored
      pgp-pubkey-DISABLED test has been unused since 2006, when support for
      built-in bignum math was added (commit 1abf76e8). pgp-encrypt-DISABLED has
      been unused forever, AFAICS.
      
      Also remove a couple of unused error codes.
      b2cc748b
  10. Nov 29, 2016
  11. Nov 22, 2016
  12. Nov 14, 2016
  13. Nov 13, 2016
  14. Nov 12, 2016
    • Andres Freund's avatar
      Add minimal set of regression tests for pg_stat_statements. · 9be244db
      Andres Freund authored
      While the set of covered functionality is fairly small, the added tests
      still are useful to get some basic buildfarm testing of
      pg_stat_statements itself, but also to exercise the lwlock tranch code
      on the buildfarm.
      
      Author: Amit Kapila, slightly editorialized by me
      Reviewed-By: Ashutosh Sharma, Andres Freund
      Discussion: <CAA4eK1JOjkdXYtHxh=2aDK4VgDtN-LNGKY_YqX0N=YEvuzQVWg@mail.gmail.com>
      9be244db
  15. Nov 08, 2016
    • Tom Lane's avatar
      Replace uses of SPI_modifytuple that intend to allocate in current context. · 9257f078
      Tom Lane authored
      Invent a new function heap_modify_tuple_by_cols() that is functionally
      equivalent to SPI_modifytuple except that it always allocates its result
      by simple palloc.  I chose however to make the API details a bit more
      like heap_modify_tuple: pass a tupdesc rather than a Relation, and use
      bool convention for the isnull array.
      
      Use this function in place of SPI_modifytuple at all call sites where the
      intended behavior is to allocate in current context.  (There actually are
      only two call sites left that depend on the old behavior, which makes me
      wonder if we should just drop this function rather than keep it.)
      
      This new function is easier to use than heap_modify_tuple() for purposes
      of replacing a single column (or, really, any fixed number of columns).
      There are a number of places where it would simplify the code to change
      over, but I resisted that temptation for the moment ... everywhere except
      in plpgsql's exec_assign_value(); changing that might offer some small
      performance benefit, so I did it.
      
      This is on the way to removing SPI_push/SPI_pop, but it seems like
      good code cleanup in its own right.
      
      Discussion: <9633.1478552022@sss.pgh.pa.us>
      9257f078
    • Tom Lane's avatar
      Make SPI_fnumber() reject dropped columns. · 6d30fb1f
      Tom Lane authored
      There's basically no scenario where it's sensible for this to match
      dropped columns, so put a test for dropped-ness into SPI_fnumber()
      itself, and excise the test from the small number of callers that
      were paying attention to the case.  (Most weren't :-(.)
      
      In passing, normalize tests at call sites: always reject attnum <= 0
      if we're disallowing system columns.  Previously there was a mixture
      of "< 0" and "<= 0" tests.  This makes no practical difference since
      SPI_fnumber() never returns 0, but I'm feeling pedantic today.
      
      Also, in the places that are actually live user-facing code and not
      legacy cruft, distinguish "column not found" from "can't handle
      system column".
      
      Per discussion with Jim Nasby; thi supersedes his original patch
      that just changed the behavior at one call site.
      
      Discussion: <b2de8258-c4c0-1cb8-7b97-e8538e5c975c@BlueTreble.com>
      6d30fb1f
  16. Nov 07, 2016
  17. Nov 05, 2016
    • Tom Lane's avatar
      Provide DLLEXPORT markers for C functions via PG_FUNCTION_INFO_V1 macro. · c8ead2a3
      Tom Lane authored
      Second try at the change originally made in commit 8518583c;
      this time with contrib updates so that manual extern declarations
      are also marked with PGDLLEXPORT.  The release notes should point
      this out as a significant source-code change for extension authors,
      since they'll have to make similar additions to avoid trouble on Windows.
      
      Laurenz Albe, doc change by me
      
      Patch: <A737B7A37273E048B164557ADEF4A58B53962ED8@ntex2010a.host.magwien.gv.at>
      c8ead2a3
  18. Nov 04, 2016
    • Tom Lane's avatar
      Delete contrib/xml2's legacy implementation of xml_is_well_formed(). · 20540710
      Tom Lane authored
      This function is unreferenced in modern usage; it was superseded in 9.1
      by a core function of the same name.  It has been left in place in the C
      code only so that pre-9.1 SQL definitions of the contrib/xml2 functions
      would continue to work.  Six years seems like enough time for people to
      have updated to the extension-style version of the xml2 module, so let's
      drop this.
      
      The key reason for not keeping it any longer is that we want to stick
      an explicit PGDLLEXPORT into PG_FUNCTION_INFO_V1(), and the similarity
      of name to the core function creates a conflict that compilers will
      complain about.
      
      Extracted from a larger patch for that purpose.  I'm committing this
      change separately to give it more visibility in the commit logs.
      
      While at it, remove the documentation entry that claimed that
      xml_is_well_formed() is a function provided by contrib/xml2, and
      instead mention the even more ancient alias xml_valid().
      
      Laurenz Albe, doc change by me
      
      Patch: <A737B7A37273E048B164557ADEF4A58B53962ED8@ntex2010a.host.magwien.gv.at>
      20540710
    • Tom Lane's avatar
      Fix gin_leafpage_items(). · 367b99bb
      Tom Lane authored
      On closer inspection, commit 84ad68d6 broke gin_leafpage_items(),
      because the aligned copy of the page got palloc'd in a short-lived
      context whereas it needs to be in the SRF's multi_call_memory_ctx.
      This was not exposed by the regression test, because the regression
      test doesn't actually exercise the function in a meaningful way.
      Fix the code bug, and extend the test in what I hope is a portable
      fashion.
      367b99bb
    • Peter Eisentraut's avatar
      pageinspect: Fix unaligned struct access in GIN functions · 84ad68d6
      Peter Eisentraut authored
      The raw page data that is passed into the functions will not be aligned
      at 8-byte boundaries.  Casting that to a struct and accessing int64
      fields will result in unaligned access.  On most platforms, you get away
      with it, but it will result on a crash on pickier platforms such as ia64
      and sparc64.
      84ad68d6
    • Robert Haas's avatar
      postgres_fdw: Fix typo in comment. · 7016e4c4
      Robert Haas authored
      Etsuro Fujita
      7016e4c4
  19. Nov 03, 2016
  20. Nov 02, 2016
    • Tom Lane's avatar
      Don't convert Consts into Vars during setrefs.c processing. · da8f3ebf
      Tom Lane authored
      While converting expressions in an upper-level plan node so that they
      reference Vars and expressions provided by the input plan node(s),
      don't convert plain Const items, even if there happens to be a matching
      Const in the input.  It's silly to do so because a Var is more expensive to
      execute than a Const.  Moreover, converting can fool ExecCheckPlanOutput's
      check that an insert or update query inserts nulls into dropped columns,
      leading to "query provides a value for a dropped column" errors during
      INSERT or UPDATE on a table with a dropped column.  We could solve this
      by making that check more complicated, but I don't see the point; this fix
      should save a marginal number of cycles, and it also makes for less messy
      EXPLAIN output, as shown by the ensuing regression test result changes.
      
      Per report from Pavel Hanák.  I have not incorporated a test case based
      on that example, as there doesn't seem to be a simple way of checking
      this in isolation without making a bunch of assumptions about other
      planner and SQL-function behavior.
      
      Back-patch to 9.6.  This setrefs.c behavior exists much further back,
      but there is not currently reason to think that it causes problems
      before 9.6.
      
      Discussion: <83shraampf.fsf@is-it.eu>
      da8f3ebf
    • Peter Eisentraut's avatar
      pageinspect: Make page test more portable · 00a86856
      Peter Eisentraut authored
      Choose test data that makes the output independent of endianness.
      00a86856
    • Tom Lane's avatar
      Fix portability bug in gin_page_opaque_info(). · 14ee3579
      Tom Lane authored
      Somebody apparently thought that "if Int32GetDatum is good,
      Int64GetDatum must be better".  Per buildfarm failures now
      that Peter has added some regression tests here.
      14ee3579
    • Peter Eisentraut's avatar
      pageinspect: Make btree test more portable · f7c9a6e0
      Peter Eisentraut authored
      Choose test data that makes the output independent of endianness and
      alignment.
      f7c9a6e0
  21. Nov 01, 2016
  22. Oct 28, 2016
    • Robert Haas's avatar
      pgstattuple: Don't take heavyweight locks when examining a hash index. · d4b5d4ca
      Robert Haas authored
      It's currently necessary to take a heavyweight lock when scanning a
      hash bucket, but pgstattuple only examines individual pages, so it
      doesn't need to do this.  If, for some hypothetical reason, it did
      need to do any heavyweight locking here, this logic would probably
      still be incorrect, because most of the locks that it is taking are
      meaningless.  Only a heavyweight lock on a primary bucket page has any
      meaning, but this takes heavyweight locks on all pages regardless of
      function - and in particular overflow pages, where you might imagine
      that we'd want to lock the primary bucket page if we needed to lock
      anything at all.
      
      This is arguably a bug that has existed since this code was added in
      commit dab42382, but I'm not going to
      bother back-patching it because in most cases the only consequence is
      that running pgstattuple() on a hash index is a little slower than it
      otherwise might be, which is no big deal.
      
      Extracted from a vastly larger patch by Amit Kapila which heavyweight
      locking for hash indexes entirely; analysis of why this can be done
      independently of the rest by me.
      d4b5d4ca
  23. Oct 26, 2016
Loading