Comments (4)
I'm not sure why this might happen, but I would try to gather more information:
- Perhaps ask for
status(conn)
before and after calling the function - Set
PQsetErrorVerbosity
toPQERRORS_VERBOSE
(typically this has little impact on connection errors but maybe it will here)
What client LibPQ.jl version and what server version do you have?
from libpq.jl.
Thanks! With your suggestions, I was able to answer my own question. The verbose errors pointed to the right line in the libpq C code.
It seems that I must wrap either operation (lo_import / lo_export) in a transaction. (This probably also is true of other lo_XXX operations.)
from libpq.jl.
For what it is worth, these functions perform basic large object import/export and deletion.
function lo_import(conn::LibPQ.Connection, filename::AbstractString)::LibPQ.Oid
execute(conn, "BEGIN;");
res = 0
try
if (res = LibPQ.libpq_c.lo_import(conn.conn, filename)) == LibPQ.Oid(0x0)
@error LibPQ.error_message(conn)
end
finally
execute(conn,"COMMIT;")
end
res
end
This export function creates a temporary file, writes the file to the temporary, hands
the filename to func
, deletes the temporary and then returns the result of func
. On
error the function returns missing
.
function lo_export(func::Function, conn::LibPQ.Connection, oid::UInt32)
res = missing
filename=tempname(;cleanup=false)
try
execute(conn, "BEGIN;");
try
if LibPQ.libpq_c.lo_export(conn.conn, oid, filename) == 1
try
res = func(filename)
catch ex
@error ex
end
else
@error LibPQ.error_message(conn)
end
finally
execute(conn, "COMMIT;")
end
finally
rm(filename; force=true)
end
res
end
The lo_unlink function doesn't seem to require a transaction.
function lo_unlink(conn::LibPQ.Connection, oid::UInt32)
res = -1
if (res=LibPQ.libpq_c.lo_unlink(conn.conn, oid)) != 1
@error LibPQ.error_message(conn)
end
res
end
from libpq.jl.
I want to keep transactions out of the functions to allow users to decide on their transactions (e.g. maybe they want to do multiple operations within the transactions). But having functions that wrap the libpq_c code would definitely be useful, and this is helpful, thanks.
With your suggestions, I was able to answer my own question. The verbose errors pointed to the right line in the libpq C code.
This is a good indication I should expose the verbosity option at the Connection
level.
from libpq.jl.
Related Issues (20)
- UndefVarError: LIBPQ_HANDLE not defined HOT 1
- Support for LISTEN/NOTIFY HOT 5
- Problems with connection timeouts and multihreadding HOT 5
- collect on LibPQ.Column allocates a lot HOT 1
- Memory Leak? HOT 4
- LibPQ and local peer trust ("ident") HOT 4
- All rational numbers are parsed as Decimals.Decimal instead of Float HOT 3
- Large select queries running 5-10x slower than with psql HOT 7
- Support UUIDs with binary_format=true HOT 1
- Make Tables.rowtable(result) as fast as Tables.rowtable(Tables.columntable(result))
- `tryparse` Inexact Error HOT 5
- Docs links return 404 HOT 3
- Using array_agg results in a string HOT 2
- I install LibPQ but test fails. HOT 1
- Guess when there is no server running in tests and suggest users install one
- Multiple `async_execute`s may not always execute in sequence?
- `execute` and `async_execute` exception handling difference
- `LibPQ`.`async_execute`'s overhead is around 3ms HOT 2
- Add functions for closing prepared statements (requires PostgreSQL 17 release and corresponding libpq_jll)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libpq.jl.