Skip to content

Commit

Permalink
Use set_notice_processor
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Apr 17, 2023
1 parent bf32bb5 commit 8535a7c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/dexter/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -669,16 +669,19 @@ def with_advisory_lock
end
yield
ensure
with_min_messages("error") do
suppress_messages do
execute("SELECT pg_advisory_unlock($1)", params: [lock_id])
end
end

def with_min_messages(value)
execute("SET client_min_messages = #{quote(value)}")
def suppress_messages
conn.set_notice_processor do |message|
# do nothing
end
yield
ensure
execute("SET client_min_messages = warning")
# clear notice processor
conn.set_notice_processor
end

def index_exists?(index)
Expand Down

0 comments on commit 8535a7c

Please sign in to comment.