-
Notifications
You must be signed in to change notification settings - Fork 573
Refactor sqlthread #1760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Refactor sqlthread #1760
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f6ffd64
refactor sqlthread and add test cases
cis-muzahid a00c898
rebase and merge conflicts
cis-muzahid 78f90ef
fixed code quality stuff
cis-muzahid 1000a2d
open for py3 porting
cis-muzahid 3276af8
update import
cis-muzahid 3d29a05
add property setter for upgrade sqlversion
cis-muzahid edf2b65
fixed version till 8
cis-muzahid 26979b8
fixed
cis-muzahid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- -- | ||
-- -- Alter table `addressbook` | ||
-- -- | ||
|
||
ALTER TABLE addressbook RENAME TO old_addressbook; | ||
|
||
|
||
-- -- | ||
-- -- Table structure for table `addressbook` | ||
-- -- | ||
|
||
CREATE TABLE `addressbook` ( | ||
`label` text NOT NULL, | ||
`address` text NOT NULL, | ||
UNIQUE(address) ON CONFLICT IGNORE | ||
) ; | ||
|
||
-- -- | ||
-- -- Table Query for `pubkeys_backup` | ||
-- -- | ||
|
||
INSERT INTO addressbook SELECT label, address FROM old_addressbook; | ||
|
||
|
||
-- -- | ||
-- -- Drop table `old_addressbook` | ||
-- -- | ||
|
||
DROP TABLE old_addressbook; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- | ||
-- Temp Table structure for table `inventory_backup` | ||
-- | ||
|
||
CREATE TEMP TABLE `inventory_backup` ( | ||
`hash` blob NOT NULL, | ||
`objecttype` text DEFAULT NULL, | ||
`streamnumber` int NOT NULL, | ||
`receivedtime` int NOT NULL, | ||
`payload` blob DEFAULT NULL, | ||
-- `integer` integer NOT NULL, | ||
-- `tag` blob DEFAULT NULL, | ||
UNIQUE(hash) ON CONFLICT REPLACE | ||
) ; | ||
|
||
-- | ||
-- Dumping data for table `inventory_backup` | ||
-- | ||
|
||
INSERT INTO `inventory_backup` SELECT hash, objecttype, streamnumber, payload, receivedtime FROM inventory; | ||
|
||
|
||
-- | ||
-- Drop table `inventory` | ||
-- | ||
|
||
DROP TABLE inventory; | ||
|
||
|
||
-- | ||
-- Table structure for table `inventory` | ||
-- | ||
|
||
|
||
CREATE TABLE `inventory` ( | ||
`hash` blob NOT NULL, | ||
`objecttype` text DEFAULT NULL, | ||
`streamnumber` int NOT NULL, | ||
`receivedtime` int NOT NULL, | ||
`payload` blob DEFAULT NULL, | ||
UNIQUE(hash) ON CONFLICT REPLACE | ||
) ; | ||
|
||
|
||
-- | ||
-- Dumping data for table `inventory` | ||
-- | ||
|
||
INSERT INTO inventory SELECT hash, objecttype, streamnumber, payload, receivedtime FROM inventory_backup; | ||
|
||
-- | ||
-- Drop data for table `inventory_backup` | ||
-- | ||
|
||
DROP TABLE inventory_backup; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
-- | ||
-- Alter table `inventory` | ||
-- | ||
|
||
ALTER TABLE inventory ADD tag blob DEFAULT ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | ||
-- Drop Table `pubkeys` | ||
-- | ||
|
||
DROP TABLE pubkeys; | ||
|
||
|
||
-- | ||
-- Table structure for table `pubkeys` | ||
-- | ||
|
||
|
||
CREATE TABLE `pubkeys` ( | ||
`hash` blob NOT NULL, | ||
`addressversion` int DEFAULT NULL, | ||
`transmitdata` blob NOT NULL, | ||
`time` int NOT NULL, | ||
`usedpersonally` text DEFAULT NULL, | ||
UNIQUE(hash, addressversion) ON CONFLICT REPLACE | ||
) ; | ||
|
||
-- | ||
-- Drop from Table `pubkeys` | ||
-- | ||
|
||
DELETE FROM inventory WHERE objecttype = 'pubkey'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- | ||
-- Drop Table `knownnodes` | ||
-- | ||
|
||
DROP TABLE knownnodes; | ||
|
||
|
||
-- | ||
-- Table structure for table `objectprocessorqueue` | ||
-- | ||
|
||
|
||
CREATE TABLE `objectprocessorqueue` ( | ||
`objecttype` text DEFAULT NULL, | ||
`data` blob DEFAULT NULL, | ||
UNIQUE(objecttype, data) ON CONFLICT REPLACE | ||
) ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- -- | ||
-- -- Drop table `inventory` | ||
-- -- | ||
|
||
DROP TABLE inventory; | ||
|
||
|
||
-- -- | ||
-- -- Table structure for table `inventory` | ||
-- -- | ||
|
||
|
||
CREATE TABLE `inventory` ( | ||
`hash` blob NOT NULL, | ||
`objecttype` int DEFAULT NULL, | ||
`streamnumber` int NOT NULL, | ||
`payload` blob NOT NULL, | ||
`expirestime` integer DEFAULT NULL, | ||
`tag` blob DEFAULT NULL, | ||
UNIQUE(hash) ON CONFLICT REPLACE | ||
) ; | ||
|
||
-- -- | ||
-- -- Drop table `inventory` | ||
-- -- | ||
|
||
DROP TABLE objectprocessorqueue; | ||
|
||
|
||
-- -- | ||
-- -- Table structure for table `objectprocessorqueue` | ||
-- -- | ||
|
||
|
||
CREATE TABLE `objectprocessorqueue` ( | ||
`objecttype` int DEFAULT NULL, | ||
`data` blob DEFAULT NULL, | ||
UNIQUE(objecttype, data) ON CONFLICT REPLACE | ||
) ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- -- | ||
-- -- Drop table `inventory` | ||
-- -- | ||
|
||
DELETE FROM inventory WHERE objecttype = 1; | ||
|
||
-- -- | ||
-- -- Drop table `pubkeys` | ||
-- -- | ||
|
||
DELETE FROM pubkeys; | ||
|
||
|
||
-- -- | ||
-- -- Update table `pubkeys` | ||
-- -- | ||
|
||
UPDATE sent SET status='msgqueued' WHERE status='doingmsgpow' or status='badkey'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- -- | ||
-- -- Alter table `inbox` | ||
-- -- | ||
|
||
ALTER TABLE inbox ADD sighash blob DEFAULT ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
-- -- | ||
-- -- Table structure for table `sent_backup` | ||
-- -- | ||
|
||
|
||
CREATE TEMPORARY TABLE `sent_backup` ( | ||
`msgid` blob DEFAULT NULL, | ||
`toaddress` text DEFAULT NULL, | ||
`toripe` blob DEFAULT NULL, | ||
`fromaddress` text DEFAULT NULL, | ||
`subject` text DEFAULT NULL, | ||
`message` text DEFAULT NULL, | ||
`ackdata` blob DEFAULT NULL, | ||
`lastactiontime` integer DEFAULT NULL, | ||
`status` text DEFAULT NULL, | ||
`retrynumber` integer DEFAULT NULL, | ||
`folder` text DEFAULT NULL, | ||
`encodingtype` int DEFAULT NULL | ||
) ; | ||
|
||
|
||
-- -- | ||
-- -- Dumping data for table `sent_backup` | ||
-- -- | ||
|
||
INSERT INTO sent_backup SELECT msgid, toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status, 0, folder, encodingtype FROM sent; | ||
|
||
|
||
-- -- | ||
-- -- Drope table `sent` | ||
-- -- | ||
|
||
DROP TABLE sent; | ||
|
||
|
||
-- -- | ||
-- -- Table structure for table `sent_backup` | ||
-- -- | ||
|
||
|
||
CREATE TABLE `sent` ( | ||
`msgid` blob DEFAULT NULL, | ||
`toaddress` text DEFAULT NULL, | ||
`toripe` blob DEFAULT NULL, | ||
`fromaddress` text DEFAULT NULL, | ||
`subject` text DEFAULT NULL, | ||
`message` text DEFAULT NULL, | ||
`ackdata` blob DEFAULT NULL, | ||
`senttime` integer DEFAULT NULL, | ||
`lastactiontime` integer DEFAULT NULL, | ||
`sleeptill` int DEFAULT NULL, | ||
`status` text DEFAULT NULL, | ||
`retrynumber` integer DEFAULT NULL, | ||
`folder` text DEFAULT NULL, | ||
`encodingtype` int DEFAULT NULL, | ||
`ttl` int DEFAULT NULL | ||
) ; | ||
|
||
|
||
-- -- | ||
-- -- Dumping data for table `sent` | ||
-- -- | ||
|
||
|
||
INSERT INTO sent SELECT msgid, toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, lastactiontime, 0, status, 0, folder, encodingtype, 216000 FROM sent_backup; | ||
|
||
|
||
--UPDATE pubkeys SET address= (select enaddr(?, ?, ?)", (addressVersion, 1, addressHash)) WHERE hash=? | ||
|
||
-- -- | ||
-- -- Drop table `sent` | ||
-- -- | ||
|
||
DROP TABLE sent_backup; | ||
|
||
-- -- | ||
-- -- Update Table `pubkeys` | ||
-- -- We're going to have to calculate the address for each row in the pubkeys | ||
-- -- table. Then we can take out the hash field. | ||
-- -- | ||
|
||
ALTER TABLE pubkeys ADD address text DEFAULT '' ; | ||
|
||
-- -- | ||
-- -- Update Table `pubkeys` | ||
-- -- replica for loop to update hashed address | ||
-- -- | ||
|
||
UPDATE pubkeys SET address=(enaddr(pubkeys.addressversion, 1, hash)); | ||
|
||
-- -- | ||
-- -- Table structure for table `pubkeys_backup` | ||
-- -- | ||
|
||
CREATE TEMPORARY TABLE `pubkeys_backup` ( | ||
`address` text DEFAULT NULL, | ||
`addressversion` int DEFAULT NULL, | ||
`transmitdata` blob DEFAULT NULL, | ||
`time` int DEFAULT NULL, | ||
`usedpersonally` text DEFAULT NULL, | ||
UNIQUE(address) ON CONFLICT REPLACE | ||
) ; | ||
|
||
|
||
-- -- | ||
-- -- Dumping data for table `pubkeys_backup` | ||
-- -- | ||
|
||
INSERT INTO pubkeys_backup SELECT address, addressversion, transmitdata, time, usedpersonally FROM pubkeys; | ||
|
||
|
||
-- -- | ||
-- -- Drope table `pubkeys` | ||
-- -- | ||
|
||
DROP TABLE pubkeys; | ||
|
||
-- -- | ||
-- -- Table structure for table `pubkeys` | ||
-- -- | ||
|
||
CREATE TABLE `pubkeys` ( | ||
`address` text DEFAULT NULL, | ||
`addressversion` int DEFAULT NULL, | ||
`transmitdata` blob DEFAULT NULL, | ||
`time` int DEFAULT NULL, | ||
`usedpersonally` text DEFAULT NULL, | ||
UNIQUE(address) ON CONFLICT REPLACE | ||
) ; | ||
|
||
-- -- | ||
-- -- Dumping data for table `pubkeys` | ||
-- -- | ||
|
||
INSERT INTO pubkeys SELECT address, addressversion, transmitdata, time, usedpersonally FROM pubkeys_backup; | ||
|
||
-- -- | ||
-- -- Dropping table `pubkeys_backup` | ||
-- -- | ||
|
||
DROP TABLE pubkeys_backup; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a code quality only change? Then it should go into a separate PR.