This repository has been archived by the owner on Sep 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 624
Coding Guidelines
Andy Pavlo edited this page May 31, 2018
·
5 revisions
These are general rules for development in the system. As of 2018, we do not follow all of these exactly. These are more aspirations.
-
The
TransactionContext
object should always be the first argument to any function that takes it.Good Example
ResultType CreateDatabase(concurrency::TransactionContext *txn, const std::string &database_name);
Bad Example
ResultType CreateDatabase(const std::string &database_name, concurrency::TransactionContext *txn);
-
Never use default values for function arguments. This prevents unexpected behavior and invalid invocations.
Good Example
void MyFunc(int arg1, int arg2);
Bad Example
void MyFunc(int arg1, int arg2 = 1234);
-
The order of catalog arguments to a function should go in the order of the catalog hierarchy (Database→Schema→Table→Index). Furthermore, you should not mix names with oids in arguments.
Good Example
void DoSomethingInCatalog(oid_t database_oid, oid_t schema_oid, oid_t table_oid);
Bad Example
void DoSomethingInCatalog(oid_t database_oid, std::string table_name, oid_t schema_oid);