Merge lp:~linuxjedi/libdrizzle/5.1-fix-null-bitmap into lp:libdrizzle
- 5.1-fix-null-bitmap
- Merge into libdrizzle-redux
Proposed by
Andrew Hutchings
Status: | Merged |
---|---|
Approved by: | Andrew Hutchings |
Approved revision: | 112 |
Merged at revision: | 112 |
Proposed branch: | lp:~linuxjedi/libdrizzle/5.1-fix-null-bitmap |
Merge into: | lp:libdrizzle |
Diff against target: |
355 lines (+68/-35) 7 files modified
libdrizzle/field.cc (+13/-1) libdrizzle/result.h (+2/-0) libdrizzle/row.cc (+7/-1) libdrizzle/statement.cc (+40/-26) libdrizzle/statement_param.cc (+1/-1) tests/unit/include.am (+0/-2) tests/unit/nulls.c (+5/-4) |
To merge this branch: | bzr merge lp:~linuxjedi/libdrizzle/5.1-fix-null-bitmap |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Drizzle Trunk | Pending | ||
Review via email:
|
Commit message
Description of the change
Fixes many bugs that break NULL data in prepared statements.
To post a comment you must log in.
- 113. By Andrew Hutchings
-
Fix valgrind errors in prep statement NULL handling
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libdrizzle/field.cc' | |||
2 | --- libdrizzle/field.cc 2013-03-12 16:27:58 +0000 | |||
3 | +++ libdrizzle/field.cc 2013-04-22 19:16:28 +0000 | |||
4 | @@ -66,7 +66,7 @@ | |||
5 | 66 | 66 | ||
6 | 67 | if (result->has_state()) | 67 | if (result->has_state()) |
7 | 68 | { | 68 | { |
9 | 69 | if (result->field_current == result->column_count) | 69 | if (result->field_current == (result->column_count - result->null_bitcount)) |
10 | 70 | { | 70 | { |
11 | 71 | *ret_ptr= DRIZZLE_RETURN_ROW_END; | 71 | *ret_ptr= DRIZZLE_RETURN_ROW_END; |
12 | 72 | return NULL; | 72 | return NULL; |
13 | @@ -324,11 +324,23 @@ | |||
14 | 324 | 324 | ||
15 | 325 | drizzle_return_t drizzle_state_binary_null_read(drizzle_st *con) | 325 | drizzle_return_t drizzle_state_binary_null_read(drizzle_st *con) |
16 | 326 | { | 326 | { |
17 | 327 | uint16_t bit_count= 0; | ||
18 | 327 | con->result->null_bitmap_length= (con->result->column_count+7+2)/8; | 328 | con->result->null_bitmap_length= (con->result->column_count+7+2)/8; |
19 | 328 | con->result->null_bitmap= new uint8_t[con->result->null_bitmap_length]; | 329 | con->result->null_bitmap= new uint8_t[con->result->null_bitmap_length]; |
20 | 329 | con->buffer_ptr++; | 330 | con->buffer_ptr++; |
21 | 330 | 331 | ||
22 | 331 | memcpy(con->result->null_bitmap, con->buffer_ptr, con->result->null_bitmap_length); | 332 | memcpy(con->result->null_bitmap, con->buffer_ptr, con->result->null_bitmap_length); |
23 | 333 | |||
24 | 334 | for (uint16_t it= 0; it < con->result->null_bitmap_length; it++) | ||
25 | 335 | { | ||
26 | 336 | uint8_t data= con->result->null_bitmap[it]; | ||
27 | 337 | while (data) | ||
28 | 338 | { | ||
29 | 339 | data &= (data - 1); | ||
30 | 340 | bit_count++; | ||
31 | 341 | } | ||
32 | 342 | } | ||
33 | 343 | con->result->null_bitcount = bit_count; | ||
34 | 332 | con->buffer_ptr+= con->result->null_bitmap_length; | 344 | con->buffer_ptr+= con->result->null_bitmap_length; |
35 | 333 | con->buffer_size-= con->result->null_bitmap_length+1; | 345 | con->buffer_size-= con->result->null_bitmap_length+1; |
36 | 334 | con->packet_size-= con->result->null_bitmap_length+1; | 346 | con->packet_size-= con->result->null_bitmap_length+1; |
37 | 335 | 347 | ||
38 | === modified file 'libdrizzle/result.h' | |||
39 | --- libdrizzle/result.h 2013-03-12 00:55:59 +0000 | |||
40 | +++ libdrizzle/result.h 2013-04-22 19:16:28 +0000 | |||
41 | @@ -81,6 +81,7 @@ | |||
42 | 81 | uint8_t **null_bitmap_list; | 81 | uint8_t **null_bitmap_list; |
43 | 82 | uint8_t *null_bitmap; | 82 | uint8_t *null_bitmap; |
44 | 83 | uint16_t null_bitmap_length; | 83 | uint16_t null_bitmap_length; |
45 | 84 | uint16_t null_bitcount; | ||
46 | 84 | bool binary_rows; | 85 | bool binary_rows; |
47 | 85 | 86 | ||
48 | 86 | drizzle_result_st() : | 87 | drizzle_result_st() : |
49 | @@ -115,6 +116,7 @@ | |||
50 | 115 | null_bitmap_list(NULL), | 116 | null_bitmap_list(NULL), |
51 | 116 | null_bitmap(NULL), | 117 | null_bitmap(NULL), |
52 | 117 | null_bitmap_length(0), | 118 | null_bitmap_length(0), |
53 | 119 | null_bitcount(0), | ||
54 | 118 | binary_rows(false) | 120 | binary_rows(false) |
55 | 119 | { | 121 | { |
56 | 120 | info[0]= '\0'; | 122 | info[0]= '\0'; |
57 | 121 | 123 | ||
58 | === modified file 'libdrizzle/row.cc' | |||
59 | --- libdrizzle/row.cc 2013-01-27 11:55:48 +0000 | |||
60 | +++ libdrizzle/row.cc 2013-04-22 19:16:28 +0000 | |||
61 | @@ -155,11 +155,17 @@ | |||
62 | 155 | return; | 155 | return; |
63 | 156 | } | 156 | } |
64 | 157 | 157 | ||
66 | 158 | for (x= 0; x < result->column_count; x++) | 158 | for (x= 0; x < (result->column_count - result->null_bitcount); x++) |
67 | 159 | { | 159 | { |
68 | 160 | drizzle_field_free(row[x]); | 160 | drizzle_field_free(row[x]); |
69 | 161 | } | 161 | } |
70 | 162 | 162 | ||
71 | 163 | if (!(result->options & DRIZZLE_RESULT_BUFFER_ROW)) | ||
72 | 164 | { | ||
73 | 165 | delete[] result->null_bitmap; | ||
74 | 166 | result->null_bitmap= NULL; | ||
75 | 167 | } | ||
76 | 168 | |||
77 | 163 | delete[] row; | 169 | delete[] row; |
78 | 164 | } | 170 | } |
79 | 165 | 171 | ||
80 | 166 | 172 | ||
81 | === modified file 'libdrizzle/statement.cc' | |||
82 | --- libdrizzle/statement.cc 2013-04-21 21:09:53 +0000 | |||
83 | +++ libdrizzle/statement.cc 2013-04-22 19:16:28 +0000 | |||
84 | @@ -105,6 +105,7 @@ | |||
85 | 105 | drizzle_return_t drizzle_stmt_execute(drizzle_stmt_st *stmt) | 105 | drizzle_return_t drizzle_stmt_execute(drizzle_stmt_st *stmt) |
86 | 106 | { | 106 | { |
87 | 107 | uint16_t current_param; | 107 | uint16_t current_param; |
88 | 108 | uint16_t param_count = stmt->param_count; | ||
89 | 108 | drizzle_bind_st *param_ptr; | 109 | drizzle_bind_st *param_ptr; |
90 | 109 | size_t param_lengths= 0; | 110 | size_t param_lengths= 0; |
91 | 110 | size_t buffer_size= 0; | 111 | size_t buffer_size= 0; |
92 | @@ -121,6 +122,12 @@ | |||
93 | 121 | drizzle_set_error(stmt->con, __func__, "parameter %d has not been bound", current_param); | 122 | drizzle_set_error(stmt->con, __func__, "parameter %d has not been bound", current_param); |
94 | 122 | return DRIZZLE_RETURN_STMT_ERROR; | 123 | return DRIZZLE_RETURN_STMT_ERROR; |
95 | 123 | } | 124 | } |
96 | 125 | /* Don't count NULLs */ | ||
97 | 126 | if (stmt->query_params[current_param].type == DRIZZLE_COLUMN_TYPE_NULL) | ||
98 | 127 | { | ||
99 | 128 | param_count--; | ||
100 | 129 | continue; | ||
101 | 130 | } | ||
102 | 124 | /* parameter length + 8 byte header */ | 131 | /* parameter length + 8 byte header */ |
103 | 125 | param_lengths+= stmt->query_params[current_param].length + 8; | 132 | param_lengths+= stmt->query_params[current_param].length + 8; |
104 | 126 | } | 133 | } |
105 | @@ -130,7 +137,7 @@ | |||
106 | 130 | + 4 /* Reserved (always set to 1) */ | 137 | + 4 /* Reserved (always set to 1) */ |
107 | 131 | + stmt->null_bitmap_length /* Null bitmap length */ | 138 | + stmt->null_bitmap_length /* Null bitmap length */ |
108 | 132 | + 1 /* New parameters bound flag */ | 139 | + 1 /* New parameters bound flag */ |
110 | 133 | + (stmt->param_count * 2) /* Parameter type data */ | 140 | + (param_count * 2) /* Parameter type data */ |
111 | 134 | + param_lengths; /* Parameter data */ | 141 | + param_lengths; /* Parameter data */ |
112 | 135 | 142 | ||
113 | 136 | buffer = new (std::nothrow) unsigned char[buffer_size]; | 143 | buffer = new (std::nothrow) unsigned char[buffer_size]; |
114 | @@ -149,7 +156,6 @@ | |||
115 | 149 | drizzle_set_byte4(&buffer[5], 1); | 156 | drizzle_set_byte4(&buffer[5], 1); |
116 | 150 | buffer_pos+= 9; | 157 | buffer_pos+= 9; |
117 | 151 | /* Null bitmap */ | 158 | /* Null bitmap */ |
118 | 152 | memcpy(buffer_pos, stmt->null_bitmap, stmt->null_bitmap_length); | ||
119 | 153 | buffer_pos+= stmt->null_bitmap_length; | 159 | buffer_pos+= stmt->null_bitmap_length; |
120 | 154 | /* New parameters bound flag | 160 | /* New parameters bound flag |
121 | 155 | * If set to 1 then we need to leave a gap between the parameters type data | 161 | * If set to 1 then we need to leave a gap between the parameters type data |
122 | @@ -162,7 +168,7 @@ | |||
123 | 162 | buffer_pos++; | 168 | buffer_pos++; |
124 | 163 | /* Each param has a 2 byte data type header so the data pointer should be | 169 | /* Each param has a 2 byte data type header so the data pointer should be |
125 | 164 | * moved to this */ | 170 | * moved to this */ |
127 | 165 | data_pos= buffer_pos + (stmt->param_count * 2); | 171 | data_pos= buffer_pos + (param_count * 2); |
128 | 166 | } | 172 | } |
129 | 167 | else | 173 | else |
130 | 168 | { | 174 | { |
131 | @@ -170,7 +176,7 @@ | |||
132 | 170 | buffer_pos++; | 176 | buffer_pos++; |
133 | 171 | data_pos= buffer_pos; | 177 | data_pos= buffer_pos; |
134 | 172 | } | 178 | } |
136 | 173 | 179 | memset(stmt->null_bitmap, 0, stmt->null_bitmap_length); | |
137 | 174 | /* Go through each param copying to buffer | 180 | /* Go through each param copying to buffer |
138 | 175 | * In an ideal world we would do this without the copy | 181 | * In an ideal world we would do this without the copy |
139 | 176 | * */ | 182 | * */ |
140 | @@ -184,13 +190,16 @@ | |||
141 | 184 | if (stmt->new_bind) | 190 | if (stmt->new_bind) |
142 | 185 | { | 191 | { |
143 | 186 | uint16_t type= (uint16_t)param_ptr->type; | 192 | uint16_t type= (uint16_t)param_ptr->type; |
145 | 187 | if (param_ptr->options.is_unsigned) | 193 | if (type != DRIZZLE_COLUMN_TYPE_NULL) |
146 | 188 | { | 194 | { |
149 | 189 | /* Set the unsigned bit flag on the type data */ | 195 | if (param_ptr->options.is_unsigned) |
150 | 190 | type |= 0x8000; | 196 | { |
151 | 197 | /* Set the unsigned bit flag on the type data */ | ||
152 | 198 | type |= 0x8000; | ||
153 | 199 | } | ||
154 | 200 | drizzle_set_byte2(buffer_pos, type); | ||
155 | 201 | buffer_pos+= 2; | ||
156 | 191 | } | 202 | } |
157 | 192 | drizzle_set_byte2(buffer_pos, type); | ||
158 | 193 | buffer_pos+= 2; | ||
159 | 194 | } | 203 | } |
160 | 195 | 204 | ||
161 | 196 | if (param_ptr->options.is_long_data) | 205 | if (param_ptr->options.is_long_data) |
162 | @@ -203,7 +212,7 @@ | |||
163 | 203 | { | 212 | { |
164 | 204 | case DRIZZLE_COLUMN_TYPE_NULL: | 213 | case DRIZZLE_COLUMN_TYPE_NULL: |
165 | 205 | /* Toggle the bit for this column in the bitmap */ | 214 | /* Toggle the bit for this column in the bitmap */ |
167 | 206 | *stmt->null_bitmap |= (current_param ^ 2); | 215 | stmt->null_bitmap[current_param/8] |= (1 << (current_param % 8)); |
168 | 207 | break; | 216 | break; |
169 | 208 | case DRIZZLE_COLUMN_TYPE_TINY: | 217 | case DRIZZLE_COLUMN_TYPE_TINY: |
170 | 209 | *data_pos= *(uint8_t*)param_ptr->data; | 218 | *data_pos= *(uint8_t*)param_ptr->data; |
171 | @@ -271,6 +280,8 @@ | |||
172 | 271 | break; | 280 | break; |
173 | 272 | } | 281 | } |
174 | 273 | } | 282 | } |
175 | 283 | /* Copy NULL bitmap */ | ||
176 | 284 | memcpy(&buffer[9], stmt->null_bitmap, stmt->null_bitmap_length); | ||
177 | 274 | if (stmt->execute_result) | 285 | if (stmt->execute_result) |
178 | 275 | { | 286 | { |
179 | 276 | drizzle_result_free(stmt->execute_result); | 287 | drizzle_result_free(stmt->execute_result); |
180 | @@ -379,7 +390,7 @@ | |||
181 | 379 | drizzle_return_t drizzle_stmt_fetch(drizzle_stmt_st *stmt) | 390 | drizzle_return_t drizzle_stmt_fetch(drizzle_stmt_st *stmt) |
182 | 380 | { | 391 | { |
183 | 381 | drizzle_return_t ret= DRIZZLE_RETURN_OK; | 392 | drizzle_return_t ret= DRIZZLE_RETURN_OK; |
185 | 382 | uint16_t column_counter= 0; | 393 | uint16_t column_counter= 0, current_column= 0; |
186 | 383 | drizzle_row_t row; | 394 | drizzle_row_t row; |
187 | 384 | drizzle_column_st *column; | 395 | drizzle_column_st *column; |
188 | 385 | 396 | ||
189 | @@ -413,22 +424,25 @@ | |||
190 | 413 | } | 424 | } |
191 | 414 | drizzle_column_seek(stmt->execute_result, 0); | 425 | drizzle_column_seek(stmt->execute_result, 0); |
192 | 415 | 426 | ||
194 | 416 | while((column= drizzle_column_next(stmt->execute_result))) | 427 | for (column_counter = 0; column_counter < stmt->execute_result->column_count; column_counter++) |
195 | 417 | { | 428 | { |
196 | 418 | drizzle_bind_st *param= &stmt->result_params[column_counter]; | 429 | drizzle_bind_st *param= &stmt->result_params[column_counter]; |
200 | 419 | param->type= column->type; | 430 | /* if this row is null in the result bitmap, skip first 2 bits */ |
201 | 420 | /* if this row is null in the result bitmap */ | 431 | if (stmt->execute_result->null_bitmap[(column_counter+2)/8] & (1 << ((column_counter+2) % 8))) |
199 | 421 | if (*stmt->execute_result->null_bitmap & ((column_counter^2) << 2)) | ||
202 | 422 | { | 432 | { |
203 | 423 | param->options.is_null= true; | 433 | param->options.is_null= true; |
204 | 424 | param->length= 0; | 434 | param->length= 0; |
205 | 435 | param->type= DRIZZLE_COLUMN_TYPE_NULL; | ||
206 | 425 | } | 436 | } |
207 | 426 | else | 437 | else |
208 | 427 | { | 438 | { |
209 | 428 | uint16_t short_data; | 439 | uint16_t short_data; |
210 | 429 | uint32_t long_data; | 440 | uint32_t long_data; |
211 | 430 | uint64_t longlong_data; | 441 | uint64_t longlong_data; |
213 | 431 | param->length= stmt->execute_result->field_sizes[column_counter]; | 442 | column= drizzle_column_next(stmt->execute_result); |
214 | 443 | param->type= column->type; | ||
215 | 444 | param->options.is_null= false; | ||
216 | 445 | param->length= stmt->execute_result->field_sizes[current_column]; | ||
217 | 432 | if (column->flags & DRIZZLE_COLUMN_FLAGS_UNSIGNED) | 446 | if (column->flags & DRIZZLE_COLUMN_FLAGS_UNSIGNED) |
218 | 433 | { | 447 | { |
219 | 434 | param->options.is_unsigned= true; | 448 | param->options.is_unsigned= true; |
220 | @@ -442,42 +456,42 @@ | |||
221 | 442 | break; | 456 | break; |
222 | 443 | case DRIZZLE_COLUMN_TYPE_TINY: | 457 | case DRIZZLE_COLUMN_TYPE_TINY: |
223 | 444 | param->data= param->data_buffer; | 458 | param->data= param->data_buffer; |
225 | 445 | *(uint8_t*)param->data= *row[column_counter]; | 459 | *(uint8_t*)param->data= *row[current_column]; |
226 | 446 | break; | 460 | break; |
227 | 447 | case DRIZZLE_COLUMN_TYPE_SHORT: | 461 | case DRIZZLE_COLUMN_TYPE_SHORT: |
228 | 448 | case DRIZZLE_COLUMN_TYPE_YEAR: | 462 | case DRIZZLE_COLUMN_TYPE_YEAR: |
229 | 449 | param->data= param->data_buffer; | 463 | param->data= param->data_buffer; |
231 | 450 | short_data= drizzle_get_byte2(row[column_counter]); | 464 | short_data= drizzle_get_byte2(row[current_column]); |
232 | 451 | memcpy(param->data, &short_data, 2); | 465 | memcpy(param->data, &short_data, 2); |
233 | 452 | break; | 466 | break; |
234 | 453 | case DRIZZLE_COLUMN_TYPE_INT24: | 467 | case DRIZZLE_COLUMN_TYPE_INT24: |
235 | 454 | case DRIZZLE_COLUMN_TYPE_LONG: | 468 | case DRIZZLE_COLUMN_TYPE_LONG: |
236 | 455 | param->data= param->data_buffer; | 469 | param->data= param->data_buffer; |
238 | 456 | long_data= drizzle_get_byte4(row[column_counter]); | 470 | long_data= drizzle_get_byte4(row[current_column]); |
239 | 457 | memcpy(param->data, &long_data, 4); | 471 | memcpy(param->data, &long_data, 4); |
240 | 458 | break; | 472 | break; |
241 | 459 | case DRIZZLE_COLUMN_TYPE_LONGLONG: | 473 | case DRIZZLE_COLUMN_TYPE_LONGLONG: |
242 | 460 | param->data= param->data_buffer; | 474 | param->data= param->data_buffer; |
244 | 461 | longlong_data= drizzle_get_byte8(row[column_counter]); | 475 | longlong_data= drizzle_get_byte8(row[current_column]); |
245 | 462 | memcpy(param->data, &longlong_data, 8); | 476 | memcpy(param->data, &longlong_data, 8); |
246 | 463 | break; | 477 | break; |
247 | 464 | case DRIZZLE_COLUMN_TYPE_FLOAT: | 478 | case DRIZZLE_COLUMN_TYPE_FLOAT: |
248 | 465 | param->data= param->data_buffer; | 479 | param->data= param->data_buffer; |
250 | 466 | memcpy(param->data, row[column_counter], 4); | 480 | memcpy(param->data, row[current_column], 4); |
251 | 467 | break; | 481 | break; |
252 | 468 | case DRIZZLE_COLUMN_TYPE_DOUBLE: | 482 | case DRIZZLE_COLUMN_TYPE_DOUBLE: |
253 | 469 | param->data= param->data_buffer; | 483 | param->data= param->data_buffer; |
255 | 470 | memcpy(param->data, row[column_counter], 8); | 484 | memcpy(param->data, row[current_column], 8); |
256 | 471 | break; | 485 | break; |
257 | 472 | case DRIZZLE_COLUMN_TYPE_TIME: | 486 | case DRIZZLE_COLUMN_TYPE_TIME: |
258 | 473 | param->data= param->data_buffer; | 487 | param->data= param->data_buffer; |
260 | 474 | drizzle_unpack_time(row[column_counter], param->length, (drizzle_datetime_st *)param->data); | 488 | drizzle_unpack_time(row[current_column], param->length, (drizzle_datetime_st *)param->data); |
261 | 475 | break; | 489 | break; |
262 | 476 | case DRIZZLE_COLUMN_TYPE_DATE: | 490 | case DRIZZLE_COLUMN_TYPE_DATE: |
263 | 477 | case DRIZZLE_COLUMN_TYPE_DATETIME: | 491 | case DRIZZLE_COLUMN_TYPE_DATETIME: |
264 | 478 | case DRIZZLE_COLUMN_TYPE_TIMESTAMP: | 492 | case DRIZZLE_COLUMN_TYPE_TIMESTAMP: |
265 | 479 | param->data= param->data_buffer; | 493 | param->data= param->data_buffer; |
267 | 480 | drizzle_unpack_datetime(row[column_counter], param->length, (drizzle_datetime_st *)param->data); | 494 | drizzle_unpack_datetime(row[current_column], param->length, (drizzle_datetime_st *)param->data); |
268 | 481 | break; | 495 | break; |
269 | 482 | case DRIZZLE_COLUMN_TYPE_TINY_BLOB: | 496 | case DRIZZLE_COLUMN_TYPE_TINY_BLOB: |
270 | 483 | case DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB: | 497 | case DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB: |
271 | @@ -489,7 +503,7 @@ | |||
272 | 489 | case DRIZZLE_COLUMN_TYPE_DECIMAL: | 503 | case DRIZZLE_COLUMN_TYPE_DECIMAL: |
273 | 490 | case DRIZZLE_COLUMN_TYPE_NEWDECIMAL: | 504 | case DRIZZLE_COLUMN_TYPE_NEWDECIMAL: |
274 | 491 | case DRIZZLE_COLUMN_TYPE_NEWDATE: | 505 | case DRIZZLE_COLUMN_TYPE_NEWDATE: |
276 | 492 | param->data= row[column_counter]; | 506 | param->data= row[current_column]; |
277 | 493 | break; | 507 | break; |
278 | 494 | /* These types aren't handled yet, most are for older MySQL versions */ | 508 | /* These types aren't handled yet, most are for older MySQL versions */ |
279 | 495 | case DRIZZLE_COLUMN_TYPE_VARCHAR: | 509 | case DRIZZLE_COLUMN_TYPE_VARCHAR: |
280 | @@ -505,8 +519,8 @@ | |||
281 | 505 | ret= DRIZZLE_RETURN_UNEXPECTED_DATA; | 519 | ret= DRIZZLE_RETURN_UNEXPECTED_DATA; |
282 | 506 | break; | 520 | break; |
283 | 507 | } | 521 | } |
284 | 522 | current_column++; | ||
285 | 508 | } | 523 | } |
286 | 509 | column_counter++; | ||
287 | 510 | if (ret == DRIZZLE_RETURN_UNEXPECTED_DATA) | 524 | if (ret == DRIZZLE_RETURN_UNEXPECTED_DATA) |
288 | 511 | { | 525 | { |
289 | 512 | break; | 526 | break; |
290 | 513 | 527 | ||
291 | === modified file 'libdrizzle/statement_param.cc' | |||
292 | --- libdrizzle/statement_param.cc 2013-04-21 21:09:31 +0000 | |||
293 | +++ libdrizzle/statement_param.cc 2013-04-22 19:16:28 +0000 | |||
294 | @@ -41,7 +41,7 @@ | |||
295 | 41 | /* Internal function */ | 41 | /* Internal function */ |
296 | 42 | drizzle_return_t drizzle_stmt_set_param(drizzle_stmt_st *stmt, uint16_t param_num, drizzle_column_type_t type, void *data, uint32_t length, bool is_unsigned) | 42 | drizzle_return_t drizzle_stmt_set_param(drizzle_stmt_st *stmt, uint16_t param_num, drizzle_column_type_t type, void *data, uint32_t length, bool is_unsigned) |
297 | 43 | { | 43 | { |
299 | 44 | if ((stmt == NULL) || (param_num >= stmt->param_count) || (data == NULL)) | 44 | if ((stmt == NULL) || (param_num >= stmt->param_count)) |
300 | 45 | { | 45 | { |
301 | 46 | return DRIZZLE_RETURN_INVALID_ARGUMENT; | 46 | return DRIZZLE_RETURN_INVALID_ARGUMENT; |
302 | 47 | } | 47 | } |
303 | 48 | 48 | ||
304 | === modified file 'tests/unit/include.am' | |||
305 | --- tests/unit/include.am 2013-04-21 21:41:39 +0000 | |||
306 | +++ tests/unit/include.am 2013-04-22 19:16:28 +0000 | |||
307 | @@ -63,8 +63,6 @@ | |||
308 | 63 | tests_unit_nulls_LDADD= libdrizzle/libdrizzle.la | 63 | tests_unit_nulls_LDADD= libdrizzle/libdrizzle.la |
309 | 64 | check_PROGRAMS+= tests/unit/nulls | 64 | check_PROGRAMS+= tests/unit/nulls |
310 | 65 | noinst_PROGRAMS+= tests/unit/nulls | 65 | noinst_PROGRAMS+= tests/unit/nulls |
311 | 66 | # Currently fails due to https://bugs.launchpad.net/libdrizzle/+bug/1150195 | ||
312 | 67 | XFAIL_TESTS+= tests/unit/nulls | ||
313 | 68 | 66 | ||
314 | 69 | tests_unit_row_SOURCES= tests/unit/row.c | 67 | tests_unit_row_SOURCES= tests/unit/row.c |
315 | 70 | tests_unit_row_LDADD= libdrizzle/libdrizzle.la | 68 | tests_unit_row_LDADD= libdrizzle/libdrizzle.la |
316 | 71 | 69 | ||
317 | === modified file 'tests/unit/nulls.c' | |||
318 | --- tests/unit/nulls.c 2013-03-06 03:06:26 +0000 | |||
319 | +++ tests/unit/nulls.c 2013-04-22 19:16:28 +0000 | |||
320 | @@ -96,7 +96,7 @@ | |||
321 | 96 | 96 | ||
322 | 97 | #define NCOLS 11 | 97 | #define NCOLS 11 |
323 | 98 | 98 | ||
325 | 99 | char *querybuf = malloc(256 + 60*64); | 99 | char *querybuf = calloc(256 + 60*64, 1); |
326 | 100 | strcpy(querybuf, "insert into libdrizzle.t1 values "); | 100 | strcpy(querybuf, "insert into libdrizzle.t1 values "); |
327 | 101 | char *p = querybuf + strlen(querybuf); | 101 | char *p = querybuf + strlen(querybuf); |
328 | 102 | 102 | ||
329 | @@ -241,7 +241,7 @@ | |||
330 | 241 | uint32_t rowvalue; | 241 | uint32_t rowvalue; |
331 | 242 | 242 | ||
332 | 243 | #define GETNULLNESS(cn) isNull = drizzle_stmt_get_is_null(sth, cn, &driz_ret); ASSERT_EQ(driz_ret, DRIZZLE_RETURN_OK); | 243 | #define GETNULLNESS(cn) isNull = drizzle_stmt_get_is_null(sth, cn, &driz_ret); ASSERT_EQ(driz_ret, DRIZZLE_RETURN_OK); |
334 | 244 | #define NULLNOTNOW(cn) ASSERT_FALSE_(isNull, "Column %d, row %d should not be NULL", cn+1, cur_row); rowvalue = drizzle_stmt_get_int(sth, cn, &driz_ret); ASSERT_EQ(driz_ret,DRIZZLE_RETURN_OK); ASSERT_EQ(rowvalue, (unsigned)(rowbase + cn)); | 244 | #define NULLNOTNOW(cn) ASSERT_FALSE_(isNull, "Column %d, row %d should not be NULL", cn+1, cur_row); rowvalue = drizzle_stmt_get_int(sth, cn, &driz_ret); ASSERT_EQ(driz_ret,DRIZZLE_RETURN_OK); ASSERT_EQ_(rowvalue, (unsigned)(rowbase + cn), "Column %d, row %d has unexpected data, expected: %d, got: %d", cn+1, cur_row, rowbase+cn, rowvalue); |
335 | 245 | #define NULLMAYBE(cn, b) GETNULLNESS(cn); if (sym & b) { ASSERT_TRUE_(isNull, "Column %d, row %d should be NULL", cn+1, cur_row); } else { NULLNOTNOW(cn); } | 245 | #define NULLMAYBE(cn, b) GETNULLNESS(cn); if (sym & b) { ASSERT_TRUE_(isNull, "Column %d, row %d should be NULL", cn+1, cur_row); } else { NULLNOTNOW(cn); } |
336 | 246 | #define NULLNEVER(cn) GETNULLNESS(cn); NULLNOTNOW(cn); | 246 | #define NULLNEVER(cn) GETNULLNESS(cn); NULLNOTNOW(cn); |
337 | 247 | 247 | ||
338 | @@ -262,7 +262,7 @@ | |||
339 | 262 | #undef GETNULLNESS | 262 | #undef GETNULLNESS |
340 | 263 | #undef NULLNOTNOW | 263 | #undef NULLNOTNOW |
341 | 264 | } | 264 | } |
343 | 265 | ASSERT_EQ(cur_row, table_size); | 265 | ASSERT_EQ_(cur_row, table_size, "Current row not equal to table size, expected %d, got %d", table_size, cur_row); |
344 | 266 | ASSERT_EQ(drizzle_stmt_close(sth), DRIZZLE_RETURN_OK); | 266 | ASSERT_EQ(drizzle_stmt_close(sth), DRIZZLE_RETURN_OK); |
345 | 267 | #endif | 267 | #endif |
346 | 268 | 268 | ||
347 | @@ -273,6 +273,7 @@ | |||
348 | 273 | 273 | ||
349 | 274 | driz_ret= drizzle_quit(con); | 274 | driz_ret= drizzle_quit(con); |
350 | 275 | ASSERT_EQ_(DRIZZLE_RETURN_OK, driz_ret, "%s", drizzle_strerror(driz_ret)); | 275 | ASSERT_EQ_(DRIZZLE_RETURN_OK, driz_ret, "%s", drizzle_strerror(driz_ret)); |
352 | 276 | 276 | ||
353 | 277 | free(querybuf); | ||
354 | 277 | return EXIT_SUCCESS; | 278 | return EXIT_SUCCESS; |
355 | 278 | } | 279 | } |