Day 23 - Directory Hierarchy

When it comes to creating Postgres extensions, understanding the directory hierarchy is crucial. It provides a structured framework for organizing the necessary files and resources. However, the official Postgres documentation lacks a definitive hierarchy, and different extensions may follow varying practices. I will propose three directory structures, ranging from basic to advanced, to assist both novice and experienced programmers in navigating the directory hierarchy during the extension creation process.

  • Basic Directory Hierarchy: The basic directory structure serves as a starting point for beginners. It involves organizing the essential files, such as the control file, SQL script file, and any additional source code files, within a single directory. This straightforward structure helps beginners focus on the core components of the extension without overwhelming them with excessive complexity.

  • Intermediate Directory Hierarchy: The intermediate directory structure builds upon the basic structure by introducing additional subdirectories for different categories of files. These categories may include source code files, documentation files, test files, and any other resources related to the extension. This hierarchical organization enhances clarity and ease of maintenance, especially as the extension becomes more complex.

  • Advanced Directory Hierarchy: The advanced directory structure caters to extensions with extensive functionality and multiple components. It incorporates a modular approach by dividing the extension into separate subdirectories based on their functionalities. For example, there may be directories for functions, types, operators, and additional features. This advanced structure facilitates scalability, code reuse, and better organization, particularly for complex extensions.