MySQL database Alter database processing logic

Source: Internet
Author: User

The Alter database processing process is not as scary as alter table, and the processing logic is clear. Sort the information as follows:

1. Check whether the database name is valid

Call check_db_name () (table. cc: 2876) to check whether the database name is valid. Call the check_table_name () (table. cc: 2904) function. The check_table_name function name is misleading. It is actually used to check whether the database name is legal.

2. Check whether the modification is permitted.

Call check_access () (SQL _parse.cc: 4715) to check whether the database exists and whether the user has the permission to modify the database.

3. Database Modification

Call mysql_alter_db () (SQL _db.cc: 685) to modify the database. Call the lock_schema_name () (lock. cc: 767) function to obtain the mutex lock of the schema. Call the write_db_opt () (SQL _db.cc: 313) function to recreate the db. opt file. The content recorded in the db. opt file is the content of the default character set. Then write the binlog.

The above analysis shows that the business logic of the Alter database operation is relatively simple, but the function is also relatively simple. The alter database option can only modify the default charset and default collation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.