forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3ab8b7f
committed
Fix/improve bytea and boolean support in PL/Python
Before, PL/Python converted data between SQL and Python by goingthrough a C string representation. This broke for bytea in two ways:- On input (function parameters), you would get a Python string that contains bytea's particular external representation with backslashes etc., instead of a sequence of bytes, which is what you would expect in a Python environment. This problem is exacerbated by the new bytea output format.- On output (function return value), null bytes in the Python string would cause truncation before the data gets stored into a bytea datum.This is now fixed by converting directly between the PostgreSQL datumand the Python representation.The required generalized infrastructure also allows for otherimprovements in passing:- When returning a boolean value, the SQL datum is now true if and only if Python considers the value that was passed out of the PL/Python function to be true. Previously, this determination was left to the boolean data type input function. So, now returning 'foo' results in true, because Python considers it true, rather than false because PostgreSQL considers it false.- On input, we can convert the integer and float types directly to their Python equivalents without having to go through an intermediate string representation.original patch by Caleb Welton, with updates by myself1 parent255f66e commit3ab8b7f
File tree
5 files changed
+454
-145
lines changed- src
- backend/utils/adt
- include/utils
- pl/plpython
- expected
- sql
5 files changed
+454
-145
lines changedLines changed: 38 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
28 |
| - | |
| 28 | + | |
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| |||
302 | 302 |
| |
303 | 303 |
| |
304 | 304 |
| |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + |
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
137 | 137 |
| |
138 | 138 |
| |
139 | 139 |
| |
| 140 | + | |
140 | 141 |
| |
141 | 142 |
| |
142 | 143 |
| |
|
Lines changed: 115 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
35 | 103 |
| |
36 | 104 |
| |
37 | 105 |
| |
| |||
278 | 346 |
| |
279 | 347 |
| |
280 | 348 |
| |
281 |
| - | |
| 349 | + | |
282 | 350 |
| |
283 | 351 |
| |
284 | 352 |
| |
285 | 353 |
| |
286 | 354 |
| |
287 | 355 |
| |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
288 | 364 |
| |
289 | 365 |
| |
290 | 366 |
| |
| |||
304 | 380 |
| |
305 | 381 |
| |
306 | 382 |
| |
307 |
| - | |
308 |
| - | |
309 | 383 |
| |
310 |
| - | |
311 |
| - | |
312 |
| - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
313 | 387 |
| |
314 | 388 |
| |
315 | 389 |
| |
316 | 390 |
| |
317 | 391 |
| |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
318 | 408 |
| |
319 | 409 |
| |
320 | 410 |
| |
| |||
342 | 432 |
| |
343 | 433 |
| |
344 | 434 |
| |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
345 | 451 |
| |
346 | 452 |
| |
347 | 453 |
| |
348 | 454 |
| |
349 | 455 |
| |
350 | 456 |
| |
351 |
| - | |
| 457 | + | |
352 | 458 |
| |
353 | 459 |
| |
354 | 460 |
| |
| |||
358 | 464 |
| |
359 | 465 |
| |
360 | 466 |
| |
361 |
| - | |
| 467 | + | |
362 | 468 |
| |
363 | 469 |
| |
364 | 470 |
| |
365 | 471 |
| |
366 | 472 |
| |
367 | 473 |
| |
368 | 474 |
| |
369 |
| - | |
| 475 | + | |
370 | 476 |
| |
371 | 477 |
| |
372 | 478 |
| |
|
0 commit comments
Comments
(0)