forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6f0cef9
committed
Fix assorted bugs in ecpg's macro mechanism.
The code associated with EXEC SQL DEFINE was unreadable and full ofbugs, notably:* It'd attempt to free a non-malloced string if the ecpg programtries to redefine a macro that was defined on the command line.* Possible memory stomp if user writes "-D=foo".* Undef'ing or redefining a macro defined on the command line wouldchange the state visible to the next file, when multiple files arespecified on the command line. (While possibly that could have beenan intentional choice, the code clearly intends to revert to theoriginal macro state; it's just failing to consider this interaction.)* Missing "break" in defining a new macro meant that redefinitionof an existing name would cause an extra entry to be added to thedefinition list. While not immediately harmful, a subsequent undefwould result in the prior entry becoming visible again.* The interactions with input buffering are subtle and were entirelyundocumented.It's not that surprising that we hadn't noticed these bugs,because there was no test coverage at all of either the -Dcommand line switch or multiple input files. This patch addssuch coverage (in a rather hacky way I guess).In addition to the code bugs, the user documentation was confusedabout whether the -D switch defines a C macro or an ecpg one, andit failed to mention that you can write "-Dsymbol=value".These problems are old, so back-patch to all supported branches.Discussion:https://postgr.es/m/998011.1713217712@sss.pgh.pa.us1 parentc62d2eb commit6f0cef9
File tree
12 files changed
+289
-80
lines changed- doc/src/sgml
- ref
- src/interfaces/ecpg
- preproc
- test
- expected
- sql
12 files changed
+289
-80
lines changedLines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5793 | 5793 |
| |
5794 | 5794 |
| |
5795 | 5795 |
| |
| 5796 | + | |
| 5797 | + | |
| 5798 | + | |
| 5799 | + | |
| 5800 | + | |
| 5801 | + | |
| 5802 | + | |
| 5803 | + | |
5796 | 5804 |
| |
5797 | 5805 |
| |
5798 | 5806 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
93 | 93 |
| |
94 | 94 |
| |
95 | 95 |
| |
96 |
| - | |
| 96 | + | |
97 | 97 |
| |
98 | 98 |
| |
99 |
| - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
100 | 102 |
| |
101 | 103 |
| |
102 | 104 |
| |
|
Lines changed: 46 additions & 33 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
82 | 82 |
| |
83 | 83 |
| |
84 | 84 |
| |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 |
| |
86 | 89 |
| |
87 | 90 |
| |
88 |
| - | |
89 |
| - | |
90 |
| - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
91 | 95 |
| |
92 |
| - | |
| 96 | + | |
93 | 97 |
| |
94 | 98 |
| |
95 | 99 |
| |
96 | 100 |
| |
97 | 101 |
| |
| 102 | + | |
98 | 103 |
| |
99 | 104 |
| |
100 |
| - | |
101 |
| - | |
| 105 | + | |
| 106 | + | |
102 | 107 |
| |
103 |
| - | |
104 |
| - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
105 | 114 |
| |
106 | 115 |
| |
107 | 116 |
| |
108 |
| - | |
109 |
| - | |
| 117 | + | |
| 118 | + | |
110 | 119 |
| |
111 |
| - | |
112 |
| - | |
113 |
| - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
114 | 125 |
| |
115 | 126 |
| |
116 | 127 |
| |
| |||
348 | 359 |
| |
349 | 360 |
| |
350 | 361 |
| |
| 362 | + | |
| 363 | + | |
351 | 364 |
| |
352 | 365 |
| |
353 | 366 |
| |
| |||
385 | 398 |
| |
386 | 399 |
| |
387 | 400 |
| |
388 |
| - | |
389 |
| - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
390 | 404 |
| |
391 |
| - | |
392 |
| - | |
393 |
| - | |
394 |
| - | |
395 |
| - | |
396 |
| - | |
397 |
| - | |
398 |
| - | |
399 |
| - | |
400 |
| - | |
401 |
| - | |
402 |
| - | |
403 |
| - | |
| 405 | + | |
| 406 | + | |
404 | 407 |
| |
405 |
| - | |
406 |
| - | |
407 |
| - | |
408 |
| - | |
409 |
| - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
410 | 423 |
| |
411 | 424 |
| |
412 | 425 |
| |
|
Lines changed: 89 additions & 38 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
72 |
| - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
73 | 80 |
| |
74 | 81 |
| |
75 | 82 |
| |
76 | 83 |
| |
77 | 84 |
| |
78 | 85 |
| |
79 | 86 |
| |
80 |
| - | |
81 |
| - | |
82 | 87 |
| |
83 | 88 |
| |
84 | 89 |
| |
| |||
444 | 449 |
| |
445 | 450 |
| |
446 | 451 |
| |
| 452 | + | |
| 453 | + | |
447 | 454 |
| |
448 | 455 |
| |
449 | 456 |
| |
| |||
1010 | 1017 |
| |
1011 | 1018 |
| |
1012 | 1019 |
| |
| 1020 | + | |
1013 | 1021 |
| |
1014 | 1022 |
| |
1015 | 1023 |
| |
| |||
1198 | 1206 |
| |
1199 | 1207 |
| |
1200 | 1208 |
| |
1201 |
| - | |
| 1209 | + | |
| 1210 | + | |
1202 | 1211 |
| |
1203 |
| - | |
| 1212 | + | |
1204 | 1213 |
| |
1205 |
| - | |
1206 |
| - | |
1207 |
| - | |
1208 |
| - | |
1209 |
| - | |
1210 |
| - | |
1211 |
| - | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
1212 | 1226 |
| |
1213 | 1227 |
| |
1214 | 1228 |
| |
| |||
1413 | 1427 |
| |
1414 | 1428 |
| |
1415 | 1429 |
| |
1416 |
| - | |
1417 |
| - | |
1418 |
| - | |
1419 |
| - | |
1420 |
| - | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
1421 | 1441 |
| |
1422 | 1442 |
| |
1423 | 1443 |
| |
| |||
1438 | 1458 |
| |
1439 | 1459 |
| |
1440 | 1460 |
| |
1441 |
| - | |
| 1461 | + | |
1442 | 1462 |
| |
1443 | 1463 |
| |
1444 | 1464 |
| |
| |||
1447 | 1467 |
| |
1448 | 1468 |
| |
1449 | 1469 |
| |
1450 |
| - | |
| 1470 | + | |
1451 | 1471 |
| |
| 1472 | + | |
1452 | 1473 |
| |
1453 | 1474 |
| |
1454 |
| - | |
1455 |
| - | |
1456 |
| - | |
1457 |
| - | |
1458 |
| - | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
1459 | 1483 |
| |
1460 | 1484 |
| |
1461 | 1485 |
| |
1462 |
| - | |
1463 |
| - | |
1464 |
| - | |
1465 |
| - | |
1466 |
| - | |
1467 |
| - | |
1468 |
| - | |
1469 |
| - | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
1470 | 1495 |
| |
1471 | 1496 |
| |
1472 | 1497 |
| |
| |||
1483 | 1508 |
| |
1484 | 1509 |
| |
1485 | 1510 |
| |
| 1511 | + | |
1486 | 1512 |
| |
1487 | 1513 |
| |
1488 | 1514 |
| |
| |||
1492 | 1518 |
| |
1493 | 1519 |
| |
1494 | 1520 |
| |
| 1521 | + | |
1495 | 1522 |
| |
1496 | 1523 |
| |
1497 | 1524 |
| |
1498 | 1525 |
| |
| 1526 | + | |
1499 | 1527 |
| |
| 1528 | + | |
1500 | 1529 |
| |
1501 | 1530 |
| |
1502 | 1531 |
| |
1503 |
| - | |
| 1532 | + | |
1504 | 1533 |
| |
| 1534 | + | |
1505 | 1535 |
| |
1506 | 1536 |
| |
1507 | 1537 |
| |
| |||
1727 | 1757 |
| |
1728 | 1758 |
| |
1729 | 1759 |
| |
1730 |
| - | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
1731 | 1766 |
| |
1732 | 1767 |
| |
1733 | 1768 |
| |
1734 | 1769 |
| |
1735 | 1770 |
| |
1736 | 1771 |
| |
1737 |
| - | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
1738 | 1776 |
| |
| 1777 | + | |
1739 | 1778 |
| |
1740 | 1779 |
| |
1741 | 1780 |
| |
| |||
1744 | 1783 |
| |
1745 | 1784 |
| |
1746 | 1785 |
| |
| 1786 | + | |
1747 | 1787 |
| |
1748 |
| - | |
| 1788 | + | |
| 1789 | + | |
1749 | 1790 |
| |
1750 |
| - | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
1751 | 1797 |
| |
1752 | 1798 |
| |
1753 | 1799 |
| |
1754 | 1800 |
| |
1755 | 1801 |
| |
1756 | 1802 |
| |
1757 | 1803 |
| |
1758 |
| - | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
1759 | 1810 |
| |
1760 | 1811 |
| |
1761 | 1812 |
| |
|
0 commit comments
Comments
(0)