Commit Graph

156 Commits

Author SHA1 Message Date
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
9f41e03278 Fix up libtool version-info logic 2020-09-05 10:50:24 -04: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
Evan Miller
cea7553e00 Export fakeglib symbols from main library 2020-08-31 13:27:08 -04:00
Evan Miller
8b40423f65 Merge pull request #36 from nyalldawson/precedence
Setup operator precedence for parser to avoid ambiguity and fix shift/reduce warnings
2020-08-22 18:28:23 -04:00
Nyall Dawson
83104b7b69 Setup operator precedence for parser to avoid ambiguity and fix shift/reduce warnings 2020-08-23 07:57:17 +10: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
5758cd6861 Try fixing Mac build with explicit Yacc output file 2020-08-18 09:06:17 -04:00
Evan Miller
78707f7aa3 Remove second -d flag 2020-08-18 07:48:54 -04: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
18de0070af New --disable-glib configure option
This option uses the fake GLib shim even when GLib is present on the
system.
2020-08-05 20:36:20 -04:00
Evan Miller
32ec8081b0 Fix build 2020-08-05 08:04:46 -04:00
Evan Miller
40433e3a11 Compile fakeglib into libmdbsql
Fixes build error
2020-08-05 00:55:49 -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
Chris Kerr
2f4b2d12fe Fixes build error introduced by previous commit 2013-10-13 19:11:10 +01:00
Chris Kerr
2892d519f3 Fix parallel builds (make -jN) in SQL lexer/parser
Initial bug repport:
https://bugs.gentoo.org/show_bug.cgi?id=486434
Thanks to Patrick Lauer.

Problem is that generated parser.h is not ready when lexer.l is compiled.
See
https://www.gnu.org/software/automake/manual/html_node/Yacc-and-Lex.html
https://www.gnu.org/software/automake/manual/automake.html#Yacc-and-Lex
2013-10-13 18:57:29 +02:00