There are a few ways you can install Trusted Language Extensions for PostgreSQL (pg_tle
).
- To build
pg_tle
from source, you will first need to clone the repository to the location of your PostgreSQL installation. You can do so with the following command:
git clone https://github.com/aws/pg_tle.git
- Enter the
pg_tle
directory and runmake
:
cd pg_tle
make
Note that pg_config
mustbe in your PATH
for the above command to work. Otherwise, the build will fail. If you do not want to add pg_config
to your PATH
, you can set the PG_CONFIG
variable when calling make
, for example:
PG_CONFIG=/path/to/pg_config make
- Install
pg_tle
to your PostgreSQL installation using the following command:
sudo make install
Note that pg_config
mustbe in your PATH
for the above command to work. Otherwise, the build will fail. If you do not want to add pg_config
to your PATH
, you can set the PG_CONFIG
variable when calling make
, for example:
sudo PG_CONFIG=/path/to/pg_config make install
Trusted Language Extensions for PostgreSQL (pg_tle
) comes with Amazon RDS for PostgreSQL and Amazon Aurora PostgreSQL-compatible edition. pg_tle
is available in Amazon RDS for PostgreSQL since version 14.5 and Amazon Aurora PostgreSQL-compatible edition since 14.6.
You can follow the directions in the next section for how to enable pg_tle
in your Amazon RDS for PostgreSQL and Amazon Aurora PostgreSQL-compatible edition instances and clusters.
Once you have installed the pg_tle
extension files into your PostgreSQL installation, you can start using pg_tle
to install Trusted Language Extensions. Before running CREATE EXTENSION
, you will have to add pg_tle
to the shared_preload_libraries
configuration parameter and restart PostgreSQL. There are a few methods to do this. Note that you must use Method #3 for Amazon RDS for PostgreSQL and Amazon Aurora PostgreSQL-compatible edition.
- As a PostgreSQL superuser (e.g. the
postgres
user), check to see if there are any other values set inshared_preload_libraries
. You can do so with theSHOW
command:
SHOW shared_preload_libraries;
If there are additional libraries, please be sure to copy them as a comma-separated list (e.g. 'pg_stat_activity,pg_tle'
) in the next step.
- Execute
ALTER SYSTEM
to addpg_tle
to the list ofshared_preload_libraries
:
ALTER SYSTEM SET shared_preload_libraries TO 'pg_tle';
If you have additional shared_preload_libraries
, include them in a comma-separated list.
- Restart your PostgreSQL instance.
- Find the
postgresql.conf
file for your installation. You can do so with the following SQL command:
SHOW config_file;
- Open up the file found in the above location. Find
shared_preload_libraries
and addpg_tle
to the list:
shared_preload_libraries = 'pg_tle'
- Save the file. Restart your PostgreSQL instance.
The following instructions use the AWS Command Line Interface (aws
CLI) for enabling pg_tle
via parameter groups. You can also use the console or the Amazon RDS API to add pg_tle
to shared_preload_libraries
.
- If you have not already done so, create a parameter group in the region that you want to install
pg_tle
to your Amazon RDS or Amazon Aurora database. For example, to create a new parameter group inus-east-1
for Amazon RDS for PostgreSQL v14:
aws rds create-db-parameter-group \
--region us-east-1 \
--db-parameter-group-name pgtle-pg \
--db-parameter-group-family postgres14 \
--description "pgtle-pg"
- Modify the
shared_preload_libraries
parameter group to add thepg_tle
library. For example, the below command addspg_tle
toshared_preload_libraries
using the paramater group created in the previous step:
aws rds modify-db-parameter-group \
--region us-east-1 \
--db-parameter-group-name pgtle-pg \
--parameters "ParameterName=shared_preload_libraries,ParameterValue=pg_tle,ApplyMethod=pending-reboot"
- Add the parameter group to your database and restart your Amazon RDS for PostgreSQL or Amazon Aurora PostgreSQL-compatible edition instance. The below command adds the parameter group created in the first step to a database called "pg-tle-is-fun" and restarts the database instance immediately:
aws rds modify-db-instance \
--region us-east-1 \
--db-instance-identifier pg-tle-is-fun \
--db-parameter-group-name pgtle-pg \
--apply-immediately
Now that pg_tle
is installed in your PostgreSQL instance, let's try creating our first Trusted Language Extensions for PostgreSQL