@@ -184,6 +184,7 @@ notificationListener callback = do
184 receiveWait [
184 receiveWait [
185 match (\(NotificationMessage eNots) -> do
185 match (\(NotificationMessage eNots) -> do
186 --say $ "NOTIFICATION: " ++ show eNots
186 --say $ "NOTIFICATION: " ++ show eNots
187+ -- when notifications are thrown, they are not adjusted for the current schema which could be problematic, but we don't have access to the current session here
187 liftIO $ mapM_ (uncurry callback) (M.toList eNots)
188 liftIO $ mapM_ (uncurry callback) (M.toList eNots)
@@ -426,9 +427,13 @@ executeDatabaseContextExpr sessionId (InProcessConnection _ _ sessions _ _) expr
426 case eSession of
427 case eSession of
427 Left err -> pure $ Just err
428 Left err -> pure $ Just err
428 Right (session, schema) -> do
429 Right (session, schema) -> do
430+ let expr' = if schemaName session == defaultSchemaName then
429− case Schema.processDatabaseContextExprInSchema schema expr of
433+ Schema.processDatabaseContextExprInSchema schema expr
430 Left err -> pure (Just err)
435 Left err -> pure (Just err)
431− Right expr' -> case runState (RE.evalContextExpr expr') (Sess.concreteDatabaseContext session) of
436+ Right expr'' -> case runState (RE.evalContextExpr expr'') (Sess.concreteDatabaseContext session) of
432 (Just err,_) -> return $ Just err
437 (Just err,_) -> return $ Just err
433 (Nothing, context') -> do
438 (Nothing, context') -> do
434 let newDiscon = DisconnectedTransaction (Sess.parentId session) newSchemas
439 let newDiscon = DisconnectedTransaction (Sess.parentId session) newSchemas
@@ -511,7 +516,7 @@ executeGraphExpr sessionId (InProcessConnection strat clientNodes sessions graph
511 --update filesystem database, if necessary
516 --update filesystem database, if necessary
512 --this should really grab a lock at the beginning of the method to be threadsafe
517 --this should really grab a lock at the beginning of the method to be threadsafe
513 processPersistence strat newGraph
518 processPersistence strat newGraph
514− sendNotifications nodesToNotify notsToFire --TODO: schema mod
519+ sendNotifications nodesToNotify notsToFire
515 return Nothing
520 return Nothing
516executeGraphExpr sessionId conn@(RemoteProcessConnection _ _) graphExpr = remoteCall conn (ExecuteGraphExpr sessionId graphExpr)
521executeGraphExpr sessionId conn@(RemoteProcessConnection _ _) graphExpr = remoteCall conn (ExecuteGraphExpr sessionId graphExpr)
@@ -600,7 +605,7 @@ inclusionDependencies sessionId (InProcessConnection _ _ sessions _ _) = do
600 atomically $ do
605 atomically $ do
601 eSession <- sessionAndSchema sessionId sessions
606 eSession <- sessionAndSchema sessionId sessions
602 case eSession of
607 case eSession of
603− Left err -> pure $ Left err --TODO: schema application
608+ Left err -> pure $ Left err
604 Right (session, schema) -> do
609 Right (session, schema) -> do
605 let context = Sess.concreteDatabaseContext session
610 let context = Sess.concreteDatabaseContext session
606 if schemaName session == defaultSchemaName then
611 if schemaName session == defaultSchemaName then
@@ -616,8 +621,12 @@ planForDatabaseContextExpr sessionId (InProcessConnection _ _ sessions _ _) dbEx
616 atomically $ do
621 atomically $ do
617 eSession <- sessionAndSchema sessionId sessions
622 eSession <- sessionAndSchema sessionId sessions
618 case eSession of
623 case eSession of
619− Left err -> pure $ Left err --TODO: schema application
624+ Left err -> pure $ Left err
625+ Right (session, _) -> if schemaName session == defaultSchemaName then
620− Right (session, schema) -> pure $ evalState (applyStaticDatabaseOptimization dbExpr) (Sess.concreteDatabaseContext session)
626+ pure $ evalState (applyStaticDatabaseOptimization dbExpr) (Sess.concreteDatabaseContext session)
627+ else -- don't show any optimization because the current optimization infrastructure relies on access to the base context- this probably underscores the need for each schema to have its own DatabaseContext, even if it is generated on-the-fly
621planForDatabaseContextExpr sessionId conn@(RemoteProcessConnection _ _) dbExpr = remoteCall conn (RetrievePlanForDatabaseContextExpr sessionId dbExpr)
630planForDatabaseContextExpr sessionId conn@(RemoteProcessConnection _ _) dbExpr = remoteCall conn (RetrievePlanForDatabaseContextExpr sessionId dbExpr)
623-- | Return a relation which represents the current state of the global transaction graph. The attributes are
632-- | Return a relation which represents the current state of the global transaction graph. The attributes are