当前位置:网站首页>MySQL field truncation principle and source code analysis
MySQL field truncation principle and source code analysis
2022-06-25 15:24:00 【Running pig ZC】
background
I met a very Weird The problem of , The data just inserted , The next time I checked, I couldn't find . After investigation, the database truncated the data we need to insert .

The screening process
Pull the front end line by line debug, Compare data entered into database , It is found that the database can be inserted successfully . So I found some information on the Internet
Positioning and problem solving
Finally, I contacted dba, yes sql_mode What a mess
follow-up
In order to thoroughly understand what is going on , So I picked it up mysql Source code , decision debug And reappear next
Source code
Install the source code environment
Reference resources
https://www.jianshu.com/p/a88ea5558f87
Mysql-5.7.23 , jb- clion , cmake,boost
| Tool name | effect |
|---|---|
| Mysql-5.7.23 | mysql Source code |
| jb- clion | ide |
| cmake | c,c++ Installation and compilation tools for |
| boost | c++ Extension library for , Similar to some three parties jar |
Environmental Science
Mysql-5.7.23 jb- clion
CREATE TABLE `test` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=utf8mb4;
Strict mode
Default configuration is good
Verify that strict mode is enabled
Key code
Field_longstr::report_if_important_data

Nonstrict mode
Modify the configuration

Key code

Suggest
In the insertion of key fields , need check Information such as the length of the field , Or some key values are generated by the backend , And then it goes back to the front end
frequently-used sql_mode
| sqol_mode | explain |
|---|---|
| ONLY_FULL_GROUP_BY | about GROUP BY Aggregation operation , If in SELECT Column in , Not in the GROUP BY It appears that , So this SQL It's illegal , Because the list is not in GROUP BY In the clause |
| NO_AUTO_VALUE_ON_ZERO | This value affects the insertion of self growing columns . By default , Insert 0 or NULL Represents the generation of the next self increasing value . If the user wants to insert a value of 0, And the column is self-growing , So this option works . |
| STRICT_TRANS_TABLES | If a value cannot be inserted into a transaction , Then interrupt the current operation , No restrictions on non transaction tables |
| NO_ZERO_IN_DATE | Zero days and months are not allowed |
| NO_ZERO_DATE | mysql Database is not allowed to insert zero date , Inserting a zero date throws an error instead of a warning |
| ERROR_FOR_DIVISION_BY_ZERO | stay insert or update In the process , If the data is divided by zero , It's a mistake, not a warning . If the mode is not given , So when the data is divided by zero Mysql return NULL |
| NO_AUTO_CREATE_USER | prohibit GRANT Create a user with a blank password |
| NO_ENGINE_SUBSTITUTION | If the required storage engine is disabled or not compiled , Then throw an error . When this value is not set , Replace... With the default storage engine , And throw an exception |
| PIPES_AS_CONCAT | take "||" Treat as the concatenation operator of a string, not as the or operator , This sum Oracle The database is the same , And string concatenation function Concat Think similar |
| ANSI_QUOTES | You can't use double quotes to refer to strings , Because it's interpreted as an identifier |
边栏推荐
- System Verilog — interface
- Single user mode
- [paper notes] street view change detection with deconvolutional networks
- QT file reading -qfile
- 2.18 codeforces supplement
- Compile Caffe's project using cmake
- Semaphore function
- Use Matplotlib to draw a line chart
- Luogu p5707 [deep foundation 2. example 12] late for school
- One code per day - day one
猜你喜欢

Learning C language today is the first time to learn C language. In college, C linguistics is not good, but I want to make progress, so I found a beep video on the Internet to learn C language

Review of arrays and pointers triggered by a topic

C language escape character and its meaning

google_ Breakpad crash detection

semget No space left on device

QT pattern prompt box implementation

Custom structure type

QT loading third-party library basic operation

Sequential programming 1

Fishing detection software
随机推荐
Go build reports an error missing go sum entry for module providing package ... to add:
System Verilog - data type
BM setup process
Errno perrno and strerrno
Stack and queue
[paper notes] contextual transformer networks for visual recognition
Use Matplotlib to draw a line chart
Postman usage notes, interface framework notes
2. operator and expression multiple choice questions
Data feature analysis skills - correlation test
QT source code online view
One question per day,
Character encoding minutes
Qlogsystem log system configuration use
3. Sequential structure multiple choice questions
[paper notes] mcunetv2: memory efficient patch based influence for tiny deep learning
Two advanced playing methods of QT signal and slot
2.18 codeforces supplement
Bessie's weight problem [01 backpack]
System Verilog — interface