This is a port of the PostgreSQL Database Management System to the C++ language (C++11 standard).
Certain features of the C++ language and its library should help simplify coding, improve code reuse, and avoid bugs. Here's a nice article that provides more context: Moving to C++.
- g++ >= 4.8 (C++11 support)
The following packages are needed for building Postgres, including ssl support:
$ sudo yum install -y bison-devel readline-devel zlib-devel openssl-devel wget
$ sudo yum groupinstall -y 'Development Tools'
$ sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev
More information is available in the PostgreSQL manual and the PostgreSQL wiki.
$ mkdir build
$ cd build
$ ../configure --prefix=/path/to/build
$ make CC=g++ CPPFLAGS+="-std=c++11 -fpermissive -w"
$ make install
$ cd build
$ ./bin/initdb ./data
We use initdb
to create a new database cluster which is a collection of databases that are managed by a single server instance. Here, ./data
is the location of the data directory for this new database cluster.
$ ./bin/pg_ctl -D ./data start
pg_ctl
is a program that can be used to start, stop, and control a Peloton server. It is installed along with Peloton, by default in usr/local/peloton/bin
. Here, we use it to start the server.
$ ./bin/createuser -s -r postgres
Let's create a default user using createuser
utility.
$ ./bin/psql postgres
Finally, we can connect to the Peloton server using the psql
terminal utility. Here, we connect to the postgres
database. We can also connect to any other database in the cluster by altering this command. To get a list of psql
shortcuts, just type help
and then press enter.
$ ./bin/pg_ctl -D ./data stop
Now, we can use pg_ctl
to stop the server.
$ cd build
$ cp ../src/test/regress/expected/security_label.out ./src/test/regress/results/
$ make check
Here's a list of the key changes:
- Refactored identifiers that conflict with C++ reserved keywords. Appended the identifiers with "__" to resolve this problem. Here's a list of the keywords that we refactored:
new
,this
,namespace
,friend
,public
,private
typename
,typeid
,constexpr
,operator
,class
,template
-
Defined the assignment operator for structures with volatile instances.
RelFileNode
atinclude/storage/relfilnode.h
QueuePosition
atbackend/commands/async.cpp
BufferTag
atinclude/storage/buf_internals.h
-
Defined the constructor for unions that contain a non-POD member.
SharedInvalidationMessage
arinclude/storage/sinval.h
-
Refactored the missing increment operator. Changed
forkNum++
toforkNum = forkNum + 1
. -
Explicity declared that a enum value belongs to the particular enumeration type.
JsonbValue
-
Refactored forward declaration of static arrays using an anonymous namespace.
pg_crc32c_table
atport/pg_crc32c_sb8.cpp
-
Handled identifiers with both extern and const qualifiers.
sync_method_options
atbackend/access/transam/xlog.cpp
wal_level_options
atbackend/access/rmgrdesc/xlogdesc.cpp
dynamic_shared_memory_options
atbackend/access/transam/xlog.cpp
archive_mode_options
atbackend/access/transam/xlog.cpp
-
Declared functions with varying number of arguments by explicity defining function pointer types.
func_ptr0
atbackend/utils/fmgr/fmgr.c
func_ptr1
atbackend/utils/fmgr/fmgr.c
- ...
func_ptr16
atbackend/utils/fmgr/fmgr.c
expression_tree_walker
atinclude/nodes/nodeFunc.h
expression_tree_mutator
atinclude/nodes/nodeFunc.h
query_tree_walker
atinclude/nodes/nodeFunc.h
query_tree_mutator
atinclude/nodes/nodeFunc.h
range_table_walker
atinclude/nodes/nodeFunc.h
range_table_mutator
atinclude/nodes/nodeFunc.h
query_or_expression_tree_walker
atinclude/nodes/nodeFunc.h
query_or_expression_tree_mutator
atinclude/nodes/nodeFunc.h
raw_expression_tree_walker
atinclude/nodes/nodeFunc.h