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

Function CVT2_get_binary_comparable_desc

src/jrd/cvt2.cpp:138–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136
137
138bool CVT2_get_binary_comparable_desc(dsc* result, const dsc* arg1, const dsc* arg2)
139{
140/**************************************
141 *
142 * C V T 2 _ g e t _ b i n a r y _ c o m p a r a b l e _ d e s c
143 *
144 **************************************
145 *
146 * Functional description
147 * Return descriptor of the data type to be used for direct (binary) comparison of the given arguments.
148 *
149 **************************************/
150
151 if (arg1->dsc_dtype == dtype_blob || arg2->dsc_dtype == dtype_blob ||
152 arg1->dsc_dtype == dtype_array || arg2->dsc_dtype == dtype_array)
153 {
154 // Any of the arguments is a blob or an array
155 return false;
156 }
157
158 if (arg1->dsc_dtype == dtype_dbkey || arg2->dsc_dtype == dtype_dbkey)
159 {
160 // Any of the arguments is DBKEY
161 result->makeText(MAX(arg1->getStringLength(), arg2->getStringLength()), ttype_binary);
162 }
163 else if (arg1->isText() && arg2->isText())
164 {
165 // Both arguments are strings
166 if (arg1->getTextType() != arg2->getTextType())
167 {
168 // Charsets/collations are different
169 return false;
170 }
171
172 if (arg1->dsc_dtype == arg2->dsc_dtype)
173 {
174 *result = *arg1;
175 result->dsc_length = MAX(arg1->dsc_length, arg2->dsc_length);
176 }
177 else
178 {
179 result->makeText(MAX(arg1->getStringLength(), arg2->getStringLength()),
180 arg1->getTextType());
181 }
182 }
183 else if (arg1->dsc_dtype == arg2->dsc_dtype && arg1->dsc_scale == arg2->dsc_scale)
184 {
185 // Arguments can be compared directly
186 *result = *arg1;
187 }
188 else if (arg1->dsc_dtype == dtype_boolean || arg2->dsc_dtype == dtype_boolean)
189 {
190 // boolean is not comparable to a non-boolean
191 return false;
192 }
193 else
194 {
195 // Arguments are of different data types

Callers 1

getEquiJoinKeysMethod · 0.85

Calls 5

makeTextMethod · 0.80
getStringLengthMethod · 0.80
isTextMethod · 0.80
getTextTypeMethod · 0.80
isExactMethod · 0.80

Tested by

no test coverage detected