Commit Graph

3 Commits

Author SHA1 Message Date
Dimitri Fontaine
3e8b7df0d3 Improve column formatting.
Have a pretty-print option where we try to be nice for the reader, and
don't use it in the CAST debug messages. Also allow working with the
real maximum length of column names rather than hardcoding 22 cols...
2016-03-16 21:46:41 +01:00
Dimitri Fontaine
eaa5807244 Adapt to CURRENT_TIMESTAMP(x) default values.
We target CURRENT_TIMESTAMP as the PostgreSQL default value for columns
when it was different before on the grounds that the type casting in
PostgreSQL is doing the job, as in the following example:

    pgloader# create table test_ts(ts timestamptz(6) not null default CURRENT_TIMESTAMP);
    CREATE TABLE
    pgloader# insert into test_ts VALUES(DEFAULT);
    INSERT 0 1
    pgloader# table test_ts;
                  ts
    -------------------------------
     2016-02-24 18:32:22.820477+01
    (1 row)

    pgloader# drop table test_ts;
    DROP TABLE
    pgloader# create table test_ts(ts timestamptz(0) not null default CURRENT_TIMESTAMP);
    CREATE TABLE
    pgloader# insert into test_ts VALUES(DEFAULT);
    INSERT 0 1
    pgloader# table test_ts;
               ts
    ------------------------
     2016-02-24 18:32:44+01
    (1 row)

Fix #341.
2016-02-24 18:30:16 +01:00
Dimitri Fontaine
782561fd4e Handle default value transforms errors, fix #333.
It turns out that MySQL catalog always store default value as strings
even when the column itself is of type bytea. In some cases, it's then
impossible to transform the expected bytea from a string.

In passing, move some code around to fix dependencies and make it
possible to issue log warnings from the default value printing code.
2016-02-03 12:27:58 +01:00