1. 04 Nov, 2020 15 commits
    • Tom Lane's avatar
      Remove underflow error in float division with infinite divisor. · fac83dbd
      Tom Lane authored
      float4_div and float8_div correctly produced zero for zero divided
      by infinity, but threw an underflow error for nonzero finite values
      divided by infinity.  This seems wrong; at the very least it's
      inconsistent with the behavior recently implemented for numeric
      infinities.  Remove the error and allow zero to be returned.
      
      This patch also removes a useless isinf() test from the overflow
      checks in these functions (non-Inf divided by Inf can't produce Inf).
      
      Extracted from a larger patch; this seems significant outside the
      context of geometric operators, so it deserves its own commit.
      
      Kyotaro Horiguchi
      
      Discussion: https://postgr.es/m/CAGf+fX70rWFOk5cd00uMfa__0yP+vtQg5ck7c2Onb-Yczp0URA@mail.gmail.com
      fac83dbd
    • Tom Lane's avatar
      Declare assorted array functions using anycompatible not anyelement. · 9e38c2bb
      Tom Lane authored
      Convert array_append, array_prepend, array_cat, array_position,
      array_positions, array_remove, array_replace, and width_bucket
      to use anycompatiblearray.  This is a simple extension of commit
      5c292e6b to hit some other places where there's a pretty obvious
      gain in usability from doing so.
      
      Ideally we'd also modify other functions taking multiple old-style
      polymorphic arguments.  But most of the remainder are tied into one
      or more operator classes, making any such change a much larger can of
      worms than I desire to open right now.
      
      Discussion: https://postgr.es/m/77675130-89da-dab1-51dd-492c93dcf5d1@postgresfriends.org
      9e38c2bb
    • Tom Lane's avatar
      Declare lead() and lag() using anycompatible not anyelement. · 5c292e6b
      Tom Lane authored
      This allows use of a "default" expression that doesn't slavishly
      match the data column's type.  Formerly you got something like
      "function lag(numeric, integer, integer) does not exist", which
      is not just unhelpful but actively misleading.
      
      The SQL spec suggests that the default should be coerced to the data
      column's type, but this implementation instead chooses the common
      supertype, which seems at least as reasonable.
      
      (Note: I took the opportunity to run "make reformat-dat-files" on
      pg_proc.dat, so this commit includes some cosmetic changes to
      recently-added entries that aren't related to lead/lag.)
      
      Vik Fearing
      
      Discussion: https://postgr.es/m/77675130-89da-dab1-51dd-492c93dcf5d1@postgresfriends.org
      5c292e6b
    • Tom Lane's avatar
      Improve our ability to regurgitate SQL-syntax function calls. · 40c24bfe
      Tom Lane authored
      The SQL spec calls out nonstandard syntax for certain function calls,
      for example substring() with numeric position info is supposed to be
      spelled "SUBSTRING(string FROM start FOR count)".  We accept many
      of these things, but up to now would not print them in the same format,
      instead simplifying down to "substring"(string, start, count).
      That's long annoyed me because it creates an interoperability
      problem: we're gratuitously injecting Postgres-specific syntax into
      what might otherwise be a perfectly spec-compliant view definition.
      However, the real reason for addressing it right now is to support
      a planned change in the semantics of EXTRACT() a/k/a date_part().
      When we switch that to returning numeric, we'll have the parser
      translate EXTRACT() to some new function name (might as well be
      "extract" if you ask me) and then teach ruleutils.c to reverse-list
      that per SQL spec.  In this way existing calls to date_part() will
      continue to have the old semantics.
      
      To implement this, invent a new CoercionForm value COERCE_SQL_SYNTAX,
      and make the parser insert that rather than COERCE_EXPLICIT_CALL when
      the input has SQL-spec decoration.  (But if the input has the form of
      a plain function call, continue to mark it COERCE_EXPLICIT_CALL, even
      if it's calling one of these functions.)  Then ruleutils.c recognizes
      COERCE_SQL_SYNTAX as a cue to emit SQL call syntax.  It can know
      which decoration to emit using hard-wired knowledge about the
      functions that could be called this way.  (While this solution isn't
      extensible without manual additions, neither is the grammar, so this
      doesn't seem unmaintainable.)  Notice that this solution will
      reverse-list a function call with SQL decoration only if it was
      entered that way; so dump-and-reload will not by itself produce any
      changes in the appearance of views.
      
      This requires adding a CoercionForm field to struct FuncCall.
      (I couldn't resist the temptation to rearrange that struct's
      field order a tad while I was at it.)  FuncCall doesn't appear
      in stored rules, so that change isn't a reason for a catversion
      bump, but I did one anyway because the new enum value for
      CoercionForm fields could confuse old backend code.
      
      Possible future work:
      
      * Perhaps CoercionForm should now be renamed to DisplayForm,
      or something like that, to reflect its more general meaning.
      This'd require touching a couple hundred places, so it's not
      clear it's worth the code churn.
      
      * The SQLValueFunction node type, which was invented partly for
      the same goal of improving SQL-compatibility of view output,
      could perhaps be replaced with regular function calls marked
      with COERCE_SQL_SYNTAX.  It's unclear if this would be a net
      code savings, however.
      
      Discussion: https://postgr.es/m/42b73d2d-da12-ba9f-570a-420e0cce19d9@phystech.edu
      40c24bfe
    • Tom Lane's avatar
      Remove useless entries for aggregate functions from fmgrtab.c. · f21636e5
      Tom Lane authored
      Gen_fmgrtab.pl treated aggregate functions the same as other built-in
      functions, which is wasteful because there is no real need to have
      entries for them in the fmgr_builtins[] table.  Suppressing those
      entries saves about 3KB in the compiled table on my machine; which
      is not a lot but it's not nothing either, considering that that
      table is pretty "hot".  The only outside code change needed is
      that ExecInitWindowAgg() can't be allowed to call fmgr_info_cxt()
      on a plain aggregate function.  But that saves a few cycles anyway.
      
      Having done that, the aggregate_dummy() function is unreferenced
      and might as well be dropped.  Using "aggregate_dummy" as the prosrc
      value for an aggregate is now just a documentation convention not
      something that matters.  There was some discussion of using NULL
      instead to save a few bytes in pg_proc, but we'd have to remove
      prosrc's BKI_FORCE_NOT_NULL marking which doesn't seem a great idea.
      Anyway, it's possible there's client-side code that expects to
      see "aggregate_dummy" there, so I'm loath to change it without a
      strong reason.
      
      Discussion: https://postgr.es/m/533989.1604263665@sss.pgh.pa.us
      f21636e5
    • Fujii Masao's avatar
      Fix segmentation fault that commit ac22929a caused. · 113d3591
      Fujii Masao authored
      Commit ac22929a changed recoveryWakeupLatch so that it's reset to
      NULL at the end of recovery. This change could cause a segmentation fault
      in the buildfarm member 'elver'.
      
      Previously the latch was reset to NULL after calling ShutdownWalRcv().
      But there could be a window between ShutdownWalRcv() and the actual
      exit of walreceiver. If walreceiver set the latch during that window,
      the segmentation fault could happen.
      
      To fix the issue, this commit changes walreceiver so that it sets
      the latch only when the latch has not been reset to NULL yet.
      
      Author: Fujii Masao
      Discussion: https://postgr.es/m/5c1f8a85-747c-7bf9-241e-dd467d8a3586@iki.fi
      113d3591
    • Peter Eisentraut's avatar
      Enable hash partitioning of text arrays · 560564d3
      Peter Eisentraut authored
      hash_array_extended() needs to pass PG_GET_COLLATION() to the hash
      function of the element type.  Otherwise, the hash function of a
      collation-aware data type such as text will error out, since the
      introduction of nondeterministic collation made hash functions require
      a collation, too.
      
      The consequence of this is that before this change, hash partitioning
      using an array over text in the partition key would not work.
      Reviewed-by: default avatarHeikki Linnakangas <hlinnaka@iki.fi>
      Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
      Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
      Discussion: https://www.postgresql.org/message-id/flat/32c1fdae-95c6-5dc6-058a-a90330a3b621%40enterprisedb.com
      560564d3
    • Heikki Linnakangas's avatar
      pg_rewind: Refactor the abstraction to fetch from local/libpq source. · 37d2ff38
      Heikki Linnakangas authored
      This makes the abstraction of a "source" server more clear, by introducing
      a common abstract class, borrowing the object-oriented programming term,
      that represents all the operations that can be done on the source server.
      There are two implementations of it, one for fetching via libpq, and
      another to fetch from a local directory. This adds some code, but makes it
      easier to understand what's going on.
      
      The copy_executeFileMap() and libpq_executeFileMap() functions contained
      basically the same logic, just calling different functions to fetch the
      source files. Refactor so that the common logic is in one place, in a new
      function called perform_rewind().
      
      Reviewed-by: Kyotaro Horiguchi, Soumyadeep Chakraborty
      Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi
      37d2ff38
    • Heikki Linnakangas's avatar
      pg_rewind: Replace the hybrid list+array data structure with simplehash. · f81e97d0
      Heikki Linnakangas authored
      Now that simplehash can be used in frontend code, let's make use of it.
      
      Reviewed-by: Kyotaro Horiguchi, Soumyadeep Chakraborty
      Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi
      f81e97d0
    • Heikki Linnakangas's avatar
      Refactor pg_rewind for more clear decision making. · eb00f1d4
      Heikki Linnakangas authored
      Deciding what to do with each file is now a separate step after all the
      necessary information has been gathered. It is more clear that way.
      Previously, the decision-making was divided between process_source_file()
      and process_target_file(), and it was a bit hard to piece together what
      the overall rules were.
      
      Reviewed-by: Kyotaro Horiguchi, Soumyadeep Chakraborty
      Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi
      eb00f1d4
    • Heikki Linnakangas's avatar
      pg_rewind: Move syncTargetDirectory() to file_ops.c · ffb4e27e
      Heikki Linnakangas authored
      For consistency. All the other low-level functions that operate on the
      target directory are in file_ops.c.
      
      Reviewed-by: Michael Paquier
      Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi
      ffb4e27e
    • Fujii Masao's avatar
      Get rid of the dedicated latch for signaling the startup process. · ac22929a
      Fujii Masao authored
      This commit gets rid of the dedicated latch for signaling the startup
      process in favor of using its procLatch,  since that comports better
      with possible generic signal handlers using that latch.
      
      Commit 1e53fe0e changed background processes so that they use standard
      SIGHUP handler. Like that, this commit also makes the startup process use
      standard SIGHUP handler to simplify the code.
      
      Author: Fujii Masao
      Reviewed-by: Bharath Rupireddy, Michael Paquier
      Discussion: https://postgr.es/m/CALj2ACXPorUqePswDtOeM_s82v9RW32E1fYmOPZ5NuE+TWKj_A@mail.gmail.com
      ac22929a
    • Fujii Masao's avatar
      Use standard SIGHUP handler in syslogger. · 02d33229
      Fujii Masao authored
      Commit 1e53fe0e changed background processes so that they use
      standard SIGHUP handler. Like that, this commit makes syslogger use
      standard SIGHUP handler to simplify the code.
      
      Author: Bharath Rupireddy
      Reviewed-by: Fujii Masao
      Discussion: https://postgr.es/m/CALj2ACXPorUqePswDtOeM_s82v9RW32E1fYmOPZ5NuE+TWKj_A@mail.gmail.com
      02d33229
    • Thomas Munro's avatar
      Tolerate version lookup failure for old style Windows locale names. · 9f12a3b9
      Thomas Munro authored
      Accept that we can't get versions for such locale names for now.  Users
      will need to specify the newer language tag format to enable the
      collation versioning feature.  It's not clear that we can do automatic
      conversion from the old style to the new style reliably enough for this
      purpose.
      
      Unfortunately, this means that collation versioning probably won't work
      for the default collation unless you provide something like en-US at
      initdb or CREATE DATABASE time (though, for reasons not yet understood,
      it does seem to work on some systems).  It'd be nice to find a better
      solution, or document this quirk if we settle on it, but this should
      unbreak the 3 failing build farm animals in the meantime.
      Reviewed-by: default avatarDavid Rowley <dgrowleyml@gmail.com>
      Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
      Discussion: https://postgr.es/m/CAEepm%3D0uEQCpfq_%2BLYFBdArCe4Ot98t1aR4eYiYTe%3DyavQygiQ%40mail.gmail.com
      9f12a3b9
    • Michael Paquier's avatar
      Revert pg_relation_check_pages() · e152506a
      Michael Paquier authored
      This reverts the following set of commits, following complaints about
      the lack of portability of the central part of the code in bufmgr.c as
      well as the use of partition mapping locks during page reads:
      c780a7a9
      f2b88396
      b787d4ce
      ce7f772c
      60a51c6b
      
      Per discussion with Andres Freund, Robert Haas and myself.
      
      Bump catalog version.
      
      Discussion: https://postgr.es/m/20201029181729.2nrub47u7yqncsv7@alap3.anarazel.de
      e152506a
  2. 03 Nov, 2020 13 commits
  3. 02 Nov, 2020 12 commits