Commit Graph

966 Commits

Author SHA1 Message Date
Evan Miller
77ee311eec Rearrange some ODBC code
Move unixODBC specific code to its own source file, and support old
iODBC installations that have only iodbinst.h.
2021-09-08 11:07:17 -04:00
Evan Miller
c04a3fb9a7 Merge branch 'dev' of github.com:mdbtools/mdbtools into dev 2021-09-08 10:58:30 -04:00
Evan Miller
ee5834d239 Print deprecation warnings before usage info 2021-09-08 10:50:28 -04:00
Evan Miller
f0d435ecdb Use TLS macro for cross-platform thread-local storage 2021-09-08 09:09:03 -04:00
Evan Miller
c137d64d13 Improved bounds checking 2021-09-08 06:41:58 -04:00
Evan Miller
4369721363 ODBC: Support SQL_C_WCHAR target type. Fixes #347
Also remove SQLFetchW and SQLGetDataW since they are not documented
in any other ODBC drivers.
2021-09-08 06:15:59 -04:00
Evan Miller
a0e72c5dfa Implement SQLFetchW
Fixes #347
2021-09-06 15:09:46 -04:00
Evan Miller
16b2970931 Merge pull request #344 from nyalldawson/repid_odbc_str2
Customizable UUID format with mdb_uuid_to_string_fmt()
2021-08-30 09:17:25 -04:00
Nyall Dawson
98ef4a1663 [odbc] Ensure repid field formatting matching Microsoft Access ODBC
driver formatting of these fields (i.e. without surrounding {} braces)
2021-08-30 09:34:29 +10:00
Evan Miller
92dc91bfe8 Merge pull request #343 from nyalldawson/fix_index_read_errors
Fix accidental reads of non-index data as indices
2021-08-29 07:20:27 -04:00
Nyall Dawson
d94796d79b Fix accidental reads of non-index data as indices
Follow up be2a287f5c - it's hard to be sure from the commit message,
but I suspect the intention here was to reduce the number of indices
read in that particular situation, instead of allowing replacing
the number of real indices read direct from the table definition
with a larger number.

In any case, omitting a possible index definition which exists
is a safer approach then trying to read an index from non-index data.

Fixes #335
2021-08-29 16:22:34 +10:00
Nyall Dawson
dccc88b722 Fix incorrect conversion of double values
Fixes #339
2021-08-29 15:31:00 +10:00
Nyall Dawson
4c61f2d49b Handle sql queries where a double constant value has a trailing .
with no extra digits, e.g. "my_double_col" = 123.
2021-08-26 23:54:06 -04:00
Nyall Dawson
036f9b95c6 Handle sql queries where a double column is compared to an int
eg "my_double_column" = 123
2021-08-26 23:54:06 -04:00
Nyall Dawson
f4ca6b9e57 Handle sql queries where an integer column is compared to a double value
(e.g. "my_int_column" = 123.0)
2021-08-26 23:54:06 -04:00
Nyall Dawson
f557e6525b Better error output 2021-08-26 23:49:11 -04:00
Nyall Dawson
fa336fd325 Handle sql queries using REP_ID columns 2021-08-26 20:17:39 -04:00
Evan Miller
41d2a797ab Check for mbstowcs_l separately 2021-08-24 15:15:34 -04:00
Evan Miller
0164b4df1a Move Unicode ODBC functions to separate file (remove ODBC's iconv)
Use wcstombs and friends to perform Unicode conversion inside the ODBC
driver. Functionality should be identical as before, except that
installations without iconv will now be able to compile and install the
Unicode (libmdbodbcW) driver.

iconv remains present in the main libmdb library.
2021-08-23 13:39:39 -04:00
Evan Miller
d3eea5f38e Simplify some locale_t code 2021-08-22 12:20:13 -04:00
Evan Miller
d1369407c5 --disable-iconv configure option 2021-08-22 11:36:31 -04:00
Nyall Dawson
fadd536e2e Add support for <> SQL operator (#329) 2021-08-22 00:28:29 -04:00
Evan Miller
49ee8272ab Remove _GNU_SOURCE (rely on AC_USE_SYSTEM_EXTENSIONS) 2021-08-20 08:23:24 -04:00
Evan Miller
f71924dab6 Use AC_USE_SYSTEM_EXTENSIONS
Defining _XOPEN_SOURCE explicitly in the source file leads to all kinds
of cross-platform headaches, plus incompatibilities between
configure-time capabilities and compile-time features. Let autoconf sort
out how to expose the largest number of functions in a way that is
consistent between configuration and compilation.
2021-08-20 08:06:19 -04:00
Evan Miller
89c7aa27b4 Fix create/drop incorrect argument order
Fixes #328
2021-08-20 08:03:44 -04:00
Nyall Dawson
05d1b373d5 [odbc] Format boolean values correctly as SQL_C_CHAR (#327)
When a boolean column value is requested as a SQL_C_CHAR value,
correctly return a "1" or "0" string value
2021-08-19 21:21:46 -04:00
Evan Miller
7fb7660b09 Restore previous mdb_register_backend API
Add new mdbi_register_backend2 function with the features introduced in
PRs #321 and #322. The purpose is to prevent API/ABI breakage in the
1.0 release.
2021-08-19 06:23:16 -04:00
Nyall Dawson
cfbca2af03 Copy date formats when cloning handle (#326)
Fix date format for odbc handles get reset to default date format
for backend when handle is cloned
2021-08-18 22:08:07 -04:00
Evan Miller
4143f34706 Install ODBC drivers to odbc/ subdirectory
See #315
2021-08-04 16:29:31 -04:00
Evan Miller
d5a42d9fed Bump _XOPEN_SOURCE to 700
This allows locale_t to be defined on Linux.
2021-08-04 16:06:47 -04:00
Evan Miller
c866b04b74 Fix Linux build 2021-08-04 15:59:17 -04:00
Evan Miller
a803abe1cf Change #if to #ifdef in a couple places 2021-08-04 15:55:20 -04:00
Evan Miller
12a888988d Update README and deprecate mdb-hexdump 2021-08-04 15:33:43 -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
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
4b5ff01a59 Corrected the name of generated PostgreSQL boolean data type (https://www.postgresql.org/docs/13/datatype-boolean.html) 2021-08-01 18:00:28 +01: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
Jose Hernandez
cec507b967 Introduced customised "create table" DDL statements per database type and made table creation statement in PostgreSQL idempotent so that the DDL generated by mdbtools works nicely with database versioning tools such as flyway or liquibase. 2021-07-31 13:34:08 +01:00
Evan Miller
8692586205 Merge branch 'dev' into no-sql 2021-07-24 11:34:25 -04:00
Evan Miller
f79f942d1f Fix RC4 decryption on big-endian platforms 2021-07-17 10:13:24 -04:00
Evan Miller
45779d03ff Merge pull request #319 from Bob620/dev
sql: Properly handle arbitrary parentheses placements in PATH breaking SELECT functions
2021-07-14 12:41:59 -04:00
Evan Miller
fe77bc5c8e Remove uses of ntohl 2021-07-14 09:33:24 -04:00
bob620
cf0f5f249c sql: fix arbitrary path parentheses placement interfering with functions 2021-07-13 16:25:32 -05:00
bob620
f7662e18ea sql: fix function arbitrary length requirement 2021-07-13 14:41:31 -05:00
Hans de Goede
d1a2f179cc Fix -Werror=array-bounds compile error in src/odbc/odbc.c
Use a local variable instead of casting the address of a SQLSMALLINT
to a (size_t *). sizeof(SQLSMALLINT) < sizeof(size_t) so gcc is
rightfully giving the following errors when building on Fedora 34:

/usr/include/sqlucode.h: In function 'SQLErrorW':
odbc.c:130:20: error: array subscript 'size_t[0]' is partly outside array bounds of 'SQLSMALLINT[1]' [-Werror=array-bounds]
  130 |         size_t lin=*_lin, lout=*_lout;
      |                    ^~~~~
odbc.c:974:21: note: while referencing 'pcbErrorMsg8'
  974 |         SQLSMALLINT pcbErrorMsg8;
      |                     ^~~~~~~~~~~~
odbc.c:133:15: error: array subscript 'size_t[0]' is partly outside array bounds of 'SQLSMALLINT[1]' [-Werror=array-bounds]
  133 |         *_lin -= lin;
      |               ^~
odbc.c:974:21: note: while referencing 'pcbErrorMsg8'
  974 |         SQLSMALLINT pcbErrorMsg8;
      |                     ^~~~~~~~~~~~
odbc.c:133:15: error: array subscript 'size_t[0]' is partly outside array bounds of 'SQLSMALLINT[1]' [-Werror=array-bounds]
  133 |         *_lin -= lin;
      |         ~~~~~~^~~~~~
odbc.c:974:21: note: while referencing 'pcbErrorMsg8'
  974 |         SQLSMALLINT pcbErrorMsg8;
      |                     ^~~~~~~~~~~~
cc1: all warnings being treated as errors
2021-07-08 22:16:02 +02:00
Evan Miller
2be2ab711e Remove tautological comparison
Fixes warnings with some versions of GCC
2021-06-10 09:50:51 -04:00
Evan Miller
d72e6381fe Fix build on some ancient systems 2021-06-03 10:05:18 -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
a31a95056d Simplify logic 2021-06-02 09:16:55 -04:00