Thread

  1. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Noah Misch <noah@leadboat.com> — 2012-01-22T05:23:55Z

    New version that repairs a defective test case.
    
  2. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Robert Haas <robertmhaas@gmail.com> — 2012-01-25T20:32:49Z

    On Sun, Jan 22, 2012 at 12:23 AM, Noah Misch <noah@leadboat.com> wrote:
    > New version that repairs a defective test case.
    
    Committed.  I don't find this to be particularly good style:
    
    +       for (i = 0; i < old_natts && ret; i++)
    +               ret = (!IsPolymorphicType(get_opclass_input_type(classObjectId[i
    +                          irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
    
    ...but I am not sure whether we have any formal policy against it, so
    I just committed it as-is for now.  I would have surrounded the loop
    with an if (ret) block and written the body of the loop as if
    (condition) { ret = false; break; }.
    
    -- 
    Robert Haas
    EnterpriseDB: http://www.enterprisedb.com
    The Enterprise PostgreSQL Company
    
    
  3. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Alvaro Herrera <alvherre@commandprompt.com> — 2012-01-25T20:52:59Z

    Excerpts from Robert Haas's message of mié ene 25 17:32:49 -0300 2012:
    > On Sun, Jan 22, 2012 at 12:23 AM, Noah Misch <noah@leadboat.com> wrote:
    > > New version that repairs a defective test case.
    > 
    > Committed.  I don't find this to be particularly good style:
    > 
    > +       for (i = 0; i < old_natts && ret; i++)
    > +               ret = (!IsPolymorphicType(get_opclass_input_type(classObjectId[i
    > +                          irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
    > 
    > ...but I am not sure whether we have any formal policy against it, so
    > I just committed it as-is for now.  I would have surrounded the loop
    > with an if (ret) block and written the body of the loop as if
    > (condition) { ret = false; break; }.
    
    I find that code way too clever.
    
    -- 
    Álvaro Herrera <alvherre@commandprompt.com>
    The PostgreSQL Company - Command Prompt, Inc.
    PostgreSQL Replication, Consulting, Custom Development, 24x7 support
    
    
  4. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Robert Haas <robertmhaas@gmail.com> — 2012-01-25T22:05:44Z

    On Wed, Jan 25, 2012 at 3:52 PM, Alvaro Herrera
    <alvherre@commandprompt.com> wrote:
    >
    > Excerpts from Robert Haas's message of mié ene 25 17:32:49 -0300 2012:
    >> On Sun, Jan 22, 2012 at 12:23 AM, Noah Misch <noah@leadboat.com> wrote:
    >> > New version that repairs a defective test case.
    >>
    >> Committed.  I don't find this to be particularly good style:
    >>
    >> +       for (i = 0; i < old_natts && ret; i++)
    >> +               ret = (!IsPolymorphicType(get_opclass_input_type(classObjectId[i
    >> +                          irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
    >>
    >> ...but I am not sure whether we have any formal policy against it, so
    >> I just committed it as-is for now.  I would have surrounded the loop
    >> with an if (ret) block and written the body of the loop as if
    >> (condition) { ret = false; break; }.
    >
    > I find that code way too clever.
    
    The way he wrote it, or the way I proposed to write it?
    
    -- 
    Robert Haas
    EnterpriseDB: http://www.enterprisedb.com
    The Enterprise PostgreSQL Company
    
    
  5. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Alvaro Herrera <alvherre@commandprompt.com> — 2012-01-25T22:45:15Z

    Excerpts from Robert Haas's message of mié ene 25 19:05:44 -0300 2012:
    > 
    > On Wed, Jan 25, 2012 at 3:52 PM, Alvaro Herrera
    > <alvherre@commandprompt.com> wrote:
    > >
    > > Excerpts from Robert Haas's message of mié ene 25 17:32:49 -0300 2012:
    > >> On Sun, Jan 22, 2012 at 12:23 AM, Noah Misch <noah@leadboat.com> wrote:
    > >> > New version that repairs a defective test case.
    > >>
    > >> Committed.  I don't find this to be particularly good style:
    > >>
    > >> +       for (i = 0; i < old_natts && ret; i++)
    > >> +               ret = (!IsPolymorphicType(get_opclass_input_type(classObjectId[i
    > >> +                          irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
    > >>
    > >> ...but I am not sure whether we have any formal policy against it, so
    > >> I just committed it as-is for now.  I would have surrounded the loop
    > >> with an if (ret) block and written the body of the loop as if
    > >> (condition) { ret = false; break; }.
    > >
    > > I find that code way too clever.
    > 
    > The way he wrote it, or the way I proposed to write it?
    
    The code as committed.
    
    -- 
    Álvaro Herrera <alvherre@commandprompt.com>
    The PostgreSQL Company - Command Prompt, Inc.
    PostgreSQL Replication, Consulting, Custom Development, 24x7 support
    
    
  6. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Noah Misch <noah@leadboat.com> — 2012-01-26T02:51:13Z

    On Wed, Jan 25, 2012 at 03:32:49PM -0500, Robert Haas wrote:
    > On Sun, Jan 22, 2012 at 12:23 AM, Noah Misch <noah@leadboat.com> wrote:
    > > New version that repairs a defective test case.
    > 
    > Committed.  I don't find this to be particularly good style:
    
    Thanks.
    
    > +       for (i = 0; i < old_natts && ret; i++)
    > +               ret = (!IsPolymorphicType(get_opclass_input_type(classObjectId[i
    > +                          irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
    > 
    > ...but I am not sure whether we have any formal policy against it, so
    > I just committed it as-is for now.  I would have surrounded the loop
    > with an if (ret) block and written the body of the loop as if
    > (condition) { ret = false; break; }.
    
    I value the savings in vertical space more than the lost idiomaticness.  This
    decision is 90+% subjective, so I cannot blame you for concluding otherwise.
    I do know the feeling of looking at PostgreSQL source code and wishing the
    author had not attempted to conserve every line.
    
    
  7. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Tom Lane <tgl@sss.pgh.pa.us> — 2012-01-26T04:53:10Z

    Alvaro Herrera <alvherre@commandprompt.com> writes:
    > Excerpts from Robert Haas's message of mi ene 25 17:32:49 -0300 2012:
    >> On Sun, Jan 22, 2012 at 12:23 AM, Noah Misch <noah@leadboat.com> wrote:
    > New version that repairs a defective test case.
    >> 
    >> Committed.  I don't find this to be particularly good style:
    >> 
    >> +       for (i = 0; i < old_natts && ret; i++)
    >> +               ret = (!IsPolymorphicType(get_opclass_input_type(classObjectId[i
    >> +                          irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
    >> 
    >> ...but I am not sure whether we have any formal policy against it, so
    >> I just committed it as-is for now.  I would have surrounded the loop
    >> with an if (ret) block and written the body of the loop as if
    >> (condition) { ret = false; break; }.
    
    > I find that code way too clever.
    
    Not only is that code spectacularly unreadable, but has nobody noticed
    that this commit broke the buildfarm?
    
    			regards, tom lane
    
    
  8. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Noah Misch <noah@leadboat.com> — 2012-01-26T11:55:36Z

    On Wed, Jan 25, 2012 at 11:53:10PM -0500, Tom Lane wrote:
    > Not only is that code spectacularly unreadable, but has nobody noticed
    > that this commit broke the buildfarm?
    
    Thanks for reporting the problem.  This arose because the new test case
    temporarily sets client_min_messages=DEBUG1.  The default buildfarm
    configuration sets log_statement=all in its postgresql.conf, so the client
    gets those log_statement lines.  I would fix this as attached, resetting the
    optional logging to defaults during the test cases in question.  Not
    delightful, but that's what we have to work with.
    
    nm
    
  9. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Robert Haas <robertmhaas@gmail.com> — 2012-01-26T13:23:34Z

    On Thu, Jan 26, 2012 at 6:55 AM, Noah Misch <noah@leadboat.com> wrote:
    > On Wed, Jan 25, 2012 at 11:53:10PM -0500, Tom Lane wrote:
    >> Not only is that code spectacularly unreadable, but has nobody noticed
    >> that this commit broke the buildfarm?
    >
    > Thanks for reporting the problem.  This arose because the new test case
    > temporarily sets client_min_messages=DEBUG1.  The default buildfarm
    > configuration sets log_statement=all in its postgresql.conf, so the client
    > gets those log_statement lines.  I would fix this as attached, resetting the
    > optional logging to defaults during the test cases in question.  Not
    > delightful, but that's what we have to work with.
    
    I'm just going to remove the test.  This is not very future-proof and
    an ugly pattern if it gets copied to other places.  We need to work on
    a more sensible way for ALTER TABLE to report what it did, but a
    solution based on what GUCs the build-farm happens to set doesn't seem
    like it's justified for the narrowness of the case we're testing here.
     Whether or not we allow this case to work without a rewrite is in
    some sense arbitrary. There's no real reason it can't be done; rather,
    we're just exercising restraint to minimize the risk of future bugs.
    So I don't want to go to great lengths to test it.
    
    -- 
    Robert Haas
    EnterpriseDB: http://www.enterprisedb.com
    The Enterprise PostgreSQL Company
    
    
  10. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Noah Misch <noah@leadboat.com> — 2012-01-28T21:25:06Z

    On Thu, Jan 26, 2012 at 08:23:34AM -0500, Robert Haas wrote:
    > On Thu, Jan 26, 2012 at 6:55 AM, Noah Misch <noah@leadboat.com> wrote:
    > > On Wed, Jan 25, 2012 at 11:53:10PM -0500, Tom Lane wrote:
    > >> Not only is that code spectacularly unreadable, but has nobody noticed
    > >> that this commit broke the buildfarm?
    > >
    > > Thanks for reporting the problem. ?This arose because the new test case
    > > temporarily sets client_min_messages=DEBUG1. ?The default buildfarm
    > > configuration sets log_statement=all in its postgresql.conf, so the client
    > > gets those log_statement lines. ?I would fix this as attached, resetting the
    > > optional logging to defaults during the test cases in question. ?Not
    > > delightful, but that's what we have to work with.
    > 
    > I'm just going to remove the test.  This is not very future-proof and
    
    It would deserve an update whenever we add a new optional-logging GUC
    pertaining to user backends.  Other tests require similarly-infrequent
    refreshes in response to other changes.  Of course, buildfarm members would
    not be setting those new GUCs the day they're available.  Calling for an
    update to the test could reasonably fall to the first buildfarm member owner
    who actually decides to use a new GUC in his configuration.
    
    > an ugly pattern if it gets copied to other places.  We need to work on
    
    I would rather folks introduce ugliness to the test suite than introduce
    behaviors having no test coverage.
    
    > a more sensible way for ALTER TABLE to report what it did, but a
    > solution based on what GUCs the build-farm happens to set doesn't seem
    > like it's justified for the narrowness of the case we're testing here.
    
    It's not based on what GUCs the buildfarm happens to set.  I looked up all
    GUCs that might create problems such as the one observed here.  They were the
    four I included in the patch, plus debug_pretty_print, debug_print_parse,
    debug_print_plan and debug_print_rewritten.  I concluded that the four debug_*
    ones were materially less likely to ever get set in postgresql.conf for a
    "make installcheck" run, so I left them out for brevity.
    
    The setting changed *by default* for buildfarm clients is log_statement.
    Buildfarm member owners can do as they wish, though.
    
    >  Whether or not we allow this case to work without a rewrite is in
    > some sense arbitrary. There's no real reason it can't be done; rather,
    > we're just exercising restraint to minimize the risk of future bugs.
    > So I don't want to go to great lengths to test it.
    
    I used the same strategy in another ALTER TABLE patch this CF:
    http://archives.postgresql.org/message-id/20120126033956.GC15670@tornado.leadboat.com
    If we pay its costs for those tests, we then may as well let this test case
    ride their coattails.
    
    
  11. Re: Second thoughts on CheckIndexCompatible() vs. operator families

    Tom Lane <tgl@sss.pgh.pa.us> — 2012-01-28T23:05:41Z

    Noah Misch <noah@leadboat.com> writes:
    > On Thu, Jan 26, 2012 at 08:23:34AM -0500, Robert Haas wrote:
    >> I'm just going to remove the test.  This is not very future-proof and
    
    > [ objections ]
    
    FWIW, I concur with Robert's choice here.  This test method is ugly and
    fragile, and I'm not even thinking about the question of whether an
    installation might have GUC settings that affect it.  My objection is
    that you're assuming that nowhere else, anywhere in the large amount of
    code executed by the queries under test, will anyone ever wish to insert
    another elog(DEBUG) message.
    
    > I used the same strategy in another ALTER TABLE patch this CF:
    > http://archives.postgresql.org/message-id/20120126033956.GC15670@tornado.leadboat.com
    
    That's going to need to be removed before commit too, then.
    
    			regards, tom lane