Skip to content
Snippets Groups Projects
  1. Dec 27, 2015
  2. Dec 21, 2015
    • Alvaro Herrera's avatar
      Rework internals of changing a type's ownership · f9643d0d
      Alvaro Herrera authored
      This is necessary so that REASSIGN OWNED does the right thing with
      composite types, to wit, that it also alters ownership of the type's
      pg_class entry -- previously, the pg_class entry remained owned by the
      original user, which caused later other failures such as the new owner's
      inability to use ALTER TYPE to rename an attribute of the affected
      composite.  Also, if the original owner is later dropped, the pg_class
      entry becomes owned by a non-existant user which is bogus.
      
      To fix, create a new routine AlterTypeOwner_oid which knows whether to
      pass the request to ATExecChangeOwner or deal with it directly, and use
      that in shdepReassignOwner rather than calling AlterTypeOwnerInternal
      directly.  AlterTypeOwnerInternal is now simpler in that it only
      modifies the pg_type entry and recurses to handle a possible array type;
      higher-level tasks are handled by either AlterTypeOwner directly or
      AlterTypeOwner_oid.
      
      I took the opportunity to add a few more objects to the test rig for
      REASSIGN OWNED, so that more cases are exercised.  Additional ones could
      be added for superuser-only-ownable objects (such as FDWs and event
      triggers) but I didn't want to push my luck by adding a new superuser to
      the tests on a backpatchable bug fix.
      
      Per bug #13666 reported by Chris Pacejo.
      
      This is a backpatch of commit 756e7b4c to branches 9.1 -- 9.4.
      f9643d0d
    • Alvaro Herrera's avatar
      some bullshit · 653530c8
      Alvaro Herrera authored
      653530c8
    • Alvaro Herrera's avatar
      adjust ACL owners for REASSIGN and ALTER OWNER TO · 7af3dd54
      Alvaro Herrera authored
      When REASSIGN and ALTER OWNER TO are used, both the object owner and ACL
      list should be changed from the old owner to the new owner. This patch
      fixes types, foreign data wrappers, and foreign servers to change their
      ACL list properly;  they already changed owners properly.
      
      Report by Alexey Bashtanov
      
      This is a backpatch of commit 59367fdf (for bug #9923) by Bruce
      Momjian to branches 9.1 - 9.4; it wasn't backpatched originally out of
      concerns that it would create a backwards compatibility problem, but per
      discussion related to bug #13666 that turns out to have been misguided.
      (Therefore, the entry in the 9.5 release notes should be removed.)
      
      Note that 9.1 didn't have privileges on types (which were introduced by
      commit 72920557), so this commit only changes foreign-data related
      objects in that branch.
      
      Discussion: http://www.postgresql.org/message-id/20151216224004.GL2618@alvherre.pgsql
      	http://www.postgresql.org/message-id/10227.1450373793@sss.pgh.pa.us
      7af3dd54
    • Tom Lane's avatar
      Remove silly completion for "DELETE FROM tabname ...". · 6ecd7f50
      Tom Lane authored
      psql offered USING, WHERE, and SET in this context, but SET is not a valid
      possibility here.  Seems to have been a thinko in commit f5ab0a14
      which added DELETE's USING option.
      6ecd7f50
  3. Dec 17, 2015
    • Tom Lane's avatar
      Fix improper initialization order for readline. · b4177798
      Tom Lane authored
      Turns out we must set rl_basic_word_break_characters *before* we call
      rl_initialize() the first time, because it will quietly copy that value
      elsewhere --- but only on the first call.  (Love these undocumented
      dependencies.)  I broke this yesterday in commit 2ec477dc;
      like that commit, back-patch to all active branches.  Per report from
      Pavel Stehule.
      b4177798
  4. Dec 16, 2015
    • Tom Lane's avatar
      Cope with Readline's failure to track SIGWINCH events outside of input. · bcce4a5e
      Tom Lane authored
      It emerges that libreadline doesn't notice terminal window size change
      events unless they occur while collecting input.  This is easy to stumble
      over if you resize the window while using a pager to look at query output,
      but it can be demonstrated without any pager involvement.  The symptom is
      that queries exceeding one line are misdisplayed during subsequent input
      cycles, because libreadline has the wrong idea of the screen dimensions.
      
      The safest, simplest way to fix this is to call rl_reset_screen_size()
      just before calling readline().  That causes an extra ioctl(TIOCGWINSZ)
      for every command; but since it only happens when reading from a tty, the
      performance impact should be negligible.  A more valid objection is that
      this still leaves a tiny window during entry to readline() wherein delivery
      of SIGWINCH will be missed; but the practical consequences of that are
      probably negligible.  In any case, there doesn't seem to be any good way to
      avoid the race, since readline exposes no functions that seem safe to call
      from a generic signal handler --- rl_reset_screen_size() certainly isn't.
      
      It turns out that we also need an explicit rl_initialize() call, else
      rl_reset_screen_size() dumps core when called before the first readline()
      call.
      
      rl_reset_screen_size() is not present in old versions of libreadline,
      so we need a configure test for that.  (rl_initialize() is present at
      least back to readline 4.0, so we won't bother with a test for it.)
      We would need a configure test anyway since libedit's emulation of
      libreadline doesn't currently include such a function.  Fortunately,
      libedit seems not to have any corresponding bug.
      
      Merlin Moncure, adjusted a bit by me
      bcce4a5e
  5. Dec 14, 2015
    • Alvaro Herrera's avatar
      Add missing CHECK_FOR_INTERRUPTS in lseg_inside_poly · 48a7074a
      Alvaro Herrera authored
      Apparently, there are bugs in this code that cause it to loop endlessly.
      That bug still needs more research, but in the meantime it's clear that
      the loop is missing a check for interrupts so that it can be cancelled
      timely.
      
      Backpatch to 9.1 -- this has been missing since 49475aab.
      48a7074a
    • Heikki Linnakangas's avatar
      Fix out-of-memory error handling in ParameterDescription message processing. · 1e23caae
      Heikki Linnakangas authored
      If libpq ran out of memory while constructing the result set, it would hang,
      waiting for more data from the server, which might never arrive. To fix,
      distinguish between out-of-memory error and not-enough-data cases, and give
      a proper error message back to the client on OOM.
      
      There are still similar issues in handling COPY start messages, but let's
      handle that as a separate patch.
      
      Michael Paquier, Amit Kapila and me. Backpatch to all supported versions.
      1e23caae
    • Andres Freund's avatar
      Correct statement to actually be the intended assert statement. · ea3f30cf
      Andres Freund authored
      e3f4cfc7 introduced a LWLockHeldByMe() call, without the corresponding
      Assert() surrounding it.
      
      Spotted by Coverity.
      
      Backpatch: 9.1+, like the previous commit
      ea3f30cf
    • Tom Lane's avatar
      Docs: document that psql's "\i -" means read from stdin. · 6436445e
      Tom Lane authored
      This has worked that way for a long time, maybe always, but you would
      not have known it from the documentation.  Also back-patch the notes
      I added to HEAD earlier today about behavior of the "-f -" switch,
      which likewise have been valid for many releases.
      6436445e
  6. Dec 13, 2015
  7. Dec 12, 2015
    • Andres Freund's avatar
      Fix ALTER TABLE ... SET TABLESPACE for unlogged relations. · a15ad670
      Andres Freund authored
      Changing the tablespace of an unlogged relation did not WAL log the
      creation and content of the init fork. Thus, after a standby is
      promoted, unlogged relation cannot be accessed anymore, with errors
      like:
      ERROR:  58P01: could not open file "pg_tblspc/...": No such file or directory
      Additionally the init fork was not synced to disk, independent of the
      configured wal_level, a relatively small durability risk.
      
      Investigation of that problem also brought to light that, even for
      permanent relations, the creation of !main forks was not WAL logged,
      i.e. no XLOG_SMGR_CREATE record were emitted. That mostly turns out not
      to be a problem, because these files were created when the actual
      relation data is copied; nonexistent files are not treated as an error
      condition during replay. But that doesn't work for empty files, and
      generally feels a bit haphazard. Luckily, outside init and main forks,
      empty forks don't occur often or are not a problem.
      
      Add the required WAL logging and syncing to disk.
      
      Reported-By: Michael Paquier
      Author: Michael Paquier and Andres Freund
      Discussion: 20151210163230.GA11331@alap3.anarazel.de
      Backpatch: 9.1, where unlogged relations were introduced
      a15ad670
    • Tom Lane's avatar
      Add an expected-file to match behavior of latest libxml2. · f5eebea8
      Tom Lane authored
      Recent releases of libxml2 do not provide error context reports for errors
      detected at the very end of the input string.  This appears to be a bug, or
      at least an infelicity, introduced by the fix for libxml2's CVE-2015-7499.
      We can hope that this behavioral change will get undone before too long;
      but the security patch is likely to spread a lot faster/further than any
      follow-on cleanup, which means this behavior is likely to be present in the
      wild for some time to come.  As a stopgap, add a variant regression test
      expected-file that matches what you get with a libxml2 that acts this way.
      f5eebea8
  8. Dec 11, 2015
    • Alvaro Herrera's avatar
      For REASSIGN OWNED for foreign user mappings · 629842a8
      Alvaro Herrera authored
      As reported in bug #13809 by Alexander Ashurkov, the code for REASSIGN
      OWNED hadn't gotten word about user mappings.  Deal with them in the
      same way default ACLs do, which is to ignore them altogether; they are
      handled just fine by DROP OWNED.  The other foreign object cases are
      already handled correctly by both commands.
      
      Also add a REASSIGN OWNED statement to foreign_data test to exercise the
      foreign data objects.  (The changes are just before the "cleanup" phase,
      so it shouldn't remove any existing live test.)
      
      Reported by Alexander Ashurkov, then independently by Jaime Casanova.
      629842a8
    • Tom Lane's avatar
      Install our "missing" script where PGXS builds can find it. · 98467b35
      Tom Lane authored
      This allows sane behavior in a PGXS build done on a machine where build
      tools such as bison are missing.
      
      Jim Nasby
      98467b35
  9. Dec 10, 2015
    • Andres Freund's avatar
      Fix bug leading to restoring unlogged relations from empty files. · 2de281da
      Andres Freund authored
      At the end of crash recovery, unlogged relations are reset to the empty
      state, using their init fork as the template. The init fork is copied to
      the main fork without going through shared buffers. Unfortunately WAL
      replay so far has not necessarily flushed writes from shared buffers to
      disk at that point. In normal crash recovery, and before the
      introduction of 'fast promotions' in fd4ced52 / 9.3, the
      END_OF_RECOVERY checkpoint flushes the buffers out in time. But with
      fast promotions that's not the case anymore.
      
      To fix, force WAL writes targeting the init fork to be flushed
      immediately (using the new FlushOneBuffer() function). In 9.5+ that
      flush can centrally be triggered from the code dealing with restoring
      full page writes (XLogReadBufferForRedoExtended), in earlier releases
      that responsibility is in the hands of XLOG_HEAP_NEWPAGE's replay
      function.
      
      Backpatch to 9.1, even if this currently is only known to trigger in
      9.3+. Flushing earlier is more robust, and it is advantageous to keep
      the branches similar.
      
      Typical symptoms of this bug are errors like
      'ERROR:  index "..." contains unexpected zero page at block 0'
      shortly after promoting a node.
      
      Reported-By: Thom Brown
      Author: Andres Freund and Michael Paquier
      Discussion: 20150326175024.GJ451@alap3.anarazel.de
      Backpatch: 9.1-
      2de281da
    • Tom Lane's avatar
      Accept flex > 2.5.x on Windows, too. · 7f94a5c1
      Tom Lane authored
      Commit 32f15d05 fixed this in configure, but missed the similar check
      in the MSVC scripts.
      
      Michael Paquier, per report from Victor Wagner
      7f94a5c1
  10. Dec 04, 2015
    • Tom Lane's avatar
      Further improve documentation of the role-dropping process. · 255cc9b2
      Tom Lane authored
      In commit 1ea0c73c I added a section to user-manag.sgml about how to drop
      roles that own objects; but as pointed out by Stephen Frost, I neglected
      that shared objects (databases or tablespaces) may need special treatment.
      Fix that.  Back-patch to supported versions, like the previous patch.
      255cc9b2
  11. Dec 01, 2015
    • Tom Lane's avatar
      Make gincostestimate() cope with hypothetical GIN indexes. · 3d4bdd2f
      Tom Lane authored
      We tried to fetch statistics data from the index metapage, which does not
      work if the index isn't actually present.  If the index is hypothetical,
      instead extrapolate some plausible internal statistics based on the index
      page count provided by the index-advisor plugin.
      
      There was already some code in gincostestimate() to invent internal stats
      in this way, but since it was only meant as a stopgap for pre-9.1 GIN
      indexes that hadn't been vacuumed since upgrading, it was pretty crude.
      If we want it to support index advisors, we should try a little harder.
      A small amount of testing says that it's better to estimate the entry pages
      as 90% of the index, not 100%.  Also, estimating the number of entries
      (keys) as equal to the heap tuple count could be wildly wrong in either
      direction.  Instead, let's estimate 100 entries per entry page.
      
      Perhaps someday somebody will want the index advisor to be able to provide
      these numbers more directly, but for the moment this should serve.
      
      Problem report and initial patch by Julien Rouhaud; modified by me to
      invent less-bogus internal statistics.  Back-patch to all supported
      branches, since we've supported index advisors since 9.0.
      3d4bdd2f
    • Tom Lane's avatar
      Use "g" not "f" format in ecpg's PGTYPESnumeric_from_double(). · 74cf6def
      Tom Lane authored
      The previous coding could overrun the provided buffer size for a very large
      input, or lose precision for a very small input.  Adopt the methodology
      that's been in use in the equivalent backend code for a long time.
      
      Per private report from Bas van Schaik.  Back-patch to all supported
      branches.
      74cf6def
  12. Nov 26, 2015
    • Tom Lane's avatar
      Fix failure to consider failure cases in GetComboCommandId(). · 47e189b5
      Tom Lane authored
      Failure to initially palloc the comboCids array, or to realloc it bigger
      when needed, left combocid's data structures in an inconsistent state that
      would cause trouble if the top transaction continues to execute.  Noted
      while examining a user complaint about the amount of memory used for this.
      (There's not much we can do about that, but it does point up that repalloc
      failure has a non-negligible chance of occurring here.)
      
      In HEAD/9.5, also avoid possible invocation of memcpy() with a null pointer
      in SerializeComboCIDState; cf commit 13bba022.
      47e189b5
  13. Nov 25, 2015
    • Tom Lane's avatar
      Be more paranoid about null return values from libpq status functions. · d44b4dea
      Tom Lane authored
      PQhost() can return NULL in non-error situations, namely when a Unix-socket
      connection has been selected by default.  That behavior is a tad debatable
      perhaps, but for the moment we should make sure that psql copes with it.
      Unfortunately, do_connect() failed to: it could pass a NULL pointer to
      strcmp(), resulting in crashes on most platforms.  This was reported as a
      security issue by ChenQin of Topsec Security Team, but the consensus of
      the security list is that it's just a garden-variety bug with no security
      implications.
      
      For paranoia's sake, I made the keep_password test not trust PQuser or
      PQport either, even though I believe those will never return NULL given
      a valid PGconn.
      
      Back-patch to all supported branches.
      d44b4dea
  14. Nov 24, 2015
  15. Nov 23, 2015
  16. Nov 22, 2015
    • Tom Lane's avatar
      Adopt the GNU convention for handling tar-archive members exceeding 8GB. · b054ca03
      Tom Lane authored
      The POSIX standard for tar headers requires archive member sizes to be
      printed in octal with at most 11 digits, limiting the representable file
      size to 8GB.  However, GNU tar and apparently most other modern tars
      support a convention in which oversized values can be stored in base-256,
      allowing any practical file to be a tar member.  Adopt this convention
      to remove two limitations:
      * pg_dump with -Ft output format failed if the contents of any one table
      exceeded 8GB.
      * pg_basebackup failed if the data directory contained any file exceeding
      8GB.  (This would be a fatal problem for installations configured with a
      table segment size of 8GB or more, and it has also been seen to fail when
      large core dump files exist in the data directory.)
      
      File sizes under 8GB are still printed in octal, so that no compatibility
      issues are created except in cases that would have failed entirely before.
      
      In addition, this patch fixes several bugs in the same area:
      
      * In 9.3 and later, we'd defined tarCreateHeader's file-size argument as
      size_t, which meant that on 32-bit machines it would write a corrupt tar
      header for file sizes between 4GB and 8GB, even though no error was raised.
      This broke both "pg_dump -Ft" and pg_basebackup for such cases.
      
      * pg_restore from a tar archive would fail on tables of size between 4GB
      and 8GB, on machines where either "size_t" or "unsigned long" is 32 bits.
      This happened even with an archive file not affected by the previous bug.
      
      * pg_basebackup would fail if there were files of size between 4GB and 8GB,
      even on 64-bit machines.
      
      * In 9.3 and later, "pg_basebackup -Ft" failed entirely, for any file size,
      on 64-bit big-endian machines.
      
      In view of these potential data-loss bugs, back-patch to all supported
      branches, even though removal of the documented 8GB limit might otherwise
      be considered a new feature rather than a bug fix.
      b054ca03
  17. Nov 20, 2015
    • Tom Lane's avatar
      Fix handling of inherited check constraints in ALTER COLUMN TYPE (again). · c49279df
      Tom Lane authored
      The previous way of reconstructing check constraints was to do a separate
      "ALTER TABLE ONLY tab ADD CONSTRAINT" for each table in an inheritance
      hierarchy.  However, that way has no hope of reconstructing the check
      constraints' own inheritance properties correctly, as pointed out in
      bug #13779 from Jan Dirk Zijlstra.  What we should do instead is to do
      a regular "ALTER TABLE", allowing recursion, at the topmost table that
      has a particular constraint, and then suppress the work queue entries
      for inherited instances of the constraint.
      
      Annoyingly, we'd tried to fix this behavior before, in commit 5ed6546c,
      but we failed to notice that it wasn't reconstructing the pg_constraint
      field values correctly.
      
      As long as I'm touching pg_get_constraintdef_worker anyway, tweak it to
      always schema-qualify the target table name; this seems like useful backup
      to the protections installed by commit 5f173040.
      
      In HEAD/9.5, get rid of get_constraint_relation_oids, which is now unused.
      (I could alternatively have modified it to also return conislocal, but that
      seemed like a pretty single-purpose API, so let's not pretend it has some
      other use.)  It's unused in the back branches as well, but I left it in
      place just in case some third-party code has decided to use it.
      
      In HEAD/9.5, also rename pg_get_constraintdef_string to
      pg_get_constraintdef_command, as the previous name did nothing to explain
      what that entry point did differently from others (and its comment was
      equally useless).  Again, that change doesn't seem like material for
      back-patching.
      
      I did a bit of re-pgindenting in tablecmds.c in HEAD/9.5, as well.
      
      Otherwise, back-patch to all supported branches.
      c49279df
  18. Nov 18, 2015
    • Tom Lane's avatar
      Accept flex > 2.5.x in configure. · 6e1d26f1
      Tom Lane authored
      Per buildfarm member anchovy, 2.6.0 exists in the wild now.
      Hopefully it works with Postgres; if not, we'll have to do something
      about that, but in any case claiming it's "too old" is pretty silly.
      6e1d26f1
  19. Nov 17, 2015
    • Tom Lane's avatar
      Fix possible internal overflow in numeric division. · c47bdb37
      Tom Lane authored
      div_var_fast() postpones propagating carries in the same way as mul_var(),
      so it has the same corner-case overflow risk we fixed in 246693e5,
      namely that the size of the carries has to be accounted for when setting
      the threshold for executing a carry propagation step.  We've not devised
      a test case illustrating the brokenness, but the required fix seems clear
      enough.  Like the previous fix, back-patch to all active branches.
      
      Dean Rasheed
      c47bdb37
  20. Nov 15, 2015
    • Tom Lane's avatar
      Fix ruleutils.c's dumping of whole-row Vars in ROW() and VALUES() contexts. · ed824cf8
      Tom Lane authored
      Normally ruleutils prints a whole-row Var as "foo.*".  We already knew that
      that doesn't work at top level of a SELECT list, because the parser would
      treat the "*" as a directive to expand the reference into separate columns,
      not a whole-row Var.  However, Joshua Yanovski points out in bug #13776
      that the same thing happens at top level of a ROW() construct; and some
      nosing around in the parser shows that the same is true in VALUES().
      Hence, apply the same workaround already devised for the SELECT-list case,
      namely to add a forced cast to the appropriate rowtype in these cases.
      (The alternative of just printing "foo" was rejected because it is
      difficult to avoid ambiguity against plain columns named "foo".)
      
      Back-patch to all supported branches.
      ed824cf8
  21. Nov 14, 2015
    • Peter Eisentraut's avatar
      PL/Python: Make tests pass with Python 3.5 · 82076c1e
      Peter Eisentraut authored
      The error message wording for AttributeError has changed in Python 3.5.
      For the plpython_error test, add a new expected file.  In the
      plpython_subtransaction test, we didn't really care what the exception
      is, only that it is something coming from Python.  So use a generic
      exception instead, which has a message that doesn't vary across
      versions.
      82076c1e
    • Bruce Momjian's avatar
      pg_upgrade: properly detect file copy failure on Windows · b4c4220e
      Bruce Momjian authored
      Previously, file copy failures were ignored on Windows due to an
      incorrect return value check.
      
      Report by Manu Joye
      
      Backpatch through 9.1
      b4c4220e
  22. Nov 10, 2015
    • Tom Lane's avatar
      Improve our workaround for 'TeX capacity exceeded' in building PDF files. · e12a99c8
      Tom Lane authored
      In commit a5ec86a7 I wrote a quick hack
      that reduced the number of TeX string pool entries created while converting
      our documentation to PDF form.  That held the fort for awhile, but as of
      HEAD we're back up against the same limitation.  It turns out that the
      original coding of \FlowObjectSetup actually results in *three* string pool
      entries being generated for every "flow object" (that is, potential
      cross-reference target) in the documentation, and my previous hack only got
      rid of one of them.  With a little more care, we can reduce the string
      count to one per flow object plus one per actually-cross-referenced flow
      object (about 115000 + 5000 as of current HEAD); that should work until
      the documentation volume roughly doubles from where it is today.
      
      As a not-incidental side benefit, this change also causes pdfjadetex to
      stop emitting unreferenced hyperlink anchors (bookmarks) into the PDF file.
      It had been making one willy-nilly for every flow object; now it's just one
      per actually-cross-referenced object.  This results in close to a 2X
      savings in PDF file size.  We will still want to run the output through
      "jpdftweak" to get it to be compressed; but we no longer need removal of
      unreferenced bookmarks, so we might be able to find a quicker tool for
      that step.
      
      Although the failure only affects HEAD and US-format output at the moment,
      9.5 cannot be more than a few pages short of failing likewise, so it
      will inevitably fail after a few rounds of minor-version release notes.
      I don't have a lot of faith that we'll never hit the limit in the older
      branches; and anyway it would be nice to get rid of jpdftweak across the
      board.  Therefore, back-patch to all supported branches.
      e12a99c8
  23. Nov 08, 2015
    • Noah Misch's avatar
      Don't connect() to a wildcard address in test_postmaster_connection(). · 99027350
      Noah Misch authored
      At least OpenBSD, NetBSD, and Windows don't support it.  This repairs
      pg_ctl for listen_addresses='0.0.0.0' and listen_addresses='::'.  Since
      pg_ctl prefers to test a Unix-domain socket, Windows users are most
      likely to need this change.  Back-patch to 9.1 (all supported versions).
      This could change pg_ctl interaction with loopback-interface firewall
      rules.  Therefore, in 9.4 and earlier (released branches), activate the
      change only on known-affected platforms.
      
      Reported (bug #13611) and designed by Kondo Yuta.
      99027350
  24. Nov 07, 2015
    • Tom Lane's avatar
      Fix enforcement of restrictions inside regexp lookaround constraints. · bfb10db8
      Tom Lane authored
      Lookahead and lookbehind constraints aren't allowed to contain backrefs,
      and parentheses within them are always considered non-capturing.  Or so
      says the manual.  But the regexp parser forgot about these rules once
      inside a parenthesized subexpression, so that constructs like (\w)(?=(\1))
      were accepted (but then not correctly executed --- a case like this acted
      like (\w)(?=\w), without any enforcement that the two \w's match the same
      text).  And in (?=((foo))) the innermost parentheses would be counted as
      capturing parentheses, though no text would ever be captured for them.
      
      To fix, properly pass down the "type" argument to the recursive invocation
      of parse().
      
      Back-patch to all supported branches; it was agreed that silent
      misexecution of such patterns is worse than throwing an error, even though
      new errors in minor releases are generally not desirable.
      bfb10db8
  25. Oct 31, 2015
    • Kevin Grittner's avatar
      Fix serialization anomalies due to race conditions on INSERT. · caff7fc3
      Kevin Grittner authored
      On insert the CheckForSerializableConflictIn() test was performed
      before the page(s) which were going to be modified had been locked
      (with an exclusive buffer content lock).  If another process
      acquired a relation SIReadLock on the heap and scanned to a page on
      which an insert was going to occur before the page was so locked,
      a rw-conflict would be missed, which could allow a serialization
      anomaly to be missed.  The window between the check and the page
      lock was small, so the bug was generally not noticed unless there
      was high concurrency with multiple processes inserting into the
      same table.
      
      This was reported by Peter Bailis as bug #11732, by Sean Chittenden
      as bug #13667, and by others.
      
      The race condition was eliminated in heap_insert() by moving the
      check down below the acquisition of the buffer lock, which had been
      the very next statement.  Because of the loop locking and unlocking
      multiple buffers in heap_multi_insert() a check was added after all
      inserts were completed.  The check before the start of the inserts
      was left because it might avoid a large amount of work to detect a
      serialization anomaly before performing the all of the inserts and
      the related WAL logging.
      
      While investigating this bug, other SSI bugs which were even harder
      to hit in practice were noticed and fixed, an unnecessary check
      (covered by another check, so redundant) was removed from
      heap_update(), and comments were improved.
      
      Back-patch to all supported branches.
      
      Kevin Grittner and Thomas Munro
      caff7fc3
  26. Oct 20, 2015
    • Noah Misch's avatar
      Fix back-patch of commit 8e3b4d9d. · 887d9142
      Noah Misch authored
      master emits an extra context message compared to 9.5 and earlier.
      887d9142
    • Noah Misch's avatar
      Eschew "RESET statement_timeout" in tests. · 934fdaac
      Noah Misch authored
      Instead, use transaction abort.  Given an unlucky bout of latency, the
      timeout would cancel the RESET itself.  Buildfarm members gharial,
      lapwing, mereswine, shearwater, and sungazer witness that.  Back-patch
      to 9.1 (all supported versions).  The query_canceled test still could
      timeout before entering its subtransaction; for whatever reason, that
      has yet to happen on the buildfarm.
      934fdaac
  27. Oct 19, 2015
    • Tom Lane's avatar
      Fix incorrect handling of lookahead constraints in pg_regprefix(). · 05e62ff5
      Tom Lane authored
      pg_regprefix was doing nothing with lookahead constraints, which would
      be fine if it were the right kind of nothing, but it isn't: we have to
      terminate our search for a fixed prefix, not just pretend the LACON arc
      isn't there.  Otherwise, if the current state has both a LACON outarc and a
      single plain-color outarc, we'd falsely conclude that the color represents
      an addition to the fixed prefix, and generate an extracted index condition
      that restricts the indexscan too much.  (See added regression test case.)
      
      Terminating the search is conservative: we could traverse the LACON arc
      (thus assuming that the constraint can be satisfied at runtime) and then
      examine the outarcs of the linked-to state.  But that would be a lot more
      work than it seems worth, because writing a LACON followed by a single
      plain character is a pretty silly thing to do.
      
      This makes a difference only in rather contrived cases, but it's a bug,
      so back-patch to all supported branches.
      05e62ff5
  28. Oct 18, 2015
Loading