nodeCreateView handles *tree.CreateView nodes.
(ctx *Context, node *tree.CreateView)
| 25 | |
| 26 | // nodeCreateView handles *tree.CreateView nodes. |
| 27 | func nodeCreateView(ctx *Context, node *tree.CreateView) (*vitess.DDL, error) { |
| 28 | if node == nil { |
| 29 | return nil, nil |
| 30 | } |
| 31 | if node.Persistence.IsTemporary() { |
| 32 | return nil, errors.Errorf("CREATE TEMPORARY VIEW is not yet supported") |
| 33 | } |
| 34 | if node.IsRecursive { |
| 35 | return nil, errors.Errorf("CREATE RECURSIVE VIEW is not yet supported") |
| 36 | } |
| 37 | var checkOption = tree.ViewCheckOptionUnspecified |
| 38 | var sqlSecurity string |
| 39 | if node.Options != nil { |
| 40 | for _, opt := range node.Options { |
| 41 | switch strings.ToLower(opt.Name) { |
| 42 | case "check_option": |
| 43 | switch strings.ToLower(opt.CheckOpt) { |
| 44 | case "local": |
| 45 | checkOption = tree.ViewCheckOptionLocal |
| 46 | case "cascaded": |
| 47 | checkOption = tree.ViewCheckOptionCascaded |
| 48 | default: |
| 49 | return nil, errors.Errorf(`"ERROR: syntax error at or near "%s"`, opt.Name) |
| 50 | } |
| 51 | case "security_barrier": |
| 52 | if opt.Security { |
| 53 | return nil, errors.Errorf("CREATE VIEW '%s' = true option is not yet supported", opt.Name) |
| 54 | } |
| 55 | case "security_invoker": |
| 56 | if opt.Security { |
| 57 | sqlSecurity = "invoker" |
| 58 | } else { |
| 59 | sqlSecurity = "definer" |
| 60 | } |
| 61 | default: |
| 62 | return nil, errors.Errorf(`"ERROR: syntax error at or near "%s"`, opt.Name) |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | if checkOption != tree.ViewCheckOptionUnspecified && node.CheckOption != tree.ViewCheckOptionUnspecified { |
| 68 | return nil, errors.Errorf(`ERROR: parameter "check_option" specified more than once`) |
| 69 | } else { |
| 70 | checkOption = node.CheckOption |
| 71 | } |
| 72 | |
| 73 | vCheckOpt := vitess.ViewCheckOptionUnspecified |
| 74 | switch checkOption { |
| 75 | case tree.ViewCheckOptionCascaded: |
| 76 | vCheckOpt = vitess.ViewCheckOptionCascaded |
| 77 | case tree.ViewCheckOptionLocal: |
| 78 | vCheckOpt = vitess.ViewCheckOptionLocal |
| 79 | default: |
| 80 | } |
| 81 | |
| 82 | tableName, err := nodeTableName(ctx, &node.Name) |
| 83 | if err != nil { |
| 84 | return nil, err |
no test coverage detected