Skip to content

Commit 2be4db3

Browse files
committedDec 18, 2023
feat: support CreateTableSpaceStmt
1 parent 7e58c4d commit 2be4db3

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
 

‎crates/codegen/src/get_node_properties.rs

+11
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,17 @@ fn custom_handlers(node: &Node) -> TokenStream {
668668
_ => panic!("Unknown IndexElem {:#?}", n.nulls_ordering()),
669669
}
670670
},
671+
"CreateTableSpaceStmt" => quote! {
672+
tokens.push(TokenProperty::from(Token::Create));
673+
tokens.push(TokenProperty::from(Token::Tablespace));
674+
tokens.push(TokenProperty::from(Token::Location));
675+
if n.owner.is_some() {
676+
tokens.push(TokenProperty::from(Token::Owner));
677+
}
678+
if n.options.len() > 0 {
679+
tokens.push(TokenProperty::from(Token::With));
680+
}
681+
},
671682
_ => quote! {},
672683
}
673684
}

‎crates/parser/src/codegen.rs

+17
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,21 @@ mod tests {
239239
],
240240
)
241241
}
242+
243+
#[test]
244+
fn test_create_tablespace() {
245+
test_get_node_properties(
246+
"create tablespace x owner a location 'b' with (seq_page_cost=3);",
247+
SyntaxKind::CreateTableSpaceStmt,
248+
vec![
249+
TokenProperty::from(SyntaxKind::Create),
250+
TokenProperty::from(SyntaxKind::Tablespace),
251+
TokenProperty::from(SyntaxKind::Location),
252+
TokenProperty::from(SyntaxKind::Owner),
253+
TokenProperty::from(SyntaxKind::With),
254+
TokenProperty::from("x".to_string()),
255+
TokenProperty::from("b".to_string()),
256+
],
257+
)
258+
}
242259
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE TABLESPACE x LOCATION 'a';
2+
CREATE TABLESPACE x OWNER a LOCATION 'b' WITH (random_page_cost=42, seq_page_cost=3);

0 commit comments

Comments
 (0)
Please sign in to comment.