Skip to content

Commit fcd29ca

Browse files
docs: Use code-block postgres consistently
1 parent 553ac79 commit fcd29ca

14 files changed

Lines changed: 55 additions & 55 deletions

docs/how-tos/sql-user-management-using-postgres-users-and-passwords.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Concerning the `pgjwt extension <https://github.com/michelp/pgjwt>`_, please cf.
5454
5555
In order to be able to work with postgres' SCRAM-SHA-256 password hashes, we also need the PBKDF2 key derivation function. Luckily there is `a PL/pgSQL implementation on stackoverflow <https://stackoverflow.com/a/72805848>`_:
5656

57-
.. code-block:: plpgsql
57+
.. code-block:: postgres
5858
5959
CREATE FUNCTION basic_auth.pbkdf2(salt bytea, pw text, count integer, desired_length integer, algorithm text) RETURNS bytea
6060
LANGUAGE plpgsql IMMUTABLE
@@ -120,7 +120,7 @@ In order to be able to work with postgres' SCRAM-SHA-256 password hashes, we als
120120
Analogous to :ref:`sql_user_management` creates the function :code:`basic_auth.user_role`, we create a helper function to check the user's password, here with another name and signature (since we want the username, not an email address).
121121
But contrary to :ref:`sql_user_management`, this function does not use a dedicated :code:`users` table with passwords, but instead utilizes the built-in table `pg_catalog.pg_authid <https://www.postgresql.org/docs/current/catalog-pg-authid.html>`_:
122122

123-
.. code-block:: plpgsql
123+
.. code-block:: postgres
124124
125125
CREATE FUNCTION basic_auth.check_user_pass(username text, password text) RETURNS name
126126
LANGUAGE sql
@@ -160,7 +160,7 @@ Logins
160160
As described in :ref:`client_auth`, we'll create a JWT token inside our login function. Note that you'll need to adjust the secret key which is hard-coded in this example to a secure (at least thirty-two character) secret of your choosing.
161161

162162

163-
.. code-block:: plpgsql
163+
.. code-block:: postgres
164164
165165
CREATE TYPE basic_auth.jwt_token AS (
166166
token text

docs/how-tos/sql-user-management.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ First we'll need a table to keep track of our users:
2828
2929
We would like the role to be a foreign key to actual database roles, however PostgreSQL does not support these constraints against the :code:`pg_roles` table. We'll use a trigger to manually enforce it.
3030

31-
.. code-block:: plpgsql
31+
.. code-block:: postgres
3232
3333
create or replace function
3434
basic_auth.check_role_exists() returns trigger as $$
@@ -50,7 +50,7 @@ We would like the role to be a foreign key to actual database roles, however Pos
5050
5151
Next we'll use the pgcrypto extension and a trigger to keep passwords safe in the :code:`users` table.
5252

53-
.. code-block:: plpgsql
53+
.. code-block:: postgres
5454
5555
create extension if not exists pgcrypto;
5656
@@ -72,7 +72,7 @@ Next we'll use the pgcrypto extension and a trigger to keep passwords safe in th
7272
7373
With the table in place we can make a helper to check a password against the encrypted column. It returns the database role for a user if the email and password are correct.
7474

75-
.. code-block:: plpgsql
75+
.. code-block:: postgres
7676
7777
create or replace function
7878
basic_auth.user_role(email text, pass text) returns name

docs/references/api/openapi.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PostgREST automatically serves a full `OpenAPI <https://www.openapis.org/>`_ des
1111

1212
For extra customization, the OpenAPI output contains a "description" field for every `SQL comment <https://www.postgresql.org/docs/current/sql-comment.html>`_ on any database object. For instance,
1313

14-
.. code-block:: sql
14+
.. code-block:: postgres
1515
1616
COMMENT ON SCHEMA mammals IS
1717
'A warm-blooded vertebrate animal of a class that is distinguished by the secretion of milk by females for the nourishment of the young';
@@ -26,7 +26,7 @@ These unsavory comments will appear in the generated JSON as the fields, ``info.
2626

2727
Also if you wish to generate a ``summary`` field you can do it by having a multiple line comment, the ``summary`` will be the first line and the ``description`` the lines that follow it:
2828

29-
.. code-block:: plpgsql
29+
.. code-block:: postgres
3030
3131
COMMENT ON TABLE entities IS
3232
$$Entities summary
@@ -37,7 +37,7 @@ Also if you wish to generate a ``summary`` field you can do it by having a multi
3737
3838
Similarly, you can override the API title by commenting the schema.
3939

40-
.. code-block:: plpgsql
40+
.. code-block:: postgres
4141
4242
COMMENT ON SCHEMA api IS
4343
$$FooBar API

docs/references/api/preferences.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ Single JSON object as Function Parameter
236236
237237
:code:`Prefer: params=single-object` allows sending the JSON request body as the single argument of a :ref:`function <s_procs>`.
238238
239-
.. code-block:: plpgsql
239+
.. code-block:: postgres
240240
241241
CREATE FUNCTION mult_them(param json) RETURNS int AS $$
242242
SELECT (param->>'x')::int * (param->>'y')::int

docs/references/api/resource_embedding.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ The join table determines many-to-many relationships. It must contain foreign ke
178178

179179
The join table is also detected if the composite key has additional columns.
180180

181-
.. code-block:: postgresql
181+
.. code-block:: postgres
182182
183183
create table roles(
184184
id int generated always as identity,
@@ -214,7 +214,7 @@ One-to-one relationships are detected in two ways.
214214
- When the foreign key is a primary key as specified in the :ref:`sample film database <erd_film>`.
215215
- When the foreign key has a unique constraint.
216216

217-
.. code-block:: postgresql
217+
.. code-block:: postgres
218218
219219
create table technical_specs(
220220
film_id int references films(id) unique,
@@ -246,7 +246,7 @@ You can manually define relationships by using functions. This is useful for dat
246246

247247
Assuming there's a foreign table ``premieres`` that we want to relate to ``films``.
248248

249-
.. code-block:: postgresql
249+
.. code-block:: postgres
250250
251251
create foreign table premieres (
252252
id integer,
@@ -478,7 +478,7 @@ Recursive One-To-One
478478

479479
To get either side of the Recursive One-To-One relationship, create the functions:
480480

481-
.. code-block:: postgresql
481+
.. code-block:: postgres
482482
483483
create or replace function predecessor(presidents) returns setof presidents rows 1 as $$
484484
select * from presidents where id = $1.predecessor_id
@@ -530,7 +530,7 @@ Recursive One-To-Many
530530

531531
To get the One-To-Many embedding, that is, the supervisors with their supervisees, create a function like this one:
532532

533-
.. code-block:: postgresql
533+
.. code-block:: postgres
534534
535535
create or replace function supervisees(employees) returns setof employees as $$
536536
select * from employees where supervisor_id = $1.id
@@ -562,7 +562,7 @@ Recursive Many-To-One
562562
Let's take the same ``employees`` table from :ref:`recursive_o2m_embed`.
563563
To get the Many-To-One relationship, that is, the employees with their respective supervisor, you need to create a function like this one:
564564

565-
.. code-block:: postgresql
565+
.. code-block:: postgres
566566
567567
create or replace function supervisor(employees) returns setof employees rows 1 as $$
568568
select * from employees where id = $1.supervisor_id
@@ -614,7 +614,7 @@ Recursive Many-To-Many
614614

615615
To get all the subscribers of a user as well as the ones they're following, define these functions:
616616

617-
.. code-block:: postgresql
617+
.. code-block:: postgres
618618
619619
create or replace function subscribers(users) returns setof users as $$
620620
select u.*
@@ -756,7 +756,7 @@ If you have a :ref:`Stored Procedure <s_procs>` that returns a table type, you c
756756

757757
Here's a sample function (notice the ``RETURNS SETOF films``).
758758

759-
.. code-block:: plpgsql
759+
.. code-block:: postgres
760760
761761
CREATE FUNCTION getallfilms() RETURNS SETOF films AS $$
762762
SELECT * FROM films;

docs/references/api/schemas.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ To add schemas dynamically, you can use :ref:`in_db_config` plus :ref:`config re
8888

8989
- If the schemas' names have a pattern, like a ``tenant_`` prefix, do:
9090

91-
.. code-block:: postgresql
91+
.. code-block:: postgres
9292
9393
create or replace function postgrest.pre_config()
9494
returns void as $$
@@ -100,7 +100,7 @@ To add schemas dynamically, you can use :ref:`in_db_config` plus :ref:`config re
100100
101101
- If there's no name pattern but they're created with a particular role (``CREATE SCHEMA mine AUTHORIZATION joe``), do:
102102

103-
.. code-block:: postgresql
103+
.. code-block:: postgres
104104
105105
create or replace function postgrest.pre_config()
106106
returns void as $$
@@ -112,7 +112,7 @@ To add schemas dynamically, you can use :ref:`in_db_config` plus :ref:`config re
112112
113113
- Otherwise, you might need to create a table that stores the allowed schemas.
114114

115-
.. code-block:: postgresql
115+
.. code-block:: postgres
116116
117117
create table postgrest.config (schemas text);
118118
@@ -125,7 +125,7 @@ To add schemas dynamically, you can use :ref:`in_db_config` plus :ref:`config re
125125
126126
Then each time you add an schema, do:
127127

128-
.. code-block:: postgresql
128+
.. code-block:: postgres
129129
130130
NOTIFY pgrst, 'reload config';
131131
NOTIFY pgrst, 'reload schema';

docs/references/api/stored_procedures.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To supply arguments in an API call, include a JSON object in the request payload
2323

2424
For instance, assume we have created this function in the database.
2525

26-
.. code-block:: plpgsql
26+
.. code-block:: postgres
2727
2828
CREATE FUNCTION add_them(a integer, b integer)
2929
RETURNS integer AS $$
@@ -73,7 +73,7 @@ Functions with a single unnamed JSON parameter
7373
If you want the JSON request body to be sent as a single argument, you can create a function with a single unnamed ``json`` or ``jsonb`` parameter.
7474
For this the ``Content-Type: application/json`` header must be included in the request.
7575

76-
.. code-block:: plpgsql
76+
.. code-block:: postgres
7777
7878
CREATE FUNCTION mult_them(json) RETURNS int AS $$
7979
SELECT ($1->>'x')::int * ($1->>'y')::int
@@ -108,7 +108,7 @@ To send raw XML, the parameter type must be ``xml`` and the header ``Content-Typ
108108

109109
To send raw binary, the parameter type must be ``bytea`` and the header ``Content-Type: application/octet-stream`` must be included in the request.
110110

111-
.. code-block:: plpgsql
111+
.. code-block:: postgres
112112
113113
CREATE TABLE files(blob bytea);
114114
@@ -252,7 +252,7 @@ Let's get its :ref:`explain_plan` when calling it with filters applied:
252252
curl "http://localhost:3000/rpc/getallprojects?id=eq.1" \
253253
-H "Accept: application/vnd.pgrst.plan"
254254
255-
.. code-block:: psql
255+
.. code-block:: postgres
256256
257257
Aggregate (cost=8.18..8.20 rows=1 width=112)
258258
-> Index Scan using projects_pkey on projects (cost=0.15..8.17 rows=1 width=40)

docs/references/api/tables_views.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ any :code:`ANY` comparison matches any value in the list
8888

8989
For more complicated filters you will have to create a new view in the database, or use a stored procedure. For instance, here's a view to show "today's stories" including possibly older pinned stories:
9090

91-
.. code-block:: postgresql
91+
.. code-block:: postgres
9292
9393
CREATE VIEW fresh_stories AS
9494
SELECT *

docs/references/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ You can also configure the server with database settings by using a :ref:`pre-co
8080
8181
PGRST_DB_PRE_CONFIG = "postgrest.pre_config"
8282
83-
.. code-block:: postgresql
83+
.. code-block:: postgres
8484
8585
-- create a dedicated schema, hidden from the API
8686
create schema postgrest;

docs/references/errors.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ RAISE errors with HTTP Status Codes
339339

340340
Custom status codes can be done by raising SQL exceptions inside :ref:`functions <s_procs>`. For instance, here's a saucy function that always responds with an error:
341341

342-
.. code-block:: postgresql
342+
.. code-block:: postgres
343343
344344
CREATE OR REPLACE FUNCTION just_fail() RETURNS void
345345
LANGUAGE plpgsql
@@ -366,7 +366,7 @@ One way to customize the HTTP status code is by raising particular exceptions ac
366366

367367
For even greater control of the HTTP status code, raise an exception of the ``PTxyz`` type. For instance to respond with HTTP 402, raise ``PT402``:
368368

369-
.. code-block:: sql
369+
.. code-block:: postgres
370370
371371
RAISE sqlstate 'PT402' using
372372
message = 'Payment Required',
@@ -394,7 +394,7 @@ Add HTTP Headers with RAISE
394394

395395
For full control over headers and status you can raise a ``PGRST`` SQLSTATE error. You can achieve this by adding the ``code``, ``message``, ``detail`` and ``hint`` in the PostgreSQL error message field as a JSON object. Here, the ``details`` and ``hint`` are optional. Similarly, the ``status`` and ``headers`` must be added to the SQL error detail field as a JSON object. For instance:
396396

397-
.. code-block:: sql
397+
.. code-block:: postgres
398398
399399
RAISE sqlstate 'PGRST' USING
400400
message = '{"code":"123","message":"Payment Required","details":"Quota exceeded","hint":"Upgrade your plan"}',
@@ -418,7 +418,7 @@ Returns:
418418
419419
For non standard HTTP status, you can optionally add ``status_text`` to describe the status code. For status code ``419`` the detail field may look like this:
420420

421-
.. code-block:: sql
421+
.. code-block:: postgres
422422
423423
detail = '{"status":419,"status_text":"Page Expired","headers":{"X-Powered-By":"Nerd Rage"}}';
424424

0 commit comments

Comments
 (0)