syncdb_lookup_backup_TR.c (2752B)
1 /* 2 This file is part of TALER 3 (C) 2014--2022 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Lesser General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file syncdb/syncdb_lookup_backup_TR.c 18 * @brief obtain backup data 19 * @author Christian Grothoff 20 */ 21 #include "syncdb_pg.h" 22 23 24 enum SYNC_DB_QueryStatus 25 SYNCDB_lookup_backup_TR ( 26 const struct SYNC_AccountPublicKeyP *account_pub, 27 struct SYNC_AccountSignatureP *account_sig, 28 struct GNUNET_HashCode *prev_hash, 29 struct GNUNET_HashCode *backup_hash, 30 size_t *backup_size, 31 void **backup) 32 { 33 enum GNUNET_DB_QueryStatus qs; 34 struct GNUNET_PQ_QueryParam params[] = { 35 GNUNET_PQ_query_param_auto_from_type (account_pub), 36 GNUNET_PQ_query_param_end 37 }; 38 struct GNUNET_PQ_ResultSpec rs[] = { 39 GNUNET_PQ_result_spec_auto_from_type ("account_sig", 40 account_sig), 41 GNUNET_PQ_result_spec_auto_from_type ("prev_hash", 42 prev_hash), 43 GNUNET_PQ_result_spec_auto_from_type ("backup_hash", 44 backup_hash), 45 GNUNET_PQ_result_spec_variable_size ("data", 46 backup, 47 backup_size), 48 GNUNET_PQ_result_spec_end 49 }; 50 51 SYNCDB_preflight (); 52 PREPARE ("backup_select", 53 "SELECT " 54 " account_sig" 55 ",prev_hash" 56 ",backup_hash" 57 ",data " 58 "FROM" 59 " backups " 60 "WHERE" 61 " account_pub=$1;"); 62 qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, 63 "backup_select", 64 params, 65 rs); 66 switch (qs) 67 { 68 case GNUNET_DB_STATUS_HARD_ERROR: 69 return SYNC_DB_HARD_ERROR; 70 case GNUNET_DB_STATUS_SOFT_ERROR: 71 GNUNET_break (0); 72 return SYNC_DB_SOFT_ERROR; 73 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 74 return SYNC_DB_NO_RESULTS; 75 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 76 return SYNC_DB_ONE_RESULT; 77 default: 78 GNUNET_break (0); 79 return SYNC_DB_HARD_ERROR; 80 } 81 } 82 83 84 /* end of syncdb_lookup_backup_TR.c */