1. 06 Apr, 2017 23 commits
    • Andres Freund's avatar
      Allow avoiding tuple copy within tuplesort_gettupleslot(). · fa117ee4
      Andres Freund authored
      Add a "copy" argument to make it optional to receive a copy of caller
      tuple that is safe to use following a subsequent manipulating of
      tuplesort's state.  This is a performance optimization.  Most existing
      tuplesort_gettupleslot() callers are made to opt out of copying.
      Existing callers that happen to rely on the validity of tuple memory
      beyond subsequent manipulations of the tuplesort request their own
      copy.
      
      This brings tuplesort_gettupleslot() in line with
      tuplestore_gettupleslot().  In the future, a "copy"
      tuplesort_getdatum() argument may be added, that similarly allows
      callers to opt out of receiving their own copy of tuple.
      
      In passing, clarify assumptions that callers of other tuplesort fetch
      routines may make about tuple memory validity, per gripe from Tom
      Lane.
      
      Author: Peter Geoghegan
      Discussion: CAM3SWZQWZZ_N=DmmL7tKy_OUjGH_5mN=N=A6h7kHyyDvEhg2DA@mail.gmail.com
      fa117ee4
    • Joe Conway's avatar
      Silence uninitialized variable compiler warning in sepgsql · af8a94d1
      Joe Conway authored
      At -Og optimization gcc warns that variable tclass may be used
      uninitialized when relkind == RELKIND_INDEX. Actually that can't
      happen due to an early return, but quiet the compiler by initializing
      tclass to 0.
      
      In passing, use uint16_t consistently for the declaration of tclass.
      
      Complaint and initial patch by Mike Palmiotto. Editorializing by me.
      Probably not worth backpatching given that it is cosmetic, so apply
      to development head only.
      
      Discussion: https://postgr.es/m/flat/623bcaae-112e-ced0-8c22-a84f75ae0c53%40joeconway.com
      af8a94d1
    • Joe Conway's avatar
      Silence compiler warning in sepgsql · bd190eae
      Joe Conway authored
      <selinux/label.h> includes <stdbool.h>, which creates an incompatible
      We don't care if <stdbool.h> redefines "true"/"false"; those are close
      enough.
      
      Complaint and initial patch by Mike Palmiotto. Final approach per
      Tom Lane's suggestion, as discussed on hackers. Backpatching to
      all supported branches.
      
      Discussion: https://postgr.es/m/flat/623bcaae-112e-ced0-8c22-a84f75ae0c53%40joeconway.com
      bd190eae
    • Andres Freund's avatar
      Fix parallel bitmapscan tests on builds without USE_PREFETCH. · d611517f
      Andres Freund authored
      This was broken in 5a593153.
      d611517f
    • Alvaro Herrera's avatar
      Fix BRIN cost estimation · 7e534adc
      Alvaro Herrera authored
      The original code was overly optimistic about the cost of scanning a
      BRIN index, leading to BRIN indexes being selected when they'd be a
      worse choice than some other index.  This complete rewrite should be
      more accurate.
      
      Author: David Rowley, based on an earlier patch by Emre Hasegeli
      Reviewed-by: Emre Hasegeli
      Discussion: https://postgr.es/m/CAKJS1f9n-Wapop5Xz1dtGdpdqmzeGqQK4sV2MK-zZugfC14Xtw@mail.gmail.com
      7e534adc
    • Andres Freund's avatar
      Add minimal test for EXPLAIN ANALYZE of parallel query. · b2ff37d4
      Andres Freund authored
      This displays the number of workers launched, thus the test is
      dependant on configuration to some degree.  We'll see whether that
      turns out ot be a problem.
      
      Author: Rafia Sabih
      Discussion: https://postgr.es/m/20170331185540.zmsue4ndvqtnayqw@alap3.anarazel.de
      b2ff37d4
    • Andres Freund's avatar
    • Peter Eisentraut's avatar
      Fix logical replication between different encodings · 6f1b9aaa
      Peter Eisentraut authored
      When sending a tuple attribute, the previous coding erroneously sent the
      length byte before encoding conversion, which would lead to protocol
      failures on the receiving side if the length did not match the following
      string.
      
      To fix that, use pq_sendcountedtext() for sending tuple attributes,
      which takes care of all of that internally.  To match the API of
      pq_sendcountedtext(), send even text values without a trailing zero byte
      and have the receiving end put it in place instead.  This matches how
      the standard FE/BE protocol behaves.
      Reported-by: default avatarKyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
      6f1b9aaa
    • Peter Eisentraut's avatar
      Mark immutable functions in information schema as parallel safe · 5f21f529
      Peter Eisentraut authored
      Also add opr_sanity check that all preloaded immutable functions are
      parallel safe.  (Per discussion, this does not necessarily have to be
      true for all possible such functions, but deviations would be unlikely
      enough that maintaining such a test is reasonable.)
      Reported-by: default avatarDavid Rowley <david.rowley@2ndquadrant.com>
      Reviewed-by: default avatarRobert Haas <robertmhaas@gmail.com>
      Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
      5f21f529
    • Peter Eisentraut's avatar
      pg_dump: Rename some typedefs to avoid name conflicts · 4be613f6
      Peter Eisentraut authored
      In struct _archiveHandle, some of the fields have the same name as a
      typedef.  This is kind of confusing, so rename the types so they have
      names distinct from the struct fields.  In C++, the previous coding
      changes the meaning of the typedef in the scope of the struct, causing
      warnings and possibly other problems.
      Reviewed-by: default avatarAndres Freund <andres@anarazel.de>
      4be613f6
    • Tom Lane's avatar
      Clean up psql/describe.c's messy query for extended stats. · 20c95f27
      Tom Lane authored
      Remove unnecessary casts, safely schema-qualify the ones that remain,
      lose an unnecessary level of sub-SELECT, reformat for tidiness.
      20c95f27
    • Peter Eisentraut's avatar
      Fix mixup of bool and ternary value · e6c9a5a9
      Peter Eisentraut authored
      Not currently a problem, but could be with stricter bool behavior under
      stdbool or C++.
      Reviewed-by: default avatarAndres Freund <andres@anarazel.de>
      e6c9a5a9
    • Peter Eisentraut's avatar
      a071fe87
    • Peter Eisentraut's avatar
      Fix AclResult vs bool type mix-up · 301ca0d9
      Peter Eisentraut authored
      Using AclResult as a bool or vice versa works by accident, but it's
      unusual and possibly confusing style, so write it out more explicitly.
      301ca0d9
    • Alvaro Herrera's avatar
      Comment fixes for extended statistics · b1fc51a3
      Alvaro Herrera authored
      Clean up some code comments in new extended statistics code, from
      7b504eb2.
      b1fc51a3
    • Peter Eisentraut's avatar
      dc0400cc
    • Heikki Linnakangas's avatar
      Remove bogus SCRAM_ITERATION_LEN constant. · 07044efe
      Heikki Linnakangas authored
      It was not used for what the comment claimed, at all. It was actually used
      as the 'base' argument to strtol(), when reading the iteration count. We
      don't need a constant for base-10, so remove it.
      07044efe
    • Simon Riggs's avatar
      Always SnapshotResetXmin() during ClearTransaction() · cd0cebaf
      Simon Riggs authored
      Avoid corner cases during 2PC with 6bad580d
      cd0cebaf
    • Peter Eisentraut's avatar
      Identity columns · 32173270
      Peter Eisentraut authored
      This is the SQL standard-conforming variant of PostgreSQL's serial
      columns.  It fixes a few usability issues that serial columns have:
      
      - CREATE TABLE / LIKE copies default but refers to same sequence
      - cannot add/drop serialness with ALTER TABLE
      - dropping default does not drop sequence
      - need to grant separate privileges to sequence
      - other slight weirdnesses because serial is some kind of special macro
      Reviewed-by: default avatarVitaly Burovoy <vitaly.burovoy@gmail.com>
      32173270
    • Simon Riggs's avatar
      Avoid SnapshotResetXmin() during AtEOXact_Snapshot() · 6bad580d
      Simon Riggs authored
      For normal commits and aborts we already reset PgXact->xmin,
      so we can simply avoid running SnapshotResetXmin() twice.
      
      During performance tests by Alexander Korotkov, diagnosis
      by Andres Freund showed PgXact array as a bottleneck. After
      manual analysis by me of the code paths that touch those
      memory locations, I was able to identify extraneous code
      in the main transaction commit path.
      
      Avoiding touching highly contented shmem improves concurrent
      performance slightly on all workloads, confirmed by tests
      run by Ashutosh Sharma and Alexander Korotkov.
      
      Simon Riggs
      
      Discussion: CANP8+jJdXE9b+b9F8CQT-LuxxO0PBCB-SZFfMVAdp+akqo4zfg@mail.gmail.com
      6bad580d
    • Heikki Linnakangas's avatar
      Remove dead code and fix comments in fast-path function handling. · fd019835
      Heikki Linnakangas authored
      HandleFunctionRequest() is no longer responsible for reading the protocol
      message from the client, since commit 2b3a8b20. Fix the outdated
      comments.
      
      HandleFunctionRequest() now always returns 0, because the code that used
      to return EOF was moved in 2b3a8b20. Therefore, the caller no longer
      needs to check the return value.
      
      Reported by Andres Freund. Backpatch to all supported versions, even though
      this doesn't have any user-visible effect, to make backporting future
      patches in this area easier.
      
      Discussion: https://www.postgresql.org/message-id/20170405010525.rt5azbya5fkbhvrx@alap3.anarazel.de
      fd019835
    • Andres Freund's avatar
      Code review for recent slot.c changes. · 5c21ad07
      Andres Freund authored
      5c21ad07
    • Tom Lane's avatar
      Fix integer-overflow problems in interval comparison. · df1a699e
      Tom Lane authored
      When using integer timestamps, the interval-comparison functions tried
      to compute the overall magnitude of an interval as an int64 number of
      microseconds.  As reported by Frazer McLean, this overflows for intervals
      exceeding about 296000 years, which is bad since we nominally allow
      intervals many times larger than that.  That results in wrong comparison
      results, and possibly in corrupted btree indexes for columns containing
      such large interval values.
      
      To fix, compute the magnitude as int128 instead.  Although some compilers
      have native support for int128 calculations, many don't, so create our
      own support functions that can do 128-bit addition and multiplication
      if the compiler support isn't there.  These support functions are designed
      with an eye to allowing the int128 code paths in numeric.c to be rewritten
      for use on all platforms, although this patch doesn't do that, or even
      provide all the int128 primitives that will be needed for it.
      
      Back-patch as far as 9.4.  Earlier releases did not guard against overflow
      of interval values at all (commit 146604ec fixed that), so it seems not
      very exciting to worry about overly-large intervals for them.
      
      Before 9.6, we did not assume that unreferenced "static inline" functions
      would not draw compiler warnings, so omit functions not directly referenced
      by timestamp.c, the only present consumer of int128.h.  (We could have
      omitted these functions in HEAD too, but since they were written and
      debugged on the way to the present patch, and they look likely to be needed
      by numeric.c, let's keep them in HEAD.)  I did not bother to try to prevent
      such warnings in a --disable-integer-datetimes build, though.
      
      Before 9.5, configure will never define HAVE_INT128, so the part of
      int128.h that exploits a native int128 implementation is dead code in the
      9.4 branch.  I didn't bother to remove it, thinking that keeping the file
      looking similar in different branches is more useful.
      
      In HEAD only, add a simple test harness for int128.h in src/tools/.
      
      In back branches, this does not change the float-timestamps code path.
      That's not subject to the same kind of overflow risk, since it computes
      the interval magnitude as float8.  (No doubt, when this code was originally
      written, overflow was disregarded for exactly that reason.)  There is a
      precision hazard instead :-(, but we'll avert our eyes from that question,
      since no complaints have been reported and that code's deprecated anyway.
      
      Kyotaro Horiguchi and Tom Lane
      
      Discussion: https://postgr.es/m/1490104629.422698.918452336.26FA96B7@webmail.messagingengine.com
      df1a699e
  2. 05 Apr, 2017 12 commits
  3. 04 Apr, 2017 5 commits
    • Kevin Grittner's avatar
      Follow-on cleanup for the transition table patch. · 5ebeb579
      Kevin Grittner authored
      Commit 59702716 added transition table support to PL/pgsql so that
      SQL queries in trigger functions could access those transient
      tables.  In order to provide the same level of support for PL/perl,
      PL/python and PL/tcl, refactor the relevant code into a new
      function SPI_register_trigger_data.  Call the new function in the
      trigger handler of all four PLs, and document it as a public SPI
      function so that authors of out-of-tree PLs can do the same.
      
      Also get rid of a second QueryEnvironment object that was
      maintained by PL/pgsql.  That was previously used to deal with
      cursors, but the same approach wasn't appropriate for PLs that are
      less tangled up with core code.  Instead, have SPI_cursor_open
      install the connection's current QueryEnvironment, as already
      happens for SPI_execute_plan.
      
      While in the docs, remove the note that transition tables were only
      supported in C and PL/pgSQL triggers, and correct some ommissions.
      
      Thomas Munro with some work by Kevin Grittner (mostly docs)
      5ebeb579
    • Simon Riggs's avatar
      Make min_wal_size/max_wal_size use MB internally · 9a321502
      Simon Riggs authored
      Previously they were defined using multiples of XLogSegSize.
      Remove GUC_UNIT_XSEGS. Introduce GUC_UNIT_MB
      
      Extracted from patch series on XLogSegSize infrastructure.
      
      Beena Emerson
      9a321502
    • Simon Riggs's avatar
      Fix uninitialized variables in twophase.c · cd740c0d
      Simon Riggs authored
      cd740c0d
    • Andres Freund's avatar
      Force synchronous commit in new-ish test_decoding test. · bae9b801
      Andres Freund authored
      This was missed in a924c327 ff.
      bae9b801
    • Andres Freund's avatar
      Fix two valgrind issues in slab allocator. · 490e9a98
      Andres Freund authored
      During allocation VALGRIND_MAKE_MEM_DEFINED was called with a pointer
      as size. That kind of works, but makes valgrind exceedingly slow for
      workloads involving the slab allocator.
      
      Secondly there was an access to memory marked as unreachable within
      SlabCheck(). Fix that too.
      
      Author: Tomas Vondra
      Discussion: https://postgr.es/m/a6543b6d-6015-99b1-63ef-3ed55a76a730@2ndquadrant.com
      490e9a98