DEV Community

Bhaskar Sharma
Bhaskar Sharma

Posted on

Installing PostgreSQL & Apache AGE for debugging (Part 2)

Introduction

This is part 2 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 Apache AGE from source for debugging.

Installing Apache AGE from Source

Clone the Apache AGE GitHub repo from here

Before proceeding with installing, make a slight change to make debugging easier later.

Open the makefile, and go the line that starts with 'PG_CPPFLAGS'. At the end of this line, append the -O0 flag. This will tell compiler to keep the optimization level at 0, which will make it easier to step through the code with the debugger.

Now install AGE while telling it your PG_CONFIG path

sudo make PG_CONFIG=/usr/local/pgsql/bin/pg_config install

PostgreSQL and AGE installation with debugging enabled has been completed.

Setting up a database with Apache AGE

(The rest of the section serves as a short tutorial for using AGE).
Once the installation has been completed, now we will move to running Apache AGE.

  • Firstly, start the server using pg_ctl utility.
  • Enter the psql command line.
  • Create a database and connect to it using: CREATE DATABASE db_name \c db_name
  • Run the following commands next CREATE EXTENSION age; LOAD ‘age’; SET search_path = ag_catalog, "$user", public; The CREATE EXTENSION only has to be run once, but remember that the LOAD and SET commands have to be re-entered every time you enter psql.
  • Let's create a graph called 'test' using create_graph command in the ag_catalog namespace: SELECT * FROM ag_catalog.create_graph('test');
  • Now we can use cypher commands to manipulate the graph, for example SELECT * FROM cypher('test', $$ CREATE (x:test {name:'test node'}) RETURN x $$) AS (x agtype); The above query will create a vertex with label 'test', and name 'test node' in the 'test' graph.

Top comments (0)