List:Internals« Previous MessageNext Message »
From:Davi Arnaut Date:October 18 2010 6:48pm
Subject:Re: How to lock individual tables in 1-db-per-file binlogging (Was:
View as plain text  
On 10/18/10 3:16 PM, Weldon Whipple wrote:
> Well, I finished a working prototype that does everything except the
> locking and unlocking of databases. Someone mentioned that it's now
> possible to lock individual tables. Would you--anyone--be willing to
> point me toward places in the 5.5 code that use that
> locking/unlocking?
>

Do you want to lock the database, or individual tables, or both? Anyway, 
take a look at mysql_rm_db as the locking is all very similar. Roughly, 
the algorithm of a DROP DATABASE is:

	// Protect against other schema operations
	lock_schema_name("db1");
	// Build list of tables in the db1 directory
	table_list = ..
	// Initialize metadata lock request
	table_list->mdl_request.init(MDL_key::TABLE,
		table_list->db,
		table_list->table_name, MDL_EXCLUSIVE);
	// Lock tables
	lock_table_names(thd, tables, NULL ...)
	// Remove from cache and drop the table...

The best thing at this point is to study (and debug) a similar statement 
and understand how metadata locks work (mdl prefix) or how tables are 
open/locked.

Regards,

Davi
Thread
How to lock individual tables in 1-db-per-file binlogging (Was: Re:Per-db binlogging)Weldon Whipple18 Oct
  • Re: How to lock individual tables in 1-db-per-file binlogging (Was:Re: Per-db binlogging)Davi Arnaut18 Oct
    • Re: How to lock individual tables in 1-db-per-file binlogging (Was:Re: Per-db binlogging)Weldon Whipple18 Oct
    • Re: How to lock individual tables in 1-db-per-file binlogging (Was:Re: Per-db binlogging)Weldon Whipple19 Oct
      • Re: How to lock individual tables in 1-db-per-file binlogging(Was: Re: Per-db binlogging)Dmitry Lenev22 Oct
        • Re: How to lock individual tables in 1-db-per-file binlogging (Was:Re: Per-db binlogging)Weldon Whipple28 Oct
          • Re: How to lock individual tables in 1-db-per-file binlogging (Was: Re: Per-db binlogging)Mark Leith28 Oct
            • Re: How to lock individual tables in 1-db-per-file binlogging (Was:Re: Per-db binlogging)Weldon Whipple29 Oct