Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8c77392
Update query syntax for starts/ends with and tweak for consistency
peterbroadhurst Jan 6, 2022
2b013c5
Andrew confirmed we don't need escaping per RFC3986
peterbroadhurst Jan 6, 2022
aec5771
Merge with main
peterbroadhurst Jan 6, 2022
2a91130
Update code after merge
peterbroadhurst Jan 6, 2022
a59a5c1
Support partial ID queries, and null queries
peterbroadhurst Jan 7, 2022
4e0a334
Handle case sensitivity in SQLite
peterbroadhurst Jan 7, 2022
d97fed1
Avoid double reigstering SQLite driver
peterbroadhurst Jan 7, 2022
f59e686
Provide error messages in the case of bad combinations
peterbroadhurst Jan 7, 2022
bc09eea
Make bytables JSONAny, and serialize to string
peterbroadhurst Jan 7, 2022
4283dc7
Err tweaks
peterbroadhurst Jan 7, 2022
7b254c9
Move to TEXT fields
peterbroadhurst Jan 7, 2022
f4663c0
Byte limit on batch size
peterbroadhurst Jan 11, 2022
4348cf0
Merge branch 'new-query' of github.com:kaleido-io/firefly into byte-b…
peterbroadhurst Jan 11, 2022
76a5e0e
Add stored size for JSON values as well as blobs and reject early
peterbroadhurst Jan 11, 2022
0bec7e3
Move to separate DB migration
peterbroadhurst Jan 11, 2022
da1c58b
Take into account onchain logic migrations in numbering
peterbroadhurst Jan 11, 2022
d216ebf
FIR-7 implementation
peterbroadhurst Jan 12, 2022
e08696a
Tidy up tests
peterbroadhurst Jan 12, 2022
1db275f
Big old merge into onchain-logic - phew!
peterbroadhurst Jan 12, 2022
f53d904
Move new JSONAny columns to TEXT too
peterbroadhurst Jan 12, 2022
87d0dde
Fix gap in coverage
peterbroadhurst Jan 12, 2022
42d2c6f
Merge branch 'onchain-logic' into byte-batch-limit
nguyer Jan 12, 2022
4478b71
Restore normality to the space time continuum
peterbroadhurst Jan 12, 2022
0942cd9
Fix comments
peterbroadhurst Jan 13, 2022
87ab9ad
Fix typo in dx callbacks unit test
awrichar Jan 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
run:
tests: false
skip-dirs:
- "mocks"
linters-settings:
golint: {}
gocritic:
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/postgres/000002_create_data_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CREATE TABLE data (
datatype_version VARCHAR(64) NOT NULL,
hash CHAR(64) NOT NULL,
created BIGINT NOT NULL,
value BYTEA NOT NULL,
value TEXT NOT NULL,
blobstore BOOLEAN NOT NULL
);
CREATE UNIQUE INDEX data_id ON data(id);
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/postgres/000004_create_batches_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CREATE TABLE batches (
group_hash CHAR(64),
hash CHAR(64),
created BIGINT NOT NULL,
payload BYTEA NOT NULL,
payload TEXT NOT NULL,
payload_ref CHAR(64),
confirmed BIGINT,
tx_type VARCHAR(64) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CREATE TABLE transactions (
created BIGINT NOT NULL,
protocol_id VARCHAR(256),
status VARCHAR(64) NOT NULL,
info BYTEA
info TEXT
);

CREATE UNIQUE INDEX transactions_id ON data(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CREATE TABLE datatypes (
version VARCHAR(64) NOT NULL,
hash CHAR(64) NOT NULL,
created BIGINT NOT NULL,
value BYTEA
value TEXT
);

CREATE UNIQUE INDEX datatypes_id ON data(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CREATE TABLE operations (
created BIGINT NOT NULL,
updated BIGINT,
error VARCHAR NOT NULL,
info BYTEA
info TEXT
);

CREATE UNIQUE INDEX operations_id ON operations(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CREATE TABLE subscriptions (
filter_topics VARCHAR(256) NOT NULL,
filter_tag VARCHAR(256) NOT NULL,
filter_group VARCHAR(256) NOT NULL,
options BYTEA NOT NULL,
options TEXT NOT NULL,
created BIGINT NOT NULL
);

Expand Down
2 changes: 1 addition & 1 deletion db/migrations/postgres/000013_create_orgs_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE orgs (
parent VARCHAR(1024),
identity VARCHAR(1024) NOT NULL,
description VARCHAR(4096) NOT NULL,
profile BYTEA,
profile TEXT,
created BIGINT NOT NULL
);

Expand Down
2 changes: 1 addition & 1 deletion db/migrations/postgres/000014_create_nodes_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE nodes (
name VARCHAR(64) NOT NULL,
description VARCHAR(4096) NOT NULL,
dx_peer VARCHAR(256),
dx_endpoint BYTEA,
dx_endpoint TEXT,
created BIGINT NOT NULL
);

Expand Down
2 changes: 1 addition & 1 deletion db/migrations/postgres/000015_create_config_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ BEGIN;
CREATE TABLE config (
seq SERIAL PRIMARY KEY,
config_key VARCHAR(512) NOT NULL,
config_value BYTEA NOT NULL
config_value TEXT NOT NULL
);
CREATE UNIQUE INDEX config_sequence ON config(seq);
CREATE UNIQUE INDEX config_config_key ON config(config_key);
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/postgres/000027_add_operations_input.up.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BEGIN;
ALTER TABLE operations RENAME COLUMN info TO output;
ALTER TABLE operations ADD COLUMN input BYTEA;
ALTER TABLE operations ADD COLUMN input TEXT;
COMMIT;
4 changes: 2 additions & 2 deletions db/migrations/postgres/000050_create_ffi_methods_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CREATE TABLE ffimethods (
name VARCHAR(1024) NOT NULL,
pathname VARCHAR(1024) NOT NULL,
description TEXT NOT NULL,
params BYTEA NOT NULL,
returns BYTEA NOT NULL
params TEXT NOT NULL,
returns TEXT NOT NULL
);

CREATE UNIQUE INDEX ffimethods_pathname ON ffimethods(interface_id,pathname);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE ffievents (
name VARCHAR(1024) NOT NULL,
pathname VARCHAR(1024) NOT NULL,
description TEXT NOT NULL,
params BYTEA NOT NULL
params TEXT NOT NULL
);

CREATE UNIQUE INDEX ffievents_pathname ON ffievents(interface_id,pathname);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ CREATE TABLE contractapis (
seq SERIAL PRIMARY KEY,
id UUID NOT NULL,
interface_id UUID NOT NULL,
ledger BYTEA,
location BYTEA,
ledger TEXT,
location TEXT,
name VARCHAR(64) NOT NULL,
namespace VARCHAR(64) NOT NULL
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ CREATE TABLE contractsubscriptions (
seq SERIAL PRIMARY KEY,
id UUID NOT NULL,
interface_id UUID NULL,
event BYTEA NOT NULL,
event TEXT NOT NULL,
namespace VARCHAR(64) NOT NULL,
name VARCHAR(64) NULL,
protocol_id VARCHAR(1024) NOT NULL,
location BYTEA NOT NULL,
location TEXT NOT NULL,
created BIGINT NOT NULL
);

Expand Down
10 changes: 5 additions & 5 deletions db/migrations/postgres/000054_create_contractevents_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ CREATE TABLE contractevents (
namespace VARCHAR(64) NOT NULL,
name VARCHAR(1024) NOT NULL,
subscription_id UUID NOT NULL,
outputs BYTEA,
info BYTEA,
outputs TEXT,
info TEXT,
timestamp BIGINT NOT NULL
);
CREATE UNIQUE INDEX contractevents_name ON contractevents(namespace,name);
CREATE UNIQUE INDEX contractevents_timestamp ON contractevents(timestamp);
CREATE UNIQUE INDEX contractevents_subscription_id ON contractevents(subscription_id);
CREATE INDEX contractevents_name ON contractevents(namespace,name);
CREATE INDEX contractevents_timestamp ON contractevents(timestamp);
CREATE INDEX contractevents_subscription_id ON contractevents(subscription_id);
COMMIT;
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ DROP INDEX data_blob_size;
ALTER TABLE blobs DROP COLUMN size;
ALTER TABLE data DROP COLUMN blob_name;
ALTER TABLE data DROP COLUMN blob_size;
ALTER TABLE data DROP COLUMN value_size;
COMMIT;
8 changes: 7 additions & 1 deletion db/migrations/postgres/000055_add_blobs_size_and_name.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ ALTER TABLE blobs ADD COLUMN size BIGINT;

ALTER TABLE data ADD COLUMN blob_name VARCHAR(1024);
ALTER TABLE data ADD COLUMN blob_size BIGINT;
ALTER TABLE data ADD COLUMN value_size BIGINT;

UPDATE blobs SET size = 0;
UPDATE data SET blob_size = 0, blob_name = '';
UPDATE data SET blob_size = 0, blob_name = '', value_size = 0;

ALTER TABLE data ALTER COLUMN blob_name SET NOT NULL;
ALTER TABLE data ALTER COLUMN blob_size SET NOT NULL;
ALTER TABLE data ALTER COLUMN value_size SET NOT NULL;

CREATE INDEX data_blob_name ON data(blob_name);
CREATE INDEX data_blob_size ON data(blob_size);

COMMIT;
2 changes: 1 addition & 1 deletion db/migrations/sqlite/000002_create_data_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE data (
datatype_version VARCHAR(64) NOT NULL,
hash CHAR(64) NOT NULL,
created BIGINT NOT NULL,
value BYTEA NOT NULL,
value TEXT NOT NULL,
blob_hash CHAR(64),
blob_public VARCHAR(1024)
);
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/sqlite/000004_create_batches_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE batches (
group_hash CHAR(64),
hash CHAR(64),
created BIGINT NOT NULL,
payload BYTEA NOT NULL,
payload TEXT NOT NULL,
payload_ref VARCHAR(256),
confirmed BIGINT,
tx_type VARCHAR(64) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CREATE TABLE transactions (
created BIGINT NOT NULL,
protocol_id VARCHAR(256),
status VARCHAR(64) NOT NULL,
info BYTEA
info TEXT
);

CREATE UNIQUE INDEX transactions_id ON data(id);
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/sqlite/000006_create_datatypes_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CREATE TABLE datatypes (
version VARCHAR(64) NOT NULL,
hash CHAR(64) NOT NULL,
created BIGINT NOT NULL,
value BYTEA
value TEXT
);

CREATE UNIQUE INDEX datatypes_id ON data(id);
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/sqlite/000008_create_operations_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CREATE TABLE operations (
created BIGINT NOT NULL,
updated BIGINT,
error VARCHAR NOT NULL,
info BYTEA
info TEXT
);

CREATE UNIQUE INDEX operations_id ON operations(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CREATE TABLE subscriptions (
filter_topics VARCHAR(256) NOT NULL,
filter_tag VARCHAR(256) NOT NULL,
filter_group VARCHAR(256) NOT NULL,
options BYTEA NOT NULL,
options TEXT NOT NULL,
created BIGINT NOT NULL
);

Expand Down
2 changes: 1 addition & 1 deletion db/migrations/sqlite/000013_create_orgs_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE TABLE orgs (
parent VARCHAR(1024),
identity VARCHAR(1024) NOT NULL,
description VARCHAR(4096) NOT NULL,
profile BYTEA,
profile TEXT,
created BIGINT NOT NULL
);

Expand Down
2 changes: 1 addition & 1 deletion db/migrations/sqlite/000014_create_nodes_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE TABLE nodes (
name VARCHAR(64) NOT NULL,
description VARCHAR(4096) NOT NULL,
dx_peer VARCHAR(256),
dx_endpoint BYTEA,
dx_endpoint TEXT,
created BIGINT NOT NULL
);

Expand Down
2 changes: 1 addition & 1 deletion db/migrations/sqlite/000015_create_config_table.up.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE TABLE config (
seq INTEGER PRIMARY KEY AUTOINCREMENT,
config_key VARCHAR(512) NOT NULL,
config_value BYTEA NOT NULL
config_value TEXT NOT NULL
);
CREATE UNIQUE INDEX config_sequence ON config(seq);
CREATE UNIQUE INDEX config_config_key ON config(config_key);
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/sqlite/000027_add_operations_input.up.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE operations RENAME COLUMN info TO output;
ALTER TABLE operations ADD COLUMN input BYTEA;
ALTER TABLE operations ADD COLUMN input TEXT;
4 changes: 2 additions & 2 deletions db/migrations/sqlite/000050_create_ffi_methods_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ CREATE TABLE ffimethods (
name VARCHAR(1024) NOT NULL,
pathname VARCHAR(1024) NOT NULL,
description TEXT NOT NULL,
params BYTEA NOT NULL,
returns BYTEA NOT NULL
params TEXT NOT NULL,
returns TEXT NOT NULL
);

CREATE UNIQUE INDEX ffimethods_pathname ON ffimethods(interface_id,pathname);
2 changes: 1 addition & 1 deletion db/migrations/sqlite/000051_create_ffi_events_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE TABLE ffievents (
name VARCHAR(1024) NOT NULL,
pathname VARCHAR(1024) NOT NULL,
description TEXT NOT NULL,
params BYTEA NOT NULL
params TEXT NOT NULL
);

CREATE UNIQUE INDEX ffievents_pathname ON ffievents(interface_id,pathname);
4 changes: 2 additions & 2 deletions db/migrations/sqlite/000052_create_contractapis_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ CREATE TABLE contractapis (
seq INTEGER PRIMARY KEY AUTOINCREMENT,
id UUID NOT NULL,
interface_id UUID NOT NULL,
ledger BYTEA,
location BYTEA,
ledger TEXT,
location TEXT,
name VARCHAR(64) NOT NULL,
namespace VARCHAR(64) NOT NULL,
message_id UUID NOT NULL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ CREATE TABLE contractsubscriptions (
seq INTEGER PRIMARY KEY AUTOINCREMENT,
id UUID NOT NULL,
interface_id UUID NULL,
event BYTEA NOT NULL,
event TEXT NOT NULL,
namespace VARCHAR(64) NOT NULL,
name VARCHAR(64) NULL,
protocol_id VARCHAR(1024) NOT NULL,
location BYTEA NOT NULL,
location TEXT NOT NULL,
created BIGINT NOT NULL
);

Expand Down
10 changes: 5 additions & 5 deletions db/migrations/sqlite/000054_create_contractevents_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ CREATE TABLE contractevents (
namespace VARCHAR(64) NOT NULL,
name VARCHAR(1024) NOT NULL,
subscription_id UUID NOT NULL,
outputs BYTEA,
info BYTEA,
outputs TEXT,
info TEXT,
timestamp BIGINT NOT NULL
);

CREATE UNIQUE INDEX contractevents_name ON contractevents(namespace,name);
CREATE UNIQUE INDEX contractevents_timestamp ON contractevents(timestamp);
CREATE UNIQUE INDEX contractevents_subscription_id ON contractevents(subscription_id);
CREATE INDEX contractevents_name ON contractevents(namespace,name);
CREATE INDEX contractevents_timestamp ON contractevents(timestamp);
CREATE INDEX contractevents_subscription_id ON contractevents(subscription_id);
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ DROP INDEX data_blob_size;
ALTER TABLE blobs DROP COLUMN "size";
ALTER TABLE data DROP COLUMN "blob_name";
ALTER TABLE data DROP COLUMN "blob_size";
ALTER TABLE data DROP COLUMN "value_size";
4 changes: 4 additions & 0 deletions db/migrations/sqlite/000055_add_blobs_size_and_name.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ ALTER TABLE blobs ADD size BIGINT;

ALTER TABLE data ADD blob_name VARCHAR(1024);
ALTER TABLE data ADD blob_size BIGINT;
ALTER TABLE data ADD COLUMN value_size BIGINT;

UPDATE blobs SET size = 0;
UPDATE data SET blob_size = 0, blob_name = '', value_size = 0;

CREATE INDEX data_blob_name ON data(blob_name);
CREATE INDEX data_blob_size ON data(blob_size);
Loading