summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc/variable.c
AgeCommit message (Collapse)Author
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/[email protected]
2019-02-18Add bytea datatype to ECPG.Michael Meskes
So far ECPG programs had to treat binary data for bytea column as 'char' type. But this meant converting from/to escaped format with PQunescapeBytea/ PQescapeBytea() and therefore forcing users to add unnecessary code and cost for the conversion in runtime. By adding a dedicated datatype for bytea most of this special handling is no longer needed. Author: Matsumura-san ("Matsumura, Ryo" <[email protected]>) Discussion: https://postgr.es/m/flat/03040DFF97E6E54E88D3BFEE5F5480F737A141F9@G01JPEXMBYT04
2018-12-01Rename ecpg's various "extern.h" files to have distinct names.Tom Lane
This should reduce confusion, and in particular make it safe to copy typename.c into preproc/ and compile it there. This doesn't affect anything outside ecpg, and particularly not end users, because these files don't get installed; they just exist to share declarations among the .c files of each subdirectory. Discussion: https://postgr.es/m/[email protected]
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 <[email protected]> Reviewed-by: Ryan Murphy <[email protected]>
2017-06-21Initial pgindent run with pg_bsd_indent version 2.0.Tom Lane
The new indent version includes numerous fixes thanks to Piotr Stefaniak. The main changes visible in this commit are: * Nicer formatting of function-pointer declarations. * No longer unexpectedly removes spaces in expressions using casts, sizeof, or offsetof. * No longer wants to add a space in "struct structname *varname", as well as some similar cases for const- or volatile-qualified pointers. * Declarations using PG_USED_FOR_ASSERTS_ONLY are formatted more nicely. * Fixes bug where comments following declarations were sometimes placed with no space separating them from the code. * Fixes some odd decisions for comments following case labels. * Fixes some cases where comments following code were indented to less than the expected column 33. On the less good side, it now tends to put more whitespace around typedef names that are not listed in typedefs.list. This might encourage us to put more effort into typedef name collection; it's not really a bug in indent itself. There are more changes coming after this round, having to do with comment indentation and alignment of lines appearing within parentheses. I wanted to limit the size of the diffs to something that could be reviewed without one's eyes completely glazing over, so it seemed better to split up the changes as much as practical. Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/[email protected]
2016-12-11Use "%option prefix" to set API names in ecpg's lexer.Tom Lane
Clean up some technical debt left behind by commit 72b1e3a21: instead of quickly hacking the name of base_yylex() with a #define, set it properly with "%option prefix". This causes the names of pgc.l's other exported symbols to change as well, so run around and modify the outside references to them as needed. Similarly, make pgc.l's external references to base_yylval use that variable's true name instead of a macro. The reason for doing this now is that the quick-hack solution will fail with future versions of flex, as reported by Дилян Палаузов. Hence, back-patch into 9.6 where the previous commit appeared, since it's likely people will build 9.6 with newer flex versions during its lifetime. Discussion: https://postgr.es/m/[email protected]
2015-06-12Fixed some memory leaks in ECPG.Michael Meskes
Patch by Michael Paquier
2014-05-06pgindent run for 9.4Bruce Momjian
This includes removing tabs after periods in C comments, which was applied to back branches, so this change should not effect backpatching.
2014-03-03Fix whitespacePeter Eisentraut
2014-03-02Various Coverity-spotted fixesStephen Frost
A number of issues were identified by the Coverity scanner and are addressed in this patch. None of these appear to be security issues and many are mostly cosmetic changes. Short comments for each of the changes follows. Correct the semi-colon placement in be-secure.c regarding SSL retries. Remove a useless comparison-to-NULL in proc.c (value is dereferenced prior to this check and therefore can't be NULL). Add checking of chmod() return values to initdb. Fix a couple minor memory leaks in initdb. Fix memory leak in pg_ctl- involves free'ing the config file contents. Use an int to capture fgetc() return instead of an enum in pg_dump. Fix minor memory leaks in pg_dump. (note minor change to convertOperatorReference()'s API) Check fclose()/remove() return codes in psql. Check fstat(), find_my_exec() return codes in psql. Various ECPG memory leak fixes. Check find_my_exec() return in ECPG. Explicitly ignore pqFlush return in libpq error-path. Change PQfnumber() to avoid doing an strdup() when no changes required. Remove a few useless check-against-NULL's (value deref'd beforehand). Check rmtree(), malloc() results in pg_regress. Also check get_alternative_expectfile() return in pg_regress.
2013-11-20ecpg: Split off mmfatal() from mmerror()Peter Eisentraut
This allows decorating mmfatal() with noreturn compiler hints, leading to better diagnostics.
2012-11-29When processing nested structure pointer variables ecpg always expected anMichael Meskes
array datatype which of course is wrong. Applied patch by Muhammad Usama <[email protected]> to fix this.
2011-12-27Standardize treatment of strcmp() return valuePeter Eisentraut
Always compare the return value to 0, don't use cute tricks like if (!strcmp(...)).
2011-01-09There is no need to have to identical functions in ecpg thus removing one of ↵Michael Meskes
them.
2010-09-20Remove cvs keywords from all files.Magnus Hagander
2010-04-01Zoltan beautified his hidden-variable-patch for ecpg. This also makes sure ↵Michael Meskes
we get an error message instead of a warning if the variable have different types.
2010-04-01Applied Zoltan's patch to make ecpg spit out warnings if a local variable ↵Michael Meskes
hides a global one with the same name.
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-26pgindent run for 9.0Bruce Momjian
2010-01-26Applied patch by Boszormenyi Zoltan <[email protected]> to add out-of-scope ↵Michael Meskes
cursor support to native mode.
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-08-07Added STRING datatype for Informix compatibility mode. This work isMichael Meskes
based on a patch send in by Böszörményi Zoltán <[email protected]>.
2009-06-118.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian
provided by Andrew.
2009-03-26Gettext plural supportPeter Eisentraut
In the backend, I changed only a handful of exemplary or important-looking instances to make use of the plural support; there is probably more work there. For the rest of the source, this should cover all relevant cases.
2009-01-26Message format tuningPeter Eisentraut
2009-01-23Message style reviewPeter Eisentraut
2008-05-16Add localization support to ecpg.Peter Eisentraut
Author: Euler Taveira de Oliveira <[email protected]>
2008-02-07- Fixed segfault in ecpg when using an array element.Michael Meskes
- Free all memory in auto-prepare mode.
2007-12-21Fixed a few minor glitches pointed out by splint.Michael Meskes
2007-08-14- Finished major rewrite to use new protocol versionMichael Meskes
- Really prepare statements - Added more regression tests - Added auto-prepare mode - Use '$n' for positional variables, '?' is still possible via ecpg option - Cleaned up the sources a little bit
2006-07-30Replaced $Header$ by $§PosgreSQL$Michael Meskes
2006-07-30Added missing $Header$ entries.Michael Meskes
2005-10-15Standard pgindent run for 8.1.Bruce Momjian
2004-12-06Fixed bug in parsing of typedef'ed array sizes.Michael Meskes
Synced parser.
2004-08-29Pgindent run for 8.0.Bruce Momjian
2004-07-04Made sure SET DESCRIPTOR accepts all data types including constants.Michael Meskes
2004-06-30Added SET DESCRIPTOR command.Michael Meskes
Note that this still has some bugs. The functionality is there though, it's just a matter of fixing the bugs now. Cleaned up error handling in preprocessor.
2004-06-27- Only use typedefs inside their scope.Michael Meskes
- Variables that are out of scope, were not removed all the time. - Make a varchar NULL set everything to 0 when not using indicators. - Synced parser.
2004-05-07- Added additional test case.Michael Meskes
- Fixed bug that reversed string length in typedefs. - Added portability file to pgtypeslib.
2004-04-23Fixed memory misusage in variable handling.Michael Meskes
2004-03-04- Fixed segfault due to missing check for variable declaration.Michael Meskes
- Added check for multidimensional array usage.
2004-01-28Removed some debugging output.Michael Meskes
2004-01-28- Issue a warning if a cursor is declared but not opened.Michael Meskes
- Fixed prototype for ECPGprepared_statement to not moan about "const char" - Fixed parsing of nested structures. - Added option to parse header files.
2003-12-17- Added just another patch by Dave that fixes a reversed order inMichael Meskes
variable listing for output variables in cursor definitions - Fixed incorrect if call in long=>numeric conversion.
2003-09-22- Fixed order mismatch in processing "using" arguments.Michael Meskes
- Fixed some minor things in test cases. - Use defines for Informix error codes.
2003-08-04pgindent run.Bruce Momjian
2003-07-07"char *" of course is not the same as "char []". So I had to fix the way ↵Michael Meskes
ecpg treated the second one.
2003-06-27Create real array comparison functions (that use the element datatype'sTom Lane
comparison functions), replacing the highly bogus bitwise array_eq. Create a btree index opclass for ANYARRAY --- it is now possible to create indexes on array columns. Arrange to cache the results of catalog lookups across multiple array operations, instead of repeating the lookups on every call. Add string_to_array and array_to_string functions. Remove singleton_array, array_accum, array_assign, and array_subscript functions, since these were for proof-of-concept and not intended to become supported functions. Minor adjustments to behavior in some corner cases with empty or zero-dimensional arrays. Joe Conway (with some editorializing by Tom Lane).
2003-06-25Back out array mega-patch.Bruce Momjian
Joe Conway
2003-06-24Array mega-patch.Bruce Momjian
Joe Conway