pgsql-mysql integrated upto 87916f6 of upstream piwik.

Tests in Core group are passing but for the following:
In upstream 2 tests are failing.
In the pg-my branch 5 tests are failing with mysql and 7 with postgresql.
The extra failing tests are because of sql query text comparisons. These
queries have been changed to make them work with both pgsql and mysql.

Plugins group: All tests are passing on both mysql and postgresql.

Integration group: Tests in AutoSuggestAPITest are failing. These are in
addition to the ones that are already failing on the upstream version.

Added the dummyWhenNotNumeric and dummyWhenNotTime functions which are
replacements for nullWhenNotNumeric and nullWhenNotTime respectively. If
null is used, then the value is not added to the $this->valuesBind
array in the Piwik_SegmentExpression class which leads to queries like
" log_visit.visit_total_time <> AND log_visit.visit_total_searches <>
AND " which are failing. Dummy value will be a valid value with the least
possibility of conflict with valid values for the column. For numeric
negative number is returned; for time a timestap of 1970 is returned.

Added isEmpty function to the generic dao classes for use in the
Piwik_SegmentExpression::getSqlMatchFromDefinition function for the
MATCH_IS_NOT_NULL case. Values are being compared with empty string ''
and zero 0 irrespective of the data type of the column. Mysql issues a
warning and moves on; postgresql raises an error and stops. To avoid
that postgresql version casts the column to text and compares with ''
and '0'.

Added the "likeKeyword" function to the site dao classes. Mysql does a
case insensitive comparison, while postgresql does a case sensitive
comparison by default. To make the query work with both, mysql returns
the "LIKE" keyword while postgresql returns the "ILIKE" keyword.

Changed the data type of location_region column of log_visit and
log_conversion tables from "char(2)" to "varchar(2)". Mysql strips off
trailing white space for char data types while postgresql doesn't. Both
RDBMSes strip off white space for varchar columns.

Added a new function "getNeededFields" to the Piwik_Segment class to
get the neede fields for the buildWrappedSelectQuery function. The
regex used to extract needed fields is changing queries like
"log_visit.idvisitor::text as idvisitor_text " to "log_visit.idvisitor"
which is undesired behaviour. If the query has "::text" in the query
text, the columns are retrieved using "explode" and "strpos" functions.
If "::text" is not present then the regex is used. Regex is required
for queries like "sum(log_visit.visit_total_time) " etc.

Added the "Zend_Registry::set('db', '');" to the "getApiForTesting"
function of the Integration/AutoSuggestAPITest.php and Integration/
TwoVisitsWithCustomVariables_SegmentMatchNONETest.php. The
"getApiForTesting" function is calling Piwik_API_API::getSegmentsMetadata
function which is invoking the Piwik_PostEvent which is calling some code
that is looking for the 'db' key in the registry. So, adding a dummy
key 'db' to circumvent the problem. No queries are executed in the
function calls, so a dummy value is good enough.