Skip to content

Commit e65d7ea

Browse files
authored
Merge branch 'main' into fix/postgres-unreserve-fulltext
2 parents 1e2df8f + ab8e6ad commit e65d7ea

6 files changed

Lines changed: 38 additions & 1 deletion

File tree

src/ast/ddl.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2881,6 +2881,10 @@ pub struct CreateIndex {
28812881
pub unique: bool,
28822882
/// whether the index is created concurrently
28832883
pub concurrently: bool,
2884+
/// whether the index is created asynchronously ([DSQL]).
2885+
///
2886+
/// [DSQL]: https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-create-index-async.html
2887+
pub r#async: bool,
28842888
/// IF NOT EXISTS clause
28852889
pub if_not_exists: bool,
28862890
/// INCLUDE clause: <https://www.postgresql.org/docs/current/sql-createindex.html>
@@ -2906,13 +2910,14 @@ impl fmt::Display for CreateIndex {
29062910
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29072911
write!(
29082912
f,
2909-
"CREATE {unique}INDEX {concurrently}{if_not_exists}",
2913+
"CREATE {unique}INDEX {concurrently}{async_}{if_not_exists}",
29102914
unique = if self.unique { "UNIQUE " } else { "" },
29112915
concurrently = if self.concurrently {
29122916
"CONCURRENTLY "
29132917
} else {
29142918
""
29152919
},
2920+
async_ = if self.r#async { "ASYNC " } else { "" },
29162921
if_not_exists = if self.if_not_exists {
29172922
"IF NOT EXISTS "
29182923
} else {

src/ast/spans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ impl Spanned for CreateIndex {
720720
columns,
721721
unique: _, // bool
722722
concurrently: _, // bool
723+
r#async: _, // bool
723724
if_not_exists: _, // bool
724725
include,
725726
nulls_distinct: _, // bool

src/keywords.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ define_keywords!(
133133
ASSERT,
134134
ASSIGNMENT,
135135
ASYMMETRIC,
136+
ASYNC,
136137
AT,
137138
ATOMIC,
138139
ATTACH,

src/parser/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8299,6 +8299,7 @@ impl<'a> Parser<'a> {
82998299
/// Parse a `CREATE INDEX` statement.
83008300
pub fn parse_create_index(&mut self, unique: bool) -> Result<CreateIndex, ParserError> {
83018301
let concurrently = self.parse_keyword(Keyword::CONCURRENTLY);
8302+
let r#async = self.parse_keyword(Keyword::ASYNC);
83028303
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
83038304

83048305
let mut using = None;
@@ -8378,6 +8379,7 @@ impl<'a> Parser<'a> {
83788379
columns,
83798380
unique,
83808381
concurrently,
8382+
r#async,
83818383
if_not_exists,
83828384
include,
83838385
nulls_distinct,

tests/sqlparser_common.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9632,6 +9632,7 @@ fn test_create_index_with_using_function() {
96329632
columns,
96339633
unique,
96349634
concurrently,
9635+
r#async,
96359636
if_not_exists,
96369637
include,
96379638
nulls_distinct: None,
@@ -9646,6 +9647,7 @@ fn test_create_index_with_using_function() {
96469647
assert_eq!(indexed_columns, columns);
96479648
assert!(unique);
96489649
assert!(!concurrently);
9650+
assert!(!r#async);
96499651
assert!(if_not_exists);
96509652
assert!(include.is_empty());
96519653
assert!(with.is_empty());
@@ -9687,6 +9689,7 @@ fn test_create_index_with_with_clause() {
96879689
columns,
96889690
unique,
96899691
concurrently,
9692+
r#async,
96909693
if_not_exists,
96919694
include,
96929695
nulls_distinct: None,
@@ -9700,6 +9703,7 @@ fn test_create_index_with_with_clause() {
97009703
pretty_assertions::assert_eq!(indexed_columns, columns);
97019704
assert!(unique);
97029705
assert!(!concurrently);
9706+
assert!(!r#async);
97039707
assert!(!if_not_exists);
97049708
assert!(include.is_empty());
97059709
pretty_assertions::assert_eq!(with_parameters, with);
@@ -9710,6 +9714,12 @@ fn test_create_index_with_with_clause() {
97109714
}
97119715
}
97129716

9717+
#[test]
9718+
fn parse_create_index_async() {
9719+
verified_stmt("CREATE INDEX ASYNC my_index ON my_table(col1)");
9720+
verified_stmt("CREATE UNIQUE INDEX ASYNC my_index ON my_table(col1)");
9721+
}
9722+
97139723
#[test]
97149724
fn parse_drop_index() {
97159725
let sql = "DROP INDEX idx_a";

tests/sqlparser_postgres.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,6 +2938,7 @@ fn parse_create_index() {
29382938
columns,
29392939
unique,
29402940
concurrently,
2941+
r#async,
29412942
if_not_exists,
29422943
nulls_distinct: None,
29432944
include,
@@ -2951,6 +2952,7 @@ fn parse_create_index() {
29512952
assert_eq!(None, using);
29522953
assert!(!unique);
29532954
assert!(!concurrently);
2955+
assert!(!r#async);
29542956
assert!(if_not_exists);
29552957
assert_eq_vec(&["col1", "col2"], &columns);
29562958
assert!(include.is_empty());
@@ -2973,6 +2975,7 @@ fn parse_create_anonymous_index() {
29732975
columns,
29742976
unique,
29752977
concurrently,
2978+
r#async,
29762979
if_not_exists,
29772980
include,
29782981
nulls_distinct: None,
@@ -2986,6 +2989,7 @@ fn parse_create_anonymous_index() {
29862989
assert_eq!(None, using);
29872990
assert!(!unique);
29882991
assert!(!concurrently);
2992+
assert!(!r#async);
29892993
assert!(!if_not_exists);
29902994
assert_eq_vec(&["col1", "col2"], &columns);
29912995
assert!(include.is_empty());
@@ -3091,6 +3095,7 @@ fn parse_create_indices_with_operator_classes() {
30913095
columns,
30923096
unique: false,
30933097
concurrently: false,
3098+
r#async: false,
30943099
if_not_exists: false,
30953100
include,
30963101
nulls_distinct: None,
@@ -3119,6 +3124,7 @@ fn parse_create_indices_with_operator_classes() {
31193124
columns,
31203125
unique: false,
31213126
concurrently: false,
3127+
r#async: false,
31223128
if_not_exists: false,
31233129
include,
31243130
nulls_distinct: None,
@@ -3202,6 +3208,7 @@ fn parse_create_bloom() {
32023208
columns,
32033209
unique: false,
32043210
concurrently: false,
3211+
r#async: false,
32053212
if_not_exists: false,
32063213
include,
32073214
nulls_distinct: None,
@@ -3258,6 +3265,7 @@ fn parse_create_brin() {
32583265
columns,
32593266
unique: false,
32603267
concurrently: false,
3268+
r#async: false,
32613269
if_not_exists: false,
32623270
include,
32633271
nulls_distinct: None,
@@ -3325,6 +3333,7 @@ fn parse_create_index_concurrently() {
33253333
columns,
33263334
unique,
33273335
concurrently,
3336+
r#async,
33283337
if_not_exists,
33293338
include,
33303339
nulls_distinct: None,
@@ -3338,6 +3347,7 @@ fn parse_create_index_concurrently() {
33383347
assert_eq!(None, using);
33393348
assert!(!unique);
33403349
assert!(concurrently);
3350+
assert!(!r#async);
33413351
assert!(if_not_exists);
33423352
assert_eq_vec(&["col1", "col2"], &columns);
33433353
assert!(include.is_empty());
@@ -3360,6 +3370,7 @@ fn parse_create_index_with_predicate() {
33603370
columns,
33613371
unique,
33623372
concurrently,
3373+
r#async,
33633374
if_not_exists,
33643375
include,
33653376
nulls_distinct: None,
@@ -3373,6 +3384,7 @@ fn parse_create_index_with_predicate() {
33733384
assert_eq!(None, using);
33743385
assert!(!unique);
33753386
assert!(!concurrently);
3387+
assert!(!r#async);
33763388
assert!(if_not_exists);
33773389
assert_eq_vec(&["col1", "col2"], &columns);
33783390
assert!(include.is_empty());
@@ -3395,6 +3407,7 @@ fn parse_create_index_with_include() {
33953407
columns,
33963408
unique,
33973409
concurrently,
3410+
r#async,
33983411
if_not_exists,
33993412
include,
34003413
nulls_distinct: None,
@@ -3408,6 +3421,7 @@ fn parse_create_index_with_include() {
34083421
assert_eq!(None, using);
34093422
assert!(!unique);
34103423
assert!(!concurrently);
3424+
assert!(!r#async);
34113425
assert!(if_not_exists);
34123426
assert_eq_vec(&["col1", "col2"], &columns);
34133427
assert_eq_vec(&["col3", "col4"], &include);
@@ -3430,6 +3444,7 @@ fn parse_create_index_with_nulls_distinct() {
34303444
columns,
34313445
unique,
34323446
concurrently,
3447+
r#async,
34333448
if_not_exists,
34343449
include,
34353450
nulls_distinct: Some(nulls_distinct),
@@ -3443,6 +3458,7 @@ fn parse_create_index_with_nulls_distinct() {
34433458
assert_eq!(None, using);
34443459
assert!(!unique);
34453460
assert!(!concurrently);
3461+
assert!(!r#async);
34463462
assert!(if_not_exists);
34473463
assert_eq_vec(&["col1", "col2"], &columns);
34483464
assert!(include.is_empty());
@@ -3463,6 +3479,7 @@ fn parse_create_index_with_nulls_distinct() {
34633479
columns,
34643480
unique,
34653481
concurrently,
3482+
r#async,
34663483
if_not_exists,
34673484
include,
34683485
nulls_distinct: Some(nulls_distinct),
@@ -3476,6 +3493,7 @@ fn parse_create_index_with_nulls_distinct() {
34763493
assert_eq!(None, using);
34773494
assert!(!unique);
34783495
assert!(!concurrently);
3496+
assert!(!r#async);
34793497
assert!(if_not_exists);
34803498
assert_eq_vec(&["col1", "col2"], &columns);
34813499
assert!(include.is_empty());

0 commit comments

Comments
 (0)