forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc16a1bb
committed
Add documentation and tests for quote marks in ECPG literal queries.
ECPG's PREPARE ... FROM and EXECUTE IMMEDIATE can optionally takethe target query as a simple literal, rather than the more usualstring-variable reference. This was previously documented asbeing a C string literal, but that's a lie in one critical respect:you can't write a data double quote as \" in such literals. That'sbecause the lexer is in SQL mode at this point, so it'll parsedouble-quoted strings as SQL identifiers, within which backslashis not special, so \" ends the literal.I looked into making this work as documented, but getting the lexerto switch behaviors at just the right point is somewhere betweenvery difficult and impossible. It's not really worth the trouble,because these cases are next to useless: if you have a fixed SQLstatement to execute or prepare, you might as well write it asa direct EXEC SQL, saving the messiness of converting it intoa string literal and gaining the opportunity for compile-timeSQL syntax checking.Instead, let's just document (and test) the workaround of writinga double quote as an octal escape (\042) in such cases.There's no code behavioral change here, so in principle this couldbe back-patched, but it's such a niche case I doubt it's worththe trouble.Per report from 1250kv.Discussion:https://postgr.es/m/673825.1603223178@sss.pgh.pa.us1 parent3dfb194 commitc16a1bb
File tree
5 files changed
+67
-11
lines changed- doc/src/sgml
- src/interfaces/ecpg
- preproc
- test
- expected
- sql
5 files changed
+67
-11
lines changedLines changed: 54 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7066 | 7066 |
| |
7067 | 7067 |
| |
7068 | 7068 |
| |
7069 |
| - | |
| 7069 | + | |
7070 | 7070 |
| |
7071 | 7071 |
| |
7072 | 7072 |
| |
7073 | 7073 |
| |
7074 | 7074 |
| |
7075 | 7075 |
| |
7076 | 7076 |
| |
| 7077 | + | |
| 7078 | + | |
| 7079 | + | |
| 7080 | + | |
| 7081 | + | |
| 7082 | + | |
| 7083 | + | |
| 7084 | + | |
| 7085 | + | |
| 7086 | + | |
| 7087 | + | |
| 7088 | + | |
| 7089 | + | |
| 7090 | + | |
| 7091 | + | |
| 7092 | + | |
| 7093 | + | |
| 7094 | + | |
| 7095 | + | |
| 7096 | + | |
| 7097 | + | |
| 7098 | + | |
| 7099 | + | |
| 7100 | + | |
7077 | 7101 |
| |
7078 | 7102 |
| |
7079 | 7103 |
| |
| |||
7388 | 7412 |
| |
7389 | 7413 |
| |
7390 | 7414 |
| |
7391 |
| - | |
| 7415 | + | |
7392 | 7416 |
| |
7393 | 7417 |
| |
7394 | 7418 |
| |
| |||
7421 | 7445 |
| |
7422 | 7446 |
| |
7423 | 7447 |
| |
7424 |
| - | |
7425 |
| - | |
7426 |
| - | |
| 7448 | + | |
| 7449 | + | |
| 7450 | + | |
| 7451 | + | |
7427 | 7452 |
| |
7428 | 7453 |
| |
7429 | 7454 |
| |
7430 | 7455 |
| |
7431 | 7456 |
| |
7432 | 7457 |
| |
| 7458 | + | |
| 7459 | + | |
| 7460 | + | |
| 7461 | + | |
| 7462 | + | |
| 7463 | + | |
| 7464 | + | |
| 7465 | + | |
| 7466 | + | |
| 7467 | + | |
| 7468 | + | |
| 7469 | + | |
| 7470 | + | |
| 7471 | + | |
| 7472 | + | |
| 7473 | + | |
| 7474 | + | |
| 7475 | + | |
| 7476 | + | |
| 7477 | + | |
| 7478 | + | |
| 7479 | + | |
| 7480 | + | |
| 7481 | + | |
7433 | 7482 |
| |
7434 | 7483 |
| |
7435 | 7484 |
| |
|
Lines changed: 8 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
715 | 715 |
| |
716 | 716 |
| |
717 | 717 |
| |
718 |
| - | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
719 | 726 |
| |
720 | 727 |
| |
721 | 728 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
77 | 77 |
| |
78 | 78 |
| |
79 | 79 |
| |
80 |
| - | |
81 |
| - | |
| 80 | + | |
| 81 | + | |
82 | 82 |
| |
83 | 83 |
| |
84 | 84 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
13 |
| - | |
| 13 | + | |
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
28 |
| - | |
29 |
| - | |
| 28 | + | |
| 29 | + | |
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
|
0 commit comments
Comments
(0)