Commit Graph

1288 Commits

Author SHA1 Message Date
Dimitri Fontaine
4f2385fa4c Refactor code from previous commit.
The goal is to make it easy to add support for the 'drop indexes' option
in other source types (fixed, ixf, db3, file-based sources).
2015-07-16 19:35:34 +02:00
Dimitri Fontaine
49bf7e56f2 Implement a "drop indexes" option in CSV mode, fix #251.
When loading against a table that already has index definitions, the
load can be quite slow. Previous commit introduced a warning in such a
case. This commit introduces the option "drop indexes" that is not used
by default.

When this option is used, pgloader drops the indexes before loading the
data then create the indexes again with the same definitions as before.
All the indexes are created again in parallel to optimize performances.
Only primary key indexes can't be created in parallel, so those are
created in two steps (create unique index then alter table).
2015-07-16 12:22:58 +02:00
Dimitri Fontaine
7c834db6e3 Warn against pre-existing indexes.
Pre-existing indexes will reduce data loading performances and it's
generally better to DROP the index prior to the load and CREATE them
again once the load is done. See #251 for an example of that.

In that patch we just add a WARNING against the situation, the next
patch will also add support for a new WITH clause option allowing to
have pgloader take care of the DROP/CREATE dance around the data
loading.
2015-07-16 12:22:58 +02:00
Dimitri Fontaine
81ad98b323 Merge pull request #257 from Jamim/master
Default cast rules for MySQL's datatime types fixed
2015-07-10 19:21:07 +02:00
Aliaksei Urbanski
6a660fcf76 Default cast rules for MySQL's datatime types fixed [issue #252] 2015-07-10 15:37:25 +00:00
Dimitri Fontaine
88c801997e Default to a static list of PostgreSQL keywords.
In some cases (such as when using a very old PostgreSQL instance or an
Amazon Redshift service, as in #255), the function pg_get_keywords()
does not exists but we assume that pgloader might still be able to
complete its job.

We're better off with a static list of keywords than with a unhandled
error here, so let's see what happens next with Redshift.
2015-07-04 20:16:50 +02:00
Dimitri Fontaine
1f7382cd0d Fix error counts when transformation functions fail.
Related to #249, stop reporting 0 errors on sources where we failed to
handle some data transformation.
2015-06-27 19:32:08 +02:00
Dimitri Fontaine
5f85bf542a Fix float-to-string to accept integers, fix #249.
The problem in #249 is that SQLite is happy processing floats in an
integer field, so pgloader needs to be instructing via the CAST
mechanism to cast to float at migration time.

But then the transformation function would choke on integers, because of
its optimisation "declare" statement. Of course the integer
representation expected by PostgreSQL is float-compatible, so just
instruct the function that integers are welcome to the party.
2015-06-27 19:30:34 +02:00
Dimitri Fontaine
1c7de22096 Add test coverage for #80. 2015-06-25 14:16:12 +02:00
Dimitri Fontaine
d75c100399 Expose cl-csv escape mode option, fix #80.
Some CSV files are using the CSV escape character internally in their
fields. In that case we enter a parsing bug in cl-csv where backtracking
from parsing the escape string isn't possible (or at least
unimplemented).

To handle the case, change the quote parameter from \" to just \ and let
cl-csv use its escape-quote mechanism to decide if we're escaping only
separators or just any data.

See https://github.com/AccelerationNet/cl-csv/issues/17 where the escape
mode feature was introduced for pgloader issue #80 already.
2015-06-25 14:10:36 +02:00
Dimitri Fontaine
250ed1c791 Fix CSV parsing to log errors when trying to continue.
The error handling was good enough to continue parsing the CSV data
after a recoverable parser error, but not good enough to actually report
its misfortunes to the user.

See #250 for a report where this is misleading.
2015-06-25 10:31:14 +02:00
Dimitri Fontaine
b55ded11e0 Fix read counters when reading data from SQLite. 2015-06-16 23:14:10 +02:00
Dimitri Fontaine
7e508374c4 Add some SQLite test cases for real type, see #249. 2015-06-16 23:13:52 +02:00
Dimitri Fontaine
322f7dd8b5 Improve logging when loading extra code, see #245. 2015-06-11 13:02:29 +02:00
Dimitri Fontaine
ff5b596219 Merge pull request #241 from alexbaretta/master
Fix DROP TABLE statements on tables with foreign keys
2015-05-28 23:53:02 +02:00
Alex Baretta
49dcae8068 Fix DROP TABLE statements on tables with foreign keys 2015-05-28 14:24:28 -07:00
Dimitri Fontaine
ceaad92f4c Merge pull request #240 from alexbaretta/master
Two bugfixes
2015-05-27 01:14:03 +02:00
Alex Baretta
817fc9a258 Fix string delimiter syntax in COMMENT statements 2015-05-26 16:10:39 -07:00
Alex Baretta
0626d56303 Fix identifier case in FOREIGN KEY constraints 2015-05-25 18:08:37 -07:00
Dimitri Fontaine
c3b5d60542 Fix type declaration to include null values, fix #238.
In passing, add a test case for NIL datetime values in our SQLite sample
database.
2015-05-22 23:49:03 +02:00
Dimitri Fontaine
d1fce3728a Allow more PostgreSQL URI options, fix #199.
As per PostgreSQL documentation on connection strings, allow overriding
of main URI components in the options parts, with a percent-encoded
syntax for parameters. It allows to bypass the main URI parser
limitations as seen in #199 (how to have a password start with a
colon?).

See:
 http://www.postgresql.org/docs/9.3/interactive/libpq-connect.html#LIBPQ-CONNSTRING
2015-05-22 23:39:04 +02:00
Dimitri Fontaine
ba7b27b60a Travis: actually push the right version of the expected file. 2015-05-22 12:41:29 +02:00
Dimitri Fontaine
bffec4cc63 Allow for more options in the CSV escape character, fix #38.
To allow for importing JSON one-liners as-is in the database it can be
interesting to leverage the CSV parser in a compatible setup. That setup
requires being able to use any separator character as the escape
character.
2015-05-22 12:31:06 +02:00
Dimitri Fontaine
62931e0312 Fix unknown source type error, fix #237.
In passing also recognize the ".sqlite3" file type as being a SQLite
database file.
2015-05-22 11:32:30 +02:00
Dimitri Fontaine
dc86b5e600 Travis: Fix the text case connection string. 2015-05-21 16:29:14 +02:00
Dimitri Fontaine
abbc105c41 Implement CSV headers support.
Some CSV files are given with an header line containing the list of
their column names, use that when given the option "csv header".

Note that when both "skip header" and "csv header" options are used,
pgloader first skip as many required lines and then uses the next one as
the csv header.

Because of temporary failure to install the `ronn` documentation tool,
this patch only commits the changes to the source docs and omits to
update the man page (pgloader.1). A following patch is intended to be
pushed that fixed that.

See #236 which is using shell tricks to retrieve the field list from the
CSV file itself and motivated this patch to finally get written.
2015-05-21 12:55:23 +02:00
Dimitri Fontaine
dfb4cc2049 Allow dollars in CSV fields names, fix #236. 2015-05-21 12:51:39 +02:00
Dimitri Fontaine
533e6b623f Review upgrade config code, fix #235.
The database connection code needed to switch to the "new" connection
facilities, and there was a bug in the processing of template sections
wherein the template user would inherit the template property.
2015-05-19 18:12:10 +02:00
Dimitri Fontaine
204a740441 Merge pull request #233 from malept/accept-periods-in-csv-field-names
Accept periods in CSV field names
2015-05-15 16:38:18 +02:00
Mark Lee
dc04b40836 Accept periods in CSV field names
Periods are allowed in PG column names as well.
2015-05-15 07:22:07 -07:00
Dimitri Fontaine
ff78ebf048 Improve SQLite values parsing, fix #231.
It turns out that SQLite3 data type handling is back to kick us wherever
it hurts, this time by the driver deciding to return blob data (a vector
of unsigned bytes) when we expect properly encoded text data.

In the wikipedia data test case used to reproduce the bug, we're lucky
enough that the byte vectors actually map to properly encoded strings.

Of course doing the proper thing costs some performances.

I'd like to be able to decide if I should blame the SQLite driver or the
whole product on this one. The per-value data type handling still is a
disaster in my book, tho, which means it's crucially important for
pgloader to get it right and allow users to seemlessly migrate away from
using such a system.
2015-05-14 21:08:19 +02:00
Dimitri Fontaine
bf62e06ff6 Accept MySQL dbname beginning with digits, fix #230.
pgloader used to have a single database name parsing rule that is
supposed to be compliant with PostgreSQL identifier rules. Of course it
turns out that MySQL naming rules are different, so adjust the parser so
that the following connection string is accepted:

  mysql://root@localhost/3scale_system_development
2015-05-12 10:20:58 +02:00
Dimitri Fontaine
8e6e67f056 Be smarter about MSSQL column_default values, fix #207.
MS SQL default values can be quite... sophisticated, so get around with
using a more complex expression in the SQL query that retrieve the
default values.

The query and implementation has been largely provided by luqelinux and
jstans github users, and I finally merged manually their cumulated
efforts on this front.
2015-05-01 21:20:45 +02:00
Dimitri Fontaine
3848ad6ae5 SQLite integers can host bigints, fix #227. 2015-04-30 18:17:13 +02:00
Dimitri Fontaine
ebc0dcda4f Allow for empty-string SQLite column types, fix #220 again. 2015-04-30 17:18:14 +02:00
Dimitri Fontaine
95a5eb3184 Implement more COPY options, fix #218.
The COPY format now supports user defined delimiter and null options,
and we don't require the column names anymore as it's useless in that
context.
2015-04-30 14:30:16 +02:00
Dimitri Fontaine
53dcdfd8ef Fix handling of COPY data, fix #222.
When given a file in the COPY format, we should expect that its content
is already properly escaped as expected by PostgreSQL. Rather than
unescape the data then escape it again, add a new more of operation to
format-vector-row in which it won't even try to reformat the data.

In passing, fix an off-by-one bug in dealing with non-ascii characters.
2015-04-30 13:17:02 +02:00
Dimitri Fontaine
5759ae50bb Handle SQLite typemod in type name normalisation.
Should fix #220.
2015-04-28 21:33:25 +02:00
Dimitri Fontaine
40cfc4e7b7 Merge pull request #213 from weepee-org/centos7
Adds bootstrap for CentOS 7
2015-04-26 18:32:52 +02:00
Gert Van Gool
661a3dad30 Adds bootstrap for CentOS 7 2015-04-23 13:48:17 +02:00
Dimitri Fontaine
da665c6b6e Fix previous commit for IXF support. 2015-04-17 23:45:59 +02:00
Dimitri Fontaine
0068a45e1c Fix parsing of qualified target table names, see #186.
We used to parse qualified table names as a simple string, which then
breaks attempts to be smart about how to quote idenfifiers. Some sources
are known to accept dots in quoted table names and we need to be able to
process that properly without tripping on qualified table names too
late.

Current code might not be the best approach as it's just using either a
cons or a string for table names internally, rather than defining a
proper data structure with a schema and a name slot.

Well, that's for a later cleanup patch, I happen to be lazy tonight.
2015-04-17 23:22:30 +02:00
Dimitri Fontaine
5ac396799a Be careful about the OS return code, fix #190.
Define a bunch of OS return codes and use them wisely, or at least in a
better way than just doing (uiop:quit) whenever there's something wrong,
without any difference whatsover to the caller.

Now we return a non-zero error code when we know something wrong did
happen. Which is more useful.
2015-04-17 22:30:04 +02:00
Dimitri Fontaine
11976d2c23 Fix census-places URL location of the source file. 2015-04-17 21:58:19 +02:00
Dimitri Fontaine
2a6ad888d0 Implement basic HTTP status checking in fetch method. 2015-04-17 21:37:21 +02:00
Dimitri Fontaine
cb94993064 Fix #202, blind attempt, passes tests. 2015-04-06 19:47:38 +02:00
Dimitri Fontaine
77394bd029 Merge pull request #201 from jdufresne/fix-typo
Fix typo
2015-04-02 20:37:54 +02:00
Jon Dufresne
b88ef6bdea Fix typo. 2015-04-02 09:45:44 -07:00
Jon Dufresne
8038931f5a Remove trailing whitespace. 2015-04-02 09:45:36 -07:00
Dimitri Fontaine
8f57c90809 Merge pull request #196 from benesch/makefile-updates
Match pgloader-standalone target to pgloader target
2015-03-23 22:19:55 +01:00