1. 13 Apr, 2021 1 commit
  2. 12 Apr, 2021 9 commits
  3. 11 Apr, 2021 5 commits
    • Tom Lane's avatar
      Silence some Coverity warnings and improve code consistency. · 6277435a
      Tom Lane authored
      Coverity complained about possible overflow in expressions like
      	intresult = tm->tm_sec * 1000000 + fsec;
      on the grounds that the multiplication would happen in 32-bit
      arithmetic before widening to the int64 result.  I think these
      are all false positives because of the limited possible range of
      tm_sec; but nonetheless it seems silly to spell it like that when
      nearby lines have the identical computation written with a 64-bit
      constant.
      
      ... or more accurately, with an LL constant, which is not project
      style.  Make all of these use INT64CONST(), as we do elsewhere.
      
      This is all new code from a2da77cd, so no need for back-patch.
      6277435a
    • Tom Lane's avatar
      Add macro PGWARNING, and make PGERROR available on all platforms. · d7cff12c
      Tom Lane authored
      We'd previously noted the need for coping with Windows headers
      that provide some other definition of macro "ERROR" than elog.h
      does.  It turns out that R also wants to define ERROR, and
      WARNING too.  PL/R has been working around this in a hacky way
      that broke when we recently changed the numeric value of ERROR.
      To let them have a more future-proof solution, provide an
      alternate macro PGWARNING for WARNING, and make PGERROR visible
      always, not only when #ifdef WIN32.
      
      Discussion: https://postgr.es/m/CADK3HHK6iMChd1yoOqssxBn5Z14Zar8Ztr3G-N_fuG7F8YTP3w@mail.gmail.com
      d7cff12c
    • Tom Lane's avatar
      Fix uninitialized variable from commit a4d75c86. · 9cb92334
      Tom Lane authored
      The path for *exprs != NIL would misbehave, and likely crash,
      since pull_varattnos expects its last argument to be valid
      at call.
      
      Found by Coverity --- we have no coverage of this path in
      the regression tests.
      9cb92334
    • Fujii Masao's avatar
      Avoid unnecessary table open/close in TRUNCATE command. · 81a23dd8
      Fujii Masao authored
      ExecuteTruncate() filters out the duplicate tables specified
      in the TRUNCATE command, for example in the case where "TRUNCATE foo, foo"
      is executed. Such duplicate tables obviously don't need to be opened
      and closed because they are skipped. But previously it always opened
      the tables before checking whether they were duplicated ones or not,
      and then closed them if they were. That is, the duplicated tables were
      opened and closed unnecessarily.
      
      This commit changes ExecuteTruncate() so that it opens the table
      after it confirms that table is not duplicated one, which leads to
      avoid unnecessary table open/close.
      
      Do not back-patch because such unnecessary table open/close is not
      a bug though it exists in older versions.
      
      Author: Bharath Rupireddy
      Reviewed-by: Amul Sul, Fujii Masao
      Discussion: https://postgr.es/m/CALj2ACUdBO_sXJTa08OZ0YT0qk7F_gAmRa9hT4dxRcgPS4nsZA@mail.gmail.com
      81a23dd8
    • Fujii Masao's avatar
      Remove COMMIT_TS_SETTS record. · 08aa89b3
      Fujii Masao authored
      Commit 438fc4a3 prevented the WAL replay from writing
      COMMIT_TS_SETTS record. By this change there is no code that
      generates COMMIT_TS_SETTS record in PostgreSQL core.
      Also we can think that there are no extensions using the record
      because we've not received so far any complaints about the issue
      that commit 438fc4a3 fixed. Therefore this commit removes
      COMMIT_TS_SETTS record and its related code. Even without
      this record, the timestamp required for commit timestamp feature
      can be acquired from the COMMIT record.
      
      Bump WAL page magic.
      Reported-by: default avatarlx zou <zoulx1982@163.com>
      Author: Fujii Masao
      Reviewed-by: Alvaro Herrera
      Discussion: https://postgr.es/m/16931-620d0f2fdc6108f1@postgresql.org
      08aa89b3
  4. 10 Apr, 2021 5 commits
  5. 09 Apr, 2021 9 commits
  6. 08 Apr, 2021 11 commits
    • Peter Geoghegan's avatar
      Silence another _bt_check_unique compiler warning. · 796092fb
      Peter Geoghegan authored
      Per complaint from Tom Lane
      
      Discussion: https://postgr.es/m/1922884.1617909599@sss.pgh.pa.us
      796092fb
    • Tom Lane's avatar
      Add support for tab-completion of type arguments in \df, \do. · d1fcbde5
      Tom Lane authored
      Oversight in commit a3027e1e.
      d1fcbde5
    • Tom Lane's avatar
      Suppress uninitialized-variable warning. · 01add894
      Tom Lane authored
      Several buildfarm critters that don't usually produce such
      warnings are complaining about e717a9a1.  I think it's
      actually safe, but move initialization to silence the warning.
      01add894
    • Bruce Momjian's avatar
      Fixes for query_id feature · 0f61727b
      Bruce Momjian authored
      Ignore parallel workers in pg_stat_statements
        Oversight in 4f0b0966 which exposed queryid in parallel workers.
        Counters are aggregated by the main backend process so parallel workers
        would report duplicated activity, and could also report activity for the
        wrong entry as they are only aware of the top level queryid.
      
      Fix thinko in pg_stat_get_activity when retrieving the queryid.
      
      Remove unnecessary call to pgstat_report_queryid().
      
      Reported-by: Amit Kapila, Andres Freund, Thomas Munro
      
      Discussion: https://postgr.es/m/20210408051735.lfbdzun5zdlax5gd@alap3.anarazel.de p634GTSOqnDW86Owrn6qDAVosC5dJjXjp7BMfc5Gz1Q@mail.gmail.com
      
      Author: Julien Rouhaud
      0f61727b
    • Magnus Hagander's avatar
      Merge v1.10 of pg_stat_statements into v1.9 · 5844c23d
      Magnus Hagander authored
      v1.9 is already new in this version of PostgreSQL, so turn it into just
      one change.
      
      Author: Julien Rohaud
      Discussion: https://postgr.es/m/20210408120505.7zinijtdexbyghvb@nol
      5844c23d
    • Thomas Munro's avatar
      Remove duplicate typedef. · 34399a67
      Thomas Munro authored
      Thinko in commit 323cbe7c, per complaint from BF animal locust's older
      GCC compiler.
      34399a67
    • Fujii Masao's avatar
      Allow TRUNCATE command to truncate foreign tables. · 8ff1c946
      Fujii Masao authored
      This commit introduces new foreign data wrapper API for TRUNCATE.
      It extends TRUNCATE command so that it accepts foreign tables as
      the targets to truncate and invokes that API. Also it extends postgres_fdw
      so that it can issue TRUNCATE command to foreign servers, by adding
      new routine for that TRUNCATE API.
      
      The information about options specified in TRUNCATE command, e.g.,
      ONLY, CACADE, etc is passed to FDW via API. The list of foreign tables to
      truncate is also passed to FDW. FDW truncates the foreign data sources
      that the passed foreign tables specify, based on those information.
      For example, postgres_fdw constructs TRUNCATE command using them
      and issues it to the foreign server.
      
      For performance, TRUNCATE command invokes the FDW routine for
      TRUNCATE once per foreign server that foreign tables to truncate belong to.
      
      Author: Kazutaka Onishi, Kohei KaiGai, slightly modified by Fujii Masao
      Reviewed-by: Bharath Rupireddy, Michael Paquier, Zhihong Yu, Alvaro Herrera, Stephen Frost, Ashutosh Bapat, Amit Langote, Daniel Gustafsson, Ibrar Ahmed, Fujii Masao
      Discussion: https://postgr.es/m/CAOP8fzb_gkReLput7OvOK+8NHgw-RKqNv59vem7=524krQTcWA@mail.gmail.com
      Discussion: https://postgr.es/m/CAJuF6cMWDDqU-vn_knZgma+2GMaout68YUgn1uyDnexRhqqM5Q@mail.gmail.com
      8ff1c946
    • David Rowley's avatar
      Speedup ScalarArrayOpExpr evaluation · 50e17ad2
      David Rowley authored
      ScalarArrayOpExprs with "useOr=true" and a set of Consts on the righthand
      side have traditionally been evaluated by using a linear search over the
      array.  When these arrays contain large numbers of elements then this
      linear search could become a significant part of execution time.
      
      Here we add a new method of evaluating ScalarArrayOpExpr expressions to
      allow them to be evaluated by first building a hash table containing each
      element, then on subsequent evaluations, we just probe that hash table to
      determine if there is a match.
      
      The planner is in charge of determining when this optimization is possible
      and it enables it by setting hashfuncid in the ScalarArrayOpExpr.  The
      executor will only perform the hash table evaluation when the hashfuncid
      is set.
      
      This means that not all cases are optimized. For example CHECK constraints
      containing an IN clause won't go through the planner, so won't get the
      hashfuncid set.  We could maybe do something about that at some later
      date.  The reason we're not doing it now is from fear that we may slow
      down cases where the expression is evaluated only once.  Those cases can
      be common, for example, a single row INSERT to a table with a CHECK
      constraint containing an IN clause.
      
      In the planner, we enable this when there are suitable hash functions for
      the ScalarArrayOpExpr's operator and only when there is at least
      MIN_ARRAY_SIZE_FOR_HASHED_SAOP elements in the array.  The threshold is
      currently set to 9.
      
      Author: James Coleman, David Rowley
      Reviewed-by: David Rowley, Tomas Vondra, Heikki Linnakangas
      Discussion: https://postgr.es/m/CAAaqYe8x62+=wn0zvNKCj55tPpg-JBHzhZFFc6ANovdqFw7-dA@mail.gmail.com
      50e17ad2
    • Thomas Munro's avatar
      Optionally prefetch referenced data in recovery. · 1d257577
      Thomas Munro authored
      Introduce a new GUC recovery_prefetch, disabled by default.  When
      enabled, look ahead in the WAL and try to initiate asynchronous reading
      of referenced data blocks that are not yet cached in our buffer pool.
      For now, this is done with posix_fadvise(), which has several caveats.
      Better mechanisms will follow in later work on the I/O subsystem.
      
      The GUC maintenance_io_concurrency is used to limit the number of
      concurrent I/Os we allow ourselves to initiate, based on pessimistic
      heuristics used to infer that I/Os have begun and completed.
      
      The GUC wal_decode_buffer_size is used to limit the maximum distance we
      are prepared to read ahead in the WAL to find uncached blocks.
      
      Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> (parts)
      Reviewed-by: Andres Freund <andres@anarazel.de> (parts)
      Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com> (parts)
      Tested-by: default avatarTomas Vondra <tomas.vondra@2ndquadrant.com>
      Tested-by: default avatarJakub Wartak <Jakub.Wartak@tomtom.com>
      Tested-by: default avatarDmitry Dolgov <9erthalion6@gmail.com>
      Tested-by: default avatarSait Talha Nisanci <Sait.Nisanci@microsoft.com>
      Discussion: https://postgr.es/m/CA%2BhUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq%3DAovOddfHpA%40mail.gmail.com
      1d257577
    • Thomas Munro's avatar
      Add circular WAL decoding buffer. · f003d9f8
      Thomas Munro authored
      Teach xlogreader.c to decode its output into a circular buffer, to
      support optimizations based on looking ahead.
      
       * XLogReadRecord() works as before, consuming records one by one, and
         allowing them to be examined via the traditional XLogRecGetXXX()
         macros.
      
       * An alternative new interface XLogNextRecord() is added that returns
         pointers to DecodedXLogRecord structs that can be examined directly.
      
       * XLogReadAhead() provides a second cursor that lets you see
         further ahead, as long as data is available and there is enough space
         in the decoding buffer.  This returns DecodedXLogRecord pointers to the
         caller, but also adds them to a queue of records that will later be
         consumed by XLogNextRecord()/XLogReadRecord().
      
      The buffer's size is controlled with wal_decode_buffer_size.  The buffer
      could potentially be placed into shared memory, for future projects.
      Large records that don't fit in the circular buffer are called
      "oversized" and allocated separately with palloc().
      
      Discussion: https://postgr.es/m/CA+hUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq=AovOddfHpA@mail.gmail.com
      f003d9f8
    • Thomas Munro's avatar
      Remove read_page callback from XLogReader. · 323cbe7c
      Thomas Munro authored
      Previously, the XLogReader module would fetch new input data using a
      callback function.  Redesign the interface so that it tells the caller
      to insert more data with a special return value instead.  This API suits
      later patches for prefetching, encryption and maybe other future
      projects that would otherwise require continually extending the callback
      interface.
      
      As incidental cleanup work, move global variables readOff, readLen and
      readSegNo inside XlogReaderState.
      
      Author: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
      Author: Heikki Linnakangas <hlinnaka@iki.fi> (parts of earlier version)
      Reviewed-by: default avatarAntonin Houska <ah@cybertec.at>
      Reviewed-by: default avatarAlvaro Herrera <alvherre@2ndquadrant.com>
      Reviewed-by: default avatarTakashi Menjo <takashi.menjo@gmail.com>
      Reviewed-by: default avatarAndres Freund <andres@anarazel.de>
      Reviewed-by: default avatarThomas Munro <thomas.munro@gmail.com>
      Discussion: https://postgr.es/m/20190418.210257.43726183.horiguchi.kyotaro%40lab.ntt.co.jp
      323cbe7c