@@ -23,6 +23,8 @@ public class CreateIndex implements Statement {
2323 private List <String > tailParameters ;
2424 private boolean indexTypeBeforeOn = false ;
2525 private boolean usingIfNotExists = false ;
26+ private boolean concurrently ;
27+ private boolean only ;
2628
2729 public boolean isIndexTypeBeforeOn () {
2830 return indexTypeBeforeOn ;
@@ -41,6 +43,22 @@ public CreateIndex setUsingIfNotExists(boolean usingIfNotExists) {
4143 return this ;
4244 }
4345
46+ public boolean isConcurrently () {
47+ return concurrently ;
48+ }
49+
50+ public void setConcurrently (boolean concurrently ) {
51+ this .concurrently = concurrently ;
52+ }
53+
54+ public boolean isOnly () {
55+ return only ;
56+ }
57+
58+ public void setOnly (boolean only ) {
59+ this .only = only ;
60+ }
61+
4462 @ Override
4563 public <T , S > T accept (StatementVisitor <T > statementVisitor , S context ) {
4664 return statementVisitor .visit (this , context );
@@ -82,17 +100,24 @@ public String toString() {
82100 }
83101
84102 buffer .append ("INDEX " );
103+ if (concurrently ) {
104+ buffer .append ("CONCURRENTLY " );
105+ }
85106 if (usingIfNotExists ) {
86107 buffer .append ("IF NOT EXISTS " );
87108 }
88- buffer .append (index .getName ());
109+ if (index .getName () != null ) {
110+ buffer .append (index .getName ()).append (" " );
111+ }
89112
90113 if (index .getUsing () != null && isIndexTypeBeforeOn ()) {
91- buffer .append (" USING " );
92- buffer .append (index .getUsing ());
114+ buffer .append ("USING " ).append (index .getUsing ()).append (" " );
93115 }
94116
95- buffer .append (" ON " );
117+ buffer .append ("ON " );
118+ if (only ) {
119+ buffer .append ("ONLY " );
120+ }
96121 buffer .append (table .getFullyQualifiedName ());
97122
98123 if (index .getUsing () != null && !isIndexTypeBeforeOn ()) {
@@ -134,4 +159,14 @@ public CreateIndex withTailParameters(List<String> tailParameters) {
134159 this .setTailParameters (tailParameters );
135160 return this ;
136161 }
162+
163+ public CreateIndex withConcurrently (boolean concurrently ) {
164+ setConcurrently (concurrently );
165+ return this ;
166+ }
167+
168+ public CreateIndex withOnly (boolean only ) {
169+ setOnly (only );
170+ return this ;
171+ }
137172}
0 commit comments