Commit Graph

52 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
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
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
d089c4072d More locale-awareness for command line arguments 2021-01-18 18:15:30 -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
538711e450 Remove unnecessary casts 2020-12-28 22:30:20 -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
8b7162ded3 Merge branch 'dev' of github.com:mdbtools/mdbtools into merge-166 2020-11-01 07:55:53 -05: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
e30b8a395a Merge branch 'sql_dynamic_bound_length' of github.com:mdbtools/mdbtools into merge-166 2020-09-02 15:33:20 -04:00
Evan Miller
90ee7bfcb5 Remove references to dmalloc
There are more modern tools for memory debugging, get rid of DMALLOC
crap in the source code.

I've left one reference in backend.c to prevent a merge conflict but
this can be removed later.
2020-08-20 08:59:08 -04:00
Evan Miller
c93156626c Fix all sign-compare warnings
Also flip on -Wsign-compare in the default configuration
2020-08-09 16:15:20 -04:00
Evan Miller
61d928ea68 Fix warning when compiling without Readline 2020-08-03 15:13:11 -04:00
Brian Bruns
23bab7c2d6 add support for LIMIT clause in SQL engine 2016-08-30 08:43:34 -04:00
William Rogers
82e3436494 Corrected memory being improperly freed
The memory for sql->bound_values is now freed by mdb_sql_reset, so these values no longer should be freed in dump_results_pp.  Also, this fixes a memory leak that was occurring when results were not being pretty printed.
2015-05-24 17:15:52 -05:00
William Rogers
9276aca347 Consolidated calls to mdb_sql_reset
SQL engine was being reset in both dump_results functions.  Rather than having several different functions responsible for resetting the engine depending on the circumstances, the reset now only occurs in run_query, the same function where the query is executed.
2015-05-24 17:05:41 -05:00
Nirgal Vourgère
072f7c6518 Decrease POSIX required level to 1
One can now compile with CFLAGS="-std=c99 -D_POSIX_C_SOURCE=1 -pedantic"

Trade getopt.h function for glib equivalents:
This mean all utilities now have long option names.
Adjust manuals and bash_completion accordingly.

Added missing manual and bash_completion for mdb-import.
2014-12-29 13:12:23 +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
William Rogers
28af8d296a Dynamic allocation of MdbSQL->bound_values
Was previously hardcoded to 256 columns max.
2013-06-27 15:09:15 +02:00
William Rogers
ecc72f8faf mdb_sql_bind_all already in mdb_sql_run_query 2013-06-26 12:13:44 +02:00
Nirgal Vourgère
f6cd70494c Automatically init/exit libmdb code
mdb_init() and mdb_exit() are now deprecated.
2012-07-22 02:29:04 +02:00
Nirgal Vourgre
dd0f4c3819 Patch docs.diff from Nirgal 2011-08-28 19:53:29 -04:00
Nirgal Vourgre
07f915b3c7 Patch utfsql.diff from Nirgal 2011-08-28 19:49:54 -04:00
Nirgl Vourgère
3f26ec69cf Stop exporting internal libmdbsql symbols 2011-08-10 18:02:51 -04:00
Nirgal
456f261cab Bunch of fixes for compilation warnings, mostly unused vars. 2011-08-10 18:00:18 -04:00
whydoubt
2b2e300513 Add fflush after each newline (Pedro Gutierrez) 2005-12-17 09:55:38 +00:00
whydoubt
278b6e284c Fix several leaks and errors 2005-11-09 13:24:26 +00:00
brianb
a443e83ae7 Clean up for 0.6 release and some bug fixes 2005-09-07 23:27:43 +00:00
whydoubt
fd550a5f52 Clean up some memory leaks 2004-12-01 06:34:27 +00:00
whydoubt
8b9c2cda5a Various mdb-sql improvements 2004-10-28 03:33:20 +00:00
whydoubt
fd04c906c8 Readline usage fixes 2004-10-25 04:11:13 +00:00
whydoubt
56995ff968 Enable multi-page temp tables 2004-09-09 03:44:35 +00:00
whydoubt
e121a82946 Lots more gcc warnings fixes 2004-07-09 12:47:04 +00:00
brianb
642a74c8c3 fix readline detection 2004-06-20 14:36:23 +00:00
whydoubt
a5afa5c9e4 better utilize glib functions, fix memory leaks 2004-05-30 07:19:22 +00:00
brianb
acd03635c4 broken pipe on commit, see previous log 2004-03-06 05:14:14 +00:00
brianb
fed589b2e7 rework of patch #879693 to support 0=1 in where clause 2004-02-08 21:54:20 +00:00
brianb
af7b6953ad last commit failed, see ChangeLog for changes 2004-02-06 02:35:18 +00:00
brianb
11b43644dc patches 00-14 from David Mansfield 2004-01-06 00:42:07 +00:00
brianb
75216d7a90 index work
dmalloc headers
mem leak fixes
start on i18n
2003-01-28 23:51:06 +00:00
brianb
f30001a4f5 typo fix 2003-01-22 20:15:42 +00:00
brianb
092e2b79af query planner stuff
some gcc -Wall fixes
added suport for _ in identifier names in SQL
gmdb2 manual additions
2003-01-20 16:04:24 +00:00
brianb
320f03c401 added man pages for utils.
lots of gmdb2 work.
added statistics collection.
2003-01-05 14:57:50 +00:00