syncbase: syncQL: support varargs in functions, functions cleanup

StrCat() now takes a variable number of args (but requires at
least two).

In addition, nearly all of the custom arg checking functions
have been deleted.  Writing custom arg checks is usually not
required.  That is, if the only check is to see if the args
match the types specified in the function definitions, nil
can be used for the check function as arg type checking is
now part of the standard check.

Note: There were some wrong types specified for some of
the date functions. Now that the arg types specified are being
used to check the types, they were uncovered and fixed.

Change-Id: I062ea666302a5cd049478f5f3b864bf4c132ff4c
diff --git a/services/syncbase/server/mojo_impl.go b/services/syncbase/server/mojo_impl.go
index 973bf7d..52e2d90 100644
--- a/services/syncbase/server/mojo_impl.go
+++ b/services/syncbase/server/mojo_impl.go
@@ -16,8 +16,6 @@
 	"fmt"
 	"strings"
 
-	"mojo/public/go/bindings"
-
 	mojom "mojom/syncbase"
 	wire "v.io/syncbase/v23/services/syncbase"
 	nosqlwire "v.io/syncbase/v23/services/syncbase/nosql"
@@ -298,7 +296,7 @@
 	return toMojoError(err), exists, nil
 }
 
-func (m *mojoImpl) DbExec(name string, query string, stream mojom.ExecStream_Pointer) (mojom.Error, error) {
+func (m *mojoImpl) DbExec(name string, query string, stream mojom.ExecStream_Request) (mojom.Error, error) {
 	return mojom.Error{}, nil
 }
 
@@ -425,57 +423,7 @@
 	return mojom.Error{}, nil
 }
 
-type scanStreamImpl struct {
-	ctx   *context.T
-	proxy *mojom.ScanStream_Proxy
-}
-
-func (s *scanStreamImpl) Send(item interface{}) error {
-	kv, ok := item.(nosqlwire.KeyValue)
-	if !ok {
-		return verror.NewErrInternal(s.ctx)
-	}
-
-	return s.proxy.OnKeyValue(mojom.KeyValue{
-		Key:   kv.Key,
-		Value: kv.Value,
-	})
-}
-
-func (s *scanStreamImpl) Recv(_ interface{}) error {
-	// This should never be called.
-	return verror.NewErrInternal(s.ctx)
-}
-
-var _ rpc.Stream = (*scanStreamImpl)(nil)
-
-// TODO(nlacasse): Provide some way for the client to cancel the stream.
-func (m *mojoImpl) TableScan(name string, start, limit []byte, ptr mojom.ScanStream_Pointer) (mojom.Error, error) {
-	ctx, call := m.newCtxCall(name, methodDesc(nosqlwire.TableDesc, "Scan"))
-	stub, err := m.getTable(ctx, call, name)
-	if err != nil {
-		return toMojoError(err), nil
-	}
-
-	proxy := mojom.NewScanStreamProxy(ptr, bindings.GetAsyncWaiter())
-
-	tableScanServerCallStub := &nosqlwire.TableScanServerCallStub{struct {
-		rpc.Stream
-		rpc.ServerCall
-	}{
-		&scanStreamImpl{
-			ctx:   ctx,
-			proxy: proxy,
-		},
-		call,
-	}}
-
-	err = stub.Scan(ctx, tableScanServerCallStub, NoSchema, start, limit)
-
-	// NOTE(nlacasse): Since we are already streaming, we send any error back
-	// to the client on the stream.  The TableScan function itself should not
-	// return an error at this point.
-	proxy.OnDone(toMojoError(err))
+func (m *mojoImpl) TableScan(name string, start, limit []byte, stream mojom.ScanStream_Request) (mojom.Error, error) {
 	return mojom.Error{}, nil
 }
 
diff --git a/services/syncbase/store/model.go b/services/syncbase/store/model.go
index 504ae01..be7265d 100644
--- a/services/syncbase/store/model.go
+++ b/services/syncbase/store/model.go
@@ -6,6 +6,9 @@
 // Currently, this API and its implementations are meant to be internal.
 package store
 
+// TODO(sadovsky): Decide whether to defensively copy passed-in []byte's vs.
+// requiring clients not to modify passed-in []byte's.
+
 // StoreReader reads data from a CRUD-capable storage engine.
 type StoreReader interface {
 	// Get returns the value for the given key. The returned slice may be a
@@ -14,8 +17,6 @@
 	// nil valbuf.
 	// If the given key is unknown, valbuf is returned unchanged and the function
 	// fails with ErrUnknownKey.
-	//
-	// It is safe to modify the contents of the key after Get returns.
 	Get(key, valbuf []byte) ([]byte, error)
 
 	// Scan returns all rows with keys in range [start, limit). If limit is "",
@@ -23,26 +24,16 @@
 	// Concurrency semantics: It is legal to perform writes concurrently with
 	// Scan. The returned stream may or may not reflect subsequent writes to keys
 	// not yet reached by the stream.
-	//
-	// It is safe to modify the contents of the arguments after Scan returns.
 	Scan(start, limit []byte) Stream
 }
 
 // StoreWriter writes data to a CRUD-capable storage engine.
 type StoreWriter interface {
 	// Put writes the given value for the given key.
-	//
-	// WARNING: For performance reasons, a Put inside a transaction doesn't make
-	// a defensive copy of the value. The client MUST keep the value unchanged
-	// until the transaction commits or aborts.
-	//
-	// It is safe to modify the contents of the key after Put returns.
 	Put(key, value []byte) error
 
 	// Delete deletes the entry for the given key.
 	// Succeeds (no-op) if the given key is unknown.
-	//
-	// It is safe to modify the contents of the key after Delete returns.
 	Delete(key []byte) error
 }
 
diff --git a/services/syncbase/syncbased/mojo_main.go b/services/syncbase/syncbased/mojo_main.go
index 74a247f..b478d4e 100644
--- a/services/syncbase/syncbased/mojo_main.go
+++ b/services/syncbase/syncbased/mojo_main.go
@@ -8,7 +8,7 @@
 
 // To build:
 // cd $V23_ROOT/experimental/projects/ether
-// make build
+// make gen/mojo/syncbased.mojo
 
 import (
 	"log"