NAME

DBIO::DB2::Test::Conformance - Answers the shared conformance case table for the Db2 driver

VERSION

version 0.900007

SYNOPSIS

use DBIO::DB2::Test::Conformance;
DBIO::DB2::Test::Conformance->run('DDL');
done_testing;

DESCRIPTION

The driver's half of the shared case table of DBIO::Test::Conformance (core ADR 0060). Core owns the cases and the runner; this class says how to reach a Db2 database, how to install a declaration into it through $schema->deploy (DBIO::DB2::Deploy), and how to read a fact back through DBIO::DB2::Introspect.

The server is the one DBIO_TEST_DB2_DSN, DBIO_TEST_DB2_USER and DBIO_TEST_DB2_PASS name. Without the DSN (or without DBD::DB2) only the declarations are checked. The login needs the right to create schemas: "diff" in DBIO::DB2::Deploy builds its target in a throwaway schema, and so does every case here.

The namespace of a case is a schema of its own, DBIO_CF_<pid>_<n> ("conformance_namespace"). The connection of the case sets CURRENT SCHEMA to it when it connects (an on_connect_do, the schema need not exist yet), so the tables of the case are made there, the deploy and the introspector read it, and the diff compares nothing else. The schema is dropped in "conformance_cleanup" -- views, then tables, then the schema -- only when "conformance_namespace" of this run created it: one that is there already makes the namespace throw, touching nothing.

The class names no storage class and never decides the driver: the schema component DB2 declares it, the DSN names the database.

METHODS

conformance_live_available

True when DBIO_TEST_DB2_DSN and DBIO_TEST_DB2_USER are set and DBD::DB2 loads.

conformance_connect

Names the schema of the case, loads the DB2 schema component into the case's schema class and connects, with CURRENT SCHEMA set to that schema.

The connection names a LongReadLen of a million bytes: DBD::DB2 reads at most 32700 bytes of a LOB by default and refuses a longer one with "Data in column has been truncated", and the Bind list writes and reads 100000 characters. The driver keeps that default; an application that stores larger values sets it.

conformance_namespace

A source named other.t is the table t in the schema other: the install makes that schema with the table, so the token also names these schemas, and the cleanup drops them. One that exists already makes the namespace throw.

Creates the schema of the case and returns the token { name, created } for "conformance_cleanup". A schema of that name that exists already makes it throw, touching nothing and returning no token.

conformance_install

Installs the declaration with $schema->deploy, the public entry point, which hands over to "install" in DBIO::DB2::Deploy.

conformance_cleanup

Disconnects, and drops the schema the token names when "conformance_namespace" created it: the views, the tables (with their indexes, keys and identity sequences), then the schema, on a connection of its own. A failure of one of those statements is thrown, not swallowed. Without a token nothing is dropped.

conformance_diff_is_empty

True when "diff" in DBIO::DB2::Deploy of the installed database against the same declaration has no changes.

conformance_upgrade

Connects the target schema class to the schema of the installed one (a connection of its own, CURRENT SCHEMA set as in "conformance_connect") and runs "upgrade" in DBIO::DB2::Deploy -- the public entry point -- through it, with allow_destructive => 1: the upgrade cases drop and change on purpose (the guard itself is the deploy cases, "conformance_deploy"). Returns the connected target schema; a refusal of the diff is thrown from here as it came. The cleanup of that schema drops the namespace through the token of the first.

conformance_deploy

Same connecting as "conformance_upgrade", but returns the deploy object over the connected target schema, DBIO::DB2::Deploy->new(schema => $to), for the deploy cases of the Diff list (ADR 0080): apply and upgrade are those of DBIO::Deploy::Base, dry_run executes nothing, and a diff with a drop needs allow_destructive. The cleanup drops the namespace through the token of the first schema.

conformance_answered_through

The table versions the answers were written against, per area: { DDL => 2, Diff => 4, Bind => 1 }, each list as it stands. Every case of all three lists is answered: correctly, or by a refusal or deviation of "conformance_refusals". Version 3 of the Diff list replaces diff-column-dropped-with-index by diff-indexed-column-dropped; version 4 adds the deploy cases, answered through "conformance_deploy".

conformance_refusals

DDL list: two server refusals and one deviation. Diff list: two server refusals. Bind list: two server refusals. The rest is answered right. text without a size is a CLOB; the character columns of a result are decoded from the UTF-8 bytes DBD::DB2 returns (DBIO::DB2::Storage::Cursor).

ddl-enum-value-apostrophe (server)

Db2 has no enum type (SQL0204N). install_ddl throws, naming table, column and type, instead of writing ENUM for the server to refuse (DBIO::DB2::Type). The way out is a varchar column.

ddl-type-size-bit (server)

Db2 has no BIT type (SQL0104N), with a size or without one; refused the same way.

bind-long-string (server)

Db2 compares a CLOB with a VARCHAR, and a value of more than 32672 bytes is too long for that (SQL0433N, whatever the type the value is bound with, measured; a stored value that long breaks the comparison for every row of the table). The storage refuses a select or delete that compares a clob/text column with such a value, naming table and column ("_prep_for_execute" in DBIO::DB2::Storage), before the server is asked. Storing and reading the value is not affected.

bind-lob-empty-and-large (server)

DBD::DB2 reads an empty BLOB as NULL (the server's LENGTH is 0), and nothing in the DBD or the storage tells the two apart on the way back. The storage refuses to store an empty string in a blob column, naming table and column, rather than store it as something that does not come back. An empty CLOB is stored and read back as ''.

ddl-default-digit-string (deviation)

A CHAR(5) pads the default '007' with blanks, so it reads back as '007 '. The default itself is written as the string it is, not as the number 7; the padding is the type's.

diff-column-added-not-null-populated, diff-not-null-over-nulls (server)

Db2 cannot be given a value for the rows in either: ADD COLUMN ... NOT NULL without a default is refused whatever rows the table holds (SQL0193N), and SET NOT NULL over a NULL is refused by the server (SQL0407N). "apply" in DBIO::DB2::Deploy and upgrade refuse both before the first statement, naming table and column, and make up no value.

conformance_fact

Reads one fact through DBIO::DB2::Introspect (the case's schema); the vocabulary is the one of "Facts" in DBIO::Test::Conformance. index_count reads SYSCAT.INDEXES itself: the model leaves the index behind a UNIQUE constraint out, and the fact counts it.

SEE ALSO

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.