Embedding OliviaDB's DL/I in a host runtime¶
For runtimes that execute migrated COBOL or PL/I programs and want their DL/I calls
served by OliviaDB in process: the host owns program storage (byte slices), OliviaDB owns the
databases. Two interfaces, same semantics: the Rust API (oliviadb-dli) and the C ABI
(oliviadb-dli-ffi, liboliviadb_dli, header open/crates/oliviadb-dli-ffi/include/oliviadb_dli.h;
cargo build --release -p oliviadb-dli-lib builds target/release/liboliviadb_dli.dylib, .so
or .a).
Rust API¶
use oliviadb_dli::{System, Runtime, PcbRef, Status};
use oliviadb_core::{Options, vfs::OsVfs};
// One System per set of databases (an OliviaDB key space on this node).
let mut sys = System::open(OsVfs::arc(), "/var/lib/oliviadb/bank", Options::default())?;
sys.load_library(Path::new("/src/dbdpsb"))?; // *.dbd, *.psb: DBDGEN/PSBGEN source
// or sys.define_dbd(text)?, sys.define_psb(text)?
// Optional: the installation's HDAM randomizing modules, by the name DBDs use.
sys.randomizers.register("MYRAND", Arc::new(MyRandomizer));
// Program start (a batch DL/I step): schedule with the PSB.
let mut prog = sys.schedule("PAYPSB", Runtime::EBCDIC)?;
// PCB masks live in host storage: allocate and initialize them.
let mut io_pcb = vec![0u8; prog.mask_len(PcbRef::Io)];
prog.init_mask(PcbRef::Io, &mut io_pcb);
let mut pcbs: Vec<Vec<u8>> = (0..prog.pcb_count()).map(|i| {
let mut m = vec![0u8; prog.mask_len(PcbRef::Db(i))];
prog.init_mask(PcbRef::Db(i), &mut m);
m
}).collect();
// Each CALL 'CBLTDLI' USING func, pcb, io, ssa...:
// func, io and the SSAs are slices of program storage; the host maps the PCB address
// the program passed to the index of the mask it allocated.
let st: Status = prog.call(&mut sys, func, PcbRef::Db(i), &mut pcbs[i], io, &[ssa1, ssa2]);
// Program end: commit (normal end) or discard (abnormal end).
prog.terminate(&mut sys)?; // or prog.abort()
func: the 4-byte function code as the program holds it.- PCB mask: written as the program sees it (status, level, segment name, key feedback
length and area); fields a call does not change keep their bytes. Layout in
oliviadb_dli::pcb. - I/O area: OliviaDB writes the segment's bytes (fixed length, or LL bytes for variable-length
segments) and nothing else; ISRT/REPL/DLET read the segment's length from it (a size
field over the DBD's maximum or short of the end of the sequence field: V1; in a path
call the segments lie back to back, each by its own length).
prog.io_size(pcb)is the most a call can touch. - SSAs: slices; OliviaDB reads only as far as the SSA goes (
oliviadb_dli::ssa::extenttells how far that is when the host only has an address). - The returned
Statusis also in the PCB. Runtime:EBCDIC(code page 037, big-endian binary: data byte for byte as on the source system),ASCII_BE,ASCII_LE. Keys are stored as the program's bytes, so an EBCDIC database must be used by EBCDIC programs to keep its order.- Several PCBs on the same database share the program's unit of work: each sees the others' uncommitted changes.
System service calls go to the I/O PCB: prog.call(&mut sys, func, PcbRef::Io, &mut
io_pcb, io, &[token]) for calls that only read their extra arguments, or
prog.call_io(&mut sys, func, &mut io_pcb, &mut [args...]) when the call writes into them
(XRST restores save areas). args are the arguments after the PCB exactly as the program
passes them: CHKP [checkpoint-id] (basic) or [io-length, io-area, area-length, area,
...] (symbolic), XRST likewise, SETS/SETU/ROLS [io-area, token], LOG/INIT/DEQ
[io-area], ROLL/ROLB/SYNC [] or [io-area].
A call can end the program abnormally (ROLL: U0778; the victim of a deadlock: U0777):
prog.abend_code() is then Some(code), the unit of work has been backed out, and the
host ends the step with prog.abort().
Threading and isolation: a System and its programs are used by one thread at a time
(wrap them in a mutex to share). Several programs scheduled on one system are isolated by
record locks (program isolation): when a call needs a lock another program holds it
changes nothing and returns Status::WAIT (not an IMS status, never written to the PCB);
the host runs another program and retries the call later. A program whose wait would
close a deadlock cycle is the victim: it gets BC (after INIT STATUS GROUPB) or ends
abnormally with U0777 (Status::DEADLOCK is returned and abend_code() says U0777).
PROCOPT=GO reads take no locks.
Several systems (or other trees) on one node can share block cache, open files and a
memtable budget: Options { node: Some(Node::new(cache_bytes, max_open_files,
mem_budget)), .. }.
C ABI¶
#include "oliviadb_dli.h"
oliviadb_system *sys = oliviadb_open("/var/lib/oliviadb/bank", /*sync=*/1);
oliviadb_load_library(sys, "/src/dbdpsb");
oliviadb_program *p = oliviadb_schedule(sys, "PAYPSB", OLIVIADB_RUNTIME_EBCDIC);
oliviadb_set_current(p); /* entry-point calls of this thread go to p */
void *iopcb = oliviadb_pcb_address(p, 0), *dbpcb = oliviadb_pcb_address(p, 1);
/* pass iopcb, dbpcb, ... to the program as its PCB list */
CBLTDLI(func, dbpcb, ioarea, ssa1, NULL); /* or with a parmcount, or oliviadb_set_argc(n) */
oliviadb_terminate(p); /* commit and free; oliviadb_abort(p) discards */
oliviadb_close(sys);
Here OliviaDB owns the PCB storage (as IMS does) and resolves the PCB address a call passes.
Entry points: CBLTDLI, CEETDLI, ASMTDLI (function, PCB, I/O area, SSAs), PLITDLI
(parmcount, function, address of a PCB pointer, ...), AIBTDLI (function, AIB, ...; the
PCB is found by the AIB's resource name). Argument counts: a leading parmcount (as IMS
allows), else oliviadb_set_argc, else a NULL-terminated list. oliviadb_dli_call(p, argc, argv)
takes an explicit argument vector. Return value: 0 for a blank status, else the two
status characters, -1 when the call cannot be attributed (oliviadb_last_error()).
System service calls through the entry points take their argument sizes from the call's
own length fields (symbolic CHKP/XRST lengths, the LL of SETS/ROLS/LOG/INIT I/O areas).
Return values beyond phase 0: -2 when the call ended the program abnormally
(oliviadb_abend_code(p); end it with oliviadb_abort(p)), -3 when the call must be retried after
another program releases a lock.
Randomizers from C: oliviadb_register_randomizer(sys, "MYRAND", fn) before the DBD's first
use.
A store has one opener at a time, across processes (spec/storage-format.md, "Store lock").
oliviadb_open on a store another process (or another system of this process) holds returns
NULL, and scheduling a PSB whose database is mapped (oliviadb_map_database) to a held store
returns NULL; oliviadb_last_error() then reads in use: store DIR is open in process PID; one
process opens a store at a time. Nothing waits: the host decides whether to retry, end the
step or report the database unavailable. The lock is released by oliviadb_close or when the
process ends, however it ends. A server that serves DL/I databases over the network API holds
their stores while it runs (network API, "DL/I databases").
HDAM and PHDAM root order: your own randomizing routine¶
The order in which an unqualified GN visits the roots of an HDAM or PHDAM database (and of
a DEDB) is the order the database's randomizing routine gives: by block, then root anchor
point, then key within an anchor point. That routine is the installation's (the RMNAME=
module of the DBD). OliviaDB does not include, reconstruct or imitate any vendor's module.
OliviaDB's order when the module is not registered. A DBD that names a module that is not
registered is opened with OliviaDB's own OLVHASH1, and the substitution is reported
(System::notes). OLVHASH1 takes the FNV-1a hash of the root key's bytes (64-bit offset
basis X'CBF29CE484222325', prime X'00000100000001B3'), h; the relative block is
1 + h mod blocks and the anchor point 1 + (h / blocks) mod anchors, with blocks and anchor
points from the DBD's RMNAME=. An unqualified GN then visits roots by relative block, then
anchor point, then ascending key within an anchor point (the order IMS keeps within an
anchor point: Database Administration, SC19-4214-02, "When not enough root storage room
exists", p.156). This order is deterministic and the same on every node and every run; it
is OliviaDB's behaviour, and it differs from the source system's, whose module computes other
blocks and anchor points. Everything else (which roots exist, GU by key, the order of
dependents, a GN qualified on the root key) does not depend on it.
To get the source system's root order, register the installation's own routine under the name its DBDs use, before the database is first used:
- Rust: implement
oliviadb_dli::randomizer::Randomizer(randomize, ortry_randomizefor a routine that can fail: the call then gets AO) andsys.randomizers.register("MYRAND", Arc::new(MyRandomizer)). The routine gets the root key and the DBD's RMNAME= parameters (Rmname: anchor points per block, blocks, bytes) and returns the relative block number and anchor point, both 1-based. - C ABI:
oliviadb_register_randomizer2(sys, "MYRAND", fn, ctx)(above: key, module name, all RMNAME parameters; non-zero return for a failure) or the version 1oliviadb_register_randomizer. The name*serves every module not registered itself. A host that runs the installation's original load module (a runtime that executes mainframe object code) registers a callback that calls it. -
A routine you write again: an installation that wrote its own routine can reimplement the same computation in Rust or C from its own source and register it as above; it must give the same block and anchor point for every key, or roots are not found where the migrated data put them. A vendor-supplied module is used as the module itself (through a host that runs it), never rebuilt from its tables or by probing it.
-
A standalone server:
oliviadb serve --randomizer NAME=LIBloads the routine from a shared library the installation builds, which exportsoliviadb_randomizerwith the callback signature ofoliviadb_register_randomizer2(itsctxis NULL);NAMEis the module name of RMNAME= or*. A library that cannot be loaded, or exports no such function, stops the server from starting (docs/operations.md).
C ABI version 2¶
oliviadb_abi_version() returns 2; every version 1 function keeps working. Version 2 adds:
- Host-owned masks.
oliviadb_mask_len(p, i)(I/O PCB 48, DB PCB 36 + KEYLEN),oliviadb_mask_init(p, i, mask, len)fills a mask in host storage;oliviadb_register_mask(p, i, mask, len)letsCBLTDLIand the other entry points accept that address as PCBi. - Calls with lengths.
oliviadb_call(p, pcb, func, mask, mask_len, args, nargs): PCB by index (0 = I/O PCB), the mask in host storage (or NULL for the library's), andoliviadb_arg {ptr, len}for every argument after the PCB: I/O area and SSAs, or the argument areas of a system service call. Nothing is read or written beyond the given lengths (a zero length means "as far as the call needs", as for the entry points). - Randomizers with context.
oliviadb_register_randomizer2(sys, name, fn, ctx): the callback getsctx, the module name the DBD uses, the key and all RMNAME parameters (anchors, blocks, bytes), and returns non-zero for a failure (the call gets status AO,oliviadb_last_error()says why). The name*serves every module not registered itself. - Definitions by name.
oliviadb_set_resolver(sys, fn, ctx): when a PSB, a database, an index database or a related database is needed and not defined, the callback supplies its DBDGEN/PSBGEN source. - Where data lives.
oliviadb_map_database(sys, dbd, path)keeps a database (and its secondary indexes) in the store atpath, e.g. the data set a step's DD names; maps are set before the database is first used. A database not mapped itself but related to a mapped one (logical parent or child, source of a logical DBD, index database) goes into that database's store. A unit of work spanning several stores commits atomically (before-images in each store, decision in the system store; an interrupted commit is rolled back when a store is next opened). Logically related databases may be mapped to different stores (see "Logical relationships across stores" below). - Abend code.
oliviadb_abend_code(prog)is exported (the header declared it before; a test now checks that every header function is exported). - Sequential data sets as records. HSAM/SHSAM data sets hold one record per segment in
hierarchic sequence (segment code, 1-based in DBD order, then the data; OliviaDB's layout,
not the IMS physical block format): a program reading the database rebuilds it from the
data set, a load writes the data set at the end of the program, so the host reads and
writes them with the data set calls.
oliviadb_dataset_write_v/oliviadb_dataset_read_vtake and give variable-length records in RDW form. GSAM data sets with RECFM=V, VB or U must go through these two calls: their records keep their own lengths. Scheduling such a PCB on an input data set given witholiviadb_dataset_write(fixed-length, each record padded to one length) fails with an error namingoliviadb_dataset_write_v, andoliviadb_dataset_readof such a PCB's output returns -1 when a record's length differs from the length asked for. - Data sets (GSAM, HSAM, SHSAM).
oliviadb_set_dd(sys, dd, dataset)(NULL: dummy),oliviadb_clear_dds,oliviadb_dataset_write/oliviadb_dataset_readfor fixed-length records. GSAM input reads DD1 and output rewrites DD2; an HSAM load writes DD2, other HSAM PCBs read DD1. Settings apply to programs scheduled afterwards. - Unload and reload.
oliviadb_export(sys, dbd, path)andoliviadb_import(sys, dbd, path, runtime)in the portable format ofspec/unload-format.md.
The Rust API has the same: System::map_database, System::set_resolver,
System::export_database / import_database, System::set_dd / clear_dds /
put_dataset / dataset, Randomizer::try_randomize (with
Rmname.bytes), Program::last_error.
Main storage databases (ACCESS=MSDB) start from an MSDBINIT data set:
System::load_msdbinit(bytes, runtime) (enterprise crate oliviadb-dli-migrate, trait
Migrate) takes its records one after the other (LL,
X'0000', DBD name, count, type, key length, key, segment) and replaces the contents of
each MSDB it names. MSDB and DEDB PCBs also take the FLD call (function code FLD, the
field search arguments in the I/O area, at most one SSA).
Logical relationships across stores¶
A logical relationship links segment types "in the same or different databases" (IMS 15.5 Database Administration, Chapter 17 "Creating logical relationships", "Bidirectional virtually paired logical relationship", p.234), so databases mapped to different stores may be logically related, and a logical DBD may draw its segments from databases in several stores. Nothing a program sees depends on the mapping:
- Where things are kept. Each segment stays in its own database's store. The entries that lead from a logical parent to its logical children (OliviaDB's form of the logical child pointers) are kept in the logical child's store, under that store's namespace; a segment deleted from its physical path but still reached through a relationship is kept aside in its own database's store. Namespace numbers are per store, so a key is always read in the store of the database it belongs to.
- Opening. Opening a database opens the databases it is related to (logical parents, logical children, the sources of a logical DBD), each in the store it is mapped to; a related database that is not mapped itself goes into the store of the one that names it.
- Reading. A call through a logical DBD reads every segment of a concatenated segment, and every virtual logical child, in the store of its database, within the program's unit of work (it sees the program's own uncommitted changes in every store).
- Rules. The insert, replace and delete rules apply as in one store (Database Administration, Chapter 17, "Insert rules" p.267, "Replace rules" p.271, "Delete rules" p.277): an ISRT checks the logical parent in its store (IX), a physically paired logical child is inserted, replaced and deleted with its pair in the other store, delete rules P, L, V and B look at the logical children in their store.
- Locks. Lock names carry the store, so equal keys in two stores do not collide. A call through a logical DBD locks the database record of the logical root's physical root, as it does in one store.
- Commit. A unit of work that changed several stores commits them as one (spec storage-format.md, "Units of work across trees"); after a crash at any step its writes stand in every store or are rolled back in every store when the stores are next opened.
- Check.
oliviadb checkreads each logical child's logical parent in the parent's store.
A host that runs each step against the data sets its DD statements name maps each physical database to its data set; a logical DBD has no data set of its own (DATASET LOGICAL) and needs none mapped.
C ABI version 3: online use¶
oliviadb_abi_version() returns 3; version 1 and 2 functions are unchanged.
- One system, several programs, several host threads. Each call holds the system's
lock for its duration and never waits inside. A call that needs a lock another program
holds returns -3 with nothing done: the host retries it (after other tasks ran). A
deadlock is detected on the wait-for graph: the victim gets BC after INIT STATUS GROUPB
(its unit of work backed out, the program still scheduled), otherwise it ends abnormally
(-2,
oliviadb_abend_codeU0777). A program is used by one thread at a time; callbacks (resolver, randomizers) run under the lock and must not call the library. - Sync point and backout that keep the program scheduled.
oliviadb_sync(prog)commits (atomically across stores), releases locks, resets positions (as after SYNC);oliviadb_backout(prog)discards uncommitted updates, releases locks, resets positions. No terminate/schedule or system reopen per SYNCPOINT. - Online region.
oliviadb_set_online(sys, 1): a ROLB call backs out and goes on. - Lock granularity.
oliviadb_set_lock_level(sys, 1): segment-level locks, the segment in the call's mode with its ancestors shared. Readers and holders of different dependents of one record proceed together; a hold on (or delete of) a segment waits for readers of its dependents. Default 0: database record (program isolation). -
Unavailable data.
oliviadb_set_unavailable(sys, dbd, 1): calls on the database get BA after INIT STATUS GROUPA or GROUPB (the call does nothing); without INIT the program ends abnormally (U3303) and is backed out. -
Uncommitted inserts. An inserted segment is locked exclusively until the inserter's sync point; another program whose call would reach it (a direct read of its key, or a sequential read passing its place) gets -3 and retries; after the inserter's sync point it sees the segment, after its backout it does not. This follows IMS program isolation as described in IMS Locking with Program Isolation or the IRLM (IBM Techdocs, R. Lewis, version 8/26/2011), sections "Database Record Locks" (locks on a database record holding updates are kept until a sync point; inserting a root also locks its key) and "Segment Locks" (a program reaching an updated, uncommitted dependent segment waits), and IBM's definition of program isolation in the IMS documentation ("separates all the activity of an application program from any other active application program until that application program indicates, using a synchronization point, that the data it has modified or created is consistent"). Through secondary-index and logical views the wait is not checked yet (the insert is simply not visible until committed).
Tests: oliviadb-dli-ffi/tests/online.rs. Four threads × 25 read-modify-write units of work on
one record, with waits retried, give exactly 100 increments. A deadlock between two
programs gives BC to the GROUPB program, and the other continues. Backout and sync keep
programs scheduled. Segment level is checked against record level, and BA against U3303.
C ABI version 4: replica of an IMS database¶
oliviadb_abi_version() returns 4; earlier functions are unchanged. A read-only copy of IMS
databases is built and kept current with no program running on the source system:
- Initial load.
oliviadb_load_hd_unload(sys, dbd, data, len, runtime)loads a database from the data set an HD Reorganization Unload wrote (records with their record descriptor words, as a binary transfer with RDWs gives them); the database's previous contents are replaced.oliviadb_load_msdbinit(sys, data, len, runtime)loads main storage databases from MSDBINIT records. - Change capture.
oliviadb_apply_capture_log(sys, data, len, runtime, &pending)applies the committed units of work found in IMS log records with data capture records, one OliviaDB commit per unit; changes after the last commit point stay pending, backed-out work is dropped, a log applied twice changes nothing the second time. This needs data capture logging on the source: the customer's database administrator addsEXIT=(*,KEY,DATA,LOG)to the DBD statement of each database to replicate (IMS System Utilities, "DBD statement"; no exit routine is involved) and runs DBDGEN and ACBGEN; IMS then writes changed-data records (type X'99') to its log, from which log extracts are taken. - As of.
oliviadb_version_at(sys, dbd, time, &version)gives the OliviaDB version that holds the database as it was at a source time (store clock of the log);oliviadb_schedule_at(sys, psb, runtime, version)schedules a read-only program that sees that version (updates get AM, no locks);oliviadb_retain_versions_from(sys, version)lets older versions go.
The Rust API: System::load_hd_unload, System::load_msdbinit (trait
oliviadb_dli_migrate::Migrate), System::apply_changes with a capture::ChangeSource
(oliviadb_dli_capture::DataCaptureLog for IMS logs; other sources implement the same trait), System::version_at,
System::schedule_at, System::retain_versions_from.
C ABI version 5: HALDB¶
oliviadb_abi_version() returns 5; earlier functions are unchanged.
- Partitions.
oliviadb_define_partitions(sys, text, runtime)takes the DBRC commands that define a HALDB in RECON (INIT.DB DBD(name) TYPHALDB [HIKEY | PARTSEL(exit)],INIT.PART DBD(name) PART(name) KEYSTRNG(...) [RANDOMZR() ANCHOR() HIBLOCK() BYTES()]; other commands and keywords are ignored), before the database is first used. The store keeps them; a later different definition is refused. - Partition selection exits.
oliviadb_register_partition_selector(sys, name, fn, ctx): the callback gets the root key and sets the partition ID (1, 2, ... in INIT.PART order), 0 for none (the call gets FM). Used when RECON names PARTSEL or the DBD names PSNAME and RECON does not say HIKEY. - HALDB control statements.
oliviadb_set_haldb_control(sys, text): the DFSHALDB data set (HALDB PCB=(nnn,partition), nnn counting the PSB's database PCBs, or the PCB label) for programs scheduled afterwards.
Rust: System::define_partitions_dbrc / define_partitions,
System::register_partition_selector (oliviadb_dli_fp::haldb::PartitionSelector),
System::set_haldb_control (trait oliviadb_dli_fp::HaldbSystem), Program::restrict_pcb.
Fast Path and HALDB are extensions¶
oliviadb-dli parses DEDB, MSDB, PHDAM, PHIDAM and PSINDEX DBDs like every other, but uses
such a database only when the extension for it is registered on the System
(oliviadb_dli::ext: trait FastPath for MSDB calls, FLD, DEDB subset pointers and the end
of a BMP; trait Haldb for partitions and control statements). Without it, opening the
database's store or scheduling a PSB with a PCB on it fails with an error that names the
missing extension ("... need the Fast Path extension, which is not registered"), and the
FLD call ends with AO and that reason in the last error. The enterprise crate
oliviadb-dli-fp implements both; oliviadb_dli_fp::install(&mut sys) registers them (the C
library does so for every system it opens).
C ABI version 6: layouts¶
oliviadb_abi_version() returns 6; earlier functions are unchanged. Layouts and the writer's
layout id are described in spec/schema.md 4; what is implemented is listed there.
- Registry.
oliviadb_register_layout(sys, dbd, json, len)registers a layout (its JSON form, with or withoutsource) for a segment type ofdbdin the store's layout registry and returns its local number (the same for the same layout; a new source is kept as metadata).oliviadb_set_segment_layout(sys, NULL, dbd, segment, n)makes it the segment type's default; with a program name it binds it to that program's writes.oliviadb_set_layout_registration(sys, 0)refuses registration on this node (a standby, or a standby promoted to primary, until registration is replicated). - Writer layout. Every version of a segment stored in a database created from this
version on carries the layout its writer used, outside the segment bytes: I/O areas,
key feedback and unloads in the source's formats are unchanged. The writer's layout is the one set for the next call
(
oliviadb_set_write_layout(prog, segment, n, variant)), else the program's binding (oliviadb_set_program_name(prog, name); the PSB name by default), else the segment type's default, else none. A database created before keeps its format. - JSON export.
oliviadb_export_json(sys, dbd, version, path): the database as of a version, one JSON document per database record, each segment decoded by its writer's layout.
Rust: System::register_layout, layout_by_digest, layout_by_number,
set_default_layout, bind_layout, writer_layout, export_json,
Program::set_program_name, Program::set_write_layout, registry::Registration;
oliviadb_dli_view::catalog::SemanticCatalog::register_layouts registers the copybook layouts of
a semantic catalog and binds them to the programs that write the segments.
C ABI version 7: BKO= and the log of a batch step¶
oliviadb_abi_version() returns 7; earlier functions are unchanged, but a program scheduled
with oliviadb_schedule now runs as BKO=N (before, dynamic backout was on by default).
oliviadb_schedule_batch(sys, psb, runtime, bko, disk_log) schedules the program of a DL/I batch step with its BKO= setting (nonzero:
BKO=Y) and whether its log data set is on disk (nonzero). Dynamic backout needs both, as
IMS's (System Definition, "BKO= parameter for procedures": the default is N; Y applies only
if the log data set is on DASD). With it a ROLB without an I/O area backs out to the last
commit point and returns, and SETS and ROLS work; without it they get AL. A ROLB with an
I/O area gets AD either way (Application Programming, "Backing out to a prior commit
point", Batch programs; Messages and Codes, "AL"). In Rust, Program::set_dynamic_backout (default System::dynamic_backout, off); in Java,
OliviaDbSystem.scheduleBatch(psb, runtime, bko, diskLog). A host passes what the step's JCL
says: the BKO= value (the procedure parameter, or its position in the PARM= of
DFSRRC00) and whether the log DD (IEFRDER) is a disk data set. The same setting decides
a deadlock victim in batch after INIT STATUS GROUPB: BC when it changed nothing or has
dynamic backout, otherwise the 777 pseudoabend (-2, oliviadb_abend_code U0777); its changes
are backed out either way (Application Programming APIs, "INIT call", INIT STATUS GROUPB).
C ABI version 8: extensions¶
oliviadb_abi_version() returns 8; the functions are those of version 7 plus
oliviadb_extensions(). Two libraries implement this C ABI with the same functions:
liboliviadb_dli(crateoliviadb-dli-ffi, built as a library byoliviadb-dli-lib): the full-function DL/I layer.oliviadb_extensions()returns 0.oliviadb_load_msdbinit,oliviadb_load_hd_unload,oliviadb_apply_capture_log,oliviadb_define_partitions,oliviadb_set_haldb_controlandoliviadb_register_partition_selectorreturn -1 andoliviadb_last_error()names what is missing; a DEDB, MSDB, PHDAM, PHIDAM or PSINDEX database is refused when first used (oliviadb_schedulereturns NULL with the reason). Before version 8 these were part of the one library.liboliviadb_dli_enterprise(enterprise crateoliviadb-dli-ffi-ent): every function ofliboliviadb_dliplus Fast Path, HALDB, IMS log capture and IMS unload formats, registered when the shared library is loaded;oliviadb_extensions()returns 15 (OLIVIADB_EXT_FAST_PATH | OLIVIADB_EXT_HALDB | OLIVIADB_EXT_CAPTURE | OLIVIADB_EXT_IMS_UNLOAD). A host that links it statically callsoliviadb_enterprise_init()first.
The JNI libraries follow the same split: liboliviadb_dli_jni (crate oliviadb-dli-jni) and
liboliviadb_dli_jni_enterprise (enterprise crate oliviadb-dli-jni-ent; Java loads it with
-Doliviadb.jni.lib=<file>). In Rust, a library registers its functions with
oliviadb_dli_ffi::ext::register (trait oliviadb_dli_ffi::ext::Extensions).
C ABI version 9: OliviaDB names¶
oliviadb_abi_version() returns 9. Version 9 is version 8 with every name changed to the
product's name OliviaDB; arguments, results and behaviour are those of version 8.
| version 8 | version 9 |
|---|---|
libhdbdli (.dylib, .so, .a) |
liboliviadb_dli (package oliviadb-dli-lib) |
libhdbdli_enterprise |
liboliviadb_dli_enterprise (enterprise package oliviadb-dli-ffi-ent) |
libhdbdli_jni, libhdbdli_jni_enterprise |
liboliviadb_dli_jni, liboliviadb_dli_jni_enterprise |
header hdb_dli.h |
header oliviadb_dli.h |
functions hdb_* (hdb_open, hdb_call, ...) |
functions oliviadb_* (oliviadb_open, oliviadb_call, ...) |
types hdb_system, hdb_program, hdb_arg, hdb_rmname, hdb_*_fn |
oliviadb_system, oliviadb_program, oliviadb_arg, oliviadb_rmname, oliviadb_*_fn |
macros HDB_RUNTIME_*, HDB_EXT_* |
OLIVIADB_RUNTIME_*, OLIVIADB_EXT_* |
hdb_enterprise_init() |
oliviadb_enterprise_init() |
Java property -Dhdb.jni.lib, package dev.hdb.dli.jni |
-Doliviadb.jni.lib, com.oliviadb.dli.jni |
The IMS entry points (CBLTDLI, CEETDLI, ASMTDLI, PLITDLI, AIBTDLI) keep their
names. The old names are gone: no library libhdbdli is built any more and no hdb_*
symbol is exported (the temporary forwarding package hdb-dli-ffi has been removed). A
host still linked against libhdbdli or calling hdb_* must switch to the names of
version 9 above.
C ABI version 10: the local call path¶
oliviadb_abi_version() returns 10. Version 10 adds a client of the DL/I server's local call
path (oliviadb serve --local SOCKET, docs/operations.md, "The local call path"): the
host's program makes its calls through a shared-memory call slot to the server on its node,
instead of running DL/I in the host's process, so a stray store of the program cannot
reach the server's buffers. Every function of version 9 keeps working.
| function | does |
|---|---|
oliviadb_local_connect(socket, mode) |
attach; OLIVIADB_LOCAL_WAKE (sleep between calls) or OLIVIADB_LOCAL_POLL (spin: the lowest latency) |
oliviadb_local_schedule(c, psb) |
schedule a program; returns the number of PCBs (I/O PCB first) |
oliviadb_local_mask_len(c, i), oliviadb_local_mask_init(c, i, mask, len) |
masks in host storage, as oliviadb_mask_len / oliviadb_mask_init |
oliviadb_local_call(c, pcb, func, mask, mask_len, args, nargs) |
a call, as oliviadb_call: the I/O area and the SSAs (or a system service call's areas) with their lengths; the I/O area and the mask are copied back |
oliviadb_local_sync(c), oliviadb_local_term(c), oliviadb_local_backout(c) |
sync point, normal end, back out |
oliviadb_local_reconnect(c), oliviadb_local_outcome(c) |
after the server's death: attach again (same session; schedule again), and whether the sync point that went unanswered committed (1) or not (0) |
oliviadb_local_close(c) |
detach (a program still scheduled is backed out) |
Return values are those of oliviadb_call (0, the status characters, -1; -3 when a lock was
not granted within the server's --lock-wait: nothing was done) and OLIVIADB_LOCAL_LOST
(-5) when the server died: the unit of work since the last sync point, the positions and the
locks are gone (oliviadb_last_error() says what was in flight). Program storage is in the
server's character set (oliviadb serve --ascii or EBCDIC); the function code is passed as
the program has it. Evidence: oliviadb-dli-lib/tests/c_abi.rs local_call_path (a C
program in both modes against a server with EBCDIC storage).
C ABI version 11: exit routines named in a DBD¶
Version 11 adds (oliviadb_abi_version() returns 12 since version 12, below):
- Index maintenance exit routines (XDFLD
EXTRTN=, Exit Routines, SC19-4217-02, "Secondary Index Database Maintenance exit routine", p.107-110):oliviadb_register_index_exit(sys, name, fn, ctx)before the database is first used. The routine is called when an ISRT, REPL or DLET changes an index source segment, after the NULLVAL test passes, withctx, its name, the indexed segment's and the XDFLD's names, the index entry (the search fields then the subsequence fields: OliviaDB's form of the manual's indexing segment, which also has constant, duplicate data and symbolic pointer) and the index source segment. It returns 0 to keep the entry and 4 to suppress it (a sparse index); any other value fails the call that changed the source with AO and the call has no effect. In Rust:System::register_index_exitwith anoliviadb_dli::index::IndexExit. A database whose routine is not registered is not opened (the routine is loaded when the database is opened, p.108). - Compression-only edit routines (SEGM
COMPRTN=):oliviadb_declare_compression_only(sys, name). A routine that only compresses changes nothing a program sees, so OliviaDB stores the segments as programs see them (and compresses its own blocks). A routine not declared refuses its database: edit routines that change data are not supported yet.
Data Capture exit routines (EXIT=name) refuse their database; EXIT=* (logging only) is
accepted. Evidence: oliviadb-dli/tests/exits.rs, oliviadb-dli-lib/tests/c_abi.rs
index_exit_from_c.
C ABI version 12: the AIB¶
oliviadb_abi_version() returns 12. AIBTDLI reads and sets the AIB fields at the offsets of
the AIB mask (Application Programming, IMS 15.5, "Specifying the AIB mask", Table 36) and
answers with the AIB return and reason codes of Messages and Codes, Volume 4, IMS 15.5,
chapter 19, "AIB return and reason codes" (page numbers: that manual's PDF). This table is the
one list a host that handles AIBTDLI itself should answer by too:
| field | offset | what AIBTDLI does |
AIBRETRN / AIBREASN | source |
|---|---|---|---|---|
| AIBID | 0 | must be DFSAIB and two blanks, else the call is refused (-1) |
not set | AIB mask, Table 36 |
| AIBLEN | 8 | below 128: no call | X'104' / X'228' | PDF p.324 |
| AIBSFUNC | 12 | not blank on a call that takes no subfunction (every call but INQY): no call; INQY's, below | X'104' / X'218' | PDF p.323 |
| AIBRSNM1 | 20 | the PCB name (IOPCB for the I/O PCB); not found: no call |
X'104' / X'208' | PDF p.322 |
| AIBOALEN | 44 | the I/O area's length; zero or negative on a call that returns data (GU, GHU, GN, GHN, GNP, GHNP): no call | X'104' / X'210' | PDF p.323 |
| AIBOAUSE | 48 | set to the length of the data the call returned (0 for a call that returns none or ends with a status) | AIB mask, Table 36 | |
| AIBRETRN, AIBREASN | 64, 68 | 0/0 for a blank status; any other status: the status is in the PCB, the reason code is left as it was | X'000' / X'000'; X'900' / unchanged | PDF p.338 (0900) |
| AIBERRXT | 72 | not set (the manual ties it to codes OliviaDB does not return) | ||
| AIBRSA1 | 76 | a PCB token, see below |
AIBRSA1 on a 64-bit host. IMS returns the PCB's address in AIBRSA1, a 4-byte field. A
64-bit host's address does not fit, so OliviaDB returns a token instead: the PCB's number in
the PSB's PCB list plus 1 (the I/O PCB is 1, the first DB PCB 2), a fullword in the program's
byte order. oliviadb_pcb_address(p, token - 1) gives the PCB's address; 0 is never a
token. A program that uses AIBRSA1 as an address works only where the host maps it back (a
31-bit run time that keeps PCBs below the line can store the address itself); the token
keeps the field's meaning, "which PCB the call used", on every host.
INQY¶
AIBTDLI serves INQY (Application Programming APIs, IMS 15.5, "INQY call", printed pages
47-59 and 129-143; codes from Messages and Codes, Volume 4, IMS 15.5, printed pages). In
Rust it is Program::inquire(sys, sfunc, pcb, io), which returns an Inquiry (status, the PCB
to write it to, AIBRETRN/AIBREASN, the lengths, AIBRSA1/AIBRSA2); oliviadb_dli::inqy has the
ENVIRON layout and System::environment the values only the host knows. INQY through the PCB
interface (CBLTDLI and the others) gets AD (p.48).
| subfunction (AIBSFUNC) | PCB (AIBRSNM1) | what OliviaDB returns | source |
|---|---|---|---|
| not in the manual's list | any | X'104'/X'218', no call | 0104/0218, p.315 |
| any but FIND | not the I/O PCB (null: not the I/O PCB or an alternate PCB) | AD in the named PCB, X'900' | Table 22, p.59; AD, p.137-138 |
| ENVIRON, ENVIRON2, PROGRAM | I/O PCB, no I/O area address | X'104'/X'610', no call | 0104/0610, p.320 |
| the same | AIBOALEN zero or negative | X'104'/X'210', no call | 0104/0210, p.315 |
| ENVIRON | I/O PCB | 108 bytes: the table in oliviadb_dli::inqy |
Table 18, p.50-52 |
| ENVIRON2 | I/O PCB | 160 bytes: ENVIRON's, then ENVIRON2's fields | Table 19, p.52-53 |
| PROGRAM | I/O PCB | the program name (oliviadb_set_program_name, else the PSB name), 8 bytes |
p.59 |
| ENVIRON, ENVIRON2, PROGRAM | AIBOALEN shorter than the output | the part that fits, AG in the I/O PCB, X'100'/X'00C', AIBOALEN the length returned, AIBOAUSE the length needed | p.48-49; AG, p.139; 0100/000C, p.311 |
| DBQUERY | I/O PCB | NA or blank in each DB PCB (GSAM PCBs are left; DEDB and MSDB are always blank); in the I/O PCB BJ (no DB PCB, or none available), BK (some NA) or blank; X'900' unless blank | p.49 |
| FIND | any named PCB | AIBRSA1 the PCB token (as for every AIB call, above); no PCB is changed | p.55 |
| LERUNOPT | I/O PCB, online | AIBRSA2 0: OliviaDB keeps no Language Environment overrides | p.58, p.143 |
| LERUNOPT | I/O PCB, batch | AD (the manual names the online environments only, p.143; the status is OliviaDB's choice) | p.143 |
| null, MSGINFO | I/O PCB | AQ: both report on messages and destinations, and OliviaDB has no transaction manager | AQ, p.143; p.130 |
NA marks a PCB whose database the host marked unavailable (oliviadb_set_unavailable): the
same test that gives a call on the PCB BA (after INIT STATUS GROUPA) or ends the program
U3303. OliviaDB marks a database unavailable as a whole, never for update only, so it does not
return NU. The same statuses come from INIT DBQUERY (with the database organization in each
DB PCB's segment-name field, p.42-43) and are in the masks from the start when a database is
unavailable at schedule ("Automatic INIT DBQUERY", p.43). DBQUERY changes other PCBs' masks
than the one in the call: the library writes them into the masks a host registered with
oliviadb_register_mask, else into its own; in Rust they come from
Program::take_mask_updates and Program::write_status.
STAT and SNAP¶
STAT and SNAP on a full-function DB PCB (Application Programming APIs, IMS 15.5, "STAT
call" and "SNAP call", printed pages 66-71; the statistics formats: Application Programming,
IMS 15.5, "Retrieving database statistics: the STAT call", printed pages 139-150). OliviaDB
has one buffer pool, the storage engine's block cache: STAT reports it as the OSAM pool
(DBAS, DBES) and as one VSAM data subpool (VBAS, VBES). Which OliviaDB counter fills which
field is the table at the top of oliviadb-dli/src/program/stat.rs; fields without a
counterpart are 0.
| case | OliviaDB |
|---|---|
DBASF/U/S, DBESF/U/S/O, VBASF/U/S, VBESF/U/S, E1 with DBESF/O/U |
the statistics; unformatted (U) by the manual's word lists, formatted (F, S, O) as records of the documented number and length with OliviaDB's LABEL value text (the manual shows them as figures without byte positions) |
| DBES, VBAS, VBES: the second call of a series | the totals (BSIZ ALL) and GA; the next call starts over, as does any other call on the PCB |
a function the manual does not define, E1 elsewhere |
AC |
| the I/O PCB, a GSAM or Fast Path PCB | AD |
| an I/O area below the function's minimum | AO (OliviaDB's choice for a short I/O area) |
| SNAP without an I/O area | AB |
| SNAP | blank; the destination, identification and options (by the LL of Table 26, defaults LOG, NOTGIVEN, YYYN) and OliviaDB's text of the PCB's state are kept for the host (System::take_snaps, at most 1000); no SNAP dump is written |
CBLTDLI and the other entry points that get addresses only take the I/O area's length from
the stat function (oliviadb_dli::program::stat_io_len) and SNAP's from its LL.
C ABI version 13: callers that do not use the variadic convention¶
CBLTDLI, CEETDLI, ASMTDLI, PLITDLI and AIBTDLI are declared variadic, but most
callers of DL/I are not C: a GnuCOBOL CALL 'CBLTDLI' USING ... passes its arguments as to a
function with that many parameters. On Linux (x86-64, aarch64) and on macOS x86-64 both kinds
of caller put the arguments in the same registers and stack slots, and the entries stay as
they were. On Apple arm64 they differ (variadic arguments go on the stack, fixed ones in
x0-x7 first), so there:
CBLTDLIand the others take eight fixed parameters and the rest variadically: what a caller that does not use the variadic convention passes.- Each has a plainly variadic twin,
oliviadb_CBLTDLI_va(andoliviadb_CEETDLI_va,oliviadb_ASMTDLI_va,oliviadb_PLITDLI_va,oliviadb_AIBTDLI_va; exported on every platform), andoliviadb_dli.hmaps the names to the twins there, so C sources keep callingCBLTDLI(...). C programs built for Apple arm64 against an older header must be rebuilt.
The argument count rules do not change (a parmcount first, else oliviadb_set_argc, else up
to the first NULL), and the library takes no argument past the count they give: an argument
slot a caller did not pass is never read. oliviadb_abi_version() returns 13. Tests:
oliviadb-dli-lib/tests/c_abi.rs fixed_arity_callers (tests/c/fixed.c: calls through
fixed-arity prototypes, ten arguments, and the twin) and the GnuCOBOL program of
DL/I from COBOL, C, Rust, Java and Python (tools/docs-snippets.py, on Linux and on
Apple arm64).
A DL/I backend interface for an existing runtime¶
A runtime that already parses CALL 'CBLTDLI' and has its own DL/I emulation can switch to
OliviaDB behind one trait-shaped seam:
| runtime event | OliviaDB call |
|---|---|
| job step with a PSB starts | sys.schedule(psb, runtime), init_mask for each PCB |
CALL 'CBLTDLI' / 'PLITDLI' / 'AIBTDLI' |
prog.call(&mut sys, func, pcb_index, pcb_mask, io_area, ssas) |
| step ends normally / abends | prog.terminate(&mut sys) / prog.abort() |
| DBD/PSB libraries | sys.load_library(dir) or define_dbd / define_psb |
| data sets of a database | one System directory holds all databases of a key space |
Served: DL/I levels 1 to 5 (calls, command codes C D F L N P Q U V -, path calls, system
service calls CHKP XRST ROLL ROLB ROLS SETS SETU SYNC INIT LOG DEQ, secondary indexes
with PROCSEQ, index databases read as databases, field sensitivity, logical
relationships with logical databases), GSAM and HSAM/SHSAM. Not served yet (the call
returns a status rather than pretending): POS (AD or AJ); GSCD (AD: no IMS control blocks);
GUR (AD through a PCB, AIB X'104'/X'248': no IMS catalog database); INIT VERSION (BF: no
database versioning). See docs/status.md and docs/dli-coverage.md.
Interface changes¶
C ABI 13: on Apple arm64 CBLTDLI, CEETDLI, ASMTDLI, PLITDLI and AIBTDLI take calls
that do not use the variadic convention, and C callers reach the variadic twins
oliviadb_<NAME>_va through the header: C programs built there against an older header must
be rebuilt. Other platforms: no change.
Since 1c2b105: dynamic backout off by default (System::dynamic_backout false; it was
on), per program (Program::set_dynamic_backout); C ABI version 7 oliviadb_schedule_batch.
Since L2-L4: C ABI version 2 (above); Store::bucket and Store::key_prefix return
Result (a randomizer can fail); Randomizer::try_randomize has a default, so existing
implementations keep compiling; FnRandomizer wraps a fallible function.
Since phase 0:
All phase-0 signatures are unchanged. Added: Program::call_io, Program::abend_code,
Status::WAIT, Status::DEADLOCK, Status::RA, Status::BC, Options::node and
Node; prog.call(.., PcbRef::Io, ..) now executes system service calls (phase 0
returned AD); Program::io_size now covers a path call through every segment of the
view. C ABI: oliviadb_abend_code, return values -2 and -3.