PutCreateTableStatement returns a CreateTableStatement to the pool. It recursively releases any nested expressions (column defaults, check constraints, etc.).
(stmt *CreateTableStatement)
| 1385 | // PutCreateTableStatement returns a CreateTableStatement to the pool. |
| 1386 | // It recursively releases any nested expressions (column defaults, check constraints, etc.). |
| 1387 | func PutCreateTableStatement(stmt *CreateTableStatement) { |
| 1388 | if stmt == nil { |
| 1389 | return |
| 1390 | } |
| 1391 | |
| 1392 | // Release expressions embedded in column definitions |
| 1393 | for i := range stmt.Columns { |
| 1394 | for j := range stmt.Columns[i].Constraints { |
| 1395 | PutExpression(stmt.Columns[i].Constraints[j].Default) |
| 1396 | PutExpression(stmt.Columns[i].Constraints[j].Check) |
| 1397 | stmt.Columns[i].Constraints[j].Default = nil |
| 1398 | stmt.Columns[i].Constraints[j].Check = nil |
| 1399 | stmt.Columns[i].Constraints[j].References = nil |
| 1400 | } |
| 1401 | stmt.Columns[i].Constraints = stmt.Columns[i].Constraints[:0] |
| 1402 | stmt.Columns[i].Name = "" |
| 1403 | stmt.Columns[i].Type = "" |
| 1404 | } |
| 1405 | stmt.Columns = stmt.Columns[:0] |
| 1406 | |
| 1407 | // Release expressions in table constraints |
| 1408 | for i := range stmt.Constraints { |
| 1409 | PutExpression(stmt.Constraints[i].Check) |
| 1410 | stmt.Constraints[i].Check = nil |
| 1411 | stmt.Constraints[i].References = nil |
| 1412 | stmt.Constraints[i].Name = "" |
| 1413 | stmt.Constraints[i].Type = "" |
| 1414 | stmt.Constraints[i].Columns = stmt.Constraints[i].Columns[:0] |
| 1415 | } |
| 1416 | stmt.Constraints = stmt.Constraints[:0] |
| 1417 | |
| 1418 | // Release expressions in PartitionBy |
| 1419 | if stmt.PartitionBy != nil { |
| 1420 | for i, expr := range stmt.PartitionBy.Boundary { |
| 1421 | PutExpression(expr) |
| 1422 | stmt.PartitionBy.Boundary[i] = nil |
| 1423 | } |
| 1424 | stmt.PartitionBy.Boundary = stmt.PartitionBy.Boundary[:0] |
| 1425 | stmt.PartitionBy.Columns = stmt.PartitionBy.Columns[:0] |
| 1426 | stmt.PartitionBy.Type = "" |
| 1427 | stmt.PartitionBy = nil |
| 1428 | } |
| 1429 | |
| 1430 | // Release expressions in PartitionDefinitions |
| 1431 | for i := range stmt.Partitions { |
| 1432 | for j, expr := range stmt.Partitions[i].Values { |
| 1433 | PutExpression(expr) |
| 1434 | stmt.Partitions[i].Values[j] = nil |
| 1435 | } |
| 1436 | PutExpression(stmt.Partitions[i].LessThan) |
| 1437 | PutExpression(stmt.Partitions[i].From) |
| 1438 | PutExpression(stmt.Partitions[i].To) |
| 1439 | for j, expr := range stmt.Partitions[i].InValues { |
| 1440 | PutExpression(expr) |
| 1441 | stmt.Partitions[i].InValues[j] = nil |
| 1442 | } |
| 1443 | stmt.Partitions[i].Values = stmt.Partitions[i].Values[:0] |
| 1444 | stmt.Partitions[i].InValues = stmt.Partitions[i].InValues[:0] |