1 module hunt.sql.ast.SQLPartition; 2 3 import hunt.sql.ast.SQLDataType; 4 import hunt.sql.ast.SQLObjectImpl; 5 import hunt.sql.ast.SQLExpr; 6 import hunt.sql.ast.SQLName; 7 import hunt.sql.ast.SQLSubPartition; 8 import hunt.sql.ast.SQLPartitionValue; 9 import hunt.sql.ast.SQLObject; 10 import hunt.sql.visitor.SQLASTVisitor; 11 12 13 import hunt.collection; 14 import hunt.Integer; 15 16 public interface OracleSegmentAttributes : SQLObject { 17 18 SQLName getTablespace(); 19 void setTablespace(SQLName name); 20 21 bool getCompress(); 22 23 void setCompress(bool compress); 24 25 Integer getCompressLevel(); 26 27 void setCompressLevel(Integer compressLevel); 28 29 Integer getInitrans(); 30 void setInitrans(Integer initrans); 31 32 Integer getMaxtrans(); 33 void setMaxtrans(Integer maxtrans); 34 35 Integer getPctincrease(); 36 void setPctincrease(Integer pctincrease); 37 38 Integer getPctused(); 39 void setPctused(Integer pctused); 40 41 Integer getPctfree(); 42 void setPctfree(Integer ptcfree); 43 44 bool getLogging(); 45 void setLogging(bool logging); 46 47 SQLObject getStorage(); 48 void setStorage(SQLObject storage); 49 50 bool isCompressForOltp(); 51 52 void setCompressForOltp(bool compressForOltp); 53 } 54 55 public abstract class OracleSegmentAttributesImpl : SQLObjectImpl , OracleSegmentAttributes { 56 private Integer pctfree; 57 private Integer pctused; 58 private Integer initrans; 59 60 private Integer maxtrans; 61 private Integer pctincrease; 62 private Integer freeLists; 63 private bool compress; 64 private Integer compressLevel; 65 private bool compressForOltp; 66 private Integer pctthreshold; 67 68 private bool logging; 69 70 protected SQLName tablespace; 71 protected SQLObject storage; 72 73 public SQLName getTablespace() { 74 return tablespace; 75 } 76 77 public void setTablespace(SQLName tablespace) { 78 if (tablespace !is null) { 79 tablespace.setParent(this); 80 } 81 this.tablespace = tablespace; 82 } 83 84 public bool getCompress() { 85 return compress; 86 } 87 88 public void setCompress(bool compress) { 89 this.compress = compress; 90 } 91 92 public Integer getCompressLevel() { 93 return compressLevel; 94 } 95 96 public void setCompressLevel(Integer compressLevel) { 97 this.compressLevel = compressLevel; 98 } 99 100 public Integer getPctthreshold() { 101 return pctthreshold; 102 } 103 104 public void setPctthreshold(Integer pctthreshold) { 105 this.pctthreshold = pctthreshold; 106 } 107 108 public Integer getPctfree() { 109 return pctfree; 110 } 111 112 public void setPctfree(Integer ptcfree) { 113 this.pctfree = ptcfree; 114 } 115 116 public Integer getPctused() { 117 return pctused; 118 } 119 120 public void setPctused(Integer ptcused) { 121 this.pctused = ptcused; 122 } 123 124 public Integer getInitrans() { 125 return initrans; 126 } 127 128 public void setInitrans(Integer initrans) { 129 this.initrans = initrans; 130 } 131 132 public Integer getMaxtrans() { 133 return maxtrans; 134 } 135 136 public void setMaxtrans(Integer maxtrans) { 137 this.maxtrans = maxtrans; 138 } 139 140 public Integer getPctincrease() { 141 return pctincrease; 142 } 143 144 public void setPctincrease(Integer pctincrease) { 145 this.pctincrease = pctincrease; 146 } 147 148 public Integer getFreeLists() { 149 return freeLists; 150 } 151 152 public void setFreeLists(Integer freeLists) { 153 this.freeLists = freeLists; 154 } 155 156 public bool getLogging() { 157 return logging; 158 } 159 160 public void setLogging(bool logging) { 161 this.logging = logging; 162 } 163 164 public SQLObject getStorage() { 165 return storage; 166 } 167 168 public void setStorage(SQLObject storage) { 169 this.storage = storage; 170 } 171 172 public bool isCompressForOltp() { 173 return compressForOltp; 174 } 175 176 public void setCompressForOltp(bool compressForOltp) { 177 this.compressForOltp = compressForOltp; 178 } 179 180 public void cloneTo(OracleSegmentAttributesImpl x) { 181 x.pctfree = pctfree; 182 x.pctused = pctused; 183 x.initrans = initrans; 184 185 x.maxtrans = maxtrans; 186 x.pctincrease = pctincrease; 187 x.freeLists = freeLists; 188 x.compress = compress; 189 x.compressLevel = compressLevel; 190 x.compressForOltp = compressForOltp; 191 x.pctthreshold = pctthreshold; 192 193 x.logging = logging; 194 195 if (tablespace !is null) { 196 x.setTablespace(tablespace.clone()); 197 } 198 199 if (storage !is null) { 200 x.setStorage(storage.clone()); 201 } 202 } 203 } 204 205 public class SQLPartition : OracleSegmentAttributesImpl // @gxc 206 { 207 208 protected SQLName name; 209 210 protected SQLExpr subPartitionsCount; 211 212 protected List!SQLSubPartition subPartitions; 213 214 protected SQLPartitionValue values; 215 216 // for mysql 217 protected SQLExpr dataDirectory; 218 protected SQLExpr indexDirectory; 219 protected SQLExpr maxRows; 220 protected SQLExpr minRows; 221 protected SQLExpr engine; 222 protected SQLExpr comment; 223 224 // for oracle 225 protected bool segmentCreationImmediate; 226 protected bool segmentCreationDeferred; 227 228 private SQLObject lobStorage; 229 230 this() 231 { 232 subPartitions = new ArrayList!SQLSubPartition(); 233 } 234 235 // override public SQLName getTablespace() { 236 // return super.getTablespace(); 237 // } 238 239 public SQLName getName() { 240 return name; 241 } 242 243 public void setName(SQLName name) { 244 if (name !is null) { 245 name.setParent(this); 246 } 247 this.name = name; 248 } 249 250 public SQLExpr getSubPartitionsCount() { 251 return subPartitionsCount; 252 } 253 254 public void setSubPartitionsCount(SQLExpr subPartitionsCount) { 255 if (subPartitionsCount !is null) { 256 subPartitionsCount.setParent(this); 257 } 258 this.subPartitionsCount = subPartitionsCount; 259 } 260 261 public SQLPartitionValue getValues() { 262 return values; 263 } 264 265 public void setValues(SQLPartitionValue values) { 266 if (values !is null) { 267 values.setParent(this); 268 } 269 this.values = values; 270 } 271 272 public List!SQLSubPartition getSubPartitions() { 273 return subPartitions; 274 } 275 276 public void addSubPartition(SQLSubPartition partition) { 277 if (partition !is null) { 278 partition.setParent(this); 279 } 280 this.subPartitions.add(partition); 281 } 282 283 public SQLExpr getIndexDirectory() { 284 return indexDirectory; 285 } 286 287 public void setIndexDirectory(SQLExpr indexDirectory) { 288 if (indexDirectory !is null) { 289 indexDirectory.setParent(this); 290 } 291 this.indexDirectory = indexDirectory; 292 } 293 294 public SQLExpr getDataDirectory() { 295 return dataDirectory; 296 } 297 298 public void setDataDirectory(SQLExpr dataDirectory) { 299 if (dataDirectory !is null) { 300 dataDirectory.setParent(this); 301 } 302 this.dataDirectory = dataDirectory; 303 } 304 305 public SQLExpr getMaxRows() { 306 return maxRows; 307 } 308 309 public void setMaxRows(SQLExpr maxRows) { 310 if (maxRows !is null) { 311 maxRows.setParent(this); 312 } 313 this.maxRows = maxRows; 314 } 315 316 public SQLExpr getMinRows() { 317 return minRows; 318 } 319 320 public void setMinRows(SQLExpr minRows) { 321 if (minRows !is null) { 322 minRows.setParent(this); 323 } 324 this.minRows = minRows; 325 } 326 327 public SQLExpr getEngine() { 328 return engine; 329 } 330 331 public void setEngine(SQLExpr engine) { 332 if (engine !is null) { 333 engine.setParent(this); 334 } 335 this.engine = engine; 336 } 337 338 public SQLExpr getComment() { 339 return comment; 340 } 341 342 public void setComment(SQLExpr comment) { 343 if (comment !is null) { 344 comment.setParent(this); 345 } 346 this.comment = comment; 347 } 348 349 override protected void accept0(SQLASTVisitor visitor) { 350 if (visitor.visit(this)) { 351 acceptChild(visitor, name); 352 acceptChild(visitor, values); 353 acceptChild(visitor, dataDirectory); 354 acceptChild(visitor, indexDirectory); 355 acceptChild(visitor, tablespace); 356 acceptChild(visitor, maxRows); 357 acceptChild(visitor, minRows); 358 acceptChild(visitor, engine); 359 acceptChild(visitor, comment); 360 361 acceptChild(visitor, storage); 362 } 363 visitor.endVisit(this); 364 } 365 366 public SQLObject getLobStorage() { 367 return lobStorage; 368 } 369 370 public void setLobStorage(SQLObject lobStorage) { 371 if (lobStorage !is null) { 372 lobStorage.setParent(this); 373 } 374 this.lobStorage = lobStorage; 375 } 376 377 public bool isSegmentCreationImmediate() { 378 return segmentCreationImmediate; 379 } 380 381 public void setSegmentCreationImmediate(bool segmentCreationImmediate) { 382 this.segmentCreationImmediate = segmentCreationImmediate; 383 } 384 385 public bool isSegmentCreationDeferred() { 386 return segmentCreationDeferred; 387 } 388 389 public void setSegmentCreationDeferred(bool segmentCreationDeferred) { 390 this.segmentCreationDeferred = segmentCreationDeferred; 391 } 392 393 override public SQLPartition clone() { 394 SQLPartition x = new SQLPartition(); 395 396 if (name !is null) { 397 x.setName(name.clone()); 398 } 399 400 if (subPartitionsCount !is null) { 401 x.setSubPartitionsCount(subPartitionsCount.clone()); 402 } 403 404 foreach (SQLSubPartition p ; subPartitions) { 405 SQLSubPartition p2 = p.clone(); 406 p2.setParent(x); 407 x.subPartitions.add(p2); 408 } 409 410 if (values !is null) { 411 x.setValues(values.clone()); 412 } 413 414 if (dataDirectory !is null) { 415 x.setDataDirectory(dataDirectory.clone()); 416 } 417 if (indexDirectory !is null) { 418 x.setDataDirectory(indexDirectory.clone()); 419 } 420 if (maxRows !is null) { 421 x.setDataDirectory(maxRows.clone()); 422 } 423 if (minRows !is null) { 424 x.setDataDirectory(minRows.clone()); 425 } 426 if (engine !is null) { 427 x.setDataDirectory(engine.clone()); 428 } 429 if (comment !is null) { 430 x.setDataDirectory(comment.clone()); 431 } 432 x.segmentCreationImmediate = segmentCreationImmediate; 433 x.segmentCreationDeferred = segmentCreationDeferred; 434 435 if (lobStorage !is null) { 436 x.setLobStorage(lobStorage.clone()); 437 } 438 439 return x; 440 } 441 }