@@ -947,6 +947,138 @@ fn parse_alter_collation() {
947947 ) ;
948948}
949949
950+ #[ test]
951+ fn parse_create_text_search_configuration ( ) {
952+ assert_eq ! (
953+ pg( ) . verified_stmt(
954+ "CREATE TEXT SEARCH CONFIGURATION public.myconfig (PARSER = myparser)"
955+ ) ,
956+ Statement :: CreateTextSearchConfiguration ( CreateTextSearchConfiguration {
957+ name: ObjectName :: from( vec![ Ident :: new( "public" ) , Ident :: new( "myconfig" ) ] ) ,
958+ options: vec![ SqlOption :: KeyValue {
959+ key: Ident :: new( "PARSER" ) ,
960+ value: Expr :: Identifier ( Ident :: new( "myparser" ) ) ,
961+ } ] ,
962+ } )
963+ ) ;
964+
965+ assert_eq ! (
966+ pg( ) . parse_sql_statements( "CREATE TEXT SEARCH CONFIGURATION myconfig PARSER = pg_catalog.default" ) ,
967+ Err ( ParserError :: ParserError (
968+ "Expected: (, found: PARSER" . to_string( )
969+ ) )
970+ ) ;
971+ }
972+
973+ #[ test]
974+ fn parse_create_text_search_dictionary ( ) {
975+ assert_eq ! (
976+ pg( ) . verified_stmt(
977+ "CREATE TEXT SEARCH DICTIONARY public.mydict (TEMPLATE = snowball, language = english)"
978+ ) ,
979+ Statement :: CreateTextSearchDictionary ( CreateTextSearchDictionary {
980+ name: ObjectName :: from( vec![ Ident :: new( "public" ) , Ident :: new( "mydict" ) ] ) ,
981+ options: vec![
982+ SqlOption :: KeyValue {
983+ key: Ident :: new( "TEMPLATE" ) ,
984+ value: Expr :: Identifier ( Ident :: new( "snowball" ) ) ,
985+ } ,
986+ SqlOption :: KeyValue {
987+ key: Ident :: new( "language" ) ,
988+ value: Expr :: Identifier ( Ident :: new( "english" ) ) ,
989+ } ,
990+ ] ,
991+ } )
992+ ) ;
993+
994+ assert_eq ! (
995+ pg( ) . parse_sql_statements( "CREATE TEXT SEARCH DICTIONARY mydict" ) ,
996+ Err ( ParserError :: ParserError (
997+ "Expected: (, found: EOF" . to_string( )
998+ ) )
999+ ) ;
1000+ }
1001+
1002+ #[ test]
1003+ fn parse_create_text_search_parser ( ) {
1004+ assert_eq ! (
1005+ pg( ) . verified_stmt(
1006+ "CREATE TEXT SEARCH PARSER myparser (START = prsd_start, GETTOKEN = prsd_nexttoken, END = prsd_end, LEXTYPES = prsd_lextype, HEADLINE = prsd_headline)"
1007+ ) ,
1008+ Statement :: CreateTextSearchParser ( CreateTextSearchParser {
1009+ name: ObjectName :: from( vec![ Ident :: new( "myparser" ) ] ) ,
1010+ options: vec![
1011+ SqlOption :: KeyValue {
1012+ key: Ident :: new( "START" ) ,
1013+ value: Expr :: Identifier ( Ident :: new( "prsd_start" ) ) ,
1014+ } ,
1015+ SqlOption :: KeyValue {
1016+ key: Ident :: new( "GETTOKEN" ) ,
1017+ value: Expr :: Identifier ( Ident :: new( "prsd_nexttoken" ) ) ,
1018+ } ,
1019+ SqlOption :: KeyValue {
1020+ key: Ident :: new( "END" ) ,
1021+ value: Expr :: Identifier ( Ident :: new( "prsd_end" ) ) ,
1022+ } ,
1023+ SqlOption :: KeyValue {
1024+ key: Ident :: new( "LEXTYPES" ) ,
1025+ value: Expr :: Identifier ( Ident :: new( "prsd_lextype" ) ) ,
1026+ } ,
1027+ SqlOption :: KeyValue {
1028+ key: Ident :: new( "HEADLINE" ) ,
1029+ value: Expr :: Identifier ( Ident :: new( "prsd_headline" ) ) ,
1030+ } ,
1031+ ] ,
1032+ } )
1033+ ) ;
1034+
1035+ assert_eq ! (
1036+ pg( ) . parse_sql_statements( "CREATE TEXT SEARCH PARSER myparser START = prsd_start" ) ,
1037+ Err ( ParserError :: ParserError (
1038+ "Expected: (, found: START" . to_string( )
1039+ ) )
1040+ ) ;
1041+ }
1042+
1043+ #[ test]
1044+ fn parse_create_text_search_template ( ) {
1045+ assert_eq ! (
1046+ pg( ) . verified_stmt(
1047+ "CREATE TEXT SEARCH TEMPLATE mytemplate (INIT = dinit, LEXIZE = dlexize)"
1048+ ) ,
1049+ Statement :: CreateTextSearchTemplate ( CreateTextSearchTemplate {
1050+ name: ObjectName :: from( vec![ Ident :: new( "mytemplate" ) ] ) ,
1051+ options: vec![
1052+ SqlOption :: KeyValue {
1053+ key: Ident :: new( "INIT" ) ,
1054+ value: Expr :: Identifier ( Ident :: new( "dinit" ) ) ,
1055+ } ,
1056+ SqlOption :: KeyValue {
1057+ key: Ident :: new( "LEXIZE" ) ,
1058+ value: Expr :: Identifier ( Ident :: new( "dlexize" ) ) ,
1059+ } ,
1060+ ] ,
1061+ } )
1062+ ) ;
1063+
1064+ assert_eq ! (
1065+ pg( ) . parse_sql_statements( "CREATE TEXT SEARCH TEMPLATE mytemplate LEXIZE = dlexize" ) ,
1066+ Err ( ParserError :: ParserError (
1067+ "Expected: (, found: LEXIZE" . to_string( )
1068+ ) )
1069+ ) ;
1070+ }
1071+
1072+ #[ test]
1073+ fn parse_create_text_search_invalid_subtype ( ) {
1074+ assert_eq ! (
1075+ pg( ) . parse_sql_statements( "CREATE TEXT SEARCH UNKNOWN myname (option = value)" ) ,
1076+ Err ( ParserError :: ParserError (
1077+ "Expected: CONFIGURATION, DICTIONARY, PARSER, or TEMPLATE after CREATE TEXT SEARCH, found: UNKNOWN" . to_string( )
1078+ ) )
1079+ ) ;
1080+ }
1081+
9501082#[ test]
9511083fn parse_drop_and_comment_collation_ast ( ) {
9521084 assert_eq ! (
0 commit comments