Commit Graph

95 Commits

Author SHA1 Message Date
Evan Miller
20842c642a mdb-schema: Exit with code 1 if the requested table is not found 2021-01-12 14:08:25 -05:00
Evan Miller
c31daeb2c4 Improved bounds and return value checking (oss-fuzz/29329) 2021-01-07 19:59:45 -05:00
Evan Miller
24a7fdab78 Restore 0.9.0 API backward compatibility of mdb_print_col and MDB_BINEXPORT_*
Other programs (e.g. gmdb2) use mdb_print_col, so restore the old enum
names and values. MDB_EXPORT_ESCAPE_INVISIBLE can be OR'ed into the
last argument to enable C-style escaping of text fields.
2020-12-30 10:28:49 -05:00
Evan Miller
0ad6fb33f6 Merge pull request #222 from evanmiller/merge-108
Revise and merge in #108 (new --escape-invisible flag to mdb-export)
2020-12-29 12:50:04 -05:00
Evan Miller
aeee354405 Fix infinite loop exporting SQLite schema 2020-12-29 09:24:31 -05:00
Evan Miller
538711e450 Remove unnecessary casts 2020-12-28 22:30:20 -05:00
Evan Miller
2bb31f05ee Improve bounds checking
No particular crashes, but replace strcpy / strncpy with snprintf
and GLib functions wherever possible.
2020-12-28 20:12:39 -05:00
Evan Miller
ccd19c69fa SQLite does not support foreign keys via ALTER TABLE
See #82. A complete solution would add the foreign keys to CREATE TABLE
but the goal here is to stop generating bad SQL.
2020-12-21 17:28:29 -05:00
Ewen McNeill
c13bcc75a7 Postgres: No namespace in INDEX, CONSTRAINT names
src/libmdb/backend.c:mdb_print_indexes() and
src/libmdb/backend.c:mdb_get_relationships(): In PostgreSQL the INDEX
names explicitly must not have a namespace name on them; they are always
created in the namespace of the table.  See:

http://www.postgresql.org/docs/current/static/sql-createindex.html

which says: "The name of the index to be created. No schema name can be
included here; the index is always created in the same schema as
its parent table."

By observation the same is true for CONSTRAINT names; they are refused
if the namespace is included before them.

Also omit the namespace from the FOREIGN KEY constraint _column_ names
on PostgreSQL (it's not clear that the _column_ names should ever be
namespaced, but behaviour should currently be unchanged for databases
other than PostgreSQL).
2020-12-22 10:34:23 +13:00
Evan Miller
bc97306d64 Merge branch 'master' of github.com:dragonfly-science/mdbtools into merge-108
Merge in pull request #108 with a few changes:

* Use the newer mdb_print_col function

* Redefine the last argument of mdb_print_col to be a flags argument

* Rename and redefine the BINEXPORT enums. While technically public,
  these were never intended as a public API.

* Name the command line option --escape-c
2020-12-19 13:21:32 -05:00
James Woodcock
9bf70e0e1e mdb-export: use sensible date formats 2020-10-24 09:41:39 +01:00
Evan Miller
7f7761e884 Improved support for "Short Date" fields
* Separate -D (date only) and -T (date/time) format options in mdb-export and mdb-json

* New public mdb_set_shortdate_fmt() function in libmdb

* New private(ish) mdb_col_is_shortdate() function

I'm calling it "shortdate" in order to preserve the existing API.

See https://github.com/mdbtools/mdbtools/issues/12
2020-09-02 22:14:57 -04:00
Evan Miller
aa0ce8fb3e Consolidate print_col functions into backend.c 2020-09-02 20:38:15 -04:00
Evan Miller
7b5d547acf Merge branch 'mysql-comments' of github.com:mdbtools/mdbtools into merge-164 2020-09-02 15:48:29 -04:00
Evan Miller
fb960553e6 New mdb_set_bind_size function overrides MDB_BIND_SIZE
This should fix long-standing complaints about the default bind size
without causing undue memory inflation in existing applications.

Could make this adjustable on the command line later.

Supersedes:

https://github.com/mdbtools/mdbtools/pull/137
2020-09-02 14:30:07 -04:00
Evan Miller
f668f25d99 Use GCC struct initializers for clarity 2020-08-20 15:37:05 -04:00
Evan Miller
452cd29343 Get rid of more static memory
* Replace backend_is_init (formerly is_init) with relationships_table

* Remove deprecated functions that used static variables

* Move static "bound" variable to MdbHandle as relationships_values
2020-08-20 08:47:13 -04:00
Evan Miller
588663675e Move backend dictionary and state to MdbHandle
Attempt to make the backend handling logic thread-safe. This removes the
last MDB_CONSTRUCTOR. Also get rid of some JAVA junk and make the
remaining static variables in backend.c constant. Finally remove some
obsolete fields from MdbFile.
2020-08-20 07:58:53 -04:00
Evan Miller
e7782f7821 Remove debugging comments from mdb-schema 2020-08-06 23:18:05 -04:00
Evan Miller
272bd191bc Merge branch 'master' into no-glib 2020-08-06 12:51:52 -04:00
Evan Miller
c67a92f459 Provide NUMERIC type in Postgres backend brianb/mdbtools#129 2020-08-06 08:20:11 -04:00
Evan Miller
edc20bcc39 Merge branch 'master' into no-glib 2020-08-06 08:16:06 -04:00
Evan Miller
c17aeb0826 Remove length specifier from MySQL TEXT types brianb/mdbtools#133 2020-08-06 08:15:06 -04:00
Evan Miller
68d3a22e77 Merge branch 'master' into no-glib 2020-08-05 18:49:24 -04:00
Evan Miller
d31bbe88c5 Fix crash when a date column lacks a Format property brianb/mdbtools#132 2020-08-05 18:33:33 -04:00
Evan Miller
e9f4c6c786 Remove GLib dependency WIP
Add a shim implementing half-assed versions of most of the GLib
functions used by MDB Tools. If GLib is detected at compile-time,
use it, otherwise use the shim.

This work is not complete, as the option-parsing code is not yet
implemented - so most of the command-line tools crash.
2020-08-03 17:19:40 -04:00
Evan Miller
cdde7c3268 Enable strict prototypes warnings, and fix warnings
If a host project has -Wstrict-prototypes enabled, the mdbtools header
results in warnings. Turn on -Wstrict-prototypes for the whole project
so that these never occur again.
2018-12-29 10:34:54 -05:00
Cyber Emissary
278f9ba441 Implemented bulk insert 2018-02-12 15:21:15 -05:00
Cyber Emissary
dbc7e51e98 do not include table name in MySQL indexes. 2018-02-06 13:11:13 -05:00
Cyber Emissary
fd230f68f2 precision and scale were used other way around. Flipped their usage
in all places
2018-02-06 13:10:56 -05:00
Cyber Emissary
702ce2b7cd fixed mysql types, and numeric scale/precision 2018-02-06 13:10:13 -05:00
Sam Shaw
ffccc9d1cf Oracle Foreign Keys
Oracle doesn't support the "ON UPDATE" clause for foreign keys.
2016-01-12 09:58:17 +08:00
Sam Shaw
7f21d4e030 Oracle BLOB & CLOB
BLOB and CLOB do not have a size constraint in Oracle
2015-12-23 13:46:31 +08:00
Sam Shaw
ffbc492a8b Oracle Indexes
Add syntax for creating indexes in oracle (it's the same as PostgreSQL)
2015-12-23 13:31:05 +08:00
Nirgal Vourgère
2a70e16a8b Allow CFLGAS="-std=c99 -D_POSIX_C_SOURCE=2"
Use glib function:
strcasecmp -> g_ascii_strcasecmp
bzero -> memset
strdup -> g_strdump

Don't use arithmetic void*+int
2014-12-28 12:36:55 +01:00
Mihai Draghicioiu
a2587a6830 Add database comments in mysql exports 2014-10-18 11:46:01 +02:00
Maurus Cuelenaere
e2c46bad8b Add MySQL support to mdb_print_indexes() 2014-10-17 22:18:34 +02:00
Maurus Cuelenaere
97ddfcf8b2 Introduce MDB_BACKEND_* enum 2014-10-17 22:16:49 +02:00
Maurus Cuelenaere
65b573637e Add MySQL support to mdb_print_indexes() 2014-03-17 13:30:40 +01:00
Maurus Cuelenaere
cce6cfead2 Introduce MDB_BACKEND_* enum 2014-03-17 13:30:28 +01:00
Nirgal Vourgère
7841d30d43 Revert use of config.h
Revert
7162e8db74
088493d499

And drop AC_CONFIG_HEADERS so that config goes though the command line.
No longer generating config.h, update .gitignore
2013-07-15 02:42:12 +02:00
Nirgal Vourgère
7162e8db74 Include config.h in all .c files
Need to be the first file since it may define large files support
and other options.
2013-07-04 10:53:13 +02:00
Nirgal Vourgère
6ef7da0597 Disabled schema comments for mysql backend
They were using an incorrect syntax
2013-06-29 12:13:09 +02:00
Nirgal Vourgère
8f0f167ab2 Memory leak fix
Free temporary variable in mdb_print_indexes
2013-06-28 17:54:30 +02:00
Nirgal Vourgère
687eeebe78 Memory leak fix
Need to free previous backend name when changing it.
2013-06-28 16:41:29 +02:00
Nirgal Vourgère
0196d34d7b __attribute__ change into macro
Makes it easier to port to another compiler.
Thanks Jimmy Taker
2013-06-28 01:51:52 +02:00
Jimmytaker
46005ae009 MDB_DEPRECATED redefined, Constructor MACRO, generate_table_schema changed to not static, date_fmt to ISODate
__attribute__ does not exist in Visual Studio. Therefore replaced wherever it appeared with a macro:
Redefines MDB_DEPRECATED to support Visual Studio
Define a Constructor MACRO so that __attribute__((constructor/destructor)) behavior is achieved in Visual Studio.

Just using generate_table_schema through mdb_print_schema deletes the purpose of a very good tool. generate_table_schemas is a rewrite of generate_table_schema but sends the data to a char* instead of FILE*. There is NO fmemopen() or similar in Visual Studio, so there is NO way to access memory through a FILE* except for first writing to the disk and then reading from the disk in memory.

I cannot suggest how to handle the case when td == 0 for the dates. The databases I work with often have just 00:00:00 in the DateTime column which is not consistent with the rest of the column either, but I have to deal with it somehow.

Leaving void* where char* is needed as a function parameter returns a compilation error in Visual Studio.
2013-01-14 19:27:53 +01:00
Nirgal Vourgère
a972c1638d merge with master 2013-01-14 14:20:10 +01:00
Nirgal Vourgère
eeadcb54f3 Use macros for depreacated function attributes
This will help porting on compilers that don't support it
2013-01-13 23:50:42 +01:00
Jimmytaker
c9f602480b Code cleanup
Enforce consistency g_malloc - g_free and malloc - free
Move var declarations on top of functions
2013-01-13 23:17:07 +01:00