add IF NOT EXISTS for indices
This commit is contained in:
parent
f4f86d2b01
commit
232606fb57
@ -115,7 +115,7 @@ CREATE TABLE IF NOT EXISTS auditor_reserves
|
|||||||
,auditor_reserves_rowid BIGSERIAL UNIQUE
|
,auditor_reserves_rowid BIGSERIAL UNIQUE
|
||||||
,origin_account TEXT
|
,origin_account TEXT
|
||||||
);
|
);
|
||||||
CREATE INDEX auditor_reserves_by_reserve_pub
|
CREATE INDEX IF NOT EXISTS auditor_reserves_by_reserve_pub
|
||||||
ON auditor_reserves
|
ON auditor_reserves
|
||||||
(reserve_pub);
|
(reserve_pub);
|
||||||
-- Table with the sum of the balances of all customer reserves
|
-- Table with the sum of the balances of all customer reserves
|
||||||
@ -203,7 +203,7 @@ CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary
|
|||||||
,reserve_profits_val INT8 NOT NULL
|
,reserve_profits_val INT8 NOT NULL
|
||||||
,reserve_profits_frac INT4 NOT NULL
|
,reserve_profits_frac INT4 NOT NULL
|
||||||
);
|
);
|
||||||
CREATE INDEX auditor_historic_reserve_summary_by_master_pub_start_date
|
CREATE INDEX IF NOT EXISTS auditor_historic_reserve_summary_by_master_pub_start_date
|
||||||
ON auditor_historic_reserve_summary
|
ON auditor_historic_reserve_summary
|
||||||
(master_pub
|
(master_pub
|
||||||
,start_date);
|
,start_date);
|
||||||
|
@ -582,6 +582,7 @@ shutdown_task (void *cls)
|
|||||||
ctc = NULL;
|
ctc = NULL;
|
||||||
}
|
}
|
||||||
TALER_EXCHANGEDB_plugin_unload (db_plugin);
|
TALER_EXCHANGEDB_plugin_unload (db_plugin);
|
||||||
|
db_plugin = NULL;
|
||||||
|
|
||||||
{
|
{
|
||||||
struct WireAccount *wa;
|
struct WireAccount *wa;
|
||||||
@ -670,6 +671,7 @@ parse_wirewatch_config ()
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Failed to initialize DB tables\n");
|
"Failed to initialize DB tables\n");
|
||||||
TALER_EXCHANGEDB_plugin_unload (db_plugin);
|
TALER_EXCHANGEDB_plugin_unload (db_plugin);
|
||||||
|
db_plugin = NULL;
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
TALER_EXCHANGEDB_find_accounts (cfg,
|
TALER_EXCHANGEDB_find_accounts (cfg,
|
||||||
@ -680,6 +682,7 @@ parse_wirewatch_config ()
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"No wire accounts configured for debit!\n");
|
"No wire accounts configured for debit!\n");
|
||||||
TALER_EXCHANGEDB_plugin_unload (db_plugin);
|
TALER_EXCHANGEDB_plugin_unload (db_plugin);
|
||||||
|
db_plugin = NULL;
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
@ -1179,10 +1182,7 @@ expired_reserve_cb (void *cls,
|
|||||||
/* Reserve balance was almost zero OR soft error */
|
/* Reserve balance was almost zero OR soft error */
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Reserve was virtually empty, moving on\n");
|
"Reserve was virtually empty, moving on\n");
|
||||||
(void) commit_or_warn (ctc->session);
|
(void) commit_or_warn (session);
|
||||||
GNUNET_free (ctc->method);
|
|
||||||
GNUNET_free (ctc);
|
|
||||||
ctc = NULL;
|
|
||||||
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
||||||
NULL);
|
NULL);
|
||||||
return qs;
|
return qs;
|
||||||
|
@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS denominations
|
|||||||
,fee_refund_val INT8 NOT NULL
|
,fee_refund_val INT8 NOT NULL
|
||||||
,fee_refund_frac INT4 NOT NULL
|
,fee_refund_frac INT4 NOT NULL
|
||||||
);
|
);
|
||||||
CREATE INDEX denominations_expire_legal_index
|
CREATE INDEX IF NOT EXISTS denominations_expire_legal_index
|
||||||
ON denominations
|
ON denominations
|
||||||
(expire_legal);
|
(expire_legal);
|
||||||
|
|
||||||
@ -65,18 +65,18 @@ CREATE TABLE IF NOT EXISTS reserves
|
|||||||
,gc_date INT8 NOT NULL
|
,gc_date INT8 NOT NULL
|
||||||
);
|
);
|
||||||
-- index on reserves table (TODO: useless due to primary key!?)
|
-- index on reserves table (TODO: useless due to primary key!?)
|
||||||
CREATE INDEX reserves_reserve_pub_index
|
CREATE INDEX IF NOT EXISTS reserves_reserve_pub_index
|
||||||
ON reserves
|
ON reserves
|
||||||
(reserve_pub);
|
(reserve_pub);
|
||||||
-- index for get_expired_reserves
|
-- index for get_expired_reserves
|
||||||
CREATE INDEX reserves_expiration_index
|
CREATE INDEX IF NOT EXISTS reserves_expiration_index
|
||||||
ON reserves
|
ON reserves
|
||||||
(expiration_date
|
(expiration_date
|
||||||
,current_balance_val
|
,current_balance_val
|
||||||
,current_balance_frac
|
,current_balance_frac
|
||||||
);
|
);
|
||||||
-- index for reserve GC operations
|
-- index for reserve GC operations
|
||||||
CREATE INDEX reserves_gc_index
|
CREATE INDEX IF NOT EXISTS reserves_gc_index
|
||||||
ON reserves
|
ON reserves
|
||||||
(gc_date);
|
(gc_date);
|
||||||
-- reserves_in table collects the transactions which transfer funds
|
-- reserves_in table collects the transactions which transfer funds
|
||||||
@ -94,12 +94,12 @@ CREATE TABLE IF NOT EXISTS reserves_in
|
|||||||
,PRIMARY KEY (reserve_pub, wire_reference)
|
,PRIMARY KEY (reserve_pub, wire_reference)
|
||||||
);
|
);
|
||||||
-- Create indices on reserves_in
|
-- Create indices on reserves_in
|
||||||
CREATE INDEX reserves_in_execution_index
|
CREATE INDEX IF NOT EXISTS reserves_in_execution_index
|
||||||
ON reserves_in
|
ON reserves_in
|
||||||
(exchange_account_section
|
(exchange_account_section
|
||||||
,execution_date
|
,execution_date
|
||||||
);
|
);
|
||||||
CREATE INDEX reserves_in_exchange_account_serial
|
CREATE INDEX IF NOT EXISTS reserves_in_exchange_account_serial
|
||||||
ON reserves_in
|
ON reserves_in
|
||||||
(exchange_account_section,
|
(exchange_account_section,
|
||||||
reserve_in_serial_id DESC
|
reserve_in_serial_id DESC
|
||||||
@ -116,7 +116,7 @@ CREATE TABLE IF NOT EXISTS reserves_close
|
|||||||
,amount_frac INT4 NOT NULL
|
,amount_frac INT4 NOT NULL
|
||||||
,closing_fee_val INT8 NOT NULL
|
,closing_fee_val INT8 NOT NULL
|
||||||
,closing_fee_frac INT4 NOT NULL);
|
,closing_fee_frac INT4 NOT NULL);
|
||||||
CREATE INDEX reserves_close_by_reserve
|
CREATE INDEX IF NOT EXISTS reserves_close_by_reserve
|
||||||
ON reserves_close
|
ON reserves_close
|
||||||
(reserve_pub);
|
(reserve_pub);
|
||||||
-- Table with the withdraw operations that have been performed on a reserve.
|
-- Table with the withdraw operations that have been performed on a reserve.
|
||||||
@ -137,13 +137,13 @@ CREATE TABLE IF NOT EXISTS reserves_out
|
|||||||
,amount_with_fee_frac INT4 NOT NULL
|
,amount_with_fee_frac INT4 NOT NULL
|
||||||
);
|
);
|
||||||
-- Index blindcoins(reserve_pub) for get_reserves_out statement
|
-- Index blindcoins(reserve_pub) for get_reserves_out statement
|
||||||
CREATE INDEX reserves_out_reserve_pub_index
|
CREATE INDEX IF NOT EXISTS reserves_out_reserve_pub_index
|
||||||
ON reserves_out
|
ON reserves_out
|
||||||
(reserve_pub);
|
(reserve_pub);
|
||||||
CREATE INDEX reserves_out_execution_date
|
CREATE INDEX IF NOT EXISTS reserves_out_execution_date
|
||||||
ON reserves_out
|
ON reserves_out
|
||||||
(execution_date);
|
(execution_date);
|
||||||
CREATE INDEX reserves_out_for_get_withdraw_info
|
CREATE INDEX IF NOT EXISTS reserves_out_for_get_withdraw_info
|
||||||
ON reserves_out
|
ON reserves_out
|
||||||
(denom_pub_hash
|
(denom_pub_hash
|
||||||
,h_blind_ev
|
,h_blind_ev
|
||||||
@ -155,7 +155,7 @@ CREATE TABLE IF NOT EXISTS known_coins
|
|||||||
,denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE
|
,denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE
|
||||||
,denom_sig BYTEA NOT NULL
|
,denom_sig BYTEA NOT NULL
|
||||||
);
|
);
|
||||||
CREATE INDEX known_coins_by_denomination
|
CREATE INDEX IF NOT EXISTS known_coins_by_denomination
|
||||||
ON known_coins
|
ON known_coins
|
||||||
(denom_pub_hash);
|
(denom_pub_hash);
|
||||||
-- Table with the commitments made when melting a coin. */
|
-- Table with the commitments made when melting a coin. */
|
||||||
@ -168,7 +168,7 @@ CREATE TABLE IF NOT EXISTS refresh_commitments
|
|||||||
,amount_with_fee_frac INT4 NOT NULL
|
,amount_with_fee_frac INT4 NOT NULL
|
||||||
,noreveal_index INT4 NOT NULL
|
,noreveal_index INT4 NOT NULL
|
||||||
);
|
);
|
||||||
CREATE INDEX refresh_commitments_old_coin_pub_index
|
CREATE INDEX IF NOT EXISTS refresh_commitments_old_coin_pub_index
|
||||||
ON refresh_commitments
|
ON refresh_commitments
|
||||||
(old_coin_pub);
|
(old_coin_pub);
|
||||||
-- Table with the revelations about the new coins that are to be created
|
-- Table with the revelations about the new coins that are to be created
|
||||||
@ -188,7 +188,7 @@ CREATE TABLE IF NOT EXISTS refresh_revealed_coins
|
|||||||
,PRIMARY KEY (rc, newcoin_index)
|
,PRIMARY KEY (rc, newcoin_index)
|
||||||
,UNIQUE (h_coin_ev)
|
,UNIQUE (h_coin_ev)
|
||||||
);
|
);
|
||||||
CREATE INDEX refresh_revealed_coins_coin_pub_index
|
CREATE INDEX IF NOT EXISTS refresh_revealed_coins_coin_pub_index
|
||||||
ON refresh_revealed_coins
|
ON refresh_revealed_coins
|
||||||
(denom_pub_hash);
|
(denom_pub_hash);
|
||||||
-- Table with the transfer keys of a refresh operation; includes
|
-- Table with the transfer keys of a refresh operation; includes
|
||||||
@ -203,7 +203,7 @@ CREATE TABLE IF NOT EXISTS refresh_transfer_keys
|
|||||||
-- for get_link (not sure if this helps, as there should be very few
|
-- for get_link (not sure if this helps, as there should be very few
|
||||||
-- transfer_pubs per rc, but at least in theory this helps the ORDER BY
|
-- transfer_pubs per rc, but at least in theory this helps the ORDER BY
|
||||||
-- clause.
|
-- clause.
|
||||||
CREATE INDEX refresh_transfer_keys_coin_tpub
|
CREATE INDEX IF NOT EXISTS refresh_transfer_keys_coin_tpub
|
||||||
ON refresh_transfer_keys
|
ON refresh_transfer_keys
|
||||||
(rc
|
(rc
|
||||||
,transfer_pub
|
,transfer_pub
|
||||||
@ -228,14 +228,14 @@ CREATE TABLE IF NOT EXISTS deposits
|
|||||||
,UNIQUE (coin_pub, merchant_pub, h_contract_terms)
|
,UNIQUE (coin_pub, merchant_pub, h_contract_terms)
|
||||||
);
|
);
|
||||||
-- Index for get_deposit_for_wtid and get_deposit_statement */
|
-- Index for get_deposit_for_wtid and get_deposit_statement */
|
||||||
CREATE INDEX deposits_coin_pub_merchant_contract_index
|
CREATE INDEX IF NOT EXISTS deposits_coin_pub_merchant_contract_index
|
||||||
ON deposits
|
ON deposits
|
||||||
(coin_pub
|
(coin_pub
|
||||||
,merchant_pub
|
,merchant_pub
|
||||||
,h_contract_terms
|
,h_contract_terms
|
||||||
);
|
);
|
||||||
-- Index for deposits_get_ready
|
-- Index for deposits_get_ready
|
||||||
CREATE INDEX deposits_get_ready_index
|
CREATE INDEX IF NOT EXISTS deposits_get_ready_index
|
||||||
ON deposits
|
ON deposits
|
||||||
(tiny
|
(tiny
|
||||||
,done
|
,done
|
||||||
@ -243,7 +243,7 @@ CREATE INDEX deposits_get_ready_index
|
|||||||
,refund_deadline
|
,refund_deadline
|
||||||
);
|
);
|
||||||
-- Index for deposits_iterate_matching
|
-- Index for deposits_iterate_matching
|
||||||
CREATE INDEX deposits_iterate_matching
|
CREATE INDEX IF NOT EXISTS deposits_iterate_matching
|
||||||
ON deposits
|
ON deposits
|
||||||
(merchant_pub
|
(merchant_pub
|
||||||
,h_wire
|
,h_wire
|
||||||
@ -265,7 +265,7 @@ CREATE TABLE IF NOT EXISTS refunds
|
|||||||
,amount_with_fee_frac INT4 NOT NULL
|
,amount_with_fee_frac INT4 NOT NULL
|
||||||
,PRIMARY KEY (coin_pub, merchant_pub, h_contract_terms, rtransaction_id)
|
,PRIMARY KEY (coin_pub, merchant_pub, h_contract_terms, rtransaction_id)
|
||||||
);
|
);
|
||||||
CREATE INDEX refunds_coin_pub_index
|
CREATE INDEX IF NOT EXISTS refunds_coin_pub_index
|
||||||
ON refunds
|
ON refunds
|
||||||
(coin_pub);
|
(coin_pub);
|
||||||
-- This table contains the data for
|
-- This table contains the data for
|
||||||
@ -287,7 +287,7 @@ CREATE TABLE IF NOT EXISTS aggregation_tracking
|
|||||||
,wtid_raw BYTEA CONSTRAINT wire_out_ref REFERENCES wire_out(wtid_raw) ON DELETE CASCADE DEFERRABLE
|
,wtid_raw BYTEA CONSTRAINT wire_out_ref REFERENCES wire_out(wtid_raw) ON DELETE CASCADE DEFERRABLE
|
||||||
);
|
);
|
||||||
-- Index for lookup_transactions statement on wtid
|
-- Index for lookup_transactions statement on wtid
|
||||||
CREATE INDEX aggregation_tracking_wtid_index
|
CREATE INDEX IF NOT EXISTS aggregation_tracking_wtid_index
|
||||||
ON aggregation_tracking
|
ON aggregation_tracking
|
||||||
(wtid_raw);
|
(wtid_raw);
|
||||||
-- Table for the wire fees.
|
-- Table for the wire fees.
|
||||||
@ -302,7 +302,7 @@ CREATE TABLE IF NOT EXISTS wire_fee
|
|||||||
,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
|
,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
|
||||||
,PRIMARY KEY (wire_method, start_date)
|
,PRIMARY KEY (wire_method, start_date)
|
||||||
);
|
);
|
||||||
CREATE INDEX wire_fee_gc_index
|
CREATE INDEX IF NOT EXISTS wire_fee_gc_index
|
||||||
ON wire_fee
|
ON wire_fee
|
||||||
(end_date);
|
(end_date);
|
||||||
-- Table for /recoup information
|
-- Table for /recoup information
|
||||||
@ -317,13 +317,13 @@ CREATE TABLE IF NOT EXISTS recoup
|
|||||||
,timestamp INT8 NOT NULL
|
,timestamp INT8 NOT NULL
|
||||||
,h_blind_ev BYTEA NOT NULL REFERENCES reserves_out (h_blind_ev) ON DELETE CASCADE
|
,h_blind_ev BYTEA NOT NULL REFERENCES reserves_out (h_blind_ev) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
CREATE INDEX recoup_by_coin_index
|
CREATE INDEX IF NOT EXISTS recoup_by_coin_index
|
||||||
ON recoup
|
ON recoup
|
||||||
(coin_pub);
|
(coin_pub);
|
||||||
CREATE INDEX recoup_by_h_blind_ev
|
CREATE INDEX IF NOT EXISTS recoup_by_h_blind_ev
|
||||||
ON recoup
|
ON recoup
|
||||||
(h_blind_ev);
|
(h_blind_ev);
|
||||||
CREATE INDEX recoup_for_by_reserve
|
CREATE INDEX IF NOT EXISTS recoup_for_by_reserve
|
||||||
ON recoup
|
ON recoup
|
||||||
(coin_pub
|
(coin_pub
|
||||||
,h_blind_ev
|
,h_blind_ev
|
||||||
@ -340,13 +340,13 @@ CREATE TABLE IF NOT EXISTS recoup_refresh
|
|||||||
,timestamp INT8 NOT NULL
|
,timestamp INT8 NOT NULL
|
||||||
,h_blind_ev BYTEA NOT NULL REFERENCES refresh_revealed_coins (h_coin_ev) ON DELETE CASCADE
|
,h_blind_ev BYTEA NOT NULL REFERENCES refresh_revealed_coins (h_coin_ev) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
CREATE INDEX recoup_refresh_by_coin_index
|
CREATE INDEX IF NOT EXISTS recoup_refresh_by_coin_index
|
||||||
ON recoup_refresh
|
ON recoup_refresh
|
||||||
(coin_pub);
|
(coin_pub);
|
||||||
CREATE INDEX recoup_refresh_by_h_blind_ev
|
CREATE INDEX IF NOT EXISTS recoup_refresh_by_h_blind_ev
|
||||||
ON recoup_refresh
|
ON recoup_refresh
|
||||||
(h_blind_ev);
|
(h_blind_ev);
|
||||||
CREATE INDEX recoup_refresh_for_by_reserve
|
CREATE INDEX IF NOT EXISTS recoup_refresh_for_by_reserve
|
||||||
ON recoup_refresh
|
ON recoup_refresh
|
||||||
(coin_pub
|
(coin_pub
|
||||||
,h_blind_ev
|
,h_blind_ev
|
||||||
@ -360,7 +360,7 @@ CREATE TABLE IF NOT EXISTS prewire
|
|||||||
,buf BYTEA NOT NULL
|
,buf BYTEA NOT NULL
|
||||||
);
|
);
|
||||||
-- Index for wire_prepare_data_get and gc_prewire statement
|
-- Index for wire_prepare_data_get and gc_prewire statement
|
||||||
CREATE INDEX prepare_iteration_index
|
CREATE INDEX IF NOT EXISTS prepare_iteration_index
|
||||||
ON prewire
|
ON prewire
|
||||||
(finished);
|
(finished);
|
||||||
|
|
||||||
|
@ -81,7 +81,8 @@ TALER_JSON_get_error_code (const json_t *json)
|
|||||||
so we are dealing with a missing error code here. */
|
so we are dealing with a missing error code here. */
|
||||||
if (NULL == jc)
|
if (NULL == jc)
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Expected Taler error code `code' in JSON, but field does not exist!\n");
|
||||||
return TALER_EC_INVALID;
|
return TALER_EC_INVALID;
|
||||||
}
|
}
|
||||||
if (json_is_integer (jc))
|
if (json_is_integer (jc))
|
||||||
|
Loading…
Reference in New Issue
Block a user