1. 30 Apr, 2018 2 commits
  2. 09 Apr, 2018 1 commit
    • Tom Lane's avatar
      Fix partial-build problems introduced by having more generated headers. · 3b8f6e75
      Tom Lane authored
      Commit 372728b0 created some problems for usages like building a
      subdirectory without having first done "make all" at the top level,
      or for proceeding directly to "make install" without "make all".
      The only reasonably clean way to fix this seems to be to force the
      submake-generated-headers rule to fire in *any* "make all" or "make
      install" command anywhere in the tree.  To avoid lots of redundant work,
      as well as parallel make jobs possibly clobbering each others' output, we
      still need to be sure that the rule fires only once in a recursive build.
      For that, adopt the same MAKELEVEL hack previously used for "temp-install".
      But try to document it a bit better.
      
      The submake-errcodes mechanism previously used in src/port/ and src/common/
      is subsumed by this, so we can get rid of those special cases.  It was
      inadequate for src/common/ anyway after the aforesaid commit, and it always
      risked parallel attempts to build errcodes.h.
      
      Discussion: https://postgr.es/m/E1f5FAB-0006LU-MB@gemulon.postgresql.org
      3b8f6e75
  3. 08 Apr, 2018 1 commit
    • 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
  4. 06 Apr, 2018 1 commit
    • Alvaro Herrera's avatar
      Faster partition pruning · 9fdb675f
      Alvaro Herrera authored
      Add a new module backend/partitioning/partprune.c, implementing a more
      sophisticated algorithm for partition pruning.  The new module uses each
      partition's "boundinfo" for pruning instead of constraint exclusion,
      based on an idea proposed by Robert Haas of a "pruning program": a list
      of steps generated from the query quals which are run iteratively to
      obtain a list of partitions that must be scanned in order to satisfy
      those quals.
      
      At present, this targets planner-time partition pruning, but there exist
      further patches to apply partition pruning at execution time as well.
      
      This commit also moves some definitions from include/catalog/partition.h
      to a new file include/partitioning/partbounds.h, in an attempt to
      rationalize partitioning related code.
      
      Authors: Amit Langote, David Rowley, Dilip Kumar
      Reviewers: Robert Haas, Kyotaro Horiguchi, Ashutosh Bapat, Jesper Pedersen.
      Discussion: https://postgr.es/m/098b9c71-1915-1a2a-8d52-1a7a50ce79e8@lab.ntt.co.jp
      9fdb675f
  5. 05 Apr, 2018 1 commit
  6. 28 Mar, 2018 1 commit
    • Andres Freund's avatar
      Add inlining support to LLVM JIT provider. · 9370462e
      Andres Freund authored
      This provides infrastructure to allow JITed code to inline code
      implemented in C. This e.g. can be postgres internal functions or
      extension code.
      
      This already speeds up long running queries, by allowing the LLVM
      optimizer to optimize across function boundaries. The optimization
      potential currently doesn't reach its full potential because LLVM
      cannot optimize the FunctionCallInfoData argument fully away, because
      it's allocated on the heap rather than the stack. Fixing that is
      beyond what's realistic for v11.
      
      To be able to do that, use CLANG to convert C code to LLVM bitcode,
      and have LLVM build a summary for it. That bitcode can then be used to
      to inline functions at runtime. For that the bitcode needs to be
      installed. Postgres bitcode goes into $pkglibdir/bitcode/postgres,
      extensions go into equivalent directories.  PGXS has been modified so
      that happens automatically if postgres has been compiled with LLVM
      support.
      
      Currently this isn't the fastest inline implementation, modules are
      reloaded from disk during inlining. That's to work around an apparent
      LLVM bug, triggering an apparently spurious error in LLVM assertion
      enabled builds.  Once that is resolved we can remove the superfluous
      read from disk.
      
      Docs will follow in a later commit containing docs for the whole JIT
      feature.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
      9370462e
  7. 23 Mar, 2018 1 commit
    • Tom Lane's avatar
      Fix make rules that generate multiple output files. · 4b538727
      Tom Lane authored
      For years, our makefiles have correctly observed that "there is no correct
      way to write a rule that generates two files".  However, what we did is to
      provide empty rules that "generate" the secondary output files from the
      primary one, and that's not right either.  Depending on the details of
      the creating process, the primary file might end up timestamped later than
      one or more secondary files, causing subsequent make runs to consider the
      secondary file(s) out of date.  That's harmless in a plain build, since
      make will just re-execute the empty rule and nothing happens.  But it's
      fatal in a VPATH build, since make will expect the secondary file to be
      rebuilt in the build directory.  This would manifest as "file not found"
      failures during VPATH builds from tarballs, if we were ever unlucky enough
      to ship a tarball with apparently out-of-date secondary files.  (It's not
      clear whether that has ever actually happened, but it definitely could.)
      
      To ensure that secondary output files have timestamps >= their primary's,
      change our makefile convention to be that we provide a "touch $@" action
      not an empty rule.  Also, make sure that this rule actually gets invoked
      during a distprep run, else the hazard remains.
      
      It's been like this a long time, so back-patch to all supported branches.
      
      In HEAD, I skipped the changes in src/backend/catalog/Makefile, because
      those rules are due to get replaced soon in the bootstrap data format
      patch, and there seems no need to create a merge issue for that patch.
      If for some reason we fail to land that patch in v11, we'll need to
      back-fill the changes in that one makefile from v10.
      
      Discussion: https://postgr.es/m/18556.1521668179@sss.pgh.pa.us
      4b538727
  8. 22 Mar, 2018 1 commit
    • Andres Freund's avatar
      Basic JIT provider and error handling infrastructure. · 432bb9e0
      Andres Freund authored
      This commit introduces:
      
      1) JIT provider abstraction, which allows JIT functionality to be
         implemented in separate shared libraries. That's desirable because
         it allows to install JIT support as a separate package, and because
         it allows experimentation with different forms of JITing.
      2) JITContexts which can be, using functions introduced in follow up
         commits, used to emit JITed functions, and have them be cleaned up
         on error.
      3) The outline of a LLVM JIT provider, which will be fleshed out in
         subsequent commits.
      
      Documentation for GUCs added, and for JIT in general, will be added in
      later commits.
      
      Author: Andres Freund, with architectural input from Jeff Davis
      Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
      432bb9e0
  9. 03 Jan, 2018 1 commit
  10. 21 Aug, 2017 1 commit
    • Noah Misch's avatar
      Inject $(ICU_LIBS) regardless of platform. · 66ed3829
      Noah Misch authored
      It appeared in a conditional that excludes AIX, Cygwin and MinGW.  Give
      ICU support a chance to work on those platforms.  Back-patch to v10,
      where ICU support was introduced.
      66ed3829
  11. 24 Mar, 2017 1 commit
    • Alvaro Herrera's avatar
      Implement multivariate n-distinct coefficients · 7b504eb2
      Alvaro Herrera authored
      Add support for explicitly declared statistic objects (CREATE
      STATISTICS), allowing collection of statistics on more complex
      combinations that individual table columns.  Companion commands DROP
      STATISTICS and ALTER STATISTICS ... OWNER TO / SET SCHEMA / RENAME are
      added too.  All this DDL has been designed so that more statistic types
      can be added later on, such as multivariate most-common-values and
      multivariate histograms between columns of a single table, leaving room
      for permitting columns on multiple tables, too, as well as expressions.
      
      This commit only adds support for collection of n-distinct coefficient
      on user-specified sets of columns in a single table.  This is useful to
      estimate number of distinct groups in GROUP BY and DISTINCT clauses;
      estimation errors there can cause over-allocation of memory in hashed
      aggregates, for instance, so it's a worthwhile problem to solve.  A new
      special pseudo-type pg_ndistinct is used.
      
      (num-distinct estimation was deemed sufficiently useful by itself that
      this is worthwhile even if no further statistic types are added
      immediately; so much so that another version of essentially the same
      functionality was submitted by Kyotaro Horiguchi:
      https://postgr.es/m/20150828.173334.114731693.horiguchi.kyotaro@lab.ntt.co.jp
      though this commit does not use that code.)
      
      Author: Tomas Vondra.  Some code rework by Álvaro.
      Reviewed-by: Dean Rasheed, David Rowley, Kyotaro Horiguchi, Jeff Janes,
          Ideriha Takeshi
      Discussion: https://postgr.es/m/543AFA15.4080608@fuzzy.cz
          https://postgr.es/m/20170320190220.ixlaueanxegqd5gr@alvherre.pgsql
      7b504eb2
  12. 23 Mar, 2017 1 commit
    • Peter Eisentraut's avatar
      ICU support · eccfef81
      Peter Eisentraut authored
      Add a column collprovider to pg_collation that determines which library
      provides the collation data.  The existing choices are default and libc,
      and this adds an icu choice, which uses the ICU4C library.
      
      The pg_locale_t type is changed to a union that contains the
      provider-specific locale handles.  Users of locale information are
      changed to look into that struct for the appropriate handle to use.
      
      Also add a collversion column that records the version of the collation
      when it is created, and check at run time whether it is still the same.
      This detects potentially incompatible library upgrades that can corrupt
      indexes and other structures.  This is currently only supported by
      ICU-provided collations.
      
      initdb initializes the default collation set as before from the `locale
      -a` output but also adds all available ICU locales with a "-x-icu"
      appended.
      
      Currently, ICU-provided collations can only be explicitly named
      collations.  The global database locales are still always libc-provided.
      
      ICU support is enabled by configure --with-icu.
      Reviewed-by: default avatarThomas Munro <thomas.munro@enterprisedb.com>
      Reviewed-by: default avatarAndreas Karlsson <andreas@proxel.se>
      eccfef81
  13. 23 Jan, 2017 1 commit
  14. 17 Jan, 2017 1 commit
    • Peter Eisentraut's avatar
      Generate fmgr prototypes automatically · 352a24a1
      Peter Eisentraut authored
      Gen_fmgrtab.pl creates a new file fmgrprotos.h, which contains
      prototypes for all functions registered in pg_proc.h.  This avoids
      having to manually maintain these prototypes across a random variety of
      header files.  It also automatically enforces a correct function
      signature, and since there are warnings about missing prototypes, it
      will detect functions that are defined but not registered in
      pg_proc.h (or otherwise used).
      Reviewed-by: default avatarPavel Stehule <pavel.stehule@gmail.com>
      352a24a1
  15. 03 Jan, 2017 1 commit
  16. 29 Nov, 2016 1 commit
  17. 25 Sep, 2016 1 commit
    • Tom Lane's avatar
      Refer to OS X as "macOS", except for the port name which is still "darwin". · da6c4f6c
      Tom Lane authored
      We weren't terribly consistent about whether to call Apple's OS "OS X"
      or "Mac OS X", and the former is probably confusing to people who aren't
      Apple users.  Now that Apple has rebranded it "macOS", follow their lead
      to establish a consistent naming pattern.  Also, avoid the use of the
      ancient project name "Darwin", except as the port code name which does not
      seem desirable to change.  (In short, this patch touches documentation and
      comments, but no actual code.)
      
      I didn't touch contrib/start-scripts/osx/, either.  I suspect those are
      obsolete and due for a rewrite, anyway.
      
      I dithered about whether to apply this edit to old release notes, but
      those were responsible for quite a lot of the inconsistencies, so I ended
      up changing them too.  Anyway, Apple's being ahistorical about this,
      so why shouldn't we be?
      da6c4f6c
  18. 01 Jul, 2016 1 commit
    • Tom Lane's avatar
      Provide and use a makefile target to build all generated headers. · 548af97f
      Tom Lane authored
      As of 9.6, pg_regress doesn't build unless storage/lwlocknames.h has been
      created; but there was nothing forcing that to happen if you just went into
      src/test/regress/ and built there.  We previously had a similar complaint
      about plpython.
      
      To fix in a way that won't break next time we invent a generated header,
      make src/backend/Makefile expose a phony target for updating all the
      include files it builds, and invoke that before building pg_regress or
      plpython.  In principle, maybe we ought to invoke that everywhere; but
      it would add a lot of usually-useless make cycles, so let's just do it
      in the places where people have complained.
      
      I made a couple of cosmetic adjustments in src/backend/Makefile as well,
      to deal with the generated headers in consistent orders.
      
      Michael Paquier and Tom Lane
      
      Report: <31398.1467036827@sss.pgh.pa.us>
      Report: <20150916200959.GB32090@msg.df7cb.de>
      548af97f
  19. 06 Apr, 2016 1 commit
    • Fujii Masao's avatar
      Support multiple synchronous standby servers. · 989be081
      Fujii Masao authored
      Previously synchronous replication offered only the ability to confirm
      that all changes made by a transaction had been transferred to at most
      one synchronous standby server.
      
      This commit extends synchronous replication so that it supports multiple
      synchronous standby servers. It enables users to consider one or more
      standby servers as synchronous, and increase the level of transaction
      durability by ensuring that transaction commits wait for replies from
      all of those synchronous standbys.
      
      Multiple synchronous standby servers are configured in
      synchronous_standby_names which is extended to support new syntax of
      'num_sync ( standby_name [ , ... ] )', where num_sync specifies
      the number of synchronous standbys that transaction commits need to
      wait for replies from and standby_name is the name of a standby
      server.
      
      The syntax of 'standby_name [ , ... ]' which was used in 9.5 or before
      is also still supported. It's the same as new syntax with num_sync=1.
      
      This commit doesn't include "quorum commit" feature which was discussed
      in pgsql-hackers. Synchronous standbys are chosen based on their priorities.
      synchronous_standby_names determines the priority of each standby for
      being chosen as a synchronous standby. The standbys whose names appear
      earlier in the list are given higher priority and will be considered as
      synchronous. Other standby servers appearing later in this list
      represent potential synchronous standbys.
      
      The regression test for multiple synchronous standbys is not included
      in this commit. It should come later.
      
      Authors: Sawada Masahiko, Beena Emerson, Michael Paquier, Fujii Masao
      Reviewed-By: Kyotaro Horiguchi, Amit Kapila, Robert Haas, Simon Riggs,
      Amit Langote, Thomas Munro, Sameer Thakur, Suraj Kharage, Abhijit Menon-Sen,
      Rajeev Rastogi
      
      Many thanks to the various individuals who were involved in
      discussing and developing this feature.
      989be081
  20. 21 Mar, 2016 1 commit
    • Andres Freund's avatar
      Combine win32 and unix latch implementations. · 72e2d21c
      Andres Freund authored
      Previously latches for windows and unix had been implemented in
      different files. A later patch introduce an expanded wait
      infrastructure, keeping the implementation separate would introduce too
      much duplication.
      
      This basically just moves the functions, without too much change. The
      reason to keep this separate is that it allows blame to continue working
      a little less badly; and to make review a tiny bit easier.
      
      Discussion: 20160114143931.GG10941@awork2.anarazel.de
      72e2d21c
  21. 03 Feb, 2016 1 commit
  22. 02 Jan, 2016 1 commit
  23. 15 Oct, 2015 1 commit
  24. 13 Oct, 2015 1 commit
    • Robert Haas's avatar
      Have dtrace depend on object files directly, not objfiles.txt · 73537828
      Robert Haas authored
      Per Mark Johnston, this resolves a build error on FreeBSD related
      to the fact that dtrace is modifying the generated object files
      under the hood.  Consequently, without this, dtrace gets reinvoked
      at install time because the object files have been updated.  This
      is a pretty hacky fix, but it shouldn't hurt anything, and it's
      not clear that it's worth expending any more effort for a feature
      that not too many people are using.
      
      Patch by Mark Johnston.  This is arguably back-patchable as a bug
      fix to the build system, but I'm not certain enough of the
      consequences to try that.  Let's see what the buildfarm (and
      our packagers) think of this change on master first.
      73537828
  25. 11 Sep, 2015 2 commits
  26. 16 Jul, 2015 1 commit
    • Noah Misch's avatar
      AIX: Link the postgres executable with -Wl,-brtllib. · bcd7c412
      Noah Misch authored
      This allows PostgreSQL modules and their dependencies to have undefined
      symbols, resolved at runtime.  Perl module shared objects rely on that
      in Perl 5.8.0 and later.  This fixes the crash when PL/PerlU loads such
      modules, as the hstore_plperl test suite does.  Module authors can link
      using -Wl,-G to permit undefined symbols; by default, linking will fail
      as it has.  Back-patch to 9.0 (all supported versions).
      bcd7c412
  27. 06 Jan, 2015 1 commit
  28. 11 Feb, 2014 2 commits
    • Tom Lane's avatar
      Get rid of use of dlltool in Mingw builds. · 846e91e0
      Tom Lane authored
      We are almost completely out of the dlltool game, if this works.
      
      Hiroshi Inoue
      846e91e0
    • Tom Lane's avatar
      Cygwin build fixes. · cba6ffae
      Tom Lane authored
      Get rid of use of dlltool for linking the main postgres executable.
      dlltool is obsolete and we'd prefer to stop depending on it.
      
      Also, include $(LDAP_LIBS_FE) in $(libpq_pgport).  (It's not clear that
      this is really needed, or why it's not a linker bug if it is needed.
      But reports are that it's needed on current Cygwin.)
      
      We might want to back-patch this if it works, but first let's see
      what the buildfarm thinks.
      
      Marco Atzeri
      cba6ffae
  29. 07 Jan, 2014 1 commit
  30. 22 Feb, 2013 1 commit
    • Alvaro Herrera's avatar
      Move relpath() to libpgcommon · a7301839
      Alvaro Herrera authored
      This enables non-backend code, such as pg_xlogdump, to use it easily.
      The previous location, in src/backend/catalog/catalog.c, made that
      essentially impossible because that file depends on many backend-only
      facilities; so this needs to live separately.
      a7301839
  31. 01 Jan, 2013 1 commit
  32. 10 Oct, 2012 1 commit
    • Tom Lane's avatar
      Fix PGXS support for building loadable modules on AIX. · 3f88fa97
      Tom Lane authored
      Building a shlib on AIX requires use of the mkldexport.sh script, but we
      failed to install that, preventing its use from non-source-tree contexts.
      Also, Makefile.aix had the wrong idea about where to find the installed
      copy of the postgres.imp symbol file used by AIX.
      
      Per report from John Pierce.  Patch all the way back, since this has been
      broken since the beginning of PGXS.
      3f88fa97
  33. 09 Oct, 2012 1 commit
  34. 07 Apr, 2012 1 commit
  35. 15 Feb, 2012 1 commit
    • Robert Haas's avatar
      Speed up in-memory tuplesorting. · 337b6f5e
      Robert Haas authored
      Per recent work by Peter Geoghegan, it's significantly faster to
      tuplesort on a single sortkey if ApplySortComparator is inlined into
      quicksort rather reached via a function pointer.  It's also faster
      in general to have a version of quicksort which is specialized for
      sorting SortTuple objects rather than objects of arbitrary size and
      type.  This requires a couple of additional copies of the quicksort
      logic, which in this patch are generate using a Perl script.  There
      might be some benefit in adding further specializations here too,
      but thus far it's not clear that those gains are worth their weight
      in code footprint.
      337b6f5e
  36. 01 Jan, 2012 1 commit
  37. 22 Jun, 2011 1 commit