001package gudusoft.gsqlparser.nodes.oceanbase; 002 003import gudusoft.gsqlparser.EDbObjectType; 004import gudusoft.gsqlparser.nodes.TObjectName; 005import gudusoft.gsqlparser.nodes.TParseTreeNode; 006import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 007 008import java.util.ArrayList; 009 010/** 011 * AST node for OceanBase {@code ALTER RESOURCE POOL} (Phase 4 Batch 2). 012 * 013 * <p>Two shapes: 014 * <ol> 015 * <li><b>Option update</b> ({@link EAction#UPDATE_OPTIONS}) — 016 * {@code ALTER RESOURCE POOL name UNIT_NUM = N[, ...]}</li> 017 * <li><b>Split</b> ({@link EAction#SPLIT}) — 018 * {@code ALTER RESOURCE POOL name SPLIT INTO (p1, p2, ...) ON 019 * ('z1', 'z2', ...)}</li> 020 * </ol> 021 * 022 * @since 4.0.1.4 023 */ 024public class TOceanbaseAlterResourcePoolSqlNode extends TParseTreeNode { 025 026 public enum EAction { 027 UPDATE_OPTIONS, 028 SPLIT, 029 MERGE 030 } 031 032 private TObjectName poolName; 033 private EAction actionType; 034 private ArrayList<TOceanbaseResourceOption> resourceOptions 035 = new ArrayList<TOceanbaseResourceOption>(); 036 private ArrayList<TObjectName> splitPoolNames 037 = new ArrayList<TObjectName>(); 038 private ArrayList<TObjectName> splitZoneValues 039 = new ArrayList<TObjectName>(); 040 private ArrayList<TObjectName> mergeSourcePoolNames 041 = new ArrayList<TObjectName>(); 042 private ArrayList<TObjectName> mergeTargetPoolNames 043 = new ArrayList<TObjectName>(); 044 045 public TObjectName getPoolName() { 046 return poolName; 047 } 048 049 public void setPoolName(TObjectName poolName) { 050 this.poolName = poolName; 051 if (poolName != null) { 052 poolName.setDbObjectType(EDbObjectType.database); 053 } 054 } 055 056 public EAction getActionType() { 057 return actionType; 058 } 059 060 public void setActionType(EAction actionType) { 061 this.actionType = actionType; 062 } 063 064 public ArrayList<TOceanbaseResourceOption> getResourceOptions() { 065 return resourceOptions; 066 } 067 068 public void addResourceOption(TOceanbaseResourceOption option) { 069 if (option != null) { 070 this.resourceOptions.add(option); 071 } 072 } 073 074 public ArrayList<TObjectName> getSplitPoolNames() { 075 return splitPoolNames; 076 } 077 078 public void addSplitPoolName(TObjectName name) { 079 if (name != null) { 080 this.splitPoolNames.add(name); 081 } 082 } 083 084 public ArrayList<TObjectName> getSplitZoneValues() { 085 return splitZoneValues; 086 } 087 088 public void addSplitZoneValue(TObjectName value) { 089 if (value != null) { 090 this.splitZoneValues.add(value); 091 } 092 } 093 094 public ArrayList<TObjectName> getMergeSourcePoolNames() { 095 return mergeSourcePoolNames; 096 } 097 098 public void addMergeSourcePoolName(TObjectName name) { 099 if (name != null) { 100 this.mergeSourcePoolNames.add(name); 101 } 102 } 103 104 public ArrayList<TObjectName> getMergeTargetPoolNames() { 105 return mergeTargetPoolNames; 106 } 107 108 public void addMergeTargetPoolName(TObjectName name) { 109 if (name != null) { 110 this.mergeTargetPoolNames.add(name); 111 } 112 } 113 114 @Override 115 public void init(Object arg1) { 116 setPoolName((TObjectName) arg1); 117 } 118 119 @Override 120 public void accept(TParseTreeVisitor v) { 121 v.preVisit(this); 122 v.postVisit(this); 123 } 124 125 @Override 126 public void acceptChildren(TParseTreeVisitor v) { 127 v.preVisit(this); 128 if (poolName != null) { 129 poolName.acceptChildren(v); 130 } 131 for (TOceanbaseResourceOption opt : resourceOptions) { 132 if (opt != null) opt.acceptChildren(v); 133 } 134 for (TObjectName n : splitPoolNames) { 135 if (n != null) n.acceptChildren(v); 136 } 137 for (TObjectName n : splitZoneValues) { 138 if (n != null) n.acceptChildren(v); 139 } 140 for (TObjectName n : mergeSourcePoolNames) { 141 if (n != null) n.acceptChildren(v); 142 } 143 for (TObjectName n : mergeTargetPoolNames) { 144 if (n != null) n.acceptChildren(v); 145 } 146 v.postVisit(this); 147 } 148}