Details

      Description

      MDEV-6697 introduced a bunch of new warning messages, many of which are totally confusing. No matter how hard I try, I cannot understand what they mean, it's very frustrating.

      create table t1(a int not null primary key, b int, key(b)) engine=innodb;
      alter table t1 add foreign key(a,b) references t1(a);
      
      Warning	150	Alter  table `test`.`t1` with foreign key constraint failed. Foreign key constraint parse error in foreign key(a,b) references t1(a) close to ). Too few referenced columns, you have 1 when you should have 2.
      

      What close to what? What does the right bracket relate to?
      Error in foreign key? Error in references?

      create table t1(a int not null primary key, b int, key(b)) engine=innodb;
      alter table t1 add foreign key(a) references t1(a,b);
      
      | Warning |  150 | Alter  table `test`.`t1` with foreign key constraint failed. Foreign key constraint parse error in foreign key(a) references t1(a,b) close to ). Too few referenced columns, you have 2 when you should have 1. |
      

      How can it be too few if I have more than I should have?

      create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb;
      ...
      | Warning |  150 | Create  table `tmp`.`t2` with foreign key constraint failed. Referenced table `tmp`.`t1` not found in the data dictionary close to foreign key(a) references t1(a)) engine=innodb. |
      

      Again, what close to what? Data dictionary to foreign keys? Referenced table to foreign keys?
      And I never referenced `tmp`.`t1` – yes, I can guess why it appeared there, but it's still wrong.

      ...

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            jplindst Jan Lindström added a comment -

            Hi, I see, if you have suggestions on how to make these more readable that would be more than welcomed. Messages like near xxxx, mean that parser has found something unexpected starting on that string, it could be or not be the exactly the correct place where something is wrong.

            Show
            jplindst Jan Lindström added a comment - Hi, I see, if you have suggestions on how to make these more readable that would be more than welcomed. Messages like near xxxx, mean that parser has found something unexpected starting on that string, it could be or not be the exactly the correct place where something is wrong.
            Hide
            elenst Elena Stepanova added a comment -

            Regarding the "close to XXXX" part, why not make it look the same as the old "error in SQL syntax", which people are used to:

            create table t1 (i int) unknown clause;
            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 'unknown clause' at line 1
            

            It's very similar, the important difference here is that the beginning of the part which could not be parsed is given in quote marks, so it's very clear that it actually quotes the original statement; "near" instead of "close to" is somewhat less important, it's just the matter of fast recognizing of familiar patterns in the message. I vote for "near".

            So, looking at the message

            Alter  table `test`.`t1` with foreign key constraint failed. Foreign key constraint parse error in foreign key(a,b) references t1(a) close to ). Too few referenced columns, you have 1 when you should have 2.
            

            First, it says twice "foreign key constraint", there is no need for that. Either

            Alter  table `test`.`t1` failed. Foreign key constraint parse error in ...
            

            or

            Alter  table `test`.`t1` with foreign key constraint failed. Parse error in ...
            

            would be more readable.

            Secondly, both quoted "in" and "close to" parts should be in quote marks.

            So, for the first example, if it were

            Alter  table `test`.`t1` with foreign key constraint failed. Parse error in 'foreign key(a,b) references t1(a)' near ')'. Too few referenced columns, you have 1 when you should have 2.
            

            it would have been much clearer, even though it looks very similar.
            For example, I with all honesty thought that the closing bracket after "close to" was a malformed message, it never occurred to me that it was just quoting the place when parsing went wrong.

            The second message in the description is plain wrong, I suspect copy-paste. "close to" (or "near") should apparently point at the comma, not at the closing bracket, and "you have 2 when you should have 1" should be backwards.

            The third message is still weird.

            Create  table `tmp`.`t2` with foreign key constraint failed. Referenced table `tmp`.`t1` not found in the data dictionary close to foreign key(a) references t1(a)) engine=innodb.
            

            I still don't like it that it claims that `tmp`.`t1` was referenced; and the "close to" part also points at the wrong place, it should be "close to 't1(a)'"; or, if you can't point at the exact place here, it should be "in 'foreign key(a) references t1(a))'", without the "close to" part.

            Show
            elenst Elena Stepanova added a comment - Regarding the "close to XXXX" part, why not make it look the same as the old "error in SQL syntax", which people are used to: create table t1 (i int ) unknown clause; 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 'unknown clause' at line 1 It's very similar, the important difference here is that the beginning of the part which could not be parsed is given in quote marks, so it's very clear that it actually quotes the original statement; "near" instead of "close to" is somewhat less important, it's just the matter of fast recognizing of familiar patterns in the message. I vote for "near". So, looking at the message Alter table `test`.`t1` with foreign key constraint failed. Foreign key constraint parse error in foreign key(a,b) references t1(a) close to ). Too few referenced columns, you have 1 when you should have 2. First, it says twice "foreign key constraint", there is no need for that. Either Alter table `test`.`t1` failed. Foreign key constraint parse error in ... or Alter table `test`.`t1` with foreign key constraint failed. Parse error in ... would be more readable. Secondly, both quoted "in" and "close to" parts should be in quote marks. So, for the first example, if it were Alter table `test`.`t1` with foreign key constraint failed. Parse error in 'foreign key(a,b) references t1(a)' near ')'. Too few referenced columns, you have 1 when you should have 2. it would have been much clearer, even though it looks very similar. For example, I with all honesty thought that the closing bracket after "close to" was a malformed message, it never occurred to me that it was just quoting the place when parsing went wrong. The second message in the description is plain wrong, I suspect copy-paste. "close to" (or "near") should apparently point at the comma, not at the closing bracket, and "you have 2 when you should have 1" should be backwards. The third message is still weird. Create table `tmp`.`t2` with foreign key constraint failed. Referenced table `tmp`.`t1` not found in the data dictionary close to foreign key(a) references t1(a)) engine=innodb. I still don't like it that it claims that `tmp`.`t1` was referenced; and the "close to" part also points at the wrong place, it should be "close to 't1(a)'"; or, if you can't point at the exact place here, it should be "in 'foreign key(a) references t1(a))'", without the "close to" part.
            Hide
            elenst Elena Stepanova added a comment -

            Please note that MDEV-8855 appears to be more important than this one.

            Show
            elenst Elena Stepanova added a comment - Please note that MDEV-8855 appears to be more important than this one.

              People

              • Assignee:
                jplindst Jan Lindström
                Reporter:
                elenst Elena Stepanova
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: