1. 07 Feb, 2016 8 commits
    • Tom Lane's avatar
      Improve documentation about PRIMARY KEY constraints. · c477e84f
      Tom Lane authored
      Get rid of the false implication that PRIMARY KEY is exactly equivalent to
      UNIQUE + NOT NULL.  That was more-or-less true at one time in our
      implementation, but the standard doesn't say that, and we've grown various
      features (many of them required by spec) that treat a pkey differently from
      less-formal constraints.  Per recent discussion on pgsql-general.
      
      I failed to resist the temptation to do some other wordsmithing in the
      same area.
      c477e84f
    • Tom Lane's avatar
      Fix deparsing of ON CONFLICT arbiter WHERE clauses. · cc2ca931
      Tom Lane authored
      The parser doesn't allow qualification of column names appearing in
      these clauses, but ruleutils.c would sometimes qualify them, leading
      to dump/reload failures.  Per bug #13891 from Onder Kalaci.
      
      (In passing, make stanzas in ruleutils.c that save/restore varprefix
      more consistent.)
      
      Peter Geoghegan
      cc2ca931
    • Tom Lane's avatar
      1d76c972
    • Tom Lane's avatar
      ExecHashRemoveNextSkewBucket must physically copy tuples to main hashtable. · f867ce55
      Tom Lane authored
      Commit 45f6240a added an assumption in ExecHashIncreaseNumBatches
      and ExecHashIncreaseNumBuckets that they could find all tuples in the main
      hash table by iterating over the "dense storage" introduced by that patch.
      However, ExecHashRemoveNextSkewBucket continued its old practice of simply
      re-linking deleted skew tuples into the main table's hashchains.  Hence,
      such tuples got lost during any subsequent increase in nbatch or nbuckets,
      and would never get joined, as reported in bug #13908 from Seth P.
      
      I (tgl) think that the aforesaid commit has got multiple design issues
      and should be reworked rather completely; but there is no time for that
      right now, so band-aid the problem by making ExecHashRemoveNextSkewBucket
      physically copy deleted skew tuples into the "dense storage" arena.
      
      The added test case is able to exhibit the problem by means of fooling the
      planner with a WHERE condition that it will underestimate the selectivity
      of, causing the initial nbatch estimate to be too small.
      
      Tomas Vondra and Tom Lane.  Thanks to David Johnston for initial
      investigation into the bug report.
      f867ce55
    • Robert Haas's avatar
      Fix parallel-safety markings for pg_upgrade functions. · d89f06f0
      Robert Haas authored
      These establish backend-local state which will not be copied to
      parallel workers, so they must be marked parallel-restricted, not
      parallel-safe.
      d89f06f0
    • Robert Haas's avatar
      Introduce a new GUC force_parallel_mode for testing purposes. · 7c944bd9
      Robert Haas authored
      When force_parallel_mode = true, we enable the parallel mode restrictions
      for all queries for which this is believed to be safe.  For the subset of
      those queries believed to be safe to run entirely within a worker, we spin
      up a worker and run the query there instead of running it in the
      original process.  When force_parallel_mode = regress, make additional
      changes to allow the regression tests to run cleanly even though parallel
      workers have been injected under the hood.
      
      Taken together, this facilitates both better user testing and better
      regression testing of the parallelism code.
      
      Robert Haas, with help from Amit Kapila and Rushabh Lathia.
      7c944bd9
    • Robert Haas's avatar
      Introduce group locking to prevent parallel processes from deadlocking. · a1c1af2a
      Robert Haas authored
      For locking purposes, we now regard heavyweight locks as mutually
      non-conflicting between cooperating parallel processes.  There are some
      possible pitfalls to this approach that are not to be taken lightly,
      but it works OK for now and can be changed later if we find a better
      approach.  Without this, it's very easy for parallel queries to
      silently self-deadlock if the user backend holds strong relation locks.
      
      Robert Haas, with help from Amit Kapila.  Thanks to Noah Misch and
      Andres Freund for extensive discussion of possible issues with this
      approach.
      a1c1af2a
    • Tom Lane's avatar
      Improve speed of timestamp/time/date output functions. · aa2387e2
      Tom Lane authored
      It seems that sprintf(), at least in glibc's version, is unreasonably slow
      compared to hand-rolled code for printing integers.  Replacing most uses of
      sprintf() in the datetime.c output functions with special-purpose code
      turns out to give more than a 2X speedup in COPY of a table with a single
      timestamp column; which is pretty impressive considering all the other
      logic in that code path.
      
      David Rowley and Andres Freund, reviewed by Peter Geoghegan and myself
      aa2387e2
  2. 06 Feb, 2016 5 commits
    • Tom Lane's avatar
      Fix comment block trashed by pgindent. · b921aeb1
      Tom Lane authored
      Looks like I put the protective dashes in the wrong place in f4e4b327.
      b921aeb1
    • Tom Lane's avatar
      Improve HJDEBUG code a bit. · be11f840
      Tom Lane authored
      Commit 30d7ae3c introduced an HJDEBUG
      stanza that probably didn't compile at the time, and definitely doesn't
      compile now, because it refers to a nonexistent variable.  It doesn't seem
      terribly useful anyway, so just get rid of it.
      
      While I'm fooling with it, use %z modifier instead of the obsolete hack of
      casting size_t to unsigned long, and include the HashJoinTable's address in
      each printout so that it's possible to distinguish the activities of
      multiple hashjoins occurring in one query.
      
      Noted while trying to use HJDEBUG to investigate bug #13908.  Back-patch
      to 9.5, because code that doesn't compile is certainly not very helpful.
      be11f840
    • Tom Lane's avatar
      Add missing "static" qualifier. · 392998bc
      Tom Lane authored
      Per buildfarm member pademelon.
      392998bc
    • Noah Misch's avatar
      Comment on dead code in AtAbort_Portals() and AtSubAbort_Portals(). · 41baee7a
      Noah Misch authored
      Reviewed by Tom Lane and Robert Haas.
      41baee7a
    • Noah Misch's avatar
      Force certain "pljava" custom GUCs to be PGC_SUSET. · f4aa3a18
      Noah Misch authored
      Future PL/Java versions will close CVE-2016-0766 by making these GUCs
      PGC_SUSET.  This PostgreSQL change independently mitigates that PL/Java
      vulnerability, helping sites that update PostgreSQL more frequently than
      PL/Java.  Back-patch to 9.1 (all supported versions).
      f4aa3a18
  3. 05 Feb, 2016 11 commits
  4. 04 Feb, 2016 4 commits
    • Robert Haas's avatar
      Add some additional core functions to support join pushdown for FDWs. · a104a017
      Robert Haas authored
      GetExistingLocalJoinPath() is useful for handling EvalPlanQual rechecks
      properly, and GetUserMappingById() is needed to make sure you're using
      the right credentials.
      
      Shigeru Hanada, Etsuro Fujita, Ashutosh Bapat, Robert Haas
      a104a017
    • Robert Haas's avatar
      Change the way that LWLocks for extensions are allocated. · c1772ad9
      Robert Haas authored
      The previous RequestAddinLWLocks() method had several disadvantages.
      First, the locks would be in the main tranche; we've recently decided
      that it's useful for LWLocks used for separate purposes to have
      separate tranche IDs.  Second, there wasn't any correlation between
      what code called RequestAddinLWLocks() and what code called
      LWLockAssign(); when multiple modules are in use, it could become
      quite difficult to troubleshoot problems where LWLockAssign() ran out
      of locks.  To fix, create a concept of named LWLock tranches which
      can be used either by extension or by core code.
      
      Amit Kapila and Robert Haas
      c1772ad9
    • Tom Lane's avatar
      Simplify syntax diagram for REINDEX. · 5ef244a2
      Tom Lane authored
      Since there currently is only one possible parenthesized option, namely
      VERBOSE, it's a bit pointless to show it with "{ } [, ... ]".  The curly
      braces are useless and therefore confusing, as seen in a recent question
      from Karsten Hilbert.  Remove the extra decoration for the time being;
      we can put it back when and if REINDEX grows some more options.
      5ef244a2
    • Tom Lane's avatar
      In pg_dump, ensure that view triggers are processed after view rules. · 0ed707e9
      Tom Lane authored
      If a view is split into CREATE TABLE + CREATE RULE to break a circular
      dependency, then any triggers on the view must be dumped/reloaded after
      the CREATE RULE; else the backend may reject the CREATE TRIGGER because
      it's the wrong type of trigger for a plain table.  This works all right
      in plain dump/restore because of pg_dump's sorting heuristic that places
      triggers after rules.  However, when using parallel restore, the ordering
      must be enforced by a dependency --- and we didn't have one.
      
      Fixing this is a mere matter of adding an addObjectDependency() call,
      except that we need to be able to find all the triggers belonging to the
      view relation, and there was no easy way to do that.  Add fields to
      pg_dump's TableInfo struct to remember where the associated TriggerInfo
      struct(s) are.
      
      Per bug report from Dennis Kögel.  The failure can be exhibited at least
      as far back as 9.1, so back-patch to all supported branches.
      0ed707e9
  5. 03 Feb, 2016 11 commits
    • Robert Haas's avatar
      Extend sortsupport for text to more opclasses. · b47b4dbf
      Robert Haas authored
      Have varlena.c expose an interface that allows the char(n), bytea, and
      bpchar types to piggyback on a now-generalized SortSupport for text.
      This pushes a little more knowledge of the bpchar/char(n) type into
      varlena.c than might be preferred, but that seems like the approach
      that creates least friction.  Also speed things up for index builds
      that use text_pattern_ops or varchar_pattern_ops.
      
      This patch does quite a bit of renaming, but it seems likely to be
      worth it, so as to avoid future confusion about the fact that this code
      is now more generally used than the old names might have suggested.
      
      Peter Geoghegan, reviewed by Álvaro Herrera and Andreas Karlsson,
      with small tweaks by me.
      b47b4dbf
    • Tom Lane's avatar
      Add hstore_to_jsonb() and hstore_to_jsonb_loose() to hstore documentation. · 24a26c9f
      Tom Lane authored
      These were never documented anywhere user-visible.  Tut tut.
      24a26c9f
    • Robert Haas's avatar
      Allow parallel custom and foreign scans. · 69d34408
      Robert Haas authored
      This patch doesn't put the new infrastructure to use anywhere, and
      indeed it's not clear how it could ever be used for something like
      postgres_fdw which has to send an SQL query and wait for a reply,
      but there might be FDWs or custom scan providers that are CPU-bound,
      so let's give them a way to join club parallel.
      
      KaiGai Kohei, reviewed by me.
      69d34408
    • Peter Eisentraut's avatar
      doc: Fix stand-alone INSTALL file build · 25e44518
      Peter Eisentraut authored
      Commit 7d17e683 introduced an external
      link.
      25e44518
    • Tom Lane's avatar
      Make hstore_to_jsonb_loose match hstore_to_json_loose on what's a number. · 41d2c081
      Tom Lane authored
      Commit e09996ff removed some ad-hoc code in hstore_to_json_loose
      that determined whether an hstore value string looked like a number,
      in favor of calling the JSON parser's is-it-a-number code.  However,
      it neglected the fact that the exact same code appeared in
      hstore_to_jsonb_loose.
      
      This is not a bug, exactly, because the requirements on the two functions
      are not the same: hstore_to_json_loose must accept only syntactically legal
      JSON numbers as numbers, or it will produce invalid JSON output, as per bug
      #12070 which spawned the prior commit.  But hstore_to_jsonb_loose could
      accept anything that numeric_in will eat, other than Inf and NaN.
      
      Nonetheless it seems surprising and arbitrary that the two functions don't
      use the same rules for what is a number versus what is a string; especially
      since they did use the same rules before the aforesaid commit.  For one
      thing, that means that doing hstore_to_json_loose and then casting to jsonb
      can produce results different from doing just hstore_to_jsonb_loose.
      
      Hence, change hstore_to_jsonb_loose's logic to match hstore_to_json_loose,
      ie, hstore values are treated as numbers when they match the JSON syntax
      for numbers.
      
      No back-patch, since this is more in the nature of a definitional change
      than a bug fix.
      41d2c081
    • Robert Haas's avatar
      Code review for commit dc203dc3. · 52b63649
      Robert Haas authored
      Remove duplicate assignment.  This part by Ashutosh Bapat.
      
      Remove now-obsolete comment.  This part by me, although the pending
      join pushdown patch does something similar, and for the same reason:
      there's no reason to keep two lists of the things in the fdw_private
      structure that have to be kept in sync with each other.
      52b63649
    • Robert Haas's avatar
      Remove CustomPath's TextOutCustomPath method. · f2305d40
      Robert Haas authored
      You can't really do anything useful with this in the form it currently
      exists; among other problems, there's no way to reread whatever
      information might be produced when the path is output.  Work is
      underway to replace this with a more useful and more general system of
      extensible nodes, but let's start by getting rid of this bit.
      
      Extracted from a larger patch by KaiGai Kohei.
      f2305d40
    • Robert Haas's avatar
      postgres_fdw: Allow fetch_size to be set per-table or per-server. · dc203dc3
      Robert Haas authored
      The default fetch size of 100 rows might not be right in every
      environment, so allow users to configure it.
      
      Corey Huinker, reviewed by Kyotaro Horiguchi, Andres Freund, and me.
      dc203dc3
    • Tom Lane's avatar
      Fix IsValidJsonNumber() to notice trailing non-alphanumeric garbage. · e6ecc93a
      Tom Lane authored
      Commit e09996ff was one brick shy of a load: it didn't insist
      that the detected JSON number be the whole of the supplied string.
      This allowed inputs such as "2016-01-01" to be misdetected as valid JSON
      numbers.  Per bug #13906 from Dmitry Ryabov.
      
      In passing, be more wary of zero-length input (I'm not sure this can
      happen given current callers, but better safe than sorry), and do some
      minor cosmetic cleanup.
      e6ecc93a
    • Peter Eisentraut's avatar
      Add support for systemd service notifications · 7d17e683
      Peter Eisentraut authored
      Insert sd_notify() calls at server start and stop for integration with
      systemd.  This allows the use of systemd service units of type "notify",
      which greatly simplifies the systemd configuration.
      Reviewed-by: default avatarPavel Stěhule <pavel.stehule@gmail.com>
      7d17e683
    • Peter Eisentraut's avatar
      Improve error reporting when location specified by postgres -D does not exist · ac7238dc
      Peter Eisentraut authored
      Previously, the first error seen would be that postgresql.conf does not
      exist.  But for the case where the whole directory does not exist, give
      an error message about that, together with a hint for how to create one.
      ac7238dc
  6. 02 Feb, 2016 1 commit
    • Tom Lane's avatar
      Remove printQueryOpt.quote field. · 2808a2e0
      Tom Lane authored
      This field was included in the original definition of the printQueryOpt
      struct in commit a45195a1, but it was not used anywhere in that
      commit, nor since then.  Spotted by Dickson S. Guedes.
      2808a2e0