Commit Graph

276 Commits

Author SHA1 Message Date
Evan Miller
a44a8ed8ae
Postgres-style ILIKE operator (with Unicode support) (#244)
Access's `LIKE` is actually case-insensitive, but to prevent breaking existing
programs that rely on mdbtools' case-sensitive behavior, introduce a new
`ILIKE` operator to perform a case-insensitive match. Use GLib's `g_utf8_casefold`
to make the comparison UTF-8 aware. A "poor man's" version is implemented
in fakeglib, which relies on `towlower`, and won't work with multi-grapheme
case transformations (e.g. German Eszett).

Fixes #233
2021-08-04 14:45:31 -04:00
Evan Miller
1b147b8d29
Merge pull request #276 from mdbtools/no-sql
Don't build/install mdb-sql if SQL is not supported
2021-08-04 14:12:20 -04:00
Jose Hernandez
f7b13bd4a7 Changed the definition of gssize and fixed some memory leaks following code review. 2021-08-01 17:49:21 +01:00
Jose Hernandez
afc6f4888b Added support for name normalisation when generating code for PostgreSQL so that generated artefact names are consistently exported in lowercase. 2021-08-01 15:26:40 +01:00
Evan Miller
8692586205 Merge branch 'dev' into no-sql 2021-07-24 11:34:25 -04:00
Patrick Reynolds
246f854b99
Add backticks around table names in mdb-query output (#307)
* Add [brackets] around mdb-query table names

* Allow column and table names to be in brackets

Column and table names can have whitespace in them.  The traditional way
to indicate that is with bracket characters, like so:
```sql
SELECT [column name] FROM [table name]
```

This change updates the parser to allow bracket format -- similar to
double-quoted format -- in all NAME contexts, i.e., column names, table
names, and database names.

Co-authored-by: Patrick Reynolds <patrick.reynolds@github.com>
2021-06-02 10:34:35 -04:00
Evan Miller
fe0175aa63
Migrate to g_memdup2 (#288)
With fakeglib and older versions of GLib, fall back to g_memdup with
a #define inside mdbprivate.h.

Fixes #287
2021-04-05 09:04:29 -04:00
Evan Miller
8f1f080e3f Support Access 2019
Per #260 I am assuming that the internal version 6 refers to files
created with Access 2019. I can't find any documentation on this format,
so I am calling it ACE17. Testing welcome.
2021-03-23 15:56:39 -04:00
Evan Miller
58222eeb35 Don't build/install mdb-sql if SQL is not supported
Eliminates obsolete message about --enable-sql. See #273
2021-03-23 15:53:43 -04:00
Evan Miller
1464882931 mdb-tables: Support --version flag 2021-02-22 09:24:06 -05:00
James Woodcock
a980d73447
mdb-export: handle MySQL blobs (#250)
* Refactor code so BLOBs are always correctly exported

Previously, BLOBs weren't exported from mdb-export correctly if the
backend had MDB_SHEXP_BULK_INSERT set.

* Export MySQL BLOBs correctly

MySQL BLOBs should be in the form 0x[hex values] when inserting them
with the mysql command line tool.

* MySQL needs a BLOB to store exported MDB_OLE values

MDB_OLE size always comes out as 256 bytes, but varbinary(256) is insufficient
to hold all possible OLE data.
2021-02-03 14:48:56 -05:00
Evan Miller
615b625d79 Let LC_COLLATE influence string-comparison operations
By default this will be set to the C locale, but set it to the user's
locale when string comparisons are performed from mdb-sql. Note that
this can be overridden with the LC_COLLATE environment variable.

We could infer the collation locale from the file itself, but this will
likely require a big ball of glue between the Windows locales and Unix
ones.
2021-01-19 21:24:31 -05:00
Evan Miller
f99c5539e7 Add --version option to the CLI tools
See #232
2021-01-19 20:37:25 -05:00
Evan Miller
8c91654426 Man page and usage updates
* MDBOPTS=no_memo is not used anywhere; mark deprecated and print a
  warning if enabled

* Mark MDBOPTS=use_index as experimental in the man pages

* MDBOPTS need to be colon separated

* Document new long forms of mdb-queries options
2021-01-19 16:27:36 -05:00
Evan Miller
d089c4072d More locale-awareness for command line arguments 2021-01-18 18:15:30 -05:00
Evan Miller
1e35bddc62 Migrate mdb-queries over to the GLib machinery
This buys us an auto-generated usage string and locale-awareness for the
query name. Short option names are preserved and long names are added.
2021-01-18 17:45:24 -05:00
Evan Miller
0e3a627ee6
Make command-line arguments locale-aware (#237)
GLib will automatically convert command line options to UTF-8 provided that setlocale(LC_TYPE, "") is called first, and the argument type is STRING (but not FILENAME). Update the CLI tools to take advantage of this behavior, and likewise implement it in fakeglib.

GLib does not automatically convert non-option arguments (i.e. everything remaining in argv after option processing), so manually call g_locale_to_utf8 on these arguments when they represent table names. This should fix the CLI tools when processing non-ASCII table names in non-UTF-8 locales. Also update fakeglib to implement a fast and loose version of g_locale_to_utf8, and factor out some of the code page => iconv name logic in iconv.c so it can be used in our fake g_locale_to_utf8. This adds a new symbol mdb_iconv_name_from_code_page that is not advertised in the main header file. I did not want to include mdbtools.h from fakeglib.c, but maybe that's not important.
2021-01-14 17:34:50 -05:00
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
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
538711e450 Remove unnecessary casts 2020-12-28 22:30:20 -05:00
Evan Miller
658e91c2ae Replace strcpy with g_strdup 2020-12-28 22:29:19 -05:00
Evan Miller
c10232fdf1 Use fewer hard-coded sizes 2020-12-28 22:04:06 -05:00
Evan Miller
d35807cd6c Remove unused variable 2020-12-28 20:22:19 -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
31d8bc13aa Fix extra newline in mdb-sql prompt
A newline appeared after "=> " when readline was not found on the
system.
2020-12-28 20:11:06 -05:00
Evan Miller
ebb049eb6a Rename --escape-c to --escape-invisible 2020-12-21 09:30:02 -05: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
Nirgal Vourgère
cc15473d71 Deprecate mdb-array mdb-header mdb-parsecsv 2020-11-25 12:14:45 +01:00
Evan Miller
ad14a04dfa
Merge pull request #192 from evanmiller/merge-166
Original author: @rogerswb 

* Dynamic allocation of MdbSQL->bound_values 

Was previously hardcoded to 256 columns max.
2020-11-01 08:31:50 -05:00
Evan Miller
8b7162ded3 Merge branch 'dev' of github.com:mdbtools/mdbtools into merge-166 2020-11-01 07:55:53 -05:00
James Woodcock
de4f5516b7 Handle errors from mdb_bind_column() 2020-10-31 09:46:00 +00:00
Nirgal Vourgère
9e50c7401d Modernize bash-completion
Use _init_completion
Support long options with or without =
Auto generate options from the --help using _parse_help
2020-10-27 00:05:26 +01:00
nirgal
58f240ac6f
Added back -q support 2020-10-25 20:49:20 +00:00
Nirgal Vourgère
f6053aa211 Quote shell special characters ...
... and add support for mdb-count mdb-json and mdb-queries
2020-10-25 20:19:39 +01:00
Nirgal Vourgère
c7d527fdeb mdb-export: Rename --backend into --insert 2020-10-25 12:09:51 +01:00
Nirgal Vourgère
ea478f3bc6 mdb-export: reorder options, man, bash-completion 2020-10-25 11:24:28 +01:00
Nirgal Vourgère
d0d95f6503 Install bash-completion snippets by default
Added autoconf --with-bash-completion-dir and --without-bash-completion-dir options
2020-10-23 18:58:45 +02:00
Nirgal Vourgère
f192c258ab bash-completion: get rid of "have" calls
have function disappeared in bash-completion 1.90 (2011)
2020-10-23 14:05:50 +02:00
nirgal
6a41020538
Spelling typo 2020-10-18 08:59:36 +00:00
Evan Miller
a051350ba1 make distcheck fixes 2020-10-11 15:46:19 -04:00
James Woodcock
eb5dd4d0b7 Support "SELECT TOP n [PERCENT]... " queries.
Updated the SQL parser to support "SELECT TOP n [PERCENT]... " queries,
matching the Mocrosoft Access SQL language.

Export these queries from databases with mdb-queries.
2020-09-26 11:28:34 +01:00
Evan Miller
9d0c40905d Merge branch 'dev' of github.com:mdbtools/mdbtools 2020-09-19 14:01:23 -04:00
James Woodcock
833985043f mdb-sql: Simplify handling files loaded by ":r"
:r is an undocumented command to load SQL files from the msb-sql prompt
2020-09-19 11:29:41 +01:00
James Woodcock
eab60a6060 mdb-sql: Handle ';' as terminators in SQL input files 2020-09-19 11:28:44 +01:00
James Woodcock
9c8b67b8f8 mdb-sql: support ';' as an SQL terminator 2020-09-19 11:28:00 +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
0023e4efe4 Update options documentation [CI SKIP] 2020-09-02 21:33:49 -04:00
Evan Miller
aa0ce8fb3e Consolidate print_col functions into backend.c 2020-09-02 20:38:15 -04:00
Evan Miller
e30b8a395a Merge branch 'sql_dynamic_bound_length' of github.com:mdbtools/mdbtools into merge-166 2020-09-02 15:33:20 -04:00