Skip to content

Added advance queuing #25 #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
version: "3"
services:
dev-db:
container_name: dev-db
image: gvenzl/oracle-free:23-slim-faststart
image: container-registry-mumbai.oracle.com/database/free
volumes:
- ./db:/container-entrypoint-startdb.d
- ./init-scripts:/opt/oracle/scripts/startup
environment:
ORACLE_DATABASE: devdb
ORACLE_PASSWORD: password
APP_USER: username
APP_USER_PASSWORD: password
ORACLE_PWD: password
ports:
- 1521:1521
4 changes: 4 additions & 0 deletions init-scripts/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alter session set "_oracle_script"=true;
CREATE USER username IDENTIFIED BY password;
GRANT ALL PRIVILEGES TO username;
GRANT EXECUTE ON DBMS_AQADM TO username;
2 changes: 2 additions & 0 deletions oracle-simple.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ library
Database.Oracle.Simple.ToField
Database.Oracle.Simple.ToRow
Database.Oracle.Simple.Transaction
Database.Oracle.Simple.Queue
hs-source-dirs:
src
c-sources:
Expand Down Expand Up @@ -92,6 +93,7 @@ executable tests
, hspec-hedgehog
, oracle-simple
, time
, bytestring

source-repository head
type: git
Expand Down
1 change: 1 addition & 0 deletions src/Database/Oracle/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ import Database.Oracle.Simple.Query as Export
import Database.Oracle.Simple.ToField as Export
import Database.Oracle.Simple.ToRow as Export
import Database.Oracle.Simple.Transaction as Export
import Database.Oracle.Simple.Queue as Export
23 changes: 22 additions & 1 deletion src/Database/Oracle/Simple/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ module Database.Oracle.Simple.Internal
OracleError (..),
ErrorInfo (..),
VersionInfo (..),
DPIJson (..),
genJSON,
renderErrorInfo,
ping,
fetch,
Expand Down Expand Up @@ -119,6 +121,10 @@ newtype DPIShardingKeyColumn = DPIShardingKeyColumn (Ptr DPIShardingKeyColumn)
deriving (Show, Eq)
deriving newtype (Storable)

newtype DPIJson = DPIJson (Ptr DPIJson)
deriving (Show, Eq)
deriving newtype (Storable)

data AdditionalConnectionParams = AdditionalConnectionParams
{ minSessions :: Natural
, maxSessions :: Natural
Expand Down Expand Up @@ -207,7 +213,7 @@ foreign import ccall unsafe "dpiConn_create"
Ptr DPICommonCreateParams ->
-- | const dpiConnCreateParams *createParams
Ptr ConnectionCreateParams ->
-- | dpi * conn
-- | dpiConn ** conn
Ptr DPIConn ->
IO CInt

Expand Down Expand Up @@ -1752,3 +1758,18 @@ Structurally equivalent to 'Data.Functor.Identity.Identity'.
newtype Only a = Only {fromOnly :: a}
deriving stock (Eq, Ord, Read, Show, Generic)
deriving newtype (Enum)

genJSON :: Connection -> IO DPIJson
genJSON (Connection fptr) = do
withForeignPtr fptr $ \conn -> do
alloca $ \jsonPtr -> do
throwOracleError =<< dpiConn_newJson conn jsonPtr
peek jsonPtr

foreign import ccall unsafe "dpiConn_newJson"
dpiConn_newJson ::
-- | dpiConn *
Ptr DPIConn ->
-- | dpiJSON **
Ptr DPIJson ->
IO CInt
Loading
Loading