3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 18:55:52 +00:00

Database (stores MySQL/Postgres/H2) column names/objects lower case consistency fix.

This commit is contained in:
Kalpesh Parmar 2015-08-01 16:55:19 +01:00 committed by Andreas Schildbach
parent 98b54d78c1
commit 7a02d2e598
4 changed files with 30 additions and 30 deletions

View File

@ -103,27 +103,27 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
private static final String INSERT_SETTINGS_SQL = "INSERT INTO settings(name, value) VALUES(?, ?)"; private static final String INSERT_SETTINGS_SQL = "INSERT INTO settings(name, value) VALUES(?, ?)";
private static final String UPDATE_SETTINGS_SQL = "UPDATE settings SET value = ? WHERE name = ?"; private static final String UPDATE_SETTINGS_SQL = "UPDATE settings SET value = ? WHERE name = ?";
private static final String SELECT_HEADERS_SQL = "SELECT chainWork, height, header, wasUndoable FROM headers WHERE hash = ?"; private static final String SELECT_HEADERS_SQL = "SELECT chainwork, height, header, wasundoable FROM headers WHERE hash = ?";
private static final String INSERT_HEADERS_SQL = "INSERT INTO headers(hash, chainWork, height, header, wasUndoable) VALUES(?, ?, ?, ?, ?)"; private static final String INSERT_HEADERS_SQL = "INSERT INTO headers(hash, chainwork, height, header, wasundoable) VALUES(?, ?, ?, ?, ?)";
private static final String UPDATE_HEADERS_SQL = "UPDATE headers SET wasUndoable=? WHERE hash=?"; private static final String UPDATE_HEADERS_SQL = "UPDATE headers SET wasundoable=? WHERE hash=?";
private static final String SELECT_UNDOABLEBLOCKS_SQL = "SELECT txOutChanges, transactions FROM undoableBlocks WHERE hash = ?"; private static final String SELECT_UNDOABLEBLOCKS_SQL = "SELECT txoutchanges, transactions FROM undoableblocks WHERE hash = ?";
private static final String INSERT_UNDOABLEBLOCKS_SQL = "INSERT INTO undoableBlocks(hash, height, txOutChanges, transactions) VALUES(?, ?, ?, ?)"; private static final String INSERT_UNDOABLEBLOCKS_SQL = "INSERT INTO undoableblocks(hash, height, txoutchanges, transactions) VALUES(?, ?, ?, ?)";
private static final String UPDATE_UNDOABLEBLOCKS_SQL = "UPDATE undoableBlocks SET txOutChanges=?, transactions=? WHERE hash = ?"; private static final String UPDATE_UNDOABLEBLOCKS_SQL = "UPDATE undoableblocks SET txoutchanges=?, transactions=? WHERE hash = ?";
private static final String DELETE_UNDOABLEBLOCKS_SQL = "DELETE FROM undoableBlocks WHERE height <= ?"; private static final String DELETE_UNDOABLEBLOCKS_SQL = "DELETE FROM undoableblocks WHERE height <= ?";
private static final String SELECT_OPENOUTPUTS_SQL = "SELECT height, value, scriptBytes, coinbase, toaddress, addresstargetable FROM openOutputs WHERE hash = ? AND index = ?"; private static final String SELECT_OPENOUTPUTS_SQL = "SELECT height, value, scriptbytes, coinbase, toaddress, addresstargetable FROM openoutputs WHERE hash = ? AND index = ?";
private static final String SELECT_OPENOUTPUTS_COUNT_SQL = "SELECT COUNT(*) FROM openOutputs WHERE hash = ?"; private static final String SELECT_OPENOUTPUTS_COUNT_SQL = "SELECT COUNT(*) FROM openoutputs WHERE hash = ?";
private static final String INSERT_OPENOUTPUTS_SQL = "INSERT INTO openOutputs (hash, index, height, value, scriptBytes, toAddress, addressTargetable, coinbase) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; private static final String INSERT_OPENOUTPUTS_SQL = "INSERT INTO openoutputs (hash, index, height, value, scriptbytes, toaddress, addresstargetable, coinbase) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
private static final String DELETE_OPENOUTPUTS_SQL = "DELETE FROM openOutputs WHERE hash = ? AND index = ?"; private static final String DELETE_OPENOUTPUTS_SQL = "DELETE FROM openoutputs WHERE hash = ? AND index = ?";
// Dump table SQL (this is just for data sizing statistics). // Dump table SQL (this is just for data sizing statistics).
private static final String SELECT_DUMP_SETTINGS_SQL = "SELECT name, value FROM settings"; private static final String SELECT_DUMP_SETTINGS_SQL = "SELECT name, value FROM settings";
private static final String SELECT_DUMP_HEADERS_SQL = "SELECT chainWork, header FROM headers"; private static final String SELECT_DUMP_HEADERS_SQL = "SELECT chainwork, header FROM headers";
private static final String SELECT_DUMP_UNDOABLEBLOCKS_SQL = "SELECT txOutChanges, transactions FROM undoableBlocks"; private static final String SELECT_DUMP_UNDOABLEBLOCKS_SQL = "SELECT txoutchanges, transactions FROM undoableblocks";
private static final String SELECT_DUMP_OPENOUTPUTS_SQL = "SELECT value, scriptBytes FROM openOutputs"; private static final String SELECT_DUMP_OPENOUTPUTS_SQL = "SELECT value, scriptbytes FROM openoutputs";
private static final String SELECT_TRANSACTION_OUTPUTS_SQL = "SELECT hash, value, scriptBytes, height, index, coinbase, toaddress, addresstargetable FROM openOutputs where toaddress = ?"; private static final String SELECT_TRANSACTION_OUTPUTS_SQL = "SELECT hash, value, scriptbytes, height, index, coinbase, toaddress, addresstargetable FROM openoutputs where toaddress = ?";
// Select the balance of an address SQL. // Select the balance of an address SQL.
private static final String SELECT_BALANCE_SQL = "select sum(value) from openoutputs where toaddress = ?"; private static final String SELECT_BALANCE_SQL = "select sum(value) from openoutputs where toaddress = ?";
@ -132,7 +132,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
private static final String SELECT_CHECK_TABLES_EXIST_SQL = "SELECT * FROM settings WHERE 1 = 2"; private static final String SELECT_CHECK_TABLES_EXIST_SQL = "SELECT * FROM settings WHERE 1 = 2";
// Compatibility SQL. // Compatibility SQL.
private static final String SELECT_COMPATIBILITY_COINBASE_SQL = "SELECT coinbase FROM openOutputs WHERE 1 = 2"; private static final String SELECT_COMPATIBILITY_COINBASE_SQL = "SELECT coinbase FROM openoutputs WHERE 1 = 2";
protected Sha256Hash chainHeadHash; protected Sha256Hash chainHeadHash;
protected StoredBlock chainHeadBlock; protected StoredBlock chainHeadBlock;

View File

@ -46,25 +46,25 @@ public class H2FullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
private static final String CREATE_HEADERS_TABLE = "CREATE TABLE headers ( " private static final String CREATE_HEADERS_TABLE = "CREATE TABLE headers ( "
+ "hash BINARY(28) NOT NULL CONSTRAINT headers_pk PRIMARY KEY," + "hash BINARY(28) NOT NULL CONSTRAINT headers_pk PRIMARY KEY,"
+ "chainWork BLOB NOT NULL," + "chainwork BLOB NOT NULL,"
+ "height INT NOT NULL," + "height INT NOT NULL,"
+ "header BLOB NOT NULL," + "header BLOB NOT NULL,"
+ "wasUndoable BOOL NOT NULL" + "wasundoable BOOL NOT NULL"
+ ")"; + ")";
private static final String CREATE_UNDOABLE_TABLE = "CREATE TABLE undoableBlocks ( " private static final String CREATE_UNDOABLE_TABLE = "CREATE TABLE undoableblocks ( "
+ "hash BINARY(28) NOT NULL CONSTRAINT undoableBlocks_pk PRIMARY KEY," + "hash BINARY(28) NOT NULL CONSTRAINT undoableblocks_pk PRIMARY KEY,"
+ "height INT NOT NULL," + "height INT NOT NULL,"
+ "txOutChanges BLOB," + "txoutchanges BLOB,"
+ "transactions BLOB" + "transactions BLOB"
+ ")"; + ")";
private static final String CREATE_OPEN_OUTPUT_TABLE = "CREATE TABLE openOutputs (" private static final String CREATE_OPEN_OUTPUT_TABLE = "CREATE TABLE openoutputs ("
+ "hash BINARY(32) NOT NULL," + "hash BINARY(32) NOT NULL,"
+ "index INT NOT NULL," + "index INT NOT NULL,"
+ "height INT NOT NULL," + "height INT NOT NULL,"
+ "value BIGINT NOT NULL," + "value BIGINT NOT NULL,"
+ "scriptBytes BLOB NOT NULL," + "scriptbytes BLOB NOT NULL,"
+ "toaddress VARCHAR(35)," + "toaddress VARCHAR(35),"
+ "addresstargetable TINYINT," + "addresstargetable TINYINT,"
+ "coinbase BOOLEAN," + "coinbase BOOLEAN,"
@ -76,7 +76,7 @@ public class H2FullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
private static final String CREATE_OUTPUTS_TOADDRESS_INDEX = "CREATE INDEX openoutputs_toaddress_idx ON openoutputs (toaddress)"; private static final String CREATE_OUTPUTS_TOADDRESS_INDEX = "CREATE INDEX openoutputs_toaddress_idx ON openoutputs (toaddress)";
private static final String CREATE_OUTPUTS_ADDRESSTARGETABLE_INDEX = "CREATE INDEX openoutputs_addresstargetable_idx ON openoutputs (addresstargetable)"; private static final String CREATE_OUTPUTS_ADDRESSTARGETABLE_INDEX = "CREATE INDEX openoutputs_addresstargetable_idx ON openoutputs (addresstargetable)";
private static final String CREATE_OUTPUTS_HASH_INDEX = "CREATE INDEX openoutputs_hash_idx ON openoutputs (hash)"; private static final String CREATE_OUTPUTS_HASH_INDEX = "CREATE INDEX openoutputs_hash_idx ON openoutputs (hash)";
private static final String CREATE_UNDOABLE_TABLE_INDEX = "CREATE INDEX undoableblocks_height_idx ON undoableBlocks (height)"; private static final String CREATE_UNDOABLE_TABLE_INDEX = "CREATE INDEX undoableblocks_height_idx ON undoableblocks (height)";
/** /**
* Creates a new H2FullPrunedBlockStore * Creates a new H2FullPrunedBlockStore

View File

@ -72,14 +72,14 @@ public class MySQLFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
private static final String CREATE_OUTPUTS_TOADDRESS_INDEX = "CREATE INDEX openoutputs_toaddress_idx ON openoutputs (toaddress) USING btree"; private static final String CREATE_OUTPUTS_TOADDRESS_INDEX = "CREATE INDEX openoutputs_toaddress_idx ON openoutputs (toaddress) USING btree";
private static final String CREATE_OUTPUTS_ADDRESSTARGETABLE_INDEX = "CREATE INDEX openoutputs_addresstargetable_idx ON openoutputs (addresstargetable) USING btree"; private static final String CREATE_OUTPUTS_ADDRESSTARGETABLE_INDEX = "CREATE INDEX openoutputs_addresstargetable_idx ON openoutputs (addresstargetable) USING btree";
private static final String CREATE_OUTPUTS_HASH_INDEX = "CREATE INDEX openoutputs_hash_idx ON openoutputs (hash) USING btree"; private static final String CREATE_OUTPUTS_HASH_INDEX = "CREATE INDEX openoutputs_hash_idx ON openoutputs (hash) USING btree";
private static final String CREATE_UNDOABLE_TABLE_INDEX = "CREATE INDEX undoableblocks_height_idx ON undoableBlocks (height) USING btree"; private static final String CREATE_UNDOABLE_TABLE_INDEX = "CREATE INDEX undoableblocks_height_idx ON undoableblocks (height) USING btree";
// SQL involving index column (table openOutputs) overridden as it is a reserved word and must be back ticked in MySQL. // SQL involving index column (table openOutputs) overridden as it is a reserved word and must be back ticked in MySQL.
private static final String SELECT_OPENOUTPUTS_SQL = "SELECT height, value, scriptBytes, coinbase, toaddress, addresstargetable FROM openOutputs WHERE hash = ? AND `index` = ?"; private static final String SELECT_OPENOUTPUTS_SQL = "SELECT height, value, scriptbytes, coinbase, toaddress, addresstargetable FROM openoutputs WHERE hash = ? AND `index` = ?";
private static final String INSERT_OPENOUTPUTS_SQL = "INSERT INTO openOutputs (hash, `index`, height, value, scriptBytes, toAddress, addressTargetable, coinbase) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; private static final String INSERT_OPENOUTPUTS_SQL = "INSERT INTO openoutputs (hash, `index`, height, value, scriptbytes, toaddress, addresstargetable, coinbase) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
private static final String DELETE_OPENOUTPUTS_SQL = "DELETE FROM openOutputs WHERE hash = ? AND `index`= ?"; private static final String DELETE_OPENOUTPUTS_SQL = "DELETE FROM openoutputs WHERE hash = ? AND `index`= ?";
private static final String SELECT_TRANSACTION_OUTPUTS_SQL = "SELECT hash, value, scriptBytes, height, `index`, coinbase, toaddress, addresstargetable FROM openOutputs where toaddress = ?"; private static final String SELECT_TRANSACTION_OUTPUTS_SQL = "SELECT hash, value, scriptbytes, height, `index`, coinbase, toaddress, addresstargetable FROM openoutputs where toaddress = ?";
/** /**
* Creates a new MySQLFullPrunedBlockStore. * Creates a new MySQLFullPrunedBlockStore.

View File

@ -86,7 +86,7 @@ public class PostgresFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
private static final String CREATE_OUTPUTS_HASH_INDEX = "CREATE INDEX openoutputs_hash_idx ON openoutputs USING btree (hash)"; private static final String CREATE_OUTPUTS_HASH_INDEX = "CREATE INDEX openoutputs_hash_idx ON openoutputs USING btree (hash)";
private static final String CREATE_UNDOABLE_TABLE_INDEX = "CREATE INDEX undoableblocks_height_idx ON undoableBlocks USING btree (height)"; private static final String CREATE_UNDOABLE_TABLE_INDEX = "CREATE INDEX undoableblocks_height_idx ON undoableBlocks USING btree (height)";
private static final String SELECT_UNDOABLEBLOCKS_EXISTS_SQL = "select 1 from undoableBlocks where hash = ?"; private static final String SELECT_UNDOABLEBLOCKS_EXISTS_SQL = "select 1 from undoableblocks where hash = ?";
/** /**
* Creates a new PostgresFullPrunedBlockStore. * Creates a new PostgresFullPrunedBlockStore.