Re: Extension development - Mailing list pgsql-hackers

From Jeevan Ladhe
Subject Re: Extension development
Date
Msg-id CAOgcT0M=eDVPHe8_6fLSbcR6APau=_8aSaCsTH7XXrpQ6WyeGg@mail.gmail.com
Whole thread Raw
In response to Extension development  (Yonatan Misgan <yonamis@dtu.edu.et>)
List pgsql-hackers
Hi Yonatan,

Here is an attempt to explain the components of the extension:

Makefile:
Makefile provides a way to compile your C code. Postgres provides an infrastructure called PGXS for building the extensions against installed Postgres server. More of this can be found in official documentation[1].

Control file:
It specifies some properties/metadata about the extension, like version, comments, directory etc. Official documentation[2]

SQL Script:
This file should be of format extension—version.sql which will have the functions that are either pure SQL functions, or interfaces for your C functions and other SQL objects to assist your functions etc. This will be executed internally by “CREATE EXTENSION” command.

C code:
Your C code is real implementation of your extension. Here you can have C implementations of SQL interface functions your declared in your .sql script file, register callbacks e.g. things you want to do post parse, before execution of a query etc. The filename can be anything but you should have PG_MODULE_MAGIC included in your C file.

Using this infrastructure one can simply do make, make install and then “CREATE EXTENSION” command to create objects. This helps keeping track of all the extension objects together, create them at once, and drop once with “DROP EXTENSION” command. Here[3] is complete documentation for extension. 

Regards,
Jeevan Ladhe


On Tue, Nov 12, 2019 at 12:24 PM Yonatan Misgan <yonamis@dtu.edu.et> wrote:

I am developed my own PostgreSQL extension for learning purpose and it is working correctly but I want to know to which components of the database is my own extension components communicate. For example I have c code, make file sql script, and control file after compiling the make file to which components of the database are each of my extension components to communicate. Thanks for your response.  

 

Regards,

____________________________________

Yonathan Misgan 

Assistant Lecturer, @ Debre Tabor University

Faculty of Technology

Department of Computer Science

Studying MSc in Computer Science (in Data and Web Engineering) 

@ Addis Ababa University 

E-mail: yonamis@dtu.edu.et

        yonathanmisgan.4@gmail.com

Tel:   (+251)-911180185 (mob)

 

pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: [HACKERS] Block level parallel vacuum
Next
From: Masahiko Sawada
Date:
Subject: Re: [HACKERS] Block level parallel vacuum