Skip to content

Instantly share code, notes, and snippets.

Last active March 18, 2024 09:19
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IshaanAdarsh/ae96669cb30806a23899cbf124f28554 to your computer and use it in GitHub Desktop.
Save IshaanAdarsh/ae96669cb30806a23899cbf124f28554 to your computer and use it in GitHub Desktop.
Google Summer of Code 2023 (PostgreSQL)

Google Summer of Code 2023 Final Work Product



Name: Ishaan Adarsh (@IshaanAdarsh)

Organisation: Postgres

Project link:

Repository link:

Project Name: Postgres extension tutorial / quick start

Project Summary: This project aims to create a comprehensive and easy-to-follow tutorial on how to write a Postgres extension, addressing the current lack of clear documentation on the topic. The tutorial will assume only knowledge of Postgres and the target language, and will cover topics such as

  • Writing a Makefile
  • Using PGXS and PGXN
  • Explaining Procedural and External languages
  • Writing regression tests
  • Extension release management. In addition,

I have included a dedicated section that intricately guides the process of extending PostgreSQL through the incorporation of Functions, Data Types, and Operators. The tutorial will be a quick start guide with clear examples, making it easy for new contributors to understand and follow along. The deliverables of this project will be the tutorial itself, along with any necessary code examples and documentation updates. This project will be valuable for the Postgres community by making it easier for new contributors to get involved and contribute to the extension ecosystem.

About the Organisation

PostgreSQL, commonly known as Postgres, is a powerful, open-source relational database management system. It has a thriving and diverse community of developers, contributors, and users who collaborate to improve its features, performance, and ecosystem. As an essential part of the open-source software landscape, PostgreSQL supports extensibility, allowing developers to create custom extensions that enhance its functionality. The PostgreSQL community actively encourages developers to contribute extensions, which has led to the creation of a rich ecosystem of extensions catering to various use cases.

The PostgreSQL Extension Ecosystem:

The extension ecosystem of PostgreSQL contributes significantly to its adaptability and versatility. Developers can build extensions to add specialized functionality, ranging from advanced data types to complex procedural languages. These extensions integrate seamlessly with PostgreSQL, enhancing its capabilities without modifying its core codebase. Such extensibility allows developers to tailor their PostgreSQL databases to suit specific application requirements.

This project, "Comprehensive Postgres Extension Tutorial," aims to bridge the gap in documentation and provide a comprehensive guide for creating PostgreSQL extensions. By doing so, it enables developers to contribute to the extension ecosystem more effectively, fostering innovation and collaboration within the PostgreSQL community.



Prior to GSoC

Started my journey with PostgreSQL in mid-March by delving into the project's intricacies. To demonstrate my progress to my mentor, I established a personal repository (Postgres-extension-tutorial) where I showcased my initial contributions. My exploration involved a comprehensive study of the extension ecosystem, enabling me to grasp its nuances.

In pursuit of understanding the project more deeply, I initiated the groundwork for the tasks ahead. By the first week of April, I had successfully outlined the pointers to be tackled, culminating in the completion of the first draft of my project plan. Additionally, the insights I gained while studying PostgreSQL's extension ecosystem provided me with valuable context and background information. This, in turn, facilitated the formulation of a Project Proposal that was informed, coherent, and aligned with the project's objectives.

Contributions during GSoC

These contributions collectively provided valuable insights into PostgreSQL extension development, showcasing a variety of techniques and illustrating the versatility of PostgreSQL's extensibility capabilities.

I authored the documentation in my personal GitHub repository -> Postgres-extension-tutorial

Final documentation

Pull Requests:

#Pull Request Title Status
Postgres-extension-tutorial#14 docs: Added comprehensive extension development guide badge
Postgres-extension-tutorial#25 docs: Added process of extending PostgreSQL badge
Postgres-extension-tutorial#32 docs: Added comprehensive tutorial explaing Procedural Languges badge
Postgres-extension-tutorial#33 docs: Added comprehensive tutorial explaing External Languges badge
Postgres-extension-tutorial#31 docs: Added information about PGXN and pgxnclient badge


Issue Link Title Status
Postgres-extension-tutorial#13 Makefile issue in Creating Postgres Extension badge
Postgres-extension-tutorial#15 Regression testing Issue [Make installcheck] badge
Postgres-extension-tutorial#17 No function matches the given name and argument types badge
Postgres-extension-tutorial#19 Unknown META specification, cannot validate. [Spec v1.0.1] badge
Postgres-extension-tutorial#20 aggregate function calls cannot contain set-returning function calls badge
Postgres-extension-tutorial#22 ALTER EXTENSION ERROR no update path badge
Postgres-extension-tutorial#23 network error: [SSL: CERTIFICATE_VERIFY_FAILED] badge
Postgres-extension-tutorial#24 gem ... (OptionParser::InvalidOption) invalid option: --no-rdoc badge
Postgres-extension-tutorial#26 Error while implementing Custom Operator in PostgreSQL badge
Postgres-extension-tutorial#28 Error while using CREATE EXTENSION command badge
Postgres-extension-tutorial#29 Issue in Installing PL/Python on Postgres badge

A Brief Overview of Created Extensions:

Extension Description Tutorial Topics Covered Version Feature
my_extension (Simple SQL Extension) Created my_extension for comprehensive tutorial on extension development. Prerequisites, Makefile, PGXS/PGXN, Procedural/External languages, Regression tests, Release management v1.0.0 Custom table creation.
v1.0.1 complex_add function.
v1.1.0 multiply function.
pg_sample_ext pg_sample_ext showcases gradual introduction of features. Custom Function, Custom Data Types (Composite, Enumerated, Domain), Custom Operator v1.0.0 square function.
v1.0.1 Custom Data Types (Composite, Enumerated, Domain).
v1.0.2 Operator @*.
pg_cext Demonstrates extension development with external language C. Custom add_nums function using C. v1.0.0 add_nums in C.
pg_plpgsql_ext Example of extension using PL/pgSQL. Custom subtract_numbers function using PL/pgSQL. v1.0.0 subtract_numbers in PL/pgSQL.
pg_py_ext Showcases extension development with PL/Python3u. Custom add_nums function using PL/Python3u. v1.0.0 add_nums in PL/Python3u.

Weekly Blogs(Proof-of-Work)


Throughout the Google Summer of Code 2023, my contributions have led to the creation of a comprehensive and user-friendly tutorial that guides developers through the process of writing PostgreSQL extensions. This tutorial aims to address the existing lack of clear documentation on this topic and provide newcomers with a quick start guide to extension development. The tutorial covers various essential aspects of extension development, making it easier for new contributors to get involved and contribute to the extension ecosystem.

The primary outcomes of my project include:

  1. Tutorial on PostgreSQL Extension Development: I have created a detailed tutorial that covers various aspects of extension development, including prerequisites, extension architecture, writing Makefiles, utilizing PGXS and PGXN tools, procedural and external languages, writing regression tests, and extension release management.

  2. Creation of Example Extensions: I have developed a set of example extensions, each showcasing different aspects of extension development using various techniques. I have uploaded the example extensions to the PGXN (PostgreSQL Extension Network) to ensure they are readily accessible to the PostgreSQL community. These extensions include:

    • my_extension: A simple SQL extension used as the centerpiece of the tutorial, demonstrating multiple features across different versions.
    • pg_sample_ext: A comprehensive example extension illustrating the gradual incorporation of functions, data types, and operators.
    • pg_cext: An extension developed in C to showcase extension development using external languages.
    • pg_plpgsql_ext: An extension developed using PL/pgSQL to demonstrate building extensions using procedural languages.
    • pg_py_ext: An extension developed using PL/Python3u to showcase extension development using procedural languages.

Future Work

While the primary goals of my Google Summer of Code project have been successfully achieved, there remains a wide range of opportunities to further enhance and expand the project. Future contributors can build upon the foundation I've laid to bring even more value to the PostgreSQL community. Here are some potential avenues for future work:

  1. Extension Examples: Continue to add more extension examples that demonstrate unique features and scenarios (indexam and tableam). This can provide a broader understanding of the extensibility capabilities of PostgreSQL and cater to various use cases.

  2. Advanced Topics: Extend the tutorial to cover advanced topics such as security considerations, error handling, and performance optimization when developing PostgreSQL extensions.

  3. Testing Strategies: Explore more comprehensive testing strategies, including functional tests, benchmarking, and performance testing, to ensure the reliability and efficiency of the extensions.

  4. Support for New Languages: Expand the tutorial to include examples of extension development using other programming languages, further broadening the scope of contributors and learners.

As a GSoC participant, I am committed to staying involved in the project and helping the community with any future contributions. By working collectively, future contributors can take this project to new heights, empower more developers to create extensions, and enrich the PostgreSQL extension ecosystem.


I extend my heartfelt gratitude to Google for hosting the Google Summer of Code program, providing a remarkable platform that enabled me to make a meaningful impact on the open-source community. This program has not only fostered personal growth but has also inspired my peers and immediate surroundings to embrace the world of open-source contributions.

I would like to express my sincere appreciation to my mentor's David E. Wheeler (@theory) and Jimmy Angelakos (@vyruss) for their support, invaluable guidance throughout the program. Their expertise and insights have been instrumental in shaping my journey and ensuring the success of my project.

I am also thankful to Jerry Sievert (@JerrySievert), whose input and suggestions have played a crucial role in refining my project and enhancing its overall quality.

Lastly, I am indebted to fellow contributors like Rajiv Harlalka (@rajivharlalka) for their collaborative spirit and support. Their willingness to share knowledge and exchange ideas significantly contributed to the success of the project.

Participating in this program has been an enriching and transformative experience, allowing me to delve into the realm of software engineering, enhance my research skills, and contribute meaningfully to the open-source community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment