pg_start_sql
pg_start_sql · runs SQL statement at instance start
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101630 | pg_start_sql | pg_start_sql | 1.0 | ADMIN | PostgreSQL | C |
PostgreSQL · 9.5, 9.6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
Usage
Sources:
pg_start_sql runs configured SQL when a PostgreSQL instance starts. The reviewed control/installation SQL is 1.0.0; upstream reports testing on PostgreSQL 9.5–19. All startup statements run as a superuser, with no setting to choose a less privileged execution role.
Configure Startup SQL
Add the library to the existing preload list and configure the target database and statement:
Restart PostgreSQL for preload, and follow upstream’s extension setup:
The worker is instance-wide; the extension need not be created in every database. pg_start_sql.dbname defaults to postgres. At least one of pg_start_sql.stmt or pg_start_sql.file must be configured; the latter selects a file containing startup statements.
Operational Boundary
Restrict configuration and SQL-file writes to trusted administrators because the statements execute with superuser privileges. Use startup work that is safe to repeat across server starts and verify its result and server logs. Preserve other preloaded libraries. The control file permits relocation of SQL objects, but that does not remove the cluster-level preload and restart requirements.