catalogNeeded reports whether the current completion statement needs this catalog's full schema/table/column metadata loaded: true for the session default catalog and for any catalog whose name appears in the statement text (a qualified reference such as catalog.schema.table). The reference check is
(normName, defaultDB, lowerStmt string)
| 145 | // case-insensitive substring, which errs toward loading an occasional extra |
| 146 | // catalog rather than missing a referenced one. |
| 147 | func catalogNeeded(normName, defaultDB, lowerStmt string) bool { |
| 148 | if normName == "" { |
| 149 | return false |
| 150 | } |
| 151 | if defaultDB != "" && normName == defaultDB { |
| 152 | return true |
| 153 | } |
| 154 | // A catalog name containing a double quote is rewritten inside a quoted |
| 155 | // reference (each " is escaped as ""), so its normalized form is not a literal |
| 156 | // substring of the statement and the check below would miss it. Such names are |
| 157 | // vanishingly rare; load them unconditionally rather than drop completion. A |
| 158 | // double quote is the only identifier character Trino re-spells when quoting — |
| 159 | // every other character appears verbatim, so the substring check is reliable. |
| 160 | if strings.Contains(normName, `"`) { |
| 161 | return true |
| 162 | } |
| 163 | return strings.Contains(lowerStmt, strings.ToLower(normName)) |
| 164 | } |
| 165 | |
| 166 | // columnsOf converts storepb columns into omni catalog columns (names |
| 167 | // normalized). |
no outgoing calls
no test coverage detected