IMPALA-1453: Fix many bugs with HS2 FETCH_FIRST

This patch fixes a number of bugs with HS2 columnar result sets,
particularly around the computation of their size in memory. It also
fixes test_fetch_first.py to be robust to the possibility of a single
fetch not returning all expected rows (IMPALA-1264).

In order to properly account for the columnar result set's size in
memory, we need to cope with the fact that the size of two result sets
combined might be larger than a result set which the result of appending
one to the other. However, we estimate the expected size of the result
cache as its current size plus the size of the result set to be
added (we do this so that we don't perform the copy, then find out it
used too much memory). This patch adds logic to
QueryExecState::FetchRowsInternal() to correct the true memory usage
after the copy, in the case where memory was saved.

(This happens for example when we stitch together two null columns and
wind up saving a byte).

Change-Id: Ie172840ea0ff40e43370825ca8f671a86dde4f22
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/5199
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins
Disable test_query_stmts

Change-Id: I584ebc4cd2a4c578b314272cb8e462f210af19db
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/5316
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: Henry Robinson <henry@cloudera.com>
IMPALA-1378: Only debug FunctionContexts track each user allocation

Maintaining the map of user allocations in FunctionContext is very
expensive (I measured a group by query going from ~11s to ~6s by
removing the map), and is only used for diagnostic information. This
patch changes the FunctionContext to only maintain the map when run
via the UDF test harness. It also adds basic allocation tracking to
FreePool to detect memory leaks and double frees during regular
execution.

Change-Id: Ia3e6e0229f9bcb227c6b5c3a21d2774bbe092fe6
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/5314
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: jenkins
IMPALA-1493: catch boost exception in TimestampFunctions::DateAddSub

I looked at the timestamp functions, cast functions, and
TimestampValue, and this is the only place I found where we were
missing a try/catch for creating a new boost::gregorian::date object.

Change-Id: I97a0e7197167b24074226009b661247991fda12c
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/5354
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins