Thread

Commits

  1. Mark multirange_constructor0() and multirange_constructor2() strict

  1. multirange constructor strictness

    Peter Eisentraut <peter.eisentraut@enterprisedb.com> — 2021-04-21T20:56:54Z

    The multirange constructors created in makeMultirangeConstructors() are:
    
    multirange_constructor0 -> not strict
    multirange_constructor1 -> strict
    multirange_constructor2 -> not strict
    
    And both multirange_constructor1 and multirange_constructor2 contain 
    code like
    
    /*
      * These checks should be guaranteed by our signature, but let's do them
      * just in case.
      */
    if (PG_ARGISNULL(0))
         ereport(ERROR,
                 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
                  errmsg("multirange values cannot contain NULL members")));
    
    In case of multirange_constructor2 the "should be guaranteed" comment is 
    not actually true right now.  In case of multirange_constructor1, maybe 
    this should be downgraded to an elog or assert or just removed.
    
    Is there a reason why we can't make them all three strict or all not 
    strict?  (Obviously, it doesn't matter for multirange_constructor0.)  Is 
    the fact that multirange_constructor2 is variadic the issue?  Maybe at 
    least some more comments would be helpful.
    
    
    
    
  2. Re: multirange constructor strictness

    Alexander Korotkov <aekorotkov@gmail.com> — 2021-04-22T11:00:38Z

    On Wed, Apr 21, 2021 at 11:57 PM Peter Eisentraut
    <peter.eisentraut@enterprisedb.com> wrote:
    > The multirange constructors created in makeMultirangeConstructors() are:
    >
    > multirange_constructor0 -> not strict
    > multirange_constructor1 -> strict
    > multirange_constructor2 -> not strict
    >
    > And both multirange_constructor1 and multirange_constructor2 contain
    > code like
    >
    > /*
    >   * These checks should be guaranteed by our signature, but let's do them
    >   * just in case.
    >   */
    > if (PG_ARGISNULL(0))
    >      ereport(ERROR,
    >              (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
    >               errmsg("multirange values cannot contain NULL members")));
    >
    > In case of multirange_constructor2 the "should be guaranteed" comment is
    > not actually true right now.  In case of multirange_constructor1, maybe
    > this should be downgraded to an elog or assert or just removed.
    >
    > Is there a reason why we can't make them all three strict or all not
    > strict?  (Obviously, it doesn't matter for multirange_constructor0.)  Is
    > the fact that multirange_constructor2 is variadic the issue?  Maybe at
    > least some more comments would be helpful.
    
    Thank you for noticing.  I'll take care of it today.
    
    ------
    Regards,
    Alexander Korotkov