The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
postgres extension docs: plpgsql_check
Oliver Ricef30648972e22
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex 290c39a3394..ad7b5d85303 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -460,6 +460,11 @@ export const database = {items: [],},{ name: 'pgTAP: Unit Testing', url: '/guides/database/extensions/pgtap', items: [] },+ {+ name: 'plpgsql_check: PL/pgSQL Linter',+ url: '/guides/database/extensions/plpgsql_check',+ items: [],+ },{name: 'uuid-ossp: Unique Identifiers',url: '/guides/database/extensions/uuid-ossp',diff --git a/apps/docs/pages/guides/database/extensions/plpgsql_check.mdx b/apps/docs/pages/guides/database/extensions/plpgsql_check.mdxnew file mode 100644index 00000000000..8a9fb7bfde4--- /dev/null+++ b/apps/docs/pages/guides/database/extensions/plpgsql_check.mdx@@ -0,0 +1,107 @@+import Layout from '~/layouts/DefaultGuideLayout'++export const meta = {+ id: 'plpgsql_check',+ title: 'plpgsql_check: PL/pgSQL Linter',+ description: 'Lint PL/pgSQL code',+}++plpg_sqlcheck is a PostgreSQL extension that lints plpgsql for syntax, semantic and other related issues. The tool helps developers to identify and correct errors before executing the code. plpgsql_sqlcheck is most useful for developers who are working with large or complex SQL codebases, as it can help identify and resolve issues early in the development cycle.++## Usage++### Enable the extension++<Tabs+ scrollable+ size="small"+ type="underlined"+ defaultActiveId="dashboard"+>+<TabPanel id="dashboard" label="Dashboard">++1. Go to the [Database](https://app.supabase.com/project/_/database/tables) page in the Dashboard.+2. Click on **Extensions** in the sidebar.+3. Search for "plpgsql_check" and enable the extension.++</TabPanel>+<TabPanel id="sql" label="SQL">++{/* prettier-ignore */}+```sql+-- Enable the "plpgsql_check" extension+create extension plpgsql_check;++-- Disable the "plpgsql_check" extension+drop extension if exists plpgsql_check;+```++Even though the SQL code is `create extension`, this is the equivalent of "enabling the extension".+To disable an extension you can call `drop extension`.++</TabPanel>+</Tabs>++## API++- [`plpgsql_check_function( ... )`](https://github.com/okbob/plpgsql_check#active-mode): Scans a function for errors.++`plpgsql_check_function` is highly customizable. For a complete list of available arguments see [their doc](https://github.com/okbob/plpgsql_check#arguments)++## Usage++To demonstrate plpgsql_check we can create a function with a known error. In this case we create a function `some_func`, that references a non-existent column `location.created_at`.++{/* prettier-ignore */}+```sql+create table place(+ x float,+ y float+);++create or replace function public.some_func()+ returns void+ language plpgsql+as $$+declare+ rec record;+begin+ for rec in select * from place+ loop+ -- Bug: There is no column `created_at` on table `location`+ raise notice '%', rec.created_at;+ end loop;+end;+$$;+```++Note that executing the function would not catch the invalid reference error because the `loop` does not execute if no rows are present in the table.++{/* prettier-ignore */}+```sql+select public.some_func();+ some_func+ ───────────++ (1 row)+```++Now we can use plpgsql_check's `plpgsql_check_function` function to identify the known error.++{/* prettier-ignore */}+```sql+select plpgsql_check_function('public.some_func()');++ plpgsql_check_function+------------------------------------------------------------+ error:42703:8:RAISE:record "rec" has no field "created_at"+ Context: SQL expression "rec.created_at"+```++## Resources++- Official [`plpgsql_check` documentation](https://github.com/okbob/plpgsql_check)++export const Page = ({ children }) => <Layout meta={meta} children={children} />++export default Page