Skip to main content

Module wire

Module wire 

Source
Expand description

DRDA in the requesting role: the Db2 client’s codec.

Rust owns everything below the SQL: DSS framing (request chains, correlators, continuation segments), DDM objects and their extended lengths, the EBCDIC (CCSID 37) DDM character strings, the package name every SQL command names, and the FD:OCA structures replies carry (SQLCA, SQLDA, the query answer set descriptor and its rows). The model chooses statements and reads decoded results; it never sees or writes a byte of this.

Every length a server declares is checked against what it sent and against a bound of ours before anything is allocated for it: a DSS and its continuations (MAX_DSS_BYTES), a whole reply chain (MAX_REPLY_BYTES, MAX_REPLY_DSS), objects per DSS (MAX_OBJECTS_PER_DSS), columns (MAX_COLUMNS), rows (MAX_ROWS_LIMIT) and the bytes of one answer set (MAX_RESULT_BYTES). None of the decoders recurses.

The layouts follow DRDA (The Open Group, Volume 1) at SQLAM level 7, cross-checked against Apache Derby’s network server and client (org.apache.derby.impl.drda, org.apache.derby.client.net), which is also the server the tests drive.

Modules§

cp
DDM code points this client sends or reads.

Structs§

Column
One described output column.
Dss
One reply DSS with its continuation segments joined.
Field
One field of an answer-set row: its DRDA type (odd = nullable) and length.
Object
One DDM object.
Package
The package, consistency token and section every SQL command names. When the database name is longer than 18 bytes the extended form (each name preceded by its length) is used.
Repr
How the server represents FD:OCA data: byte order from its TYPDEFNAM, character sets from its TYPDEFOVR.
Sqlca
An SQL communications area: what a statement did.

Enums§

Endian
RowItem
One row’s worth of an answer set.
Short
Why a read stopped.

Constants§

CCSID_UTF8
CCSID_UTF16
DEFAULT_MAX_ROWS
Rows delivered when max_rows is not given.
DSS_OBJDSS
DSS_RPYDSS
DSS_RQSDSS
DSS types (low nibble of the format byte).
MAX_COLUMNS
A described result may have at most this many columns (Db2’s own limit is 1012).
MAX_CONTINUES
CNTQRY round trips one query may take.
MAX_CREDENTIAL_BYTES
User id and password are DDM strings of at most 255 bytes.
MAX_DSS_BYTES
One reassembled DSS (all its continuation segments joined) may be at most this large.
MAX_OBJECTS_PER_DSS
One DSS may hold at most this many DDM objects.
MAX_RDBNAM_BYTES
A relational database name, with any connection attributes, is at most 255 bytes here.
MAX_REPLY_BYTES
One reply chain — every DSS answering one command — may be at most this large.
MAX_REPLY_DSS
One reply chain may hold at most this many DSSes.
MAX_RESULT_BYTES
The answer-set bytes (QRYDTA) one query may accumulate before it is refused.
MAX_ROWS_LIMIT
The most rows one execute_query may deliver, whatever max_rows asks for.
MAX_SQL_BYTES
The longest statement sent (Db2’s own statement limit is 2 MiB).
OUR_TYPDEFNAM
The data representation this client declares for what it sends: big-endian integers, and through TYPDEFOVR, UTF-8 single-byte and mixed characters.
PKG_COLLECTION
The dynamic-SQL package every statement names: collection NULLID, package SYSLH200 (large, with hold, isolation 2 = cursor stability), consistency token SYSLVL01, section 1. These are the names IBM’s JDBC driver binds; Derby reads isolation and holdability out of them.
PKG_ID
PKG_SECTION
PKG_TOKEN
QUERY_BLOCK_SIZE
The query block size asked for in OPNQRY and CNTQRY.
SECMEC_USRIDONL
USRIDONL: user id only, for a connection with no password.
SECMEC_USRIDPWD
USRIDPWD: user id and password, sent in the clear.
SQLAM_LEVEL
SQLAM level whose FD:OCA layouts this codec reads. A server below it is refused.

Functions§

accrdb
ACCRDB: open the database, declaring our data representation and product.
accsec
clsqry
cntqry
command
One command: its DSSes, all under one correlator, chained to each other.
correlation_token
The correlation token DRDA asks a TCP/IP requester for: its IPv4 address as eight hex digits whose first is shifted into G..P, a dot, its port as four hex digits, then six bytes that make this connection’s token unique.
decode_row
Decode the row at the front of buf. Ok(None): the row continues in the next query block.
decode_text
Decode character data in ccsid.
dss
Wrap payload in a DSS, splitting it into continuation segments when it is longer than one segment can say.
ebcdic
Encode a DDM character string in CCSID 37, refusing any character it cannot carry rather than substituting one: a user id or password that arrived altered would be a different credential.
excsat
EXCSAT: who we are and the manager levels we speak.
excsqlimm
EXCSQLIMM + SQLSTT: run a statement that returns no rows.
from_ebcdic
Decode a DDM character string from CCSID 37, trailing blanks dropped.
name_of
The name of a reply message or reply data object, for errors and logs.
object
length | codepoint | data, with an extended length when data does not fit 15 bits.
objects
The objects in one DSS, in order. Extended lengths are honoured; a length running past the DSS is an error.
opnqry
OPNQRY: open the prepared query; the server closes it itself at end of data.
param
params
The parameters inside an object’s data.
parse_qrydsc
Parse the FD:OCA triplets of a QRYDSC (or several, concatenated) into the row layout.
parse_sqlcard
SQLCARD: one SQLCA, or none when the statement succeeded without comment.
parse_sqldard
SQLDARD: the statement’s SQLCA, then its described columns.
prpsqlstt
PRPSQLSTT + SQLSTT: prepare a query and have its output described (extended SQLDA).
rdb_name
RDBNAM as DDM wants it: CCSID 37, at least 18 bytes (blank-padded), at most MAX_RDBNAM_BYTES.
rdbcmm
rdbrllbck
row_object
Pair decoded values with column names into one JSON object per row. Names a statement repeats get #2, #3, …; an unnamed column is COLn.
secchk
secchkcd_meaning
What SECCHKCD says, in words.
severity
SVRCOD of a reply message, 0 when absent.
sqlstt
SQLSTT: a nullable mixed-character LOB (null indicator, 4-byte length, UTF-8 text) then a null single-byte string.
take_dss
Take one complete DSS off the front of buf. Ok(None) means more bytes are needed; an error means the stream is not DRDA, or declares more than MAX_DSS_BYTES.