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

PARSER - new sql function

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Implement some new functions (maybe UDF),

      1)return a JSON object with token tree of SQL parser, example

      SELECT SQL_TOKEN_TREE(
      "SELECT * FROM (SELECT 1 AS a) AS b WHERE a=@var"
      )

      Result

      {Query:[select, *, from, [select, var<1>, as, const<a>], as, const<b>, where, var<2>, =, var<3>], vars:{1:'1', 2:'a',3:'@var','@var':'qwert'}}

      Or something more intelligent since i don't know how mysql parser works

      2)SQL_TOKEN_SQL(sql tree)
      Result a string removing consts with a willchar (like prepared statments)

      SELECT * FROM TABLE WHERE A=1234

      should return

      SELECT * FROM TABLE WHERE A=?

      this is something like percona tools, but it run inside server with server parse and not a third part parser:

      $pt-fingerprint --query "/* -- S++ SU ABORTABLE -- spd_user: rspadim */SELECT SQL_SMALL_RESULT SQL_CACHE DISTINCT centro_atividade FROM est_dia WHERE unidade_id=1001 AND item_id=67 AND item_id_red=573"
       
      SELECT DISTINCT centro_atividade FROM est_dia WHERE unidade_id=? AND item_id=? AND item_id_red=?

      3)Add a SQL_PARSER_OPTIMIZE(QUERY)
      it parse the query and execute optimizations (opt_range and others)
      example

      SELECT * FROM TABLE WHERE A=1234 AND 0=0

      rewrite to

      SELECT * FROM TABLE WHERE A=1234

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              rspadim roberto spadim
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:

                  Git Integration

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