5 Utilities
The bindings described in this section are provided by the specific modules below, not by db or db/base.
5.1 Datetime Type Utilities
(require db/util/datetime) |
procedure
(sql-datetime->srfi-date t) → srfi:date?
t : (or/c sql-date? sql-time? sql-timestamp?)
procedure
(srfi-date->sql-date d) → sql-date?
d : srfi:date?
procedure
(srfi-date->sql-time d) → sql-time?
d : srfi:date?
procedure
d : srfi:date?
procedure
d : srfi:date?
procedure
d : srfi:date?
Examples: | ||||||||||||
|
procedure
(sql-day-time-interval->seconds interval) → rational?
interval : sql-day-time-interval?
5.2 Geometric Types
(require db/util/geometry) |
The following structures and functions deal with geometric values based on the OpenGIS (ISO 19125) model.
Note: Geometric columns defined using the PostGIS extension to PostgreSQL are not directly supported. Instead, data should be exchanged in the Well-Known Binary format; conversion of the following structures to and from WKB format is supported by the wkb->geometry and geometry->wkb functions.
struct
(struct line-string (points))
points : (listof point?)
struct
exterior : linear-ring? interior : (listof linear-ring?)
struct
(struct multi-point (elements))
elements : (listof point?)
struct
(struct multi-line-string (elements))
elements : (listof line-string?)
struct
(struct multi-polygon (elements))
elements : (listof polygon?)
struct
(struct geometry-collection (elements))
elements : (listof geometry2d?)
procedure
(geometry2d? x) → boolean?
x : any/c
procedure
(linear-ring? x) → boolean?
x : any/c
procedure
(geometry->wkb g #:big-endian? big-endian?) → bytes?
g : geometry2d? big-endian? : (system-big-endian?)
procedure
(wkb->geometry b) → geometry2d?
b : bytes?
5.3 PostgreSQL-specific Types
(require db/util/postgresql) |
struct
(struct pg-array ( dimensions dimension-lengths dimension-lower-bounds contents)) dimensions : exact-nonnegative-integer? dimension-lengths : (listof exact-positive-integer?) dimension-lower-bounds : (listof exact-integer?) contents : vector?
procedure
(pg-array-ref arr index ...+) → any/c
arr : pg-array? index : exact-integer?
procedure
(pg-array->list arr) → list?
arr : pg-array?
procedure
(list->pg-array lst) → pg-array?
lst : list?
struct
ne : point? sw : point?
struct
closed? : boolean? points : (listof point?)
struct
center : point? radius : real?
Note: PostgreSQL’s built-in geometric types are distinct from those provided by the PostGIS extension library (see Geometric Types).
5.4 Testing Database Programs
(require db/util/testing) |
This module provides utilities for testing programs that use database connections.
procedure
(high-latency-connection connection latency [ #:sleep-atomic? sleep-atomic?]) → connection? connection : connection? latency : (>=/c 0) sleep-atomic? : any/c = #f
Use this function in performance testing to roughly simulate environments with high-latency communication with a database back end.
If sleep-atomic? is true, then the proxy enters atomic mode before sleeping, to better simulate the effect of a long-running FFI call (see FFI-Based Connections and Concurrency). Even so, it may not accurately simulate an ODBC connection that internally uses cursors to fetch data on demand, as each fetch would introduce additional latency.