Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-23001

Precreate static Item_bool() to simplify code

    XMLWordPrintable

Details

    Description

      cd sql
      grep new.*Item_bool *c
      shows that we have 14 cases of code like:

      conds= new (thd->mem_root) Item_bool(thd, true); // Always true

      We also have a few cases like this that should also be replaced (Search for Item_int that is set to a value of 0 or 1):
      Item *false_cond= new (thd->mem_root) Item_int(thd, (longlong) 0, 1);

      Instead of creating these on the fly, it would be better to have two static Item_bool variables (one true and one false), created statically or at startup, that we could use everywhere. This would make the code smaller and faster

      Proposed code in item.cc:

      Item_bool_static Item_false("FALSE", 0);
      Item_bool_static Item_true("TRUE", 1);

      The main difference between the above and a normal item is that the above would not take THD as an argument and thus the Item's should not be put on the item list in THD.
      One would have to fix the related item, like item_num, to handle the case where the required THD is NULL.
      Note that the above items should be marked as 'fixed' from the start in the constructor

      Suggestion how to start:

      • Create the items in item.cc
      • Add a constructor based on Item_bool in item.h
      • Get it to compile
      • Test with one test case, like "mtr main.alias" , to see that the items are created properly.
      • Replace items found by the 'grep' above with the new items.
      • Get it to compile
      • Run test suite

      Attachments

        Activity

          People

            monty Michael Widenius
            monty Michael Widenius
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.