Day 24 - Refining

Title: Refining the Directory Hierarchy for Postgres Extension Creation: Real-World Examples

I explored real-world examples of extensions and how their directory hierarchies can provide valuable insights for organizing our own projects. We will examine the directory structures of three extensions: pg_stat_statements, pgcrypto, and PostGIS. Additionally, we will delve into language-specific considerations for file organization. Let's dive in!

  • Basic Directory Hierarchy - pg_stat_statements The pg_stat_statements extension, which provides detailed statistics on SQL statement execution, offers a simple yet effective directory structure. It primarily consists of a single directory containing the control file, SQL script file, and any additional source code files. This basic structure allows developers to focus on the core functionality of the extension without unnecessary complexity.

  • Intermediate Directory Hierarchy - pgcrypto Taking a step further, let's explore the directory structure of the pgcrypto extension. As a cryptography extension for Postgres, it introduces an intermediate level of hierarchy. Alongside the essential files, pgcrypto employs subdirectories for additional organization. For example, it includes directories for source code files, test files, and documentation. This structured approach enhances maintainability and makes it easier to locate specific resources within the extension.

  • Advanced Directory Hierarchy - POSTGIS Moving on to the POSTGIS extension, which adds support for geographic objects to Postgres, we encounter a more advanced directory hierarchy. POSTGIS embraces a modular approach, dividing its functionality into distinct subdirectories. These subdirectories may include components such as functions, types, operators, and additional features specific to geospatial operations. This advanced structure promotes modularity, code reuse, and better organization, especially for complex extensions like POSTGIS.

Language-Specific Considerations While the directory hierarchy discussed so far is language-agnostic, it is important to consider language-specific aspects when organizing extension files. Different programming languages may have conventions or preferences regarding file placement and naming. It is recommended to refer to language-specific guidelines or established practices for incorporating language-specific files within your extension's directory hierarchy.