syncbase: syncQL: add support for functions and add time type

This change implements functions.  It's a big change, that doesn't
need to get any bigger, so functions are currently only supported
in where clause expressions.  A [small] follow-up change will
add support for functions in the select clause.

During the semantic check,
1. the function name is checked
2. the arg count is checked
3. any literal argument values are checked. (E.g., the tz argument
   to a date function is often a literal. If it's wrong, the
   entire query will fail rather than having the function fail
   for every row being considered.)
4. If the args consist of only literal values (or functions
   that can, themselves, be executed early), the function
   is executed and the return value is subsituted for the
   function in the AST.

During evaluation, functions are executed (unless they were
already executed during semantic checking.  If functions fail at
this stage (e.g, if a field type argument doesn't exist in
the value being considered), the expression always returns false
(and, as such, will never be the reason a row is selected.  This
is consistent with other expressions.

I've added some functions, but they are more to show that
functions will work, rather than being the final say on what
built-in functions we need and what args they take.

The following have been added:
Date constructs a time from a string specifying YMD and tz
DateTime construct a time from a string specifying YMD HMS tz
Y zeroes out all but the year part of its time arg
YM zeros out all but the year/month part of its time arg
YMD you get the pattern...
YMDH
YMDHM
YMDHMS
Now current time
LowerCase does what you think to its string arg
UpperCase ditto

Note: conversions.go is functions that were in eval.go.  They
needed to be moved to there own package to avoid a cyclic
dependency since the functions package needs to call them
and is, itself, called by the query package (that contains
eval.go).  The new function in is conversions.go is
ConvertValueToTime.  The rest have been copied.  Sorry that
I messed up the diff.

This change also implements support for time types.

Change-Id: I542a0e53f01ae8f4a249e8e1e75cf84b7351d6b9
16 files changed
tree: e68f3b18ba36526eb9fc893927180b81658800b3
  1. v23/
  2. x/
  3. .gitignore
  4. AUTHORS
  5. CONTRIBUTORS
  6. LICENSE
  7. PATENTS
  8. VERSION