WL#5419: 5.5.4/LOCK_open scalability: shorten the critical section in open_table().

Affects: Server-5.5   —   Status: Complete   —   Priority: Medium

This is a subset of WL#3983 implemented in 5.5.4.
The worklog is created for documentation purposes.

Split the large LOCK_open section in open_table().
Do not call open_table_from_share() under LOCK_open.
Remove thd->version.

This task has effect on storage engines that rely on
ha_open() PSEA method being called under LOCK_open.
In particular:

1) NDB is broken and left unfixed. NDB relies on LOCK_open
  being kept as part of ha_open(), since it uses auto-discovery.
  While previously the NDB open code was race-prone, now
  it simply fails on asserts.

2) HEAP engine has a race in ha_heap::open() when
   a share for the same table could be added twice
   to the list of shares, or a dangling reference to a share
   stored in HEAP handler. This task aims to address this
   problem by 'pinning' the newly created share in the
   internal HEAP engine share list until at least one
   handler instance is created using that share.