1. 21 Aug, 2015 4 commits
    • Tom Lane's avatar
      Allow record_in() and record_recv() to work for transient record types. · 09b3d272
      Tom Lane authored
      If we have the typmod that identifies a registered record type, there's no
      reason that record_in() should refuse to perform input conversion for it.
      Now, in direct SQL usage, record_in() will always be passed typmod = -1
      with type OID RECORDOID, because no typmodin exists for type RECORD, so the
      case can't arise.  However, some InputFunctionCall users such as PLs may be
      able to supply the right typmod, so we should allow this to support them.
      
      Note: the previous coding and comment here predate commit 59c016aa.
      There has been no case since 8.1 in which the passed type OID wouldn't be
      valid; and if it weren't, this error message wouldn't be apropos anyway.
      Better to let lookup_rowtype_tupdesc complain about it.
      
      Back-patch to 9.1, as this is necessary for my upcoming plpython fix.
      I'm committing it separately just to make it a bit more visible in the
      commit history.
      09b3d272
    • Stephen Frost's avatar
      Rename 'cmd' to 'cmd_name' in CreatePolicyStmt · 3c997887
      Stephen Frost authored
      To avoid confusion, rename CreatePolicyStmt's 'cmd' to 'cmd_name',
      parse_policy_command's 'cmd' to 'polcmd', and AlterPolicy's 'cmd_datum'
      to 'polcmd_datum', per discussion with Noah and as a follow-up to his
      correction of copynodes/equalnodes handling of the CreatePolicyStmt
      'cmd' field.
      
      Back-patch to 9.5 where the CreatePolicyStmt was introduced, as we
      are still only in alpha.
      3c997887
    • Stephen Frost's avatar
      In AlterRole, make bypassrls an int · 7ec8296e
      Stephen Frost authored
      When reworking bypassrls in AlterRole to operate the same way the other
      attribute handling is done, I missed that the variable was incorrectly a
      bool rather than an int.  This meant that on platforms with an unsigned
      char, we could end up with incorrect behavior during ALTER ROLE.
      
      Pointed out by Andres thanks to tests he did changing our bool to be the
      one from stdbool.h which showed this and a number of other issues.
      
      Add regression tests to test CREATE/ALTER role for the various role
      attributes.  Arrange to leave roles behind for testing pg_dumpall, but
      none which have the LOGIN attribute.
      
      Back-patch to 9.5 where the AlterRole bug exists.
      7ec8296e
    • Peter Eisentraut's avatar
      doc: Whitespace and formatting fixes · 90a1d0aa
      Peter Eisentraut authored
      90a1d0aa
  2. 20 Aug, 2015 1 commit
  3. 19 Aug, 2015 2 commits
    • Peter Eisentraut's avatar
      Update config.guess and config.sub · 960ea971
      Peter Eisentraut authored
      960ea971
    • Kevin Grittner's avatar
      Fix bug in calculations of hash join buckets. · 1cac8c98
      Kevin Grittner authored
      Commit 8cce08f1 used a left-shift
      on a literal of 1 that could (in large allocations) be shifted by
      31 or more bits.  This was assigned to a local variable that was
      already declared to be a long to protect against overruns of int,
      but the literal in this shift needs to be declared long to allow it
      to work correctly in some compilers.
      
      Backpatch to 9.5, where the bug was introduced.
      
      Report and patch by KaiGai Kohei, slighly modified based on
      discussion.
      1cac8c98
  4. 18 Aug, 2015 2 commits
    • Tom Lane's avatar
      Fix a few bogus statement type names in plpgsql error messages. · 2edb9491
      Tom Lane authored
      plpgsql's error location context messages ("PL/pgSQL function fn-name line
      line-no at stmt-type") would misreport a CONTINUE statement as being an
      EXIT, and misreport a MOVE statement as being a FETCH.  These are clear
      bugs that have been there a long time, so back-patch to all supported
      branches.
      
      In addition, in 9.5 and HEAD, change the description of EXECUTE from
      "EXECUTE statement" to just plain EXECUTE; there seems no good reason why
      this statement type should be described differently from others that have
      a well-defined head keyword.  And distinguish GET STACKED DIAGNOSTICS from
      plain GET DIAGNOSTICS.  These are a bit more of a judgment call, and also
      affect existing regression-test outputs, so I did not back-patch into
      stable branches.
      
      Pavel Stehule and Tom Lane
      2edb9491
    • Robert Haas's avatar
      psql: Make EXECUTE PROCEDURE tab completion a bit narrower. · db5a703b
      Robert Haas authored
      If the user has typed GRANT EXECUTE, the correct completion is "ON",
      not "PROCEDURE".
      
      Daniel Verite
      db5a703b
  5. 17 Aug, 2015 4 commits
    • Tom Lane's avatar
      Fix performance bug from conflict between two previous improvements. · d3eaab3e
      Tom Lane authored
      My expanded-objects patch (commit 1dc5ebc9) included code to make
      plpgsql pass expanded-object variables as R/W pointers to certain functions
      that are trusted for modifying such variables in-place.  However, that
      optimization got broken by commit 6c82d8d1, which arranged to share
      a single ParamListInfo across most expressions evaluated by a plpgsql
      function.  We don't want a R/W pointer to be passed to other functions
      just because we decided one function was safe!  Fortunately, the breakage
      was in the other direction, of never passing a R/W pointer at all, because
      we'd always have pre-initialized the shared array slot with a R/O pointer.
      So it was still functionally correct, but we were back to O(N^2)
      performance for repeated use of "a := a || x".  To fix, force an unshared
      param array to be used when the R/W param optimization is active.
      
      Commit 6c82d8d1 is in HEAD only, so no need for a back-patch.
      d3eaab3e
    • Andres Freund's avatar
      docs: Fix "typo" introduced in 3f811c2d. · 47ebbdce
      Andres Freund authored
      Reported-By: Michael Paquier
      Discussion: CAB7nPqSco+RFw9C-VgbCpyurQB3OocS-fuTOa_gFnUy1EE-pyQ@mail.gmail.com
      47ebbdce
    • Andres Freund's avatar
      Improve configure test for the sse4.2 crc instruction. · 6cf72879
      Andres Freund authored
      With optimizations enabled at least one compiler, clang 3.7, optimized
      away the crc intrinsics knowing that the result went on unused and has
      no side effects. That can trigger errors in code generation when the
      intrinsic is used, as we chose to use the intrinsics without any
      additional compiler flag. Return the computed value to prevent that.
      
      With some more pedantic warning flags (-Wold-style-definition) the
      configure test failed to recognize the existence of _mm_crc32_u*
      intrinsics due to an independent warning in the test because the test
      turned on -Werror, but that's not actually needed here.
      
      Discussion: 20150814092039.GH4955@awork2.anarazel.de
      Backpatch: 9.5, where the use of crc intrinsics was integrated.
      6cf72879
    • Heikki Linnakangas's avatar
      Fix reporting of skipped transactions in pgbench. · 0e8efed5
      Heikki Linnakangas authored
      Broken by commit 1bc90f7a.
      
      Fabien Coelho.
      0e8efed5
  6. 15 Aug, 2015 13 commits
    • Tom Lane's avatar
      Add docs about postgres_fdw's setting of search_path and other GUCs. · 522400a5
      Tom Lane authored
      This behavior wasn't documented, but it should be because it's user-visible
      in triggers and other functions executed on the remote server.
      Per question from Adam Fuchs.
      
      Back-patch to 9.3 where postgres_fdw was added.
      522400a5
    • Tom Lane's avatar
      Improve documentation about MVCC-unsafe utility commands. · 5869cbfe
      Tom Lane authored
      The table-rewriting forms of ALTER TABLE are MVCC-unsafe, in much the same
      way as TRUNCATE, because they replace all rows of the table with newly-made
      rows with a new xmin.  (Ideally, concurrent transactions with old snapshots
      would continue to see the old table contents, but the data is not there
      anymore --- and if it were there, it would be inconsistent with the table's
      updated rowtype, so there would be serious implementation problems to fix.)
      This was nowhere documented though, and the problem was only documented for
      TRUNCATE in a note in the TRUNCATE reference page.  Create a new "Caveats"
      section in the MVCC chapter that can be home to this and other limitations
      on serializable consistency.
      
      In passing, fix a mistaken statement that VACUUM and CLUSTER would reclaim
      space occupied by a dropped column.  They don't reconstruct existing tuples
      so they couldn't do that.
      
      Back-patch to all supported branches.
      5869cbfe
    • Tom Lane's avatar
      Repair unsafe use of shared typecast-lookup table in plpgsql DO blocks. · 83604cc4
      Tom Lane authored
      DO blocks use private simple_eval_estates to avoid intra-transaction memory
      leakage, cf commit c7b849a8.  I had forgotten about that while writing
      commit 0fc94a5b, but it means that expression execution trees created
      within a DO block disappear immediately on exiting the DO block, and hence
      can't safely be linked into plpgsql's session-wide cast hash table.
      To fix, give a DO block a private cast hash table to go with its private
      simple_eval_estate.  This is less efficient than one could wish, since
      DO blocks can no longer share any cast lookup work with other plpgsql
      execution, but it shouldn't be too bad; in any case it's no worse than
      what happened in DO blocks before commit 0fc94a5b.
      
      Per bug #13571 from Feike Steenbergen.  Preliminary analysis by
      Oleksandr Shulgin.
      83604cc4
    • Andres Freund's avatar
      Don't use function definitions looking like old-style ones. · e95126cf
      Andres Freund authored
      This fixes a bunch of somewhat pedantic warnings with new
      compilers. Since by far the majority of other functions definitions use
      the (void) style it just seems to be consistent to do so as well in the
      remaining few places.
      e95126cf
    • Andres Freund's avatar
      Correct type of waitMode variable in ExecInsertIndexTuples(). · f9dec81a
      Andres Freund authored
      It was a bool, even though it should be CEOUC_WAIT_MODE. That's unlikely
      to have a negative effect with the current definition of bool (char),
      but it's definitely wrong.
      
      Discussion: 20150812084351.GD8470@awork2.anarazel.de
      Backpatch: 9.5, where ON CONFLICT was merged
      f9dec81a
    • Andres Freund's avatar
      vacuumdb: Don't assign negative values to a boolean. · 1d4bd775
      Andres Freund authored
      Since a1792320 (vacuumdb: enable parallel mode) -1 has been assigned
      to a boolean. That can, justifiedly, trigger compiler warnings. There's
      also no need for ternary logic, result was only ever set to 0 or -1. So
      don't.
      
      Discussion: 20150812084351.GD8470@awork2.anarazel.de
      Backpatch: 9.5
      1d4bd775
    • Andres Freund's avatar
      Don't use 'bool' as a struct member name in help_config.c. · 6c772c74
      Andres Freund authored
      Doing so doesn't work if bool is a macro rather than a typedef.
      
      Although c.h spends some effort to support configurations where bool is
      a preexisting macro, help_config.c has existed this way since
      2003 (b700a6), and there have not been any reports of
      problems. Backpatch anyway since this is as riskless as it gets.
      
      Discussion: 20150812084351.GD8470@awork2.anarazel.de
      Backpatch: 9.0-master
      6c772c74
    • Andres Freund's avatar
      Use the correct type for TableInfo->relreplident. · a8015fe7
      Andres Freund authored
      Mistakenly relreplident was stored as a bool. That works today as c.h
      typedefs bool to a char, but isn't very future proof.
      
      Discussion: 20150812084351.GD8470@awork2.anarazel.de
      Backpatch: 9.4 where replica identity was introduced.
      a8015fe7
    • Robert Haas's avatar
      Remove unused expected-output file. · 8bd42fe5
      Robert Haas authored
      8bd42fe5
    • Robert Haas's avatar
      Remove bogus step from test_decoding isolation tests. · 5243a358
      Robert Haas authored
      Commit 43b4a168 made the isolation
      tester reject duplicate step names, and it turns out that the
      test_decoding module's concurrent_ddl_dml isolation test has a
      duplicate name.  I think the second definition isn't actually getting
      used, so just remove it.
      
      Per buildfarm.
      5243a358
    • Robert Haas's avatar
      Reject isolation test specifications with duplicate step names. · 43b4a168
      Robert Haas authored
      alter-table-1.spec has such a case, so change one instance of step
      rx1 to rx3 instead.
      43b4a168
    • Noah Misch's avatar
      Encoding PG_UHC is code page 949. · ec79978d
      Noah Misch authored
      This fixes presentation of non-ASCII messages to the Windows event log
      and console in rare cases involving Korean locale.  Processes like the
      postmaster and checkpointer, but not processes attached to databases,
      were affected.  Back-patch to 9.4, where MessageEncoding was introduced.
      The problem exists in all supported versions, but this change has no
      effect in the absence of the code recognizing PG_UHC MessageEncoding.
      
      Noticed while investigating bug #13427 from Dmitri Bourlatchkov.
      ec79978d
    • Noah Misch's avatar
      Restore old pgwin32_message_to_UTF16() behavior outside transactions. · 43adc7a7
      Noah Misch authored
      Commit 49c817ea replaced with a hard
      error the dubious pg_do_encoding_conversion() behavior when outside a
      transaction.  Reintroduce the historic soft failure locally within
      pgwin32_message_to_UTF16().  This fixes errors when writing messages in
      less-common encodings to the Windows event log or console.  Back-patch
      to 9.4, where the aforementioned commit first appeared.
      
      Per bug #13427 from Dmitri Bourlatchkov.
      43adc7a7
  7. 14 Aug, 2015 3 commits
    • Peter Eisentraut's avatar
      Update key words table for 9.5 · 845405a7
      Peter Eisentraut authored
      845405a7
    • Simon Riggs's avatar
      Reduce lock levels for ALTER TABLE SET autovacuum storage options · 47167b79
      Simon Riggs authored
      Reduce lock levels down to ShareUpdateExclusiveLock for all autovacuum-related
      relation options when setting them using ALTER TABLE.
      
      Add infrastructure to allow varying lock levels for relation options in later
      patches. Setting multiple options together uses the highest lock level required
      for any option. Works for both main and toast tables.
      
      Fabrízio Mello, reviewed by Michael Paquier, mild edit and additional regression
      tests from myself
      47167b79
    • Peter Eisentraut's avatar
      PL/Python: Make tests pass with Python 3.5 · f16d5226
      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.
      f16d5226
  8. 13 Aug, 2015 8 commits
    • Alvaro Herrera's avatar
      MSVC: Exclude 'brin' contrib module · d67616c7
      Alvaro Herrera authored
      The build script is not able to parse the Makefile, so remove it.
      d67616c7
    • Alvaro Herrera's avatar
      Re-add BRIN isolation test · 672e3ec0
      Alvaro Herrera authored
      This time, instead of using a core isolation test, put it on its own
      test module; this way it can require the pageinspect module to be
      present before running.
      
      The module's Makefile is loosely modeled after test_decoding's, so that
      it's easy to add further tests for either pg_regress or isolationtester
      later.
      
      Backpatch to 9.5.
      672e3ec0
    • Tom Lane's avatar
      Improve regression test case to avoid depending on system catalog stats. · 6a0779a3
      Tom Lane authored
      In commit 95f4e59c I added a regression test case that examined
      the plan of a query on system catalogs.  That isn't a terribly great idea
      because the catalogs tend to change from version to version, or even
      within a version if someone makes an unrelated regression-test change that
      populates the catalogs a bit differently.  Usually I try to make planner
      test cases rely on test tables that have not changed since Berkeley days,
      but I got sloppy in this case because the submitted crasher example queried
      the catalogs and I didn't spend enough time on rewriting it.  But it was a
      problem waiting to happen, as I was rudely reminded when I tried to port
      that patch into Salesforce's Postgres variant :-(.  So spend a little more
      effort and rewrite the query to not use any system catalogs.  I verified
      that this version still provokes the Assert if 95f4e59c's code fix
      is reverted.
      
      I also removed the EXPLAIN output from the test, as it turns out that the
      assertion occurs while considering a plan that isn't the one ultimately
      selected anyway; so there's no value in risking any cross-platform
      variation in that printout.
      
      Back-patch to 9.2, like the previous patch.
      6a0779a3
    • Alvaro Herrera's avatar
      Use materialize SRF mode in brin_page_items · 94d626ff
      Alvaro Herrera authored
      This function was using the single-value-per-call mechanism, but the
      code relied on a relcache entry that wasn't kept open across calls.
      This manifested as weird errors in buildfarm during the short time that
      the "brin-1" isolation test lived.
      
      Backpatch to 9.5, where it was introduced.
      94d626ff
    • Heikki Linnakangas's avatar
      Run autoheader to add a few missing #defines to pg_config.h.in. · 36e863bb
      Heikki Linnakangas authored
      These are emitted by the new ax_pthread.m4 script version. They are not
      used for anything in PostgreSQL, but let's keep the generated header file
      up-to-date.
      
      Andres Freund
      36e863bb
    • Michael Meskes's avatar
      Fix declaration of isarray variable. · c396f2b8
      Michael Meskes authored
      Found and fixed by Andres Freund.
      c396f2b8
    • Alvaro Herrera's avatar
      Fix unitialized variables · fcbf4558
      Alvaro Herrera authored
      As complained by clang, reported by Andres Freund.  Brown paper bag bug
      in ccc4c074.
      
      Add some comments, too.
      
      Backpatch to 9.5, like that one.
      fcbf4558
    • Tom Lane's avatar
      Undo mistaken tightening in join_is_legal(). · cfe30a72
      Tom Lane authored
      One of the changes I made in commit 8703059c turns out not to have
      been such a good idea: we still need the exception in join_is_legal() that
      allows a join if both inputs already overlap the RHS of the special join
      we're checking.  Otherwise we can miss valid plans, and might indeed fail
      to find a plan at all, as in recent report from Andreas Seltenreich.
      
      That code was added way back in commit c1711764, but I failed to
      include a regression test case then; my bad.  Put it back with a better
      explanation, and a test this time.  The logic does end up a bit different
      than before though: I now believe it's appropriate to make this check
      first, thereby allowing such a case whether or not we'd consider the
      previous SJ(s) to commute with this one.  (Presumably, we already decided
      they did; but it was confusing to have this consideration in the middle
      of the code that was handling the other case.)
      
      Back-patch to all active branches, like the previous patch.
      cfe30a72
  9. 12 Aug, 2015 3 commits
    • Alvaro Herrera's avatar
      Close some holes in BRIN page assignment · ccc4c074
      Alvaro Herrera authored
      In some corner cases, it is possible for the BRIN index relation to be
      extended by brin_getinsertbuffer but the new page not be used
      immediately for anything by its callers; when this happens, the page is
      initialized and the FSM is updated (by brin_getinsertbuffer) with the
      info about that page, but these actions are not WAL-logged.  A later
      index insert/update can use the page, but since the page is already
      initialized, the initialization itself is not WAL-logged then either.
      Replay of this sequence of events causes recovery to fail altogether.
      
      There is a related corner case within brin_getinsertbuffer itself, in
      which we extend the relation to put a new index tuple there, but later
      find out that we cannot do so, and do not return the buffer; the page
      obtained from extension is not even initialized.  The resulting page is
      lost forever.
      
      To fix, shuffle the code so that initialization is not the
      responsibility of brin_getinsertbuffer anymore, in normal cases;
      instead, the initialization is done by its callers (brin_doinsert and
      brin_doupdate) once they're certain that the page is going to be used.
      When either those functions determine that the new page cannot be used,
      before bailing out they initialize the page as an empty regular page,
      enter it in FSM and WAL-log all this.  This way, the page is usable for
      future index insertions, and WAL replay doesn't find trying to insert
      tuples in pages whose initialization didn't make it to the WAL.  The
      same strategy is used in brin_getinsertbuffer when it cannot return the
      new page.
      
      Additionally, add a new step to vacuuming so that all pages of the index
      are scanned; whenever an uninitialized page is found, it is initialized
      as empty and WAL-logged.  This closes the hole that the relation is
      extended but the system crashes before anything is WAL-logged about it.
      We also take this opportunity to update the FSM, in case it has gotten
      out of date.
      
      Thanks to Heikki Linnakangas for finding the problem that kicked some
      additional analysis of BRIN page assignment code.
      
      Backpatch to 9.5, where BRIN was introduced.
      
      Discussion: https://www.postgresql.org/message-id/20150723204810.GY5596@postgresql.org
      ccc4c074
    • Andres Freund's avatar
      Remove duplicated assignment in pg_create_physical_replication_slot. · a4b059fd
      Andres Freund authored
      Reported-By: Gurjeet Singh
      a4b059fd
    • Andres Freund's avatar
      Handle PQresultErrorField(PG_DIAG_SQLSTATE) returning NULL in streamutil.c. · 7685963e
      Andres Freund authored
      In ff27db5d I missed that PQresultErrorField() may return NULL if
      there's no sqlstate associated with an error.
      
      Spotted-By: Coverity
      Reported-By: Michael Paquier
      Discussion: CAB7nPqQ3o10SY6NVdU4pjq85GQTN5tbbkq2gnNUh2fBNU3rKyQ@mail.gmail.com
      Backpatch: 9.5, like ff27db5d
      7685963e