func Build(stmt algebra.Statement, datastore, systemstore datastore.Datastore, namespace string, subquery bool) (plan.Operator, error) { builder := newBuilder(datastore, systemstore, namespace, subquery) o, err := stmt.Accept(builder) if err != nil { return nil, err } op := o.(plan.Operator) _, is_prepared := o.(*plan.Prepared) if !subquery && !is_prepared { privs, er := stmt.Privileges() if er != nil { return nil, er } if len(privs) > 0 { op = plan.NewAuthorize(privs, op) } return plan.NewSequence(op, plan.NewStream()), nil } else { return op, nil } }
func BuildPrepared(stmt algebra.Statement, datastore, systemstore datastore.Datastore, namespace string, subquery bool) (*plan.Prepared, error) { operator, err := Build(stmt, datastore, systemstore, namespace, subquery) if err != nil { return nil, err } signature := stmt.Signature() return plan.NewPrepared(operator, signature), nil }