WalkSourceSelect is a single source select
(p *Source)
| 169 | |
| 170 | // WalkSourceSelect is a single source select |
| 171 | func (m *PlannerDefault) WalkSourceSelect(p *Source) error { |
| 172 | |
| 173 | if p.Stmt.Source != nil { |
| 174 | //u.Debugf("%p VisitSubselect from.source = %q", p, p.Stmt.Source) |
| 175 | } else { |
| 176 | //u.Debugf("%p VisitSubselect from=%q", p, p) |
| 177 | } |
| 178 | |
| 179 | // All of this is plan info, ie needs JoinKey |
| 180 | needsJoinKey := false |
| 181 | if p.Stmt.Source != nil && len(p.Stmt.JoinNodes()) > 0 { |
| 182 | needsJoinKey = true |
| 183 | } |
| 184 | |
| 185 | // We need to build a ColIndex of source column/select/projection column |
| 186 | //u.Debugf("datasource? %#v", p.Conn) |
| 187 | if p.Conn == nil { |
| 188 | err := p.LoadConn() |
| 189 | if err != nil { |
| 190 | u.Errorf("no conn? %v", err) |
| 191 | return err |
| 192 | } |
| 193 | if p.Conn == nil { |
| 194 | if p.Stmt != nil { |
| 195 | if p.Stmt.IsLiteral() { |
| 196 | // this is fine |
| 197 | } else { |
| 198 | u.Warnf("No DataSource found, and not literal query? Source Required for %s", p.Stmt.String()) |
| 199 | return ErrNoDataSource |
| 200 | } |
| 201 | } else { |
| 202 | u.Warnf("hm no conn, no stmt?....") |
| 203 | return ErrNoDataSource |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | if sourcePlanner, hasSourcePlanner := p.Conn.(SourcePlanner); hasSourcePlanner { |
| 209 | // Can do our own planning |
| 210 | t, err := sourcePlanner.WalkSourceSelect(m.Planner, p) |
| 211 | if err != nil { |
| 212 | return err |
| 213 | } |
| 214 | if t != nil { |
| 215 | p.Add(t) |
| 216 | } |
| 217 | |
| 218 | } else { |
| 219 | |
| 220 | if schemaCols, ok := p.Conn.(schema.ConnColumns); ok { |
| 221 | if err := buildColIndex(schemaCols, p); err != nil { |
| 222 | return err |
| 223 | } |
| 224 | } else { |
| 225 | return fmt.Errorf("%q Didn't implement schema.ConnColumns: %T", p.Stmt.SourceName(), p.Conn) |
| 226 | } |
| 227 | |
| 228 | if p.Stmt.Source != nil && p.Stmt.Source.Where != nil { |
nothing calls this directly
no test coverage detected