cmu-db / peloton

The Self-Driving Database Management System
http://pelotondb.io
Apache License 2.0
2.03k stars 624 forks source link

Add New SessionContext Object #1397

Open apavlo opened 6 years ago

apavlo commented 6 years ago

There are certain parameters that we need during execution that need to persist across transactions.

  1. current_database: The database that the client is currently connected to. This is currently called default_database in the code.

  2. temp_namespace: This is the namespace (schema in Postgres parlance) where all temp tables will get created. Anytime that we need to do a look-up in the catalog for a table or an index, we should check this namespace first. If it doesn't exist, then we will check the 'public' namespace.

In going through #1345, I found that they were passing around the temp_namespace all over the place. They were storing it multiple places in the traffic_cop, binder, optimizer, and execution plans. The correct place to store it is in the TransactionContext. But since a session can have multiple transactions, we actually want to persist it outside of the TransactionContext and reuse it as much as possible.

I propose that we create a new object called SessionObject. This will be created by the TrafficCop for a new connection/session. Then this parameter is passed into TransactionManager::BeginTransaction as a shared-pointer and stored in the TransactionContext.