From 5d3780f25df53978f4d3289c4a02bc5ecd2f3cb3 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 25 Aug 2025 11:12:41 +0300 Subject: [PATCH] core/translate: Add `CREATE INDEX IF NOT EXISTS` support Fixes #2263 --- core/translate/index.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/translate/index.rs b/core/translate/index.rs index ef574f6af..7d332f0d2 100644 --- a/core/translate/index.rs +++ b/core/translate/index.rs @@ -44,6 +44,10 @@ pub fn translate_create_index( // Check if the index is being created on a valid btree table and // the name is globally unique in the schema. if !schema.is_unique_idx_name(&idx_name) { + // If IF NOT EXISTS is specified, silently return without error + if unique_if_not_exists.1 { + return Ok(program); + } crate::bail_parse_error!("Error: index with name '{idx_name}' already exists."); } let Some(tbl) = schema.tables.get(&tbl_name) else {