Skip to content

Commit

Permalink
Capitalised the keywords in the code block and formatted the output
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhibhammar committed Sep 22, 2023
1 parent 4207d15 commit 2f216d4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
2 changes: 2 additions & 0 deletions advocacy_docs/pg_extensions/spl_check/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: EDB SPL Check
directoryDefaults:
product: EDB SPL Check
---

EDB SPL Check is a code analysis tool for SPL on EDB Postgres Advanced Server. Using only the internal PostgreSQL parser, it identifies errors that can occur at runtime. In addition, it parses the SQL inside your routines and identifies errors that are usually missed when executing `CREATE PROCEDURE/FUNCTION/PACKAGE`. Similarly, it identifies errors that are usually missed when executing `CREATE PACKAGE/OBJECT TYPES/COMPOUND TRIGGER`.
Expand Down
56 changes: 28 additions & 28 deletions advocacy_docs/pg_extensions/spl_check/using/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ CREATE TABLE bar(a int, b int);
CREATE OR REPLACE FUNCTION public.foo();

\sf+ foo_trg
CREATE OR REPLACE FUNCTION public.foo_trg()
RETURNS trigger
LANGUAGE edbspl
1 AS $function$
2 BEGIN
3 NEW.c := NEW.a + NEW.b;
4 RETURN NEW;
5 END;
6 $function$
CREATE OR REPLACE FUNCTION public.foo_trg()
RETURNS trigger
LANGUAGE edbspl
AS $function$
BEGIN
NEW.c := NEW.a + NEW.b;
RETURN NEW;
END;
$function$
```

When there's no specified relation for the trigger, the following is returned:

```sql
select * from spl_check_function('foo_trg()');
SELECT * FROM spl_check_function('foo_trg()');
__OUTPUT__
ERROR: missing trigger relation
HINT: Trigger relation oid must be valid
Expand All @@ -38,7 +38,7 @@ HINT: Trigger relation oid must be valid
When the trigger is checked successfully with a specified relation, the following is returned:

```sql
select * from spl_check_function('foo_trg()', 'bar');
SELECT * FROM spl_check_function('foo_trg()', 'bar');
__OUTPUT__
spl_check_function
--------------------------------------------------------
Expand All @@ -49,35 +49,35 @@ __OUTPUT__
For triggers with transitive tables, set the `oldtable` and `newtable` parameters:

```sql
create or replace function footab_trig_func()
returns trigger as $$
declare x int;
begin
if false then
CREATE OR REPLACE FUNCTION footab_trig_func()
RETURNS trigger as $$
DECLARE x int;
BEGIN
IF false THEN
-- should be ok;
select count(*) from newtab into x;
SELECT COUNT(*) FROM newtab INTO x;

-- should fail;
select count(*) from newtab where d = 10 into x;
end if;
return null;
end;
$$ language edbspl;
SELECT COUNT(*) FROM newtab WHERE d = 10 into x;
END If;
RETURN null;
END;
$$ LANGUAGE edbspl;

select * from spl_check_function('footab_trig_func','footab', newtable := 'newtab');
SELECT * FROM spl_check_function('footab_trig_func','footab', newtable := 'newtab');
```

## Validating compound triggers

Another way to verify a trigger function is to use `spl_check_trigger()` by providing the trigger name and, optionally, the relation name. This method is useful for redwood-style triggers and compound triggers where trigger functions are created internally. For example:

```sql
create table tab(a int);
create or replace trigger tg1 before insert on tab
for each row
begin
CREATE TABLE tab(a int);
CREATE or REPLACE trigger tg1 before insert on tab
FOR EACH ROW
BEGIN
NEW.a := NEW.b;
end;
END;

select * from spl_check_trigger('tg1');
__OUTPUT__
Expand Down
8 changes: 3 additions & 5 deletions advocacy_docs/pg_extensions/spl_check/using/profiler.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ Due to dependencies, `shared_preload_libraries` must contain `edb-spl` first:
```sql
show shared_preload_libraries ;
__OUTPUT__
┌──────────────────────────┐
│ shared_preload_libraries │
╞══════════════════════════╡
│ edb-spl,spl_check │
└──────────────────────────┘
shared_preload_libraries
----------------------------
edb-spl,spl_check
(1 row)
```

Expand Down

0 comments on commit 2f216d4

Please sign in to comment.