Skip to content

Commit 87549d4

Browse files
fix: execute statement reliable
1 parent 69b21e6 commit 87549d4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

crates/pgt_lsp/src/handlers/code_actions.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::sync::atomic::Ordering;
2+
13
use crate::{adapters::get_cursor_position, session::Session};
24
use anyhow::{Result, anyhow};
35
use tower_lsp::lsp_types::{
@@ -91,6 +93,8 @@ pub async fn execute_command(
9193
path,
9294
})?;
9395

96+
std::sync::atomic::fence(Ordering::SeqCst);
97+
9498
/*
9599
* Updating all diagnostics: the changes caused by the statement execution
96100
* might affect many files.

crates/pgt_typecheck/src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ pub async fn check_sql(params: TypecheckParams<'_>) -> Option<TypecheckDiagnosti
4242
return None;
4343
}
4444

45-
let res = params.conn.prepare(params.sql).await;
45+
let mut conn = match params.conn.acquire().await {
46+
Ok(c) => c,
47+
Err(_) => return None,
48+
};
49+
50+
conn.close_on_drop();
51+
52+
let res = conn.prepare(params.sql).await;
4653

4754
match res {
4855
Ok(_) => None,

0 commit comments

Comments
 (0)