Skip to content

WebClub-NITK/chillpg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChillGuy PostgreSQL C Extension

Overview

This project is a fun PostgreSQL C extension that generates an ASCII art design when called. It demonstrates how to create a simple PostgreSQL extension using C, showcasing the extensibility of PostgreSQL.

Development Environment

Prerequisites

  • Docker
  • PostgreSQL development tools

Docker Development Setup

Docker Image

  • Base Image: postgres:17
  • Development Isolation: Containerized PostgreSQL environment

Starting the PostgreSQL Container

# Create and start the PostgreSQL container
docker run -d \
    --name chillguy-postgres \
    -p 5432:5432 \
    -e POSTGRES_PASSWORD=mysecretpassword \
    postgres:17

Connecting to the Database

# Connect using psql
psql -U postgres -h localhost -p 5432

Project Structure

chillguy/
├── Dockerfile
├── Makefile
├── chillguy.control
├── chillguy.c
└── chillguy--0.0.1.sql

Building the Extension

Inside the PostgreSQL Container

# Enter the PostgreSQL container
docker exec -it chillguy-postgres bash

# Install development libraries
apt-get update && apt-get install -y postgresql-server-dev-17 build-essential

These tools are necessary for building C extensions in PostgreSQL.

# Copy extension files to the container
docker cp ./chillguy postgres:/path/to/extension

# Build and install the extension
cd /path/to/extension
make
make install

Usage in PostgreSQL

  1. Create the extension:
CREATE EXTENSION chillguy;
  1. Call the function to display ASCII art:
SELECT chillguy();

Learning Objectives

  • PostgreSQL extension development with Docker
  • Creating C functions in PostgreSQL
  • Containerized database development

Potential Improvements

  • Add more ASCII art designs
  • Implement design variations
  • Create randomization logic

Troubleshooting

  • Ensure Docker is running
  • Check port 5432 is not in use
  • Verify PostgreSQL container is up

Contributing

Contributions, creative ASCII art, and feature requests are welcome!

Development Notes

  • PostgreSQL Version: 17
  • Development Environment: Docker
  • Connection: psql -U postgres -h localhost -p 5432

References

About

ChillGuy PostgreSQL C Extension

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published