Results 1 to 9 of 9

Thread: The copy option for a database does not work as a copy

  1. #1

    The copy option for a database does not work as a copy

    Hi!

    When I create a copy for a database it works as a mirror, meaning that when I modify something from the original the changes reflect in the copy as well and vice versa.

    I tried to create a database from cero and copying the tables structure by using the command copy structure and itīs the same problem.

    How can I fix this issue?

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,144
    Hi,

    Have you tried the COPY DATABASE command? https://www.lianja.com/doc/index.php/COPY_DATABASE

    Read the entire help document so you don't miss the finer points (such as: the database being copied must be closed).

    It works for me: I just tested it.

    Hank

  3. #3
    Hi Hank,

    Thank you for your reply, I tried what you suggested and it didnīt work, do you have another suggestion that I can try?

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,144
    Hi,

    Try this from the Command Window in the LAB:

    close database all
    copy database southwind to myveryown_southwind

    Open database myveryown_southwind
    use customers alias mycustomers
    browse nowait

    open database southwind
    use customers alias original_customers
    browse nowait

    Now change a value in one, go to the other, refresh the browse, and see if it changed.

    Hank

  5. #5
    Hi,

    I did it, I enter those commands, and change a value in one and vice versa and itīs still not working. what else can I try?

  6. #6
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,144
    Hi,

    You're right. I submitted a bug.

    Here's the reproducibility code I submitted:

    close database all
    drop database if exists myveryown_southwind
    copy database southwind to myveryown_southwind
    rebuild database myveryown_southwind


    Open database myveryown_southwind
    use customers alias mycustomers
    browse nowait


    open database southwind
    use customers alias original_customers
    browse nowait

    Change Maria Anders name to Anderson in one, refresh the other browse, and it has changed.

    However, as often happens in these matters, as soon as I submitted the bug I thought I'd better try again.

    This code works:

    close database all
    drop database if exists myveryown_southwind
    copy database southwind to myveryown_southwind
    rebuild database myveryown_southwind


    use myveryown_southwind!customers alias mycustomers in 0
    browse nowait


    use southwind!customers alias original_customers in 0
    browse nowait

    But, it's not just the "in 0" that makes the difference. It's the database staying open that makes the difference, as this code does not work (the change happens in both browse windows):


    close database all
    drop database if exists myveryown_southwind
    copy database southwind to myveryown_southwind
    rebuild database myveryown_southwind


    Open database myveryown_southwind
    use customers alias mycustomers in 0
    browse nowait


    open database southwind
    use customers alias original_customers in 0
    browse nowait


    So, good catch. Interesting findings, to be sure.

    Hank

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,730
    Blog Entries
    18
    Hi hank,

    As i mentioned on the ticket that you submitted.

    You need to REBUILD THE NEW DATABASE after the copy.

    I have changed the code to do this after the COPY DATABASE in 6.4 to remove any confusion.
    Last edited by barrymavin; 2022-01-11 at 03:04.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  8. #8
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,144
    Hi Barry,

    My code, above and in the ticket, does rebuild the database.

    I agree about the need to rebuild the database. And having that happen automatically will make things more straightforward (when would one NOT want to rebuild it?) in scenarios where database tenanting is happening on the fly within some part of an application.

    That said, the code above does rebuild the database. So there was another issue as well, as illustrated by the 3 code examples (the latter two I added to the ticket last night).

    The second issue seems to be when a database is left open which contains a table that is open from another database, which is then open after opening the same table, with a different alias, from the first database. The browse window is also a common element that I did not test removing from the scenario.

    Hank
    Last edited by HankFay; 2022-01-11 at 16:15.

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,730
    Blog Entries
    18
    Hi Hank,

    Yes as you have pointed out. The original ticket however was to do with COPY DATABASE and the solution as you identified is to REBUILD the target database after the copy.

    To answer your question about why you would not want to rebuild after a copy.

    Databases are containers for tables and their associated resources. They can however contain linked tables that have been added interactively in the console using ADD TABLE which may not exist in the database contain itself.

    With Lianja this is used rarely so performing a rebuild after a copy provides the solution .

    Regarding your other observation, I will investigate. Normally closing a database closes all the tables and that also happens on opening a database. having browse windows open in a desktop application is the only time these can be affected. In a normal Lianja app the database stays open for the duration that the app is open. Web and mobile apps are not affected.
    Last edited by barrymavin; 2022-01-11 at 19:16.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us