From 07cdf3e7e53d582b2163bb61ae2159fc0371804c Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Fri, 22 Dec 2017 14:15:46 +0100 Subject: [PATCH] Use MySQL column names in MySQL queries. The query for concurrency-support didn't get the memo that we should ignore PostgreSQL identifier-case when querying the source MySQL database. Fix the query string to include column names as given by the MySQL catalogs. In bug report #703, the problem is found in PostgreSQL queries. This has been fixed before already. Trying to reproduce the bug produced an error in the concurrency-support query instead, so let's fix this one. Fix #703. --- src/sources/mysql/mysql.lisp | 4 +++- test/mysql/my.load | 3 ++- test/mysql/my.sql | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sources/mysql/mysql.lisp b/src/sources/mysql/mysql.lisp index 72a8cf1..34e5caf 100644 --- a/src/sources/mysql/mysql.lisp +++ b/src/sources/mysql/mysql.lisp @@ -54,7 +54,9 @@ ;; the table has a primary key over a integer data type we are able ;; to generate WHERE clause and range index scans. (with-connection (*connection* (source-db mysql)) - (let* ((col pcol) + (let* ((col (mysql-column-name + (nth (position coldef (table-column-list (target mysql))) + (fields mysql)))) (sql (format nil "select min(`~a`), max(`~a`) from `~a`" col col (table-source-name (source mysql))))) (destructuring-bind (min max) diff --git a/test/mysql/my.load b/test/mysql/my.load index fc82232..1bc17d9 100644 --- a/test/mysql/my.load +++ b/test/mysql/my.load @@ -5,7 +5,8 @@ load database WITH concurrency = 2, multiple readers per thread, - rows per range = 50000 + rows per range = 50000, + quote identifiers ALTER SCHEMA 'pgloader' RENAME TO 'mysql' diff --git a/test/mysql/my.sql b/test/mysql/my.sql index 44234f1..17cd3b6 100644 --- a/test/mysql/my.sql +++ b/test/mysql/my.sql @@ -100,6 +100,13 @@ create table bits insert into bits(bool) values(0b00), (0b01); +/* + * https://github.com/dimitri/pgloader/issues/703 + */ +create table `CamelCase` ( + `validSizes` varchar(12) +); + CREATE TABLE `fcm_batches` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `raw_payload` mediumtext COLLATE utf8_unicode_ci,