diff --git a/ctl/server.go b/ctl/server.go index c451b5c78..b43c8d907 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -67,7 +67,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags.StringVar(&srv.Config.Etcd.InitCluster, "etcd.initial-cluster", srv.Config.Etcd.InitCluster, "Initial cluster name1=apurl1,name2=apurl2") // External DB - flags.StringVar(&srv.Config.ExternalDB, "externaldb", "", "external (postgres) database DSN to use for ExternalQuery calls") + flags.StringVar(&srv.Config.ExternalDBDSN, "external-db-dsn", "", "external (postgres) database DSN to use for ExternalLookup calls") // AntiEntropy flags.DurationVar((*time.Duration)(&srv.Config.AntiEntropy.Interval), "anti-entropy.interval", (time.Duration)(srv.Config.AntiEntropy.Interval), "Interval at which to run anti-entropy routine.") diff --git a/executor.go b/executor.go index 4ae6044fc..c6252c7ba 100644 --- a/executor.go +++ b/executor.go @@ -4042,10 +4042,11 @@ func (e *executor) executeExternalLookup(ctx context.Context, qcx *Qcx, index st if err != nil { return ExtractedTable{}, errors.Wrap(err, "translating query result") } - argRow := qr[0].(*Row) + argRow, ok := qr[0].(*Row) + if !ok { + return ExtractedTable{}, errors.Errorf("argument call result is a %T but expected a row", qr[0]) + } if !argRow.Any() { - // If we attempt to substitute in an empty slice, the substitution will fail. - // Do not attempt to execute the query. return ExtractedTable{}, nil } diff --git a/holder.go b/holder.go index fa9efe254..3f960433f 100644 --- a/holder.go +++ b/holder.go @@ -243,7 +243,7 @@ type HolderConfig struct { RBFConfig *rbfcfg.Config AntiEntropyInterval time.Duration - ExternalDB string + ExternalDBDSN string } func DefaultHolderConfig() *HolderConfig { @@ -733,10 +733,10 @@ func (h *Holder) Open() error { h.txf.blueGreenOnIfRunningBlueGreen() - if h.cfg.ExternalDB != "" { + if h.cfg.ExternalDBDSN != "" { h.Logger.Printf("connecting to external DB") - db, err := sql.Open("postgres", h.cfg.ExternalDB) + db, err := sql.Open("postgres", h.cfg.ExternalDBDSN) if err != nil { return errors.Wrap(err, "connecting to external database") } diff --git a/server.go b/server.go index 6bbfa2ba4..38a77dd39 100644 --- a/server.go +++ b/server.go @@ -403,7 +403,7 @@ func OptServerDisCo(disCo disco.DisCo, // OptServerExternalDB configures a connection to an external postgres database. func OptServerExternalDB(dsn string) ServerOption { return func(s *Server) error { - s.holderConfig.ExternalDB = dsn + s.holderConfig.ExternalDBDSN = dsn return nil } } diff --git a/server/config.go b/server/config.go index 9081e197c..484a4b0f1 100644 --- a/server/config.go +++ b/server/config.go @@ -223,8 +223,8 @@ type Config struct { // result combines the history from all nodes. QueryHistoryLength int `toml:"query-history-length"` - // ExternalDB is an external database to connect to for `ExternalLookup` queries. - ExternalDB string `toml:"external-db"` + // ExternalDBDSN is an external database to connect to for `ExternalLookup` queries. + ExternalDBDSN string `toml:"external-db-dsn"` } // MustValidate checks that all ports in a Config are unique and not zero. diff --git a/server/server.go b/server/server.go index 4422858b0..556e7b6b6 100644 --- a/server/server.go +++ b/server/server.go @@ -429,8 +429,8 @@ func (m *Command) SetupServer() error { discoOpt, } - if m.Config.ExternalDB != "" { - serverOptions = append(serverOptions, pilosa.OptServerExternalDB(m.Config.ExternalDB)) + if m.Config.ExternalDBDSN != "" { + serverOptions = append(serverOptions, pilosa.OptServerExternalDB(m.Config.ExternalDBDSN)) } serverOptions = append(serverOptions, m.serverOptions...)