Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Show statements to Select #68

Merged
merged 11 commits into from
Mar 8, 2016
Prev Previous commit
Fix sourceexec implementation
  • Loading branch information
Aaron Raddon committed Mar 8, 2016
commit e94473de706c12f7e26d9a51cf08c38501b1222d
19 changes: 17 additions & 2 deletions exec/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,23 @@ func (m *JobExecutor) WalkCommand(p *plan.Command) (Task, error) {
}
func (m *JobExecutor) WalkSource(p *plan.Source) (Task, error) {
//u.Debugf("%p NewSource? %p", m, p)
if p.SourceExec {
return m.WalkSourceExec(p)
if p.Conn == nil {
u.Warnf("no conn? %T", p.DataSource)
if p.DataSource == nil {
u.Warnf("no datasource")
return nil, fmt.Errorf("missing data source")
}
source, err := p.DataSource.Open(p.Stmt.SourceName())
if err != nil {
return nil, err
}
p.Conn = source
//u.Debugf("setting p.Conn %p %T", p.Conn, p.Conn)
}

e, hasSourceExec := p.Conn.(ExecutorSource)
if hasSourceExec {
return e.WalkExecSource(p)
}
return NewSource(m.Ctx, p)
}
Expand Down
6 changes: 4 additions & 2 deletions exec/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewSource(ctx *plan.Context, p *plan.Source) (*Source, error) {
u.Warnf("source %T does not implement datasource.Scanner", p.Conn)
return nil, fmt.Errorf("%T Must Implement Scanner for %q", p.Conn, p.Stmt.String())
}

//u.Debugf("NewSource: hasScanner? %T", scanner)
s := &Source{
TaskBase: NewTaskBase(ctx),
Scanner: scanner,
Expand Down Expand Up @@ -110,7 +110,9 @@ func (m *Source) Run() error {
defer m.Ctx.Recover()
defer close(m.msgOutCh)

//u.Infof("Run() ")
if m.Scanner == nil {
return fmt.Errorf("No datasource found")
}

//u.Debugf("scanner: %T %#v", scanner, scanner)
iter := m.Scanner.CreateIterator(nil)
Expand Down