More fixes to make SQL thread safe

Fix for bug 1403334 – T2 multithread tests core dump in SQLCLI_DropContext

NAMemory was not threadsafe in derived memory management.  The calls
registerMemory, unRegisterMemory was not threadSafe when the heap is marked
 as threadsafe heap.  Also, the mutex is now dropped as part of NAHeap
destructor.

Fix for bug 1403410 - With 128 threads thru T2 driver,  MTTrans and YCSB tests
crash and generate this core

The context list was being manipulated without acquiring a mutex in some places
These obsolete codes are now removed.

Some of the globals were wrongly declared as thread globals.

Other Fixes
SQL_EXEC_GetDiagnosticsCondInfo2 CLI call is now protected by mutexes
like any other CLI call.
Also removed some of the obsolete codes in the cli layer.

Currently commented out the code to close all the open cursors in all
the contexts when a change in transaction id is detected. We need to detect
the change in transaction at context level and close cursors belonging to
that context only.

Change-Id: I0edb7b7f0a844c8c49995af4c130dd319472a783
Merge "More fixes to make SQL thread safe"