1. 12 Dec, 2014 8 commits
    • Tom Lane's avatar
      Revert misguided change to postgres_fdw FOR UPDATE/SHARE code. · 8ec8760f
      Tom Lane authored
      In commit 462bd957, I changed postgres_fdw
      to rely on get_plan_rowmark() instead of get_parse_rowmark().  I still
      think that's a good idea in the long run, but as Etsuro Fujita pointed out,
      it doesn't work today because planner.c forces PlanRowMarks to have
      markType = ROW_MARK_COPY for all foreign tables.  There's no urgent reason
      to change this in the back branches, so let's just revert that part of
      yesterday's commit rather than trying to design a better solution under
      time pressure.
      
      Also, add a regression test case showing what postgres_fdw does with FOR
      UPDATE/SHARE.  I'd blithely assumed there was one already, else I'd have
      realized yesterday that this code didn't work.
      8ec8760f
    • Andrew Dunstan's avatar
      Add json_strip_nulls and jsonb_strip_nulls functions. · 237a8824
      Andrew Dunstan authored
      The functions remove object fields, including in nested objects, that
      have null as a value. In certain cases this can lead to considerably
      smaller datums, with no loss of semantic information.
      
      Andrew Dunstan, reviewed by Pavel Stehule.
      237a8824
    • Heikki Linnakangas's avatar
      Put the logic to decide which synchronous standby is active into a function. · b1332e98
      Heikki Linnakangas authored
      This avoids duplicating the code.
      
      Michael Paquier, reviewed by Simon Riggs and me
      b1332e98
    • Peter Eisentraut's avatar
    • Peter Eisentraut's avatar
      SSL tests: Remove trailing blank lines · 2f860786
      Peter Eisentraut authored
      2f860786
    • Peter Eisentraut's avatar
      SSL tests: Silence pg_ctl output · ce37eff0
      Peter Eisentraut authored
      Otherwise the pg_ctl start and stop messages get mixed up with the TAP
      output, which isn't technically valid.
      ce37eff0
    • Tom Lane's avatar
      Fix planning of SELECT FOR UPDATE on child table with partial index. · 462bd957
      Tom Lane authored
      Ordinarily we can omit checking of a WHERE condition that matches a partial
      index's condition, when we are using an indexscan on that partial index.
      However, in SELECT FOR UPDATE we must include the "redundant" filter
      condition in the plan so that it gets checked properly in an EvalPlanQual
      recheck.  The planner got this mostly right, but improperly omitted the
      filter condition if the index in question was on an inheritance child
      table.  In READ COMMITTED mode, this could result in incorrectly returning
      just-updated rows that no longer satisfy the filter condition.
      
      The cause of the error is using get_parse_rowmark() when get_plan_rowmark()
      is what should be used during planning.  In 9.3 and up, also fix the same
      mistake in contrib/postgres_fdw.  It's currently harmless there (for lack
      of inheritance support) but wrong is wrong, and the incorrect code might
      get copied to someplace where it's more significant.
      
      Report and fix by Kyotaro Horiguchi.  Back-patch to all supported branches.
      462bd957
    • Tom Lane's avatar
      Fix corner case where SELECT FOR UPDATE could return a row twice. · 2db576ba
      Tom Lane authored
      In READ COMMITTED mode, if a SELECT FOR UPDATE discovers it has to redo
      WHERE-clause checking on rows that have been updated since the SELECT's
      snapshot, it invokes EvalPlanQual processing to do that.  If this first
      occurs within a non-first child table of an inheritance tree, the previous
      coding could accidentally re-return a matching row from an earlier,
      already-scanned child table.  (And, to add insult to injury, I think this
      could make it miss returning a row that should have been returned, if the
      updated row that this happens on should still have passed the WHERE qual.)
      Per report from Kyotaro Horiguchi; the added isolation test is based on his
      test case.
      
      This has been broken for quite awhile, so back-patch to all supported
      branches.
      2db576ba
  2. 11 Dec, 2014 7 commits
    • Simon Riggs's avatar
      Further changes to REINDEX SCHEMA · 2646d2d4
      Simon Riggs authored
      Ensure we reindex indexes built on Mat Views.
      Based on patch from Micheal Paquier
      
      Add thorough tests to check that indexes on
      tables, toast tables and mat views are reindexed.
      
      Simon Riggs
      2646d2d4
    • Tom Lane's avatar
      Make rowsecurity test clean up after itself, too. · 08452646
      Tom Lane authored
      Leaving global objects like roles hanging around is bad practice.
      08452646
    • Tom Lane's avatar
      Fix completely broken REINDEX SCHEMA testcase. · 58af84f4
      Tom Lane authored
      Aside from not testing the case it claimed to test (namely a permissions
      failure), it left a login-capable role lying around, which quite aside
      from possibly being a security hole would cause subsequent regression runs
      to fail since the role would already exist.
      58af84f4
    • Tom Lane's avatar
      Fix assorted confusion between Oid and int32. · 06d5803f
      Tom Lane authored
      In passing, also make some debugging elog's in pgstat.c a bit more
      consistently worded.
      
      Back-patch as far as applicable (9.3 or 9.4; none of these mistakes are
      really old).
      
      Mark Dilger identified and patched the type violations; the message
      rewordings are mine.
      06d5803f
    • Heikki Linnakangas's avatar
      Use correct macro for reltablespace. · 10eb7dfa
      Heikki Linnakangas authored
      It's an OID. WRITE_UINT_FIELD is identical to WRITE_OID_FIELD, but let's
      be tidy.
      
      Mark Dilger
      10eb7dfa
    • Peter Eisentraut's avatar
      Fix typo · 7442a889
      Peter Eisentraut authored
      Author: Fabrízio de Royes Mello <fabriziomello@gmail.com>
      7442a889
    • Tom Lane's avatar
      Fix minor thinko in convertToJsonb(). · 24688f4e
      Tom Lane authored
      The amount of space to reserve for the value's varlena header is
      VARHDRSZ, not sizeof(VARHDRSZ).  The latter coding accidentally
      failed to fail because of the way the VARHDRSZ macro is currently
      defined; but if we ever change it to return size_t (as one might
      reasonably expect it to do), convertToJsonb() would have failed.
      
      Spotted by Mark Dilger.
      24688f4e
  3. 09 Dec, 2014 3 commits
  4. 08 Dec, 2014 6 commits
    • Simon Riggs's avatar
      Execute 18 tests for src/bin/scripts/t/090.. · 1135aaba
      Simon Riggs authored
      Some requests count as two tests.
      1135aaba
    • Simon Riggs's avatar
      REINDEX SCHEMA · fe263d11
      Simon Riggs authored
      Add new SCHEMA option to REINDEX and reindexdb.
      
      Sawada Masahiko
      
      Reviewed by Michael Paquier and Fabrízio de Royes Mello
      fe263d11
    • Simon Riggs's avatar
      Windows: use GetSystemTimePreciseAsFileTime if available · 8001fe67
      Simon Riggs authored
      PostgreSQL on Windows 8 or Windows Server 2012 will now
      get high-resolution timestamps by dynamically loading the
      GetSystemTimePreciseAsFileTime function. It'll fall back to
      to GetSystemTimeAsFileTime if the higher precision variant
      isn't found, so the same binaries without problems on older
      Windows releases.
      
      No attempt is made to detect the Windows version.  Only the
      presence or absence of the desired function is considered.
      
      Craig Ringer
      8001fe67
    • Simon Riggs's avatar
      Use GetSystemTimeAsFileTime directly in win32 · 519b0757
      Simon Riggs authored
      PostgreSQL was calling GetSystemTime followed by SystemTimeToFileTime in the
      win32 port gettimeofday function. This is not necessary and limits the reported
      precision to the 1ms granularity that the SYSTEMTIME struct can represent. By
      using GetSystemTimeAsFileTime we avoid unnecessary conversions and capture
      timestamps at 100ns granularity, which is then rounded to 1µs granularity for
      storage in a PostgreSQL timestamp.
      
      On most Windows systems this change will actually have no significant effect on
      timestamp resolution as the system timer tick is typically between 1ms and 15ms
      depending on what timer resolution currently running applications have
      requested. You can check this with clockres.exe from sysinternals. Despite the
      platform limiation this change still permits capture of finer timestamps where
      the system is capable of producing them and it gets rid of an unnecessary
      syscall.
      
      The higher resolution GetSystemTimePreciseAsFileTime call available on Windows
      8 and Windows Server 2012 has the same interface as GetSystemTimeAsFileTime, so
      switching to GetSystemTimeAsFileTime makes it easier to use the Precise variant
      later.
      
      Craig Ringer, reviewed by David Rowley
      519b0757
    • Peter Eisentraut's avatar
      doc: Fix DocBook table column count declaration · 611d46ea
      Peter Eisentraut authored
      This was broken in 618c9430.
      611d46ea
    • Simon Riggs's avatar
      Correct recovery_target_action docs · da71632f
      Simon Riggs authored
      From Michael Paquier
      da71632f
  5. 07 Dec, 2014 3 commits
    • Simon Riggs's avatar
      Remove duplicate code in heap_prune_chain() · c2707547
      Simon Riggs authored
      No need to set tuple tableOid twice
      
      Jim Nasby
      c2707547
    • Simon Riggs's avatar
      Event Trigger for table_rewrite · 618c9430
      Simon Riggs authored
      Generate a table_rewrite event when ALTER TABLE
      attempts to rewrite a table. Provide helper
      functions to identify table and reason.
      
      Intended use case is to help assess or to react
      to schema changes that might hold exclusive locks
      for long periods.
      
      Dimitri Fontaine, triggering an edit by Simon Riggs
      
      Reviewed in detail by Michael Paquier
      618c9430
    • Simon Riggs's avatar
      Tweaks for recovery_target_action · b8e33a85
      Simon Riggs authored
      Rename parameter action_at_recovery_target to
      recovery_target_action suggested by Christoph Berg.
      
      Place into recovery.conf suggested by Fujii Masao,
      replacing (deprecating) earlier parameters, per
      Michael Paquier.
      b8e33a85
  6. 05 Dec, 2014 7 commits
  7. 04 Dec, 2014 6 commits
    • Andres Freund's avatar
      Document that pg_stat_*_tables.n_tup_upd includes n_tup_hot_upd. · 5ede3a31
      Andres Freund authored
      Author: Peter Geoghegan
      5ede3a31
    • Peter Eisentraut's avatar
      Fix PGXS vpath build when PostgreSQL is built with vpath · b58233c7
      Peter Eisentraut authored
      PGXS computes srcdir from VPATH, PostgreSQL proper computes VPATH from
      srcdir, and doing both results in an error from make.  Conditionalize so
      only one of these takes effect.
      b58233c7
    • Peter Eisentraut's avatar
      Revert haphazard pgxs makefile changes · e4b5a070
      Peter Eisentraut authored
      These changes were originally submitted as "adds support for VPATH with
      USE_PGXS", but they are not necessary for VPATH support, so they just
      add more lines of code for no reason.
      e4b5a070
    • Peter Eisentraut's avatar
      Remove USE_VPATH make variable from PGXS · eb1c3f47
      Peter Eisentraut authored
      The user can just set VPATH directly.  There is no need to invent
      another variable.
      eb1c3f47
    • Peter Eisentraut's avatar
      Fix SHLIB_PREREQS use in contrib, allowing PGXS builds · 1e95bbc8
      Peter Eisentraut authored
      dblink and postgres_fdw use SHLIB_PREREQS = submake-libpq to build libpq
      first.  This doesn't work in a PGXS build, because there is no libpq to
      build.  So just omit setting SHLIB_PREREQS in this case.
      
      Note that PGXS users can still use SHLIB_PREREQS (although it is not
      documented).  The problem here is only that contrib modules can be built
      in-tree or using PGXS, and the prerequisite is only applicable in the
      former case.
      
      Commit 6697aa2b previously attempted to
      address this by creating a somewhat fake submake-libpq target in
      Makefile.global.  That was not the right fix, and it was also done in a
      nonportable way, so revert that.
      1e95bbc8
    • Peter Eisentraut's avatar
      Move PG_AUTOCONF_FILENAME definition · e86507d7
      Peter Eisentraut authored
      Since this is not something that a user should change,
      pg_config_manual.h was an inappropriate place for it.
      
      In initdb.c, remove the use of the macro, because utils/guc.h can't be
      included by non-backend code.  But we hardcode all the other
      configuration file names there, so this isn't a disaster.
      e86507d7