Fix locking error for searches + composite columns

Fix a locking error when composite columns containing formats are used
and formats are added/deleted. The error would only be triggered if a search
was previously done that looked at the formats column. Also speed up
searching a little by avoiding a full get_metadata when searching
composite columns. Fixes #1233330 [Custom column Formats error](https://bugs.launchpad.net/calibre/+bug/1233330)