0

I'm trying to work with ODBC on a Mac OS X 10.14 comp.

My devel env have a nginx webserver and php 7.3.10. After following some guides, I've installed mdbtools with odbc support.

I can read my access database with isql, via odbc name or DSN.

Command: isql -v -k "Driver=MDBTools;DBQ=/database.accdb;"
Command: isql -v MyODBOrigin

Using both connection commands, isql connects OK, and I can use a SELECT * FROM MyTable to see data.

Now, the problems:

Using PHP odbc_connect:

$connection = odbc_connect('MyODBCOrigin', '', '');
$res = odbc_exec($connection, 'SELECT * FROM MyTable');
while(odbc_fetch_row($res)){
    for($i=1;$i<=odbc_num_fields($res);$i++){
        echo "Result is ".odbc_result($res,$i);
    }
}
PHP Error:
( ! ) Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 21474836512 bytes) in /web/odbc.php on line 34
Call Stack
#   Time    Memory  Function    Location
1   0.0003  410408  {main}( )   .../odbc.php:0
2   0.5053  434576  odbc_result ( ) .../odbc.php:34

Using PDO:

$connection = new \PDO('odbc:MyODBCOrigin');
$connection = new \PDO('Driver=MDBTools;DBQ=/database.accdb;');

Using both connection methods causes odbc to die (nginx returns a 404 error).

ODBC Trace:
[ODBC][31713][1570202266.779582][__handles.c][460]
                Exit:[SQL_SUCCESS]
                        Environment = 0x7f8844001200 [ODBC][31713][1570202266.779895][SQLSetEnvAttr.c][189]
                Entry:
                        Environment = 0x7f8844001200
                        Attribute = SQL_ATTR_ODBC_VERSION
                        Value = 0x3
                        StrLen = 0 [ODBC][31713][1570202266.779998][SQLSetEnvAttr.c][381]
                Exit:[SQL_SUCCESS] [ODBC][31713][1570202266.780138][SQLSetEnvAttr.c][189]
                Entry:
                        Environment = 0x7f8844001200
                        Attribute = SQL_ATTR_CP_MATCH
                        Value = 0x0
                        StrLen = 0 [ODBC][31713][1570202266.780217][SQLSetEnvAttr.c][381]
                Exit:[SQL_SUCCESS] [ODBC][31713][1570202266.780316][SQLAllocHandle.c][377]
                Entry:
                        Handle Type = 2
                        Input Handle = 0x7f8844001200 [ODBC][31713][1570202266.780419][SQLAllocHandle.c][493]
                Exit:[SQL_SUCCESS]
                        Output Handle = 0x7f8844008a00 [ODBC][31713][1570202266.780493][SQLSetConnectAttr.c][399]
                Entry:
                        Connection = 0x7f8844008a00
                        Attribute = SQL_ATTR_AUTOCOMMIT
                        Value = 0x1
                        StrLen = -6 [ODBC][31713][1570202266.780562][SQLSetConnectAttr.c][691]
                Exit:[SQL_SUCCESS] [ODBC][31713][1570202266.780625][SQLSetConnectAttr.c][399]
                Entry:
                        Connection = 0x7f8844008a00
                        Attribute = SQL_ATTR_ODBC_CURSORS
                        Value = 0x0
                        StrLen = -6 [ODBC][31713][1570202266.780684][SQLSetConnectAttr.c][691]
                Exit:[SQL_SUCCESS] [ODBC][31713][1570202266.780752][SQLConnect.c][3721]
                Entry:
                        Connection = 0x7f8844008a00
                        Server Name = [MyODBCOrigin][length = 7 (SQL_NTS)]
                        User Name = [NULL]
                        Authentication = [NULL]
                UNICODE Using encoding ASCII 'US-ASCII' and UNICODE 'UCS-2-INTERNAL'

Configuration used for tests:

My odbc.ini:
[MyODBCOrigin]
Description = Example
Driver = MDBTools
Servername = localhost
Database = /database.accdb
UserName =
Password =
port = 5432
My odbcinst.ini:
[ODBC]
Trace = 1
TraceFile = /tmp/odbctrace.log

[MDBTools]
Driver = /usr/local/lib/libmdbodbc.dylib
Setup  =

Anyone can help me with this problem?

EDIT

I've found this "bug report" on mdbtools repository. That seems to be the same problem. I've tried the solution suggested on last comment but it's not working.

EDIT2

Using SQL_CUR_USE_ODBC as parameter for odbc_connect() return a 404 nginx error (odbc process die, same error as with pdo). Using SQL_CUR_USE_DRIVER, returns the specified error (fatal error detail on this post).

TallTed
  • 9,069
  • 2
  • 22
  • 37
Sakura Kinomoto
  • 1,784
  • 2
  • 21
  • 30
  • Are you able to try same in a `docker` container? It feels more like your env problems. – freeek Oct 04 '19 at 15:36
  • I didn’t tried because that’s my dev env and I doesn’t use docker on it... I have all apps/drivers installed on the OS – Sakura Kinomoto Oct 04 '19 at 15:59
  • Yea, I believe. Just isolation helps a lot finding such bugs, as we are not able to reproduce your env. Just giving you some hint to solve you the problem. – freeek Oct 04 '19 at 16:02
  • I Know I can do a workaround if I use virtualization, containers, or even another machine (for example, windows or *nix ones). But the question are about a problem and a possible fix, not a workaround. I have *nix servers for devel, for testing and for production, but I want to manage a copy on my actual personal devel environment, I'm not trying to revamp all the env. – Sakura Kinomoto Oct 04 '19 at 23:35

0 Answers0