You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kim Haase (JIRA)" <ji...@apache.org> on 2010/03/18 15:26:28 UTC

[jira] Created: (DERBY-4590) You can drop a file-system database from a directory named "memory"

You can drop a file-system database from a directory named "memory"
-------------------------------------------------------------------

                 Key: DERBY-4590
                 URL: https://issues.apache.org/jira/browse/DERBY-4590
             Project: Derby
          Issue Type: Bug
          Components: JDBC, Services, Store
    Affects Versions: 10.6.0.0
            Reporter: Kim Haase
            Priority: Minor


With both the embedded and network client drivers, it is possible to create a file-system database and drop it, if you put it in a directory named "memory". 

I found this out by accident when I accidentally typed "memory/mydb" instead of "memory:mydb" to create an in-memory database.

If you call the directory something other than "memory", you can't drop the db:

ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;create=true';
ij> create table t(c int);
0 rows inserted/updated/deleted
ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;drop=true';
ERROR XBM0I: DERBY SQL error: SQLCODE: -1, SQLSTATE: XBM0I, SQLERRMC: Directory subdir/mycdb cannot be removed.

But if you do exactly the same thing specifying "memory", the drop succeeds:

ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;create=true';
ij> create table t(c int);
0 rows inserted/updated/deleted
ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;drop=true';
ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'memory/mycdb' dropped.

When you do this, the "memory" directory continues to exist, but the database directory under it is removed.

Here are similar examples using the embedded driver:

ij>  connect 'jdbc:derby:subdir/mydb;create=true';
ij> create table t(c int);
0 rows inserted/updated/deleted
ij> connect 'jdbc:derby:subdir/mydb;drop=true';
ERROR XBM0I: Directory subdir/mydb cannot be removed.

ij> connect 'jdbc:derby:memory/mydb;create=true';
ij> create table t(c int);
0 rows inserted/updated/deleted
ij> connect 'jdbc:derby:memory/mydb;drop=true';
ERROR 08006: Database 'memory/mydb' dropped.

Some part of Derby seems to think you actually created an in-memory database, although you did not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4590) You can drop a file-system database from a directory named "memory"

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12846931#action_12846931 ] 

Kristian Waagan commented on DERBY-4590:
----------------------------------------

In some cases Derby uses protocol prefixes to determine the protocol. At the same time, the default protocol (which is formally 'directory:') is represented with no protocol prefix. In this case Derby is probably just checking if the string starts with "memory".
I'll have a look.

> You can drop a file-system database from a directory named "memory"
> -------------------------------------------------------------------
>
>                 Key: DERBY-4590
>                 URL: https://issues.apache.org/jira/browse/DERBY-4590
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, Services, Store
>    Affects Versions: 10.6.0.0
>            Reporter: Kim Haase
>            Priority: Minor
>
> With both the embedded and network client drivers, it is possible to create a file-system database and drop it, if you put it in a directory named "memory". 
> I found this out by accident when I accidentally typed "memory/mydb" instead of "memory:mydb" to create an in-memory database.
> If you call the directory something other than "memory", you can't drop the db:
> ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;drop=true';
> ERROR XBM0I: DERBY SQL error: SQLCODE: -1, SQLSTATE: XBM0I, SQLERRMC: Directory subdir/mycdb cannot be removed.
> But if you do exactly the same thing specifying "memory", the drop succeeds:
> ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;drop=true';
> ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'memory/mycdb' dropped.
> When you do this, the "memory" directory continues to exist, but the database directory under it is removed.
> Here are similar examples using the embedded driver:
> ij>  connect 'jdbc:derby:subdir/mydb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby:subdir/mydb;drop=true';
> ERROR XBM0I: Directory subdir/mydb cannot be removed.
> ij> connect 'jdbc:derby:memory/mydb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby:memory/mydb;drop=true';
> ERROR 08006: Database 'memory/mydb' dropped.
> Some part of Derby seems to think you actually created an in-memory database, although you did not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (DERBY-4590) You can drop a file-system database from a directory named "memory"

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4590?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan reassigned DERBY-4590:
--------------------------------------

    Assignee: Kristian Waagan

> You can drop a file-system database from a directory named "memory"
> -------------------------------------------------------------------
>
>                 Key: DERBY-4590
>                 URL: https://issues.apache.org/jira/browse/DERBY-4590
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, Services, Store
>    Affects Versions: 10.6.0.0
>            Reporter: Kim Haase
>            Assignee: Kristian Waagan
>            Priority: Minor
>
> With both the embedded and network client drivers, it is possible to create a file-system database and drop it, if you put it in a directory named "memory". 
> I found this out by accident when I accidentally typed "memory/mydb" instead of "memory:mydb" to create an in-memory database.
> If you call the directory something other than "memory", you can't drop the db:
> ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;drop=true';
> ERROR XBM0I: DERBY SQL error: SQLCODE: -1, SQLSTATE: XBM0I, SQLERRMC: Directory subdir/mycdb cannot be removed.
> But if you do exactly the same thing specifying "memory", the drop succeeds:
> ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;drop=true';
> ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'memory/mycdb' dropped.
> When you do this, the "memory" directory continues to exist, but the database directory under it is removed.
> Here are similar examples using the embedded driver:
> ij>  connect 'jdbc:derby:subdir/mydb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby:subdir/mydb;drop=true';
> ERROR XBM0I: Directory subdir/mydb cannot be removed.
> ij> connect 'jdbc:derby:memory/mydb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby:memory/mydb;drop=true';
> ERROR 08006: Database 'memory/mydb' dropped.
> Some part of Derby seems to think you actually created an in-memory database, although you did not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DERBY-4590) You can drop a file-system database from a directory named "memory"

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4590?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan resolved DERBY-4590.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 10.6.0.0

Committed 1a to trunk with revision 926600.

> You can drop a file-system database from a directory named "memory"
> -------------------------------------------------------------------
>
>                 Key: DERBY-4590
>                 URL: https://issues.apache.org/jira/browse/DERBY-4590
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, Services, Store
>    Affects Versions: 10.6.0.0
>            Reporter: Kim Haase
>            Assignee: Kristian Waagan
>            Priority: Minor
>             Fix For: 10.6.0.0
>
>         Attachments: derby-4590-1a-disallow_drop_properly.diff
>
>
> With both the embedded and network client drivers, it is possible to create a file-system database and drop it, if you put it in a directory named "memory". 
> I found this out by accident when I accidentally typed "memory/mydb" instead of "memory:mydb" to create an in-memory database.
> If you call the directory something other than "memory", you can't drop the db:
> ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;drop=true';
> ERROR XBM0I: DERBY SQL error: SQLCODE: -1, SQLSTATE: XBM0I, SQLERRMC: Directory subdir/mycdb cannot be removed.
> But if you do exactly the same thing specifying "memory", the drop succeeds:
> ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;drop=true';
> ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'memory/mycdb' dropped.
> When you do this, the "memory" directory continues to exist, but the database directory under it is removed.
> Here are similar examples using the embedded driver:
> ij>  connect 'jdbc:derby:subdir/mydb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby:subdir/mydb;drop=true';
> ERROR XBM0I: Directory subdir/mydb cannot be removed.
> ij> connect 'jdbc:derby:memory/mydb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby:memory/mydb;drop=true';
> ERROR 08006: Database 'memory/mydb' dropped.
> Some part of Derby seems to think you actually created an in-memory database, although you did not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4590) You can drop a file-system database from a directory named "memory"

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4590?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan updated DERBY-4590:
-----------------------------------

    Attachment: derby-4590-1a-disallow_drop_properly.diff

Attaching a very simple fix for this bug. There isn't a general problem allowing one to delete on-disk databases - the database name has to start with "memory" to be able to trigger the bug.
I'm not sure if this catches all corner-cases, but it will hopefully do. We are already using the remove service root functionality for on-disk databases internally, so we cannot disable it.

I'll run the regression tests to be sure, but hopefully this change shouldn't cause any trouble.
I plan to commit it tomorrow. 

> You can drop a file-system database from a directory named "memory"
> -------------------------------------------------------------------
>
>                 Key: DERBY-4590
>                 URL: https://issues.apache.org/jira/browse/DERBY-4590
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, Services, Store
>    Affects Versions: 10.6.0.0
>            Reporter: Kim Haase
>            Assignee: Kristian Waagan
>            Priority: Minor
>         Attachments: derby-4590-1a-disallow_drop_properly.diff
>
>
> With both the embedded and network client drivers, it is possible to create a file-system database and drop it, if you put it in a directory named "memory". 
> I found this out by accident when I accidentally typed "memory/mydb" instead of "memory:mydb" to create an in-memory database.
> If you call the directory something other than "memory", you can't drop the db:
> ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby://localhost:1527/subdir/mycdb;drop=true';
> ERROR XBM0I: DERBY SQL error: SQLCODE: -1, SQLSTATE: XBM0I, SQLERRMC: Directory subdir/mycdb cannot be removed.
> But if you do exactly the same thing specifying "memory", the drop succeeds:
> ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby://localhost:1527/memory/mycdb;drop=true';
> ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'memory/mycdb' dropped.
> When you do this, the "memory" directory continues to exist, but the database directory under it is removed.
> Here are similar examples using the embedded driver:
> ij>  connect 'jdbc:derby:subdir/mydb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby:subdir/mydb;drop=true';
> ERROR XBM0I: Directory subdir/mydb cannot be removed.
> ij> connect 'jdbc:derby:memory/mydb;create=true';
> ij> create table t(c int);
> 0 rows inserted/updated/deleted
> ij> connect 'jdbc:derby:memory/mydb;drop=true';
> ERROR 08006: Database 'memory/mydb' dropped.
> Some part of Derby seems to think you actually created an in-memory database, although you did not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.