1. 11 Apr, 2018 2 commits
  2. 10 Apr, 2018 7 commits
    • Andrew Dunstan's avatar
      minor comment fixes in nbtinsert.c · 8716b264
      Andrew Dunstan authored
      8716b264
    • Tom Lane's avatar
      Fix incorrect close() call in dsm_impl_mmap(). · 231bcd08
      Tom Lane authored
      One improbable error-exit path in this function used close() where
      it should have used CloseTransientFile().  This is unlikely to be
      hit in the field, and I think the consequences wouldn't be awful
      (just an elog(LOG) bleat later).  But a bug is a bug, so back-patch
      to 9.4 where this code came in.
      
      Pan Bian
      
      Discussion: https://postgr.es/m/152056616579.4966.583293218357089052@wrigleys.postgresql.org
      231bcd08
    • Andrew Dunstan's avatar
      Adjustments to the btree fastpath optimization. · 074251db
      Andrew Dunstan authored
      This optimization was introduced in commit 2b272734. The changes include
      some additional comments and documentation, and also these more
      substantive changes:
      . ensure the optimization is only applied on the leaf node of a tree
      whose root is on level 2 or more. It's of little value on small trees.
      . Delay calling RelationSetTargetBlock() until after the critical
      section of _bt_insertonpg
      . ensure the optimization is also applied to unlogged tables.
      
      Pavan Deolasee and Peter Geoghegan with some very light editing from me.
      
      Discussion: https://postgr.es/m/CABOikdO8jhRarNC60nZLktZYhxt+TK8z_V97+Ny499YQdyAfug@mail.gmail.com
      074251db
    • Tom Lane's avatar
      Put back parallel-safety guards in plpython and src/test/regress/. · 31f1f0bb
      Tom Lane authored
      I'd hoped that commit 3b8f6e75 was sufficient to ensure parallel safety
      even when a build started in a subdirectory requires rebuilding of
      generated headers.  This isn't so, because making submake-generated-headers
      a prerequisite of "all" isn't enough to ensure it's completed before
      starting on "all"'s other prerequisites.  The explicit dependencies we put
      on the recursive make targets ensure safe ordering before we recurse into
      child directories, but they don't protect targets to be made in the current
      directory.  Hence, put back some ordering dependencies in directories that
      we've traditionally expected to be starting points for "standalone" builds,
      to wit src/pl/plpython and src/test/regress.  (The former needs this in
      order to minimize the work involved in building for both python 2 and
      python 3; the latter to support packagings that make the regression tests
      available for out-of-build-tree execution.)  Adjust some other dependencies
      so that these two cases work correctly even at high -j settings.
      
      I'm not terribly happy with this partial solution, but I don't see a
      way to do better without massive makefile restructuring, which we surely
      aren't doing at this point in the development cycle.  In any case, it's
      little if any worse than what we had in prior releases.
      
      Discussion: https://postgr.es/m/1523353963.8169.26.camel@gunduz.org
      31f1f0bb
    • Alvaro Herrera's avatar
      Fix IndexOnlyScan counter for heap fetches in parallel mode · 15a8f8ca
      Alvaro Herrera authored
      The HeapFetches counter was using a simple value in IndexOnlyScanState,
      which fails to propagate values from parallel workers; so the counts are
      wrong when IndexOnlyScan runs in parallel.  Move it to Instrumentation,
      like all the other counters.
      
      While at it, change INSERT ON CONFLICT conflicting tuple counter to use
      the new ntuples2 instead of nfiltered2, which is a blatant misuse.
      
      Discussion: https://postgr.es/m/20180409215851.idwc75ct2bzi6tea@alvherre.pgsql
      15a8f8ca
    • Tom Lane's avatar
      Fix pgxs.mk to not try to build generated headers in external builds. · 1a40485a
      Tom Lane authored
      Per Julien Rouhaud and the buildfarm.  This is not quite Julien's
      patch: there's no need to lobotomize this build rule when building
      contrib modules in-tree, so set NO_GENERATED_HEADERS only if PGXS.
      
      In passing, also set NO_TEMP_INSTALL in external builds.  This doesn't
      seem to be fixing any live bug, because "make check" in an external
      build just produces the expected error message without first trying to
      make a temp install ... but it's far from obvious why it doesn't, so
      this change seems like good future-proofing.
      
      Julien Rouhaud and Tom Lane
      
      Discussion: https://postgr.es/m/CAOBaU_YH=g68opbbMk8is3jNwhoXGa8ckRSre1nx0Obe1C7i-Q@mail.gmail.com
      1a40485a
    • Heikki Linnakangas's avatar
      Fix comment on B-tree insertion fastpath condition. · 29d7ebf5
      Heikki Linnakangas authored
      The comment earlier in the function correctly states "and the insertion
      key is strictly greater than the first key in this page". That is what
      we check here, not "greater than or equal".
      29d7ebf5
  3. 09 Apr, 2018 15 commits
  4. 08 Apr, 2018 13 commits
    • Tom Lane's avatar
      Fix additional breakage in covering-index patch. · b3b7f789
      Tom Lane authored
      CheckIndexCompatible() misused ComputeIndexAttrs() by not bothering
      to fill ii_NumIndexAttrs and ii_NumIndexKeyAttrs in the passed
      IndexInfo.  Omission of ii_NumIndexAttrs was previously unimportant,
      but now this matters because ComputeIndexAttrs depends on
      ii_NumIndexKeyAttrs to decide how many columns it needs to report on.
      
      (BTW, the fact that this oversight wasn't detected earlier implies
      that we have no regression test verifying whether CheckIndexCompatible
      ever succeeds.  Bad dog.  Not the job of this patch to fix it, though.)
      
      Also, change the API of ComputeIndexAttrs so that it fills the opclass
      output array for all column positions, as it does for the options output
      array; positions for non-key index columns are filled with zeroes.
      This isn't directly fixing any bug, but it seems like a good idea.
      
      Per valgrind failure reports from buildfarm.
      
      Alexander Korotkov, tweaked a bit by me
      
      Discussion: https://postgr.es/m/CAPpHfduWrysrT-qAhn+3Ea5+Mg6Vhc-oA6o2Z-hRCPRdvf3tiw@mail.gmail.com
      b3b7f789
    • Tom Lane's avatar
      Doc: clarify explanation of pg_dump usage. · 893e9e65
      Tom Lane authored
      This section confusingly used both "infile" and "outfile" to refer
      to the same file, i.e. the textual output of pg_dump.  Use "dumpfile"
      for both cases, per suggestion from Jonathan Katz.
      
      Discussion: https://postgr.es/m/152311295239.31235.6487236091906987117@wrigleys.postgresql.org
      893e9e65
    • Tom Lane's avatar
      Cosmetic cleanups in initial catalog data. · 4f85f664
      Tom Lane authored
      Write ',' and ';' for typdelim values instead of the obscurantist
      ASCII octal equivalents.  Not sure why anybody ever thought the
      latter were better; maybe it had something to do with lack of
      a better quoting convention, twenty-plus years ago?
      
      Reassign a couple of high-numbered OIDs that were left in during
      yesterday's mad rush to commit stuff of uncertain internal
      temperature.
      
      The latter requires a catversion bump, though the former wouldn't
      since the end-result catalog data is unchanged.
      4f85f664
    • Tom Lane's avatar
      Reduce worst-case shell command line length during "make install". · cca563f3
      Tom Lane authored
      Addition of the catalog/pg_foo_d.h headers seems to have pushed us over
      the brink of the maximum command line length for some older platforms
      during "make install" for our header files.  The main culprit here is
      repetition of the target directory path, which could be long.
      Rearrange so that we don't repeat that once per file, but only once
      per subdirectory.
      
      Per buildfarm.
      
      Discussion: https://postgr.es/m/E1f5Dwm-0004n5-7O@gemulon.postgresql.org
      cca563f3
    • Tom Lane's avatar
      Merge catalog/pg_foo_fn.h headers back into pg_foo.h headers. · cefa3871
      Tom Lane authored
      Traditionally, include/catalog/pg_foo.h contains extern declarations
      for functions in backend/catalog/pg_foo.c, in addition to its function
      as the authoritative definition of the pg_foo catalog's rowtype.
      In some cases, we'd been forced to split out those extern declarations
      into separate pg_foo_fn.h headers so that the catalog definitions
      could be #include'd by frontend code.  That problem is gone as of
      commit 9c0a0de4, so let's undo the splits to make things less
      confusing.
      
      Discussion: https://postgr.es/m/23690.1523031777@sss.pgh.pa.us
      cefa3871
    • Tom Lane's avatar
      Switch client-side code to include catalog/pg_foo_d.h not pg_foo.h. · 9c0a0de4
      Tom Lane authored
      Everything of use to frontend code should now appear in the _d.h files,
      and making this change frees us from needing to worry about whether the
      catalog header files proper are frontend-safe.
      
      Remove src/interfaces/ecpg/ecpglib/pg_type.h entirely, as the previous
      commit reduced it to a confusingly-named wrapper around pg_type_d.h.
      
      In passing, make test_rls_hooks.c follow project convention of including
      our own files with #include "" not <>.
      
      Discussion: https://postgr.es/m/23690.1523031777@sss.pgh.pa.us
      9c0a0de4
    • Tom Lane's avatar
      Replace our traditional initial-catalog-data format with a better design. · 372728b0
      Tom Lane authored
      Historically, the initial catalog data to be installed during bootstrap
      has been written in DATA() lines in the catalog header files.  This had
      lots of disadvantages: the format was badly underdocumented, it was
      very difficult to edit the data in any mechanized way, and due to the
      lack of any abstraction the data was verbose, hard to read/understand,
      and easy to get wrong.
      
      Hence, move this data into separate ".dat" files and represent it in a way
      that can easily be read and rewritten by Perl scripts.  The new format is
      essentially "key => value" for each column; while it's a bit repetitive,
      explicit labeling of each value makes the data far more readable and less
      error-prone.  Provide a way to abbreviate entries by omitting field values
      that match a specified default value for their column.  This allows removal
      of a large amount of repetitive boilerplate and also lowers the barrier to
      adding new columns.
      
      Also teach genbki.pl how to translate symbolic OID references into
      numeric OIDs for more cases than just "regproc"-like pg_proc references.
      It can now do that for regprocedure-like references (thus solving the
      problem that regproc is ambiguous for overloaded functions), operators,
      types, opfamilies, opclasses, and access methods.  Use this to turn
      nearly all OID cross-references in the initial data into symbolic form.
      This represents a very large step forward in readability and error
      resistance of the initial catalog data.  It should also reduce the
      difficulty of renumbering OID assignments in uncommitted patches.
      
      Also, solve the longstanding problem that frontend code that would like to
      use OID macros and other information from the catalog headers often had
      difficulty with backend-only code in the headers.  To do this, arrange for
      all generated macros, plus such other declarations as we deem fit, to be
      placed in "derived" header files that are safe for frontend inclusion.
      (Once clients migrate to using these pg_*_d.h headers, it will be possible
      to get rid of the pg_*_fn.h headers, which only exist to quarantine code
      away from clients.  That is left for follow-on patches, however.)
      
      The now-automatically-generated macros include the Anum_xxx and Natts_xxx
      constants that we used to have to update by hand when adding or removing
      catalog columns.
      
      Replace the former manual method of generating OID macros for pg_type
      entries with an automatic method, ensuring that all built-in types have
      OID macros.  (But note that this patch does not change the way that
      OID macros for pg_proc entries are built and used.  It's not clear that
      making that match the other catalogs would be worth extra code churn.)
      
      Add SGML documentation explaining what the new data format is and how to
      work with it.
      
      Despite being a very large change in the catalog headers, there is no
      catversion bump here, because postgres.bki and related output files
      haven't changed at all.
      
      John Naylor, based on ideas from various people; review and minor
      additional coding by me; previous review by Alvaro Herrera
      
      Discussion: https://postgr.es/m/CAJVSVGWO48JbbwXkJz_yBFyGYW-M9YWxnPdxJBUosDC9ou_F0Q@mail.gmail.com
      372728b0
    • Teodor Sigaev's avatar
      match_clause_to_index should check only key columns · 02f3e558
      Teodor Sigaev authored
      Alexander Korotkov per gripe from Tom Lane noticed on valgrind-enabled
      buildfarm members
      02f3e558
    • Teodor Sigaev's avatar
      Remove unused variable in non-assert-enabled build · 34602b0a
      Teodor Sigaev authored
      Use field of structure in Assert directly
      
      Jeff Janes
      34602b0a
    • Tom Lane's avatar
      Add missing "static" markers. · 2fa55f26
      Tom Lane authored
      Evidently forgotten in commit 11523e86.  Per buildfarm member pademelon.
      2fa55f26
    • Andrew Gierth's avatar
      Attempt to stabilize partition_prune test output. · b47a86f5
      Andrew Gierth authored
      Disable index-only scan for tests that might report variable results
      for "Heap Fetches" statistic due to concurrent transactions affecting
      whether all-visible flags can be set.
      
      Author: David Rowley
      Discussion: https://postgr.es/m/CAKJS1f_yjtHDJnDzx1uuR_3D7beDVAkNQfWJhRLA1gvPCzkAhg@mail.gmail.com
      b47a86f5
    • Andrew Gierth's avatar
      Support index INCLUDE in the AM properties interface. · 49b0e300
      Andrew Gierth authored
      This rectifies an oversight in commit 8224de4f, by adding a new
      property 'can_include' for pg_indexam_has_property, and adjusting the
      results of pg_index_column_has_property to give more appropriate
      results for INCLUDEd columns.
      49b0e300
    • Andres Freund's avatar
      Remove overzeleous assertions in pg_atomic_flag code. · d234602c
      Andres Freund authored
      The atomics code asserts proper alignment in various places. That's
      mainly because the alignment of 64bit integers is not sufficient for
      atomic operations on all platforms. Some ABIs only have four byte
      alignment, but don't have atomic behavior when crossing page
      boundaries.
      
      The flags code isn't affected by that however, as the type alignment
      always is sufficient for atomic operations. Nevertheless the code
      asserted alignment requirements. Before 8c3debbb it was only broken on
      hppa, after it probably affect further platforms.
      
      Thus remove the assertions for pg_atomic_flag operators.
      
      Per buildfarm animal pademelon.
      
      Discussion: https://postgr.es/m/7223.1523124425@sss.pgh.pa.us
      Backpatch: 9.5-
      d234602c
  5. 07 Apr, 2018 3 commits
    • Stephen Frost's avatar
      Fix EXEC BACKEND + Windows builds for group privs · 2b740224
      Stephen Frost authored
      Under EXEC BACKEND we also need to be going through the group privileges
      setup since we do support that on Unixy systems, so add that to
      SubPostmasterMain().
      
      Under Windows, we need to simply return true from
      GetDataDirectoryCreatePerm(), but that wasn't happening due to a missing
       #else clause.
      
      Per buildfarm.
      2b740224
    • Stephen Frost's avatar
      Allow group access on PGDATA · c37b3d08
      Stephen Frost authored
      Allow the cluster to be optionally init'd with read access for the
      group.
      
      This means a relatively non-privileged user can perform a backup of the
      cluster without requiring write privileges, which enhances security.
      
      The mode of PGDATA is used to determine whether group permissions are
      enabled for directory and file creates.  This method was chosen as it's
      simple and works well for the various utilities that write into PGDATA.
      
      Changing the mode of PGDATA manually will not automatically change the
      mode of all the files contained therein.  If the user would like to
      enable group access on an existing cluster then changing the mode of all
      the existing files will be required.  Note that pg_upgrade will
      automatically change the mode of all migrated files if the new cluster
      is init'd with the -g option.
      
      Tests are included for the backend and all the utilities which operate
      on the PG data directory to ensure that the correct mode is set based on
      the data directory permissions.
      
      Author: David Steele <david@pgmasters.net>
      Reviewed-By: Michael Paquier, with discussion amongst many others.
      Discussion: https://postgr.es/m/ad346fe6-b23e-59f1-ecb7-0e08390ad629%40pgmasters.net
      c37b3d08
    • Stephen Frost's avatar
      Refactor dir/file permissions · da9b580d
      Stephen Frost authored
      Consolidate directory and file create permissions for tools which work
      with the PG data directory by adding a new module (common/file_perm.c)
      that contains variables (pg_file_create_mode, pg_dir_create_mode) and
      constants to initialize them (0600 for files and 0700 for directories).
      
      Convert mkdir() calls in the backend to MakePGDirectory() if the
      original call used default permissions (always the case for regular PG
      directories).
      
      Add tests to make sure permissions in PGDATA are set correctly by the
      tools which modify the PG data directory.
      
      Authors: David Steele <david@pgmasters.net>,
               Adam Brightwell <adam.brightwell@crunchydata.com>
      Reviewed-By: Michael Paquier, with discussion amongst many others.
      Discussion: https://postgr.es/m/ad346fe6-b23e-59f1-ecb7-0e08390ad629%40pgmasters.net
      da9b580d