Skip to content

Commit

Permalink
Simplify error condition
Browse files Browse the repository at this point in the history
  • Loading branch information
cmey committed Dec 30, 2021
1 parent 5ae0fb3 commit 46ab31b
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,9 @@ function execute(
result_status = libpq_c.PQresultStatus(result)

if result_status != libpq_c.PGRES_COPY_OUT
if !(result_status in (libpq_c.PGRES_BAD_RESPONSE, libpq_c.PGRES_FATAL_ERROR))
level(LOGGER, Errors.JLResultError(
"Expected PGRES_COPY_OUT after COPY query, got $result_status"
))
end
level(LOGGER, Errors.JLResultError(
"Expected PGRES_COPY_OUT after COPY query, got $result_status"
))
return result
end

Expand All @@ -148,11 +146,7 @@ function execute(
end
end
seekstart(io) # rewind iobuffer so future user read will begin from start
if -2 == status_code
level(LOGGER, Errors.JLResultError(
"PQgetCopyData error: $(error_message(jl_conn))"
))
end
-2 == status_code && level(LOGGER, Errors.JLResultError("PQgetCopyData error: $(error_message(jl_conn))"))

libpq_c.PQgetResult(jl_conn.conn)
end
Expand Down

0 comments on commit 46ab31b

Please sign in to comment.