001package gudusoft.gsqlparser.nodes.oceanbase; 002 003import gudusoft.gsqlparser.EDbObjectType; 004import gudusoft.gsqlparser.nodes.TBaseTablePartition; 005import gudusoft.gsqlparser.nodes.TObjectName; 006import gudusoft.gsqlparser.nodes.TParseTreeNode; 007import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 008 009import java.util.ArrayList; 010 011/** 012 * AST node for OceanBase {@code CREATE TABLEGROUP} (Phase 4 Batch 6). 013 * 014 * <p>Grammar shape: 015 * {@code CREATE TABLEGROUP [IF NOT EXISTS] name [option [, option ...]]} 016 * where each option is one of {@code PRIMARY_ZONE = 'zone'}, 017 * {@code LOCALITY = 'F@zone1,F@zone2'}, {@code BINDING = TRUE|FALSE}, 018 * etc. 019 * 020 * @since 4.0.1.4 021 */ 022public class TOceanbaseCreateTablegroupSqlNode extends TParseTreeNode { 023 024 private TObjectName tablegroupName; 025 private boolean ifNotExists; 026 private ArrayList<TOceanbaseTablegroupOption> tablegroupOptions 027 = new ArrayList<TOceanbaseTablegroupOption>(); 028 private TBaseTablePartition tablePartition; 029 030 public TObjectName getTablegroupName() { 031 return tablegroupName; 032 } 033 034 public void setTablegroupName(TObjectName tablegroupName) { 035 this.tablegroupName = tablegroupName; 036 if (tablegroupName != null) { 037 tablegroupName.setDbObjectType(EDbObjectType.database); 038 } 039 } 040 041 public boolean isIfNotExists() { 042 return ifNotExists; 043 } 044 045 public void setIfNotExists(boolean ifNotExists) { 046 this.ifNotExists = ifNotExists; 047 } 048 049 public ArrayList<TOceanbaseTablegroupOption> getTablegroupOptions() { 050 return tablegroupOptions; 051 } 052 053 public void addTablegroupOption(TOceanbaseTablegroupOption option) { 054 if (option != null) { 055 this.tablegroupOptions.add(option); 056 } 057 } 058 059 /** 060 * @return the trailing {@code PARTITION BY ...} clause, or 061 * {@code null} if no partition clause was specified. 062 */ 063 public TBaseTablePartition getTablePartition() { 064 return tablePartition; 065 } 066 067 public void setTablePartition(TBaseTablePartition tablePartition) { 068 this.tablePartition = tablePartition; 069 } 070 071 @Override 072 public void init(Object arg1) { 073 setTablegroupName((TObjectName) arg1); 074 } 075 076 @Override 077 public void accept(TParseTreeVisitor v) { 078 v.preVisit(this); 079 v.postVisit(this); 080 } 081 082 @Override 083 public void acceptChildren(TParseTreeVisitor v) { 084 v.preVisit(this); 085 if (tablegroupName != null) { 086 tablegroupName.acceptChildren(v); 087 } 088 for (TOceanbaseTablegroupOption opt : tablegroupOptions) { 089 if (opt != null) opt.acceptChildren(v); 090 } 091 if (tablePartition != null) { 092 tablePartition.acceptChildren(v); 093 } 094 v.postVisit(this); 095 } 096}