1
# This is a very basic sanity test for PBMS
2
# it makes a lot of use of the system tables
3
# which is frowned on in a real application.
5
CREATE TABLE t1 (a int primary key, b blob);
6
insert into t1 values (1, "Hello World");
7
insert into t1 values (2, "Hello PBMS");
8
insert into t1 values (3, "Hello BLOB World");
9
SELECT COUNT(*) FROM t1;
11
# Check that the BLOBs look OK
12
select a, Table_name, Blob_size from pbms_reference ref, t1 where ref.Blob_url = t1.b order by a;
13
select a, MD5_Checksum from pbms_repository rep, pbms_reference ref, t1 where t1.b = ref.Blob_url and ref.Repository_id = rep.Repository_id and ref.Repo_blob_offset = rep.Repo_blob_offset order by a;
15
# This should work but it doesn't because of a bug in the current version of PBMS
16
#insert into pbms_metadata (select Repository_id, Repo_blob_offset, "Name", "Test1" from pbms_reference ref, t1 where t1.a = 1 and ref.Blob_url = t1.b);
18
# For now I will use a temp table.
19
CREATE Temporary TABLE my_pbms_blob_ids (id int, offset int, url varchar(120));
20
insert into my_pbms_blob_ids (select Repository_id, Repo_blob_offset, Blob_url from pbms_reference);
22
insert into pbms_metadata (select id, offset, "Name", "Test1" from my_pbms_blob_ids ref, t1 where t1.a = 1 and ref.url = t1.b);
23
insert into pbms_metadata (select id, offset, "Name", "Test2" from my_pbms_blob_ids ref, t1 where t1.a = 2 and ref.url = t1.b);
24
insert into pbms_metadata (select id, offset, "Name", "Test3" from my_pbms_blob_ids ref, t1 where t1.a = 3 and ref.url = t1.b);
26
select a, name, value from pbms_metadata meta, pbms_reference ref, t1 where t1.b = ref.Blob_url and ref.Repository_id = meta.Repository_id and ref.Repo_blob_offset = meta.Repo_blob_offset order by a;
28
# Inserting metadata can cause BLOBs to be moved around so before adding more metadata to a BLOB
29
# I need to refresh the temp table. (This wil not be required in the new version of PBMS.)
30
delete from my_pbms_blob_ids;
31
insert into my_pbms_blob_ids (select Repository_id, Repo_blob_offset, Blob_url from pbms_reference);
33
insert into pbms_metadata (select id, offset, "Name2", "Test2.2" from my_pbms_blob_ids ref, t1 where t1.a = 2 and ref.url = t1.b);
36
select a, name, value from pbms_metadata meta, pbms_reference ref, t1 where t1.b = ref.Blob_url and ref.Repository_id = meta.Repository_id and ref.Repo_blob_offset = meta.Repo_blob_offset order by a, name;
39
drop Temporary table my_pbms_blob_ids;
42
create table autoincbug (id int not null primary key auto_increment, test varchar(10));
43
alter table autoincbug auto_increment = 1000;
44
insert into autoincbug values (null, 'hej');
45
alter table autoincbug auto_increment = 32727;
46
drop table autoincbug;