JuliaDatabases / LibPQ.jl

A Julia wrapper for libpq
MIT License
216 stars 51 forks source link

LibPQ logs but doesn't throw for nonexistent column names #211

Open c42f opened 3 years ago

c42f commented 3 years ago

It seems that when getting a nonexistent column from a LibPQ.Row via getproperty, LibPQ logs a mysterious-looking error to stderr but doesn't otherwise indicate failure.

Should this be an exception?

Demo:

julia> conn = LibPQ.Connection("...");
julia> LibPQ.execute(conn, "create table test (a integer, b integer)")
julia> LibPQ.execute(conn, "insert into test values (1,2)")
julia> row = only(LibPQ.execute(conn, "select * from test"))
LibPQ.Row(PostgreSQL result, 1)

julia> row.a
1

julia> row.x
column number -1 is out of range 0..1
missing

The error column number -1 is out of range 0..1 is coming from inside upstream libpq: https://github.com/postgres/postgres/blob/28d1601ad988790c3c53d7ffd24ef6d2366d4457/src/interfaces/libpq/fe-exec.c#L2798-L2810

iamed2 commented 3 years ago

You're right, I think I know how to fix this as well