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

mysql command line tool provides useless error messages

    XMLWordPrintable

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Incomplete
    • N/A
    • None
    • None

    Description

      I'm a SQL novice, but I have about 20 years of C/C++ experience. I also understand SQL language is standardized by ANSI and some other organizations.

      The following SQL file:

      SET @DB_DATABASE_NAME = "test_db";
      SET @DB_TABLE_NUMBERS = "name_number";
       
      DROP DATABASE IF EXISTS @DB_DATABASE_NAME;
      CREATE DATABASE IF NOT EXISTS @DB_DATABASE_NAME;
      USE @DB_DATABASE_NAME;
       
      CREATE TABLE IF NOT EXISTS @DB_TABLE_NUMBERS
      (
      	`nn_id` INT PRIMARY KEY AUTO_INCREMENT,
      	`nn_name` VARCHAR(64) CHARACTER SET utf8,
      	`nn_number` VARCHAR(18) CHARACTER SET utf8
      );
      

      Results in:

      $ mysql -v -uroot -pMMGhbfb8sFYYbJCh < test.sql
      --------------
      SET @DB_DATABASE_NAME = "test_db"
      --------------
       
      --------------
      SET @DB_TABLE_NUMBERS = "name_number"
      --------------
       
      --------------
      DROP DATABASE IF EXISTS @DB_DATABASE_NAME
      --------------
       
      ERROR 1064 (42000) at line 4: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@DB_DATABASE_NAME' at line 1
      

      Searching for ERROR 1064 (42000) is producing irrelevant hits. And reading the mysql(1) man page is equally useless (https://linux.die.net/man/1/mysql). I still have not figured out how to get the tool to print a useful error message, let alone help me diagnose the problem.

      After asking on Unix & Linux Stack Exchange I learned MySQL does not use variables as expected (https://unix.stackexchange.com/q/501694/56041). What genius thought that was a good idea...

      Looking around the web for MySQL error messages has shown me that thousands of man hours are wasted because of the useless MySQL error messages. Telling someone to look in the SQL manual is absolutely useless. This is from experience after spending two days reading mysql(1) looking for clues.

      Here's the MySQL report, but it was kicked back to MariaDB because that is what I am using: https://bugs.mysql.com/bug.php?id=94398 .

      Please provide helpful error messages.

      Attachments

        Activity

          People

            Unassigned Unassigned
            noloader Jeffrey Walton
            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.