1. 17 Nov, 2015 2 commits
  2. 16 Nov, 2015 2 commits
    • Robert Haas's avatar
      Remove volatile qualifiers from bufmgr.c and freelist.c · e93b6298
      Robert Haas authored
      Prior to commit 0709b7ee, access to
      variables within a spinlock-protected critical section had to be done
      through a volatile pointer, but that should no longer be necessary.
      
      Review by Andres Freund
      e93b6298
    • Tom Lane's avatar
      Speed up ruleutils' name de-duplication code, and fix overlength-name case. · 8004953b
      Tom Lane authored
      Since commit 11e13185, ruleutils.c has
      attempted to ensure that each RTE in a query or plan tree has a unique
      alias name.  However, the code that was added for this could be quite slow,
      even as bad as O(N^3) if N identical RTE names must be replaced, as noted
      by Jeff Janes.  Improve matters by building a transient hash table within
      set_rtable_names.  The hash table in itself reduces the cost of detecting a
      duplicate from O(N) to O(1), and we can save another factor of N by storing
      the number of de-duplicated names already created for each entry, so that
      we don't have to re-try names already created.  This way is probably a bit
      slower overall for small range tables, but almost by definition, such cases
      should not be a performance problem.
      
      In principle the same problem applies to the column-name-de-duplication
      code; but in practice that seems to be less of a problem, first because
      N is limited since we don't support extremely wide tables, and second
      because duplicate column names within an RTE are fairly rare, so that in
      practice the cost is more like O(N^2) not O(N^3).  It would be very much
      messier to fix the column-name code, so for now I've left that alone.
      
      An independent problem in the same area was that the de-duplication code
      paid no attention to the identifier length limit, and would happily produce
      identifiers that were longer than NAMEDATALEN and wouldn't be unique after
      truncation to NAMEDATALEN.  This could result in dump/reload failures, or
      perhaps even views that silently behaved differently than before.  We can
      fix that by shortening the base name as needed.  Fix it for both the
      relation and column name cases.
      
      In passing, check for interrupts in set_rtable_names, just in case it's
      still slow enough to be an issue.
      
      Back-patch to 9.3 where this code was introduced.
      8004953b
  3. 15 Nov, 2015 2 commits
    • Robert Haas's avatar
      Remove accidentally-committed debugging code. · 179c97bf
      Robert Haas authored
      Amit Kapila
      179c97bf
    • Tom Lane's avatar
      Fix ruleutils.c's dumping of whole-row Vars in ROW() and VALUES() contexts. · 7745bc35
      Tom Lane authored
      Normally ruleutils prints a whole-row Var as "foo.*".  We already knew that
      that doesn't work at top level of a SELECT list, because the parser would
      treat the "*" as a directive to expand the reference into separate columns,
      not a whole-row Var.  However, Joshua Yanovski points out in bug #13776
      that the same thing happens at top level of a ROW() construct; and some
      nosing around in the parser shows that the same is true in VALUES().
      Hence, apply the same workaround already devised for the SELECT-list case,
      namely to add a forced cast to the appropriate rowtype in these cases.
      (The alternative of just printing "foo" was rejected because it is
      difficult to avoid ambiguity against plain columns named "foo".)
      
      Back-patch to all supported branches.
      7745bc35
  4. 14 Nov, 2015 3 commits
    • Tom Lane's avatar
      Improve type numeric's calculations for ln(), log(), exp(), pow(). · 7d9a4737
      Tom Lane authored
      Set the "rscales" for intermediate-result calculations to ensure that
      suitable numbers of significant digits are maintained throughout.  The
      previous coding hadn't thought this through in any detail, and as a result
      could deliver results with many inaccurate digits, or in the worst cases
      even fail with divide-by-zero errors as a result of losing all nonzero
      digits of intermediate results.
      
      In exp_var(), get rid entirely of the logic that separated the calculation
      into integer and fractional parts: that was neither accurate nor
      particularly fast.  The existing range-reduction method of dividing by 2^n
      can be applied across the full input range instead of only 0..1, as long as
      we are careful to set an appropriate rscale for each step.
      
      Also fix the logic in mul_var() for shortening the calculation when the
      caller asks for fewer output digits than an exact calculation would
      require.  This bug doesn't affect simple multiplications since that code
      path asks for an exact result, but it does contribute to accuracy issues
      in the transcendental math functions.
      
      In passing, improve performance of mul_var() a bit by forcing the shorter
      input to be on the left, thus reducing the number of iterations of the
      outer loop and probably also reducing the number of carry-propagation
      steps needed.
      
      This is arguably a bug fix, but in view of the lack of field complaints,
      it does not seem worth the risk of back-patching.
      
      Dean Rasheed
      7d9a4737
    • Bruce Momjian's avatar
      Fix spelling error in postgresql.conf · e57646e9
      Bruce Momjian authored
      Report by Greg Clough
      e57646e9
    • Bruce Momjian's avatar
      pg_upgrade: properly detect file copy failure on Windows · 025106e3
      Bruce Momjian authored
      Previously, file copy failures were ignored on Windows due to an
      incorrect return value check.
      
      Report by Manu Joye
      
      Backpatch through 9.1
      025106e3
  5. 13 Nov, 2015 1 commit
    • Stephen Frost's avatar
      Correct sepgsql docs with regard to RLS · 42aa1c03
      Stephen Frost authored
      The sepgsql docs included a comment that PG doesn't support RLS.  That
      is only true for versions prior to 9.5.
      
      Update the docs for 9.5 and master to say that PG supports RLS but that
      sepgsql does not yet.
      
      Pointed out by Heikki.
      
      Back-patch to 9.5
      42aa1c03
  6. 12 Nov, 2015 7 commits
    • Alvaro Herrera's avatar
      vacuumdb: don't prompt for passwords over and over · 83dec5a7
      Alvaro Herrera authored
      Having the script prompt for passwords over and over was a preexisting
      problem when it processed multiple databases or when it processed
      multiple analyze stages, but the parallel mode introduced in commit
      a1792320 made it worse.
      
      Fix the annoyance by keeping a copy of the password used by the first
      connection that requires one.  Since users can (currently) only have a
      single password, there's no need for more complex arrangements (such as
      remembering one password per database).
      
      Per bug #13741 reported by Eric Brown.  Patch authored and
      cross-reviewed by Haribabu Kommi and Michael Paquier, slightly tweaked
      by Álvaro Herrera.
      
      Discussion: http://www.postgresql.org/message-id/20151027193919.931.54948@wrigleys.postgresql.org
      Backpatch to 9.5, where parallel vacuumdb was introduced.
      83dec5a7
    • Robert Haas's avatar
      Move each SLRU's lwlocks to a separate tranche. · fe702a7b
      Robert Haas authored
      This makes it significantly easier to identify these lwlocks in
      LWLOCK_STATS or Trace_lwlocks output.  It's also arguably better
      from a modularity standpoint, since lwlock.c no longer needs to
      know anything about the LWLock needs of the higher-level SLRU
      facility.
      
      Ildus Kurbangaliev, reviewd by Álvaro Herrera and by me.
      fe702a7b
    • Tom Lane's avatar
      Fix unwanted flushing of libpq's input buffer when socket EOF is seen. · c4059188
      Tom Lane authored
      In commit 210eb9b7 I centralized libpq's logic for closing down
      the backend communication socket, and made the new pqDropConnection
      routine always reset the I/O buffers to empty.  Many of the call sites
      previously had not had such code, and while that amounted to an oversight
      in some cases, there was one place where it was intentional and necessary
      *not* to flush the input buffer: pqReadData should never cause that to
      happen, since we probably still want to process whatever data we read.
      
      This is the true cause of the problem Robert was attempting to fix in
      c3e7c24a, namely that libpq no longer reported the backend's final
      ERROR message before reporting "server closed the connection unexpectedly".
      But that only accidentally fixed it, by invoking parseInput before the
      input buffer got flushed; and very likely there are timing scenarios
      where we'd still lose the message before processing it.
      
      To fix, pass a flag to pqDropConnection to tell it whether to flush the
      input buffer or not.  On review I think flushing is actually correct for
      every other call site.
      
      Back-patch to 9.3 where the problem was introduced.  In HEAD, also improve
      the comments added by c3e7c24a.
      c4059188
    • Robert Haas's avatar
      libpq: Notice errors a backend may have sent just before dying. · c3e7c24a
      Robert Haas authored
      At least since the introduction of Hot Standby, the backend has
      sometimes sent fatal errors even when no client query was in
      progress, assuming that the client would receive it.  However,
      pqHandleSendFailure was not in sync with this assumption, and
      only tries to catch notices and notifies.  Add a parseInput call
      to the loop there to fix.
      
      Andres Freund suggested the fix.  Comments are by me.
      Reviewed by Michael Paquier.
      c3e7c24a
    • Robert Haas's avatar
      Make idle backends exit if the postmaster dies. · ac1d7945
      Robert Haas authored
      Letting backends continue to run if the postmaster has exited prevents
      PostgreSQL from being restarted, which in many environments is
      catastrophic.  Worse, if some other backend crashes, we no longer have
      any protection against shared memory corruption.  So, arrange for them
      to exit instead.  We don't want to expend many cycles on this, but
      including postmaster death in the set of things that we wait for when
      a backend is idle seems cheap enough.
      
      Rajeev Rastogi and Robert Haas
      ac1d7945
    • Robert Haas's avatar
      Provide readfuncs support for custom scans. · a05dc4d7
      Robert Haas authored
      Commit a0d9f6e4 added this support for
      all other plan node types; this fills in the gap.
      
      Since TextOutCustomScan complicates this and is pretty well useless,
      remove it.
      
      KaiGai Kohei, with some modifications by me.
      a05dc4d7
    • Tom Lane's avatar
      Do a round of copy-editing on the 9.5 release notes. · 39b9978d
      Tom Lane authored
      Also fill in the previously empty "major enhancements" list.  YMMV as to
      which items should make the cut, but it's past time we had something more
      than a placeholder here.
      
      (I meant to get this done before beta2 was wrapped, but got distracted by
      PDF build problems.  Better late than never.)
      39b9978d
  7. 11 Nov, 2015 6 commits
    • Tom Lane's avatar
      Improve documentation around autovacuum-related storage parameters. · 6404751c
      Tom Lane authored
      These were discussed in three different sections of the manual, which
      unsurprisingly had diverged over time; and the descriptions of individual
      variables lacked stylistic consistency even within each section (and
      frequently weren't in very good English anyway).  Clean up the mess, and
      remove some of the redundant information in hopes that future additions
      will be less likely to re-introduce inconsistency.  For instance I see
      no need for maintenance.sgml to include its very own list of all the
      autovacuum storage parameters, especially since that list was already
      incomplete.
      6404751c
    • Tom Lane's avatar
      Be more noisy about "wrong number of nailed relations" initfile problems. · da3751c8
      Tom Lane authored
      In commit 5d1ff6bd I added some logic to
      relcache.c to try to ensure that the regression tests would fail if we
      made a mistake about which relations belong in the relcache init files.
      I'm quite sure I tested that, but I must have done so only for the
      non-shared-catalog case, because a report from Adam Brightwell showed that
      the regression tests still pass just fine if we bollix the shared-catalog
      init file in the way this code was supposed to catch.  The reason is that
      that file gets loaded before we do client authentication, so the WARNING
      is not sent to the client, only to the postmaster log, where it's far too
      easily missed.
      
      The least Rube Goldbergian answer to this is to put an Assert(false)
      after the elog(WARNING).  That will certainly get developers' attention,
      while not breaking production builds' ability to recover from corner
      cases with similar symptoms.
      
      Since this is only of interest to developers, there seems no need for
      a back-patch, even though the previous commit went into all branches.
      da3751c8
    • Robert Haas's avatar
      Generate parallel sequential scan plans in simple cases. · 80558c1f
      Robert Haas authored
      Add a new flag, consider_parallel, to each RelOptInfo, indicating
      whether a plan for that relation could conceivably be run inside of
      a parallel worker.  Right now, we're pretty conservative: for example,
      it might be possible to defer applying a parallel-restricted qual
      in a worker, and later do it in the leader, but right now we just
      don't try to parallelize access to that relation.  That's probably
      the right decision in most cases, anyway.
      
      Using the new flag, generate parallel sequential scan plans for plain
      baserels, meaning that we now have parallel sequential scan in
      PostgreSQL.  The logic here is pretty unsophisticated right now: the
      costing model probably isn't right in detail, and we can't push joins
      beneath Gather nodes, so the number of plans that can actually benefit
      from this is pretty limited right now.  Lots more work is needed.
      Nevertheless, it seems time to enable this functionality so that all
      this code can actually be tested easily by users and developers.
      
      Note that, if you wish to test this functionality, it will be
      necessary to set max_parallel_degree to a value greater than the
      default of 0.  Once a few more loose ends have been tidied up here, we
      might want to consider changing the default value of this GUC, but
      I'm leaving it alone for now.
      
      Along the way, fix a bug in cost_gather: the previous coding thought
      that a Gather node's transfer overhead should be costed on the basis of
      the relation size rather than the number of tuples that actually need
      to be passed off to the leader.
      
      Patch by me, reviewed in earlier versions by Amit Kapila.
      80558c1f
    • Robert Haas's avatar
      Make sequential scans parallel-aware. · f0661c4e
      Robert Haas authored
      In addition, this path fills in a number of missing bits and pieces in
      the parallel infrastructure.  Paths and plans now have a parallel_aware
      flag indicating whether whatever parallel-aware logic they have should
      be engaged.  It is believed that we will need this flag for a number of
      path/plan types, not just sequential scans, which is why the flag is
      generic rather than part of the SeqScan structures specifically.
      Also, execParallel.c now gives parallel nodes a chance to initialize
      their PlanState nodes from the DSM during parallel worker startup.
      
      Amit Kapila, with a fair amount of adjustment by me.  Review of previous
      patch versions by Haribabu Kommi and others.
      f0661c4e
    • Robert Haas's avatar
      Add outfuncs.c support for GatherPath. · f764ecd8
      Robert Haas authored
      I dunno how commit 3bd909b2 missed
      this, but it evidently did.
      f764ecd8
    • Tom Lane's avatar
      Docs: fix misleading example. · 7b6fb763
      Tom Lane authored
      Commit 8457d0be introduced an example which, while not incorrect,
      failed to exhibit the behavior it meant to describe, as a result of omitting
      an E'' prefix that needed to be there.  Noticed and fixed by Peter Geoghegan.
      
      I (tgl) failed to resist the temptation to wordsmith nearby text a bit
      while at it.
      7b6fb763
  8. 10 Nov, 2015 2 commits
    • Tom Lane's avatar
      Add missing "static" qualifier. · b05ae27e
      Tom Lane authored
      Per buildfarm member pademelon.
      b05ae27e
    • Tom Lane's avatar
      Improve our workaround for 'TeX capacity exceeded' in building PDF files. · 944b41fc
      Tom Lane authored
      In commit a5ec86a7 I wrote a quick hack
      that reduced the number of TeX string pool entries created while converting
      our documentation to PDF form.  That held the fort for awhile, but as of
      HEAD we're back up against the same limitation.  It turns out that the
      original coding of \FlowObjectSetup actually results in *three* string pool
      entries being generated for every "flow object" (that is, potential
      cross-reference target) in the documentation, and my previous hack only got
      rid of one of them.  With a little more care, we can reduce the string
      count to one per flow object plus one per actually-cross-referenced flow
      object (about 115000 + 5000 as of current HEAD); that should work until
      the documentation volume roughly doubles from where it is today.
      
      As a not-incidental side benefit, this change also causes pdfjadetex to
      stop emitting unreferenced hyperlink anchors (bookmarks) into the PDF file.
      It had been making one willy-nilly for every flow object; now it's just one
      per actually-cross-referenced object.  This results in close to a 2X
      savings in PDF file size.  We will still want to run the output through
      "jpdftweak" to get it to be compressed; but we no longer need removal of
      unreferenced bookmarks, so we might be able to find a quicker tool for
      that step.
      
      Although the failure only affects HEAD and US-format output at the moment,
      9.5 cannot be more than a few pages short of failing likewise, so it
      will inevitably fail after a few rounds of minor-version release notes.
      I don't have a lot of faith that we'll never hit the limit in the older
      branches; and anyway it would be nice to get rid of jpdftweak across the
      board.  Therefore, back-patch to all supported branches.
      944b41fc
  9. 09 Nov, 2015 4 commits
  10. 08 Nov, 2015 3 commits
    • Andres Freund's avatar
      Set replication origin when decoding commit records. · f3a764b0
      Andres Freund authored
      By accident the replication origin was not set properly in
      DecodeCommit(). That's bad because the origin is passed to the output
      plugins origin filter, and accessible from the output plugin via
      ReorderBufferTXN->origin_id.  Accessing the origin of individual changes
      worked before the fix, which is why this wasn't notices earlier.
      
      Reported-By: Craig Ringer
      Author: Craig Ringer
      Discussion: CAMsr+YFhBJLp=qfSz3-J+0P1zLkE8zNXM2otycn20QRMx380gw@mail.gmail.com
      Backpatch: 9.5, where replication origins where introduced
      f3a764b0
    • Noah Misch's avatar
      Don't connect() to a wildcard address in test_postmaster_connection(). · fed19f31
      Noah Misch authored
      At least OpenBSD, NetBSD, and Windows don't support it.  This repairs
      pg_ctl for listen_addresses='0.0.0.0' and listen_addresses='::'.  Since
      pg_ctl prefers to test a Unix-domain socket, Windows users are most
      likely to need this change.  Back-patch to 9.1 (all supported versions).
      This could change pg_ctl interaction with loopback-interface firewall
      rules.  Therefore, in 9.4 and earlier (released branches), activate the
      change only on known-affected platforms.
      
      Reported (bug #13611) and designed by Kondo Yuta.
      fed19f31
    • Robert Haas's avatar
      Remove set-but-not-used variables. · fba60e57
      Robert Haas authored
      Reported by both Peter Eisentraunt and Kevin Grittner.
      fba60e57
  11. 07 Nov, 2015 6 commits
    • Tom Lane's avatar
      Update 9.5 release notes through today. · ad9fad7b
      Tom Lane authored
      ad9fad7b
    • Tom Lane's avatar
      Add "xid <> xid" and "xid <> int4" operators. · c5e86ea9
      Tom Lane authored
      The corresponding "=" operators have been there a long time, and not
      having their negators is a bit of a nuisance.
      
      Michael Paquier
      c5e86ea9
    • Tom Lane's avatar
      Rename PQsslAttributes() to PQsslAttributeNames(), and const-ify fully. · 9042f583
      Tom Lane authored
      Per discussion, the original name was a bit misleading, and
      PQsslAttributeNames() seems more apropos.  It's not quite too late to
      change this in 9.5, so let's change it while we can.
      
      Also, make sure that the pointer array is const, not only the pointed-to
      strings.
      
      Minor documentation wordsmithing while at it.
      
      Lars Kanis, slight adjustments by me
      9042f583
    • Tom Lane's avatar
      Fix enforcement of restrictions inside regexp lookaround constraints. · a43b4ab1
      Tom Lane authored
      Lookahead and lookbehind constraints aren't allowed to contain backrefs,
      and parentheses within them are always considered non-capturing.  Or so
      says the manual.  But the regexp parser forgot about these rules once
      inside a parenthesized subexpression, so that constructs like (\w)(?=(\1))
      were accepted (but then not correctly executed --- a case like this acted
      like (\w)(?=\w), without any enforcement that the two \w's match the same
      text).  And in (?=((foo))) the innermost parentheses would be counted as
      capturing parentheses, though no text would ever be captured for them.
      
      To fix, properly pass down the "type" argument to the recursive invocation
      of parse().
      
      Back-patch to all supported branches; it was agreed that silent
      misexecution of such patterns is worse than throwing an error, even though
      new errors in minor releases are generally not desirable.
      a43b4ab1
    • Robert Haas's avatar
      Try to convince gcc that TupleQueueRemap never falls off the end. · 8d7396e5
      Robert Haas authored
      Without this, MacOS gcc version 4.2.1 isn't convinced.
      8d7396e5
    • Robert Haas's avatar
      When completing ALTER INDEX .. SET, add an equals sign also. · af9773cf
      Robert Haas authored
      Jeff Janes
      af9773cf
  12. 06 Nov, 2015 2 commits
    • Robert Haas's avatar
      Modify tqueue infrastructure to support transient record types. · 6e71dd7c
      Robert Haas authored
      Commit 4a4e6893, which introduced this
      mechanism, failed to account for the fact that the RECORD pseudo-type
      uses transient typmods that are only meaningful within a single
      backend.  Transferring such tuples without modification between two
      cooperating backends does not work.  This commit installs a system
      for passing the tuple descriptors over the same shm_mq being used to
      send the tuples themselves.  The two sides might not assign the same
      transient typmod to any given tuple descriptor, so we must also
      substitute the appropriate receiver-side typmod for the one used by
      the sender.  That adds some CPU overhead, but still seems better than
      being unable to pass records between cooperating parallel processes.
      
      Along the way, move the logic for handling multiple tuple queues from
      tqueue.c to nodeGather.c; tqueue.c now provides a TupleQueueReader,
      which reads from a single queue, rather than a TupleQueueFunnel, which
      potentially reads from multiple queues.  This change was suggested
      previously as a way to make sure that nodeGather.c rather than tqueue.c
      had policy control over the order in which to read from queues, but
      it wasn't clear to me until now how good an idea it was.  typmod
      mapping needs to be performed separately for each queue, and it is
      much simpler if the tqueue.c code handles that and leaves multiplexing
      multiple queues to higher layers of the stack.
      6e71dd7c
    • Robert Haas's avatar
      Remove unnecessary cast in previous commit. · cbb82e37
      Robert Haas authored
      Noted by Kyotaro Horiguchi, who also reviewed the previous patch, but
      I failed to notice his review before committing.
      cbb82e37