Replaced the string "KEY" by "key" in the description for column name in table key_value.

Running OpenSuse 13.2
MariaDB 10.0.20

I've not been able to export and import the database, due to an SQL error. With "KEY" the export looks like:

CREATE TABLE IF NOT EXISTS `key_value` (
  `collection` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'A named collection of key and value pairs.'
`value` longblob NOT NULL COMMENT 'The value.',
  PRIMARY KEY (`collection`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Generic key-value storage table. See the state system for…';

The Column "name" is lost ...

Not big deal, but when you need to recover a system quickly and you are not aware about it, no fun ...

CommentFileSizeAuthor
system_install.patch724 bytesslowflyer

Comments

cilefen’s picture

Title: Error dumping database » All-caps "KEY" in table description prevents database dumps
Issue tags: -key_value
cilefen’s picture

Title: All-caps "KEY" in table description prevents database dumps » All-caps "KEY" in the key-value table description prevents database dumps
cilefen’s picture

Status: Active » Needs review

I

cilefen’s picture

Title: All-caps "KEY" in the key-value table description prevents database dumps » All-caps "KEY" in the key-value table description prevents database dump and import
Status: Needs review » Reviewed & tested by the community

The patch is simple and fixed the issue for me.

cilefen’s picture

I tested on MariaDB 10.0.20.

xjm’s picture

Component: system.module » database system
Assigned: Unassigned » Crell
Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs subsystem maintainer review

Um, hm. That's... weird. I wonder if this is a bug in the way Maria parses exports? As far as I know any reserved word in the comment should be fine since it's quoted, and it's especially weird that the bug is case-sensitive like this. I can't find any resources with issues about SQL reserved words in column comments.

This fix might be fine since it resolves the bug, but it'd be good to know why it's happening so we can either document it or ensure that there isn't an underlying bug in Drupal. I think a DB subsystem maintainer's input or +1 would be good here. Pinging Crell in particular.

Crell’s picture

... Wow, MariaDB. Wow.

Can we test this on a recent MySQL, too? I'm fine with the patch posted, but I too would like to have a better understanding of what's going on to know if we need to do anything else with it. I'll see if I can track down any MariaDB experts who might have some insight. My gut feeling is that it's a parser bug in MariaDB (or maybe MySQL as well? I've no idea), in which case we should at least make sure it gets reported upstream.

kthari85’s picture

Actually I am unable to run the create table from MySQL.

CREATE TABLE IF NOT EXISTS `key_value` (
  `collection` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'A named collection of key and value pairs.'
`value` longblob NOT NULL COMMENT 'The value.',
  PRIMARY KEY (`collection`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Generic key-value storage table. See the state system for…';
Error in query (1064): Syntax error near '`value` longblob NOT NULL COMMENT 'The value.', PRIMARY KEY (`collection`,`na' at line 3

Is it really a MariaDB only error or is it related to MySQL also ? (Version : 5.6.24 )

btmash’s picture

I'm looking at this and there are a lot of issues with the SQL that was originally posted.

  1. There should be a comma between each field/column definition
  2. 'value' column mentions being NOT NULL yet does not provide a default
  3. There is no column named 'name', only 'value'
  4. Since 'value' column is a longblob, it cannot really be indexed unless you specify a key length. See http://www.mydigitallife.info/mysql-error-1170-42000-blobtext-column-use...

As far as I see, this is less an issue of MariaDB and more an issue of bad SQL.

btmash’s picture

Oh, and there is no 'name' column definition. I initially thought value was what is being referred to.

If the case is against a dump of d8 and trying to recreate it, doing so now.

btmash’s picture

I just tried against a fresh sql-dump into Maria 10.0.20 and it worked without any issues.

Anonymous’s picture

I also had no issue with a dump of a relatively fresh D8 (installed last week) on Percona XtraDB 5.6, MySQL 5.6, and MariaDB 10.0.20.

slowflyer’s picture

@BTMash: The originally posted SQL is corrupt, thats why I posted this example
@Brian Altenhofel: Have you been able to import the dump?

btmash’s picture

@slowflyer I understood that after the fact; I apologize for my comment. However, I was able to do a successful export/import of the dump.

Crell’s picture

So based on the most recent comments, is this issue now a wont-fix red herring?

slowflyer’s picture

I had the issue, my suggested patch did fix the issue.

#4 the patch worked for cilefen as well.

cilefen’s picture

I definitely saw the issue in the configuration I mentioned.

btmash’s picture

@slowflyer, @cilefen: How did you create the database dump? I've tried with drush-master, mysqldump and they both export/import correctly (again, with MariaDB-10.0.20). Mind you, I have tried this in Ubuntu and Debian and not in OpenSuse.

cilefen’s picture

@BTMash phpMyAdmin 4.3.2. Maybe that's my problem.

slowflyer’s picture

@BTMash: phpMyAdmin on my site as well, I will check with mysqldump tomorrow morning.

cilefen’s picture

Ha - I think we may have the answer.

Anonymous’s picture

Only did Debian here. It seems a common denominator may be phpMyAdmin, but I'm not setup to test that. However, it looks like a known bug in phpMyAdmin that has been fixed since 4.3.13.0 (released 2015-03-29).

btmash’s picture

I can confirm being able to replicate this issue locally with phpMyAdmin (I have acquia dev desktop locally and was able to replicate the bad sql from the export since it uses phpMyAdmin 4.3.7). Will be able to try with newer versions soon-ish to see if there is an issue but atleast now we can confirm MariaDB is not cause of the issue. But phpMyAdmin may still contain the problem so we should keep the issue open.

cilefen’s picture

Status: Needs review » Closed (works as designed)

I tried and it is fixed in the 4.4.4 phpMyAdmin release. This is a phpMyAdmin bug that has been fixed. This is not a Drupal issue.