summaryrefslogtreecommitdiff
path: root/statement.c
AgeCommit message (Collapse)Author
2017-06-07Clean up the use of sprintf(). Replace sprintf() by snprintf() or the macro ↵Hiroshi Inoue
SPRINTF_FIXED().
2017-06-05Cleanup the code by replacing strcpy() by strncpy_null(), strlcat() or ↵Hiroshi Inoue
snprintf_add().
2017-05-13Implement SC_get_localtime() and reduce time()/localtime() calls.Hiroshi Inoue
2017-05-11Reorganize the language conversion between the current locale and unicode.Hiroshi Inoue
Support the platforms e.g. FreeBSD which satisfies __STDC_UTF_16__ (but not satify __STDC_ISO_10646__) using mbrtoc16() and c16rtomb(). Use the functions bindpara_msg_to_utf8(), bindpara_wchar_to_msg(), bindcol_hybrid_estimate(), bindcol_hybrid_exec(), bindcol_localize_estimate() and bindcol_localize_exec() which hide the difference of platforms instead of platform specific functions. They are implemented using already implemented wstrtomsg(), msgtowstr(), wcs_to_utf8(), utf8_to_wcs_lf() and newly implemented mbstoc16_lf(), c16tomsb(), ucs4_to_ucs2_lf(), ucs2_to_ucs4(). Add eucJP encoding case to wchar-char test. [Minor changes] Add conversion error check between unicode and the current locale. Rename buf to send_buf in ResolveOneParam() so that grep or find can them find easily. Separate "unicode_support.h" from "psqlodbc.h" Change convert_linefeeds() from static to external. Add AC_CHECK_FUNCS(mbrtoc16 c16rtomb) to Makefile.am. Remove win_unicode.c from psqlsetup.vcxproj.
2017-03-18Remove obsolete code in statement.c.Hiroshi Inoue
2017-03-08Stop specifying parameter datatype oids in parse message. Unfortunately it ↵Hiroshi Inoue
is inflexible and rather harmful. Though I don't know if it has much meaning, use cast instead just in order to keep regression test results. It's not necessary to cast any more the 2nd parameter of {call a_b_c_d_e(?, ?, ?, ?, ?)} in odbc-escapes-test.
2017-03-08Fix regression test failures in diagnostic-test.Hiroshi Inoue
2017-03-07Revise recent lost connection check.Hiroshi Inoue
Check the lost connection 1. at the beginning of ODBC APIs. 2. at the beginning of FE-BE communications using extended protocol.
2017-03-06Oops the implementation of SC_set_error_if_not_set() is terribly wrong.Hiroshi Inoue
2017-03-05Make check of connection lost.Hiroshi Inoue
2017-03-04Handle output parameters properly in build_libpq_bind_params.Hiroshi Inoue
Also handle return values properly. Now passes odbc-escapes-test.
2017-03-04The failure of libpq_bind_exec() which returns NULL doesn't mean a FATAL ↵Hiroshi Inoue
error. Also make a check for disconnected connections.
2017-01-21Enable SQLBulkOperations in declare/fetch mode using long (>=12bytes) bookmarks.Hiroshi Inoue
Formerly the driver offered very simple bookmark support -- it is just the current row number. Now the driver offers more verbose bookmarks which contain KeySet informations (CTID (+ OID)). Though they consume 12bytes (row number + CTID) or 16bytes (row number + CTID + OID), they are useful in declare/fetch mode.
2017-01-12Use lo_lseek64(lo_tell64) instead of lo_lseek(lo_tell) if the server's ↵Hiroshi Inoue
version >= 9.3. We are now able to handle > 2GB BLOBs.
2016-11-02Added to commit 7849ba( was a patch by Tsunakawa,Takayuki).Hiroshi Inoue
Now default isolation level is server's default instead of fixed SQL_TXN_READ_COMMITTED. Also reduced the number of round trips using multiple commands.
2016-10-29Commit 3b6f3d changed the results of regression tests. Put back to set error ↵Hiroshi Inoue
messages only when error messages are not set.
2016-10-26Return proper sqlstate error 08S01 in case of communication link failures. ↵Hiroshi Inoue
Patch by Tsunakawa,Takayuki.
2016-10-12Mark ParseWithLibpq as static.Heikki Linnakangas
For sake of tidiness.
2016-06-17Implement SQL_QUERY_TIMEOUT. Patch by Tsunakawa, Takayuki.Hiroshi Inoue
2016-05-21Convert tableoid to relation name in case of inheritance.Hiroshi Inoue
2016-03-21Make sure that EOF occurs when 'fetched < fetch requested'.Hiroshi Inoue
2016-02-27Fix NULL dereferences which causes application crash. Patch by Tsunakawa, ↵Hiroshi Inoue
Takayuki.
2015-12-21Fix handling of return value in {? = CALL ... } syntax.Heikki Linnakangas
When sending the query to the server, need to use the number of parameters calculated by build_libpq_bind_params(), which excludes the OUT parameter, rather than the original number of parameters. The branch that executes an already prepared statement got this right. There was one test query for the CALL syntax already, but it was commented out, because it doesn't work for unrelated issues. Add a simpler test case that does work. This was broken by commit e6d7ded, in version 09.03.0400. The code was heavily refactored in commit e85fbb24, but that refactoring failed to fix this issue. Reported by Haribabu Kommi.
2015-09-22Fix buffer overrun in constructing error message.Heikki Linnakangas
If the server returned an error longer than 4096 bytes, we would overrun the buffer by two bytes. If you're unlucky, that could lead to a crash, and it consistently did on Windows. Per report from Andrus Moor.
2015-01-29Fix crash when a query is described, without binding params.Heikki Linnakangas
Add test case for the same.
2015-01-29Don't do premature execution.Heikki Linnakangas
Use protocol v3 Parse instead, even in UseServerSidePrepare=0 mode. Remove the DisallowPremature config option.
2015-01-28Use fixed-width fields for SQLState values.Heikki Linnakangas
I'm hoping that this silences a Coverity warning, making it realize that none of the strings in the array are longer than 5 bytes.
2015-01-23Fix miscellaneous little issues spotted by Coverity.Heikki Linnakangas
A few were real bugs, although highly unlikely ones. Others were false positives like dead code, but let's be tidy.
2015-01-23Check return values of a few function calls.Heikki Linnakangas
While we're at it, fix spelling of the error messages. Clang static analyzer complained.
2015-01-23More miscellaneous cleanup.Heikki Linnakangas
* Simplify the way the ignore-round-trip-time config option works. (No need for the caller of CC_send_query_append to pass it as argument, CC_send_query_append can look at the options in the connection object itself) * remove unnecessary local variable used for "fetch" constant. * remove unused FLGP_BUILDING_PREPARE_STATEMENT flag. * remove unused parameter, and check for stmt==NULL, from QB_Initialize. * inline process_statements function into its only caller.
2015-01-22Miscellaneous cleanup.Heikki Linnakangas
* Mark functions used only in same file as static. * Remove unused 'encoding' argument from msgtowstr and wstrtoms (all callers passed NULL). * Silence remaining compiler warnings on 64-bit Windows about assigning size_t to int without cast. * Remove superfluous FORMAT_INT4/FORMAT_UINT4 defines. * Remove useless dollar_quote argument from findTag (it was always '$'), and add comment. * Turn OID_NAME into a #define, to avoid a useless sprintf. * Turn the mapFuncs array into structs, for clarity, and add comment.
2015-01-21Fix reference to free'd plan name.Heikki Linnakangas
libpq_bind_and_exec fetched a pointer to the statement's plan name to a local variable, but then called prepareParameters which free'd it, and allocated a new plan name. The already-free'd name was then passed to PQexecParams(). Spotted by valgrind
2015-01-21Fix bug in determining the datatypes when binding.Heikki Linnakangas
In the big libpq patch, I accidentally removed the line where current_exec_param was reset to 0. It's still required (which is a very fiddly way to pass that value to ParseAndDescribeWithLibpq, but let's live with it for now..)
2015-01-21Minor cleanup.Heikki Linnakangas
Remove local variable that was never used for anything real (just passed as NULL to mylog/qlog). Replace with real query in the logs, and add some extra logging.
2015-01-19Remove long-since obsolete FAR/NEAR decorations from pointers.Heikki Linnakangas
We haven't supported a segmented memory model for ages, probably never.
2015-01-19Misc cleanup, mostly dead code removal.Heikki Linnakangas
2015-01-16Send proper datatypes to the server when binding parameters.Heikki Linnakangas
We used to always send 0 as the parameter type, which means that the server should deduce the datatype from the context. That usually works well, but we can do better. Sometimes there is ambiguity, like in "SELECT '555' > ?". If the parameter is bound as a string, '6' would return true, but if it's bound as an integer, it returns false. When the application calls SQLBindParameter, it specifies the datatype, so we should make use of that. Add a test case for the "SELECT '555' > ?" case.
2015-01-14Silence compiler warnings about variables being used uninitialized.Heikki Linnakangas
2014-12-31Use libpq for everything.Heikki Linnakangas
Instead of speaking the frontend/backend protocol directly, use libpq's functions for executing queries. This makes it libpq a hard dependency, but removes direct dependencies to SSL and SSPI, and a lot of related code.
2014-10-29Remove support for ODBC versions < 3.51.Heikki Linnakangas
Older versions have been obsolete for a very long time by now. Removing the support lets us get rid of a lot of code that no-one has in practice been even compiling for a long time. Michael Paquier
2014-10-29Remove support for protocol versions older than 3.Heikki Linnakangas
PostgreSQL added support for protocol version 3 in server version 7.4. There's no need to support servers older than that. This simplifies the code a lot, removing a lot of corner cases that haven't been properly regression tested for a long time anyway. Original patch by me, with some tweaks by Michael Paquier.
2014-07-06Revise descriptor stuff.Hiroshi Inoue
descriptor.c(h) was broken by the commit 2da1668f4c7d7871a7212db10af606a7e646abd6 and it now causes a crash bug. Instead of reverting the change revising the stuff completely.
2014-06-19Fix the problems using SQLFetch on prepared INSERT with RETURNING clause ↵Hiroshi Inoue
reported by John Smith.
2014-06-19Clear errors for prepared statement for subsequent exections.Hiroshi Inoue
2014-06-04Fix crash if connection is closed while sending a query to the server.Heikki Linnakangas
This is a similar bug that was fixed in commit 22b151eb. Some functions reset conn->sock to NULL on a socket error, so we must not keep a copy of it in a local variable. Also, SOCK_get_id should check for NULL argument like all the rest of the SOCK_get/put_* functions.
2014-05-12Fix typo in error message.Heikki Linnakangas
2014-04-11Fix two UseDeclareFetch bugs.Heikki Linnakangas
1. NOTICE messages were not delivered to the application, if they arrived as response to the DECLARE CURSOR statement. 2. Array-bound parameters on SELECT-queries caused a "cursor already open" error. These bugs were found by running the regression suite with UseDeclareFetch=1. It's now clean.
2014-03-11More whitespace cleanup.Heikki Linnakangas
Make whitespace and indentation more consistent in SQL_API function declarations.
2014-03-11Whitespace and indentation fixes.Heikki Linnakangas
This also changed the file permissions stored in git for a couple of header files, removing the executable bit. Didn't realize they were different from all the others, but apparently my editor decided to change them. Now they're the same as all the other files, which seems good. Michael Paquier and me.
2014-02-24Fix locking in SC_set_preparedHeikki Linnakangas
Commit 2f4f8eabf6ce685c38d69da3e98132b77d38d188 added ENTER/LEAVE_CRIT_CS calls in SC_set_prepared, as a belt-and-suspenders fix for the race condition already fixed by commit 7065a7af196bb09f80beddce82fa728c8a6dfcba. But it didn't take a NULL connection into account.