IndexedDB: UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code. (error code 0) - firefox

I'm trying to migrate an IndexedDB database to a different instance of Firefox.
I can migrate it to a different site (or directory, for file URLs) just by copying ~/.mozilla/firefox/PROFILE/storage/default/file++++... to the new name.
I can also migrate to a different profile in the same Firefox instance.
But if I create a new home directory (export HOME=/tmp/test-home) and copy into that, then Firefox refuses to open the database, giving the error:
UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code. (error code 0))
(I actually want to migrate to a new machine, but testing with the same machine, user, and FF version narrows down the problem)
What tests does FF do to decide whether to allow opening the database? I see a binary .metadata file with a path in, and also a .sqlite file with it in the "database" table (which I tried updating manually).
I'm testing with Firefox 40.0.3.
Update: found this in the Javascript console:
Security Error: Content at file:///home/.../ may not load data from file:///cache.manifest.
Quota 'idb' is not a valid schema!: QuotaManager.cpp:4932 <unknown>
Quota Origin 'idb' failed to parse, handled tokens: : QuotaManager.cpp:4858 <unknown>
IndexedDB UnknownErr: ActorsParent.cpp:573

The metadata file gives the old origin. Firefox's QuotaManager loads the metadata file, reads the old origin, and tries to scan the 'idb' directory for the old origin. This directory doesn't exist and so it aborts. If the metadata file is deleted, Firefox will recreate it with the correct contents.
Also, make sure the target Firefox instance is at least as new as the source one. I also got this error with Firefox 37 trying to read a file from Firefox 40.

Thanks for your post, it was helpful.
Let me explain what I'm doing, and I think it will help you to at least understand the problem. So far as I can tell the hidden file .metadata is not related to this problem.
I'm trying to move a sqlite database from FFOS 2.1 to FFOS 2.6. The application uses the indexDB and so far as the application is aware nothing has changed (applicaiton, code, applicaiton's database are unchanged). However Firefox changed the schema of the database that stores the application's database. This back-end storage database is agnostic to the application database.
Using sqlite3 and the .schema command I can explain the differences:
Older 2.1
CREATE TABLE database (name TEXT PRIMARY KEY, origin TEXT NOT NULL, version INTEGER NOT NULL DEFAULT 0, last_vacuum_time INTEGER NOT NULL DEFAULT 0, last_analyze_time INTEGER NOT NULL DEFAULT 0, last_vacuum_size INTEGER NOT NULL DEFAULT 0) WITHOUT ROWID;
CREATE TABLE index_data( index_id INTEGER NOT NULL, value BLOB NOT NULL, object_data_key BLOB NOT NULL, object_store_id INTEGER NOT NULL, value_locale BLOB, PRIMARY KEY (index_id, value, object_data_key), FOREIGN KEY (index_id) REFERENCES object_store_index(id) , FOREIGN KEY (object_store_id, object_data_key) REFERENCES object_data(object_store_id, key) ) WITHOUT ROWID;
CREATE INDEX index_data_value_locale_index ON index_data (index_id, value_locale, object_data_key, value) WHERE value_locale IS NOT NULL;
CREATE TABLE object_store( id INTEGER PRIMARY KEY, auto_increment INTEGER NOT NULL DEFAULT 0, name TEXT NOT NULL, key_path TEXT);
CREATE TABLE unique_index_data( index_id INTEGER NOT NULL, value BLOB NOT NULL, object_store_id INTEGER NOT NULL, object_data_key BLOB NOT NULL, value_localeBLOB, PRIMARY KEY (index_id, value), FOREIGN KEY (index_id) REFERENCES object_store_index(id) , FOREIGN KEY (object_store_id, object_data_key) REFERENCES object_data(object_store_id, key) ) WITHOUT ROWID;
CREATE INDEX unique_index_data_value_locale_index ON unique_index_data (index_id, value_locale, object_data_key, value) WHERE value_locale IS NOT NULL;
CREATE TABLE file (id INTEGER PRIMARY KEY, refcount INTEGER NOT NULL);
CREATE TRIGGER file_update_trigger AFTER UPDATE ON file FOR EACH ROW WHEN NEW.refcount = 0 BEGIN DELETE FROM file WHERE id = OLD.id; END;
CREATE TABLE object_data ( object_store_id INTEGER NOT NULL, key BLOB NOT NULL, index_data_values BLOB DEFAULT NULL, file_ids TEXT, data BLOB NOT NULL, PRIMARY KEY (object_store_id, key), FOREIGN KEY (object_store_id) REFERENCES object_store(id) ) WITHOUT ROWID;
CREATE TRIGGER object_data_insert_trigger AFTER INSERT ON object_data WHEN NEW.file_ids IS NOT NULL BEGIN SELECT update_refcount(NULL, NEW.file_ids);END;
CREATE TRIGGER object_data_update_trigger AFTER UPDATE OF file_ids ON object_data WHEN OLD.file_ids IS NOT NULL OR NEW.file_ids IS NOT NULL BEGIN SELECT update_refcount(OLD.file_ids, NEW.file_ids);END;
CREATE TRIGGER object_data_delete_trigger AFTER DELETE ON object_data WHEN OLD.file_ids IS NOT NULL BEGIN SELECT update_refcount(OLD.file_ids, NULL);END;
CREATE TABLE object_store_index ( id INTEGER PRIMARY KEY, object_store_id INTEGER NOT NULL, name TEXT NOT NULL, key_path TEXT NOT NULL, unique_index INTEGER NOT NULL, multientry INTEGER NOT NULL, locale TEXT, is_auto_locale BOOLEAN, FOREIGN KEY (object_store_id) REFERENCES object_store(id) );
Newer 2.6
CREATE TABLE database (name TEXT NOT NULL, version INTEGER NOT NULL DEFAULT 0);
CREATE TABLE index_data (index_id INTEGER NOT NULL, value BLOB NOT NULL, object_data_key BLOB NOT NULL, object_data_id INTEGER NOT NULL, PRIMARY KEY (index_id,value, object_data_key), FOREIGN KEY (index_id) REFERENCES object_store_index(id) ON DELETE CASCADE, FOREIGN KEY (object_data_id) REFERENCES object_data(id) ONDELETE CASCADE);
CREATE INDEX index_data_object_data_id_index ON index_data (object_data_id);
CREATE TABLE object_store (id INTEGER PRIMARY KEY, auto_increment INTEGER NOT NULL DEFAULT 0, name TEXT NOT NULL, key_path TEXT, UNIQUE (name));
CREATE TABLE unique_index_data (index_id INTEGER NOT NULL, value BLOB NOT NULL, object_data_key BLOB NOT NULL, object_data_id INTEGER NOT NULL, PRIMARY KEY (index_id, value, object_data_key), UNIQUE (index_id, value), FOREIGN KEY (index_id) REFERENCES object_store_index(id) ON DELETE CASCADE FOREIGN KEY (object_data_id) REFERENCES object_data(id) ON DELETE CASCADE);
CREATE INDEX unique_index_data_object_data_id_index ON unique_index_data (object_data_id);
CREATE TABLE file (id INTEGER PRIMARY KEY, refcount INTEGER NOT NULL);
CREATE TRIGGER file_update_trigger AFTER UPDATE ON file FOR EACH ROW WHEN NEW.refcount = 0 BEGIN DELETE FROM file WHERE id = OLD.id; END;
CREATE TABLE object_data (id INTEGER PRIMARY KEY, object_store_id INTEGER NOT NULL, key_value BLOB DEFAULT NULL, file_ids TEXT, data BLOB NOT NULL, UNIQUE (object_store_id, key_value), FOREIGN KEY (object_store_id) REFERENCES object_store(id) ON DELETE CASCADE);
CREATE TRIGGER object_data_insert_trigger AFTER INSERT ON object_data FOR EACH ROW WHEN NEW.file_ids IS NOT NULL BEGIN SELECT update_refcount(NULL, NEW.file_ids); END;
CREATE TRIGGER object_data_update_trigger AFTER UPDATE OF file_ids ON object_data FOR EACH ROW WHEN OLD.file_ids IS NOT NULL OR NEW.file_ids IS NOT NULL BEGIN SELECT update_refcount(OLD.file_ids, NEW.file_ids); END;
CREATE TRIGGER object_data_delete_trigger AFTER DELETE ON object_data FOR EACH ROW WHEN OLD.file_ids IS NOT NULL BEGIN SELECT update_refcount(OLD.file_ids, NULL); END;
CREATE TABLE object_store_index (id INTEGER PRIMARY KEY, object_store_id INTEGER NOT NULL, name TEXT NOT NULL, key_path TEXT NOT NULL, unique_index INTEGER NOTNULL, multientry INTEGER NOT NULL, UNIQUE (object_store_id, name), FOREIGN KEY (object_store_id) REFERENCES object_store(id) ON DELETE CASCADE);
I have been unable to find a script written by mozilla that addresses this. But I suspect you could trick firefox into repairing this issue for you-- downgrade Firefox insert old database then upgrade firefox. Allow upgrade script to rewrite the database.
Unfortunately these changes look more complex than a simple adding/columns so I doubt you could safely just change or upgrade the existing database. So unless someone at Mozilla left a script lying around I believe there is no other solution.

I met this error with Firefox 63, end of 2018.
IndexedDB: UnknownError: The operation failed for reasons unrelated to the database itself and not covered by any other error code. (error code 0)
It comes from many updates over the same user profile.
localStorage panel from the debugger was empty, whith keys still accessible.
devdocs refused to install offline, with an error indexedDB.
Solution: This mozilla page and click the refresh Firefox button.

Related

drop foreign key constraint on DB2 table through alter table

I have a DB2 (for IBMi) table created as below. I would like to drop the forign key constraint while running in an SQLRPGLE program. Is this possible?
create table grid_action_details(id integer not null
generated always as identity
(start with 1 increment by 1)
PRIMARY KEY,grid_details_id integer,foreign key(grid_details_id)
references grid_details(id),action_code_details_id integer,
foreign key(action_code_details_id)
references action_code_details(id),action_code_status varchar(2),
created_date date default
current_date,created_by varchar(30),
last_updated_date date default current_date,updated_by
varchar(30),required_parameter clob);
I tried the below syntax but it just doesn't seem to work for me:
ALTER TABLE table-name
DROP FOREIGN KEY foreign_key_name
alter table iesqafile.grid_action_details
drop foreign key action_code_details_id
ACTION_CODE_DETAILS_ID in IESQAFILE type *N not found.
You drop the FK constraint via name, not via column.
Since you didn't specify one during create, you'll need to look to see what name the system generated.
Always a best practice to name things yourself.
CONSTAINT <name> FOREIGN KEY (<columns>)
create table grid_action_details (
id integer not null generated always as identity (
start with 1 increment by 1
)
,constraint grid_action_details_pk
primary key
,grid_details_id integer
,constraint grid_details_fk
foreign key (grid_details_id)
references grid_details (id)
,action_code_details_id integer
,constraint action_code_details_fk
foreign key (action_code_details_id)
references action_code_details (id)
,action_code_status varchar(2)
,created_date date default current_date
,created_by varchar(30)
,last_updated_date date default current_date
,updated_by varchar(30)
,required_parameter clob
);
Now you can drop by the known name
alter table iesqafile.grid_action_details
drop foreign key action_code_details_fk
EDIT
To find the generated name use:
the ACS Schema component
DSPFD
SQL against one of the catalog views (QSYS2.SYSCST, SYSIBM.SQLFOREIGNKEYS, SYSIBM.REFERENTIAL_CONSTRAINTS )

H2DB - executeUpdate() returns 0 or 1 on DELETE depending on table definition

I wonder if someone could explain the behaviour of the H2 JDBC driver when deleting an entry from a rather simple table.
When using the following table definition, the method executeUpdate() for a PreparedStatement instance returns 1 if one entry has been deleted (expected behaviour).
CREATE TABLE IF NOT EXISTS "MATERIAL" (
"CODE" VARCHAR(5) NOT NULL,
"NAME" VARCHAR(100) NOT NULL
);
When adding a PRIMARY KEY constraint on the CODE column, the same method returns 0 although the entry gets deleted successfully (behaviour not expected).
CREATE TABLE IF NOT EXISTS "MATERIAL" (
"CODE" VARCHAR(5) NOT NULL,
"NAME" VARCHAR(100) NOT NULL,
PRIMARY KEY ("CODE")
);
Most interestingly, when adding an INT typed column to serve as PRIMARY KEY the return value is 1 again:
CREATE TABLE IF NOT EXISTS "MATERIAL" (
"ID" INT NOT NULL AUTO_INCREMENT,
"CODE" VARCHAR(5) NOT NULL,
"NAME" VARCHAR(100) NOT NULL,
PRIMARY KEY ("ID")
);
Is someone able to reconstruct this behaviour and probably somehow explain it to me?
I have included the current version of H2 DB using maven.
EDIT:
If I eventually add a UNIQUE constraint for the CODE column, the return value is 0 again ...
CREATE TABLE IF NOT EXISTS "MATERIAL" (
"ID" INT NOT NULL AUTO_INCREMENT,
"CODE" VARCHAR(5) NOT NULL UNIQUE,
"NAME" VARCHAR(100) NOT NULL,
PRIMARY KEY ("CODE")
);
EDIT 2:
The query used to delete an entry looks like the following (used in PreparedStatement):
DELETE FROM MATERIAL WHERE CODE = ?
SOLUTION:
I'm sorry to have you bothered with this. Actually, there was no problem with the table definition or the JDBC driver. It was my test data - from earlier testing I had wanted to INSERT two entries having the same CODE. It was a multiple row insert - obviously this failed, when CODE was the PK or having a UNIQUE index. Thus, in this cases executeUpdate() could only return 0 because there was no data in the table at all.

How to get DataMapper to not specify a NULL default value

I'm getting an error when I use DataMapper's auto_upgrade! method to add fields in an SQLite3 db based on the properties defined in my code:
DataObjects::SyntaxError at /history
Cannot add a NOT NULL column with default value NULL
An example of an offending line would be:
property :fieldname, Text, required: true
The error goes away if I (a) remove the line, (b) remove required: true, (c) change true to false, or (d) add a default value.
SQLite does not require a default value to be specified for every field, so this problem is definitely with DataMapper, not SQLite.
How can I get around this, so DataMapper can specify that a field is required without assuming that not specifying a default value automatically means the default should be NULL?
(If you want to know more about why I'm designing this way: there will be another client process accessing SQLite and logging data into the SQLite database, while a Sinatra app will be pulling data out of the db for display in a browser. I want the database therefore to enforce the field requirements, but DM's auto_upgrade is a very convenient way to be able to upgrade the database as needed—so long as it doesn't foul things up in the process.)
You are requiring the field, hence it cannot be NULL. This is simple table properties.
When DataMapper runs auto_upgrade! it runs the SQL commands on the database.
CREATE TABLE Test
(
P_Id int NOT NULL,
lname varchar(255) NOT NULL,
fname varchar(255),
Address varchar(255),
City varchar(255)
)
And doing something like this won't work.
CREATE TABLE Test
(
P_Id int NOT NULL,
lname varchar(255) NOT NULL DEFAULT NULL,
fname varchar(255),
Address varchar(255),
City varchar(255)
)
I tested it in MySQL and this is the error.
02:52:43 CREATE TABLE TestTest ( P_Id int NOT NULL, lname
varchar(255) NOT NULL DEFAULT NULL, fname varchar(255), Address
varchar(255), City varchar(255) ) Error Code: 1067. Invalid default
value for 'lname' 0.062 sec
Correction: SQLite does allow you to create a table with such properties. However, when trying to insert anything to that table makes it throw an error whether the field is NULL or not. So DataMapper might be doing some sanitation for your before even creating the table.
It is not clear to me if you are creating a new table or modifying an existing one.
If you have an existing table and are trying to alter it with a column defined as NOT NULL, then you must provide a default value so that the existing rows can be migrated. The RDBMS needs to know what to put in the field for pre-existing rows.
If you are creating a new table, then the property definition you have should be fine.

About restrictive record creation in a child table. (Oracle Forms Builder)

I created a form where i add records to a child table. However I don't want people to be able to edit the secondary key, only select it from the list of primary keys of the parent or something along those lines. How could i do that?
The tables:
CREATE TABLE CHAMPIONS (CNAME VARCHAR2(15) NOT NULL, PRICELEVEL NUMBER(1) NOT NULL, ROLE VARCHAR2(10) NOT NULL, HPLEVEL NUMBER(2) NOT NULL, ATKLEVEL NUMBER(2) NOT NULL, MAGICLEVEL NUMBER(2) NOT NULL, DIFFLEVEL NUMBER(2) NOT NULL);
CREATE TABLE SKINS (SNAME VARCHAR2(20) NOT NULL, CNAME VARCHAR2(15) NOT NULL, PRICELEVEL NUMBER(1) NOT NULL);
ALTER TABLE Champions ADD CONSTRAINT pk_Champions PRIMARY KEY (CNAME);
ALTER TABLE Skins ADD CONSTRAINT fk_Skins FOREIGN KEY (CNAME) REFERENCES champions(CNAME);
Too less information to be able to give an answer, but I can give it a try.
You can have LOVs created in the detail table and have that LOV driven off of the parent tables primary key, also the text item with which you would be linking the LOV you need to put a WHEN-VALIDATE-ITEM trigger with the same query as in the LOVs RECORD GROUP so that in case the user types instead of using the LOV you can validate the input and then alert them in case of invalid input and fetch the correct master primary key in case of correct value entered.
Below is how the datablock with the LOV buttons look like-
And below is the Trigger on the STORE item in the datablock-
You can code the RG similarly as the query in the trigger considering your master table in the query.
The simplest way to get this functionality is to create a LOV based on champions.cname and attach it to item form column skins.cname (Please refer the Forms help if you are not familiar with creating LOV:s). Then set the item property 'Validate from list' of item skins.cname to Yes. This will validate all entered values against the existing cname values.

Table creation with h2 database

I am new to h2.I just using h2 in spring embedded mode with hibernate.I am trying to execute the following scripts using h2.
CREATE TABLE acct_authority (
id bigint(20) NOT NULL auto_increment,
name varchar(255) NOT NULL default '',
value varchar(255) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY name (name)
);
The table acct_authority is created without any error.But if i create another table with the following script.
CREATE TABLE acct_role (
id bigint(20) NOT NULL auto_increment,
name varchar(255) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY name (name)
);
It shows error as constraint name allready exists.What mistake i did.
You tried to create two constraints with same name. As you see, both CREATE TABLE statements contain following:
UNIQUE KEY name (name)
Result is that first one creates constraint named name, and second one fails because constraint name already exists. Problem can be solved by using unique names. Also in general it makes sense have little bit more descriptive names for database objects. Maybe you can use for example something like following:
UNIQUE KEY acct_authority_name_UNIQUE (name)
...
UNIQUE KEY acct_role_name_UNIQUE (name)

Resources