include "security.m"; # need Auth for algorithm names
include "db.m";
db := load DB DB->PATH;
DB_Handle: adt {
SQLOpen: fn(oldh: self ref DB_Handle): (int, ref DB_Handle);
SQLClose: fn(dbh: self ref DB_Handle): int;
SQL: fn(handle: self ref DB_Handle, command: string):
(int, string);
columns: fn(handle: self ref DB_Handle): int;
nextRow: fn(handle: self ref DB_Handle): int;
read: fn(handle: self ref DB_Handle, column: int):
(int, array of byte);
write: fn(handle: self ref DB_Handle, param: int,
fld: array of byte): int
columnTitle: fn(handle: self ref DB_Handle,
column: int): string;
errmsg: fn(handle: self ref DB_Handle): string;
datafd: ref Sys->FD;
sqlconn: int;
sqlstream: int;
lock: chan of int;
};
connect: fn(addr, alg: string): (ref Sys->FD, string);
dbopen: fn(fd: ref Sys->FD, username, password, dbname: string):
(ref DB_Handle, list of string);
open: fn(addr, username, password, dbname: string):
(ref DB_Handle, list of string);
Dbsrv(7) must be running (usually in a hosted emu(1)) to service database requests.
If security features will be used in conjunction with DB, the Auth module definitions (see security-auth(2)) from security.m must be included.
If authentication is in use, DB will use the certificate in the file
if that file exists. Otherwise, db will attempt to find a certificate in the file
Connect establishes a connection to the dbsrv at addr. Addr has the form machine!service. Machine is a symbolic or numeric network address, and service is a service or port on that machine. Dbsrv starts a corresponding infdb process. After some negotiation, infdb will take the appropriate authentication, digesting, and decryption actions, based on the alg requested by the client. If successful, connect will return a file descriptor required by dbopen.
Dbopen initiates a session with a database dbname, passing username and password down the fd returned by connect. Dbopen returns a reference to an instance of DB_Handle and an error string, which is nil on success. On error, the reference is nil, but the string contains a diagnostic. Dbopen implicitly opens an initial SQL stream via SQLOpen.
Open returns the result of a connect followed (if successful) by a dbopen.
| DB(7 ) | Rev: Thu Feb 15 14:43:49 GMT 2007 |