Skip to content

Commit

Permalink
pgtest: default to including error severity
Browse files Browse the repository at this point in the history
  • Loading branch information
maddyblue committed Feb 15, 2022
1 parent 59b9547 commit e1ae81d
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 28 deletions.
5 changes: 3 additions & 2 deletions src/pgtest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
//! no_error_fields`.
//! - `err_field_typs` specifies the set of error message fields
//! ([reference](https://www.postgresql.org/docs/current/protocol-error-fields.html)).
//! For example: `until err_field_typs=VC` would return the severity and code
//! The default is `CMS` (code, message, severity).
//! For example: `until err_field_typs=SC` would return the severity and code
//! fields in any ErrorResponse message.
//!
//! For example, to execute a simple prepared statement:
Expand Down Expand Up @@ -486,7 +487,7 @@ pub fn run_test(tf: &mut datadriven::TestFile, addr: &str, user: &str, timeout:
} else {
match args.remove("err_field_typs") {
Some(typs) => typs.join("").chars().collect(),
None => vec!['C', 'M'],
None => vec!['C', 'S', 'M'],
}
};
let mut ignore = HashSet::new();
Expand Down
8 changes: 4 additions & 4 deletions test/pgtest/copy-from-2.pt
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ until
ErrorResponse
ReadyForQuery
----
ErrorResponse {"fields":[{"typ":"C","value":"0A000"},{"typ":"M","value":"COPY delimiter must be a single one-byte character"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"COPY delimiter must be a single one-byte character"}]}
ReadyForQuery {"status":"I"}

send
Expand All @@ -350,9 +350,9 @@ ReadyForQuery
ErrorResponse
ReadyForQuery
----
ErrorResponse {"fields":[{"typ":"C","value":"0A000"},{"typ":"M","value":"COPY quote available only in CSV mode"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"COPY quote available only in CSV mode"}]}
ReadyForQuery {"status":"I"}
ErrorResponse {"fields":[{"typ":"C","value":"0A000"},{"typ":"M","value":"COPY escape available only in CSV mode"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"COPY escape available only in CSV mode"}]}
ReadyForQuery {"status":"I"}
ErrorResponse {"fields":[{"typ":"C","value":"0A000"},{"typ":"M","value":"COPY HEADER available only in CSV mode"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"COPY HEADER available only in CSV mode"}]}
ReadyForQuery {"status":"I"}
2 changes: 1 addition & 1 deletion test/pgtest/copy-from-fail.pt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ReadyForQuery
ReadyForQuery
----
CopyIn {"format":"text","column_formats":["text","text"]}
ErrorResponse {"fields":[{"typ":"C","value":"57014"},{"typ":"M","value":"COPY from stdin failed: frontend failure"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"57014"},{"typ":"M","value":"COPY from stdin failed: frontend failure"}]}
ReadyForQuery {"status":"I"}
ReadyForQuery {"status":"I"}

Expand Down
2 changes: 1 addition & 1 deletion test/pgtest/copy-from.pt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ CopyDone
until
ReadyForQuery
----
ErrorResponse {"fields":[{"typ":"C","value":"22P04"},{"typ":"M","value":"extra data after last expected column"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"22P04"},{"typ":"M","value":"extra data after last expected column"}]}
ReadyForQuery {"status":"I"}

# invalid type
Expand Down
18 changes: 9 additions & 9 deletions test/pgtest/cursors.pt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CommandComplete {"tag":"FETCH 1"}
ReadyForQuery {"status":"T"}
CommandComplete {"tag":"CLOSE CURSOR"}
ReadyForQuery {"status":"T"}
ErrorResponse {"fields":[{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"p\" does not exist"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"p\" does not exist"}]}
ReadyForQuery {"status":"E"}
CommandComplete {"tag":"ROLLBACK"}
ReadyForQuery {"status":"I"}
Expand Down Expand Up @@ -178,7 +178,7 @@ ReadyForQuery
ReadyForQuery
ReadyForQuery
----
ErrorResponse {"fields":[{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"c\" does not exist"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"c\" does not exist"}]}
ReadyForQuery {"status":"I"}
CommandComplete {"tag":"BEGIN"}
ReadyForQuery {"status":"T"}
Expand All @@ -187,7 +187,7 @@ ReadyForQuery {"status":"T"}
RowDescription {"fields":[{"name":"column1"}]}
CommandComplete {"tag":"COMMIT"}
ReadyForQuery {"status":"I"}
ErrorResponse {"fields":[{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"c\" does not exist"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"c\" does not exist"}]}
ReadyForQuery {"status":"I"}

# Verify that a single Query message can declare and fetch from a
Expand All @@ -213,7 +213,7 @@ RowDescription {"fields":[{"name":"column1"}]}
DataRow {"fields":["6"]}
CommandComplete {"tag":"FETCH 1"}
ReadyForQuery {"status":"I"}
ErrorResponse {"fields":[{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"c\" does not exist"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"c\" does not exist"}]}
ReadyForQuery {"status":"I"}

# Test cursors in extended protocol.
Expand Down Expand Up @@ -379,7 +379,7 @@ ReadyForQuery {"status":"T"}
ParseComplete
BindComplete
CommandComplete {"tag":"DECLARE CURSOR"}
ErrorResponse {"fields":[{"typ":"C","value":"55000"},{"typ":"M","value":"portal \"\" cannot be run"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"55000"},{"typ":"M","value":"portal \"\" cannot be run"}]}
ReadyForQuery {"status":"E"}
CommandComplete {"tag":"ROLLBACK"}
ReadyForQuery {"status":"I"}
Expand Down Expand Up @@ -429,7 +429,7 @@ CommandComplete {"tag":"FETCH 1"}
ParseComplete
BindComplete
CommandComplete {"tag":"CLOSE CURSOR"}
ErrorResponse {"fields":[{"typ":"C","value":"55000"},{"typ":"M","value":"portal \"\" cannot be run"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"55000"},{"typ":"M","value":"portal \"\" cannot be run"}]}
ReadyForQuery {"status":"E"}
CommandComplete {"tag":"ROLLBACK"}
ReadyForQuery {"status":"I"}
Expand Down Expand Up @@ -508,7 +508,7 @@ RowDescription {"fields":[{"name":"column1"}]}
DataRow {"fields":["1"]}
CommandComplete {"tag":"FETCH 1"}
ReadyForQuery {"status":"T"}
ErrorResponse {"fields":[{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"\" does not exist"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"34000"},{"typ":"M","value":"portal \"\" does not exist"}]}
ReadyForQuery {"status":"E"}
CommandComplete {"tag":"ROLLBACK"}
ReadyForQuery {"status":"I"}
Expand Down Expand Up @@ -549,7 +549,7 @@ Query {"query": "DECLARE c CURSOR FOR SELECT 1"}
until
ReadyForQuery
----
ErrorResponse {"fields":[{"typ":"C","value":"25P01"},{"typ":"M","value":"DECLARE CURSOR can only be used in transaction blocks"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"25P01"},{"typ":"M","value":"DECLARE CURSOR can only be used in transaction blocks"}]}
ReadyForQuery {"status":"I"}

send
Expand All @@ -564,5 +564,5 @@ ReadyForQuery
----
ParseComplete
BindComplete
ErrorResponse {"fields":[{"typ":"C","value":"25P01"},{"typ":"M","value":"DECLARE CURSOR can only be used in transaction blocks"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"25P01"},{"typ":"M","value":"DECLARE CURSOR can only be used in transaction blocks"}]}
ReadyForQuery {"status":"I"}
4 changes: 2 additions & 2 deletions test/pgtest/desc.pt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Sync
until ignore=ParameterDescription
ReadyForQuery
----
ErrorResponse {"fields":[{"typ":"C","value":"0A000"},{"typ":"M","value":"cached plan must not change result type"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"cached plan must not change result type"}]}
ReadyForQuery {"status":"I"}

send
Expand All @@ -93,7 +93,7 @@ Query {"query": "EXECUTE q"}
until ignore=RowDescription
ReadyForQuery
----
ErrorResponse {"fields":[{"typ":"C","value":"0A000"},{"typ":"M","value":"cached plan must not change result type"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"0A000"},{"typ":"M","value":"cached plan must not change result type"}]}
ReadyForQuery {"status":"I"}

# Changing it back fixes it.
Expand Down
8 changes: 4 additions & 4 deletions test/pgtest/portals.pt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Query {"query": "CLOSE c"}
until
ReadyForQuery
----
ErrorResponse {"fields":[{"typ":"C","value":"34000"},{"typ":"M","value":"cursor \"c\" does not exist"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"34000"},{"typ":"M","value":"cursor \"c\" does not exist"}]}
ReadyForQuery {"status":"I"}

# Verify that portals (cursors) are destroyed on Sync.
Expand Down Expand Up @@ -107,7 +107,7 @@ ReadyForQuery
----
CommandComplete {"tag":"BEGIN"}
CommandComplete {"tag":"DECLARE CURSOR"}
ErrorResponse {"fields":[{"typ":"C","value":"42P03"},{"typ":"M","value":"cursor \"c\" already exists"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"42P03"},{"typ":"M","value":"cursor \"c\" already exists"}]}
ReadyForQuery {"status":"E"}
CommandComplete {"tag":"ROLLBACK"}
ReadyForQuery {"status":"I"}
Expand All @@ -129,7 +129,7 @@ CommandComplete {"tag":"BEGIN"}
CommandComplete {"tag":"DECLARE CURSOR"}
ReadyForQuery {"status":"T"}
ParseComplete
ErrorResponse {"fields":[{"typ":"C","value":"42P03"},{"typ":"M","value":"cursor \"c\" already exists"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"42P03"},{"typ":"M","value":"cursor \"c\" already exists"}]}
ReadyForQuery {"status":"E"}
CommandComplete {"tag":"ROLLBACK"}
ReadyForQuery {"status":"I"}
Expand All @@ -154,7 +154,7 @@ ReadyForQuery {"status":"T"}
ParseComplete
BindComplete
ReadyForQuery {"status":"T"}
ErrorResponse {"fields":[{"typ":"C","value":"42P03"},{"typ":"M","value":"cursor \"c\" already exists"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"42P03"},{"typ":"M","value":"cursor \"c\" already exists"}]}
ReadyForQuery {"status":"E"}
CommandComplete {"tag":"ROLLBACK"}
ReadyForQuery {"status":"I"}
6 changes: 3 additions & 3 deletions test/pgtest/prepare.pt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ReadyForQuery
----
CommandComplete {"tag":"DEALLOCATE ALL"}
ReadyForQuery {"status":"I"}
ErrorResponse {"fields":[{"typ":"C","value":"26000"},{"typ":"M","value":"prepared statement \"a\" does not exist"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"26000"},{"typ":"M","value":"prepared statement \"a\" does not exist"}]}
ReadyForQuery {"status":"I"}

# TOOD(mjibson): Teach scl.rs how to return error codes.
Expand Down Expand Up @@ -41,7 +41,7 @@ ReadyForQuery
----
CommandComplete {"tag":"PREPARE"}
ReadyForQuery {"status":"I"}
ErrorResponse {"fields":[{"typ":"C","value":"42P05"},{"typ":"M","value":"prepared statement \"a\" already exists"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"42P05"},{"typ":"M","value":"prepared statement \"a\" already exists"}]}
ReadyForQuery {"status":"I"}
RowDescription {"fields":[{"name":"?column?"}]}
DataRow {"fields":["1"]}
Expand All @@ -64,7 +64,7 @@ ReadyForQuery {"status":"I"}
until
ReadyForQuery
----
ErrorResponse {"fields":[{"typ":"C","value":"26000"},{"typ":"M","value":"prepared statement \"a\" does not exist"}]}
ErrorResponse {"fields":[{"typ":"S","value":"ERROR"},{"typ":"C","value":"26000"},{"typ":"M","value":"prepared statement \"a\" does not exist"}]}
ReadyForQuery {"status":"I"}

send
Expand Down
4 changes: 2 additions & 2 deletions test/pgtest/transactions.pt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Query {"query": "COMMIT;"}
Query {"query": "ROLLBACK;"}
----

until err_field_typs=SCM
until
ReadyForQuery
ReadyForQuery
ReadyForQuery
Expand Down Expand Up @@ -187,7 +187,7 @@ ReadyForQuery
----
CommandComplete {"tag":"BEGIN"}
ReadyForQuery {"status":"T"}
NoticeResponse {"fields":[{"typ":"C","value":"25001"},{"typ":"M","value":"there is already a transaction in progress"}]}
NoticeResponse {"fields":[{"typ":"S","value":"WARNING"},{"typ":"C","value":"25001"},{"typ":"M","value":"there is already a transaction in progress"}]}
CommandComplete {"tag":"BEGIN"}
ReadyForQuery {"status":"T"}

Expand Down

0 comments on commit e1ae81d

Please sign in to comment.