#
# NOT NULL attribute in columns
#
# Usage:
# let $col_definition = <column type (and possibly more options)>;
# let $col_default = <default non-null value for a column>;
# --source col_not_null.inc
#
# We will add NOT NULL at the endof$col;
#
# Also, if$col_defaultis defined,
# we will create a table with2 columns
# (one with DEFAULT $col_default, and one without any default),
# and will also attempt to add a column with DEFAULT NULL.
#
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $create_definition = c $col_definitionNOT NULL
--source create_table.inc if ($mysql_errname)
{
--source unexpected_result.inc
} if (!$mysql_errname)
{
SHOW COLUMNS IN t1;
if ($col_default != '')
{
let $create_definition =
c $col_definitionNOT NULL,
c2 $col_definitionNOT NULL DEFAULT $col_default
;
--source create_table.inc if ($mysql_errname)
{
--source unexpected_result.inc
} if (!$mysql_errname)
{
SHOW COLUMNS IN t1;
--let $error_codes = ER_INVALID_DEFAULT
--let $alter_definition = ADD COLUMN err $col_definitionNOT NULL DEFAULT NULL
--source alter_table.inc if ($mysql_errname != ER_INVALID_DEFAULT)
{
--let $functionality = ALTER or DEFAULT
--source unexpected_result.inc
}
--let $error_codes = ER_BAD_NULL_ERROR
INSERT INTO t1 (c) VALUES (NULL);
--source check_errors.inc if ($mysql_errname != ER_BAD_NULL_ERROR)
{
--let $functionality = NOT NULL columns
--source unexpected_result.inc
}
# HEX should be universal for all column types
SELECT HEX(c), HEX(c2) FROM t1;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.