Skip to content

Commit

Permalink
Merge pull request #1 from mhw/issue-202
Browse files Browse the repository at this point in the history
Issue 202
  • Loading branch information
francoisp authored Sep 23, 2020
2 parents 252ec8e + 32c7ee8 commit 2040af9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions expected/select.out
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,17 @@ SELECT * FROM enum_t1 ORDER BY id;
(3 rows)

DROP FOREIGN TABLE enum_t1;
-- 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;
Expand Down
2 changes: 1 addition & 1 deletion mysql_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,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 (");
Expand Down
3 changes: 3 additions & 0 deletions mysql_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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_regress1 -e "DROP TABLE IF EXISTS student;"
mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress1 -e "DROP TABLE IF EXISTS numbers;"
mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "DROP TABLE IF EXISTS enum_t1;"
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);"
Expand All @@ -40,3 +41,5 @@ mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress1 -e
mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress1 -e "CREATE TABLE numbers (a int, b varchar(255));"
mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "CREATE TABLE enum_t1 (id int PRIMARY KEY, size ENUM('small', 'medium', 'large'));"
mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -P $MYSQL_PORT -D mysql_fdw_regress -e "INSERT INTO enum_t1 VALUES (1, 'small'),(2, 'medium'),(3, 'medium');"
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');"
5 changes: 5 additions & 0 deletions sql/select.sql
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ IMPORT FOREIGN SCHEMA mysql_fdw_regress LIMIT TO (enum_t1) FROM SERVER mysql_svr
SELECT * FROM enum_t1 ORDER BY id;
DROP FOREIGN TABLE enum_t1;

-- 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;
Expand Down

0 comments on commit 2040af9

Please sign in to comment.