Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-pgmq
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-pgmq
Commits
91f80083
Verified
Commit
91f80083
authored
Oct 03, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[pgmq] use Paths_haskell_pgmq for pgmq.sql
parent
cd93101b
Pipeline
#6741
passed with stages
in 8 minutes and 52 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
haskell-pgmq.cabal
haskell-pgmq.cabal
+3
-2
Schema.hs
src/Database/PGMQ/Schema.hs
+5
-6
Simple.hs
src/Database/PGMQ/Simple.hs
+3
-2
No files found.
haskell-pgmq.cabal
View file @
91f80083
...
...
@@ -66,6 +66,9 @@ library
, Database.PGMQ.Schema
, Database.PGMQ.Simple
, Database.PGMQ.Types
other-modules:
, Paths_haskell_pgmq
-- Modules included in this library but not exported.
-- other-modules:
...
...
@@ -79,9 +82,7 @@ library
, bytestring >= 0.11 && < 0.13
, postgresql-simple >= 0.6 && < 0.8
, safe >= 0.3 && < 0.4
, template-haskell >= 2.19.0.0 && < 2.20
, text >= 1.2 && < 2.2
, th-utilities >= 0.2.5.0 && < 0.3
, time >= 1.10 && < 1.15
, units >= 2.4 && < 2.5
...
...
src/Database/PGMQ/Schema.hs
View file @
91f80083
{-# LANGUAGE TemplateHaskell #-}
module
Database.PGMQ.Schema
where
import
Language.Haskell.TH.Syntax
(
lift
)
import
TH.RelativePaths
(
qReadFileString
)
import
Paths_haskell_pgmq
pgmqSchema
::
String
pgmqSchema
=
$
(
qReadFileString
"sql/pgmq.sql"
>>=
lift
)
pgmqSchema
::
IO
String
pgmqSchema
=
do
f
<-
getDataFileName
"sql/pgmq.sql"
readFile
f
src/Database/PGMQ/Simple.hs
View file @
91f80083
...
...
@@ -57,13 +57,14 @@ import Safe (headMay)
{-| Initialize PGMQ given a PostgreSQL connection. Mainly concerned
with creating the 'pgmq' extension. -}
initialize
::
PSQL
.
Connection
->
IO
()
initialize
conn
=
initialize
conn
=
do
-- OK so this is a bit tricky because of the usage of IF NOT EXISTS:
-- https://stackoverflow.com/questions/29900845/create-schema-if-not-exists-raises-duplicate-key-error
-- PostgreSQL will complain badly if 'initialize' is called
-- from multiple threads at once.
-- Hence, we use 'pg_advisory_xact_lock' to lock ourselves
-- out of this situation.
pgmqSchema'
<-
pgmqSchema
PSQL
.
withTransaction
conn
$
do
let
magicLockId
=
1122334455
::
Int
_
<-
PSQL
.
query
conn
[
sql
|
SELECT pg_advisory_xact_lock(?)
|]
(
PSQL
.
Only
magicLockId
)
::
IO
[
PSQL
.
Only
()
]
...
...
@@ -75,7 +76,7 @@ initialize conn =
-- extension by only running the SQL, not using `CREATE
-- EXTENSION`. But it works and is quite hassle-free
void
$
PSQL
.
execute_
conn
[
sql
|
CREATE SCHEMA pgmq
|]
void
$
PSQL
.
execute_
conn
(
fromString
pgmqSchema
)
void
$
PSQL
.
execute_
conn
(
fromString
pgmqSchema
'
)
-- void $ PSQL.execute_ conn [sql| CREATE EXTENSION IF NOT EXISTS pgmq |]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment