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