Skip to content
Snippets Groups Projects
  1. Jun 29, 2017
  2. Jun 28, 2017
    • Tom Lane's avatar
      Change pg_ctl to detect server-ready by watching status in postmaster.pid. · f13ea95f
      Tom Lane authored
      Traditionally, "pg_ctl start -w" has waited for the server to become
      ready to accept connections by attempting a connection once per second.
      That has the major problem that connection issues (for instance, a
      kernel packet filter blocking traffic) can't be reliably told apart
      from server startup issues, and the minor problem that if server startup
      isn't quick, we accumulate "the database system is starting up" spam
      in the server log.  We've hacked around many of the possible connection
      issues, but it resulted in ugly and complicated code in pg_ctl.c.
      
      In commit c61559ec, I changed the probe rate to every tenth of a second.
      That prompted Jeff Janes to complain that the log-spam problem had become
      much worse.  In the ensuing discussion, Andres Freund pointed out that
      we could dispense with connection attempts altogether if the postmaster
      were changed to report its status in postmaster.pid, which "pg_ctl start"
      already relies on being able to read.  This patch implements that, teaching
      postmaster.c to report a status string into the pidfile at the same
      state-change points already identified as being of interest for systemd
      status reporting (cf commit 7d17e683).  pg_ctl no longer needs to link
      with libpq at all; all its functions now depend on reading server files.
      
      In support of this, teach AddToDataDirLockFile() to allow addition of
      postmaster.pid lines in not-necessarily-sequential order.  This is needed
      on Windows where the SHMEM_KEY line will never be written at all.  We still
      have the restriction that we don't want to truncate the pidfile; document
      the reasons for that a bit better.
      
      Also, fix the pg_ctl TAP tests so they'll notice if "start -w" mode
      is broken --- before, they'd just wait out the sixty seconds until
      the loop gives up, and then report success anyway.  (Yes, I found that
      out the hard way.)
      
      While at it, arrange for pg_ctl to not need to #include miscadmin.h;
      as a rather low-level backend header, requiring that to be compilable
      client-side is pretty dubious.  This requires moving the #define's
      associated with the pidfile into a new header file, and moving
      PG_BACKEND_VERSIONSTR someplace else.  For lack of a clearly better
      "someplace else", I put it into port.h, beside the declaration of
      find_other_exec(), since most users of that macro are passing the value to
      find_other_exec().  (initdb still depends on miscadmin.h, but at least
      pg_ctl and pg_upgrade no longer do.)
      
      In passing, fix main.c so that PG_BACKEND_VERSIONSTR actually defines the
      output of "postgres -V", which remarkably it had never done before.
      
      Discussion: https://postgr.es/m/CAMkU=1xJW8e+CTotojOMBd-yzUvD0e_JZu2xHo=MnuZ4__m7Pg@mail.gmail.com
      f13ea95f
  3. Jun 21, 2017
    • Tom Lane's avatar
      Remove entab and associated detritus. · 81f056c7
      Tom Lane authored
      We don't need this anymore, because pg_bsd_indent has been taught to
      follow the same tab-vs-space rules that entab used to enforce.
      
      Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
      Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
      81f056c7
    • Tom Lane's avatar
      Phase 3 of pgindent updates. · 382ceffd
      Tom Lane authored
      Don't move parenthesized lines to the left, even if that means they
      flow past the right margin.
      
      By default, BSD indent lines up statement continuation lines that are
      within parentheses so that they start just to the right of the preceding
      left parenthesis.  However, traditionally, if that resulted in the
      continuation line extending to the right of the desired right margin,
      then indent would push it left just far enough to not overrun the margin,
      if it could do so without making the continuation line start to the left of
      the current statement indent.  That makes for a weird mix of indentations
      unless one has been completely rigid about never violating the 80-column
      limit.
      
      This behavior has been pretty universally panned by Postgres developers.
      Hence, disable it with indent's new -lpl switch, so that parenthesized
      lines are always lined up with the preceding left paren.
      
      This patch is much less interesting than the first round of indent
      changes, but also bulkier, so I thought it best to separate the effects.
      
      Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
      Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
      382ceffd
    • Tom Lane's avatar
      Phase 2 of pgindent updates. · c7b8998e
      Tom Lane authored
      Change pg_bsd_indent to follow upstream rules for placement of comments
      to the right of code, and remove pgindent hack that caused comments
      following #endif to not obey the general rule.
      
      Commit e3860ffa wasn't actually using
      the published version of pg_bsd_indent, but a hacked-up version that
      tried to minimize the amount of movement of comments to the right of
      code.  The situation of interest is where such a comment has to be
      moved to the right of its default placement at column 33 because there's
      code there.  BSD indent has always moved right in units of tab stops
      in such cases --- but in the previous incarnation, indent was working
      in 8-space tab stops, while now it knows we use 4-space tabs.  So the
      net result is that in about half the cases, such comments are placed
      one tab stop left of before.  This is better all around: it leaves
      more room on the line for comment text, and it means that in such
      cases the comment uniformly starts at the next 4-space tab stop after
      the code, rather than sometimes one and sometimes two tabs after.
      
      Also, ensure that comments following #endif are indented the same
      as comments following other preprocessor commands such as #else.
      That inconsistency turns out to have been self-inflicted damage
      from a poorly-thought-through post-indent "fixup" in pgindent.
      
      This patch is much less interesting than the first round of indent
      changes, but also bulkier, so I thought it best to separate the effects.
      
      Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
      Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
      c7b8998e
    • Tom Lane's avatar
      Initial pgindent run with pg_bsd_indent version 2.0. · e3860ffa
      Tom Lane authored
      The new indent version includes numerous fixes thanks to Piotr Stefaniak.
      The main changes visible in this commit are:
      
      * Nicer formatting of function-pointer declarations.
      * No longer unexpectedly removes spaces in expressions using casts,
        sizeof, or offsetof.
      * No longer wants to add a space in "struct structname *varname", as
        well as some similar cases for const- or volatile-qualified pointers.
      * Declarations using PG_USED_FOR_ASSERTS_ONLY are formatted more nicely.
      * Fixes bug where comments following declarations were sometimes placed
        with no space separating them from the code.
      * Fixes some odd decisions for comments following case labels.
      * Fixes some cases where comments following code were indented to less
        than the expected column 33.
      
      On the less good side, it now tends to put more whitespace around typedef
      names that are not listed in typedefs.list.  This might encourage us to
      put more effort into typedef name collection; it's not really a bug in
      indent itself.
      
      There are more changes coming after this round, having to do with comment
      indentation and alignment of lines appearing within parentheses.  I wanted
      to limit the size of the diffs to something that could be reviewed without
      one's eyes completely glazing over, so it seemed better to split up the
      changes as much as practical.
      
      Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
      Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
      e3860ffa
    • Tom Lane's avatar
      Adjust pgindent script to use pg_bsd_indent 2.0. · 8ff6d4ec
      Tom Lane authored
      Update version-checking code and list of switches.  Delete obsolete
      quasi-support for using GNU indent.  Remove a lot of no-longer-needed
      workarounds for bugs of the old version, and improve comments for
      the hacks that remain.  Update run_build() subroutine to fetch the
      pg_bsd_indent code from the newly established git repo for it.
      
      In passing, fix pgindent to not overwrite files that require no changes;
      this makes it a bit more friendly to run on a built tree.
      
      Adjust relevant documentation.
      
      Remove indent.bsd.patch; it's not relevant anymore (and was obsolete
      long ago anyway).  Likewise remove pgcppindent, since we're no longer
      in the business of shipping C++ code.
      
      Piotr Stefaniak is responsible for most of the algorithmic changes
      to the pgindent script; I did the rest.
      
      Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
      Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
      8ff6d4ec
    • Tom Lane's avatar
      Final pgindent run with old pg_bsd_indent (version 1.3). · 9ef2dbef
      Tom Lane authored
      This is just to have a clean basis for comparison with the results of
      the new version (which will indeed end up reverting some of these
      changes...)
      
      Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
      Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
      9ef2dbef
  4. Jun 17, 2017
    • Tom Lane's avatar
      Teach pgindent to skip files generated by bison or flex automatically. · cea258b6
      Tom Lane authored
      If a .c or .h file corresponds to a .y or .l file, skip indenting it.
      There's no point in reindenting derived files, and these files tend to
      confuse pgindent.  (Which probably indicates a bug in BSD indent, but
      I can't get excited about trying to fix it.)
      
      For the same reasons, add src/backend/utils/fmgrtab.c to the set of
      files excluded by src/tools/pgindent/exclude_file_patterns.
      
      The point of doing this is that it makes it safe to run pgindent over
      the tree without doing "make maintainer-clean" first.  While these are
      not the only derived .c/.h files in the tree, they are the only ones
      pgindent fails on.  Removing that prerequisite step results in one less
      way to mess up a pgindent run, and it's necessary if we ever hope to get
      to the ease of running pgindent via "make indent".
      cea258b6
  5. Jun 13, 2017
  6. Jun 12, 2017
  7. Jun 10, 2017
  8. Jun 06, 2017
  9. Jun 05, 2017
  10. May 23, 2017
  11. May 18, 2017
  12. May 17, 2017
  13. May 15, 2017
  14. May 12, 2017
    • Andrew Dunstan's avatar
      Honor PROVE_FLAGS environment setting · 56b6ef89
      Andrew Dunstan authored
      On MSVC builds and on back branches that means removing the hardcoded
      --verbose setting. On master for Unix that means removing the empty
      setting in the global Makefile so that the value can be acquired from
      the environment as well as from the make arguments.
      
      Backpatch to 9.4 where we introduced TAP tests
      56b6ef89
    • Andrew Dunstan's avatar
      Add libxml2 include path for MSVC builds · b757e01f
      Andrew Dunstan authored
      On Unix this path is detected via the use of xml2-config, but that's not
      available on Windows. This means that users building with libxml2 will
      no longer need to move things around from the standard libxml2
      installation for MSVC builds.
      
      Backpatch to all live branches.
      b757e01f
  15. May 09, 2017
  16. May 07, 2017
  17. May 05, 2017
  18. May 02, 2017
  19. May 01, 2017
    • Andrew Dunstan's avatar
      Allow vcregress.pl to run an arbitrary TAP test set · fed6df48
      Andrew Dunstan authored
      Currently only provision for running the bin checks in a single step is
      provided for. Now these tests can be run individually, as well as tests
      in other locations (e.g. src.test/recover).
      
      Also provide for suppressing unnecessary temp installs by setting the
      NO_TEMP_INSTALL environment variable just as the Makefiles do.
      
      Backpatch to 9.4.
      fed6df48
  20. Apr 13, 2017
  21. Apr 12, 2017
  22. Apr 11, 2017
    • Tom Lane's avatar
      Remove bogus redefinition of _MSC_VER. · 587d62d8
      Tom Lane authored
      Commit a4777f35 was a shade too mechanical: we don't want to override
      MSVC's own definition of _MSC_VER, as that breaks tests on its numerical
      value.  Per buildfarm.
      587d62d8
    • Magnus Hagander's avatar
      Remove symbol WIN32_ONLY_COMPILER · a4777f35
      Magnus Hagander authored
      This used to mean "Visual C++ except in those parts where Borland C++
      was supported where it meant one of those". Now that we don't support
      Borland C++ anymore, simplify by using _MSC_VER which is the normal way
      to detect Visual C++.
      a4777f35
  23. Apr 07, 2017
    • Heikki Linnakangas's avatar
      Use SASLprep to normalize passwords for SCRAM authentication. · 60f11b87
      Heikki Linnakangas authored
      An important step of SASLprep normalization, is to convert the string to
      Unicode normalization form NFKC. Unicode normalization requires a fairly
      large table of character decompositions, which is generated from data
      published by the Unicode consortium. The script to generate the table is
      put in src/common/unicode, as well test code for the normalization.
      A pre-generated version of the tables is included in src/include/common,
      so you don't need the code in src/common/unicode to build PostgreSQL, only
      if you wish to modify the normalization tables.
      
      The SASLprep implementation depends on the UTF-8 functions from
      src/backend/utils/mb/wchar.c. So to use it, you must also compile and link
      that. That doesn't change anything for the current users of these
      functions, the backend and libpq, as they both already link with wchar.o.
      It would be good to move those functions into a separate file in
      src/commmon, but I'll leave that for another day.
      
      No documentation changes included, because there is no details on the
      SCRAM mechanism in the docs anyway. An overview on that in the protocol
      specification would probably be good, even though SCRAM is documented in
      detail in RFC5802. I'll write that as a separate patch. An important thing
      to mention there is that we apply SASLprep even on invalid UTF-8 strings,
      to support other encodings.
      
      Patch by Michael Paquier and me.
      
      Discussion: https://www.postgresql.org/message-id/CAB7nPqSByyEmAVLtEf1KxTRh=PWNKiWKEKQR=e1yGehz=wbymQ@mail.gmail.com
      60f11b87
  24. Apr 06, 2017
    • 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
  25. Apr 03, 2017
  26. Mar 28, 2017
    • Peter Eisentraut's avatar
      Fix Perl code which had broken the Windows build · 4d33a7f2
      Peter Eisentraut authored
      The previous change wanted to avoid modifying $_ in grep, but the code
      just made the change in a local variable and then lost it.  Rewrite the
      code using a separate map and grep, which is clearer anyway.
      
      Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
      4d33a7f2
  27. Mar 27, 2017
  28. Mar 25, 2017
    • Andres Freund's avatar
      Faster expression evaluation and targetlist projection. · b8d7f053
      Andres Freund authored
      This replaces the old, recursive tree-walk based evaluation, with
      non-recursive, opcode dispatch based, expression evaluation.
      Projection is now implemented as part of expression evaluation.
      
      This both leads to significant performance improvements, and makes
      future just-in-time compilation of expressions easier.
      
      The speed gains primarily come from:
      - non-recursive implementation reduces stack usage / overhead
      - simple sub-expressions are implemented with a single jump, without
        function calls
      - sharing some state between different sub-expressions
      - reduced amount of indirect/hard to predict memory accesses by laying
        out operation metadata sequentially; including the avoidance of
        nearly all of the previously used linked lists
      - more code has been moved to expression initialization, avoiding
        constant re-checks at evaluation time
      
      Future just-in-time compilation (JIT) has become easier, as
      demonstrated by released patches intended to be merged in a later
      release, for primarily two reasons: Firstly, due to a stricter split
      between expression initialization and evaluation, less code has to be
      handled by the JIT. Secondly, due to the non-recursive nature of the
      generated "instructions", less performance-critical code-paths can
      easily be shared between interpreted and compiled evaluation.
      
      The new framework allows for significant future optimizations. E.g.:
      - basic infrastructure for to later reduce the per executor-startup
        overhead of expression evaluation, by caching state in prepared
        statements.  That'd be helpful in OLTPish scenarios where
        initialization overhead is measurable.
      - optimizing the generated "code". A number of proposals for potential
        work has already been made.
      - optimizing the interpreter. Similarly a number of proposals have
        been made here too.
      
      The move of logic into the expression initialization step leads to some
      backward-incompatible changes:
      - Function permission checks are now done during expression
        initialization, whereas previously they were done during
        execution. In edge cases this can lead to errors being raised that
        previously wouldn't have been, e.g. a NULL array being coerced to a
        different array type previously didn't perform checks.
      - The set of domain constraints to be checked, is now evaluated once
        during expression initialization, previously it was re-built
        every time a domain check was evaluated. For normal queries this
        doesn't change much, but e.g. for plpgsql functions, which caches
        ExprStates, the old set could stick around longer.  The behavior
        around might still change.
      
      Author: Andres Freund, with significant changes by Tom Lane,
      	changes by Heikki Linnakangas
      Reviewed-By: Tom Lane, Heikki Linnakangas
      Discussion: https://postgr.es/m/20161206034955.bh33paeralxbtluv@alap3.anarazel.de
      b8d7f053
  29. Mar 23, 2017
Loading