leptonyu / odpic-raw

Haskell raw bindings to Oracle ODPI-C Library
BSD 3-Clause "New" or "Revised" License
18 stars 5 forks source link

[WIP] support odpic 3.x #14

Closed flokli closed 5 years ago

flokli commented 5 years ago

odpic 3.0.0 introduced some breaking changes.

From their changelog:

Version 3.0.0 (September 13, 2018)
----------------------------------

#)  Added support for Oracle Client 18 libraries.
#)  Added support for SODA (as preview). See
    :ref:`SODA Database<dpiSodaDbFunctions>`,
    :ref:`SODA Collection<dpiSodaCollFunctions>` and
    :ref:`SODA Document<dpiSodaDocFunctions>` for more information.
#)  Added support for call timeouts available in Oracle Client 18.1 and higher.
    See functions :func:`dpiConn_setCallTimeout()` and
    :func:`dpiConn_getCallTimeout()`.
#)  Added support for setting a LOB attribute of an object with string/bytes
    using the function :func:`dpiObject_setAttributeValue()`.
#)  Added support for the packed decimal type used by object attributes with
    historical types DECIMAL and NUMERIC
    (`cx_Oracle issue 212
    <https://github.com/oracle/python-cx_Oracle/issues/212>`__).
#)  On Windows, first attempt to load oci.dll from the same directory as the
    module that contains ODPI-C.
#)  SQL Objects that are created or fetched from the database are now tracked
    and marked unusable when a connection is closed. This was done in order to
    avoid a segfault in some circumstances.
#)  Improved support for closing pools by ensuring that once a pool has closed,
    further attempts to use connections acquired from that pool will fail with
    error "DPI-1010: not connected".
#)  Re-enabled pool pinging functionality for Oracle Client 12.2 and higher
    to handle classes of connection errors such as resource profile limits.
#)  Improved error messages when the Oracle Client or Oracle Database need to
    be at a minimum version in order to support a particular feature.
#)  Use plain integers instead of enumerations in order to simplify code and
    reduce the requirement for casts. Typedefs have been included so that code
    does not need to be changed.
#)  Eliminated potential buffer overrun
    (`issue 69 <https://github.com/oracle/odpi/issues/69>`__).
#)  In the Makefile for non-Windows platforms, the version information for
    ODPI-C is acquired directly from include/dpi.h as suggested
    (`issue 66 <https://github.com/oracle/odpi/issues/66>`__).
#)  Removed function dpiConn_newSubscription(). Use function
    :func:`dpiConn_subscribe()` instead.
#)  Removed function dpiLob_flushBuffer(). This function never worked anyway.
#)  Removed function dpiSubscr_close(). Use function
    :func:`dpiConn_unsubscribe()` instead.
#)  Removed function dpiVar_getData(). Use function
    :func:`dpiVar_getReturnedData()` instead.
#)  Added additional test cases.
#)  Improved documentation.

So far, I did the following:

I'm currently stuck at some weird CInt / CUInt problems, and lack the haskell-foo to do that on my own:

building
Preprocessing library for odpic-raw-0.3.0..
Building library for odpic-raw-0.3.0..
[1 of 6] Compiling Database.Dpi.Prelude ( src/Database/Dpi/Prelude.hs, dist/build/Database/Dpi/Prelude.o )
[2 of 6] Compiling Database.Dpi.Internal ( dist/build/Database/Dpi/Internal.hs, dist/build/Database/Dpi/Internal.o )

src/Database/Dpi/Internal.chs:1484:12: error:
    • Couldn't match expected type ‘CInt’ with actual type ‘CUInt’
    • In the ‘operations’ field of a record
      In the first argument of ‘return’, namely
        ‘Data_SubscrCreateParams {..}’
      In a stmt of a 'do' block: return Data_SubscrCreateParams {..}
     |
1484 | #if DPI_MAJOR_VERSION >= 2 && DPI_MINOR_VERSION >= 4
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: keeping build directory '/tmp/nix-build-odpic-raw-0.3.0.drv-16'
builder for '/nix/store/v0w2w6vbvfw83l84mj81gy9zszcaxkpw-odpic-raw-0.3.0.drv' failed with exit code 1
error: build of '/nix/store/v0w2w6vbvfw83l84mj81gy9zszcaxkpw-odpic-raw-0.3.0.drv' failed

I'd appreciate if somebody could take it over from here.

fixes #13

flokli commented 5 years ago

Uff, this wasn't complete, and still fails to build, see my last comment.

leptonyu commented 5 years ago

@flokli fine, let me check later.

flokli commented 5 years ago

@leptonyu thanks. Seems the enum mapping could also be made a bit less verbose by using

{#enum define…}

see https://github.com/haskell/c2hs/blob/7e45dc8497bf38054f00e9e2c46f5a525a299273/tests/bugs/issue-102/Issue102.chs#L22