defineView installs a view in the catalog. Unlike tables, the only structured input is the view's definition SQL, whose exact shape varies (full "CREATE VIEW ..." vs. a bare SELECT). We try the definition as-is, then wrapped in CREATE VIEW, and finally fall back to a trivial view so the view name st
(cat *catalog.Catalog, name, definition string)
| 283 | // name still surfaces as a candidate (matching mysql, which reads view names |
| 284 | // straight from metadata) even when the definition cannot be parsed. |
| 285 | func defineView(cat *catalog.Catalog, name, definition string) { |
| 286 | var attempts []string |
| 287 | if definition != "" { |
| 288 | attempts = append(attempts, |
| 289 | definition, |
| 290 | fmt.Sprintf("CREATE VIEW %s AS %s", backtickIdentifier(name), definition), |
| 291 | ) |
| 292 | } |
| 293 | attempts = append(attempts, fmt.Sprintf("CREATE VIEW %s AS SELECT 1", backtickIdentifier(name))) |
| 294 | for _, ddl := range attempts { |
| 295 | if execOK(cat, ddl) { |
| 296 | return |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | // execOK runs DDL against the catalog and reports whether it actually installed |
| 302 | // a schema object: every statement parsed without error AND at least one was a |
no test coverage detected