LCOV - code coverage report
Current view: top level - data/include/storage - data_database_classifier_reader.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.61.0_covts Lines: 33 47 70.2 %
Date: 2024-10-26 21:44:38 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /* File: data_database_classifier_reader.inl; Copyright and License: see below */
       2             : 
       3             : #include "u8/u8_log.h"
       4             : #include "u8/u8_trace.h"
       5             : #include <assert.h>
       6             : 
       7             : /* ================================ private ================================ */
       8             : 
       9         246 : static inline u8_error_t data_database_classifier_reader_private_bind_id_to_statement ( data_database_classifier_reader_t *this_,
      10             :                                                                                         sqlite3_stmt *statement_ptr,
      11             :                                                                                         data_row_id_t id )
      12             : {
      13         246 :     assert( NULL != statement_ptr );
      14         246 :     u8_error_t result = U8_ERROR_NONE;
      15             :     static const int FIRST_SQL_BIND_PARAM = 1;
      16             :     int sqlite_err;
      17             : 
      18         246 :     sqlite_err = sqlite3_reset( statement_ptr );
      19         246 :     if ( SQLITE_OK != sqlite_err )
      20             :     {
      21           0 :         U8_LOG_ERROR_INT( "sqlite3_reset() failed:", sqlite_err );
      22           0 :         result |= U8_ERROR_AT_DB;
      23             :     }
      24             : 
      25         246 :     U8_TRACE_INFO_STR( "sqlite3_bind_int64():", sqlite3_sql(statement_ptr) );
      26         246 :     U8_TRACE_INFO_INT( "sqlite3_bind_int64():", id );
      27         246 :     sqlite_err = sqlite3_bind_int64( statement_ptr, FIRST_SQL_BIND_PARAM, id );
      28         246 :     if ( SQLITE_OK != sqlite_err )
      29             :     {
      30           0 :         U8_LOG_ERROR_INT( "sqlite3_bind_int64() failed:", sqlite_err );
      31           0 :         result |= U8_ERROR_AT_DB;
      32             :     }
      33             : 
      34         246 :     return result;
      35             : }
      36             : 
      37          27 : static inline u8_error_t data_database_classifier_reader_private_bind_two_ids_to_statement ( data_database_classifier_reader_t *this_,
      38             :                                                                                              sqlite3_stmt *statement_ptr,
      39             :                                                                                              data_row_id_t id1,
      40             :                                                                                              data_row_id_t id2 )
      41             : {
      42          27 :     assert( NULL != statement_ptr );
      43          27 :     u8_error_t result = U8_ERROR_NONE;
      44             :     static const int FIRST_SQL_BIND_PARAM = 1;
      45             :     static const int SECOND_SQL_BIND_PARAM = 2;
      46             :     int sqlite_err;
      47             : 
      48          27 :     sqlite_err = sqlite3_reset( statement_ptr );
      49          27 :     if ( SQLITE_OK != sqlite_err )
      50             :     {
      51           0 :         U8_LOG_ERROR_INT( "sqlite3_reset() failed:", sqlite_err );
      52           0 :         result |= U8_ERROR_AT_DB;
      53             :     }
      54             : 
      55          27 :     U8_TRACE_INFO_STR( "sqlite3_bind_int64():", sqlite3_sql(statement_ptr) );
      56          27 :     U8_TRACE_INFO_INT_INT( "sqlite3_bind_int64():", id1, id2 );
      57          27 :     sqlite_err = sqlite3_bind_int64( statement_ptr, FIRST_SQL_BIND_PARAM, id1 );
      58          27 :     if ( SQLITE_OK != sqlite_err )
      59             :     {
      60           0 :         U8_LOG_ERROR_INT( "sqlite3_bind_int64() failed:", sqlite_err );
      61           0 :         result |= U8_ERROR_AT_DB;
      62             :     }
      63          27 :     sqlite_err = sqlite3_bind_int64( statement_ptr, SECOND_SQL_BIND_PARAM, id2 );
      64          27 :     if ( SQLITE_OK != sqlite_err )
      65             :     {
      66           0 :         U8_LOG_ERROR_INT( "sqlite3_bind_int64() failed:", sqlite_err );
      67           0 :         result |= U8_ERROR_AT_DB;
      68             :     }
      69             : 
      70          27 :     return result;
      71             : }
      72             : 
      73         149 : static inline u8_error_t data_database_classifier_reader_private_bind_text_to_statement ( data_database_classifier_reader_t *this_,
      74             :                                                                                           sqlite3_stmt *statement_ptr,
      75             :                                                                                           const char *text )
      76             : {
      77         149 :     assert( NULL != statement_ptr );
      78         149 :     assert( NULL != text );
      79         149 :     u8_error_t result = U8_ERROR_NONE;
      80             :     static const int FIRST_SQL_BIND_PARAM = 1;
      81             :     int sqlite_err;
      82             : 
      83         149 :     sqlite_err = sqlite3_reset( statement_ptr );
      84         149 :     if ( SQLITE_OK != sqlite_err )
      85             :     {
      86           0 :         U8_LOG_ERROR_INT( "sqlite3_reset() failed:", sqlite_err );
      87           0 :         result |= U8_ERROR_AT_DB;
      88             :     }
      89             : 
      90         149 :     U8_TRACE_INFO_STR( "sqlite3_bind_text():", sqlite3_sql(statement_ptr) );
      91             :     /* SQLITE_STATIC vs SQLITE_TRANSIENT: This function is used to perform a SELECT statement. */
      92             :     /* During the SELECT, the text string is not modified. This is guaranteed by data_database_classifier_reader. */
      93         149 :     U8_TRACE_INFO_STR( "sqlite3_bind_text():", text );
      94         149 :     sqlite_err = sqlite3_bind_text( statement_ptr, FIRST_SQL_BIND_PARAM, text, -1, SQLITE_STATIC );
      95         149 :     if ( SQLITE_OK != sqlite_err )
      96             :     {
      97           0 :         U8_LOG_ERROR_INT( "sqlite3_bind_text() failed:", sqlite_err );
      98           0 :         result |= U8_ERROR_AT_DB;
      99             :     }
     100             : 
     101         149 :     return result;
     102             : }
     103             : 
     104             : 
     105             : /*
     106             : Copyright 2016-2024 Andreas Warnke
     107             : 
     108             : Licensed under the Apache License, Version 2.0 (the "License");
     109             : you may not use this file except in compliance with the License.
     110             : You may obtain a copy of the License at
     111             : 
     112             :     http://www.apache.org/licenses/LICENSE-2.0
     113             : 
     114             : Unless required by applicable law or agreed to in writing, software
     115             : distributed under the License is distributed on an "AS IS" BASIS,
     116             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     117             : See the License for the specific language governing permissions and
     118             : limitations under the License.
     119             : */

Generated by: LCOV version 1.16