1. 12 Nov, 2019 3 commits
    • Tom Lane's avatar
      Fix ecpglib.h to declare bool consistently with c.h. · 7a0574b5
      Tom Lane authored
      This completes the task begun in commit 1408d5d8, to synchronize
      ECPG's exported definitions with the definition of bool used by
      c.h (and, therefore, the one actually in use in the ECPG library).
      On practically all modern platforms, ecpglib.h will now just
      include <stdbool.h>, which should surprise nobody anymore.
      That removes a header-inclusion-order hazard for ECPG clients,
      who previously might get build failures or unexpected behavior
      depending on whether they'd included <stdbool.h> themselves,
      and if so, whether before or after ecpglib.h.
      
      On platforms where sizeof(_Bool) is not 1 (only old PPC-based
      Mac systems, as far as I know), things are still messy, as
      inclusion of <stdbool.h> could still break ECPG client code.
      There doesn't seem to be any clean fix for that, and given the
      probably-negligible population of users who would care anymore,
      it's not clear we should go far out of our way to cope with it.
      This change at least fixes some header-inclusion-order hazards
      for our own code, since c.h and ecpglib.h previously disagreed
      on whether bool should be char or unsigned char.
      
      To implement this with minimal invasion of ECPG client namespace,
      move the choice of whether to rely on <stdbool.h> into configure,
      and have it export a configuration symbol PG_USE_STDBOOL.
      
      ecpglib.h no longer exports definitions for TRUE and FALSE,
      only their lowercase brethren.  We could undo that if we get
      push-back about it.
      
      Ideally we'd back-patch this as far as v11, which is where c.h
      started to rely on <stdbool.h>.  But the odds of creating problems
      for formerly-working ECPG client code seem about as large as the
      odds of fixing any non-working cases, so we'll just do this in HEAD.
      
      Discussion: https://postgr.es/m/CAA4eK1LmaKO7Du9M9Lo=kxGU8sB6aL8fa3sF6z6d5yYYVe3BuQ@mail.gmail.com
      7a0574b5
    • Peter Eisentraut's avatar
      gitattributes: Add new file · de7c2d30
      Peter Eisentraut authored
      de7c2d30
    • Amit Kapila's avatar
      Make the order of the header file includes consistent in backend modules. · 14aec035
      Amit Kapila authored
      Similar to commits 7e735035 and dddf4cdc, this commit makes the order
      of header file inclusion consistent for backend modules.
      
      In the passing, removed a couple of duplicate inclusions.
      
      Author: Vignesh C
      Reviewed-by: Kuntal Ghosh and Amit Kapila
      Discussion: https://postgr.es/m/CALDaNm2Sznv8RR6Ex-iJO6xAdsxgWhCoETkaYX=+9DW3q0QCfA@mail.gmail.com
      14aec035
  2. 11 Nov, 2019 8 commits
  3. 09 Nov, 2019 6 commits
  4. 08 Nov, 2019 6 commits
  5. 07 Nov, 2019 9 commits
  6. 06 Nov, 2019 8 commits
    • Tomas Vondra's avatar
      Allow sampling of statements depending on duration · 6e3e6cc0
      Tomas Vondra authored
      This allows logging a sample of statements, without incurring excessive
      log traffic (which may impact performance).  This can be useful when
      analyzing workloads with lots of short queries.
      
      The sampling is configured using two new GUC parameters:
      
       * log_min_duration_sample - minimum required statement duration
      
       * log_statement_sample_rate - sample rate (0.0 - 1.0)
      
      Only statements with duration exceeding log_min_duration_sample are
      considered for sampling. To enable sampling, both those GUCs have to
      be set correctly.
      
      The existing log_min_duration_statement GUC has a higher priority, i.e.
      statements with duration exceeding log_min_duration_statement will be
      always logged, irrespectedly of how the sampling is configured. This
      means only configurations
      
        log_min_duration_sample < log_min_duration_statement
      
      do actually sample the statements, instead of logging everything.
      
      Author: Adrien Nayrat
      Reviewed-by: David Rowley, Vik Fearing, Tomas Vondra
      Discussion: https://postgr.es/m/bbe0a1a8-a8f7-3be2-155a-888e661cc06c@anayrat.info
      6e3e6cc0
    • Tomas Vondra's avatar
      Document log_transaction_sample_rate as superuser-only · 11d9ac28
      Tomas Vondra authored
      The docs do say which GUCs can be changed only by superusers, but we
      forgot to mention this for the new log_transaction_sample_rate. This
      GUC was introduced in PostgreSQL 12, so backpatch accordingly.
      
      Author: Adrien Nayrat
      Backpatch-through: 12
      11d9ac28
    • Tom Lane's avatar
      Minor code review for tuple slot rewrite. · 22e44e8d
      Tom Lane authored
      Avoid creating transiently-inconsistent slot states where possible,
      by not setting TTS_FLAG_SHOULDFREE until after the slot actually has
      a free'able tuple pointer, and by making sure that we reset tts_nvalid
      and related derived state before we replace the tuple contents.  This
      would only matter if something were to examine the slot after we'd
      suffered some kind of error (e.g. out of memory) while manipulating
      the slot.  We typically don't do that, so these changes might just be
      cosmetic --- but even if so, it seems like good future-proofing.
      
      Also remove some redundant Asserts, and add a couple for consistency.
      
      Back-patch to v12 where all this code was rewritten.
      
      Discussion: https://postgr.es/m/16095-c3ff2e5283b8dba5@postgresql.org
      22e44e8d
    • Tom Lane's avatar
      Sync our DTrace infrastructure with c.h's definition of type bool. · ff43b3e8
      Tom Lane authored
      Since commit d26a810e, we've defined bool as being either _Bool from
      <stdbool.h>, or "unsigned char"; but that commit overlooked the fact
      that probes.d has "#define bool char".  For consistency, make it say
      "unsigned char" instead.  This should be strictly a cosmetic change,
      but it seems best to be in sync.
      
      Formally, in the now-normal case where we're using <stdbool.h>, it'd
      be better to write "#define bool _Bool".  However, then we'd need
      some build infrastructure to inject that configuration choice into
      probes.d, and it doesn't seem worth the trouble.  We only use
      <stdbool.h> if sizeof(_Bool) is 1, so having DTrace think that
      bool parameters are "unsigned char" should be close enough.
      
      Back-patch to v12 where d26a810e came in.
      
      Discussion: https://postgr.es/m/CAA4eK1LmaKO7Du9M9Lo=kxGU8sB6aL8fa3sF6z6d5yYYVe3BuQ@mail.gmail.com
      ff43b3e8
    • Peter Eisentraut's avatar
      Fix memory allocation mistake · d40abd5f
      Peter Eisentraut authored
      The previous code was allocating more memory than necessary because
      the formula used the wrong data type.
      Reported-by: default avatarJehan-Guillaume de Rorthais <jgdr@dalibo.com>
      Discussion: https://www.postgresql.org/message-id/20191105172918.3e32a446@firost
      d40abd5f
    • Peter Eisentraut's avatar
      Remove unused function argument · 5b7ba75f
      Peter Eisentraut authored
      The cache_plan argument to ri_PlanCheck has not been used since
      e8c9fd5f.
      Reviewed-by: default avatarvignesh C <vignesh21@gmail.com>
      Discussion: https://www.postgresql.org/message-id/flat/ec8a8b45-a30b-9193-cd4b-985d60d1497e%402ndquadrant.com
      5b7ba75f
    • Michael Paquier's avatar
      Fix timestamp of sent message for write context in logical decoding · 5f6b1eb0
      Michael Paquier authored
      When sending data for logical decoding using the streaming replication
      protocol via a WAL sender, the timestamp of the sent write message is
      allocated at the beginning of the message when preparing for the write,
      and actually computed when the write message is ready to be sent.
      
      The timestamp was getting computed after sending the message.  This
      impacts anything using logical decoding, causing for example logical
      replication to report mostly NULL for last_msg_send_time in
      pg_stat_subscription.
      
      This commit makes sure that the timestamp is computed before sending the
      message.  This is wrong since 5a991ef8, so backpatch down to 9.4.
      
      Author: Jeff Janes
      Discussion: https://postgr.es/m/CAMkU=1z=WMn8jt7iEdC5sYNaPgAgOASb_OW5JYv-vMdYaJSL-w@mail.gmail.com
      Backpatch-through: 9.4
      5f6b1eb0
    • Andrew Gierth's avatar
      Request small targetlist for input to WindowAgg. · a9056cc6
      Andrew Gierth authored
      WindowAgg will potentially store large numbers of input rows into
      tuplestores to allow access to other rows in the frame. If the input
      is coming via an explicit Sort node, then unneeded columns will
      already have been discarded (since Sort requests a small tlist); but
      there are idioms like COUNT(*) OVER () that result in the input not
      being sorted at all, and cases where the input is being sorted by some
      means other than a Sort; if we don't request a small tlist, then
      WindowAgg's storage requirement is inflated by the unneeded columns.
      
      Backpatch back to 9.6, where the current tlist handling was added.
      (Prior to that, WindowAgg would always use a small tlist.)
      
      Discussion: https://postgr.es/m/87a7ator8n.fsf@news-spur.riddles.org.uk
      a9056cc6