README.md

March 17, 2016 ยท View on GitHub

pg_hello_world - An example PostgreSQL extension written in C

DISCLAIMER: DO NOT USE THIS IN PRODUCTION! This is just a playground for myself and contains a huge bug, because the extension is not loadable with the shared_preload_libraries option in the PostgreSQL configuration.

This extension defines two functions:

  • HW_hello_world()
  • HW_hello_world_shared_memory()

Both return some kind of "Hello World" message. The difference is that the second one takes its return value from shared memory.

Compiling & Installing

make clean             # Delete all object files and other build artifacts

make all               # Compile the extension

make install           # Install the extension

make installcheck      # Check if the extension is installed by running the tests
                       # See:
                       #   ./sql/pg_hello_world_test.sql - The test file
                       #   ./expected/pg_hello_world_test.out - Expectations

make uninstall         # Uninstall the extension by deleting the files

Files

  • pg_hello_world.c - Defines the functions in C
  • pg_hello_world--0.0.1.sql - Uses CREATE FUNCTION to make the C functions accessible
  • pg_hello_world.control - Meta-Data File
  • sql/pg_hello_world_test.sql - Calls the functions as a test
  • expected/pg_hello_world_test.out - The expected output when running the test file

Resources