Commit 296e7ba2 authored by Bruce Momjian's avatar Bruce Momjian

ODBC source code cleanup patch. Should match rest of PostgreSQL code better.

parent 062a79a9
/* Module: bind.c /*-------
* Module: bind.c
* *
* Description: This module contains routines related to binding * Description: This module contains routines related to binding
* columns and parameters. * columns and parameters.
...@@ -9,7 +10,7 @@ ...@@ -9,7 +10,7 @@
* SQLParamOptions(NI) * SQLParamOptions(NI)
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *-------
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
...@@ -33,8 +34,8 @@ ...@@ -33,8 +34,8 @@
#include "sqlext.h" #include "sqlext.h"
#endif #endif
/* Bind parameters on a statement handle */
/* Bind parameters on a statement handle */
RETCODE SQL_API RETCODE SQL_API
SQLBindParameter( SQLBindParameter(
HSTMT hstmt, HSTMT hstmt,
...@@ -112,8 +113,8 @@ SQLBindParameter( ...@@ -112,8 +113,8 @@ SQLBindParameter(
} }
} }
ipar--; /* use zero based column numbers for the /* use zero based column numbers for the below part */
* below part */ ipar--;
/* store the given info */ /* store the given info */
stmt->parameters[ipar].buflen = cbValueMax; stmt->parameters[ipar].buflen = cbValueMax;
...@@ -158,9 +159,8 @@ SQLBindParameter( ...@@ -158,9 +159,8 @@ SQLBindParameter(
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* - - - - - - - - - */
/* Associate a user-supplied buffer with a database column. */ /* Associate a user-supplied buffer with a database column. */
RETCODE SQL_API RETCODE SQL_API
SQLBindCol( SQLBindCol(
HSTMT hstmt, HSTMT hstmt,
...@@ -197,7 +197,6 @@ SQLBindCol( ...@@ -197,7 +197,6 @@ SQLBindCol(
/* If the bookmark column is being bound, then just save it */ /* If the bookmark column is being bound, then just save it */
if (icol == 0) if (icol == 0)
{ {
if (rgbValue == NULL) if (rgbValue == NULL)
{ {
stmt->bookmark.buffer = NULL; stmt->bookmark.buffer = NULL;
...@@ -220,10 +219,12 @@ SQLBindCol( ...@@ -220,10 +219,12 @@ SQLBindCol(
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* allocate enough bindings if not already done */ /*
/* Most likely, execution of a statement would have setup the */ * Allocate enough bindings if not already done.
/* necessary bindings. But some apps call BindCol before any */ * Most likely, execution of a statement would have setup the
/* statement is executed. */ * necessary bindings. But some apps call BindCol before any
* statement is executed.
*/
if (icol > stmt->bindings_allocated) if (icol > stmt->bindings_allocated)
extend_bindings(stmt, icol); extend_bindings(stmt, icol);
...@@ -236,8 +237,8 @@ SQLBindCol( ...@@ -236,8 +237,8 @@ SQLBindCol(
return SQL_ERROR; return SQL_ERROR;
} }
icol--; /* use zero based col numbers from here /* use zero based col numbers from here out */
* out */ icol--;
/* Reset for SQLGetData */ /* Reset for SQLGetData */
stmt->bindings[icol].data_left = -1; stmt->bindings[icol].data_left = -1;
...@@ -264,15 +265,15 @@ SQLBindCol( ...@@ -264,15 +265,15 @@ SQLBindCol(
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* - - - - - - - - - */
/* Returns the description of a parameter marker. */
/* This function is listed as not being supported by SQLGetFunctions() because it is */
/* used to describe "parameter markers" (not bound parameters), in which case, */
/* the dbms should return info on the markers. Since Postgres doesn't support that, */
/* it is best to say this function is not supported and let the application assume a */
/* data type (most likely varchar). */
/*
* Returns the description of a parameter marker.
* This function is listed as not being supported by SQLGetFunctions() because it is
* used to describe "parameter markers" (not bound parameters), in which case,
* the dbms should return info on the markers. Since Postgres doesn't support that,
* it is best to say this function is not supported and let the application assume a
* data type (most likely varchar).
*/
RETCODE SQL_API RETCODE SQL_API
SQLDescribeParam( SQLDescribeParam(
HSTMT hstmt, HSTMT hstmt,
...@@ -323,10 +324,8 @@ SQLDescribeParam( ...@@ -323,10 +324,8 @@ SQLDescribeParam(
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* - - - - - - - - - */
/* Sets multiple values (arrays) for the set of parameter markers. */
/* Sets multiple values (arrays) for the set of parameter markers. */
RETCODE SQL_API RETCODE SQL_API
SQLParamOptions( SQLParamOptions(
HSTMT hstmt, HSTMT hstmt,
...@@ -341,15 +340,16 @@ SQLParamOptions( ...@@ -341,15 +340,16 @@ SQLParamOptions(
return SQL_ERROR; return SQL_ERROR;
} }
/* - - - - - - - - - */
/* This function should really talk to the dbms to determine the number of */ /*
/* "parameter markers" (not bound parameters) in the statement. But, since */ * This function should really talk to the dbms to determine the number of
/* Postgres doesn't support that, the driver should just count the number of markers */ * "parameter markers" (not bound parameters) in the statement. But, since
/* and return that. The reason the driver just can't say this function is unsupported */ * Postgres doesn't support that, the driver should just count the number of markers
/* like it does for SQLDescribeParam is that some applications don't care and try */ * and return that. The reason the driver just can't say this function is unsupported
/* to call it anyway. */ * like it does for SQLDescribeParam is that some applications don't care and try
/* If the statement does not have parameters, it should just return 0. */ * to call it anyway.
* If the statement does not have parameters, it should just return 0.
*/
RETCODE SQL_API RETCODE SQL_API
SQLNumParams( SQLNumParams(
HSTMT hstmt, HSTMT hstmt,
...@@ -387,10 +387,8 @@ SQLNumParams( ...@@ -387,10 +387,8 @@ SQLNumParams(
} }
else else
{ {
for (i = 0; i < strlen(stmt->statement); i++) for (i = 0; i < strlen(stmt->statement); i++)
{ {
if (stmt->statement[i] == '?' && !in_quote) if (stmt->statement[i] == '?' && !in_quote)
(*pcpar)++; (*pcpar)++;
else else
...@@ -399,12 +397,12 @@ SQLNumParams( ...@@ -399,12 +397,12 @@ SQLNumParams(
in_quote = (in_quote ? FALSE : TRUE); in_quote = (in_quote ? FALSE : TRUE);
} }
} }
return SQL_SUCCESS; return SQL_SUCCESS;
} }
} }
/********************************************************************
/*
* Bindings Implementation * Bindings Implementation
*/ */
BindInfoClass * BindInfoClass *
...@@ -428,6 +426,7 @@ create_empty_bindings(int num_columns) ...@@ -428,6 +426,7 @@ create_empty_bindings(int num_columns)
return new_bindings; return new_bindings;
} }
void void
extend_bindings(StatementClass *stmt, int num_columns) extend_bindings(StatementClass *stmt, int num_columns)
{ {
...@@ -437,11 +436,12 @@ extend_bindings(StatementClass *stmt, int num_columns) ...@@ -437,11 +436,12 @@ extend_bindings(StatementClass *stmt, int num_columns)
mylog("%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n", func, stmt, stmt->bindings_allocated, num_columns); mylog("%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n", func, stmt, stmt->bindings_allocated, num_columns);
/* if we have too few, allocate room for more, and copy the old */ /*
/* entries into the new structure */ * if we have too few, allocate room for more, and copy the old
* entries into the new structure
*/
if (stmt->bindings_allocated < num_columns) if (stmt->bindings_allocated < num_columns)
{ {
new_bindings = create_empty_bindings(num_columns); new_bindings = create_empty_bindings(num_columns);
if (!new_bindings) if (!new_bindings)
{ {
...@@ -466,11 +466,12 @@ extend_bindings(StatementClass *stmt, int num_columns) ...@@ -466,11 +466,12 @@ extend_bindings(StatementClass *stmt, int num_columns)
stmt->bindings = new_bindings; stmt->bindings = new_bindings;
stmt->bindings_allocated = num_columns; stmt->bindings_allocated = num_columns;
} }
/* There is no reason to zero out extra bindings if there are */ /*
/* more than needed. If an app has allocated extra bindings, */ * There is no reason to zero out extra bindings if there are
/* let it worry about it by unbinding those columns. */ * more than needed. If an app has allocated extra bindings,
* let it worry about it by unbinding those columns.
*/
/* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */ /* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */
/* SQLExecDirect(...) # returns 5 cols */ /* SQLExecDirect(...) # returns 5 cols */
......
/* Module: columninfo.c /*-------
* Module: columninfo.c
* *
* Description: This module contains routines related to * Description: This module contains routines related to
* reading and storing the field information from a query. * reading and storing the field information from a query.
...@@ -8,7 +9,7 @@ ...@@ -8,7 +9,7 @@
* API functions: none * API functions: none
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *-------
*/ */
#include "columninfo.h" #include "columninfo.h"
...@@ -37,6 +38,7 @@ CI_Constructor() ...@@ -37,6 +38,7 @@ CI_Constructor()
return rv; return rv;
} }
void void
CI_Destructor(ColumnInfoClass *self) CI_Destructor(ColumnInfoClass *self)
{ {
...@@ -45,10 +47,12 @@ CI_Destructor(ColumnInfoClass *self) ...@@ -45,10 +47,12 @@ CI_Destructor(ColumnInfoClass *self)
free(self); free(self);
} }
/* Read in field descriptions.
If self is not null, then also store the information. /*
If self is null, then just read, don't store. * Read in field descriptions.
*/ * If self is not null, then also store the information.
* If self is null, then just read, don't store.
*/
char char
CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn) CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
{ {
...@@ -71,14 +75,12 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn) ...@@ -71,14 +75,12 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
mylog("num_fields = %d\n", new_num_fields); mylog("num_fields = %d\n", new_num_fields);
if (self) if (self)
{ /* according to that allocate memory */ /* according to that allocate memory */
CI_set_num_fields(self, new_num_fields); CI_set_num_fields(self, new_num_fields);
}
/* now read in the descriptions */ /* now read in the descriptions */
for (lf = 0; lf < new_num_fields; lf++) for (lf = 0; lf < new_num_fields; lf++)
{ {
SOCK_get_string(sock, new_field_name, 2 * MAX_COLUMN_LEN); SOCK_get_string(sock, new_field_name, 2 * MAX_COLUMN_LEN);
new_adtid = (Oid) SOCK_get_int(sock, 4); new_adtid = (Oid) SOCK_get_int(sock, 4);
new_adtsize = (Int2) SOCK_get_int(sock, 2); new_adtsize = (Int2) SOCK_get_int(sock, 2);
...@@ -86,7 +88,6 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn) ...@@ -86,7 +88,6 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
/* If 6.4 protocol, then read the atttypmod field */ /* If 6.4 protocol, then read the atttypmod field */
if (PG_VERSION_GE(conn, 6.4)) if (PG_VERSION_GE(conn, 6.4))
{ {
mylog("READING ATTTYPMOD\n"); mylog("READING ATTTYPMOD\n");
new_atttypmod = (Int4) SOCK_get_int(sock, 4); new_atttypmod = (Int4) SOCK_get_int(sock, 4);
...@@ -107,7 +108,6 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn) ...@@ -107,7 +108,6 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
} }
void void
CI_free_memory(ColumnInfoClass *self) CI_free_memory(ColumnInfoClass *self)
{ {
...@@ -143,6 +143,7 @@ CI_free_memory(ColumnInfoClass *self) ...@@ -143,6 +143,7 @@ CI_free_memory(ColumnInfoClass *self)
self->atttypmod = NULL; self->atttypmod = NULL;
} }
void void
CI_set_num_fields(ColumnInfoClass *self, int new_num_fields) CI_set_num_fields(ColumnInfoClass *self, int new_num_fields)
{ {
...@@ -158,11 +159,11 @@ CI_set_num_fields(ColumnInfoClass *self, int new_num_fields) ...@@ -158,11 +159,11 @@ CI_set_num_fields(ColumnInfoClass *self, int new_num_fields)
self->atttypmod = (Int4 *) malloc(sizeof(Int4) * self->num_fields); self->atttypmod = (Int4 *) malloc(sizeof(Int4) * self->num_fields);
} }
void void
CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name, CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod) Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
{ {
/* check bounds */ /* check bounds */
if ((field_num < 0) || (field_num >= self->num_fields)) if ((field_num < 0) || (field_num >= self->num_fields))
return; return;
......
This diff is collapsed.
This diff is collapsed.
/* Module: dlg_specific.c /*-------
* Module: dlg_specific.c
* *
* Description: This module contains any specific code for handling * Description: This module contains any specific code for handling
* dialog boxes such as driver/datasource options. Both the * dialog boxes such as driver/datasource options. Both the
...@@ -12,7 +13,7 @@ ...@@ -12,7 +13,7 @@
* API functions: none * API functions: none
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *-------
*/ */
/* Multibyte support Eiji Tokuya 2001-03-15 */ /* Multibyte support Eiji Tokuya 2001-03-15 */
...@@ -50,11 +51,11 @@ ...@@ -50,11 +51,11 @@
extern GLOBAL_VALUES globals; extern GLOBAL_VALUES globals;
#ifdef WIN32 #ifdef WIN32
void void
SetDlgStuff(HWND hdlg, ConnInfo *ci) SetDlgStuff(HWND hdlg, ConnInfo *ci)
{ {
/* /*
* If driver attribute NOT present, then set the datasource name and * If driver attribute NOT present, then set the datasource name and
* description * description
...@@ -72,6 +73,7 @@ SetDlgStuff(HWND hdlg, ConnInfo *ci) ...@@ -72,6 +73,7 @@ SetDlgStuff(HWND hdlg, ConnInfo *ci)
SetDlgItemText(hdlg, IDC_PORT, ci->port); SetDlgItemText(hdlg, IDC_PORT, ci->port);
} }
void void
GetDlgStuff(HWND hdlg, ConnInfo *ci) GetDlgStuff(HWND hdlg, ConnInfo *ci)
{ {
...@@ -85,7 +87,6 @@ GetDlgStuff(HWND hdlg, ConnInfo *ci) ...@@ -85,7 +87,6 @@ GetDlgStuff(HWND hdlg, ConnInfo *ci)
} }
int CALLBACK int CALLBACK
driver_optionsProc(HWND hdlg, driver_optionsProc(HWND hdlg,
WORD wMsg, WORD wMsg,
...@@ -141,7 +142,6 @@ driver_optionsProc(HWND hdlg, ...@@ -141,7 +142,6 @@ driver_optionsProc(HWND hdlg,
switch (GET_WM_COMMAND_ID(wParam, lParam)) switch (GET_WM_COMMAND_ID(wParam, lParam))
{ {
case IDOK: case IDOK:
globals.commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG); globals.commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG);
globals.disable_optimizer = IsDlgButtonChecked(hdlg, DRV_OPTIMIZER); globals.disable_optimizer = IsDlgButtonChecked(hdlg, DRV_OPTIMIZER);
globals.ksqo = IsDlgButtonChecked(hdlg, DRV_KSQO); globals.ksqo = IsDlgButtonChecked(hdlg, DRV_KSQO);
...@@ -228,12 +228,12 @@ driver_optionsProc(HWND hdlg, ...@@ -228,12 +228,12 @@ driver_optionsProc(HWND hdlg,
break; break;
} }
} }
return FALSE; return FALSE;
} }
int CALLBACK int CALLBACK
ds_optionsProc(HWND hdlg, ds_optionsProc(HWND hdlg,
WORD wMsg, WORD wMsg,
...@@ -267,11 +267,9 @@ ds_optionsProc(HWND hdlg, ...@@ -267,11 +267,9 @@ ds_optionsProc(HWND hdlg,
else if (strncmp(ci->protocol, PG63, strlen(PG63)) == 0) else if (strncmp(ci->protocol, PG63, strlen(PG63)) == 0)
CheckDlgButton(hdlg, DS_PG63, 1); CheckDlgButton(hdlg, DS_PG63, 1);
else else
/* latest */ /* latest */
CheckDlgButton(hdlg, DS_PG64, 1); CheckDlgButton(hdlg, DS_PG64, 1);
CheckDlgButton(hdlg, DS_SHOWOIDCOLUMN, atoi(ci->show_oid_column)); CheckDlgButton(hdlg, DS_SHOWOIDCOLUMN, atoi(ci->show_oid_column));
CheckDlgButton(hdlg, DS_FAKEOIDINDEX, atoi(ci->fake_oid_index)); CheckDlgButton(hdlg, DS_FAKEOIDINDEX, atoi(ci->fake_oid_index));
CheckDlgButton(hdlg, DS_ROWVERSIONING, atoi(ci->row_versioning)); CheckDlgButton(hdlg, DS_ROWVERSIONING, atoi(ci->row_versioning));
...@@ -283,7 +281,6 @@ ds_optionsProc(HWND hdlg, ...@@ -283,7 +281,6 @@ ds_optionsProc(HWND hdlg,
SetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings); SetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings);
break; break;
case WM_COMMAND: case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam)) switch (GET_WM_COMMAND_ID(wParam, lParam))
{ {
...@@ -292,9 +289,7 @@ ds_optionsProc(HWND hdlg, ...@@ -292,9 +289,7 @@ ds_optionsProc(HWND hdlg,
EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN)); EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN));
return TRUE; return TRUE;
case IDOK: case IDOK:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
mylog("IDOK: got ci = %u\n", ci); mylog("IDOK: got ci = %u\n", ci);
...@@ -307,7 +302,7 @@ ds_optionsProc(HWND hdlg, ...@@ -307,7 +302,7 @@ ds_optionsProc(HWND hdlg,
else if (IsDlgButtonChecked(hdlg, DS_PG63)) else if (IsDlgButtonChecked(hdlg, DS_PG63))
strcpy(ci->protocol, PG63); strcpy(ci->protocol, PG63);
else else
/* latest */ /* latest */
strcpy(ci->protocol, PG64); strcpy(ci->protocol, PG64);
sprintf(ci->show_system_tables, "%d", IsDlgButtonChecked(hdlg, DS_SHOWSYSTEMTABLES)); sprintf(ci->show_system_tables, "%d", IsDlgButtonChecked(hdlg, DS_SHOWSYSTEMTABLES));
...@@ -321,7 +316,6 @@ ds_optionsProc(HWND hdlg, ...@@ -321,7 +316,6 @@ ds_optionsProc(HWND hdlg,
/* Datasource Connection Settings */ /* Datasource Connection Settings */
GetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings, sizeof(ci->conn_settings)); GetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings, sizeof(ci->conn_settings));
/* fall through */ /* fall through */
case IDCANCEL: case IDCANCEL:
...@@ -335,6 +329,7 @@ ds_optionsProc(HWND hdlg, ...@@ -335,6 +329,7 @@ ds_optionsProc(HWND hdlg,
#endif /* WIN32 */ #endif /* WIN32 */
void void
makeConnectString(char *connect_string, ConnInfo *ci) makeConnectString(char *connect_string, ConnInfo *ci)
{ {
...@@ -365,10 +360,10 @@ makeConnectString(char *connect_string, ConnInfo *ci) ...@@ -365,10 +360,10 @@ makeConnectString(char *connect_string, ConnInfo *ci)
encoded_conn_settings); encoded_conn_settings);
} }
void void
copyAttributes(ConnInfo *ci, char *attribute, char *value) copyAttributes(ConnInfo *ci, char *attribute, char *value)
{ {
if (stricmp(attribute, "DSN") == 0) if (stricmp(attribute, "DSN") == 0)
strcpy(ci->dsn, value); strcpy(ci->dsn, value);
...@@ -415,9 +410,9 @@ copyAttributes(ConnInfo *ci, char *attribute, char *value) ...@@ -415,9 +410,9 @@ copyAttributes(ConnInfo *ci, char *attribute, char *value)
} }
mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s', conn_settings='%s')\n", ci->dsn, ci->server, ci->database, ci->username, ci->password, ci->port, ci->onlyread, ci->protocol, ci->conn_settings); mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s', conn_settings='%s')\n", ci->dsn, ci->server, ci->database, ci->username, ci->password, ci->port, ci->onlyread, ci->protocol, ci->conn_settings);
} }
void void
getDSNdefaults(ConnInfo *ci) getDSNdefaults(ConnInfo *ci)
{ {
...@@ -450,8 +445,10 @@ getDSNinfo(ConnInfo *ci, char overwrite) ...@@ -450,8 +445,10 @@ getDSNinfo(ConnInfo *ci, char overwrite)
char *DSN = ci->dsn; char *DSN = ci->dsn;
char encoded_conn_settings[LARGE_REGISTRY_LEN]; char encoded_conn_settings[LARGE_REGISTRY_LEN];
/* If a driver keyword was present, then dont use a DSN and return. */ /*
/* If DSN is null and no driver, then use the default datasource. */ * If a driver keyword was present, then dont use a DSN and return.
* If DSN is null and no driver, then use the default datasource.
*/
if (DSN[0] == '\0') if (DSN[0] == '\0')
{ {
if (ci->driver[0] != '\0') if (ci->driver[0] != '\0')
...@@ -514,11 +511,9 @@ getDSNinfo(ConnInfo *ci, char overwrite) ...@@ -514,11 +511,9 @@ getDSNinfo(ConnInfo *ci, char overwrite)
if (ci->translation_option[0] == '\0' || overwrite) if (ci->translation_option[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_TRANSLATIONOPTION, "", ci->translation_option, sizeof(ci->translation_option), ODBC_INI); SQLGetPrivateProfileString(DSN, INI_TRANSLATIONOPTION, "", ci->translation_option, sizeof(ci->translation_option), ODBC_INI);
/* Allow override of odbcinst.ini parameters here */ /* Allow override of odbcinst.ini parameters here */
getGlobalDefaults(DSN, ODBC_INI, TRUE); getGlobalDefaults(DSN, ODBC_INI, TRUE);
qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n", qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n",
DSN, DSN,
ci->server, ci->server,
...@@ -546,7 +541,6 @@ getDSNinfo(ConnInfo *ci, char overwrite) ...@@ -546,7 +541,6 @@ getDSNinfo(ConnInfo *ci, char overwrite)
qlog(" translation_dll='%s',translation_option='%s'\n", qlog(" translation_dll='%s',translation_option='%s'\n",
ci->translation_dll, ci->translation_dll,
ci->translation_option); ci->translation_option);
} }
...@@ -626,15 +620,15 @@ writeDSNinfo(ConnInfo *ci) ...@@ -626,15 +620,15 @@ writeDSNinfo(ConnInfo *ci)
} }
/* This function reads the ODBCINST.INI portion of /*
the registry and gets any driver defaults. * This function reads the ODBCINST.INI portion of
*/ * the registry and gets any driver defaults.
*/
void void
getGlobalDefaults(char *section, char *filename, char override) getGlobalDefaults(char *section, char *filename, char override)
{ {
char temp[256]; char temp[256];
/* Fetch Count is stored in driver section */ /* Fetch Count is stored in driver section */
SQLGetPrivateProfileString(section, INI_FETCH, "", SQLGetPrivateProfileString(section, INI_FETCH, "",
temp, sizeof(temp), filename); temp, sizeof(temp), filename);
...@@ -648,7 +642,6 @@ getGlobalDefaults(char *section, char *filename, char override) ...@@ -648,7 +642,6 @@ getGlobalDefaults(char *section, char *filename, char override)
else if (!override) else if (!override)
globals.fetch_max = FETCH_MAX; globals.fetch_max = FETCH_MAX;
/* Socket Buffersize is stored in driver section */ /* Socket Buffersize is stored in driver section */
SQLGetPrivateProfileString(section, INI_SOCKET, "", SQLGetPrivateProfileString(section, INI_SOCKET, "",
temp, sizeof(temp), filename); temp, sizeof(temp), filename);
...@@ -657,7 +650,6 @@ getGlobalDefaults(char *section, char *filename, char override) ...@@ -657,7 +650,6 @@ getGlobalDefaults(char *section, char *filename, char override)
else if (!override) else if (!override)
globals.socket_buffersize = SOCK_BUFFER_SIZE; globals.socket_buffersize = SOCK_BUFFER_SIZE;
/* Debug is stored in the driver section */ /* Debug is stored in the driver section */
SQLGetPrivateProfileString(section, INI_DEBUG, "", SQLGetPrivateProfileString(section, INI_DEBUG, "",
temp, sizeof(temp), filename); temp, sizeof(temp), filename);
...@@ -666,7 +658,6 @@ getGlobalDefaults(char *section, char *filename, char override) ...@@ -666,7 +658,6 @@ getGlobalDefaults(char *section, char *filename, char override)
else if (!override) else if (!override)
globals.debug = DEFAULT_DEBUG; globals.debug = DEFAULT_DEBUG;
/* CommLog is stored in the driver section */ /* CommLog is stored in the driver section */
SQLGetPrivateProfileString(section, INI_COMMLOG, "", SQLGetPrivateProfileString(section, INI_COMMLOG, "",
temp, sizeof(temp), filename); temp, sizeof(temp), filename);
...@@ -675,7 +666,6 @@ getGlobalDefaults(char *section, char *filename, char override) ...@@ -675,7 +666,6 @@ getGlobalDefaults(char *section, char *filename, char override)
else if (!override) else if (!override)
globals.commlog = DEFAULT_COMMLOG; globals.commlog = DEFAULT_COMMLOG;
/* Optimizer is stored in the driver section only */ /* Optimizer is stored in the driver section only */
SQLGetPrivateProfileString(section, INI_OPTIMIZER, "", SQLGetPrivateProfileString(section, INI_OPTIMIZER, "",
temp, sizeof(temp), filename); temp, sizeof(temp), filename);
...@@ -734,8 +724,6 @@ getGlobalDefaults(char *section, char *filename, char override) ...@@ -734,8 +724,6 @@ getGlobalDefaults(char *section, char *filename, char override)
else if (!override) else if (!override)
globals.cancel_as_freestmt = DEFAULT_CANCELASFREESTMT; globals.cancel_as_freestmt = DEFAULT_CANCELASFREESTMT;
/* UseDeclareFetch is stored in the driver section only */ /* UseDeclareFetch is stored in the driver section only */
SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, "", SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, "",
temp, sizeof(temp), filename); temp, sizeof(temp), filename);
...@@ -744,7 +732,6 @@ getGlobalDefaults(char *section, char *filename, char override) ...@@ -744,7 +732,6 @@ getGlobalDefaults(char *section, char *filename, char override)
else if (!override) else if (!override)
globals.use_declarefetch = DEFAULT_USEDECLAREFETCH; globals.use_declarefetch = DEFAULT_USEDECLAREFETCH;
/* Max Varchar Size */ /* Max Varchar Size */
SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, "", SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, "",
temp, sizeof(temp), filename); temp, sizeof(temp), filename);
...@@ -804,7 +791,6 @@ getGlobalDefaults(char *section, char *filename, char override) ...@@ -804,7 +791,6 @@ getGlobalDefaults(char *section, char *filename, char override)
/* Dont allow override of an override! */ /* Dont allow override of an override! */
if (!override) if (!override)
{ {
/* /*
* ConnSettings is stored in the driver section and per datasource * ConnSettings is stored in the driver section and per datasource
* for override * for override
...@@ -831,14 +817,14 @@ getGlobalDefaults(char *section, char *filename, char override) ...@@ -831,14 +817,14 @@ getGlobalDefaults(char *section, char *filename, char override)
strcpy(globals.protocol, temp); strcpy(globals.protocol, temp);
else else
strcpy(globals.protocol, DEFAULT_PROTOCOL); strcpy(globals.protocol, DEFAULT_PROTOCOL);
} }
} }
/* This function writes any global parameters (that can be manipulated) /*
to the ODBCINST.INI portion of the registry * This function writes any global parameters (that can be manipulated)
*/ * to the ODBCINST.INI portion of the registry
*/
void void
updateGlobals(void) updateGlobals(void)
{ {
......
/* Module: drvconn.c /*-------
* Module: drvconn.c
* *
* Description: This module contains only routines related to * Description: This module contains only routines related to
* implementing SQLDriverConnect. * implementing SQLDriverConnect.
...@@ -8,7 +9,7 @@ ...@@ -8,7 +9,7 @@
* API functions: SQLDriverConnect * API functions: SQLDriverConnect
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *-------
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
...@@ -110,9 +111,11 @@ SQLDriverConnect( ...@@ -110,9 +111,11 @@ SQLDriverConnect(
/* Parse the connect string and fill in conninfo for this hdbc. */ /* Parse the connect string and fill in conninfo for this hdbc. */
dconn_get_connect_attributes(connStrIn, ci); dconn_get_connect_attributes(connStrIn, ci);
/* If the ConnInfo in the hdbc is missing anything, */ /*
/* this function will fill them in from the registry (assuming */ * If the ConnInfo in the hdbc is missing anything,
/* of course there is a DSN given -- if not, it does nothing!) */ * this function will fill them in from the registry (assuming
* of course there is a DSN given -- if not, it does nothing!)
*/
getDSNinfo(ci, CONN_DONT_OVERWRITE); getDSNinfo(ci, CONN_DONT_OVERWRITE);
/* Fill in any default parameters if they are not there. */ /* Fill in any default parameters if they are not there. */
...@@ -147,7 +150,6 @@ dialog: ...@@ -147,7 +150,6 @@ dialog:
ci->port[0] == '\0' || ci->port[0] == '\0' ||
password_required) password_required)
{ {
dialog_result = dconn_DoDialog(hwnd, ci); dialog_result = dconn_DoDialog(hwnd, ci);
if (dialog_result != SQL_SUCCESS) if (dialog_result != SQL_SUCCESS)
return dialog_result; return dialog_result;
...@@ -173,12 +175,11 @@ dialog: ...@@ -173,12 +175,11 @@ dialog:
ci->database[0] == '\0' || ci->database[0] == '\0' ||
ci->port[0] == '\0') ci->port[0] == '\0')
{ {
/* (password_required && ci->password[0] == '\0')) */ /* (password_required && ci->password[0] == '\0')) */
return SQL_NO_DATA_FOUND; return SQL_NO_DATA_FOUND;
} }
/* do the actual connect */ /* do the actual connect */
retval = CC_connect(conn, password_required); retval = CC_connect(conn, password_required);
if (retval < 0) if (retval < 0)
...@@ -206,9 +207,9 @@ dialog: ...@@ -206,9 +207,9 @@ dialog:
return SQL_ERROR; return SQL_ERROR;
} }
/*********************************************/ /*
/* Create the Output Connection String */ * Create the Output Connection String
/*********************************************/ */
result = SQL_SUCCESS; result = SQL_SUCCESS;
makeConnectString(connStrOut, ci); makeConnectString(connStrOut, ci);
...@@ -216,7 +217,6 @@ dialog: ...@@ -216,7 +217,6 @@ dialog:
if (szConnStrOut) if (szConnStrOut)
{ {
/* /*
* Return the completed string to the caller. The correct method * Return the completed string to the caller. The correct method
* is to only construct the connect string if a dialog was put up, * is to only construct the connect string if a dialog was put up,
...@@ -247,6 +247,7 @@ dialog: ...@@ -247,6 +247,7 @@ dialog:
return result; return result;
} }
#ifdef WIN32 #ifdef WIN32
RETCODE RETCODE
dconn_DoDialog(HWND hwnd, ConnInfo *ci) dconn_DoDialog(HWND hwnd, ConnInfo *ci)
...@@ -296,7 +297,6 @@ dconn_FDriverConnectProc( ...@@ -296,7 +297,6 @@ dconn_FDriverConnectProc(
SetWindowLong(hdlg, DWL_USER, lParam); /* Save the ConnInfo for SetWindowLong(hdlg, DWL_USER, lParam); /* Save the ConnInfo for
* the "OK" */ * the "OK" */
SetDlgStuff(hdlg, ci); SetDlgStuff(hdlg, ci);
if (ci->database[0] == '\0') if (ci->database[0] == '\0')
...@@ -309,38 +309,29 @@ dconn_FDriverConnectProc( ...@@ -309,38 +309,29 @@ dconn_FDriverConnectProc(
SetFocus(GetDlgItem(hdlg, IDC_USER)); SetFocus(GetDlgItem(hdlg, IDC_USER));
else if (ci->focus_password) else if (ci->focus_password)
SetFocus(GetDlgItem(hdlg, IDC_PASSWORD)); SetFocus(GetDlgItem(hdlg, IDC_PASSWORD));
break; break;
case WM_COMMAND: case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam)) switch (GET_WM_COMMAND_ID(wParam, lParam))
{ {
case IDOK: case IDOK:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
GetDlgStuff(hdlg, ci); GetDlgStuff(hdlg, ci);
case IDCANCEL: case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK); EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
return TRUE; return TRUE;
case IDC_DRIVER: case IDC_DRIVER:
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV), DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
hdlg, driver_optionsProc, (LPARAM) NULL); hdlg, driver_optionsProc, (LPARAM) NULL);
break; break;
case IDC_DATASOURCE: case IDC_DATASOURCE:
ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER);
DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DS), DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DS),
hdlg, ds_optionsProc, (LPARAM) ci); hdlg, ds_optionsProc, (LPARAM) ci);
break; break;
} }
} }
...@@ -350,6 +341,7 @@ dconn_FDriverConnectProc( ...@@ -350,6 +341,7 @@ dconn_FDriverConnectProc(
#endif /* WIN32 */ #endif /* WIN32 */
void void
dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci) dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci)
{ {
...@@ -393,6 +385,5 @@ dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci) ...@@ -393,6 +385,5 @@ dconn_get_connect_attributes(UCHAR FAR *connect_string, ConnInfo *ci)
} }
free(our_connect_string); free(our_connect_string);
} }
/* Module: environ.c /*-------
* Module: environ.c
* *
* Description: This module contains routines related to * Description: This module contains routines related to
* the environment, such as storing connection handles, * the environment, such as storing connection handles,
...@@ -9,7 +10,7 @@ ...@@ -9,7 +10,7 @@
* API functions: SQLAllocEnv, SQLFreeEnv, SQLError * API functions: SQLAllocEnv, SQLFreeEnv, SQLError
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *-------
*/ */
#include "environ.h" #include "environ.h"
...@@ -54,6 +55,7 @@ SQLAllocEnv(HENV FAR *phenv) ...@@ -54,6 +55,7 @@ SQLAllocEnv(HENV FAR *phenv)
return SQL_SUCCESS; return SQL_SUCCESS;
} }
RETCODE SQL_API RETCODE SQL_API
SQLFreeEnv(HENV henv) SQLFreeEnv(HENV henv)
{ {
...@@ -73,8 +75,8 @@ SQLFreeEnv(HENV henv) ...@@ -73,8 +75,8 @@ SQLFreeEnv(HENV henv)
return SQL_ERROR; return SQL_ERROR;
} }
/* Returns the next SQL error information. */
/* Returns the next SQL error information. */
RETCODE SQL_API RETCODE SQL_API
SQLError( SQLError(
HENV henv, HENV henv,
...@@ -208,24 +210,19 @@ SQLError( ...@@ -208,24 +210,19 @@ SQLError(
case STMT_INVALID_CURSOR_POSITION: case STMT_INVALID_CURSOR_POSITION:
strcpy(szSqlState, "S1109"); strcpy(szSqlState, "S1109");
break; break;
case STMT_VALUE_OUT_OF_RANGE: case STMT_VALUE_OUT_OF_RANGE:
strcpy(szSqlState, "22003"); strcpy(szSqlState, "22003");
break; break;
case STMT_OPERATION_INVALID: case STMT_OPERATION_INVALID:
strcpy(szSqlState, "S1011"); strcpy(szSqlState, "S1011");
break; break;
case STMT_EXEC_ERROR: case STMT_EXEC_ERROR:
default: default:
strcpy(szSqlState, "S1000"); strcpy(szSqlState, "S1000");
/* also a general error */ /* also a general error */
break; break;
} }
mylog(" szSqlState = '%s', szError='%s'\n", szSqlState, szErrorMsg); mylog(" szSqlState = '%s', szError='%s'\n", szSqlState, szErrorMsg);
} }
else else
{ {
...@@ -237,10 +234,11 @@ SQLError( ...@@ -237,10 +234,11 @@ SQLError(
szErrorMsg[0] = '\0'; szErrorMsg[0] = '\0';
mylog(" returning NO_DATA_FOUND\n"); mylog(" returning NO_DATA_FOUND\n");
return SQL_NO_DATA_FOUND; return SQL_NO_DATA_FOUND;
} }
return SQL_SUCCESS;
return SQL_SUCCESS;
} }
else if (SQL_NULL_HDBC != hdbc) else if (SQL_NULL_HDBC != hdbc)
{ {
...@@ -310,7 +308,6 @@ SQLError( ...@@ -310,7 +308,6 @@ SQLError(
break; break;
case CONN_TRANSACT_IN_PROGRES: case CONN_TRANSACT_IN_PROGRES:
strcpy(szSqlState, "S1010"); strcpy(szSqlState, "S1010");
/* /*
* when the user tries to switch commit mode in a * when the user tries to switch commit mode in a
* transaction * transaction
...@@ -324,18 +321,15 @@ SQLError( ...@@ -324,18 +321,15 @@ SQLError(
case STMT_NOT_IMPLEMENTED_ERROR: case STMT_NOT_IMPLEMENTED_ERROR:
strcpy(szSqlState, "S1C00"); strcpy(szSqlState, "S1C00");
break; break;
case CONN_VALUE_OUT_OF_RANGE: case CONN_VALUE_OUT_OF_RANGE:
case STMT_VALUE_OUT_OF_RANGE: case STMT_VALUE_OUT_OF_RANGE:
strcpy(szSqlState, "22003"); strcpy(szSqlState, "22003");
break; break;
default: default:
strcpy(szSqlState, "S1000"); strcpy(szSqlState, "S1000");
/* general error */ /* general error */
break; break;
} }
} }
else else
{ {
...@@ -349,8 +343,8 @@ SQLError( ...@@ -349,8 +343,8 @@ SQLError(
return SQL_NO_DATA_FOUND; return SQL_NO_DATA_FOUND;
} }
return SQL_SUCCESS;
return SQL_SUCCESS;
} }
else if (SQL_NULL_HENV != henv) else if (SQL_NULL_HENV != henv)
{ {
...@@ -419,15 +413,10 @@ SQLError( ...@@ -419,15 +413,10 @@ SQLError(
} }
/*********************************************************************/
/* /*
* EnvironmentClass implementation * EnvironmentClass implementation
*/ */
EnvironmentClass *
EnvironmentClass
*
EN_Constructor(void) EN_Constructor(void)
{ {
EnvironmentClass *rv; EnvironmentClass *rv;
...@@ -451,8 +440,10 @@ EN_Destructor(EnvironmentClass *self) ...@@ -451,8 +440,10 @@ EN_Destructor(EnvironmentClass *self)
mylog("in EN_Destructor, self=%u\n", self); mylog("in EN_Destructor, self=%u\n", self);
/* the error messages are static strings distributed throughout */ /*
/* the source--they should not be freed */ * the error messages are static strings distributed throughout
* the source--they should not be freed
*/
/* Free any connections belonging to this environment */ /* Free any connections belonging to this environment */
for (lf = 0; lf < MAX_CONNECTIONS; lf++) for (lf = 0; lf < MAX_CONNECTIONS; lf++)
...@@ -466,6 +457,7 @@ EN_Destructor(EnvironmentClass *self) ...@@ -466,6 +457,7 @@ EN_Destructor(EnvironmentClass *self)
return rv; return rv;
} }
char char
EN_get_error(EnvironmentClass *self, int *number, char **message) EN_get_error(EnvironmentClass *self, int *number, char **message)
{ {
...@@ -481,6 +473,7 @@ EN_get_error(EnvironmentClass *self, int *number, char **message) ...@@ -481,6 +473,7 @@ EN_get_error(EnvironmentClass *self, int *number, char **message)
return 0; return 0;
} }
char char
EN_add_connection(EnvironmentClass *self, ConnectionClass *conn) EN_add_connection(EnvironmentClass *self, ConnectionClass *conn)
{ {
...@@ -504,6 +497,7 @@ EN_add_connection(EnvironmentClass *self, ConnectionClass *conn) ...@@ -504,6 +497,7 @@ EN_add_connection(EnvironmentClass *self, ConnectionClass *conn)
return FALSE; return FALSE;
} }
char char
EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn) EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn)
{ {
...@@ -519,6 +513,7 @@ EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn) ...@@ -519,6 +513,7 @@ EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn)
return FALSE; return FALSE;
} }
void void
EN_log_error(char *func, char *desc, EnvironmentClass *self) EN_log_error(char *func, char *desc, EnvironmentClass *self)
{ {
......
/* Module: execute.c /*-------
* Module: execute.c
* *
* Description: This module contains routines related to * Description: This module contains routines related to
* preparing and executing an SQL statement. * preparing and executing an SQL statement.
...@@ -9,7 +10,7 @@ ...@@ -9,7 +10,7 @@
* SQLCancel, SQLNativeSql, SQLParamData, SQLPutData * SQLCancel, SQLNativeSql, SQLParamData, SQLPutData
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *-------
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
...@@ -126,14 +127,10 @@ SQLPrepare(HSTMT hstmt, ...@@ -126,14 +127,10 @@ SQLPrepare(HSTMT hstmt,
} }
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* - - - - - - - - - */
/* Performs the equivalent of SQLPrepare, followed by SQLExecute. */ /* Performs the equivalent of SQLPrepare, followed by SQLExecute. */
RETCODE SQL_API RETCODE SQL_API
SQLExecDirect( SQLExecDirect(
HSTMT hstmt, HSTMT hstmt,
...@@ -155,8 +152,10 @@ SQLExecDirect( ...@@ -155,8 +152,10 @@ SQLExecDirect(
if (stmt->statement) if (stmt->statement)
free(stmt->statement); free(stmt->statement);
/* keep a copy of the un-parametrized statement, in case */ /*
/* they try to execute this statement again */ * keep a copy of the un-parametrized statement, in case
* they try to execute this statement again
*/
stmt->statement = make_string(szSqlStr, cbSqlStr, NULL); stmt->statement = make_string(szSqlStr, cbSqlStr, NULL);
if (!stmt->statement) if (!stmt->statement)
{ {
...@@ -170,9 +169,11 @@ SQLExecDirect( ...@@ -170,9 +169,11 @@ SQLExecDirect(
stmt->prepare = FALSE; stmt->prepare = FALSE;
/* If an SQLPrepare was performed prior to this, but was left in */ /*
/* the premature state because an error occurred prior to SQLExecute */ * If an SQLPrepare was performed prior to this, but was left in
/* then set the statement to finished so it can be recycled. */ * the premature state because an error occurred prior to SQLExecute
* then set the statement to finished so it can be recycled.
*/
if (stmt->status == STMT_PREMATURE) if (stmt->status == STMT_PREMATURE)
stmt->status = STMT_FINISHED; stmt->status = STMT_FINISHED;
...@@ -195,7 +196,8 @@ SQLExecDirect( ...@@ -195,7 +196,8 @@ SQLExecDirect(
return result; return result;
} }
/* Execute a prepared SQL statement */
/* Execute a prepared SQL statement */
RETCODE SQL_API RETCODE SQL_API
SQLExecute( SQLExecute(
HSTMT hstmt) HSTMT hstmt)
...@@ -206,7 +208,6 @@ SQLExecute( ...@@ -206,7 +208,6 @@ SQLExecute(
int i, int i,
retval; retval;
mylog("%s: entering...\n", func); mylog("%s: entering...\n", func);
if (!stmt) if (!stmt)
...@@ -280,7 +281,6 @@ SQLExecute( ...@@ -280,7 +281,6 @@ SQLExecute(
if ((stmt->prepare && stmt->status != STMT_READY) || if ((stmt->prepare && stmt->status != STMT_READY) ||
(stmt->status != STMT_ALLOCATED && stmt->status != STMT_READY)) (stmt->status != STMT_ALLOCATED && stmt->status != STMT_READY))
{ {
stmt->errornumber = STMT_STATUS_ERROR; stmt->errornumber = STMT_STATUS_ERROR;
stmt->errormsg = "The handle does not point to a statement that is ready to be executed"; stmt->errormsg = "The handle does not point to a statement that is ready to be executed";
SC_log_error(func, "", stmt); SC_log_error(func, "", stmt);
...@@ -288,7 +288,6 @@ SQLExecute( ...@@ -288,7 +288,6 @@ SQLExecute(
return SQL_ERROR; return SQL_ERROR;
} }
/* Check if statement has any data-at-execute parameters when it is not in SC_pre_execute. */ /* Check if statement has any data-at-execute parameters when it is not in SC_pre_execute. */
if (!stmt->pre_executing) if (!stmt->pre_executing)
{ {
...@@ -336,15 +335,10 @@ SQLExecute( ...@@ -336,15 +335,10 @@ SQLExecute(
mylog(" stmt_with_params = '%s'\n", stmt->stmt_with_params); mylog(" stmt_with_params = '%s'\n", stmt->stmt_with_params);
return SC_execute(stmt); return SC_execute(stmt);
} }
/* - - - - - - - - - */
RETCODE SQL_API RETCODE SQL_API
SQLTransact( SQLTransact(
HENV henv, HENV henv,
...@@ -380,7 +374,6 @@ SQLTransact( ...@@ -380,7 +374,6 @@ SQLTransact(
if (conn && conn->henv == henv) if (conn && conn->henv == henv)
if (SQLTransact(henv, (HDBC) conn, fType) != SQL_SUCCESS) if (SQLTransact(henv, (HDBC) conn, fType) != SQL_SUCCESS)
return SQL_ERROR; return SQL_ERROR;
} }
return SQL_SUCCESS; return SQL_SUCCESS;
} }
...@@ -388,15 +381,9 @@ SQLTransact( ...@@ -388,15 +381,9 @@ SQLTransact(
conn = (ConnectionClass *) hdbc; conn = (ConnectionClass *) hdbc;
if (fType == SQL_COMMIT) if (fType == SQL_COMMIT)
{
stmt_string = "COMMIT"; stmt_string = "COMMIT";
}
else if (fType == SQL_ROLLBACK) else if (fType == SQL_ROLLBACK)
{
stmt_string = "ROLLBACK"; stmt_string = "ROLLBACK";
}
else else
{ {
conn->errornumber = CONN_INVALID_ARGUMENT_NO; conn->errornumber = CONN_INVALID_ARGUMENT_NO;
...@@ -408,7 +395,6 @@ SQLTransact( ...@@ -408,7 +395,6 @@ SQLTransact(
/* If manual commit and in transaction, then proceed. */ /* If manual commit and in transaction, then proceed. */
if (!CC_is_in_autocommit(conn) && CC_is_in_trans(conn)) if (!CC_is_in_autocommit(conn) && CC_is_in_trans(conn))
{ {
mylog("SQLTransact: sending on conn %d '%s'\n", conn, stmt_string); mylog("SQLTransact: sending on conn %d '%s'\n", conn, stmt_string);
res = CC_send_query(conn, stmt_string, NULL); res = CC_send_query(conn, stmt_string, NULL);
...@@ -433,7 +419,6 @@ SQLTransact( ...@@ -433,7 +419,6 @@ SQLTransact(
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* - - - - - - - - - */
RETCODE SQL_API RETCODE SQL_API
SQLCancel( SQLCancel(
...@@ -464,8 +449,6 @@ SQLCancel( ...@@ -464,8 +449,6 @@ SQLCancel(
*/ */
if (stmt->data_at_exec < 0) if (stmt->data_at_exec < 0)
{ {
/* /*
* MAJOR HACK for Windows to reset the driver manager's cursor * MAJOR HACK for Windows to reset the driver manager's cursor
* state: Because of what seems like a bug in the Odbc driver * state: Because of what seems like a bug in the Odbc driver
...@@ -507,14 +490,14 @@ SQLCancel( ...@@ -507,14 +490,14 @@ SQLCancel(
stmt->put_data = FALSE; stmt->put_data = FALSE;
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* - - - - - - - - - */
/* Returns the SQL string as modified by the driver. */ /*
/* Currently, just copy the input string without modification */ * Returns the SQL string as modified by the driver.
/* observing buffer limits and truncation. */ * Currently, just copy the input string without modification
* observing buffer limits and truncation.
*/
RETCODE SQL_API RETCODE SQL_API
SQLNativeSql( SQLNativeSql(
HDBC hdbc, HDBC hdbc,
...@@ -564,11 +547,11 @@ SQLNativeSql( ...@@ -564,11 +547,11 @@ SQLNativeSql(
return result; return result;
} }
/* - - - - - - - - - */
/* Supplies parameter data at execution time. Used in conjuction with */
/* SQLPutData. */
/*
* Supplies parameter data at execution time.
* Used in conjuction with SQLPutData.
*/
RETCODE SQL_API RETCODE SQL_API
SQLParamData( SQLParamData(
HSTMT hstmt, HSTMT hstmt,
...@@ -636,11 +619,9 @@ SQLParamData( ...@@ -636,11 +619,9 @@ SQLParamData(
CC_set_no_trans(stmt->hdbc); CC_set_no_trans(stmt->hdbc);
} }
stmt->lobj_fd = -1; stmt->lobj_fd = -1;
} }
/* Done, now copy the params and then execute the statement */ /* Done, now copy the params and then execute the statement */
if (stmt->data_at_exec == 0) if (stmt->data_at_exec == 0)
{ {
...@@ -675,11 +656,11 @@ SQLParamData( ...@@ -675,11 +656,11 @@ SQLParamData(
return SQL_NEED_DATA; return SQL_NEED_DATA;
} }
/* - - - - - - - - - */
/* Supplies parameter data at execution time. Used in conjunction with */
/* SQLParamData. */
/*
* Supplies parameter data at execution time.
* Used in conjunction with SQLParamData.
*/
RETCODE SQL_API RETCODE SQL_API
SQLPutData( SQLPutData(
HSTMT hstmt, HSTMT hstmt,
...@@ -701,7 +682,6 @@ SQLPutData( ...@@ -701,7 +682,6 @@ SQLPutData(
return SQL_INVALID_HANDLE; return SQL_INVALID_HANDLE;
} }
if (stmt->current_exec_param < 0) if (stmt->current_exec_param < 0)
{ {
stmt->errornumber = STMT_SEQUENCE_ERROR; stmt->errornumber = STMT_SEQUENCE_ERROR;
...@@ -714,7 +694,6 @@ SQLPutData( ...@@ -714,7 +694,6 @@ SQLPutData(
if (!stmt->put_data) if (!stmt->put_data)
{ /* first call */ { /* first call */
mylog("SQLPutData: (1) cbValue = %d\n", cbValue); mylog("SQLPutData: (1) cbValue = %d\n", cbValue);
stmt->put_data = TRUE; stmt->put_data = TRUE;
...@@ -733,11 +712,9 @@ SQLPutData( ...@@ -733,11 +712,9 @@ SQLPutData(
if (cbValue == SQL_NULL_DATA) if (cbValue == SQL_NULL_DATA)
return SQL_SUCCESS; return SQL_SUCCESS;
/* Handle Long Var Binary with Large Objects */ /* Handle Long Var Binary with Large Objects */
if (current_param->SQLType == SQL_LONGVARBINARY) if (current_param->SQLType == SQL_LONGVARBINARY)
{ {
/* begin transaction if needed */ /* begin transaction if needed */
if (!CC_is_in_trans(stmt->hdbc)) if (!CC_is_in_trans(stmt->hdbc))
{ {
...@@ -775,8 +752,10 @@ SQLPutData( ...@@ -775,8 +752,10 @@ SQLPutData(
return SQL_ERROR; return SQL_ERROR;
} }
/* major hack -- to allow convert to see somethings there */ /*
/* have to modify convert to handle this better */ * major hack -- to allow convert to see somethings there
* have to modify convert to handle this better
*/
current_param->EXEC_buffer = (char *) &current_param->lobj_oid; current_param->EXEC_buffer = (char *) &current_param->lobj_oid;
/* store the fd */ /* store the fd */
...@@ -791,11 +770,10 @@ SQLPutData( ...@@ -791,11 +770,10 @@ SQLPutData(
retval = lo_write(stmt->hdbc, stmt->lobj_fd, rgbValue, cbValue); retval = lo_write(stmt->hdbc, stmt->lobj_fd, rgbValue, cbValue);
mylog("lo_write: cbValue=%d, wrote %d bytes\n", cbValue, retval); mylog("lo_write: cbValue=%d, wrote %d bytes\n", cbValue, retval);
} }
else else
{ /* for handling fields */ {
/* for handling fields */
if (cbValue == SQL_NTS) if (cbValue == SQL_NTS)
{ {
current_param->EXEC_buffer = strdup(rgbValue); current_param->EXEC_buffer = strdup(rgbValue);
...@@ -841,25 +819,21 @@ SQLPutData( ...@@ -841,25 +819,21 @@ SQLPutData(
} }
} }
} }
else else
{ /* calling SQLPutData more than once */ {
/* calling SQLPutData more than once */
mylog("SQLPutData: (>1) cbValue = %d\n", cbValue); mylog("SQLPutData: (>1) cbValue = %d\n", cbValue);
if (current_param->SQLType == SQL_LONGVARBINARY) if (current_param->SQLType == SQL_LONGVARBINARY)
{ {
/* the large object fd is in EXEC_buffer */ /* the large object fd is in EXEC_buffer */
retval = lo_write(stmt->hdbc, stmt->lobj_fd, rgbValue, cbValue); retval = lo_write(stmt->hdbc, stmt->lobj_fd, rgbValue, cbValue);
mylog("lo_write(2): cbValue = %d, wrote %d bytes\n", cbValue, retval); mylog("lo_write(2): cbValue = %d, wrote %d bytes\n", cbValue, retval);
*current_param->EXEC_used += cbValue; *current_param->EXEC_used += cbValue;
} }
else else
{ {
buffer = current_param->EXEC_buffer; buffer = current_param->EXEC_buffer;
if (cbValue == SQL_NTS) if (cbValue == SQL_NTS)
...@@ -880,11 +854,9 @@ SQLPutData( ...@@ -880,11 +854,9 @@ SQLPutData(
/* reassign buffer incase realloc moved it */ /* reassign buffer incase realloc moved it */
current_param->EXEC_buffer = buffer; current_param->EXEC_buffer = buffer;
} }
else if (cbValue > 0) else if (cbValue > 0)
{ {
old_pos = *current_param->EXEC_used; old_pos = *current_param->EXEC_used;
*current_param->EXEC_used += cbValue; *current_param->EXEC_used += cbValue;
...@@ -906,17 +878,14 @@ SQLPutData( ...@@ -906,17 +878,14 @@ SQLPutData(
/* reassign buffer incase realloc moved it */ /* reassign buffer incase realloc moved it */
current_param->EXEC_buffer = buffer; current_param->EXEC_buffer = buffer;
} }
else else
{ {
SC_log_error(func, "bad cbValue", stmt); SC_log_error(func, "bad cbValue", stmt);
return SQL_ERROR; return SQL_ERROR;
} }
} }
} }
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* GetPrivateProfileString() /*-------
* GetPrivateProfileString()
* *
* approximate implementation of * approximate implementation of
* Windows NT System Services version of GetPrivateProfileString() * Windows NT System Services version of GetPrivateProfileString()
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
* are allowed (that is an anachronism anyway) * are allowed (that is an anachronism anyway)
* Added code to search for ODBC_INI file in users home directory on * Added code to search for ODBC_INI file in users home directory on
* Unix * Unix
*-------
*/ */
#ifndef WIN32 #ifndef WIN32
...@@ -46,7 +48,7 @@ ...@@ -46,7 +48,7 @@
DWORD DWORD
GetPrivateProfileString(char *theSection, /* section name */ GetPrivateProfileString(char *theSection, /* section name */
char *theKey, /* search key name */ char *theKey, /* search key name */
char *theDefault, /* default value if not char *theDefault, /* default value if not
* found */ * found */
char *theReturnBuffer, /* return value stored char *theReturnBuffer, /* return value stored
...@@ -110,7 +112,6 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -110,7 +112,6 @@ GetPrivateProfileString(char *theSection, /* section name */
aFile = (FILE *) (buf ? fopen(buf, PG_BINARY_R) : NULL); aFile = (FILE *) (buf ? fopen(buf, PG_BINARY_R) : NULL);
} }
aLength = (theDefault == NULL) ? 0 : strlen(theDefault); aLength = (theDefault == NULL) ? 0 : strlen(theDefault);
if (theReturnBufferLength == 0 || theReturnBuffer == NULL) if (theReturnBufferLength == 0 || theReturnBuffer == NULL)
...@@ -123,7 +124,6 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -123,7 +124,6 @@ GetPrivateProfileString(char *theSection, /* section name */
if (aFile == NULL) if (aFile == NULL)
{ {
/* no ini file specified, return the default */ /* no ini file specified, return the default */
++aLength; /* room for NULL char */ ++aLength; /* room for NULL char */
aLength = theReturnBufferLength < aLength ? aLength = theReturnBufferLength < aLength ?
theReturnBufferLength : aLength; theReturnBufferLength : aLength;
...@@ -132,7 +132,6 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -132,7 +132,6 @@ GetPrivateProfileString(char *theSection, /* section name */
return aLength - 1; return aLength - 1;
} }
while (fgets(aLine, sizeof(aLine), aFile) != NULL) while (fgets(aLine, sizeof(aLine), aFile) != NULL)
{ {
aLineLength = strlen(aLine); aLineLength = strlen(aLine);
...@@ -147,7 +146,6 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -147,7 +146,6 @@ GetPrivateProfileString(char *theSection, /* section name */
break; break;
case '[': /* section marker */ case '[': /* section marker */
if ((aString = strchr(aLine, ']'))) if ((aString = strchr(aLine, ']')))
{ {
aStart = aLine + 1; aStart = aLine + 1;
...@@ -159,30 +157,25 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -159,30 +157,25 @@ GetPrivateProfileString(char *theSection, /* section name */
*(aString + 1) = '\0'; *(aString + 1) = '\0';
/* accept as matched if NULL key or exact match */ /* accept as matched if NULL key or exact match */
if (!theSection || !strcmp(aStart, theSection)) if (!theSection || !strcmp(aStart, theSection))
aSectionFound = TRUE; aSectionFound = TRUE;
else else
aSectionFound = FALSE; aSectionFound = FALSE;
} }
break; break;
default: default:
/* try to match value keys if in proper section */ /* try to match value keys if in proper section */
if (aSectionFound) if (aSectionFound)
{ {
/* try to match requested key */ /* try to match requested key */
if ((aString = aValue = strchr(aLine, '='))) if ((aString = aValue = strchr(aLine, '=')))
{ {
*aValue = '\0'; *aValue = '\0';
++aValue; ++aValue;
/* strip leading blanks in value field */ /* strip leading blanks in value field */
while (*aValue == ' ' && aValue < aLine + sizeof(aLine)) while (*aValue == ' ' && aValue < aLine + sizeof(aLine))
*aValue++ = '\0'; *aValue++ = '\0';
if (aValue >= aLine + sizeof(aLine)) if (aValue >= aLine + sizeof(aLine))
...@@ -196,7 +189,6 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -196,7 +189,6 @@ GetPrivateProfileString(char *theSection, /* section name */
aStart++; aStart++;
/* strip trailing blanks from key */ /* strip trailing blanks from key */
if (aString) if (aString)
{ {
while (--aString >= aStart && *aString == ' ') while (--aString >= aStart && *aString == ' ')
...@@ -204,16 +196,13 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -204,16 +196,13 @@ GetPrivateProfileString(char *theSection, /* section name */
} }
/* see if key is matched */ /* see if key is matched */
if (theKey == NULL || !strcmp(theKey, aStart)) if (theKey == NULL || !strcmp(theKey, aStart))
{ {
/* matched -- first, terminate value part */ /* matched -- first, terminate value part */
aKeyFound = TRUE; aKeyFound = TRUE;
aLength = strlen(aValue); aLength = strlen(aValue);
/* remove trailing blanks from aValue if any */ /* remove trailing blanks from aValue if any */
aString = aValue + aLength - 1; aString = aValue + aLength - 1;
while (--aString > aValue && *aString == ' ') while (--aString > aValue && *aString == ' ')
...@@ -223,7 +212,6 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -223,7 +212,6 @@ GetPrivateProfileString(char *theSection, /* section name */
} }
/* unquote value if quoted */ /* unquote value if quoted */
if (aLength >= 2 && aValue[0] == '"' && if (aLength >= 2 && aValue[0] == '"' &&
aValue[aLength - 1] == '"') aValue[aLength - 1] == '"')
{ {
...@@ -236,7 +224,6 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -236,7 +224,6 @@ GetPrivateProfileString(char *theSection, /* section name */
else else
{ {
/* single quotes allowed also... */ /* single quotes allowed also... */
if (aLength >= 2 && aValue[0] == '\'' && if (aLength >= 2 && aValue[0] == '\'' &&
aValue[aLength - 1] == '\'') aValue[aLength - 1] == '\'')
{ {
...@@ -247,13 +234,11 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -247,13 +234,11 @@ GetPrivateProfileString(char *theSection, /* section name */
} }
/* compute maximum length copyable */ /* compute maximum length copyable */
aLineLength = (aLength < aLineLength = (aLength <
theReturnBufferLength - aReturnLength) ? aLength : theReturnBufferLength - aReturnLength) ? aLength :
theReturnBufferLength - aReturnLength; theReturnBufferLength - aReturnLength;
/* do the copy to return buffer */ /* do the copy to return buffer */
if (aLineLength) if (aLineLength)
{ {
strncpy(&theReturnBuffer[aReturnLength], strncpy(&theReturnBuffer[aReturnLength],
...@@ -270,11 +255,9 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -270,11 +255,9 @@ GetPrivateProfileString(char *theSection, /* section name */
fclose(aFile); fclose(aFile);
aFile = NULL; aFile = NULL;
} }
return aReturnLength > 0 ? aReturnLength - 1 : 0; return aReturnLength > 0 ? aReturnLength - 1 : 0;
} }
} }
break; break;
} }
} }
...@@ -283,7 +266,8 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -283,7 +266,8 @@ GetPrivateProfileString(char *theSection, /* section name */
fclose(aFile); fclose(aFile);
if (!aKeyFound) if (!aKeyFound)
{ /* key wasn't found return default */ {
/* key wasn't found return default */
++aLength; /* room for NULL char */ ++aLength; /* room for NULL char */
aLength = theReturnBufferLength < aLength ? aLength = theReturnBufferLength < aLength ?
theReturnBufferLength : aLength; theReturnBufferLength : aLength;
...@@ -294,9 +278,10 @@ GetPrivateProfileString(char *theSection, /* section name */ ...@@ -294,9 +278,10 @@ GetPrivateProfileString(char *theSection, /* section name */
return aReturnLength > 0 ? aReturnLength - 1 : 0; return aReturnLength > 0 ? aReturnLength - 1 : 0;
} }
DWORD DWORD
WritePrivateProfileString(char *theSection, /* section name */ WritePrivateProfileString(char *theSection, /* section name */
char *theKey, /* write key name */ char *theKey, /* write key name */
char *theBuffer, /* input buffer */ char *theBuffer, /* input buffer */
char *theIniFileName) /* pathname of ini file to char *theIniFileName) /* pathname of ini file to
* write */ * write */
...@@ -304,14 +289,16 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -304,14 +289,16 @@ WritePrivateProfileString(char *theSection, /* section name */
return 0; return 0;
} }
#if 0 #if 0
/* Ok. What the hell's the default behaviour for a null input buffer, and null /*
* Ok. What the hell's the default behaviour for a null input buffer, and null
* section name. For now if either are null I ignore the request, until * section name. For now if either are null I ignore the request, until
* I find out different. * I find out different.
*/ */
DWORD DWORD
WritePrivateProfileString(char *theSection, /* section name */ WritePrivateProfileString(char *theSection, /* section name */
char *theKey, /* write key name */ char *theKey, /* write key name */
char *theBuffer, /* input buffer */ char *theBuffer, /* input buffer */
char *theIniFileName) /* pathname of ini file to char *theIniFileName) /* pathname of ini file to
* write */ * write */
...@@ -353,11 +340,12 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -353,11 +340,12 @@ WritePrivateProfileString(char *theSection, /* section name */
if (ptr == NULL || *ptr == '\0') if (ptr == NULL || *ptr == '\0')
ptr = "/home"; ptr = "/home";
/* This doesn't make it so we find an ini file but allows normal */ /*
/* processing to continue further on down. The likelihood is that */ * This doesn't make it so we find an ini file but allows normal
/* the file won't be found and thus the default value will be */ * processing to continue further on down. The likelihood is that
/* returned. */ * the file won't be found and thus the default value will be
/* */ * returned.
*/
if (MAXPGPATH - 1 < strlen(ptr) + j) if (MAXPGPATH - 1 < strlen(ptr) + j)
{ {
if (MAXPGPATH - 1 < strlen(ptr)) if (MAXPGPATH - 1 < strlen(ptr))
...@@ -368,9 +356,10 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -368,9 +356,10 @@ WritePrivateProfileString(char *theSection, /* section name */
sprintf(buf, "%s/%s", ptr, theIniFileName); sprintf(buf, "%s/%s", ptr, theIniFileName);
/* This code makes it so that a file in the users home dir */ /*
/* overrides a the "default" file as passed in */ * This code makes it so that a file in the users home dir
/* */ * overrides a the "default" file as passed in
*/
aFile = (FILE *) (buf ? fopen(buf, "r+") : NULL); aFile = (FILE *) (buf ? fopen(buf, "r+") : NULL);
if (!aFile) if (!aFile)
{ {
...@@ -380,13 +369,13 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -380,13 +369,13 @@ WritePrivateProfileString(char *theSection, /* section name */
return 0; return 0;
} }
aLength = strlen(theBuffer); aLength = strlen(theBuffer);
/* We have to search for theKey, because if it already */ /*
/* exists we have to overwrite it. If it doesn't exist */ * We have to search for theKey, because if it already
/* we just write a new line to the file. */ * exists we have to overwrite it. If it doesn't exist
/* */ * we just write a new line to the file.
*/
while (fgets(aLine, sizeof(aLine), aFile) != NULL) while (fgets(aLine, sizeof(aLine), aFile) != NULL)
{ {
aLineLength = strlen(aLine); aLineLength = strlen(aLine);
...@@ -401,7 +390,6 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -401,7 +390,6 @@ WritePrivateProfileString(char *theSection, /* section name */
break; break;
case '[': /* section marker */ case '[': /* section marker */
if ((aString = strchr(aLine, ']'))) if ((aString = strchr(aLine, ']')))
{ {
*aString = '\0'; *aString = '\0';
...@@ -411,13 +399,10 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -411,13 +399,10 @@ WritePrivateProfileString(char *theSection, /* section name */
if (!strcmp(aLine + 1, theSection)) if (!strcmp(aLine + 1, theSection))
aSectionFound = TRUE; aSectionFound = TRUE;
} }
break; break;
default: default:
/* try to match value keys if in proper section */ /* try to match value keys if in proper section */
if (aSectionFound) if (aSectionFound)
{ {
/* try to match requested key */ /* try to match requested key */
...@@ -428,7 +413,6 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -428,7 +413,6 @@ WritePrivateProfileString(char *theSection, /* section name */
++aValue; ++aValue;
/* strip leading blanks in value field */ /* strip leading blanks in value field */
while (*aValue == ' ' && aValue < aLine + sizeof(aLine)) while (*aValue == ' ' && aValue < aLine + sizeof(aLine))
*aValue++ = '\0'; *aValue++ = '\0';
if (aValue >= aLine + sizeof(aLine)) if (aValue >= aLine + sizeof(aLine))
...@@ -438,7 +422,6 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -438,7 +422,6 @@ WritePrivateProfileString(char *theSection, /* section name */
aValue = ""; aValue = "";
/* strip trailing blanks from key */ /* strip trailing blanks from key */
if (aString) if (aString)
{ {
while (--aString >= aLine && *aString == ' ') while (--aString >= aLine && *aString == ' ')
...@@ -446,7 +429,6 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -446,7 +429,6 @@ WritePrivateProfileString(char *theSection, /* section name */
} }
/* see if key is matched */ /* see if key is matched */
if (!strcmp(theKey, aLine)) if (!strcmp(theKey, aLine))
{ {
keyFound = TRUE; keyFound = TRUE;
...@@ -460,7 +442,6 @@ WritePrivateProfileString(char *theSection, /* section name */ ...@@ -460,7 +442,6 @@ WritePrivateProfileString(char *theSection, /* section name */
} }
} }
} }
break; break;
} }
} }
......
This diff is collapsed.
/* Module: lobj.c /*--------
* Module: lobj.c
* *
* Description: This module contains routines related to manipulating * Description: This module contains routines related to manipulating
* large objects. * large objects.
...@@ -8,13 +9,14 @@ ...@@ -8,13 +9,14 @@
* API functions: none * API functions: none
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *--------
*/ */
#include "lobj.h" #include "lobj.h"
#include "psqlodbc.h" #include "psqlodbc.h"
#include "connection.h" #include "connection.h"
Oid Oid
lo_creat(ConnectionClass *conn, int mode) lo_creat(ConnectionClass *conn, int mode)
{ {
...@@ -30,18 +32,16 @@ lo_creat(ConnectionClass *conn, int mode) ...@@ -30,18 +32,16 @@ lo_creat(ConnectionClass *conn, int mode)
return 0; /* invalid oid */ return 0; /* invalid oid */
else else
return retval; return retval;
} }
int int
lo_open(ConnectionClass *conn, int lobjId, int mode) lo_open(ConnectionClass *conn, int lobjId, int mode)
{ {
int fd; int fd;
int result_len; int result_len;
LO_ARG argv[2]; LO_ARG argv[2];
argv[0].isint = 1; argv[0].isint = 1;
argv[0].len = 4; argv[0].len = 4;
argv[0].u.integer = lobjId; argv[0].u.integer = lobjId;
...@@ -59,6 +59,7 @@ lo_open(ConnectionClass *conn, int lobjId, int mode) ...@@ -59,6 +59,7 @@ lo_open(ConnectionClass *conn, int lobjId, int mode)
return fd; return fd;
} }
int int
lo_close(ConnectionClass *conn, int fd) lo_close(ConnectionClass *conn, int fd)
{ {
...@@ -66,17 +67,14 @@ lo_close(ConnectionClass *conn, int fd) ...@@ -66,17 +67,14 @@ lo_close(ConnectionClass *conn, int fd)
int retval, int retval,
result_len; result_len;
argv[0].isint = 1; argv[0].isint = 1;
argv[0].len = 4; argv[0].len = 4;
argv[0].u.integer = fd; argv[0].u.integer = fd;
if (!CC_send_function(conn, LO_CLOSE, &retval, &result_len, 1, argv, 1)) if (!CC_send_function(conn, LO_CLOSE, &retval, &result_len, 1, argv, 1))
return -1; return -1;
else else
return retval; return retval;
} }
...@@ -86,7 +84,6 @@ lo_read(ConnectionClass *conn, int fd, char *buf, int len) ...@@ -86,7 +84,6 @@ lo_read(ConnectionClass *conn, int fd, char *buf, int len)
LO_ARG argv[2]; LO_ARG argv[2];
int result_len; int result_len;
argv[0].isint = 1; argv[0].isint = 1;
argv[0].len = 4; argv[0].len = 4;
argv[0].u.integer = fd; argv[0].u.integer = fd;
...@@ -97,11 +94,11 @@ lo_read(ConnectionClass *conn, int fd, char *buf, int len) ...@@ -97,11 +94,11 @@ lo_read(ConnectionClass *conn, int fd, char *buf, int len)
if (!CC_send_function(conn, LO_READ, (int *) buf, &result_len, 0, argv, 2)) if (!CC_send_function(conn, LO_READ, (int *) buf, &result_len, 0, argv, 2))
return -1; return -1;
else else
return result_len; return result_len;
} }
int int
lo_write(ConnectionClass *conn, int fd, char *buf, int len) lo_write(ConnectionClass *conn, int fd, char *buf, int len)
{ {
...@@ -109,7 +106,6 @@ lo_write(ConnectionClass *conn, int fd, char *buf, int len) ...@@ -109,7 +106,6 @@ lo_write(ConnectionClass *conn, int fd, char *buf, int len)
int retval, int retval,
result_len; result_len;
if (len <= 0) if (len <= 0)
return 0; return 0;
...@@ -123,11 +119,11 @@ lo_write(ConnectionClass *conn, int fd, char *buf, int len) ...@@ -123,11 +119,11 @@ lo_write(ConnectionClass *conn, int fd, char *buf, int len)
if (!CC_send_function(conn, LO_WRITE, &retval, &result_len, 1, argv, 2)) if (!CC_send_function(conn, LO_WRITE, &retval, &result_len, 1, argv, 2))
return -1; return -1;
else else
return retval; return retval;
} }
int int
lo_lseek(ConnectionClass *conn, int fd, int offset, int whence) lo_lseek(ConnectionClass *conn, int fd, int offset, int whence)
{ {
...@@ -135,7 +131,6 @@ lo_lseek(ConnectionClass *conn, int fd, int offset, int whence) ...@@ -135,7 +131,6 @@ lo_lseek(ConnectionClass *conn, int fd, int offset, int whence)
int retval, int retval,
result_len; result_len;
argv[0].isint = 1; argv[0].isint = 1;
argv[0].len = 4; argv[0].len = 4;
argv[0].u.integer = fd; argv[0].u.integer = fd;
...@@ -150,11 +145,11 @@ lo_lseek(ConnectionClass *conn, int fd, int offset, int whence) ...@@ -150,11 +145,11 @@ lo_lseek(ConnectionClass *conn, int fd, int offset, int whence)
if (!CC_send_function(conn, LO_LSEEK, &retval, &result_len, 1, argv, 3)) if (!CC_send_function(conn, LO_LSEEK, &retval, &result_len, 1, argv, 3))
return -1; return -1;
else else
return retval; return retval;
} }
int int
lo_tell(ConnectionClass *conn, int fd) lo_tell(ConnectionClass *conn, int fd)
{ {
...@@ -162,18 +157,17 @@ lo_tell(ConnectionClass *conn, int fd) ...@@ -162,18 +157,17 @@ lo_tell(ConnectionClass *conn, int fd)
int retval, int retval,
result_len; result_len;
argv[0].isint = 1; argv[0].isint = 1;
argv[0].len = 4; argv[0].len = 4;
argv[0].u.integer = fd; argv[0].u.integer = fd;
if (!CC_send_function(conn, LO_TELL, &retval, &result_len, 1, argv, 1)) if (!CC_send_function(conn, LO_TELL, &retval, &result_len, 1, argv, 1))
return -1; return -1;
else else
return retval; return retval;
} }
int int
lo_unlink(ConnectionClass *conn, Oid lobjId) lo_unlink(ConnectionClass *conn, Oid lobjId)
{ {
...@@ -181,14 +175,12 @@ lo_unlink(ConnectionClass *conn, Oid lobjId) ...@@ -181,14 +175,12 @@ lo_unlink(ConnectionClass *conn, Oid lobjId)
int retval, int retval,
result_len; result_len;
argv[0].isint = 1; argv[0].isint = 1;
argv[0].len = 4; argv[0].len = 4;
argv[0].u.integer = lobjId; argv[0].u.integer = lobjId;
if (!CC_send_function(conn, LO_UNLINK, &retval, &result_len, 1, argv, 1)) if (!CC_send_function(conn, LO_UNLINK, &retval, &result_len, 1, argv, 1))
return -1; return -1;
else else
return retval; return retval;
} }
/* Module: misc.c /*-------
* Module: misc.c
* *
* Description: This module contains miscellaneous routines * Description: This module contains miscellaneous routines
* such as for debugging/logging and string functions. * such as for debugging/logging and string functions.
...@@ -8,7 +9,7 @@ ...@@ -8,7 +9,7 @@
* API functions: none * API functions: none
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *-------
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -31,6 +32,7 @@ ...@@ -31,6 +32,7 @@
extern GLOBAL_VALUES globals; extern GLOBAL_VALUES globals;
void generate_filename(char *, char *, char *); void generate_filename(char *, char *, char *);
void void
generate_filename(char *dirname, char *prefix, char *filename) generate_filename(char *dirname, char *prefix, char *filename)
{ {
...@@ -56,8 +58,8 @@ generate_filename(char *dirname, char *prefix, char *filename) ...@@ -56,8 +58,8 @@ generate_filename(char *dirname, char *prefix, char *filename)
return; return;
} }
#ifdef MY_LOG
#ifdef MY_LOG
void void
mylog(char *fmt,...) mylog(char *fmt,...)
{ {
...@@ -83,12 +85,10 @@ mylog(char *fmt,...) ...@@ -83,12 +85,10 @@ mylog(char *fmt,...)
va_end(args); va_end(args);
} }
} }
#endif #endif
#ifdef Q_LOG #ifdef Q_LOG
void void
qlog(char *fmt,...) qlog(char *fmt,...)
{ {
...@@ -114,7 +114,6 @@ qlog(char *fmt,...) ...@@ -114,7 +114,6 @@ qlog(char *fmt,...)
va_end(args); va_end(args);
} }
} }
#endif #endif
/* Undefine these because windows.h will redefine and cause a warning */ /* Undefine these because windows.h will redefine and cause a warning */
...@@ -137,7 +136,10 @@ qlog(char *fmt,...) ...@@ -137,7 +136,10 @@ qlog(char *fmt,...)
#endif #endif
/* returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied (not including null term) */ /*
* returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied
* (not including null term)
*/
int int
my_strcpy(char *dst, int dst_len, char *src, int src_len) my_strcpy(char *dst, int dst_len, char *src, int src_len)
{ {
...@@ -154,7 +156,6 @@ my_strcpy(char *dst, int dst_len, char *src, int src_len) ...@@ -154,7 +156,6 @@ my_strcpy(char *dst, int dst_len, char *src, int src_len)
if (src_len <= 0) if (src_len <= 0)
return STRCPY_FAIL; return STRCPY_FAIL;
else else
{ {
if (src_len < dst_len) if (src_len < dst_len)
...@@ -173,10 +174,13 @@ my_strcpy(char *dst, int dst_len, char *src, int src_len) ...@@ -173,10 +174,13 @@ my_strcpy(char *dst, int dst_len, char *src, int src_len)
return strlen(dst); return strlen(dst);
} }
/* strncpy copies up to len characters, and doesn't terminate */
/* the destination string if src has len characters or more. */ /*
/* instead, I want it to copy up to len-1 characters and always */ * strncpy copies up to len characters, and doesn't terminate
/* terminate the destination string. */ * the destination string if src has len characters or more.
* instead, I want it to copy up to len-1 characters and always
* terminate the destination string.
*/
char * char *
strncpy_null(char *dst, const char *src, int len) strncpy_null(char *dst, const char *src, int len)
{ {
...@@ -185,7 +189,6 @@ strncpy_null(char *dst, const char *src, int len) ...@@ -185,7 +189,6 @@ strncpy_null(char *dst, const char *src, int len)
if (NULL != dst) if (NULL != dst)
{ {
/* Just in case, check for special lengths */ /* Just in case, check for special lengths */
if (len == SQL_NULL_DATA) if (len == SQL_NULL_DATA)
{ {
...@@ -204,9 +207,14 @@ strncpy_null(char *dst, const char *src, int len) ...@@ -204,9 +207,14 @@ strncpy_null(char *dst, const char *src, int len)
return dst; return dst;
} }
/* Create a null terminated string (handling the SQL_NTS thing): */
/* 1. If buf is supplied, place the string in there (assumes enough space) and return buf. */ /*------
/* 2. If buf is not supplied, malloc space and return this string */ * Create a null terminated string (handling the SQL_NTS thing):
* 1. If buf is supplied, place the string in there
* (assumes enough space) and return buf.
* 2. If buf is not supplied, malloc space and return this string
*------
*/
char * char *
make_string(char *s, int len, char *buf) make_string(char *s, int len, char *buf)
{ {
...@@ -234,14 +242,16 @@ make_string(char *s, int len, char *buf) ...@@ -234,14 +242,16 @@ make_string(char *s, int len, char *buf)
return NULL; return NULL;
} }
/* Concatenate a single formatted argument to a given buffer handling the SQL_NTS thing. */
/* "fmt" must contain somewhere in it the single form '%.*s' */ /*
/* This is heavily used in creating queries for info routines (SQLTables, SQLColumns). */ * Concatenate a single formatted argument to a given buffer handling the SQL_NTS thing.
/* This routine could be modified to use vsprintf() to handle multiple arguments. */ * "fmt" must contain somewhere in it the single form '%.*s'.
* This is heavily used in creating queries for info routines (SQLTables, SQLColumns).
* This routine could be modified to use vsprintf() to handle multiple arguments.
*/
char * char *
my_strcat(char *buf, char *fmt, char *s, int len) my_strcat(char *buf, char *fmt, char *s, int len)
{ {
if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0)))
{ {
int length = (len > 0) ? len : strlen(s); int length = (len > 0) ? len : strlen(s);
...@@ -254,6 +264,7 @@ my_strcat(char *buf, char *fmt, char *s, int len) ...@@ -254,6 +264,7 @@ my_strcat(char *buf, char *fmt, char *s, int len)
return NULL; return NULL;
} }
void void
remove_newlines(char *string) remove_newlines(char *string)
{ {
...@@ -267,6 +278,7 @@ remove_newlines(char *string) ...@@ -267,6 +278,7 @@ remove_newlines(char *string)
} }
} }
char * char *
trim(char *s) trim(char *s)
{ {
......
/* /*--------
* Module : multibyte.c * Module : multibyte.c
* *
* Description: Mlutibyte related additional function. * Description: Mlutibyte related additional function.
* *
* Create 2001-03-03 Eiji Tokuya * Create 2001-03-03 Eiji Tokuya
* *--------
*/ */
#include <string.h> #include <string.h>
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
int multibyte_client_encoding; /* Multibyte Client Encoding. */ int multibyte_client_encoding; /* Multibyte Client Encoding. */
int multibyte_status; /* Multibyte Odds and ends character. */ int multibyte_status; /* Multibyte Odds and ends character. */
unsigned char * unsigned char *
multibyte_strchr(unsigned char *s, unsigned char c) multibyte_strchr(unsigned char *s, unsigned char c)
{ {
...@@ -36,7 +37,6 @@ multibyte_strchr(unsigned char *s, unsigned char c) ...@@ -36,7 +37,6 @@ multibyte_strchr(unsigned char *s, unsigned char c)
} }
break; break;
/* Chinese Big5 Support. */ /* Chinese Big5 Support. */
case BIG5: case BIG5:
{ {
...@@ -59,12 +59,14 @@ multibyte_strchr(unsigned char *s, unsigned char c) ...@@ -59,12 +59,14 @@ multibyte_strchr(unsigned char *s, unsigned char c)
return (s + i); return (s + i);
} }
void void
multibyte_init(void) multibyte_init(void)
{ {
multibyte_status = 0; multibyte_status = 0;
} }
unsigned char * unsigned char *
check_client_encoding(unsigned char *str) check_client_encoding(unsigned char *str)
{ {
...@@ -81,19 +83,21 @@ check_client_encoding(unsigned char *str) ...@@ -81,19 +83,21 @@ check_client_encoding(unsigned char *str)
return ("OHTER"); return ("OHTER");
} }
/*
/*--------
* Multibyte Status Function. * Multibyte Status Function.
* Input char * Input char
* Output 0 : 1 Byte Character. * Output 0 : 1 Byte Character.
* 1 : MultibyteCharacter Last Byte. * 1 : MultibyteCharacter Last Byte.
* N : MultibyteCharacter Fast or Middle Byte. * N : MultibyteCharacter Fast or Middle Byte.
*--------
*/ */
int int
multibyte_char_check(unsigned char s) multibyte_char_check(unsigned char s)
{ {
switch (multibyte_client_encoding) switch (multibyte_client_encoding)
{ {
/* Japanese Shift-JIS(CP932) Support. */ /* Japanese Shift-JIS(CP932) Support. */
case SJIS: case SJIS:
{ {
if (multibyte_status < 2 && s > 0x80 && !(s > 0x9f && s < 0xE0)) if (multibyte_status < 2 && s > 0x80 && !(s > 0x9f && s < 0xE0))
...@@ -105,20 +109,19 @@ multibyte_char_check(unsigned char s) ...@@ -105,20 +109,19 @@ multibyte_char_check(unsigned char s)
} }
break; break;
/* Chinese Big5(CP950) Support. */
/* Chinese Big5(CP950) Support. */ case BIG5:
case BIG5: {
{ if (multibyte_status < 2 && s > 0xA0)
if (multibyte_status < 2 && s > 0xA0) multibyte_status = 2;
multibyte_status = 2; else if (multibyte_status == 2)
else if (multibyte_status == 2) multibyte_status = 1;
multibyte_status = 1; else
else multibyte_status = 0;
multibyte_status = 0; }
} break;
break; default:
default: multibyte_status = 0;
multibyte_status = 0;
} }
#ifdef _DEBUG #ifdef _DEBUG
qlog("multibyte_client_encoding = %d s = 0x%02X multibyte_stat = %d\n", multibyte_client_encoding, s, multibyte_status); qlog("multibyte_client_encoding = %d s = 0x%02X multibyte_stat = %d\n", multibyte_client_encoding, s, multibyte_status);
......
/* Module: options.c /*--------
* Module: options.c
* *
* Description: This module contains routines for getting/setting * Description: This module contains routines for getting/setting
* connection and statement options. * connection and statement options.
...@@ -9,7 +10,7 @@ ...@@ -9,7 +10,7 @@
* SQLGetStmtOption * SQLGetStmtOption
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *--------
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
...@@ -43,7 +44,6 @@ RETCODE set_statement_option(ConnectionClass *conn, ...@@ -43,7 +44,6 @@ RETCODE set_statement_option(ConnectionClass *conn,
UDWORD vParam); UDWORD vParam);
RETCODE RETCODE
set_statement_option(ConnectionClass *conn, set_statement_option(ConnectionClass *conn,
StatementClass *stmt, StatementClass *stmt,
...@@ -53,7 +53,6 @@ set_statement_option(ConnectionClass *conn, ...@@ -53,7 +53,6 @@ set_statement_option(ConnectionClass *conn,
static char *func = "set_statement_option"; static char *func = "set_statement_option";
char changed = FALSE; char changed = FALSE;
switch (fOption) switch (fOption)
{ {
case SQL_ASYNC_ENABLE: /* ignored */ case SQL_ASYNC_ENABLE: /* ignored */
...@@ -68,12 +67,10 @@ set_statement_option(ConnectionClass *conn, ...@@ -68,12 +67,10 @@ set_statement_option(ConnectionClass *conn,
break; break;
case SQL_CONCURRENCY: case SQL_CONCURRENCY:
/* /*
* positioned update isn't supported so cursor concurrency is * positioned update isn't supported so cursor concurrency is
* read-only * read-only
*/ */
if (conn) if (conn)
conn->stmtOptions.scroll_concurrency = vParam; conn->stmtOptions.scroll_concurrency = vParam;
if (stmt) if (stmt)
...@@ -104,7 +101,6 @@ set_statement_option(ConnectionClass *conn, ...@@ -104,7 +101,6 @@ set_statement_option(ConnectionClass *conn,
*/ */
case SQL_CURSOR_TYPE: case SQL_CURSOR_TYPE:
/* /*
* if declare/fetch, then type can only be forward. otherwise, * if declare/fetch, then type can only be forward. otherwise,
* it can only be forward or static. * it can only be forward or static.
...@@ -113,18 +109,15 @@ set_statement_option(ConnectionClass *conn, ...@@ -113,18 +109,15 @@ set_statement_option(ConnectionClass *conn,
if (globals.lie) if (globals.lie)
{ {
if (conn) if (conn)
conn->stmtOptions.cursor_type = vParam; conn->stmtOptions.cursor_type = vParam;
if (stmt) if (stmt)
stmt->options.cursor_type = vParam; stmt->options.cursor_type = vParam;
} }
else else
{ {
if (globals.use_declarefetch) if (globals.use_declarefetch)
{ {
if (conn) if (conn)
conn->stmtOptions.cursor_type = SQL_CURSOR_FORWARD_ONLY; conn->stmtOptions.cursor_type = SQL_CURSOR_FORWARD_ONLY;
if (stmt) if (stmt)
...@@ -137,7 +130,6 @@ set_statement_option(ConnectionClass *conn, ...@@ -137,7 +130,6 @@ set_statement_option(ConnectionClass *conn,
{ {
if (vParam == SQL_CURSOR_FORWARD_ONLY || vParam == SQL_CURSOR_STATIC) if (vParam == SQL_CURSOR_FORWARD_ONLY || vParam == SQL_CURSOR_STATIC)
{ {
if (conn) if (conn)
conn->stmtOptions.cursor_type = vParam; /* valid type */ conn->stmtOptions.cursor_type = vParam; /* valid type */
if (stmt) if (stmt)
...@@ -145,7 +137,6 @@ set_statement_option(ConnectionClass *conn, ...@@ -145,7 +137,6 @@ set_statement_option(ConnectionClass *conn,
} }
else else
{ {
if (conn) if (conn)
conn->stmtOptions.cursor_type = SQL_CURSOR_STATIC; conn->stmtOptions.cursor_type = SQL_CURSOR_STATIC;
if (stmt) if (stmt)
...@@ -167,14 +158,20 @@ set_statement_option(ConnectionClass *conn, ...@@ -167,14 +158,20 @@ set_statement_option(ConnectionClass *conn,
break; break;
/* /*-------
* if (globals.lie) stmt->keyset_size = vParam; else { * if (globals.lie)
* stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR; * stmt->keyset_size = vParam;
* stmt->errormsg = "Driver does not support keyset size * else
* option"; SC_log_error(func, "", stmt); return SQL_ERROR; } * {
* stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
* stmt->errormsg = "Driver does not support keyset size option";
* SC_log_error(func, "", stmt);
* return SQL_ERROR;
* }
*-------
*/ */
case SQL_MAX_LENGTH: /* ignored, but saved */ case SQL_MAX_LENGTH: /* ignored, but saved */
mylog("SetStmtOption(): SQL_MAX_LENGTH, vParam = %d\n", vParam); mylog("SetStmtOption(): SQL_MAX_LENGTH, vParam = %d\n", vParam);
if (conn) if (conn)
conn->stmtOptions.maxLength = vParam; conn->stmtOptions.maxLength = vParam;
...@@ -182,7 +179,7 @@ set_statement_option(ConnectionClass *conn, ...@@ -182,7 +179,7 @@ set_statement_option(ConnectionClass *conn,
stmt->options.maxLength = vParam; stmt->options.maxLength = vParam;
break; break;
case SQL_MAX_ROWS: /* ignored, but saved */ case SQL_MAX_ROWS: /* ignored, but saved */
mylog("SetStmtOption(): SQL_MAX_ROWS, vParam = %d\n", vParam); mylog("SetStmtOption(): SQL_MAX_ROWS, vParam = %d\n", vParam);
if (conn) if (conn)
conn->stmtOptions.maxRows = vParam; conn->stmtOptions.maxRows = vParam;
...@@ -190,16 +187,16 @@ set_statement_option(ConnectionClass *conn, ...@@ -190,16 +187,16 @@ set_statement_option(ConnectionClass *conn,
stmt->options.maxRows = vParam; stmt->options.maxRows = vParam;
break; break;
case SQL_NOSCAN: /* ignored */ case SQL_NOSCAN: /* ignored */
mylog("SetStmtOption: SQL_NOSCAN, vParam = %d\n", vParam); mylog("SetStmtOption: SQL_NOSCAN, vParam = %d\n", vParam);
break; break;
case SQL_QUERY_TIMEOUT:/* ignored */ case SQL_QUERY_TIMEOUT: /* ignored */
mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", vParam); mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", vParam);
/* "0" returned in SQLGetStmtOption */ /* "0" returned in SQLGetStmtOption */
break; break;
case SQL_RETRIEVE_DATA:/* ignored, but saved */ case SQL_RETRIEVE_DATA: /* ignored, but saved */
mylog("SetStmtOption(): SQL_RETRIEVE_DATA, vParam = %d\n", vParam); mylog("SetStmtOption(): SQL_RETRIEVE_DATA, vParam = %d\n", vParam);
if (conn) if (conn)
conn->stmtOptions.retrieve_data = vParam; conn->stmtOptions.retrieve_data = vParam;
...@@ -210,7 +207,6 @@ set_statement_option(ConnectionClass *conn, ...@@ -210,7 +207,6 @@ set_statement_option(ConnectionClass *conn,
case SQL_ROWSET_SIZE: case SQL_ROWSET_SIZE:
mylog("SetStmtOption(): SQL_ROWSET_SIZE, vParam = %d\n", vParam); mylog("SetStmtOption(): SQL_ROWSET_SIZE, vParam = %d\n", vParam);
/* /*
* Save old rowset size for SQLExtendedFetch purposes If the * Save old rowset size for SQLExtendedFetch purposes If the
* rowset_size is being changed since the last call to fetch * rowset_size is being changed since the last call to fetch
...@@ -230,7 +226,6 @@ set_statement_option(ConnectionClass *conn, ...@@ -230,7 +226,6 @@ set_statement_option(ConnectionClass *conn,
conn->stmtOptions.rowset_size = vParam; conn->stmtOptions.rowset_size = vParam;
if (stmt) if (stmt)
stmt->options.rowset_size = vParam; stmt->options.rowset_size = vParam;
break; break;
case SQL_SIMULATE_CURSOR: /* NOT SUPPORTED */ case SQL_SIMULATE_CURSOR: /* NOT SUPPORTED */
...@@ -249,7 +244,6 @@ set_statement_option(ConnectionClass *conn, ...@@ -249,7 +244,6 @@ set_statement_option(ConnectionClass *conn,
return SQL_ERROR; return SQL_ERROR;
case SQL_USE_BOOKMARKS: case SQL_USE_BOOKMARKS:
if (stmt) if (stmt)
stmt->options.use_bookmarks = vParam; stmt->options.use_bookmarks = vParam;
if (conn) if (conn)
...@@ -298,7 +292,6 @@ set_statement_option(ConnectionClass *conn, ...@@ -298,7 +292,6 @@ set_statement_option(ConnectionClass *conn,
} }
/* Implements only SQL_AUTOCOMMIT */ /* Implements only SQL_AUTOCOMMIT */
RETCODE SQL_API RETCODE SQL_API
SQLSetConnectOption( SQLSetConnectOption(
...@@ -320,14 +313,12 @@ SQLSetConnectOption( ...@@ -320,14 +313,12 @@ SQLSetConnectOption(
return SQL_INVALID_HANDLE; return SQL_INVALID_HANDLE;
} }
switch (fOption) switch (fOption)
{ {
/*
/* * Statement Options (apply to all stmts on the connection and
* Statement Options (apply to all stmts on the connection and * become defaults for new stmts)
* become defaults for new stmts) */
*/
case SQL_ASYNC_ENABLE: case SQL_ASYNC_ENABLE:
case SQL_BIND_TYPE: case SQL_BIND_TYPE:
case SQL_CONCURRENCY: case SQL_CONCURRENCY:
...@@ -362,15 +353,14 @@ SQLSetConnectOption( ...@@ -362,15 +353,14 @@ SQLSetConnectOption(
break; break;
/**********************************/ /*
/***** Connection Options *******/ * Connection Options
/**********************************/ */
case SQL_ACCESS_MODE: /* ignored */ case SQL_ACCESS_MODE: /* ignored */
break; break;
case SQL_AUTOCOMMIT: case SQL_AUTOCOMMIT:
if (CC_is_in_trans(conn)) if (CC_is_in_trans(conn))
{ {
conn->errormsg = "Cannot switch commit mode while a transaction is in progress"; conn->errormsg = "Cannot switch commit mode while a transaction is in progress";
...@@ -397,13 +387,12 @@ SQLSetConnectOption( ...@@ -397,13 +387,12 @@ SQLSetConnectOption(
CC_log_error(func, "", conn); CC_log_error(func, "", conn);
return SQL_ERROR; return SQL_ERROR;
} }
break; break;
case SQL_CURRENT_QUALIFIER: /* ignored */ case SQL_CURRENT_QUALIFIER: /* ignored */
break; break;
case SQL_LOGIN_TIMEOUT:/* ignored */ case SQL_LOGIN_TIMEOUT: /* ignored */
break; break;
case SQL_PACKET_SIZE: /* ignored */ case SQL_PACKET_SIZE: /* ignored */
...@@ -412,10 +401,10 @@ SQLSetConnectOption( ...@@ -412,10 +401,10 @@ SQLSetConnectOption(
case SQL_QUIET_MODE: /* ignored */ case SQL_QUIET_MODE: /* ignored */
break; break;
case SQL_TXN_ISOLATION:/* ignored */ case SQL_TXN_ISOLATION: /* ignored */
break; break;
/* These options should be handled by driver manager */ /* These options should be handled by driver manager */
case SQL_ODBC_CURSORS: case SQL_ODBC_CURSORS:
case SQL_OPT_TRACE: case SQL_OPT_TRACE:
case SQL_OPT_TRACEFILE: case SQL_OPT_TRACEFILE:
...@@ -434,7 +423,6 @@ SQLSetConnectOption( ...@@ -434,7 +423,6 @@ SQLSetConnectOption(
CC_log_error(func, option, conn); CC_log_error(func, option, conn);
return SQL_ERROR; return SQL_ERROR;
} }
} }
if (changed) if (changed)
...@@ -447,7 +435,6 @@ SQLSetConnectOption( ...@@ -447,7 +435,6 @@ SQLSetConnectOption(
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* - - - - - - - - - */
/* This function just can tell you whether you are in Autcommit mode or not */ /* This function just can tell you whether you are in Autcommit mode or not */
RETCODE SQL_API RETCODE SQL_API
...@@ -469,7 +456,7 @@ SQLGetConnectOption( ...@@ -469,7 +456,7 @@ SQLGetConnectOption(
switch (fOption) switch (fOption)
{ {
case SQL_ACCESS_MODE: /* NOT SUPPORTED */ case SQL_ACCESS_MODE: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = SQL_MODE_READ_WRITE; *((UDWORD *) pvParam) = SQL_MODE_READ_WRITE;
break; break;
...@@ -484,23 +471,23 @@ SQLGetConnectOption( ...@@ -484,23 +471,23 @@ SQLGetConnectOption(
break; break;
case SQL_LOGIN_TIMEOUT:/* NOT SUPPORTED */ case SQL_LOGIN_TIMEOUT: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = 0; *((UDWORD *) pvParam) = 0;
break; break;
case SQL_PACKET_SIZE: /* NOT SUPPORTED */ case SQL_PACKET_SIZE: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = globals.socket_buffersize; *((UDWORD *) pvParam) = globals.socket_buffersize;
break; break;
case SQL_QUIET_MODE: /* NOT SUPPORTED */ case SQL_QUIET_MODE: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = (UDWORD) NULL; *((UDWORD *) pvParam) = (UDWORD) NULL;
break; break;
case SQL_TXN_ISOLATION:/* NOT SUPPORTED */ case SQL_TXN_ISOLATION: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = SQL_TXN_SERIALIZABLE; *((UDWORD *) pvParam) = SQL_TXN_SERIALIZABLE;
break; break;
/* These options should be handled by driver manager */ /* These options should be handled by driver manager */
case SQL_ODBC_CURSORS: case SQL_ODBC_CURSORS:
case SQL_OPT_TRACE: case SQL_OPT_TRACE:
case SQL_OPT_TRACEFILE: case SQL_OPT_TRACEFILE:
...@@ -520,13 +507,11 @@ SQLGetConnectOption( ...@@ -520,13 +507,11 @@ SQLGetConnectOption(
return SQL_ERROR; return SQL_ERROR;
break; break;
} }
} }
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* - - - - - - - - - */
RETCODE SQL_API RETCODE SQL_API
SQLSetStmtOption( SQLSetStmtOption(
...@@ -539,10 +524,11 @@ SQLSetStmtOption( ...@@ -539,10 +524,11 @@ SQLSetStmtOption(
mylog("%s: entering...\n", func); mylog("%s: entering...\n", func);
/* thought we could fake Access out by just returning SQL_SUCCESS */ /*
/* all the time, but it tries to set a huge value for SQL_MAX_LENGTH */ * Though we could fake Access out by just returning SQL_SUCCESS
/* and expects the driver to reduce it to the real value */ * all the time, but it tries to set a huge value for SQL_MAX_LENGTH
* and expects the driver to reduce it to the real value.
*/
if (!stmt) if (!stmt)
{ {
SC_log_error(func, "", NULL); SC_log_error(func, "", NULL);
...@@ -553,8 +539,6 @@ SQLSetStmtOption( ...@@ -553,8 +539,6 @@ SQLSetStmtOption(
} }
/* - - - - - - - - - */
RETCODE SQL_API RETCODE SQL_API
SQLGetStmtOption( SQLGetStmtOption(
HSTMT hstmt, HSTMT hstmt,
...@@ -567,10 +551,11 @@ SQLGetStmtOption( ...@@ -567,10 +551,11 @@ SQLGetStmtOption(
mylog("%s: entering...\n", func); mylog("%s: entering...\n", func);
/* thought we could fake Access out by just returning SQL_SUCCESS */ /*
/* all the time, but it tries to set a huge value for SQL_MAX_LENGTH */ * thought we could fake Access out by just returning SQL_SUCCESS
/* and expects the driver to reduce it to the real value */ * all the time, but it tries to set a huge value for SQL_MAX_LENGTH
* and expects the driver to reduce it to the real value
*/
if (!stmt) if (!stmt)
{ {
SC_log_error(func, "", NULL); SC_log_error(func, "", NULL);
...@@ -689,5 +674,3 @@ SQLGetStmtOption( ...@@ -689,5 +674,3 @@ SQLGetStmtOption(
return SQL_SUCCESS; return SQL_SUCCESS;
} }
/* - - - - - - - - - */
/* Module: parse.c /*--------
* Module: parse.c
* *
* Description: This module contains routines related to parsing SQL statements. * Description: This module contains routines related to parsing SQL
* This can be useful for two reasons: * statements. This can be useful for two reasons:
* *
* 1. So the query does not actually have to be executed to return data about it * 1. So the query does not actually have to be executed
* to return data about it
* *
* 2. To be able to return information about precision, nullability, aliases, etc. * 2. To be able to return information about precision,
* in the functions SQLDescribeCol and SQLColAttributes. Currently, Postgres * nullability, aliases, etc. in the functions
* doesn't return any information about these things in a query. * SQLDescribeCol and SQLColAttributes. Currently,
* Postgres doesn't return any information about
* these things in a query.
* *
* Classes: none * Classes: none
* *
* API functions: none * API functions: none
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *--------
*/ */
/* Multibyte support Eiji Tokuya 2001-03-15 */ /* Multibyte support Eiji Tokuya 2001-03-15 */
...@@ -50,6 +54,7 @@ char *getNextToken(char *s, char *token, int smax, char *delim, char *quote, ...@@ -50,6 +54,7 @@ char *getNextToken(char *s, char *token, int smax, char *delim, char *quote,
void getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k); void getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k);
char searchColInfo(COL_INFO *col_info, FIELD_INFO *fi); char searchColInfo(COL_INFO *col_info, FIELD_INFO *fi);
char * char *
getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dquote, char *numeric) getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dquote, char *numeric)
{ {
...@@ -87,7 +92,6 @@ getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dqu ...@@ -87,7 +92,6 @@ getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dqu
while (!isspace((unsigned char) s[i]) && s[i] != ',' && while (!isspace((unsigned char) s[i]) && s[i] != ',' &&
s[i] != '\0' && out != smax) s[i] != '\0' && out != smax)
{ {
/* Handle quoted stuff */ /* Handle quoted stuff */
if (out == 0 && (s[i] == '\"' || s[i] == '\'')) if (out == 0 && (s[i] == '\"' || s[i] == '\''))
{ {
...@@ -225,13 +229,13 @@ getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k) ...@@ -225,13 +229,13 @@ getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k)
fi->display_size = atoi(QR_get_value_manual(col_info->result, k, 12)); fi->display_size = atoi(QR_get_value_manual(col_info->result, k, 12));
} }
char char
searchColInfo(COL_INFO *col_info, FIELD_INFO *fi) searchColInfo(COL_INFO *col_info, FIELD_INFO *fi)
{ {
int k, cmp; int k, cmp;
char *col; char *col;
for (k = 0; k < QR_get_num_tuples(col_info->result); k++) for (k = 0; k < QR_get_num_tuples(col_info->result); k++)
{ {
col = QR_get_value_manual(col_info->result, k, 3); col = QR_get_value_manual(col_info->result, k, 3);
...@@ -289,7 +293,6 @@ parse_statement(StatementClass *stmt) ...@@ -289,7 +293,6 @@ parse_statement(StatementClass *stmt)
StatementClass *col_stmt; StatementClass *col_stmt;
RETCODE result; RETCODE result;
mylog("%s: entering...\n", func); mylog("%s: entering...\n", func);
ptr = stmt->statement; ptr = stmt->statement;
...@@ -301,7 +304,6 @@ parse_statement(StatementClass *stmt) ...@@ -301,7 +304,6 @@ parse_statement(StatementClass *stmt)
while ((ptr = getNextToken(ptr, token, sizeof(token), &delim, &quote, &dquote, &numeric)) != NULL) while ((ptr = getNextToken(ptr, token, sizeof(token), &delim, &quote, &dquote, &numeric)) != NULL)
{ {
unquoted = !(quote || dquote); unquoted = !(quote || dquote);
mylog("unquoted=%d, quote=%d, dquote=%d, numeric=%d, delim='%c', token='%s', ptr='%s'\n", unquoted, quote, dquote, numeric, delim, token, ptr); mylog("unquoted=%d, quote=%d, dquote=%d, numeric=%d, delim='%c', token='%s', ptr='%s'\n", unquoted, quote, dquote, numeric, delim, token, ptr);
...@@ -345,7 +347,6 @@ parse_statement(StatementClass *stmt) ...@@ -345,7 +347,6 @@ parse_statement(StatementClass *stmt)
!stricmp(token, "group") || !stricmp(token, "group") ||
!stricmp(token, "having"))) !stricmp(token, "having")))
{ {
in_select = FALSE; in_select = FALSE;
in_from = FALSE; in_from = FALSE;
in_where = TRUE; in_where = TRUE;
...@@ -356,7 +357,6 @@ parse_statement(StatementClass *stmt) ...@@ -356,7 +357,6 @@ parse_statement(StatementClass *stmt)
if (in_select) if (in_select)
{ {
if (in_distinct) if (in_distinct)
{ {
mylog("in distinct\n"); mylog("in distinct\n");
...@@ -378,7 +378,8 @@ parse_statement(StatementClass *stmt) ...@@ -378,7 +378,8 @@ parse_statement(StatementClass *stmt)
} }
if (in_expr || in_func) if (in_expr || in_func)
{ /* just eat the expression */ {
/* just eat the expression */
mylog("in_expr=%d or func=%d\n", in_expr, in_func); mylog("in_expr=%d or func=%d\n", in_expr, in_func);
if (quote || dquote) if (quote || dquote)
continue; continue;
...@@ -389,7 +390,6 @@ parse_statement(StatementClass *stmt) ...@@ -389,7 +390,6 @@ parse_statement(StatementClass *stmt)
in_expr = FALSE; in_expr = FALSE;
in_field = FALSE; in_field = FALSE;
} }
else if (token[0] == '(') else if (token[0] == '(')
{ {
blevel++; blevel++;
...@@ -414,7 +414,6 @@ parse_statement(StatementClass *stmt) ...@@ -414,7 +414,6 @@ parse_statement(StatementClass *stmt)
if (!in_field) if (!in_field)
{ {
if (!token[0]) if (!token[0])
continue; continue;
...@@ -462,7 +461,6 @@ parse_statement(StatementClass *stmt) ...@@ -462,7 +461,6 @@ parse_statement(StatementClass *stmt)
blevel = 1; blevel = 1;
continue; continue;
} }
else else
{ {
strcpy(fi[stmt->nfld]->name, token); strcpy(fi[stmt->nfld]->name, token);
...@@ -478,9 +476,9 @@ parse_statement(StatementClass *stmt) ...@@ -478,9 +476,9 @@ parse_statement(StatementClass *stmt)
continue; continue;
} }
/**************************/ /*
/* We are in a field now */ * We are in a field now
/**************************/ */
if (in_dot) if (in_dot)
{ {
stmt->nfld--; stmt->nfld--;
...@@ -494,7 +492,6 @@ parse_statement(StatementClass *stmt) ...@@ -494,7 +492,6 @@ parse_statement(StatementClass *stmt)
mylog("in_dot: got comma\n"); mylog("in_dot: got comma\n");
in_field = FALSE; in_field = FALSE;
} }
continue; continue;
} }
...@@ -547,12 +544,10 @@ parse_statement(StatementClass *stmt) ...@@ -547,12 +544,10 @@ parse_statement(StatementClass *stmt)
fi[stmt->nfld - 1]->expr = TRUE; fi[stmt->nfld - 1]->expr = TRUE;
fi[stmt->nfld - 1]->name[0] = '\0'; fi[stmt->nfld - 1]->name[0] = '\0';
mylog("*** setting expression\n"); mylog("*** setting expression\n");
} }
if (in_from) if (in_from)
{ {
if (!in_table) if (!in_table)
{ {
if (!token[0]) if (!token[0])
...@@ -603,17 +598,15 @@ parse_statement(StatementClass *stmt) ...@@ -603,17 +598,15 @@ parse_statement(StatementClass *stmt)
} }
} }
/*
/*************************************************/ * Resolve any possible field names with tables
/* Resolve any possible field names with tables */ */
/*************************************************/
parse = TRUE; parse = TRUE;
/* Resolve field names with tables */ /* Resolve field names with tables */
for (i = 0; i < stmt->nfld; i++) for (i = 0; i < stmt->nfld; i++)
{ {
if (fi[i]->func || fi[i]->expr || fi[i]->numeric) if (fi[i]->func || fi[i]->expr || fi[i]->numeric)
{ {
fi[i]->ti = NULL; fi[i]->ti = NULL;
...@@ -621,7 +614,6 @@ parse_statement(StatementClass *stmt) ...@@ -621,7 +614,6 @@ parse_statement(StatementClass *stmt)
parse = FALSE; parse = FALSE;
continue; continue;
} }
else if (fi[i]->quote) else if (fi[i]->quote)
{ /* handle as text */ { /* handle as text */
fi[i]->ti = NULL; fi[i]->ti = NULL;
...@@ -629,7 +621,6 @@ parse_statement(StatementClass *stmt) ...@@ -629,7 +621,6 @@ parse_statement(StatementClass *stmt)
fi[i]->precision = 0; fi[i]->precision = 0;
continue; continue;
} }
/* it's a dot, resolve to table or alias */ /* it's a dot, resolve to table or alias */
else if (fi[i]->dot[0]) else if (fi[i]->dot[0])
{ {
...@@ -665,15 +656,13 @@ parse_statement(StatementClass *stmt) ...@@ -665,15 +656,13 @@ parse_statement(StatementClass *stmt)
mylog("Table %d: name='%s', alias='%s'\n", i, ti[i]->name, ti[i]->alias); mylog("Table %d: name='%s', alias='%s'\n", i, ti[i]->name, ti[i]->alias);
/******************************************************/ /*
/* Now save the SQLColumns Info for the parse tables */ * Now save the SQLColumns Info for the parse tables
/******************************************************/ */
/* Call SQLColumns for each table and store the result */ /* Call SQLColumns for each table and store the result */
for (i = 0; i < stmt->ntab; i++) for (i = 0; i < stmt->ntab; i++)
{ {
/* See if already got it */ /* See if already got it */
char found = FALSE; char found = FALSE;
...@@ -689,7 +678,6 @@ parse_statement(StatementClass *stmt) ...@@ -689,7 +678,6 @@ parse_statement(StatementClass *stmt)
if (!found) if (!found)
{ {
mylog("PARSE: Getting SQLColumns for table[%d]='%s'\n", i, ti[i]->name); mylog("PARSE: Getting SQLColumns for table[%d]='%s'\n", i, ti[i]->name);
result = SQLAllocStmt(stmt->hdbc, &hcol_stmt); result = SQLAllocStmt(stmt->hdbc, &hcol_stmt);
...@@ -713,7 +701,6 @@ parse_statement(StatementClass *stmt) ...@@ -713,7 +701,6 @@ parse_statement(StatementClass *stmt)
mylog(" Success\n"); mylog(" Success\n");
if (!(conn->ntables % COL_INCR)) if (!(conn->ntables % COL_INCR))
{ {
mylog("PARSE: Allocing col_info at ntables=%d\n", conn->ntables); mylog("PARSE: Allocing col_info at ntables=%d\n", conn->ntables);
conn->col_info = (COL_INFO **) realloc(conn->col_info, (conn->ntables + COL_INCR) * sizeof(COL_INFO *)); conn->col_info = (COL_INFO **) realloc(conn->col_info, (conn->ntables + COL_INCR) * sizeof(COL_INFO *));
...@@ -762,18 +749,13 @@ parse_statement(StatementClass *stmt) ...@@ -762,18 +749,13 @@ parse_statement(StatementClass *stmt)
mylog("associate col_info: i=%d, k=%d\n", i, k); mylog("associate col_info: i=%d, k=%d\n", i, k);
} }
mylog("Done SQLColumns\n"); mylog("Done SQLColumns\n");
/******************************************************/ /*
/* Now resolve the fields to point to column info */ * Now resolve the fields to point to column info
/******************************************************/ */
for (i = 0; i < stmt->nfld;) for (i = 0; i < stmt->nfld;)
{ {
/* Dont worry about functions or quotes */ /* Dont worry about functions or quotes */
if (fi[i]->func || fi[i]->quote || fi[i]->numeric) if (fi[i]->func || fi[i]->quote || fi[i]->numeric)
{ {
...@@ -784,7 +766,6 @@ parse_statement(StatementClass *stmt) ...@@ -784,7 +766,6 @@ parse_statement(StatementClass *stmt)
/* Stars get expanded to all fields in the table */ /* Stars get expanded to all fields in the table */
else if (fi[i]->name[0] == '*') else if (fi[i]->name[0] == '*')
{ {
char do_all_tables; char do_all_tables;
int total_cols, int total_cols,
old_alloc, old_alloc,
...@@ -810,7 +791,6 @@ parse_statement(StatementClass *stmt) ...@@ -810,7 +791,6 @@ parse_statement(StatementClass *stmt)
increased_cols = total_cols - 1; increased_cols = total_cols - 1;
/* Allocate some more field pointers if necessary */ /* Allocate some more field pointers if necessary */
/*------------------------------------------------------------- */
old_alloc = ((stmt->nfld - 1) / FLD_INCR + 1) * FLD_INCR; old_alloc = ((stmt->nfld - 1) / FLD_INCR + 1) * FLD_INCR;
new_size = stmt->nfld + increased_cols; new_size = stmt->nfld + increased_cols;
...@@ -830,8 +810,6 @@ parse_statement(StatementClass *stmt) ...@@ -830,8 +810,6 @@ parse_statement(StatementClass *stmt)
stmt->fi = fi; stmt->fi = fi;
} }
/*------------------------------------------------------------- */
/* /*
* copy any other fields (if there are any) up past the * copy any other fields (if there are any) up past the
* expansion * expansion
...@@ -843,21 +821,16 @@ parse_statement(StatementClass *stmt) ...@@ -843,21 +821,16 @@ parse_statement(StatementClass *stmt)
} }
mylog("done copying fields\n"); mylog("done copying fields\n");
/*------------------------------------------------------------- */
/* Set the new number of fields */ /* Set the new number of fields */
stmt->nfld += increased_cols; stmt->nfld += increased_cols;
mylog("stmt->nfld now at %d\n", stmt->nfld); mylog("stmt->nfld now at %d\n", stmt->nfld);
/*------------------------------------------------------------- */
/* copy the new field info */ /* copy the new field info */
do_all_tables = (fi[i]->ti ? FALSE : TRUE); do_all_tables = (fi[i]->ti ? FALSE : TRUE);
for (k = 0; k < (do_all_tables ? stmt->ntab : 1); k++) for (k = 0; k < (do_all_tables ? stmt->ntab : 1); k++)
{ {
TABLE_INFO *the_ti = do_all_tables ? ti[k] : fi[i]->ti; TABLE_INFO *the_ti = do_all_tables ? ti[k] : fi[i]->ti;
cols = QR_get_num_tuples(the_ti->col_info->result); cols = QR_get_num_tuples(the_ti->col_info->result);
...@@ -890,8 +863,6 @@ parse_statement(StatementClass *stmt) ...@@ -890,8 +863,6 @@ parse_statement(StatementClass *stmt)
i += cols; i += cols;
mylog("i now at %d\n", i); mylog("i now at %d\n", i);
} }
/*------------------------------------------------------------- */
} }
/* /*
...@@ -901,7 +872,6 @@ parse_statement(StatementClass *stmt) ...@@ -901,7 +872,6 @@ parse_statement(StatementClass *stmt)
*/ */
else if (fi[i]->ti) else if (fi[i]->ti)
{ {
if (!searchColInfo(fi[i]->ti->col_info, fi[i])) if (!searchColInfo(fi[i]->ti->col_info, fi[i]))
parse = FALSE; parse = FALSE;
...@@ -925,13 +895,11 @@ parse_statement(StatementClass *stmt) ...@@ -925,13 +895,11 @@ parse_statement(StatementClass *stmt)
} }
} }
if (!parse) if (!parse)
stmt->parse_status = STMT_PARSE_INCOMPLETE; stmt->parse_status = STMT_PARSE_INCOMPLETE;
else else
stmt->parse_status = STMT_PARSE_COMPLETE; stmt->parse_status = STMT_PARSE_COMPLETE;
mylog("done parse_statement: parse=%d, parse_status=%d\n", parse, stmt->parse_status); mylog("done parse_statement: parse=%d, parse_status=%d\n", parse, stmt->parse_status);
return parse; return parse;
} }
This diff is collapsed.
/* Module: psqlodbc.c /*--------
* Module: psqlodbc.c
* *
* Description: This module contains the main entry point (DllMain) for the library. * Description: This module contains the main entry point (DllMain)
* It also contains functions to get and set global variables for the * for the library. It also contains functions to get
* driver in the registry. * and set global variables for the driver in the registry.
* *
* Classes: n/a * Classes: n/a
* *
* API functions: none * API functions: none
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *--------
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
...@@ -59,7 +60,6 @@ DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) ...@@ -59,7 +60,6 @@ DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
if (LOBYTE(wsaData.wVersion) != 1 || if (LOBYTE(wsaData.wVersion) != 1 ||
HIBYTE(wsaData.wVersion) != 1) HIBYTE(wsaData.wVersion) != 1)
{ {
WSACleanup(); WSACleanup();
return FALSE; return FALSE;
} }
...@@ -71,9 +71,7 @@ DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) ...@@ -71,9 +71,7 @@ DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
WSACleanup(); WSACleanup();
return TRUE; return TRUE;
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
...@@ -111,7 +109,8 @@ init(void) ...@@ -111,7 +109,8 @@ init(void)
#else /* not __GNUC__ */ #else /* not __GNUC__ */
/* These two functions do shared library initialziation on UNIX, well at least /*
* These two functions do shared library initialziation on UNIX, well at least
* on Linux. I don't know about other systems. * on Linux. I don't know about other systems.
*/ */
BOOL BOOL
...@@ -131,12 +130,14 @@ _fini(void) ...@@ -131,12 +130,14 @@ _fini(void)
#endif /* not WIN32 */ #endif /* not WIN32 */
/* This function is used to cause the Driver Manager to
call functions by number rather than name, which is faster. /*
The ordinal value of this function must be 199 to have the * This function is used to cause the Driver Manager to
Driver Manager do this. Also, the ordinal values of the * call functions by number rather than name, which is faster.
functions must match the value of fFunction in SQLGetFunctions() * The ordinal value of this function must be 199 to have the
*/ * Driver Manager do this. Also, the ordinal values of the
* functions must match the value of fFunction in SQLGetFunctions()
*/
RETCODE SQL_API RETCODE SQL_API
SQLDummyOrdinal(void) SQLDummyOrdinal(void)
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Module: tuple.c /*-------
* Module: tuple.c
* *
* Description: This module contains functions for setting the data for individual * Description: This module contains functions for setting the data
* fields (TupleField structure) of a manual result set. * for individual fields (TupleField structure) of a
* manual result set.
* *
* Important Note: These functions are ONLY used in building manual result sets for * Important Note: These functions are ONLY used in building manual
* info functions (SQLTables, SQLColumns, etc.) * result sets for info functions (SQLTables,
* SQLColumns, etc.)
* *
* Classes: n/a * Classes: n/a
* *
* API functions: none * API functions: none
* *
* Comments: See "notice.txt" for copyright and license information. * Comments: See "notice.txt" for copyright and license information.
* *-------
*/ */
#include "tuple.h" #include "tuple.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
void void
set_tuplefield_null(TupleField *tuple_field) set_tuplefield_null(TupleField *tuple_field)
{ {
...@@ -25,6 +29,7 @@ set_tuplefield_null(TupleField *tuple_field) ...@@ -25,6 +29,7 @@ set_tuplefield_null(TupleField *tuple_field)
tuple_field->value = NULL; /* strdup(""); */ tuple_field->value = NULL; /* strdup(""); */
} }
void void
set_tuplefield_string(TupleField *tuple_field, char *string) set_tuplefield_string(TupleField *tuple_field, char *string)
{ {
...@@ -39,7 +44,6 @@ set_tuplefield_int2(TupleField *tuple_field, Int2 value) ...@@ -39,7 +44,6 @@ set_tuplefield_int2(TupleField *tuple_field, Int2 value)
{ {
char buffer[10]; char buffer[10];
sprintf(buffer, "%d", value); sprintf(buffer, "%d", value);
tuple_field->len = strlen(buffer) + 1; tuple_field->len = strlen(buffer) + 1;
...@@ -47,6 +51,7 @@ set_tuplefield_int2(TupleField *tuple_field, Int2 value) ...@@ -47,6 +51,7 @@ set_tuplefield_int2(TupleField *tuple_field, Int2 value)
tuple_field->value = strdup(buffer); tuple_field->value = strdup(buffer);
} }
void void
set_tuplefield_int4(TupleField *tuple_field, Int4 value) set_tuplefield_int4(TupleField *tuple_field, Int4 value)
{ {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment