View Ticket
Not logged in
Ticket Hash: bf309c33018bdba0ff81bf7f8c034dea79f4d37f
Title: RenameTable in DB Browser with mod_spatialite
Status: Closed Type: Incident
Severity: Cosmetic Priority: Immediate
Subsystem: Resolution: Unable_To_Reproduce
Last Modified: 2023-07-23 12:51:32
Version Found In: 5.0.1
User Comments:
anonymous added on 2021-03-30 15:12:37:

I am trying to use the spatialite extension with db browser on windows and having an issue with a specific function in the extension. Spatialite has a helper function for renaming a table. I have no problem using that function in the spatialite cli or spatialite-gui applications, but cannot get it to work in db browser.

In db browser, if I execute:

select load_extension('mod_spatialite');
select RenameTable('main','Land_Use_2015','Land_Use_2015_proj');
I see the following in the SQL log:

-- EXECUTING ALL IN 'SQL 1'
--
-- At line 1:
select load_extension('mod_spatialite');
-- Result: 1 rows returned in 156ms
-- At line 2:
select RenameTable('main','Land_Use_2015','Land_Use_2015_proj');
-- Result: RenameTable exception - FOREIGN KEY constraint failed.

I know the gaiaRenameTable function in spatialite (statistics.c) should automatically disable foreign keys via PRAGMA foreign_keys = 0, but for some reason it is not. Nonetheless, if I explicitly disable myself and execute:

select load_extension('mod_spatialite');
PRAGMA foreign_keys = OFF;
select RenameTable('main','Land_Use_2015','Land_Use_2015_proj');

I see the following in the SQL log:

-- EXECUTING ALL IN 'SQL 1'
--
-- At line 1:
select load_extension('mod_spatialite');
-- Result: 1 rows returned in 10ms
-- At line 2:
PRAGMA foreign_keys = OFF;
-- Result: 0 rows returned in 17ms
-- At line 2:
PRAGMA foreign_keys = OFF;
-- Result: 0 rows returned in 18ms
-- At line 2:
PRAGMA foreign_keys = OFF;
-- Result: 0 rows returned in 608ms
-- At line 3:
select RenameTable('main','Land_Use_2015','Land_Use_2015_proj');
-- Result: 0 rows returned in 589ms

the RenameTable does not return any rows and the table is not renamed. I don't understand why this issue only comes up in db browser with mod_spatialite and not the spatialite cli or spatialite gui. I have no problem loading the extension and all dependencies are in a directory in my system $PATH.

Wondering if it has something to do with the mod_spatialite vs libspatialite issues?


sandro added on 2023-07-23 12:51:32:

I've tested yout sample using sqlite3 (the official SQLite's front end) and anything works exactely as expected.

I suspect that db browser may do something odd and unexpected forbidding mod_spatialite to correctly work