summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/test/preproc
AgeCommit message (Collapse)Author
2025-01-01Update copyright for 2025Bruce Momjian
Backpatch-through: 13
2024-01-03Update copyright for 2024Bruce Momjian
Reported-by: Michael Paquier Discussion: https://postgr.es/m/ZZKTDPxBBMt3C0J9@paquier.xyz Backpatch-through: 12
2023-01-02Update copyright for 2023Bruce Momjian
Backpatch-through: 11
2022-12-20Add copyright notices to meson filesAndrew Dunstan
Discussion: https://postgr.es/m/222b43a5-2fb3-2c1b-9cd0-375d376c8246@dunslane.net
2022-09-21meson: Add initial version of meson based build systemAndres Freund
Autoconf is showing its age, fewer and fewer contributors know how to wrangle it. Recursive make has a lot of hard to resolve dependency issues and slow incremental rebuilds. Our home-grown MSVC build system is hard to maintain for developers not using Windows and runs tests serially. While these and other issues could individually be addressed with incremental improvements, together they seem best addressed by moving to a more modern build system. After evaluating different build system choices, we chose to use meson, to a good degree based on the adoption by other open source projects. We decided that it's more realistic to commit a relatively early version of the new build system and mature it in tree. This commit adds an initial version of a meson based build system. It supports building postgres on at least AIX, FreeBSD, Linux, macOS, NetBSD, OpenBSD, Solaris and Windows (however only gcc is supported on aix, solaris). For Windows/MSVC postgres can now be built with ninja (faster, particularly for incremental builds) and msbuild (supporting the visual studio GUI, but building slower). Several aspects (e.g. Windows rc file generation, PGXS compatibility, LLVM bitcode generation, documentation adjustments) are done in subsequent commits requiring further review. Other aspects (e.g. not installing test-only extensions) are not yet addressed. When building on Windows with msbuild, builds are slower when using a visual studio version older than 2019, because those versions do not support MultiToolTask, required by meson for intra-target parallelism. The plan is to remove the MSVC specific build system in src/tools/msvc soon after reaching feature parity. However, we're not planning to remove the autoconf/make build system in the near future. Likely we're going to keep at least the parts required for PGXS to keep working around until all supported versions build with meson. Some initial help for postgres developers is at https://wiki.postgresql.org/wiki/Meson With contributions from Thomas Munro, John Naylor, Stone Tickle and others. Author: Andres Freund <andres@anarazel.de> Author: Nazir Bilal Yavuz <byavuz81@gmail.com> Author: Peter Eisentraut <peter@eisentraut.org> Reviewed-By: Peter Eisentraut <peter.eisentraut@enterprisedb.com> Discussion: https://postgr.es/m/20211012083721.hvixq4pnh2pixr3j@alap3.anarazel.de
2022-09-09Fix possible omission of variable storage markers in ECPG.Tom Lane
The ECPG preprocessor converted code such as static varchar str1[10], str2[20], str3[30]; into static struct varchar_1 { int len; char arr[ 10 ]; } str1 ; struct varchar_2 { int len; char arr[ 20 ]; } str2 ; struct varchar_3 { int len; char arr[ 30 ]; } str3 ; thus losing the storage attribute for the later variables. Repeat the declaration for each such variable. (Note that this occurred only for variables declared "varchar" or "bytea", which may help explain how it escaped detection for so long.) Andrey Sokolov Discussion: https://postgr.es/m/942241662288242@mail.yandex.ru
2022-07-12Fix ECPG's handling of type names that match SQL keywords.Tom Lane
Previously, ECPG could only cope with variable declarations whose type names either weren't any SQL keyword, or were at least partially reserved. If you tried to use something in the unreserved_keyword category, you got a syntax error. This is pretty awful, not only because it says right on the tin that those words are not reserved, but because the set of such keywords tends to grow over time. Thus, an ECPG program that was just fine last year could fail when recompiled with a newer SQL grammar. We had to work around this recently when STRING became a keyword, but it's time for an actual fix instead of a band-aid. To fix, borrow a trick from C parsers and make the lexer's behavior change when it sees a word that is known as a typedef. This is not free of downsides: if you try to use such a name as a SQL keyword in EXEC SQL later in the program, it won't be recognized as a SQL keyword, leading to a syntax error there instead. So in a real sense this is just trading one hazard for another. But there is an important difference: with this, whether your ECPG program works depends only on what typedef names and SQL commands are used in the program text. If it compiles today it'll still compile next year, even if more words have become SQL keywords. Discussion: https://postgr.es/m/3661437.1653855582@sss.pgh.pa.us
2021-01-25Remove duplicate includePeter Eisentraut
Reported-by: Ashutosh Sharma <ashu.coek88@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CAE9k0PkORqHHGKY54-sFyDpP90yAf%2B05Auc4fs9EAn4J%2BuBeUQ%40mail.gmail.com
2020-11-07Avoid re-using output variables in new ecpg test case.Tom Lane
The buildfarm thinks this leads to memory stomps, though annoyingly I can't duplicate that here. The existing code in strings.pgc is doing something that doesn't seem to be sanctioned at all really by the documentation, but I'm disinclined to try to make that nicer right now. Let's just declare some more output variables in hopes of working around it.
2020-11-07Fix ecpg's mishandling of B'...' and X'...' literals.Tom Lane
These were broken in multiple ways: * The xbstart and xhstart lexer actions neglected to set "state_before_str_start" before transitioning to the xb/xh states, thus possibly resulting in "internal error: unreachable state" later. * The test for valid string contents at the end of xb state was flat out wrong, as it accounted incorrectly for the "b" prefix that the xbstart action had injected. Meanwhile, the xh state had no such check at all. * The generated literal value failed to include any quote marks. * The grammar did the wrong thing anyway, typically ignoring the literal value and emitting something else, since BCONST and XCONST tokens were handled randomly differently from SCONST tokens. The first of these problems is evidently an oversight in commit 7f380c59f, but the others seem to be very ancient. The lack of complaints shows that ECPG users aren't using these syntaxes much (although I do vaguely remember one previous complaint). As written, this patch is dependent on 7f380c59f, so it can't go back further than v13. Given the shortage of complaints, I'm not excited about adapting the patch to prior branches. Report and patch by Shenhao Wang (test case adjusted by me) Discussion: https://postgr.es/m/d6402f1bacb74ecba22ef715dbba17fd@G08CNEXMBPEKD06.g08.fujitsu.local
2020-10-22Avoid premature de-doubling of quote marks in ECPG strings.Tom Lane
If you write the literal 'abc''def' in an EXEC SQL command, that will come out the other end as 'abc'def', triggering a syntax error in the backend. Likewise, "abc""def" is reduced to "abc"def" which is wrong syntax for a quoted identifier. The cause is that the lexer thinks it should emit just one quote mark, whereas what it really should do is keep the string as-is. Add some docs and test cases, too. Although this seems clearly a bug, I fear users wouldn't appreciate changing it in minor releases. Some may well be working around it by applying an extra doubling of affected quotes, as for example sql/dyntest.pgc has been doing. Per investigation of a report from 1250kv, although this isn't exactly what he/she was on about. Discussion: https://postgr.es/m/673825.1603223178@sss.pgh.pa.us
2020-08-03Fix behavior of ecpg's "EXEC SQL elif name".Tom Lane
This ought to work much like C's "#elif defined(name)"; but the code implemented it in a way equivalent to endif followed by ifdef, so that it didn't matter whether any previous branch of the IF construct had succeeded. Fix that; add some test cases covering elif and nested IFs; and improve the documentation, which also seemed a bit confused. AFAICS the code has been like this since the feature was added in 1999 (commit b57b0e044). So while it's surely wrong, there might be code out there relying on the current behavior. Hence, don't back-patch into stable branches. It seems all right to fix it in v13 though. Per report from Ashutosh Sharma. Reviewed by Ashutosh Sharma and Michael Meskes. Discussion: https://postgr.es/m/CAE9k0P=dQk9X0cU2tN49S7a9tv733-e1pVdpB1P-pWJ5PdTktg@mail.gmail.com
2019-06-08Stop using spelling "nonexistant".Noah Misch
The documentation used "nonexistent" exclusively, and the source tree used it three times as often as "nonexistant".
2019-01-30Make some ecpg test cases more robust against unexpected errors that happenMichael Meskes
during development. Test cases themselves should not hang or segfault.
2019-01-24Remove infinite-loop hazards in ecpg test suite.Tom Lane
A report from Andrew Dunstan showed that an ecpglib breakage that causes repeated query failures could lead to infinite loops in some ecpg test scripts, because they contain "while(1)" loops with no exit condition other than successful test completion. That might be all right for manual testing, but it seems entirely unacceptable for automated test environments such as our buildfarm. We don't want buildfarm owners to have to intervene manually when a test goes wrong. To fix, just change all those while(1) loops to exit after at most 100 iterations (which is more than any of them expect to iterate). This seems sufficient since we'd see discrepancies in the test output if any loop executed the wrong number of times. I tested this by dint of intentionally breaking ecpg_do_prologue to always fail, and verifying that the tests still got to completion. Back-patch to all supported branches, since the whole point of this exercise is to protect the buildfarm against future mistakes. Discussion: https://postgr.es/m/18693.1548302004@sss.pgh.pa.us
2018-05-20printf("%lf") is not portable, so omit the "l".Tom Lane
The "l" (ell) width spec means something in the corresponding scanf usage, but not here. While modern POSIX says that applying "l" to "f" and other floating format specs is a no-op, SUSv2 says it's undefined. Buildfarm experience says that some old compilers emit warnings about it, and at least one old stdio implementation (mingw's "ANSI" option) actually produces wrong answers and/or crashes. Discussion: https://postgr.es/m/21670.1526769114@sss.pgh.pa.us Discussion: https://postgr.es/m/c085e1da-0d64-1c15-242d-c921f32e0d5c@dunslane.net
2017-11-10Add some const decorations to prototypesPeter Eisentraut
Reviewed-by: Fabien COELHO <coelho@cri.ensmp.fr>
2017-09-05Remove unnecessary parentheses in return statementsPeter Eisentraut
The parenthesized style has only been used in a few modules. Change that to use the style that is predominant across the whole tree. Reviewed-by: Michael Paquier <michael.paquier@gmail.com> Reviewed-by: Ryan Murphy <ryanfmurphy@gmail.com>
2017-08-25Fix locale dependency in new ecpg test case.Tom Lane
Force sorting in "C" locale so that the output ordering doesn't vary, per buildfarm. In passing, add missing .gitignore entries. Discussion: https://postgr.es/m/0975f4bb-5dee-c33c-b719-3ce44026d397@chrullrich.net
2017-08-25Implement DO CONTINUE action for ECPG WHENEVER statement.Michael Meskes
Author: Vinayak Pokale Reviewed-By: Masahiko Sawada
2015-03-09Revert "Ignore object files generated by ecpg test suite on Windows"Michael Meskes
This reverts commit b9e538b190d9cf4387361214eadc430393ebf852.
2015-03-09Ignore object files generated by ecpg test suite on WindowsMichael Meskes
Patch by Michael Paquier
2014-05-08Fix missing dependencies in ecpg's test Makefiles.Tom Lane
Ensure that ecpg preprocessor output files are rebuilt when re-testing after a change in the ecpg preprocessor itself, or a change in any of several include files that get copied verbatim into the output files. The lack of these dependencies was what created problems for Kevin Grittner after the recent pgindent run. There's no way for --enable-depend to discover these dependencies automatically, so we've gotta put them into the Makefiles by hand. While at it, reduce the amount of duplication in the ecpg invocations.
2014-04-23ecpg: Add additional files to .gitignorePeter Eisentraut
These are test files added by f9179685371b74bf4752bf3f87846e5625cf91fa.
2014-04-09Several fixes to array handling in ecpg.Michael Meskes
Patches by Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
2013-11-26ECPG: Free the malloc()'ed variables in the test so it comes out clean onMichael Meskes
Valgrind runs. Patch by Boszormenyi Zoltan <zb@cybertec.at>
2013-11-10Fix whitespace issues found by git diff --check, add gitattributesPeter Eisentraut
Set per file type attributes in .gitattributes to fine-tune whitespace checks. With the associated cleanups, the tree is now clean for git
2013-11-03Changed test case slightly so it doesn't have an unused typedef.Michael Meskes
2012-02-13Do not use the variable name when defining a varchar structure in ecpg.Michael Meskes
With a unique counter being added anyway, there is no need anymore to have the variable name listed, too.
2011-12-18Added test for cursor handling on different connections to regression testMichael Meskes
suite for ecpg.
2010-11-23Remove useless whitespace at end of linesPeter Eisentraut
2010-09-24Still more .gitignore cleanup.Tom Lane
Fix overly-enthusiastic ignores, as identified by git ls-files -i --exclude-standard
2010-09-22Add gitignore files for ecpg regression tests.Magnus Hagander
Backpatch to 8.2 as that's how far the structure looks the same.
2010-08-19Remove extra newlines at end and beginning of files, add missing newlinesPeter Eisentraut
at end of files.
2010-07-06pgindent run for 9.0, second runBruce Momjian
2010-03-22Fixed ECPG regression test to make sure it uses absolute paths for includeMichael Meskes
files instead of relative ones which break vpath builds.
2010-03-21ECPG only copied #include statements instead of processing them according toMichael Meskes
commandline option "-i". This change fixes this and adds a test case. It also honors #include_next, although this is probably never used for embedded SQL.
2010-03-09ecpg now adds a unique counter to its varchar struct definitions to make ↵Michael Meskes
these definitions unique, too. It used to use the linenumber but in the rare case of two definitions in one line this was not unique.
2010-02-26Revert pgindent changes to ecpg include files that are part of ecpgBruce Momjian
regession test output, and update pgindent script to avoid them in the future.
2010-02-26pgindent run for 9.0Bruce Momjian
2010-01-29Changed ECPG outofscope handling to always print out statements in the same ↵Michael Meskes
order so regression testing is possible, by Zoltan Boszormenyi
2010-01-26Added test case that was part of Zoltan's patch but apparently wasn't part ↵Michael Meskes
of my commit.
2010-01-26Applied patch by Boszormenyi Zoltan <zb@cybertec.at> to add out-of-scope ↵Michael Meskes
cursor support to native mode.
2010-01-22Applied patch by Boszormenyi Zoltan <zb@cybertec.at> to fix problem in ↵Michael Meskes
auto-prepare mode if the connection is closed and re-opened and the previously prepared query is issued again.
2009-12-16Fixed auto-prepare to not try preparing statements that are not preparable. BugMichael Meskes
found and solved by Boszormenyi Zoltan <zb@cybertec.at>, some small adjustments by me.
2009-11-26Added missing files.Michael Meskes
2009-11-26Added dynamic cursor names to ecpg. Almost the whole patch was done byMichael Meskes
Boszormenyi Zoltan, with only a minor tweak or two from me.
2009-05-20More variables gcc moans aboutMichael Meskes
2009-05-06Fix ecpg tests for change that disallowed Unicode literals unlessTom Lane
standard_conforming_strings is on.
2008-10-29Unicode escapes in strings and identifiersPeter Eisentraut