This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250304 - IndexOutOfBoundsException: Index: 3, Size: 3
Summary: IndexOutOfBoundsException: Index: 3, Size: 3
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Show Data (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: matthias42
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-09 08:24 UTC by henry_oc
Modified: 2015-02-14 06:46 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter: 205921


Attachments
stacktrace (3.14 KB, text/plain)
2015-02-09 08:24 UTC, henry_oc
Details

Note You need to log in before you can comment on or make changes to this bug.
Description henry_oc 2015-02-09 08:24:43 UTC
Build: NetBeans IDE 8.0.2 (Build 201411181905)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.25-b02, Java(TM) SE Runtime Environment, 1.8.0_25-b18
OS: Windows 7

User Comments:
GUEST: Not sure

GUEST: <Please provide a description of the problem or the steps to reproduce>

GUEST: <Please provide a description of the problem or the steps to reproduce>

GUEST: I'm in the SQL editor window. I ran this query "select gro_date IS NOT NULL, groups.* from groups;". I went to one of the rows in the results window, did right click and -> Show SQL script for INSERT. Then I got this error.

GUEST: Selected two database rows. Right clicked and selected "Show SQL Script for Insert"

GUEST: no information available

GUEST: Error after clicked SHOW SQL SCRIPT FOR INSERT in sql results

henry_oc: I hope this is relevant and helps:
Ran a MySQL statement (with left joins, etc.), then selected a few continues rows (on the second/last page), right-clicked and selected the option to "Show SQL Script for INSERT". I then noticed the notification icon.

GUEST: select from a sql server database table
click on show sql for insert




Stacktrace: 
java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
   at java.util.ArrayList.RangeCheck(ArrayList.java:653)
   at java.util.ArrayList.get(ArrayList.java:429)
   at org.netbeans.modules.db.dataview.output.SQLStatementGenerator.generateRawInsertStatement(SQLStatementGenerator.java:137)
   at org.netbeans.modules.db.dataview.output.DataViewTableUI$11.actionPerformed(DataViewTableUI.java:439)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
   at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
Comment 1 henry_oc 2015-02-09 08:24:44 UTC
Created attachment 151894 [details]
stacktrace
Comment 2 matthias42 2015-02-09 18:52:39 UTC
This is reproducible - good catch!

Sample:

-------------------------------------------------------------------
create table t1 (id integer, title varchar(255), ref_id integer);
insert into t1 values (1, 'Demo1-1', 1);
insert into t1 values (2, 'Demo1-2', 2);
insert into t1 values (3, 'Demo1-3', 1);
insert into t1 values (4, 'Demo1-4', 2);
create table t2 (id integer, title varchar(255));
insert into t2 values (1, 'Demo 2-1');
insert into t2 values (2, 'Demo 2-2');
select * from t1 inner join t2 on (t1.ref_id = t2.id);
-------------------------------------------------------------------

Its enougth to select one row. and select "Show SQL Script for INSERT".

I had a look at the code and there is a mistake in the case selection for the menu. I would fix it by disabling the options ("Show SQL Script for INSERT" and "Show SQL Script for DELETE"). In this case the mentioning of the JOIN is the core problem - I doubt a database survives an update/insert through a JOIN.

If you see a reason to provide one of the Script menu elements, please add them here, else I'll fix the menu disable code in the next few days.
Comment 3 matthias42 2015-02-12 19:50:02 UTC
I committed a fix as:

http://hg.netbeans.org/core-main/rev/85cc25b3eaab

That change unifies the decision handling disabling/enabling each menuitem at one place and not multiple. This makes it easier to read and corrects the problem.

The problem in short: A join results in multiple tables reported for the result set, but then what is the definition of an update/insert into a join. That case is not covered and so the solution is not to enable the menuitems.

My tests were positive, but please verify that. In the next few days a nightly build will be done and a message will be appended to this bug. Please check that version whether you can trigger hits bug again.

If you find it fixed, please change the status of this bug to "VERIFIED". Thank you!
Comment 4 Quality Engineering 2015-02-14 06:46:37 UTC
Integrated into 'main-silver', will be available in build *201502140001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/85cc25b3eaab
User: Matthias Blaesing <matthias42@netbeans.org>
Log: #250304: Correct decision process to disable/enable table actions in dataview