rv->pg_version_major = 0;
rv->pg_version_minor = 0;
-
/* Initialize statement options to defaults */
/* Statements under this conn will inherit these options */
InitializeStatementOptions(&rv->stmtOptions);
-
}
return rv;
}
free(self->col_info);
}
-
free(self);
mylog("exit CC_Destructor\n");
for (i = 0; i < self->num_stmts; i++) {
stmt = self->stmts[i];
if (stmt) {
-
stmt->hdbc = NULL; /* prevent any more dbase interactions */
-
SC_Destructor(stmt);
-
self->stmts[i] = NULL;
}
}
CC_connect(ConnectionClass *self, char do_password)
{
StartupPacket sp;
-StartupPacket6_2 sp62;
QResultClass *res;
SocketClass *sock;
ConnInfo *ci = &(self->connInfo);
}
mylog("connection to the server socket succeeded.\n");
- if ( PROTOCOL_62(ci)) {
- sock->reverse = TRUE; /* make put_int and get_int work for 6.2 */
+ memset(&sp, 0, sizeof(StartupPacket));
- memset(&sp62, 0, sizeof(StartupPacket6_2));
- SOCK_put_int(sock, htonl(4+sizeof(StartupPacket6_2)), 4);
- sp62.authtype = htonl(NO_AUTHENTICATION);
- strncpy(sp62.database, ci->database, PATH_SIZE);
- strncpy(sp62.user, ci->username, NAMEDATALEN);
- SOCK_put_n_char(sock, (char *) &sp62, sizeof(StartupPacket6_2));
- SOCK_flush_output(sock);
- }
- else {
- memset(&sp, 0, sizeof(StartupPacket));
+ mylog("sizeof startup packet = %d\n", sizeof(StartupPacket));
- mylog("sizeof startup packet = %d\n", sizeof(StartupPacket));
+ /* Send length of Authentication Block */
+ SOCK_put_int(sock, 4+sizeof(StartupPacket), 4);
- /* Send length of Authentication Block */
- SOCK_put_int(sock, 4+sizeof(StartupPacket), 4);
+ sp.protoVersion = (ProtocolVersion) htonl(PG_PROTOCOL_LATEST);
- if ( PROTOCOL_63(ci))
- sp.protoVersion = (ProtocolVersion) htonl(PG_PROTOCOL_63);
- else
- sp.protoVersion = (ProtocolVersion) htonl(PG_PROTOCOL_LATEST);
+ strncpy(sp.database, ci->database, SM_DATABASE);
+ strncpy(sp.user, ci->username, SM_USER);
- strncpy(sp.database, ci->database, SM_DATABASE);
- strncpy(sp.user, ci->username, SM_USER);
-
- SOCK_put_n_char(sock, (char *) &sp, sizeof(StartupPacket));
- SOCK_flush_output(sock);
- }
+ SOCK_put_n_char(sock, (char *) &sp, sizeof(StartupPacket));
+ SOCK_flush_output(sock);
mylog("sent the authentication block.\n");
mylog("sent the authentication block successfully.\n");
}
-
mylog("gonna do authentication\n");
/* Now get the authentication request from backend */
/* *************************************************** */
- if ( ! PROTOCOL_62(ci)) do {
+ do {
if (do_password)
beresp = 'R';
} while (areq != AUTH_REQ_OK);
-
CC_clear_error(self); /* clear any password error */
/* send an empty query in order to find out whether the specified */
until an 'I' is received
*/
-
SOCK_put_string(sock, "Q ");
SOCK_flush_output(sock);
SOCK_put_int(sock, fnid, 4);
SOCK_put_int(sock, nargs, 4);
-
mylog("send_function: done sending function\n");
for (i = 0; i < nargs; ++i) {
SOCK_put_int(sock, args[i].u.integer, 4);
else
SOCK_put_n_char(sock, (char *) args[i].u.ptr, args[i].len);
-
-
}
mylog(" done sending args\n");
CC_initialize_pg_version(ConnectionClass *self)
{
strcpy(self->pg_version, self->connInfo.protocol);
- if (PROTOCOL_62(&self->connInfo)) {
- self->pg_version_number = (float) 6.2;
- self->pg_version_major = 6;
- self->pg_version_minor = 2;
- } else if (PROTOCOL_63(&self->connInfo)) {
- self->pg_version_number = (float) 6.3;
- self->pg_version_major = 6;
- self->pg_version_minor = 3;
- } else {
- self->pg_version_number = (float) 6.4;
- self->pg_version_major = 6;
- self->pg_version_minor = 4;
- }
+ self->pg_version_number = (float) 6.4;
+ self->pg_version_major = 6;
+ self->pg_version_minor = 4;
}
/* This function gets the version of PostgreSQL that we're connected to.
This is used to return the correct info in SQLGetInfo
#define PG_PROTOCOL(major, minor) (((major) << 16) | (minor))
#define PG_PROTOCOL_LATEST PG_PROTOCOL(2, 0)
-#define PG_PROTOCOL_63 PG_PROTOCOL(1, 0)
-#define PG_PROTOCOL_62 PG_PROTOCOL(0, 0)
-/* This startup packet is to support latest Postgres protocol (6.4, 6.3) */
+/* This startup packet is to support latest Postgres protocol */
typedef struct _StartupPacket
{
ProtocolVersion protoVersion;
} StartupPacket;
-/* This startup packet is to support pre-Postgres 6.3 protocol */
-typedef struct _StartupPacket6_2
-{
- unsigned int authtype;
- char database[PATH_SIZE];
- char user[NAMEDATALEN];
- char options[ARGV_SIZE];
- char execfile[ARGV_SIZE];
- char tty[PATH_SIZE];
-} StartupPacket6_2;
-
-
/* Structure to hold all the connection attributes for a specific
connection (used for both registry and file, DSN and DRIVER)
*/
char focus_password;
} ConnInfo;
-/* Macro to determine is the connection using 6.2 protocol? */
-#define PROTOCOL_62(conninfo_) (strncmp((conninfo_)->protocol, PG62, strlen(PG62)) == 0)
-
-/* Macro to determine is the connection using 6.3 protocol? */
-#define PROTOCOL_63(conninfo_) (strncmp((conninfo_)->protocol, PG63, strlen(PG63)) == 0)
-
/*
* Macros to compare the server's version with a specified version
* 1st parameter: pointer to a ConnectionClass object
CheckDlgButton(hdlg, DS_READONLY, atoi(ci->onlyread));
/* Protocol */
- if (strncmp(ci->protocol, PG62, strlen(PG62)) == 0)
- CheckDlgButton(hdlg, DS_PG62, 1);
- else if (strncmp(ci->protocol, PG63, strlen(PG63)) == 0)
- CheckDlgButton(hdlg, DS_PG63, 1);
- else /* latest */
- CheckDlgButton(hdlg, DS_PG64, 1);
+ CheckDlgButton(hdlg, DS_PG64, 1);
sprintf(ci->onlyread, "%d", IsDlgButtonChecked(hdlg, DS_READONLY));
/* Protocol */
- if ( IsDlgButtonChecked(hdlg, DS_PG62))
- strcpy(ci->protocol, PG62);
- else if ( IsDlgButtonChecked(hdlg, DS_PG63))
- strcpy(ci->protocol, PG63);
- else /* latest */
- strcpy(ci->protocol, PG64);
+ strcpy(ci->protocol, PG64);
sprintf(ci->show_system_tables, "%d", IsDlgButtonChecked(hdlg, DS_SHOWSYSTEMTABLES));