{"record":{"id":"a33e3e882416f23d","repo":"NationalSecurityAgency/ghidra","slug":"column-is-not-indexed","errorCode":null,"errorMessage":"Column {} is not indexed","messagePattern":"Column (.+?) is not indexed","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBCachedObjectStore.java","lineNumber":998,"sourceCode":"\t\tint index = ArrayUtils.indexOf(schema.getFieldNames(), name);\n\t\tif (index < 0) {\n\t\t\tthrow new NoSuchElementException(name);\n\t\t}\n\t\treturn index;\n\t}\n\n\t/**\n\t * Get the table index for the given column number\n\t * \n\t * @param <K> the type of the object field for the indexed column\n\t * @param fieldClass the class specifying {@link K}\n\t * @param columnIndex the column number\n\t * @return the index\n\t * @throws IllegalArgumentException if the column has a different type than {@link K}\n\t */\n\tprotected <K> DBCachedObjectIndex<K, T> getIndex(Class<K> fieldClass, int columnIndex) {\n\t\tif (!ArrayUtils.contains(table.getIndexedColumns(), columnIndex)) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"Column \" + schema.getFieldNames()[columnIndex] + \" is not indexed\");\n\t\t}\n\n\t\tDBFieldCodec<?, T, ?> codec = codecs.get(columnIndex);\n\t\tClass<?> exp = codec.getValueType();\n\t\tif (fieldClass != exp) {\n\t\t\tthrow new IllegalArgumentException(\"Column \" + schema.getFieldNames()[columnIndex] +\n\t\t\t\t\" is not of type \" + fieldClass + \"! It is \" + exp);\n\t\t}\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tDBFieldCodec<K, T, ?> castCodec = (DBFieldCodec<K, T, ?>) codec;\n\t\treturn new DBCachedObjectIndex<>(this, adapter, castCodec, columnIndex, FieldSpan.ALL,\n\t\t\tDirection.FORWARD);\n\t}\n\n\t/**\n\t * Get the index for a given column\n\t * ","sourceCodeStart":980,"sourceCodeEnd":1016,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBCachedObjectStore.java#L980-L1016","documentation":"Thrown (unchecked IllegalArgumentException) by DBCachedObjectStore.getIndex(fieldClass, columnIndex) when the column at columnIndex is not among the table's indexed columns (table.getIndexedColumns()). An index must be declared when the store/table is created; requesting one on a non-indexed column is rejected because no backing DB index exists.","triggerScenarios":"Calling getIndex on a column that was not registered as indexed in the store factory/schema. The table only knows indexed columns it was built with; a plain (non-indexed) field cannot be queried via an index.","commonSituations":"Forgetting to mark a field @DBAnnotatedObject indexed (or the factory's indexed-columns set) when you later need to look it up by value; schema change adding a lookup but not an index; assuming all columns are indexed.","solutions":["Declare the column as indexed in the store factory / annotated schema so the table builds a backing index for it.","If you only need a scan, use a non-indexed find (scan) instead of getIndex-based lookup.","Confirm columnIndex maps to the intended column via schema.getFieldNames()[columnIndex]."],"exampleFix":"// before\nDBCachedObjectIndex<String,T> idx = store.getIndex(String.class, store.getColumnByName(\"name\"));\n// throws \"Column name is not indexed\"\n\n// after: declare the column indexed when creating the store\nstoreFactory.createIndexedStore(\"myTable\", schema, Set.of(\"name\")); // name now indexed","handlingStrategy":"validation","validationCode":"// Check the column is indexed before requesting its index\nif (!ArrayUtils.contains(table.getIndexedColumns(), columnIndex)) {\n    // not indexed: declare it indexed in the store factory, or use a scan\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare columns as indexed in the store factory when you need value lookups.","Use scan-based find for non-indexed columns.","Confirm columnIndex maps to the intended column."],"tags":["database","index","schema","illegal-argument","unchecked-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}