This file contains the two major components to name resolution: - classification algorithms. These are used when two different semantic constructs can appear in the same position in the SQL grammar. For example, table patterns and table names in GRANT. - resolution algorithms. These are used to ma
(n *UnresolvedName)
| 34 | // part is a table name) and an AllTablesSelector. |
| 35 | // Used e.g. for GRANT. |
| 36 | func classifyTablePattern(n *UnresolvedName) (TablePattern, error) { |
| 37 | if n.NumParts < 1 || n.NumParts > 3 { |
| 38 | return nil, newInvTableNameError(n) |
| 39 | } |
| 40 | // Check that all the parts specified are not empty. |
| 41 | firstCheck := 0 |
| 42 | if n.Star { |
| 43 | firstCheck = 1 |
| 44 | } |
| 45 | // It's OK if the catalog name is empty. |
| 46 | // We allow this in e.g. `select * from "".crdb_internal.tables`. |
| 47 | lastCheck := n.NumParts |
| 48 | if lastCheck > 2 { |
| 49 | lastCheck = 2 |
| 50 | } |
| 51 | for i := firstCheck; i < lastCheck; i++ { |
| 52 | if len(n.Parts[i]) == 0 { |
| 53 | return nil, newInvTableNameError(n) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // Construct the result. |
| 58 | if n.Star { |
| 59 | return &AllTablesSelector{makeTableNamePrefixFromUnresolvedName(n)}, nil |
| 60 | } |
| 61 | tb := makeTableNameFromUnresolvedName(n) |
| 62 | return &tb, nil |
| 63 | } |
| 64 | |
| 65 | // classifyColumnItem distinguishes between a ColumnItem (last name |
| 66 | // part is a column name) and an AllColumnsSelector. |
no test coverage detected
searching dependent graphs…