Skip to content

Commit 9175c69

Browse files
author
Andrey Oskin
committed
restart 0.1.0 again
1 parent e693fc3 commit 9175c69

File tree

7 files changed

+314
-319
lines changed

7 files changed

+314
-319
lines changed

Project.toml

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
1616
LayerDicts = "6f188dcb-512c-564b-bc01-e0f76e72f166"
1717
LibPQ_jll = "08be9ffa-1c94-5ee5-a977-46a84ec9b350"
1818
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
19-
Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
2019
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
2120
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
2221
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
@@ -32,7 +31,6 @@ Intervals = "1.4"
3231
IterTools = "1"
3332
LayerDicts = "1"
3433
LibPQ_jll = "12"
35-
Memento = "0.10, 0.11, 0.12, 0.13, 1"
3634
OffsetArrays = "0.9.1, 0.10, 0.11, 1"
3735
Tables = "0.2, 1"
3836
TimeZones = "0.9.2, 0.10, 0.11, 1"

src/LibPQ2.jl

-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ using Infinity: InfExtendedTime, isposinf, ∞
1717
using Intervals
1818
using IterTools: imap
1919
using LayerDicts
20-
using Memento: Memento, getlogger, warn, info, error, debug
2120
using OffsetArrays
2221
using TimeZones
2322

2423
const Parameter = Union{String, Missing}
25-
const LOGGER = getlogger(@__MODULE__)
2624

2725
function __init__()
2826
INTERVAL_REGEX[] = _interval_regex()
29-
Memento.register(LOGGER)
3027
end
3128

3229
# Docstring template for types using DocStringExtensions

src/asyncresults.jl

+2-4
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,9 @@ function _cancel(jl_conn::Connection)
158158
errbuf = zeros(UInt8, errbuf_size)
159159
success = libpq_c.PQcancel(cancel_ptr, pointer(errbuf), errbuf_size) == 1
160160
if !success
161-
warn(LOGGER, Errors.JLConnectionError(
162-
"Failed cancelling query: $(String(errbuf))"
163-
))
161+
@warn Errors.JLConnectionError("Failed cancelling query: $(String(errbuf))")
164162
else
165-
debug(LOGGER, "Cancelled query for connection $(jl_conn.conn)")
163+
@debug "Cancelled query for connection $(jl_conn.conn)"
166164
end
167165
finally
168166
libpq_c.PQfreeCancel(cancel_ptr)

src/connections.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ function handle_new_connection(jl_conn::Connection; throw_error::Bool=true)
124124

125125
if throw_error
126126
close(jl_conn)
127-
error(LOGGER, err)
127+
error(err)
128128
else
129-
warn(LOGGER, err)
129+
@warn err
130130
end
131131
else
132-
debug(LOGGER, "Connection established: $(jl_conn.conn)")
132+
@debug "Connection established: $(jl_conn.conn)"
133133
# if connection is successful, set client_encoding
134134
reset_encoding!(jl_conn)
135135
end
@@ -140,7 +140,7 @@ function handle_new_connection(jl_conn::Connection; throw_error::Bool=true)
140140
# finalizers can't task swtich, but they can schedule tasks
141141
@async begin
142142
if !atomic_cas!(closed, false, true)
143-
debug(LOGGER, "Closing connection $(conn_ptr) in finalizer")
143+
@debug "Closing connection $(conn_ptr) in finalizer"
144144
# we don't need to acquire a lock, because if anyone else is holding a
145145
# lock on the connection (using lock(::Connection)) then it won't be
146146
# cleaned up by the gc yet

src/copy.jl

+10-4
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ function execute(
5858

5959
if result_status != libpq_c.PGRES_COPY_IN
6060
if !(result_status in (libpq_c.PGRES_BAD_RESPONSE, libpq_c.PGRES_FATAL_ERROR))
61-
level(LOGGER, Errors.JLResultError(
62-
"Expected PGRES_COPY_IN after COPY query, got $result_status"
63-
))
61+
if throw_error
62+
error(Errors.JLResultError("Expected PGRES_COPY_IN after COPY query, got $result_status"))
63+
else
64+
@warn Errors.JLResultError("Expected PGRES_COPY_IN after COPY query, got $result_status")
65+
end
6466
end
6567
return result
6668
end
@@ -71,7 +73,11 @@ function execute(
7173

7274
status_code = put_copy_end(jl_conn)
7375
if status_code == -1
74-
level(LOGGER, Errors.PQConnectionError(jl_conn))
76+
if throw_error
77+
error(Errors.PQConnectionError(jl_conn))
78+
else
79+
@warn Errors.PQConnectionError(jl_conn)
80+
end
7581
end
7682

7783
libpq_c.PQgetResult(jl_conn.conn)

src/results.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,16 @@ function handle_result(jl_result::Result; throw_error::Bool=true)
225225

226226
if throw_error
227227
close(jl_result)
228-
error(LOGGER, err)
228+
error(err)
229229
else
230-
warn(LOGGER, err)
230+
@warn err
231231
end
232232
else
233233
if result_status == libpq_c.PGRES_NONFATAL_ERROR
234-
warn(LOGGER, Errors.PQResultError(jl_result))
234+
@warn Errors.PQResultError(jl_result)
235235
end
236236

237-
debug(LOGGER, unsafe_string(libpq_c.PQcmdStatus(jl_result.result)))
237+
@debug unsafe_string(libpq_c.PQcmdStatus(jl_result.result))
238238
end
239239

240240
return jl_result

0 commit comments

Comments
 (0)