summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connection.c19
-rw-r--r--inouealc.c2
-rw-r--r--psqlodbc.h24
-rw-r--r--qresult.c20
-rw-r--r--qresult.h35
-rw-r--r--results.c2
-rw-r--r--socket.c4
-rw-r--r--statement.c6
-rw-r--r--version.h2
-rw-r--r--win_unicode.c2
10 files changed, 66 insertions, 50 deletions
diff --git a/connection.c b/connection.c
index f22a4bc..4cb7ce0 100644
--- a/connection.c
+++ b/connection.c
@@ -23,6 +23,7 @@
#include <errno.h>
#endif /* WIN32 */
+#include <libpq-fe.h>
#include "environ.h"
#include "socket.h"
#include "statement.h"
@@ -813,7 +814,7 @@ inolog("new_format=%d\n", new_format);
CC_on_abort(self, abort_opt);
if (res)
{
- QR_set_rstatus(res, PGRES_FATAL_ERROR);
+ QR_set_rstatus(res, PORES_FATAL_ERROR);
QR_set_message(res, msgbuf);
QR_set_aborted(res, TRUE);
}
@@ -897,7 +898,7 @@ handle_notice_message(ConnectionClass *self, char *msgbuf, int buflen, char *sql
if (res)
{
if (QR_command_successful(res))
- QR_set_rstatus(res, PGRES_NONFATAL_ERROR);
+ QR_set_rstatus(res, PORES_NONFATAL_ERROR);
QR_set_notice(res, msgbuf); /* will dup this string */
}
@@ -1517,7 +1518,7 @@ inolog("Ekita\n");
res = CC_send_query(self, " ", NULL, 0, NULL);
if (res == NULL ||
- (QR_get_rstatus(res) != PGRES_EMPTY_QUERY &&
+ (QR_get_rstatus(res) != PORES_EMPTY_QUERY &&
QR_command_nonfatal(res)))
{
CC_set_error(self, CONNECTION_NO_SUCH_DATABASE, "The database does not exist on the server\nor user authentication failed.", func);
@@ -2190,7 +2191,7 @@ inolog("Discarded the first SAVEPOINT\n");
}
if (QR_command_successful(res))
- QR_set_rstatus(res, PGRES_COMMAND_OK);
+ QR_set_rstatus(res, PORES_COMMAND_OK);
QR_set_command(res, cmdbuffer);
query_completed = TRUE;
mylog("send_query: returning res = %x\n", res);
@@ -2239,7 +2240,7 @@ inolog("Discarded the first SAVEPOINT\n");
{
CC_set_errornumber(self, CONNECTION_BACKEND_CRAZY);
QR_set_message(res, "Unexpected protocol character from backend (send_query - I)");
- QR_set_rstatus(res, PGRES_FATAL_ERROR);
+ QR_set_rstatus(res, PORES_FATAL_ERROR);
ReadyToReturn = TRUE;
retres = cmdres;
break;
@@ -2247,7 +2248,7 @@ inolog("Discarded the first SAVEPOINT\n");
else
{
/* We return the empty query */
- QR_set_rstatus(res, PGRES_EMPTY_QUERY);
+ QR_set_rstatus(res, PORES_EMPTY_QUERY);
}
if (empty_reqs > 0)
{
@@ -2305,7 +2306,7 @@ inolog("Discarded the first SAVEPOINT\n");
{
CC_set_error(self, CONNECTION_COULD_NOT_RECEIVE, QR_get_message(res), func);
ReadyToReturn = TRUE;
- if (PGRES_FATAL_ERROR == QR_get_rstatus(res))
+ if (PORES_FATAL_ERROR == QR_get_rstatus(res))
retres = cmdres;
else
retres = NULL;
@@ -2336,7 +2337,7 @@ inolog("Discarded the first SAVEPOINT\n");
res->next = QR_Constructor();
res = res->next;
}
- QR_set_rstatus(res, PGRES_COPY_IN);
+ QR_set_rstatus(res, PORES_COPY_IN);
ReadyToReturn = TRUE;
retres = cmdres;
break;
@@ -2346,7 +2347,7 @@ inolog("Discarded the first SAVEPOINT\n");
res->next = QR_Constructor();
res = res->next;
}
- QR_set_rstatus(res, PGRES_COPY_OUT);
+ QR_set_rstatus(res, PORES_COPY_OUT);
ReadyToReturn = TRUE;
retres = cmdres;
break;
diff --git a/inouealc.c b/inouealc.c
index d010ada..4505f2c 100644
--- a/inouealc.c
+++ b/inouealc.c
@@ -14,7 +14,9 @@
#undef memset
*/
#include "misc.h"
+#ifdef WIN32
#include <malloc.h>
+#endif /* WIN32 */
#ifdef _DEBUG
#include <stdlib.h>
#define _CRTDBG_MAP_ALLOC
diff --git a/psqlodbc.h b/psqlodbc.h
index 3b2e790..743e5af 100644
--- a/psqlodbc.h
+++ b/psqlodbc.h
@@ -5,7 +5,7 @@
*
* Comments: See "notice.txt" for copyright and license information.
*
- * $Id: psqlodbc.h,v 1.104 2006/08/24 15:03:56 hinoue Exp $
+ * $Id: psqlodbc.h,v 1.105 2006/08/26 22:54:16 hinoue Exp $
*
*/
@@ -64,7 +64,7 @@
#include "iodbc.h"
#include "isql.h"
#include "isqlext.h"
-#endif
+#endif /* WIN32 */
#if defined(WIN32)
#include <odbcinst.h>
@@ -76,33 +76,29 @@
#include "gpps.h"
#endif
-/* #include <libpq-fe.h> */
-
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef WIN32
+
#define Int4 int
#define UInt4 unsigned int
#define Int2 short
#define UInt2 unsigned short
+#ifndef WIN32
#if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
typedef float SFLOAT;
typedef double SDOUBLE;
-#endif
+#endif /* WITH_UNIXODBC */
#ifndef CALLBACK
#define CALLBACK
-#endif
+#endif /* CALLBACK */
+#endif /* WIN32 */
-#else
-#define Int4 int
-#define UInt4 unsigned int
-#define Int2 short
-#define UInt2 unsigned short
-#endif
+#ifndef LIBPQ_FE_H
typedef UInt4 Oid;
+#endif /* LIBPQ_FE_H */
#ifndef WIN32
#define stricmp strcasecmp
@@ -119,7 +115,7 @@ typedef UInt4 Oid;
#define strnicmp _strnicmp
#define stricmp _stricmp
#define vsnprintf _vsnprintf
-#endif
+#endif /* WIN32 */
#ifndef SQL_ATTR_APP_ROW_DESC
#define SQL_ATTR_APP_ROW_DESC 10010
diff --git a/qresult.c b/qresult.c
index fb130b9..3c96c38 100644
--- a/qresult.c
+++ b/qresult.c
@@ -131,7 +131,7 @@ QR_Constructor()
if (rv != NULL)
{
- rv->rstatus = PGRES_EMPTY_QUERY;
+ rv->rstatus = PORES_EMPTY_QUERY;
rv->pstatus = 0;
/* construct the column info */
@@ -521,7 +521,7 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, const char *cursor)
{
if (!cursor)
{
- QR_set_rstatus(self, PGRES_INTERNAL_ERROR);
+ QR_set_rstatus(self, PORES_INTERNAL_ERROR);
QR_set_message(self, "Internal Error -- no cursor for fetch");
return FALSE;
}
@@ -535,14 +535,14 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, const char *cursor)
*/
if (CI_read_fields(self->fields, QR_get_conn(self)))
{
- QR_set_rstatus(self, PGRES_FIELDS_OK);
+ QR_set_rstatus(self, PORES_FIELDS_OK);
self->num_fields = CI_get_num_fields(self->fields);
if (QR_haskeyset(self))
self->num_fields -= self->num_key_fields;
}
else
{
- QR_set_rstatus(self, PGRES_BAD_RESPONSE);
+ QR_set_rstatus(self, PORES_BAD_RESPONSE);
QR_set_message(self, "Error reading field information");
return FALSE;
}
@@ -570,7 +570,7 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, const char *cursor)
{
if (self->keyset = (KeySet *) calloc(sizeof(KeySet), tuple_size), !self->keyset)
{
- QR_set_rstatus(self, PGRES_FATAL_ERROR);
+ QR_set_rstatus(self, PORES_FATAL_ERROR);
QR_set_message(self, "Could not get memory for tuple cache.");
return FALSE;
}
@@ -596,7 +596,7 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, const char *cursor)
if (!CI_read_fields(NULL, QR_get_conn(self)))
{
- QR_set_rstatus(self, PGRES_BAD_RESPONSE);
+ QR_set_rstatus(self, PORES_BAD_RESPONSE);
QR_set_message(self, "Error reading field information");
return FALSE;
}
@@ -649,7 +649,7 @@ QR_close(QResultClass *self)
if (!CC_commit(conn))
{
- QR_set_rstatus(self, PGRES_FATAL_ERROR);
+ QR_set_rstatus(self, PORES_FATAL_ERROR);
QR_set_message(self, "Error ending transaction.");
ret = FALSE;
}
@@ -699,7 +699,7 @@ inolog("QR_get_tupledata num_fields=%d\n", self->num_fields);
if (!QR_read_a_tuple_from_db(self, (char) binary))
{
- QR_set_rstatus(self, PGRES_BAD_RESPONSE);
+ QR_set_rstatus(self, PORES_BAD_RESPONSE);
QR_set_message(self, "Error reading the tuple");
return FALSE;
}
@@ -1071,7 +1071,7 @@ inolog("clear obsolete %d tuples\n", num_backend_rows);
res = CC_send_query(conn, fetch, &qi, 0, stmt);
if (!QR_command_maybe_successful(res))
{
- QR_set_rstatus(self, PGRES_FATAL_ERROR);
+ QR_set_rstatus(self, PORES_FATAL_ERROR);
QR_set_message(self, "Error fetching next group.");
return FALSE;
}
@@ -1231,7 +1231,7 @@ inolog("id='%c' response_length=%d\n", id, response_length);
mylog("%s: Unexpected result from backend: id = '%c' (%d)\n", func, id, id);
qlog("%s: Unexpected result from backend: id = '%c' (%d)\n", func, id, id);
QR_set_message(self, "Unexpected result from backend. It probably crashed");
- QR_set_rstatus(self, PGRES_FATAL_ERROR);
+ QR_set_rstatus(self, PORES_FATAL_ERROR);
CC_on_abort(conn, CONN_DEAD);
ret = FALSE;
rcvend = TRUE;
diff --git a/qresult.h b/qresult.h
index b5db09a..5fdf724 100644
--- a/qresult.h
+++ b/qresult.h
@@ -16,15 +16,30 @@
#include "columninfo.h"
#include "tuple.h"
-#include <libpq-fe.h>
-
#ifdef __cplusplus
extern "C" {
#endif
-typedef ExecStatusType QueryResultCode;
-#define PGRES_FIELDS_OK 100
-#define PGRES_INTERNAL_ERROR (PGRES_FIELDS_OK + 1)
+typedef
+enum QueryResultCode_
+{
+ PORES_EMPTY_QUERY = 0,
+ PORES_COMMAND_OK, /* a query command that doesn't return
+ * anything was executed properly by the backend */
+ PORES_TUPLES_OK, /* a query command that returns tuples
+ * was executed properly by the backend, PGresult
+ * contains the resulttuples */
+ PORES_COPY_OUT,
+ PORES_COPY_IN,
+ PORES_BAD_RESPONSE, /* an unexpected response was recv'd from
+ * the backend */
+ PORES_NONFATAL_ERROR,
+ PORES_FATAL_ERROR,
+ PORES_FIELDS_OK = 100, /* field information from a query was
+ * successful */
+ /* PORES_END_TUPLES, */
+ PORES_INTERNAL_ERROR
+} QueryResultCode;
enum
{
@@ -132,9 +147,9 @@ enum {
#define QR_set_field_info_v(self, field_num, name, adtid, adtsize) (CI_set_field_info(self->fields, field_num, name, adtid, adtsize, -1, 0, 0))
/* status macros */
-#define QR_command_successful(self) (self && !(self->rstatus == PGRES_BAD_RESPONSE || self->rstatus == PGRES_NONFATAL_ERROR || self->rstatus == PGRES_FATAL_ERROR))
-#define QR_command_maybe_successful(self) (self && !(self->rstatus == PGRES_BAD_RESPONSE || self->rstatus == PGRES_FATAL_ERROR))
-#define QR_command_nonfatal(self) ( self->rstatus == PGRES_NONFATAL_ERROR)
+#define QR_command_successful(self) (self && !(self->rstatus == PORES_BAD_RESPONSE || self->rstatus == PORES_NONFATAL_ERROR || self->rstatus == PORES_FATAL_ERROR))
+#define QR_command_maybe_successful(self) (self && !(self->rstatus == PORES_BAD_RESPONSE || self->rstatus == PORES_FATAL_ERROR))
+#define QR_command_nonfatal(self) ( self->rstatus == PORES_NONFATAL_ERROR)
#define QR_set_conn(self, conn_) ( self->conn = conn_ )
#define QR_set_rstatus(self, condition) ( self->rstatus = condition )
#define QR_set_sqlstatus(self, status) strcpy(self->sqlstatus, status)
@@ -224,7 +239,7 @@ Int4 getNthValid(const QResultClass *self, Int4 sta, UWORD orientation, UInt4 n
do { \
if (t = (tp *) malloc(s), NULL == t) \
{ \
- QR_set_rstatus(a, PGRES_FATAL_ERROR); \
+ QR_set_rstatus(a, PORES_FATAL_ERROR); \
QR_set_message(a, m); \
return r; \
} \
@@ -233,7 +248,7 @@ do { \
do { \
if (t = (tp *) realloc(t, s), NULL == t) \
{ \
- QR_set_rstatus(a, PGRES_FATAL_ERROR); \
+ QR_set_rstatus(a, PORES_FATAL_ERROR); \
QR_set_message(a, m); \
return r; \
} \
diff --git a/results.c b/results.c
index 9d7caea..0922dda 100644
--- a/results.c
+++ b/results.c
@@ -3527,7 +3527,7 @@ QR_get_rowstart_in_cache(res), SC_get_rowset_start(stmt), stmt->options.cursor_t
res->num_fields * sizeof(TupleField) * tuple_size);
if (!res->backend_tuples)
{
- SC_set_error(stmt, QR_set_rstatus(res, PGRES_FATAL_ERROR), "Out of memory while reading tuples.", func);
+ SC_set_error(stmt, QR_set_rstatus(res, PORES_FATAL_ERROR), "Out of memory while reading tuples.", func);
QR_Destructor(qres);
return SQL_ERROR;
}
diff --git a/socket.c b/socket.c
index f50d59e..b9b1ed5 100644
--- a/socket.c
+++ b/socket.c
@@ -271,7 +271,7 @@ retry:
do {
FD_ZERO(&fds);
FD_SET(self->socket, &fds);
- ret = select(1, NULL, &fds, NULL, timeout > 0 ? &tm : NULL);
+ ret = select(self->socket + 1, NULL, &fds, NULL, timeout > 0 ? &tm : NULL);
if (0 < ret)
break;
else if (0 == ret)
@@ -354,7 +354,7 @@ static int SOCK_wait_for_ready(SocketClass *sock, BOOL output, int retry_count)
tm.tv_sec = retry_count;
tm.tv_usec = 0;
}
- ret = select(1, output ? NULL : &fds, output ? &fds : NULL, NULL, sock->ssl ? &tm : NULL);
+ ret = select(sock->socket + 1, output ? NULL : &fds, output ? &fds : NULL, NULL, sock->ssl ? &tm : NULL);
} while (ret < 0 && EINTR == SOCK_ERRNO);
if (0 == ret && retry_count > MAX_RETRY_COUNT)
{
diff --git a/statement.c b/statement.c
index 46ac1f8..8c6e348 100644
--- a/statement.c
+++ b/statement.c
@@ -889,7 +889,7 @@ SC_pre_execute(StatementClass *self)
if (!SC_is_pre_executable(self))
{
SC_set_Result(self, QR_Constructor());
- QR_set_rstatus(SC_get_Result(self), PGRES_TUPLES_OK);
+ QR_set_rstatus(SC_get_Result(self), PORES_TUPLES_OK);
self->inaccurate_result = TRUE;
self->status = STMT_PREMATURE;
num_fields = 0;
@@ -2165,7 +2165,7 @@ inolog("num_params=%d info=%d\n", stmt->num_params, num_p);
Int2 dummy1, dummy2;
int cidx;
- QR_set_rstatus(res, PGRES_FIELDS_OK);
+ QR_set_rstatus(res, PORES_FIELDS_OK);
res->num_fields = CI_get_num_fields(res->fields);
if (QR_haskeyset(res))
res->num_fields -= res->num_key_fields;
@@ -2192,7 +2192,7 @@ inolog("!![%d].PGType %u->%u\n", i, ipdopts->parameters[i].PGType, CI_get_oid(re
}
else
{
- QR_set_rstatus(res, PGRES_BAD_RESPONSE);
+ QR_set_rstatus(res, PORES_BAD_RESPONSE);
QR_set_message(res, "Error reading field information");
rcvend = TRUE;
}
diff --git a/version.h b/version.h
index 7b7ce31..b462d48 100644
--- a/version.h
+++ b/version.h
@@ -11,6 +11,6 @@
#define POSTGRESDRIVERVERSION "08.02.0007"
#define POSTGRES_RESOURCE_VERSION "08.02.0007\0"
-#define PG_DRVFILE_VERSION 8,2,0,07
+#define PG_DRVFILE_VERSION 8,2,0,07
#endif
diff --git a/win_unicode.c b/win_unicode.c
index 9a43b07..b0396d2 100644
--- a/win_unicode.c
+++ b/win_unicode.c
@@ -10,7 +10,9 @@
#include "psqlodbc.h"
#include <stdio.h>
#include <string.h>
+#ifdef WIN32
#include <malloc.h>
+#endif /* WIN32 */
#define byte3check 0xfffff800
#define byte2_base 0x80c0