Skip to content
Snippets Groups Projects
  1. Jun 27, 2015
    • Andres Freund's avatar
      Fix test_decoding's handling of nonexistant columns in old tuple versions. · d47a1136
      Andres Freund authored
      test_decoding used fastgetattr() to extract column values. That's wrong
      when decoding updates and deletes if a table's replica identity is set
      to FULL and new columns have been added since the old version of the
      tuple was created. Due to the lack of a crosscheck with the datum's
      natts values an invalid value will be output, leading to errors or
      worse.
      
      Bug: #13470
      Reported-By: Krzysztof Kotlarski
      Discussion: 20150626100333.3874.90852@wrigleys.postgresql.org
      
      Backpatch to 9.4, where the feature, including the bug, was added.
      d47a1136
  2. May 24, 2015
  3. May 20, 2015
    • Heikki Linnakangas's avatar
      Collection of typo fixes. · 4fc72cc7
      Heikki Linnakangas authored
      Use "a" and "an" correctly, mostly in comments. Two error messages were
      also fixed (they were just elogs, so no translation work required). Two
      function comments in pg_proc.h were also fixed. Etsuro Fujita reported one
      of these, but I found a lot more with grep.
      
      Also fix a few other typos spotted while grepping for the a/an typos.
      For example, "consists out of ..." -> "consists of ...". Plus a "though"/
      "through" mixup reported by Euler Taveira.
      
      Many of these typos were in old code, which would be nice to backpatch to
      make future backpatching easier. But much of the code was new, and I didn't
      feel like crafting separate patches for each branch. So no backpatching.
      4fc72cc7
  4. May 12, 2015
  5. May 08, 2015
    • Andres Freund's avatar
      Remove dependency on ordering in logical decoding upsert test. · 581f4f96
      Andres Freund authored
      Buildfarm member magpie sorted the output differently than intended by
      Peter. "Resolve" the problem by simply not aggregating, it's not that
      many lines.
      581f4f96
    • Andres Freund's avatar
      Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE. · 168d5805
      Andres Freund authored
      The newly added ON CONFLICT clause allows to specify an alternative to
      raising a unique or exclusion constraint violation error when inserting.
      ON CONFLICT refers to constraints that can either be specified using a
      inference clause (by specifying the columns of a unique constraint) or
      by naming a unique or exclusion constraint.  DO NOTHING avoids the
      constraint violation, without touching the pre-existing row.  DO UPDATE
      SET ... [WHERE ...] updates the pre-existing tuple, and has access to
      both the tuple proposed for insertion and the existing tuple; the
      optional WHERE clause can be used to prevent an update from being
      executed.  The UPDATE SET and WHERE clauses have access to the tuple
      proposed for insertion using the "magic" EXCLUDED alias, and to the
      pre-existing tuple using the table name or its alias.
      
      This feature is often referred to as upsert.
      
      This is implemented using a new infrastructure called "speculative
      insertion". It is an optimistic variant of regular insertion that first
      does a pre-check for existing tuples and then attempts an insert.  If a
      violating tuple was inserted concurrently, the speculatively inserted
      tuple is deleted and a new attempt is made.  If the pre-check finds a
      matching tuple the alternative DO NOTHING or DO UPDATE action is taken.
      If the insertion succeeds without detecting a conflict, the tuple is
      deemed inserted.
      
      To handle the possible ambiguity between the excluded alias and a table
      named excluded, and for convenience with long relation names, INSERT
      INTO now can alias its target table.
      
      Bumps catversion as stored rules change.
      
      Author: Peter Geoghegan, with significant contributions from Heikki
          Linnakangas and Andres Freund. Testing infrastructure by Jeff Janes.
      Reviewed-By: Heikki Linnakangas, Andres Freund, Robert Haas, Simon Riggs,
          Dean Rasheed, Stephen Frost and many others.
      168d5805
  6. Apr 30, 2015
    • Peter Eisentraut's avatar
      Fix parallel make risk with new check temp-install setup · dbf2ec1a
      Peter Eisentraut authored
      The "check" target no longer needs to depend on "all", because it now
      runs "install" directly, which in turn depends on "all".  Doing both
      will cause problems with parallel make, because two builds will run next
      to each other.
      
      Also remove the redirection of the temp-install output into a log file.
      This was appropriate when this was done from within pg_regress, but now
      it's just a regular make run, and especially with the above changes this
      will now take the place of running the "all" target before the test
      suites.
      
      problem report by Jeff Janes, patch in part by Michael Paquier
      dbf2ec1a
  7. Apr 29, 2015
    • Andres Freund's avatar
      Introduce replication progress tracking infrastructure. · 5aa23504
      Andres Freund authored
      When implementing a replication solution ontop of logical decoding, two
      related problems exist:
      * How to safely keep track of replication progress
      * How to change replication behavior, based on the origin of a row;
        e.g. to avoid loops in bi-directional replication setups
      
      The solution to these problems, as implemented here, consist out of
      three parts:
      
      1) 'replication origins', which identify nodes in a replication setup.
      2) 'replication progress tracking', which remembers, for each
         replication origin, how far replay has progressed in a efficient and
         crash safe manner.
      3) The ability to filter out changes performed on the behest of a
         replication origin during logical decoding; this allows complex
         replication topologies. E.g. by filtering all replayed changes out.
      
      Most of this could also be implemented in "userspace", e.g. by inserting
      additional rows contain origin information, but that ends up being much
      less efficient and more complicated.  We don't want to require various
      replication solutions to reimplement logic for this independently. The
      infrastructure is intended to be generic enough to be reusable.
      
      This infrastructure also replaces the 'nodeid' infrastructure of commit
      timestamps. It is intended to provide all the former capabilities,
      except that there's only 2^16 different origins; but now they integrate
      with logical decoding. Additionally more functionality is accessible via
      SQL.  Since the commit timestamp infrastructure has also been introduced
      in 9.5 (commit 73c986ad) changing the API is not a problem.
      
      For now the number of origins for which the replication progress can be
      tracked simultaneously is determined by the max_replication_slots
      GUC. That GUC is not a perfect match to configure this, but there
      doesn't seem to be sufficient reason to introduce a separate new one.
      
      Bumps both catversion and wal page magic.
      
      Author: Andres Freund, with contributions from Petr Jelinek and Craig Ringer
      Reviewed-By: Heikki Linnakangas, Petr Jelinek, Robert Haas, Steve Singer
      Discussion: 20150216002155.GI15326@awork2.anarazel.de,
          20140923182422.GA15776@alap3.anarazel.de,
          20131114172632.GE7522@alap2.anarazel.de
      5aa23504
  8. Apr 23, 2015
    • Peter Eisentraut's avatar
      Improve speed of make check-world · dcae5fac
      Peter Eisentraut authored
      Before, make check-world would create a new temporary installation for
      each test suite, which is slow and wasteful.  Instead, we now create one
      test installation that is used by all test suites that are part of a
      make run.
      
      The management of the temporary installation is removed from pg_regress
      and handled in the makefiles.  This allows for better control, and
      unifies the code with that of test suites not run through pg_regress.
      
      review and msvc support by Michael Paquier <michael.paquier@gmail.com>
      
      more review by Fabien Coelho <coelho@cri.ensmp.fr>
      dcae5fac
  9. Apr 22, 2015
  10. Apr 21, 2015
    • Andres Freund's avatar
      Add 'active_in' column to pg_replication_slots. · d811c037
      Andres Freund authored
      Right now it is visible whether a replication slot is active in any
      session, but not in which.  Adding the active_in column, containing the
      pid of the backend having acquired the slot, makes it much easier to
      associate pg_replication_slots entries with the corresponding
      pg_stat_replication/pg_stat_activity row.
      
      This should have been done from the start, but I (Andres) dropped the
      ball there somehow.
      
      Author: Craig Ringer, revised by me Discussion:
      CAMsr+YFKgZca5_7_ouaMWxA5PneJC9LNViPzpDHusaPhU9pA7g@mail.gmail.com
      d811c037
  11. Jan 06, 2015
  12. Dec 02, 2014
    • Andres Freund's avatar
      Don't skip SQL backends in logical decoding for visibility computation. · 0fd38e13
      Andres Freund authored
      The logical decoding patchset introduced PROC_IN_LOGICAL_DECODING flag
      PGXACT flag, that allows such backends to be skipped when computing
      the xmin horizon/snapshots. That's fine and sensible for walsenders
      streaming out logical changes, but not at all fine for SQL backends
      doing logical decoding. If the latter set that flag any change they
      have performed outside of logical decoding will not be regarded as
      visible - which e.g. can lead to that change being vacuumed away.
      
      Note that not setting the flag for SQL backends isn't particularly
      bothersome - the SQL backend doesn't do streaming, so it only runs for
      a limited amount of time.
      
      Per buildfarm member 'tick' and Alvaro.
      
      Backpatch to 9.4, where logical decoding was introduced.
      0fd38e13
  13. Nov 13, 2014
    • Andres Freund's avatar
      Fix and improve cache invalidation logic for logical decoding. · 89fd41b3
      Andres Freund authored
      There are basically three situations in which logical decoding needs
      to perform cache invalidation. During/After replaying a transaction
      with catalog changes, when skipping a uninteresting transaction that
      performed catalog changes and when erroring out while replaying a
      transaction. Unfortunately these three cases were all done slightly
      differently - partially because 8de3e410, which greatly simplifies
      matters, got committed in the midst of the development of logical
      decoding.
      
      The actually problematic case was when logical decoding skipped
      transaction commits (and thus processed invalidations). When used via
      the SQL interface cache invalidation could access the catalog - bad,
      because we didn't set up enough state to allow that correctly. It'd
      not be hard to setup sufficient state, but the simpler solution is to
      always perform cache invalidation outside a valid transaction.
      
      Also make the different cache invalidation cases look as similar as
      possible, to ease code review.
      
      This fixes the assertion failure reported by Antonin Houska in
      53EE02D9.7040702@gmail.com. The presented testcase has been expanded
      into a regression test.
      
      Backpatch to 9.4, where logical decoding was introduced.
      89fd41b3
  14. Nov 12, 2014
    • Andres Freund's avatar
      Fix several weaknesses in slot and logical replication on-disk serialization. · ec5896ae
      Andres Freund authored
      Heikki noticed in 544E23C0.8090605@vmware.com that slot.c and
      snapbuild.c were missing the FIN_CRC32 call when computing/checking
      checksums of on disk files. That doesn't lower the the error detection
      capabilities of the checksum, but is inconsistent with other usages.
      
      In a followup mail Heikki also noticed that, contrary to a comment,
      the 'version' and 'length' struct fields of replication slot's on disk
      data where not covered by the checksum. That's not likely to lead to
      actually missed corruption as those fields are cross checked with the
      expected version and the actual file length. But it's wrong
      nonetheless.
      
      As fixing these issues makes existing on disk files unreadable, bump
      the expected versions of on disk files for both slots and logical
      decoding historic catalog snapshots.  This means that loading old
      files will fail with
      ERROR: "replication slot file ... has unsupported version 1"
      and
      ERROR: "snapbuild state file ... has unsupported version 1 instead of
      2" respectively. Given the low likelihood of anybody already using
      these new features in a production setup that seems acceptable.
      
      Fixing these issues made me notice that there's no regression test
      covering the loading of historic snapshot from disk - so add one.
      
      Backpatch to 9.4 where these features were introduced.
      ec5896ae
  15. Oct 01, 2014
    • Andres Freund's avatar
      Improve documentation about binary/textual output mode for output plugins. · 0ef3c29a
      Andres Freund authored
      Also improve related error message as it contributed to the confusion.
      
      Discussion: CAB7nPqQrqFzjqCjxu4GZzTrD9kpj6HMn9G5aOOMwt1WZ8NfqeA@mail.gmail.com,
          CAB7nPqQXc_+g95zWnqaa=mVQ4d3BVRs6T41frcEYi2ocUrR3+A@mail.gmail.com
      
      Per discussion between Michael Paquier, Robert Haas and Andres Freund
      
      Backpatch to 9.4 where logical decoding was introduced.
      0ef3c29a
  16. Sep 05, 2014
  17. Sep 01, 2014
    • Andres Freund's avatar
      Add skip-empty-xacts option to test_decoding for use in the regression tests. · d6fa44fc
      Andres Freund authored
      The regression tests for contrib/test_decoding regularly failed on
      postgres instances that were very slow. Either because the hardware
      itself was slow or because very expensive debugging options like
      CLOBBER_CACHE_ALWAYS were used.
      
      The reason they failed was just that some additional transactions were
      decoded. Analyze and vacuum, triggered by autovac.
      
      To fix just add a option to test_decoding to only display transactions
      in which a change was actually displayed. That's not pretty because it
      removes information from the tests; but better than constantly failing
      tests in very likely harmless ways.
      
      Backpatch to 9.4 where logical decoding was introduced.
      
      Discussion: 20140629142511.GA26930@awork2.anarazel.de
      d6fa44fc
  18. Jul 14, 2014
  19. Jul 12, 2014
    • Andres Freund's avatar
      Fix decoding of consecutive MULTI_INSERTs emitted by one heap_multi_insert(). · 626bfad6
      Andres Freund authored
      Commit 1b86c81d fixed the decoding of toasted columns for the rows
      contained in one xl_heap_multi_insert record. But that's not actually
      enough, because heap_multi_insert() will actually first toast all
      passed in rows and then emit several *_multi_insert records; one for
      each page it fills with tuples.
      
      Add a XLOG_HEAP_LAST_MULTI_INSERT flag which is set in
      xl_heap_multi_insert->flag denoting that this multi_insert record is
      the last emitted by one heap_multi_insert() call. Then use that flag
      in decode.c to only set clear_toast_afterwards in the right situation.
      
      Expand the number of rows inserted via COPY in the corresponding
      regression test to make sure that more than one heap page is filled
      with tuples by one heap_multi_insert() call.
      
      Backpatch to 9.4 like the previous commit.
      626bfad6
  20. Jul 10, 2014
  21. Jul 06, 2014
    • Andres Freund's avatar
      Fix decoding of MULTI_INSERTs when rows other than the last are toasted. · 1b86c81d
      Andres Freund authored
      When decoding the results of a HEAP2_MULTI_INSERT (currently only
      generated by COPY FROM) toast columns for all but the last tuple
      weren't replaced by their actual contents before being handed to the
      output plugin. The reassembled toast datums where disregarded after
      every REORDER_BUFFER_CHANGE_(INSERT|UPDATE|DELETE) which is correct
      for plain inserts, updates, deletes, but not multi inserts - there we
      generate several REORDER_BUFFER_CHANGE_INSERTs for a single
      xl_heap_multi_insert record.
      
      To solve the problem add a clear_toast_afterwards boolean to
      ReorderBufferChange's union member that's used by modifications. All
      row changes but multi_inserts always set that to true, but
      multi_insert sets it only for the last change generated.
      
      Add a regression test covering decoding of multi_inserts - there was
      none at all before.
      
      Backpatch to 9.4 where logical decoding was introduced.
      
      Bug found by Petr Jelinek.
      1b86c81d
  22. May 16, 2014
  23. May 06, 2014
    • Bruce Momjian's avatar
      pgindent run for 9.4 · 0a783200
      Bruce Momjian authored
      This includes removing tabs after periods in C comments, which was
      applied to back branches, so this change should not effect backpatching.
      0a783200
  24. Apr 15, 2014
  25. Mar 31, 2014
  26. Mar 30, 2014
  27. Mar 29, 2014
  28. Mar 27, 2014
  29. Mar 12, 2014
  30. 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
  31. Mar 05, 2014
  32. 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
Loading