Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Apply suggestions from code review

Jonathan Summers-Muirc581bb035eb7
diff --git a/apps/www/_blog/2023-04-14-pg-tle.mdx b/apps/www/_blog/2023-04-14-pg-tle.mdx
index c78688914f6..4d85f799da1 100644
--- a/apps/www/_blog/2023-04-14-pg-tle.mdx
+++ b/apps/www/_blog/2023-04-14-pg-tle.mdx
@@ -1,9 +1,9 @@
---
-title: 'User-managed Trusted Language Extensions for Supabase and RDS'
+title: 'Trusted Language Extensions for Postgres'
launchweek: 7
tags:
- launch-week
- - tle
+ - postgres
date: '2023-04-14'
to_depth: 3
author: michel,oli_rice
@@ -12,15 +12,17 @@ thumb: launch-week-7/day-5-supabase-pg-tle/day-5-postgres-tle-thumb.jpg
---
-Most PostgreSQL cloud providers, such as Supabase and AWS RDS, do not allow users to install Postgres extensions into their databases until they have been rigorously vetted. Because of this, many useful Postgres extensions cannot be used on cloud platforms. However, the RDS has developed a new kind of extension called a **Trusted Language Extension** has been introduced that allows extensions written in Trusted Languages to be created from any database user without requiring filesystem access.
+Most PostgreSQL cloud providers, such as Supabase and AWS RDS, do not allow users to install Postgres extensions into their databases until they have been rigorously vetted. Because of this, many useful Postgres extensions cannot be used on cloud platforms. To solve this, the RDS team has developed a new kind of extension called a **Trusted Language Extension** (TLE).
+
+A TLE is a Postgres extension that is written in a Trusted Language, and it can be installed in any Postgres provider that has the [pg_tle](https://github.com/aws/pg_tle) extension installed. The goal is to make more extensions available to developers, even if your database is hosted on the cloud.
## Introduction
Before exploring what a Trusted Language Extension is, let’s cover the basics of Postgres Extensions and the notion of “Trusted Languages” in general.
-A Postgres Extension is a bundle of SQL and other code, primarily [Data Definition Language](https://www.postgresql.org/docs/current/ddl.html) (DDL) code installed into the server’s filesystem, and instantiated in a database with the `[CREATE EXTENSION](https://www.postgresql.org/docs/current/sql-createextension.html)` command. This code can contain any SQL, but almost always includes additional function objects created with the `[CREATE FUNCTION](https://www.postgresql.org/docs/current/sql-createfunction.html)` DDL statement that expose the core features of the extension to the database in some programming language, including an external library function written in C.
+A Postgres Extension is a bundle of SQL and other code, primarily [Data Definition Language](https://www.postgresql.org/docs/current/ddl.html) (DDL) code installed into the server’s filesystem, and instantiated in a database with the [`CREATE EXTENSION`](https://www.postgresql.org/docs/current/sql-createextension.html) command. This code can contain any SQL, but almost always includes additional function objects created with the [`CREATE FUNCTION`](https://www.postgresql.org/docs/current/sql-createfunction.html) DDL statement that expose the core features of the extension to the database in some programming language, including an external library function written in C.
-Extensions provide a wide variety of additional functionality to Postgres and allow third party feature distribution, like new data types, storage engines, helper functions, even entire language runtimes like Javascript or Python, without requiring changes to the Postgres database itself.
+Extensions provide a variety of additional functionality and allow third-party feature distribution without requiring changes to the Postgres database itself - including new data types, storage engines, helper functions, and even entire language runtimes like Javascript or Python.
Some examples of popular Postgres extensions include:
@@ -30,11 +32,11 @@ Some examples of popular Postgres extensions include:
- [plv8](https://plv8.github.io/): for running Node.js inside Postgres
- [pgsodium](https://github.com/michelp/pgsodium): for accessing the libsodium encryption API
-Before extensions can be created, they must first be installed on the filesystem of the database server, which is an important security measure because extensions in some cases may require external libraries and can interact with the internals of Postgres. Their installation is something that requires careful consideration.
+Before extensions can be created, they must first be installed on the filesystem of the database server, which is an important security measure because in some cases extensions may require external libraries and can interact with Postgres internals. Their installation is something that requires careful consideration.
## Trusted vs Untrusted
-As mentioned, extensions often include function objects created with `CREATE FUNCTION`. Many extensions provide functions whose implementation is written in C, and creating them in a database means that the compiled C code is “dynamically linked” into your running Postgres process. These dynamically-loaded libraries can now access every aspect of your running database process, right down to raw memory. They are essentially database superusers on steroids. Because of this, C is an “untrusted language” and installing extensions written in C requires filesystem access.
+Many extensions provide functions whose implementation is written in C, and creating them in a database means that the compiled C code is “dynamically linked” into your running Postgres process. These dynamically-loaded libraries can now access every aspect of your running database process, right down to raw memory. They are essentially database superusers on steroids. Because of this, C is an “untrusted language” and installing extensions written in C requires filesystem access.
However there are several _trusted_ languages in Postgres that don’t provide raw access to process memory, the filesytem, or other system functions. These languages obey the security rules of Postgres. The most obvious example of these trusted languages is SQL itself. Another built-in trusted language in Postgres is called [pl/pgsql](https://www.postgresql.org/docs/current/plpgsql.html). It looks a lot like SQL but with some imperative programming features like `IF` blocks and `FOR` loops. The aforementioned plv8 is also a trusted language, as are the languages [pl/perl](https://www.postgresql.org/docs/current/plperl.html) and [pl/tcl](https://www.postgresql.org/docs/current/pltcl.html). Other languages like [pl/python](https://www.postgresql.org/docs/current/plpython.html) are **_not_** trusted because of the way they are integrated into Postgres, they do not obey the “rules” of Postgres security, and so are not included in most cloud provider platforms since they would allow database users to effectively act as a superuser.