Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/actions/setup-postgres/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,20 @@ runs:
export PATH="$(pg_config --bindir):$PATH"

# Install cargo-pgrx (version must match pglinter's pgrx dependency).
# pgrx 0.18.0 requires Rust 1.89+, while this project currently builds with 1.88.
rustup toolchain install 1.89.0 --profile minimal
cargo +1.89.0 install cargo-pgrx --version 0.18.0 --locked
rustup toolchain install 1.90.0 --profile minimal
cargo +1.90.0 install cargo-pgrx --version 0.18.0 --locked

# Ensure we build the extension for the host architecture (macOS-14 runners are arm64).
# Release workflow also cross-compiles x86_64, but the local PostgreSQL installation is arm64.
HOST_TARGET=$(rustc +1.89.0 -vV | sed -n 's/^host: //p')
HOST_TARGET=$(rustc +1.90.0 -vV | sed -n 's/^host: //p')
echo "Host target: ${HOST_TARGET}"

# Determine postgres version for pgrx init
PG_VERSION=$(pg_config --version | grep -oE '[0-9]+' | head -1)
echo "PostgreSQL version: $PG_VERSION"

# Initialize pgrx for the installed PostgreSQL version
cargo +1.89.0 pgrx init --pg${PG_VERSION} $(which pg_config)
cargo +1.90.0 pgrx init --pg${PG_VERSION} $(which pg_config)

# Clone and build pglinter (requires v1.1.0+ for get_violations API + rule_messages table)
cd /tmp
Expand All @@ -93,7 +92,7 @@ runs:
# Install using pgrx
# Ensure macOS linker allows unresolved PostgreSQL symbols at link time.
export RUSTFLAGS="${RUSTFLAGS:-} -C link-arg=-Wl,-undefined,dynamic_lookup"
cargo +1.89.0 pgrx install --pg-config $(which pg_config) --release --target "${HOST_TARGET}"
cargo +1.90.0 pgrx install --pg-config $(which pg_config) --release --target "${HOST_TARGET}"

# Verify installation
echo "Extension control files:"
Expand Down
31 changes: 18 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ homepage = "https://supabase.com/"
keywords = ["linter", "typechecker", "postgres", "language-server"]
license = "MIT"
repository = "https://github.com/supabase-community/postgres-language-server"
rust-version = "1.86.0"
rust-version = "1.90.0"

[workspace.dependencies]
# supporting crates unrelated to postgres
Expand Down Expand Up @@ -53,7 +53,7 @@ tokio = { version = "1.40.0", features = ["full"] }
tracing = { version = "0.1.40", default-features = false, features = ["std"] }
tracing-bunyan-formatter = { version = "0.3.10 " }
tracing-subscriber = "0.3.18"
tree-sitter = "0.25.9"
tree-sitter = "0.27.0"
unicode-width = "0.1.12"

# postgres specific crates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,21 @@ impl LinterRule for AvoidAddingExclusionConstraint {
for cmd in &stmt.cmds {
if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node
&& cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddConstraint
{
if let Some(pgls_query::NodeEnum::Constraint(constraint)) =
&& let Some(pgls_query::NodeEnum::Constraint(constraint)) =
cmd.def.as_ref().and_then(|d| d.node.as_ref())
{
if constraint.contype()
== pgls_query::protobuf::ConstrType::ConstrExclusion
{
diagnostics.push(exclusion_diagnostic());
}
}
&& constraint.contype() == pgls_query::protobuf::ConstrType::ConstrExclusion
{
diagnostics.push(exclusion_diagnostic());
}
}
}
pgls_query::NodeEnum::CreateStmt(stmt) => {
for constraint_node in &stmt.constraints {
if let Some(pgls_query::NodeEnum::Constraint(constraint)) =
&constraint_node.node
&& constraint.contype() == pgls_query::protobuf::ConstrType::ConstrExclusion
{
if constraint.contype() == pgls_query::protobuf::ConstrType::ConstrExclusion
{
diagnostics.push(exclusion_diagnostic());
}
diagnostics.push(exclusion_diagnostic());
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/pgls_analyser/src/lint/safety/ban_vacuum_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ impl LinterRule for BanVacuumFull {
fn run(ctx: &LinterRuleContext<Self>) -> Vec<LinterDiagnostic> {
let mut diagnostics = vec![];

if let pgls_query::NodeEnum::VacuumStmt(stmt) = &ctx.stmt() {
if is_vacuum_full(stmt) {
diagnostics.push(
if let pgls_query::NodeEnum::VacuumStmt(stmt) = &ctx.stmt()
&& is_vacuum_full(stmt)
{
diagnostics.push(
LinterDiagnostic::new(
rule_category!(),
None,
Expand All @@ -54,7 +55,6 @@ impl LinterRule for BanVacuumFull {
"Use regular VACUUM or pg_repack for online table maintenance without blocking reads and writes.",
),
);
}
}

diagnostics
Expand Down
5 changes: 2 additions & 3 deletions crates/pgls_analyser/src/lint/safety/changing_column_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ impl LinterRule for ChangingColumnType {
{
if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) =
cmd.def.as_ref().and_then(|d| d.node.as_ref())
&& is_safe_type_widening(col_def)
{
if is_safe_type_widening(col_def) {
continue;
}
continue;
}

diagnostics.push(LinterDiagnostic::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ impl LinterRule for RequireConcurrentReindex {
fn run(ctx: &LinterRuleContext<Self>) -> Vec<LinterDiagnostic> {
let mut diagnostics = vec![];

if let pgls_query::NodeEnum::ReindexStmt(stmt) = &ctx.stmt() {
if !is_reindex_concurrent(stmt) {
diagnostics.push(
if let pgls_query::NodeEnum::ReindexStmt(stmt) = &ctx.stmt()
&& !is_reindex_concurrent(stmt)
{
diagnostics.push(
LinterDiagnostic::new(
rule_category!(),
None,
Expand All @@ -55,7 +56,6 @@ impl LinterRule for RequireConcurrentReindex {
"Use REINDEX CONCURRENTLY to rebuild the index without blocking reads and writes.",
),
);
}
}

diagnostics
Expand Down
20 changes: 9 additions & 11 deletions crates/pgls_analyser/src/linter_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,18 +456,16 @@ impl TransactionState {
for cmd in &alter_stmt.cmds {
if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node
&& cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddConstraint
{
if let Some(pgls_query::NodeEnum::Constraint(constraint)) =
&& let Some(pgls_query::NodeEnum::Constraint(constraint)) =
cmd.def.as_ref().and_then(|d| d.node.as_ref())
{
if constraint.skip_validation && !constraint.conname.is_empty() {
self.not_valid_constraints.push((
table_schema.clone(),
table_name.clone(),
constraint.conname.clone(),
));
}
}
&& constraint.skip_validation
&& !constraint.conname.is_empty()
{
self.not_valid_constraints.push((
table_schema.clone(),
table_name.clone(),
constraint.conname.clone(),
));
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion crates/pgls_completions/src/providers/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,11 @@ pub fn complete_keywords<'a>(
}

let keywords_to_try = ALL_KEYWORDS.iter().filter(|kw| {
ctx.tree.root_node().has_error() || ctx.possible_keywords_at_position.contains(&kw.name)
ctx.tree.root_node().has_error()
|| ctx
.possible_keywords_at_position
.iter()
.any(|name| name == kw.name)
});

for kw in keywords_to_try {
Expand Down
Loading