Heidisql: MySQL 8.0 - Export views problem

Created on 23 Sep 2019  ·  3Comments  ·  Source: HeidiSQL/HeidiSQL

Steps to reproduce this issue

Hi, there's a problem exporting a database to another one. Using Mysql 8.0 and Heidi 10.2.0

  1. Select database to export: "Export dababase as SQL"
  2. Select Table: Drop and Create
  3. Select Data: Delete + insert (truncate existing data)
  4. Select output: Dabase
  5. Click Export
  6. On view's I get error "SQL Error 1347: xxxx is not VIEW "

Current behavior


Views get error when exporting "SQL Error 1347: xxxx is not VIEW "
They have been created as tables.

Expected behavior


Views have not been exported as "Views"

Possible solution

Environment

  • HeidiSQL version: 10.2.0.5695
  • Database system and version: Mysql Version: 8.0.17 - Database Collation: utf8mb4_0900_ai_ci
  • Operating system: Windows 10

Image 1
Screenshot_2
Image 2
Screenshot_3
Image 3
Screenshot_4

bug confirmed nettype-mysql

Most helpful comment

I believe the root of this issue is not the DROP VIEW IF EXISTS xyz, but that HeidiSQL is creating the views as tables when moving things from one DB to another.

I attempted to do this on a totally empty DB and HeidiSQL created the views as tables which in turn caused this issue.

All 3 comments

Problem is in MySQL 8, the changed behaviour of DROP VIEW xyz. The new behaviour is described here: https://dev.mysql.com/doc/refman/8.0/en/drop-view.html
Though the docs say clearly when using DROP VIEW IF EXISTS xyz, then just a note returns, not an error. HeidiSQL fires the query due to the checked left checkbox (Drop tables), and fires it with the IF EXISTS clause, which should avoid the error. Obviously, it still returns with an error if xyz exists as a table. I am unsure if that's a bug in MySQL or if that's intentionally. The docs are incomplete however, and I have no idea for a workaround.

I believe the root of this issue is not the DROP VIEW IF EXISTS xyz, but that HeidiSQL is creating the views as tables when moving things from one DB to another.

I attempted to do this on a totally empty DB and HeidiSQL created the views as tables which in turn caused this issue.

A possible solution would be to do the same thing mysqldump does to solve this:

--
-- Temporary view structure for view `xyz`
--

DROP TABLE IF EXISTS `xyz`;
/*!50001 DROP VIEW IF EXISTS `xyz`*/;
SET @saved_cs_client     = @@character_set_client;
/*!50503 SET character_set_client = utf8mb4 */;
/*!50001 CREATE VIEW `xyz` AS SELECT 
 1 AS `x`,
 1 AS `y`,
 1 AS `z`*/;
SET character_set_client = @saved_cs_client;

-- Rest of the dump...

--
-- Final view structure for view `xyz`
--

/*!50001 DROP VIEW IF EXISTS `xyz`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`john.doe`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `xyz` AS SELECT x, y, z FROM tbl */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrysler5798 picture chrysler5798  ·  5Comments

chrysler5798 picture chrysler5798  ·  5Comments

yz778 picture yz778  ·  4Comments

rkmaier picture rkmaier  ·  5Comments

andreybatalof picture andreybatalof  ·  4Comments