Commit Graph

1288 Commits

Author SHA1 Message Date
Dimitri Fontaine
bd44e6423b Add support for IXF CLOB data type.
In passing, fix the condition message to read the unknown IXF data types
as decimal numbers (rather than hexadecimal) as they are documented that
way in the IBM reference documentation.
2015-09-23 23:15:48 +02:00
Dimitri Fontaine
598c860cf5 Improve user code parsing, fix #297.
To be able to use "t" (or "nil") as a column name, pgloader needs to be
able to generate lisp code where those symbols are available. It's
simple enough in that a Common Lisp package that doesn't :use :cl
fullfills the condition, so intern user symbols in a specially crafted
package that doesn't :use :cl.

Now, we still need to be able to run transformation code that is using
the :cl package symbols and the pgloader.transforms functions too. In
this commit we introduce a heuristic to pick symbols either as functions
from pgloader.transforms or anything else in pgloader.user-symbols.

And so that user code may use NIL too, we provide an override mechanism
to the intern-symbol heuristic and use it only when parsing user code,
not when producing Common Lisp code from the parsed load command.
2015-09-21 13:23:21 +02:00
Dimitri Fontaine
fe812061c4 Update README file for build instructions, fix #296.
When building from source you should really build from current's HEAD in
git master branch...

In passing, comment out the --self-update paragraph as it's know to be
broken unless you still have all the source dependencies at the right
place for ASDF to find them... making the feature developer only.
2015-09-17 20:27:55 +02:00
Dimitri Fontaine
f6aa8210b9 Load libsybdb even in --dry-run mode, fix #295. 2015-09-16 20:39:42 +02:00
Dimitri Fontaine
78c6bf097a Fix the build again.
Once more did I change a test file data and forgot to commit the changes
to the expected file of the regression test.
2015-09-12 00:40:15 +02:00
Dimitri Fontaine
98f18c4877 Improve CSV date format, fix #293.
The date format wouldn't allow using colon (:) in the noise parts of it,
and would also insist that milliseconds should be on 4 digits and micro
seconds on 6 digits. Allow for "ragged" input and take however many
digits we actually find in the input.
2015-09-12 00:35:14 +02:00
Dimitri Fontaine
a195ac6dd4 Adapt to the new cl-ixf API.
This allows fixing bugs in processing the IXF files, which pgloader
directly benefits from.
2015-09-12 00:19:02 +02:00
Dimitri Fontaine
a0dc59624c Fix schema qualified table names usage again.
When the list of columns of the PostgreSQL target table isn't given in
the load command, pgloader will happily query the system catalogs to get
that information. The list-columns query didn't get the memo about the
qualified table name format and the with-schema macro... fix #288.
2015-09-11 11:53:28 +02:00
Dimitri Fontaine
e054eb3838 Travis: set PGTZ in regress.sh
The TimeZone parameter should be set both for input and for output in
order to match our expected result file. Let's try to set PGTZ in the
shell environment...
2015-09-07 20:24:00 +02:00
Dimitri Fontaine
60d58a96b8 Travis: let's try to force client timezone.
The cvs-parse-date test is failing on Travis because the server up there
in the Cloud isn't using the same timezone as my local machine. Let's
just force the timezone in the SET clause...
2015-09-07 20:00:05 +02:00
Dimitri Fontaine
3f539b7384 Travis: update expected output file.
Forgot to update the expected output file in the previous commit, which
Travis is rightfully complaining about...
2015-09-07 17:47:03 +02:00
Dimitri Fontaine
04b2779239 Allow date format parsing to support time.
A useful use case for date parsing at tine input level is to parse
time (hour, minutes, seconds) rather than a full date (timestamp).
Improve the code so that it's possible to use the date format facility
even when the data field lacks the year/month/day information.

Fix #288.
2015-09-07 17:05:10 +02:00
Dimitri Fontaine
bd50ba45ea Make it easier to contact me from the moral license. 2015-09-06 22:00:02 +02:00
Dimitri Fontaine
769a4c579f Preparing next pgloader release (3.2.2). 2015-09-06 21:14:24 +02:00
Dimitri Fontaine
87698cf114 Fix MS SQL int conversion, fix #282.
This is a blind fix that I hope is the one needed, wherein -1 get sent
to unsigned-to-sign which fails to handle it as expected. The protocol
and driver are then sending unsigned ints and that's what we now handle
in the CFFI layer.

This allows to push the attempt to ease testing of it, and allows me
also to cut a release without modified files handling around.
2015-09-06 21:11:14 +02:00
Dimitri Fontaine
fce44a3f49 Update website, download, sponsors, license.
The download section now explains why binaries are not to be found here
anymore. Also we add Redpill Linpro as a sponsor, and we add a pgloader
Moral License page in the spirit of the Varnish License. Let's see what
happens with that.
2015-09-06 21:05:00 +02:00
Dimitri Fontaine
930b540aff Default to source table name in IXF loading.
The cleanup introduced by eabfbb9cc8 did
break the case when we lack a target table name for the IXF load. Just
default to using the source name in that case.
2015-09-04 14:15:48 +02:00
Dimitri Fontaine
33fc3add25 Handle default values particularities for IXF.
It turns out that IXF format might embed particulars of the systems the
data comes from (Informix or DB2) and we need to process some strings so
that they are compatible with PostgreSQL ("CURRENT TIMESTAMP" here).

See #272 that should be fixed here, but being in the blind, don't close
the issue just yet.
2015-09-04 12:25:11 +02:00
Dimitri Fontaine
e76a4c8f5a Error early when failing to match IXF type.
Our IXF type matching appears to be incomplete, and pgloader would then
happily try to create a table column of type NIL in PostgreSQL: prevent
that from happening by raising an error condition early. Fix #289.
2015-09-04 12:17:57 +02:00
Victor Kryukov
792db2fcf4 Better regexp for PG SQL identifiers 2015-09-04 01:15:45 +02:00
Victor Kryukov
54997be2dd Fix 182: properly quote tables with . in their names 2015-09-04 01:15:29 +02:00
Dimitri Fontaine
eabfbb9cc8 Fix schema qualified table names usage (more).
When parsing table names in the target URI, we are careful of splitting
the table and schema name and store them into a cons in that case. Not
all sources methods got the memo, clean that up.

See #182 and #186, a pull request I am now going to be able to accept.
Also see #287 that should be helped by being able to apply #186.
2015-09-04 01:06:15 +02:00
Dimitri Fontaine
92d27f4f98 Allow quote/downcase identifiers option for MS SQL.
As seen in #287 the previous decision to force quoting to :none is
wrong, because index names in MS SQL source database might contain
spaces, and then need to be quoted.

Let's see what happens if we do it the usual way for MS SQL too, and
allow users to control the quoting behaviour of pgloader here.
2015-09-03 23:34:25 +02:00
Dimitri Fontaine
b78bb6dd31 Allow quoted field names to contain spaces, fix #285.
Given a fully quoted field name, there should be no restriction about
using spaces in between the quotes, but the parser used to choke on that
case.
2015-09-01 14:32:50 +02:00
Dimitri Fontaine
62f0b7fc56 Support String Constants with Escapes in SQL files.
pgloader has to parse external SQL files because of the driver we use,
Postmodern, only know how to deal with sending one query at a time. So
SQL parsing we do, and split the queries, and send them one after the
other to the server.

PostgreSQL allows String Constants with C-style Escapes to be used in
some situations, and the SQL parsing done in pgloader failed to support
that.

  http://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE

This fixes #284.
2015-08-31 20:34:22 +02:00
Dimitri Fontaine
72fdf112ff Simplify how to compute total load time, see #283.
In some cases pgloader total time computing is quite off: in the archive
case because it fails to take into account per-file before and after
sections, and in the general case when there's parallel work done.

This patch helps by storing the start time explicitely and using it at
the moment when the summary is displayed: no guessing any more. This is
only used in the archive case for now because I want some feedback.

On my machine with the usual test cases I have, the difference with and
without this patch is line-noise, something more serious has to be done:
let's push testing to the user by committing this early version of the
work.
2015-08-29 23:08:22 +02:00
Gavin Wahl
d71d39c59f Fix mssql int conversion
The case statement got messed up in commit db0f21b5a5. Fixes #277.
2015-08-26 10:17:10 +02:00
Dimitri Fontaine
75727df72f Quote table names when migrating from SQLite, fix #281.
Apparently I just forgot to apply any smartness whatsoever to SQLite
identifiers and just copied them as they are to PostgreSQL. Change that
by calling apply-identifier-case.
2015-08-25 01:13:19 +02:00
Dimitri Fontaine
573a63cd3a Add a local test, per #271. 2015-08-24 16:42:39 +02:00
Dimitri Fontaine
04aa743eb7 Cleanup file based "connections".
When the notion of a connection class with a generic set of method was
invented, the very flexible specification formats available for the file
based sources where not integrated into the new connection system.

This patch provides a new connection class md-connection with a specific
sub-protocol (after opening a connection, the caller is supposed to loop
around open-next-stream) so that it's possible to both properly fit into
the connection concept and to better share the code in between our three
implementation (csv, copy, fixed).
2015-08-24 16:33:00 +02:00
Dimitri Fontaine
ea35eb575d Implement --dry-run option, fix #264.
The dry run option will currently only check database connections, but
as that happens after having correctly parsed the load file, it allows
to also check that the command file is correct for the parser.

Note that the list load-data API isn't subject to the dry-run method.

In passing, we add some more API entry points to the connection objects
and we should actually clean the code base to use the new QUERY generic
all over the place. It's for another patch tho.
2015-08-22 16:23:47 +02:00
Dimitri Fontaine
04ddf940d9 Left pad COPY octal chars with 0, fix #275.
The COPY TEXT format accepts non printable characters with an escaped
sequence wherin pgloader can pass in the octal number for the character
in its encoding. When doing that with small numbers like \6 and the
non-printable character is then followed by other numbers, then it
becomes e.g. \646 which might not be part of the target encoding...

To fix, always left pad the character octal number with zeroes, so that
we now send in \00646 which COPY knows how to read: the char at \006
then 4 then 6.

Also copy the test case over to pgloader and run it in the test suite.
2015-08-20 18:17:18 +02:00
Dimitri Fontaine
3a6120b931 Improve logging again.
The user experience is greatly enhanced by this little change, where you
know from the logs that pgloader could actually connect rather than
thinking it might be still trying...
2015-08-20 12:38:19 +02:00
Dimitri Fontaine
ba44e9786d More MySQL debugging information. 2015-08-20 12:34:12 +02:00
Dimitri Fontaine
8f0db173de Add some debug information when connecting to MySQL.
Makes debugging connection strings easier...
2015-08-20 12:19:03 +02:00
Dimitri Fontaine
178210b6f8 Fix 273 by renaming the new create-schemas option properly. 2015-08-18 17:38:04 +02:00
Dimitri Fontaine
56a89e9b53 Cleanup schema data structure building.
As reported by clisp maintainer (thanks jackdaniel!) when trying to load
pgloader, we had redoundant labels function names in places. Get rid of
those by pushing the new columns found directly at the end of the list,
avoiding the bulky code to then reverse the complex anonymous data
structure.

The Real Fix™ would be to define proper structures where to hold all
those database catalogs representation, but that's an invasive patch and
now isn't a good time to write it.

At least pgloader should load and run with clisp now.
2015-08-15 23:54:45 +02:00
Dimitri Fontaine
6fc40c4844 Implement MS SQL option to skip creating schemas, fix #263.
Allow the user to control whether pgloader should create the same set of
schema as found on the MS SQL database.
2015-08-15 16:10:15 +02:00
Dimitri Fontaine
3e3ebf2333 Fix numeric casting support for MS SQL.
It's possible to get a numeric column with nil precision and scale, and
the code wasn't ready for this situation. Bug found while seeing about
2015-08-15 16:02:21 +02:00
Dimitri Fontaine
5e7e5391ef Fix the drop indexes option again, fix #251.
The index and constraint names given by PostgreSQL catalogs should not
be second guessed, we need to just quote them. The identifier down
casing is interesting when we get identifiers from other system for a
migration, but are wrong when dropping existing indexes in PostgreSQL.

Also, the :null special value from Postmodern was routing the code
badly, just transform it manually to nil when fetching the index list,
manually.
2015-07-26 15:38:15 +02:00
Dimitri Fontaine
833b41c23b Fix the regression test expected values, see #266. 2015-07-26 14:45:43 +02:00
Dimitri Fontaine
b4b36caa84 Fix parsing dates with less-than 4 digits, fix #266.
The previous coding decided to add 2000 to the year as an integer if it
was below 2000, which parses 1999 as 3999. Oops. Trigger the correction
only when the date is given on 2 digits only, parsing 04 as 2004.

Dates given on 3 digits are kept as-is.

Playing with the *century* special parameter allows to cancel this
behavior, that maybe should be made entirely optional. It's just too
common to find current years on 2 digits only, sadly.
2015-07-26 14:41:44 +02:00
Dimitri Fontaine
d2a1a5643e Improve SQL blocks support, fix #265.
It's now possible to use several files in a BEFORE LOAD EXECUTE section,
and to mix DO and EXECUTE parts, bringing lots of flexibility in the
commands. Also it actually simplifies the parser.
2015-07-24 17:41:35 +02:00
Dimitri Fontaine
db0f21b5a5 Process MS SQL smallint datatypes as unsigned, fix #262.
The freetds protocol apparently sends unsigned versions of the values on
the wire, so that we have to convert them to signed numbers upon
reception.
2015-07-22 10:32:13 +02:00
Dimitri Fontaine
3af99051d2 Fix the preserve index names option.
MySQL names its primary keys "PRIMARY" and we need to always uniquify
this name even when the used asked pgloader to preserve index names.

Also, the create-indexes-again function now needs to ask for index names
to be preserved specifically.
2015-07-18 23:39:32 +02:00
Dimitri Fontaine
54e29773d7 Fix index creation reporting, see #251.
The new option 'drop indexes' reuses the existing code to build all the
indexes in parallel but failed to properly account for that fact in the
summary report with timings.

While fixing this, also fix the SQL used to re-establish the indexes and
associated constraints to allow for parallel execution, the ALTER TABLE
statements would block in ACCESS EXCLUSIVE MODE otherwise and make our
efforts vain.
2015-07-18 23:06:15 +02:00
Dimitri Fontaine
8511294ac7 Generalize index support to handle constraints, fix #251.
PostgreSQL rightfully forbifs DROP INDEX when the index is used to
enforce a constraint, the proper SQL to issue is then ALTER TABLE DROP
CONSTRAINT. Also, in such a case pg_dump issues a single ALTER TABLE ADD
CONSTRAINT statement to restore the situation.

Have pgloader do the same with indexes that are used to back a constraint.
2015-07-17 17:06:09 +02:00
Dimitri Fontaine
c3986b0997 Cast MySQL bigint(20) into numeric, fix #253.
In MySQL it's possible to have a bigint of 20 digits when using the
"unsigned" variant of the data type, whereas in PostgreSQL there's no
such variant and bigints are "limited" to the range -9223372036854775808
to +9223372036854775807 (19 digits numbers).

Fix the default casting rule to switch to PostgreSQL numeric in such cases.
2015-07-17 12:05:28 +02:00
Dimitri Fontaine
a308dd9bda Desultory code review and indentation. 2015-07-17 12:04:57 +02:00
Dimitri Fontaine
a98788b670 Implement drop indexes option for copy and fixed.
The option doesn't seem relevant to the db3 source type which contains a
table definition: pgloader will create the table from scratch and no
indexes are going to be found.
2015-07-16 21:39:06 +02:00