Commit 716bd12
committed
SQL/JSON: Always coerce JsonExpr result at runtime
Instead of looking up casts at parse time for converting the result
of JsonPath* query functions to the specified or the default
RETURNING type, always perform the conversion at runtime using either
the target type's input function or the function
json_populate_type().
There are two motivations for this change:
1. json_populate_type() coerces to types with typmod such that any
string values that exceed length limit cause an error instead of
silent truncation, which is necessary to be standard-conforming.
2. It was possible to end up with a cast expression that doesn't
support soft handling of errors causing bugs in the of handling
ON ERROR clause.
JsonExpr.coercion_expr which would store the cast expression is no
longer necessary, so remove.
Bump catversion because stored rules change because of the above
removal.
Reported-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Jian He <jian.universality@gmail.com>
Discussion: Discussion: https://postgr.es/m/202405271326.5a5rprki64aw%40alvherre.pgsql1 parent c2d93c3 commit 716bd12
File tree
15 files changed
+213
-309
lines changed- src
- backend
- executor
- jit/llvm
- nodes
- parser
- utils/adt
- include
- catalog
- executor
- nodes
- utils
- test/regress
- expected
- sql
15 files changed
+213
-309
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
4313 | 4313 | | |
4314 | 4314 | | |
4315 | 4315 | | |
4316 | | - | |
4317 | | - | |
4318 | | - | |
4319 | | - | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
| 4319 | + | |
4320 | 4320 | | |
4321 | | - | |
| 4321 | + | |
| 4322 | + | |
4322 | 4323 | | |
| 4324 | + | |
4323 | 4325 | | |
4324 | 4326 | | |
4325 | 4327 | | |
| |||
4337 | 4339 | | |
4338 | 4340 | | |
4339 | 4341 | | |
4340 | | - | |
4341 | | - | |
4342 | | - | |
4343 | | - | |
4344 | | - | |
4345 | | - | |
4346 | | - | |
4347 | | - | |
4348 | | - | |
4349 | | - | |
4350 | | - | |
4351 | | - | |
4352 | | - | |
4353 | | - | |
4354 | | - | |
4355 | | - | |
4356 | | - | |
4357 | | - | |
4358 | | - | |
4359 | | - | |
4360 | | - | |
4361 | | - | |
4362 | | - | |
| 4342 | + | |
4363 | 4343 | | |
4364 | 4344 | | |
4365 | 4345 | | |
4366 | | - | |
| 4346 | + | |
| 4347 | + | |
4367 | 4348 | | |
4368 | 4349 | | |
4369 | 4350 | | |
| |||
4435 | 4416 | | |
4436 | 4417 | | |
4437 | 4418 | | |
4438 | | - | |
4439 | | - | |
| 4419 | + | |
| 4420 | + | |
4440 | 4421 | | |
4441 | 4422 | | |
4442 | 4423 | | |
| |||
4468 | 4449 | | |
4469 | 4450 | | |
4470 | 4451 | | |
4471 | | - | |
4472 | | - | |
| 4452 | + | |
| 4453 | + | |
4473 | 4454 | | |
4474 | 4455 | | |
4475 | 4456 | | |
| |||
4488 | 4469 | | |
4489 | 4470 | | |
4490 | 4471 | | |
4491 | | - | |
| 4472 | + | |
4492 | 4473 | | |
4493 | 4474 | | |
4494 | 4475 | | |
| |||
4501 | 4482 | | |
4502 | 4483 | | |
4503 | 4484 | | |
| 4485 | + | |
4504 | 4486 | | |
4505 | 4487 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4303 | 4303 | | |
4304 | 4304 | | |
4305 | 4305 | | |
4306 | | - | |
4307 | 4306 | | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
| 4312 | + | |
| 4313 | + | |
4308 | 4314 | | |
4309 | 4315 | | |
4310 | 4316 | | |
| |||
4316 | 4322 | | |
4317 | 4323 | | |
4318 | 4324 | | |
4319 | | - | |
4320 | | - | |
4321 | | - | |
4322 | | - | |
4323 | | - | |
4324 | | - | |
4325 | | - | |
4326 | | - | |
4327 | | - | |
4328 | | - | |
4329 | | - | |
4330 | | - | |
4331 | | - | |
4332 | | - | |
4333 | | - | |
4334 | | - | |
4335 | 4325 | | |
4336 | 4326 | | |
4337 | 4327 | | |
| |||
4343 | 4333 | | |
4344 | 4334 | | |
4345 | 4335 | | |
4346 | | - | |
| 4336 | + | |
4347 | 4337 | | |
4348 | 4338 | | |
4349 | 4339 | | |
| |||
4355 | 4345 | | |
4356 | 4346 | | |
4357 | 4347 | | |
| 4348 | + | |
| 4349 | + | |
| 4350 | + | |
| 4351 | + | |
| 4352 | + | |
4358 | 4353 | | |
4359 | 4354 | | |
4360 | 4355 | | |
4361 | 4356 | | |
4362 | 4357 | | |
4363 | | - | |
4364 | | - | |
4365 | | - | |
| 4358 | + | |
| 4359 | + | |
4366 | 4360 | | |
4367 | | - | |
4368 | | - | |
4369 | | - | |
| 4361 | + | |
| 4362 | + | |
| 4363 | + | |
4370 | 4364 | | |
4371 | 4365 | | |
4372 | 4366 | | |
| |||
4545 | 4539 | | |
4546 | 4540 | | |
4547 | 4541 | | |
4548 | | - | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
4549 | 4545 | | |
4550 | 4546 | | |
4551 | 4547 | | |
4552 | | - | |
4553 | | - | |
4554 | | - | |
| 4548 | + | |
| 4549 | + | |
4555 | 4550 | | |
4556 | 4551 | | |
4557 | 4552 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2010 | 2010 | | |
2011 | 2011 | | |
2012 | 2012 | | |
2013 | | - | |
| 2013 | + | |
2014 | 2014 | | |
2015 | 2015 | | |
2016 | 2016 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1006 | 1006 | | |
1007 | 1007 | | |
1008 | 1008 | | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
| 1009 | + | |
1013 | 1010 | | |
1014 | 1011 | | |
1015 | 1012 | | |
| |||
1265 | 1262 | | |
1266 | 1263 | | |
1267 | 1264 | | |
1268 | | - | |
1269 | | - | |
1270 | | - | |
1271 | | - | |
| 1265 | + | |
1272 | 1266 | | |
1273 | 1267 | | |
1274 | 1268 | | |
| |||
2368 | 2362 | | |
2369 | 2363 | | |
2370 | 2364 | | |
2371 | | - | |
2372 | | - | |
2373 | 2365 | | |
2374 | 2366 | | |
2375 | 2367 | | |
| |||
3411 | 3403 | | |
3412 | 3404 | | |
3413 | 3405 | | |
3414 | | - | |
3415 | 3406 | | |
3416 | 3407 | | |
3417 | 3408 | | |
| |||
0 commit comments