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

Unable to specify escape character for FMT

    XMLWordPrintable

Details

    Description

      The request path in the 2nd line of the following sample has a trailing quotation mark, which is escaped with a backslash:

      imusic.dk:80 5.255.253.131 - - [20/Jul/2014:10:47:25 +0200] "GET /image.php?id=2090503593091&type=thumbnail HTTP/1.1" 302 266 "-" "Mozilla/5.0 (compatible; YandexImages/3.0; +http://yandex.com/bots)"
      imusic.dk:80 157.55.39.105 - - [20/Jul/2014:10:47:25 +0200] "GET /cd/5053105444328/christoffer-hoeyer-2012-silent-songs-about-things-that-don-t-happen-cd\" HTTP/1.1" 301 335 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"

      Here's a CREATE string to query the log data using the CONNECT engine:

      CREATE TABLE access_logs (
        server_name CHAR(30)          NOT NULL FIELD_FORMAT = ' %n%s%n',
        remote_host CHAR(15)          NOT NULL FIELD_FORMAT = ' %n%s%n',
        time        DATETIME          NOT NULL FIELD_FORMAT = ' - - [%n%s%n +0200]' 
          DATE_FORMAT = 'DD/MMM/YYYY:hh:mm:ss',
        request     VARCHAR(16384)    NOT NULL FIELD_FORMAT = ' "%n%[^"]%n"',
        status      SMALLINT UNSIGNED NOT NULL FIELD_FORMAT = ' %n%d%n',
        bytes_sent  INT UNSIGNED      NOT NULL FIELD_FORMAT = ' %n%d%n',
        referer     VARCHAR(16384)    NOT NULL FIELD_FORMAT = ' "%n%[^"]%m',
        user_agent  VARCHAR(512)      NOT NULL FIELD_FORMAT = '" "%n%[^"]%n"'
      )
        ENGINE = CONNECT
        TABLE_TYPE = FMT
        FILE_NAME = '/tmp/text.txt';

      Querying the first line works well:

      MariaDB [test]> SELECT * FROM access_logs LIMIT 1;
      +--------------+---------------+---------------------+---------------------------------------------------------+--------+------------+---------+---------------------------------------------------------------------+
      | server_name  | remote_host   | time                | request                                                 | status | bytes_sent | referer | user_agent                                                          |
      +--------------+---------------+---------------------+---------------------------------------------------------+--------+------------+---------+---------------------------------------------------------------------+
      | imusic.dk:80 | 5.255.253.131 | 2014-07-20 10:47:02 | GET /image.php?id=2090503593091&type=thumbnail HTTP/1.1 |    302 |        266 | -       | Mozilla/5.0 (compatible; YandexImages/3.0; +http://yandex.com/bots) |
      +--------------+---------------+---------------------+---------------------------------------------------------+--------+------------+---------+---------------------------------------------------------------------+
      1 row in set, 1 warning (0.01 sec)

      For the second line, I get an error:

      MariaDB [test]> SELECT * FROM access_logs LIMIT 2 OFFSET 1;
      ERROR 1296 (HY000): Got error 122 'Bad format line 2 field 5 of access_logs' from CONNECT

      I suppose the engine chokes on the escaped quotation mark (\"), and assume that this case requires the ability to specify an escape character (which in turn might prove troublesome, in case the parsing is sscanf-based).

      Attachments

        Activity

          People

            bertrandop Olivier Bertrand
            crishoj Christian Rishøj
            Votes:
            0 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.