Easysoft ODBC-ODBC Bridge

Why do I get "[unixODBC][Easysoft ODBC (Server)]Memory allocation error"?

Article:
00712
Last Reviewed:
17th January 2024
Revision:
2

There is more than one way of getting this error, but the most common reason is the application calling SQLBindCol with a very large BufferLength argument. This often arises from the following sequence of events:

  1. SQLPrepare(select bigcol from table)
    SQLExecute
    SQLDescribeCol(1) - returns bigcol, which is a big number (e.g. 1073741824)
    SQLBindCol(1, BufferLength=number_returned_from_SQLDescribeCol)
  2. The Easysoft ODBC-ODBC Bridge Client and ODBC-ODBC Bridge Server are running on different machines.
  3. The application calls SQLBindCol with a very large buffer size.

In effect, the application is saying I have this much memory available for the column data (even if it doesn't). The ODBC-ODBC Bridge Server needs to allocate the same buffer size to hold the data returned from the ODBC driver, and in the case of very large buffers, that is sometimes not possible. In most cases, the application did not intend to do this or does not have that much buffer space available. There is one specific example of this with Perl's DBD::ODBC driver and SQL_WLONGVARCHAR columns:

DBD::ODBC only supports SQL_WLONGVARCHAR if the ODBC header files it is built with include sqlucode.h. In some versions of DBD::ODBC, sqlucode.h is not included, and so when an SQL_WLONGVARCHAR column is seen (ntext in SQL Server) DBD::ODBC ignores LongReadLen and uses the value from SQLDescribeCol.

When building DBD::ODBC 0.45 or earlier with the ODBC-ODBC Bridge or unixODBC, the Makefile.PL needs to be altered to include sqlucode.h output in dbdodbc.h. To do this:

  1. Decide if you are building DBD::ODBC against the unixODBC Driver Manager or ODBC-ODBC Bridge directly. This affects which section of Makefile.PL you need to alter.
    • If building DBD::ODBC against ODBC-ODBC Bridge directly, look for the section of the Makefile.PL starting with:
      elsif ($myodbc eq 'esodbc') {

      move down the blocks of lines from there until you see print commands writing #include lines to SQLH. At the end of the 3 print commands (but before the end of the block '}') add:

      print SQLH qq{#include <sqlucode.h>\n};

      -Or

    • If building DBD::ODBC against the unixODBC Driver Manager, look for the section of the Makefile.PL starting with:
      "elsif ($myodbc eq 'unixodbc') {"

      Now follow the instructions in the previous bullet.

  2. After setting up all the environment variables DBD::ODBC needs run the "perl Makefile.PL", you should now have a file called dbdodbc.h, which contains a line like this:
    #include <sqlucode.h>
  3. Continue building, testing and installing DBD::ODBC as usual.
Applies To

Knowledge Base Feedback

* Did this content help you?
* Please select one option based on your first choice:

(* Required Fields)