{"record":{"id":"2556d96a4e581a29","repo":"t8y2/dbx","slug":"table-not-found-s-s-2556d9","errorCode":null,"errorMessage":"table not found: %s.%s","messagePattern":"table not found: (.+?)\\.(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/xugu/main.go","lineNumber":3745,"sourceCode":"\t\t}\n\t}\n\t// DBMS_METADATA.GET_DDL can block indefinitely on XuguDB, even when the\n\t// table metadata itself is accessible. Reconstruct the DDL from the same\n\t// ALL_* catalog views used by the object browser instead.\n\tddl, err := s.buildTableDDL(catalogSchema, catalogTable)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn s.appendTableIndexDDL(catalogSchema, catalogTable, ddl), nil\n}\n\nfunc (s *server) buildFallbackTableDDL(schema, table string) (string, error) {\n\tcolumns, err := s.columnsFromSelect(schema, table, map[string]bool{})\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif len(columns) == 0 {\n\t\treturn \"\", fmt.Errorf(\"table not found: %s.%s\", schema, table)\n\t}\n\treturn renderXuguTableDDL(schema, table, columns, xuguTableMetadata{}, nil, nil, nil, nil), nil\n}\n\nfunc xuguUnavailableTableDDL(schema, table string) string {\n\treturn fmt.Sprintf(\"-- XuguDB did not expose enough metadata to reconstruct %s.%s.\\n-- The table may still be readable, but its DDL requires additional metadata privileges.\", schema, table)\n}\n\ntype xuguCatalogTableName struct {\n\tSchema string\n\tTable  string\n}\n\n// resolveCatalogTableName returns SCHEMA_NAME/TABLE_NAME exactly as stored in\n// ALL_SCHEMAS/ALL_TABLES. The lookup accepts a case-insensitive input only\n// when it has a single catalog candidate; otherwise it requires the exact\n// stored spelling rather than silently exporting a different quoted object.\nfunc (s *server) resolveCatalogTableName(schema, table string) (string, string, error) {","sourceCodeStart":3727,"sourceCodeEnd":3763,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/xugu/main.go#L3727-L3763","documentation":"buildFallbackTableDDL reconstructs a table's DDL from a SELECT over it (columnsFromSelect). If the query yields zero columns, the driver concludes the table does not exist (or is unreadable) and throws this error instead of rendering an empty DDL.","triggerScenarios":"Calling the fallback DDL path for schema.table where a SELECT * FROM schema.table returns no columns — the table does not exist, the caller lacks SELECT privilege, or the schema name is wrong.","commonSituations":"Table dropped between listing and DDL extraction; insufficient privileges so the SELECT silently yields no metadata; typo in schema or table name; connecting to a database where the table never existed.","solutions":["Confirm the table exists: SELECT COUNT(*) FROM ALL_TABLES WHERE UPPER(TABLE_NAME)=UPPER('?') AND UPPER(SCHEMA_NAME)=UPPER('?');","Check SELECT privileges on the table for the connecting user.","Verify the schema/table spelling and case.","If the table exists but metadata is restricted, prefer the non-fallback buildTableDDL path or grant metadata privileges."],"exampleFix":"-- before (fallback path, no SELECT privilege)\nSELECT * FROM app.orders; -- 0 columns returned -> error\n\n-- after\nGRANT SELECT ON app.orders TO app_reader;","handlingStrategy":"validation","validationCode":"var n int\nerr := db.QueryRow(`SELECT COUNT(*) FROM ALL_TABLES t JOIN ALL_SCHEMAS s ON s.SCHEMA_ID=t.SCHEMA_ID WHERE UPPER(s.SCHEMA_NAME)=UPPER(?) AND UPPER(t.TABLE_NAME)=UPPER(?)`, schema, table).Scan(&n)\nif err != nil || n == 0 { return fmt.Errorf(\"table %s.%s not visible; check existence and SELECT privilege\", schema, table) }","typeGuard":null,"tryCatchPattern":"if strings.HasPrefix(err.Error(), \"table not found:\") {\n    ddl = \"-- table unavailable; skipped\"\n}","preventionTips":["Grant SELECT and metadata-catalog privileges to the extraction user.","Verify object existence right before extraction (avoid TOCTOU during migrations).","Spell-check schema/table parameters; prefer constants over ad-hoc strings."],"tags":["database","table","not-found","ddl"],"backgroundTag":"object-not-found","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"}