Skip to content

Commit

Permalink
Don't store _jll lib names as consts (#351)
Browse files Browse the repository at this point in the history
* Don't store _jll lib names as consts

Fixes #350.

* fix ci failures
  • Loading branch information
quinnj authored Aug 18, 2022
1 parent 88493b6 commit 4e0545d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
25 changes: 7 additions & 18 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,9 @@ module API
using Scratch

using unixODBC_jll
const unixODBC_dm = unixODBC_jll.libodbc
const unixODBC_inst = unixODBC_jll.libodbcinst

@static if Sys.iswindows()
const odbc32_dm = "odbc32"
const odbc32_inst = "odbccp32"
const iODBC_dm = odbc32_dm
const iODBC_inst = odbc32_inst
else
@static if !Sys.iswindows()
using iODBC_jll
const iODBC_dm = iODBC_jll.libiodbc
const iODBC_inst = iODBC_jll.libiodbcinst
const odbc32_dm = unixODBC_jll.libodbc
const odbc32_inst = unixODBC_jll.libodbcinst
end

@enum DM_TYPE unixODBC iODBC odbc32
Expand Down Expand Up @@ -75,20 +64,20 @@ macro odbc(func,args,vals...)
@static if Sys.iswindows() # odbc_dm[] == odbc32
# This branch is guarded by `@static` to avoid issues on Apple Silicon
while true
ret = ccall( ($func, odbc32_dm), stdcall, SQLRETURN, $args, $(vals...))
ret = ccall( ($func, "odbc32"), stdcall, SQLRETURN, $args, $(vals...))
ret == SQL_STILL_EXECUTING || break
sleep(0.001)
end
else
if odbc_dm[] == iODBC
while true
ret = ccall( ($func, iODBC_dm), SQLRETURN, $(swapsqlwchar(args)), $(vals...))
ret = ccall( ($func, iODBC_jll.libiodbc), SQLRETURN, $(swapsqlwchar(args)), $(vals...))
ret == SQL_STILL_EXECUTING || break
sleep(0.001)
end
elseif odbc_dm[] == unixODBC
while true
ret = ccall( ($func, unixODBC_dm), SQLRETURN, $args, $(vals...))
ret = ccall( ($func, unixODBC_jll.libodbc), SQLRETURN, $args, $(vals...))
ret == SQL_STILL_EXECUTING || break
sleep(0.001)
end
Expand All @@ -102,12 +91,12 @@ macro odbcinst(func,args,vals...)
esc(quote
@static if Sys.iswindows() # odbc_dm[] == odbc32
# This branch is guarded by `@static` to avoid issues on Apple Silicon
ccall( ($func, odbc32_inst), stdcall, SQLRETURN, $args, $(vals...))
ccall( ($func, "odbccp32"), stdcall, SQLRETURN, $args, $(vals...))
else
if odbc_dm[] == iODBC
ccall( ($func, iODBC_inst), SQLRETURN, $(swapsqlwchar(args)), $(vals...))
ccall( ($func, iODBC_jll.libiodbcinst), SQLRETURN, $(swapsqlwchar(args)), $(vals...))
elseif odbc_dm[] == unixODBC
ccall( ($func, unixODBC_inst), SQLRETURN, $args, $(vals...))
ccall( ($func, unixODBC_jll.libodbcinst), SQLRETURN, $args, $(vals...))
end
end
end)
Expand Down
2 changes: 1 addition & 1 deletion src/ODBC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ setiODBC(; kw...) = API.setiODBC(; kw...)
Set the ODBC driver manager used to odbc32. On windows, ODBC.jl uses the system-wide
configurations for drivers and datasources. Drivers and datasources can still be added
via `ODBC.adddriver`/`ODBC.removdriver` and `ODBC.adddsn`/`ODBC.removedsn`, but you must
via `ODBC.adddriver`/`ODBC.removedriver` and `ODBC.adddsn`/`ODBC.removedsn`, but you must
have administrator privileges in the Julia session. This is accomplished easiest by pressing
CTRL then right-clicking on the terminal/Julia application and choosing "Run as administrator".
"""
Expand Down
2 changes: 1 addition & 1 deletion src/dbinterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ function Cursor(stmt; iterate_rows::Bool=false, ignore_driver_row_count::Bool=fa
end
else
if nullables[i] == API.SQL_NO_NULLS
columns[i] = binding.value.buffer
columns[i] = copy(binding.value.buffer)
else
specialize(binding.value.buffer) do A
inds = binding.strlen_or_indptr
Expand Down
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function jlcast(::Type{T}, bytes) where {T <: DecFP.DecimalFloatingPoint}
x = rstrip(String(bytes), '\0')
parse(T, x)
end
jlcast(::Type{Vector{UInt8}}, bytes) = bytes
jlcast(::Type{Vector{UInt8}}, bytes) = copy(bytes)
jlcast(::Type{String}, bytes) = String(bytes)

# given the SQL type as described by the driver library
Expand Down

0 comments on commit 4e0545d

Please sign in to comment.