From 4e0545de10b9d6f43a5955c873180870b3551836 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Wed, 17 Aug 2022 18:47:07 -0600 Subject: [PATCH] Don't store _jll lib names as consts (#351) * Don't store _jll lib names as consts Fixes #350. * fix ci failures --- src/API.jl | 25 +++++++------------------ src/ODBC.jl | 2 +- src/dbinterface.jl | 2 +- src/utils.jl | 2 +- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/API.jl b/src/API.jl index ddd6f5b..25a2f0c 100644 --- a/src/API.jl +++ b/src/API.jl @@ -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 @@ -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 @@ -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) diff --git a/src/ODBC.jl b/src/ODBC.jl index 01b180b..9bcda67 100644 --- a/src/ODBC.jl +++ b/src/ODBC.jl @@ -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". """ diff --git a/src/dbinterface.jl b/src/dbinterface.jl index 950b3df..76d832c 100644 --- a/src/dbinterface.jl +++ b/src/dbinterface.jl @@ -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 diff --git a/src/utils.jl b/src/utils.jl index 3163d40..35b5c62 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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