Re: WIP: Faster Expression Processing v4

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Date: 2017-03-14T01:11:04Z
Lists: pgsql-hackers
Hi,

On 2017-03-13 01:03:51 -0700, Andres Freund wrote:
> What's basically missing here is:
> - pgindent run and minimizing resulting damage

Running into a bit of an issue here - pgindent mangles something like

    EEO_SWITCH (op->opcode)
    {
        EEO_CASE(EEO_DONE):
            goto out;

        EEO_CASE(EEO_INNER_FETCHSOME):
            /* XXX: worthwhile to check tts_nvalid inline first? */
            slot_getsomeattrs(innerslot, op->d.fetch.last_var);
            EEO_DISPATCH(op);

        EEO_CASE(EEO_OUTER_FETCHSOME):
            slot_getsomeattrs(outerslot, op->d.fetch.last_var);
            EEO_DISPATCH(op);

        EEO_CASE(EEO_SCAN_FETCHSOME):
            slot_getsomeattrs(scanslot, op->d.fetch.last_var);
            EEO_DISPATCH(op);

        EEO_CASE(EEO_INNER_VAR):
            {
                int attnum = op->d.var.attnum;

                /*
                 * Can't assert tts_nvalid, as wholerow var evaluation or such
                 * could have materialized the slot - but the contents are
                 * still valid :/
                 */
                Assert(op->d.var.attnum >= 0);
                *op->resnull = innerslot->tts_isnull[attnum];
                *op->resvalue = innerslot->tts_values[attnum];
                EEO_DISPATCH(op);
            }

into

    EEO_SWITCH(op->opcode)
    {
EEO_CASE(EEO_DONE):
        goto out;

EEO_CASE(EEO_INNER_FETCHSOME):
        /* XXX: worthwhile to check tts_nvalid inline first? */
        slot_getsomeattrs(innerslot, op->d.fetch.last_var);
        EEO_DISPATCH(op);

EEO_CASE(EEO_OUTER_FETCHSOME):
        slot_getsomeattrs(outerslot, op->d.fetch.last_var);
        EEO_DISPATCH(op);

EEO_CASE(EEO_SCAN_FETCHSOME):
        slot_getsomeattrs(scanslot, op->d.fetch.last_var);
        EEO_DISPATCH(op);

EEO_CASE(EEO_INNER_VAR):
        {
            int         attnum = op->d.var.attnum;

            /*
             * Can't assert tts_nvalid, as wholerow var evaluation or such
             * could have materialized the slot - but the contents are still
             * valid :/
             */
            Assert(op->d.var.attnum >= 0);
            *op->resnull = innerslot->tts_isnull[attnum];
            *op->resvalue = innerslot->tts_values[attnum];
            EEO_DISPATCH(op);
        }


which is a bit annoying.  (the EEO_CASE is either a jump label or a case
statement, depending on computed goto availability).

It seems we could either:
1) live with the damage
2) disable pgindent
3) move the : inside EEO_CASE's definition, and only use {} blocks.

I'm inclined to go for 3).

Opinions?

- Andres


Commits

  1. Improve performance of ExecEvalWholeRowVar.

  2. Remove unreachable code in expression evaluation.

  3. Faster expression evaluation and targetlist projection.

  4. Avoid syntax error on platforms that have neither LOCALE_T nor ICU.

  5. Add configure test to see if the C compiler has gcc-style computed gotos.

  6. Improve regression test coverage for TID scanning.

  7. Improve expression evaluation test coverage.

  8. Fix two errors with nested CASE/WHEN constructs.