diff --git a/fdw.go b/fdw.go index 5efa22ec..06d5d462 100644 --- a/fdw.go +++ b/fdw.go @@ -72,7 +72,7 @@ func init() { //export goLog func goLog(msg *C.char) { - log.Println("[WARN] " + C.GoString(msg)) + log.Println("[INFO] " + C.GoString(msg)) } // Given a list of FdwDeparsedSortGroup and a FdwPlanState, @@ -80,7 +80,6 @@ func goLog(msg *C.char) { // //export goFdwCanSort func goFdwCanSort(deparsed *C.List, planstate *C.FdwPlanState) *C.List { - log.Println("[WARN] goFdwCanSort deparsed", deparsed) // This will be the list of FdwDeparsedSortGroup items that can be pushed down var pushDownList *C.List = nil @@ -111,7 +110,8 @@ func goFdwCanSort(deparsed *C.List, planstate *C.FdwPlanState) *C.List { // add deparsedSortGroup to pushDownList pushDownList = C.lappend(pushDownList, unsafe.Pointer(deparsedSortGroup)) } else { - log.Printf("[INFO] goFdwCanSort column %s CANNOT be pushed down", columnName) + log.Printf("[INFO] goFdwCanSort column %s CANNOT be pushed down - not pushing down any further columns", columnName) + break } } @@ -121,6 +121,9 @@ func goFdwCanSort(deparsed *C.List, planstate *C.FdwPlanState) *C.List { func getSortableFields(foreigntableid C.Oid) map[string]proto.SortOrder { opts := GetFTableOptions(types.Oid(foreigntableid)) connection := GetSchemaNameFromForeignTableId(types.Oid(foreigntableid)) + if connection == constants.InternalSchema || connection == constants.LegacyCommandSchema { + return nil + } tableName := opts["table"] pluginHub := hub.GetHub() @@ -305,6 +308,8 @@ func goFdwBeginForeignScan(node *C.ForeignScanState, eflags C.int) { // if we are NOT explaining, create an iterator to scan for us if !explain { var sortOrder = getSortColumns(execState) + log.Printf("[INFO] goFdwBeginForeignScan, table '%s', sortOrder: %v", opts["table"], sortOrder) + ts := int64(C.GetSQLCurrentTimestamp(0)) iter, err := pluginHub.GetIterator(columns, quals, unhandledRestrictions, int64(execState.limit), sortOrder, ts, opts) if err != nil { diff --git a/fdw/query.c b/fdw/query.c index 8d1462b8..65d3bef5 100644 --- a/fdw/query.c +++ b/fdw/query.c @@ -680,29 +680,33 @@ deserializeDeparsedSortGroup(List *items) FdwDeparsedSortGroup *key = palloc0(sizeof(FdwDeparsedSortGroup)); - lc = list_head(lfirst(k)); - key->attname = (Name)strdup(strVal(lfirst(lc))); - lc = lnext(items, lc); - key->attnum = (int)intVal(lfirst(lc)); + List *list = lfirst(k); - lc = lnext(items, lc); - key->reversed = (bool)intVal(lfirst(lc)); + lc = list_head(lfirst(k)); + key->attname = (Name) strdup(strVal(lfirst(lc))); - lc = lnext(items, lc); - key->nulls_first = (bool)intVal(lfirst(lc)); + lc = lnext(list, lc); + key->attnum = (int) intVal(lfirst(lc)); - lc = lnext(items, lc); - if (lfirst(lc) != NULL) - key->collate = (Name)strdup(strVal(lfirst(lc))); - else - key->collate = NULL; + lc = lnext(list, lc); + key->reversed = (bool) intVal(lfirst(lc)); - lc = lnext(items, lc); - key->key = (PathKey *)lfirst(lc); + lc = lnext(list, lc); + key->nulls_first = (bool) intVal(lfirst(lc)); - result = lappend(result, key); - } + lc = lnext(list, lc); + if(lfirst(lc) != NULL) + key->collate = (Name) strdup(strVal(lfirst(lc))); + else + key->collate = NULL; + + lc = lnext(list, lc); + key->key = (PathKey *) lfirst(lc); + + result = lappend(result, key); + } + + return result; - return result; } diff --git a/hub/connection_factory.go b/hub/connection_factory.go index 7e5f3060..203993e7 100644 --- a/hub/connection_factory.go +++ b/hub/connection_factory.go @@ -92,7 +92,7 @@ func (f *connectionFactory) createConnectionPlugin(pluginFQN string, connectionN // load the config for this connection connection, ok := steampipeconfig.GlobalConfig.Connections[connectionName] if !ok { - log.Printf("[INFO] connectionFactory.createConnectionPlugin create connection %s - no config found so reloading config", connectionName) + log.Printf("[INFO] connectionFactory.createConnectionPlugin create connection %s - no config found so reloading config!", connectionName) // ask hub to reload config - it's possible we are being asked to import a newly added connection // TODO remove need for hub to load config at all