1. 29 Jan, 2019 4 commits
    • Etsuro Fujita's avatar
      postgres_fdw: Fix test for cached costs in estimate_path_cost_size(). · 449d0a85
      Etsuro Fujita authored
      estimate_path_cost_size() failed to re-use cached costs when the cached
      startup/total cost was 0, so it calculated the costs redundantly.
      
      This is an oversight in commit aa09cd24; but apply the patch to HEAD
      only because there are no reports of actual trouble from that.
      
      Author: Etsuro Fujita
      Discussion: https://postgr.es/m/5C4AF3F3.4060409%40lab.ntt.co.jp
      449d0a85
    • Michael Paquier's avatar
      Use catalog query to discover tables to process in vacuumdb · e0c2933a
      Michael Paquier authored
      vacuumdb would use a catalog query only when the command caller does not
      define a list of tables.  Switching to a catalog table represents two
      advantages:
      - Relation existence check can happen before running any VACUUM or
      ANALYZE query.  Before this change, if multiple relations are defined
      using --table, the utility would fail only after processing the
      firstly-defined ones, which may be a long some depending on the size of
      the relation.  This adds checks for the relation names, and does
      nothing, at least yet, for the attribute names.
      - More filtering options can become available for the utility user.
      These options, which may be introduced later on, are based on the
      relation size or the relation age, and need to be made available even if
      the user does not list any specific table with --table.
      
      Author: Nathan Bossart
      Reviewed-by: Michael Paquier, Masahiko Sawada
      Discussion: https://postgr.es/m/FFE5373C-E26A-495B-B5C8-911EC4A41C5E@amazon.com
      e0c2933a
    • Andres Freund's avatar
      Fix LLVM related headers to compile standalone (to fix cpluspluscheck). · da05eb51
      Andres Freund authored
      Previously llvmjit.h #error'ed when USE_LLVM was not defined, to
      prevent it from being included from code not having #ifdef USE_LLVM
      guards - but that's not actually that useful after, during the
      development of JIT support, LLVM related code was moved into a
      separately compiled .so.  Having that #error means cpluspluscheck
      doesn't work when llvm support isn't enabled, which isn't great.
      
      Similarly add USE_LLVM guards to llvmjit_emit.h, and additionally make
      sure it compiles standalone.
      
      Per complaint from Tom Lane.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/19808.1548692361@sss.pgh.pa.us
      Backpatch: 11, where JIT support was added
      da05eb51
    • Andres Freund's avatar
      Revert "Move page initialization from RelationAddExtraBlocks() to use." · 68420054
      Andres Freund authored
      This reverts commit fc02e672 and
      e6799d5a.
      
      Parts of the buildfarm error out with
      ERROR: page %u of relation "%s" should be empty but is not
      errors, and so far I/we do not know why. fc02e672 didn't fix the
      issue.  As I cannot reproduce the issue locally, it seems best to get
      the buildfarm green again, and reproduce the issue without time
      pressure.
      68420054
  2. 28 Jan, 2019 11 commits
    • Andres Freund's avatar
      Fix race condition between relation extension and vacuum. · fc02e672
      Andres Freund authored
      In e6799d5a I removed vacuumlazy.c trickery around re-checking
      whether a page is actually empty after acquiring an extension lock on
      the relation, because the page is not PageInit()ed anymore, and
      entries in the FSM ought not to lead to user-visible errors.
      
      As reported by various buildfarm animals that is not correct, given
      the way to code currently stands: If vacuum processes a page that's
      just been newly added by either RelationGetBufferForTuple() or
      RelationAddExtraBlocks(), it could add that page to the FSM and it
      could be reused by other backends, before those two functions check
      whether the newly added page is actually new.  That's a relatively
      narrow race, but several buildfarm machines appear to be able to hit
      it.
      
      While it seems wrong that the FSM, given it's lack of durability and
      approximative nature, can trigger errors like this, that seems better
      fixed in a separate commit. Especially given that a good portion of
      the buildfarm is red, and this is just re-introducing logic that
      existed a few hours ago.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20190128222259.zhi7ovzgtkft6em6@alap3.anarazel.de
      fc02e672
    • Tomas Vondra's avatar
      Separate per-batch and per-tuple memory contexts in COPY · 36a1281f
      Tomas Vondra authored
      In batching mode, COPY was using the same (per-tuple) memory context for
      allocations with longer lifetime. This was confusing but harmless, until
      commit 31f38174 added COPY FROM ... WHERE feature, introducing a risk
      of memory leak.
      
      The "per-tuple" memory context was reset only when starting new batch,
      but as the rows may be filtered out by the WHERE clauses, that may not
      happen at all.  The WHERE clause however has to be evaluated for all
      rows, before filtering them out.
      
      This commit separates the per-tuple and per-batch contexts, removing the
      ambiguity.  Expressions (both defaults and WHERE clause) are evaluated
      in the per-tuple context, while tuples are formed in the batch context.
      This allows resetting the contexts at appropriate times.
      
      The main complexity is related to partitioning, in which case we need to
      reset the batch context after forming the tuple (which happens before
      routing to leaf partition).  Instead of switching between two contexts
      as before, we simply copy the last tuple aside, reset the context and
      then copy the tuple back.  The performance impact is negligible, and
      juggling with two contexts is not free either.
      
      Discussion: https://www.postgresql.org/message-id/flat/CALAY4q_DdpWDuB5-Zyi-oTtO2uSk8pmy+dupiRe3AvAc++1imA@mail.gmail.com
      36a1281f
    • Tom Lane's avatar
      In the planner, replace an empty FROM clause with a dummy RTE. · 4be058fe
      Tom Lane authored
      The fact that "SELECT expression" has no base relations has long been a
      thorn in the side of the planner.  It makes it hard to flatten a sub-query
      that looks like that, or is a trivial VALUES() item, because the planner
      generally uses relid sets to identify sub-relations, and such a sub-query
      would have an empty relid set if we flattened it.  prepjointree.c contains
      some baroque logic that works around this in certain special cases --- but
      there is a much better answer.  We can replace an empty FROM clause with a
      dummy RTE that acts like a table of one row and no columns, and then there
      are no such corner cases to worry about.  Instead we need some logic to
      get rid of useless dummy RTEs, but that's simpler and covers more cases
      than what was there before.
      
      For really trivial cases, where the query is just "SELECT expression" and
      nothing else, there's a hazard that adding the extra RTE makes for a
      noticeable slowdown; even though it's not much processing, there's not
      that much for the planner to do overall.  However testing says that the
      penalty is very small, close to the noise level.  In more complex queries,
      this is able to find optimizations that we could not find before.
      
      The new RTE type is called RTE_RESULT, since the "scan" plan type it
      gives rise to is a Result node (the same plan we produced for a "SELECT
      expression" query before).  To avoid confusion, rename the old ResultPath
      path type to GroupResultPath, reflecting that it's only used in degenerate
      grouping cases where we know the query produces just one grouped row.
      (It wouldn't work to unify the two cases, because there are different
      rules about where the associated quals live during query_planner.)
      
      Note: although this touches readfuncs.c, I don't think a catversion
      bump is required, because the added case can't occur in stored rules,
      only plans.
      
      Patch by me, reviewed by David Rowley and Mark Dilger
      
      Discussion: https://postgr.es/m/15944.1521127664@sss.pgh.pa.us
      4be058fe
    • Andres Freund's avatar
      Install JIT related headers. · 5c118675
      Andres Freund authored
      There's no reason not to install these, and jit.h can be useful for
      users of e.g. planner hooks.
      
      Author: Donald Dong
      Reviewed-By: Andres Freund
      Discussion: https://postgr.es/m/296D405F-7F95-49F1-B565-389D6AA78505@csumb.edu
      Backpatch: 11-, where JIT compilation was introduced
      5c118675
    • Andres Freund's avatar
      Move page initialization from RelationAddExtraBlocks() to use. · e6799d5a
      Andres Freund authored
      Previously we initialized pages when bulk extending in
      RelationAddExtraBlocks(). That has a major disadvantage: It ties
      RelationAddExtraBlocks() to heap, as other types of storage are likely
      to need different amounts of special space, have different amount of
      free space (previously determined by PageGetHeapFreeSpace()).
      
      That we're relying on initializing pages, but not WAL logging the
      initialization, also means the risk for getting
      "WARNING:  relation \"%s\" page %u is uninitialized --- fixing"
      style warnings in vacuums after crashes/immediate shutdowns, is
      considerably higher. The warning sounds much more serious than what
      they are.
      
      Fix those two issues together by not initializing pages in
      RelationAddExtraPages() (but continue to do so in
      RelationGetBufferForTuple(), which is linked much more closely to
      heap), and accepting uninitialized pages as normal in
      vacuumlazy.c. When vacuumlazy encounters an empty page it now adds it
      to the FSM, but does nothing else.  We chose to not issue a debug
      message, much less a warning in that case - it seems rarely useful,
      and quite likely to scare people unnecessarily.
      
      For now empty pages aren't added to the VM, because standbys would not
      re-discover such pages after a promotion. In contrast to other sources
      for empty pages, there's no corresponding WAL records triggering FSM
      updates during replay.
      
      Author: Andres Freund
      Reviewed-By: Tom Lane
      Discussion: https://postgr.es/m/20181219083945.6khtgm36mivonhva@alap3.anarazel.de
      e6799d5a
    • Peter Eisentraut's avatar
      psql: Remove unused tab completion query · d4316b87
      Peter Eisentraut authored
      This was used for the old CLUSTER syntax, has been unused since
      e55c8e36.
      d4316b87
    • Peter Eisentraut's avatar
    • Michael Paquier's avatar
      Add tab completion for ALTER INDEX ALTER COLUMN in psql · 23349b18
      Michael Paquier authored
      The completion here consists of attribute numbers, which is specific to
      this grammar.
      
      Author: Tatsuro Yamada
      Reviewed-by: Peter Eisentraut
      Discussion: https://portgr.es/m/b58a78fa-81ce-186f-f0bc-c1aa93c46cbf@lab.ntt.co.jp
      23349b18
    • Amit Kapila's avatar
      a2367650
    • Amit Kapila's avatar
      Avoid creation of the free space map for small heap relations. · ac88d296
      Amit Kapila authored
      Previously, all heaps had FSMs. For very small tables, this means that the
      FSM took up more space than the heap did. This is wasteful, so now we
      refrain from creating the FSM for heaps with 4 pages or fewer. If the last
      known target block has insufficient space, we still try to insert into some
      other page before giving up and extending the relation, since doing
      otherwise leads to table bloat. Testing showed that trying every page
      penalized performance slightly, so we compromise and try every other page.
      This way, we visit at most two pages. Any pages with wasted free space
      become visible at next relation extension, so we still control table bloat.
      As a bonus, directly attempting one or two pages can even be faster than
      consulting the FSM would have been.
      
      Once the FSM is created for a heap we don't remove it even if somebody
      deletes all the rows from the corresponding relation.  We don't think it is
      a useful optimization as it is quite likely that relation will again grow
      to the same size.
      
      Author: John Naylor with design inputs and some code contribution by Amit Kapila
      Reviewed-by: Amit Kapila
      Tested-by: Mithun C Y
      Discussion: https://www.postgresql.org/message-id/CAJVSVGWvB13PzpbLEecFuGFc5V2fsO736BsdTakPiPAcdMM5tQ@mail.gmail.com
      ac88d296
    • Amit Kapila's avatar
      In bootstrap mode, don't allow the creation of files if they don't already · d66e3664
      Amit Kapila authored
      exist.
      
      In commit's b9d01fe2 and 3908473c, we have added some code where we
      allowed the creation of files during mdopen even if they didn't exist
      during the bootstrap mode.  The later commit obviates the need for same.
      
      This was harmless code till now but with an upcoming feature where we don't
      allow to create FSM for small tables, this will needlessly create FSM
      files.
      
      Author: John Naylor
      Reviewed-by: Amit Kapila
      Discussion: https://www.postgresql.org/message-id/CAJVSVGWvB13PzpbLEecFuGFc5V2fsO736BsdTakPiPAcdMM5tQ@mail.gmail.com
      	    https://www.postgresql.org/message-id/CAA4eK1KsET6sotf+rzOTQfb83pzVEzVhbQi1nxGFYVstVWXUGw@mail.gmail.com
      d66e3664
  3. 27 Jan, 2019 2 commits
  4. 26 Jan, 2019 5 commits
    • Andres Freund's avatar
      Change function call information to be variable length. · a9c35cf8
      Andres Freund authored
      Before this change FunctionCallInfoData, the struct arguments etc for
      V1 function calls are stored in, always had space for
      FUNC_MAX_ARGS/100 arguments, storing datums and their nullness in two
      arrays.  For nearly every function call 100 arguments is far more than
      needed, therefore wasting memory. Arg and argnull being two separate
      arrays also guarantees that to access a single argument, two
      cachelines have to be touched.
      
      Change the layout so there's a single variable-length array with pairs
      of value / isnull. That drastically reduces memory consumption for
      most function calls (on x86-64 a two argument function now uses
      64bytes, previously 936 bytes), and makes it very likely that argument
      value and its nullness are on the same cacheline.
      
      Arguments are stored in a new NullableDatum struct, which, due to
      padding, needs more memory per argument than before. But as usually
      far fewer arguments are stored, and individual arguments are cheaper
      to access, that's still a clear win.  It's likely that there's other
      places where conversion to NullableDatum arrays would make sense,
      e.g. TupleTableSlots, but that's for another commit.
      
      Because the function call information is now variable-length
      allocations have to take the number of arguments into account. For
      heap allocations that can be done with SizeForFunctionCallInfoData(),
      for on-stack allocations there's a new LOCAL_FCINFO(name, nargs) macro
      that helps to allocate an appropriately sized and aligned variable.
      
      Some places with stack allocation function call information don't know
      the number of arguments at compile time, and currently variably sized
      stack allocations aren't allowed in postgres. Therefore allow for
      FUNC_MAX_ARGS space in these cases. They're not that common, so for
      now that seems acceptable.
      
      Because of the need to allocate FunctionCallInfo of the appropriate
      size, older extensions may need to update their code. To avoid subtle
      breakages, the FunctionCallInfoData struct has been renamed to
      FunctionCallInfoBaseData. Most code only references FunctionCallInfo,
      so that shouldn't cause much collateral damage.
      
      This change is also a prerequisite for more efficient expression JIT
      compilation (by allocating the function call information on the stack,
      allowing LLVM to optimize it away); previously the size of the call
      information caused problems inside LLVM's optimizer.
      
      Author: Andres Freund
      Reviewed-By: Tom Lane
      Discussion: https://postgr.es/m/20180605172952.x34m5uz6ju6enaem@alap3.anarazel.de
      a9c35cf8
    • Tom Lane's avatar
      Fix psql's "\g target" meta-command to work with COPY TO STDOUT. · 6d3ede5f
      Tom Lane authored
      Previously, \g would successfully execute the COPY command, but
      the target specification if any was ignored, so that the data was
      always dumped to the regular query output target.  This seems like
      a clear bug, so let's not just fix it but back-patch it.
      
      While at it, adjust the documentation for \copy to recommend
      "COPY ... TO STDOUT \g foo" as a plausible alternative.
      
      Back-patch to 9.5.  The problem exists much further back, but the
      code associated with \g was refactored enough in 9.5 that we'd
      need a significantly different patch for 9.4, and it doesn't
      seem worth the trouble.
      
      Daniel Vérité, reviewed by Fabien Coelho
      
      Discussion: https://postgr.es/m/15dadc39-e050-4d46-956b-dcc4ed098753@manitou-mail.org
      6d3ede5f
    • Peter Eisentraut's avatar
      Make regression test output locale-independent · 1e4730c6
      Peter Eisentraut authored
      In some locales, letters sort before numbers, so change the object
      naming to not depend on that.  Introduced by commit
      7c079d74.
      1e4730c6
    • Tom Lane's avatar
      Allow UNLISTEN in hot-standby mode. · ebfe20dc
      Tom Lane authored
      Since LISTEN is (still) disallowed, UNLISTEN must be a no-op in a
      hot-standby session, and so there's no harm in allowing it.  This
      change allows client code to not worry about whether it's connected
      to a primary or standby server when performing session-state-reset
      type activities.  (Note that DISCARD ALL, which includes UNLISTEN,
      was already allowed, making it inconsistent to reject UNLISTEN.)
      
      Per discussion, back-patch to all supported versions.
      
      Shay Rojansky, reviewed by Mi Tar
      
      Discussion: https://postgr.es/m/CADT4RqCf2gA_TJtPAjnGzkC3ZiexfBZiLmA-mV66e4UyuVv8bA@mail.gmail.com
      ebfe20dc
    • Michael Paquier's avatar
      Simplify restriction handling of two-phase commit for temporary objects · c9b75c58
      Michael Paquier authored
      There were two flags used to track the access to temporary tables and
      to the temporary namespace of a session which are used to restrict
      PREPARE TRANSACTION, however the first control flag is a concept
      included in the second.  This removes the flag for temporary table
      tracking, keeping around only the one at namespace level.
      
      Author: Michael Paquier
      Reviewed-by: Álvaro Herrera
      Discussion: https://postgr.es/m/20190118053126.GH1883@paquier.xyz
      c9b75c58
  5. 25 Jan, 2019 7 commits
    • Bruce Momjian's avatar
      SQL comment: remove extra word in heading comment · df4c9044
      Bruce Momjian authored
      Reported-by: Daniel Gustafsson
      
      Discussion: https://postgr.es/m/431D5BC1-9696-43FA-B54C-39D5503EB753@yesql.se
      
      Backpatch-through: master
      df4c9044
    • Tom Lane's avatar
      Split QTW_EXAMINE_RTES flag into QTW_EXAMINE_RTES_BEFORE/_AFTER. · 18c0da88
      Tom Lane authored
      This change allows callers of query_tree_walker() to choose whether
      to visit an RTE before or after visiting the contents of the RTE
      (i.e., prefix or postfix tree order).  All existing users of
      QTW_EXAMINE_RTES want the QTW_EXAMINE_RTES_BEFORE behavior, but
      an upcoming patch will want QTW_EXAMINE_RTES_AFTER, and it seems
      like a potentially useful change on its own.
      
      Andreas Karlsson (extracted from CTE inlining patch)
      
      Discussion: https://postgr.es/m/8810.1542402910@sss.pgh.pa.us
      18c0da88
    • Tom Lane's avatar
      Teach nulltestsel() that system columns are never NULL. · ff750ce2
      Tom Lane authored
      While it's perhaps unlikely that users would write an explicit test
      like "ctid IS NULL", this function is also used in range estimation,
      and an incorrect answer can throw off the results for tight ranges.
      Anyway it's not much code so we might as well do it.
      
      Edmund Horner
      
      Discussion: https://postgr.es/m/CAMyN-kCa3BFUFrCTtQeprxTU1anCd3Pua7zXstGCKq4pXgjukw@mail.gmail.com
      ff750ce2
    • Tom Lane's avatar
      Fix possibly-uninitialized-variable warning from commit 9556aa01. · 6119060d
      Tom Lane authored
      Heikki's compiler doesn't complain about end_ptr, apparently,
      but mine does.
      
      In passing, I failed to resist the temptation to remove the
      no-longer-used fldnum variable, and relocate chunk_len's
      declaration to a narrower scope.
      6119060d
    • Heikki Linnakangas's avatar
      Use single-byte Boyer-Moore-Horspool search even with multibyte encodings. · 9556aa01
      Heikki Linnakangas authored
      The old implementation first converted the input strings to arrays of
      wchars, and performed the conversion on those. However, the conversion is
      expensive, and for a large input string, consumes a lot of memory.
      Allocating the large arrays also meant that these functions could not be
      used on strings larger 1 GB / pg_encoding_max_length() (256 MB for UTF-8).
      
      Avoid the conversion, and instead use the single-byte algorithm even with
      multibyte encodings. That can get fooled, if there is a matching byte
      sequence in the middle of a multi-byte character, so to eliminate false
      positives like that, we verify any matches by walking the string character
      by character with pg_mblen(). Also, if the caller needs the position of
      the match, as a character-offset, we also need to walk the string to count
      the characters.
      
      Performance testing shows that walking the whole string with pg_mblen() is
      somewhat slower than converting the whole string to wchars. It's still
      often a win, though, because we don't need to do it if there is no match,
      and even when there is, we only need to walk up to the point where the
      match is, not the whole string. Even in the worst case, there would be
      room for optimization: Much of the CPU time in the current loop with
      pg_mblen() is function call overhead, and could be improved by inlining
      pg_mblen() and/or the encoding-specific mblen() functions. But I didn't
      attempt to do that as part of this patch.
      
      Most of the callers of text_position_setup/next functions were actually
      not interested in the position of the match, counted in characters. To
      cater for them, refactor the text_position_next() interface into two
      parts: searching for the next match (text_position_next()), and returning
      the current match's position as a pointer (text_position_get_match_ptr())
      or as a character offset (text_position_get_match_pos()). Getting the
      pointer to the match is a more convenient API for many callers, and with
      UTF-8, it allows skipping the character-walking step altogether, because
      UTF-8 can't have false matches even when treated like raw byte strings.
      
      Reviewed-by: John Naylor
      Discussion: https://www.postgresql.org/message-id/3173d989-bc1c-fc8a-3b69-f24246f73876%40iki.fi
      9556aa01
    • Heikki Linnakangas's avatar
      Fix comments that claimed that mblen() only looks at first byte. · a5be6e9a
      Heikki Linnakangas authored
      GB18030's mblen() function looks at the first and the second byte of the
      multibyte character, to determine its length. copy.c had made the
      assumption that mblen() only looks at the first byte, but it turns out to
      work out fine, because of the way the GB18030 encoding works. COPY will
      see a 4-byte encoded character as two 2-byte encoded characters, which is
      enough for COPY's purposes. It cannot mix those up with delimiter or
      escaping characters, because only single-byte ASCII characters are
      supported as delimiters or escape characters.
      
      Discussion: https://www.postgresql.org/message-id/7704d099-9643-2a55-fb0e-becd64400dcb%40iki.fi
      a5be6e9a
    • Peter Eisentraut's avatar
      Allow generalized expression syntax for partition bounds · 7c079d74
      Peter Eisentraut authored
      Previously, only literals were allowed.  This change allows general
      expressions, including functions calls, which are evaluated at the
      time the DDL command is executed.
      
      Besides offering some more functionality, it simplifies the parser
      structures and removes some inconsistencies in how the literals were
      handled.
      
      Author: Kyotaro Horiguchi, Tom Lane, Amit Langote
      Reviewed-by: default avatarPeter Eisentraut <peter.eisentraut@2ndquadrant.com>
      Discussion: https://www.postgresql.org/message-id/flat/9f88b5e0-6da2-5227-20d0-0d7012beaa1c@lab.ntt.co.jp/
      7c079d74
  6. 24 Jan, 2019 10 commits
    • Tom Lane's avatar
      Remove _configthreadlocale() calls in ecpg test suite. · e3565fd6
      Tom Lane authored
      This essentially reverts commits a772624b and 04fbe0e4, which
      added "_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)" calls to the
      thread-related ecpg test programs.  That was nothing but a hack,
      because we shouldn't expect that ecpg-using applications have
      done that for us; and now that we've inserted such calls into
      ecpglib, the tests should still pass without it.
      
      (If they don't, it would be good to know that.)
      
      HEAD only; there seems no big need to change this in the
      back branches.
      
      Discussion: https://postgr.es/m/22937.1548307384@sss.pgh.pa.us
      e3565fd6
    • Tom Lane's avatar
      Remove infinite-loop hazards in ecpg test suite. · d5a1fde3
      Tom Lane authored
      A report from Andrew Dunstan showed that an ecpglib breakage that
      causes repeated query failures could lead to infinite loops in some
      ecpg test scripts, because they contain "while(1)" loops with no
      exit condition other than successful test completion.  That might
      be all right for manual testing, but it seems entirely unacceptable
      for automated test environments such as our buildfarm.  We don't
      want buildfarm owners to have to intervene manually when a test
      goes wrong.
      
      To fix, just change all those while(1) loops to exit after at most
      100 iterations (which is more than any of them expect to iterate).
      This seems sufficient since we'd see discrepancies in the test output
      if any loop executed the wrong number of times.
      
      I tested this by dint of intentionally breaking ecpg_do_prologue
      to always fail, and verifying that the tests still got to completion.
      
      Back-patch to all supported branches, since the whole point of this
      exercise is to protect the buildfarm against future mistakes.
      
      Discussion: https://postgr.es/m/18693.1548302004@sss.pgh.pa.us
      d5a1fde3
    • Peter Eisentraut's avatar
      PL/pgSQL: Add statement ID to statement structures · bbd5c207
      Peter Eisentraut authored
      This can be used by a profiler as the index for an array of
      per-statement metrics.
      
      Author: Pavel Stehule <pavel.stehule@gmail.com>
      Reviewed-by: default avatarPeter Eisentraut <peter.eisentraut@2ndquadrant.com>
      Discussion: https://www.postgresql.org/message-id/flat/CAFj8pRDRCjN6rpM9ZccU7Ta_afsNX7mg9=n34F+r445Nt9v2tA@mail.gmail.com/
      bbd5c207
    • Peter Eisentraut's avatar
      Fix whitespace · bf2fb2e0
      Peter Eisentraut authored
      bf2fb2e0
    • Alvaro Herrera's avatar
      Fix droppability of constraints upon partition detach · efd9366d
      Alvaro Herrera authored
      We were failing to set conislocal correctly for constraints in
      partitions after partition detach, leading to those constraints becoming
      undroppable.  Fix by setting the flag correctly.  Existing databases
      might contain constraints with the conislocal wrongly set to false, for
      partitions that were detached; this situation should be fixable by
      applying an UPDATE on pg_constraint to set conislocal true.  This
      problem should otherwise be innocuous and should disappear across a
      dump/restore or pg_upgrade.
      
      Secondarily, when constraint drop was attempted in a partitioned table,
      ATExecDropConstraint would try to recurse to partitions after doing
      performDeletion() of the constraint in the partitioned table itself; but
      since the constraint in the partitions are dropped by the initial call
      of performDeletion() (because of following dependencies), the recursion
      step would fail since it would not find the constraint, causing the
      whole operation to fail.  Fix by preventing recursion.
      
      Reported-by: Amit Langote
      Diagnosed-by: Amit Langote
      Author: Amit Langote, Álvaro Herrera
      Discussion: https://postgr.es/m/f2b8ead5-4131-d5a8-8016-2ea0a31250af@lab.ntt.co.jp
      efd9366d
    • Tom Lane's avatar
      Fix portability problem in pgbench. · e6c3ba7f
      Tom Lane authored
      The pgbench regression test supposed that srandom() with a specific value
      would result in deterministic output from random(), as required by POSIX.
      It emerges however that OpenBSD is too smart to be constrained by mere
      standards, so their random() emits nondeterministic output anyway.
      While a workaround does exist, what seems like a better fix is to stop
      relying on the platform's srandom()/random() altogether, so that what
      you get from --random-seed=N is not merely deterministic but platform
      independent.  Hence, use a separate pg_jrand48() random sequence in
      place of random().
      
      Also adjust the regression test case that's supposed to detect
      nondeterminism so that it's more likely to detect it; the original
      choice of random_zipfian parameter tended to produce the same output
      all the time even if the underlying behavior wasn't deterministic.
      
      In passing, improve pgbench's docs about random_zipfian().
      
      Back-patch to v11 where this code was introduced.
      
      Fabien Coelho and Tom Lane
      
      Discussion: https://postgr.es/m/4615.1547792324@sss.pgh.pa.us
      e6c3ba7f
    • Alvaro Herrera's avatar
      Simplify coding to detach constraints when detaching partition · 19184fcc
      Alvaro Herrera authored
      The original coding was too baroque and led to an use-after-release
      mistake, noticed by buildfarm member prion.
      
      Discussion: https://postgr.es/m/21693.1548305934@sss.pgh.pa.us
      19184fcc
    • Etsuro Fujita's avatar
      postgres_fdw: Account for tlist eval costs in estimate_path_cost_size(). · fd1afdba
      Etsuro Fujita authored
      Previously, estimate_path_cost_size() didn't account for tlist eval
      costs, except when costing a foreign-grouping path using local
      statistics, but such costs should be accounted for when costing that path
      using remote estimates, because some of the tlist expressions might be
      evaluated locally.  Also, such costs should be accounted for in the case
      of a foreign-scan or foreign-join path, because the tlist might contain
      PlaceHolderVars, which postgres_fdw currently evaluates locally.
      
      This also fixes an oversight in my commit f8f6e446.
      
      Like that commit, apply this to HEAD only to avoid destabilizing existing
      plan choices.
      
      Author: Etsuro Fujita
      Discussion: https://postgr.es/m/5BFD3EAD.2060301%40lab.ntt.co.jp
      fd1afdba
    • Tom Lane's avatar
      Blind attempt to fix _configthreadlocale() failures on MinGW. · 2cf91ccb
      Tom Lane authored
      Apparently, some builds of MinGW contain a version of
      _configthreadlocale() that always returns -1, indicating failure.
      Rather than treating that as a curl-up-and-die condition, soldier on
      as though the function didn't exist.  This leaves us without thread
      safety on such MinGW versions, but we didn't have it anyway.
      
      Discussion: https://postgr.es/m/d06a16bc-52d6-9f0d-2379-21242d7dbe81@2ndQuadrant.com
      2cf91ccb
    • Alvaro Herrera's avatar
      Detach constraints when partitions are detached · ae366aa5
      Alvaro Herrera authored
      I (Álvaro) forgot to do this in eb7ed3f3, leading to undroppable
      constraints after partitions are detached.  Repair.
      
      Reported-by: Amit Langote
      Author: Amit Langote
      Discussion: https://postgr.es/m/c1c9b688-b886-84f7-4048-1e4ebe9b1d06@lab.ntt.co.jp
      ae366aa5
  7. 23 Jan, 2019 1 commit