Merge pull request #4876 from blockscout/vb-add-missing-columns-in-updates

Add missing columns updates when INSERT ... ON CONFLICT DO UPDATE ... happens
pull/4895/head
Victor Baranov 3 years ago committed by GitHub
commit db3b11309d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 1
      apps/explorer/lib/explorer/chain/import/runner/address/current_token_balances.ex
  3. 1
      apps/explorer/lib/explorer/chain/import/runner/address/token_balances.ex
  4. 3
      apps/explorer/lib/explorer/chain/import/runner/addresses.ex
  5. 14
      apps/explorer/lib/explorer/chain/import/runner/transactions.ex

@ -67,6 +67,7 @@
- [#4582](https://github.com/blockscout/blockscout/pull/4582) - Fix NaN input on write contract page - [#4582](https://github.com/blockscout/blockscout/pull/4582) - Fix NaN input on write contract page
### Chore ### Chore
- [#4876](https://github.com/blockscout/blockscout/pull/4876) - Add missing columns updates when INSERT ... ON CONFLICT DO UPDATE ... happens
- [#4872](https://github.com/blockscout/blockscout/pull/4872) - Set explicit ascending order by hash in acquire transactions query of internal transactions import - [#4872](https://github.com/blockscout/blockscout/pull/4872) - Set explicit ascending order by hash in acquire transactions query of internal transactions import
- [#4871](https://github.com/blockscout/blockscout/pull/4871) - Remove cumulative gas used update duplicate - [#4871](https://github.com/blockscout/blockscout/pull/4871) - Remove cumulative gas used update duplicate
- [#4860](https://github.com/blockscout/blockscout/pull/4860) - Node 16 support - [#4860](https://github.com/blockscout/blockscout/pull/4860) - Node 16 support

@ -322,6 +322,7 @@ defmodule Explorer.Chain.Import.Runner.Address.CurrentTokenBalances do
value: fragment("EXCLUDED.value"), value: fragment("EXCLUDED.value"),
value_fetched_at: fragment("EXCLUDED.value_fetched_at"), value_fetched_at: fragment("EXCLUDED.value_fetched_at"),
old_value: current_token_balance.value, old_value: current_token_balance.value,
token_type: fragment("EXCLUDED.token_type"),
inserted_at: fragment("LEAST(EXCLUDED.inserted_at, ?)", current_token_balance.inserted_at), inserted_at: fragment("LEAST(EXCLUDED.inserted_at, ?)", current_token_balance.inserted_at),
updated_at: fragment("GREATEST(EXCLUDED.updated_at, ?)", current_token_balance.updated_at) updated_at: fragment("GREATEST(EXCLUDED.updated_at, ?)", current_token_balance.updated_at)
] ]

@ -176,6 +176,7 @@ defmodule Explorer.Chain.Import.Runner.Address.TokenBalances do
set: [ set: [
value: fragment("EXCLUDED.value"), value: fragment("EXCLUDED.value"),
value_fetched_at: fragment("EXCLUDED.value_fetched_at"), value_fetched_at: fragment("EXCLUDED.value_fetched_at"),
token_type: fragment("EXCLUDED.token_type"),
inserted_at: fragment("LEAST(EXCLUDED.inserted_at, ?)", token_balance.inserted_at), inserted_at: fragment("LEAST(EXCLUDED.inserted_at, ?)", token_balance.inserted_at),
updated_at: fragment("GREATEST(EXCLUDED.updated_at, ?)", token_balance.updated_at) updated_at: fragment("GREATEST(EXCLUDED.updated_at, ?)", token_balance.updated_at)
] ]

@ -123,7 +123,8 @@ defmodule Explorer.Chain.Import.Runner.Addresses do
"GREATEST(EXCLUDED.fetched_coin_balance_block_number, ?)", "GREATEST(EXCLUDED.fetched_coin_balance_block_number, ?)",
address.fetched_coin_balance_block_number address.fetched_coin_balance_block_number
), ),
nonce: fragment("GREATEST(EXCLUDED.nonce, ?)", address.nonce) nonce: fragment("GREATEST(EXCLUDED.nonce, ?)", address.nonce),
updated_at: fragment("GREATEST(?, EXCLUDED.updated_at)", address.updated_at)
] ]
], ],
# where any of `set`s would make a change # where any of `set`s would make a change

@ -118,6 +118,11 @@ defmodule Explorer.Chain.Import.Runner.Transactions do
to_address_hash: fragment("EXCLUDED.to_address_hash"), to_address_hash: fragment("EXCLUDED.to_address_hash"),
v: fragment("EXCLUDED.v"), v: fragment("EXCLUDED.v"),
value: fragment("EXCLUDED.value"), value: fragment("EXCLUDED.value"),
earliest_processing_start: fragment("EXCLUDED.earliest_processing_start"),
revert_reason: fragment("EXCLUDED.revert_reason"),
max_priority_fee_per_gas: fragment("EXCLUDED.max_priority_fee_per_gas"),
max_fee_per_gas: fragment("EXCLUDED.max_fee_per_gas"),
type: fragment("EXCLUDED.type"),
# Don't update `hash` as it is part of the primary key and used for the conflict target # Don't update `hash` as it is part of the primary key and used for the conflict target
inserted_at: fragment("LEAST(?, EXCLUDED.inserted_at)", transaction.inserted_at), inserted_at: fragment("LEAST(?, EXCLUDED.inserted_at)", transaction.inserted_at),
updated_at: fragment("GREATEST(?, EXCLUDED.updated_at)", transaction.updated_at) updated_at: fragment("GREATEST(?, EXCLUDED.updated_at)", transaction.updated_at)
@ -125,7 +130,7 @@ defmodule Explorer.Chain.Import.Runner.Transactions do
], ],
where: where:
fragment( fragment(
"(EXCLUDED.block_hash, EXCLUDED.block_number, EXCLUDED.created_contract_address_hash, EXCLUDED.created_contract_code_indexed_at, EXCLUDED.cumulative_gas_used, EXCLUDED.from_address_hash, EXCLUDED.gas, EXCLUDED.gas_price, EXCLUDED.gas_used, EXCLUDED.index, EXCLUDED.input, EXCLUDED.nonce, EXCLUDED.r, EXCLUDED.s, EXCLUDED.status, EXCLUDED.to_address_hash, EXCLUDED.v, EXCLUDED.value) IS DISTINCT FROM (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", "(EXCLUDED.block_hash, EXCLUDED.block_number, EXCLUDED.created_contract_address_hash, EXCLUDED.created_contract_code_indexed_at, EXCLUDED.cumulative_gas_used, EXCLUDED.from_address_hash, EXCLUDED.gas, EXCLUDED.gas_price, EXCLUDED.gas_used, EXCLUDED.index, EXCLUDED.input, EXCLUDED.nonce, EXCLUDED.r, EXCLUDED.s, EXCLUDED.status, EXCLUDED.to_address_hash, EXCLUDED.v, EXCLUDED.value, EXCLUDED.earliest_processing_start, EXCLUDED.revert_reason, EXCLUDED.max_priority_fee_per_gas, EXCLUDED.max_fee_per_gas, EXCLUDED.type) IS DISTINCT FROM (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
transaction.block_hash, transaction.block_hash,
transaction.block_number, transaction.block_number,
transaction.created_contract_address_hash, transaction.created_contract_address_hash,
@ -143,7 +148,12 @@ defmodule Explorer.Chain.Import.Runner.Transactions do
transaction.status, transaction.status,
transaction.to_address_hash, transaction.to_address_hash,
transaction.v, transaction.v,
transaction.value transaction.value,
transaction.earliest_processing_start,
transaction.revert_reason,
transaction.max_priority_fee_per_gas,
transaction.max_fee_per_gas,
transaction.type
) )
) )
end end

Loading…
Cancel
Save