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

CTE statement causes "Table doesn't exist in engine" error

    XMLWordPrintable

Details

    • Bug
    • Status: Needs Feedback (View Workflow)
    • Major
    • Resolution: Unresolved
    • 12.0.2
    • None
    • None

    Description

      On MariaDB 12.0.2 CTE causes table doesn't exist in engine error. This only happens, if database's name is in camelCase. On testdb statement works fine, but on testDB it causes an error.

      Tested on macOS 26.

      Following is a statement to reproduce the error:

      CREATE TABLE deviceEvents (
      	id INT AUTO_INCREMENT PRIMARY KEY,
      	deviceID INT NOT NULL,
      	event JSON NOT NULL,
      	occurredAt DATETIME NOT NULL
      );
       
      INSERT INTO deviceEvents (deviceID, event, occurredAt) VALUES
      (101, '{"type": "login", "user": "admin", "status": "success"}', NOW() - INTERVAL 55 MINUTE),
      (102, '{"type": "data_sync", "records_synced": 152, "source": "cloud", "temperature": 35.5}', NOW() - INTERVAL 50 MINUTE),
      (103, '{"type": "status_report", "battery_level": 85, "signal_strength": "good", "temperature": 32.1}', NOW() - INTERVAL 45 MINUTE),
      (101, '{"type": "settings_change", "setting": "brightness", "value": 75}', NOW() - INTERVAL 40 MINUTE),
      (102, '{"type": "error", "code": "E-802", "message": "Device overheating", "temperature": 85.5}', NOW() - INTERVAL 35 MINUTE),
      (104, '{"type": "login", "user": "guest", "status": "success"}', NOW() - INTERVAL 30 MINUTE),
      (101, '{"type": "data_sync", "records_synced": 34, "source": "local", "temperature": 38.0}', NOW() - INTERVAL 25 MINUTE),
      (103, '{"type": "low_battery_warning", "battery_level": 15, "temperature": 29.5}', NOW() - INTERVAL 20 MINUTE),
      (102, '{"type": "temperature_reading", "value": 33.7, "unit": "Celsius"}', NOW() - INTERVAL 15 MINUTE),
      (101, '{"type": "logout", "user": "admin"}', NOW() - INTERVAL 10 MINUTE);
       
       
       
      WITH RankedEvents AS (
        SELECT
          occurredAt,
          event,
          -- This is the window function that does the magic
          ROW_NUMBER() OVER (
            PARTITION BY DATE(occurredAt), HOUR(occurredAt) 
            ORDER BY occurredAt ASC
          ) as row_num
        FROM
          deviceEvents
        WHERE
          deviceID = 5 AND
          JSON_EXTRACT(event, '$.temperature') IS NOT NULL
      )
      SELECT
        occurredAt,
        JSON_EXTRACT(event, '$.temperature') as temperature
      FROM
        RankedEvents
      WHERE
        row_num = 1
      ORDER BY
        occurredAt ASC;
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            Mörökölli Markus Metsäranta
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.