-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from kaaveland/structured-hint-examples
Introduce structure to the examples and demo each lint
- Loading branch information
Showing
140 changed files
with
3,709 additions
and
1,553 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
create table authors(id integer generated always as identity primary key, name text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
set local lock_timeout = '2s'; | ||
alter table authors add constraint name_not_null check (name is not null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Eugene 🔒 lint report of `examples/E1/bad/1.sql` | ||
|
||
This is a human readable SQL script safety report generated by [eugene](https://github.com/kaaveland/eugene). Keep in mind that lints can be ignored by adding a `-- eugene: ignore E123` comment to the SQL statement or by passing --ignore E123 on the command line. | ||
|
||
The migration script passed all the checks ✅ | ||
|
||
## Statement number 1 | ||
|
||
### SQL | ||
|
||
```sql | ||
create table authors(id integer generated always as identity primary key, name text) | ||
``` | ||
|
||
No checks matched for this statement. ✅ | ||
|
||
|
||
# Eugene 🔒 lint report of `examples/E1/bad/2.sql` | ||
|
||
This is a human readable SQL script safety report generated by [eugene](https://github.com/kaaveland/eugene). Keep in mind that lints can be ignored by adding a `-- eugene: ignore E123` comment to the SQL statement or by passing --ignore E123 on the command line. | ||
|
||
The migration script did not pass all the checks ❌ | ||
|
||
## Statement number 1 | ||
|
||
### SQL | ||
|
||
```sql | ||
set local lock_timeout = '2s' | ||
``` | ||
|
||
No checks matched for this statement. ✅ | ||
|
||
## Statement number 2 | ||
|
||
### SQL | ||
|
||
```sql | ||
alter table authors add constraint name_not_null check (name is not null) | ||
``` | ||
|
||
### Lints | ||
|
||
#### Validating table with a new constraint | ||
|
||
ID: `E1` | ||
|
||
A new constraint was added and it is already `VALID`. This blocks all table access until all rows are validated. A safer way is: Add the constraint as `NOT VALID` and validate it with `ALTER TABLE ... VALIDATE CONSTRAINT` later. | ||
|
||
Statement takes `AccessExclusiveLock` on `public.authors`, blocking reads until constraint `name_not_null` is validated | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Eugene 🔒 trace report of `examples/E1/bad/1.sql` | ||
|
||
## Statement number 1 for 10 ms | ||
|
||
### SQL | ||
|
||
```sql | ||
create table authors(id integer generated always as identity primary key, name text) | ||
``` | ||
|
||
### Locks at start | ||
|
||
No locks held at the start of this statement. | ||
|
||
### New locks taken | ||
|
||
No new locks taken by this statement. | ||
|
||
|
||
|
||
# Eugene 🔒 trace report of `examples/E1/bad/2.sql` | ||
|
||
## Statement number 1 for 10 ms | ||
|
||
### SQL | ||
|
||
```sql | ||
set local lock_timeout = '2s' | ||
``` | ||
|
||
### Locks at start | ||
|
||
No locks held at the start of this statement. | ||
|
||
### New locks taken | ||
|
||
No new locks taken by this statement. | ||
|
||
|
||
## Statement number 2 for 10 ms | ||
|
||
### SQL | ||
|
||
```sql | ||
alter table authors add constraint name_not_null check (name is not null) | ||
``` | ||
|
||
### Locks at start | ||
|
||
No locks held at the start of this statement. | ||
|
||
### New locks taken | ||
|
||
| Schema | Object | Mode | Relkind | OID | Safe | | ||
|--------|--------|------|---------|-----|------| | ||
| `public` | `authors` | `AccessExclusiveLock` | Table | 1 | ❌ | | ||
|
||
### Hints | ||
|
||
#### Validating table with a new constraint | ||
|
||
ID: `E1` | ||
|
||
A new constraint was added and it is already `VALID`. This blocks all table access until all rows are validated. A safer way is: Add the constraint as `NOT VALID` and validate it with `ALTER TABLE ... VALIDATE CONSTRAINT` later. | ||
|
||
A new constraint `name_not_null` of type `CHECK` was added to the table `public.authors` as `VALID`. Constraints that are `NOT VALID` can be made `VALID` by `ALTER TABLE public.authors VALIDATE CONSTRAINT name_not_null` which takes a lesser lock. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
create table authors(id integer generated always as identity primary key, name text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
set local lock_timeout = '2s'; | ||
alter table authors add constraint name_not_null check (name is not null) not valid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
set local lock_timeout = '2s'; | ||
alter table authors validate constraint name_not_null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Eugene 🔒 lint report of `examples/E1/good/1.sql` | ||
|
||
This is a human readable SQL script safety report generated by [eugene](https://github.com/kaaveland/eugene). Keep in mind that lints can be ignored by adding a `-- eugene: ignore E123` comment to the SQL statement or by passing --ignore E123 on the command line. | ||
|
||
The migration script passed all the checks ✅ | ||
|
||
## Statement number 1 | ||
|
||
### SQL | ||
|
||
```sql | ||
create table authors(id integer generated always as identity primary key, name text) | ||
``` | ||
|
||
No checks matched for this statement. ✅ | ||
|
||
|
||
# Eugene 🔒 lint report of `examples/E1/good/2.sql` | ||
|
||
This is a human readable SQL script safety report generated by [eugene](https://github.com/kaaveland/eugene). Keep in mind that lints can be ignored by adding a `-- eugene: ignore E123` comment to the SQL statement or by passing --ignore E123 on the command line. | ||
|
||
The migration script passed all the checks ✅ | ||
|
||
## Statement number 1 | ||
|
||
### SQL | ||
|
||
```sql | ||
set local lock_timeout = '2s' | ||
``` | ||
|
||
No checks matched for this statement. ✅ | ||
|
||
## Statement number 2 | ||
|
||
### SQL | ||
|
||
```sql | ||
alter table authors add constraint name_not_null check (name is not null) not valid | ||
``` | ||
|
||
No checks matched for this statement. ✅ | ||
|
||
|
||
# Eugene 🔒 lint report of `examples/E1/good/3.sql` | ||
|
||
This is a human readable SQL script safety report generated by [eugene](https://github.com/kaaveland/eugene). Keep in mind that lints can be ignored by adding a `-- eugene: ignore E123` comment to the SQL statement or by passing --ignore E123 on the command line. | ||
|
||
The migration script passed all the checks ✅ | ||
|
||
## Statement number 1 | ||
|
||
### SQL | ||
|
||
```sql | ||
set local lock_timeout = '2s' | ||
``` | ||
|
||
No checks matched for this statement. ✅ | ||
|
||
## Statement number 2 | ||
|
||
### SQL | ||
|
||
```sql | ||
alter table authors validate constraint name_not_null | ||
``` | ||
|
||
No checks matched for this statement. ✅ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Eugene 🔒 trace report of `examples/E1/good/1.sql` | ||
|
||
## Statement number 1 for 10 ms | ||
|
||
### SQL | ||
|
||
```sql | ||
create table authors(id integer generated always as identity primary key, name text) | ||
``` | ||
|
||
### Locks at start | ||
|
||
No locks held at the start of this statement. | ||
|
||
### New locks taken | ||
|
||
No new locks taken by this statement. | ||
|
||
|
||
|
||
# Eugene 🔒 trace report of `examples/E1/good/2.sql` | ||
|
||
## Statement number 1 for 10 ms | ||
|
||
### SQL | ||
|
||
```sql | ||
set local lock_timeout = '2s' | ||
``` | ||
|
||
### Locks at start | ||
|
||
No locks held at the start of this statement. | ||
|
||
### New locks taken | ||
|
||
No new locks taken by this statement. | ||
|
||
|
||
## Statement number 2 for 10 ms | ||
|
||
### SQL | ||
|
||
```sql | ||
alter table authors add constraint name_not_null check (name is not null) not valid | ||
``` | ||
|
||
### Locks at start | ||
|
||
No locks held at the start of this statement. | ||
|
||
### New locks taken | ||
|
||
| Schema | Object | Mode | Relkind | OID | Safe | | ||
|--------|--------|------|---------|-----|------| | ||
| `public` | `authors` | `AccessExclusiveLock` | Table | 1 | ❌ | | ||
|
||
|
||
# Eugene 🔒 trace report of `examples/E1/good/3.sql` | ||
|
||
## Statement number 1 for 10 ms | ||
|
||
### SQL | ||
|
||
```sql | ||
set local lock_timeout = '2s' | ||
``` | ||
|
||
### Locks at start | ||
|
||
No locks held at the start of this statement. | ||
|
||
### New locks taken | ||
|
||
No new locks taken by this statement. | ||
|
||
|
||
## Statement number 2 for 10 ms | ||
|
||
### SQL | ||
|
||
```sql | ||
alter table authors validate constraint name_not_null | ||
``` | ||
|
||
### Locks at start | ||
|
||
No locks held at the start of this statement. | ||
|
||
### New locks taken | ||
|
||
No new locks taken by this statement. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
create table prices (id integer generated always as identity primary key, price int not null); | ||
create table authors (id integer generated always as identity primary key, name text not null); |
Oops, something went wrong.