291 Commits

Author SHA1 Message Date
Dimitri Fontaine
7cf7e714fc Implement the source date format option. 2014-10-02 01:03:24 +02:00
Dimitri Fontaine
dfb1e9355a Get rid of our own implementation of alexandria:read-file-into-string. 2014-10-01 23:23:46 +02:00
Dimitri Fontaine
2369a142a7 Refactor source code organisation.
In passing, fix a bug in the previous commit where left-over code would
cancel the whole new parsing code for advanced source fields options.
2014-10-01 23:20:24 +02:00
Dimitri Fontaine
ac55d71401 Rework CSV and Fixed files source fields options, see #116.
It's not possible to use a comma separator when using more than one
source field option at the same time, and for better readability the
options are to be found enclosed in squared brackets.

Also, it's now possible to spell out "from" and "for" keywords on the
source definitions, making it easier to read and maintain the load file,
as in this full example:

          (
           a from  0 for 10,
           b from 10 for  8,
           c from 18 for  8,
           d from 26 for 17 [null if blanks, trim right whitespace]
          )
2014-10-01 18:32:40 +02:00
Dimitri Fontaine
ea97fc4659 Implement a new source level filter: trim.
As seen in #116, it might be better for the users to be able to ask for
field trimming right in the source definition, like we do for processing
nulls.
2014-09-29 15:16:04 +02:00
Dimitri Fontaine
8a0c91fa40 Fix conjunctions for the INCLUDING clause in MySQL.
We want all table matching any of the given constraints (regexp or
equality search).
2014-09-23 16:44:38 +02:00
Dimitri Fontaine
52e3371be8 Review default SQLite options. 2014-09-22 14:34:57 +02:00
Dimitri Fontaine
d4b58a1f78 Review MySQL default options.
The default values for MySQL WITH clause options wasn't really tested
and broke on simple cases, the new set of defaults is known to work in
many cases (most?).

Other combinations of options will need some review work, and we might
need to consider preventing some of them, that's for another patch tho.
2014-09-21 12:19:20 -05:00
Dimitri Fontaine
c4141c464d Now that 3.1.0 is released, we're preparing 3.1.1 here. 2014-09-10 23:03:42 +02:00
Dimitri Fontaine
0a3b4af290 Release pgloader 3.1.0! 2014-09-10 23:02:27 +02:00
Dimitri Fontaine
be9abe48fe Cleanup some pgsql connection handling. 2014-09-10 22:20:20 +02:00
Dimitri Fontaine
9c604f969b Rename --load into --load-lisp-file
To avoid wasting everybody's time when trying to debug --load
command.load, rename the option to be more explicit about what it does.
Also implement some basic guards in the form of testing that the
filename extension is part of a very short whitelist: .lisp, .cl, .lsp
and .asd.
2014-09-02 22:33:51 +02:00
Dimitri Fontaine
6fda4eb52b Fix MySQL queries for INCLUDING/EXCLUDING clauses, fix #111.
The format string were wrong in that ~@[...~] will not consume the argument
where we need to consume it, so use the more verbose form ~:[~*~;...~]
wherein the ~* rule forces the consuming of the unused argument.

Also, prefer using != and NOT REGEXP operators to the "not ( or )" form,
which was wrong too because spelled "not ( and )".
2014-08-30 13:39:56 +02:00
Dimitri Fontaine
a41f8ea6d3 Create root-dir when it does not exists, fix #35. 2014-08-29 23:19:01 +02:00
Alexander Couzens
b8807f52b1 sqlite: convert clob -> text 2014-08-22 20:44:49 +02:00
Dimitri Fontaine
aad272769f Implement MySQL table names filtering in SQL, fix #105.
This allows returning only selected table names as early as possible
rather than post-filtering a possibly large result list.
2014-08-16 16:43:52 +02:00
Neil Gentleman
16d3edf5be check for reserved keyword after downcasing
uppercase USER isn't reserved, but lowercase is
2014-08-08 18:25:06 -07:00
Dimitri Fontaine
b4ec0ec52f Implement support for gzip and tarball archives format, see #80. 2014-08-06 22:53:51 +02:00
Dimitri Fontaine
68dc8e07b4 When given --summary, refrain from writing to the terminal, fixing #102. 2014-08-03 22:56:24 +02:00
Dimitri Fontaine
1179f449dc Remove outdated comments about the reader and writer batches... 2014-08-03 19:49:10 +02:00
Dimitri Fontaine
624077bb95 Count bytes only once when under memory watch. 2014-08-03 19:48:49 +02:00
Dimitri Fontaine
ca52ddacb1 SQLite: transform "0" timestamps to NULL, see #100. 2014-07-30 18:42:49 +02:00
Dimitri Fontaine
ed8022ce64 SQLite: transform default values to their PostgreSQL representation.
When default values are used in SQLite they are of course using their
SQLite representation, which might not be compatible with the PostgreSQL
target data type we're casting to. Make it so that the default values
are transformed too, as we already do in the MySQL case.

See #100.
2014-07-30 16:32:35 +02:00
Dimitri Fontaine
a621a48c04 Fix including/excluding options parsing for SQLite, fix #99 (again). 2014-07-27 14:13:54 +02:00
Dimitri Fontaine
79f622234f Allow specifying the SQLite text encoding, fix #99. 2014-07-25 19:01:15 +02:00
Dimitri Fontaine
b538539fb3 Handle errors when processing data from SQLite.
Some errors could be related to encoding issues, as in #99.
2014-07-25 18:40:46 +02:00
Dimitri Fontaine
368dd88b48 Implement GETENV facility for reading FROM and INTO clauses.
It might be important to be able to use the exact same pgloader commands
file but adapt its source and target depending on the environment where
the command is to be run (production, development, staging, etc).

Introduce the new sub-clause GETENV 'variable-name' to that effect.

The regression test facility that we have now isn't nearly sophisticated
enough to support this, so the feature isn't yet covered.
2014-07-24 18:28:59 +02:00
Dimitri Fontaine
3b2119cae4 Don't catch all and any errors for retrying batches.
In particular a non existing table or column shouldn't be considered as
an error we can just retry upon receiving.
2014-07-21 15:38:53 +02:00
Dimitri Fontaine
a090f2fe3d Fix CCL compat where nil can't be a plist key. 2014-07-18 12:49:14 +02:00
Dimitri Fontaine
cb4b2a3334 Convert SQLite tinyint to PostgreSQL smallint, fixes #97. 2014-07-18 11:06:37 +02:00
Dimitri Fontaine
07b5aa3ed6 Add BEFORE/AFTER LOAD clauses to IXF and DBF commands. 2014-07-17 16:56:13 +02:00
Dimitri Fontaine
e4948a3627 Move some logic up to the parser.
As per grammar review at  https://github.com/nikodemus/esrap/issues/26,
improve the situation.
2014-07-16 23:25:46 +02:00
Dimitri Fontaine
0f3103da2d Improve the parsing rules, avoiding eating all possible chars.
Help improving the situation for #56.
2014-07-16 23:09:11 +02:00
Dimitri Fontaine
9ddf117a90 In-passing desultory cleanup. 2014-07-14 21:54:50 +02:00
Dimitri Fontaine
3e0526c957 Implement early support for IXF files. 2014-07-14 21:53:50 +02:00
Dimitri Fontaine
d00837f8fc Fix --upgrade-config basic usage. 2014-07-13 16:35:53 +02:00
Dimitri Fontaine
53a7e47058 New MySQL default Cast Rule for bit(1) to boolean, fix #93.
We need a new transformation function that work with a vector of
integers as input.
2014-07-03 11:47:59 +02:00
Dimitri Fontaine
55655ed927 Fix fixed-file column name quoting, as we did for CSV, fixes #70. 2014-06-29 16:25:30 +02:00
Dimitri Fontaine
2577308ad6 Ensure field level processing is happening in all cases.
When using both field level specifications and transformation functions,
the transformation needs to happen on the result of the field processing
rather than on the raw field.

Fixes #92.
2014-06-26 02:08:49 +02:00
Dimitri Fontaine
ab75e6c626 Improve ragged right code comments, follow-up to #90. 2014-06-25 13:29:26 +02:00
Dimitri Fontaine
a70a0ddd77 Keep typemod, default and not null when lacking casting rules, fixes #91. 2014-06-25 12:39:51 +02:00
Dimitri Fontaine
d1100efa28 Fix ragged lines support for fixed files, fixing #90.
It's possible for the data to stop before the end of a specified column,
in which case we still want to accept whatever shortened data we have.
2014-06-24 18:58:26 +02:00
Dimitri Fontaine
f7d251ed86 Fix quoting of TRUNCATE command, fix #84.
That patch is not a principaled approach at fixing the problem but
should allow for not messing up with fully qualified table names.

A proper way to do it would be to have a pgsql object name structure
composed of the catalog, the schema and the name as separate entries,
with assorted API to print that object properly. That's for another day
though.
2014-06-20 13:10:39 +02:00
Dimitri Fontaine
252abdeaa7 Find field attributes case-insensitively, fix #80.
That's a follow-up to the case management cleanup for fields and
columns, wherein the "null if" property would stop being applied
properly.
2014-06-17 21:53:53 +02:00
Dimitri Fontaine
88eba90776 Handle "ragged right" fixed width files, fix #82. 2014-06-17 17:24:07 +02:00
Dimitri Fontaine
9ad98c5c2a Handle errors when parsing fixed width files, per #82. 2014-06-17 17:10:04 +02:00
Dimitri Fontaine
899f0a3291 Improve nil handling of transformation functions, fix #81.
Several transformation functions where not handling nil value
specifically, preventing the compiler to do its best and producing
WARNING at pgloader run time.
2014-06-17 16:13:35 +02:00
Dimitri Fontaine
f5c703c206 Handle camelCase column names for CSV, fix #79 again.
The previous patch didn't take into account the need to retain the case
of the PostgreSQL column names when using double-quotes in the load
command, which is now properly forwarded down in the COPY command.
2014-06-16 17:33:14 +02:00
Dimitri Fontaine
0cba5edacd Handle the whole of PostgreSQL errors.
In a recent test case about camelCasing column names, another kind of
error did pop up and there's really no point not to handle it correctly.
2014-06-16 17:31:41 +02:00
Dimitri Fontaine
ecd4f31d12 Accept more syntaxes for fields and columns, fixes #79.
With this patch it's now possible to "quote" column names and to use
_ (underscore) as the leading character in a field or column name. Of
course it is still unnecessary to quote the column names, but handling
the PostgreSQL quoting rules can't be bad here.
2014-06-16 16:27:46 +02:00