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

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

Generated by: LCOV version 1.16