You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
5.1 KiB

  1. #
  2. # test of already fixed bugs
  3. #
  4. --disable_warnings
  5. drop table if exists t1,t2,t3,t4,t5,t6;
  6. drop database if exists mysqltest;
  7. #
  8. # Bug 10838
  9. # Insert causes warnings for no default values and corrupts tables
  10. #
  11. CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ',
  12. b varchar(1) binary NOT NULL DEFAULT ' ',
  13. c varchar(4) binary NOT NULL DEFAULT '0000',
  14. d tinyblob NULL,
  15. e tinyblob NULL,
  16. f tinyblob NULL,
  17. g tinyblob NULL,
  18. h tinyblob NULL,
  19. i tinyblob NULL,
  20. j tinyblob NULL,
  21. k tinyblob NULL,
  22. l tinyblob NULL,
  23. m tinyblob NULL,
  24. n tinyblob NULL,
  25. o tinyblob NULL,
  26. p tinyblob NULL,
  27. q varchar(30) binary NOT NULL DEFAULT ' ',
  28. r varchar(30) binary NOT NULL DEFAULT ' ',
  29. s tinyblob NULL,
  30. t varchar(4) binary NOT NULL DEFAULT ' ',
  31. u varchar(1) binary NOT NULL DEFAULT ' ',
  32. v varchar(30) binary NOT NULL DEFAULT ' ',
  33. w varchar(30) binary NOT NULL DEFAULT ' ',
  34. x tinyblob NULL,
  35. y varchar(5) binary NOT NULL DEFAULT ' ',
  36. z varchar(20) binary NOT NULL DEFAULT ' ',
  37. a1 varchar(30) binary NOT NULL DEFAULT ' ',
  38. b1 tinyblob NULL)
  39. ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
  40. --enable_warnings
  41. INSERT into t1 (b) values ('1');
  42. SHOW WARNINGS;
  43. SELECT * from t1;
  44. CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ',
  45. b varchar(1) binary NOT NULL DEFAULT ' ',
  46. c varchar(4) binary NOT NULL DEFAULT '0000',
  47. d tinyblob NULL,
  48. e tinyblob NULL,
  49. f tinyblob NULL,
  50. g tinyblob NULL,
  51. h tinyblob NULL,
  52. i tinyblob NULL,
  53. j tinyblob NULL,
  54. k tinyblob NULL,
  55. l tinyblob NULL,
  56. m tinyblob NULL,
  57. n tinyblob NULL,
  58. o tinyblob NULL,
  59. p tinyblob NULL,
  60. q varchar(30) binary NOT NULL DEFAULT ' ',
  61. r varchar(30) binary NOT NULL DEFAULT ' ',
  62. s tinyblob NULL,
  63. t varchar(4) binary NOT NULL DEFAULT ' ',
  64. u varchar(1) binary NOT NULL DEFAULT ' ',
  65. v varchar(30) binary NOT NULL DEFAULT ' ',
  66. w varchar(30) binary NOT NULL DEFAULT ' ',
  67. x tinyblob NULL,
  68. y varchar(5) binary NOT NULL DEFAULT ' ',
  69. z varchar(20) binary NOT NULL DEFAULT ' ',
  70. a1 varchar(30) binary NOT NULL DEFAULT ' ',
  71. b1 tinyblob NULL)
  72. ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
  73. SHOW CREATE TABLE t2;
  74. INSERT into t2 (b) values ('1');
  75. SHOW WARNINGS;
  76. SELECT * from t2;
  77. drop table t1;
  78. drop table t2;
  79. #
  80. # Bug#20691: DATETIME col (NOT NULL, NO DEFAULT) may insert garbage when specifying DEFAULT
  81. #
  82. # From the docs:
  83. # If the column can take NULL as a value, the column is defined with an
  84. # explicit DEFAULT NULL clause. This is the same as before 5.0.2.
  85. #
  86. # If the column cannot take NULL as the value, MySQL defines the column with
  87. # no explicit DEFAULT clause. For data entry, if an INSERT or REPLACE
  88. # statement includes no value for the column, MySQL handles the column
  89. # according to the SQL mode in effect at the time:
  90. #
  91. # * If strict SQL mode is not enabled, MySQL sets the column to the
  92. # implicit default value for the column data type.
  93. #
  94. # * If strict mode is enabled, an error occurs for transactional tables and
  95. # the statement is rolled back. For non-transactional tables, an error
  96. # occurs, but if this happens for the second or subsequent row of a
  97. # multiple-row statement, the preceding rows will have been inserted.
  98. #
  99. create table bug20691 (i int, d datetime NOT NULL, dn datetime not null default '0000-00-00 00:00:00');
  100. insert into bug20691 values (1, DEFAULT, DEFAULT), (1, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (1, DEFAULT, DEFAULT);
  101. insert into bug20691 (i) values (2);
  102. desc bug20691;
  103. insert into bug20691 values (3, DEFAULT, DEFAULT), (3, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (3, DEFAULT, DEFAULT);
  104. insert into bug20691 (i) values (4);
  105. insert into bug20691 values (5, DEFAULT, DEFAULT), (5, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (5, DEFAULT, DEFAULT);
  106. SET sql_mode = 'ALLOW_INVALID_DATES';
  107. insert into bug20691 values (6, DEFAULT, DEFAULT), (6, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (6, DEFAULT, DEFAULT);
  108. SET sql_mode = 'STRICT_ALL_TABLES';
  109. --error 1364
  110. insert into bug20691 values (7, DEFAULT, DEFAULT), (7, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (7, DEFAULT, DEFAULT);
  111. select * from bug20691 order by i asc;
  112. drop table bug20691;
  113. SET sql_mode = '';
  114. create table bug20691 (
  115. a set('one', 'two', 'three') not null,
  116. b enum('small', 'medium', 'large', 'enormous', 'ellisonego') not null,
  117. c time not null,
  118. d date not null,
  119. e int not null,
  120. f long not null,
  121. g blob not null,
  122. h datetime not null,
  123. i decimal not null,
  124. x int);
  125. insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 1);
  126. insert into bug20691 (x) values (2);
  127. insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 3);
  128. insert into bug20691 values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, 4);
  129. select * from bug20691 order by x asc;
  130. drop table bug20691;
  131. ###
  132. --echo End of 5.0 tests.