MCPcopy Create free account
hub / github.com/dolthub/doltgresql / nodeAlterTablePartition

Function nodeAlterTablePartition

server/ast/alter_table.go:403–444  ·  view source on GitHub ↗

nodeAlterTableSetNotNull converts a tree.AlterTablePartition instance into an equivalent vitess.DDL instance.

(ctx *Context, node *tree.AlterTablePartition)

Source from the content-addressed store, hash-verified

401
402// nodeAlterTableSetNotNull converts a tree.AlterTablePartition instance into an equivalent vitess.DDL instance.
403func nodeAlterTablePartition(ctx *Context, node *tree.AlterTablePartition) (*vitess.AlterTable, error) {
404 if node == nil {
405 return nil, nil
406 }
407
408 // TODO: This is an incomplete translation because our GMS implementation doesn't support the MySQL
409 // equivalent of these statements either. Regardless, these are all no-ops.
410 treeTableName := node.Name.ToTableName()
411 tableName, err := nodeTableName(ctx, &treeTableName)
412 if err != nil {
413 return nil, err
414 }
415
416 switch node.Spec.Type {
417 case tree.PartitionBoundIn:
418 case tree.PartitionBoundFromTo:
419 case tree.PartitionBoundWith:
420 default:
421 return nil, errors.Errorf("ALTER TABLE with unsupported partition type %v", node.Spec.Type)
422 }
423
424 partitionDef := &vitess.PartitionDefinition{
425 Name: vitess.NewColIdent(node.Partition.String()),
426 }
427
428 actionStr := ""
429 if node.IsDetach {
430 actionStr = vitess.DropStr
431 } else {
432 actionStr = vitess.AddStr
433 }
434
435 partitionSpec := &vitess.PartitionSpec{
436 Action: actionStr,
437 Definitions: []*vitess.PartitionDefinition{partitionDef},
438 }
439
440 return &vitess.AlterTable{
441 Table: tableName,
442 PartitionSpecs: []*vitess.PartitionSpec{partitionSpec},
443 }, nil
444}
445
446// nodeAlterTableComputed converts a tree.AlterTableComputed instance into an equivalent CREATE/ALTER SEQUENCE statement.
447func nodeAlterTableComputed(ctx *Context, tableName tree.TableName, node *tree.AlterTableComputed) (vitess.Statement, error) {

Callers 1

ConvertFunction · 0.85

Calls 4

nodeTableNameFunction · 0.85
ToTableNameMethod · 0.80
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected