MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / BLB_check_well_formed

Method BLB_check_well_formed

src/jrd/blb.cpp:128–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126
127
128void blb::BLB_check_well_formed(Jrd::thread_db* tdbb, const dsc* desc)
129{
130/**************************************
131 *
132 * b l b : : c h e c k _ w e l l _ f o r m e d
133 *
134 **************************************
135 *
136 * Functional description
137 * Check if a text BLOB is well formed.
138 *
139 **************************************/
140
141 SET_TDBB(tdbb);
142
143 // Need to verify this to work in database creation, as the charsets didn't exist yet.
144 if (desc->getCharSet() == CS_NONE || desc->getCharSet() == CS_BINARY)
145 return;
146
147 CharSet* charSet = INTL_charset_lookup(tdbb, desc->getCharSet());
148
149 if (!charSet->shouldCheckWellFormedness())
150 return;
151
152 HalfStaticArray<UCHAR, BUFFER_MEDIUM> buffer;
153 ULONG pos = 0;
154
155 while (!(blb_flags & BLB_eof))
156 {
157 const ULONG len = BLB_get_data(tdbb,
158 buffer.getBuffer(buffer.getCapacity()) + pos, buffer.getCapacity() - pos, false);
159 buffer.resize(pos + len);
160
161 if (charSet->wellFormed(pos + len, buffer.begin(), &pos))
162 pos = 0;
163 else
164 {
165 if (pos == 0)
166 status_exception::raise(Arg::Gds(isc_malformed_string));
167 else
168 {
169 buffer.removeCount(0, pos);
170 pos = buffer.getCount();
171 }
172 }
173 }
174
175 if (pos != 0)
176 status_exception::raise(Arg::Gds(isc_malformed_string));
177}
178
179
180bool blb::BLB_close(thread_db* tdbb)

Callers 2

executeMethod · 0.80
moveMethod · 0.80

Calls 13

SET_TDBBFunction · 0.85
INTL_charset_lookupFunction · 0.85
raiseFunction · 0.85
GdsClass · 0.85
wellFormedMethod · 0.80
getCharSetMethod · 0.45
getBufferMethod · 0.45
getCapacityMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
removeCountMethod · 0.45

Tested by

no test coverage detected