github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/parsers/tree/create.go (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package tree 16 17 import ( 18 "fmt" 19 "strconv" 20 "strings" 21 22 "github.com/matrixorigin/matrixone/pkg/common/reuse" 23 ) 24 25 func init() { 26 reuse.CreatePool[CreateOptionCharset]( 27 func() *CreateOptionCharset { return &CreateOptionCharset{} }, 28 func(c *CreateOptionCharset) { c.reset() }, 29 reuse.DefaultOptions[CreateOptionCharset](), //. 30 ) //WithEnableChecker() 31 32 reuse.CreatePool[ClusterByOption]( 33 func() *ClusterByOption { return &ClusterByOption{} }, 34 func(c *ClusterByOption) { c.reset() }, 35 reuse.DefaultOptions[ClusterByOption](), //. 36 ) //WithEnableChecker() 37 38 reuse.CreatePool[CreateOptionCollate]( 39 func() *CreateOptionCollate { return &CreateOptionCollate{} }, 40 func(c *CreateOptionCollate) { c.reset() }, 41 reuse.DefaultOptions[CreateOptionCollate](), //. 42 ) //WithEnableChecker() 43 44 reuse.CreatePool[CreateOptionEncryption]( 45 func() *CreateOptionEncryption { return &CreateOptionEncryption{} }, 46 func(c *CreateOptionEncryption) { c.reset() }, 47 reuse.DefaultOptions[CreateOptionEncryption](), //. 48 ) //WithEnableChecker() 49 50 reuse.CreatePool[SubscriptionOption]( 51 func() *SubscriptionOption { return &SubscriptionOption{} }, 52 func(s *SubscriptionOption) { s.reset() }, 53 reuse.DefaultOptions[SubscriptionOption](), //. 54 ) //WithEnableChecker() 55 56 reuse.CreatePool[CreateDatabase]( 57 func() *CreateDatabase { return &CreateDatabase{} }, 58 func(c *CreateDatabase) { c.reset() }, 59 reuse.DefaultOptions[CreateDatabase](), //. 60 ) //WithEnableChecker() 61 62 reuse.CreatePool[CreateTable]( 63 func() *CreateTable { return &CreateTable{} }, 64 func(c *CreateTable) { c.reset() }, 65 reuse.DefaultOptions[CreateTable](), //. 66 ) //WithEnableChecker() 67 68 reuse.CreatePool[ColumnTableDef]( 69 func() *ColumnTableDef { return &ColumnTableDef{} }, 70 func(c *ColumnTableDef) { c.reset() }, 71 reuse.DefaultOptions[ColumnTableDef](), //. 72 ) //WithEnableChecker() 73 74 reuse.CreatePool[AttributeNull]( 75 func() *AttributeNull { return &AttributeNull{} }, 76 func(a *AttributeNull) { a.reset() }, 77 reuse.DefaultOptions[AttributeNull](), //. 78 ) //WithEnableChecker() 79 80 reuse.CreatePool[AttributeDefault]( 81 func() *AttributeDefault { return &AttributeDefault{} }, 82 func(a *AttributeDefault) { a.reset() }, 83 reuse.DefaultOptions[AttributeDefault](), //. 84 ) //WithEnableChecker() 85 86 reuse.CreatePool[AttributeAutoIncrement]( 87 func() *AttributeAutoIncrement { return &AttributeAutoIncrement{} }, 88 func(a *AttributeAutoIncrement) { a.reset() }, 89 reuse.DefaultOptions[AttributeAutoIncrement](), //. 90 ) //WithEnableChecker() 91 92 reuse.CreatePool[AttributeUniqueKey]( 93 func() *AttributeUniqueKey { return &AttributeUniqueKey{} }, 94 func(a *AttributeUniqueKey) { a.reset() }, 95 reuse.DefaultOptions[AttributeUniqueKey](), //. 96 ) //WithEnableChecker() 97 98 reuse.CreatePool[AttributeUnique]( 99 func() *AttributeUnique { return &AttributeUnique{} }, 100 func(a *AttributeUnique) { a.reset() }, 101 reuse.DefaultOptions[AttributeUnique](), //. 102 ) //WithEnableChecker() 103 104 reuse.CreatePool[AttributeKey]( 105 func() *AttributeKey { return &AttributeKey{} }, 106 func(a *AttributeKey) { a.reset() }, 107 reuse.DefaultOptions[AttributeKey](), //. 108 ) //WithEnableChecker() 109 110 reuse.CreatePool[AttributePrimaryKey]( 111 func() *AttributePrimaryKey { return &AttributePrimaryKey{} }, 112 func(a *AttributePrimaryKey) { a.reset() }, 113 reuse.DefaultOptions[AttributePrimaryKey](), //. 114 ) //WithEnableChecker() 115 116 reuse.CreatePool[AttributeComment]( 117 func() *AttributeComment { return &AttributeComment{} }, 118 func(a *AttributeComment) { a.reset() }, 119 reuse.DefaultOptions[AttributeComment](), //. 120 ) //WithEnableChecker() 121 122 reuse.CreatePool[AttributeCollate]( 123 func() *AttributeCollate { return &AttributeCollate{} }, 124 func(a *AttributeCollate) { a.reset() }, 125 reuse.DefaultOptions[AttributeCollate](), //. 126 ) //WithEnableChecker() 127 128 reuse.CreatePool[AttributeColumnFormat]( 129 func() *AttributeColumnFormat { return &AttributeColumnFormat{} }, 130 func(a *AttributeColumnFormat) { a.reset() }, 131 reuse.DefaultOptions[AttributeColumnFormat](), //. 132 ) //WithEnableChecker() 133 134 reuse.CreatePool[AttributeStorage]( 135 func() *AttributeStorage { return &AttributeStorage{} }, 136 func(a *AttributeStorage) { a.reset() }, 137 reuse.DefaultOptions[AttributeStorage](), //. 138 ) //WithEnableChecker() 139 140 reuse.CreatePool[AttributeCheckConstraint]( 141 func() *AttributeCheckConstraint { return &AttributeCheckConstraint{} }, 142 func(a *AttributeCheckConstraint) { a.reset() }, 143 reuse.DefaultOptions[AttributeCheckConstraint](), //. 144 ) //WithEnableChecker() 145 146 reuse.CreatePool[AttributeGeneratedAlways]( 147 func() *AttributeGeneratedAlways { return &AttributeGeneratedAlways{} }, 148 func(a *AttributeGeneratedAlways) { a.reset() }, 149 reuse.DefaultOptions[AttributeGeneratedAlways](), //. 150 ) //WithEnableChecker() 151 152 reuse.CreatePool[AttributeLowCardinality]( 153 func() *AttributeLowCardinality { return &AttributeLowCardinality{} }, 154 func(a *AttributeLowCardinality) { a.reset() }, 155 reuse.DefaultOptions[AttributeLowCardinality](), //. 156 ) //WithEnableChecker() 157 158 reuse.CreatePool[KeyPart]( 159 func() *KeyPart { return &KeyPart{} }, 160 func(k *KeyPart) { k.reset() }, 161 reuse.DefaultOptions[KeyPart](), //. 162 ) //WithEnableChecker() 163 164 reuse.CreatePool[AttributeReference]( 165 func() *AttributeReference { return &AttributeReference{} }, 166 func(a *AttributeReference) { a.reset() }, 167 reuse.DefaultOptions[AttributeReference](), //. 168 ) //WithEnableChecker() 169 170 reuse.CreatePool[AttributeOnUpdate]( 171 func() *AttributeOnUpdate { return &AttributeOnUpdate{} }, 172 func(a *AttributeOnUpdate) { a.reset() }, 173 reuse.DefaultOptions[AttributeOnUpdate](), //. 174 ) //WithEnableChecker() 175 176 reuse.CreatePool[IndexOption]( 177 func() *IndexOption { return &IndexOption{} }, 178 func(i *IndexOption) { i.reset() }, 179 reuse.DefaultOptions[IndexOption](), //. 180 ) //WithEnableChecker() 181 182 reuse.CreatePool[PrimaryKeyIndex]( 183 func() *PrimaryKeyIndex { return &PrimaryKeyIndex{} }, 184 func(p *PrimaryKeyIndex) { p.reset() }, 185 reuse.DefaultOptions[PrimaryKeyIndex](), //. 186 ) //WithEnableChecker() 187 188 reuse.CreatePool[Index]( 189 func() *Index { return &Index{} }, 190 func(i *Index) { i.reset() }, 191 reuse.DefaultOptions[Index](), //. 192 ) //WithEnableChecker() 193 194 reuse.CreatePool[UniqueIndex]( 195 func() *UniqueIndex { return &UniqueIndex{} }, 196 func(u *UniqueIndex) { u.reset() }, 197 reuse.DefaultOptions[UniqueIndex](), //. 198 ) //WithEnableChecker() 199 200 reuse.CreatePool[ForeignKey]( 201 func() *ForeignKey { return &ForeignKey{} }, 202 func(f *ForeignKey) { f.reset() }, 203 reuse.DefaultOptions[ForeignKey](), //. 204 ) //WithEnableChecker() 205 206 reuse.CreatePool[FullTextIndex]( 207 func() *FullTextIndex { return &FullTextIndex{} }, 208 func(f *FullTextIndex) { f.reset() }, 209 reuse.DefaultOptions[FullTextIndex](), //. 210 ) //WithEnableChecker() 211 212 reuse.CreatePool[CheckIndex]( 213 func() *CheckIndex { return &CheckIndex{} }, 214 func(c *CheckIndex) { c.reset() }, 215 reuse.DefaultOptions[CheckIndex](), //. 216 ) //WithEnableChecker() 217 218 reuse.CreatePool[TableOptionProperties]( 219 func() *TableOptionProperties { return &TableOptionProperties{} }, 220 func(t *TableOptionProperties) { t.reset() }, 221 reuse.DefaultOptions[TableOptionProperties](), //. 222 ) //WithEnableChecker() 223 224 reuse.CreatePool[Property]( 225 func() *Property { return &Property{} }, 226 func(p *Property) { p.reset() }, 227 reuse.DefaultOptions[Property](), //. 228 ) //WithEnableChecker() 229 230 reuse.CreatePool[TableOptionEngine]( 231 func() *TableOptionEngine { return &TableOptionEngine{} }, 232 func(t *TableOptionEngine) { t.reset() }, 233 reuse.DefaultOptions[TableOptionEngine](), //. 234 ) //WithEnableChecker() 235 236 reuse.CreatePool[TableOptionEngineAttr]( 237 func() *TableOptionEngineAttr { return &TableOptionEngineAttr{} }, 238 func(t *TableOptionEngineAttr) { t.reset() }, 239 reuse.DefaultOptions[TableOptionEngineAttr](), //. 240 ) //WithEnableChecker() 241 242 reuse.CreatePool[TableOptionInsertMethod]( 243 func() *TableOptionInsertMethod { return &TableOptionInsertMethod{} }, 244 func(t *TableOptionInsertMethod) { t.reset() }, 245 reuse.DefaultOptions[TableOptionInsertMethod](), //. 246 ) //WithEnableChecker() 247 248 reuse.CreatePool[TableOptionSecondaryEngine]( 249 func() *TableOptionSecondaryEngine { return &TableOptionSecondaryEngine{} }, 250 func(t *TableOptionSecondaryEngine) { t.reset() }, 251 reuse.DefaultOptions[TableOptionSecondaryEngine](), //. 252 ) //WithEnableChecker() 253 254 reuse.CreatePool[TableOptionCharset]( 255 func() *TableOptionCharset { return &TableOptionCharset{} }, 256 func(t *TableOptionCharset) { t.reset() }, 257 reuse.DefaultOptions[TableOptionCharset](), //. 258 ) //WithEnableChecker() 259 260 reuse.CreatePool[TableOptionCollate]( 261 func() *TableOptionCollate { return &TableOptionCollate{} }, 262 func(t *TableOptionCollate) { t.reset() }, 263 reuse.DefaultOptions[TableOptionCollate](), //. 264 ) //WithEnableChecker() 265 266 reuse.CreatePool[TableOptionAUTOEXTEND_SIZE]( 267 func() *TableOptionAUTOEXTEND_SIZE { return &TableOptionAUTOEXTEND_SIZE{} }, 268 func(t *TableOptionAUTOEXTEND_SIZE) { t.reset() }, 269 reuse.DefaultOptions[TableOptionAUTOEXTEND_SIZE](), //. 270 ) //WithEnableChecker() 271 272 reuse.CreatePool[TableOptionAutoIncrement]( 273 func() *TableOptionAutoIncrement { return &TableOptionAutoIncrement{} }, 274 func(t *TableOptionAutoIncrement) { t.reset() }, 275 reuse.DefaultOptions[TableOptionAutoIncrement](), //. 276 ) //WithEnableChecker() 277 278 reuse.CreatePool[TableOptionComment]( 279 func() *TableOptionComment { return &TableOptionComment{} }, 280 func(t *TableOptionComment) { t.reset() }, 281 reuse.DefaultOptions[TableOptionComment](), //. 282 ) //WithEnableChecker() 283 284 reuse.CreatePool[TableOptionAvgRowLength]( 285 func() *TableOptionAvgRowLength { return &TableOptionAvgRowLength{} }, 286 func(t *TableOptionAvgRowLength) { t.reset() }, 287 reuse.DefaultOptions[TableOptionAvgRowLength](), //. 288 ) //WithEnableChecker() 289 290 reuse.CreatePool[TableOptionChecksum]( 291 func() *TableOptionChecksum { return &TableOptionChecksum{} }, 292 func(t *TableOptionChecksum) { t.reset() }, 293 reuse.DefaultOptions[TableOptionChecksum](), //. 294 ) //WithEnableChecker() 295 296 reuse.CreatePool[TableOptionCompression]( 297 func() *TableOptionCompression { return &TableOptionCompression{} }, 298 func(t *TableOptionCompression) { t.reset() }, 299 reuse.DefaultOptions[TableOptionCompression](), //. 300 ) //WithEnableChecker() 301 302 reuse.CreatePool[TableOptionConnection]( 303 func() *TableOptionConnection { return &TableOptionConnection{} }, 304 func(t *TableOptionConnection) { t.reset() }, 305 reuse.DefaultOptions[TableOptionConnection](), //. 306 ) //WithEnableChecker() 307 308 reuse.CreatePool[TableOptionPassword]( 309 func() *TableOptionPassword { return &TableOptionPassword{} }, 310 func(t *TableOptionPassword) { t.reset() }, 311 reuse.DefaultOptions[TableOptionPassword](), //. 312 ) //WithEnableChecker() 313 314 reuse.CreatePool[TableOptionKeyBlockSize]( 315 func() *TableOptionKeyBlockSize { return &TableOptionKeyBlockSize{} }, 316 func(t *TableOptionKeyBlockSize) { t.reset() }, 317 reuse.DefaultOptions[TableOptionKeyBlockSize](), //. 318 ) //WithEnableChecker() 319 320 reuse.CreatePool[TableOptionMaxRows]( 321 func() *TableOptionMaxRows { return &TableOptionMaxRows{} }, 322 func(t *TableOptionMaxRows) { t.reset() }, 323 reuse.DefaultOptions[TableOptionMaxRows](), //. 324 ) //WithEnableChecker() 325 326 reuse.CreatePool[TableOptionMinRows]( 327 func() *TableOptionMinRows { return &TableOptionMinRows{} }, 328 func(t *TableOptionMinRows) { t.reset() }, 329 reuse.DefaultOptions[TableOptionMinRows](), //. 330 ) //WithEnableChecker() 331 332 reuse.CreatePool[TableOptionDelayKeyWrite]( 333 func() *TableOptionDelayKeyWrite { return &TableOptionDelayKeyWrite{} }, 334 func(t *TableOptionDelayKeyWrite) { t.reset() }, 335 reuse.DefaultOptions[TableOptionDelayKeyWrite](), //. 336 ) //WithEnableChecker() 337 338 reuse.CreatePool[TableOptionRowFormat]( 339 func() *TableOptionRowFormat { return &TableOptionRowFormat{} }, 340 func(t *TableOptionRowFormat) { t.reset() }, 341 reuse.DefaultOptions[TableOptionRowFormat](), //. 342 ) //WithEnableChecker() 343 344 reuse.CreatePool[TableOptionStartTrans]( 345 func() *TableOptionStartTrans { return &TableOptionStartTrans{} }, 346 func(t *TableOptionStartTrans) { t.reset() }, 347 reuse.DefaultOptions[TableOptionStartTrans](), //. 348 ) //WithEnableChecker() 349 350 reuse.CreatePool[TableOptionSecondaryEngineAttr]( 351 func() *TableOptionSecondaryEngineAttr { return &TableOptionSecondaryEngineAttr{} }, 352 func(t *TableOptionSecondaryEngineAttr) { t.reset() }, 353 reuse.DefaultOptions[TableOptionSecondaryEngineAttr](), //. 354 ) //WithEnableChecker() 355 356 reuse.CreatePool[TableOptionStatsPersistent]( 357 func() *TableOptionStatsPersistent { return &TableOptionStatsPersistent{} }, 358 func(t *TableOptionStatsPersistent) { t.reset() }, 359 reuse.DefaultOptions[TableOptionStatsPersistent](), //. 360 ) //WithEnableChecker() 361 362 reuse.CreatePool[TableOptionStatsAutoRecalc]( 363 func() *TableOptionStatsAutoRecalc { return &TableOptionStatsAutoRecalc{} }, 364 func(t *TableOptionStatsAutoRecalc) { t.reset() }, 365 reuse.DefaultOptions[TableOptionStatsAutoRecalc](), //. 366 ) //WithEnableChecker() 367 368 reuse.CreatePool[TableOptionPackKeys]( 369 func() *TableOptionPackKeys { return &TableOptionPackKeys{} }, 370 func(t *TableOptionPackKeys) { t.reset() }, 371 reuse.DefaultOptions[TableOptionPackKeys](), //. 372 ) //WithEnableChecker() 373 374 reuse.CreatePool[TableOptionTablespace]( 375 func() *TableOptionTablespace { return &TableOptionTablespace{} }, 376 func(t *TableOptionTablespace) { t.reset() }, 377 reuse.DefaultOptions[TableOptionTablespace](), //. 378 ) //WithEnableChecker() 379 380 reuse.CreatePool[TableOptionDataDirectory]( 381 func() *TableOptionDataDirectory { return &TableOptionDataDirectory{} }, 382 func(t *TableOptionDataDirectory) { t.reset() }, 383 reuse.DefaultOptions[TableOptionDataDirectory](), //. 384 ) //WithEnableChecker() 385 386 reuse.CreatePool[TableOptionIndexDirectory]( 387 func() *TableOptionIndexDirectory { return &TableOptionIndexDirectory{} }, 388 func(t *TableOptionIndexDirectory) { t.reset() }, 389 reuse.DefaultOptions[TableOptionIndexDirectory](), //. 390 ) //WithEnableChecker() 391 392 reuse.CreatePool[TableOptionStorageMedia]( 393 func() *TableOptionStorageMedia { return &TableOptionStorageMedia{} }, 394 func(t *TableOptionStorageMedia) { t.reset() }, 395 reuse.DefaultOptions[TableOptionStorageMedia](), //. 396 ) //WithEnableChecker() 397 398 reuse.CreatePool[TableOptionStatsSamplePages]( 399 func() *TableOptionStatsSamplePages { return &TableOptionStatsSamplePages{} }, 400 func(t *TableOptionStatsSamplePages) { t.reset() }, 401 reuse.DefaultOptions[TableOptionStatsSamplePages](), //. 402 ) //WithEnableChecker() 403 404 reuse.CreatePool[TableOptionUnion]( 405 func() *TableOptionUnion { return &TableOptionUnion{} }, 406 func(t *TableOptionUnion) { t.reset() }, 407 reuse.DefaultOptions[TableOptionUnion](), //. 408 ) //WithEnableChecker() 409 410 reuse.CreatePool[TableOptionEncryption]( 411 func() *TableOptionEncryption { return &TableOptionEncryption{} }, 412 func(t *TableOptionEncryption) { t.reset() }, 413 reuse.DefaultOptions[TableOptionEncryption](), //. 414 ) //WithEnableChecker() 415 416 reuse.CreatePool[HashType]( 417 func() *HashType { return &HashType{} }, 418 func(h *HashType) { h.reset() }, 419 reuse.DefaultOptions[HashType](), //. 420 ) //WithEnableChecker() 421 422 reuse.CreatePool[KeyType]( 423 func() *KeyType { return &KeyType{} }, 424 func(k *KeyType) { k.reset() }, 425 reuse.DefaultOptions[KeyType](), //. 426 ) //WithEnableChecker() 427 428 reuse.CreatePool[RangeType]( 429 func() *RangeType { return &RangeType{} }, 430 func(r *RangeType) { r.reset() }, 431 reuse.DefaultOptions[RangeType](), //. 432 ) //WithEnableChecker() 433 434 reuse.CreatePool[ListType]( 435 func() *ListType { return &ListType{} }, 436 func(l *ListType) { l.reset() }, 437 reuse.DefaultOptions[ListType](), //. 438 ) //WithEnableChecker() 439 440 reuse.CreatePool[PartitionBy]( 441 func() *PartitionBy { return &PartitionBy{} }, 442 func(p *PartitionBy) { p.reset() }, 443 reuse.DefaultOptions[PartitionBy](), //. 444 ) //WithEnableChecker() 445 446 reuse.CreatePool[ValuesLessThan]( 447 func() *ValuesLessThan { return &ValuesLessThan{} }, 448 func(v *ValuesLessThan) { v.reset() }, 449 reuse.DefaultOptions[ValuesLessThan](), //. 450 ) //WithEnableChecker() 451 452 reuse.CreatePool[ValuesIn]( 453 func() *ValuesIn { return &ValuesIn{} }, 454 func(v *ValuesIn) { v.reset() }, 455 reuse.DefaultOptions[ValuesIn](), //. 456 ) //WithEnableChecker() 457 458 reuse.CreatePool[Partition]( 459 func() *Partition { return &Partition{} }, 460 func(p *Partition) { p.reset() }, 461 reuse.DefaultOptions[Partition](), //. 462 ) //WithEnableChecker() 463 464 reuse.CreatePool[SubPartition]( 465 func() *SubPartition { return &SubPartition{} }, 466 func(s *SubPartition) { s.reset() }, 467 reuse.DefaultOptions[SubPartition](), //. 468 ) //WithEnableChecker() 469 470 reuse.CreatePool[PartitionOption]( 471 func() *PartitionOption { return &PartitionOption{} }, 472 func(p *PartitionOption) { p.reset() }, 473 reuse.DefaultOptions[PartitionOption](), //. 474 ) //WithEnableChecker() 475 476 reuse.CreatePool[CreateIndex]( 477 func() *CreateIndex { return &CreateIndex{} }, 478 func(c *CreateIndex) { c.reset() }, 479 reuse.DefaultOptions[CreateIndex](), //. 480 ) //WithEnableChecker() 481 482 reuse.CreatePool[CreateRole]( 483 func() *CreateRole { return &CreateRole{} }, 484 func(c *CreateRole) { c.reset() }, 485 reuse.DefaultOptions[CreateRole](), //. 486 ) //WithEnableChecker() 487 488 reuse.CreatePool[Role]( 489 func() *Role { return &Role{} }, 490 func(r *Role) { r.reset() }, 491 reuse.DefaultOptions[Role](), //. 492 ) //WithEnableChecker() 493 494 reuse.CreatePool[User]( 495 func() *User { return &User{} }, 496 func(u *User) { u.reset() }, 497 reuse.DefaultOptions[User](), //. 498 ) //WithEnableChecker() 499 500 reuse.CreatePool[TlsOptionNone]( 501 func() *TlsOptionNone { return &TlsOptionNone{} }, 502 func(t *TlsOptionNone) { t.reset() }, 503 reuse.DefaultOptions[TlsOptionNone](), //. 504 ) //WithEnableChecker() 505 506 reuse.CreatePool[TlsOptionSSL]( 507 func() *TlsOptionSSL { return &TlsOptionSSL{} }, 508 func(t *TlsOptionSSL) { t.reset() }, 509 reuse.DefaultOptions[TlsOptionSSL](), //. 510 ) //WithEnableChecker() 511 512 reuse.CreatePool[TlsOptionX509]( 513 func() *TlsOptionX509 { return &TlsOptionX509{} }, 514 func(t *TlsOptionX509) { t.reset() }, 515 reuse.DefaultOptions[TlsOptionX509](), //. 516 ) //WithEnableChecker() 517 518 reuse.CreatePool[TlsOptionCipher]( 519 func() *TlsOptionCipher { return &TlsOptionCipher{} }, 520 func(t *TlsOptionCipher) { t.reset() }, 521 reuse.DefaultOptions[TlsOptionCipher](), //. 522 ) //WithEnableChecker() 523 524 reuse.CreatePool[TlsOptionIssuer]( 525 func() *TlsOptionIssuer { return &TlsOptionIssuer{} }, 526 func(t *TlsOptionIssuer) { t.reset() }, 527 reuse.DefaultOptions[TlsOptionIssuer](), //. 528 ) //WithEnableChecker() 529 530 reuse.CreatePool[TlsOptionSubject]( 531 func() *TlsOptionSubject { return &TlsOptionSubject{} }, 532 func(t *TlsOptionSubject) { t.reset() }, 533 reuse.DefaultOptions[TlsOptionSubject](), //. 534 ) //WithEnableChecker() 535 536 reuse.CreatePool[TlsOptionSan]( 537 func() *TlsOptionSan { return &TlsOptionSan{} }, 538 func(t *TlsOptionSan) { t.reset() }, 539 reuse.DefaultOptions[TlsOptionSan](), //. 540 ) //WithEnableChecker() 541 542 reuse.CreatePool[ResourceOptionMaxQueriesPerHour]( 543 func() *ResourceOptionMaxQueriesPerHour { return &ResourceOptionMaxQueriesPerHour{} }, 544 func(r *ResourceOptionMaxQueriesPerHour) { r.reset() }, 545 reuse.DefaultOptions[ResourceOptionMaxQueriesPerHour](), //. 546 ) //WithEnableChecker() 547 548 reuse.CreatePool[ResourceOptionMaxUpdatesPerHour]( 549 func() *ResourceOptionMaxUpdatesPerHour { return &ResourceOptionMaxUpdatesPerHour{} }, 550 func(r *ResourceOptionMaxUpdatesPerHour) { r.reset() }, 551 reuse.DefaultOptions[ResourceOptionMaxUpdatesPerHour](), //. 552 ) //WithEnableChecker() 553 554 reuse.CreatePool[ResourceOptionMaxConnectionPerHour]( 555 func() *ResourceOptionMaxConnectionPerHour { return &ResourceOptionMaxConnectionPerHour{} }, 556 func(r *ResourceOptionMaxConnectionPerHour) { r.reset() }, 557 reuse.DefaultOptions[ResourceOptionMaxConnectionPerHour](), //. 558 ) //WithEnableChecker() 559 560 reuse.CreatePool[ResourceOptionMaxUserConnections]( 561 func() *ResourceOptionMaxUserConnections { return &ResourceOptionMaxUserConnections{} }, 562 func(r *ResourceOptionMaxUserConnections) { r.reset() }, 563 reuse.DefaultOptions[ResourceOptionMaxUserConnections](), //. 564 ) //WithEnableChecker() 565 566 reuse.CreatePool[UserMiscOptionPasswordExpireNone]( 567 func() *UserMiscOptionPasswordExpireNone { return &UserMiscOptionPasswordExpireNone{} }, 568 func(u *UserMiscOptionPasswordExpireNone) { u.reset() }, 569 reuse.DefaultOptions[UserMiscOptionPasswordExpireNone](), //. 570 ) //WithEnableChecker() 571 572 reuse.CreatePool[UserMiscOptionPasswordExpireDefault]( 573 func() *UserMiscOptionPasswordExpireDefault { return &UserMiscOptionPasswordExpireDefault{} }, 574 func(u *UserMiscOptionPasswordExpireDefault) { u.reset() }, 575 reuse.DefaultOptions[UserMiscOptionPasswordExpireDefault](), //. 576 ) //WithEnableChecker() 577 578 reuse.CreatePool[UserMiscOptionPasswordExpireNever]( 579 func() *UserMiscOptionPasswordExpireNever { return &UserMiscOptionPasswordExpireNever{} }, 580 func(u *UserMiscOptionPasswordExpireNever) { u.reset() }, 581 reuse.DefaultOptions[UserMiscOptionPasswordExpireNever](), //. 582 ) //WithEnableChecker() 583 584 reuse.CreatePool[UserMiscOptionPasswordExpireInterval]( 585 func() *UserMiscOptionPasswordExpireInterval { return &UserMiscOptionPasswordExpireInterval{} }, 586 func(u *UserMiscOptionPasswordExpireInterval) { u.reset() }, 587 reuse.DefaultOptions[UserMiscOptionPasswordExpireInterval](), //. 588 ) //WithEnableChecker() 589 590 reuse.CreatePool[UserMiscOptionPasswordHistoryDefault]( 591 func() *UserMiscOptionPasswordHistoryDefault { return &UserMiscOptionPasswordHistoryDefault{} }, 592 func(u *UserMiscOptionPasswordHistoryDefault) { u.reset() }, 593 reuse.DefaultOptions[UserMiscOptionPasswordHistoryDefault](), //. 594 ) //WithEnableChecker() 595 596 reuse.CreatePool[UserMiscOptionPasswordHistoryCount]( 597 func() *UserMiscOptionPasswordHistoryCount { return &UserMiscOptionPasswordHistoryCount{} }, 598 func(u *UserMiscOptionPasswordHistoryCount) { u.reset() }, 599 reuse.DefaultOptions[UserMiscOptionPasswordHistoryCount](), //. 600 ) //WithEnableChecker() 601 602 reuse.CreatePool[UserMiscOptionPasswordReuseIntervalDefault]( 603 func() *UserMiscOptionPasswordReuseIntervalDefault { 604 return &UserMiscOptionPasswordReuseIntervalDefault{} 605 }, 606 func(u *UserMiscOptionPasswordReuseIntervalDefault) { u.reset() }, 607 reuse.DefaultOptions[UserMiscOptionPasswordReuseIntervalDefault](), //. 608 ) //WithEnableChecker() 609 610 reuse.CreatePool[UserMiscOptionPasswordReuseIntervalCount]( 611 func() *UserMiscOptionPasswordReuseIntervalCount { return &UserMiscOptionPasswordReuseIntervalCount{} }, 612 func(u *UserMiscOptionPasswordReuseIntervalCount) { u.reset() }, 613 reuse.DefaultOptions[UserMiscOptionPasswordReuseIntervalCount](), //. 614 ) //WithEnableChecker() 615 616 reuse.CreatePool[UserMiscOptionPasswordRequireCurrentNone]( 617 func() *UserMiscOptionPasswordRequireCurrentNone { return &UserMiscOptionPasswordRequireCurrentNone{} }, 618 func(u *UserMiscOptionPasswordRequireCurrentNone) { u.reset() }, 619 reuse.DefaultOptions[UserMiscOptionPasswordRequireCurrentNone](), //. 620 ) //WithEnableChecker() 621 622 reuse.CreatePool[UserMiscOptionPasswordRequireCurrentDefault]( 623 func() *UserMiscOptionPasswordRequireCurrentDefault { 624 return &UserMiscOptionPasswordRequireCurrentDefault{} 625 }, 626 func(u *UserMiscOptionPasswordRequireCurrentDefault) { u.reset() }, 627 reuse.DefaultOptions[UserMiscOptionPasswordRequireCurrentDefault](), //. 628 ) //WithEnableChecker() 629 630 reuse.CreatePool[UserMiscOptionPasswordRequireCurrentOptional]( 631 func() *UserMiscOptionPasswordRequireCurrentOptional { 632 return &UserMiscOptionPasswordRequireCurrentOptional{} 633 }, 634 func(u *UserMiscOptionPasswordRequireCurrentOptional) { u.reset() }, 635 reuse.DefaultOptions[UserMiscOptionPasswordRequireCurrentOptional](), //. 636 ) //WithEnableChecker() 637 638 reuse.CreatePool[UserMiscOptionFailedLoginAttempts]( 639 func() *UserMiscOptionFailedLoginAttempts { return &UserMiscOptionFailedLoginAttempts{} }, 640 func(u *UserMiscOptionFailedLoginAttempts) { u.reset() }, 641 reuse.DefaultOptions[UserMiscOptionFailedLoginAttempts](), //. 642 ) //WithEnableChecker() 643 644 reuse.CreatePool[UserMiscOptionPasswordLockTimeCount]( 645 func() *UserMiscOptionPasswordLockTimeCount { return &UserMiscOptionPasswordLockTimeCount{} }, 646 func(u *UserMiscOptionPasswordLockTimeCount) { u.reset() }, 647 reuse.DefaultOptions[UserMiscOptionPasswordLockTimeCount](), //. 648 ) //WithEnableChecker() 649 650 reuse.CreatePool[UserMiscOptionPasswordLockTimeUnbounded]( 651 func() *UserMiscOptionPasswordLockTimeUnbounded { return &UserMiscOptionPasswordLockTimeUnbounded{} }, 652 func(u *UserMiscOptionPasswordLockTimeUnbounded) { u.reset() }, 653 reuse.DefaultOptions[UserMiscOptionPasswordLockTimeUnbounded](), //. 654 ) //WithEnableChecker() 655 656 reuse.CreatePool[UserMiscOptionAccountLock]( 657 func() *UserMiscOptionAccountLock { return &UserMiscOptionAccountLock{} }, 658 func(u *UserMiscOptionAccountLock) { u.reset() }, 659 reuse.DefaultOptions[UserMiscOptionAccountLock](), //. 660 ) //WithEnableChecker() 661 662 reuse.CreatePool[UserMiscOptionAccountUnlock]( 663 func() *UserMiscOptionAccountUnlock { return &UserMiscOptionAccountUnlock{} }, 664 func(u *UserMiscOptionAccountUnlock) { u.reset() }, 665 reuse.DefaultOptions[UserMiscOptionAccountUnlock](), //. 666 ) //WithEnableChecker() 667 668 reuse.CreatePool[CreateUser]( 669 func() *CreateUser { return &CreateUser{} }, 670 func(c *CreateUser) { c.reset() }, 671 reuse.DefaultOptions[CreateUser](), //. 672 ) //WithEnableChecker() 673 674 reuse.CreatePool[CreateAccount]( 675 func() *CreateAccount { return &CreateAccount{} }, 676 func(c *CreateAccount) { c.reset() }, 677 reuse.DefaultOptions[CreateAccount](), //. 678 ) //WithEnableChecker() 679 680 reuse.CreatePool[AccountAuthOption]( 681 func() *AccountAuthOption { return &AccountAuthOption{} }, 682 func(a *AccountAuthOption) { a.reset() }, 683 reuse.DefaultOptions[AccountAuthOption](), //. 684 ) //WithEnableChecker() 685 686 reuse.CreatePool[AccountIdentified]( 687 func() *AccountIdentified { return &AccountIdentified{} }, 688 func(a *AccountIdentified) { a.reset() }, 689 reuse.DefaultOptions[AccountIdentified](), //. 690 ) //WithEnableChecker() 691 692 reuse.CreatePool[AccountStatus]( 693 func() *AccountStatus { return &AccountStatus{} }, 694 func(a *AccountStatus) { a.reset() }, 695 reuse.DefaultOptions[AccountStatus](), //. 696 ) //WithEnableChecker() 697 698 reuse.CreatePool[AccountComment]( 699 func() *AccountComment { return &AccountComment{} }, 700 func(a *AccountComment) { a.reset() }, 701 reuse.DefaultOptions[AccountComment](), //. 702 ) //WithEnableChecker() 703 704 reuse.CreatePool[AccountCommentOrAttribute]( 705 func() *AccountCommentOrAttribute { return &AccountCommentOrAttribute{} }, 706 func(a *AccountCommentOrAttribute) { a.reset() }, 707 reuse.DefaultOptions[AccountCommentOrAttribute](), //. 708 ) //WithEnableChecker() 709 710 reuse.CreatePool[CreatePublication]( 711 func() *CreatePublication { return &CreatePublication{} }, 712 func(c *CreatePublication) { c.reset() }, 713 reuse.DefaultOptions[CreatePublication](), //. 714 ) //WithEnableChecker() 715 716 reuse.CreatePool[AttributeVisable]( 717 func() *AttributeVisable { return &AttributeVisable{} }, 718 func(a *AttributeVisable) { a.reset() }, 719 reuse.DefaultOptions[AttributeVisable](), //. 720 ) //WithEnableChecker() 721 } 722 723 type CreateOption interface { 724 NodeFormatter 725 } 726 727 type createOptionImpl struct { 728 CreateOption 729 } 730 731 type CreateOptionDefault struct { 732 createOptionImpl 733 } 734 735 type CreateOptionCharset struct { 736 createOptionImpl 737 IsDefault bool 738 Charset string 739 } 740 741 func (node *CreateOptionCharset) Format(ctx *FmtCtx) { 742 if node.IsDefault { 743 ctx.WriteString("default ") 744 } 745 ctx.WriteString("character set ") 746 ctx.WriteString(node.Charset) 747 } 748 749 func (node CreateOptionCharset) TypeName() string { return "tree.CreateOptionCharset" } 750 751 func (node *CreateOptionCharset) reset() { 752 *node = CreateOptionCharset{} 753 } 754 755 func (node *CreateOptionCharset) Free() { 756 reuse.Free[CreateOptionCharset](node, nil) 757 } 758 759 func NewCreateOptionCharset(i bool, c string) *CreateOptionCharset { 760 cc := reuse.Alloc[CreateOptionCharset](nil) 761 cc.IsDefault = i 762 cc.Charset = c 763 return cc 764 } 765 766 type CreateOptionCollate struct { 767 createOptionImpl 768 IsDefault bool 769 Collate string 770 } 771 772 func (node *CreateOptionCollate) Format(ctx *FmtCtx) { 773 if node.IsDefault { 774 ctx.WriteString("default ") 775 } 776 ctx.WriteString("collate ") 777 ctx.WriteString(node.Collate) 778 } 779 780 func (node CreateOptionCollate) TypeName() string { return "tree.CreateOptionCollate" } 781 782 func (node *CreateOptionCollate) reset() { 783 *node = CreateOptionCollate{} 784 } 785 786 func (node *CreateOptionCollate) Free() { 787 reuse.Free[CreateOptionCollate](node, nil) 788 } 789 790 func NewCreateOptionCollate(i bool, c string) *CreateOptionCollate { 791 cc := reuse.Alloc[CreateOptionCollate](nil) 792 cc.IsDefault = i 793 cc.Collate = c 794 return cc 795 } 796 797 type CreateOptionEncryption struct { 798 createOptionImpl 799 Encrypt string 800 } 801 802 func (node *CreateOptionEncryption) Format(ctx *FmtCtx) { 803 ctx.WriteString("encryption ") 804 ctx.WriteString(node.Encrypt) 805 } 806 807 func (node CreateOptionEncryption) TypeName() string { return "tree.CreateOptionEncryption" } 808 809 func (node *CreateOptionEncryption) reset() { 810 *node = CreateOptionEncryption{} 811 } 812 813 func (node *CreateOptionEncryption) Free() { 814 reuse.Free[CreateOptionEncryption](node, nil) 815 } 816 817 func NewCreateOptionEncryption(e string) *CreateOptionEncryption { 818 cr := reuse.Alloc[CreateOptionEncryption](nil) 819 cr.Encrypt = e 820 return cr 821 } 822 823 type SubscriptionOption struct { 824 statementImpl 825 From Identifier 826 Publication Identifier 827 } 828 829 func NewSubscriptionOption(from Identifier, publication Identifier) *SubscriptionOption { 830 s := reuse.Alloc[SubscriptionOption](nil) 831 s.From = from 832 s.Publication = publication 833 return s 834 } 835 836 func (node *SubscriptionOption) Format(ctx *FmtCtx) { 837 ctx.WriteString(" from ") 838 node.From.Format(ctx) 839 ctx.WriteString(" publication ") 840 node.Publication.Format(ctx) 841 } 842 843 func (node SubscriptionOption) TypeName() string { return "tree.SubscriptionOption" } 844 845 func (node *SubscriptionOption) reset() { 846 *node = SubscriptionOption{} 847 } 848 849 func (node *SubscriptionOption) Free() { 850 reuse.Free[SubscriptionOption](node, nil) 851 } 852 853 type CreateDatabase struct { 854 statementImpl 855 IfNotExists bool 856 Name Identifier 857 CreateOptions []CreateOption 858 SubscriptionOption *SubscriptionOption 859 Sql string 860 } 861 862 func (node *CreateDatabase) Format(ctx *FmtCtx) { 863 ctx.WriteString("create database ") 864 if node.IfNotExists { 865 ctx.WriteString("if not exists ") 866 } 867 node.Name.Format(ctx) 868 869 if node.SubscriptionOption != nil { 870 node.SubscriptionOption.Format(ctx) 871 } 872 873 if node.CreateOptions != nil { 874 for _, opt := range node.CreateOptions { 875 ctx.WriteByte(' ') 876 opt.Format(ctx) 877 } 878 } 879 } 880 881 func (node *CreateDatabase) GetStatementType() string { return "Create Database" } 882 func (node *CreateDatabase) GetQueryType() string { return QueryTypeDDL } 883 884 func (node CreateDatabase) TypeName() string { return "tree.CreateDatabase" } 885 886 func (node *CreateDatabase) reset() { 887 if node.CreateOptions != nil { 888 for _, item := range node.CreateOptions { 889 switch opt := item.(type) { 890 case *CreateOptionCharset: 891 opt.Free() 892 case *CreateOptionCollate: 893 opt.Free() 894 case *CreateOptionEncryption: 895 opt.Free() 896 } 897 } 898 } 899 if node.SubscriptionOption != nil { 900 node.SubscriptionOption.Free() 901 } 902 *node = CreateDatabase{} 903 } 904 905 func (node *CreateDatabase) Free() { 906 reuse.Free[CreateDatabase](node, nil) 907 } 908 909 func NewCreateDatabase(ine bool, name Identifier, sub *SubscriptionOption, opts []CreateOption) *CreateDatabase { 910 cr := reuse.Alloc[CreateDatabase](nil) 911 cr.IfNotExists = ine 912 cr.Name = name 913 cr.SubscriptionOption = sub 914 cr.CreateOptions = opts 915 return cr 916 } 917 918 type CreateTable struct { 919 statementImpl 920 /* 921 it is impossible to be the temporary table, the cluster table, 922 the normal table and the external table at the same time. 923 */ 924 Temporary bool 925 IsClusterTable bool 926 IfNotExists bool 927 Table TableName 928 Defs TableDefs 929 Options []TableOption 930 PartitionOption *PartitionOption 931 ClusterByOption *ClusterByOption 932 Param *ExternParam 933 AsSource *Select 934 IsDynamicTable bool 935 DTOptions []TableOption 936 IsAsSelect bool 937 IsAsLike bool 938 LikeTableName TableName 939 SubscriptionOption *SubscriptionOption 940 } 941 942 func NewCreateTable() *CreateTable { 943 return reuse.Alloc[CreateTable](nil) 944 } 945 946 func (node *CreateTable) Format(ctx *FmtCtx) { 947 ctx.WriteString("create") 948 if node.Temporary { 949 ctx.WriteString(" temporary") 950 } 951 if node.IsClusterTable { 952 ctx.WriteString(" cluster") 953 } 954 if node.Param != nil { 955 ctx.WriteString(" external") 956 } 957 if node.IsDynamicTable { 958 ctx.WriteString(" dynamic") 959 } 960 961 ctx.WriteString(" table") 962 963 if node.IfNotExists { 964 ctx.WriteString(" if not exists") 965 } 966 967 ctx.WriteByte(' ') 968 node.Table.Format(ctx) 969 970 if node.IsAsLike { 971 ctx.WriteString(" like ") 972 node.LikeTableName.Format(ctx) 973 return 974 } 975 976 if node.SubscriptionOption != nil { 977 node.SubscriptionOption.Format(ctx) 978 } else if node.IsDynamicTable { 979 ctx.WriteString(" as ") 980 node.AsSource.Format(ctx) 981 982 if node.DTOptions != nil { 983 prefix := " with (" 984 for _, t := range node.DTOptions { 985 ctx.WriteString(prefix) 986 t.Format(ctx) 987 prefix = ", " 988 } 989 ctx.WriteByte(')') 990 } 991 } else { 992 993 ctx.WriteString(" (") 994 for i, def := range node.Defs { 995 if i != 0 { 996 ctx.WriteString(",") 997 ctx.WriteByte(' ') 998 } 999 def.Format(ctx) 1000 } 1001 ctx.WriteByte(')') 1002 } 1003 1004 if node.IsAsSelect { 1005 ctx.WriteString(" as ") 1006 node.AsSource.Format(ctx) 1007 } 1008 1009 if node.Options != nil && !node.IsDynamicTable { 1010 prefix := " " 1011 for _, t := range node.Options { 1012 ctx.WriteString(prefix) 1013 t.Format(ctx) 1014 } 1015 } 1016 1017 if node.PartitionOption != nil { 1018 ctx.WriteByte(' ') 1019 node.PartitionOption.Format(ctx) 1020 } 1021 1022 if node.Param != nil { 1023 if len(node.Param.Option) == 0 { 1024 ctx.WriteString(" infile ") 1025 ctx.WriteString("'" + node.Param.Filepath + "'") 1026 } else { 1027 if node.Param.ScanType == S3 { 1028 ctx.WriteString(" url s3option ") 1029 } else { 1030 ctx.WriteString(" infile ") 1031 } 1032 ctx.WriteString("{") 1033 for i := 0; i < len(node.Param.Option); i += 2 { 1034 switch strings.ToLower(node.Param.Option[i]) { 1035 case "endpoint": 1036 ctx.WriteString("'endpoint'='" + node.Param.Option[i+1] + "'") 1037 case "region": 1038 ctx.WriteString("'region'='" + node.Param.Option[i+1] + "'") 1039 case "access_key_id": 1040 ctx.WriteString("'access_key_id'='******'") 1041 case "secret_access_key": 1042 ctx.WriteString("'secret_access_key'='******'") 1043 case "bucket": 1044 ctx.WriteString("'bucket'='" + node.Param.Option[i+1] + "'") 1045 case "filepath": 1046 ctx.WriteString("'filepath'='" + node.Param.Option[i+1] + "'") 1047 case "compression": 1048 ctx.WriteString("'compression'='" + node.Param.Option[i+1] + "'") 1049 case "format": 1050 ctx.WriteString("'format'='" + node.Param.Option[i+1] + "'") 1051 case "jsondata": 1052 ctx.WriteString("'jsondata'='" + node.Param.Option[i+1] + "'") 1053 } 1054 if i != len(node.Param.Option)-2 { 1055 ctx.WriteString(", ") 1056 } 1057 } 1058 ctx.WriteString("}") 1059 } 1060 if node.Param.Tail.Fields != nil { 1061 ctx.WriteByte(' ') 1062 node.Param.Tail.Fields.Format(ctx) 1063 } 1064 1065 if node.Param.Tail.Lines != nil { 1066 ctx.WriteByte(' ') 1067 node.Param.Tail.Lines.Format(ctx) 1068 } 1069 1070 if node.Param.Tail.IgnoredLines != 0 { 1071 ctx.WriteString(" ignore ") 1072 ctx.WriteString(strconv.FormatUint(node.Param.Tail.IgnoredLines, 10)) 1073 ctx.WriteString(" lines") 1074 } 1075 if node.Param.Tail.ColumnList != nil { 1076 prefix := " (" 1077 for _, c := range node.Param.Tail.ColumnList { 1078 ctx.WriteString(prefix) 1079 c.Format(ctx) 1080 prefix = ", " 1081 } 1082 ctx.WriteByte(')') 1083 } 1084 if node.Param.Tail.Assignments != nil { 1085 ctx.WriteString(" set ") 1086 node.Param.Tail.Assignments.Format(ctx) 1087 } 1088 } 1089 } 1090 1091 func (node *CreateTable) GetStatementType() string { return "Create Table" } 1092 1093 func (node *CreateTable) GetQueryType() string { return QueryTypeDDL } 1094 1095 func (node CreateTable) TypeName() string { return "tree.CreateTable" } 1096 1097 func (node *CreateTable) reset() { 1098 1099 if node.Defs != nil { 1100 for _, def := range node.Defs { 1101 switch d := def.(type) { 1102 case *ColumnTableDef: 1103 d.Free() 1104 case *PrimaryKeyIndex: 1105 d.Free() 1106 case *Index: 1107 d.Free() 1108 case *UniqueIndex: 1109 d.Free() 1110 case *ForeignKey: 1111 d.Free() 1112 case *FullTextIndex: 1113 d.Free() 1114 case *CheckIndex: 1115 d.Free() 1116 default: 1117 if d != nil { 1118 panic(fmt.Sprintf("miss Free for %v", def)) 1119 } 1120 } 1121 } 1122 } 1123 1124 if node.Options != nil { 1125 for _, item := range node.Options { 1126 switch opt := item.(type) { 1127 case *TableOptionProperties: 1128 opt.Free() 1129 case *TableOptionEngine: 1130 opt.Free() 1131 case *TableOptionEngineAttr: 1132 opt.Free() 1133 case *TableOptionInsertMethod: 1134 opt.Free() 1135 case *TableOptionSecondaryEngine: 1136 opt.Free() 1137 case *TableOptionSecondaryEngineNull: 1138 panic("currently not used") 1139 case *TableOptionCharset: 1140 opt.Free() 1141 case *TableOptionCollate: 1142 opt.Free() 1143 case *TableOptionAUTOEXTEND_SIZE: 1144 opt.Free() 1145 case *TableOptionAutoIncrement: 1146 opt.Free() 1147 case *TableOptionComment: 1148 opt.Free() 1149 case *TableOptionAvgRowLength: 1150 opt.Free() 1151 case *TableOptionChecksum: 1152 opt.Free() 1153 case *TableOptionCompression: 1154 opt.Free() 1155 case *TableOptionConnection: 1156 opt.Free() 1157 case *TableOptionPassword: 1158 opt.Free() 1159 case *TableOptionKeyBlockSize: 1160 opt.Free() 1161 case *TableOptionMaxRows: 1162 opt.Free() 1163 case *TableOptionMinRows: 1164 opt.Free() 1165 case *TableOptionDelayKeyWrite: 1166 opt.Free() 1167 case *TableOptionRowFormat: 1168 opt.Free() 1169 case *TableOptionStartTrans: 1170 opt.Free() 1171 case *TableOptionSecondaryEngineAttr: 1172 opt.Free() 1173 case *TableOptionStatsPersistent: 1174 opt.Free() 1175 case *TableOptionStatsAutoRecalc: 1176 opt.Free() 1177 case *TableOptionPackKeys: 1178 opt.Free() 1179 case *TableOptionTablespace: 1180 opt.Free() 1181 case *TableOptionDataDirectory: 1182 opt.Free() 1183 case *TableOptionIndexDirectory: 1184 opt.Free() 1185 case *TableOptionStorageMedia: 1186 opt.Free() 1187 case *TableOptionStatsSamplePages: 1188 opt.Free() 1189 case *TableOptionUnion: 1190 opt.Free() 1191 case *TableOptionEncryption: 1192 opt.Free() 1193 default: 1194 if opt != nil { 1195 panic(fmt.Sprintf("miss Free for %v", item)) 1196 } 1197 } 1198 } 1199 } 1200 1201 if node.PartitionOption != nil { 1202 node.PartitionOption.Free() 1203 } 1204 1205 if node.ClusterByOption != nil { 1206 node.ClusterByOption.Free() 1207 } 1208 1209 // if node.AsSource != nil { 1210 // reuse.Free[Select](node.AsSource, nil) 1211 // } 1212 1213 if node.DTOptions != nil { 1214 for _, item := range node.DTOptions { 1215 switch opt := item.(type) { 1216 case *TableOptionProperties: 1217 opt.Free() 1218 case *TableOptionEngine: 1219 opt.Free() 1220 case *TableOptionEngineAttr: 1221 opt.Free() 1222 case *TableOptionInsertMethod: 1223 opt.Free() 1224 case *TableOptionSecondaryEngine: 1225 opt.Free() 1226 case *TableOptionSecondaryEngineNull: 1227 panic("currently not used") 1228 case *TableOptionCharset: 1229 opt.Free() 1230 case *TableOptionCollate: 1231 opt.Free() 1232 case *TableOptionAUTOEXTEND_SIZE: 1233 opt.Free() 1234 case *TableOptionAutoIncrement: 1235 opt.Free() 1236 case *TableOptionComment: 1237 opt.Free() 1238 case *TableOptionAvgRowLength: 1239 opt.Free() 1240 case *TableOptionChecksum: 1241 opt.Free() 1242 case *TableOptionCompression: 1243 opt.Free() 1244 case *TableOptionConnection: 1245 opt.Free() 1246 case *TableOptionPassword: 1247 opt.Free() 1248 case *TableOptionKeyBlockSize: 1249 opt.Free() 1250 case *TableOptionMaxRows: 1251 opt.Free() 1252 case *TableOptionMinRows: 1253 opt.Free() 1254 case *TableOptionDelayKeyWrite: 1255 opt.Free() 1256 case *TableOptionRowFormat: 1257 opt.Free() 1258 case *TableOptionStartTrans: 1259 opt.Free() 1260 case *TableOptionSecondaryEngineAttr: 1261 opt.Free() 1262 case *TableOptionStatsPersistent: 1263 opt.Free() 1264 case *TableOptionStatsAutoRecalc: 1265 opt.Free() 1266 case *TableOptionPackKeys: 1267 opt.Free() 1268 case *TableOptionTablespace: 1269 opt.Free() 1270 case *TableOptionDataDirectory: 1271 opt.Free() 1272 case *TableOptionIndexDirectory: 1273 opt.Free() 1274 case *TableOptionStorageMedia: 1275 opt.Free() 1276 case *TableOptionStatsSamplePages: 1277 opt.Free() 1278 case *TableOptionUnion: 1279 opt.Free() 1280 case *TableOptionEncryption: 1281 opt.Free() 1282 default: 1283 if opt != nil { 1284 panic(fmt.Sprintf("miss Free for %v", item)) 1285 } 1286 } 1287 } 1288 } 1289 1290 *node = CreateTable{} 1291 } 1292 1293 func (node *CreateTable) Free() { 1294 reuse.Free[CreateTable](node, nil) 1295 } 1296 1297 type TableDef interface { 1298 NodeFormatter 1299 } 1300 1301 type tableDefImpl struct { 1302 TableDef 1303 } 1304 1305 // the list of table definitions 1306 type TableDefs []TableDef 1307 1308 type ColumnTableDef struct { 1309 tableDefImpl 1310 Name *UnresolvedName 1311 Type ResolvableTypeReference 1312 Attributes []ColumnAttribute 1313 } 1314 1315 func (node *ColumnTableDef) Format(ctx *FmtCtx) { 1316 node.Name.Format(ctx) 1317 1318 ctx.WriteByte(' ') 1319 node.Type.(*T).InternalType.Format(ctx) 1320 1321 if node.Attributes != nil { 1322 prefix := " " 1323 for _, a := range node.Attributes { 1324 ctx.WriteString(prefix) 1325 if a != nil { 1326 a.Format(ctx) 1327 } 1328 } 1329 } 1330 } 1331 1332 func (node ColumnTableDef) TypeName() string { return "tree.ColumnTableDef" } 1333 1334 func (node *ColumnTableDef) reset() { 1335 // if node.Name != nil { 1336 // reuse.Free[UnresolvedName](node.Name, nil) 1337 // } 1338 if node.Attributes != nil { 1339 for _, item := range node.Attributes { 1340 switch opt := item.(type) { 1341 case *AttributeNull: 1342 opt.Free() 1343 case *AttributeDefault: 1344 opt.Free() 1345 case *AttributeAutoIncrement: 1346 opt.Free() 1347 case *AttributeUniqueKey: 1348 opt.Free() 1349 case *AttributeUnique: 1350 opt.Free() 1351 case *AttributeKey: 1352 opt.Free() 1353 case *AttributePrimaryKey: 1354 opt.Free() 1355 case *AttributeComment: 1356 opt.Free() 1357 case *AttributeCollate: 1358 opt.Free() 1359 case *AttributeColumnFormat: 1360 opt.Free() 1361 case *AttributeStorage: 1362 opt.Free() 1363 case *AttributeCheckConstraint: 1364 opt.Free() 1365 case *AttributeGeneratedAlways: 1366 opt.Free() 1367 case *AttributeLowCardinality: 1368 opt.Free() 1369 case *AttributeReference: 1370 opt.Free() 1371 case *AttributeAutoRandom: 1372 panic("currently not used") 1373 case *AttributeOnUpdate: 1374 opt.Free() 1375 case *AttributeVisable: 1376 opt.Free() 1377 case *KeyPart: 1378 opt.Free() 1379 default: 1380 if opt != nil { 1381 panic(fmt.Sprintf("miss Free for %v", item)) 1382 } 1383 } 1384 } 1385 } 1386 *node = ColumnTableDef{} 1387 } 1388 1389 func (node *ColumnTableDef) Free() { 1390 reuse.Free[ColumnTableDef](node, nil) 1391 } 1392 1393 func NewColumnTableDef(n *UnresolvedName, t ResolvableTypeReference, a []ColumnAttribute) *ColumnTableDef { 1394 co := reuse.Alloc[ColumnTableDef](nil) 1395 co.Name = n 1396 co.Type = t 1397 co.Attributes = a 1398 return co 1399 } 1400 1401 // column attribute 1402 type ColumnAttribute interface { 1403 NodeFormatter 1404 } 1405 1406 type columnAttributeImpl struct { 1407 ColumnAttribute 1408 } 1409 1410 type AttributeNull struct { 1411 columnAttributeImpl 1412 Is bool // true NULL (default); false NOT NULL 1413 } 1414 1415 func (node *AttributeNull) Format(ctx *FmtCtx) { 1416 if node.Is { 1417 ctx.WriteString("null") 1418 } else { 1419 ctx.WriteString("not null") 1420 } 1421 } 1422 1423 func (node AttributeNull) TypeName() string { return "tree.AttributeNull" } 1424 1425 func (node *AttributeNull) reset() { 1426 *node = AttributeNull{} 1427 } 1428 1429 func (node *AttributeNull) Free() { 1430 reuse.Free[AttributeNull](node, nil) 1431 } 1432 1433 func NewAttributeNull(b bool) *AttributeNull { 1434 a := reuse.Alloc[AttributeNull](nil) 1435 a.Is = b 1436 return a 1437 } 1438 1439 type AttributeDefault struct { 1440 columnAttributeImpl 1441 Expr Expr 1442 } 1443 1444 func (node *AttributeDefault) Format(ctx *FmtCtx) { 1445 ctx.WriteString("default ") 1446 if node.Expr != nil { 1447 node.Expr.Format(ctx) 1448 } 1449 } 1450 1451 func (node AttributeDefault) TypeName() string { return "tree.AttributeDefault" } 1452 1453 func (node *AttributeDefault) reset() { 1454 *node = AttributeDefault{} 1455 } 1456 1457 func (node *AttributeDefault) Free() { 1458 reuse.Free[AttributeDefault](node, nil) 1459 } 1460 1461 func NewAttributeDefault(e Expr) *AttributeDefault { 1462 a := reuse.Alloc[AttributeDefault](nil) 1463 a.Expr = e 1464 return a 1465 } 1466 1467 type AttributeAutoIncrement struct { 1468 columnAttributeImpl 1469 IsAutoIncrement bool 1470 } 1471 1472 func (node *AttributeAutoIncrement) Format(ctx *FmtCtx) { 1473 ctx.WriteString("auto_increment") 1474 } 1475 1476 func (node AttributeAutoIncrement) TypeName() string { return "tree.AttributeAutoIncrement" } 1477 1478 func (node *AttributeAutoIncrement) reset() { 1479 *node = AttributeAutoIncrement{} 1480 } 1481 1482 func (node *AttributeAutoIncrement) Free() { 1483 reuse.Free[AttributeAutoIncrement](node, nil) 1484 } 1485 1486 func NewAttributeAutoIncrement() *AttributeAutoIncrement { 1487 return reuse.Alloc[AttributeAutoIncrement](nil) 1488 } 1489 1490 type AttributeUniqueKey struct { 1491 columnAttributeImpl 1492 } 1493 1494 func (node *AttributeUniqueKey) Format(ctx *FmtCtx) { 1495 ctx.WriteString("unique key") 1496 } 1497 1498 func (node AttributeUniqueKey) TypeName() string { return "tree.AttributeUniqueKey" } 1499 1500 func (node *AttributeUniqueKey) reset() { 1501 *node = AttributeUniqueKey{} 1502 } 1503 1504 func (node *AttributeUniqueKey) Free() { 1505 reuse.Free[AttributeUniqueKey](node, nil) 1506 } 1507 1508 func NewAttributeUniqueKey() *AttributeUniqueKey { 1509 return reuse.Alloc[AttributeUniqueKey](nil) 1510 } 1511 1512 type AttributeUnique struct { 1513 columnAttributeImpl 1514 } 1515 1516 func (node *AttributeUnique) Format(ctx *FmtCtx) { 1517 ctx.WriteString("unique") 1518 } 1519 1520 func (node AttributeUnique) TypeName() string { return "tree.AttributeUnique" } 1521 1522 func (node *AttributeUnique) reset() { 1523 *node = AttributeUnique{} 1524 } 1525 1526 func (node *AttributeUnique) Free() { 1527 reuse.Free[AttributeUnique](node, nil) 1528 } 1529 1530 func NewAttributeUnique() *AttributeUnique { 1531 return reuse.Alloc[AttributeUnique](nil) 1532 } 1533 1534 type AttributeKey struct { 1535 columnAttributeImpl 1536 } 1537 1538 func (node *AttributeKey) Format(ctx *FmtCtx) { 1539 ctx.WriteString("key") 1540 } 1541 1542 func (node AttributeKey) TypeName() string { return "tree.AttributeKey" } 1543 1544 func (node *AttributeKey) reset() { 1545 *node = AttributeKey{} 1546 } 1547 1548 func (node *AttributeKey) Free() { 1549 reuse.Free[AttributeKey](node, nil) 1550 } 1551 1552 func NewAttributeKey() *AttributeKey { 1553 return reuse.Alloc[AttributeKey](nil) 1554 } 1555 1556 type AttributePrimaryKey struct { 1557 columnAttributeImpl 1558 } 1559 1560 func (node *AttributePrimaryKey) Format(ctx *FmtCtx) { 1561 ctx.WriteString("primary key") 1562 } 1563 1564 func (node AttributePrimaryKey) TypeName() string { return "tree.AttributePrimaryKey" } 1565 1566 func (node *AttributePrimaryKey) reset() { 1567 *node = AttributePrimaryKey{} 1568 } 1569 1570 func (node *AttributePrimaryKey) Free() { 1571 reuse.Free[AttributePrimaryKey](node, nil) 1572 } 1573 1574 func NewAttributePrimaryKey() *AttributePrimaryKey { 1575 return reuse.Alloc[AttributePrimaryKey](nil) 1576 } 1577 1578 type AttributeComment struct { 1579 columnAttributeImpl 1580 CMT Expr 1581 } 1582 1583 func (node *AttributeComment) Format(ctx *FmtCtx) { 1584 ctx.WriteString("comment ") 1585 node.CMT.Format(ctx) 1586 } 1587 1588 func (node AttributeComment) TypeName() string { return "tree.AttributeComment" } 1589 1590 func (node *AttributeComment) reset() { 1591 *node = AttributeComment{} 1592 } 1593 1594 func (node *AttributeComment) Free() { 1595 reuse.Free[AttributeComment](node, nil) 1596 } 1597 1598 func NewAttributeComment(c Expr) *AttributeComment { 1599 ac := reuse.Alloc[AttributeComment](nil) 1600 ac.CMT = c 1601 return ac 1602 } 1603 1604 type AttributeCollate struct { 1605 columnAttributeImpl 1606 Collate string 1607 } 1608 1609 func (node *AttributeCollate) Format(ctx *FmtCtx) { 1610 ctx.WriteString("collate ") 1611 ctx.WriteString(node.Collate) 1612 } 1613 1614 func (node AttributeCollate) TypeName() string { return "tree.AttributeCollate" } 1615 1616 func (node *AttributeCollate) reset() { 1617 *node = AttributeCollate{} 1618 } 1619 1620 func (node *AttributeCollate) Free() { 1621 reuse.Free[AttributeCollate](node, nil) 1622 } 1623 1624 func NewAttributeCollate(c string) *AttributeCollate { 1625 ac := reuse.Alloc[AttributeCollate](nil) 1626 ac.Collate = c 1627 return ac 1628 } 1629 1630 type AttributeColumnFormat struct { 1631 columnAttributeImpl 1632 ColumnFormat string 1633 } 1634 1635 func (node *AttributeColumnFormat) Format(ctx *FmtCtx) { 1636 ctx.WriteString("format ") 1637 ctx.WriteString(node.ColumnFormat) 1638 } 1639 1640 func (node AttributeColumnFormat) TypeName() string { return "tree.AttributeColumnFormat" } 1641 1642 func (node *AttributeColumnFormat) reset() { 1643 *node = AttributeColumnFormat{} 1644 } 1645 1646 func (node *AttributeColumnFormat) Free() { 1647 reuse.Free[AttributeColumnFormat](node, nil) 1648 } 1649 1650 func NewAttributeColumnFormat(f string) *AttributeColumnFormat { 1651 ac := reuse.Alloc[AttributeColumnFormat](nil) 1652 ac.ColumnFormat = f 1653 return ac 1654 } 1655 1656 type AttributeStorage struct { 1657 columnAttributeImpl 1658 Storage string 1659 } 1660 1661 func (node *AttributeStorage) Format(ctx *FmtCtx) { 1662 ctx.WriteString("storage ") 1663 ctx.WriteString(node.Storage) 1664 } 1665 1666 func (node AttributeStorage) TypeName() string { return "tree.AttributeStorage" } 1667 1668 func (node *AttributeStorage) reset() { 1669 *node = AttributeStorage{} 1670 } 1671 1672 func (node *AttributeStorage) Free() { 1673 reuse.Free[AttributeStorage](node, nil) 1674 } 1675 1676 func NewAttributeStorage(s string) *AttributeStorage { 1677 as := reuse.Alloc[AttributeStorage](nil) 1678 as.Storage = s 1679 return as 1680 } 1681 1682 type AttributeCheckConstraint struct { 1683 columnAttributeImpl 1684 Name string 1685 Expr Expr 1686 Enforced bool 1687 } 1688 1689 func (node *AttributeCheckConstraint) Format(ctx *FmtCtx) { 1690 ctx.WriteString("constraint") 1691 if node.Name != "" { 1692 ctx.WriteByte(' ') 1693 ctx.WriteString(node.Name) 1694 } 1695 ctx.WriteString(" check") 1696 ctx.WriteString(" (") 1697 node.Expr.Format(ctx) 1698 ctx.WriteString(") ") 1699 1700 if node.Enforced { 1701 ctx.WriteString("enforced") 1702 } else { 1703 ctx.WriteString("not enforced") 1704 } 1705 } 1706 1707 func (node AttributeCheckConstraint) TypeName() string { return "tree.AttributeCheckConstraint" } 1708 1709 func (node *AttributeCheckConstraint) reset() { 1710 *node = AttributeCheckConstraint{} 1711 } 1712 1713 func (node *AttributeCheckConstraint) Free() { 1714 reuse.Free[AttributeCheckConstraint](node, nil) 1715 } 1716 1717 func NewAttributeCheckConstraint(e Expr, f bool, n string) *AttributeCheckConstraint { 1718 ac := reuse.Alloc[AttributeCheckConstraint](nil) 1719 ac.Name = n 1720 ac.Expr = e 1721 ac.Enforced = f 1722 return ac 1723 } 1724 1725 type AttributeGeneratedAlways struct { 1726 columnAttributeImpl 1727 Expr Expr 1728 Stored bool 1729 } 1730 1731 func (node *AttributeGeneratedAlways) Format(ctx *FmtCtx) { 1732 node.Expr.Format(ctx) 1733 } 1734 1735 func (node AttributeGeneratedAlways) TypeName() string { return "tree.AttributeGeneratedAlways" } 1736 1737 func (node *AttributeGeneratedAlways) reset() { 1738 *node = AttributeGeneratedAlways{} 1739 } 1740 1741 func (node *AttributeGeneratedAlways) Free() { 1742 reuse.Free[AttributeGeneratedAlways](node, nil) 1743 } 1744 1745 func NewAttributeGeneratedAlways(e Expr, s bool) *AttributeGeneratedAlways { 1746 ag := reuse.Alloc[AttributeGeneratedAlways](nil) 1747 ag.Expr = e 1748 ag.Stored = s 1749 return ag 1750 } 1751 1752 type AttributeLowCardinality struct { 1753 columnAttributeImpl 1754 } 1755 1756 func (node *AttributeLowCardinality) Format(ctx *FmtCtx) { 1757 ctx.WriteString("low_cardinality") 1758 } 1759 1760 func (node AttributeLowCardinality) TypeName() string { return "tree.AttributeLowCardinality" } 1761 1762 func (node *AttributeLowCardinality) reset() { 1763 *node = AttributeLowCardinality{} 1764 } 1765 1766 func (node *AttributeLowCardinality) Free() { 1767 reuse.Free[AttributeLowCardinality](node, nil) 1768 } 1769 1770 func NewAttributeLowCardinality() *AttributeLowCardinality { 1771 return reuse.Alloc[AttributeLowCardinality](nil) 1772 } 1773 1774 type KeyPart struct { 1775 columnAttributeImpl 1776 ColName *UnresolvedName 1777 Length int 1778 Direction Direction // asc or desc 1779 Expr Expr 1780 } 1781 1782 func (node *KeyPart) Format(ctx *FmtCtx) { 1783 if node.ColName != nil { 1784 node.ColName.Format(ctx) 1785 } 1786 if node.Length != 0 { 1787 ctx.WriteByte('(') 1788 if node.Length == -1 { 1789 ctx.WriteString("0") 1790 } else { 1791 ctx.WriteString(strconv.Itoa(node.Length)) 1792 } 1793 ctx.WriteByte(')') 1794 } 1795 if node.Direction != DefaultDirection { 1796 ctx.WriteByte(' ') 1797 ctx.WriteString(node.Direction.String()) 1798 return 1799 } 1800 if node.Expr != nil { 1801 ctx.WriteByte('(') 1802 node.Expr.Format(ctx) 1803 ctx.WriteByte(')') 1804 if node.Direction != DefaultDirection { 1805 ctx.WriteByte(' ') 1806 ctx.WriteString(node.Direction.String()) 1807 } 1808 } 1809 } 1810 1811 func (node KeyPart) TypeName() string { return "tree.KeyPart" } 1812 1813 func (node *KeyPart) reset() { 1814 // if node.ColName != nil { 1815 // reuse.Free[UnresolvedName](node.ColName, nil) 1816 // } 1817 *node = KeyPart{} 1818 } 1819 1820 func (node *KeyPart) Free() { 1821 reuse.Free[KeyPart](node, nil) 1822 } 1823 1824 func NewKeyPart(c *UnresolvedName, l int, d Direction, e Expr) *KeyPart { 1825 kp := reuse.Alloc[KeyPart](nil) 1826 kp.ColName = c 1827 kp.Length = l 1828 kp.Direction = d 1829 kp.Expr = e 1830 return kp 1831 } 1832 1833 // in reference definition 1834 type MatchType int 1835 1836 func (node *MatchType) ToString() string { 1837 switch *node { 1838 case MATCH_FULL: 1839 return "full" 1840 case MATCH_PARTIAL: 1841 return "partial" 1842 case MATCH_SIMPLE: 1843 return "simple" 1844 default: 1845 return "Unknown MatchType" 1846 } 1847 } 1848 1849 const ( 1850 MATCH_INVALID MatchType = iota 1851 MATCH_FULL 1852 MATCH_PARTIAL 1853 MATCH_SIMPLE 1854 ) 1855 1856 type ReferenceOptionType int 1857 1858 func (node *ReferenceOptionType) ToString() string { 1859 switch *node { 1860 case REFERENCE_OPTION_RESTRICT: 1861 return "restrict" 1862 case REFERENCE_OPTION_CASCADE: 1863 return "cascade" 1864 case REFERENCE_OPTION_SET_NULL: 1865 return "set null" 1866 case REFERENCE_OPTION_NO_ACTION: 1867 return "no action" 1868 case REFERENCE_OPTION_SET_DEFAULT: 1869 return "set default" 1870 default: 1871 return "Unknown ReferenceOptionType" 1872 } 1873 } 1874 1875 // Reference option 1876 const ( 1877 REFERENCE_OPTION_INVALID ReferenceOptionType = iota 1878 REFERENCE_OPTION_RESTRICT 1879 REFERENCE_OPTION_CASCADE 1880 REFERENCE_OPTION_SET_NULL 1881 REFERENCE_OPTION_NO_ACTION 1882 REFERENCE_OPTION_SET_DEFAULT 1883 ) 1884 1885 type AttributeReference struct { 1886 columnAttributeImpl 1887 TableName *TableName 1888 KeyParts []*KeyPart 1889 Match MatchType 1890 OnDelete ReferenceOptionType 1891 OnUpdate ReferenceOptionType 1892 } 1893 1894 func (node *AttributeReference) Format(ctx *FmtCtx) { 1895 ctx.WriteString("references ") 1896 node.TableName.Format(ctx) 1897 if node.KeyParts != nil { 1898 ctx.WriteByte('(') 1899 prefix := "" 1900 for _, k := range node.KeyParts { 1901 ctx.WriteString(prefix) 1902 k.Format(ctx) 1903 prefix = ", " 1904 } 1905 ctx.WriteByte(')') 1906 } 1907 if node.Match != MATCH_INVALID { 1908 ctx.WriteString(" match ") 1909 ctx.WriteString(node.Match.ToString()) 1910 } 1911 if node.OnDelete != REFERENCE_OPTION_INVALID { 1912 ctx.WriteString(" on delete ") 1913 ctx.WriteString(node.OnDelete.ToString()) 1914 } 1915 if node.OnUpdate != REFERENCE_OPTION_INVALID { 1916 ctx.WriteString(" on update ") 1917 ctx.WriteString(node.OnUpdate.ToString()) 1918 } 1919 } 1920 1921 func (node AttributeReference) TypeName() string { return "tree.AttributeReference" } 1922 1923 func (node *AttributeReference) reset() { 1924 // if node.TableName != nil { 1925 // reuse.Free[TableName](node.TableName, nil) 1926 // } 1927 if node.KeyParts != nil { 1928 for _, item := range node.KeyParts { 1929 reuse.Free[KeyPart](item, nil) 1930 } 1931 } 1932 *node = AttributeReference{} 1933 } 1934 1935 func (node *AttributeReference) Free() { 1936 reuse.Free[AttributeReference](node, nil) 1937 } 1938 1939 func NewAttributeReference(t *TableName, kps []*KeyPart, m MatchType, 1940 od ReferenceOptionType, ou ReferenceOptionType, 1941 ) *AttributeReference { 1942 ar := reuse.Alloc[AttributeReference](nil) 1943 ar.TableName = t 1944 ar.KeyParts = kps 1945 ar.Match = m 1946 ar.OnDelete = od 1947 ar.OnUpdate = ou 1948 return ar 1949 } 1950 1951 type ReferenceOnRecord struct { 1952 OnDelete ReferenceOptionType 1953 OnUpdate ReferenceOptionType 1954 } 1955 1956 type AttributeAutoRandom struct { 1957 columnAttributeImpl 1958 BitLength int 1959 } 1960 1961 func NewAttributeAutoRandom(b int) *AttributeAutoRandom { 1962 aa := reuse.Alloc[AttributeAutoRandom](nil) 1963 aa.BitLength = b 1964 return aa 1965 } 1966 1967 func (node AttributeAutoRandom) TypeName() string { return "tree.AttributeAutoRandom" } 1968 1969 type AttributeOnUpdate struct { 1970 columnAttributeImpl 1971 Expr Expr 1972 } 1973 1974 func (node *AttributeOnUpdate) Format(ctx *FmtCtx) { 1975 ctx.WriteString("on update ") 1976 node.Expr.Format(ctx) 1977 } 1978 1979 func (node AttributeOnUpdate) TypeName() string { return "tree.AttributeOnUpdate" } 1980 1981 func (node *AttributeOnUpdate) reset() { 1982 *node = AttributeOnUpdate{} 1983 } 1984 1985 func (node *AttributeOnUpdate) Free() { 1986 reuse.Free[AttributeOnUpdate](node, nil) 1987 } 1988 1989 func NewAttributeOnUpdate(e Expr) *AttributeOnUpdate { 1990 ao := reuse.Alloc[AttributeOnUpdate](nil) 1991 ao.Expr = e 1992 return ao 1993 } 1994 1995 type IndexType int 1996 1997 func (it IndexType) ToString() string { 1998 switch it { 1999 case INDEX_TYPE_BTREE: 2000 return "btree" 2001 case INDEX_TYPE_HASH: 2002 return "hash" 2003 case INDEX_TYPE_RTREE: 2004 return "rtree" 2005 case INDEX_TYPE_BSI: 2006 return "bsi" 2007 case INDEX_TYPE_ZONEMAP: 2008 return "zonemap" 2009 case INDEX_TYPE_IVFFLAT: 2010 return "ivfflat" 2011 case INDEX_TYPE_MASTER: 2012 return "master" 2013 case INDEX_TYPE_INVALID: 2014 return "" 2015 default: 2016 return "Unknown IndexType" 2017 } 2018 } 2019 2020 const ( 2021 INDEX_TYPE_INVALID IndexType = iota 2022 INDEX_TYPE_BTREE 2023 INDEX_TYPE_HASH 2024 INDEX_TYPE_RTREE 2025 INDEX_TYPE_BSI 2026 INDEX_TYPE_ZONEMAP 2027 INDEX_TYPE_IVFFLAT 2028 INDEX_TYPE_MASTER 2029 ) 2030 2031 type VisibleType int 2032 2033 const ( 2034 VISIBLE_TYPE_INVALID VisibleType = iota 2035 VISIBLE_TYPE_VISIBLE 2036 VISIBLE_TYPE_INVISIBLE 2037 ) 2038 2039 func (vt VisibleType) ToString() string { 2040 switch vt { 2041 case VISIBLE_TYPE_VISIBLE: 2042 return "visible" 2043 case VISIBLE_TYPE_INVISIBLE: 2044 return "invisible" 2045 default: 2046 return "Unknown VisibleType" 2047 } 2048 } 2049 2050 type IndexOption struct { 2051 NodeFormatter 2052 KeyBlockSize uint64 2053 IType IndexType 2054 ParserName string 2055 Comment string 2056 Visible VisibleType 2057 EngineAttribute string 2058 SecondaryEngineAttribute string 2059 AlgoParamList int64 2060 AlgoParamVectorOpType string 2061 } 2062 2063 // Must follow the following sequence when test 2064 func (node *IndexOption) Format(ctx *FmtCtx) { 2065 if node.KeyBlockSize != 0 || node.ParserName != "" || 2066 node.Comment != "" || node.Visible != VISIBLE_TYPE_INVALID || 2067 node.AlgoParamList != 0 || node.AlgoParamVectorOpType != "" { 2068 ctx.WriteByte(' ') 2069 } 2070 if node.KeyBlockSize != 0 { 2071 ctx.WriteString("KEY_BLOCK_SIZE ") 2072 ctx.WriteString(strconv.FormatUint(node.KeyBlockSize, 10)) 2073 ctx.WriteByte(' ') 2074 } 2075 if node.ParserName != "" { 2076 ctx.WriteString("with parser ") 2077 ctx.WriteString(node.ParserName) 2078 ctx.WriteByte(' ') 2079 } 2080 if node.Comment != "" { 2081 ctx.WriteString("comment ") 2082 ctx.WriteString(node.Comment) 2083 ctx.WriteByte(' ') 2084 } 2085 if node.AlgoParamList != 0 { 2086 ctx.WriteString("LISTS ") 2087 ctx.WriteString(strconv.FormatInt(node.AlgoParamList, 10)) 2088 ctx.WriteByte(' ') 2089 } 2090 if node.AlgoParamVectorOpType != "" { 2091 ctx.WriteString("OP_TYPE ") 2092 ctx.WriteString(node.AlgoParamVectorOpType) 2093 ctx.WriteByte(' ') 2094 } 2095 if node.Visible != VISIBLE_TYPE_INVALID { 2096 ctx.WriteString(node.Visible.ToString()) 2097 } 2098 } 2099 2100 func (node IndexOption) TypeName() string { return "tree.IndexOption" } 2101 2102 func (node *IndexOption) reset() { 2103 *node = IndexOption{} 2104 } 2105 2106 func (node *IndexOption) Free() { 2107 reuse.Free[IndexOption](node, nil) 2108 } 2109 2110 func NewIndexOption() *IndexOption { 2111 return reuse.Alloc[IndexOption](nil) 2112 } 2113 2114 type PrimaryKeyIndex struct { 2115 tableDefImpl 2116 KeyParts []*KeyPart 2117 Name string 2118 ConstraintSymbol string 2119 Empty bool 2120 IndexOption *IndexOption 2121 } 2122 2123 func (node *PrimaryKeyIndex) Format(ctx *FmtCtx) { 2124 if node.ConstraintSymbol != "" { 2125 ctx.WriteString("constraint " + node.ConstraintSymbol + " ") 2126 } 2127 ctx.WriteString("primary key") 2128 if node.Name != "" { 2129 ctx.WriteByte(' ') 2130 ctx.WriteString(node.Name) 2131 } 2132 if !node.Empty { 2133 ctx.WriteString(" using none") 2134 } 2135 if node.KeyParts != nil { 2136 prefix := " (" 2137 for _, k := range node.KeyParts { 2138 ctx.WriteString(prefix) 2139 k.Format(ctx) 2140 prefix = ", " 2141 } 2142 ctx.WriteByte(')') 2143 } 2144 if node.IndexOption != nil { 2145 ctx.WriteByte(' ') 2146 node.IndexOption.Format(ctx) 2147 } 2148 } 2149 2150 func (node PrimaryKeyIndex) TypeName() string { return "tree.PrimaryKeyIndex" } 2151 2152 func (node *PrimaryKeyIndex) reset() { 2153 if node.KeyParts != nil { 2154 for _, item := range node.KeyParts { 2155 reuse.Free[KeyPart](item, nil) 2156 } 2157 } 2158 if node.IndexOption != nil { 2159 reuse.Free[IndexOption](node.IndexOption, nil) 2160 } 2161 *node = PrimaryKeyIndex{} 2162 } 2163 2164 func (node *PrimaryKeyIndex) Free() { 2165 reuse.Free[PrimaryKeyIndex](node, nil) 2166 } 2167 2168 func NewPrimaryKeyIndex(k []*KeyPart, n string, e bool, io *IndexOption) *PrimaryKeyIndex { 2169 pki := reuse.Alloc[PrimaryKeyIndex](nil) 2170 pki.KeyParts = k 2171 pki.Name = n 2172 pki.Empty = e 2173 pki.IndexOption = io 2174 return pki 2175 } 2176 2177 type Index struct { 2178 tableDefImpl 2179 IfNotExists bool 2180 KeyParts []*KeyPart 2181 Name string 2182 KeyType IndexType 2183 IndexOption *IndexOption 2184 } 2185 2186 func (node *Index) Format(ctx *FmtCtx) { 2187 ctx.WriteString("index") 2188 if node.IfNotExists { 2189 ctx.WriteString(" if not exists") 2190 } 2191 if node.Name != "" { 2192 ctx.WriteByte(' ') 2193 ctx.WriteString(node.Name) 2194 } 2195 if node.KeyType != INDEX_TYPE_INVALID { 2196 ctx.WriteString(" using ") 2197 ctx.WriteString(node.KeyType.ToString()) 2198 } 2199 if node.KeyParts != nil { 2200 prefix := " (" 2201 for _, k := range node.KeyParts { 2202 ctx.WriteString(prefix) 2203 k.Format(ctx) 2204 prefix = ", " 2205 } 2206 ctx.WriteByte(')') 2207 } 2208 if node.IndexOption != nil { 2209 ctx.WriteByte(' ') 2210 node.IndexOption.Format(ctx) 2211 } 2212 } 2213 2214 func (node Index) TypeName() string { return "tree.Index" } 2215 2216 func (node *Index) reset() { 2217 if node.KeyParts != nil { 2218 for _, item := range node.KeyParts { 2219 reuse.Free[KeyPart](item, nil) 2220 } 2221 } 2222 if node.IndexOption != nil { 2223 reuse.Free[IndexOption](node.IndexOption, nil) 2224 } 2225 *node = Index{} 2226 } 2227 2228 func (node *Index) Free() { 2229 reuse.Free[Index](node, nil) 2230 } 2231 2232 func NewIndex(ifn bool, k []*KeyPart, n string, t IndexType, io *IndexOption) *Index { 2233 i := reuse.Alloc[Index](nil) 2234 i.IfNotExists = ifn 2235 i.KeyParts = k 2236 i.Name = n 2237 i.KeyType = t 2238 i.IndexOption = io 2239 return i 2240 } 2241 2242 type UniqueIndex struct { 2243 tableDefImpl 2244 KeyParts []*KeyPart 2245 Name string 2246 ConstraintSymbol string 2247 Empty bool 2248 IndexOption *IndexOption 2249 } 2250 2251 func (node *UniqueIndex) Format(ctx *FmtCtx) { 2252 if node.ConstraintSymbol != "" { 2253 ctx.WriteString("constraint " + node.ConstraintSymbol + " ") 2254 } 2255 ctx.WriteString("unique key") 2256 if node.Name != "" { 2257 ctx.WriteByte(' ') 2258 ctx.WriteString(node.Name) 2259 } 2260 if !node.Empty { 2261 ctx.WriteString(" using none") 2262 } 2263 if node.KeyParts != nil { 2264 prefix := " (" 2265 for _, k := range node.KeyParts { 2266 ctx.WriteString(prefix) 2267 k.Format(ctx) 2268 prefix = ", " 2269 } 2270 ctx.WriteByte(')') 2271 } 2272 if node.IndexOption != nil { 2273 ctx.WriteByte(' ') 2274 node.IndexOption.Format(ctx) 2275 } 2276 } 2277 2278 func (node *UniqueIndex) GetIndexName() string { 2279 if len(node.Name) != 0 { 2280 return node.Name 2281 } else { 2282 return node.ConstraintSymbol 2283 } 2284 } 2285 2286 func (node UniqueIndex) TypeName() string { return "tree.UniqueIndex" } 2287 2288 func (node *UniqueIndex) reset() { 2289 if node.KeyParts != nil { 2290 for _, item := range node.KeyParts { 2291 reuse.Free[KeyPart](item, nil) 2292 } 2293 } 2294 if node.IndexOption != nil { 2295 reuse.Free[IndexOption](node.IndexOption, nil) 2296 } 2297 *node = UniqueIndex{} 2298 } 2299 2300 func (node *UniqueIndex) Free() { 2301 reuse.Free[UniqueIndex](node, nil) 2302 } 2303 2304 func NewUniqueIndex(k []*KeyPart, n string, e bool, io *IndexOption) *UniqueIndex { 2305 ui := reuse.Alloc[UniqueIndex](nil) 2306 ui.KeyParts = k 2307 ui.Name = n 2308 ui.Empty = e 2309 ui.IndexOption = io 2310 return ui 2311 } 2312 2313 type ForeignKey struct { 2314 tableDefImpl 2315 IfNotExists bool 2316 KeyParts []*KeyPart 2317 Name string 2318 ConstraintSymbol string 2319 Refer *AttributeReference 2320 Empty bool 2321 } 2322 2323 func (node *ForeignKey) Format(ctx *FmtCtx) { 2324 if node.ConstraintSymbol != "" { 2325 ctx.WriteString("constraint " + node.ConstraintSymbol + " ") 2326 } 2327 ctx.WriteString("foreign key") 2328 if node.IfNotExists { 2329 ctx.WriteString(" if not exists") 2330 } 2331 if node.Name != "" { 2332 ctx.WriteByte(' ') 2333 ctx.WriteString(node.Name) 2334 } 2335 if !node.Empty { 2336 ctx.WriteString(" using none") 2337 } 2338 if node.KeyParts != nil { 2339 prefix := " (" 2340 for _, k := range node.KeyParts { 2341 ctx.WriteString(prefix) 2342 k.Format(ctx) 2343 prefix = ", " 2344 } 2345 ctx.WriteByte(')') 2346 } 2347 if node.Refer != nil { 2348 ctx.WriteByte(' ') 2349 node.Refer.Format(ctx) 2350 } 2351 } 2352 2353 func (node ForeignKey) TypeName() string { return "tree.ForeignKey" } 2354 2355 func (node *ForeignKey) reset() { 2356 if node.KeyParts != nil { 2357 for _, item := range node.KeyParts { 2358 reuse.Free[KeyPart](item, nil) 2359 } 2360 } 2361 if node.Refer != nil { 2362 reuse.Free[AttributeReference](node.Refer, nil) 2363 } 2364 *node = ForeignKey{} 2365 } 2366 2367 func (node *ForeignKey) Free() { 2368 reuse.Free[ForeignKey](node, nil) 2369 } 2370 2371 func NewForeignKey(ine bool, k []*KeyPart, n string, r *AttributeReference, e bool) *ForeignKey { 2372 fk := reuse.Alloc[ForeignKey](nil) 2373 fk.IfNotExists = ine 2374 fk.KeyParts = k 2375 fk.Name = n 2376 fk.Refer = r 2377 fk.Empty = e 2378 return fk 2379 } 2380 2381 type FullTextIndex struct { 2382 tableDefImpl 2383 KeyParts []*KeyPart 2384 Name string 2385 Empty bool 2386 IndexOption *IndexOption 2387 } 2388 2389 func (node *FullTextIndex) Format(ctx *FmtCtx) { 2390 ctx.WriteString("fulltext") 2391 if node.Name != "" { 2392 ctx.WriteByte(' ') 2393 ctx.WriteString(node.Name) 2394 } 2395 if !node.Empty { 2396 ctx.WriteString(" using none") 2397 } 2398 if node.KeyParts != nil { 2399 prefix := " (" 2400 for _, k := range node.KeyParts { 2401 ctx.WriteString(prefix) 2402 k.Format(ctx) 2403 prefix = ", " 2404 } 2405 ctx.WriteByte(')') 2406 } 2407 if node.IndexOption != nil { 2408 ctx.WriteByte(' ') 2409 node.IndexOption.Format(ctx) 2410 } 2411 } 2412 2413 func (node FullTextIndex) TypeName() string { return "tree.FullTextIndex" } 2414 2415 func (node *FullTextIndex) reset() { 2416 if node.KeyParts != nil { 2417 for _, item := range node.KeyParts { 2418 reuse.Free[KeyPart](item, nil) 2419 } 2420 } 2421 if node.IndexOption != nil { 2422 reuse.Free[IndexOption](node.IndexOption, nil) 2423 } 2424 *node = FullTextIndex{} 2425 } 2426 2427 func (node *FullTextIndex) Free() { 2428 reuse.Free[FullTextIndex](node, nil) 2429 } 2430 2431 func NewFullTextIndex(k []*KeyPart, n string, e bool, io *IndexOption) *FullTextIndex { 2432 fi := reuse.Alloc[FullTextIndex](nil) 2433 fi.KeyParts = k 2434 fi.Name = n 2435 fi.Empty = e 2436 fi.IndexOption = io 2437 return fi 2438 } 2439 2440 type CheckIndex struct { 2441 tableDefImpl 2442 Expr Expr 2443 Enforced bool 2444 } 2445 2446 func (node *CheckIndex) Format(ctx *FmtCtx) { 2447 ctx.WriteString("check (") 2448 node.Expr.Format(ctx) 2449 ctx.WriteByte(')') 2450 if node.Enforced { 2451 ctx.WriteString(" enforced") 2452 } 2453 } 2454 2455 func (node CheckIndex) TypeName() string { return "tree.CheckIndex" } 2456 2457 func (node *CheckIndex) reset() { 2458 *node = CheckIndex{} 2459 } 2460 2461 func (node *CheckIndex) Free() { 2462 reuse.Free[CheckIndex](node, nil) 2463 } 2464 2465 func NewCheckIndex(e Expr, en bool) *CheckIndex { 2466 ci := reuse.Alloc[CheckIndex](nil) 2467 ci.Expr = e 2468 ci.Enforced = en 2469 return ci 2470 } 2471 2472 type TableOption interface { 2473 AlterTableOption 2474 } 2475 2476 type tableOptionImpl struct { 2477 TableOption 2478 } 2479 2480 type TableOptionProperties struct { 2481 tableOptionImpl 2482 Preperties []Property 2483 } 2484 2485 func NewTableOptionProperties(p []Property) *TableOptionProperties { 2486 tp := reuse.Alloc[TableOptionProperties](nil) 2487 tp.Preperties = p 2488 return tp 2489 } 2490 2491 func (node *TableOptionProperties) Format(ctx *FmtCtx) { 2492 ctx.WriteString("properties") 2493 if node.Preperties != nil { 2494 prefix := "(" 2495 for _, p := range node.Preperties { 2496 ctx.WriteString(prefix) 2497 p.Format(ctx) 2498 prefix = ", " 2499 } 2500 ctx.WriteByte(')') 2501 } 2502 } 2503 2504 func (node TableOptionProperties) TypeName() string { return "tree.TableOptionProperties" } 2505 2506 func (node *TableOptionProperties) reset() { 2507 if node.Preperties != nil { 2508 for _, item := range node.Preperties { 2509 reuse.Free[Property](&item, nil) 2510 } 2511 } 2512 *node = TableOptionProperties{} 2513 } 2514 2515 func (node *TableOptionProperties) Free() { 2516 reuse.Free[TableOptionProperties](node, nil) 2517 } 2518 2519 type Property struct { 2520 Key string 2521 Value string 2522 } 2523 2524 func NewProperty(k, v string) *Property { 2525 p := reuse.Alloc[Property](nil) 2526 p.Key = k 2527 p.Value = v 2528 return p 2529 } 2530 2531 func (node *Property) Format(ctx *FmtCtx) { 2532 ctx.WriteString(node.Key) 2533 ctx.WriteString(" = ") 2534 ctx.WriteString(node.Value) 2535 } 2536 2537 func (node Property) TypeName() string { return "tree.Property" } 2538 2539 func (node *Property) reset() { 2540 *node = Property{} 2541 } 2542 2543 func (node *Property) Free() { 2544 reuse.Free[Property](node, nil) 2545 } 2546 2547 type TableOptionEngine struct { 2548 tableOptionImpl 2549 Engine string 2550 } 2551 2552 func (node *TableOptionEngine) Format(ctx *FmtCtx) { 2553 ctx.WriteString("engine = ") 2554 ctx.WriteString(node.Engine) 2555 } 2556 2557 func (node TableOptionEngine) TypeName() string { return "tree.TableOptionEngine" } 2558 2559 func (node *TableOptionEngine) reset() { 2560 *node = TableOptionEngine{} 2561 } 2562 2563 func (node *TableOptionEngine) Free() { 2564 reuse.Free[TableOptionEngine](node, nil) 2565 } 2566 2567 func NewTableOptionEngine(s string) *TableOptionEngine { 2568 tb := reuse.Alloc[TableOptionEngine](nil) 2569 tb.Engine = s 2570 return tb 2571 } 2572 2573 type TableOptionEngineAttr struct { 2574 tableOptionImpl 2575 Engine string 2576 } 2577 2578 func (node *TableOptionEngineAttr) Format(ctx *FmtCtx) { 2579 ctx.WriteString("ENGINE_ATTRIBUTE = ") 2580 ctx.WriteString(node.Engine) 2581 } 2582 2583 func (node TableOptionEngineAttr) TypeName() string { return "tree.TableOptionEngineAttr" } 2584 2585 func (node *TableOptionEngineAttr) reset() { 2586 *node = TableOptionEngineAttr{} 2587 } 2588 2589 func (node *TableOptionEngineAttr) Free() { 2590 reuse.Free[TableOptionEngineAttr](node, nil) 2591 } 2592 2593 func NewTableOptionEngineAttr(s string) *TableOptionEngineAttr { 2594 tba := reuse.Alloc[TableOptionEngineAttr](nil) 2595 tba.Engine = s 2596 return tba 2597 } 2598 2599 type TableOptionInsertMethod struct { 2600 tableOptionImpl 2601 Method string 2602 } 2603 2604 func (node *TableOptionInsertMethod) Format(ctx *FmtCtx) { 2605 ctx.WriteString("INSERT_METHOD = ") 2606 ctx.WriteString(node.Method) 2607 } 2608 2609 func (node TableOptionInsertMethod) TypeName() string { return "tree.TableOptionInsertMethod" } 2610 2611 func (node *TableOptionInsertMethod) reset() { 2612 *node = TableOptionInsertMethod{} 2613 } 2614 2615 func (node *TableOptionInsertMethod) Free() { 2616 reuse.Free[TableOptionInsertMethod](node, nil) 2617 } 2618 2619 func NewTableOptionInsertMethod(s string) *TableOptionInsertMethod { 2620 t := reuse.Alloc[TableOptionInsertMethod](nil) 2621 t.Method = s 2622 return t 2623 } 2624 2625 type TableOptionSecondaryEngine struct { 2626 tableOptionImpl 2627 Engine string 2628 } 2629 2630 func (node *TableOptionSecondaryEngine) Format(ctx *FmtCtx) { 2631 ctx.WriteString("engine = ") 2632 ctx.WriteString(node.Engine) 2633 } 2634 2635 func (node TableOptionSecondaryEngine) TypeName() string { return "tree.TableOptionSecondaryEngine" } 2636 2637 func (node *TableOptionSecondaryEngine) reset() { 2638 *node = TableOptionSecondaryEngine{} 2639 } 2640 2641 func (node *TableOptionSecondaryEngine) Free() { 2642 reuse.Free[TableOptionSecondaryEngine](node, nil) 2643 } 2644 2645 func NewTableOptionSecondaryEngine(s string) *TableOptionSecondaryEngine { 2646 t := reuse.Alloc[TableOptionSecondaryEngine](nil) 2647 t.Engine = s 2648 return t 2649 } 2650 2651 type TableOptionSecondaryEngineNull struct { 2652 tableOptionImpl 2653 } 2654 2655 func (node TableOptionSecondaryEngineNull) TypeName() string { 2656 return "tree.TableOptionSecondaryEngineNull" 2657 } 2658 2659 func NewTableOptionSecondaryEngineNull() *TableOptionSecondaryEngineNull { 2660 return reuse.Alloc[TableOptionSecondaryEngineNull](nil) 2661 } 2662 2663 type TableOptionCharset struct { 2664 tableOptionImpl 2665 Charset string 2666 } 2667 2668 func (node *TableOptionCharset) Format(ctx *FmtCtx) { 2669 ctx.WriteString("charset = ") 2670 ctx.WriteString(node.Charset) 2671 } 2672 2673 func (node TableOptionCharset) TypeName() string { return "tree.TableOptionCharset" } 2674 2675 func (node *TableOptionCharset) reset() { 2676 *node = TableOptionCharset{} 2677 } 2678 2679 func (node *TableOptionCharset) Free() { 2680 reuse.Free[TableOptionCharset](node, nil) 2681 } 2682 2683 func NewTableOptionCharset(s string) *TableOptionCharset { 2684 t := reuse.Alloc[TableOptionCharset](nil) 2685 t.Charset = s 2686 return t 2687 } 2688 2689 type TableOptionCollate struct { 2690 tableOptionImpl 2691 Collate string 2692 } 2693 2694 func (node *TableOptionCollate) Format(ctx *FmtCtx) { 2695 ctx.WriteString("Collate = ") 2696 ctx.WriteString(node.Collate) 2697 } 2698 2699 func (node TableOptionCollate) TypeName() string { return "tree.TableOptionCollate" } 2700 2701 func (node *TableOptionCollate) reset() { 2702 *node = TableOptionCollate{} 2703 } 2704 2705 func (node *TableOptionCollate) Free() { 2706 reuse.Free[TableOptionCollate](node, nil) 2707 } 2708 2709 func NewTableOptionCollate(s string) *TableOptionCollate { 2710 t := reuse.Alloc[TableOptionCollate](nil) 2711 t.Collate = s 2712 return t 2713 } 2714 2715 type TableOptionAUTOEXTEND_SIZE struct { 2716 tableOptionImpl 2717 Value uint64 2718 } 2719 2720 func (node *TableOptionAUTOEXTEND_SIZE) Format(ctx *FmtCtx) { 2721 ctx.WriteString("AUTOEXTEND_SIZE = ") 2722 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 2723 } 2724 2725 func (node TableOptionAUTOEXTEND_SIZE) TypeName() string { return "tree.TableOptionAUTOEXTEND_SIZE" } 2726 2727 func (node *TableOptionAUTOEXTEND_SIZE) reset() { 2728 *node = TableOptionAUTOEXTEND_SIZE{} 2729 } 2730 2731 func (node *TableOptionAUTOEXTEND_SIZE) Free() { 2732 reuse.Free[TableOptionAUTOEXTEND_SIZE](node, nil) 2733 } 2734 2735 func NewTableOptionAUTOEXTEND_SIZE(v uint64) *TableOptionAUTOEXTEND_SIZE { 2736 t := reuse.Alloc[TableOptionAUTOEXTEND_SIZE](nil) 2737 t.Value = v 2738 return t 2739 } 2740 2741 type TableOptionAutoIncrement struct { 2742 tableOptionImpl 2743 Value uint64 2744 } 2745 2746 func (node *TableOptionAutoIncrement) Format(ctx *FmtCtx) { 2747 ctx.WriteString("auto_increment = ") 2748 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 2749 } 2750 2751 func (node TableOptionAutoIncrement) TypeName() string { return "tree.TableOptionAutoIncrement" } 2752 2753 func (node *TableOptionAutoIncrement) reset() { 2754 *node = TableOptionAutoIncrement{} 2755 } 2756 2757 func (node *TableOptionAutoIncrement) Free() { 2758 reuse.Free[TableOptionAutoIncrement](node, nil) 2759 } 2760 2761 func NewTableOptionAutoIncrement(v uint64) *TableOptionAutoIncrement { 2762 t := reuse.Alloc[TableOptionAutoIncrement](nil) 2763 t.Value = v 2764 return t 2765 } 2766 2767 type TableOptionComment struct { 2768 tableOptionImpl 2769 Comment string 2770 } 2771 2772 func (node *TableOptionComment) Format(ctx *FmtCtx) { 2773 ctx.WriteString("comment = '" + node.Comment + "'") 2774 } 2775 2776 func (node TableOptionComment) TypeName() string { return "tree.TableOptionComment" } 2777 2778 func (node *TableOptionComment) reset() { 2779 *node = TableOptionComment{} 2780 } 2781 2782 func (node *TableOptionComment) Free() { 2783 reuse.Free[TableOptionComment](node, nil) 2784 } 2785 2786 func NewTableOptionComment(c string) *TableOptionComment { 2787 t := reuse.Alloc[TableOptionComment](nil) 2788 t.Comment = c 2789 return t 2790 } 2791 2792 type TableOptionAvgRowLength struct { 2793 tableOptionImpl 2794 Length uint64 2795 } 2796 2797 func (node *TableOptionAvgRowLength) Format(ctx *FmtCtx) { 2798 ctx.WriteString("avg_row_length = ") 2799 ctx.WriteString(strconv.FormatUint(node.Length, 10)) 2800 } 2801 2802 func (node TableOptionAvgRowLength) TypeName() string { return "tree.TableOptionAvgRowLength" } 2803 2804 func (node *TableOptionAvgRowLength) reset() { 2805 *node = TableOptionAvgRowLength{} 2806 } 2807 2808 func (node *TableOptionAvgRowLength) Free() { 2809 reuse.Free[TableOptionAvgRowLength](node, nil) 2810 } 2811 2812 func NewTableOptionAvgRowLength(l uint64) *TableOptionAvgRowLength { 2813 t := reuse.Alloc[TableOptionAvgRowLength](nil) 2814 t.Length = l 2815 return t 2816 } 2817 2818 type TableOptionChecksum struct { 2819 tableOptionImpl 2820 Value uint64 2821 } 2822 2823 func (node *TableOptionChecksum) Format(ctx *FmtCtx) { 2824 ctx.WriteString("checksum = ") 2825 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 2826 } 2827 2828 func (node TableOptionChecksum) TypeName() string { return "tree.TableOptionChecksum" } 2829 2830 func (node *TableOptionChecksum) reset() { 2831 *node = TableOptionChecksum{} 2832 } 2833 2834 func (node *TableOptionChecksum) Free() { 2835 reuse.Free[TableOptionChecksum](node, nil) 2836 } 2837 2838 func NewTableOptionChecksum(v uint64) *TableOptionChecksum { 2839 t := reuse.Alloc[TableOptionChecksum](nil) 2840 t.Value = v 2841 return t 2842 } 2843 2844 type TableOptionCompression struct { 2845 tableOptionImpl 2846 Compression string 2847 } 2848 2849 func (node *TableOptionCompression) Format(ctx *FmtCtx) { 2850 ctx.WriteString("compression = ") 2851 ctx.WriteString(node.Compression) 2852 } 2853 2854 func (node TableOptionCompression) TypeName() string { return "tree.TableOptionCompression" } 2855 2856 func (node *TableOptionCompression) reset() { 2857 *node = TableOptionCompression{} 2858 } 2859 2860 func (node *TableOptionCompression) Free() { 2861 reuse.Free[TableOptionCompression](node, nil) 2862 } 2863 2864 func NewTableOptionCompression(c string) *TableOptionCompression { 2865 t := reuse.Alloc[TableOptionCompression](nil) 2866 t.Compression = c 2867 return t 2868 } 2869 2870 type TableOptionConnection struct { 2871 tableOptionImpl 2872 Connection string 2873 } 2874 2875 func (node *TableOptionConnection) Format(ctx *FmtCtx) { 2876 ctx.WriteString("connection = ") 2877 ctx.WriteString(node.Connection) 2878 } 2879 2880 func (node TableOptionConnection) TypeName() string { return "tree.TableOptionConnection" } 2881 2882 func (node *TableOptionConnection) reset() { 2883 *node = TableOptionConnection{} 2884 } 2885 2886 func (node *TableOptionConnection) Free() { 2887 reuse.Free[TableOptionConnection](node, nil) 2888 } 2889 2890 func NewTableOptionConnection(c string) *TableOptionConnection { 2891 t := reuse.Alloc[TableOptionConnection](nil) 2892 t.Connection = c 2893 return t 2894 } 2895 2896 type TableOptionPassword struct { 2897 tableOptionImpl 2898 Password string 2899 } 2900 2901 func (node *TableOptionPassword) Format(ctx *FmtCtx) { 2902 ctx.WriteString("password = ") 2903 ctx.WriteString(node.Password) 2904 } 2905 2906 func (node TableOptionPassword) TypeName() string { return "tree.TableOptionPassword" } 2907 2908 func (node *TableOptionPassword) reset() { 2909 *node = TableOptionPassword{} 2910 } 2911 2912 func (node *TableOptionPassword) Free() { 2913 reuse.Free[TableOptionPassword](node, nil) 2914 } 2915 2916 func NewTableOptionPassword(p string) *TableOptionPassword { 2917 t := reuse.Alloc[TableOptionPassword](nil) 2918 t.Password = p 2919 return t 2920 } 2921 2922 type TableOptionKeyBlockSize struct { 2923 tableOptionImpl 2924 Value uint64 2925 } 2926 2927 func (node *TableOptionKeyBlockSize) Format(ctx *FmtCtx) { 2928 ctx.WriteString("key_block_size = ") 2929 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 2930 } 2931 2932 func (node TableOptionKeyBlockSize) TypeName() string { return "tree.TableOptionKeyBlockSize" } 2933 2934 func (node *TableOptionKeyBlockSize) reset() { 2935 *node = TableOptionKeyBlockSize{} 2936 } 2937 2938 func (node *TableOptionKeyBlockSize) Free() { 2939 reuse.Free[TableOptionKeyBlockSize](node, nil) 2940 } 2941 2942 func NewTableOptionKeyBlockSize(v uint64) *TableOptionKeyBlockSize { 2943 t := reuse.Alloc[TableOptionKeyBlockSize](nil) 2944 t.Value = v 2945 return t 2946 } 2947 2948 type TableOptionMaxRows struct { 2949 tableOptionImpl 2950 Value uint64 2951 } 2952 2953 func (node *TableOptionMaxRows) Format(ctx *FmtCtx) { 2954 ctx.WriteString("max_rows = ") 2955 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 2956 } 2957 2958 func (node TableOptionMaxRows) TypeName() string { return "tree.TableOptionMaxRows" } 2959 2960 func (node *TableOptionMaxRows) reset() { 2961 *node = TableOptionMaxRows{} 2962 } 2963 2964 func (node *TableOptionMaxRows) Free() { 2965 reuse.Free[TableOptionMaxRows](node, nil) 2966 } 2967 2968 func NewTableOptionMaxRows(v uint64) *TableOptionMaxRows { 2969 t := reuse.Alloc[TableOptionMaxRows](nil) 2970 t.Value = v 2971 return t 2972 } 2973 2974 type TableOptionMinRows struct { 2975 tableOptionImpl 2976 Value uint64 2977 } 2978 2979 func (node *TableOptionMinRows) Format(ctx *FmtCtx) { 2980 ctx.WriteString("min_rows = ") 2981 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 2982 } 2983 2984 func (node TableOptionMinRows) TypeName() string { return "tree.TableOptionMinRows" } 2985 2986 func (node *TableOptionMinRows) reset() { 2987 *node = TableOptionMinRows{} 2988 } 2989 2990 func (node *TableOptionMinRows) Free() { 2991 reuse.Free[TableOptionMinRows](node, nil) 2992 } 2993 2994 func NewTableOptionMinRows(v uint64) *TableOptionMinRows { 2995 t := reuse.Alloc[TableOptionMinRows](nil) 2996 t.Value = v 2997 return t 2998 } 2999 3000 type TableOptionDelayKeyWrite struct { 3001 tableOptionImpl 3002 Value uint64 3003 } 3004 3005 func (node *TableOptionDelayKeyWrite) Format(ctx *FmtCtx) { 3006 ctx.WriteString("key_write = ") 3007 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 3008 } 3009 3010 func (node TableOptionDelayKeyWrite) TypeName() string { return "tree.TableOptionDelayKeyWrite" } 3011 3012 func (node *TableOptionDelayKeyWrite) reset() { 3013 *node = TableOptionDelayKeyWrite{} 3014 } 3015 3016 func (node *TableOptionDelayKeyWrite) Free() { 3017 reuse.Free[TableOptionDelayKeyWrite](node, nil) 3018 } 3019 3020 func NewTableOptionDelayKeyWrite(v uint64) *TableOptionDelayKeyWrite { 3021 t := reuse.Alloc[TableOptionDelayKeyWrite](nil) 3022 t.Value = v 3023 return t 3024 } 3025 3026 type RowFormatType uint64 3027 3028 const ( 3029 ROW_FORMAT_DEFAULT RowFormatType = iota 3030 ROW_FORMAT_DYNAMIC 3031 ROW_FORMAT_FIXED 3032 ROW_FORMAT_COMPRESSED 3033 ROW_FORMAT_REDUNDANT 3034 ROW_FORMAT_COMPACT 3035 ) 3036 3037 func (node *RowFormatType) ToString() string { 3038 switch *node { 3039 case ROW_FORMAT_DEFAULT: 3040 return "default" 3041 case ROW_FORMAT_DYNAMIC: 3042 return "dynamic" 3043 case ROW_FORMAT_FIXED: 3044 return "fixed" 3045 case ROW_FORMAT_COMPRESSED: 3046 return "compressed" 3047 case ROW_FORMAT_REDUNDANT: 3048 return "redundant" 3049 case ROW_FORMAT_COMPACT: 3050 return "compact" 3051 default: 3052 return "Unknown RowFormatType" 3053 } 3054 } 3055 3056 type TableOptionRowFormat struct { 3057 tableOptionImpl 3058 Value RowFormatType 3059 } 3060 3061 func (node *TableOptionRowFormat) Format(ctx *FmtCtx) { 3062 ctx.WriteString("row_format = ") 3063 ctx.WriteString(node.Value.ToString()) 3064 } 3065 3066 func (node TableOptionRowFormat) TypeName() string { return "tree.TableOptionRowFormat" } 3067 3068 func (node *TableOptionRowFormat) reset() { 3069 *node = TableOptionRowFormat{} 3070 } 3071 3072 func (node *TableOptionRowFormat) Free() { 3073 reuse.Free[TableOptionRowFormat](node, nil) 3074 } 3075 3076 func NewTableOptionRowFormat(v RowFormatType) *TableOptionRowFormat { 3077 t := reuse.Alloc[TableOptionRowFormat](nil) 3078 t.Value = v 3079 return t 3080 } 3081 3082 type TableOptionStartTrans struct { 3083 tableOptionImpl 3084 Value bool 3085 } 3086 3087 func (node *TableOptionStartTrans) Format(ctx *FmtCtx) { 3088 ctx.WriteString("START TRANSACTION") 3089 } 3090 3091 func (node TableOptionStartTrans) TypeName() string { return "tree.TableOptionStartTrans" } 3092 3093 func (node *TableOptionStartTrans) reset() { 3094 *node = TableOptionStartTrans{} 3095 } 3096 3097 func (node *TableOptionStartTrans) Free() { 3098 reuse.Free[TableOptionStartTrans](node, nil) 3099 } 3100 3101 func NewTTableOptionStartTrans(v bool) *TableOptionStartTrans { 3102 t := reuse.Alloc[TableOptionStartTrans](nil) 3103 t.Value = v 3104 return t 3105 } 3106 3107 type TableOptionSecondaryEngineAttr struct { 3108 tableOptionImpl 3109 Attr string 3110 } 3111 3112 func (node *TableOptionSecondaryEngineAttr) Format(ctx *FmtCtx) { 3113 ctx.WriteString("SECONDARY_ENGINE_ATTRIBUTE = ") 3114 ctx.WriteString(node.Attr) 3115 } 3116 3117 func (node TableOptionSecondaryEngineAttr) TypeName() string { 3118 return "tree.TableOptionSecondaryEngineAttr" 3119 } 3120 3121 func (node *TableOptionSecondaryEngineAttr) reset() { 3122 *node = TableOptionSecondaryEngineAttr{} 3123 } 3124 3125 func (node *TableOptionSecondaryEngineAttr) Free() { 3126 reuse.Free[TableOptionSecondaryEngineAttr](node, nil) 3127 } 3128 3129 func NewTTableOptionSecondaryEngineAttr(v string) *TableOptionSecondaryEngineAttr { 3130 t := reuse.Alloc[TableOptionSecondaryEngineAttr](nil) 3131 t.Attr = v 3132 return t 3133 } 3134 3135 type TableOptionStatsPersistent struct { 3136 tableOptionImpl 3137 Value uint64 3138 Default bool 3139 } 3140 3141 func (node *TableOptionStatsPersistent) Format(ctx *FmtCtx) { 3142 ctx.WriteString("stats_persistent = ") 3143 if node.Default { 3144 ctx.WriteString("default") 3145 } else { 3146 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 3147 } 3148 } 3149 3150 func (node TableOptionStatsPersistent) TypeName() string { return "tree.TableOptionStatsPersistent" } 3151 3152 func (node *TableOptionStatsPersistent) reset() { 3153 *node = TableOptionStatsPersistent{} 3154 } 3155 3156 func (node *TableOptionStatsPersistent) Free() { 3157 reuse.Free[TableOptionStatsPersistent](node, nil) 3158 } 3159 3160 func NewTableOptionStatsPersistent() *TableOptionStatsPersistent { 3161 return reuse.Alloc[TableOptionStatsPersistent](nil) 3162 } 3163 3164 type TableOptionStatsAutoRecalc struct { 3165 tableOptionImpl 3166 Value uint64 3167 Default bool // false -- see Value; true -- Value is useless 3168 } 3169 3170 func (node *TableOptionStatsAutoRecalc) Format(ctx *FmtCtx) { 3171 ctx.WriteString("stats_auto_recalc = ") 3172 if node.Default { 3173 ctx.WriteString("default") 3174 } else { 3175 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 3176 } 3177 } 3178 3179 func (node TableOptionStatsAutoRecalc) TypeName() string { return "tree.TableOptionStatsAutoRecalc" } 3180 3181 func (node *TableOptionStatsAutoRecalc) reset() { 3182 *node = TableOptionStatsAutoRecalc{} 3183 } 3184 3185 func (node *TableOptionStatsAutoRecalc) Free() { 3186 reuse.Free[TableOptionStatsAutoRecalc](node, nil) 3187 } 3188 3189 func NewTableOptionStatsAutoRecalc() *TableOptionStatsAutoRecalc { 3190 return reuse.Alloc[TableOptionStatsAutoRecalc](nil) 3191 } 3192 3193 type TableOptionPackKeys struct { 3194 tableOptionImpl 3195 Value int64 3196 Default bool 3197 } 3198 3199 func (node *TableOptionPackKeys) Format(ctx *FmtCtx) { 3200 ctx.WriteString("pack_keys = ") 3201 if node.Default { 3202 ctx.WriteString("default") 3203 } else { 3204 ctx.WriteString(strconv.FormatInt(node.Value, 10)) 3205 } 3206 } 3207 3208 func (node TableOptionPackKeys) TypeName() string { return "tree.TableOptionPackKeys" } 3209 3210 func (node *TableOptionPackKeys) reset() { 3211 *node = TableOptionPackKeys{} 3212 } 3213 3214 func (node *TableOptionPackKeys) Free() { 3215 reuse.Free[TableOptionPackKeys](node, nil) 3216 } 3217 3218 func NewTableOptionPackKeys() *TableOptionPackKeys { 3219 return reuse.Alloc[TableOptionPackKeys](nil) 3220 } 3221 3222 type TableOptionTablespace struct { 3223 tableOptionImpl 3224 Name string 3225 StorageOpt string 3226 } 3227 3228 func (node *TableOptionTablespace) Format(ctx *FmtCtx) { 3229 ctx.WriteString("tablespace = ") 3230 ctx.WriteString(node.Name) 3231 ctx.WriteString(node.StorageOpt) 3232 } 3233 3234 func (node TableOptionTablespace) TypeName() string { return "tree.TableOptionTablespace" } 3235 3236 func (node *TableOptionTablespace) reset() { 3237 *node = TableOptionTablespace{} 3238 } 3239 3240 func (node *TableOptionTablespace) Free() { 3241 reuse.Free[TableOptionTablespace](node, nil) 3242 } 3243 3244 func NewTableOptionTablespace(n string, s string) *TableOptionTablespace { 3245 t := reuse.Alloc[TableOptionTablespace](nil) 3246 t.Name = n 3247 t.StorageOpt = s 3248 return t 3249 } 3250 3251 type TableOptionDataDirectory struct { 3252 tableOptionImpl 3253 Dir string 3254 } 3255 3256 func (node *TableOptionDataDirectory) Format(ctx *FmtCtx) { 3257 ctx.WriteString("data directory = ") 3258 ctx.WriteString(node.Dir) 3259 } 3260 3261 func (node TableOptionDataDirectory) TypeName() string { return "tree.TableOptionDataDirectory" } 3262 3263 func (node *TableOptionDataDirectory) reset() { 3264 *node = TableOptionDataDirectory{} 3265 } 3266 3267 func (node *TableOptionDataDirectory) Free() { 3268 reuse.Free[TableOptionDataDirectory](node, nil) 3269 } 3270 3271 func NewTableOptionDataDirectory(d string) *TableOptionDataDirectory { 3272 t := reuse.Alloc[TableOptionDataDirectory](nil) 3273 t.Dir = d 3274 return t 3275 } 3276 3277 type TableOptionIndexDirectory struct { 3278 tableOptionImpl 3279 Dir string 3280 } 3281 3282 func (node *TableOptionIndexDirectory) Format(ctx *FmtCtx) { 3283 ctx.WriteString("index directory = ") 3284 ctx.WriteString(node.Dir) 3285 } 3286 3287 func (node TableOptionIndexDirectory) TypeName() string { return "tree.TableOptionIndexDirectory" } 3288 3289 func (node *TableOptionIndexDirectory) reset() { 3290 *node = TableOptionIndexDirectory{} 3291 } 3292 3293 func (node *TableOptionIndexDirectory) Free() { 3294 reuse.Free[TableOptionIndexDirectory](node, nil) 3295 } 3296 3297 func NewTableOptionIndexDirectory(d string) *TableOptionIndexDirectory { 3298 t := reuse.Alloc[TableOptionIndexDirectory](nil) 3299 t.Dir = d 3300 return t 3301 } 3302 3303 type TableOptionStorageMedia struct { 3304 tableOptionImpl 3305 Media string 3306 } 3307 3308 func (node *TableOptionStorageMedia) Format(ctx *FmtCtx) { 3309 ctx.WriteString("storage media = ") 3310 ctx.WriteString(node.Media) 3311 } 3312 3313 func (node TableOptionStorageMedia) TypeName() string { return "tree.TableOptionStorageMedia" } 3314 3315 func (node *TableOptionStorageMedia) reset() { 3316 *node = TableOptionStorageMedia{} 3317 } 3318 3319 func (node *TableOptionStorageMedia) Free() { 3320 reuse.Free[TableOptionStorageMedia](node, nil) 3321 } 3322 3323 func NewTableOptionStorageMedia(m string) *TableOptionStorageMedia { 3324 t := reuse.Alloc[TableOptionStorageMedia](nil) 3325 t.Media = m 3326 return t 3327 } 3328 3329 type TableOptionStatsSamplePages struct { 3330 tableOptionImpl 3331 Value uint64 3332 Default bool // false -- see Value; true -- Value is useless 3333 } 3334 3335 func (node *TableOptionStatsSamplePages) Format(ctx *FmtCtx) { 3336 ctx.WriteString("stats_sample_pages = ") 3337 if node.Default { 3338 ctx.WriteString("default") 3339 } else { 3340 ctx.WriteString(strconv.FormatUint(node.Value, 10)) 3341 } 3342 } 3343 3344 func (node TableOptionStatsSamplePages) TypeName() string { return "tree.TableOptionStatsSamplePages" } 3345 3346 func (node *TableOptionStatsSamplePages) reset() { 3347 *node = TableOptionStatsSamplePages{} 3348 } 3349 3350 func (node *TableOptionStatsSamplePages) Free() { 3351 reuse.Free[TableOptionStatsSamplePages](node, nil) 3352 } 3353 3354 func NewTableOptionStatsSamplePages() *TableOptionStatsSamplePages { 3355 return reuse.Alloc[TableOptionStatsSamplePages](nil) 3356 } 3357 3358 type TableOptionUnion struct { 3359 tableOptionImpl 3360 Names TableNames 3361 } 3362 3363 func (node *TableOptionUnion) Format(ctx *FmtCtx) { 3364 ctx.WriteString("union (") 3365 node.Names.Format(ctx) 3366 ctx.WriteByte(')') 3367 } 3368 3369 func (node TableOptionUnion) TypeName() string { return "tree.TableOptionUnion" } 3370 3371 func (node *TableOptionUnion) reset() { 3372 *node = TableOptionUnion{} 3373 } 3374 3375 func (node *TableOptionUnion) Free() { 3376 reuse.Free[TableOptionUnion](node, nil) 3377 } 3378 3379 func NewTableOptionUnion(n TableNames) *TableOptionUnion { 3380 t := reuse.Alloc[TableOptionUnion](nil) 3381 t.Names = n 3382 return t 3383 } 3384 3385 type TableOptionEncryption struct { 3386 tableOptionImpl 3387 Encryption string 3388 } 3389 3390 func (node *TableOptionEncryption) Format(ctx *FmtCtx) { 3391 ctx.WriteString("encryption = ") 3392 ctx.WriteString(node.Encryption) 3393 } 3394 3395 func (node TableOptionEncryption) TypeName() string { return "tree.TableOptionEncryption" } 3396 3397 func (node *TableOptionEncryption) reset() { 3398 *node = TableOptionEncryption{} 3399 } 3400 3401 func (node *TableOptionEncryption) Free() { 3402 reuse.Free[TableOptionEncryption](node, nil) 3403 } 3404 3405 func NewTableOptionEncryption(e string) *TableOptionEncryption { 3406 t := reuse.Alloc[TableOptionEncryption](nil) 3407 t.Encryption = e 3408 return t 3409 } 3410 3411 type PartitionType interface { 3412 NodeFormatter 3413 } 3414 3415 type partitionTypeImpl struct { 3416 PartitionType 3417 } 3418 3419 type HashType struct { 3420 partitionTypeImpl 3421 Linear bool 3422 Expr Expr 3423 } 3424 3425 func (node *HashType) Format(ctx *FmtCtx) { 3426 if node.Linear { 3427 ctx.WriteString("linear ") 3428 } 3429 ctx.WriteString("hash") 3430 if node.Expr != nil { 3431 ctx.WriteString(" (") 3432 node.Expr.Format(ctx) 3433 ctx.WriteByte(')') 3434 } 3435 } 3436 3437 func (node HashType) TypeName() string { return "tree.HashType" } 3438 3439 func (node *HashType) reset() { 3440 *node = HashType{} 3441 } 3442 3443 func (node *HashType) Free() { 3444 reuse.Free[HashType](node, nil) 3445 } 3446 3447 func NewHashType(l bool, e Expr) *HashType { 3448 h := reuse.Alloc[HashType](nil) 3449 h.Linear = l 3450 h.Expr = e 3451 return h 3452 } 3453 3454 type KeyType struct { 3455 partitionTypeImpl 3456 Linear bool 3457 ColumnList []*UnresolvedName 3458 Algorithm int64 3459 } 3460 3461 func (node *KeyType) Format(ctx *FmtCtx) { 3462 if node.Linear { 3463 ctx.WriteString("linear ") 3464 } 3465 ctx.WriteString("key") 3466 if node.Algorithm != 0 { 3467 ctx.WriteString(" algorithm = ") 3468 ctx.WriteString(strconv.FormatInt(node.Algorithm, 10)) 3469 } 3470 if node.ColumnList != nil { 3471 prefix := " (" 3472 for _, c := range node.ColumnList { 3473 ctx.WriteString(prefix) 3474 c.Format(ctx) 3475 prefix = ", " 3476 } 3477 ctx.WriteByte(')') 3478 } 3479 } 3480 3481 func (node KeyType) TypeName() string { return "tree.KeyType" } 3482 3483 func (node *KeyType) reset() { 3484 // if node.ColumnList != nil { 3485 // for _, item := range node.ColumnList { 3486 // reuse.Free[UnresolvedName](item, nil) 3487 // } 3488 // } 3489 *node = KeyType{} 3490 } 3491 3492 func (node *KeyType) Free() { 3493 reuse.Free[KeyType](node, nil) 3494 } 3495 3496 func NewKeyType() *KeyType { 3497 return reuse.Alloc[KeyType](nil) 3498 } 3499 3500 type RangeType struct { 3501 partitionTypeImpl 3502 Expr Expr 3503 ColumnList []*UnresolvedName 3504 } 3505 3506 func (node *RangeType) Format(ctx *FmtCtx) { 3507 ctx.WriteString("range") 3508 if node.ColumnList != nil { 3509 prefix := " columns (" 3510 for _, c := range node.ColumnList { 3511 ctx.WriteString(prefix) 3512 c.Format(ctx) 3513 prefix = ", " 3514 } 3515 ctx.WriteByte(')') 3516 } 3517 if node.Expr != nil { 3518 ctx.WriteString("(") 3519 node.Expr.Format(ctx) 3520 ctx.WriteByte(')') 3521 } 3522 } 3523 3524 func (node RangeType) TypeName() string { return "tree.RangeType" } 3525 3526 func (node *RangeType) reset() { 3527 // if node.ColumnList != nil { 3528 // for _, item := range node.ColumnList { 3529 // reuse.Free[UnresolvedName](item, nil) 3530 // } 3531 // } 3532 *node = RangeType{} 3533 } 3534 3535 func (node *RangeType) Free() { 3536 reuse.Free[RangeType](node, nil) 3537 } 3538 3539 func NewRangeType() *RangeType { 3540 return reuse.Alloc[RangeType](nil) 3541 } 3542 3543 type ListType struct { 3544 partitionTypeImpl 3545 Expr Expr 3546 ColumnList []*UnresolvedName 3547 } 3548 3549 func (node *ListType) Format(ctx *FmtCtx) { 3550 ctx.WriteString("list") 3551 if node.ColumnList != nil { 3552 prefix := " columns (" 3553 for _, c := range node.ColumnList { 3554 ctx.WriteString(prefix) 3555 c.Format(ctx) 3556 prefix = ", " 3557 } 3558 ctx.WriteByte(')') 3559 } 3560 if node.Expr != nil { 3561 ctx.WriteString("(") 3562 node.Expr.Format(ctx) 3563 ctx.WriteByte(')') 3564 } 3565 } 3566 3567 func (node ListType) TypeName() string { return "tree.ListType" } 3568 3569 func (node *ListType) reset() { 3570 // if node.ColumnList != nil { 3571 // for _, item := range node.ColumnList { 3572 // reuse.Free[UnresolvedName](item, nil) 3573 // } 3574 // } 3575 *node = ListType{} 3576 } 3577 3578 func (node *ListType) Free() { 3579 reuse.Free[ListType](node, nil) 3580 } 3581 3582 func NewListType() *ListType { 3583 return reuse.Alloc[ListType](nil) 3584 } 3585 3586 type PartitionBy struct { 3587 IsSubPartition bool // for format 3588 PType PartitionType 3589 Num uint64 3590 } 3591 3592 func (node *PartitionBy) Format(ctx *FmtCtx) { 3593 node.PType.Format(ctx) 3594 if node.Num != 0 { 3595 if node.IsSubPartition { 3596 ctx.WriteString(" subpartitions ") 3597 } else { 3598 ctx.WriteString(" partitions ") 3599 } 3600 ctx.WriteString(strconv.FormatUint(node.Num, 10)) 3601 } 3602 } 3603 3604 func (node PartitionBy) TypeName() string { return "tree.PartitionBy" } 3605 3606 func (node *PartitionBy) reset() { 3607 switch t := node.PType.(type) { 3608 case *HashType: 3609 t.Free() 3610 case *KeyType: 3611 t.Free() 3612 case *RangeType: 3613 t.Free() 3614 case *ListType: 3615 t.Free() 3616 default: 3617 if t != nil { 3618 panic(fmt.Sprintf("miss Free for %v", node.PType)) 3619 } 3620 } 3621 3622 *node = PartitionBy{} 3623 } 3624 3625 func (node *PartitionBy) Free() { 3626 reuse.Free[PartitionBy](node, nil) 3627 } 3628 3629 func NewPartitionBy(typ PartitionType) *PartitionBy { 3630 pb := reuse.Alloc[PartitionBy](nil) 3631 pb.PType = typ 3632 return pb 3633 } 3634 3635 func NewPartitionBy2(issub bool, pt PartitionType, n uint64) *PartitionBy { 3636 pb := reuse.Alloc[PartitionBy](nil) 3637 pb.IsSubPartition = issub 3638 pb.PType = pt 3639 pb.Num = n 3640 return pb 3641 } 3642 3643 type Values interface { 3644 NodeFormatter 3645 } 3646 3647 type valuesImpl struct { 3648 Values 3649 } 3650 3651 type ValuesLessThan struct { 3652 valuesImpl 3653 ValueList Exprs 3654 } 3655 3656 func (node *ValuesLessThan) Format(ctx *FmtCtx) { 3657 ctx.WriteString("values less than (") 3658 node.ValueList.Format(ctx) 3659 ctx.WriteByte(')') 3660 } 3661 3662 func (node ValuesLessThan) TypeName() string { return "tree.ValuesLessThan" } 3663 3664 func (node *ValuesLessThan) reset() { 3665 *node = ValuesLessThan{} 3666 } 3667 3668 func (node *ValuesLessThan) Free() { 3669 reuse.Free[ValuesLessThan](node, nil) 3670 } 3671 3672 func NewValuesLessThan(vl Exprs) *ValuesLessThan { 3673 v := reuse.Alloc[ValuesLessThan](nil) 3674 v.ValueList = vl 3675 return v 3676 } 3677 3678 type ValuesIn struct { 3679 valuesImpl 3680 ValueList Exprs 3681 } 3682 3683 func (node *ValuesIn) Format(ctx *FmtCtx) { 3684 ctx.WriteString("values in (") 3685 node.ValueList.Format(ctx) 3686 ctx.WriteByte(')') 3687 } 3688 3689 func (node ValuesIn) TypeName() string { return "tree.ValuesIn" } 3690 3691 func (node *ValuesIn) reset() { 3692 *node = ValuesIn{} 3693 } 3694 3695 func (node *ValuesIn) Free() { 3696 reuse.Free[ValuesIn](node, nil) 3697 } 3698 3699 func NewValuesIn(vl Exprs) *ValuesIn { 3700 vi := reuse.Alloc[ValuesIn](nil) 3701 vi.ValueList = vl 3702 return vi 3703 } 3704 3705 type Partition struct { 3706 Name Identifier 3707 Values Values 3708 Options []TableOption 3709 Subs []*SubPartition 3710 } 3711 3712 func (node *Partition) Format(ctx *FmtCtx) { 3713 ctx.WriteString("partition ") 3714 ctx.WriteString(string(node.Name)) 3715 if node.Values != nil { 3716 ctx.WriteByte(' ') 3717 node.Values.Format(ctx) 3718 } 3719 if node.Options != nil { 3720 prefix := " " 3721 for _, t := range node.Options { 3722 ctx.WriteString(prefix) 3723 t.Format(ctx) 3724 prefix = " " 3725 } 3726 } 3727 if node.Subs != nil { 3728 prefix := " (" 3729 for _, s := range node.Subs { 3730 ctx.WriteString(prefix) 3731 s.Format(ctx) 3732 prefix = ", " 3733 } 3734 ctx.WriteByte(')') 3735 } 3736 } 3737 3738 func (node Partition) TypeName() string { return "tree.Partition" } 3739 3740 func (node *Partition) reset() { 3741 if node.Options != nil { 3742 for _, item := range node.Options { 3743 switch opt := item.(type) { 3744 case *TableOptionProperties: 3745 opt.Free() 3746 case *TableOptionEngine: 3747 opt.Free() 3748 case *TableOptionEngineAttr: 3749 opt.Free() 3750 case *TableOptionInsertMethod: 3751 opt.Free() 3752 case *TableOptionSecondaryEngine: 3753 opt.Free() 3754 case *TableOptionSecondaryEngineNull: 3755 panic("currently not used") 3756 case *TableOptionCharset: 3757 opt.Free() 3758 case *TableOptionCollate: 3759 opt.Free() 3760 case *TableOptionAUTOEXTEND_SIZE: 3761 opt.Free() 3762 case *TableOptionAutoIncrement: 3763 opt.Free() 3764 case *TableOptionComment: 3765 opt.Free() 3766 case *TableOptionAvgRowLength: 3767 opt.Free() 3768 case *TableOptionChecksum: 3769 opt.Free() 3770 case *TableOptionCompression: 3771 opt.Free() 3772 case *TableOptionConnection: 3773 opt.Free() 3774 case *TableOptionPassword: 3775 opt.Free() 3776 case *TableOptionKeyBlockSize: 3777 opt.Free() 3778 case *TableOptionMaxRows: 3779 opt.Free() 3780 case *TableOptionMinRows: 3781 opt.Free() 3782 case *TableOptionDelayKeyWrite: 3783 opt.Free() 3784 case *TableOptionRowFormat: 3785 opt.Free() 3786 case *TableOptionStartTrans: 3787 opt.Free() 3788 case *TableOptionSecondaryEngineAttr: 3789 opt.Free() 3790 case *TableOptionStatsPersistent: 3791 opt.Free() 3792 case *TableOptionStatsAutoRecalc: 3793 opt.Free() 3794 case *TableOptionPackKeys: 3795 opt.Free() 3796 case *TableOptionTablespace: 3797 opt.Free() 3798 case *TableOptionDataDirectory: 3799 opt.Free() 3800 case *TableOptionIndexDirectory: 3801 opt.Free() 3802 case *TableOptionStorageMedia: 3803 opt.Free() 3804 case *TableOptionStatsSamplePages: 3805 opt.Free() 3806 case *TableOptionUnion: 3807 opt.Free() 3808 case *TableOptionEncryption: 3809 opt.Free() 3810 default: 3811 if opt != nil { 3812 panic(fmt.Sprintf("miss Free for %v", item)) 3813 } 3814 } 3815 } 3816 } 3817 3818 if node.Values != nil { 3819 switch v := node.Values.(type) { 3820 case *ValuesLessThan: 3821 v.Free() 3822 case *ValuesIn: 3823 v.Free() 3824 default: 3825 if v != nil { 3826 panic(fmt.Sprintf("miss Free for %v", node.Values)) 3827 } 3828 } 3829 } 3830 3831 if node.Subs != nil { 3832 for _, item := range node.Subs { 3833 item.Free() 3834 } 3835 } 3836 *node = Partition{} 3837 } 3838 3839 func (node *Partition) Free() { 3840 reuse.Free[Partition](node, nil) 3841 } 3842 3843 func NewPartition(n Identifier, v Values, o []TableOption, s []*SubPartition) *Partition { 3844 p := reuse.Alloc[Partition](nil) 3845 p.Name = n 3846 p.Values = v 3847 p.Options = o 3848 p.Subs = s 3849 return p 3850 } 3851 3852 type SubPartition struct { 3853 Name Identifier 3854 Options []TableOption 3855 } 3856 3857 func (node *SubPartition) Format(ctx *FmtCtx) { 3858 ctx.WriteString("subpartition ") 3859 ctx.WriteString(string(node.Name)) 3860 3861 if node.Options != nil { 3862 prefix := " " 3863 for _, t := range node.Options { 3864 ctx.WriteString(prefix) 3865 t.Format(ctx) 3866 prefix = " " 3867 } 3868 } 3869 } 3870 3871 func (node SubPartition) TypeName() string { return "tree.SubPartition" } 3872 3873 func (node *SubPartition) reset() { 3874 if node.Options != nil { 3875 for _, item := range node.Options { 3876 switch opt := item.(type) { 3877 case *TableOptionProperties: 3878 opt.Free() 3879 case *TableOptionEngine: 3880 opt.Free() 3881 case *TableOptionEngineAttr: 3882 opt.Free() 3883 case *TableOptionInsertMethod: 3884 opt.Free() 3885 case *TableOptionSecondaryEngine: 3886 opt.Free() 3887 case *TableOptionSecondaryEngineNull: 3888 panic("currently not used") 3889 case *TableOptionCharset: 3890 opt.Free() 3891 case *TableOptionCollate: 3892 opt.Free() 3893 case *TableOptionAUTOEXTEND_SIZE: 3894 opt.Free() 3895 case *TableOptionAutoIncrement: 3896 opt.Free() 3897 case *TableOptionComment: 3898 opt.Free() 3899 case *TableOptionAvgRowLength: 3900 opt.Free() 3901 case *TableOptionChecksum: 3902 opt.Free() 3903 case *TableOptionCompression: 3904 opt.Free() 3905 case *TableOptionConnection: 3906 opt.Free() 3907 case *TableOptionPassword: 3908 opt.Free() 3909 case *TableOptionKeyBlockSize: 3910 opt.Free() 3911 case *TableOptionMaxRows: 3912 opt.Free() 3913 case *TableOptionMinRows: 3914 opt.Free() 3915 case *TableOptionDelayKeyWrite: 3916 opt.Free() 3917 case *TableOptionRowFormat: 3918 opt.Free() 3919 case *TableOptionStartTrans: 3920 opt.Free() 3921 case *TableOptionSecondaryEngineAttr: 3922 opt.Free() 3923 case *TableOptionStatsPersistent: 3924 opt.Free() 3925 case *TableOptionStatsAutoRecalc: 3926 opt.Free() 3927 case *TableOptionPackKeys: 3928 opt.Free() 3929 case *TableOptionTablespace: 3930 opt.Free() 3931 case *TableOptionDataDirectory: 3932 opt.Free() 3933 case *TableOptionIndexDirectory: 3934 opt.Free() 3935 case *TableOptionStorageMedia: 3936 opt.Free() 3937 case *TableOptionStatsSamplePages: 3938 opt.Free() 3939 case *TableOptionUnion: 3940 opt.Free() 3941 case *TableOptionEncryption: 3942 opt.Free() 3943 default: 3944 if opt != nil { 3945 panic(fmt.Sprintf("miss Free for %v", item)) 3946 } 3947 } 3948 } 3949 } 3950 *node = SubPartition{} 3951 } 3952 3953 func (node *SubPartition) Free() { 3954 reuse.Free[SubPartition](node, nil) 3955 } 3956 3957 func NewSubPartition(n Identifier, o []TableOption) *SubPartition { 3958 s := reuse.Alloc[SubPartition](nil) 3959 s.Name = n 3960 s.Options = o 3961 return s 3962 } 3963 3964 type ClusterByOption struct { 3965 ColumnList []*UnresolvedName 3966 } 3967 3968 func NewClusterByOption(c []*UnresolvedName) *ClusterByOption { 3969 cb := reuse.Alloc[ClusterByOption](nil) 3970 cb.ColumnList = c 3971 return cb 3972 } 3973 3974 func (node ClusterByOption) TypeName() string { return "tree.ClusterByOption" } 3975 3976 func (node *ClusterByOption) reset() { 3977 // if node.ColumnList != nil { 3978 // for _, item := range node.ColumnList { 3979 // reuse.Free[UnresolvedName](item, nil) 3980 // } 3981 // } 3982 } 3983 3984 func (node *ClusterByOption) Free() { 3985 reuse.Free[ClusterByOption](node, nil) 3986 } 3987 3988 type PartitionOption struct { 3989 statementImpl 3990 PartBy *PartitionBy 3991 SubPartBy *PartitionBy 3992 Partitions []*Partition 3993 } 3994 3995 func (node *PartitionOption) Format(ctx *FmtCtx) { 3996 ctx.WriteString("partition by ") 3997 node.PartBy.Format(ctx) 3998 if node.SubPartBy != nil { 3999 ctx.WriteString(" subpartition by ") 4000 node.SubPartBy.Format(ctx) 4001 } 4002 if node.Partitions != nil { 4003 prefix := " (" 4004 for _, p := range node.Partitions { 4005 ctx.WriteString(prefix) 4006 p.Format(ctx) 4007 prefix = ", " 4008 } 4009 ctx.WriteByte(')') 4010 } 4011 } 4012 4013 func (node PartitionOption) TypeName() string { return "tree.PartitionOption" } 4014 4015 func (node *PartitionOption) reset() { 4016 if node.PartBy != nil { 4017 node.PartBy.Free() 4018 } 4019 if node.SubPartBy != nil { 4020 node.SubPartBy.Free() 4021 } 4022 if node.Partitions != nil { 4023 for _, item := range node.Partitions { 4024 item.Free() 4025 } 4026 } 4027 *node = PartitionOption{} 4028 } 4029 4030 func (node *PartitionOption) Free() { 4031 reuse.Free[PartitionOption](node, nil) 4032 } 4033 4034 func NewPartitionOption(pb *PartitionBy, spb *PartitionBy, parts []*Partition) *PartitionOption { 4035 p := reuse.Alloc[PartitionOption](nil) 4036 p.PartBy = pb 4037 p.SubPartBy = spb 4038 p.Partitions = parts 4039 return p 4040 } 4041 4042 type IndexCategory int 4043 4044 func (ic IndexCategory) ToString() string { 4045 switch ic { 4046 case INDEX_CATEGORY_UNIQUE: 4047 return "unique" 4048 case INDEX_CATEGORY_FULLTEXT: 4049 return "fulltext" 4050 case INDEX_CATEGORY_SPATIAL: 4051 return "spatial" 4052 default: 4053 return "Unknown IndexCategory" 4054 } 4055 } 4056 4057 const ( 4058 INDEX_CATEGORY_NONE IndexCategory = iota 4059 INDEX_CATEGORY_UNIQUE 4060 INDEX_CATEGORY_FULLTEXT 4061 INDEX_CATEGORY_SPATIAL 4062 ) 4063 4064 type CreateIndex struct { 4065 statementImpl 4066 Name Identifier 4067 Table *TableName 4068 IndexCat IndexCategory 4069 IfNotExists bool 4070 KeyParts []*KeyPart 4071 IndexOption *IndexOption 4072 MiscOption []MiscOption 4073 } 4074 4075 func (node *CreateIndex) Format(ctx *FmtCtx) { 4076 ctx.WriteString("create ") 4077 if node.IndexCat != INDEX_CATEGORY_NONE { 4078 ctx.WriteString(node.IndexCat.ToString()) 4079 ctx.WriteByte(' ') 4080 } 4081 4082 ctx.WriteString("index ") 4083 node.Name.Format(ctx) 4084 ctx.WriteByte(' ') 4085 4086 if node.IndexOption != nil && node.IndexOption.IType != INDEX_TYPE_INVALID { 4087 ctx.WriteString("using ") 4088 ctx.WriteString(node.IndexOption.IType.ToString()) 4089 ctx.WriteByte(' ') 4090 } 4091 4092 ctx.WriteString("on ") 4093 node.Table.Format(ctx) 4094 4095 ctx.WriteString(" (") 4096 if node.KeyParts != nil { 4097 prefix := "" 4098 for _, kp := range node.KeyParts { 4099 ctx.WriteString(prefix) 4100 kp.Format(ctx) 4101 prefix = ", " 4102 } 4103 } 4104 ctx.WriteString(")") 4105 if node.IndexOption != nil { 4106 node.IndexOption.Format(ctx) 4107 } 4108 } 4109 4110 func (node *CreateIndex) GetStatementType() string { return "Create Index" } 4111 func (node *CreateIndex) GetQueryType() string { return QueryTypeDDL } 4112 4113 func (node CreateIndex) TypeName() string { return "tree.CreateIndex" } 4114 4115 func (node *CreateIndex) reset() { 4116 if node.KeyParts != nil { 4117 for _, item := range node.KeyParts { 4118 item.Free() 4119 } 4120 } 4121 if node.IndexOption != nil { 4122 node.IndexOption.Free() 4123 } 4124 4125 *node = CreateIndex{} 4126 } 4127 4128 func (node *CreateIndex) Free() { 4129 reuse.Free[CreateIndex](node, nil) 4130 } 4131 4132 func NewCreateIndex(n Identifier, t *TableName, ife bool, it IndexCategory, k []*KeyPart, i *IndexOption, m []MiscOption) *CreateIndex { 4133 c := reuse.Alloc[CreateIndex](nil) 4134 c.Name = n 4135 c.Table = t 4136 c.IfNotExists = ife 4137 c.IndexCat = it 4138 c.KeyParts = k 4139 c.IndexOption = i 4140 c.MiscOption = m 4141 return c 4142 } 4143 4144 type MiscOption interface { 4145 NodeFormatter 4146 } 4147 4148 type miscOption struct { 4149 MiscOption 4150 } 4151 4152 type AlgorithmDefault struct { 4153 miscOption 4154 } 4155 4156 type AlgorithmInplace struct { 4157 miscOption 4158 } 4159 4160 type AlgorithmCopy struct { 4161 miscOption 4162 } 4163 4164 type LockDefault struct { 4165 miscOption 4166 } 4167 4168 type LockNone struct { 4169 miscOption 4170 } 4171 4172 type LockShared struct { 4173 miscOption 4174 } 4175 4176 type LockExclusive struct { 4177 miscOption 4178 } 4179 4180 type CreateRole struct { 4181 statementImpl 4182 IfNotExists bool 4183 Roles []*Role 4184 } 4185 4186 func (node *CreateRole) Format(ctx *FmtCtx) { 4187 ctx.WriteString("create role ") 4188 if node.IfNotExists { 4189 ctx.WriteString("if not exists ") 4190 } 4191 prefix := "" 4192 for _, r := range node.Roles { 4193 ctx.WriteString(prefix) 4194 r.Format(ctx) 4195 prefix = ", " 4196 } 4197 } 4198 4199 func (node *CreateRole) GetStatementType() string { return "Create Role" } 4200 func (node *CreateRole) GetQueryType() string { return QueryTypeDCL } 4201 4202 func (node CreateRole) TypeName() string { return "tree.CreateRole" } 4203 4204 func (node *CreateRole) reset() { 4205 if node.Roles != nil { 4206 for _, role := range node.Roles { 4207 role.Free() 4208 } 4209 } 4210 *node = CreateRole{} 4211 } 4212 4213 func (node *CreateRole) Free() { 4214 reuse.Free[CreateRole](node, nil) 4215 } 4216 4217 func NewCreateRole(ife bool, r []*Role) *CreateRole { 4218 cr := reuse.Alloc[CreateRole](nil) 4219 cr.IfNotExists = ife 4220 cr.Roles = r 4221 return cr 4222 } 4223 4224 type Role struct { 4225 NodeFormatter 4226 UserName string 4227 } 4228 4229 func (node *Role) Format(ctx *FmtCtx) { 4230 ctx.WriteString(node.UserName) 4231 } 4232 4233 func (node Role) TypeName() string { return "tree.Role" } 4234 4235 func (node *Role) reset() { 4236 *node = Role{} 4237 } 4238 4239 func (node *Role) Free() { 4240 // reuse.Free[Role](node, nil) 4241 } 4242 4243 func NewRole(u string) *Role { 4244 // r := reuse.Alloc[Role](nil) 4245 r := new(Role) 4246 r.UserName = u 4247 return r 4248 } 4249 4250 type User struct { 4251 NodeFormatter 4252 Username string 4253 Hostname string 4254 AuthOption *AccountIdentified 4255 } 4256 4257 func (node *User) Format(ctx *FmtCtx) { 4258 ctx.WriteString(node.Username) 4259 if node.Hostname != "%" { 4260 ctx.WriteByte('@') 4261 ctx.WriteString(node.Hostname) 4262 } 4263 if node.AuthOption != nil { 4264 node.AuthOption.Format(ctx) 4265 } 4266 } 4267 4268 func (node User) TypeName() string { return "tree.User" } 4269 4270 func (node *User) reset() { 4271 if node.AuthOption != nil { 4272 node.AuthOption.Free() 4273 } 4274 *node = User{} 4275 } 4276 4277 func (node *User) Free() { 4278 // if node.AuthOption != nil { 4279 // node.AuthOption.Free() 4280 // } 4281 // reuse.Free[User](node, nil) 4282 } 4283 4284 func NewUser(u, h string, a *AccountIdentified) *User { 4285 // ur := reuse.Alloc[User](nil) 4286 ur := new(User) 4287 ur.Username = u 4288 ur.Hostname = h 4289 ur.AuthOption = a 4290 return ur 4291 } 4292 4293 type UsernameRecord struct { 4294 Username string 4295 Hostname string 4296 } 4297 4298 type AuthRecord struct { 4299 AuthPlugin string 4300 AuthString string 4301 HashString string 4302 ByAuth bool 4303 } 4304 4305 type TlsOption interface { 4306 NodeFormatter 4307 } 4308 4309 type tlsOptionImpl struct { 4310 TlsOption 4311 } 4312 4313 type TlsOptionNone struct { 4314 tlsOptionImpl 4315 } 4316 4317 func (node *TlsOptionNone) Format(ctx *FmtCtx) { 4318 ctx.WriteString("none") 4319 } 4320 4321 func (node TlsOptionNone) TypeName() string { return "tree.TlsOptionNone" } 4322 4323 func (node *TlsOptionNone) reset() { 4324 *node = TlsOptionNone{} 4325 } 4326 4327 func (node *TlsOptionNone) Free() { 4328 reuse.Free[TlsOptionNone](node, nil) 4329 } 4330 4331 type TlsOptionSSL struct { 4332 tlsOptionImpl 4333 } 4334 4335 func (node *TlsOptionSSL) Format(ctx *FmtCtx) { 4336 ctx.WriteString("ssl") 4337 } 4338 4339 func (node TlsOptionSSL) TypeName() string { return "tree.TlsOptionSSL" } 4340 4341 func (node *TlsOptionSSL) reset() { 4342 *node = TlsOptionSSL{} 4343 } 4344 4345 func (node *TlsOptionSSL) Free() { 4346 reuse.Free[TlsOptionSSL](node, nil) 4347 } 4348 4349 type TlsOptionX509 struct { 4350 tlsOptionImpl 4351 } 4352 4353 func (node *TlsOptionX509) Format(ctx *FmtCtx) { 4354 ctx.WriteString("x509") 4355 } 4356 4357 func (node TlsOptionX509) TypeName() string { return "tree.TlsOptionX509" } 4358 4359 func (node *TlsOptionX509) reset() { 4360 *node = TlsOptionX509{} 4361 } 4362 4363 func (node *TlsOptionX509) Free() { 4364 reuse.Free[TlsOptionX509](node, nil) 4365 } 4366 4367 type TlsOptionCipher struct { 4368 tlsOptionImpl 4369 Cipher string 4370 } 4371 4372 func (node *TlsOptionCipher) Format(ctx *FmtCtx) { 4373 ctx.WriteString("cipher ") 4374 ctx.WriteString(node.Cipher) 4375 } 4376 4377 func (node TlsOptionCipher) TypeName() string { return "tree.TlsOptionCipher" } 4378 4379 func (node *TlsOptionCipher) reset() { 4380 *node = TlsOptionCipher{} 4381 } 4382 4383 func (node *TlsOptionCipher) Free() { 4384 reuse.Free[TlsOptionCipher](node, nil) 4385 } 4386 4387 type TlsOptionIssuer struct { 4388 tlsOptionImpl 4389 Issuer string 4390 } 4391 4392 func (node *TlsOptionIssuer) Format(ctx *FmtCtx) { 4393 ctx.WriteString("issuer ") 4394 ctx.WriteString(node.Issuer) 4395 } 4396 4397 func (node TlsOptionIssuer) TypeName() string { return "tree.TlsOptionIssuer" } 4398 4399 func (node *TlsOptionIssuer) reset() { 4400 *node = TlsOptionIssuer{} 4401 } 4402 4403 func (node *TlsOptionIssuer) Free() { 4404 reuse.Free[TlsOptionIssuer](node, nil) 4405 } 4406 4407 type TlsOptionSubject struct { 4408 tlsOptionImpl 4409 Subject string 4410 } 4411 4412 func (node *TlsOptionSubject) Format(ctx *FmtCtx) { 4413 ctx.WriteString("subject ") 4414 ctx.WriteString(node.Subject) 4415 } 4416 4417 func (node TlsOptionSubject) TypeName() string { return "tree.TlsOptionSubject" } 4418 4419 func (node *TlsOptionSubject) reset() { 4420 *node = TlsOptionSubject{} 4421 } 4422 4423 func (node *TlsOptionSubject) Free() { 4424 reuse.Free[TlsOptionSubject](node, nil) 4425 } 4426 4427 type TlsOptionSan struct { 4428 tlsOptionImpl 4429 San string 4430 } 4431 4432 func (node *TlsOptionSan) Format(ctx *FmtCtx) { 4433 ctx.WriteString("san ") 4434 ctx.WriteString(node.San) 4435 } 4436 4437 func (node TlsOptionSan) TypeName() string { return "tree.TlsOptionSan" } 4438 4439 func (node *TlsOptionSan) reset() { 4440 *node = TlsOptionSan{} 4441 } 4442 4443 func (node *TlsOptionSan) Free() { 4444 reuse.Free[TlsOptionSan](node, nil) 4445 } 4446 4447 type ResourceOption interface { 4448 NodeFormatter 4449 } 4450 4451 type resourceOptionImpl struct { 4452 ResourceOption 4453 } 4454 4455 type ResourceOptionMaxQueriesPerHour struct { 4456 resourceOptionImpl 4457 Count int64 4458 } 4459 4460 func (node *ResourceOptionMaxQueriesPerHour) Format(ctx *FmtCtx) { 4461 ctx.WriteString("max_queries_per_hour ") 4462 ctx.WriteString(strconv.FormatInt(node.Count, 10)) 4463 } 4464 4465 func (node ResourceOptionMaxQueriesPerHour) TypeName() string { 4466 return "tree.ResourceOptionMaxQueriesPerHour" 4467 } 4468 4469 func (node *ResourceOptionMaxQueriesPerHour) reset() { 4470 *node = ResourceOptionMaxQueriesPerHour{} 4471 } 4472 4473 func (node *ResourceOptionMaxQueriesPerHour) Free() { 4474 reuse.Free[ResourceOptionMaxQueriesPerHour](node, nil) 4475 } 4476 4477 type ResourceOptionMaxUpdatesPerHour struct { 4478 resourceOptionImpl 4479 Count int64 4480 } 4481 4482 func (node *ResourceOptionMaxUpdatesPerHour) Format(ctx *FmtCtx) { 4483 ctx.WriteString("max_updates_per_hour ") 4484 ctx.WriteString(strconv.FormatInt(node.Count, 10)) 4485 } 4486 4487 func (node ResourceOptionMaxUpdatesPerHour) TypeName() string { 4488 return "tree.ResourceOptionMaxUpdatesPerHour" 4489 } 4490 4491 func (node *ResourceOptionMaxUpdatesPerHour) reset() { 4492 *node = ResourceOptionMaxUpdatesPerHour{} 4493 } 4494 4495 func (node *ResourceOptionMaxUpdatesPerHour) Free() { 4496 reuse.Free[ResourceOptionMaxUpdatesPerHour](node, nil) 4497 } 4498 4499 type ResourceOptionMaxConnectionPerHour struct { 4500 resourceOptionImpl 4501 Count int64 4502 } 4503 4504 func (node *ResourceOptionMaxConnectionPerHour) Format(ctx *FmtCtx) { 4505 ctx.WriteString("max_connections_per_hour ") 4506 ctx.WriteString(strconv.FormatInt(node.Count, 10)) 4507 } 4508 4509 func (node ResourceOptionMaxConnectionPerHour) TypeName() string { 4510 return "tree.ResourceOptionMaxConnectionPerHour" 4511 } 4512 4513 func (node *ResourceOptionMaxConnectionPerHour) reset() { 4514 *node = ResourceOptionMaxConnectionPerHour{} 4515 } 4516 4517 func (node *ResourceOptionMaxConnectionPerHour) Free() { 4518 reuse.Free[ResourceOptionMaxConnectionPerHour](node, nil) 4519 } 4520 4521 type ResourceOptionMaxUserConnections struct { 4522 resourceOptionImpl 4523 Count int64 4524 } 4525 4526 func (node *ResourceOptionMaxUserConnections) Format(ctx *FmtCtx) { 4527 ctx.WriteString("max_user_connections ") 4528 ctx.WriteString(strconv.FormatInt(node.Count, 10)) 4529 } 4530 4531 func (node ResourceOptionMaxUserConnections) TypeName() string { 4532 return "tree.ResourceOptionMaxUserConnections" 4533 } 4534 4535 func (node *ResourceOptionMaxUserConnections) reset() { 4536 *node = ResourceOptionMaxUserConnections{} 4537 } 4538 4539 func (node *ResourceOptionMaxUserConnections) Free() { 4540 reuse.Free[ResourceOptionMaxUserConnections](node, nil) 4541 } 4542 4543 type UserMiscOption interface { 4544 NodeFormatter 4545 } 4546 4547 type userMiscOptionImpl struct { 4548 UserMiscOption 4549 } 4550 4551 type UserMiscOptionPasswordExpireNone struct { 4552 userMiscOptionImpl 4553 } 4554 4555 func NewUserMiscOptionPasswordExpireNone() *UserMiscOptionPasswordExpireNone { 4556 return reuse.Alloc[UserMiscOptionPasswordExpireNone](nil) 4557 } 4558 4559 func (node *UserMiscOptionPasswordExpireNone) Format(ctx *FmtCtx) { 4560 ctx.WriteString("password expire") 4561 } 4562 4563 func (node UserMiscOptionPasswordExpireNone) TypeName() string { 4564 return "tree.UserMiscOptionPasswordExpireNone" 4565 } 4566 4567 func (node *UserMiscOptionPasswordExpireNone) reset() { 4568 *node = UserMiscOptionPasswordExpireNone{} 4569 } 4570 4571 func (node *UserMiscOptionPasswordExpireNone) Free() { 4572 reuse.Free[UserMiscOptionPasswordExpireNone](node, nil) 4573 } 4574 4575 type UserMiscOptionPasswordExpireDefault struct { 4576 userMiscOptionImpl 4577 } 4578 4579 func NewUserMiscOptionPasswordExpireDefault() *UserMiscOptionPasswordExpireDefault { 4580 return reuse.Alloc[UserMiscOptionPasswordExpireDefault](nil) 4581 } 4582 4583 func (node *UserMiscOptionPasswordExpireDefault) Format(ctx *FmtCtx) { 4584 ctx.WriteString("password expire default") 4585 } 4586 4587 func (node UserMiscOptionPasswordExpireDefault) TypeName() string { 4588 return "tree.UserMiscOptionPasswordExpireDefault" 4589 } 4590 4591 func (node *UserMiscOptionPasswordExpireDefault) reset() { 4592 *node = UserMiscOptionPasswordExpireDefault{} 4593 } 4594 4595 func (node *UserMiscOptionPasswordExpireDefault) Free() { 4596 reuse.Free[UserMiscOptionPasswordExpireDefault](node, nil) 4597 } 4598 4599 type UserMiscOptionPasswordExpireNever struct { 4600 userMiscOptionImpl 4601 } 4602 4603 func NewUserMiscOptionPasswordExpireNever() *UserMiscOptionPasswordExpireNever { 4604 return reuse.Alloc[UserMiscOptionPasswordExpireNever](nil) 4605 } 4606 4607 func (node *UserMiscOptionPasswordExpireNever) Format(ctx *FmtCtx) { 4608 ctx.WriteString("password expire never") 4609 } 4610 4611 func (node UserMiscOptionPasswordExpireNever) TypeName() string { 4612 return "tree.UserMiscOptionPasswordExpireNever" 4613 } 4614 4615 func (node *UserMiscOptionPasswordExpireNever) reset() { 4616 *node = UserMiscOptionPasswordExpireNever{} 4617 } 4618 4619 func (node *UserMiscOptionPasswordExpireNever) Free() { 4620 reuse.Free[UserMiscOptionPasswordExpireNever](node, nil) 4621 } 4622 4623 type UserMiscOptionPasswordExpireInterval struct { 4624 userMiscOptionImpl 4625 Value int64 4626 } 4627 4628 func NewUserMiscOptionPasswordExpireInterval(v int64) *UserMiscOptionPasswordExpireInterval { 4629 pi := reuse.Alloc[UserMiscOptionPasswordExpireInterval](nil) 4630 pi.Value = v 4631 return pi 4632 } 4633 4634 func (node *UserMiscOptionPasswordExpireInterval) Format(ctx *FmtCtx) { 4635 ctx.WriteString("password expire interval ") 4636 ctx.WriteString(strconv.FormatInt(node.Value, 10)) 4637 ctx.WriteString(" day") 4638 } 4639 4640 func (node UserMiscOptionPasswordExpireInterval) TypeName() string { 4641 return "tree.UserMiscOptionPasswordExpireInterval" 4642 } 4643 4644 func (node *UserMiscOptionPasswordExpireInterval) reset() { 4645 *node = UserMiscOptionPasswordExpireInterval{} 4646 } 4647 4648 func (node *UserMiscOptionPasswordExpireInterval) Free() { 4649 reuse.Free[UserMiscOptionPasswordExpireInterval](node, nil) 4650 } 4651 4652 type UserMiscOptionPasswordHistoryDefault struct { 4653 userMiscOptionImpl 4654 } 4655 4656 func NewUserMiscOptionPasswordHistoryDefault() *UserMiscOptionPasswordHistoryDefault { 4657 return reuse.Alloc[UserMiscOptionPasswordHistoryDefault](nil) 4658 } 4659 4660 func (node *UserMiscOptionPasswordHistoryDefault) Format(ctx *FmtCtx) { 4661 ctx.WriteString("password history default") 4662 } 4663 4664 func (node UserMiscOptionPasswordHistoryDefault) TypeName() string { 4665 return "tree.UserMiscOptionPasswordHistoryDefault" 4666 } 4667 4668 func (node *UserMiscOptionPasswordHistoryDefault) reset() { 4669 *node = UserMiscOptionPasswordHistoryDefault{} 4670 } 4671 4672 func (node *UserMiscOptionPasswordHistoryDefault) Free() { 4673 reuse.Free[UserMiscOptionPasswordHistoryDefault](node, nil) 4674 } 4675 4676 type UserMiscOptionPasswordHistoryCount struct { 4677 userMiscOptionImpl 4678 Value int64 4679 } 4680 4681 func NewUserMiscOptionPasswordHistoryCount(v int64) *UserMiscOptionPasswordHistoryCount { 4682 phc := reuse.Alloc[UserMiscOptionPasswordHistoryCount](nil) 4683 phc.Value = v 4684 return phc 4685 } 4686 4687 func (node *UserMiscOptionPasswordHistoryCount) Format(ctx *FmtCtx) { 4688 ctx.WriteString(fmt.Sprintf("password history %d", node.Value)) 4689 } 4690 4691 func (node UserMiscOptionPasswordHistoryCount) TypeName() string { 4692 return "tree.UserMiscOptionPasswordHistoryCount" 4693 } 4694 4695 func (node *UserMiscOptionPasswordHistoryCount) reset() { 4696 *node = UserMiscOptionPasswordHistoryCount{} 4697 } 4698 4699 func (node *UserMiscOptionPasswordHistoryCount) Free() { 4700 reuse.Free[UserMiscOptionPasswordHistoryCount](node, nil) 4701 } 4702 4703 type UserMiscOptionPasswordReuseIntervalDefault struct { 4704 userMiscOptionImpl 4705 } 4706 4707 func NewUserMiscOptionPasswordReuseIntervalDefault() *UserMiscOptionPasswordReuseIntervalDefault { 4708 return reuse.Alloc[UserMiscOptionPasswordReuseIntervalDefault](nil) 4709 } 4710 4711 func (node *UserMiscOptionPasswordReuseIntervalDefault) Format(ctx *FmtCtx) { 4712 ctx.WriteString("password reuse interval default") 4713 } 4714 4715 func (node UserMiscOptionPasswordReuseIntervalDefault) TypeName() string { 4716 return "tree.UserMiscOptionPasswordReuseIntervalDefault" 4717 } 4718 4719 func (node *UserMiscOptionPasswordReuseIntervalDefault) reset() { 4720 *node = UserMiscOptionPasswordReuseIntervalDefault{} 4721 } 4722 4723 func (node *UserMiscOptionPasswordReuseIntervalDefault) Free() { 4724 reuse.Free[UserMiscOptionPasswordReuseIntervalDefault](node, nil) 4725 } 4726 4727 type UserMiscOptionPasswordReuseIntervalCount struct { 4728 userMiscOptionImpl 4729 Value int64 4730 } 4731 4732 func NewUserMiscOptionPasswordReuseIntervalCount(v int64) *UserMiscOptionPasswordReuseIntervalCount { 4733 pr := reuse.Alloc[UserMiscOptionPasswordReuseIntervalCount](nil) 4734 pr.Value = v 4735 return pr 4736 } 4737 4738 func (node *UserMiscOptionPasswordReuseIntervalCount) Format(ctx *FmtCtx) { 4739 ctx.WriteString(fmt.Sprintf("password reuse interval %d day", node.Value)) 4740 } 4741 4742 func (node UserMiscOptionPasswordReuseIntervalCount) TypeName() string { 4743 return "tree.UserMiscOptionPasswordReuseIntervalCount" 4744 } 4745 4746 func (node *UserMiscOptionPasswordReuseIntervalCount) reset() { 4747 *node = UserMiscOptionPasswordReuseIntervalCount{} 4748 } 4749 4750 func (node *UserMiscOptionPasswordReuseIntervalCount) Free() { 4751 reuse.Free[UserMiscOptionPasswordReuseIntervalCount](node, nil) 4752 } 4753 4754 type UserMiscOptionPasswordRequireCurrentNone struct { 4755 userMiscOptionImpl 4756 } 4757 4758 func NewUserMiscOptionPasswordRequireCurrentNone() *UserMiscOptionPasswordRequireCurrentNone { 4759 return reuse.Alloc[UserMiscOptionPasswordRequireCurrentNone](nil) 4760 } 4761 4762 func (node *UserMiscOptionPasswordRequireCurrentNone) Format(ctx *FmtCtx) { 4763 ctx.WriteString("password require current") 4764 } 4765 4766 func (node UserMiscOptionPasswordRequireCurrentNone) TypeName() string { 4767 return "tree.UserMiscOptionPasswordRequireCurrentNone" 4768 } 4769 4770 func (node *UserMiscOptionPasswordRequireCurrentNone) reset() { 4771 *node = UserMiscOptionPasswordRequireCurrentNone{} 4772 } 4773 4774 func (node *UserMiscOptionPasswordRequireCurrentNone) Free() { 4775 reuse.Free[UserMiscOptionPasswordRequireCurrentNone](node, nil) 4776 } 4777 4778 type UserMiscOptionPasswordRequireCurrentDefault struct { 4779 userMiscOptionImpl 4780 } 4781 4782 func NewUserMiscOptionPasswordRequireCurrentDefault() *UserMiscOptionPasswordRequireCurrentDefault { 4783 return reuse.Alloc[UserMiscOptionPasswordRequireCurrentDefault](nil) 4784 } 4785 4786 func (node *UserMiscOptionPasswordRequireCurrentDefault) Format(ctx *FmtCtx) { 4787 ctx.WriteString("password require current default") 4788 } 4789 4790 func (node UserMiscOptionPasswordRequireCurrentDefault) TypeName() string { 4791 return "tree.UserMiscOptionPasswordRequireCurrentDefault" 4792 } 4793 4794 func (node *UserMiscOptionPasswordRequireCurrentDefault) reset() { 4795 *node = UserMiscOptionPasswordRequireCurrentDefault{} 4796 } 4797 4798 func (node *UserMiscOptionPasswordRequireCurrentDefault) Free() { 4799 reuse.Free[UserMiscOptionPasswordRequireCurrentDefault](node, nil) 4800 } 4801 4802 type UserMiscOptionPasswordRequireCurrentOptional struct { 4803 userMiscOptionImpl 4804 } 4805 4806 func NewUserMiscOptionPasswordRequireCurrentOptional() *UserMiscOptionPasswordRequireCurrentOptional { 4807 return reuse.Alloc[UserMiscOptionPasswordRequireCurrentOptional](nil) 4808 } 4809 4810 func (node *UserMiscOptionPasswordRequireCurrentOptional) Format(ctx *FmtCtx) { 4811 ctx.WriteString("password require current optional") 4812 } 4813 4814 func (node UserMiscOptionPasswordRequireCurrentOptional) TypeName() string { 4815 return "tree.UserMiscOptionPasswordRequireCurrentOptional" 4816 } 4817 4818 func (node *UserMiscOptionPasswordRequireCurrentOptional) reset() { 4819 *node = UserMiscOptionPasswordRequireCurrentOptional{} 4820 } 4821 4822 func (node *UserMiscOptionPasswordRequireCurrentOptional) Free() { 4823 reuse.Free[UserMiscOptionPasswordRequireCurrentOptional](node, nil) 4824 } 4825 4826 type UserMiscOptionFailedLoginAttempts struct { 4827 userMiscOptionImpl 4828 Value int64 4829 } 4830 4831 func NewUserMiscOptionFailedLoginAttempts(v int64) *UserMiscOptionFailedLoginAttempts { 4832 fla := reuse.Alloc[UserMiscOptionFailedLoginAttempts](nil) 4833 fla.Value = v 4834 return fla 4835 } 4836 4837 func (node *UserMiscOptionFailedLoginAttempts) Format(ctx *FmtCtx) { 4838 ctx.WriteString(fmt.Sprintf("failed_login_attempts %d", node.Value)) 4839 } 4840 4841 func (node UserMiscOptionFailedLoginAttempts) TypeName() string { 4842 return "tree.UserMiscOptionFailedLoginAttempts" 4843 } 4844 4845 func (node *UserMiscOptionFailedLoginAttempts) reset() { 4846 *node = UserMiscOptionFailedLoginAttempts{} 4847 } 4848 4849 func (node *UserMiscOptionFailedLoginAttempts) Free() { 4850 reuse.Free[UserMiscOptionFailedLoginAttempts](node, nil) 4851 } 4852 4853 type UserMiscOptionPasswordLockTimeCount struct { 4854 userMiscOptionImpl 4855 Value int64 4856 } 4857 4858 func NewUserMiscOptionPasswordLockTimeCount(v int64) *UserMiscOptionPasswordLockTimeCount { 4859 ua := reuse.Alloc[UserMiscOptionPasswordLockTimeCount](nil) 4860 ua.Value = v 4861 return ua 4862 } 4863 4864 func (node *UserMiscOptionPasswordLockTimeCount) Format(ctx *FmtCtx) { 4865 ctx.WriteString(fmt.Sprintf("password_lock_time %d", node.Value)) 4866 } 4867 4868 func (node UserMiscOptionPasswordLockTimeCount) TypeName() string { 4869 return "tree.UserMiscOptionPasswordLockTimeCount" 4870 } 4871 4872 func (node *UserMiscOptionPasswordLockTimeCount) reset() { 4873 *node = UserMiscOptionPasswordLockTimeCount{} 4874 } 4875 4876 func (node *UserMiscOptionPasswordLockTimeCount) Free() { 4877 reuse.Free[UserMiscOptionPasswordLockTimeCount](node, nil) 4878 } 4879 4880 type UserMiscOptionPasswordLockTimeUnbounded struct { 4881 userMiscOptionImpl 4882 } 4883 4884 func NewUserMiscOptionPasswordLockTimeUnbounded() *UserMiscOptionPasswordLockTimeUnbounded { 4885 return reuse.Alloc[UserMiscOptionPasswordLockTimeUnbounded](nil) 4886 } 4887 4888 func (node *UserMiscOptionPasswordLockTimeUnbounded) Format(ctx *FmtCtx) { 4889 ctx.WriteString("password_lock_time unbounded") 4890 } 4891 4892 func (node UserMiscOptionPasswordLockTimeUnbounded) TypeName() string { 4893 return "tree.UserMiscOptionPasswordLockTimeUnbounded" 4894 } 4895 4896 func (node *UserMiscOptionPasswordLockTimeUnbounded) reset() { 4897 *node = UserMiscOptionPasswordLockTimeUnbounded{} 4898 } 4899 4900 func (node *UserMiscOptionPasswordLockTimeUnbounded) Free() { 4901 reuse.Free[UserMiscOptionPasswordLockTimeUnbounded](node, nil) 4902 } 4903 4904 type UserMiscOptionAccountLock struct { 4905 userMiscOptionImpl 4906 } 4907 4908 func NewUserMiscOptionAccountLock() *UserMiscOptionAccountLock { 4909 ua := reuse.Alloc[UserMiscOptionAccountLock](nil) 4910 return ua 4911 } 4912 4913 func (node *UserMiscOptionAccountLock) Format(ctx *FmtCtx) { 4914 ctx.WriteString("lock") 4915 } 4916 4917 func (node UserMiscOptionAccountLock) TypeName() string { return "tree.UserMiscOptionAccountLock" } 4918 4919 func (node *UserMiscOptionAccountLock) reset() { 4920 *node = UserMiscOptionAccountLock{} 4921 } 4922 4923 func (node *UserMiscOptionAccountLock) Free() { 4924 reuse.Free[UserMiscOptionAccountLock](node, nil) 4925 } 4926 4927 type UserMiscOptionAccountUnlock struct { 4928 userMiscOptionImpl 4929 } 4930 4931 func (node *UserMiscOptionAccountUnlock) Format(ctx *FmtCtx) { 4932 ctx.WriteString("unlock") 4933 } 4934 4935 func NewUserMiscOptionAccountUnlock() *UserMiscOptionAccountUnlock { 4936 ua := reuse.Alloc[UserMiscOptionAccountUnlock](nil) 4937 return ua 4938 } 4939 4940 func (node UserMiscOptionAccountUnlock) TypeName() string { return "tree.UserMiscOptionAccountUnlock" } 4941 4942 func (node *UserMiscOptionAccountUnlock) reset() { 4943 *node = UserMiscOptionAccountUnlock{} 4944 } 4945 4946 func (node *UserMiscOptionAccountUnlock) Free() { 4947 reuse.Free[UserMiscOptionAccountUnlock](node, nil) 4948 } 4949 4950 type CreateUser struct { 4951 statementImpl 4952 IfNotExists bool 4953 Users []*User 4954 Role *Role 4955 MiscOpt UserMiscOption 4956 // comment or attribute 4957 CommentOrAttribute AccountCommentOrAttribute 4958 } 4959 4960 func (node *CreateUser) Format(ctx *FmtCtx) { 4961 ctx.WriteString("create user ") 4962 if node.IfNotExists { 4963 ctx.WriteString("if not exists ") 4964 } 4965 if node.Users != nil { 4966 prefix := "" 4967 for _, u := range node.Users { 4968 ctx.WriteString(prefix) 4969 u.Format(ctx) 4970 prefix = ", " 4971 } 4972 } 4973 4974 if node.Role != nil { 4975 ctx.WriteString(" default role") 4976 ctx.WriteString(" ") 4977 node.Role.Format(ctx) 4978 } 4979 4980 if node.MiscOpt != nil { 4981 ctx.WriteString(" ") 4982 node.MiscOpt.Format(ctx) 4983 } 4984 4985 node.CommentOrAttribute.Format(ctx) 4986 } 4987 4988 func (node *CreateUser) GetStatementType() string { return "Create User" } 4989 func (node *CreateUser) GetQueryType() string { return QueryTypeDCL } 4990 4991 func (node CreateUser) TypeName() string { return "tree.CreateUser" } 4992 4993 func (node *CreateUser) reset() { 4994 if node.Users != nil { 4995 for _, item := range node.Users { 4996 item.Free() 4997 } 4998 } 4999 5000 if node.Role != nil { 5001 node.Role.Free() 5002 } 5003 5004 if node.MiscOpt != nil { 5005 switch mt := node.MiscOpt.(type) { 5006 case *UserMiscOptionPasswordExpireNone: 5007 mt.Free() 5008 case *UserMiscOptionPasswordExpireDefault: 5009 mt.Free() 5010 case *UserMiscOptionPasswordExpireNever: 5011 mt.Free() 5012 case *UserMiscOptionPasswordExpireInterval: 5013 mt.Free() 5014 case *UserMiscOptionPasswordHistoryDefault: 5015 mt.Free() 5016 case *UserMiscOptionPasswordHistoryCount: 5017 mt.Free() 5018 case *UserMiscOptionPasswordReuseIntervalDefault: 5019 mt.Free() 5020 case *UserMiscOptionPasswordReuseIntervalCount: 5021 mt.Free() 5022 case *UserMiscOptionPasswordRequireCurrentNone: 5023 mt.Free() 5024 case *UserMiscOptionPasswordRequireCurrentDefault: 5025 mt.Free() 5026 case *UserMiscOptionPasswordRequireCurrentOptional: 5027 mt.Free() 5028 case *UserMiscOptionFailedLoginAttempts: 5029 mt.Free() 5030 case *UserMiscOptionPasswordLockTimeCount: 5031 mt.Free() 5032 case *UserMiscOptionPasswordLockTimeUnbounded: 5033 mt.Free() 5034 case *UserMiscOptionAccountLock: 5035 mt.Free() 5036 case *UserMiscOptionAccountUnlock: 5037 mt.Free() 5038 default: 5039 if mt != nil { 5040 panic(fmt.Sprintf("miss Free for %v", node.MiscOpt)) 5041 } 5042 } 5043 } 5044 5045 node.CommentOrAttribute.Free() 5046 *node = CreateUser{} 5047 } 5048 5049 func (node *CreateUser) Free() { 5050 reuse.Free[CreateUser](node, nil) 5051 } 5052 5053 func NewCreateUser(ife bool, u []*User, r *Role, misc UserMiscOption, c AccountCommentOrAttribute) *CreateUser { 5054 cu := reuse.Alloc[CreateUser](nil) 5055 cu.IfNotExists = ife 5056 cu.Users = u 5057 cu.Role = r 5058 cu.MiscOpt = misc 5059 cu.CommentOrAttribute = c 5060 return cu 5061 } 5062 5063 type CreateAccount struct { 5064 statementImpl 5065 IfNotExists bool 5066 Name Expr 5067 AuthOption AccountAuthOption 5068 // status_option or not 5069 StatusOption AccountStatus 5070 // comment or not 5071 Comment AccountComment 5072 } 5073 5074 func NewCreateAccount(ife bool, n Expr, ao AccountAuthOption, so AccountStatus, c AccountComment) *CreateAccount { 5075 ca := reuse.Alloc[CreateAccount](nil) 5076 ca.IfNotExists = ife 5077 ca.Name = n 5078 ca.AuthOption = ao 5079 ca.StatusOption = so 5080 ca.Comment = c 5081 return ca 5082 } 5083 5084 func (node *CreateAccount) Format(ctx *FmtCtx) { 5085 ctx.WriteString("create account ") 5086 if node.IfNotExists { 5087 ctx.WriteString("if not exists ") 5088 } 5089 node.Name.Format(ctx) 5090 node.AuthOption.Format(ctx) 5091 node.StatusOption.Format(ctx) 5092 node.Comment.Format(ctx) 5093 } 5094 5095 func (node *CreateAccount) GetStatementType() string { return "Create Account" } 5096 func (node *CreateAccount) GetQueryType() string { return QueryTypeDCL } 5097 5098 func (node CreateAccount) TypeName() string { return "tree.CreateAccount" } 5099 5100 func (node *CreateAccount) reset() { 5101 *node = CreateAccount{} 5102 } 5103 5104 func (node *CreateAccount) Free() { 5105 reuse.Free[CreateAccount](node, nil) 5106 } 5107 5108 type AccountAuthOption struct { 5109 Equal string 5110 AdminName Expr 5111 IdentifiedType AccountIdentified 5112 } 5113 5114 func NewAccountAuthOption(e string, an Expr, it AccountIdentified) *AccountAuthOption { 5115 ao := reuse.Alloc[AccountAuthOption](nil) 5116 ao.Equal = e 5117 ao.AdminName = an 5118 ao.IdentifiedType = it 5119 return ao 5120 } 5121 5122 func (node *AccountAuthOption) Format(ctx *FmtCtx) { 5123 ctx.WriteString(" admin_name") 5124 if len(node.Equal) != 0 { 5125 ctx.WriteString(" ") 5126 ctx.WriteString(node.Equal) 5127 } 5128 5129 ctx.WriteString(" ") 5130 quoteCtx := *ctx 5131 quoteCtx.singleQuoteString = true 5132 node.AdminName.Format("eCtx) 5133 node.IdentifiedType.Format(ctx) 5134 } 5135 5136 func (node AccountAuthOption) TypeName() string { return "tree.AccountAuthOption" } 5137 5138 func (node *AccountAuthOption) reset() { 5139 *node = AccountAuthOption{} 5140 } 5141 5142 func (node *AccountAuthOption) Free() { 5143 reuse.Free[AccountAuthOption](node, nil) 5144 } 5145 5146 type AccountIdentifiedOption int 5147 5148 const ( 5149 AccountIdentifiedByPassword AccountIdentifiedOption = iota 5150 AccountIdentifiedByRandomPassword 5151 AccountIdentifiedWithSSL 5152 ) 5153 5154 type AccountIdentified struct { 5155 Typ AccountIdentifiedOption 5156 Str Expr 5157 } 5158 5159 func NewAccountIdentified(t AccountIdentifiedOption, s Expr) *AccountIdentified { 5160 // ai := reuse.Alloc[AccountIdentified](nil) 5161 ai := new(AccountIdentified) 5162 ai.Typ = t 5163 ai.Str = s 5164 return ai 5165 } 5166 5167 func (node *AccountIdentified) Format(ctx *FmtCtx) { 5168 _, isParam := node.Str.(*ParamExpr) 5169 5170 switch node.Typ { 5171 case AccountIdentifiedByPassword: 5172 if isParam { 5173 ctx.WriteString(" identified by ?") 5174 } else { 5175 ctx.WriteString(" identified by '******'") 5176 } 5177 case AccountIdentifiedByRandomPassword: 5178 ctx.WriteString(" identified by random password") 5179 case AccountIdentifiedWithSSL: 5180 if isParam { 5181 ctx.WriteString(" identified with ?") 5182 } else { 5183 ctx.WriteString(" identified with '******'") 5184 } 5185 } 5186 } 5187 5188 func (node AccountIdentified) TypeName() string { return "tree.AccountIdentified" } 5189 5190 func (node *AccountIdentified) reset() { 5191 *node = AccountIdentified{} 5192 } 5193 5194 func (node *AccountIdentified) Free() { 5195 // reuse.Free[AccountIdentified](node, nil) 5196 } 5197 5198 type AccountStatusOption int 5199 5200 const ( 5201 AccountStatusOpen AccountStatusOption = iota 5202 AccountStatusSuspend 5203 AccountStatusRestricted 5204 ) 5205 5206 func (aso AccountStatusOption) String() string { 5207 switch aso { 5208 case AccountStatusOpen: 5209 return "open" 5210 case AccountStatusSuspend: 5211 return "suspend" 5212 case AccountStatusRestricted: 5213 return "restricted" 5214 default: 5215 return "open" 5216 } 5217 } 5218 5219 type AccountStatus struct { 5220 Exist bool 5221 Option AccountStatusOption 5222 } 5223 5224 func NewAccountStatus() *AccountStatus { 5225 as := reuse.Alloc[AccountStatus](nil) 5226 return as 5227 } 5228 5229 func (node *AccountStatus) Format(ctx *FmtCtx) { 5230 if node.Exist { 5231 switch node.Option { 5232 case AccountStatusOpen: 5233 ctx.WriteString(" open") 5234 case AccountStatusSuspend: 5235 ctx.WriteString(" suspend") 5236 case AccountStatusRestricted: 5237 ctx.WriteString(" restricted") 5238 } 5239 } 5240 } 5241 5242 func (node AccountStatus) TypeName() string { return "tree.AccountStatus" } 5243 5244 func (node *AccountStatus) reset() { 5245 *node = AccountStatus{} 5246 } 5247 5248 func (node *AccountStatus) Free() { 5249 reuse.Free[AccountStatus](node, nil) 5250 } 5251 5252 type AccountComment struct { 5253 Exist bool 5254 Comment string 5255 } 5256 5257 func NewAccountComment() *AccountComment { 5258 ac := reuse.Alloc[AccountComment](nil) 5259 return ac 5260 } 5261 5262 func (node *AccountComment) Format(ctx *FmtCtx) { 5263 if node.Exist { 5264 ctx.WriteString(" comment ") 5265 ctx.WriteString(fmt.Sprintf("'%s'", node.Comment)) 5266 } 5267 } 5268 5269 func (node AccountComment) TypeName() string { return "tree.AccountComment" } 5270 5271 func (node *AccountComment) reset() { 5272 *node = AccountComment{} 5273 } 5274 5275 func (node *AccountComment) Free() { 5276 reuse.Free[AccountComment](node, nil) 5277 } 5278 5279 type AccountCommentOrAttribute struct { 5280 Exist bool 5281 IsComment bool 5282 Str string 5283 } 5284 5285 func NewAccountCommentOrAttribute(e bool, c bool, s string) *AccountCommentOrAttribute { 5286 // aca := reuse.Alloc[AccountCommentOrAttribute](nil) 5287 aca := new(AccountCommentOrAttribute) 5288 aca.Exist = e 5289 aca.IsComment = c 5290 aca.Str = s 5291 return aca 5292 } 5293 5294 func (node *AccountCommentOrAttribute) Format(ctx *FmtCtx) { 5295 if node.Exist { 5296 if node.IsComment { 5297 ctx.WriteString(" comment ") 5298 } else { 5299 ctx.WriteString(" attribute ") 5300 } 5301 ctx.WriteString(fmt.Sprintf("'%s'", node.Str)) 5302 } 5303 } 5304 5305 func (node AccountCommentOrAttribute) TypeName() string { return "tree.AccountCommentOrAttribute" } 5306 5307 func (node *AccountCommentOrAttribute) reset() { 5308 *node = AccountCommentOrAttribute{} 5309 } 5310 5311 func (node *AccountCommentOrAttribute) Free() { 5312 // reuse.Free[AccountCommentOrAttribute](node, nil) 5313 } 5314 5315 type CreatePublication struct { 5316 statementImpl 5317 IfNotExists bool 5318 Name Identifier 5319 Database Identifier 5320 Table Identifier 5321 AccountsSet *AccountsSetOption 5322 Comment string 5323 } 5324 5325 func NewCreatePublication(ife bool, n Identifier, db Identifier, table Identifier, as *AccountsSetOption, c string) *CreatePublication { 5326 cp := reuse.Alloc[CreatePublication](nil) 5327 cp.IfNotExists = ife 5328 cp.Name = n 5329 cp.Database = db 5330 cp.Table = table 5331 cp.AccountsSet = as 5332 cp.Comment = c 5333 return cp 5334 } 5335 5336 func (node *CreatePublication) Format(ctx *FmtCtx) { 5337 ctx.WriteString("create publication ") 5338 if node.IfNotExists { 5339 ctx.WriteString(" if not exists") 5340 } 5341 node.Name.Format(ctx) 5342 if node.Database != "" { 5343 ctx.WriteString(" database ") 5344 node.Database.Format(ctx) 5345 } else { 5346 ctx.WriteString(" table ") 5347 node.Table.Format(ctx) 5348 } 5349 if node.AccountsSet != nil && len(node.AccountsSet.SetAccounts) > 0 { 5350 ctx.WriteString(" account ") 5351 prefix := "" 5352 for _, a := range node.AccountsSet.SetAccounts { 5353 ctx.WriteString(prefix) 5354 a.Format(ctx) 5355 prefix = ", " 5356 } 5357 } 5358 if len(node.Comment) > 0 { 5359 ctx.WriteString(" comment ") 5360 ctx.WriteString(fmt.Sprintf("'%s'", node.Comment)) 5361 } 5362 } 5363 5364 func (node *CreatePublication) GetStatementType() string { return "Create Publication" } 5365 func (node *CreatePublication) GetQueryType() string { return QueryTypeDCL } 5366 5367 func (node CreatePublication) TypeName() string { return "tree.CreatePublication" } 5368 5369 func (node *CreatePublication) reset() { 5370 if node.AccountsSet != nil { 5371 node.AccountsSet.Free() 5372 } 5373 *node = CreatePublication{} 5374 } 5375 5376 func (node *CreatePublication) Free() { 5377 reuse.Free[CreatePublication](node, nil) 5378 } 5379 5380 type AttributeVisable struct { 5381 columnAttributeImpl 5382 Is bool // true NULL (default); false NOT NULL 5383 } 5384 5385 func (node *AttributeVisable) Format(ctx *FmtCtx) { 5386 if node.Is { 5387 ctx.WriteString("visible") 5388 } else { 5389 ctx.WriteString("not visible") 5390 } 5391 } 5392 5393 func (node AttributeVisable) TypeName() string { return "tree.AttributeVisable" } 5394 5395 func (node *AttributeVisable) reset() { 5396 *node = AttributeVisable{} 5397 } 5398 5399 func (node *AttributeVisable) Free() { 5400 reuse.Free[AttributeVisable](node, nil) 5401 } 5402 5403 func NewAttributeVisable(b bool) *AttributeVisable { 5404 av := reuse.Alloc[AttributeVisable](nil) 5405 av.Is = b 5406 return av 5407 }