Skip to content

Commit 4d9ea7f

Browse files
amgad-naiemwookay
authored andcommitted
Julia 0.6 fixes (#1)
* updates for Julia v0.5 compatibility (mostly related to Strings warnings) * added missing types definition + updated deprecated * removed io seek unused functions + duplicate function * Removed duplicate function declarations * Fixed type alias declaration * Changed bytestring to unsafe_string * Fixed String to be AbstractString * Fixed convert function redefinition warning * Fixed multiple type declarations * fixed getting byte array from strings * fixed deprecated bytestring in test * Fixed formatting * added abstact type for julia 0.6 (with compat support)
1 parent e87b3a5 commit 4d9ea7f

File tree

4 files changed

+36
-29
lines changed

4 files changed

+36
-29
lines changed

src/dbi_impl.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function copy_from(db::PostgresDatabaseHandle, table::AbstractString,
130130
return checkerrclear(PQgetResult(db.ptr))
131131
end
132132

133-
hashsql(sql::AbstractString) = unsafe_string(string("__", hash(sql), "__"))
133+
hashsql(sql::AbstractString) = String(string("__", hash(sql), "__"))
134134

135135
function getparamtypes(result::Ptr{PGresult})
136136
nparams = PQnparams(result)

src/libpq_common.jl

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ const PGF_BINARY = 1
5050
# Skipping MacroDefinition: PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME)PQsetdbLogin(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME,NULL,NULL)
5151
# Skipping MacroDefinition: PQfreeNotify(ptr)PQfreemem(ptr)
5252
const PQnoPasswordSupplied = "fe_sendauth: no password supplied\n"
53-
typealias _IO_lock_t Union{}
54-
typealias va_list Cint
53+
const _IO_lock_t = Union{}
54+
const va_list = Cint
5555
# typealias off_t __off_t
5656
# typealias ssize_t __ssize_t
5757
# typealias fpos_t _G_fpos_t
58-
typealias Oid UInt32
58+
const Oid = UInt32
5959
# begin enum ConnStatusType
60-
typealias ConnStatusType UInt32
60+
const ConnStatusType = UInt32
6161
const CONNECTION_OK = 0
6262
const CONNECTION_BAD = 1
6363
const CONNECTION_STARTED = 2
@@ -69,15 +69,15 @@ const CONNECTION_SSL_STARTUP = 7
6969
const CONNECTION_NEEDED = 8
7070
# end enum ConnStatusType
7171
# begin enum PostgresPollingStatusType
72-
typealias PostgresPollingStatusType UInt32
72+
const PostgresPollingStatusType = UInt32
7373
const PGRES_POLLING_FAILED = 0
7474
const PGRES_POLLING_READING = 1
7575
const PGRES_POLLING_WRITING = 2
7676
const PGRES_POLLING_OK = 3
7777
const PGRES_POLLING_ACTIVE = 4
7878
# end enum PostgresPollingStatusType
7979
# begin enum ExecStatusType
80-
typealias ExecStatusType UInt32
80+
const ExecStatusType = UInt32
8181
const PGRES_EMPTY_QUERY = 0
8282
const PGRES_COMMAND_OK = 1
8383
const PGRES_TUPLES_OK = 2
@@ -90,29 +90,38 @@ const PGRES_COPY_BOTH = 8
9090
const PGRES_SINGLE_TUPLE = 9
9191
# end enum ExecStatusType
9292
# begin enum PGTransactionStatusType
93-
typealias PGTransactionStatusType UInt32
93+
const PGTransactionStatusType = UInt32
9494
const PQTRANS_IDLE = 0
9595
const PQTRANS_ACTIVE = 1
9696
const PQTRANS_INTRANS = 2
9797
const PQTRANS_INERROR = 3
9898
const PQTRANS_UNKNOWN = 4
9999
# end enum PGTransactionStatusType
100100
# begin enum PGVerbosity
101-
typealias PGVerbosity UInt32
101+
const PGVerbosity = UInt32
102102
const PQERRORS_TERSE = 0
103103
const PQERRORS_DEFAULT = 1
104104
const PQERRORS_VERBOSE = 2
105105
# end enum PGVerbosity
106106
# begin enum PGPing
107-
typealias PGPing UInt32
107+
const PGPing = UInt32
108108
const PQPING_OK = 0
109109
const PQPING_REJECT = 1
110110
const PQPING_NO_RESPONSE = 2
111111
const PQPING_NO_ATTEMPT = 3
112112
# end enum PGPing
113-
typealias PQnoticeReceiver Ptr{Void}
114-
typealias PQnoticeProcessor Ptr{Void}
115-
typealias pqbool UInt8
116-
typealias pgthreadlock_t Ptr{Void}
117-
typealias PGconn Void
118-
typealias PGresult Void
113+
const PQnoticeReceiver = Ptr{Void}
114+
const PQnoticeProcessor = Ptr{Void}
115+
const pqbool = UInt8
116+
const pgthreadlock_t = Ptr{Void}
117+
const PGconn = Void
118+
const PGresult = Void
119+
120+
const _IO_FILE = Void
121+
const FILE = Void
122+
const PQconninfoOption = Void
123+
const PGcancel = Void
124+
const PGnotify = Void
125+
const PQArgBlock = Void
126+
const PGresAttDesc = Void
127+
const PQprintOpt = Void

src/libpq_interface.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ module libpq_interface
9494
@c Cint _IO_vfprintf (Ptr{_IO_FILE}, Ptr{UInt8}, Cint) libpq
9595
# @c __ssize_t _IO_padn (Ptr{_IO_FILE}, Cint, __ssize_t) libpq
9696
@c Cint _IO_sgetn (Ptr{_IO_FILE}, Ptr{Void}, Cint) libpq
97-
@c __off64_t _IO_seekoff (Ptr{_IO_FILE}, __off64_t, Cint, Cint) libpq
98-
@c __off64_t _IO_seekpos (Ptr{_IO_FILE}, __off64_t, Cint) libpq
9997
@c Void _IO_free_backup_area (Ptr{_IO_FILE},) libpq
10098
@c Cint remove (Ptr{UInt8},) libpq
10199
@c Cint rename (Ptr{UInt8}, Ptr{UInt8}) libpq

src/types.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import DataArrays: NAtype
22
import JSON
33
import Compat: Libc, unsafe_convert, parse, @compat, String, unsafe_string
44

5-
abstract AbstractPostgresType
5+
@compat abstract type AbstractPostgresType end
66
type PostgresType{Name} <: AbstractPostgresType end
77

8-
abstract AbstractOID
8+
@compat abstract type AbstractOID end
99
type OID{N} <: AbstractOID end
1010

1111
oid{T<:AbstractPostgresType}(t::Type{T}) = convert(OID, t)
@@ -55,7 +55,7 @@ newpgtype(:_varchar, 1015, (Vector{String},))
5555
newpgtype(:_text, 1009, (Vector{String},))
5656

5757

58-
typealias PGStringTypes Union{Type{PostgresType{:bpchar}},
58+
const PGStringTypes = Union{Type{PostgresType{:bpchar}},
5959
Type{PostgresType{:varchar}},
6060
Type{PostgresType{:text}},
6161
Type{PostgresType{:date}}}
@@ -153,36 +153,36 @@ function pgdata(::Type{PostgresType{:numeric}}, ptr::Ptr{UInt8}, data::Number)
153153
end
154154

155155
function pgdata(::PGStringTypes, ptr::Ptr{UInt8}, data::AbstractString)
156-
ptr = storestring!(ptr, data)
156+
ptr = storestring!(ptr, String(data))
157157
end
158158

159159
function pgdata(::PostgresType{:date}, ptr::Ptr{UInt8}, data::AbstractString)
160-
ptr = storestring!(ptr, data)
160+
ptr = storestring!(ptr, String(data))
161161
ptr = Dates.DateFormat(ptr)
162162
end
163163

164164
function pgdata(::PostgresType{:timestamp}, ptr::Ptr{UInt8}, data::AbstractString)
165-
ptr = storestring!(ptr, data)
165+
ptr = storestring!(ptr, String(data))
166166
end
167167

168168
function pgdata(::PostgresType{:timestamptz}, ptr::Ptr{UInt8}, data::AbstractString)
169-
ptr = storestring!(ptr, data)
169+
ptr = storestring!(ptr, String(data))
170170
end
171171

172172
function pgdata(::Type{PostgresType{:bytea}}, ptr::Ptr{UInt8}, data::Vector{UInt8})
173-
ptr = storestring!(ptr, string("\\x", bytes2hex(data)))
173+
ptr = storestring!(ptr, String(string("\\x", bytes2hex(data))))
174174
end
175175

176176
function pgdata(::Type{PostgresType{:unknown}}, ptr::Ptr{UInt8}, data)
177177
ptr = storestring!(ptr, string(data))
178178
end
179179

180180
function pgdata{T<:AbstractString}(::Type{PostgresType{:json}}, ptr::Ptr{UInt8}, data::Dict{T,Any})
181-
ptr = storestring!(ptr, JSON.json(data))
181+
ptr = storestring!(ptr, String(JSON.json(data)))
182182
end
183183

184184
function pgdata{T<:AbstractString}(::Type{PostgresType{:jsonb}}, ptr::Ptr{UInt8}, data::Dict{T,Any})
185-
ptr = storestring!(ptr, JSON.json(data))
185+
ptr = storestring!(ptr, String(JSON.json(data)))
186186
end
187187

188188
function pgdata(::Type{PostgresType{:_bool}}, ptr::Ptr{UInt8}, data::Vector{Bool})
@@ -218,7 +218,7 @@ function pgdata(::Type{PostgresType{:_text}}, ptr::Ptr{UInt8}, data::Vector{Stri
218218
end
219219

220220
# dbi
221-
abstract Postgres <: DBI.DatabaseSystem
221+
@compat abstract type Postgres<:DBI.DatabaseSystem end
222222

223223
type PostgresDatabaseHandle <: DBI.DatabaseHandle
224224
ptr::Ptr{PGconn}

0 commit comments

Comments
 (0)