skeleton for postgres_insert_records_by_table

This commit is contained in:
Christian Grothoff 2021-01-10 13:27:33 +01:00
parent 0e16fb816c
commit 80b4fc0869
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 440 additions and 3 deletions

View File

@ -25,6 +25,7 @@ EXTRA_DIST = \
exchangedb.conf \
exchangedb-postgres.conf \
plugin_exchangedb_common.c \
irbt_callbacks.c \
lrbt_callbacks.c \
test-exchange-db-postgres.conf \
$(sql_DATA)

View File

@ -0,0 +1,346 @@
/*
This file is part of GNUnet
Copyright (C) 2020 Taler Systems SA
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
* @file exchangedb/irbt_callbacks.c
* @brief callbacks used by postgres_insert_records_by_table, to be
* inlined into the plugin
* @author Christian Grothoff
*/
/**
* Function called with denominations records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_denominations (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with denomination_revocations records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_denomination_revocations (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct
TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with reserves records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_reserves (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with reserves_in records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_reserves_in (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with reserves_close records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_reserves_close (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with reserves_out records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_reserves_out (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with auditors records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_auditors (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with auditor_denom_sigs records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_auditor_denom_sigs (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with exchange_sign_keys records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_exchange_sign_keys (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with signkey_revocations records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_signkey_revocations (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with known_coins records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_known_coins (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with refresh_commitments records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_refresh_commitments (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with refresh_revealed_coins records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_refresh_revealed_coins (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct
TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with refresh_transfer_keys records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_refresh_transfer_keys (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct
TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with deposits records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_deposits (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with refunds records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_refunds (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with wire_out records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_wire_out (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with aggregation_tracking records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_aggregation_tracking (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with wire_fee records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_wire_fee (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with recoup records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_recoup (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/**
* Function called with recoup_refresh records to insert into table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_recoup_refresh (struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
}
/* end of irbt_callbacks.c */

View File

@ -9770,6 +9770,23 @@ postgres_lookup_records_by_table (void *cls,
}
/**
* Signature of helper functions of #postgres_insert_records_by_table.
*
* @param pg plugin context
* @param session database session
* @param td record to insert
* @return transaction status code
*/
typedef enum GNUNET_DB_QueryStatus
(*InsertRecordCallback)(struct PostgresClosure *pg,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td);
#include "irbt_callbacks.c"
/**
* Insert record set into @a table. Used in exchange-auditor database
* replication.
@ -9778,15 +9795,88 @@ postgres_lookup_records_by_table (void *cls,
* @param session a session
* @param tb table data to insert
* @return transaction status code, #GNUNET_DB_STATUS_HARD_ERROR if
* @a table does not have a serial number
* @e table in @a tr is not supported
*/
static enum GNUNET_DB_QueryStatus
postgres_insert_records_by_table (void *cls,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_TableData *td)
{
GNUNET_break (0); // FIXME: not implemented!
return GNUNET_DB_STATUS_HARD_ERROR;
struct PostgresClosure *pg = cls;
InsertRecordCallback rh;
switch (td->table)
{
case TALER_EXCHANGEDB_RT_DENOMINATIONS:
rh = &irbt_cb_table_denominations;
break;
case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
rh = &irbt_cb_table_denomination_revocations;
break;
case TALER_EXCHANGEDB_RT_RESERVES:
rh = &irbt_cb_table_reserves;
break;
case TALER_EXCHANGEDB_RT_RESERVES_IN:
rh = &irbt_cb_table_reserves_in;
break;
case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
rh = &irbt_cb_table_reserves_close;
break;
case TALER_EXCHANGEDB_RT_RESERVES_OUT:
rh = &irbt_cb_table_reserves_out;
break;
case TALER_EXCHANGEDB_RT_AUDITORS:
rh = &irbt_cb_table_auditors;
break;
case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS:
rh = &irbt_cb_table_auditor_denom_sigs;
break;
case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS:
rh = &irbt_cb_table_exchange_sign_keys;
break;
case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS:
rh = &irbt_cb_table_signkey_revocations;
break;
case TALER_EXCHANGEDB_RT_KNOWN_COINS:
rh = &irbt_cb_table_known_coins;
break;
case TALER_EXCHANGEDB_RT_REFRESH_COMMITMENTS:
rh = &irbt_cb_table_refresh_commitments;
break;
case TALER_EXCHANGEDB_RT_REFRESH_REVEALED_COINS:
rh = &irbt_cb_table_refresh_revealed_coins;
break;
case TALER_EXCHANGEDB_RT_REFRESH_TRANSFER_KEYS:
rh = &irbt_cb_table_refresh_transfer_keys;
break;
case TALER_EXCHANGEDB_RT_DEPOSITS:
rh = &irbt_cb_table_deposits;
break;
case TALER_EXCHANGEDB_RT_REFUNDS:
rh = &irbt_cb_table_refunds;
break;
case TALER_EXCHANGEDB_RT_WIRE_OUT:
rh = &irbt_cb_table_wire_out;
break;
case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING:
rh = &irbt_cb_table_aggregation_tracking;
break;
case TALER_EXCHANGEDB_RT_WIRE_FEE:
rh = &irbt_cb_table_wire_fee;
break;
case TALER_EXCHANGEDB_RT_RECOUP:
rh = &irbt_cb_table_recoup;
break;
case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
rh = &irbt_cb_table_recoup_refresh;
break;
default:
GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR;
}
return rh (pg,
session,
td);
}