Skip to content
Snippets Groups Projects
  1. Feb 15, 2017
    • Robert Haas's avatar
      Add optimizer and executor support for parallel index scans. · 5262f7a4
      Robert Haas authored
      In combination with 569174f1, which
      taught the btree AM how to perform parallel index scans, this allows
      parallel index scan plans on btree indexes.  This infrastructure
      should be general enough to support parallel index scans for other
      index AMs as well, if someone updates them to support parallel
      scans.
      
      Amit Kapila, reviewed and tested by Anastasia Lubennikova, Tushar
      Ahuja, and Haribabu Kommi, and me.
      5262f7a4
  2. Feb 09, 2017
    • Robert Haas's avatar
      Remove all references to "xlog" from SQL-callable functions in pg_proc. · 806091c9
      Robert Haas authored
      Commit f82ec32a renamed the pg_xlog
      directory to pg_wal.  To make things consistent, and because "xlog" is
      terrible terminology for either "transaction log" or "write-ahead log"
      rename all SQL-callable functions that contain "xlog" in the name to
      instead contain "wal".  (Note that this may pose an upgrade hazard for
      some users.)
      
      Similarly, rename the xlog_position argument of the functions that
      create slots to be called wal_position.
      
      Discussion: https://www.postgresql.org/message-id/CA+Tgmob=YmA=H3DbW1YuOXnFVgBheRmyDkWcD9M8f=5bGWYEoQ@mail.gmail.com
      806091c9
    • Tom Lane's avatar
      Allow index AMs to cache data across aminsert calls within a SQL command. · 86d911ec
      Tom Lane authored
      It's always been possible for index AMs to cache data across successive
      amgettuple calls within a single SQL command: the IndexScanDesc.opaque
      field is meant for precisely that.  However, no comparable facility
      exists for amortizing setup work across successive aminsert calls.
      This patch adds such a feature and teaches GIN, GIST, and BRIN to use it
      to amortize catalog lookups they'd previously been doing on every call.
      (The other standard index AMs keep everything they need in the relcache,
      so there's little to improve there.)
      
      For GIN, the overall improvement in a statement that inserts many rows
      can be as much as 10%, though it seems a bit less for the other two.
      In addition, this makes a really significant difference in runtime
      for CLOBBER_CACHE_ALWAYS tests, since in those builds the repeated
      catalog lookups are vastly more expensive.
      
      The reason this has been hard up to now is that the aminsert function is
      not passed any useful place to cache per-statement data.  What I chose to
      do is to add suitable fields to struct IndexInfo and pass that to aminsert.
      That's not widening the index AM API very much because IndexInfo is already
      within the ken of ambuild; in fact, by passing the same info to aminsert
      as to ambuild, this is really removing an inconsistency in the AM API.
      
      Discussion: https://postgr.es/m/27568.1486508680@sss.pgh.pa.us
      86d911ec
  3. Feb 06, 2017
  4. Jan 24, 2017
  5. Jan 21, 2017
  6. Jan 03, 2017
  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. Sep 30, 2016
  9. Aug 27, 2016
    • Tom Lane's avatar
      Add macros to make AllocSetContextCreate() calls simpler and safer. · ea268cdc
      Tom Lane authored
      I found that half a dozen (nearly 5%) of our AllocSetContextCreate calls
      had typos in the context-sizing parameters.  While none of these led to
      especially significant problems, they did create minor inefficiencies,
      and it's now clear that expecting people to copy-and-paste those calls
      accurately is not a great idea.  Let's reduce the risk of future errors
      by introducing single macros that encapsulate the common use-cases.
      Three such macros are enough to cover all but two special-purpose contexts;
      those two calls can be left as-is, I think.
      
      While this patch doesn't in itself improve matters for third-party
      extensions, it doesn't break anything for them either, and they can
      gradually adopt the simplified notation over time.
      
      In passing, change TopMemoryContext to use the default allocation
      parameters.  Formerly it could only be extended 8K at a time.  That was
      probably reasonable when this code was written; but nowadays we create
      many more contexts than we did then, so that it's not unusual to have a
      couple hundred K in TopMemoryContext, even without considering various
      dubious code that sticks other things there.  There seems no good reason
      not to let it use growing blocks like most other contexts.
      
      Back-patch to 9.6, mostly because that's still close enough to HEAD that
      it's easy to do so, and keeping the branches in sync can be expected to
      avoid some future back-patching pain.  The bugs fixed by these changes
      don't seem to be significant enough to justify fixing them further back.
      
      Discussion: <21072.1472321324@sss.pgh.pa.us>
      ea268cdc
  10. Aug 14, 2016
    • Tom Lane's avatar
      Fix assorted bugs in contrib/bloom. · d6c9e05c
      Tom Lane authored
      In blinsert(), cope with the possibility that a page we pull from the
      notFullPage list is marked BLOOM_DELETED.  This could happen if VACUUM
      recently marked it deleted but hasn't (yet) updated the metapage.
      We can re-use such a page safely, but we *must* reinitialize it so that
      it's no longer marked deleted.
      
      Fix blvacuum() so that it updates the notFullPage list even if it's
      going to update it to empty.  The previous "optimization" of skipping
      the update seems pretty dubious, since it means that the next blinsert()
      will uselessly visit whatever pages we left in the list.
      
      Uniformly treat PageIsNew pages the same as deleted pages.  This should
      allow proper recovery if a crash occurs just after relation extension.
      
      Properly use vacuum_delay_point, not assorted ad-hoc CHECK_FOR_INTERRUPTS
      calls, in the blvacuum() main loop.
      
      Fix broken tuple-counting logic: blvacuum.c counted the number of live
      index tuples over again in each scan, leading to VACUUM VERBOSE reporting
      some multiple of the actual number of surviving index tuples after any
      vacuum that removed any tuples (since they'd be counted in blvacuum, maybe
      more than once, and then again in blvacuumcleanup, without ever zeroing the
      counter).  It's sufficient to count them in blvacuumcleanup.
      
      stats->estimated_count is a boolean, not a counter, and we don't want
      to set it true, so don't add tuple counts to it.
      
      Add a couple of Asserts that we don't overrun available space on a bloom
      page.  I don't think there's any bug there today, but the way the
      FreeBlockNumberArray size calculation is set up is scarily fragile, and
      BloomPageGetFreeSpace isn't much better.  The Asserts should help catch
      any future mistakes.
      
      Per investigation of a report from Jeff Janes.  I think the first item
      above may explain his report; the other changes were things I noticed
      while casting about for an explanation.
      
      Report: <CAMkU=1xEUuBphDwDmB1WjN4+td4kpnEniFaTBxnk1xzHCw8_OQ@mail.gmail.com>
      d6c9e05c
    • Tom Lane's avatar
      Add SQL-accessible functions for inspecting index AM properties. · ed0097e4
      Tom Lane authored
      Per discussion, we should provide such functions to replace the lost
      ability to discover AM properties by inspecting pg_am (cf commit
      65c5fcd3).  The added functionality is also meant to displace any code
      that was looking directly at pg_index.indoption, since we'd rather not
      believe that the bit meanings in that field are part of any client API
      contract.
      
      As future-proofing, define the SQL API to not assume that properties that
      are currently AM-wide or index-wide will remain so unless they logically
      must be; instead, expose them only when inquiring about a specific index
      or even specific index column.  Also provide the ability for an index
      AM to override the behavior.
      
      In passing, document pg_am.amtype, overlooked in commit 473b9328.
      
      Andrew Gierth, with kibitzing by me and others
      
      Discussion: <87mvl5on7n.fsf@news-spur.riddles.org.uk>
      ed0097e4
  11. Aug 11, 2016
  12. Jun 14, 2016
    • Tom Lane's avatar
      Minor fixes in contrib installation scripts. · 5484c0a9
      Tom Lane authored
      Extension scripts should never use CREATE OR REPLACE for initial object
      creation.  If there is a collision with a pre-existing (probably
      user-created) object, we want extension installation to fail, not silently
      overwrite the user's object.  Bloom and sslinfo both violated this precept.
      
      Also fix a number of scripts that had no standard header (the file name
      comment and the \echo...\quit guard).  Probably the \echo...\quit hack
      is less important now than it was in 9.1 days, but that doesn't mean
      that individual extensions get to choose whether to use it or not.
      
      And fix a couple of evident copy-and-pasteos in file name comments.
      
      No need for back-patch: the REPLACE bugs are both new in 9.6, and the
      rest of this is pretty much cosmetic.
      
      Andreas Karlsson and Tom Lane
      5484c0a9
  13. Jun 12, 2016
  14. Jun 10, 2016
  15. Jun 07, 2016
  16. Jun 03, 2016
    • Tom Lane's avatar
      Measure Bloom index signature-length reloption in bits, not words. · ee4af347
      Tom Lane authored
      Per discussion, this is a more understandable and future-proof way of
      exposing the setting to users.  On-disk, we can still store it in words,
      so as to not break on-disk compatibility with beta1.
      
      Along the way, clean up the code associated with Bloom reloptions.
      Provide explicit macros for default and maximum lengths rather than
      having magic numbers buried in multiple places in the code.  Drop
      the adjustBloomOptions() code altogether: it was useless in view of
      the fact that reloptions.c already performed default-substitution and
      range checking for the options.  Rename a couple of macros and types
      for more clarity.
      
      Discussion: <23767.1464926580@sss.pgh.pa.us>
      ee4af347
  17. May 25, 2016
    • Tom Lane's avatar
      Fix contrib/bloom to work for unlogged indexes. · abaffa90
      Tom Lane authored
      blbuildempty did not do even approximately the right thing: it tried
      to add a metapage to the relation's regular data fork, which already
      has one at that point.  It should look like the ambuildempty methods
      for all the standard index types, ie, initialize a metapage image in
      some transient storage and then write it directly to the init fork.
      To support that, refactor BloomInitMetapage into two functions.
      
      In passing, fix BloomInitMetapage so it doesn't leave the rd_options
      field of the index's relcache entry pointing at transient storage.
      I'm not sure this had any visible consequence, since nothing much
      else is likely to look at a bloom index's rd_options, but it's
      certainly poor practice.
      
      Per bug #14155 from Zhou Digoal.
      
      Report: <20160524144146.22598.42558@wrigleys.postgresql.org>
      abaffa90
  18. May 17, 2016
    • Tom Lane's avatar
      Avoid possible crash in contrib/bloom's blendscan(). · e13ac558
      Tom Lane authored
      It's possible to begin and end an indexscan without ever calling
      amrescan.  contrib/bloom, unlike every other index AM, allocated
      its "scan->opaque" storage at amrescan time, and thus would crash
      in amendscan if amrescan hadn't been called.  We could fix this
      by putting in a null-pointer check in blendscan, but I see no very
      good reason why contrib/bloom should march to its own drummer in
      this respect.  Let's move that initialization to blbeginscan
      instead.  Per report from Jeff Janes.
      e13ac558
  19. Apr 28, 2016
    • Teodor Sigaev's avatar
      Prevent to use magic constants · f8467f7d
      Teodor Sigaev authored
      Use macroses for definition amstrategies/amsupport fields instead of
      hardcoded values.
      
      Author: Nikolay Shaplov with addition for contrib/bloom
      f8467f7d
  20. Apr 21, 2016
    • Tom Lane's avatar
      PGDLLIMPORT-ify old_snapshot_threshold. · 14216649
      Tom Lane authored
      Revert commit 7cb1db1d, which represented
      a misunderstanding of the problem (if snapmgr.h weren't already included
      in bufmgr.h, things wouldn't compile anywhere).  Instead install what
      I think is the real fix.
      14216649
    • Kevin Grittner's avatar
      Include snapmgr.h in blscan.c · 7cb1db1d
      Kevin Grittner authored
      Windows builds on buildfarm are failing because
      old_snapshot_threshold is not found in the bloom filter contrib
      module.
      7cb1db1d
  21. Apr 20, 2016
    • Kevin Grittner's avatar
      Revert no-op changes to BufferGetPage() · a343e223
      Kevin Grittner authored
      The reverted changes were intended to force a choice of whether any
      newly-added BufferGetPage() calls needed to be accompanied by a
      test of the snapshot age, to support the "snapshot too old"
      feature.  Such an accompanying test is needed in about 7% of the
      cases, where the page is being used as part of a scan rather than
      positioning for other purposes (such as DML or vacuuming).  The
      additional effort required for back-patching, and the doubt whether
      the intended benefit would really be there, have indicated it is
      best just to rely on developers to do the right thing based on
      comments and existing usage, as we do with many other conventions.
      
      This change should have little or no effect on generated executable
      code.
      
      Motivated by the back-patching pain of Tom Lane and Robert Haas
      a343e223
  22. Apr 12, 2016
    • Tom Lane's avatar
      Improve API of GenericXLogRegister(). · 5713f039
      Tom Lane authored
      Rename this function to GenericXLogRegisterBuffer() to make it clearer
      what it does, and leave room for other sorts of "register" actions in
      future.  Also, replace its "bool isNew" argument with an integer flags
      argument, so as to allow adding more flags in future without an API
      break.
      
      Alexander Korotkov, adjusted slightly by me
      5713f039
    • Teodor Sigaev's avatar
      Add page id to bloom index · 813b456e
      Teodor Sigaev authored
      Added to ensure that bloom index pages can be distinguished from other pages
      by pg_filedump. Because there wasn't any public/production versions before,
      it doesn't pay attention to any compatibility issues.
      
      Per notice from Tom Lane
      813b456e
  23. Apr 10, 2016
    • Tom Lane's avatar
      Improve contrib/bloom regression test using code coverage info. · cf223c3b
      Tom Lane authored
      Originally, this test created a 100000-row test table, which made it
      run rather slowly compared to other contrib tests.  Investigation with
      gcov showed that we got no further improvement in code coverage after
      the first 700 or so rows, making the large table 99% a waste of time.
      Cut it back to 2000 rows to fix the runtime problem and still leave
      some headroom for testing behaviors that may appear later.
      
      A closer look at the gcov results showed that the main coverage
      omissions in contrib/bloom occurred because the test never filled more
      than one entry in the notFullPage array; which is unsurprising because
      it exercised index cleanup only in the scenario of complete table
      deletion, allowing every page in the index to become deleted rather
      than not-full.  Add testing that allows the not-full path to be
      exercised as well.
      
      Also, test the amvalidate function, because blvalidate.c had zero
      coverage without that, and besides it's a good idea to check for
      mistakes in the bloom opclass definitions.
      cf223c3b
  24. Apr 09, 2016
  25. Apr 08, 2016
    • Kevin Grittner's avatar
      Add the "snapshot too old" feature · 848ef42b
      Kevin Grittner authored
      This feature is controlled by a new old_snapshot_threshold GUC.  A
      value of -1 disables the feature, and that is the default.  The
      value of 0 is just intended for testing.  Above that it is the
      number of minutes a snapshot can reach before pruning and vacuum
      are allowed to remove dead tuples which the snapshot would
      otherwise protect.  The xmin associated with a transaction ID does
      still protect dead tuples.  A connection which is using an "old"
      snapshot does not get an error unless it accesses a page modified
      recently enough that it might not be able to produce accurate
      results.
      
      This is similar to the Oracle feature, and we use the same SQLSTATE
      and error message for compatibility.
      848ef42b
    • Kevin Grittner's avatar
      Modify BufferGetPage() to prepare for "snapshot too old" feature · 8b65cf4c
      Kevin Grittner authored
      This patch is a no-op patch which is intended to reduce the chances
      of failures of omission once the functional part of the "snapshot
      too old" patch goes in.  It adds parameters for snapshot, relation,
      and an enum to specify whether the snapshot age check needs to be
      done for the page at this point.  This initial patch passes NULL
      for the first two new parameters and BGP_NO_SNAPSHOT_TEST for the
      third.  The follow-on patch will change the places where the test
      needs to be made.
      8b65cf4c
  26. Apr 04, 2016
  27. Apr 03, 2016
    • Tom Lane's avatar
      Fix contrib/bloom to not fail under CLOBBER_CACHE_ALWAYS. · 8f75fd1f
      Tom Lane authored
      The code was supposing that rd_amcache wouldn't disappear from under it
      during a scan; which is wrong.  Copy the data out of the relcache rather
      than trying to reference it there.
      8f75fd1f
    • Tom Lane's avatar
      Clean up some stuff in new contrib/bloom module. · a9284849
      Tom Lane authored
      Coverity complained about implicit sign-extension in the
      BloomPageGetFreeSpace macro, probably because sizeOfBloomTuple isn't wide
      enough for size calculations.  No overflow is really possible as long as
      maxoff and sizeOfBloomTuple are small enough to represent a realistic
      situation, but it seems like a good idea to declare sizeOfBloomTuple as
      Size not int32.
      
      Add missing check on BloomPageAddItem() result, again from Coverity.
      
      Avoid core dump due to not allocating so->sign array when
      scan->numberOfKeys is zero.  Also thanks to Coverity.
      
      Use FLEXIBLE_ARRAY_MEMBER rather than declaring an array as size 1
      when it isn't necessarily.
      
      Very minor beautification of related code.
      
      Unfortunately, none of the Coverity-detected mistakes look like they
      could account for the remaining buildfarm unhappiness with this
      module.  It's barely possible that the FLEXIBLE_ARRAY_MEMBER mistake
      does account for that, if it's enabling bogus compiler optimizations;
      but I'm not terribly optimistic.  We probably still have bugs to
      find here.
      a9284849
  28. Apr 02, 2016
  29. Apr 01, 2016
    • Teodor Sigaev's avatar
      Fixes in bloom contrib module missed during review · 27f3bbfa
      Teodor Sigaev authored
      - macroses llike (var & FLAG) are changed to ((var & FLAG) != 0)
      - do not copy uninitialized part of notFullPage array to page
      27f3bbfa
    • Teodor Sigaev's avatar
      Bloom index contrib module · 9ee014fc
      Teodor Sigaev authored
      Module provides new access method. It is actually a simple Bloom filter
      implemented as pgsql's index. It could give some benefits on search
      with large number of columns.
      
      Module is a single way to test generic WAL interface committed earlier.
      
      Author: Teodor Sigaev, Alexander Korotkov
      Reviewers: Aleksander Alekseev, Michael Paquier, Jim Nasby
      9ee014fc
Loading