{"record":{"id":"9422ed5f3a21ca12","repo":"t8y2/dbx","slug":"ambiguous-vastbase-relation-name-s-s-under-case","errorCode":null,"errorMessage":"ambiguous Vastbase relation name %s.%s under case-insensitive matching","messagePattern":"ambiguous Vastbase relation name (.+?)\\.(.+?) under case-insensitive matching","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/vastbase-go/vastbase_metadata.go","lineNumber":1676,"sourceCode":"\tmatches := []relationName{}\n\tfor rows.Next() {\n\t\tvar match relationName\n\t\tif err := rows.Scan(&match.schema, &match.table); err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\t\tmatches = append(matches, match)\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\tif len(matches) == 0 {\n\t\treturn \"\", \"\", fmt.Errorf(\"Vastbase relation not found: %s.%s\", schema, table)\n\t}\n\tif matches[0].schema == schema && matches[0].table == table {\n\t\treturn schema, table, nil\n\t}\n\tif len(matches) > 1 {\n\t\treturn \"\", \"\", fmt.Errorf(\"ambiguous Vastbase relation name %s.%s under case-insensitive matching\", schema, table)\n\t}\n\treturn matches[0].schema, matches[0].table, nil\n}\n\nfunc (s *server) relationAttributesByNumber(catalog, prefix, schema, table string) (map[int]string, error) {\n\tquery := fmt.Sprintf(`SELECT a.attnum, a.attname\nFROM %s.%s_attribute a JOIN %s.%s_class c ON c.oid = a.attrelid\nJOIN %s.%s_namespace n ON n.oid = c.relnamespace\nWHERE n.nspname = %s AND c.relname = %s AND a.attnum > 0 AND NOT a.attisdropped`, catalog, prefix, catalog, prefix, catalog, prefix, quoteLiteral(schema), quoteLiteral(table))\n\trows, err := s.metadataQuery(query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\tresult := map[int]string{}\n\tfor rows.Next() {\n\t\tvar number int\n\t\tvar name string","sourceCodeStart":1658,"sourceCodeEnd":1694,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/vastbase-go/vastbase_metadata.go#L1658-L1694","documentation":"After case-insensitive matching, if more than one relation matches the given schema.table and none matches exactly, the driver refuses to guess and returns this ambiguity error. This happens when e.g. both \"users\" and \"Users\" exist as distinct quoted identifiers in the same schema.","triggerScenarios":"Passing a name whose case differs from any existing relation while at least two case-insensitive matches exist — e.g. schema contains both `orders` and `Orders` and the caller asks for 'ORDERS'.","commonSituations":"Schemas where quoted mixed-case and lowercase tables with the same spelling coexist (common after migrations from case-sensitive systems); automated tooling creating duplicate-cased names.","solutions":["Pass the exact case of the intended relation so the exact-match branch resolves it unambiguously.","Rename one of the duplicate-cased relations (e.g. ALTER TABLE \"Orders\" RENAME TO orders_legacy).","Query the catalog to list the case-insensitive matches and pick the intended one explicitly.","Avoid creating tables differing only by identifier case."],"exampleFix":"// before\n// schema has both `users` and \"Users\"\ncols, err := srv.ListColumns(\"public\", \"USERS\")\n// ambiguous Vastbase relation name public.USERS under case-insensitive matching\n\n// after\ncols, err := srv.ListColumns(\"public\", \"Users\") // exact match resolves","handlingStrategy":"validation","validationCode":"var matches int\nerr := db.QueryRow(`SELECT COUNT(*) FROM pg_class c JOIN pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname=$1 AND lower(c.relname)=lower($2)`, schema, table).Scan(&matches)\nif matches > 1 {\n    return fmt.Errorf(\"%d case-insensitive matches for %s.%s — pass exact case\", matches, schema, table)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"ambiguous Vastbase relation\") {\n    // resolve manually: query pg_class for all case variants and pick exact one\n    return resolveManually(schema, table)\n}","preventionTips":["Never create relations differing only by identifier case.","Pass exact-case identifiers to the driver.","Audit schemas for duplicate cased names after migrations."],"tags":["vastbase","metadata","ambiguity","case-sensitivity"],"backgroundTag":"ambiguous-relation-name","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}