DEV Community

Bhaskar Sharma
Bhaskar Sharma

Posted on

1

Installing PostgreSQL & Apache AGE for debugging (Part 1)

INTRODUCTION

This is part 1 of a guide for setting up PostgreSQL and Apache AGE on a Linux (Ubuntu) machine for debugging. After following this blogpost, you'll be able to:

  • Install PostgreSQL from source with debugging flags enabled.

  • Check part 2 to know how to install Apache AGE from source for debugging.

Installing PostgreSQL from source (with debugging flags enabled)

The first step is to download a compatible version of PostgreSQL with the Apache AGE version you will be working with.
At the time of writing this guide, PostgreSQL version 15 can be downloaded as it is compatible with the latest version of Apache AGE.

  • Download the PostgreSQL version 15 source from here https://www.postgresql.org/ftp/source/ download the .tar.gz file.

  • Unpack it using gunzip like
    gzip -d postgresql-15.4.tar.gz

  • Unpack the tarball
    tar -xf postgresql-15.4.tar

  • cd into the folder
    cd ./postgresql-15.4/

  • Before installing PostgreSQL, we need to install some prerequisites (Bison & Flex) which are used both by PostgreSQL and Apache AGE for parsing queries
    sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison

  • We are ready to install. So, first we configure it with the debugging flags
    ./configure --enable-debug --enable-cassert

  • Then we install it using the make commands
    make all
    sudo make install

  • Now, we have PostgreSQL installed on our system, but we need to tell our system where the binaries are. For that, we'll add the location to our PATH variable.
    PATH=/usr/local/pgsql/bin:$PATH
    export PATH

    To make it permanent, you need to add the export commmand to the end of your your ~/.bash_profile file.

  • Next, let us initialize a database cluster using
    initdb -D $HOME/pgdata

You can replace $HOME/pgdata with a directory of your choice, the -D flag is used to specify a directory.

  • To start the server, we will use pg_ctl command pg_ctl start -D $HOME/pgdata The server should start successfully. To enter PostgreSQL command line you can use psql.

Use \q to quit it, and proceed to next blog post.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️