/*
dbDeleteNodes will remove nodes from the provided list from the inventory.
  takes []NodeConsoleInfo - these nodes are no longer in the system at all
*/
dbDeleteNodes will remove nodes from the provided list from the inventory.
takes []NodeConsoleInfo - these nodes are no longer in the system at all
/ * dbDeleteNodes will remove nodes from the provided list from the inventory . takes [] NodeConsoleInfo - these nodes are no longer in the system at all * /
func dbDeleteNodes(ncis *[]NodeConsoleInfo) (rowsAffected int64, err error) {
	if ncis == nil || len(*ncis) == 0 {
		return 0, nil
	}
	var nodes string
	i := 0
	for _, nci := range *ncis {
		if i > 0 {
			nodes += fmt.Sprintf(",'%s' ", nci.NodeName)
		} else {
			nodes += fmt.Sprintf("'%s' ", nci.NodeName)
		}
		i++
	}
	sqlStmt := `
		delete from ownership
		where node_name in (%s)
	`
	sqlStmt = fmt.Sprintf(sqlStmt, nodes)
	mu.Lock()
	defer mu.Unlock()
	result, err := DB.Exec(sqlStmt)
	rowsAffected = 0
	if err != nil {
		errMsg := fmt.Sprintf("WARN: dbDeleteNodes: There is a DELETE error: %s", err)
		log.Printf(errMsg)
		err = errors.New(errMsg)
	}
	if result != nil {
		rowsAffected, _ = result.RowsAffected()
		debugLog.Println(fmt.Sprintf("result.RowsAffected %d", rowsAffected))
	}
	return rowsAffected, err
}
func dbDeleteNodes ( ncis * [ ] NodeConsoleInfo ) ( rowsAffected int64 , err error ) { if ncis == nil || len ( * ncis ) == 0 { return 0 , nil } var nodes string i := 0 for _ , nci := range * ncis { if i > 0 { nodes += fmt . Sprintf ( " " , nci . NodeName ) } else { nodes += fmt . Sprintf ( " " , nci . NodeName ) } i ++ } sqlStmt := `
		delete from ownership
		where node_name in (%s)
	` sqlStmt = fmt . Sprintf ( sqlStmt , nodes ) mu . Lock ( ) defer mu . Unlock ( ) result , err := DB . Exec ( sqlStmt ) rowsAffected = 0 if err != nil { errMsg := fmt . Sprintf ( " " , err ) log . Printf ( errMsg ) err = errors . New ( errMsg ) } if result != nil { rowsAffected , _ = result . RowsAffected ( ) debugLog . Println ( fmt . Sprintf ( " " , rowsAffected ) ) } return rowsAffected , err }
dbDeleteNodes will remove nodes from the provided list from the inventory.
dbDeleteNodes will remove nodes from the provided list from the inventory .
// exit fast // On an update operation RowsAffected will be the count acually updated.