diff --git a/expected/select.out b/expected/select.out index 98a9224..0313204 100644 --- a/expected/select.out +++ b/expected/select.out @@ -1431,6 +1431,17 @@ SELECT c1, c2, c3 FROM f_test_tbl1 WHERE pg_catalog.timeofday() IS NOT NULL 500 | EMP5 | SALESMAN (5 rows) +-- Issue #202 - correct handling of mixed-case table names. +IMPORT FOREIGN SCHEMA mysql_fdw_regress LIMIT TO ("mixedCaseTable") FROM SERVER mysql_svr INTO public; +SELECT * FROM "mixedCaseTable" ORDER BY id; + id | mixedCaseColumn +----+----------------- + 1 | small + 2 | medium + 3 | large +(3 rows) + +DROP FOREIGN TABLE "mixedCaseTable"; -- Cleanup DROP TABLE l_test_tbl1; DROP TABLE l_test_tbl2; diff --git a/mysql_fdw.c b/mysql_fdw.c index 5a22630..b1e5367 100644 --- a/mysql_fdw.c +++ b/mysql_fdw.c @@ -2138,7 +2138,7 @@ mysqlImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid) { bool first_item = true; - appendStringInfoString(&buf, " AND t.TABLE_NAME "); + appendStringInfoString(&buf, " AND t.TABLE_NAME COLLATE UTF8_GENERAL_CI "); if (stmt->list_type == FDW_IMPORT_SCHEMA_EXCEPT) appendStringInfoString(&buf, "NOT "); appendStringInfoString(&buf, "IN ("); diff --git a/mysql_init.sh b/mysql_init.sh index 624e577..fe8e2a9 100755 --- a/mysql_init.sh +++ b/mysql_init.sh @@ -36,6 +36,7 @@ mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "DROP TABLE IF EXISTS test3;" mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "DROP TABLE IF EXISTS test4;" mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "DROP TABLE IF EXISTS test5;" +mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "DROP TABLE IF EXISTS mixedCaseTable;" mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "CREATE TABLE mysql_test(a int primary key, b int);" mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "INSERT INTO mysql_test(a,b) VALUES (1,1);" @@ -55,3 +56,5 @@ mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "CREATE TABLE test4 (c1 int PRIMARY KEY, c2 int, c3 varchar(255))" mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "CREATE TABLE test5 (c1 int primary key, c2 binary, c3 binary(3), c4 binary(1), c5 binary(10), c6 varbinary(3), c7 varbinary(1), c8 varbinary(10), c9 binary(0), c10 varbinary(0));" mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "INSERT INTO test5 VALUES (1, 'c', 'c3c', 't', 'c5c5c5', '04', '1', '01-10-2021', NULL, '');" +mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "CREATE TABLE mixedCaseTable (id int PRIMARY KEY, mixedCaseColumn text);" +mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "INSERT INTO mixedCaseTable VALUES (1, 'small'),(2, 'medium'),(3, 'large');" diff --git a/sql/select.sql b/sql/select.sql index 608871f..0ac3a7e 100644 --- a/sql/select.sql +++ b/sql/select.sql @@ -419,6 +419,11 @@ SELECT c1, c2, c3 FROM f_test_tbl1 WHERE pg_catalog.timeofday() IS NOT NULL SELECT c1, c2, c3 FROM f_test_tbl1 WHERE pg_catalog.timeofday() IS NOT NULL ORDER BY 1 limit 5; +-- Issue #202 - correct handling of mixed-case table names. +IMPORT FOREIGN SCHEMA mysql_fdw_regress LIMIT TO ("mixedCaseTable") FROM SERVER mysql_svr INTO public; +SELECT * FROM "mixedCaseTable" ORDER BY id; +DROP FOREIGN TABLE "mixedCaseTable"; + -- Cleanup DROP TABLE l_test_tbl1; DROP TABLE l_test_tbl2;