aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/ecpglib/execute.c
Commit message (Collapse)AuthorAge
* Blind attempt to fix _configthreadlocale() failures on MinGW.Tom Lane2019-01-23
| | | | | | | | | | Apparently, some builds of MinGW contain a version of _configthreadlocale() that always returns -1, indicating failure. Rather than treating that as a curl-up-and-die condition, soldier on as though the function didn't exist. This leaves us without thread safety on such MinGW versions, but we didn't have it anyway. Discussion: https://postgr.es/m/d06a16bc-52d6-9f0d-2379-21242d7dbe81@2ndQuadrant.com
* Avoid thread-safety problem in ecpglib.Tom Lane2019-01-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | ecpglib attempts to force the LC_NUMERIC locale to "C" while reading server output, to avoid problems with strtod() and related functions. Historically it's just issued setlocale() calls to do that, but that has major problems if we're in a threaded application. setlocale() itself is not required by POSIX to be thread-safe (and indeed is not, on recent OpenBSD). Moreover, its effects are process-wide, so that we could cause unexpected results in other threads, or another thread could change our setting. On platforms having uselocale(), which is required by POSIX:2008, we can avoid these problems by using uselocale() instead. Windows goes its own way as usual, but we can make it safe by using _configthreadlocale(). Platforms having neither continue to use the old code, but that should be pretty much nobody among current systems. (Subsequent buildfarm results show that recent NetBSD versions still lack uselocale(), but it's not a big problem because they also do not support non-"C" settings for LC_NUMERIC.) Back-patch of commits 8eb4a9312 and ee27584c4. Michael Meskes and Tom Lane; thanks also to Takayuki Tsunakawa. Discussion: https://postgr.es/m/31420.1547783697@sss.pgh.pa.us
* Client-side fixes for delayed NOTIFY receipt.Tom Lane2018-10-19
| | | | | | | | | | | | | | | | | | | | | | | | PQnotifies() is defined to just process already-read data, not try to read any more from the socket. (This is a debatable decision, perhaps, but I'm hesitant to change longstanding library behavior.) The documentation has long recommended calling PQconsumeInput() before PQnotifies() to ensure that any already-arrived message would get absorbed and processed. However, psql did not get that memo, which explains why it's not very reliable about reporting notifications promptly. Also, most (not quite all) callers called PQconsumeInput() just once before a PQnotifies() loop. Taking this recommendation seriously implies that we should do PQconsumeInput() before each call. This is more important now that we have "payload" strings in notification messages than it was before; that increases the probability of having more than one packet's worth of notify messages. Hence, adjust code as well as documentation examples to do it like that. Back-patch to 9.5 to match related server fixes. In principle we could probably go back further with these changes, but given lack of field complaints I doubt it's worthwhile. Discussion: https://postgr.es/m/CAOYf6ec-TmRYjKBXLLaGaB-jrd=mjG1Hzn1a1wufUAR39PQYhw@mail.gmail.com
* Fix misc typos, mostly in comments.Heikki Linnakangas2018-07-18
| | | | | | | | A collection of typos I happened to spot while reading code, as well as grepping for common mistakes. Backpatch to all supported versions, as applicable, to avoid conflicts when backporting other commits in the future.
* Fixed handling of escape character in libecpg.Michael Meskes2017-10-26
| | | | Patch by Tsunakawa Takayuki <tsunakawa.takay@jp.fujitsu.com>
* Fix typos in comments.Heikki Linnakangas2017-02-06
| | | | | | | | | Backpatch to all supported versions, where applicable, to make backpatching of future fixes go more smoothly. Josh Soref Discussion: https://www.postgresql.org/message-id/CACZqfqCf+5qRztLPgmmosr-B0Ye4srWzzw_mo4c_8_B_mtjmJQ@mail.gmail.com
* Fix whitespacePeter Eisentraut2015-09-21
|
* Let compiler handle size calculation of bool types.Michael Meskes2015-09-19
| | | | Back in the day this did not work, but modern compilers should handle it themselves.
* Fix declaration of isarray variable.Michael Meskes2015-08-13
| | | | Found and fixed by Andres Freund.
* Check for out of memory when allocating sqlca.Michael Meskes2015-06-15
| | | | Patch by Michael Paquier
* pgindent run for 9.5Bruce Momjian2015-05-23
|
* Fixed array handling in ecpg.Michael Meskes2015-02-10
| | | | | | When ecpg was rewritten to the new protocol version not all variable types were corrected. This patch rewrites the code for these types to fix that. It also fixes the documentation to correctly tell the status of array handling.
* This routine was calling ecpg_alloc to allocate to memory but did notMichael Meskes2015-02-05
| | | | | | | actually check the returned pointer allocated, potentially NULL which could be the result of a malloc call. Issue noted by Coverity, fixed by Michael Paquier <michael@otacoo.com>
* Fix memory leaks on OOM in ecpg.Heikki Linnakangas2015-02-04
| | | | | | These are fairly obscure cases, but let's keep Coverity happy. Michael Paquier with some further fixes by me.
* Replace a bunch more uses of strncpy() with safer coding.Tom Lane2015-01-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | strncpy() has a well-deserved reputation for being unsafe, so make an effort to get rid of nearly all occurrences in HEAD. A large fraction of the remaining uses were passing length less than or equal to the known strlen() of the source, in which case no null-padding can occur and the behavior is equivalent to memcpy(), though doubtless slower and certainly harder to reason about. So just use memcpy() in these cases. In other cases, use either StrNCpy() or strlcpy() as appropriate (depending on whether padding to the full length of the destination buffer seems useful). I left a few strncpy() calls alone in the src/timezone/ code, to keep it in sync with upstream (the IANA tzcode distribution). There are also a few such calls in ecpg that could possibly do with more analysis. AFAICT, none of these changes are more than cosmetic, except for the four occurrences in fe-secure-openssl.c, which are in fact buggy: an overlength source leads to a non-null-terminated destination buffer and ensuing misbehavior. These don't seem like security issues, first because no stack clobber is possible and second because if your values of sslcert etc are coming from untrusted sources then you've got problems way worse than this. Still, it's undesirable to have unpredictable behavior for overlength inputs, so back-patch those four changes to all active branches.
* pgindent run for 9.4Bruce Momjian2014-05-06
| | | | | This includes removing tabs after periods in C comments, which was applied to back branches, so this change should not effect backpatching.
* Fix handling of array of char pointers in ecpglib.Michael Meskes2014-05-06
| | | | | | | | | | When array of char * was used as target for a FETCH statement returning more than one row, it tried to store all the result in the first element. Instead it should dump array of char pointers with right offset, use the address instead of the value of the C variable while reading the array and treat such variable as char **, instead of char * for pointer arithmetic. Patch by Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
* Various Coverity-spotted fixesStephen Frost2014-03-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Split ecpg_execute() in constituent partsAlvaro Herrera2014-01-16
| | | | | | | | | | | | Split the rather long ecpg_execute() function into ecpg_build_params(), ecpg_autostart_transaction(), a smaller ecpg_execute() and ecpg_process_output(). There is no user-visible change here, only code reorganization to support future patches. Author: Zoltán Böszörményi Reviewed by Antonin Houska. Larger, older versions of this patch were reviewed by Noah Misch and Michael Meskes.
* Split ECPGdo() in constituent partsAlvaro Herrera2014-01-16
| | | | | | | | | | | | | | | This splits ECPGdo() into ecpg_prologue(), ecpg_do() and ecpg_epilogue(), and renames free_params() into ecpg_free_params() and exports it. This makes it possible for future code to use these routines for their own purposes. There is no user-visible functionality change here, only code reorganization. Zoltán Böszörményi Reviewed by Antonin Houska. Larger, older versions of this patch were reviewed by Noah Misch and Michael Meskes.
* ECPG: Simplify free_variable()Michael Meskes2013-11-26
| | | | Patch by Boszormenyi Zoltan <zb@cybertec.at>
* Run pgindent on 9.2 source tree in preparation for first 9.3Bruce Momjian2012-06-10
| | | | commit-fest.
* ecpg: Fix rare memory leaksPeter Eisentraut2012-03-08
| | | | found by Coverity
* ecpg: Clean up some const usagePeter Eisentraut2012-03-02
|
* Standardize treatment of strcmp() return valuePeter Eisentraut2011-12-27
| | | | | Always compare the return value to 0, don't use cute tricks like if (!strcmp(...)).
* Remove many -Wcast-qual warningsPeter Eisentraut2011-09-11
| | | | | | This addresses only those cases that are easy to fix by adding or moving a const qualifier or removing an unnecessary cast. There are many more complicated cases remaining.
* Add missing format attributesPeter Eisentraut2011-09-10
| | | | | | | | | | | Add __attribute__ decorations for printf format checking to the places that were missing them. Fix the resulting warnings. Add -Wmissing-format-attribute to the standard set of warnings for GCC, so these don't happen again. The warning fixes here are relatively harmless. The one serious problem discovered by this was already committed earlier in cf15fb5cabfbc71e07be23cfbc813daee6c5014f.
* Add missing format argument to ecpg_log() callPeter Eisentraut2011-09-08
|
* Fix brace indentation of commit 63d06ef59156719efd0208c62e764a69611b3f12 to ↵Michael Meskes2011-09-02
| | | | fit PostgreSQL style.
* In ecpglib restore LC_NUMERIC in case of an error.Michael Meskes2011-09-01
|
* Made ecpglib write double with a precision of 15 digits.Michael Meskes2011-07-18
| | | | Patch originally by Akira Kurosawa <kurosawa-akira@mxc.nes.nec.co.jp>.
* Capitalization fixesPeter Eisentraut2011-06-19
|
* Revert "Remove hard coded formats for INT64 and use configured settings ↵Andrew Dunstan2011-04-27
| | | | | | | | instead." This reverts commit 9b1508af8971c1627cda5bb65f5e9eddb9a1a55e. As requested by Tom.
* Remove hard coded formats for INT64 and use configured settings instead.Andrew Dunstan2011-04-27
|
* Applied patch by Itagaki Takahiro to fix incorrect status calculation inMichael Meskes2010-10-14
| | | | | | ecpglib. Instead of parsing the statement just as ask the database server. This patch removes the whole client side track keeping of the current transaction status.
* Remove cvs keywords from all files.Magnus Hagander2010-09-20
|
* pgindent run for 9.0, second runBruce Momjian2010-07-06
|
* Replace self written 'long long int' configure test by standard ↵Michael Meskes2010-05-25
| | | | 'AC_TYPE_LONG_LONG_INT' macro call.
* Ecpg now accepts "long long" datatypes even if "long" is 64bit wide. This ↵Michael Meskes2010-05-20
| | | | used to cover the equally long "long long" type. This patch closes bug #5464.
* pgindent run for 9.0Bruce Momjian2010-02-26
|
* Do not check nan values for infinity. Some system are not able to handle this.Michael Meskes2010-02-16
| | | | By Zoltán Böszörményi
* Streamlined array handling code in libecpg a little bit, in the process ↵Michael Meskes2010-02-04
| | | | fixing yet another incorrect log output.
* Add #include <float.h> --- guessing the lack of this is why WindowsTom Lane2010-02-03
| | | | machines are all rejecting isinf() calls in this file.
* Fixed NaN/Infinity problems in ECPG for float/double/numeric/decimal by ↵Michael Meskes2010-02-02
| | | | | | making it OS independant. Patch done by Zoltán Böszörményi.
* Fixed a few typos in ecpg. Two were in comments, the third made a log output ↵Michael Meskes2010-01-29
| | | | reverse yes and no.
* Applied patch by Boszormenyi Zoltan <zb@cybertec.at> to fix problem in ↵Michael Meskes2010-01-22
| | | | auto-prepare mode if the connection is closed and re-opened and the previously prepared query is issued again.
* Applied patch by Boszormenyi Zoltan <zb@cybertec.at> to add sqlda support toMichael Meskes2010-01-05
| | | | ecpg in both native and compatiblity mode.
* Fixed incorrect memory management.Michael Meskes2009-09-03
|
* Added STRING datatype for Informix compatibility mode. This work isMichael Meskes2009-08-07
| | | | based on a patch send in by Böszörményi Zoltán <zb@cybertec.at>.
* 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian2009-06-11
| | | | provided by Andrew.