mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
added check for invalid database and sanity check for executor
This commit is contained in:
parent
aa00270de8
commit
e4dcf867c3
3 changed files with 20 additions and 1 deletions
|
|
@ -283,6 +283,10 @@ func (self *WebService) HandleQuery(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, "Provide a database (db)", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if !self.service.Cluster.IsValidDatabase(database_name) {
|
||||
http.Error(w, "Unknown Database:"+database_name, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
pql := r.Form.Get("pql")
|
||||
if pql == "" {
|
||||
http.Error(w, "Provide a valid query string (pql)", http.StatusNotFound)
|
||||
|
|
|
|||
|
|
@ -117,6 +117,16 @@ func (self *Cluster) GetDatabases() map[string]*Database {
|
|||
|
||||
}
|
||||
|
||||
func (self *Cluster) IsValidDatabase(dbname string) bool {
|
||||
for name, _ := range self.GetDatabases() {
|
||||
if name == dbname {
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/////////// DATABASES ////////////////////////////////////////////////////////////////////
|
||||
|
||||
// A database is a collection of all the frames within a given profile space
|
||||
|
|
|
|||
|
|
@ -97,7 +97,12 @@ func (self *Executor) runQuery(database *db.Database, qry *query.Query) error {
|
|||
msg.Data = qs
|
||||
switch step := qs.(type) {
|
||||
case query.PortableQueryStep:
|
||||
self.service.Transport.Send(msg, step.GetLocation().ProcessId)
|
||||
loc := step.GetLocation()
|
||||
if loc != nil {
|
||||
self.service.Transport.Send(msg, loc.ProcessId)
|
||||
} else {
|
||||
log.Println("Problem with querystep(nil location)", spew.Sdump(step))
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue