1. 04 Feb, 2018 1 commit
  2. 03 Feb, 2018 4 commits
  3. 02 Feb, 2018 8 commits
    • Tom Lane's avatar
      Fix another instance of unsafe coding for shm_toc_lookup failure. · d59ff4ab
      Tom Lane authored
      One or another author of commit 5bcf389e seems to have thought that
      computing an offset from a NULL pointer would yield another NULL pointer.
      There may possibly be architectures where that works, but common machines
      don't work like that.  Per a quick code review of places calling
      shm_toc_lookup and not using noError = false.
      d59ff4ab
    • Tom Lane's avatar
      Be more wary about shm_toc_lookup failure. · 957ff087
      Tom Lane authored
      Commit 445dbd82 basically missed the point of commit d4663350,
      which was that we shouldn't allow shm_toc_lookup() failure to lead
      to a core dump or assertion crash, because the odds of such a
      failure should never be considered negligible.  It's correct that
      we can't expect the PARALLEL_KEY_ERROR_QUEUE TOC entry to be there
      if we have no workers.  But if we have no workers, we're not going
      to do anything in this function with the lookup result anyway,
      so let's just skip it.  That lets the code use the easy-to-prove-safe
      noError=false case, rather than anything requiring effort to review.
      
      Back-patch to v10, like the previous commit.
      
      Discussion: https://postgr.es/m/3647.1517601675@sss.pgh.pa.us
      957ff087
    • Tom Lane's avatar
      First-draft release notes for 10.2. · bf641d33
      Tom Lane authored
      As usual, the release notes for other branches will be made by cutting
      these down, but put them up for community review first.
      bf641d33
    • Peter Eisentraut's avatar
      Fix application of identity values in some cases · 533c5d8b
      Peter Eisentraut authored
      Investigation of 2d2d06b7 revealed that
      identity values were not applied in some further cases, including
      logical replication subscribers, VALUES RTEs, and ALTER TABLE ... ADD
      COLUMN.  To fix all that, apply the identity column expression in
      build_column_default() instead of repeating the same logic at each call
      site.
      
      For ALTER TABLE ... ADD COLUMN ... IDENTITY, the previous coding
      completely ignored that existing rows for the new column should have
      values filled in from the identity sequence.  The coding using
      build_column_default() fails for this because the sequence ownership
      isn't registered until after ALTER TABLE, and we can't do it before
      because we don't have the column in the catalog yet.  So we specially
      remember in ColumnDef the sequence name that we decided on and build a
      custom NextValueExpr using that.
      Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
      533c5d8b
    • Robert Haas's avatar
      Support parallel btree index builds. · 9da0cc35
      Robert Haas authored
      To make this work, tuplesort.c and logtape.c must also support
      parallelism, so this patch adds that infrastructure and then applies
      it to the particular case of parallel btree index builds.  Testing
      to date shows that this can often be 2-3x faster than a serial
      index build.
      
      The model for deciding how many workers to use is fairly primitive
      at present, but it's better than not having the feature.  We can
      refine it as we get more experience.
      
      Peter Geoghegan with some help from Rushabh Lathia.  While Heikki
      Linnakangas is not an author of this patch, he wrote other patches
      without which this feature would not have been possible, and
      therefore the release notes should possibly credit him as an author
      of this feature.  Reviewed by Claudio Freire, Heikki Linnakangas,
      Thomas Munro, Tels, Amit Kapila, me.
      
      Discussion: http://postgr.es/m/CAM3SWZQKM=Pzc=CAHzRixKjp2eO5Q0Jg1SoFQqeXFQ647JiwqQ@mail.gmail.com
      Discussion: http://postgr.es/m/CAH2-Wz=AxWqDoVvGU7dq856S4r6sJAj6DBn7VMtigkB33N5eyg@mail.gmail.com
      9da0cc35
    • Robert Haas's avatar
      Refactor code for partition bound searching · 9aef1731
      Robert Haas authored
      Remove partition_bound_cmp() and partition_bound_bsearch(), whose
      void * argument could be, depending on the situation, of any of
      three different types: PartitionBoundSpec *, PartitionRangeBound *,
      Datum *.
      
      Instead, introduce separate bound-searching functions for each
      situation: partition_list_bsearch, partition_range_bsearch,
      partition_range_datum_bsearch, and partition_hash_bsearch.  This
      requires duplicating the code for binary search, but it makes the
      code much more type safe, involves fewer branches at runtime, and
      at least in my opinion, is much easier to understand.
      
      Along the way, add an option to partition_range_datum_bsearch
      allowing the number of keys to be specified, so that we can search
      for partitions based on a prefix of the full list of partition
      keys.  This is important for pending work to improve partition
      pruning.
      
      Amit Langote, per a suggestion from me.
      
      Discussion: http://postgr.es/m/CA+TgmoaVLDLc8=YESRwD32gPhodU_ELmXyKs77gveiYp+JE4vQ@mail.gmail.com
      9aef1731
    • Robert Haas's avatar
      Add new function WaitForParallelWorkersToAttach. · 9222c0d9
      Robert Haas authored
      Once this function has been called, we know that all workers have
      started and attached to their error queues -- so if any of them
      subsequently exit uncleanly, we'll be sure to throw an ERROR promptly.
      Otherwise, users of the ParallelContext machinery must be careful not
      to wait forever for a worker that has failed to start.  Parallel query
      manages to work without needing this for reasons explained in new
      comments added by this patch, but it's a useful primitive for other
      parallel operations, such as the pending patch to make creating a
      btree index run in parallel.
      
      Amit Kapila, revised by me.  Additional review by Peter Geoghegan.
      
      Discussion: http://postgr.es/m/CAA4eK1+e2MzyouF5bg=OtyhDSX+=Ao=3htN=T-r_6s3gCtKFiw@mail.gmail.com
      9222c0d9
    • Stephen Frost's avatar
      Improve ALTER TABLE synopsis · a2a22057
      Stephen Frost authored
      Add into the ALTER TABLE synopsis the definition of
      partition_bound_spec, column_constraint, index_parameters and
      exclude_element.
      
      Initial patch by Lætitia Avrot, with further improvements by Amit
      Langote and Thomas Munro.
      
      Discussion: https://postgr.es/m/flat/27ec4df3-d1ab-3411-f87f-647f944897e1%40lab.ntt.co.jp
      a2a22057
  4. 01 Feb, 2018 2 commits
  5. 31 Jan, 2018 11 commits
  6. 30 Jan, 2018 5 commits
  7. 29 Jan, 2018 7 commits
    • Andres Freund's avatar
      Introduce ExecQualAndReset() helper. · c12693d8
      Andres Freund authored
      It's a common task to evaluate a qual and reset the corresponding
      expression context. Currently that requires storing the result of the
      qual eval, resetting the context, and then reacting on the result. As
      that's awkward several places only reset the context next time through
      a node. That's not great, so introduce a helper that evaluates and
      resets.
      
      It's a bit ugly that it currently uses MemoryContextReset() instead of
      ResetExprContext(), but that seems easier than reordering all of
      executor.h.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20180109222544.f7loxrunqh3xjl5f@alap3.anarazel.de
      c12693d8
    • Tom Lane's avatar
      Save a few bytes by removing useless last argument to SearchCatCacheList. · 97d4445a
      Tom Lane authored
      There's never any value in giving a fully specified cache key to
      SearchCatCacheList: you might as well call SearchCatCache instead,
      since there could be only one match.  So the maximum useful number of
      key arguments is one less than the supported number of key columns.
      We might as well remove the useless extra argument and save some few
      bytes per call site, as well as a cycle or so per call.
      
      I believe the reason it was coded like this is that originally, callers
      had to write out all the dummy arguments in each call, and so it seemed
      less confusing if SearchCatCache and SearchCatCacheList took the same
      number of key arguments.  But since commit e26c539e, callers only write
      their live arguments explicitly, making that a non-factor; and there's
      surely been enough time for third-party modules to adapt to that coding
      style.  So this is only an ABI break not an API break for callers.
      
      Per discussion with Oliver Ford, this might also make it less confusing
      how to use SearchCatCacheList correctly.
      
      Discussion: https://postgr.es/m/27788.1517069693@sss.pgh.pa.us
      97d4445a
    • Andres Freund's avatar
      Initialize unused ExprEvalStep fields. · fc96c694
      Andres Freund authored
      ExecPushExprSlots didn't initialize ExprEvalStep's resvalue/resnull
      steps as it didn't use them. That caused wrong valgrind warnings for
      an upcoming patch, so zero-intialize.
      
      Also zero-initialize all scratch ExprEvalStep's allocated on the
      stack, to avoid issues with similar future omissions of non-critial
      data.
      fc96c694
    • Peter Eisentraut's avatar
      doc: Clarify pg_upgrade documentation · 1e1e599d
      Peter Eisentraut authored
      Clarify that the restriction against reg* types only applies to table
      columns using these types, not to the type appearing in any other way,
      for example as a function argument.
      1e1e599d
    • Andres Freund's avatar
      Prevent growth of simplehash tables when they're "too empty". · ab9f2c42
      Andres Freund authored
      In cases where simplehash tables where filled with either a lot of
      conflicting hash-values, or values that hash to consecutive
      values (i.e. build "chains") the growth heuristics in
      d4c62a6b could trigger rather
      explosively.
      
      To fix that, address some of the reasons (see previous commit) of why
      the growth heuristics where needed, and only allow growth when the
      table isn't too empty. While that means there's a few cases of bad
      input that can be slower, that seems a lot better than running very
      quickly out of memory.
      
      Author: Tomas Vondra and Andres Freund, with additional input by
          Thomas Munro, Tom Lane Todd A. Cook
      Reported-By: Todd A. Cook, Tomas Vondra, Thomas Munro
      Discussion: https://postgr.es/m/20171127185700.1470.20362@wrigleys.postgresql.org
      Backpatch: 10, where simplehash was introduced
      ab9f2c42
    • Andres Freund's avatar
      Improve bit perturbation in TupleHashTableHash. · c068f877
      Andres Freund authored
      The changes in b81b5a96 did not fully
      address the issue, because the bit-mixing of the IV into the final
      hash-key didn't prevent clustering in the input-data survive in the
      output data.
      
      This didn't cause a lot of problems because of the additional growth
      conditions added d4c62a6b. But as we
      want to rein those in due to explosive growth in some edges, this
      needs to be fixed.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20171127185700.1470.20362@wrigleys.postgresql.org
      Backpatch: 10, where simplehash was introduced
      c068f877
    • Tom Lane's avatar
      Avoid misleading psql password prompt when username is multiply specified. · 15be2746
      Tom Lane authored
      When a password is needed, cases such as
      	psql -d "postgresql://alice@localhost/testdb" -U bob
      would incorrectly prompt for "Password for user bob: ", when actually the
      connection will be attempted with username alice.  The priority order of
      which name to use isn't that important here, but the misleading prompt is.
      
      When we are prompting for a password after initial connection failure,
      we can fix this reliably by looking at PQuser(conn) to see how libpq
      interpreted the connection arguments.  But when we're doing a forced
      password prompt because of a -W switch, we can't use that solution.
      Fortunately, because the main use of -W is for noninteractive situations,
      it's less critical to produce a helpful prompt in such cases.  I made
      the startup prompt for -W just say "Password: " all the time, rather
      than expending extra code on trying to identify which username to use.
      In the case of a \c command (after -W has been given), there's already
      logic in do_connect that determines whether the "dbname" is a connstring
      or URI, so we can avoid lobotomizing the prompt except in cases that
      are actually dubious.  (We could do similarly in startup.c if anyone
      complains, but for now it seems not worthwhile, especially since that
      would still be only a partial solution.)
      
      Per bug #15025 from Akos Vandra.  Although this is arguably a bug fix,
      it doesn't seem worth back-patching.  The case where it matters seems
      like a very corner-case usage, and someone might complain that we'd
      changed the behavior of -W in a minor release.
      
      Discussion: https://postgr.es/m/20180123130013.7407.24749@wrigleys.postgresql.org
      15be2746
  8. 28 Jan, 2018 2 commits
    • Tom Lane's avatar
      Add stack-overflow guards in set-operation planning. · 35a52806
      Tom Lane authored
      create_plan_recurse lacked any stack depth check.  This is not per
      our normal coding rules, but I'd supposed it was safe because earlier
      planner processing is more complex and presumably should eat more
      stack.  But bug #15033 from Andrew Grossman shows this isn't true,
      at least not for queries having the form of a many-thousand-way
      INTERSECT stack.
      
      Further testing showed that recurse_set_operations is also capable
      of being crashed in this way, since it likewise will recurse to the
      bottom of a parsetree before calling any support functions that
      might themselves contain any stack checks.  However, its stack
      consumption is only perhaps a third of create_plan_recurse's.
      
      It's possible that this particular problem with create_plan_recurse can
      only manifest in 9.6 and later, since before that we didn't build a Path
      tree for set operations.  But having seen this example, I now have no
      faith in the proposition that create_plan_recurse doesn't need a stack
      check, so back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/20180127050845.28812.58244@wrigleys.postgresql.org
      35a52806
    • Bruce Momjian's avatar
      C includes: Reorder C includes in partition.c · 010123e1
      Bruce Momjian authored
      Discussion: https://postgr.es/m/5A69AA50.2060600@lab.ntt.co.jp
      
      Author: Etsuro Fujita
      010123e1