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 205677 - Valid script fails on NetBeans (SQL Editor)
Summary: Valid script fails on NetBeans (SQL Editor)
Status: RESOLVED INVALID
Alias: None
Product: db
Classification: Unclassified
Component: MySQL (show other bugs)
Version: 7.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Jiri Rechtacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-29 20:55 UTC by javydreamercsw
Modified: 2011-12-02 07:33 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
DB script (53.62 KB, application/octet-stream)
2011-11-29 20:55 UTC, javydreamercsw
Details
MySQL Workbench file (62.95 KB, application/octet-stream)
2011-11-29 20:56 UTC, javydreamercsw
Details
output of SQL execution (16.76 KB, text/plain)
2011-12-01 10:29 UTC, Jiri Rechtacek
Details
NB7.1 RC1 - messages.log (49.04 KB, text/plain)
2011-12-01 10:30 UTC, Jiri Rechtacek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description javydreamercsw 2011-11-29 20:55:56 UTC
Created attachment 113644 [details]
DB script

The attached script runs successfully from the command prompt and MySQL workbench (generated from MySQL Workbench) but fails from NetBeans.
Comment 1 javydreamercsw 2011-11-29 20:56:19 UTC
Created attachment 113645 [details]
MySQL Workbench file

Just in case.
Comment 2 matthias42 2011-11-29 21:29:28 UTC
Please provide more information, what exactly fails. I tested with netbeans 7.0.1 and nightly build 201111220600. Both work fine with your script. I ran this test against mysql 5.1.58.

Closing for now.
Comment 3 javydreamercsw 2011-11-29 22:07:41 UTC
As noted above it fails against 7.1.

I'm on MySQL 5.5.14.

Here are my failures:
Error code 1005, SQL state HY000: Can't create table 'xinco.xinco_core_node' (errno: 121)
Line 245, column 1

Error code 1005, SQL state HY000: Can't create table 'xinco.xinco_core_data' (errno: 121)
Line 289, column 1

Error code 1005, SQL state HY000: Can't create table 'xinco.xinco_core_ace' (errno: 121)
Line 365, column 1

Error code 1005, SQL state HY000: Can't create table 'xinco.xinco_core_user_has_xinco_core_group' (errno: 121)
Line 409, column 1

Error code 1005, SQL state HY000: Can't create table 'xinco.xinco_core_data_type_attribute' (errno: 121)
Line 461, column 1

Error code 1005, SQL state HY000: Can't create table 'xinco.xinco_core_log' (errno: 121)
Line 483, column 1

And various errors because some tables were not created above.

I'll try updating MySQL.
Comment 4 Jiri Rechtacek 2011-12-01 10:28:47 UTC
It works for me on custom build
  Product Version         = NetBeans IDE Dev (Build 20111109-cc4badb5130d) (#cc4badb5130d)
  Operating System        = Linux version 3.0.0-13-generic running on amd64
  Java; VM; Vendor        = 1.6.0_20; Java HotSpot(TM) 64-Bit Server VM 16.3-b01; Sun Microsystems Inc.
  Runtime                 = Java(TM) SE Runtime Environment 1.6.0_20-b02
  Java Home               = /usr/local/share/java/jdk1.6.0_20/jre

as well on NetBeans 7.1 RC1, see attached messages.log and output from SQL execution.
I'm running mysql-server from Ubuntu 11.10 distribution, version 5.1.58-1ubuntu1, with JDBC driver mysql-connector-java-5.1.13-bin.jar, bundled with NB7.1.
So, it's db server specific problem, no way to solve it on NB side I guess.
Comment 5 Jiri Rechtacek 2011-12-01 10:29:41 UTC
Created attachment 113688 [details]
output of SQL execution
Comment 6 Jiri Rechtacek 2011-12-01 10:30:38 UTC
Created attachment 113689 [details]
NB7.1 RC1 - messages.log
Comment 7 Sergey Petrov 2011-12-01 10:32:57 UTC
it may be windows specific as I have the same and on win7 as reporter
Comment 8 Jiri Rechtacek 2011-12-01 10:38:57 UTC
(In reply to comment #7)
> it may be windows specific as I have the same and on win7 as reporter

It's important point, you can reproduce it on windows too? If so, please reopen it. Thanks
Comment 9 Sergey Petrov 2011-12-01 10:53:33 UTC
just tried with custom (yesterday build from web-main), with Execute Command on db connection from services tab and copy-paste attached sql and mysql 5.5.18/32bit and got:

.....
Error code 1005, SQL state HY000: Can't create table 'xinco.xinco_core_node' (errno: 121)
Line 245, column 1
.....
Error code 1005, SQL state HY000: Can't create table 'xinco.xinco_core_data' (errno: 121)
Line 289, column 1
///
some more 121, and later some errors regarding missed tables as tables creation fails for some.
///
Execution finished after 0,483 s, 75 error(s) occurred.
Comment 10 matthias42 2011-12-01 19:58:08 UTC
Ok - I reproduced the bug and also found out, why it worked in my tests.

== Step 1 == 

I reduced the problem to a small test-case (and did a fresh install of mysql on a windows 2003 server system):

CREATE SCHEMA IF NOT EXISTS `xinco` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `xinco` ;

DROP TABLE IF EXISTS `xinco`.`xinco_core_data` ;
CREATE  TABLE IF NOT EXISTS `xinco`.`xinco_core_data` (
  `id` INT UNSIGNED NOT NULL ,
  `xinco_core_node_id` INT UNSIGNED NOT NULL ,
  `xinco_core_language_id` INT UNSIGNED NOT NULL ,
  `xinco_core_data_type_id` INT UNSIGNED NOT NULL ,
  `designation` VARCHAR(255) NOT NULL ,
  `status_number` INT UNSIGNED NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `xinco_core_data_FKIndex1` (`xinco_core_node_id` ASC) ,
  INDEX `xinco_core_data_FKIndex2` (`xinco_core_language_id` ASC) ,
  INDEX `xinco_core_data_FKIndex5` (`xinco_core_data_type_id` ASC) ,
  INDEX `xinco_core_data_index_designation` (`designation` ASC) ,
  INDEX `xinco_core_data_index_status` (`status_number` ASC) ,
  CONSTRAINT `fk_{0FE42428-0C82-42FC-923F-7314A740D04F}`
    FOREIGN KEY (`xinco_core_node_id` )
    REFERENCES `xinco`.`xinco_core_data` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_{249C3090-F2CF-4C6B-A528-C9DDF697E702}`
    FOREIGN KEY (`xinco_core_language_id` )
    REFERENCES `xinco`.`xinco_core_data` (`id` )
    ON DELETE RESTRICT
    ON UPDATE CASCADE,
  CONSTRAINT `fk_{592A6D87-0049-4758-9D7F-D4F421983CDB}`
    FOREIGN KEY (`xinco_core_data_type_id` )
    REFERENCES `xinco`.`xinco_core_data` (`id` )
    ON DELETE RESTRICT
    ON UPDATE CASCADE) 
;

== Step 2 == 

I checked whether netbeans or somethink else is fishy.

I used a small java programm, that just issued the statements above directly via jdbc and got the same problem.

At this time the bug was resolved, as not a bug in netbeans.

== Step 3 == 

I ran wireshark and had a look at the command stream

And I saw this:

CREATE  TABLE IF NOT EXISTS `xinco`.`xinco_core_data` (
  `id` INT UNSIGNED NOT NULL ,
  `xinco_core_node_id` INT UNSIGNED NOT NULL ,
  `xinco_core_language_id` INT UNSIGNED NOT NULL ,
  `xinco_core_data_type_id` INT UNSIGNED NOT NULL ,
  `designation` VARCHAR(255) NOT NULL ,
  `status_number` INT UNSIGNED NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `xinco_core_data_FKIndex1` (`xinco_core_node_id` ASC) ,
  INDEX `xinco_core_data_FKIndex2` (`xinco_core_language_id` ASC) ,
  INDEX `xinco_core_data_FKIndex5` (`xinco_core_data_type_id` ASC) ,
  INDEX `xinco_core_data_index_designation` (`designation` ASC) ,
  INDEX `xinco_core_data_index_status` (`status_number` ASC) ,
  CONSTRAINT `fk_`
    FOREIGN KEY (`xinco_core_node_id` )
    REFERENCES `xinco`.`xinco_core_data` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_`
    FOREIGN KEY (`xinco_core_language_id` )
    REFERENCES `xinco`.`xinco_core_data` (`id` )
    ON DELETE RESTRICT
    ON UPDATE CASCADE,
  CONSTRAINT `fk_`
    FOREIGN KEY (`xinco_core_data_type_id` )
    REFERENCES `xinco`.`xinco_core_data` (`id` )
    ON DELETE RESTRICT
    ON UPDATE CASCADE)

I think you see the problem (hint: look at the constraint names)

Basicly: The JBDC driver stripped out the parts in curly braces.

This could be an artifact of the jdbc escape handling, but this is speculation!

== Step 4 == 

Repeat the test against my local mysql system - I saw the same thing on the wire but didn't get the failure and then it dawned on me. The default engine in my install is MyISAM and that does not enforce constraints and I doubt it even tries to create them, so the engine ignores the statements and just produces the table successfully.

So jayvdreamercsw I owe you an apology!

Long story short: The problem lies in the jdbc escape processing. It's debatable whether escapes should only be replaced, if a valid is encountered or not, but I think its a bug in the jdbc driver of mysql jdbc driver (I tested the newest available version: 5.1.18). 

PS: Yes I know, that escape processing can be deactived per Statement, but I consider the escape syntax a feature of jdbc and not a bug.
Comment 11 javydreamercsw 2011-12-01 22:32:59 UTC
I created a MySQL bug agains the JDBC driver: http://bugs.mysql.com/bug.php?id=63526

Shouldn't this be Won't fix instead since a workaround in NetBeans is possible deactivating escape processing per statement?
Comment 12 matthias42 2011-12-02 07:33:10 UTC
(In reply to comment #11)
> I created a MySQL bug agains the JDBC driver:
> http://bugs.mysql.com/bug.php?id=63526
> 
> Shouldn't this be Won't fix instead since a workaround in NetBeans is possible
> deactivating escape processing per statement?

Actually I don't think so - the workaround won't work. I use the escaping feature, so disabling escaping breaks my use-case.

The correct resolution would be "NOTOURBUG" (as seen on the freedesktop bugzilla), but as that is not existing, I won't change the resolution, but I also won't interfere if you do.