findTableMatches returns every (schema, table) pair whose table name equals the requested name. The caller decides how to handle 0, 1, or multiple matches.
(metadata *databaseMetadata, table string)
| 459 | // findTableMatches returns every (schema, table) pair whose table name equals |
| 460 | // the requested name. The caller decides how to handle 0, 1, or multiple matches. |
| 461 | func findTableMatches(metadata *databaseMetadata, table string) []tableMatch { |
| 462 | var matches []tableMatch |
| 463 | for i := range metadata.Schemas { |
| 464 | schema := &metadata.Schemas[i] |
| 465 | for j := range schema.Tables { |
| 466 | t := &schema.Tables[j] |
| 467 | if t.Name == table { |
| 468 | matches = append(matches, tableMatch{schema: schema.Name, table: t}) |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | return matches |
| 473 | } |
| 474 | |
| 475 | // lookupTableCandidates issues a second GetDatabaseMetadata call (no table filter) |
| 476 | // to build a list of candidate table names for a TABLE_NOT_FOUND error. |