PostgreSQL to MySQL data migration

若如初见. 提交于 2019-12-02 07:28:45

This error bring me here.

If your "psqlcfg_lid_seq" actually including both uppercase and lowercase character(s), remember that PostgreSQL will convert the name into ALL lowercase for query.

A basic knowledge is: In order to perform a case matched query, the name must be wrapped by double quotation marks ("), so the convertion will be avoided.

However, in MySQL Workbench, they forget to do that when try to fetch sequences.

In db_postgresql_re_grt.py. Located in %Program Files%\MySQL\MySQL Workbench (Your version, for example "6.1 CE")\modules on Windows.

Line around 70, you will found the SQL query in the variable seq_details_query, it will be something like:

        seq_details_query = """SELECT min_value, max_value, start_value, 
increment_by, last_value, is_cycled, cache_value
FROM %s.%s"""

Change that to:

        seq_details_query = """SELECT min_value, max_value, start_value, 
increment_by, last_value, is_cycled, cache_value
FROM \"%s\".\"%s\""""

So the sequences can be fetched, and so whole flow can be proceed.

Notice that: You may need to restart MySQL Workbench to use modified scripts.

I'm surprised MySQL guys still not fix this problem. Maybe i need report the bug somehow? :P

42P01 is a generic error meaning the object doesn't exist.

In this case it's the sequence public.psqlcfg_lid_seq that does not exist. Based on the series of error messages, the error happens when the tool tries to query the attributes of that sequence (with SELECT ... FROM schema_name.sequence_name)

Presumably this sequence is still referenced somewhere in the database even if ot no longer exists. In theory there are safeguards in PostgreSQL against this situation (dependency tracking) but I believe they depend on your server version and maybe on the specifics of the dependency.

To find the references to this sequence, one approach would be to dump the database schema to an SQL text file (with pg_dump -s) and search for the text psqlcfg_lid_seq within it.

Once found, presumably some ALTER statements may be able to remove the references.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!