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§
Constants§
- CCSID_
UTF8 - CCSID_
UTF16 - DEFAULT_
MAX_ ROWS - Rows delivered when
max_rowsis 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_querymay deliver, whatevermax_rowsasks 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
payloadin 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 whendatadoes 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 isCOLn. - 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 thanMAX_DSS_BYTES.