apache / apache/iotdb

[Bug] ResultSetMetaData.getCatalogName throws IndexOutOfBoundsException instead of SQLException for out-of-range columns

Aperta Adatta ai principianti
#18,241 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
6.4k
Fork
1.2k
Merge medio
1g 23h
PR unite (30g)
115

Descrizione

### Search before asking

- [x] I searched in the [issues](https://github.com/apache/iotdb/issues) and found nothing similar.

### Version

`master` (2.0.x). The affected code is also present in released 2.0.x versions.

### Describe the bug and provide the minimal reproduce step

`IoTDBResultMetadata.getCatalogName(int column)` reads `columnInfoList.get(column - 1)` before its range check runs, so an out-of-range column index throws a raw `IndexOutOfBoundsException` instead of the `SQLException` required by the `ResultSetMetaData` contract. The subsequent range check (`if (column < 1 || column > columnInfoList.size())`) is therefore unreachable for an out-of-range column. The seven sibling `ResultSetMetaData` accessors in the same class all call `checkColumnIndex(column)` first; `getCatalogName` is the only one missing that guard.

Minimal reproduce step:

1. Obtain a `ResultSetMetaData` from any (non-empty) query result.
2. Call `metaData.getCatalogName(0)` (or any column index `<= 0` or `> column count`).
3. A raw `IndexOutOfBoundsException` is thrown instead of a `SQLException`.

### What did you expect to see?

`getCatalogName` throws a `SQLException` for an out-of-range column index, consistent with the `ResultSetMetaData` contract and with the sibling accessors.

### What did you see instead?

A raw `java.lang.IndexOutOfBoundsException` from `columnInfoList.get(column - 1)`.

### Anything else?

The fix is to call `checkColumnIndex(column)` first, as the sibling accessors already do — it throws `SQLException` on `column <= 0`, `column > size`, and an empty column list. I'd like to work on this and will open a PR.

### Are you willing to submit a PR?

- [x] I'm willing to submit a PR!

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia nella classe che contiene IoTDBResultMetadata.getCatalogName(int) e confrontala con i sette accessor affini di ResultSetMetaData che chiamano prima checkColumnIndex(column). Riproduci il problema con getCatalogName(0) o con un'altra colonna fuori intervallo, quindi verifica che gli indici non validi producano sistematicamente SQLException anziché IndexOutOfBoundsException.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
databases
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
78/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.