Commit Graph

100 Commits

Author SHA1 Message Date
Evan Miller
c866b04b74 Fix Linux build 2021-08-04 15:59:17 -04:00
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
3e11f6dc26 Set _XOPEN_SOURCE to 600. Fixes #301
Some platforms including RHEL need _XOPEN_SOURCE to be defined as a
particular value. 600 seems to be a popular choice.
2021-05-18 14:01:01 -04:00
Evan Miller
ceb65d6ece Conditionally define _XOPEN_SOURCE
Fixes #298
2021-04-13 07:19:19 -04:00
Evan Miller
c494f0d746 SQL: Allow spaces in DB names (remove wordexp.h)
Fixes #292
2021-04-04 22:07:31 -04:00
Evan Miller
f1eac042b5 Fix misuse of "%*s" in sprintf strings
%*s takes the output length, not the input length. The intended
specifier was %.*s in several places. Bug(s) introduced in
2bb31f05ee
2021-01-21 18:27:20 -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
pedromorgan
da730d3696 apidocs with doxygen 2021-01-16 16:05:28 +00:00
Evan Miller
c31daeb2c4 Improved bounds and return value checking (oss-fuzz/29329) 2021-01-07 19:59:45 -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
e7d5125e2b Fix libmdbsql build on Windows 2020-12-17 11:04:54 -05:00
Evan Miller
1efe8fc709
Merge pull request #194 from evanmiller/bounds-check-mdb-sql-bind-column
[Updated] Bounds check mdb_sql_bind_column()
2020-11-14 08:16:53 -05:00
Evan Miller
1bef1b1dca Use re-entrant functions in a couple of places
Replace strtok and gmtime with their re-entrant versions. More to come.
2020-11-12 11:20:05 -05:00
Evan Miller
12de22459a Fix indentation warning on GCC 2020-11-08 09:39:59 -05:00
Evan Miller
cdc0d184f2 Fix syntax error 2020-11-08 09:25:26 -05:00
Evan Miller
bbc53dfade Bounds check mdb_sql_bind_column()
Return -1 if the bounds check fails, otherwise the result of
mdb_bind_column_by_name.

Update other places in the code to check the return value.
2020-11-08 08:50:17 -05:00
Evan Miller
8b7162ded3 Merge branch 'dev' of github.com:mdbtools/mdbtools into merge-166 2020-11-01 07:55:53 -05:00
Nyall Dawson
3ac497c6ff Fix crash when a missing file is accessed via ODBC 2020-10-12 13:47:11 +10: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
f915a4f601 Fix double free (merge error) 2020-09-02 16:18:34 -04:00
Evan Miller
55e39b6ba9 Fix merge errors 2020-09-02 15:53:21 -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
Nyall Dawson
88e2ffa34a const correctness (fixes warning) 2020-08-23 07:56:26 +10: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
Nyall Dawson
333f4712b9 Fix empty table results
Fixes #19
2020-08-19 10:28:01 +10:00
Evan Miller
858e1dff49
Merge pull request #16 from nyalldawson/reentrant
Make SQL parser/lexer reentrant
2020-08-18 07:20:35 -04:00
Evan Miller
1e983c70f1
Merge pull request #18 from nyalldawson/fix_limit
Fix LIMIT clause is ignored when executing SQL via ODBC, incorrect behavior with LIMIT 0
2020-08-18 07:02:00 -04:00
Nyall Dawson
083ec7f9e4 SELECT ... LIMIT 0 should return no rows, not all rows 2020-08-18 14:54:38 +10:00
Nyall Dawson
e82c1e9e1b Fix another leak 2020-08-18 14:36:44 +10:00
Nyall Dawson
e8ab7e7ea6 Fix leak after running "SELECT COUNT(*)..." sql query 2020-08-18 12:36:29 +10:00
Nyall Dawson
c65b402348 Fix leak after running "SELECT COUNT(*)..." sql query 2020-08-18 12:31:38 +10:00
Nyall Dawson
e92f14f9c4 Make SQL parser/lexer reentrant
Provides thread safety for mdbtools ODBC driver
2020-08-18 12:23:04 +10: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
2be700826a Fix build error when strptime is not present 2020-08-04 17:38:07 -04:00
Evan Miller
a9fb4c65d3 Fix strict prototypes warning 2020-08-04 17:35:20 -04:00
leecher1337
135f452407
Merge branch 'master' into master 2017-12-03 17:02:15 +01:00
Nirgal Vourgère
492df3e927 Spelling fixes
Thanks lintian
2016-10-24 22:54:13 +02:00
Brian Bruns
23bab7c2d6 add support for LIMIT clause in SQL engine 2016-08-30 08:43:34 -04:00
leecher1337
e2449c11f3 Added strptime function to SQL parser as a feature. This is needed to i.e. be able to query time-fields in DB and to use dates <1.1.1970 and >19.1.2038. All changes should be backwards-compatible to not break existing queries. 2015-08-30 11:23:57 +02:00
leecher1337
16bf355d6b Added simple support for count(*) to SQL parser to quickly get number of rows in table 2015-08-20 14:35:09 +02:00
William Rogers
4148518906 Freed memory on SQL engine termination
Modified mdb_sql_exit to free the memory allocated for the SQL engine in mdb_sql_init
2015-05-24 18:04:14 -05:00
William Rogers
0123d7e1c2 Fixed memory leak - sql->bound_values
Memory allocated by mdb_sql_bind_all for sql->bound_values was being leaked at each query execution.  Memory is now freed in mdb_sql_reset
2015-05-24 17:12:29 -05: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
Nirgal Vourgère
1213f84859 Fix buffer overflow in sql error message buffer
Also use existing buffer when printing to stderr
2013-10-13 09:05:18 +02:00
bokic
bb08d92bfb FIX: mdb-sql crashed with SIGSEGV in _IO_vfprintf_internal() on amd64
https://bugs.launchpad.net/ubuntu/+source/mdbtools/+bug/1227033
2013-10-06 06:23:35 +02: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
Nirgal Vourgère
a69281e7bf Fix memory leak
Free sql->cur-table->sargs_tree
Thanks William Rogers.
2013-06-27 13:09:53 +02:00