Skip to content

Commit fc2c16d

Browse files
committed
Fix indentation after RAISE EXCEPTION ... USING. Thanks to Ray Ng for the report.
1 parent 9cba19e commit fc2c16d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/pgFormatter/Beautify.pm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,10 +2974,6 @@ sub beautify {
29742974
( uc($token) eq 'ON' and uc( $self->_next_token() ) eq 'CONFLICT' )
29752975
)
29762976
{
2977-
#if (uc($last) ne 'RAISE' and $token =~ /^EXCEPTION$/i)
2978-
#{
2979-
#$self->{ '_is_in_exception' } = 1;
2980-
#}
29812977
if ( $self->{'format_type'}
29822978
and uc($token) eq 'GROUP'
29832979
and uc( $self->_next_token() ) eq 'BY' )
@@ -3462,6 +3458,12 @@ sub beautify {
34623458
if ( !$self->{'_is_in_join'} );
34633459
}
34643460
$self->_add_token($token);
3461+
3462+
if (defined $self->_next_token and uc($self->_next_token) eq 'ERRCODE') {
3463+
$self->_set_level( $self->_pop_level( $token, $last ),
3464+
$token, $last );
3465+
}
3466+
34653467
$self->{'_is_in_using'} = 1;
34663468
$self->{'_is_in_policy'}++
34673469
if ( !$self->{'_is_in_from'}

t/test-files/expected/ex77.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ BEGIN
2424
IF i IS NULL THEN
2525
RAISE EXCEPTION 'i is null'
2626
USING errcode = 'invalid_parameter_value';
27-
END IF;
28-
RETURN i + 1;
27+
END IF;
28+
RETURN i + 1;
2929
END;
3030
$$
3131
LANGUAGE plpgsql;

0 commit comments

Comments
 (0)