New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't know how to represent mysql type of <table>.<column> (timestamp) #6
Comments
So we have two ways we could represent this. One option is to add a mysql-specific type and to map it to the existing type on postgresql. The other is to treat this as a datetime column with a special default. Is the CURRENT_TIMESTAMP default the only reason you are using the timestamp type? |
Here are some details of the conversion MySQL to PostgreSQL
We need to transform the |
So we can turn the mysql special cases into postgresql default value functions. I agree we should use -infinity for the 0000-00-00 00:00:00 time. What about going the other way? Currently we have no default value function conversion (ie. from mysql to postgresql syntax or vice versa), so maybe we would need to add this for some special cases that kitchen sync itself produces. |
I have this error too. Any plans to fix this? Or workarounds? |
@xrewndel is the CURRENT_TIMESTAMP default the only reason you are using the timestamp type? |
@willbryant I don't know. I just want to sync mysql to postgres every 5 min. That is my task. I'm looking for simple solutions and don't want to use Talend or smth like this, cause its over-engineering in my particular case. |
The issue is that postgresql doesn't have a TIMESTAMP type, so we're trying to decide what it should be mapped to. We can use a default value function to make inserts into the postgresql table populate the TIMESTAMP column, simulating the mysql behavior. But as far as I'm aware there's no column setting that can make postgresql reset the timestamp column every time the row is updated, which we'd need to simulate the mysql update behavior. I think you'd have to write a trigger function. What behavior are you expecting when it gets converted to a postgresql schema? |
Have the same problem. |
Cool. What about the defaults stuff in my preceding comment? |
… parsing now() back to CURRENT_TIMESTAMP for postgresql so that it can round-trip. work towards #6. NB. mysql does not support other expressions for column defaults; mariadb 10.2 does, although there seems to be no way to distinguish `CURRENT_TIMESTAMP` from `'CURRENT_TIMESTAMP'` in INFORMATION_SCHEMA.COLUMNS or SHOW FULL FIELDS, so recognising the function definition may be impossible for string column types, which makes me reluctant to implement it yet. filed as MDEV-13132.
…ial cases with mysql's timestamp type when we implement issue #6
… its unique 'on update current_timestamp' behavior
I think version 0.59 has enough that most of you should be able to use it. The special behavior of the column type is mostly supported, except for ON UPDATE CURRENT_TIMESTAMP which has no equivalent in PostgreSQL, and the special values. Please open new issues for any remaining blockers you find. |
Seems to be a problem with the work of the timestamp data type:
Types formats
Conversion: mysql2pgsql/lib/postgres_writer.py
https://github.com/mihailShumilov/mysql2postgresql (PHP)
https://github.com/dimitri/pgloader ( Tcl (1.х), Python (2.x), Common Lisp (3.x) )
https://github.com/maxlapshin/mysql2postgres (Ruby)
https://github.com/lanyrd/mysql-postgresql-converter (Python)
http://www.postgresonline.com/journal/archives/29-How-to-convert-a-table-column-to-another-data-type.html
PostgreSQL complain about timestamp '0000-00-00 00:00:00'
mysqlcompat (SQL functions, easing migration)
The text was updated successfully, but these errors were encountered: