Bug #114587 i am able to insert the value in table , while my column is set on not null.

Submitted: 8 Apr 2024 19:06 Modified: 9 Apr 2024 20:09
Reporter: Sunny kumar Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: DML Severity:S1 (Critical)
Version:8.0.36 OS:Windows (Microsoft Windows 10 Enterprise)
Assigned to: CPU Architecture:Any
Tags: WBBugReporter

[8 Apr 2024 19:06] Sunny kumar
Description:
----[For better reports, please attach the log file after submitting. You can find it in C:\Users\sunnkumar\AppData\Roaming\MySQL\Workbench\log\wb.log]

i am able to insert the value in table , while my column is set on not null.

as for exmaple :

I had created table with given query :

create table uniq (id int primary key, name varchar(50) unique ,address varchar(50) not null , state varchar (50) default "Bihar" , age int check (age<=18));

then i tried to insert the given value :

insert into  uniq  values(6,"p",'',"mumbai",17);

here my address column is already set on not null , but here i am able to execute this query , and able to see the value as NULL while running select query.

you guys should add one file tab, where someone can add screenshots.

Thanks 
Sunny Kumar
mail id : sunnykumarkashyap19@gmail.com

How to repeat:
.

Suggested fix:
you need work on server side to resolve this issue.
[9 Apr 2024 10:16] MySQL Verification Team
Hi Mr. kumar,

Thank you for your bug report.

However, this is not a bug.

These is the result that we get:

select * from uniq;
+----+------+---------+--------+------+
| id | name | address | state  | age  |
+----+------+---------+--------+------+
|  6 | p    |         | mumbai |   17 |
+----+------+---------+--------+------+

Problem is that you have set `address` column as NOT NULL. However, you have not inserted NULL in it, but a blank. A blank string is a very valid string.

If you have tried to insert NULL, you would have got this :

insert into  uniq  values(6,"p",NULL,"mumbai",17);
ERROR 1048 (23000): Column 'address' cannot be null

Not a bug.
[9 Apr 2024 20:09] Sunny kumar
Hi,

SELECT CHAR_LENGTH(address) AS address_length FROM uniq;

when you'll run rhis query you can get the size of address , which is ZERO.
which means here value is NULL.

so this instertion should not possible, cause i am giving null value which should not be acceptable.

so this is BUG(functionality should not be affect any how).

Thanks 
Sunny Kumar
[10 Apr 2024 10:21] MySQL Verification Team
Hi Mr. kumar,

For your information, the empty string has a size of 0 (zero).

This is SQL, not a C programming language, so '\0' is not counted at all.

Not a bug.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.043 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.