Skip to content
Snippets Groups Projects
  1. Jun 07, 2016
  2. Jun 05, 2016
    • Tom Lane's avatar
      Properly initialize SortSupport for ORDER BY rechecks in nodeIndexscan.c. · 8a859691
      Tom Lane authored
      Fix still another bug in commit 35fcb1b3: it failed to fully initialize
      the SortSupport states it introduced to allow the executor to re-check
      ORDER BY expressions containing distance operators.  That led to a null
      pointer dereference if the sortsupport code tried to use ssup_cxt.  The
      problem only manifests in narrow cases, explaining the lack of previous
      field reports.  It requires a GiST-indexable distance operator that lacks
      SortSupport and is on a pass-by-ref data type, which among core+contrib
      seems to be only btree_gist's interval opclass; and it requires the scan
      to be done as an IndexScan not an IndexOnlyScan, which explains how
      btree_gist's regression test didn't catch it.  Per bug #14134 from
      Jihyun Yu.
      
      Peter Geoghegan
      
      Report: <20160511154904.2603.43889@wrigleys.postgresql.org>
      8a859691
  3. Jun 04, 2016
  4. 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
  5. 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
  6. 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
  7. May 16, 2016
    • Robert Haas's avatar
      postgres_fdw: Fix the fix for crash when pushing down multiple joins. · 02a568a0
      Robert Haas authored
      Commit 3151f16e was intended to be
      a commit of a patch from Ashutosh Bapat, but instead I mistakenly
      committed an earlier version from Michael Paquier (because both
      patches were submitted with the same filename, and I confused them).
      Michael's patch fixes the crash but doesn't actually implement the
      correct test.
      
      Repair the incorrect logic, and also expand the comments considerably
      so that this is all more clear.
      
      Ashutosh Bapat and Robert Haas
      02a568a0
    • Robert Haas's avatar
      Fix multiple problems in postgres_fdw query cancellation logic. · 1b812afb
      Robert Haas authored
      First, even if we cancel a query, we still have to roll back the
      containing transaction; otherwise, the session will be left in a
      failed transaction state.
      
      Second, we need to support canceling queries whe aborting a
      subtransaction as well as when aborting a toplevel transaction.
      
      Etsuro Fujita, reviewed by Michael Paquier
      1b812afb
  8. May 13, 2016
    • Tom Lane's avatar
      Ensure plan stability in contrib/btree_gist regression test. · d94977ef
      Tom Lane authored
      Buildfarm member skink failed with symptoms suggesting that an
      auto-analyze had happened and changed the plan displayed for a
      test query.  Although this is evidently of low probability,
      regression tests that sometimes fail are no fun, so add commands
      to force a bitmap scan to be chosen.
      d94977ef
  9. May 03, 2016
    • Robert Haas's avatar
      Tweak a few more things in preparation for upcoming pgindent run. · 8826d850
      Robert Haas authored
      These adjustments adjust code and comments in minor ways to prevent
      pgindent from mangling them.  Among other things, I tried to avoid
      situations where pgindent would emit "a +b" instead of "a + b", and I
      tried to avoid having it break up inline comments across multiple
      lines.
      8826d850
  10. May 02, 2016
    • Heikki Linnakangas's avatar
      Remove unused macros. · d22b85fb
      Heikki Linnakangas authored
      CHECK_PAGE_OFFSET_RANGE() has been unused forever.
      CHECK_RELATION_BLOCK_RANGE() has been unused in pgstatindex.c ever since
      bt_page_stats() and bt_page_items() functions were moved from pgstattuple
      to pageinspect module. It still exists in pageinspect/btreefuncs.c.
      
      Daniel Gustafsson
      d22b85fb
  11. Apr 28, 2016
  12. Apr 22, 2016
    • Tom Lane's avatar
      Convert contrib/seg's bool-returning SQL functions to V1 call convention. · c8e81afc
      Tom Lane authored
      It appears that we can no longer get away with using V0 call convention
      for bool-returning functions in newer versions of MSVC.  The compiler
      seems to generate code that doesn't clear the higher-order bits of the
      result register, causing the bool result Datum to often read as "true"
      when "false" was intended.  This is not very surprising, since the
      function thinks it's returning a bool-width result but fmgr_oldstyle
      assumes that V0 functions return "char *"; what's surprising is that
      that hack worked for so long on so many platforms.
      
      The only functions of this description in core+contrib are in contrib/seg,
      which we'd intentionally left mostly in V0 style to serve as a warning
      canary if V0 call convention breaks.  We could imagine hacking things
      so that they're still V0 (we'd have to redeclare the bool-returning
      functions as returning some suitably wide integer type, like size_t,
      at the C level).  But on the whole it seems better to convert 'em to V1.
      We can still leave the pointer- and int-returning functions in V0 style,
      so that the test coverage isn't gone entirely.
      
      Back-patch to 9.5, since our intention is to support VS2015 in 9.5
      and later.  There's no SQL-level change in the functions' behavior
      so back-patching should be safe enough.
      
      Discussion: <22094.1461273324@sss.pgh.pa.us>
      
      Michael Paquier, adjusted some by me
      c8e81afc
  13. 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
    • Robert Haas's avatar
      Allow queries submitted by postgres_fdw to be canceled. · f039eaac
      Robert Haas authored
      This fixes a problem which is not new, but with the advent of direct
      foreign table modification in 0bf3ae88,
      it's somewhat more likely to be annoying than previously.  So,
      arrange for a local query cancelation to propagate to the remote side.
      
      Michael Paquier, reviewed by Etsuro Fujita.	 Original report by
      Thom Brown.
      f039eaac
    • Robert Haas's avatar
      postgres_fdw: Don't push down certain full joins. · 5b1f9ce1
      Robert Haas authored
      If there's a filter condition on either side of a full outer join,
      it is neither correct to attach it to the join's ON clause nor to
      throw it into the toplevel WHERE clause.  Just don't push down the
      join in that case.
      
      To maximize the number of cases where we can still push down full
      joins, push inner join conditions into the ON clause at the first
      opportunity rather than postponing them to the top-level WHERE
      clause.  This produces nicer SQL, anyway.
      
      This bug was introduced in e4106b25.
      
      Ashutosh Bapat, per report from Rajkumar Raghuwanshi.
      5b1f9ce1
  14. 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
  15. Apr 15, 2016
    • Robert Haas's avatar
      postgres_fdw: Clean up handling of system columns. · da7d44b6
      Robert Haas authored
      Previously, querying the xmin column of a single postgres_fdw foreign
      table fetched the tuple length, xmax the typmod, and cmin or cmax the
      composite type OID of the tuple.  However, when you queried several
      such tables and the join got shipped to the remote side, these columns
      ended up containing the remote values of the corresponding columns.
      Both behaviors are rather unprincipled, the former for obvious reasons
      and the latter because the remote values of these columns don't have
      any local significance; our transaction IDs are in a different space
      than those of the remote machine.  Clean this up by setting all of
      these fields to 0 in both cases.  Also fix the handling of tableoid
      to be sane.
      
      Robert Haas and Ashutosh Bapat, reviewed by Etsuro Fujita.
      da7d44b6
    • Tom Lane's avatar
      Fix core dump in ReorderBufferRestoreChange on alignment-picky platforms. · 6a3d3965
      Tom Lane authored
      When re-reading an update involving both an old tuple and a new tuple from
      disk, reorderbuffer.c was careless about whether the new tuple is suitably
      aligned for direct access --- in general, it isn't.  We'd missed seeing
      this in the buildfarm because the contrib/test_decoding tests exercise this
      code path only a few times, and by chance all of those cases have old
      tuples with length a multiple of 4, which is usually enough to make the
      access to the new tuple's t_len safe.  For some still-not-entirely-clear
      reason, however, Debian's sparc build gets a bus error, as reported by
      Christoph Berg; perhaps it's assuming 8-byte alignment of the pointer?
      
      The lack of previous field reports is probably because you need all of
      these conditions to trigger a crash: an alignment-picky platform (not
      Intel), a transaction large enough to spill to disk, an update within
      that xact that changes a primary-key field and has an odd-length old tuple,
      and of course logical decoding tracing the transaction.
      
      Avoid the alignment assumption by using memcpy instead of fetching t_len
      directly, and add a test case that exposes the crash on picky platforms.
      Back-patch to 9.4 where the bug was introduced.
      
      Discussion: <20160413094117.GC21485@msg.credativ.de>
      6a3d3965
  16. Apr 14, 2016
    • Andres Freund's avatar
      Add required database and origin filtering for logical messages. · be65eddd
      Andres Freund authored
      Logical messages, added in 3fe3511d, during decoding failed to filter
      messages emitted in other databases and messages emitted "under" a
      replication origin the output plugin isn't interested in.
      
      Add tests to verify that both types of filtering actually work. While
      touching message.sql remove hunk obsoleted by d25379eb.
      
      Bump XLOG_PAGE_MAGIC because xl_logical_message changed and because
      3fe3511d had omitted doing so. 3fe3511d additionally didn't bump
      catversion, but 7a542700 has done so since.
      
      Author: Petr Jelinek
      Reported-By: Andres Freund
      Discussion: 20160406142513.wotqy3ba3kanr423@alap3.anarazel.de
      be65eddd
  17. 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
  18. Apr 11, 2016
    • Andres Freund's avatar
      Allow Pin/UnpinBuffer to operate in a lockfree manner. · 48354581
      Andres Freund authored
      Pinning/Unpinning a buffer is a very frequent operation; especially in
      read-mostly cache resident workloads. Benchmarking shows that in various
      scenarios the spinlock protecting a buffer header's state becomes a
      significant bottleneck. The problem can be reproduced with pgbench -S on
      larger machines, but can be considerably worse for queries which touch
      the same buffers over and over at a high frequency (e.g. nested loops
      over a small inner table).
      
      To allow atomic operations to be used, cram BufferDesc's flags,
      usage_count, buf_hdr_lock, refcount into a single 32bit atomic variable;
      that allows to manipulate them together using 32bit compare-and-swap
      operations. This requires reducing MAX_BACKENDS to 2^18-1 (which could
      be lifted by using a 64bit field, but it's not a realistic configuration
      atm).
      
      As not all operations can easily implemented in a lockfree manner,
      implement the previous buf_hdr_lock via a flag bit in the atomic
      variable. That way we can continue to lock the header in places where
      it's needed, but can get away without acquiring it in the more frequent
      hot-paths.  There's some additional operations which can be done without
      the lock, but aren't in this patch; but the most important places are
      covered.
      
      As bufmgr.c now essentially re-implements spinlocks, abstract the delay
      logic from s_lock.c into something more generic. It now has already two
      users, and more are coming up; there's a follupw patch for lwlock.c at
      least.
      
      This patch is based on a proof-of-concept written by me, which Alexander
      Korotkov made into a fully working patch; the committed version is again
      revised by me.  Benchmarking and testing has, amongst others, been
      provided by Dilip Kumar, Alexander Korotkov, Robert Haas.
      
      On a large x86 system improvements for readonly pgbench, with a high
      client count, of a factor of 8 have been observed.
      
      Author: Alexander Korotkov and Andres Freund
      Discussion: 2400449.GjM57CE0Yg@dinodell
      48354581
  19. 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
  20. Apr 09, 2016
  21. 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
    • Teodor Sigaev's avatar
      Revert CREATE INDEX ... INCLUDING ... · 8b99edef
      Teodor Sigaev authored
      It's not ready yet, revert two commits
      690c5435 - unstable test output
      386e3d76 - patch itself
      8b99edef
    • Teodor Sigaev's avatar
      Fix output of regression test of contrib/tsearch2 · 38627f68
      Teodor Sigaev authored
      Just forget to add in 1ec4c7c0
      38627f68
    • Teodor Sigaev's avatar
      CREATE INDEX ... INCLUDING (column[, ...]) · 386e3d76
      Teodor Sigaev authored
      Now indexes (but only B-tree for now) can contain "extra" column(s) which
      doesn't participate in index structure, they are just stored in leaf
      tuples. It allows to use index only scan by using single index instead
      of two or more indexes.
      
      Author: Anastasia Lubennikova with minor editorializing by me
      Reviewers: David Rowley, Peter Geoghegan, Jeff Janes
      386e3d76
    • Peter Eisentraut's avatar
      Replace printf format %i by %d · 339025c6
      Peter Eisentraut authored
      see also ce8d7bb6
      339025c6
    • Peter Eisentraut's avatar
      Fix printf format · 8b737f90
      Peter Eisentraut authored
      8b737f90
  22. Apr 07, 2016
    • Teodor Sigaev's avatar
      Phrase full text search. · bb140506
      Teodor Sigaev authored
      Patch introduces new text search operator (<-> or <DISTANCE>) into tsquery.
      On-disk and binary in/out format of tsquery are backward compatible.
      It has two side effect:
      - change order for tsquery, so, users, who has a btree index over tsquery,
        should reindex it
      - less number of parenthesis in tsquery output, and tsquery becomes more
        readable
      
      Authors: Teodor Sigaev, Oleg Bartunov, Dmitry Ivanov
      Reviewers: Alexander Korotkov, Artur Zakirov
      bb140506
  23. Apr 06, 2016
Loading