diff options
Diffstat (limited to 'src/interfaces')
91 files changed, 3487 insertions, 3305 deletions
diff --git a/src/interfaces/cli/example1.c b/src/interfaces/cli/example1.c index 9660ce5719..75cedda3dd 100644 --- a/src/interfaces/cli/example1.c +++ b/src/interfaces/cli/example1.c @@ -40,7 +40,7 @@ int print_err(SQLSMALLINT handletype, SQLINTEGER handle); int -example1(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen) +example1(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen) { SQLHENV henv; SQLHDBC hdbc; @@ -135,12 +135,12 @@ example1(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen) /* this time, explicitly allocate an application row descriptor */ SQLAllocHandle(SQL_HANDLE_DESC, hdbc, &hdesc); SQLSetDescRec(hdesc, 1, SQL_INTEGER, 0, 0L, 0, 0, - (SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) &idind); + (SQLPOINTER) & id, (SQLINTEGER *) NULL, (SQLSMALLINT *) & idind); SQLSetDescRec(hdesc, 2, SQL_ CHAR, 0, (SQLINTEGER) sizeof(name), - 0, 0, (SQLPOINTER) & name, (SQLINTEGER *) &namelen, - (SQLSMALLINT *) &nameind); + 0, 0, (SQLPOINTER) & name, (SQLINTEGER *) & namelen, + (SQLSMALLINT *) & nameind); /* associate descriptor with statement handle */ SQLSetStmtAttr(hstmt, SQL_ATTR_APP_ROW_DESC, &hdesc, 0); /* execute the fetch */ diff --git a/src/interfaces/cli/example2.c b/src/interfaces/cli/example2.c index 21685ef21b..7230abc4da 100644 --- a/src/interfaces/cli/example2.c +++ b/src/interfaces/cli/example2.c @@ -39,17 +39,17 @@ #define max(a,b) (a>b?a:b) int print_err(SQLSMALLINT handletype, SQLINTEGER handle); -int build_indicator_message(SQLCHAR *errmsg, +int build_indicator_message(SQLCHAR * errmsg, SQLPOINTER * data, SQLINTEGER collen, - SQLINTEGER *outlen, + SQLINTEGER * outlen, SQLSMALLINT colnum); SQLINTEGER display_length(SQLSMALLINT coltype, SQLINTEGER collen, - SQLCHAR *colname); + SQLCHAR * colname); -example2(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen, SQLCHAR *sqlstr) +example2(SQLCHAR * server, SQLCHAR * uid, SQLCHAR * authen, SQLCHAR * sqlstr) { int i; SQLHENV henv; @@ -214,13 +214,13 @@ example2(SQLCHAR *server, SQLCHAR *uid, SQLCHAR *authen, SQLCHAR *sqlstr) SQLINTEGER display_length(SQLSMALLINT coltype, SQLINTEGER collen, - SQLCHAR *colname) + SQLCHAR * colname) { switch (coltype) { - case SQL_VARCHAR: - case SQL_CHAR: + case SQL_VARCHAR: + case SQL_CHAR: return (max(collen, strlen((char *) colname))); break; @@ -252,8 +252,8 @@ display_length(SQLSMALLINT coltype, SQLINTEGER collen, } int -build_indicator_message(SQLCHAR *errmsg, SQLPOINTER * data, - SQLINTEGER collen, SQLINTEGER *outlen, SQLSMALLINT colnum) +build_indicator_message(SQLCHAR * errmsg, SQLPOINTER * data, + SQLINTEGER collen, SQLINTEGER * outlen, SQLSMALLINT colnum) { if (*outlen == SQL_NULL_DATA) { diff --git a/src/interfaces/cli/sqlcli.h b/src/interfaces/cli/sqlcli.h index 2942abf12f..a9145495fc 100644 --- a/src/interfaces/cli/sqlcli.h +++ b/src/interfaces/cli/sqlcli.h @@ -473,7 +473,7 @@ SQLRETURN SQLAllocEnv(SQLHENV * EnvironmentHandle); SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType, SQLINTEGER InputHandle, - SQLINTEGER *OutputHandle); + SQLINTEGER * OutputHandle); SQLRETURN SQLAllocStmt(SQLHDBC ConnectionHandle, SQLSTMT * StatementHandle); @@ -483,7 +483,7 @@ SQLRETURN SQLBindCol(SQLHSTMT StatementHandle, SQLSMALLINT BufferType, SQLPOINTER Data, SQLINTEGER BufferLength, - SQLINTEGER *DataLength); + SQLINTEGER * DataLength); SQLRETURN SQLBindParam(SQLHSTMT StatementHandle, SQLSMALLINT ParamNumber, @@ -492,7 +492,7 @@ SQLRETURN SQLBindParam(SQLHSTMT StatementHandle, SQLINTEGER ParamLength, SQLSMALLINT Scale, SQLPOINTER Data, - SQLINTEGER *DataLength); + SQLINTEGER * DataLength); SQLRETURN SQLCancel(SQLHSTMT StatementHandle); @@ -501,17 +501,17 @@ SQLRETURN SQLCloseCursor(SQLHSTMT StatementHandle); SQLRETURN SQLColAttribute(SQLHSTMT StatementHandle, SQLSMALLINT ColumnNumber, SQLSMALLINT FieldIdentifier, - SQLCHAR *CharacterAttribute, + SQLCHAR * CharacterAttribute, SQLINTEGER BufferLength, - SQLINTEGER *AttributetLength, - SQLINTEGER *NumericAttribute); + SQLINTEGER * AttributetLength, + SQLINTEGER * NumericAttribute); SQLRETURN SQLConnect(SQLHDBC ConnectionHandle, - SQLCHAR *ServerName, + SQLCHAR * ServerName, SQLSMALLINT NameLength1, - SQLCHAR *UserName, + SQLCHAR * UserName, SQLSMALLINT NameLength2, - SQLCHAR *Authentication, + SQLCHAR * Authentication, SQLSMALLINT NameLength3); SQLRETURN SQLCopyDesc(SQLHDESC SourceDescHandle, @@ -519,22 +519,22 @@ SQLRETURN SQLCopyDesc(SQLHDESC SourceDescHandle, SQLRETURN SQLDataSources(SQLHENV EnvironmentHandle, SQLSMALLINT Direction, - SQLCHAR *ServerName, + SQLCHAR * ServerName, SQLSMALLINT BufferLength1, - SQLSMALLINT *NameLength1, - SQLCHAR *Description, + SQLSMALLINT * NameLength1, + SQLCHAR * Description, SQLSMALLINT BufferLength2, - SQLSMALLINT *NameLength2); + SQLSMALLINT * NameLength2); SQLRETURN SQLDescribeCol(SQLHSTMT StatementHandle, SQLSMALLINT ColumnNumber, - SQLCHAR *ColumnName, + SQLCHAR * ColumnName, SQLSMALLINT BufferLength, - SQLSMALLINT *ColumnNameLength, - SQLSMALLINT *ColumnType, - SQLINTEGER *ColumnLength, - SQLSMALLINT *ColumnScale, - SQLSMALLINT *Nullable); + SQLSMALLINT * ColumnNameLength, + SQLSMALLINT * ColumnType, + SQLINTEGER * ColumnLength, + SQLSMALLINT * ColumnScale, + SQLSMALLINT * Nullable); SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle); @@ -545,14 +545,14 @@ SQLRETURN SQLEndTran(SQLSMALLINT HandleType, SQLRETURN SQLError(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, SQLSTMT StatementHandle, - SQLCHAR *Sqlstate, - SQLINTEGER *NativeError, - SQLCHAR *MessageText, + SQLCHAR * Sqlstate, + SQLINTEGER * NativeError, + SQLCHAR * MessageText, SQLINTEGER BufferLength, - SQLINTEGER *TextLength); + SQLINTEGER * TextLength); SQLRETURN SQLExecDirect(SQLHSTMT StatementHandle, - SQLCHAR *StatementText, + SQLCHAR * StatementText, SQLSMALLINT StringLength); SQLRETURN SQLExecute(SQLHSTMT StatementHandle); @@ -576,38 +576,38 @@ SQLRETURN SQLGetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength); + SQLINTEGER * StringLength); SQLRETURN SQLGetCursorName(SQLHSTMT StatementHandle, - SQLCHAR *CursorName, + SQLCHAR * CursorName, SQLSMALLINT BufferLength, - SQLSMALLINT *NameLength); + SQLSMALLINT * NameLength); SQLRETURN SQLGetData(SQLHSTMT StatementHandle, SQLSMALLINT ColumnNumber, SQLSMALLINT TargetType, SQLPOINTER TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *IndicatorValue); + SQLINTEGER * IndicatorValue); SQLRETURN SQLGetDescField(SQLHDESC DescriptorHandle, SQLSMALLINT RecordNumber, SQLSMALLINT FieldIdentifier, SQLPOINTER Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength); + SQLINTEGER * StringLength); SQLRETURN SQLGetDescRec(SQLHDESC DescriptorHandle, SQLSMALLINT RecordNumber, - SQLCHAR *Name, + SQLCHAR * Name, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength, - SQLSMALLINT *Type, - SQLSMALLINT *SubType, - SQLINTEGER *Length, - SQLSMALLINT *Precision, - SQLSMALLINT *Scale, - SQLSMALLINT *Nullable); + SQLSMALLINT * StringLength, + SQLSMALLINT * Type, + SQLSMALLINT * SubType, + SQLINTEGER * Length, + SQLSMALLINT * Precision, + SQLSMALLINT * Scale, + SQLSMALLINT * Nullable); SQLRETURN SQLGetDiagField(SQLSMALLINT HandleType, SQLINTEGER Handle, @@ -615,51 +615,51 @@ SQLRETURN SQLGetDiagField(SQLSMALLINT HandleType, SQLSMALLINT DiagIdentifier, SQLPOINTER DiagInfo, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength); + SQLSMALLINT * StringLength); SQLRETURN SQLGetDiagRec(SQLSMALLINT HandleType, SQLINTEGER Handle, SQLSMALLINT RecordNumber, - SQLCHAR *Sqlstate, - SQLINTEGER *NativeError, - SQLCHAR *MessageText, + SQLCHAR * Sqlstate, + SQLINTEGER * NativeError, + SQLCHAR * MessageText, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength); + SQLSMALLINT * StringLength); SQLRETURN SQLGetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength); + SQLINTEGER * StringLength); SQLRETURN SQLGetFunctions(SQLHDBC ConnectionHandle, SQLSMALLINT FunctionId, - SQLSMALLINT *Supported); + SQLSMALLINT * Supported); SQLRETURN SQLGetInfo(SQLHDBC ConnectionHandle, SQLSMALLINT InfoType, SQLPOINTER InfoValue, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength); + SQLSMALLINT * StringLength); SQLRETURN SQLGetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength); + SQLINTEGER * StringLength); SQLRETURN SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType); SQLRETURN SQLNumResultCols(SQLHSTMT StatementHandle, - SQLINTEGER *ColumnCount); + SQLINTEGER * ColumnCount); SQLRETURN SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER * Value); SQLRETURN SQLPrepare(SQLHSTMT StatementHandle, - SQLCHAR *StatementText, + SQLCHAR * StatementText, SQLSMALLINT StringLength); @@ -668,7 +668,7 @@ SQLRETURN SQLPutData(SQLHSTMT StatementHandle, SQLINTEGER StringLength); SQLRETURN SQLRowCount(SQLHSTMT StatementHandle, - SQLINTEGER *RowCount); + SQLINTEGER * RowCount); SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER AttributeCursorName, @@ -676,7 +676,7 @@ SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER StringLength); SQLRETURN SQLSetCursorName(SQLHSTMT StatementHandle, - SQLCHAR *CursorName, + SQLCHAR * CursorName, SQLSMALLINT NameLength); SQLRETURN SQLSetDescField(SQLHDESC DescriptorHandle, @@ -692,8 +692,8 @@ SQLRETURN SQLSetDescRec(SQLHDESC DescriptorHandle, SQLSMALLINT Precision, SQLSMALLINT Scale, SQLPOINTER Data, - SQLINTEGER *StringLength, - SQLSMALLINT *Indicator); + SQLINTEGER * StringLength, + SQLSMALLINT * Indicator); SQLRETURN SQLSetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, diff --git a/src/interfaces/ecpg/include/ecpgerrno.h b/src/interfaces/ecpg/include/ecpgerrno.h index 49e6269d8a..81d67277fe 100644 --- a/src/interfaces/ecpg/include/ecpgerrno.h +++ b/src/interfaces/ecpg/include/ecpgerrno.h @@ -61,5 +61,4 @@ #define ECPG_NOTICE_NO_TRANSACTION -604 /* NOTICE: BlankPortalAssignName: portal * already exists */ #define ECPG_NOTICE_PORTAL_EXISTS -605 - #endif /* !_ECPG_ERROR_H */ diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h index acb022aa1b..732e70f3ce 100644 --- a/src/interfaces/ecpg/include/ecpglib.h +++ b/src/interfaces/ecpg/include/ecpglib.h @@ -70,5 +70,4 @@ extern "C" #ifdef __cplusplus } - #endif diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h index 3e6875cf1d..c2e698b84f 100644 --- a/src/interfaces/ecpg/include/ecpgtype.h +++ b/src/interfaces/ecpg/include/ecpgtype.h @@ -47,7 +47,7 @@ extern "C" ECPGt_EORT, /* End of result types. */ ECPGt_NO_INDICATOR, /* no indicator */ ECPGt_long_long, ECPGt_unsigned_long_long, - ECPGt_descriptor /* sql descriptor, no C variable */ + ECPGt_descriptor /* sql descriptor, no C variable */ }; /* descriptor items */ @@ -76,5 +76,4 @@ extern "C" #ifdef __cplusplus } - #endif diff --git a/src/interfaces/ecpg/include/sql3types.h b/src/interfaces/ecpg/include/sql3types.h index 17fe493c11..02305dd54a 100644 --- a/src/interfaces/ecpg/include/sql3types.h +++ b/src/interfaces/ecpg/include/sql3types.h @@ -2,29 +2,29 @@ * * Copyright (c) 2000, Christof Petig <christof.petig@wtal.de> * - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.5 2001/09/19 14:09:32 meskes Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/include/sql3types.h,v 1.6 2001/10/25 05:50:11 momjian Exp $ */ /* chapter 13.1 table 2: Codes used for SQL data types in Dynamic SQL */ enum { - SQL3_CHARACTER = 1, - SQL3_NUMERIC, - SQL3_DECIMAL, - SQL3_INTEGER, - SQL3_SMALLINT, - SQL3_FLOAT, - SQL3_REAL, - SQL3_DOUBLE_PRECISION, - SQL3_DATE_TIME_TIMESTAMP, - SQL3_INTERVAL, /* 10 */ - SQL3_CHARACTER_VARYING = 12, - SQL3_ENUMERATED, - SQL3_BIT, - SQL3_BIT_VARYING, - SQL3_BOOLEAN, - SQL3_abstract + SQL3_CHARACTER = 1, + SQL3_NUMERIC, + SQL3_DECIMAL, + SQL3_INTEGER, + SQL3_SMALLINT, + SQL3_FLOAT, + SQL3_REAL, + SQL3_DOUBLE_PRECISION, + SQL3_DATE_TIME_TIMESTAMP, + SQL3_INTERVAL, /* 10 */ + SQL3_CHARACTER_VARYING = 12, + SQL3_ENUMERATED, + SQL3_BIT, + SQL3_BIT_VARYING, + SQL3_BOOLEAN, + SQL3_abstract /* the rest is xLOB stuff */ }; @@ -32,12 +32,12 @@ enum enum { - SQL3_DDT_DATE = 1, - SQL3_DDT_TIME, - SQL3_DDT_TIMESTAMP, - SQL3_DDT_TIME_WITH_TIME_ZONE, - SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE, + SQL3_DDT_DATE = 1, + SQL3_DDT_TIME, + SQL3_DDT_TIMESTAMP, + SQL3_DDT_TIME_WITH_TIME_ZONE, + SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE, - SQL3_DDT_ILLEGAL /* not a datetime data type (not part of + SQL3_DDT_ILLEGAL/* not a datetime data type (not part of * standard) */ }; diff --git a/src/interfaces/ecpg/include/sqlca.h b/src/interfaces/ecpg/include/sqlca.h index 3f7e307da7..28ab20533d 100644 --- a/src/interfaces/ecpg/include/sqlca.h +++ b/src/interfaces/ecpg/include/sqlca.h @@ -6,8 +6,8 @@ #define DLLIMPORT __declspec (dllimport) #else #define DLLIMPORT -#endif /* __CYGWIN__ */ -#endif /* DLLIMPORT */ +#endif /* __CYGWIN__ */ +#endif /* DLLIMPORT */ #define SQLERRMC_LEN 70 @@ -44,7 +44,7 @@ extern "C" /* * 2: if 'W' a (hopefully) non-fatal notice occured - *//* 3: empty */ +*//* 3: empty */ /* 4: empty */ /* 5: empty */ /* 6: empty */ @@ -58,7 +58,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif diff --git a/src/interfaces/ecpg/lib/connect.c b/src/interfaces/ecpg/lib/connect.c index 9da651a020..239c766d7c 100644 --- a/src/interfaces/ecpg/lib/connect.c +++ b/src/interfaces/ecpg/lib/connect.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.12 2001/09/19 14:09:32 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.13 2001/10/25 05:50:11 momjian Exp $ */ #include "postgres_fe.h" @@ -313,7 +313,7 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd, /*------ * new style: - * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] + * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] * [/db name][?options] *------ */ diff --git a/src/interfaces/ecpg/lib/descriptor.c b/src/interfaces/ecpg/lib/descriptor.c index ba11f5af5e..af30723266 100644 --- a/src/interfaces/ecpg/lib/descriptor.c +++ b/src/interfaces/ecpg/lib/descriptor.c @@ -1,6 +1,6 @@ /* dynamic SQL support routines * - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.16 2001/09/19 14:09:32 meskes Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.17 2001/10/25 05:50:11 momjian Exp $ */ #include "postgres_fe.h" @@ -18,8 +18,10 @@ static PGresult * ECPGresultByDescriptor(int line, const char *name) { - PGresult **resultpp = ECPGdescriptor_lvalue ( line, name ); - if (resultpp) return *resultpp; + PGresult **resultpp = ECPGdescriptor_lvalue(line, name); + + if (resultpp) + return *resultpp; return NULL; } @@ -28,7 +30,8 @@ ECPGDynamicType_DDT(Oid type) { switch (type) { - case 1082:return SQL3_DDT_DATE; /* date */ + case 1082: + return SQL3_DDT_DATE; /* date */ case 1083: return SQL3_DDT_TIME; /* time */ case 1184: @@ -103,8 +106,8 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va { switch (vartype) { - case ECPGt_char: - case ECPGt_unsigned_char: + case ECPGt_char: + case ECPGt_unsigned_char: strncpy((char *) var, value, varcharsize); break; case ECPGt_varchar: @@ -136,9 +139,10 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) va_list args; PGresult *ECPGresult = ECPGresultByDescriptor(lineno, desc_name); enum ECPGdtype type; - bool Indicator_seen = false, - Data_seen = false; - int ntuples, act_tuple; + bool Indicator_seen = false, + Data_seen = false; + int ntuples, + act_tuple; va_start(args, index); if (!ECPGresult) @@ -180,21 +184,24 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) switch (type) { case (ECPGd_indicator): - /* this is like ECPGexecute - * missing : allocate arrays, perhaps this should go into - * a common function !! + + /* + * this is like ECPGexecute missing : allocate arrays, + * perhaps this should go into a common function !! */ if (ntuples > arrsize) - { ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", - lineno, ntuples, arrsize); + { + ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", + lineno, ntuples, arrsize); ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL); return false; } Indicator_seen = true; - for (act_tuple = 0; act_tuple < ntuples ; act_tuple++) - { if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, act_tuple, index))) + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, act_tuple, index))) return (false); - var = (char*)var + offset; + var = (char *) var + offset; ECPGlog("ECPGget_desc: INDICATOR[%d] = %d\n", act_tuple, -PQgetisnull(ECPGresult, act_tuple, index)); } break; @@ -234,20 +241,23 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) case ECPGd_ret_length: case ECPGd_ret_octet: - /* this is like ECPGexecute - * missing : allocate arrays, perhaps this should go into - * a common function !! + + /* + * this is like ECPGexecute missing : allocate arrays, + * perhaps this should go into a common function !! */ if (ntuples > arrsize) - { ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", - lineno, ntuples, arrsize); + { + ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", + lineno, ntuples, arrsize); ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL); return false; } - for (act_tuple = 0; act_tuple < ntuples ; act_tuple++) - { if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index))) + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, act_tuple, index))) return (false); - var = (char*)var + offset; + var = (char *) var + offset; ECPGlog("ECPGget_desc: RETURNED[%d] = %d\n", act_tuple, PQgetlength(ECPGresult, act_tuple, index)); } break; @@ -280,27 +290,30 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) ECPGlog("ECPGget_desc: TYPE = %d\n", ECPGDynamicType_DDT(PQftype(ECPGresult, index))); break; case ECPGd_data: - /* this is like ECPGexecute - * missing : allocate arrays, perhaps this should go into - * a common function !! + + /* + * this is like ECPGexecute missing : allocate arrays, + * perhaps this should go into a common function !! */ if (ntuples > arrsize) - { ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", - lineno, ntuples, arrsize); + { + ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n", + lineno, ntuples, arrsize); ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL); return false; } Data_seen = true; - for (act_tuple = 0; act_tuple < ntuples ; act_tuple++) - { if (PQgetisnull(ECPGresult, act_tuple, index)) - continue; /* do not touch data on null value */ - if (!get_data(ECPGresult, act_tuple, index, lineno, - vartype, ECPGt_NO_INDICATOR, var, NULL, - varcharsize, offset, false)) + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + if (PQgetisnull(ECPGresult, act_tuple, index)) + continue; /* do not touch data on null value */ + if (!get_data(ECPGresult, act_tuple, index, lineno, + vartype, ECPGt_NO_INDICATOR, var, NULL, + varcharsize, offset, false)) return (false); } break; - + case ECPGd_cardinality: if (!get_int_item(lineno, var, vartype, PQntuples(ECPGresult))) return (false); @@ -318,9 +331,10 @@ ECPGget_desc(int lineno, char *desc_name, int index,...) } if (Data_seen && !Indicator_seen) - { - for (act_tuple = 0; act_tuple < ntuples ; act_tuple++) - { if (PQgetisnull(ECPGresult, act_tuple, index)) + { + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + if (PQgetisnull(ECPGresult, act_tuple, index)) { ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL); return (false); @@ -365,14 +379,14 @@ ECPGallocate_desc(int line, const char *name) return true; } -PGresult ** +PGresult ** ECPGdescriptor_lvalue(int line, const char *descriptor) { struct descriptor *i; for (i = all_descriptors; i != NULL; i = i->next) { - if (!strcmp(descriptor, i->name)) + if (!strcmp(descriptor, i->name)) return &i->result; } diff --git a/src/interfaces/ecpg/lib/execute.c b/src/interfaces/ecpg/lib/execute.c index 099b4cff27..e9454ec215 100644 --- a/src/interfaces/ecpg/lib/execute.c +++ b/src/interfaces/ecpg/lib/execute.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.28 2001/10/05 17:37:07 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.29 2001/10/25 05:50:11 momjian Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -30,14 +30,29 @@ /* variables visible to the programs */ struct sqlca sqlca = { - {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '}, - sizeof(struct sqlca), - 0, - {0, {0}}, - {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '}, - {0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0} + { + 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' ' + } , + sizeof(struct sqlca), + 0, + { + 0, + { + 0 + } + }, + { + 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' ' + }, + { + 0, 0, 0, 0, 0, 0 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0 + } }; struct variable @@ -288,7 +303,6 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia if ((stmt->connection->cache_head) == NULL) { - /* * Text like types are not an array for ecpg, but postgres counts * them as an array. This define reminds you to not 'correct' @@ -356,7 +370,6 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia if (ECPGDynamicType(type) == SQL3_CHARACTER || ECPGDynamicType(type) == SQL3_CHARACTER_VARYING) { - /* * arrays of character strings are not yet implemented */ @@ -371,443 +384,439 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia bool -ECPGstore_result(const PGresult *results, int act_field, - const struct statement * stmt, struct variable *var) -{ int isarray, - act_tuple, - ntuples = PQntuples(results); - bool status = true; - - isarray = ECPGis_type_an_array(PQftype(results, act_field), stmt, var); - - if (!isarray) - { +ECPGstore_result(const PGresult *results, int act_field, + const struct statement * stmt, struct variable * var) +{ + int isarray, + act_tuple, + ntuples = PQntuples(results); + bool status = true; - /* - * if we don't have enough space, we cannot read - * all tuples - */ - if ((var->arrsize > 0 && ntuples > var->arrsize) || (var->ind_arrsize > 0 && ntuples > var->ind_arrsize)) - { - ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n", - stmt->lineno, ntuples, var->arrsize); - ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL); - return false; - } - } - else - { + isarray = ECPGis_type_an_array(PQftype(results, act_field), stmt, var); - /* - * since we read an array, the variable has to be - * an array too - */ - if (var->arrsize == 0) - { - ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL); - return false; - } - } + if (!isarray) + { + /* + * if we don't have enough space, we cannot read all tuples + */ + if ((var->arrsize > 0 && ntuples > var->arrsize) || (var->ind_arrsize > 0 && ntuples > var->ind_arrsize)) + { + ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n", + stmt->lineno, ntuples, var->arrsize); + ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL); + return false; + } + } + else + { + /* + * since we read an array, the variable has to be an array too + */ + if (var->arrsize == 0) + { + ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL); + return false; + } + } - /* - * allocate memory for NULL pointers - */ - if ((var->arrsize == 0 || var->varcharsize == 0) && var->value == NULL) - { - int len = 0; + /* + * allocate memory for NULL pointers + */ + if ((var->arrsize == 0 || var->varcharsize == 0) && var->value == NULL) + { + int len = 0; - switch (var->type) - { - case ECPGt_char: - case ECPGt_unsigned_char: - var->varcharsize = 0; - /* check strlen for each tuple */ - for (act_tuple = 0; act_tuple < ntuples; act_tuple++) - { - int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1; - - if (len > var->varcharsize) - var->varcharsize = len; - } - var->offset *= var->varcharsize; - len = var->offset * ntuples; - break; - case ECPGt_varchar: - len = ntuples * (var->varcharsize + sizeof(int)); - break; - default: - len = var->offset * ntuples; - break; - } - var->value = (void *) ecpg_alloc(len, stmt->lineno); - *((void **) var->pointer) = var->value; - add_mem(var->value, stmt->lineno); - } + switch (var->type) + { + case ECPGt_char: + case ECPGt_unsigned_char: + var->varcharsize = 0; + /* check strlen for each tuple */ + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1; - for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++) - { - if (!get_data(results, act_tuple, act_field, stmt->lineno, - var->type, var->ind_type, var->value, - var->ind_value, var->varcharsize, var->offset, isarray)) - status = false; - } + if (len > var->varcharsize) + var->varcharsize = len; + } + var->offset *= var->varcharsize; + len = var->offset * ntuples; + break; + case ECPGt_varchar: + len = ntuples * (var->varcharsize + sizeof(int)); + break; + default: + len = var->offset * ntuples; + break; + } + var->value = (void *) ecpg_alloc(len, stmt->lineno); + *((void **) var->pointer) = var->value; + add_mem(var->value, stmt->lineno); + } + + for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++) + { + if (!get_data(results, act_tuple, act_field, stmt->lineno, + var->type, var->ind_type, var->value, + var->ind_value, var->varcharsize, var->offset, isarray)) + status = false; + } return status; } static bool -ECPGstore_input(const struct statement * stmt, const struct variable *var, - const char **tobeinserted_p, bool *malloced_p) +ECPGstore_input(const struct statement * stmt, const struct variable * var, + const char **tobeinserted_p, bool *malloced_p) { - char *mallocedval = NULL; - char *newcopy = NULL; + char *mallocedval = NULL; + char *newcopy = NULL; - /* - * Some special treatment is needed for records since we want - * their contents to arrive in a comma-separated list on insert (I - * think). - */ - - *malloced_p=false; - *tobeinserted_p=""; + /* + * Some special treatment is needed for records since we want their + * contents to arrive in a comma-separated list on insert (I think). + */ - /* check for null value and set input buffer accordingly */ - switch (var->ind_type) - { - case ECPGt_short: - case ECPGt_unsigned_short: - if (*(short *) var->ind_value < 0) - *tobeinserted_p="null"; - break; - case ECPGt_int: - case ECPGt_unsigned_int: - if (*(int *) var->ind_value < 0) - *tobeinserted_p="null"; - break; - case ECPGt_long: - case ECPGt_unsigned_long: - if (*(long *) var->ind_value < 0L) - *tobeinserted_p="null"; - break; + *malloced_p = false; + *tobeinserted_p = ""; + + /* check for null value and set input buffer accordingly */ + switch (var->ind_type) + { + case ECPGt_short: + case ECPGt_unsigned_short: + if (*(short *) var->ind_value < 0) + *tobeinserted_p = "null"; + break; + case ECPGt_int: + case ECPGt_unsigned_int: + if (*(int *) var->ind_value < 0) + *tobeinserted_p = "null"; + break; + case ECPGt_long: + case ECPGt_unsigned_long: + if (*(long *) var->ind_value < 0L) + *tobeinserted_p = "null"; + break; #ifdef HAVE_LONG_LONG_INT_64 - case ECPGt_long_long: - case ECPGt_unsigned_long_long: - if (*(long long int *) var->ind_value < (long long) 0) - *tobeinserted_p="null"; - break; + case ECPGt_long_long: + case ECPGt_unsigned_long_long: + if (*(long long int *) var->ind_value < (long long) 0) + *tobeinserted_p = "null"; + break; #endif /* HAVE_LONG_LONG_INT_64 */ - default: - break; - } + default: + break; + } - if (**tobeinserted_p == '\0') + if (**tobeinserted_p == '\0') + { + switch (var->type) { - switch (var->type) - { - int element; + int element; - case ECPGt_short: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_short: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%hd,", ((short *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%hd,", ((short *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%hd", *((short *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%hd", *((short *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_int: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_int: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%d", *((int *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%d", *((int *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_unsigned_short: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_unsigned_short: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%hu,", ((unsigned short *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%hu,", ((unsigned short *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%hu", *((unsigned short *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%hu", *((unsigned short *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_unsigned_int: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_unsigned_int: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%u,", ((unsigned int *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%u,", ((unsigned int *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%u", *((unsigned int *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%u", *((unsigned int *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_long: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%ld", *((long *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%ld", *((long *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_unsigned_long: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_unsigned_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%lu,", ((unsigned long *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%lu,", ((unsigned long *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%lu", *((unsigned long *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%lu", *((unsigned long *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; #ifdef HAVE_LONG_LONG_INT_64 - case ECPGt_long_long: - if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) - return false; + case ECPGt_long_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%lld,", ((long long *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%lld,", ((long long *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%lld", *((long long *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%lld", *((long long *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_unsigned_long_long: - if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) - return false; + case ECPGt_unsigned_long_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%llu,", ((unsigned long long *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%llu,", ((unsigned long long *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%llu", *((unsigned long long *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%llu", *((unsigned long long *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; #endif /* HAVE_LONG_LONG_INT_64 */ - case ECPGt_float: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_float: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%.14g", *((float *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%.14g", *((float *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_double: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_double: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]); + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]); - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } - else - sprintf(mallocedval, "%.14g", *((double *) var->value)); + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%.14g", *((double *) var->value)); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; - case ECPGt_bool: - if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) - return false; + case ECPGt_bool: + if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) + return false; - if (var->arrsize > 1) - { - strncpy(mallocedval, "'{", sizeof("'{")); - - if (var->offset == sizeof(char)) - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f'); - - /* - * this is necessary since sizeof(C++'s - * bool)==sizeof(int) - */ - else if (var->offset == sizeof(int)) - for (element = 0; element < var->arrsize; element++) - sprintf(mallocedval + strlen(mallocedval), "%c,", (((int *) var->value)[element]) ? 't' : 'f'); - else - ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size"); - - strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); - } + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); + + if (var->offset == sizeof(char)) + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f'); + + /* + * this is necessary since sizeof(C++'s + * bool)==sizeof(int) + */ + else if (var->offset == sizeof(int)) + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%c,", (((int *) var->value)[element]) ? 't' : 'f'); else - { - if (var->offset == sizeof(char)) - sprintf(mallocedval, "'%c'", (*((char *) var->value)) ? 't' : 'f'); - else if (var->offset == sizeof(int)) - sprintf(mallocedval, "'%c'", (*((int *) var->value)) ? 't' : 'f'); - else - ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size"); - } + ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size"); - *tobeinserted_p = mallocedval; - *malloced_p = true; - break; + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + { + if (var->offset == sizeof(char)) + sprintf(mallocedval, "'%c'", (*((char *) var->value)) ? 't' : 'f'); + else if (var->offset == sizeof(int)) + sprintf(mallocedval, "'%c'", (*((int *) var->value)) ? 't' : 'f'); + else + ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size"); + } - case ECPGt_char: - case ECPGt_unsigned_char: - { - /* set slen to string length if type is char * */ - int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : var->varcharsize; + *tobeinserted_p = mallocedval; + *malloced_p = true; + break; + + case ECPGt_char: + case ECPGt_unsigned_char: + { + /* set slen to string length if type is char * */ + int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : var->varcharsize; - if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno))) - return false; + if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno))) + return false; - strncpy(newcopy, (char *) var->value, slen); - newcopy[slen] = '\0'; + strncpy(newcopy, (char *) var->value, slen); + newcopy[slen] = '\0'; - mallocedval = quote_postgres(newcopy, stmt->lineno); - if (!mallocedval) - return false; + mallocedval = quote_postgres(newcopy, stmt->lineno); + if (!mallocedval) + return false; - free(newcopy); + free(newcopy); - *tobeinserted_p = mallocedval; - *malloced_p = true; - } - break; - case ECPGt_char_variable: - { - int slen = strlen((char *) var->value); + *tobeinserted_p = mallocedval; + *malloced_p = true; + } + break; + case ECPGt_char_variable: + { + int slen = strlen((char *) var->value); - if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno))) - return false; + if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno))) + return false; - strncpy(mallocedval, (char *) var->value, slen); - mallocedval[slen] = '\0'; + strncpy(mallocedval, (char *) var->value, slen); + mallocedval[slen] = '\0'; - *tobeinserted_p = mallocedval; - *malloced_p = true; - } - break; - case ECPGt_varchar: - { - struct ECPGgeneric_varchar *variable = - (struct ECPGgeneric_varchar *) (var->value); + *tobeinserted_p = mallocedval; + *malloced_p = true; + } + break; + case ECPGt_varchar: + { + struct ECPGgeneric_varchar *variable = + (struct ECPGgeneric_varchar *) (var->value); - if (!(newcopy = (char *) ecpg_alloc(variable->len + 1, stmt->lineno))) - return false; + if (!(newcopy = (char *) ecpg_alloc(variable->len + 1, stmt->lineno))) + return false; - strncpy(newcopy, variable->arr, variable->len); - newcopy[variable->len] = '\0'; + strncpy(newcopy, variable->arr, variable->len); + newcopy[variable->len] = '\0'; - mallocedval = quote_postgres(newcopy, stmt->lineno); - if (!mallocedval) - return false; + mallocedval = quote_postgres(newcopy, stmt->lineno); + if (!mallocedval) + return false; - free(newcopy); + free(newcopy); - *tobeinserted_p = mallocedval; - *malloced_p = true; - } - break; + *tobeinserted_p = mallocedval; + *malloced_p = true; + } + break; - default: - /* Not implemented yet */ - ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *) ECPGtype_name(var->type)); - return false; - break; - } + default: + /* Not implemented yet */ + ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *) ECPGtype_name(var->type)); + return false; + break; } + } return true; } @@ -831,15 +840,15 @@ ECPGexecute(struct statement * stmt) var = stmt->inlist; while (var) { - char *newcopy = NULL; + char *newcopy = NULL; const char *tobeinserted = NULL; char *p; - bool malloced=FALSE; - int hostvarl = 0; + bool malloced = FALSE; + int hostvarl = 0; if (!ECPGstore_input(stmt, var, &tobeinserted, &malloced)) return false; - + /* * Now tobeinserted points to an area that is to be inserted at * the first %s @@ -850,7 +859,6 @@ ECPGexecute(struct statement * stmt) strcpy(newcopy, copiedquery); if ((p = next_insert(newcopy + hostvarl)) == NULL) { - /* * We have an argument but we dont have the matched up string * in the string @@ -880,7 +888,7 @@ ECPGexecute(struct statement * stmt) */ if (malloced) { - free((char*)tobeinserted); + free((char *) tobeinserted); tobeinserted = NULL; } @@ -921,11 +929,14 @@ ECPGexecute(struct statement * stmt) ECPGraise(stmt->lineno, ECPG_PGSQL, PQerrorMessage(stmt->connection->connection)); } else - /* note: since some of the following code is duplicated in descriptor.c - * it should go into a separate function - */ + + /* + * note: since some of the following code is duplicated in + * descriptor.c it should go into a separate function + */ { - bool clear_result = TRUE; + bool clear_result = TRUE; + var = stmt->outlist; switch (PQresultStatus(results)) { @@ -940,37 +951,43 @@ ECPGexecute(struct statement * stmt) if (ntuples < 1) { - if (ntuples) ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n", - stmt->lineno, ntuples); + if (ntuples) + ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n", + stmt->lineno, ntuples); ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL); status = false; break; } - if (var != NULL && var->type==ECPGt_descriptor) - { PGresult **resultpp = ECPGdescriptor_lvalue(stmt->lineno, (const char*)var->pointer); - if (resultpp == NULL) status = false; + if (var != NULL && var->type == ECPGt_descriptor) + { + PGresult **resultpp = ECPGdescriptor_lvalue(stmt->lineno, (const char *) var->pointer); + + if (resultpp == NULL) + status = false; else - { if (*resultpp) - PQclear(*resultpp); - *resultpp=results; + { + if (*resultpp) + PQclear(*resultpp); + *resultpp = results; clear_result = FALSE; - ECPGlog("ECPGexecute putting result (%d tuples) into descriptor '%s'\n", PQntuples(results), (const char*)var->pointer); + ECPGlog("ECPGexecute putting result (%d tuples) into descriptor '%s'\n", PQntuples(results), (const char *) var->pointer); } var = var->next; } - else for (act_field = 0; act_field < nfields && status; act_field++) - { - if (var == NULL) + else + for (act_field = 0; act_field < nfields && status; act_field++) { - ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL); - return (false); - } - - status = ECPGstore_result(results, act_field, stmt, var); + if (var == NULL) + { + ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL); + return (false); + } - var = var->next; - } + status = ECPGstore_result(results, act_field, stmt, var); + + var = var->next; + } if (status && var != NULL) { @@ -1016,7 +1033,8 @@ ECPGexecute(struct statement * stmt) status = false; break; } - if (clear_result) PQclear(results); + if (clear_result) + PQclear(results); } /* check for asynchronous returns */ @@ -1038,7 +1056,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...) struct statement *stmt; struct connection *con = get_connection(connection_name); bool status; - char *oldlocale; + char *oldlocale; /* Make sure we do NOT honor the locale for numeric input/output */ /* since the database wants the standard decimal point */ @@ -1081,12 +1099,12 @@ ECPGdo(int lineno, const char *connection_name, char *query,...) return (status); } -/* old descriptor interface */ +/* old descriptor interface */ bool ECPGdo_descriptor(int line, const char *connection, const char *descriptor, const char *query) { - return ECPGdo(line, connection, (char *)query, ECPGt_EOIT, - ECPGt_descriptor, descriptor, 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + return ECPGdo(line, connection, (char *) query, ECPGt_EOIT, + ECPGt_descriptor, descriptor, 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); } diff --git a/src/interfaces/ecpg/lib/extern.h b/src/interfaces/ecpg/lib/extern.h index 971924e708..8e7ba566a3 100644 --- a/src/interfaces/ecpg/lib/extern.h +++ b/src/interfaces/ecpg/lib/extern.h @@ -62,9 +62,8 @@ struct descriptor struct descriptor *next; }; -PGresult ** -ECPGdescriptor_lvalue(int line, const char *descriptor); +PGresult ** + ECPGdescriptor_lvalue(int line, const char *descriptor); -bool -ECPGstore_result(const PGresult *results, int act_field, - const struct statement * stmt, struct variable *var); +bool ECPGstore_result(const PGresult *results, int act_field, + const struct statement * stmt, struct variable * var); diff --git a/src/interfaces/ecpg/lib/misc.c b/src/interfaces/ecpg/lib/misc.c index b5dd56e3cf..a37cd7ceb6 100644 --- a/src/interfaces/ecpg/lib/misc.c +++ b/src/interfaces/ecpg/lib/misc.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.6 2001/10/05 17:37:07 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.7 2001/10/25 05:50:12 momjian Exp $ */ #include "postgres_fe.h" @@ -11,14 +11,29 @@ static struct sqlca sqlca_init = { - {'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '}, - sizeof(struct sqlca), - 0, - {0, {0}}, - {'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '}, - {0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0} + { + 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' ' + } , + sizeof(struct sqlca), + 0, + { + 0, + { + 0 + } + }, + { + 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' ' + }, + { + 0, 0, 0, 0, 0, 0 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0 + } }; static int simple_debug = 0; diff --git a/src/interfaces/ecpg/lib/pg_type.h b/src/interfaces/ecpg/lib/pg_type.h index a9ffbfb627..5961dc23c6 100644 --- a/src/interfaces/ecpg/lib/pg_type.h +++ b/src/interfaces/ecpg/lib/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.2 2001/01/24 19:43:29 momjian Exp $ + * $Id: pg_type.h,v 1.3 2001/10/25 05:50:12 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -68,5 +68,4 @@ #define ZPBITOID 1560 #define VARBITOID 1562 #define NUMERICOID 1700 - #endif /* PG_TYPE_H */ diff --git a/src/interfaces/ecpg/lib/typename.c b/src/interfaces/ecpg/lib/typename.c index 345a5f36f1..48747e2c71 100644 --- a/src/interfaces/ecpg/lib/typename.c +++ b/src/interfaces/ecpg/lib/typename.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/typename.c,v 1.19 2001/09/19 14:09:32 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/typename.c,v 1.20 2001/10/25 05:50:12 momjian Exp $ */ #include "postgres_fe.h" @@ -17,7 +17,7 @@ ECPGtype_name(enum ECPGttype typ) { switch (typ) { - case ECPGt_char: + case ECPGt_char: return "char"; case ECPGt_unsigned_char: return "unsigned char"; @@ -58,11 +58,12 @@ ECPGDynamicType(Oid type) { switch (type) { - case BOOLOID:return SQL3_BOOLEAN; /* bool */ + case BOOLOID: + return SQL3_BOOLEAN; /* bool */ case INT2OID: return SQL3_SMALLINT; /* int2 */ case INT4OID: - return SQL3_INTEGER;/* int4 */ + return SQL3_INTEGER; /* int4 */ case TEXTOID: return SQL3_CHARACTER; /* text */ case FLOAT4OID: @@ -80,7 +81,7 @@ ECPGDynamicType(Oid type) case TIMESTAMPOID: return SQL3_DATE_TIME_TIMESTAMP; /* datetime */ case NUMERICOID: - return SQL3_NUMERIC;/* numeric */ + return SQL3_NUMERIC; /* numeric */ default: return -type; } diff --git a/src/interfaces/ecpg/preproc/descriptor.c b/src/interfaces/ecpg/preproc/descriptor.c index 6542888dd7..372a0c362d 100644 --- a/src/interfaces/ecpg/preproc/descriptor.c +++ b/src/interfaces/ecpg/preproc/descriptor.c @@ -75,9 +75,10 @@ void add_descriptor(char *name, char *connection) { struct descriptor *new; - - if (name[0]!='"') return; - + + if (name[0] != '"') + return; + new = (struct descriptor *) mm_alloc(sizeof(struct descriptor)); new->next = descriptors; @@ -99,7 +100,8 @@ drop_descriptor(char *name, char *connection) struct descriptor *i; struct descriptor **lastptr = &descriptors; - if (name[0]!='"') return; + if (name[0] != '"') + return; for (i = descriptors; i; lastptr = &i->next, i = i->next) { @@ -128,7 +130,8 @@ lookup_descriptor(char *name, char *connection) { struct descriptor *i; - if (name[0]!='"') return NULL; + if (name[0] != '"') + return NULL; for (i = descriptors; i; i = i->next) { @@ -199,21 +202,23 @@ output_get_descr(char *desc_name, char *index) /* I consider dynamic allocation overkill since at most two descriptor variables are possible per statement. (input and output descriptor) - And descriptors are no normal variables, so they don't belong into + And descriptors are no normal variables, so they don't belong into the variable list. */ - + #define MAX_DESCRIPTOR_NAMELEN 128 -struct variable *descriptor_variable(const char *name,int input) -{ static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN]; +struct variable * +descriptor_variable(const char *name, int input) +{ + static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN]; static const struct ECPGtype descriptor_type = - { ECPGt_descriptor, 0 }; + {ECPGt_descriptor, 0}; static const struct variable varspace[2] = - {{ descriptor_names[0], (struct ECPGtype*)&descriptor_type, 0, NULL }, - { descriptor_names[1], (struct ECPGtype*)&descriptor_type, 0, NULL } + {{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL}, + {descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL} }; - - strncpy(descriptor_names[input],name,MAX_DESCRIPTOR_NAMELEN); - descriptor_names[input][MAX_DESCRIPTOR_NAMELEN-1]=0; - return (struct variable*)&varspace[input]; + + strncpy(descriptor_names[input], name, MAX_DESCRIPTOR_NAMELEN); + descriptor_names[input][MAX_DESCRIPTOR_NAMELEN - 1] = 0; + return (struct variable *) & varspace[input]; } diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 4897f77393..7b6f33e794 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.49 2001/09/19 14:09:32 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.50 2001/10/25 05:50:12 momjian Exp $ */ /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */ @@ -32,7 +32,7 @@ help(const char *progname) /* printf is a macro some places; don't #ifdef inside its arguments */ #ifdef YYDEBUG printf("Usage:\n" - " %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] file1 [file2...]\n\n", + " %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] file1 [file2...]\n\n", progname); #else printf("Usage:\n" @@ -47,7 +47,7 @@ help(const char *progname) printf(" -o OUTFILE write result to OUTFILE\n"); printf(" -t turn on autocommit of transactions\n"); printf("\nIf no output file is specified, the name is formed by adding .c\n" - "to the input file name, after stripping off .pgc if present.\n"); + "to the input file name, after stripping off .pgc if present.\n"); printf("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"); } @@ -90,12 +90,12 @@ main(int argc, char *const argv[]) if (argc > 1) { - if (strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-?")==0) + if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { help(progname); exit(0); } - else if (strcmp(argv[1], "--version")==0) + else if (strcmp(argv[1], "--version") == 0) { printf("ecpg (PostgreSQL %s) %d.%d.%d\n", PG_VERSION, MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL); diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h index b393fd3ad7..43f99c9cc7 100644 --- a/src/interfaces/ecpg/preproc/extern.h +++ b/src/interfaces/ecpg/preproc/extern.h @@ -22,7 +22,6 @@ extern char *yytext, #ifdef YYDEBUG extern int yydebug; - #endif extern int yylineno, yyleng; @@ -67,7 +66,7 @@ extern void whenever_action(int); extern void add_descriptor(char *, char *); extern void drop_descriptor(char *, char *); extern struct descriptor *lookup_descriptor(char *, char *); -extern struct variable *descriptor_variable(const char *name,int input); +extern struct variable *descriptor_variable(const char *name, int input); extern void add_variable(struct arguments **, struct variable *, struct variable *); extern void append_variable(struct arguments **, struct variable *, struct variable *); extern void dump_variables(struct arguments *, int); diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c index 690ed861a3..7e626b1971 100644 --- a/src/interfaces/ecpg/preproc/output.c +++ b/src/interfaces/ecpg/preproc/output.c @@ -39,7 +39,8 @@ print_action(struct when * w) { switch (w->code) { - case W_SQLPRINT:fprintf(yyout, "sqlprint();"); + case W_SQLPRINT: + fprintf(yyout, "sqlprint();"); break; case W_GOTO: fprintf(yyout, "goto %s;", w->command); diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c index be688ab63e..7efca2c376 100644 --- a/src/interfaces/ecpg/preproc/type.c +++ b/src/interfaces/ecpg/preproc/type.c @@ -121,7 +121,7 @@ get_type(enum ECPGttype typ) { switch (typ) { - case ECPGt_char: + case ECPGt_char: return ("ECPGt_char"); break; case ECPGt_unsigned_char: @@ -212,10 +212,10 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in switch (typ->typ) { - case ECPGt_array: + case ECPGt_array: switch (typ->u.element->typ) { - case ECPGt_array: + case ECPGt_array: yyerror("No nested arrays allowed (except strings)"); /* array of array */ break; case ECPGt_struct: @@ -351,7 +351,6 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ, static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz, struct ECPGtype * typ, struct ECPGtype * ind_typ, const char *offsetarg, const char *prefix, const char *ind_prefix) { - /* * If offset is NULL, then this is the first recursive level. If not * then we are in a struct in a struct and the offset is used as @@ -409,10 +408,10 @@ ECPGfree_type(struct ECPGtype * typ) { switch (typ->typ) { - case ECPGt_array: + case ECPGt_array: switch (typ->u.element->typ) { - case ECPGt_array: + case ECPGt_array: yyerror("internal error, found multi-dimensional array\n"); break; case ECPGt_struct: @@ -446,7 +445,7 @@ get_dtype(enum ECPGdtype typ) { switch (typ) { - case ECPGd_count: + case ECPGd_count: return ("ECPGd_countr"); break; case ECPGd_data: diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h index 12e45ab43a..a44cbec1ca 100644 --- a/src/interfaces/ecpg/preproc/type.h +++ b/src/interfaces/ecpg/preproc/type.h @@ -60,13 +60,13 @@ extern const char *ECPGtype_name(enum ECPGttype typ); /* some stuff for whenever statements */ enum WHEN_TYPE { - W_NOTHING, - W_CONTINUE, - W_BREAK, - W_SQLPRINT, - W_GOTO, - W_DO, - W_STOP + W_NOTHING, + W_CONTINUE, + W_BREAK, + W_SQLPRINT, + W_GOTO, + W_DO, + W_STOP }; struct when @@ -155,7 +155,7 @@ struct assignment enum errortype { - ET_NOTICE, ET_ERROR, ET_FATAL + ET_NOTICE, ET_ERROR, ET_FATAL }; struct fetch_desc diff --git a/src/interfaces/libpgeasy/libpgeasy.c b/src/interfaces/libpgeasy/libpgeasy.c index f8682c2761..0f049d6262 100644 --- a/src/interfaces/libpgeasy/libpgeasy.c +++ b/src/interfaces/libpgeasy/libpgeasy.c @@ -70,7 +70,7 @@ disconnectdb() ** doquery - returns PGresult structure ** */ -PGresult * +PGresult * doquery(char *query) { if (res != NULL && @@ -206,7 +206,7 @@ on_error_continue() ** get_result ** */ -PGresult * +PGresult * get_result() { char *cmdstatus = PQcmdStatus(res); diff --git a/src/interfaces/libpgtcl/libpgtcl.h b/src/interfaces/libpgtcl/libpgtcl.h index 2f9b49086f..7d225d03e8 100644 --- a/src/interfaces/libpgtcl/libpgtcl.h +++ b/src/interfaces/libpgtcl/libpgtcl.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpgtcl.h,v 1.11 2001/01/24 19:43:29 momjian Exp $ + * $Id: libpgtcl.h,v 1.12 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,5 +20,4 @@ extern int Pgtcl_Init(Tcl_Interp *interp); extern int Pgtcl_SafeInit(Tcl_Interp *interp); - #endif /* LIBPGTCL_H */ diff --git a/src/interfaces/libpgtcl/pgtcl.c b/src/interfaces/libpgtcl/pgtcl.c index 10f2ab0396..32e775f5d9 100644 --- a/src/interfaces/libpgtcl/pgtcl.c +++ b/src/interfaces/libpgtcl/pgtcl.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.23 2001/09/17 00:42:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.24 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ int Pgtcl_Init(Tcl_Interp *interp) { - double tclversion; + double tclversion; /* * finish off the ChannelType struct. Much easier to do it here then @@ -41,8 +41,9 @@ Pgtcl_Init(Tcl_Interp *interp) #endif /* - * Tcl versions >= 8.1 use UTF-8 for their internal string representation. - * Therefore PGCLIENTENCODING must be set to UNICODE for these versions. + * Tcl versions >= 8.1 use UTF-8 for their internal string + * representation. Therefore PGCLIENTENCODING must be set to UNICODE + * for these versions. */ Tcl_GetDouble(interp, Tcl_GetVar(interp, "tcl_version", TCL_GLOBAL_ONLY), &tclversion); if (tclversion >= 8.1) diff --git a/src/interfaces/libpgtcl/pgtclCmds.c b/src/interfaces/libpgtcl/pgtclCmds.c index 8fef8732fd..f3b4cf95f5 100644 --- a/src/interfaces/libpgtcl/pgtclCmds.c +++ b/src/interfaces/libpgtcl/pgtclCmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.57 2001/09/06 02:54:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.58 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -209,7 +209,6 @@ tcl_value(char *value) { if (*p == '\\') { - /* * escape sequence, translate it */ @@ -224,7 +223,6 @@ tcl_value(char *value) #endif return value; } - #endif /* TCL_ARRAYS */ @@ -310,7 +308,6 @@ Pg_connect(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) if (!strcmp("-conninfo", argv[1])) { - /* * Establish a connection using the new PQconnectdb() interface */ @@ -324,7 +321,6 @@ Pg_connect(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) } else { - /* * Establish a connection using the old PQsetdb() interface */ @@ -661,7 +657,6 @@ Pg_result(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) #else PQgetvalue(result, tupno, 0); - #endif char *workspace = malloc(strlen(field0) + strlen(appendstr) + 210); @@ -830,7 +825,6 @@ Pg_execute(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) if (strcmp(argv[i], "-array") == 0) { - /* * The rows should appear in an array vs. to single variables */ @@ -846,7 +840,6 @@ Pg_execute(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) if (strcmp(argv[i], "-oid") == 0) { - /* * We should place PQoidValue() somewhere */ @@ -955,7 +948,6 @@ Pg_execute(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) */ if (i == argc) { - /* * We don't have a loop body. If we have at least one result row, * we set all the variables to the first one and return. @@ -1272,7 +1264,6 @@ Pg_lo_read(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) return TCL_OK; } - #endif /*********************************** @@ -1365,7 +1356,6 @@ Pg_lo_write(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) sprintf(interp->result, "%d", nbytes); return TCL_OK; } - #endif /*********************************** @@ -1893,7 +1883,6 @@ Pg_listen(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) if (callback) { - /* * Create or update a callback for a relation */ @@ -1937,7 +1926,6 @@ Pg_listen(ClientData cData, Tcl_Interp *interp, int argc, char *argv[]) } else { - /* * Remove a callback for a relation */ diff --git a/src/interfaces/libpgtcl/pgtclCmds.h b/src/interfaces/libpgtcl/pgtclCmds.h index 6b40ea63c6..8f90af5aa9 100644 --- a/src/interfaces/libpgtcl/pgtclCmds.h +++ b/src/interfaces/libpgtcl/pgtclCmds.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pgtclCmds.h,v 1.22 2001/09/06 02:54:56 momjian Exp $ + * $Id: pgtclCmds.h,v 1.23 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,12 +62,13 @@ typedef struct Pg_ConnectionId_s int res_copyStatus; /* Copying status */ PGresult **results; /* The results */ - Pg_TclNotifies *notify_list;/* head of list of notify info */ + Pg_TclNotifies *notify_list; /* head of list of notify info */ int notifier_running; /* notify event source is live */ #if TCL_MAJOR_VERSION >= 8 - Tcl_Channel notifier_channel;/* Tcl_Channel on which notifier is listening */ + Tcl_Channel notifier_channel; /* Tcl_Channel on which notifier + * is listening */ #else - int notifier_socket;/* PQsocket on which notifier is listening */ + int notifier_socket; /* PQsocket on which notifier is listening */ #endif } Pg_ConnectionId; @@ -112,7 +113,6 @@ extern int Pg_lo_read( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); extern int Pg_lo_write( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); - #endif extern int Pg_lo_lseek( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); @@ -128,5 +128,4 @@ extern int Pg_lo_export( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); extern int Pg_listen( ClientData cData, Tcl_Interp *interp, int argc, char *argv[]); - #endif /* PGTCLCMDS_H */ diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c index ef34c595a4..06c3f3e18e 100644 --- a/src/interfaces/libpgtcl/pgtclId.c +++ b/src/interfaces/libpgtcl/pgtclId.c @@ -13,7 +13,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.27 2001/09/07 21:55:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.28 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,7 +135,6 @@ PgGetFileProc(ClientData cData, int direction) { return (Tcl_File) NULL; } - #endif /* @@ -147,7 +146,7 @@ PgWatchProc(ClientData instanceData, int mask) } static int PgGetHandleProc(ClientData instanceData, int direction, - ClientData *handlePtr) + ClientData *handlePtr) { return TCL_ERROR; } @@ -163,7 +162,7 @@ Tcl_ChannelType Pg_ConnType = { NULL, /* GetOptionProc, Not used */ PgWatchProc, /* WatchProc, must be defined */ PgGetHandleProc, /* GetHandleProc, must be defined */ - NULL /* Close2Proc, Not used */ + NULL /* Close2Proc, Not used */ }; /* @@ -395,7 +394,7 @@ getresid(Tcl_Interp *interp, char *id, Pg_ConnectionId ** connid_p) /* * Get back the result pointer from the Id */ -PGresult * +PGresult * PgGetResultId(Tcl_Interp *interp, char *id) { Pg_ConnectionId *connid; @@ -710,7 +709,7 @@ PgStartNotifyEventSource(Pg_ConnectionId * connid) { #if TCL_MAJOR_VERSION >= 8 Tcl_CreateChannelHandler(connid->notifier_channel, TCL_READABLE, - Pg_Notify_FileHandler, (ClientData) connid); + Pg_Notify_FileHandler, (ClientData) connid); #else /* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */ Tcl_File tclfile = Tcl_GetFile((ClientData) pqsock, TCL_UNIX_FD); @@ -732,7 +731,7 @@ PgStopNotifyEventSource(Pg_ConnectionId * connid) { #if TCL_MAJOR_VERSION >= 8 Tcl_DeleteChannelHandler(connid->notifier_channel, - Pg_Notify_FileHandler, (ClientData) connid); + Pg_Notify_FileHandler, (ClientData) connid); #else /* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */ Tcl_File tclfile = Tcl_GetFile((ClientData) connid->notifier_socket, diff --git a/src/interfaces/libpgtcl/pgtclId.h b/src/interfaces/libpgtcl/pgtclId.h index fd12ee4a48..4f37378f34 100644 --- a/src/interfaces/libpgtcl/pgtclId.h +++ b/src/interfaces/libpgtcl/pgtclId.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pgtclId.h,v 1.16 2001/01/24 19:43:29 momjian Exp $ + * $Id: pgtclId.h,v 1.17 2001/10/25 05:50:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,6 @@ extern void PgNotifyInterpDelete(ClientData clientData, Tcl_Interp *interp); #if HAVE_TCL_GETFILEPROC extern Tcl_File PgGetFileProc(ClientData cData, int direction); - #endif extern Tcl_ChannelType Pg_ConnType; diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 4b4b039910..8cfc1d940f 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.61 2001/09/26 19:54:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.62 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -231,7 +231,6 @@ pg_krb4_sendauth(char *PQerrormsg, int sock, } return STATUS_OK; } - #endif /* KRB4 */ #ifdef KRB5 @@ -405,7 +404,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, if (retval == KRB5_SENDAUTH_REJECTED && err_ret) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), + libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), err_ret->text.length, err_ret->text.data); } else @@ -432,33 +431,34 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, return ret; } - #endif /* KRB5 */ static int pg_local_sendauth(char *PQerrormsg, PGconn *conn) { #if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) - char buf; + char buf; struct iovec iov; struct msghdr msg; + #ifdef HAVE_STRUCT_CMSGCRED /* Prevent padding */ - char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)]; + char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)]; + /* Point to start of first structure */ - struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem; + struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem; #endif #ifdef HAVE_STRUCT_SOCKCRED /* Prevent padding */ - char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct sockcred)]; + char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct sockcred)]; + /* Point to start of first structure */ - struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem; + struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem; #endif /* - * The backend doesn't care what we send here, but it wants - * exactly one character to force recvmsg() to block and wait - * for us. + * The backend doesn't care what we send here, but it wants exactly + * one character to force recvmsg() to block and wait for us. */ buf = '\0'; iov.iov_base = &buf; @@ -481,13 +481,13 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn) if (sendmsg(conn->sock, &msg, 0) == -1) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "pg_local_sendauth: sendmsg: %s\n", strerror(errno)); + "pg_local_sendauth: sendmsg: %s\n", strerror(errno)); return STATUS_ERROR; } return STATUS_OK; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("SCM_CRED authentication method not supported\n")); + libpq_gettext("SCM_CRED authentication method not supported\n")); return STATUS_ERROR; #endif } @@ -495,51 +495,51 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn) static int pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq) { - int ret; - char *crypt_pwd; + int ret; + char *crypt_pwd; /* Encrypt the password if needed. */ switch (areq) { case AUTH_REQ_MD5: - { - char *crypt_pwd2; - - if (!(crypt_pwd = malloc(MD5_PASSWD_LEN+1)) || - !(crypt_pwd2 = malloc(MD5_PASSWD_LEN+1))) - { - perror("malloc"); - return STATUS_ERROR; - } - if (!EncryptMD5(password, conn->pguser, - strlen(conn->pguser), crypt_pwd2)) { - free(crypt_pwd); + char *crypt_pwd2; + + if (!(crypt_pwd = malloc(MD5_PASSWD_LEN + 1)) || + !(crypt_pwd2 = malloc(MD5_PASSWD_LEN + 1))) + { + perror("malloc"); + return STATUS_ERROR; + } + if (!EncryptMD5(password, conn->pguser, + strlen(conn->pguser), crypt_pwd2)) + { + free(crypt_pwd); + free(crypt_pwd2); + return STATUS_ERROR; + } + if (!EncryptMD5(crypt_pwd2 + strlen("md5"), conn->md5Salt, + sizeof(conn->md5Salt), crypt_pwd)) + { + free(crypt_pwd); + free(crypt_pwd2); + return STATUS_ERROR; + } free(crypt_pwd2); - return STATUS_ERROR; + break; } - if (!EncryptMD5(crypt_pwd2 + strlen("md5"), conn->md5Salt, - sizeof(conn->md5Salt), crypt_pwd)) - { - free(crypt_pwd); - free(crypt_pwd2); - return STATUS_ERROR; - } - free(crypt_pwd2); - break; - } case AUTH_REQ_CRYPT: - { - char salt[3]; + { + char salt[3]; - StrNCpy(salt, conn->cryptSalt,3); - crypt_pwd = crypt(password, salt); - break; - } + StrNCpy(salt, conn->cryptSalt, 3); + crypt_pwd = crypt(password, salt); + break; + } case AUTH_REQ_PASSWORD: /* discard const so we can assign it */ - crypt_pwd = (char *)password; + crypt_pwd = (char *) password; break; default: return STATUS_ERROR; @@ -573,13 +573,13 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, hostname) != STATUS_OK) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 4 authentication failed\n")); + libpq_gettext("Kerberos 4 authentication failed\n")); return STATUS_ERROR; } break; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 4 authentication not supported\n")); + libpq_gettext("Kerberos 4 authentication not supported\n")); return STATUS_ERROR; #endif @@ -590,13 +590,13 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, hostname) != STATUS_OK) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication failed\n")); + libpq_gettext("Kerberos 5 authentication failed\n")); return STATUS_ERROR; } break; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication not supported\n")); + libpq_gettext("Kerberos 5 authentication not supported\n")); return STATUS_ERROR; #endif diff --git a/src/interfaces/libpq/fe-auth.h b/src/interfaces/libpq/fe-auth.h index ed8d5b7774..4d99399cb9 100644 --- a/src/interfaces/libpq/fe-auth.h +++ b/src/interfaces/libpq/fe-auth.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fe-auth.h,v 1.12 2001/01/24 19:43:30 momjian Exp $ + * $Id: fe-auth.h,v 1.13 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,5 +41,4 @@ extern char *fe_getauthname(char *PQerrormsg); #define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */ #define PG_KRB5_VERSION "PGVER5.1" - #endif /* FE_AUTH_H */ diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 8829c69e32..69bd5fa591 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.177 2001/09/06 04:57:30 ishii Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.178 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,13 +59,11 @@ inet_aton(const char *cp, struct in_addr * inp) inp->s_addr = a; return 1; } - #endif #ifdef USE_SSL static SSL_CTX *SSL_context = NULL; - #endif #define NOTIFYLIST_INITIAL_SIZE 10 @@ -99,7 +97,6 @@ static SSL_CTX *SSL_context = NULL; * ---------- */ static const PQconninfoOption PQconninfoOptions[] = { - /* * "authtype" is no longer used, so mark it "don't show". We keep it * in the array so as not to reject conninfo strings from old apps @@ -191,7 +188,7 @@ static int parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage); -/* +/* * Connecting to a Database * * There are now four different ways a user of this API can connect to the @@ -576,7 +573,7 @@ update_db_info(PGconn *conn) /*------- * new style: - * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] + * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] * [/db name][?options] *------- */ @@ -601,7 +598,6 @@ update_db_info(PGconn *conn) } else { - /* * Why do we default only this value from the environment * again? @@ -676,7 +672,6 @@ update_db_info(PGconn *conn) return 0; } - #endif /* NOT_USED */ @@ -696,13 +691,13 @@ connectMakeNonblocking(PGconn *conn) #if defined(WIN32) if (ioctlsocket(conn->sock, FIONBIO, &on) != 0) #elif defined(__BEOS__) - if (ioctl(conn->sock, FIONBIO, &on) != 0) + if (ioctl(conn->sock, FIONBIO, &on) != 0) #else if (fcntl(conn->sock, F_SETFL, O_NONBLOCK) < 0) #endif { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not set socket to non-blocking mode: %s\n"), + libpq_gettext("could not set socket to non-blocking mode: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return 0; } @@ -726,7 +721,7 @@ connectNoDelay(PGconn *conn) sizeof(on)) < 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not set socket to TCP no delay mode: %s\n"), + libpq_gettext("could not set socket to TCP no delay mode: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return 0; } @@ -746,19 +741,19 @@ connectFailureMessage(PGconn *conn, int errorno) if (conn->raddr.sa.sa_family == AF_UNIX) printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "could not connect to server: %s\n" - "\tIs the server running locally and accepting\n" - "\tconnections on Unix domain socket \"%s\"?\n" - ), + "could not connect to server: %s\n" + "\tIs the server running locally and accepting\n" + "\tconnections on Unix domain socket \"%s\"?\n" + ), SOCK_STRERROR(errorno), conn->raddr.un.sun_path); else printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "could not connect to server: %s\n" - "\tIs the server running on host %s and accepting\n" - "\tTCP/IP connections on port %s?\n" - ), + "could not connect to server: %s\n" + "\tIs the server running on host %s and accepting\n" + "\tTCP/IP connections on port %s?\n" + ), SOCK_STRERROR(errorno), conn->pghost ? conn->pghost @@ -785,7 +780,6 @@ connectDBStart(PGconn *conn) #ifdef USE_SSL StartupPacket np; /* Used to negotiate SSL connection */ char SSLok; - #endif if (!conn) @@ -944,7 +938,7 @@ connectDBStart(PGconn *conn) if (pqPacketSend(conn, (char *) &np, sizeof(StartupPacket)) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send SSL negotiation packet: %s\n"), + libpq_gettext("could not send SSL negotiation packet: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); goto connect_errReturn; } @@ -966,8 +960,8 @@ connectDBStart(PGconn *conn) if (!SSL_context) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create SSL context: %s\n"), - ERR_reason_error_string(ERR_get_error())); + libpq_gettext("could not create SSL context: %s\n"), + ERR_reason_error_string(ERR_get_error())); goto connect_errReturn; } } @@ -976,8 +970,8 @@ connectDBStart(PGconn *conn) SSL_connect(conn->ssl) <= 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not establish SSL connection: %s\n"), - ERR_reason_error_string(ERR_get_error())); + libpq_gettext("could not establish SSL connection: %s\n"), + ERR_reason_error_string(ERR_get_error())); goto connect_errReturn; } /* SSL connection finished. Continue to send startup packet */ @@ -1053,7 +1047,6 @@ connectDBComplete(PGconn *conn) for (;;) { - /* * Wait, if necessary. Note that the initial state (just after * PQconnectStart) is to wait for the socket to select for @@ -1134,7 +1127,6 @@ PQconnectPoll(PGconn *conn) /* Get the new data */ switch (conn->status) { - /* * We really shouldn't have been polled in these two cases, * but we can handle it. @@ -1171,9 +1163,9 @@ PQconnectPoll(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid connection state, " - "probably indicative of memory corruption\n" - )); + "invalid connection state, " + "probably indicative of memory corruption\n" + )); goto error_return; } @@ -1261,7 +1253,7 @@ keep_going: /* We will come back to here until there sizeof(StartupPacket)) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send startup packet: %s\n"), + libpq_gettext("could not send startup packet: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); goto error_return; } @@ -1317,9 +1309,9 @@ keep_going: /* We will come back to here until there { printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "expected authentication request from " - "server, but received %c\n" - ), + "expected authentication request from " + "server, but received %c\n" + ), beresp); goto error_return; } @@ -1404,7 +1396,6 @@ keep_going: /* We will come back to here until there case CONNECTION_AUTH_OK: { - /* * Now we expect to hear from the backend. A ReadyForQuery * message indicates that startup is successful, but we @@ -1489,9 +1480,9 @@ keep_going: /* We will come back to here until there default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid connection state %c, " - "probably indicative of memory corruption\n" - ), + "invalid connection state %c, " + "probably indicative of memory corruption\n" + ), conn->status); goto error_return; } @@ -1549,7 +1540,6 @@ PQsetenvPoll(PGconn *conn) #ifdef MULTIBYTE static const char envname[] = "PGCLIENTENCODING"; - #endif if (conn == NULL || conn->status == CONNECTION_BAD) @@ -1589,9 +1579,9 @@ PQsetenvPoll(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid setenv state %c, " - "probably indicative of memory corruption\n" - ), + "invalid setenv state %c, " + "probably indicative of memory corruption\n" + ), conn->setenv_state); goto error_return; } @@ -1610,7 +1600,6 @@ keep_going: /* We will come back to here until there env = getenv(envname); if (!env || *env == '\0') { - /* * query server encoding if PGCLIENTENCODING is not * specified @@ -1756,7 +1745,7 @@ keep_going: /* We will come back to here until there default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext("invalid state %c, " - "probably indicative of memory corruption\n"), + "probably indicative of memory corruption\n"), conn->setenv_state); goto error_return; } @@ -1793,7 +1782,6 @@ PQsetenv(PGconn *conn) for (;;) { - /* * Wait, if necessary. Note that the initial state (just after * PQsetenvStart) is to wait for the socket to select for writing. @@ -1834,7 +1822,6 @@ PQsetenv(PGconn *conn) flag = PQsetenvPoll(conn); } } - #endif /* NOT_USED */ @@ -1955,11 +1942,12 @@ freePGconn(PGconn *conn) static void closePGconn(PGconn *conn) { - /* Note that the protocol doesn't allow us to send Terminate - messages during the startup phase. */ + /* + * Note that the protocol doesn't allow us to send Terminate messages + * during the startup phase. + */ if (conn->sock >= 0 && conn->status == CONNECTION_OK) { - /* * Try to send "close connection" message to backend. Ignore any * error. Note: this routine used to go to substantial lengths to @@ -2298,7 +2286,6 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) { if (group_found) { - /* * Finally, we are in the right group and can parse * the line @@ -2507,7 +2494,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) if (option->keyword == NULL) { printfPQExpBuffer(errorMessage, - libpq_gettext("invalid connection option \"%s\"\n"), + libpq_gettext("invalid connection option \"%s\"\n"), pname); PQconninfoFree(options); free(buf); @@ -2758,14 +2745,13 @@ PQsetClientEncoding(PGconn *conn, const char *encoding) return (status); } -#else /* without multibytle support */ +#else /* without multibytle support */ int PQsetClientEncoding(PGconn *conn, const char *encoding) { return -1; } - #endif #ifdef USE_SSL @@ -2776,7 +2762,6 @@ PQgetssl(PGconn *conn) return NULL; return conn->ssl; } - #endif void diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 2741ec67aa..123d7abd12 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.112 2001/09/14 17:46:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.113 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,31 +67,33 @@ static int getNotice(PGconn *conn); */ size_t -PQescapeString (char *to, const char *from, size_t length) +PQescapeString(char *to, const char *from, size_t length) { const char *source = from; - char *target = to; + char *target = to; unsigned int remaining = length; - while (remaining > 0) { - switch (*source) { - case '\\': - *target = '\\'; - target++; - *target = '\\'; - /* target and remaining are updated below. */ - break; + while (remaining > 0) + { + switch (*source) + { + case '\\': + *target = '\\'; + target++; + *target = '\\'; + /* target and remaining are updated below. */ + break; - case '\'': - *target = '\''; - target++; - *target = '\''; - /* target and remaining are updated below. */ - break; + case '\'': + *target = '\''; + target++; + *target = '\''; + /* target and remaining are updated below. */ + break; - default: - *target = *source; - /* target and remaining are updated below. */ + default: + *target = *source; + /* target and remaining are updated below. */ } source++; target++; @@ -100,7 +102,7 @@ PQescapeString (char *to, const char *from, size_t length) /* Write the terminating NUL character. */ *target = '\0'; - + return target - to; } @@ -117,11 +119,11 @@ PQescapeString (char *to, const char *from, size_t length) unsigned char * PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen) { - unsigned char *vp; - unsigned char *rp; - unsigned char *result; - size_t i; - size_t len; + unsigned char *vp; + unsigned char *rp; + unsigned char *result; + size_t i; + size_t len; /* * empty string has 1 char ('\0') @@ -253,7 +255,7 @@ PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen) * and the Perl5 interface, so maybe it's not so unreasonable. */ -PGresult * +PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status) { PGresult *result; @@ -346,7 +348,7 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary) } /* If there's enough space in the current block, no problem. */ - if (nBytes <= (size_t)res->spaceLeft) + if (nBytes <= (size_t) res->spaceLeft) { space = res->curBlock->space + res->curOffset; res->curOffset += nBytes; @@ -369,7 +371,6 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary) space = block->space + PGRESULT_BLOCK_OVERHEAD; if (res->curBlock) { - /* * Tuck special block below the active block, so that we don't * have to waste the free space in the active block. @@ -515,7 +516,6 @@ pqClearAsyncResult(PGconn *conn) static void saveErrorResult(PGconn *conn) { - /* * If no old async result, just let PQmakeEmptyPGresult make one. * Likewise if old result is not an error message. @@ -558,7 +558,6 @@ prepareAsyncResult(PGconn *conn) res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); else { - /* * Make sure PQerrorMessage agrees with result; it could be * different if we have concatenated messages. @@ -580,7 +579,6 @@ addTuple(PGresult *res, PGresAttValue * tup) { if (res->ntups >= res->tupArrSize) { - /* * Try to grow the array. * @@ -632,7 +630,7 @@ PQsendQuery(PGconn *conn, const char *query) if (!query) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("command string is a null pointer\n")); + libpq_gettext("command string is a null pointer\n")); return 0; } @@ -647,7 +645,7 @@ PQsendQuery(PGconn *conn, const char *query) if (conn->asyncStatus != PGASYNC_IDLE) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("another command is already in progress\n")); + libpq_gettext("another command is already in progress\n")); return 0; } @@ -669,7 +667,6 @@ PQsendQuery(PGconn *conn, const char *query) */ if (pqIsnonblocking(conn)) { - /* * the buffer must have emptied completely before we allow a new * query to be buffered @@ -692,7 +689,6 @@ PQsendQuery(PGconn *conn, const char *query) } else { - /* * the frontend-backend protocol uses 'Q' to designate queries */ @@ -721,7 +717,6 @@ PQsendQuery(PGconn *conn, const char *query) static void handleSendFailure(PGconn *conn) { - /* * Accept any available input data, ignoring errors. Note that if * pqReadData decides the backend has closed the channel, it will @@ -757,7 +752,6 @@ PQconsumeInput(PGconn *conn) */ if (pqReadData(conn) < 0) { - /* * for non-blocking connections try to flush the send-queue * otherwise we may never get a responce for something that may @@ -789,7 +783,6 @@ parseInput(PGconn *conn) */ for (;;) { - /* * Quit if in COPY_OUT state: we expect raw data from the server * until PQendcopy is called. Don't try to parse it according to @@ -860,7 +853,6 @@ parseInput(PGconn *conn) } else { - /* * In BUSY state, we can process everything. */ @@ -929,7 +921,6 @@ parseInput(PGconn *conn) } else { - /* * A new 'T' message is treated as the start of * another PGresult. (It is not clear that this @@ -984,7 +975,7 @@ parseInput(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "unexpected response from server; first received character was \"%c\"\n"), + "unexpected response from server; first received character was \"%c\"\n"), id); /* build an error result holding the error message */ saveErrorResult(conn); @@ -1147,7 +1138,7 @@ getAnotherTuple(PGconn *conn, int binary) vlen = 0; if (tup[i].value == NULL) { - tup[i].value = (char *) pqResultAlloc(result, vlen + 1, (bool)binary); + tup[i].value = (char *) pqResultAlloc(result, vlen + 1, (bool) binary); if (tup[i].value == NULL) goto outOfMemory; } @@ -1228,7 +1219,7 @@ PQisBusy(PGconn *conn) * Returns NULL if and only if no query work remains. */ -PGresult * +PGresult * PQgetResult(PGconn *conn) { PGresult *res; @@ -1246,7 +1237,6 @@ PQgetResult(PGconn *conn) if (pqWait(TRUE, FALSE, conn) || pqReadData(conn) < 0) { - /* * conn->errorMessage has been set by pqWait or pqReadData. We * want to append it to any already-received error message. @@ -1278,7 +1268,7 @@ PQgetResult(PGconn *conn) break; default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unexpected asyncStatus: %d\n"), + libpq_gettext("unexpected asyncStatus: %d\n"), (int) conn->asyncStatus); res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); break; @@ -1300,7 +1290,7 @@ PQgetResult(PGconn *conn) * when done with it. */ -PGresult * +PGresult * PQexec(PGconn *conn, const char *query) { PGresult *result; @@ -1328,7 +1318,7 @@ PQexec(PGconn *conn, const char *query) { PQclear(result); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("COPY state must be terminated first\n")); + libpq_gettext("COPY state must be terminated first\n")); /* restore blocking status */ goto errout; } @@ -1445,7 +1435,7 @@ getNotify(PGconn *conn) * the CALLER is responsible for FREE'ing the structure returned */ -PGnotify * +PGnotify * PQnotifies(PGconn *conn) { Dlelem *e; @@ -1757,7 +1747,7 @@ PQendcopy(PGconn *conn) * ---------------- */ -PGresult * +PGresult * PQfn(PGconn *conn, int fnid, int *result_buf, @@ -1787,9 +1777,9 @@ PQfn(PGconn *conn, return NULL; } - if (pqPuts("F ", conn) != 0 || /* function */ - pqPutInt(fnid, 4, conn) != 0 || /* function id */ - pqPutInt(nargs, 4, conn) != 0) /* # of args */ + if (pqPuts("F ", conn) != 0 || /* function */ + pqPutInt(fnid, 4, conn) != 0 || /* function id */ + pqPutInt(nargs, 4, conn) != 0) /* # of args */ { handleSendFailure(conn); return NULL; @@ -1885,7 +1875,7 @@ PQfn(PGconn *conn, { /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("protocol error: id=0x%x\n"), + libpq_gettext("protocol error: id=0x%x\n"), id); saveErrorResult(conn); conn->inStart = conn->inCursor; @@ -1919,7 +1909,7 @@ PQfn(PGconn *conn, default: /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("protocol error: id=0x%x\n"), + libpq_gettext("protocol error: id=0x%x\n"), id); saveErrorResult(conn); conn->inStart = conn->inCursor; @@ -2007,7 +1997,7 @@ check_field_number(const PGresult *res, int field_num) if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("column number %d is out of range 0..%d\n"), + libpq_gettext("column number %d is out of range 0..%d\n"), field_num, res->numAttributes - 1); DONOTICE(res, noticeBuf); } @@ -2029,8 +2019,8 @@ check_tuple_field_number(const PGresult *res, if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("row number %d is out of range 0..%d\n"), - tup_num, res->ntups - 1); + libpq_gettext("row number %d is out of range 0..%d\n"), + tup_num, res->ntups - 1); DONOTICE(res, noticeBuf); } return FALSE; @@ -2040,8 +2030,8 @@ check_tuple_field_number(const PGresult *res, if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("column number %d is out of range 0..%d\n"), - field_num, res->numAttributes - 1); + libpq_gettext("column number %d is out of range 0..%d\n"), + field_num, res->numAttributes - 1); DONOTICE(res, noticeBuf); } return FALSE; @@ -2152,7 +2142,6 @@ PQcmdStatus(PGresult *res) char * PQoidStatus(const PGresult *res) { - /* * This must be enough to hold the result. Don't laugh, this is better * than what this function used to do. @@ -2188,7 +2177,7 @@ PQoidValue(const PGresult *res) return InvalidOid; #ifdef WIN32 - SetLastError(0); + SetLastError(0); #else errno = 0; #endif @@ -2225,8 +2214,8 @@ PQcmdTuples(PGresult *res) if (res->noticeHook) { snprintf(noticeBuf, sizeof(noticeBuf), - libpq_gettext("could not interpret result from server: %s\n"), - res->cmdStatus); + libpq_gettext("could not interpret result from server: %s\n"), + res->cmdStatus); DONOTICE(res, noticeBuf); } return ""; diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 7be372d6a3..99a1724bc1 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.39 2001/09/17 20:05:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.40 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -397,7 +397,7 @@ lo_import(PGconn *conn, const char *filename) if (fd < 0) { /* error */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open file \"%s\": %s\n"), + libpq_gettext("could not open file \"%s\": %s\n"), filename, strerror(errno)); return InvalidOid; } @@ -409,7 +409,7 @@ lo_import(PGconn *conn, const char *filename) if (lobjOid == InvalidOid) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create large object for file \"%s\"\n"), + libpq_gettext("could not create large object for file \"%s\"\n"), filename); (void) close(fd); return InvalidOid; @@ -419,7 +419,7 @@ lo_import(PGconn *conn, const char *filename) if (lobj == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open large object %u\n"), + libpq_gettext("could not open large object %u\n"), lobjOid); (void) close(fd); return InvalidOid; @@ -434,7 +434,7 @@ lo_import(PGconn *conn, const char *filename) if (tmp < nbytes) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("error while reading file \"%s\"\n"), + libpq_gettext("error while reading file \"%s\"\n"), filename); (void) close(fd); (void) lo_close(conn, lobj); @@ -469,7 +469,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (lobj == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open large object %u\n"), lobjId); + libpq_gettext("could not open large object %u\n"), lobjId); return -1; } @@ -480,7 +480,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (fd < 0) { /* error */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open file \"%s\": %s\n"), + libpq_gettext("could not open file \"%s\": %s\n"), filename, strerror(errno)); (void) lo_close(conn, lobj); return -1; @@ -495,7 +495,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (tmp < nbytes) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("error while writing to file \"%s\"\n"), + libpq_gettext("error while writing to file \"%s\"\n"), filename); (void) lo_close(conn, lobj); (void) close(fd); @@ -599,56 +599,56 @@ lo_initialize(PGconn *conn) if (lobjfuncs->fn_lo_open == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_open\n")); + libpq_gettext("cannot determine OID of function lo_open\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_close == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_close\n")); + libpq_gettext("cannot determine OID of function lo_close\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_creat == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_creat\n")); + libpq_gettext("cannot determine OID of function lo_creat\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_unlink == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_unlink\n")); + libpq_gettext("cannot determine OID of function lo_unlink\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_lseek == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_lseek\n")); + libpq_gettext("cannot determine OID of function lo_lseek\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_tell == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_tell\n")); + libpq_gettext("cannot determine OID of function lo_tell\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_read == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function loread\n")); + libpq_gettext("cannot determine OID of function loread\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_write == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lowrite\n")); + libpq_gettext("cannot determine OID of function lowrite\n")); free(lobjfuncs); return -1; } diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index cb7684e88f..2a75ce43d7 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -25,7 +25,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.57 2001/09/30 16:23:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.58 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,16 +59,16 @@ #define DONOTICE(conn,message) \ ((*(conn)->noticeHook) ((conn)->noticeArg, (message))) -static int pqPutBytes(const char *s, size_t nbytes, PGconn *conn); +static int pqPutBytes(const char *s, size_t nbytes, PGconn *conn); /* * pqGetc: - * get a character from the connection + * get a character from the connection * - * All these routines return 0 on success, EOF on error. - * Note that for the Get routines, EOF only means there is not enough - * data in the buffer, not that there is necessarily a hard error. + * All these routines return 0 on success, EOF on error. + * Note that for the Get routines, EOF only means there is not enough + * data in the buffer, not that there is necessarily a hard error. */ int pqGetc(char *result, PGconn *conn) @@ -116,7 +116,6 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn) */ if (pqIsnonblocking(conn) && nbytes > avail && pqFlush(conn)) { - /* * even if the flush failed we may still have written some data, * recalculate the size of the send-queue relative to the amount @@ -129,7 +128,7 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not flush enough data (space available: %d, space needed %d)\n"), - Max(conn->outBufSize - conn->outCount, 0), nbytes); + Max(conn->outBufSize - conn->outCount, 0), nbytes); return EOF; } /* fixup avail for while loop */ @@ -211,7 +210,7 @@ pqPuts(const char *s, PGconn *conn) /* * pqGetnchar: - * get a string of exactly len bytes in buffer s, no null termination + * get a string of exactly len bytes in buffer s, no null termination */ int pqGetnchar(char *s, size_t len, PGconn *conn) @@ -232,7 +231,7 @@ pqGetnchar(char *s, size_t len, PGconn *conn) /* * pqPutnchar: - * send a string of exactly len bytes, no null termination needed + * send a string of exactly len bytes, no null termination needed */ int pqPutnchar(const char *s, size_t len, PGconn *conn) @@ -248,8 +247,8 @@ pqPutnchar(const char *s, size_t len, PGconn *conn) /* * pgGetInt - * read a 2 or 4 byte integer and convert from network byte order - * to local byte order + * read a 2 or 4 byte integer and convert from network byte order + * to local byte order */ int pqGetInt(int *result, size_t bytes, PGconn *conn) @@ -484,7 +483,7 @@ tryAgain: goto definitelyFailed; #endif printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not receive data from server: %s\n"), + libpq_gettext("could not receive data from server: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return -1; } @@ -570,7 +569,7 @@ tryAgain2: goto definitelyFailed; #endif printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not receive data from server: %s\n"), + libpq_gettext("could not receive data from server: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); return -1; } @@ -587,9 +586,9 @@ tryAgain2: definitelyFailed: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request.\n")); conn->status = CONNECTION_BAD; /* No more connection to backend */ #ifdef WIN32 closesocket(conn->sock); @@ -647,7 +646,6 @@ pqFlush(PGconn *conn) if (sent < 0) { - /* * Anything except EAGAIN or EWOULDBLOCK is trouble. If it's * EPIPE or ECONNRESET, assume we've lost the backend @@ -672,9 +670,9 @@ pqFlush(PGconn *conn) #endif printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request.\n")); /* * We used to close the socket here, but that's a bad @@ -688,7 +686,7 @@ pqFlush(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send data to server: %s\n"), + libpq_gettext("could not send data to server: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); /* We don't assume it's a fatal error... */ return EOF; @@ -832,7 +830,6 @@ PQenv2encoding(void) { return 0; } - #endif /* MULTIBYTE */ @@ -840,7 +837,7 @@ PQenv2encoding(void) char * libpq_gettext(const char *msgid) { - static int already_bound = 0; + static int already_bound = 0; if (!already_bound) { @@ -850,7 +847,7 @@ libpq_gettext(const char *msgid) return dgettext("libpq", msgid); } -#endif /* ENABLE_NLS */ +#endif /* ENABLE_NLS */ #ifdef WIN32 /* @@ -860,41 +857,41 @@ libpq_gettext(const char *msgid) * If you can verify this working on win9x or have a solution, let us know, ok? * */ -const char* +const char * winsock_strerror(DWORD eno) { - #define WSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12) /* 12 == "(0x00000000)" */ - int length; +#define WSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12) /* 12 == "(0x00000000)" */ + int length; + + /* First try the "system table", this works on Win2k pro */ - /* First try the "system table", this works on Win2k pro */ + if (FormatMessage( + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + 0, eno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + winsock_strerror_buf, WSSE_MAXLEN, NULL + )) + goto WSSE_GOODEXIT; - if (FormatMessage( - FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM, - 0,eno,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - winsock_strerror_buf,WSSE_MAXLEN,NULL - )) - goto WSSE_GOODEXIT; + /* That didn't work, let's try the netmsg.dll */ - /* That didn't work, let's try the netmsg.dll */ + if (netmsgModule && + FormatMessage( + FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE, + 0, eno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + winsock_strerror_buf, WSSE_MAXLEN, NULL + )) + goto WSSE_GOODEXIT; - if (netmsgModule && - FormatMessage( - FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE, - 0,eno,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - winsock_strerror_buf,WSSE_MAXLEN,NULL - )) - goto WSSE_GOODEXIT; + /* Everything failed, just tell the user that we don't know the desc */ - /* Everything failed, just tell the user that we don't know the desc */ - - strcat(winsock_strerror_buf,"Socket error, no description available."); + strcat(winsock_strerror_buf, "Socket error, no description available."); WSSE_GOODEXIT: - length = strlen(winsock_strerror_buf); - sprintf(winsock_strerror_buf + (length<WSSE_MAXLEN?length:WSSE_MAXLEN), - "(0x%08X)",eno); + length = strlen(winsock_strerror_buf); + sprintf(winsock_strerror_buf + (length < WSSE_MAXLEN ? length : WSSE_MAXLEN), + "(0x%08X)", eno); - return winsock_strerror_buf; + return winsock_strerror_buf; } #endif diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index f581260de0..e753e5dd52 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -10,7 +10,7 @@ * didn't really belong there. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.42 2001/03/22 04:01:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.43 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -102,7 +102,6 @@ PQprint(FILE *fout, int ws_row; int ws_col; } screen_size; - #endif nTups = PQntuples(res); @@ -152,7 +151,6 @@ PQprint(FILE *fout, #endif ) { - /* * If we think there'll be more than one screen of output, try * to pipe to the pager program. diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 02448ef843..de8fa5636e 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fe.h,v 1.75 2001/09/14 17:46:40 momjian Exp $ + * $Id: libpq-fe.h,v 1.76 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,11 +23,11 @@ extern "C" #include <stdio.h> #ifdef WIN32 - #define SOCK_ERRNO (WSAGetLastError ()) - #define SOCK_STRERROR winsock_strerror +#define SOCK_ERRNO (WSAGetLastError ()) +#define SOCK_STRERROR winsock_strerror #else - #define SOCK_ERRNO errno - #define SOCK_STRERROR strerror +#define SOCK_ERRNO errno +#define SOCK_STRERROR strerror #endif @@ -44,7 +44,6 @@ extern "C" typedef enum { - /* * Although you may decide to change this list in some way, values * which become unused should never be removed, nor should @@ -252,13 +251,13 @@ extern "C" /* === in fe-exec.c === */ /* Quoting strings before inclusion in queries. */ - extern size_t PQescapeString (char *to, const char *from, size_t length); + extern size_t PQescapeString(char *to, const char *from, size_t length); extern unsigned char *PQescapeBytea(unsigned char *bintext, size_t binlen, size_t *bytealen); /* Simple synchronous query */ extern PGresult *PQexec(PGconn *conn, const char *query); extern PGnotify *PQnotifies(PGconn *conn); - extern void PQfreeNotify(PGnotify *notify); + extern void PQfreeNotify(PGnotify *notify); /* Interface for multiple-result or asynchronous queries */ extern int PQsendQuery(PGconn *conn, const char *query); @@ -374,7 +373,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif /* LIBPQ_FE_H */ diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index 6b088e94d7..26acd3ed83 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-int.h,v 1.40 2001/10/03 21:58:28 tgl Exp $ + * $Id: libpq-int.h,v 1.41 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -139,7 +139,7 @@ struct pg_result */ PQnoticeProcessor noticeHook; /* notice/error message processor */ void *noticeArg; - int client_encoding;/* encoding id */ + int client_encoding; /* encoding id */ char *errMsg; /* error message, or NULL if no error */ @@ -160,22 +160,26 @@ struct pg_result /* PGAsyncStatusType defines the state of the query-execution state machine */ typedef enum { - PGASYNC_IDLE, /* nothing's happening, dude */ - PGASYNC_BUSY, /* query in progress */ - PGASYNC_READY, /* result ready for PQgetResult */ - PGASYNC_COPY_IN, /* Copy In data transfer in progress */ - PGASYNC_COPY_OUT /* Copy Out data transfer in progress */ + PGASYNC_IDLE, /* nothing's happening, dude */ + PGASYNC_BUSY, /* query in progress */ + PGASYNC_READY, /* result ready for PQgetResult */ + PGASYNC_COPY_IN,/* Copy In data transfer in progress */ + PGASYNC_COPY_OUT/* Copy Out data transfer in progress */ } PGAsyncStatusType; /* PGSetenvStatusType defines the state of the PQSetenv state machine */ typedef enum { - SETENV_STATE_OPTION_SEND, /* About to send an Environment Option */ - SETENV_STATE_OPTION_WAIT, /* Waiting for above send to complete */ + SETENV_STATE_OPTION_SEND, /* About to send an + * Environment Option */ + SETENV_STATE_OPTION_WAIT, /* Waiting for above send + * to complete */ /* these next two are only used in MULTIBYTE mode */ - SETENV_STATE_ENCODINGS_SEND,/* About to send an "encodings" query */ - SETENV_STATE_ENCODINGS_WAIT,/* Waiting for query to complete */ - SETENV_STATE_IDLE + SETENV_STATE_ENCODINGS_SEND, /* About to send an + * "encodings" query */ + SETENV_STATE_ENCODINGS_WAIT, /* Waiting for query to + * complete */ + SETENV_STATE_IDLE } PGSetenvStatusType; /* large-object-access data ... allocated only if large-object code is used. */ @@ -236,8 +240,8 @@ struct pg_conn /* Miscellaneous stuff */ int be_pid; /* PID of backend --- needed for cancels */ int be_key; /* key of backend --- needed for cancels */ - char md5Salt[4]; /* password salt received from backend */ - char cryptSalt[2]; /* password salt received from backend */ + char md5Salt[4]; /* password salt received from backend */ + char cryptSalt[2]; /* password salt received from backend */ PGlobjfuncs *lobjfuncs; /* private state for large-object access * fns */ @@ -278,7 +282,7 @@ struct pg_conn /* Buffer for receiving various parts of messages */ PQExpBufferData workBuffer; /* expansible string */ - int client_encoding;/* encoding id */ + int client_encoding; /* encoding id */ }; /* String descriptions of the ExecStatusTypes. @@ -345,10 +349,11 @@ extern int pqWriteReady(PGconn *conn); #define pqIsnonblocking(conn) ((conn)->nonblocking) #ifdef ENABLE_NLS -extern char * libpq_gettext(const char *msgid) +extern char * +libpq_gettext(const char *msgid) __attribute__((format_arg(1))); + #else #define libpq_gettext(x) (x) #endif - #endif /* LIBPQ_INT_H */ diff --git a/src/interfaces/libpq/libpqdll.c b/src/interfaces/libpq/libpqdll.c index 1e7d647937..9f9c93d2f9 100644 --- a/src/interfaces/libpq/libpqdll.c +++ b/src/interfaces/libpq/libpqdll.c @@ -14,19 +14,17 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, case DLL_PROCESS_ATTACH: if (WSAStartup(MAKEWORD(1, 1), &wsaData)) { - /* * No really good way to do error handling here, since we * don't know how we were loaded */ return FALSE; } - if (netmsgModule == NULL){ - netmsgModule=LoadLibraryEx("netmsg.dll",NULL,LOAD_LIBRARY_AS_DATAFILE); - } + if (netmsgModule == NULL) + netmsgModule = LoadLibraryEx("netmsg.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); break; case DLL_PROCESS_DETACH: - if (netmsgModule != NULL) + if (netmsgModule != NULL) FreeLibrary(netmsgModule); WSACleanup(); break; diff --git a/src/interfaces/libpq/pqexpbuffer.c b/src/interfaces/libpq/pqexpbuffer.c index 06471ee939..cf565eb9a3 100644 --- a/src/interfaces/libpq/pqexpbuffer.c +++ b/src/interfaces/libpq/pqexpbuffer.c @@ -17,7 +17,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.11 2001/08/17 15:11:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.12 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -174,7 +174,6 @@ printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) for (;;) { - /* * Try to format the given string into the available space; but if * there's hardly any space, don't bother trying, just fall @@ -223,7 +222,6 @@ appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) for (;;) { - /* * Try to format the given string into the available space; but if * there's hardly any space, don't bother trying, just fall diff --git a/src/interfaces/libpq/pqexpbuffer.h b/src/interfaces/libpq/pqexpbuffer.h index 0db0806595..9e17b314f7 100644 --- a/src/interfaces/libpq/pqexpbuffer.h +++ b/src/interfaces/libpq/pqexpbuffer.h @@ -18,7 +18,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqexpbuffer.h,v 1.7 2001/10/03 21:58:28 tgl Exp $ + * $Id: pqexpbuffer.h,v 1.8 2001/10/25 05:50:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -122,7 +122,8 @@ extern int enlargePQExpBuffer(PQExpBuffer str, size_t needed); * This is a convenience routine that does the same thing as * resetPQExpBuffer() followed by appendPQExpBuffer(). */ -extern void printfPQExpBuffer(PQExpBuffer str, const char *fmt, ...) +extern void +printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); @@ -133,7 +134,8 @@ __attribute__((format(printf, 2, 3))); * to str if necessary. This is sort of like a combination of sprintf and * strcat. */ -extern void appendPQExpBuffer(PQExpBuffer str, const char *fmt, ...) +extern void +appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); @@ -158,5 +160,4 @@ extern void appendPQExpBufferChar(PQExpBuffer str, char ch); */ extern void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen); - #endif /* PQEXPBUFFER_H */ diff --git a/src/interfaces/libpq/pqsignal.h b/src/interfaces/libpq/pqsignal.h index 3444bfb70e..b6b167c188 100644 --- a/src/interfaces/libpq/pqsignal.h +++ b/src/interfaces/libpq/pqsignal.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqsignal.h,v 1.10 2001/02/10 02:31:30 tgl Exp $ + * $Id: pqsignal.h,v 1.11 2001/10/25 05:50:13 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -23,5 +23,4 @@ typedef void (*pqsigfunc) (int); extern pqsigfunc pqsignal(int signo, pqsigfunc func); - #endif /* PQSIGNAL_H */ diff --git a/src/interfaces/libpq/win32.h b/src/interfaces/libpq/win32.h index 2ba2d842a6..ac6a0ea388 100644 --- a/src/interfaces/libpq/win32.h +++ b/src/interfaces/libpq/win32.h @@ -23,7 +23,7 @@ */ #define crypt(a,b) (a) -#undef EAGAIN /* doesn't apply on sockets */ +#undef EAGAIN /* doesn't apply on sockets */ #undef EINTR #define EINTR WSAEINTR #define EWOULDBLOCK WSAEWOULDBLOCK @@ -36,4 +36,4 @@ static HINSTANCE netmsgModule = NULL; static char winsock_strerror_buf[512]; -const char* winsock_strerror(DWORD eno); +const char *winsock_strerror(DWORD eno); diff --git a/src/interfaces/odbc/bind.c b/src/interfaces/odbc/bind.c index 062632df48..4bd2c0ce08 100644 --- a/src/interfaces/odbc/bind.c +++ b/src/interfaces/odbc/bind.c @@ -26,18 +26,18 @@ /* Bind parameters on a statement handle */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_BindParameter( - HSTMT hstmt, - UWORD ipar, - SWORD fParamType, - SWORD fCType, - SWORD fSqlType, - UDWORD cbColDef, - SWORD ibScale, - PTR rgbValue, - SDWORD cbValueMax, - SDWORD FAR *pcbValue) + HSTMT hstmt, + UWORD ipar, + SWORD fParamType, + SWORD fCType, + SWORD fSqlType, + UDWORD cbColDef, + SWORD ibScale, + PTR rgbValue, + SDWORD cbValueMax, + SDWORD FAR * pcbValue) { StatementClass *stmt = (StatementClass *) hstmt; static char *func = "PGAPI_BindParameter"; @@ -152,14 +152,14 @@ PGAPI_BindParameter( /* Associate a user-supplied buffer with a database column. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_BindCol( - HSTMT hstmt, - UWORD icol, - SWORD fCType, - PTR rgbValue, - SDWORD cbValueMax, - SDWORD FAR *pcbValue) + HSTMT hstmt, + UWORD icol, + SWORD fCType, + PTR rgbValue, + SDWORD cbValueMax, + SDWORD FAR * pcbValue) { StatementClass *stmt = (StatementClass *) hstmt; static char *func = "PGAPI_BindCol"; @@ -167,7 +167,7 @@ PGAPI_BindCol( mylog("%s: entering...\n", func); mylog("**** PGAPI_BindCol: stmt = %u, icol = %d\n", stmt, icol); -mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueMax, pcbValue); + mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueMax, pcbValue); if (!stmt) { @@ -265,14 +265,14 @@ mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueM * 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 PGAPI_DescribeParam( - HSTMT hstmt, - UWORD ipar, - SWORD FAR *pfSqlType, - UDWORD FAR *pcbColDef, - SWORD FAR *pibScale, - SWORD FAR *pfNullable) + HSTMT hstmt, + UWORD ipar, + SWORD FAR * pfSqlType, + UDWORD FAR * pcbColDef, + SWORD FAR * pibScale, + SWORD FAR * pfNullable) { StatementClass *stmt = (StatementClass *) hstmt; static char *func = "PGAPI_DescribeParam"; @@ -318,18 +318,19 @@ PGAPI_DescribeParam( /* Sets multiple values (arrays) for the set of parameter markers. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ParamOptions( - HSTMT hstmt, - UDWORD crow, - UDWORD FAR *pirow) + HSTMT hstmt, + UDWORD crow, + UDWORD FAR * pirow) { static char *func = "PGAPI_ParamOptions"; - StatementClass *stmt = (StatementClass *) hstmt; + StatementClass *stmt = (StatementClass *) hstmt; mylog("%s: entering... %d %x\n", func, crow, pirow); - if (crow == 1) /* temporary solution and must be rewritten later */ + if (crow == 1) /* temporary solution and must be + * rewritten later */ { if (pirow) *pirow = 1; @@ -351,10 +352,10 @@ PGAPI_ParamOptions( * to call it anyway. * If the statement does not have parameters, it should just return 0. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_NumParams( - HSTMT hstmt, - SWORD FAR *pcpar) + HSTMT hstmt, + SWORD FAR * pcpar) { StatementClass *stmt = (StatementClass *) hstmt; char in_quote = FALSE; @@ -430,7 +431,7 @@ create_empty_bindings(int num_columns) void -extend_bindings(StatementClass *stmt, int num_columns) +extend_bindings(StatementClass * stmt, int num_columns) { static char *func = "extend_bindings"; BindInfoClass *new_bindings; diff --git a/src/interfaces/odbc/bind.h b/src/interfaces/odbc/bind.h index 444d30f2d2..a792c38951 100644 --- a/src/interfaces/odbc/bind.h +++ b/src/interfaces/odbc/bind.h @@ -48,6 +48,5 @@ struct ParameterInfoClass_ }; BindInfoClass *create_empty_bindings(int num_columns); -void extend_bindings(StatementClass *stmt, int num_columns); - +void extend_bindings(StatementClass * stmt, int num_columns); #endif diff --git a/src/interfaces/odbc/columninfo.c b/src/interfaces/odbc/columninfo.c index d9a22a163a..d05de1ffb7 100644 --- a/src/interfaces/odbc/columninfo.c +++ b/src/interfaces/odbc/columninfo.c @@ -42,7 +42,7 @@ CI_Constructor() void -CI_Destructor(ColumnInfoClass *self) +CI_Destructor(ColumnInfoClass * self) { CI_free_memory(self); @@ -56,7 +56,7 @@ CI_Destructor(ColumnInfoClass *self) * If self is null, then just read, don't store. */ char -CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn) +CI_read_fields(ColumnInfoClass * self, ConnectionClass * conn) { Int2 lf; int new_num_fields; @@ -112,7 +112,7 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn) void -CI_free_memory(ColumnInfoClass *self) +CI_free_memory(ColumnInfoClass * self) { register Int2 lf; int num_fields = self->num_fields; @@ -148,7 +148,7 @@ CI_free_memory(ColumnInfoClass *self) void -CI_set_num_fields(ColumnInfoClass *self, int new_num_fields) +CI_set_num_fields(ColumnInfoClass * self, int new_num_fields) { CI_free_memory(self); /* always safe to call */ @@ -164,7 +164,7 @@ CI_set_num_fields(ColumnInfoClass *self, int new_num_fields) 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) { /* check bounds */ diff --git a/src/interfaces/odbc/columninfo.h b/src/interfaces/odbc/columninfo.h index 41e9400dce..1c805cc977 100644 --- a/src/interfaces/odbc/columninfo.h +++ b/src/interfaces/odbc/columninfo.h @@ -29,14 +29,13 @@ struct ColumnInfoClass_ #define CI_get_atttypmod(self, col) (self->atttypmod[col]) ColumnInfoClass *CI_Constructor(void); -void CI_Destructor(ColumnInfoClass *self); -void CI_free_memory(ColumnInfoClass *self); -char CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn); +void CI_Destructor(ColumnInfoClass * self); +void CI_free_memory(ColumnInfoClass * self); +char CI_read_fields(ColumnInfoClass * self, ConnectionClass * conn); /* functions for setting up the fields from within the program, */ /* without reading from a socket */ -void CI_set_num_fields(ColumnInfoClass *self, int new_num_fields); -void CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name, +void CI_set_num_fields(ColumnInfoClass * self, int new_num_fields); +void CI_set_field_info(ColumnInfoClass * self, int field_num, char *new_name, Oid new_adtid, Int2 new_adtsize, Int4 atttypmod); - #endif diff --git a/src/interfaces/odbc/connection.c b/src/interfaces/odbc/connection.c index 70c7b78230..408bef8f80 100644 --- a/src/interfaces/odbc/connection.c +++ b/src/interfaces/odbc/connection.c @@ -41,10 +41,10 @@ extern GLOBAL_VALUES globals; -RETCODE SQL_API +RETCODE SQL_API PGAPI_AllocConnect( - HENV henv, - HDBC FAR *phdbc) + HENV henv, + HDBC FAR * phdbc) { EnvironmentClass *env = (EnvironmentClass *) henv; ConnectionClass *conn; @@ -80,15 +80,15 @@ PGAPI_AllocConnect( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Connect( - HDBC hdbc, - UCHAR FAR *szDSN, - SWORD cbDSN, - UCHAR FAR *szUID, - SWORD cbUID, - UCHAR FAR *szAuthStr, - SWORD cbAuthStr) + HDBC hdbc, + UCHAR FAR * szDSN, + SWORD cbDSN, + UCHAR FAR * szUID, + SWORD cbUID, + UCHAR FAR * szAuthStr, + SWORD cbAuthStr) { ConnectionClass *conn = (ConnectionClass *) hdbc; ConnInfo *ci; @@ -137,14 +137,14 @@ PGAPI_Connect( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_BrowseConnect( - HDBC hdbc, - UCHAR FAR *szConnStrIn, - SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, - SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut) + HDBC hdbc, + UCHAR FAR * szConnStrIn, + SWORD cbConnStrIn, + UCHAR FAR * szConnStrOut, + SWORD cbConnStrOutMax, + SWORD FAR * pcbConnStrOut) { static char *func = "PGAPI_BrowseConnect"; @@ -155,9 +155,9 @@ PGAPI_BrowseConnect( /* Drop any hstmts open on hdbc and disconnect from database */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Disconnect( - HDBC hdbc) + HDBC hdbc) { ConnectionClass *conn = (ConnectionClass *) hdbc; static char *func = "PGAPI_Disconnect"; @@ -194,9 +194,9 @@ PGAPI_Disconnect( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_FreeConnect( - HDBC hdbc) + HDBC hdbc) { ConnectionClass *conn = (ConnectionClass *) hdbc; static char *func = "PGAPI_FreeConnect"; @@ -251,7 +251,7 @@ CC_Constructor() memset(&rv->connInfo, 0, sizeof(ConnInfo)); #ifdef DRIVER_CURSOR_IMPLEMENT rv->connInfo.updatable_cursors = 1; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ memcpy(&(rv->connInfo.drivers), &globals, sizeof(globals)); rv->sock = SOCK_Constructor(rv); if (!rv->sock) @@ -282,7 +282,7 @@ CC_Constructor() #ifdef MULTIBYTE rv->client_encoding = NULL; rv->server_encoding = NULL; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* Initialize statement options to defaults */ @@ -297,7 +297,7 @@ CC_Constructor() char -CC_Destructor(ConnectionClass *self) +CC_Destructor(ConnectionClass * self) { mylog("enter CC_Destructor, self=%u\n", self); @@ -313,7 +313,7 @@ CC_Destructor(ConnectionClass *self) free(self->client_encoding); if (self->server_encoding) free(self->server_encoding); -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* Free up statement holders */ if (self->stmts) { @@ -349,7 +349,7 @@ CC_Destructor(ConnectionClass *self) /* Return how many cursors are opened on this connection */ int -CC_cursor_count(ConnectionClass *self) +CC_cursor_count(ConnectionClass * self) { StatementClass *stmt; int i, @@ -371,7 +371,7 @@ CC_cursor_count(ConnectionClass *self) void -CC_clear_error(ConnectionClass *self) +CC_clear_error(ConnectionClass * self) { self->errornumber = 0; self->errormsg = NULL; @@ -384,7 +384,7 @@ CC_clear_error(ConnectionClass *self) * We are almost always in the middle of a transaction. */ char -CC_abort(ConnectionClass *self) +CC_abort(ConnectionClass * self) { QResultClass *res; @@ -410,7 +410,7 @@ CC_abort(ConnectionClass *self) /* This is called by SQLDisconnect also */ char -CC_cleanup(ConnectionClass *self) +CC_cleanup(ConnectionClass * self) { int i; StatementClass *stmt; @@ -466,7 +466,7 @@ CC_cleanup(ConnectionClass *self) int -CC_set_translation(ConnectionClass *self) +CC_set_translation(ConnectionClass * self) { #ifdef WIN32 @@ -510,7 +510,7 @@ CC_set_translation(ConnectionClass *self) char -CC_connect(ConnectionClass *self, char do_password) +CC_connect(ConnectionClass * self, char do_password) { StartupPacket sp; StartupPacket6_2 sp62; @@ -522,9 +522,10 @@ CC_connect(ConnectionClass *self, char do_password) char msgbuffer[ERROR_MSG_LENGTH]; char salt[5]; static char *func = "CC_connect"; + #ifdef MULTIBYTE - char *encoding; -#endif /* MULTIBYTE */ + char *encoding; +#endif /* MULTIBYTE */ mylog("%s: entering...\n", func); @@ -556,7 +557,7 @@ CC_connect(ConnectionClass *self, char do_password) if (encoding && strcmp(encoding, "OTHER")) self->client_encoding = strdup(encoding); else - { + { encoding = check_client_encoding(ci->drivers.conn_settings); if (encoding && strcmp(encoding, "OTHER")) self->client_encoding = strdup(encoding); @@ -588,6 +589,7 @@ CC_connect(ConnectionClass *self, char do_password) mylog("CC_connect(): DSN = '%s', server = '%s', port = '%s', database = '%s', username = '%s', password='%s'\n", ci->dsn, ci->server, ci->port, ci->database, ci->username, ci->password); another_version_retry: + /* * If the socket was closed for some reason (like a SQLDisconnect, * but no SQLFreeConnect then create a socket now. @@ -673,7 +675,9 @@ another_version_retry: if (!PROTOCOL_62(ci)) { - BOOL before_64 = PG_VERSION_LT(self, 6.4), ReadyForQuery = FALSE; + BOOL before_64 = PG_VERSION_LT(self, 6.4), + ReadyForQuery = FALSE; + do { if (do_password) @@ -693,7 +697,7 @@ another_version_retry: self->errormsg = msgbuffer; qlog("ERROR from backend during authentication: '%s'\n", self->errormsg); if (strncmp(msgbuffer, "Unsupported frontend protocol", 29) == 0) - { /* retry older version */ + { /* retry older version */ if (PROTOCOL_63(ci)) strcpy(ci->protocol, PG62); else @@ -703,7 +707,7 @@ another_version_retry: CC_initialize_pg_version(self); goto another_version_retry; } - + return 0; case 'R': @@ -775,12 +779,12 @@ another_version_retry: return 0; } break; - case 'K': /* Secret key (6.4 protocol) */ - (void) SOCK_get_int(sock, 4); /* pid */ - (void) SOCK_get_int(sock, 4); /* key */ + case 'K': /* Secret key (6.4 protocol) */ + (void) SOCK_get_int(sock, 4); /* pid */ + (void) SOCK_get_int(sock, 4); /* key */ break; - case 'Z': /* Backend is ready for new query (6.4) */ + case 'Z': /* Backend is ready for new query (6.4) */ ReadyForQuery = TRUE; break; default: @@ -789,9 +793,8 @@ another_version_retry: return 0; } - /* - * There were no ReadyForQuery responce - * before 6.4. + /* + * There were no ReadyForQuery responce before 6.4. */ if (before_64 && areq == AUTH_REQ_OK) ReadyForQuery = TRUE; @@ -851,7 +854,7 @@ another_version_retry: char -CC_add_statement(ConnectionClass *self, StatementClass *stmt) +CC_add_statement(ConnectionClass * self, StatementClass * stmt) { int i; @@ -884,7 +887,7 @@ CC_add_statement(ConnectionClass *self, StatementClass *stmt) char -CC_remove_statement(ConnectionClass *self, StatementClass *stmt) +CC_remove_statement(ConnectionClass * self, StatementClass * stmt) { int i; @@ -906,7 +909,7 @@ CC_remove_statement(ConnectionClass *self, StatementClass *stmt) * error message with its socket error message. */ char * -CC_create_errormsg(ConnectionClass *self) +CC_create_errormsg(ConnectionClass * self) { SocketClass *sock = self->sock; int pos; @@ -933,7 +936,7 @@ CC_create_errormsg(ConnectionClass *self) char -CC_get_error(ConnectionClass *self, int *number, char **message) +CC_get_error(ConnectionClass * self, int *number, char **message) { int rv; @@ -971,16 +974,22 @@ CC_get_error(ConnectionClass *self, int *number, char **message) * 'declare cursor C3326857 for ...' and 'fetch 100 in C3326857' statements. */ QResultClass * -CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) +CC_send_query(ConnectionClass * self, char *query, QueryInfo * qi) { - QResultClass *result_in = NULL, *res = NULL, *retres = NULL; - char swallow, *wq; + QResultClass *result_in = NULL, + *res = NULL, + *retres = NULL; + char swallow, + *wq; int id; SocketClass *sock = self->sock; - int maxlen, empty_reqs; - BOOL msg_truncated, ReadyToReturn, - tuples_return = FALSE, query_completed = FALSE, - before_64 = PG_VERSION_LT(self, 6.4); + int maxlen, + empty_reqs; + BOOL msg_truncated, + ReadyToReturn, + tuples_return = FALSE, + query_completed = FALSE, + before_64 = PG_VERSION_LT(self, 6.4); /* ERROR_MSG_LENGTH is suffcient */ static char msgbuffer[ERROR_MSG_LENGTH + 1]; @@ -1095,6 +1104,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) mylog("send_query: returning res = %u\n", res); if (!before_64) break; + /* * (Quotation from the original comments) since * backend may produce more than one result for some @@ -1188,9 +1198,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) CC_set_no_trans(self); } else - { self->errornumber = CONNECTION_SERVER_REPORTED_WARNING; - } QR_set_status(res, PGRES_FATAL_ERROR); QR_set_aborted(res, TRUE); while (msg_truncated) @@ -1232,9 +1240,10 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) } else { /* next fetch, so reuse an existing result */ + /* - * called from QR_next_tuple - * and must return immediately. + * called from QR_next_tuple and must return + * immediately. */ ReadyToReturn = TRUE; if (!QR_fetch_tuples(result_in, NULL, NULL)) @@ -1275,8 +1284,9 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) retres = NULL; break; } + /* - * There were no ReadyForQuery response before 6.4. + * There were no ReadyForQuery response before 6.4. */ if (before_64) { @@ -1284,8 +1294,9 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) break; } } - /* - * Break before being ready to return. + + /* + * Break before being ready to return. */ if (!ReadyToReturn) { @@ -1296,8 +1307,9 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) else retres = res; } + /* - * set notice message to result_in. + * set notice message to result_in. */ if (result_in && res && retres == result_in) { @@ -1305,8 +1317,9 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) QR_set_status(result_in, QR_get_status(res)); QR_set_notice(result_in, QR_get_notice(res)); } + /* - * Cleanup garbage results before returning. + * Cleanup garbage results before returning. */ if (res && retres != res) QR_Destructor(res); @@ -1322,7 +1335,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) int -CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *args, int nargs) +CC_send_function(ConnectionClass * self, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG * args, int nargs) { char id, c, @@ -1474,7 +1487,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_ char -CC_send_settings(ConnectionClass *self) +CC_send_settings(ConnectionClass * self) { /* char ini_query[MAX_MESSAGE_LEN]; */ ConnInfo *ci = &(self->connInfo); @@ -1583,7 +1596,7 @@ CC_send_settings(ConnectionClass *self) * will go away and the define 'PG_TYPE_LO' will be updated. */ void -CC_lookup_lo(ConnectionClass *self) +CC_lookup_lo(ConnectionClass * self) { HSTMT hstmt; StatementClass *stmt; @@ -1635,7 +1648,7 @@ CC_lookup_lo(ConnectionClass *self) * h-inoue 01-2-2001 */ void -CC_initialize_pg_version(ConnectionClass *self) +CC_initialize_pg_version(ConnectionClass * self) { strcpy(self->pg_version, self->connInfo.protocol); if (PROTOCOL_62(&self->connInfo)) @@ -1665,7 +1678,7 @@ CC_initialize_pg_version(ConnectionClass *self) * DJP - 25-1-2001 */ void -CC_lookup_pg_version(ConnectionClass *self) +CC_lookup_pg_version(ConnectionClass * self) { HSTMT hstmt; StatementClass *stmt; @@ -1731,7 +1744,7 @@ CC_lookup_pg_version(ConnectionClass *self) void -CC_log_error(char *func, char *desc, ConnectionClass *self) +CC_log_error(char *func, char *desc, ConnectionClass * self) { #ifdef PRN_NULLCHECK #define nullcheck(a) (a ? a : "(NULL)") @@ -1760,17 +1773,19 @@ CC_log_error(char *func, char *desc, ConnectionClass *self) #undef PRN_NULLCHECK } -int CC_get_max_query_len(const ConnectionClass *conn) +int +CC_get_max_query_len(const ConnectionClass * conn) { - int value; - /* Long Queries in 7.0+ */ - if (PG_VERSION_GE(conn, 7.0)) - value = 0 /* MAX_STATEMENT_LEN */; - /* Prior to 7.0 we used 2*BLCKSZ */ - else if (PG_VERSION_GE(conn, 6.5)) - value = (2 * BLCKSZ); - else - /* Prior to 6.5 we used BLCKSZ */ - value = BLCKSZ; - return value; + int value; + + /* Long Queries in 7.0+ */ + if (PG_VERSION_GE(conn, 7.0)) + value = 0 /* MAX_STATEMENT_LEN */ ; + /* Prior to 7.0 we used 2*BLCKSZ */ + else if (PG_VERSION_GE(conn, 6.5)) + value = (2 * BLCKSZ); + else + /* Prior to 6.5 we used BLCKSZ */ + value = BLCKSZ; + return value; } diff --git a/src/interfaces/odbc/connection.h b/src/interfaces/odbc/connection.h index 505325ad68..782fb0e4d1 100644 --- a/src/interfaces/odbc/connection.h +++ b/src/interfaces/odbc/connection.h @@ -17,13 +17,14 @@ typedef enum { - CONN_NOT_CONNECTED, /* Connection has not been established */ - CONN_CONNECTED, /* Connection is up and has been + CONN_NOT_CONNECTED, /* Connection has not been + * established */ + CONN_CONNECTED, /* Connection is up and has been * established */ - CONN_DOWN, /* Connection is broken */ - CONN_EXECUTING /* the connection is currently executing a + CONN_DOWN, /* Connection is broken */ + CONN_EXECUTING /* the connection is currently executing a * statement */ -} CONN_Status; +} CONN_Status; /* These errors have general sql error state */ #define CONNECTION_SERVER_NOT_REACHED 101 @@ -151,8 +152,8 @@ typedef struct char focus_password; char disallow_premature; char updatable_cursors; - GLOBAL_VALUES drivers; /* moved from driver's option */ -} ConnInfo; + GLOBAL_VALUES drivers; /* moved from driver's option */ +} ConnInfo; /* Macro to determine is the connection using 6.2 protocol? */ #define PROTOCOL_62(conninfo_) (strncmp((conninfo_)->protocol, PG62, strlen(PG62)) == 0) @@ -212,27 +213,27 @@ struct col_info #define HINSTANCE void * #endif -typedef BOOL (FAR WINAPI * DataSourceToDriverProc) (UDWORD, - SWORD, - PTR, - SDWORD, - PTR, - SDWORD, - SDWORD FAR *, - UCHAR FAR *, - SWORD, - SWORD FAR *); - -typedef BOOL (FAR WINAPI * DriverToDataSourceProc) (UDWORD, - SWORD, - PTR, - SDWORD, - PTR, - SDWORD, - SDWORD FAR *, - UCHAR FAR *, - SWORD, - SWORD FAR *); +typedef BOOL(FAR WINAPI * DataSourceToDriverProc) (UDWORD, + SWORD, + PTR, + SDWORD, + PTR, + SDWORD, + SDWORD FAR *, + UCHAR FAR *, + SWORD, + SWORD FAR *); + +typedef BOOL(FAR WINAPI * DriverToDataSourceProc) (UDWORD, + SWORD, + PTR, + SDWORD, + PTR, + SDWORD, + SDWORD FAR *, + UCHAR FAR *, + SWORD, + SWORD FAR *); /******* The Connection handle ************/ struct ConnectionClass_ @@ -267,9 +268,9 @@ struct ConnectionClass_ Int2 pg_version_minor; char ms_jet; #ifdef MULTIBYTE - char *client_encoding; - char *server_encoding; -#endif /* MULTIBYTE */ + char *client_encoding; + char *server_encoding; +#endif /* MULTIBYTE */ }; @@ -289,24 +290,23 @@ struct ConnectionClass_ /* prototypes */ ConnectionClass *CC_Constructor(void); -char CC_Destructor(ConnectionClass *self); -int CC_cursor_count(ConnectionClass *self); -char CC_cleanup(ConnectionClass *self); -char CC_abort(ConnectionClass *self); -int CC_set_translation(ConnectionClass *self); -char CC_connect(ConnectionClass *self, char do_password); -char CC_add_statement(ConnectionClass *self, StatementClass *stmt); -char CC_remove_statement(ConnectionClass *self, StatementClass *stmt); -char CC_get_error(ConnectionClass *self, int *number, char **message); -QResultClass *CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi); -void CC_clear_error(ConnectionClass *self); -char *CC_create_errormsg(ConnectionClass *self); -int CC_send_function(ConnectionClass *conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG *argv, int nargs); -char CC_send_settings(ConnectionClass *self); -void CC_lookup_lo(ConnectionClass *conn); -void CC_lookup_pg_version(ConnectionClass *conn); -void CC_initialize_pg_version(ConnectionClass *conn); -void CC_log_error(char *func, char *desc, ConnectionClass *self); -int CC_get_max_query_len(const ConnectionClass *self); - +char CC_Destructor(ConnectionClass * self); +int CC_cursor_count(ConnectionClass * self); +char CC_cleanup(ConnectionClass * self); +char CC_abort(ConnectionClass * self); +int CC_set_translation(ConnectionClass * self); +char CC_connect(ConnectionClass * self, char do_password); +char CC_add_statement(ConnectionClass * self, StatementClass * stmt); +char CC_remove_statement(ConnectionClass * self, StatementClass * stmt); +char CC_get_error(ConnectionClass * self, int *number, char **message); +QResultClass *CC_send_query(ConnectionClass * self, char *query, QueryInfo * qi); +void CC_clear_error(ConnectionClass * self); +char *CC_create_errormsg(ConnectionClass * self); +int CC_send_function(ConnectionClass * conn, int fnid, void *result_buf, int *actual_result_len, int result_is_int, LO_ARG * argv, int nargs); +char CC_send_settings(ConnectionClass * self); +void CC_lookup_lo(ConnectionClass * conn); +void CC_lookup_pg_version(ConnectionClass * conn); +void CC_initialize_pg_version(ConnectionClass * conn); +void CC_log_error(char *func, char *desc, ConnectionClass * self); +int CC_get_max_query_len(const ConnectionClass * self); #endif diff --git a/src/interfaces/odbc/convert.c b/src/interfaces/odbc/convert.c index 2afc079dfd..aae290970c 100644 --- a/src/interfaces/odbc/convert.c +++ b/src/interfaces/odbc/convert.c @@ -1,5 +1,5 @@ /*------- - * Module: convert.c + * Module: convert.c * * Description: This module contains routines related to * converting parameters and columns into requested data types. @@ -111,10 +111,10 @@ char *mapFuncs[][2] = { {0, 0} }; -static char *mapFunction(const char *func); +static char *mapFunction(const char *func); static unsigned int conv_from_octal(const unsigned char *s); static unsigned int conv_from_hex(const unsigned char *s); -static char *conv_to_octal(unsigned char val); +static char *conv_to_octal(unsigned char val); /*--------- * A Guide for date/time/timestamp conversions @@ -138,7 +138,7 @@ static char *conv_to_octal(unsigned char val); /* This is called by SQLFetch() */ int -copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *value, int col) +copy_and_convert_field_bindinfo(StatementClass * stmt, Int4 field_type, void *value, int col) { BindInfoClass *bic = &(stmt->bindings[col]); @@ -149,8 +149,8 @@ copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *val /* This is called by SQLGetData() */ int -copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType, - PTR rgbValue, SDWORD cbValueMax, SDWORD *pcbValue) +copy_and_convert_field(StatementClass * stmt, Int4 field_type, void *value, Int2 fCType, + PTR rgbValue, SDWORD cbValueMax, SDWORD * pcbValue) { Int4 len = 0, copy_len = 0; @@ -160,16 +160,16 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 int pcbValueOffset, rgbValueOffset; char *rgbValueBindRow; - const char *ptr; + const char *ptr; int bind_row = stmt->bind_row; int bind_size = stmt->options.bind_size; int result = COPY_OK; BOOL changed; - static char *tempBuf= NULL; - static unsigned int tempBuflen = 0; + static char *tempBuf = NULL; + static unsigned int tempBuflen = 0; const char *neut_str = value; - char midtemp[2][32]; - int mtemp_cnt = 0; + char midtemp[2][32]; + int mtemp_cnt = 0; if (!tempBuf) tempBuflen = 0; @@ -200,7 +200,6 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 if (!value) { - /* * handle a null just by returning SQL_NULL_DATA in pcbValue, and * doing nothing to the buffer. @@ -229,7 +228,6 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 */ switch (field_type) { - /* * $$$ need to add parsing for date/time/timestamp strings in * PG_TYPE_CHAR,VARCHAR $$$ @@ -249,7 +247,6 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 sscanf(value, "%4d-%2d-%2d %2d:%2d:%2d", &st.y, &st.m, &st.d, &st.hh, &st.mm, &st.ss); else { - /* * The timestamp is invalid so set something conspicuous, * like the epoch @@ -266,7 +263,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 break; case PG_TYPE_BOOL: - { /* change T/F to 1/0 */ + { /* change T/F to 1/0 */ char *s; s = midtemp[mtemp_cnt]; @@ -287,7 +284,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 { int nval, i; - const char *vp; + const char *vp; /* this is an array of eight integers */ short *short_array = (short *) ((char *) rgbValue + rgbValueOffset); @@ -425,12 +422,14 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 default: if (stmt->current_col >= 0 && stmt->bindings[stmt->current_col].data_left == -2) - stmt->bindings[stmt->current_col].data_left = (cbValueMax > 0) ? 0 : -1; /* This seems to be needed for ADO ? */ + stmt->bindings[stmt->current_col].data_left = (cbValueMax > 0) ? 0 : -1; /* This seems to be + * needed for ADO ? */ if (stmt->current_col < 0 || stmt->bindings[stmt->current_col].data_left < 0) { /* convert linefeeds to carriage-return/linefeed */ len = convert_linefeeds(neut_str, NULL, 0, &changed); - if (cbValueMax == 0) /* just returns length info */ + if (cbValueMax == 0) /* just returns length + * info */ { result = COPY_RESULT_TRUNCATED; break; @@ -519,7 +518,6 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 } else { - /* * for SQL_C_CHAR, it's probably ok to leave currency symbols in. * But to convert to numeric types, it is necessary to get rid of @@ -595,8 +593,9 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 *((UCHAR *) rgbValue + bind_row) = atoi(neut_str); /* - * mylog("SQL_C_BIT: bind_row = %d val = %d, cb = %d, rgb=%d\n", - * bind_row, atoi(neut_str), cbValueMax, *((UCHAR *)rgbValue)); + * mylog("SQL_C_BIT: bind_row = %d val = %d, cb = %d, + * rgb=%d\n", bind_row, atoi(neut_str), cbValueMax, + * *((UCHAR *)rgbValue)); */ break; @@ -751,14 +750,15 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 * Functions/Macros to get rid of query size limit. * * I always used the follwoing macros to convert from - * old_statement to new_statement. Please improve it + * old_statement to new_statement. Please improve it * if you have a better way. Hiroshi 2001/05/22 *-------------------------------------------------------------------- */ -#define INIT_MIN_ALLOC 4096 -static int enlarge_statement(StatementClass *stmt, unsigned int newsize) +#define INIT_MIN_ALLOC 4096 +static int +enlarge_statement(StatementClass * stmt, unsigned int newsize) { - unsigned int newalsize = INIT_MIN_ALLOC; + unsigned int newalsize = INIT_MIN_ALLOC; static char *func = "enlarge_statement"; if (stmt->stmt_size_limit > 0 && stmt->stmt_size_limit < (int) newsize) @@ -784,7 +784,7 @@ static int enlarge_statement(StatementClass *stmt, unsigned int newsize) * Enlarge stmt_with_params if necessary. *---------- */ -#define ENLARGE_NEWSTATEMENT(newpos) \ +#define ENLARGE_NEWSTATEMENT(newpos) \ if (newpos >= new_stsize) \ { \ if ((new_stsize = enlarge_statement(stmt, newpos)) <= 0) \ @@ -795,7 +795,7 @@ static int enlarge_statement(StatementClass *stmt, unsigned int newsize) * Initialize stmt_with_params, new_statement etc. *---------- */ -#define CVT_INIT(size) \ +#define CVT_INIT(size) \ do { \ if (stmt->stmt_with_params) \ free(stmt->stmt_with_params); \ @@ -817,7 +817,7 @@ do { \ * Terminate the stmt_with_params string with NULL. *---------- */ -#define CVT_TERMINATE \ +#define CVT_TERMINATE \ do { \ new_statement[npos] = '\0'; \ } while (0) @@ -826,7 +826,7 @@ do { \ * Append a data. *---------- */ -#define CVT_APPEND_DATA(s, len) \ +#define CVT_APPEND_DATA(s, len) \ do { \ unsigned int newpos = npos + len; \ ENLARGE_NEWSTATEMENT(newpos) \ @@ -839,17 +839,17 @@ do { \ * Append a string. *---------- */ -#define CVT_APPEND_STR(s) \ +#define CVT_APPEND_STR(s) \ do { \ unsigned int len = strlen(s); \ CVT_APPEND_DATA(s, len); \ } while (0) /*---------- - * Append a char. + * Append a char. *---------- */ -#define CVT_APPEND_CHAR(c) \ +#define CVT_APPEND_CHAR(c) \ do { \ ENLARGE_NEWSTATEMENT(npos + 1); \ new_statement[npos++] = c; \ @@ -857,10 +857,10 @@ do { \ /*---------- * Append a binary data. - * Newly reqeuired size may be overestimated currently. + * Newly reqeuired size may be overestimated currently. *---------- */ -#define CVT_APPEND_BINARY(buf, used) \ +#define CVT_APPEND_BINARY(buf, used) \ do { \ unsigned int newlimit = npos + 5 * used; \ ENLARGE_NEWSTATEMENT(newlimit); \ @@ -871,9 +871,9 @@ do { \ * *---------- */ -#define CVT_SPECIAL_CHARS(buf, used) \ +#define CVT_SPECIAL_CHARS(buf, used) \ do { \ - int cnvlen = convert_special_chars(buf, NULL, used); \ + int cnvlen = convert_special_chars(buf, NULL, used); \ unsigned int newlimit = npos + cnvlen; \ \ ENLARGE_NEWSTATEMENT(newlimit); \ @@ -882,10 +882,10 @@ do { \ } while (0) /*---------- - * Check if the statement is + * Check if the statement is * SELECT ... INTO table FROM ..... * This isn't really a strict check but ... - *---------- + *---------- */ static BOOL into_table_from(const char *stmt) @@ -902,15 +902,14 @@ into_table_from(const char *stmt) case ',': case '\'': return FALSE; - case '\"': /* double quoted table name ? */ + case '\"': /* double quoted table name ? */ do { do - { - while (*(++stmt) != '\"' && *stmt); - } + while (*(++stmt) != '\"' && *stmt); while (*stmt && *(++stmt) == '\"'); - while (*stmt && !isspace((unsigned char) *stmt) && *stmt != '\"') stmt++; + while (*stmt && !isspace((unsigned char) *stmt) && *stmt != '\"') + stmt++; } while (*stmt == '\"'); break; @@ -918,7 +917,7 @@ into_table_from(const char *stmt) while (!isspace((unsigned char) *(++stmt))); break; } - if (! *stmt) + if (!*stmt) return FALSE; while (isspace((unsigned char) *(++stmt))); if (strnicmp(stmt, "from", 4)) @@ -927,17 +926,18 @@ into_table_from(const char *stmt) } /*---------- - * Check if the statement is + * Check if the statement is * SELECT ... FOR UPDATE ..... * This isn't really a strict check but ... - *---------- + *---------- */ static BOOL table_for_update(const char *stmt, int *endpos) { const char *wstmt = stmt; + while (isspace((unsigned char) *(++wstmt))); - if (! *wstmt) + if (!*wstmt) return FALSE; if (strnicmp(wstmt, "update", 6)) return FALSE; @@ -952,7 +952,7 @@ table_for_update(const char *stmt, int *endpos) * This function does a dynamic memory allocation to get rid of query size limit! */ int -copy_statement_with_parameters(StatementClass *stmt) +copy_statement_with_parameters(StatementClass * stmt) { static char *func = "copy_statement_with_parameters"; unsigned int opos, @@ -960,34 +960,43 @@ copy_statement_with_parameters(StatementClass *stmt) oldstmtlen; char param_string[128], tmp[256], - cbuf[PG_NUMERIC_MAX_PRECISION * 2]; /* seems big enough to handle the data in this function */ + cbuf[PG_NUMERIC_MAX_PRECISION * 2]; /* seems big enough to + * handle the data in + * this function */ int param_number; Int2 param_ctype, param_sqltype; - char *old_statement = stmt->statement, oldchar; + char *old_statement = stmt->statement, + oldchar; char *new_statement = stmt->stmt_with_params; - unsigned int new_stsize = 0; + unsigned int new_stsize = 0; SIMPLE_TIME st; time_t t = time(NULL); struct tm *tim; SDWORD used; - char *buffer, *buf; - BOOL in_quote = FALSE, in_dquote = FALSE, in_escape = FALSE; + char *buffer, + *buf; + BOOL in_quote = FALSE, + in_dquote = FALSE, + in_escape = FALSE; Oid lobj_oid; int lobj_fd, retval; - BOOL check_cursor_ok = FALSE; /* check cursor restriction */ - BOOL proc_no_param = TRUE; - unsigned int declare_pos = 0; - ConnectionClass *conn = SC_get_conn(stmt); - ConnInfo *ci = &(conn->connInfo); - BOOL prepare_dummy_cursor = FALSE, begin_first = FALSE; - char token_save[64]; - int token_len; - BOOL prev_token_end; + BOOL check_cursor_ok = FALSE; /* check cursor + * restriction */ + BOOL proc_no_param = TRUE; + unsigned int declare_pos = 0; + ConnectionClass *conn = SC_get_conn(stmt); + ConnInfo *ci = &(conn->connInfo); + BOOL prepare_dummy_cursor = FALSE, + begin_first = FALSE; + char token_save[64]; + int token_len; + BOOL prev_token_end; + #ifdef DRIVER_CURSOR_IMPLEMENT - BOOL search_from_pos = FALSE; -#endif /* DRIVER_CURSOR_IMPLEMENT */ + BOOL search_from_pos = FALSE; +#endif /* DRIVER_CURSOR_IMPLEMENT */ if (ci->disallow_premature) prepare_dummy_cursor = stmt->pre_executing; @@ -1012,7 +1021,7 @@ copy_statement_with_parameters(StatementClass *stmt) stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; } else if (stmt->options.cursor_type == SQL_CURSOR_FORWARD_ONLY) - stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; + stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; else if (stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) { if (stmt->parse_status == STMT_PARSE_NONE) @@ -1020,11 +1029,11 @@ copy_statement_with_parameters(StatementClass *stmt) if (stmt->parse_status != STMT_PARSE_COMPLETE) stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; else if (!stmt->ti || stmt->ntab != 1) - stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; + stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; else search_from_pos = TRUE; } -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ /* If the application hasn't set a cursor name, then generate one */ if (stmt->cursor_name[0] == '\0') @@ -1052,7 +1061,7 @@ copy_statement_with_parameters(StatementClass *stmt) else if (ci->drivers.use_declarefetch) SC_set_fetchcursor(stmt); sprintf(new_statement, "%sdeclare %s cursor for ", - new_statement, stmt->cursor_name); + new_statement, stmt->cursor_name); npos = strlen(new_statement); check_cursor_ok = TRUE; declare_pos = npos; @@ -1072,18 +1081,18 @@ copy_statement_with_parameters(StatementClass *stmt) CVT_APPEND_CHAR(oldchar); continue; } + /* - * From here we are guaranteed to handle a - * 1-byte character. + * From here we are guaranteed to handle a 1-byte character. */ #endif - if (in_escape) /* escape check */ + if (in_escape) /* escape check */ { in_escape = FALSE; CVT_APPEND_CHAR(oldchar); continue; - } + } else if (in_quote || in_dquote) /* quote/double quote check */ { if (oldchar == '\\') @@ -1093,16 +1102,18 @@ copy_statement_with_parameters(StatementClass *stmt) else if (oldchar == '\"' && in_dquote) in_dquote = FALSE; CVT_APPEND_CHAR(oldchar); - continue; + continue; } + /* - * From here we are guranteed to be in neither - * an escape, a quote nor a double quote. + * From here we are guranteed to be in neither an escape, a quote + * nor a double quote. */ /* Squeeze carriage-return/linefeed pairs to linefeed only */ else if (oldchar == '\r' && opos + 1 < oldstmtlen && - old_statement[opos + 1] == '\n') + old_statement[opos + 1] == '\n') continue; + /* * Handle literals (date, time, timestamp) and ODBC scalar * functions @@ -1117,7 +1128,6 @@ copy_statement_with_parameters(StatementClass *stmt) #else char *end = strchr(begin, '}'); - #endif if (!end) @@ -1125,7 +1135,8 @@ copy_statement_with_parameters(StatementClass *stmt) /* procedure calls */ if (stmt->statement_type == STMT_TYPE_PROCCALL) { - int lit_call_len = 4; + int lit_call_len = 4; + while (isspace((unsigned char) old_statement[++opos])); /* '=?' to accept return values exists ? */ if (old_statement[opos] == '?') @@ -1145,23 +1156,21 @@ copy_statement_with_parameters(StatementClass *stmt) opos--; continue; } - opos += lit_call_len; + opos += lit_call_len; CVT_APPEND_STR("SELECT "); #ifdef MULTIBYTE if (multibyte_strchr(&old_statement[opos], '(')) #else if (strchr(&old_statement[opos], '(')) -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ proc_no_param = FALSE; - continue; + continue; } *end = '\0'; esc = convert_escape(begin); if (esc) - { CVT_APPEND_STR(esc); - } else { /* it's not a valid literal so just copy */ *end = '}'; @@ -1196,7 +1205,7 @@ copy_statement_with_parameters(StatementClass *stmt) in_escape = TRUE; else if (oldchar == '\"') in_dquote = TRUE; - else + else { if (isspace(oldchar)) { @@ -1207,7 +1216,7 @@ copy_statement_with_parameters(StatementClass *stmt) if (token_len == 4) { if (check_cursor_ok && - into_table_from(&old_statement[opos - token_len])) + into_table_from(&old_statement[opos - token_len])) { stmt->statement_type = STMT_TYPE_CREATE; SC_no_pre_executable(stmt); @@ -1218,20 +1227,21 @@ copy_statement_with_parameters(StatementClass *stmt) } #ifdef DRIVER_CURSOR_IMPLEMENT else if (search_from_pos && /* where's from clause */ - strnicmp(token_save, "from", 4) == 0) + strnicmp(token_save, "from", 4) == 0) { search_from_pos = FALSE; npos -= 5; CVT_APPEND_STR(", CTID, OID from"); } -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ } if (token_len == 3) { - int endpos; + int endpos; + if (check_cursor_ok && - strnicmp(token_save, "for", 3) == 0 && - table_for_update(&old_statement[opos], &endpos)) + strnicmp(token_save, "for", 3) == 0 && + table_for_update(&old_statement[opos], &endpos)) { SC_no_fetchcursor(stmt); stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1247,7 +1257,7 @@ copy_statement_with_parameters(StatementClass *stmt) } } } - } + } } else if (prev_token_end) { @@ -1257,7 +1267,7 @@ copy_statement_with_parameters(StatementClass *stmt) } else if (token_len + 1 < sizeof(token_save)) token_save[token_len++] = oldchar; - } + } CVT_APPEND_CHAR(oldchar); continue; } @@ -1290,10 +1300,10 @@ copy_statement_with_parameters(StatementClass *stmt) } else { - - + + used = stmt->parameters[param_number].used ? *stmt->parameters[param_number].used : SQL_NTS; - + buffer = stmt->parameters[param_number].buffer; } @@ -1457,15 +1467,11 @@ copy_statement_with_parameters(StatementClass *stmt) /* it was a SQL_C_CHAR */ if (buf) - { CVT_SPECIAL_CHARS(buf, used); - } /* it was a numeric type */ else if (param_string[0] != '\0') - { CVT_APPEND_STR(param_string); - } /* it was date,time,timestamp -- use m,d,y,hh,mm,ss */ else @@ -1694,19 +1700,20 @@ copy_statement_with_parameters(StatementClass *stmt) int length = strlen(new_statement); conn->DriverToDataSource(conn->translation_option, - SQL_CHAR, - new_statement, length, - new_statement, length, NULL, - NULL, 0, NULL); + SQL_CHAR, + new_statement, length, + new_statement, length, NULL, + NULL, 0, NULL); } #ifdef DRIVER_CURSOR_IMPLEMENT if (search_from_pos) stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ if (prepare_dummy_cursor && SC_is_pre_executable(stmt)) { - char fetchstr[128]; + char fetchstr[128]; + sprintf(fetchstr, ";fetch backward in %s;close %s;", stmt->cursor_name, stmt->cursor_name); if (begin_first && CC_is_in_autocommit(conn)) @@ -1765,7 +1772,6 @@ convert_escape(char *value) } else if (strcmp(key, "fn") == 0) { - /* * Function invocation Separate off the func name, skipping * trailing whitespace. @@ -1796,8 +1802,8 @@ convert_escape(char *value) mapFunc = mapFunction(key); /* - * We could have mapFunction() return key if not in table... - * - thomas 2000-04-03 + * We could have mapFunction() return key if not in table... - + * thomas 2000-04-03 */ if (mapFunc == NULL) { @@ -1822,7 +1828,8 @@ convert_escape(char *value) BOOL convert_money(const char *s, char *sout, size_t soutmax) { - size_t i = 0, out = 0; + size_t i = 0, + out = 0; for (i = 0; s[i]; i++) { @@ -1831,7 +1838,7 @@ convert_money(const char *s, char *sout, size_t soutmax) else { if (out + 1 >= soutmax) - return FALSE; /* sout is too short */ + return FALSE; /* sout is too short */ if (s[i] == '(') sout[out++] = '-'; else @@ -1848,7 +1855,7 @@ convert_money(const char *s, char *sout, size_t soutmax) * It does not zero out SIMPLE_TIME in case it is desired to initialize it with a value */ char -parse_datetime(char *buf, SIMPLE_TIME *st) +parse_datetime(char *buf, SIMPLE_TIME * st) { int y, m, @@ -1915,7 +1922,7 @@ parse_datetime(char *buf, SIMPLE_TIME *st) /* Change linefeed to carriage-return/linefeed */ int -convert_linefeeds(const char *si, char *dst, size_t max, BOOL *changed) +convert_linefeeds(const char *si, char *dst, size_t max, BOOL * changed) { size_t i = 0, out = 0; @@ -2069,7 +2076,8 @@ conv_from_hex(const unsigned char *s) int convert_from_pgbinary(const unsigned char *value, unsigned char *rgbValue, int cbValueMax) { - size_t i, ilen = strlen(value); + size_t i, + ilen = strlen(value); int o = 0; @@ -2148,7 +2156,8 @@ convert_to_pgbinary(const unsigned char *in, char *out, int len) void encode(const char *in, char *out) { - unsigned int i, ilen = strlen(in), + unsigned int i, + ilen = strlen(in), o = 0; for (i = 0; i < ilen; i++) @@ -2175,7 +2184,8 @@ encode(const char *in, char *out) void decode(const char *in, char *out) { - unsigned int i, ilen = strlen(in), + unsigned int i, + ilen = strlen(in), o = 0; for (i = 0; i < ilen; i++) @@ -2211,16 +2221,16 @@ decode(const char *in, char *out) *------- */ int -convert_lo(StatementClass *stmt, const void *value, Int2 fCType, PTR rgbValue, - SDWORD cbValueMax, SDWORD *pcbValue) +convert_lo(StatementClass * stmt, const void *value, Int2 fCType, PTR rgbValue, + SDWORD cbValueMax, SDWORD * pcbValue) { Oid oid; int retval, result, left = -1; BindInfoClass *bindInfo = NULL; - ConnectionClass *conn = SC_get_conn(stmt); - ConnInfo *ci = &(conn->connInfo); + ConnectionClass *conn = SC_get_conn(stmt); + ConnInfo *ci = &(conn->connInfo); /* If using SQLGetData, then current_col will be set */ if (stmt->current_col >= 0) diff --git a/src/interfaces/odbc/convert.h b/src/interfaces/odbc/convert.h index 33df7ddd71..9ef3dffa64 100644 --- a/src/interfaces/odbc/convert.h +++ b/src/interfaces/odbc/convert.h @@ -27,25 +27,24 @@ typedef struct int hh; int mm; int ss; -} SIMPLE_TIME; +} SIMPLE_TIME; -int copy_and_convert_field_bindinfo(StatementClass *stmt, Int4 field_type, void *value, int col); -int copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType, - PTR rgbValue, SDWORD cbValueMax, SDWORD *pcbValue); +int copy_and_convert_field_bindinfo(StatementClass * stmt, Int4 field_type, void *value, int col); +int copy_and_convert_field(StatementClass * stmt, Int4 field_type, void *value, Int2 fCType, + PTR rgbValue, SDWORD cbValueMax, SDWORD * pcbValue); -int copy_statement_with_parameters(StatementClass *stmt); +int copy_statement_with_parameters(StatementClass * stmt); char *convert_escape(char *value); -BOOL convert_money(const char *s, char *sout, size_t soutmax); -char parse_datetime(char *buf, SIMPLE_TIME *st); -int convert_linefeeds(const char *s, char *dst, size_t max, BOOL *changed); -int convert_special_chars(const char *si, char *dst, int used); +BOOL convert_money(const char *s, char *sout, size_t soutmax); +char parse_datetime(char *buf, SIMPLE_TIME * st); +int convert_linefeeds(const char *s, char *dst, size_t max, BOOL * changed); +int convert_special_chars(const char *si, char *dst, int used); int convert_pgbinary_to_char(const char *value, char *rgbValue, int cbValueMax); int convert_from_pgbinary(const unsigned char *value, unsigned char *rgbValue, int cbValueMax); int convert_to_pgbinary(const unsigned char *in, char *out, int len); void encode(const char *in, char *out); void decode(const char *in, char *out); -int convert_lo(StatementClass *stmt, const void *value, Int2 fCType, PTR rgbValue, - SDWORD cbValueMax, SDWORD *pcbValue); - +int convert_lo(StatementClass * stmt, const void *value, Int2 fCType, PTR rgbValue, + SDWORD cbValueMax, SDWORD * pcbValue); #endif diff --git a/src/interfaces/odbc/dlg_specific.c b/src/interfaces/odbc/dlg_specific.c index e67a1dc020..d395e9a35e 100644 --- a/src/interfaces/odbc/dlg_specific.c +++ b/src/interfaces/odbc/dlg_specific.c @@ -37,17 +37,17 @@ #endif extern GLOBAL_VALUES globals; + #ifdef WIN32 -static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable); -static int driver_options_update(HWND hdlg, ConnInfo *ci, BOOL); -static void updateCommons(const ConnInfo *ci); +static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable); +static int driver_options_update(HWND hdlg, ConnInfo * ci, BOOL); +static void updateCommons(const ConnInfo * ci); #endif #ifdef WIN32 void -SetDlgStuff(HWND hdlg, const ConnInfo *ci) +SetDlgStuff(HWND hdlg, const ConnInfo * ci) { - /* * If driver attribute NOT present, then set the datasource name and * description @@ -67,7 +67,7 @@ SetDlgStuff(HWND hdlg, const ConnInfo *ci) void -GetDlgStuff(HWND hdlg, ConnInfo *ci) +GetDlgStuff(HWND hdlg, ConnInfo * ci) { GetDlgItemText(hdlg, IDC_DESC, ci->desc, sizeof(ci->desc)); @@ -80,21 +80,21 @@ GetDlgStuff(HWND hdlg, ConnInfo *ci) static int -driver_optionsDraw(HWND hdlg, const ConnInfo *ci, int src, BOOL enable) +driver_optionsDraw(HWND hdlg, const ConnInfo * ci, int src, BOOL enable) { - const GLOBAL_VALUES *comval; - static BOOL defset = FALSE; - static GLOBAL_VALUES defval; - + const GLOBAL_VALUES *comval; + static BOOL defset = FALSE; + static GLOBAL_VALUES defval; + switch (src) { - case 0: /* driver common */ + case 0: /* driver common */ comval = &globals; break; - case 1: /* dsn specific */ + case 1: /* dsn specific */ comval = &(ci->drivers); break; - case 2: /* default */ + case 2: /* default */ if (!defset) { defval.commlog = DEFAULT_COMMLOG; @@ -164,9 +164,9 @@ driver_optionsDraw(HWND hdlg, const ConnInfo *ci, int src, BOOL enable) return 0; } static int -driver_options_update(HWND hdlg, ConnInfo *ci, BOOL updateProfile) +driver_options_update(HWND hdlg, ConnInfo * ci, BOOL updateProfile) { - GLOBAL_VALUES *comval; + GLOBAL_VALUES *comval; if (ci) comval = &(ci->drivers); @@ -204,7 +204,7 @@ driver_options_update(HWND hdlg, ConnInfo *ci, BOOL updateProfile) comval->fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_SIZE, NULL, FALSE); comval->max_varchar_size = GetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, NULL, FALSE); comval->max_longvarchar_size = GetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, NULL, TRUE); /* allows for - * SQL_NO_TOTAL */ + * SQL_NO_TOTAL */ GetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, sizeof(comval->extra_systable_prefixes)); @@ -225,17 +225,16 @@ driver_optionsProc(HWND hdlg, WPARAM wParam, LPARAM lParam) { - ConnInfo *ci; + ConnInfo *ci; + switch (wMsg) { case WM_INITDIALOG: - SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK etc */ + SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK etc */ ci = (ConnInfo *) lParam; CheckDlgButton(hdlg, DRV_OR_DSN, 0); if (ci && ci->dsn && ci->dsn[0]) - { SetWindowText(hdlg, "Advanced Options (per DSN)"); - } else { SetWindowText(hdlg, "Advanced Options (Connection)"); @@ -250,7 +249,7 @@ driver_optionsProc(HWND hdlg, case IDOK: ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); driver_options_update(hdlg, IsDlgButtonChecked(hdlg, DRV_OR_DSN) ? NULL : ci, - ci && ci->dsn && ci->dsn[0]); + ci && ci->dsn && ci->dsn[0]); case IDCANCEL: EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK); @@ -262,6 +261,7 @@ driver_optionsProc(HWND hdlg, else { ConnInfo *ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); + driver_optionsDraw(hdlg, ci, 0, FALSE); } break; @@ -278,6 +278,7 @@ driver_optionsProc(HWND hdlg, else { ConnInfo *ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); + SetWindowText(hdlg, "Advanced Options (per DSN)"); driver_optionsDraw(hdlg, ci, ci ? 1 : 0, ci == NULL); } @@ -390,11 +391,11 @@ ds_optionsProc(HWND hdlg, * to the ODBCINST.INI portion of the registry */ static void -updateCommons(const ConnInfo *ci) +updateCommons(const ConnInfo * ci) { - const char *sectionName; - const char *fileName; - const GLOBAL_VALUES *comval; + const char *sectionName; + const char *fileName; + const GLOBAL_VALUES *comval; char tmp[128]; if (ci) @@ -409,7 +410,7 @@ updateCommons(const ConnInfo *ci) { mylog("ci but dsn==NULL\n"); return; - } + } else { mylog("drivers updating\n"); @@ -437,14 +438,16 @@ updateCommons(const ConnInfo *ci) SQLWritePrivateProfileString(sectionName, INI_KSQO, tmp, fileName); - /* Never update the onlyread, unique_index from this module - sprintf(tmp, "%d", comval->unique_index); - SQLWritePrivateProfileString(sectionName, - INI_UNIQUEINDEX, tmp, fileName); - - sprintf(tmp, "%d", comval->onlyread); - SQLWritePrivateProfileString(sectionName, - INI_READONLY, tmp, fileName);*/ + /* + * Never update the onlyread, unique_index from this module + * sprintf(tmp, "%d", comval->unique_index); + * SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, + * fileName); + * + * sprintf(tmp, "%d", comval->onlyread); + * SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp, + * fileName); + */ sprintf(tmp, "%d", comval->use_declarefetch); SQLWritePrivateProfileString(sectionName, @@ -456,11 +459,11 @@ updateCommons(const ConnInfo *ci) sprintf(tmp, "%d", comval->text_as_longvarchar); SQLWritePrivateProfileString(sectionName, - INI_TEXTASLONGVARCHAR, tmp, fileName); + INI_TEXTASLONGVARCHAR, tmp, fileName); sprintf(tmp, "%d", comval->unknowns_as_longvarchar); SQLWritePrivateProfileString(sectionName, - INI_UNKNOWNSASLONGVARCHAR, tmp, fileName); + INI_UNKNOWNSASLONGVARCHAR, tmp, fileName); sprintf(tmp, "%d", comval->bools_as_char); SQLWritePrivateProfileString(sectionName, @@ -480,20 +483,22 @@ updateCommons(const ConnInfo *ci) sprintf(tmp, "%d", comval->max_longvarchar_size); SQLWritePrivateProfileString(sectionName, - INI_MAXLONGVARCHARSIZE, tmp, fileName); + INI_MAXLONGVARCHARSIZE, tmp, fileName); SQLWritePrivateProfileString(sectionName, - INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName); + INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName); - /* Never update the conn_setting from this module - SQLWritePrivateProfileString(sectionName, - INI_CONNSETTINGS, comval->conn_settings, fileName); */ + /* + * Never update the conn_setting from this module + * SQLWritePrivateProfileString(sectionName, INI_CONNSETTINGS, + * comval->conn_settings, fileName); + */ } #endif /* WIN32 */ void -makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len) +makeConnectString(char *connect_string, const ConnInfo * ci, UWORD len) { char got_dsn = (ci->dsn[0] != '\0'); char encoded_conn_settings[LARGE_REGISTRY_LEN]; @@ -516,62 +521,62 @@ makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len) hlen = strlen(connect_string); if (!abbrev) sprintf(&connect_string[hlen], - ";READONLY=%s;PROTOCOL=%s;FAKEOIDINDEX=%s;SHOWOIDCOLUMN=%s;ROWVERSIONING=%s;SHOWSYSTEMTABLES=%s;CONNSETTINGS=%s;FETCH=%d;SOCKET=%d;UNKNOWNSIZES=%d;MAXVARCHARSIZE=%d;MAXLONGVARCHARSIZE=%d;DEBUG=%d;COMMLOG=%d;OPTIMIZER=%d;KSQO=%d;USEDECLAREFETCH=%d;TEXTASLONGVARCHAR=%d;UNKNOWNSASLONGVARCHAR=%d;BOOLSASCHAR=%d;PARSE=%d;CANCELASFREESTMT=%d;EXTRASYSTABLEPREFIXES=%s", - ci->onlyread, - ci->protocol, - ci->fake_oid_index, - ci->show_oid_column, - ci->row_versioning, - ci->show_system_tables, - encoded_conn_settings, - ci->drivers.fetch_max, - ci->drivers.socket_buffersize, - ci->drivers.unknown_sizes, - ci->drivers.max_varchar_size, - ci->drivers.max_longvarchar_size, - ci->drivers.debug, - ci->drivers.commlog, - ci->drivers.disable_optimizer, - ci->drivers.ksqo, - ci->drivers.use_declarefetch, - ci->drivers.text_as_longvarchar, - ci->drivers.unknowns_as_longvarchar, - ci->drivers.bools_as_char, - ci->drivers.parse, - ci->drivers.cancel_as_freestmt, - ci->drivers.extra_systable_prefixes); + ";READONLY=%s;PROTOCOL=%s;FAKEOIDINDEX=%s;SHOWOIDCOLUMN=%s;ROWVERSIONING=%s;SHOWSYSTEMTABLES=%s;CONNSETTINGS=%s;FETCH=%d;SOCKET=%d;UNKNOWNSIZES=%d;MAXVARCHARSIZE=%d;MAXLONGVARCHARSIZE=%d;DEBUG=%d;COMMLOG=%d;OPTIMIZER=%d;KSQO=%d;USEDECLAREFETCH=%d;TEXTASLONGVARCHAR=%d;UNKNOWNSASLONGVARCHAR=%d;BOOLSASCHAR=%d;PARSE=%d;CANCELASFREESTMT=%d;EXTRASYSTABLEPREFIXES=%s", + ci->onlyread, + ci->protocol, + ci->fake_oid_index, + ci->show_oid_column, + ci->row_versioning, + ci->show_system_tables, + encoded_conn_settings, + ci->drivers.fetch_max, + ci->drivers.socket_buffersize, + ci->drivers.unknown_sizes, + ci->drivers.max_varchar_size, + ci->drivers.max_longvarchar_size, + ci->drivers.debug, + ci->drivers.commlog, + ci->drivers.disable_optimizer, + ci->drivers.ksqo, + ci->drivers.use_declarefetch, + ci->drivers.text_as_longvarchar, + ci->drivers.unknowns_as_longvarchar, + ci->drivers.bools_as_char, + ci->drivers.parse, + ci->drivers.cancel_as_freestmt, + ci->drivers.extra_systable_prefixes); /* Abbrebiation is needed ? */ if (abbrev || strlen(connect_string) >= len) sprintf(&connect_string[hlen], - ";A0=%s;A1=%s;A2=%s;A3=%s;A4=%s;A5=%s;A6=%s;A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s", - ci->onlyread, - ci->protocol, - ci->fake_oid_index, - ci->show_oid_column, - ci->row_versioning, - ci->show_system_tables, - encoded_conn_settings, - ci->drivers.fetch_max, - ci->drivers.socket_buffersize, - ci->drivers.unknown_sizes, - ci->drivers.max_varchar_size, - ci->drivers.max_longvarchar_size, - ci->drivers.debug, - ci->drivers.commlog, - ci->drivers.disable_optimizer, - ci->drivers.ksqo, - ci->drivers.use_declarefetch, - ci->drivers.text_as_longvarchar, - ci->drivers.unknowns_as_longvarchar, - ci->drivers.bools_as_char, - ci->drivers.parse, - ci->drivers.cancel_as_freestmt, - ci->drivers.extra_systable_prefixes); + ";A0=%s;A1=%s;A2=%s;A3=%s;A4=%s;A5=%s;A6=%s;A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s", + ci->onlyread, + ci->protocol, + ci->fake_oid_index, + ci->show_oid_column, + ci->row_versioning, + ci->show_system_tables, + encoded_conn_settings, + ci->drivers.fetch_max, + ci->drivers.socket_buffersize, + ci->drivers.unknown_sizes, + ci->drivers.max_varchar_size, + ci->drivers.max_longvarchar_size, + ci->drivers.debug, + ci->drivers.commlog, + ci->drivers.disable_optimizer, + ci->drivers.ksqo, + ci->drivers.use_declarefetch, + ci->drivers.text_as_longvarchar, + ci->drivers.unknowns_as_longvarchar, + ci->drivers.bools_as_char, + ci->drivers.parse, + ci->drivers.cancel_as_freestmt, + ci->drivers.extra_systable_prefixes); } void -copyAttributes(ConnInfo *ci, const char *attribute, const char *value) +copyAttributes(ConnInfo * ci, const char *attribute, const char *value) { if (stricmp(attribute, "DSN") == 0) strcpy(ci->dsn, value); @@ -618,19 +623,15 @@ copyAttributes(ConnInfo *ci, const char *attribute, const char *value) /* strcpy(ci->conn_settings, value); */ } else if (stricmp(attribute, INI_DISALLOWPREMATURE) == 0 || stricmp(attribute, "C3") == 0) - { ci->disallow_premature = atoi(value); - } else if (stricmp(attribute, INI_UPDATABLECURSORS) == 0 || stricmp(attribute, "C4") == 0) - { ci->updatable_cursors = atoi(value); - } mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s',conn_settings='%s',disallow_premature=%d)\n", ci->dsn, ci->server, ci->database, ci->username, ci->password, ci->port, ci->onlyread, ci->protocol, ci->conn_settings, ci->disallow_premature); } void -copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value) +copyCommonAttributes(ConnInfo * ci, const char *attribute, const char *value) { if (stricmp(attribute, INI_FETCH) == 0 || stricmp(attribute, "A7") == 0) ci->drivers.fetch_max = atoi(value); @@ -644,10 +645,12 @@ copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value) ci->drivers.disable_optimizer = atoi(value); else if (stricmp(attribute, INI_KSQO) == 0 || stricmp(attribute, "B5") == 0) ci->drivers.ksqo = atoi(value); + /* - else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 || stricmp(attribute, "UIX") == 0) - ci->drivers.unique_index = atoi(value); - */ + * else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 || + * stricmp(attribute, "UIX") == 0) ci->drivers.unique_index = + * atoi(value); + */ else if (stricmp(attribute, INI_UNKNOWNSIZES) == 0 || stricmp(attribute, "A9") == 0) ci->drivers.unknown_sizes = atoi(value); else if (stricmp(attribute, INI_LIE) == 0) @@ -671,27 +674,27 @@ copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value) else if (stricmp(attribute, INI_EXTRASYSTABLEPREFIXES) == 0 || stricmp(attribute, "C2") == 0) strcpy(ci->drivers.extra_systable_prefixes, value); mylog("CopyCommonAttributes: A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s", - ci->drivers.fetch_max, - ci->drivers.socket_buffersize, - ci->drivers.unknown_sizes, - ci->drivers.max_varchar_size, - ci->drivers.max_longvarchar_size, - ci->drivers.debug, - ci->drivers.commlog, - ci->drivers.disable_optimizer, - ci->drivers.ksqo, - ci->drivers.use_declarefetch, - ci->drivers.text_as_longvarchar, - ci->drivers.unknowns_as_longvarchar, - ci->drivers.bools_as_char, - ci->drivers.parse, - ci->drivers.cancel_as_freestmt, - ci->drivers.extra_systable_prefixes); + ci->drivers.fetch_max, + ci->drivers.socket_buffersize, + ci->drivers.unknown_sizes, + ci->drivers.max_varchar_size, + ci->drivers.max_longvarchar_size, + ci->drivers.debug, + ci->drivers.commlog, + ci->drivers.disable_optimizer, + ci->drivers.ksqo, + ci->drivers.use_declarefetch, + ci->drivers.text_as_longvarchar, + ci->drivers.unknowns_as_longvarchar, + ci->drivers.bools_as_char, + ci->drivers.parse, + ci->drivers.cancel_as_freestmt, + ci->drivers.extra_systable_prefixes); } void -getDSNdefaults(ConnInfo *ci) +getDSNdefaults(ConnInfo * ci) { if (ci->port[0] == '\0') strcpy(ci->port, DEFAULT_PORT); @@ -717,11 +720,11 @@ getDSNdefaults(ConnInfo *ci) void -getDSNinfo(ConnInfo *ci, char overwrite) +getDSNinfo(ConnInfo * ci, char overwrite) { char *DSN = ci->dsn; char encoded_conn_settings[LARGE_REGISTRY_LEN], - temp[SMALL_REGISTRY_LEN]; + temp[SMALL_REGISTRY_LEN]; /* * If a driver keyword was present, then dont use a DSN and return. @@ -837,11 +840,11 @@ getDSNinfo(ConnInfo *ci, char overwrite) /* This is for datasource based options only */ void -writeDSNinfo(const ConnInfo *ci) +writeDSNinfo(const ConnInfo * ci) { - const char *DSN = ci->dsn; + const char *DSN = ci->dsn; char encoded_conn_settings[LARGE_REGISTRY_LEN], - temp[SMALL_REGISTRY_LEN]; + temp[SMALL_REGISTRY_LEN]; encode(ci->conn_settings, encoded_conn_settings); @@ -910,12 +913,12 @@ writeDSNinfo(const ConnInfo *ci) encoded_conn_settings, ODBC_INI); - sprintf(temp, "%d", ci->disallow_premature); + sprintf(temp, "%d", ci->disallow_premature); SQLWritePrivateProfileString(DSN, INI_DISALLOWPREMATURE, temp, ODBC_INI); - sprintf(temp, "%d", ci->updatable_cursors); + sprintf(temp, "%d", ci->updatable_cursors); SQLWritePrivateProfileString(DSN, INI_UPDATABLECURSORS, temp, @@ -928,10 +931,10 @@ writeDSNinfo(const ConnInfo *ci) * the registry and gets any driver defaults. */ void -getCommonDefaults(const char *section, const char *filename, ConnInfo *ci) +getCommonDefaults(const char *section, const char *filename, ConnInfo * ci) { char temp[256]; - GLOBAL_VALUES *comval; + GLOBAL_VALUES *comval; if (ci) comval = &(ci->drivers); @@ -1101,13 +1104,12 @@ getCommonDefaults(const char *section, const char *filename, ConnInfo *ci) /* Dont allow override of an override! */ if (!ci) { - /* * ConnSettings is stored in the driver section and per datasource * for override */ SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "", - comval->conn_settings, sizeof(comval->conn_settings), filename); + comval->conn_settings, sizeof(comval->conn_settings), filename); /* Default state for future DSN's Readonly attribute */ SQLGetPrivateProfileString(section, INI_READONLY, "", diff --git a/src/interfaces/odbc/dlg_specific.h b/src/interfaces/odbc/dlg_specific.h index 4a221469b0..b1ec7090c0 100644 --- a/src/interfaces/odbc/dlg_specific.h +++ b/src/interfaces/odbc/dlg_specific.h @@ -120,11 +120,11 @@ #define DEFAULT_EXTRASYSTABLEPREFIXES "dd_;" /* prototypes */ -void getCommonDefaults(const char *section, const char *filename, ConnInfo *ci); +void getCommonDefaults(const char *section, const char *filename, ConnInfo * ci); #ifdef WIN32 -void SetDlgStuff(HWND hdlg, const ConnInfo *ci); -void GetDlgStuff(HWND hdlg, ConnInfo *ci); +void SetDlgStuff(HWND hdlg, const ConnInfo * ci); +void GetDlgStuff(HWND hdlg, ConnInfo * ci); int CALLBACK driver_optionsProc(HWND hdlg, WORD wMsg, @@ -134,16 +134,14 @@ int CALLBACK ds_optionsProc(HWND hdlg, WORD wMsg, WPARAM wParam, LPARAM lParam); - #endif /* WIN32 */ void updateGlobals(void); -void writeDSNinfo(const ConnInfo *ci); -void getDSNdefaults(ConnInfo *ci); -void getDSNinfo(ConnInfo *ci, char overwrite); -void makeConnectString(char *connect_string, const ConnInfo *ci, UWORD); -void copyAttributes(ConnInfo *ci, const char *attribute, const char *value); -void copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value); - +void writeDSNinfo(const ConnInfo * ci); +void getDSNdefaults(ConnInfo * ci); +void getDSNinfo(ConnInfo * ci, char overwrite); +void makeConnectString(char *connect_string, const ConnInfo * ci, UWORD); +void copyAttributes(ConnInfo * ci, const char *attribute, const char *value); +void copyCommonAttributes(ConnInfo * ci, const char *attribute, const char *value); #endif diff --git a/src/interfaces/odbc/drvconn.c b/src/interfaces/odbc/drvconn.c index b2fa55345e..ce95296e54 100644 --- a/src/interfaces/odbc/drvconn.c +++ b/src/interfaces/odbc/drvconn.c @@ -45,28 +45,27 @@ #include "dlg_specific.h" /* prototypes */ -void dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci); -static void dconn_get_common_attributes(const UCHAR FAR *connect_string, ConnInfo *ci); +void dconn_get_connect_attributes(const UCHAR FAR * connect_string, ConnInfo * ci); +static void dconn_get_common_attributes(const UCHAR FAR * connect_string, ConnInfo * ci); #ifdef WIN32 BOOL FAR PASCAL dconn_FDriverConnectProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam); -RETCODE dconn_DoDialog(HWND hwnd, ConnInfo *ci); - -extern HINSTANCE NEAR s_hModule;/* Saved module handle. */ +RETCODE dconn_DoDialog(HWND hwnd, ConnInfo * ci); +extern HINSTANCE NEAR s_hModule; /* Saved module handle. */ #endif -RETCODE SQL_API +RETCODE SQL_API PGAPI_DriverConnect( - HDBC hdbc, - HWND hwnd, - UCHAR FAR *szConnStrIn, - SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, - SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut, - UWORD fDriverCompletion) + HDBC hdbc, + HWND hwnd, + UCHAR FAR * szConnStrIn, + SWORD cbConnStrIn, + UCHAR FAR * szConnStrOut, + SWORD cbConnStrOutMax, + SWORD FAR * pcbConnStrOut, + UWORD fDriverCompletion) { static char *func = "PGAPI_DriverConnect"; ConnectionClass *conn = (ConnectionClass *) hdbc; @@ -74,7 +73,6 @@ PGAPI_DriverConnect( #ifdef WIN32 RETCODE dialog_result; - #endif RETCODE result; char connStrIn[MAX_CONNECT_STRING]; @@ -208,13 +206,12 @@ dialog: lenStrout = cbConnStrOutMax; if (conn->ms_jet && lenStrout > 255) - lenStrout = 255; + lenStrout = 255; makeConnectString(connStrOut, ci, lenStrout); len = strlen(connStrOut); if (szConnStrOut) { - /* * Return the completed string to the caller. The correct method * is to only construct the connect string if a dialog was put up, @@ -228,7 +225,8 @@ dialog: if (len >= cbConnStrOutMax) { - int clen; + int clen; + for (clen = strlen(szConnStrOut) - 1; clen >= 0 && szConnStrOut[clen] != ';'; clen--) szConnStrOut[clen] = '\0'; result = SQL_SUCCESS_WITH_INFO; @@ -251,7 +249,7 @@ dialog: #ifdef WIN32 RETCODE -dconn_DoDialog(HWND hwnd, ConnInfo *ci) +dconn_DoDialog(HWND hwnd, ConnInfo * ci) { int dialog_result; @@ -327,7 +325,7 @@ dconn_FDriverConnectProc( case IDC_DRIVER: ci = (ConnInfo *) GetWindowLong(hdlg, DWL_USER); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV), - hdlg, driver_optionsProc, (LPARAM) ci); + hdlg, driver_optionsProc, (LPARAM) ci); break; case IDC_DATASOURCE: @@ -340,12 +338,11 @@ dconn_FDriverConnectProc( return FALSE; } - #endif /* WIN32 */ void -dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci) +dconn_get_connect_attributes(const UCHAR FAR * connect_string, ConnInfo * ci) { char *our_connect_string; char *pair, @@ -357,7 +354,7 @@ dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci) memset(ci, 0, sizeof(ConnInfo)); #ifdef DRIVER_CURSOR_IMPLEMENT ci->updatable_cursors = 1; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ our_connect_string = strdup(connect_string); strtok_arg = our_connect_string; @@ -394,7 +391,7 @@ dconn_get_connect_attributes(const UCHAR FAR *connect_string, ConnInfo *ci) } static void -dconn_get_common_attributes(const UCHAR FAR *connect_string, ConnInfo *ci) +dconn_get_common_attributes(const UCHAR FAR * connect_string, ConnInfo * ci) { char *our_connect_string; char *pair, diff --git a/src/interfaces/odbc/environ.c b/src/interfaces/odbc/environ.c index 072987f165..c36c300caf 100644 --- a/src/interfaces/odbc/environ.c +++ b/src/interfaces/odbc/environ.c @@ -28,8 +28,8 @@ extern GLOBAL_VALUES globals; ConnectionClass *conns[MAX_CONNECTIONS]; -RETCODE SQL_API -PGAPI_AllocEnv(HENV FAR *phenv) +RETCODE SQL_API +PGAPI_AllocEnv(HENV FAR * phenv) { static char *func = "PGAPI_AllocEnv"; @@ -58,7 +58,7 @@ PGAPI_AllocEnv(HENV FAR *phenv) } -RETCODE SQL_API +RETCODE SQL_API PGAPI_FreeEnv(HENV henv) { static char *func = "PGAPI_FreeEnv"; @@ -79,21 +79,21 @@ PGAPI_FreeEnv(HENV henv) /* Returns the next SQL error information. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Error( - HENV henv, - HDBC hdbc, - HSTMT hstmt, - UCHAR FAR *szSqlState, - SDWORD FAR *pfNativeError, - UCHAR FAR *szErrorMsg, - SWORD cbErrorMsgMax, - SWORD FAR *pcbErrorMsg) + HENV henv, + HDBC hdbc, + HSTMT hstmt, + UCHAR FAR * szSqlState, + SDWORD FAR * pfNativeError, + UCHAR FAR * szErrorMsg, + SWORD cbErrorMsgMax, + SWORD FAR * pcbErrorMsg) { char *msg; int status; - BOOL once_again = FALSE; - SWORD msglen; + BOOL once_again = FALSE; + SWORD msglen; mylog("**** PGAPI_Error: henv=%u, hdbc=%u, hstmt=%u <%d>\n", henv, hdbc, hstmt, cbErrorMsgMax); @@ -212,7 +212,7 @@ PGAPI_Error( strcpy(szSqlState, "07006"); break; case STMT_INVALID_CURSOR_STATE_ERROR: - strcpy(szSqlState, "24000"); + strcpy(szSqlState, "24000"); break; case STMT_OPTION_VALUE_CHANGED: strcpy(szSqlState, "01S02"); @@ -266,7 +266,8 @@ PGAPI_Error( if (once_again) { - int outlen; + int outlen; + stmt->errornumber = status; if (cbErrorMsgMax > 0) outlen = *pcbErrorMsg; @@ -493,7 +494,7 @@ EN_Constructor(void) char -EN_Destructor(EnvironmentClass *self) +EN_Destructor(EnvironmentClass * self) { int lf; char rv = 1; @@ -515,14 +516,14 @@ EN_Destructor(EnvironmentClass *self) mylog("exit EN_Destructor: rv = %d\n", rv); #ifdef _MEMORY_DEBUG_ -debug_memory_inouecheck(); -#endif /* _MEMORY_DEBUG_ */ + debug_memory_inouecheck(); +#endif /* _MEMORY_DEBUG_ */ return rv; } char -EN_get_error(EnvironmentClass *self, int *number, char **message) +EN_get_error(EnvironmentClass * self, int *number, char **message) { if (self && self->errormsg && self->errornumber) { @@ -538,7 +539,7 @@ EN_get_error(EnvironmentClass *self, int *number, char **message) char -EN_add_connection(EnvironmentClass *self, ConnectionClass *conn) +EN_add_connection(EnvironmentClass * self, ConnectionClass * conn) { int i; @@ -562,7 +563,7 @@ EN_add_connection(EnvironmentClass *self, ConnectionClass *conn) char -EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn) +EN_remove_connection(EnvironmentClass * self, ConnectionClass * conn) { int i; @@ -578,7 +579,7 @@ EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn) void -EN_log_error(char *func, char *desc, EnvironmentClass *self) +EN_log_error(char *func, char *desc, EnvironmentClass * self) { if (self) qlog("ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->errornumber, self->errormsg); diff --git a/src/interfaces/odbc/environ.h b/src/interfaces/odbc/environ.h index 7b463b3e74..a99a4e5a28 100644 --- a/src/interfaces/odbc/environ.h +++ b/src/interfaces/odbc/environ.h @@ -22,10 +22,9 @@ struct EnvironmentClass_ /* Environment prototypes */ EnvironmentClass *EN_Constructor(void); -char EN_Destructor(EnvironmentClass *self); -char EN_get_error(EnvironmentClass *self, int *number, char **message); -char EN_add_connection(EnvironmentClass *self, ConnectionClass *conn); -char EN_remove_connection(EnvironmentClass *self, ConnectionClass *conn); -void EN_log_error(char *func, char *desc, EnvironmentClass *self); - +char EN_Destructor(EnvironmentClass * self); +char EN_get_error(EnvironmentClass * self, int *number, char **message); +char EN_add_connection(EnvironmentClass * self, ConnectionClass * conn); +char EN_remove_connection(EnvironmentClass * self, ConnectionClass * conn); +void EN_log_error(char *func, char *desc, EnvironmentClass * self); #endif diff --git a/src/interfaces/odbc/execute.c b/src/interfaces/odbc/execute.c index 991407975e..5a693b7163 100644 --- a/src/interfaces/odbc/execute.c +++ b/src/interfaces/odbc/execute.c @@ -31,10 +31,10 @@ /* Perform a Prepare on the SQL statement */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Prepare(HSTMT hstmt, - UCHAR FAR *szSqlStr, - SDWORD cbSqlStr) + UCHAR FAR * szSqlStr, + SDWORD cbSqlStr) { static char *func = "PGAPI_Prepare"; StatementClass *self = (StatementClass *) hstmt; @@ -121,11 +121,11 @@ PGAPI_Prepare(HSTMT hstmt, /* Performs the equivalent of SQLPrepare, followed by SQLExecute. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ExecDirect( - HSTMT hstmt, - UCHAR FAR *szSqlStr, - SDWORD cbSqlStr) + HSTMT hstmt, + UCHAR FAR * szSqlStr, + SDWORD cbSqlStr) { StatementClass *stmt = (StatementClass *) hstmt; RETCODE result; @@ -188,9 +188,9 @@ PGAPI_ExecDirect( /* Execute a prepared SQL statement */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Execute( - HSTMT hstmt) + HSTMT hstmt) { static char *func = "PGAPI_Execute"; StatementClass *stmt = (StatementClass *) hstmt; @@ -284,7 +284,6 @@ PGAPI_Execute( */ if (!stmt->pre_executing) { - /* * The bound parameters could have possibly changed since the last * execute of this statement? Therefore check for params and @@ -333,17 +332,19 @@ PGAPI_Execute( return retval; mylog(" stmt_with_params = '%s'\n", stmt->stmt_with_params); + /* - * Get the field info for the prepared - * query using dummy backward fetch. + * Get the field info for the prepared query using dummy backward + * fetch. */ if (stmt->inaccurate_result && conn->connInfo.disallow_premature) { if (SC_is_pre_executable(stmt)) { - BOOL in_trans = CC_is_in_trans(conn); - BOOL issued_begin = FALSE, begin_included = FALSE; - QResultClass *res; + BOOL in_trans = CC_is_in_trans(conn); + BOOL issued_begin = FALSE, + begin_included = FALSE; + QResultClass *res; if (strnicmp(stmt->stmt_with_params, "BEGIN;", 6) == 0) begin_included = TRUE; @@ -384,8 +385,8 @@ PGAPI_Execute( } else if (!in_trans && begin_included) CC_set_no_trans(conn); - } - stmt->status =STMT_FINISHED; + } + stmt->status = STMT_FINISHED; return SQL_SUCCESS; } } @@ -397,11 +398,11 @@ PGAPI_Execute( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Transact( - HENV henv, - HDBC hdbc, - UWORD fType) + HENV henv, + HDBC hdbc, + UWORD fType) { static char *func = "PGAPI_Transact"; extern ConnectionClass *conns[]; @@ -478,19 +479,18 @@ PGAPI_Transact( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Cancel( - HSTMT hstmt) /* Statement to cancel. */ + HSTMT hstmt) /* Statement to cancel. */ { static char *func = "PGAPI_Cancel"; StatementClass *stmt = (StatementClass *) hstmt; RETCODE result; - ConnInfo *ci; + ConnInfo *ci; #ifdef WIN32 HMODULE hmodule; FARPROC addr; - #endif mylog("%s: entering...\n", func); @@ -509,7 +509,6 @@ PGAPI_Cancel( */ if (stmt->data_at_exec < 0) { - /* * MAJOR HACK for Windows to reset the driver manager's cursor * state: Because of what seems like a bug in the Odbc driver @@ -559,14 +558,14 @@ PGAPI_Cancel( * Currently, just copy the input string without modification * observing buffer limits and truncation. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_NativeSql( - HDBC hdbc, - UCHAR FAR *szSqlStrIn, - SDWORD cbSqlStrIn, - UCHAR FAR *szSqlStr, - SDWORD cbSqlStrMax, - SDWORD FAR *pcbSqlStr) + HDBC hdbc, + UCHAR FAR * szSqlStrIn, + SDWORD cbSqlStrIn, + UCHAR FAR * szSqlStr, + SDWORD cbSqlStrMax, + SDWORD FAR * pcbSqlStr) { static char *func = "PGAPI_NativeSql"; int len = 0; @@ -614,16 +613,16 @@ PGAPI_NativeSql( * Supplies parameter data at execution time. * Used in conjuction with SQLPutData. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ParamData( - HSTMT hstmt, - PTR FAR *prgbValue) + HSTMT hstmt, + PTR FAR * prgbValue) { static char *func = "PGAPI_ParamData"; StatementClass *stmt = (StatementClass *) hstmt; int i, retval; - ConnInfo *ci; + ConnInfo *ci; mylog("%s: entering...\n", func); @@ -724,11 +723,11 @@ PGAPI_ParamData( * Supplies parameter data at execution time. * Used in conjunction with SQLParamData. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_PutData( - HSTMT hstmt, - PTR rgbValue, - SDWORD cbValue) + HSTMT hstmt, + PTR rgbValue, + SDWORD cbValue) { static char *func = "PGAPI_PutData"; StatementClass *stmt = (StatementClass *) hstmt; diff --git a/src/interfaces/odbc/gpps.c b/src/interfaces/odbc/gpps.c index 5128966c02..658829a5fd 100644 --- a/src/interfaces/odbc/gpps.c +++ b/src/interfaces/odbc/gpps.c @@ -50,21 +50,21 @@ /* * theIniFileName is searched for in: - * $HOME/theIniFileName - * theIniFileName - * ODBCINSTDIR/ODBCINST_INI + * $HOME/theIniFileName + * theIniFileName + * ODBCINSTDIR/ODBCINST_INI */ DWORD -GetPrivateProfileString(const char *theSection, /* section name */ - const char *theKey, /* search key name */ - const char *theDefault, /* default value if not +GetPrivateProfileString(const char *theSection, /* section name */ + const char *theKey, /* search key name */ + const char *theDefault, /* default value if not * found */ char *theReturnBuffer, /* return value stored * here */ size_t theReturnBufferLength, /* byte length of return * buffer */ - const char *theIniFileName) /* pathname of ini file to - * search */ + const char *theIniFileName) /* pathname of ini file + * to search */ { char buf[MAXPGPATH]; char *ptr = 0; @@ -84,13 +84,13 @@ GetPrivateProfileString(const char *theSection, /* section name */ if (ptr == NULL || (((struct passwd *) ptr)->pw_dir) == NULL || *(((struct passwd *) ptr)->pw_dir) == '\0') ptr = "/home"; else - ptr = ((struct passwd *) ptr)->pw_dir; /* get user home dir */ + ptr = ((struct passwd *) ptr)->pw_dir; /* get user home dir */ /* - * If it can't be opened because the paths are too long, then - * skip it, don't just truncate the path string... The truncated path - * might accidently be an existing file. The default value will be - * returned instead. + * If it can't be opened because the paths are too long, then skip it, + * don't just truncate the path string... The truncated path might + * accidently be an existing file. The default value will be returned + * instead. */ if (MAXPGPATH - 1 >= strlen(ptr) + 1 + strlen(theIniFileName)) { @@ -278,10 +278,10 @@ GetPrivateProfileString(const char *theSection, /* section name */ DWORD WritePrivateProfileString(const char *theSection, /* section name */ - const char *theKey, /* write key name */ + const char *theKey, /* write key name */ const char *theBuffer, /* input buffer */ - const char *theIniFileName) /* pathname of ini file to - * write */ + const char *theIniFileName) /* pathname of ini file + * to write */ { return 0; } @@ -449,8 +449,6 @@ if (!keyFound) return aReturnLength > 0 ? aReturnLength - 1 : 0; } +#endif /* NOT_USED */ -#endif /* NOT_USED */ - - -#endif /* not WIN32 */ +#endif /* not WIN32 */ diff --git a/src/interfaces/odbc/gpps.h b/src/interfaces/odbc/gpps.h index 48b6722573..f44a266f39 100644 --- a/src/interfaces/odbc/gpps.h +++ b/src/interfaces/odbc/gpps.h @@ -18,28 +18,27 @@ extern "C" { #endif - DWORD - GetPrivateProfileString(const char *theSection, /* section name */ - const char *theKey, /* search key name */ - const char *theDefault, /* default value if not - * found */ + DWORD + GetPrivateProfileString(const char *theSection, /* section name */ + const char *theKey, /* search key name */ + const char *theDefault, /* default value if not + * found */ char *theReturnBuffer, /* return valuse stored * here */ size_t theBufferLength, /* byte length of return * buffer */ - const char *theIniFileName); /* pathname of ini file + const char *theIniFileName); /* pathname of ini file * to search */ - DWORD + DWORD WritePrivateProfileString(const char *theSection, /* section name */ const char *theKey, /* write key name */ - const char *theBuffer, /* input buffer */ - const char *theIniFileName); /* pathname of ini file + const char *theBuffer, /* input buffer */ + const char *theIniFileName); /* pathname of ini file * to write */ #ifdef __cplusplus } - #endif #ifndef WIN32 diff --git a/src/interfaces/odbc/info.c b/src/interfaces/odbc/info.c index 5f4059bd2d..0752ab03ab 100644 --- a/src/interfaces/odbc/info.c +++ b/src/interfaces/odbc/info.c @@ -49,13 +49,13 @@ -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetInfo( - HDBC hdbc, - UWORD fInfoType, - PTR rgbInfoValue, - SWORD cbInfoValueMax, - SWORD FAR *pcbInfoValue) + HDBC hdbc, + UWORD fInfoType, + PTR rgbInfoValue, + SWORD cbInfoValueMax, + SWORD FAR * pcbInfoValue) { static char *func = "PGAPI_GetInfo"; ConnectionClass *conn = (ConnectionClass *) hdbc; @@ -219,16 +219,20 @@ PGAPI_GetInfo( #ifdef DRIVER_CURSOR_IMPLEMENT { static char dver[32]; + SQLGetPrivateProfileString(DBMS_NAME, - "DriverODBCVer", "", dver, sizeof(dver), "odbcinst.ini"); + "DriverODBCVer", "", dver, sizeof(dver), "odbcinst.ini"); if (dver[0]) { - int major, minor; + int major, + minor; + mylog("REGISTRY_ODBC_VER = %s\n", dver) -; + ; if (sscanf(dver, "%x.%x", &major, &minor) >= 2) { - Int2 drv_ver = (major << 8) + minor; + Int2 drv_ver = (major << 8) + minor; + if (drv_ver > ODBCVER) { conn->driver_version = drv_ver; @@ -237,7 +241,7 @@ PGAPI_GetInfo( } } } -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ break; case SQL_DRIVER_VER: /* ODBC 1.0 */ @@ -520,8 +524,8 @@ PGAPI_GetInfo( case SQL_POSITIONED_STATEMENTS: /* ODBC 2.0 */ len = 4; value = ci->drivers.lie ? (SQL_PS_POSITIONED_DELETE | - SQL_PS_POSITIONED_UPDATE | - SQL_PS_SELECT_FOR_UPDATE) : 0; + SQL_PS_POSITIONED_UPDATE | + SQL_PS_SELECT_FOR_UPDATE) : 0; break; case SQL_PROCEDURE_TERM: /* ODBC 1.0 */ @@ -568,10 +572,10 @@ PGAPI_GetInfo( case SQL_SCROLL_CONCURRENCY: /* ODBC 1.0 */ len = 4; value = ci->drivers.lie ? (SQL_SCCO_READ_ONLY | - SQL_SCCO_LOCK | - SQL_SCCO_OPT_ROWVER | - SQL_SCCO_OPT_VALUES) : - (SQL_SCCO_READ_ONLY); + SQL_SCCO_LOCK | + SQL_SCCO_OPT_ROWVER | + SQL_SCCO_OPT_VALUES) : + (SQL_SCCO_READ_ONLY); if (ci->updatable_cursors) value |= SQL_SCCO_OPT_ROWVER; break; @@ -579,13 +583,13 @@ PGAPI_GetInfo( case SQL_SCROLL_OPTIONS: /* ODBC 1.0 */ len = 4; value = ci->drivers.lie ? (SQL_SO_FORWARD_ONLY | - SQL_SO_STATIC | - SQL_SO_KEYSET_DRIVEN | - SQL_SO_DYNAMIC | - SQL_SO_MIXED) - : (ci->drivers.use_declarefetch ? SQL_SO_FORWARD_ONLY : (SQL_SO_FORWARD_ONLY | SQL_SO_STATIC)); + SQL_SO_STATIC | + SQL_SO_KEYSET_DRIVEN | + SQL_SO_DYNAMIC | + SQL_SO_MIXED) + : (ci->drivers.use_declarefetch ? SQL_SO_FORWARD_ONLY : (SQL_SO_FORWARD_ONLY | SQL_SO_STATIC)); if (ci->updatable_cursors) - value |= 0; /* SQL_SO_KEYSET_DRIVEN in the furure */ + value |= 0; /* SQL_SO_KEYSET_DRIVEN in the furure */ break; case SQL_SEARCH_PATTERN_ESCAPE: /* ODBC 1.0 */ @@ -730,10 +734,10 @@ PGAPI_GetInfo( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetTypeInfo( - HSTMT hstmt, - SWORD fSqlType) + HSTMT hstmt, + SWORD fSqlType) { static char *func = "PGAPI_GetTypeInfo"; StatementClass *stmt = (StatementClass *) hstmt; @@ -785,7 +789,7 @@ PGAPI_GetTypeInfo( if (fSqlType == SQL_ALL_TYPES || fSqlType == sqlType) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (15 - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (15 - 1) * sizeof(TupleField)); /* These values can't be NULL */ set_tuplefield_string(&row->tuple[0], pgtype_to_name(stmt, pgType)); @@ -824,15 +828,15 @@ PGAPI_GetTypeInfo( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetFunctions( - HDBC hdbc, - UWORD fFunction, - UWORD FAR *pfExists) + HDBC hdbc, + UWORD fFunction, + UWORD FAR * pfExists) { static char *func = "PGAPI_GetFunctions"; - ConnectionClass *conn = (ConnectionClass *)hdbc; - ConnInfo *ci = &(conn->connInfo); + ConnectionClass *conn = (ConnectionClass *) hdbc; + ConnInfo *ci = &(conn->connInfo); mylog("%s: entering...%u\n", func, fFunction); @@ -1114,17 +1118,17 @@ PGAPI_GetFunctions( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Tables( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UCHAR FAR *szTableType, - SWORD cbTableType) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UCHAR FAR * szTableType, + SWORD cbTableType) { static char *func = "PGAPI_Tables"; StatementClass *stmt = (StatementClass *) hstmt; @@ -1274,7 +1278,7 @@ PGAPI_Tables( } result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_CHAR, - table_name, MAX_INFO_STRING, NULL); + table_name, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -1285,7 +1289,7 @@ PGAPI_Tables( } result = PGAPI_BindCol(htbl_stmt, 2, SQL_C_CHAR, - table_owner, MAX_INFO_STRING, NULL); + table_owner, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -1295,7 +1299,7 @@ PGAPI_Tables( return SQL_ERROR; } result = PGAPI_BindCol(htbl_stmt, 3, SQL_C_CHAR, - relkind_or_hasrules, MAX_INFO_STRING, NULL); + relkind_or_hasrules, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -1335,7 +1339,6 @@ PGAPI_Tables( result = PGAPI_Fetch(htbl_stmt); while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { - /* * Determine if this table name is a system table. If treating * system tables as regular tables, then no need to do this test. @@ -1384,7 +1387,7 @@ PGAPI_Tables( (view && show_views) || (regular_table && show_regular_tables)) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (5 - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (5 - 1) * sizeof(TupleField)); set_tuplefield_string(&row->tuple[0], ""); @@ -1434,17 +1437,17 @@ PGAPI_Tables( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Columns( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UCHAR FAR *szColumnName, - SWORD cbColumnName) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UCHAR FAR * szColumnName, + SWORD cbColumnName) { static char *func = "PGAPI_Columns"; StatementClass *stmt = (StatementClass *) hstmt; @@ -1520,7 +1523,7 @@ PGAPI_Columns( mylog("%s: hcol_stmt = %u, col_stmt = %u\n", func, hcol_stmt, col_stmt); result = PGAPI_ExecDirect(hcol_stmt, columns_query, - strlen(columns_query)); + strlen(columns_query)); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = SC_create_errormsg(hcol_stmt); @@ -1531,7 +1534,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 1, SQL_C_CHAR, - table_owner, MAX_INFO_STRING, NULL); + table_owner, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1542,7 +1545,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 2, SQL_C_CHAR, - table_name, MAX_INFO_STRING, NULL); + table_name, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1553,7 +1556,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 3, SQL_C_CHAR, - field_name, MAX_INFO_STRING, NULL); + field_name, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1564,7 +1567,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 4, SQL_C_LONG, - &field_type, 4, NULL); + &field_type, 4, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1575,7 +1578,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 5, SQL_C_CHAR, - field_type_name, MAX_INFO_STRING, NULL); + field_type_name, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1586,7 +1589,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 6, SQL_C_SHORT, - &field_number, MAX_INFO_STRING, NULL); + &field_number, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1597,7 +1600,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 7, SQL_C_LONG, - &field_length, MAX_INFO_STRING, NULL); + &field_length, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1608,7 +1611,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 8, SQL_C_LONG, - &mod_length, MAX_INFO_STRING, NULL); + &mod_length, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1619,7 +1622,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 9, SQL_C_CHAR, - not_null, MAX_INFO_STRING, NULL); + not_null, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1630,7 +1633,7 @@ PGAPI_Columns( } result = PGAPI_BindCol(hcol_stmt, 10, SQL_C_CHAR, - relhasrules, MAX_INFO_STRING, NULL); + relhasrules, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1695,7 +1698,7 @@ PGAPI_Columns( /* For OID fields */ the_type = PG_TYPE_OID; row = (TupleNode *) malloc(sizeof(TupleNode) + - (result_cols - 1) *sizeof(TupleField)); + (result_cols - 1) * sizeof(TupleField)); set_tuplefield_string(&row->tuple[0], ""); /* see note in SQLTables() */ @@ -1724,7 +1727,7 @@ PGAPI_Columns( while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { row = (TupleNode *) malloc(sizeof(TupleNode) + - (result_cols - 1) *sizeof(TupleField)); + (result_cols - 1) * sizeof(TupleField)); set_tuplefield_string(&row->tuple[0], ""); @@ -1758,7 +1761,7 @@ PGAPI_Columns( if (field_type == PG_TYPE_NUMERIC) { if (mod_length >= 4) - mod_length -= 4;/* the length is in atttypmod - 4 */ + mod_length -= 4; /* the length is in atttypmod - 4 */ if (mod_length >= 0) { @@ -1782,7 +1785,7 @@ PGAPI_Columns( useStaticPrecision = FALSE; if (mod_length >= 4) - mod_length -= 4;/* the length is in atttypmod - 4 */ + mod_length -= 4; /* the length is in atttypmod - 4 */ if (mod_length > ci->drivers.max_varchar_size || mod_length <= 0) mod_length = ci->drivers.max_varchar_size; @@ -1835,7 +1838,7 @@ PGAPI_Columns( the_type = PG_TYPE_INT4; row = (TupleNode *) malloc(sizeof(TupleNode) + - (result_cols - 1) *sizeof(TupleField)); + (result_cols - 1) * sizeof(TupleField)); set_tuplefield_string(&row->tuple[0], ""); set_tuplefield_string(&row->tuple[1], ""); @@ -1872,18 +1875,18 @@ PGAPI_Columns( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_SpecialColumns( - HSTMT hstmt, - UWORD fColType, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UWORD fScope, - UWORD fNullable) + HSTMT hstmt, + UWORD fColType, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UWORD fScope, + UWORD fNullable) { static char *func = "PGAPI_SpecialColumns"; TupleNode *row; @@ -1930,7 +1933,7 @@ PGAPI_SpecialColumns( mylog("%s: hcol_stmt = %u, col_stmt = %u\n", func, hcol_stmt, col_stmt); result = PGAPI_ExecDirect(hcol_stmt, columns_query, - strlen(columns_query)); + strlen(columns_query)); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = SC_create_errormsg(hcol_stmt); @@ -1941,7 +1944,7 @@ PGAPI_SpecialColumns( } result = PGAPI_BindCol(hcol_stmt, 1, SQL_C_CHAR, - relhasrules, MAX_INFO_STRING, NULL); + relhasrules, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -1972,7 +1975,7 @@ PGAPI_SpecialColumns( /* use the oid value for the rowid */ if (fColType == SQL_BEST_ROWID) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField)); set_tuplefield_int2(&row->tuple[0], SQL_SCOPE_SESSION); set_tuplefield_string(&row->tuple[1], "oid"); @@ -1992,7 +1995,7 @@ PGAPI_SpecialColumns( if (atoi(ci->row_versioning)) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (8 - 1) * sizeof(TupleField)); set_tuplefield_null(&row->tuple[0]); set_tuplefield_string(&row->tuple[1], "xmin"); @@ -2018,17 +2021,17 @@ PGAPI_SpecialColumns( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Statistics( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UWORD fUnique, - UWORD fAccuracy) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UWORD fUnique, + UWORD fAccuracy) { static char *func = "PGAPI_Statistics"; StatementClass *stmt = (StatementClass *) hstmt; @@ -2136,7 +2139,7 @@ PGAPI_Statistics( */ col_stmt->internal = TRUE; result = PGAPI_Columns(hcol_stmt, "", 0, "", 0, - table_name, (SWORD) strlen(table_name), "", 0); + table_name, (SWORD) strlen(table_name), "", 0); col_stmt->internal = FALSE; if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) @@ -2148,7 +2151,7 @@ PGAPI_Statistics( goto SEEYA; } result = PGAPI_BindCol(hcol_stmt, 4, SQL_C_CHAR, - column_name, MAX_INFO_STRING, &column_name_len); + column_name, MAX_INFO_STRING, &column_name_len); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = col_stmt->errormsg; @@ -2206,7 +2209,7 @@ PGAPI_Statistics( " and d.oid = i.indrelid" " and i.indexrelid = c.oid" " and c.relam = a.oid" - , table_name); + ,table_name); if (PG_VERSION_GT(SC_get_conn(stmt), 6.4)) strcat(index_query, " order by i.indisprimary desc"); @@ -2226,7 +2229,7 @@ PGAPI_Statistics( /* bind the index name column */ result = PGAPI_BindCol(hindx_stmt, 1, SQL_C_CHAR, - index_name, MAX_INFO_STRING, &index_name_len); + index_name, MAX_INFO_STRING, &index_name_len); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2238,7 +2241,7 @@ PGAPI_Statistics( } /* bind the vector column */ result = PGAPI_BindCol(hindx_stmt, 2, SQL_C_DEFAULT, - fields_vector, 32, &fields_vector_len); + fields_vector, 32, &fields_vector_len); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2250,7 +2253,7 @@ PGAPI_Statistics( } /* bind the "is unique" column */ result = PGAPI_BindCol(hindx_stmt, 3, SQL_C_CHAR, - isunique, sizeof(isunique), NULL); + isunique, sizeof(isunique), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2262,7 +2265,7 @@ PGAPI_Statistics( /* bind the "is clustered" column */ result = PGAPI_BindCol(hindx_stmt, 4, SQL_C_CHAR, - isclustered, sizeof(isclustered), NULL); + isclustered, sizeof(isclustered), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2275,7 +2278,7 @@ PGAPI_Statistics( /* bind the "is hash" column */ result = PGAPI_BindCol(hindx_stmt, 5, SQL_C_CHAR, - ishash, sizeof(ishash), NULL); + ishash, sizeof(ishash), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column @@ -2287,7 +2290,7 @@ PGAPI_Statistics( } result = PGAPI_BindCol(hindx_stmt, 6, SQL_C_CHAR, - relhasrules, MAX_INFO_STRING, NULL); + relhasrules, MAX_INFO_STRING, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = indx_stmt->errormsg; @@ -2300,7 +2303,7 @@ PGAPI_Statistics( if (relhasrules[0] != '1' && atoi(ci->show_oid_column) && atoi(ci->fake_oid_index)) { row = (TupleNode *) malloc(sizeof(TupleNode) + - (13 - 1) *sizeof(TupleField)); + (13 - 1) * sizeof(TupleField)); /* no table qualifier */ set_tuplefield_string(&row->tuple[0], ""); @@ -2344,7 +2347,7 @@ PGAPI_Statistics( while (i < 16 && fields_vector[i] != 0) { row = (TupleNode *) malloc(sizeof(TupleNode) + - (13 - 1) *sizeof(TupleField)); + (13 - 1) * sizeof(TupleField)); /* no table qualifier */ set_tuplefield_string(&row->tuple[0], ""); @@ -2366,8 +2369,8 @@ PGAPI_Statistics( * Clustered/HASH index? */ set_tuplefield_int2(&row->tuple[6], (Int2) - (atoi(isclustered) ? SQL_INDEX_CLUSTERED : - (!strncmp(ishash, "hash", 4)) ? SQL_INDEX_HASHED : SQL_INDEX_OTHER)); + (atoi(isclustered) ? SQL_INDEX_CLUSTERED : + (!strncmp(ishash, "hash", 4)) ? SQL_INDEX_HASHED : SQL_INDEX_OTHER)); set_tuplefield_int2(&row->tuple[7], (Int2) (i + 1)); if (fields_vector[i] == OID_ATTNUM) @@ -2441,17 +2444,17 @@ SEEYA: } -RETCODE SQL_API +RETCODE SQL_API PGAPI_ColumnPrivileges( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName, - UCHAR FAR *szColumnName, - SWORD cbColumnName) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName, + UCHAR FAR * szColumnName, + SWORD cbColumnName) { static char *func = "PGAPI_ColumnPrivileges"; @@ -2469,15 +2472,15 @@ PGAPI_ColumnPrivileges( * * Retrieve the primary key columns for the specified table. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_PrimaryKeys( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName) { static char *func = "PGAPI_PrimaryKeys"; StatementClass *stmt = (StatementClass *) hstmt; @@ -2492,7 +2495,9 @@ PGAPI_PrimaryKeys( SDWORD attname_len; char pktab[MAX_TABLE_LEN + 1]; Int2 result_cols; - int qno, qstart, qend; + int qno, + qstart, + qend; mylog("%s: entering...stmt=%u\n", func, stmt); @@ -2554,7 +2559,7 @@ PGAPI_PrimaryKeys( } result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_CHAR, - attname, MAX_INFO_STRING, &attname_len); + attname, MAX_INFO_STRING, &attname_len); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -2575,32 +2580,35 @@ PGAPI_PrimaryKeys( switch (qno) { case 1: + /* - * Simplified query to remove assumptions about number of possible - * index columns. Courtesy of Tom Lane - thomas 2000-03-21 - */ + * Simplified query to remove assumptions about number of + * possible index columns. Courtesy of Tom Lane - thomas + * 2000-03-21 + */ sprintf(tables_query, "select ta.attname, ia.attnum" - " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i" - " where c.relname = '%s'" - " AND c.oid = i.indrelid" - " AND i.indisprimary = 't'" - " AND ia.attrelid = i.indexrelid" - " AND ta.attrelid = i.indrelid" - " AND ta.attnum = i.indkey[ia.attnum-1]" - " order by ia.attnum", pktab); + " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i" + " where c.relname = '%s'" + " AND c.oid = i.indrelid" + " AND i.indisprimary = 't'" + " AND ia.attrelid = i.indexrelid" + " AND ta.attrelid = i.indrelid" + " AND ta.attnum = i.indkey[ia.attnum-1]" + " order by ia.attnum", pktab); break; case 2: + /* - * Simplified query to search old fashoned primary key - */ + * Simplified query to search old fashoned primary key + */ sprintf(tables_query, "select ta.attname, ia.attnum" - " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i" - " where c.relname = '%s_pkey'" - " AND c.oid = i.indexrelid" - " AND ia.attrelid = i.indexrelid" - " AND ta.attrelid = i.indrelid" - " AND ta.attnum = i.indkey[ia.attnum-1]" - " order by ia.attnum", pktab); + " from pg_attribute ta, pg_attribute ia, pg_class c, pg_index i" + " where c.relname = '%s_pkey'" + " AND c.oid = i.indexrelid" + " AND ia.attrelid = i.indexrelid" + " AND ta.attrelid = i.indrelid" + " AND ta.attnum = i.indkey[ia.attnum-1]" + " order by ia.attnum", pktab); break; } mylog("%s: tables_query='%s'\n", func, tables_query); @@ -2622,7 +2630,7 @@ PGAPI_PrimaryKeys( while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField)); set_tuplefield_null(&row->tuple[0]); @@ -2679,7 +2687,8 @@ PGAPI_PrimaryKeys( * There may be much more effective way in the * future version. The way is very forcive currently. */ -static BOOL isMultibyte(const unsigned char *str) +static BOOL +isMultibyte(const unsigned char *str) { for (; *str; str++) { @@ -2688,11 +2697,15 @@ static BOOL isMultibyte(const unsigned char *str) } return FALSE; } -static char *getClientTableName(ConnectionClass *conn, char *serverTableName, BOOL *nameAlloced) +static char * +getClientTableName(ConnectionClass * conn, char *serverTableName, BOOL * nameAlloced) { - char query[1024], saveoid[24], *ret = serverTableName; - BOOL continueExec = TRUE, bError = FALSE; - QResultClass *res; + char query[1024], + saveoid[24], + *ret = serverTableName; + BOOL continueExec = TRUE, + bError = FALSE; + QResultClass *res; *nameAlloced = FALSE; if (!conn->client_encoding || !isMultibyte(serverTableName)) @@ -2764,11 +2777,16 @@ static char *getClientTableName(ConnectionClass *conn, char *serverTableName, BO } return ret; } -static char *getClientColumnName(ConnectionClass *conn, const char *serverTableName, char *serverColumnName, BOOL *nameAlloced) +static char * +getClientColumnName(ConnectionClass * conn, const char *serverTableName, char *serverColumnName, BOOL * nameAlloced) { - char query[1024], saveattrelid[24], saveattnum[16], *ret = serverColumnName; - BOOL continueExec = TRUE, bError = FALSE; - QResultClass *res; + char query[1024], + saveattrelid[24], + saveattnum[16], + *ret = serverColumnName; + BOOL continueExec = TRUE, + bError = FALSE; + QResultClass *res; *nameAlloced = FALSE; if (!conn->client_encoding || !isMultibyte(serverColumnName)) @@ -2795,8 +2813,8 @@ static char *getClientColumnName(ConnectionClass *conn, const char *serverTableN if (!bError && continueExec) { sprintf(query, "select attrelid, attnum from pg_class, pg_attribute " - "where relname = '%s' and attrelid = pg_class.oid " - "and attname = '%s'", serverTableName, serverColumnName); + "where relname = '%s' and attrelid = pg_class.oid " + "and attname = '%s'", serverTableName, serverColumnName); if (res = CC_send_query(conn, query, NULL), res) { if (QR_get_num_tuples(res) > 0) @@ -2845,23 +2863,23 @@ static char *getClientColumnName(ConnectionClass *conn, const char *serverTableN } return ret; } -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ForeignKeys( - HSTMT hstmt, - UCHAR FAR *szPkTableQualifier, - SWORD cbPkTableQualifier, - UCHAR FAR *szPkTableOwner, - SWORD cbPkTableOwner, - UCHAR FAR *szPkTableName, - SWORD cbPkTableName, - UCHAR FAR *szFkTableQualifier, - SWORD cbFkTableQualifier, - UCHAR FAR *szFkTableOwner, - SWORD cbFkTableOwner, - UCHAR FAR *szFkTableName, - SWORD cbFkTableName) + HSTMT hstmt, + UCHAR FAR * szPkTableQualifier, + SWORD cbPkTableQualifier, + UCHAR FAR * szPkTableOwner, + SWORD cbPkTableOwner, + UCHAR FAR * szPkTableName, + SWORD cbPkTableName, + UCHAR FAR * szFkTableQualifier, + SWORD cbFkTableQualifier, + UCHAR FAR * szFkTableOwner, + SWORD cbFkTableOwner, + UCHAR FAR * szFkTableName, + SWORD cbFkTableName) { static char *func = "PGAPI_ForeignKeys"; StatementClass *stmt = (StatementClass *) hstmt; @@ -2879,14 +2897,22 @@ PGAPI_ForeignKeys( del_rule[MAX_TABLE_LEN]; char pk_table_needed[MAX_TABLE_LEN + 1]; char fk_table_needed[MAX_TABLE_LEN + 1]; - char *pkey_ptr, *pkey_text, - *fkey_ptr, *fkey_text, - *pk_table, *pkt_text, - *fk_table, *fkt_text; + char *pkey_ptr, + *pkey_text, + *fkey_ptr, + *fkey_text, + *pk_table, + *pkt_text, + *fk_table, + *fkt_text; + #ifdef MULTIBYTE - BOOL pkey_alloced, fkey_alloced, pkt_alloced, fkt_alloced; - ConnectionClass *conn; -#endif /* MULTIBYTE */ + BOOL pkey_alloced, + fkey_alloced, + pkt_alloced, + fkt_alloced; + ConnectionClass *conn; +#endif /* MULTIBYTE */ int i, j, k, @@ -2897,7 +2923,6 @@ PGAPI_ForeignKeys( #if (ODBCVER >= 0x0300) SWORD defer_type; - #endif char pkey[MAX_INFO_STRING]; Int2 result_cols; @@ -2983,7 +3008,8 @@ PGAPI_ForeignKeys( #ifdef MULTIBYTE pkey_alloced = fkey_alloced = pkt_alloced = fkt_alloced = FALSE; conn = SC_get_conn(stmt); -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ + /* * Case #2 -- Get the foreign keys in the specified table (fktab) that * refer to the primary keys of other table(s). @@ -3032,7 +3058,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_BINARY, - trig_args, sizeof(trig_args), NULL); + trig_args, sizeof(trig_args), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3043,7 +3069,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 2, SQL_C_SHORT, - &trig_nargs, 0, NULL); + &trig_nargs, 0, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3076,7 +3102,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 5, SQL_C_CHAR, - upd_rule, sizeof(upd_rule), NULL); + upd_rule, sizeof(upd_rule), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3087,7 +3113,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 6, SQL_C_CHAR, - del_rule, sizeof(del_rule), NULL); + del_rule, sizeof(del_rule), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3120,7 +3146,7 @@ PGAPI_ForeignKeys( } keyresult = PGAPI_BindCol(hpkey_stmt, 4, SQL_C_CHAR, - pkey, sizeof(pkey), NULL); + pkey, sizeof(pkey), NULL); if (keyresult != SQL_SUCCESS) { stmt->errornumber = STMT_NO_MEMORY_ERROR; @@ -3148,7 +3174,7 @@ PGAPI_ForeignKeys( pkt_text = getClientTableName(conn, pk_table, &pkt_alloced); #else pkt_text = pk_table; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* If there is a pk table specified, then check it. */ if (pk_table_needed[0] != '\0') { @@ -3189,7 +3215,7 @@ PGAPI_ForeignKeys( pkey_text = getClientColumnName(conn, pk_table, pkey_ptr, &pkey_alloced); #else pkey_text = pkey_ptr; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ mylog("%s: pkey_ptr='%s', pkey='%s'\n", func, pkey_text, pkey); if (strcmp(pkey_text, pkey)) { @@ -3199,7 +3225,7 @@ PGAPI_ForeignKeys( #ifdef MULTIBYTE if (pkey_alloced) free(pkey_text); -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* Get to next primary key */ for (k = 0; k < 2; k++) pkey_ptr += strlen(pkey_ptr) + 1; @@ -3251,7 +3277,7 @@ PGAPI_ForeignKeys( for (k = 0; k < num_keys; k++) { - row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField)); #ifdef MULTIBYTE pkey_text = getClientColumnName(conn, pk_table, pkey_ptr, &pkey_alloced); @@ -3259,7 +3285,7 @@ PGAPI_ForeignKeys( #else pkey_text = pkey_ptr; fkey_text = fkey_ptr; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ mylog("%s: pk_table = '%s', pkey_ptr = '%s'\n", func, pkt_text, pkey_text); set_tuplefield_null(&row->tuple[0]); set_tuplefield_string(&row->tuple[1], ""); @@ -3291,7 +3317,7 @@ PGAPI_ForeignKeys( if (pkey_alloced) free(pkey_text); pkey_alloced = FALSE; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* next primary/foreign key */ for (i = 0; i < 2; i++) { @@ -3303,7 +3329,7 @@ PGAPI_ForeignKeys( if (pkt_alloced) free(pkt_text); pkt_alloced = FALSE; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ result = PGAPI_Fetch(htbl_stmt); } @@ -3358,7 +3384,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 1, SQL_C_BINARY, - trig_args, sizeof(trig_args), NULL); + trig_args, sizeof(trig_args), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3369,7 +3395,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 2, SQL_C_SHORT, - &trig_nargs, 0, NULL); + &trig_nargs, 0, NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3402,7 +3428,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 5, SQL_C_CHAR, - upd_rule, sizeof(upd_rule), NULL); + upd_rule, sizeof(upd_rule), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3413,7 +3439,7 @@ PGAPI_ForeignKeys( } result = PGAPI_BindCol(htbl_stmt, 6, SQL_C_CHAR, - del_rule, sizeof(del_rule), NULL); + del_rule, sizeof(del_rule), NULL); if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { stmt->errormsg = tbl_stmt->errormsg; @@ -3489,7 +3515,7 @@ PGAPI_ForeignKeys( fkt_text = getClientTableName(conn, fk_table, &fkt_alloced); #else fkt_text = fk_table; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* Get to first foreign key */ fkey_ptr = trig_args; @@ -3504,10 +3530,10 @@ PGAPI_ForeignKeys( #else pkey_text = pkey_ptr; fkey_text = fkey_ptr; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ mylog("pkey_ptr = '%s', fk_table = '%s', fkey_ptr = '%s'\n", pkey_text, fkt_text, fkey_text); - row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) *sizeof(TupleField)); + row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField)); mylog("pk_table_needed = '%s', pkey_ptr = '%s'\n", pk_table_needed, pkey_text); set_tuplefield_null(&row->tuple[0]); @@ -3545,7 +3571,7 @@ PGAPI_ForeignKeys( if (fkey_alloced) free(fkey_text); fkey_alloced = FALSE; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ /* next primary/foreign key */ for (j = 0; j < 2; j++) @@ -3558,7 +3584,7 @@ PGAPI_ForeignKeys( if (fkt_alloced) free(fkt_text); fkt_alloced = FALSE; -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ result = PGAPI_Fetch(htbl_stmt); } } @@ -3579,7 +3605,7 @@ PGAPI_ForeignKeys( free(fkt_text); if (fkey_alloced) free(fkey_text); -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ PGAPI_FreeStmt(htbl_stmt, SQL_DROP); @@ -3588,17 +3614,17 @@ PGAPI_ForeignKeys( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_ProcedureColumns( - HSTMT hstmt, - UCHAR FAR *szProcQualifier, - SWORD cbProcQualifier, - UCHAR FAR *szProcOwner, - SWORD cbProcOwner, - UCHAR FAR *szProcName, - SWORD cbProcName, - UCHAR FAR *szColumnName, - SWORD cbColumnName) + HSTMT hstmt, + UCHAR FAR * szProcQualifier, + SWORD cbProcQualifier, + UCHAR FAR * szProcOwner, + SWORD cbProcOwner, + UCHAR FAR * szProcName, + SWORD cbProcName, + UCHAR FAR * szColumnName, + SWORD cbColumnName) { static char *func = "PGAPI_ProcedureColumns"; @@ -3609,24 +3635,24 @@ PGAPI_ProcedureColumns( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_Procedures( - HSTMT hstmt, - UCHAR FAR *szProcQualifier, - SWORD cbProcQualifier, - UCHAR FAR *szProcOwner, - SWORD cbProcOwner, - UCHAR FAR *szProcName, - SWORD cbProcName) + HSTMT hstmt, + UCHAR FAR * szProcQualifier, + SWORD cbProcQualifier, + UCHAR FAR * szProcOwner, + SWORD cbProcOwner, + UCHAR FAR * szProcName, + SWORD cbProcName) { static char *func = "PGAPI_Procedures"; - StatementClass *stmt = (StatementClass *) hstmt; - ConnectionClass *conn = SC_get_conn(stmt); + StatementClass *stmt = (StatementClass *) hstmt; + ConnectionClass *conn = SC_get_conn(stmt); char proc_query[INFO_INQUIRY_LEN]; - QResultClass *res; + QResultClass *res; mylog("%s: entering...\n", func); - + if (PG_VERSION_LT(conn, 6.5)) { stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR; @@ -3636,14 +3662,15 @@ PGAPI_Procedures( } if (!SC_recycle_statement(stmt)) return SQL_ERROR; + /* - * The following seems the simplest implementation + * The following seems the simplest implementation */ - strcpy(proc_query, "select '' as ""PROCEDURE_CAT"", '' as ""PROCEDURE_SCHEM""," - " proname as ""PROCEDURE_NAME"", '' as ""NUM_INPUT_PARAMS""," - " '' as ""NUM_OUTPUT_PARAMS"", '' as ""NUM_RESULT_SETS""," - " '' as ""REMARKS""," - " case when prorettype =0 then 1::int2 else 2::int2 end as ""PROCEDURE_TYPE"" from pg_proc"); + strcpy(proc_query, "select '' as " "PROCEDURE_CAT" ", '' as " "PROCEDURE_SCHEM" "," + " proname as " "PROCEDURE_NAME" ", '' as " "NUM_INPUT_PARAMS" "," + " '' as " "NUM_OUTPUT_PARAMS" ", '' as " "NUM_RESULT_SETS" "," + " '' as " "REMARKS" "," + " case when prorettype =0 then 1::int2 else 2::int2 end as " "PROCEDURE_TYPE" " from pg_proc"); my_strcat(proc_query, " where proname like '%.*s'", szProcName, cbProcName); res = CC_send_query(conn, proc_query, NULL); @@ -3656,6 +3683,7 @@ PGAPI_Procedures( return SQL_ERROR; } stmt->result = res; + /* * also, things need to think that this statement is finished so the * results can be retrieved. @@ -3671,26 +3699,26 @@ PGAPI_Procedures( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_TablePrivileges( - HSTMT hstmt, - UCHAR FAR *szTableQualifier, - SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, - SWORD cbTableOwner, - UCHAR FAR *szTableName, - SWORD cbTableName) + HSTMT hstmt, + UCHAR FAR * szTableQualifier, + SWORD cbTableQualifier, + UCHAR FAR * szTableOwner, + SWORD cbTableOwner, + UCHAR FAR * szTableName, + SWORD cbTableName) { - StatementClass *stmt = (StatementClass *) hstmt; + StatementClass *stmt = (StatementClass *) hstmt; static char *func = "PGAPI_TablePrivileges"; Int2 result_cols; mylog("%s: entering...\n", func); /* - * a statement is actually executed, so we'll have to do this - * ourselves. - */ + * a statement is actually executed, so we'll have to do this + * ourselves. + */ result_cols = 7; extend_bindings(stmt, result_cols); @@ -3703,7 +3731,7 @@ PGAPI_TablePrivileges( QR_set_field_info(stmt->result, 4, "GRANTEE", PG_TYPE_TEXT, MAX_INFO_STRING); QR_set_field_info(stmt->result, 5, "PRIVILEGE", PG_TYPE_TEXT, MAX_INFO_STRING); QR_set_field_info(stmt->result, 6, "IS_GRANTABLE", PG_TYPE_TEXT, MAX_INFO_STRING); - + SC_log_error(func, "Function not implemented", (StatementClass *) hstmt); return SQL_ERROR; } diff --git a/src/interfaces/odbc/iodbc.h b/src/interfaces/odbc/iodbc.h index 99ed552055..ca12dd0373 100644 --- a/src/interfaces/odbc/iodbc.h +++ b/src/interfaces/odbc/iodbc.h @@ -8,7 +8,7 @@ #include <sys/types.h> #define MEM_ALLOC(size) (malloc((size_t)(size))) -#define MEM_FREE(ptr) \ +#define MEM_FREE(ptr) \ do { \ if(ptr) \ free(ptr); \ @@ -33,7 +33,6 @@ typedef WORD WPARAM; typedef DWORD LPARAM; typedef void *HWND; typedef int BOOL; - #endif /* _UNIX_ */ #if defined(WIN32) || defined(WIN32_SYSTEM) @@ -58,7 +57,6 @@ typedef int BOOL; #define STRLEN(str) ((str)? _fstrlen((char FAR*)(str)):0) #define STREQ(a, b) (_fstrcmp((char FAR*)(a), (char FAR*)(b) == 0) #endif - #endif /* WIN32 */ #define SYSERR (-1) @@ -66,5 +64,4 @@ typedef int BOOL; #ifndef NULL #define NULL ((void FAR*)0UL) #endif - #endif diff --git a/src/interfaces/odbc/isql.h b/src/interfaces/odbc/isql.h index 5a5a8afafd..fafb01594b 100644 --- a/src/interfaces/odbc/isql.h +++ b/src/interfaces/odbc/isql.h @@ -136,16 +136,16 @@ extern "C" #endif RETCODE SQL_API SQLAllocConnect(HENV henv, - HDBC FAR *phdbc); - RETCODE SQL_API SQLAllocEnv(HENV FAR *phenv); + HDBC FAR * phdbc); + RETCODE SQL_API SQLAllocEnv(HENV FAR * phenv); RETCODE SQL_API SQLAllocStmt(HDBC hdbc, - HSTMT FAR *phstmt); + HSTMT FAR * phstmt); RETCODE SQL_API SQLBindCol(HSTMT hstmt, UWORD icol, SWORD fCType, PTR rgbValue, SDWORD cbValueMax, - SDWORD FAR *pcbValue); + SDWORD FAR * pcbValue); RETCODE SQL_API SQLCancel(HSTMT hstmt); @@ -154,40 +154,40 @@ extern "C" UWORD fDescType, PTR rgbDesc, SWORD cbDescMax, - SWORD FAR *pcbDesc, - SDWORD FAR *pfDesc); + SWORD FAR * pcbDesc, + SDWORD FAR * pfDesc); RETCODE SQL_API SQLConnect(HDBC hdbc, - UCHAR FAR *szDSN, + UCHAR FAR * szDSN, SWORD cbDSN, - UCHAR FAR *szUID, + UCHAR FAR * szUID, SWORD cbUID, - UCHAR FAR *szAuthStr, + UCHAR FAR * szAuthStr, SWORD cbAuthStr); RETCODE SQL_API SQLDescribeCol(HSTMT hstmt, UWORD icol, - UCHAR FAR *szColName, + UCHAR FAR * szColName, SWORD cbColNameMax, - SWORD FAR *pcbColName, - SWORD FAR *pfSqlType, - UDWORD FAR *pcbColDef, - SWORD FAR *pibScale, - SWORD FAR *pfNullable); + SWORD FAR * pcbColName, + SWORD FAR * pfSqlType, + UDWORD FAR * pcbColDef, + SWORD FAR * pibScale, + SWORD FAR * pfNullable); RETCODE SQL_API SQLDisconnect(HDBC hdbc); RETCODE SQL_API SQLError(HENV henv, HDBC hdbc, HSTMT hstmt, - UCHAR FAR *szSqlState, - SDWORD FAR *pfNativeError, - UCHAR FAR *szErrorMsg, + UCHAR FAR * szSqlState, + SDWORD FAR * pfNativeError, + UCHAR FAR * szErrorMsg, SWORD cbErrorMsgMax, - SWORD FAR *pcbErrorMsg); + SWORD FAR * pcbErrorMsg); RETCODE SQL_API SQLExecDirect(HSTMT hstmt, - UCHAR FAR *szSqlStr, + UCHAR FAR * szSqlStr, SDWORD cbSqlStr); RETCODE SQL_API SQLExecute(HSTMT hstmt); @@ -202,22 +202,22 @@ extern "C" UWORD fOption); RETCODE SQL_API SQLGetCursorName(HSTMT hstmt, - UCHAR FAR *szCursor, + UCHAR FAR * szCursor, SWORD cbCursorMax, - SWORD FAR *pcbCursor); + SWORD FAR * pcbCursor); RETCODE SQL_API SQLNumResultCols(HSTMT hstmt, - SWORD FAR *pccol); + SWORD FAR * pccol); RETCODE SQL_API SQLPrepare(HSTMT hstmt, - UCHAR FAR *szSqlStr, + UCHAR FAR * szSqlStr, SDWORD cbSqlStr); RETCODE SQL_API SQLRowCount(HSTMT hstmt, - SDWORD FAR *pcrow); + SDWORD FAR * pcrow); RETCODE SQL_API SQLSetCursorName(HSTMT hstmt, - UCHAR FAR *szCursor, + UCHAR FAR * szCursor, SWORD cbCursor); RETCODE SQL_API SQLTransact(HENV henv, @@ -231,10 +231,9 @@ extern "C" UDWORD cbColDef, SWORD ibScale, PTR rgbValue, - SDWORD FAR *pcbValue); + SDWORD FAR * pcbValue); #ifdef __cplusplus } - #endif #endif diff --git a/src/interfaces/odbc/isqlext.h b/src/interfaces/odbc/isqlext.h index 88c9e4495b..83e9c83ee2 100644 --- a/src/interfaces/odbc/isqlext.h +++ b/src/interfaces/odbc/isqlext.h @@ -371,14 +371,13 @@ typedef struct { SQLUINTEGER dwLowWord; SQLUINTEGER dwHighWord; -} SQLUBIGINT; +} SQLUBIGINT; typedef struct { SQLUINTEGER dwLowWord; SQLINTEGER dwHighWord; -} SQLBIGINT; - +} SQLBIGINT; #endif /* GCC */ typedef struct tagDATE_STRUCT @@ -386,16 +385,18 @@ typedef struct tagDATE_STRUCT SQLSMALLINT year; SQLUSMALLINT month; SQLUSMALLINT day; -} DATE_STRUCT, -SQL_DATE_STRUCT; +} DATE_STRUCT, + + SQL_DATE_STRUCT; typedef struct tagTIME_STRUCT { SQLUSMALLINT hour; SQLUSMALLINT minute; SQLUSMALLINT second; -} TIME_STRUCT, -SQL_TIME_STRUCT; +} TIME_STRUCT, + + SQL_TIME_STRUCT; typedef struct tagTIMESTAMP_STRUCT { @@ -406,8 +407,9 @@ typedef struct tagTIMESTAMP_STRUCT SQLUSMALLINT minute; SQLUSMALLINT second; SQLUINTEGER fraction; -} TIMESTAMP_STRUCT, -SQL_TIMESTAMP_STRUCT; +} TIMESTAMP_STRUCT, + + SQL_TIMESTAMP_STRUCT; /* postodbc doesn't use these but what the heck */ /* Don't know what SQL_MAX_NUMERIC_LEN should be so I can't include this. It's @@ -428,30 +430,30 @@ typedef struct tagSQLGUID WORD Data2; WORD Data3; BYTE Data4[8]; -} SQLGUID; +} SQLGUID; typedef enum { - SQL_IS_YEAR = 1, - SQL_IS_MONTH = 2, - SQL_IS_DAY = 3, - SQL_IS_HOUR = 4, - SQL_IS_MINUTE = 5, - SQL_IS_SECOND = 6, - SQL_IS_YEAR_TO_MONTH = 7, - SQL_IS_DAY_TO_HOUR = 8, - SQL_IS_DAY_TO_MINUTE = 9, - SQL_IS_DAY_TO_SECOND = 10, - SQL_IS_HOUR_TO_MINUTE = 11, - SQL_IS_HOUR_TO_SECOND = 12, - SQL_IS_MINUTE_TO_SECOND = 13 -} SQLINTERVAL; + SQL_IS_YEAR = 1, + SQL_IS_MONTH = 2, + SQL_IS_DAY = 3, + SQL_IS_HOUR = 4, + SQL_IS_MINUTE = 5, + SQL_IS_SECOND = 6, + SQL_IS_YEAR_TO_MONTH = 7, + SQL_IS_DAY_TO_HOUR = 8, + SQL_IS_DAY_TO_MINUTE = 9, + SQL_IS_DAY_TO_SECOND = 10, + SQL_IS_HOUR_TO_MINUTE = 11, + SQL_IS_HOUR_TO_SECOND = 12, + SQL_IS_MINUTE_TO_SECOND = 13 +} SQLINTERVAL; typedef struct tagSQL_YEAR_MONTH { SQLUINTEGER year; SQLUINTEGER month; -} SQL_YEAR_MONTH_STRUCT; +} SQL_YEAR_MONTH_STRUCT; typedef struct tagSQL_DAY_SECOND { @@ -460,7 +462,7 @@ typedef struct tagSQL_DAY_SECOND SQLUINTEGER minute; SQLUINTEGER second; SQLUINTEGER fraction; -} SQL_DAY_SECOND_STRUCT; +} SQL_DAY_SECOND_STRUCT; typedef struct tagSQL_INTERVAL_STRUCT { @@ -471,7 +473,7 @@ typedef struct tagSQL_INTERVAL_STRUCT SQL_YEAR_MONTH_STRUCT year_month; SQL_DAY_SECOND_STRUCT day_second; } intval; -} SQL_INTERVAL_STRUCT; +} SQL_INTERVAL_STRUCT; #define SQL_MAX_OPTION_STRING_LENGTH 256 #define SQL_NUM_EXTENSIONS (SQL_EXT_API_LAST - SQL_EXT_API_START + 1) @@ -1347,22 +1349,22 @@ extern "C" * function prototypes previously missing from isqlext.h */ RETCODE SQL_API SQLColumns(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, - UCHAR FAR *szColumnName, + UCHAR FAR * szColumnName, SWORD cbColumnName); RETCODE SQL_API SQLDriverConnect(HDBC hdbc, HWND hwnd, - UCHAR FAR *szConnStrIn, + UCHAR FAR * szConnStrIn, SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, + UCHAR FAR * szConnStrOut, SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut, + SWORD FAR * pcbConnStrOut, UWORD fDriverCompletion); RETCODE SQL_API SQLGetConnectOption(HDBC hdbc, @@ -1374,17 +1376,17 @@ extern "C" SWORD fCType, PTR rgbValue, SDWORD cbValueMax, - SDWORD FAR *pcbValue); + SDWORD FAR * pcbValue); RETCODE SQL_API SQLGetFunctions(HDBC hdbc, UWORD fFunction, - UWORD FAR *pfExists); + UWORD FAR * pfExists); RETCODE SQL_API SQLGetInfo(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue, SWORD cbInfoValueMax, - SWORD FAR *pcbInfoValue); + SWORD FAR * pcbInfoValue); RETCODE SQL_API SQLGetStmtOption(HSTMT hstmt, UWORD fOption, @@ -1394,7 +1396,7 @@ extern "C" SWORD fSqlType); RETCODE SQL_API SQLParamData(HSTMT hstmt, - PTR FAR *prgbValue); + PTR FAR * prgbValue); RETCODE SQL_API SQLPutData(HSTMT hstmt, PTR rgbValue, @@ -1406,119 +1408,119 @@ extern "C" RETCODE SQL_API SQLSpecialColumns(HSTMT hstmt, UWORD fColType, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, UWORD fScope, UWORD fNullable); RETCODE SQL_API SQLStatistics(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, UWORD fUnique, UWORD fAccuracy); RETCODE SQL_API SQLTables(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, - UCHAR FAR *szTableType, + UCHAR FAR * szTableType, SWORD cbTableType); RETCODE SQL_API SQLBrowseConnect(HDBC hdbc, - UCHAR FAR *szConnStrIn, + UCHAR FAR * szConnStrIn, SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, + UCHAR FAR * szConnStrOut, SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut); + SWORD FAR * pcbConnStrOut); RETCODE SQL_API SQLColumnPrivileges(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName, - UCHAR FAR *szColumnName, + UCHAR FAR * szColumnName, SWORD cbColumnName); RETCODE SQL_API SQLDescribeParam(HSTMT hstmt, UWORD ipar, - SWORD FAR *pfSqlType, - UDWORD FAR *pcbColDef, - SWORD FAR *pibScale, - SWORD FAR *pfNullable); + SWORD FAR * pfSqlType, + UDWORD FAR * pcbColDef, + SWORD FAR * pibScale, + SWORD FAR * pfNullable); RETCODE SQL_API SQLExtendedFetch(HSTMT hstmt, UWORD fFetchType, SDWORD irow, - UDWORD FAR *pcrow, - UWORD FAR *rgfRowStatus); + UDWORD FAR * pcrow, + UWORD FAR * rgfRowStatus); RETCODE SQL_API SQLForeignKeys(HSTMT hstmt, - UCHAR FAR *szPkTableQualifier, + UCHAR FAR * szPkTableQualifier, SWORD cbPkTableQualifier, - UCHAR FAR *szPkTableOwner, + UCHAR FAR * szPkTableOwner, SWORD cbPkTableOwner, - UCHAR FAR *szPkTableName, + UCHAR FAR * szPkTableName, SWORD cbPkTableName, - UCHAR FAR *szFkTableQualifier, + UCHAR FAR * szFkTableQualifier, SWORD cbFkTableQualifier, - UCHAR FAR *szFkTableOwner, + UCHAR FAR * szFkTableOwner, SWORD cbFkTableOwner, - UCHAR FAR *szFkTableName, + UCHAR FAR * szFkTableName, SWORD cbFkTableName); RETCODE SQL_API SQLMoreResults(HSTMT hstmt); RETCODE SQL_API SQLNativeSql(HDBC hdbc, - UCHAR FAR *szSqlStrIn, + UCHAR FAR * szSqlStrIn, SDWORD cbSqlStrIn, - UCHAR FAR *szSqlStr, + UCHAR FAR * szSqlStr, SDWORD cbSqlStrMax, - SDWORD FAR *pcbSqlStr); + SDWORD FAR * pcbSqlStr); RETCODE SQL_API SQLNumParams(HSTMT hstmt, - SWORD FAR *pcpar); + SWORD FAR * pcpar); RETCODE SQL_API SQLParamOptions(HSTMT hstmt, UDWORD crow, - UDWORD FAR *pirow); + UDWORD FAR * pirow); RETCODE SQL_API SQLPrimaryKeys(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName); RETCODE SQL_API SQLProcedureColumns(HSTMT hstmt, - UCHAR FAR *szProcQualifier, + UCHAR FAR * szProcQualifier, SWORD cbProcQualifier, - UCHAR FAR *szProcOwner, + UCHAR FAR * szProcOwner, SWORD cbProcOwner, - UCHAR FAR *szProcName, + UCHAR FAR * szProcName, SWORD cbProcName, - UCHAR FAR *szColumnName, + UCHAR FAR * szColumnName, SWORD cbColumnName); RETCODE SQL_API SQLProcedures(HSTMT hstmt, - UCHAR FAR *szProcQualifier, + UCHAR FAR * szProcQualifier, SWORD cbProcQualifier, - UCHAR FAR *szProcOwner, + UCHAR FAR * szProcOwner, SWORD cbProcOwner, - UCHAR FAR *szProcName, + UCHAR FAR * szProcName, SWORD cbProcName); RETCODE SQL_API SQLSetPos(HSTMT hstmt, @@ -1527,11 +1529,11 @@ extern "C" UWORD fLock); RETCODE SQL_API SQLTablePrivileges(HSTMT hstmt, - UCHAR FAR *szTableQualifier, + UCHAR FAR * szTableQualifier, SWORD cbTableQualifier, - UCHAR FAR *szTableOwner, + UCHAR FAR * szTableOwner, SWORD cbTableOwner, - UCHAR FAR *szTableName, + UCHAR FAR * szTableName, SWORD cbTableName); RETCODE SQL_API SQLBindParameter(HSTMT hstmt, @@ -1543,7 +1545,7 @@ extern "C" SWORD ibScale, PTR rgbValue, SDWORD cbValueMax, - SDWORD FAR *pcbValue); + SDWORD FAR * pcbValue); RETCODE SQL_API SQLSetScrollOptions(HSTMT hstmt, UWORD fConcurrency, @@ -1553,7 +1555,5 @@ extern "C" #ifdef __cplusplus } - #endif - #endif diff --git a/src/interfaces/odbc/lobj.c b/src/interfaces/odbc/lobj.c index 6b55b82d54..ab9c287e6a 100644 --- a/src/interfaces/odbc/lobj.c +++ b/src/interfaces/odbc/lobj.c @@ -18,7 +18,7 @@ Oid -lo_creat(ConnectionClass *conn, int mode) +lo_creat(ConnectionClass * conn, int mode) { LO_ARG argv[1]; int retval, @@ -36,7 +36,7 @@ lo_creat(ConnectionClass *conn, int mode) int -lo_open(ConnectionClass *conn, int lobjId, int mode) +lo_open(ConnectionClass * conn, int lobjId, int mode) { int fd; int result_len; @@ -61,7 +61,7 @@ lo_open(ConnectionClass *conn, int lobjId, int mode) int -lo_close(ConnectionClass *conn, int fd) +lo_close(ConnectionClass * conn, int fd) { LO_ARG argv[1]; int retval, @@ -79,7 +79,7 @@ lo_close(ConnectionClass *conn, int fd) int -lo_read(ConnectionClass *conn, int fd, char *buf, int len) +lo_read(ConnectionClass * conn, int fd, char *buf, int len) { LO_ARG argv[2]; int result_len; @@ -100,7 +100,7 @@ lo_read(ConnectionClass *conn, int fd, char *buf, int len) int -lo_write(ConnectionClass *conn, int fd, char *buf, int len) +lo_write(ConnectionClass * conn, int fd, char *buf, int len) { LO_ARG argv[2]; int retval, @@ -125,7 +125,7 @@ lo_write(ConnectionClass *conn, int fd, char *buf, int len) int -lo_lseek(ConnectionClass *conn, int fd, int offset, int whence) +lo_lseek(ConnectionClass * conn, int fd, int offset, int whence) { LO_ARG argv[3]; int retval, @@ -151,7 +151,7 @@ lo_lseek(ConnectionClass *conn, int fd, int offset, int whence) int -lo_tell(ConnectionClass *conn, int fd) +lo_tell(ConnectionClass * conn, int fd) { LO_ARG argv[1]; int retval, @@ -169,7 +169,7 @@ lo_tell(ConnectionClass *conn, int fd) int -lo_unlink(ConnectionClass *conn, Oid lobjId) +lo_unlink(ConnectionClass * conn, Oid lobjId) { LO_ARG argv[1]; int retval, diff --git a/src/interfaces/odbc/lobj.h b/src/interfaces/odbc/lobj.h index 4d720488a0..f245411c2c 100644 --- a/src/interfaces/odbc/lobj.h +++ b/src/interfaces/odbc/lobj.h @@ -35,13 +35,12 @@ struct lo_arg #define INV_WRITE 0x00020000 #define INV_READ 0x00040000 -Oid lo_creat(ConnectionClass *conn, int mode); -int lo_open(ConnectionClass *conn, int lobjId, int mode); -int lo_close(ConnectionClass *conn, int fd); -int lo_read(ConnectionClass *conn, int fd, char *buf, int len); -int lo_write(ConnectionClass *conn, int fd, char *buf, int len); -int lo_lseek(ConnectionClass *conn, int fd, int offset, int len); -int lo_tell(ConnectionClass *conn, int fd); -int lo_unlink(ConnectionClass *conn, Oid lobjId); - +Oid lo_creat(ConnectionClass * conn, int mode); +int lo_open(ConnectionClass * conn, int lobjId, int mode); +int lo_close(ConnectionClass * conn, int fd); +int lo_read(ConnectionClass * conn, int fd, char *buf, int len); +int lo_write(ConnectionClass * conn, int fd, char *buf, int len); +int lo_lseek(ConnectionClass * conn, int fd, int offset, int len); +int lo_tell(ConnectionClass * conn, int fd); +int lo_unlink(ConnectionClass * conn, Oid lobjId); #endif diff --git a/src/interfaces/odbc/misc.c b/src/interfaces/odbc/misc.c index b17c45e311..443d1f47b3 100644 --- a/src/interfaces/odbc/misc.c +++ b/src/interfaces/odbc/misc.c @@ -30,7 +30,7 @@ #endif extern GLOBAL_VALUES globals; -void generate_filename(const char *, const char *, char *); +void generate_filename(const char *, const char *, char *); void @@ -58,15 +58,19 @@ generate_filename(const char *dirname, const char *prefix, char *filename) return; } -static int mylog_on = 0, qlog_on = 0; -void logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff) +static int mylog_on = 0, + qlog_on = 0; +void +logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff) { - static int mylog_on_count = 0, mylog_off_count = 0, - qlog_on_count = 0, qlog_off_count = 0; + static int mylog_on_count = 0, + mylog_off_count = 0, + qlog_on_count = 0, + qlog_off_count = 0; if (mylog_onoff) mylog_on_count += cnopen; - else + else mylog_off_count += cnopen; if (mylog_on_count > 0) mylog_on = 1; @@ -76,7 +80,7 @@ void logs_on_off(int cnopen, int mylog_onoff, int qlog_onoff) mylog_on = globals.debug; if (qlog_onoff) qlog_on_count += cnopen; - else + else qlog_off_count += cnopen; if (qlog_on_count > 0) qlog_on = 1; @@ -92,7 +96,7 @@ mylog(char *fmt,...) { va_list args; char filebuf[80]; - static FILE *LOGFP = NULL; + static FILE *LOGFP = NULL; if (mylog_on) { @@ -111,7 +115,6 @@ mylog(char *fmt,...) va_end(args); } } - #endif @@ -121,7 +124,7 @@ qlog(char *fmt,...) { va_list args; char filebuf[80]; - static FILE *LOGFP = NULL; + static FILE *LOGFP = NULL; if (qlog_on) { @@ -140,7 +143,6 @@ qlog(char *fmt,...) va_end(args); } } - #endif diff --git a/src/interfaces/odbc/misc.h b/src/interfaces/odbc/misc.h index 5cedd4c147..5237af6bbe 100644 --- a/src/interfaces/odbc/misc.h +++ b/src/interfaces/odbc/misc.h @@ -94,5 +94,4 @@ char *my_strcat(char *buf, const char *fmt, const char *s, int len); #define STRCPY_NULL (-2) int my_strcpy(char *dst, int dst_len, const char *src, int src_len); - #endif diff --git a/src/interfaces/odbc/multibyte.c b/src/interfaces/odbc/multibyte.c index fa81f4775f..b19af2764c 100644 --- a/src/interfaces/odbc/multibyte.c +++ b/src/interfaces/odbc/multibyte.c @@ -70,20 +70,20 @@ multibyte_init(void) unsigned char * check_client_encoding(unsigned char *str) { - if (strstr(str, "%27SJIS%27") || - strstr(str, "%27Shift_JIS%27") || - strstr(str, "'SJIS'") || - strstr(str, "'sjis'") || - strstr(str, "'Shift_JIS'")) + if (strstr(str, "%27SJIS%27") || + strstr(str, "%27Shift_JIS%27") || + strstr(str, "'SJIS'") || + strstr(str, "'sjis'") || + strstr(str, "'Shift_JIS'")) { multibyte_client_encoding = SJIS; return ("SJIS"); } - if (strstr(str, "%27BIG5%27") || - strstr(str, "%27Big5%27") || - strstr(str, "'BIG5'") || - strstr(str, "'big5'") || - strstr(str, "'Big5'")) + if (strstr(str, "%27BIG5%27") || + strstr(str, "%27Big5%27") || + strstr(str, "'BIG5'") || + strstr(str, "'big5'") || + strstr(str, "'Big5'")) { multibyte_client_encoding = BIG5; return ("BIG5"); @@ -106,7 +106,7 @@ multibyte_char_check(unsigned char s) switch (multibyte_client_encoding) { /* Japanese Shift-JIS(CP932) Support. */ - case SJIS: + case SJIS: { if (multibyte_status < 2 && s > 0x80 && !(s > 0x9f && s < 0xE0)) multibyte_status = 2; diff --git a/src/interfaces/odbc/odbcapi.c b/src/interfaces/odbc/odbcapi.c index cec41ea2e6..3b1b1a0fc3 100644 --- a/src/interfaces/odbc/odbcapi.c +++ b/src/interfaces/odbc/odbcapi.c @@ -18,16 +18,16 @@ SQLSetConnectOption, SQLSetCursorName, SQLSetParam, SQLSetStmtOption, SQLSpecialColumns, SQLStatistics, SQLTables, SQLTransact, SQLColAttributes, - SQLColumnPrivileges, SQLDescribeParam, SQLExtendedFetch, - SQLForeignKeys, SQLMoreResults, SQLNativeSql, - SQLNumParams, SQLParamOptions, SQLPrimaryKeys, - SQLProcedureColumns, SQLProcedures, SQLSetPos, - SQLTablePrivileges, SQLBindParameter + SQLColumnPrivileges, SQLDescribeParam, SQLExtendedFetch, + SQLForeignKeys, SQLMoreResults, SQLNativeSql, + SQLNumParams, SQLParamOptions, SQLPrimaryKeys, + SQLProcedureColumns, SQLProcedures, SQLSetPos, + SQLTablePrivileges, SQLBindParameter *------- */ #ifdef WIN32 -#define ODBCVER_REP 0x3000 +#define ODBCVER_REP 0x3000 #endif #include "psqlodbc.h" #include <stdio.h> @@ -37,214 +37,240 @@ #include "connection.h" #include "statement.h" -RETCODE SQL_API SQLAllocConnect(HENV EnvironmentHandle, - HDBC FAR *ConnectionHandle) +RETCODE SQL_API +SQLAllocConnect(HENV EnvironmentHandle, + HDBC FAR * ConnectionHandle) { mylog("[SQLAllocConnect]"); return PGAPI_AllocConnect(EnvironmentHandle, ConnectionHandle); } -RETCODE SQL_API SQLAllocEnv(HENV FAR *EnvironmentHandle) +RETCODE SQL_API +SQLAllocEnv(HENV FAR * EnvironmentHandle) { mylog("[SQLAllocEnv]"); return PGAPI_AllocEnv(EnvironmentHandle); } -RETCODE SQL_API SQLAllocStmt(HDBC ConnectionHandle, - HSTMT *StatementHandle) +RETCODE SQL_API +SQLAllocStmt(HDBC ConnectionHandle, + HSTMT * StatementHandle) { mylog("[SQLAllocStmt]"); return PGAPI_AllocStmt(ConnectionHandle, StatementHandle); } -RETCODE SQL_API SQLBindCol(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, - PTR TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *StrLen_or_Ind) +RETCODE SQL_API +SQLBindCol(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + PTR TargetValue, SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_Ind) { mylog("[SQLBindCol]"); return PGAPI_BindCol(StatementHandle, ColumnNumber, - TargetType, TargetValue, BufferLength, StrLen_or_Ind); + TargetType, TargetValue, BufferLength, StrLen_or_Ind); } -RETCODE SQL_API SQLCancel(HSTMT StatementHandle) +RETCODE SQL_API +SQLCancel(HSTMT StatementHandle) { mylog("[SQLCancel]"); return PGAPI_Cancel(StatementHandle); } -RETCODE SQL_API SQLColumns(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLCHAR *ColumnName, SQLSMALLINT NameLength4) +RETCODE SQL_API +SQLColumns(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLCHAR * ColumnName, SQLSMALLINT NameLength4) { mylog("[SQLColumns]"); return PGAPI_Columns(StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, - ColumnName, NameLength4); + SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4); } -RETCODE SQL_API SQLConnect(HDBC ConnectionHandle, - SQLCHAR *ServerName, SQLSMALLINT NameLength1, - SQLCHAR *UserName, SQLSMALLINT NameLength2, - SQLCHAR *Authentication, SQLSMALLINT NameLength3) +RETCODE SQL_API +SQLConnect(HDBC ConnectionHandle, + SQLCHAR * ServerName, SQLSMALLINT NameLength1, + SQLCHAR * UserName, SQLSMALLINT NameLength2, + SQLCHAR * Authentication, SQLSMALLINT NameLength3) { mylog("[SQLConnect]"); return PGAPI_Connect(ConnectionHandle, ServerName, NameLength1, - UserName, NameLength2, Authentication, NameLength3); + UserName, NameLength2, Authentication, NameLength3); } -RETCODE SQL_API SQLDriverConnect(HDBC hdbc, - HWND hwnd, - UCHAR FAR *szConnStrIn, - SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, - SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut, - UWORD fDriverCompletion) +RETCODE SQL_API +SQLDriverConnect(HDBC hdbc, + HWND hwnd, + UCHAR FAR * szConnStrIn, + SWORD cbConnStrIn, + UCHAR FAR * szConnStrOut, + SWORD cbConnStrOutMax, + SWORD FAR * pcbConnStrOut, + UWORD fDriverCompletion) { mylog("[SQLDriverConnect]"); return PGAPI_DriverConnect(hdbc, hwnd, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion); } -RETCODE SQL_API SQLBrowseConnect( - HDBC hdbc, - SQLCHAR *szConnStrIn, - SQLSMALLINT cbConnStrIn, - SQLCHAR *szConnStrOut, - SQLSMALLINT cbConnStrOutMax, - SQLSMALLINT *pcbConnStrOut) +RETCODE SQL_API +SQLBrowseConnect( + HDBC hdbc, + SQLCHAR * szConnStrIn, + SQLSMALLINT cbConnStrIn, + SQLCHAR * szConnStrOut, + SQLSMALLINT cbConnStrOutMax, + SQLSMALLINT * pcbConnStrOut) { mylog("[SQLBrowseConnect]"); return PGAPI_BrowseConnect(hdbc, szConnStrIn, cbConnStrIn, - szConnStrOut, cbConnStrOutMax, pcbConnStrOut); + szConnStrOut, cbConnStrOutMax, pcbConnStrOut); } -RETCODE SQL_API SQLDataSources(HENV EnvironmentHandle, - SQLUSMALLINT Direction, SQLCHAR *ServerName, - SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1, - SQLCHAR *Description, SQLSMALLINT BufferLength2, - SQLSMALLINT *NameLength2) +RETCODE SQL_API +SQLDataSources(HENV EnvironmentHandle, + SQLUSMALLINT Direction, SQLCHAR * ServerName, + SQLSMALLINT BufferLength1, SQLSMALLINT * NameLength1, + SQLCHAR * Description, SQLSMALLINT BufferLength2, + SQLSMALLINT * NameLength2) { mylog("[SQLDataSources]"); + /* - return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName, - BufferLength1, NameLength1, Description, BufferLength2, - NameLength2); - */ + * return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName, + * BufferLength1, NameLength1, Description, BufferLength2, + * NameLength2); + */ return SQL_ERROR; } -RETCODE SQL_API SQLDescribeCol(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName, - SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, - SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize, - SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable) +RETCODE SQL_API +SQLDescribeCol(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLCHAR * ColumnName, + SQLSMALLINT BufferLength, SQLSMALLINT * NameLength, + SQLSMALLINT * DataType, SQLUINTEGER * ColumnSize, + SQLSMALLINT * DecimalDigits, SQLSMALLINT * Nullable) { mylog("[SQLDescribeCol]"); return PGAPI_DescribeCol(StatementHandle, ColumnNumber, - ColumnName, BufferLength, NameLength, - DataType, ColumnSize, DecimalDigits, Nullable); + ColumnName, BufferLength, NameLength, + DataType, ColumnSize, DecimalDigits, Nullable); } -RETCODE SQL_API SQLDisconnect(HDBC ConnectionHandle) +RETCODE SQL_API +SQLDisconnect(HDBC ConnectionHandle) { mylog("[SQLDisconnect]"); return PGAPI_Disconnect(ConnectionHandle); } -RETCODE SQL_API SQLError(HENV EnvironmentHandle, - HDBC ConnectionHandle, HSTMT StatementHandle, - SQLCHAR *Sqlstate, SQLINTEGER *NativeError, - SQLCHAR *MessageText, SQLSMALLINT BufferLength, - SQLSMALLINT *TextLength) +RETCODE SQL_API +SQLError(HENV EnvironmentHandle, + HDBC ConnectionHandle, HSTMT StatementHandle, + SQLCHAR * Sqlstate, SQLINTEGER * NativeError, + SQLCHAR * MessageText, SQLSMALLINT BufferLength, + SQLSMALLINT * TextLength) { mylog("[SQLError]"); return PGAPI_Error(EnvironmentHandle, ConnectionHandle, StatementHandle, - Sqlstate, NativeError, MessageText, BufferLength, TextLength); + Sqlstate, NativeError, MessageText, BufferLength, TextLength); } -RETCODE SQL_API SQLExecDirect(HSTMT StatementHandle, - SQLCHAR *StatementText, SQLINTEGER TextLength) +RETCODE SQL_API +SQLExecDirect(HSTMT StatementHandle, + SQLCHAR * StatementText, SQLINTEGER TextLength) { mylog("[SQLExecDirect]"); return PGAPI_ExecDirect(StatementHandle, StatementText, TextLength); } -RETCODE SQL_API SQLExecute(HSTMT StatementHandle) +RETCODE SQL_API +SQLExecute(HSTMT StatementHandle) { mylog("[SQLExecute]"); return PGAPI_Execute(StatementHandle); } -RETCODE SQL_API SQLFetch(HSTMT StatementHandle) +RETCODE SQL_API +SQLFetch(HSTMT StatementHandle) { - static char *func = "SQLFetch"; + static char *func = "SQLFetch"; + #if (ODBCVER >= 0x3000) - StatementClass *stmt = (StatementClass *) StatementHandle; + StatementClass *stmt = (StatementClass *) StatementHandle; ConnectionClass *conn = SC_get_conn(stmt); - if (conn->driver_version >= 0x0300) + + if (conn->driver_version >= 0x0300) { - SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray; - SQLINTEGER *pcRow = stmt->options.rowsFetched; + SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray; + SQLINTEGER *pcRow = stmt->options.rowsFetched; mylog("[[%s]]", func); - return PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0, - pcRow, rowStatusArray); + return PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0, + pcRow, rowStatusArray); } #endif mylog("[%s]", func); return PGAPI_Fetch(StatementHandle); } -RETCODE SQL_API SQLFreeConnect(HDBC ConnectionHandle) +RETCODE SQL_API +SQLFreeConnect(HDBC ConnectionHandle) { mylog("[SQLFreeStmt]"); return PGAPI_FreeConnect(ConnectionHandle); } -RETCODE SQL_API SQLFreeEnv(HENV EnvironmentHandle) +RETCODE SQL_API +SQLFreeEnv(HENV EnvironmentHandle) { mylog("[SQLFreeEnv]"); return PGAPI_FreeEnv(EnvironmentHandle); } -RETCODE SQL_API SQLFreeStmt(HSTMT StatementHandle, - SQLUSMALLINT Option) +RETCODE SQL_API +SQLFreeStmt(HSTMT StatementHandle, + SQLUSMALLINT Option) { mylog("[SQLFreeStmt]"); return PGAPI_FreeStmt(StatementHandle, Option); } -RETCODE SQL_API SQLGetConnectOption(HDBC ConnectionHandle, - SQLUSMALLINT Option, PTR Value) +RETCODE SQL_API +SQLGetConnectOption(HDBC ConnectionHandle, + SQLUSMALLINT Option, PTR Value) { mylog("[SQLGetConnectOption]"); return PGAPI_GetConnectOption(ConnectionHandle, Option, Value); -} -RETCODE SQL_API SQLGetCursorName(HSTMT StatementHandle, - SQLCHAR *CursorName, SQLSMALLINT BufferLength, - SQLSMALLINT *NameLength) +} +RETCODE SQL_API +SQLGetCursorName(HSTMT StatementHandle, + SQLCHAR * CursorName, SQLSMALLINT BufferLength, + SQLSMALLINT * NameLength) { mylog("[SQLGetCursorName]"); return PGAPI_GetCursorName(StatementHandle, CursorName, BufferLength, - NameLength); + NameLength); } -RETCODE SQL_API SQLGetData(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, - PTR TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *StrLen_or_Ind) +RETCODE SQL_API +SQLGetData(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + PTR TargetValue, SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_Ind) { mylog("[SQLGetData]"); return PGAPI_GetData(StatementHandle, ColumnNumber, TargetType, - TargetValue, BufferLength, StrLen_or_Ind); + TargetValue, BufferLength, StrLen_or_Ind); } -RETCODE SQL_API SQLGetFunctions(HDBC ConnectionHandle, - SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported) +RETCODE SQL_API +SQLGetFunctions(HDBC ConnectionHandle, + SQLUSMALLINT FunctionId, SQLUSMALLINT * Supported) { mylog("[SQLGetFunctions]"); #if (ODBCVER >= 0x3000) @@ -253,353 +279,386 @@ RETCODE SQL_API SQLGetFunctions(HDBC ConnectionHandle, #endif return PGAPI_GetFunctions(ConnectionHandle, FunctionId, Supported); } -RETCODE SQL_API SQLGetInfo(HDBC ConnectionHandle, - SQLUSMALLINT InfoType, PTR InfoValue, - SQLSMALLINT BufferLength, SQLSMALLINT *StringLength) +RETCODE SQL_API +SQLGetInfo(HDBC ConnectionHandle, + SQLUSMALLINT InfoType, PTR InfoValue, + SQLSMALLINT BufferLength, SQLSMALLINT * StringLength) { #if (ODBCVER >= 0x3000) - RETCODE ret; + RETCODE ret; + mylog("[SQLGetInfo(30)]"); if ((ret = PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue, - BufferLength, StringLength)) == SQL_ERROR) + BufferLength, StringLength)) == SQL_ERROR) { if (((ConnectionClass *) ConnectionHandle)->driver_version >= 0x3000) return PGAPI_GetInfo30(ConnectionHandle, InfoType, InfoValue, - BufferLength, StringLength); + BufferLength, StringLength); } return ret; #else mylog("[SQLGetInfo]"); return PGAPI_GetInfo(ConnectionHandle, InfoType, InfoValue, - BufferLength, StringLength); + BufferLength, StringLength); #endif } -RETCODE SQL_API SQLGetStmtOption(HSTMT StatementHandle, - SQLUSMALLINT Option, PTR Value) +RETCODE SQL_API +SQLGetStmtOption(HSTMT StatementHandle, + SQLUSMALLINT Option, PTR Value) { mylog("[SQLGetStmtOption]"); return PGAPI_GetStmtOption(StatementHandle, Option, Value); } -RETCODE SQL_API SQLGetTypeInfo(HSTMT StatementHandle, - SQLSMALLINT DataType) +RETCODE SQL_API +SQLGetTypeInfo(HSTMT StatementHandle, + SQLSMALLINT DataType) { mylog("[SQLGetTypeInfo]"); - return PGAPI_GetTypeInfo(StatementHandle,DataType); + return PGAPI_GetTypeInfo(StatementHandle, DataType); } -RETCODE SQL_API SQLNumResultCols(HSTMT StatementHandle, - SQLSMALLINT *ColumnCount) +RETCODE SQL_API +SQLNumResultCols(HSTMT StatementHandle, + SQLSMALLINT * ColumnCount) { mylog("[SQLNumResultCols]"); return PGAPI_NumResultCols(StatementHandle, ColumnCount); } -RETCODE SQL_API SQLParamData(HSTMT StatementHandle, - PTR *Value) +RETCODE SQL_API +SQLParamData(HSTMT StatementHandle, + PTR * Value) { mylog("[SQLParamData]"); return PGAPI_ParamData(StatementHandle, Value); } -RETCODE SQL_API SQLPrepare(HSTMT StatementHandle, - SQLCHAR *StatementText, SQLINTEGER TextLength) +RETCODE SQL_API +SQLPrepare(HSTMT StatementHandle, + SQLCHAR * StatementText, SQLINTEGER TextLength) { mylog("[SQLPrepare]"); return PGAPI_Prepare(StatementHandle, StatementText, TextLength); } -RETCODE SQL_API SQLPutData(HSTMT StatementHandle, - PTR Data, SQLINTEGER StrLen_or_Ind) +RETCODE SQL_API +SQLPutData(HSTMT StatementHandle, + PTR Data, SQLINTEGER StrLen_or_Ind) { mylog("[SQLPutData]"); return PGAPI_PutData(StatementHandle, Data, StrLen_or_Ind); } -RETCODE SQL_API SQLRowCount(HSTMT StatementHandle, - SQLINTEGER *RowCount) +RETCODE SQL_API +SQLRowCount(HSTMT StatementHandle, + SQLINTEGER * RowCount) { mylog("[SQLRowCount]"); return PGAPI_RowCount(StatementHandle, RowCount); } -RETCODE SQL_API SQLSetConnectOption(HDBC ConnectionHandle, - SQLUSMALLINT Option, SQLUINTEGER Value) +RETCODE SQL_API +SQLSetConnectOption(HDBC ConnectionHandle, + SQLUSMALLINT Option, SQLUINTEGER Value) { mylog("[SQLSetConnectionOption]"); return PGAPI_SetConnectOption(ConnectionHandle, Option, Value); } -RETCODE SQL_API SQLSetCursorName(HSTMT StatementHandle, - SQLCHAR *CursorName, SQLSMALLINT NameLength) +RETCODE SQL_API +SQLSetCursorName(HSTMT StatementHandle, + SQLCHAR * CursorName, SQLSMALLINT NameLength) { mylog("[SQLSetCursorName]"); return PGAPI_SetCursorName(StatementHandle, CursorName, NameLength); } -RETCODE SQL_API SQLSetParam(HSTMT StatementHandle, - SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, - SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, - SQLSMALLINT ParameterScale, PTR ParameterValue, - SQLINTEGER *StrLen_or_Ind) +RETCODE SQL_API +SQLSetParam(HSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, + SQLSMALLINT ParameterScale, PTR ParameterValue, + SQLINTEGER * StrLen_or_Ind) { mylog("[SQLSetParam]"); + /* - return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType, - ParameterType, LengthPrecision, ParameterScale, ParameterValue, - StrLen_or_Ind); - */ - return SQL_ERROR; + * return PGAPI_SetParam(StatementHandle, ParameterNumber, ValueType, + * ParameterType, LengthPrecision, ParameterScale, ParameterValue, + * StrLen_or_Ind); + */ + return SQL_ERROR; } -RETCODE SQL_API SQLSetStmtOption(HSTMT StatementHandle, - SQLUSMALLINT Option, SQLUINTEGER Value) +RETCODE SQL_API +SQLSetStmtOption(HSTMT StatementHandle, + SQLUSMALLINT Option, SQLUINTEGER Value) { mylog("[SQLSetStmtOption]"); return PGAPI_SetStmtOption(StatementHandle, Option, Value); } -RETCODE SQL_API SQLSpecialColumns(HSTMT StatementHandle, - SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName, - SQLSMALLINT NameLength1, SQLCHAR *SchemaName, - SQLSMALLINT NameLength2, SQLCHAR *TableName, - SQLSMALLINT NameLength3, SQLUSMALLINT Scope, - SQLUSMALLINT Nullable) +RETCODE SQL_API +SQLSpecialColumns(HSTMT StatementHandle, + SQLUSMALLINT IdentifierType, SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, SQLCHAR * TableName, + SQLSMALLINT NameLength3, SQLUSMALLINT Scope, + SQLUSMALLINT Nullable) { mylog("[SQLSpecialColumns]"); return PGAPI_SpecialColumns(StatementHandle, IdentifierType, CatalogName, - NameLength1, SchemaName, NameLength2, TableName, NameLength3, - Scope, Nullable); + NameLength1, SchemaName, NameLength2, TableName, NameLength3, + Scope, Nullable); } -RETCODE SQL_API SQLStatistics(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLUSMALLINT Unique, SQLUSMALLINT Reserved) +RETCODE SQL_API +SQLStatistics(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLUSMALLINT Unique, SQLUSMALLINT Reserved) { mylog("[SQLStatistics]"); return PGAPI_Statistics(StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, Unique, - Reserved); + SchemaName, NameLength2, TableName, NameLength3, Unique, + Reserved); } -RETCODE SQL_API SQLTables(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLCHAR *TableType, SQLSMALLINT NameLength4) +RETCODE SQL_API +SQLTables(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLCHAR * TableType, SQLSMALLINT NameLength4) { mylog("[SQLTables]"); return PGAPI_Tables(StatementHandle, CatalogName, NameLength1, - SchemaName, NameLength2, TableName, NameLength3, - TableType, NameLength4); + SchemaName, NameLength2, TableName, NameLength3, + TableType, NameLength4); } -RETCODE SQL_API SQLTransact(HENV EnvironmentHandle, - HDBC ConnectionHandle, SQLUSMALLINT CompletionType) +RETCODE SQL_API +SQLTransact(HENV EnvironmentHandle, + HDBC ConnectionHandle, SQLUSMALLINT CompletionType) { mylog("[SQLTransact]"); return PGAPI_Transact(EnvironmentHandle, ConnectionHandle, CompletionType); } -RETCODE SQL_API SQLColAttributes( - HSTMT hstmt, - SQLUSMALLINT icol, - SQLUSMALLINT fDescType, - PTR rgbDesc, - SQLSMALLINT cbDescMax, - SQLSMALLINT *pcbDesc, - SQLINTEGER *pfDesc) +RETCODE SQL_API +SQLColAttributes( + HSTMT hstmt, + SQLUSMALLINT icol, + SQLUSMALLINT fDescType, + PTR rgbDesc, + SQLSMALLINT cbDescMax, + SQLSMALLINT * pcbDesc, + SQLINTEGER * pfDesc) { mylog("[SQLColAttributes]"); return PGAPI_ColAttributes(hstmt, icol, fDescType, rgbDesc, - cbDescMax, pcbDesc, pfDesc); + cbDescMax, pcbDesc, pfDesc); } -RETCODE SQL_API SQLColumnPrivileges( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName, - SQLCHAR *szColumnName, - SQLSMALLINT cbColumnName) +RETCODE SQL_API +SQLColumnPrivileges( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName, + SQLCHAR * szColumnName, + SQLSMALLINT cbColumnName) { mylog("[SQLColumnPrivileges]"); return PGAPI_ColumnPrivileges(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szTableName, cbTableName, - szColumnName, cbColumnName); + szSchemaName, cbSchemaName, szTableName, cbTableName, + szColumnName, cbColumnName); } -RETCODE SQL_API SQLDescribeParam( - HSTMT hstmt, - SQLUSMALLINT ipar, - SQLSMALLINT *pfSqlType, - SQLUINTEGER *pcbParamDef, - SQLSMALLINT *pibScale, - SQLSMALLINT *pfNullable) +RETCODE SQL_API +SQLDescribeParam( + HSTMT hstmt, + SQLUSMALLINT ipar, + SQLSMALLINT * pfSqlType, + SQLUINTEGER * pcbParamDef, + SQLSMALLINT * pibScale, + SQLSMALLINT * pfNullable) { mylog("[SQLDescribeParam]"); return PGAPI_DescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, - pibScale, pfNullable); + pibScale, pfNullable); } -RETCODE SQL_API SQLExtendedFetch( - HSTMT hstmt, - SQLUSMALLINT fFetchType, - SQLINTEGER irow, - SQLUINTEGER *pcrow, - SQLUSMALLINT *rgfRowStatus) +RETCODE SQL_API +SQLExtendedFetch( + HSTMT hstmt, + SQLUSMALLINT fFetchType, + SQLINTEGER irow, + SQLUINTEGER * pcrow, + SQLUSMALLINT * rgfRowStatus) { mylog("[SQLExtendedFetch]"); return PGAPI_ExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus); } -RETCODE SQL_API SQLForeignKeys( - HSTMT hstmt, - SQLCHAR *szPkCatalogName, - SQLSMALLINT cbPkCatalogName, - SQLCHAR *szPkSchemaName, - SQLSMALLINT cbPkSchemaName, - SQLCHAR *szPkTableName, - SQLSMALLINT cbPkTableName, - SQLCHAR *szFkCatalogName, - SQLSMALLINT cbFkCatalogName, - SQLCHAR *szFkSchemaName, - SQLSMALLINT cbFkSchemaName, - SQLCHAR *szFkTableName, - SQLSMALLINT cbFkTableName) +RETCODE SQL_API +SQLForeignKeys( + HSTMT hstmt, + SQLCHAR * szPkCatalogName, + SQLSMALLINT cbPkCatalogName, + SQLCHAR * szPkSchemaName, + SQLSMALLINT cbPkSchemaName, + SQLCHAR * szPkTableName, + SQLSMALLINT cbPkTableName, + SQLCHAR * szFkCatalogName, + SQLSMALLINT cbFkCatalogName, + SQLCHAR * szFkSchemaName, + SQLSMALLINT cbFkSchemaName, + SQLCHAR * szFkTableName, + SQLSMALLINT cbFkTableName) { mylog("[SQLForeignKeys]"); return PGAPI_ForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, - szPkSchemaName, cbPkSchemaName, szPkTableName, - cbPkTableName, szFkCatalogName, cbFkCatalogName, - szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName); + szPkSchemaName, cbPkSchemaName, szPkTableName, + cbPkTableName, szFkCatalogName, cbFkCatalogName, + szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName); } -RETCODE SQL_API SQLMoreResults(HSTMT hstmt) +RETCODE SQL_API +SQLMoreResults(HSTMT hstmt) { mylog("[SQLMoreResults]"); return PGAPI_MoreResults(hstmt); } - -RETCODE SQL_API SQLNativeSql( - HDBC hdbc, - SQLCHAR *szSqlStrIn, - SQLINTEGER cbSqlStrIn, - SQLCHAR *szSqlStr, - SQLINTEGER cbSqlStrMax, - SQLINTEGER *pcbSqlStr) + +RETCODE SQL_API +SQLNativeSql( + HDBC hdbc, + SQLCHAR * szSqlStrIn, + SQLINTEGER cbSqlStrIn, + SQLCHAR * szSqlStr, + SQLINTEGER cbSqlStrMax, + SQLINTEGER * pcbSqlStr) { mylog("[SQLNativeSql]"); return PGAPI_NativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, - cbSqlStrMax, pcbSqlStr); + cbSqlStrMax, pcbSqlStr); } -RETCODE SQL_API SQLNumParams( - HSTMT hstmt, - SQLSMALLINT *pcpar) +RETCODE SQL_API +SQLNumParams( + HSTMT hstmt, + SQLSMALLINT * pcpar) { mylog("[SQLNumParams]"); return PGAPI_NumParams(hstmt, pcpar); } -RETCODE SQL_API SQLParamOptions( - HSTMT hstmt, - SQLUINTEGER crow, - SQLUINTEGER *pirow) +RETCODE SQL_API +SQLParamOptions( + HSTMT hstmt, + SQLUINTEGER crow, + SQLUINTEGER * pirow) { mylog("[SQLParamOptions]"); return PGAPI_ParamOptions(hstmt, crow, pirow); } -RETCODE SQL_API SQLPrimaryKeys( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName) +RETCODE SQL_API +SQLPrimaryKeys( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName) { mylog("[SQLPrimaryKeys]"); return PGAPI_PrimaryKeys(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szTableName, cbTableName); + szSchemaName, cbSchemaName, szTableName, cbTableName); } -RETCODE SQL_API SQLProcedureColumns( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, - SQLSMALLINT cbProcName, - SQLCHAR *szColumnName, - SQLSMALLINT cbColumnName) +RETCODE SQL_API +SQLProcedureColumns( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szProcName, + SQLSMALLINT cbProcName, + SQLCHAR * szColumnName, + SQLSMALLINT cbColumnName) { mylog("[SQLProcedureColumns]"); return PGAPI_ProcedureColumns(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szProcName, cbProcName, - szColumnName, cbColumnName); + szSchemaName, cbSchemaName, szProcName, cbProcName, + szColumnName, cbColumnName); } -RETCODE SQL_API SQLProcedures( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, - SQLSMALLINT cbProcName) +RETCODE SQL_API +SQLProcedures( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szProcName, + SQLSMALLINT cbProcName) { mylog("[SQLProcedures]"); return PGAPI_Procedures(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szProcName, cbProcName); + szSchemaName, cbSchemaName, szProcName, cbProcName); } -RETCODE SQL_API SQLSetPos( - HSTMT hstmt, - SQLUSMALLINT irow, - SQLUSMALLINT fOption, - SQLUSMALLINT fLock) +RETCODE SQL_API +SQLSetPos( + HSTMT hstmt, + SQLUSMALLINT irow, + SQLUSMALLINT fOption, + SQLUSMALLINT fLock) { mylog("[SQLSetPos]"); return PGAPI_SetPos(hstmt, irow, fOption, fLock); } -RETCODE SQL_API SQLTablePrivileges( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName) +RETCODE SQL_API +SQLTablePrivileges( + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName) { mylog("[SQLTablePrivileges]"); return PGAPI_TablePrivileges(hstmt, szCatalogName, cbCatalogName, - szSchemaName, cbSchemaName, szTableName, cbTableName); -} - -RETCODE SQL_API SQLBindParameter( - HSTMT hstmt, - SQLUSMALLINT ipar, - SQLSMALLINT fParamType, - SQLSMALLINT fCType, - SQLSMALLINT fSqlType, - SQLUINTEGER cbColDef, - SQLSMALLINT ibScale, - PTR rgbValue, - SQLINTEGER cbValueMax, - SQLINTEGER *pcbValue) + szSchemaName, cbSchemaName, szTableName, cbTableName); +} + +RETCODE SQL_API +SQLBindParameter( + HSTMT hstmt, + SQLUSMALLINT ipar, + SQLSMALLINT fParamType, + SQLSMALLINT fCType, + SQLSMALLINT fSqlType, + SQLUINTEGER cbColDef, + SQLSMALLINT ibScale, + PTR rgbValue, + SQLINTEGER cbValueMax, + SQLINTEGER * pcbValue) { mylog("[SQLBindParameter]"); return PGAPI_BindParameter(hstmt, ipar, fParamType, fCType, - fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, - pcbValue); + fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, + pcbValue); } diff --git a/src/interfaces/odbc/odbcapi30.c b/src/interfaces/odbc/odbcapi30.c index cce9c37d42..ccd214a69d 100644 --- a/src/interfaces/odbc/odbcapi30.c +++ b/src/interfaces/odbc/odbcapi30.c @@ -29,8 +29,9 @@ #include "pgapifunc.h" /* SQLAllocConnect/SQLAllocEnv/SQLAllocStmt -> SQLAllocHandle */ -RETCODE SQL_API SQLAllocHandle(SQLSMALLINT HandleType, - SQLHANDLE InputHandle, SQLHANDLE *OutputHandle) +RETCODE SQL_API +SQLAllocHandle(SQLSMALLINT HandleType, + SQLHANDLE InputHandle, SQLHANDLE * OutputHandle) { mylog("[[SQLAllocHandle]]"); switch (HandleType) @@ -41,71 +42,87 @@ RETCODE SQL_API SQLAllocHandle(SQLSMALLINT HandleType, return PGAPI_AllocConnect(InputHandle, OutputHandle); case SQL_HANDLE_STMT: return PGAPI_AllocStmt(InputHandle, OutputHandle); - default: break; + default: + break; } return SQL_ERROR; } + /* SQLBindParameter/SQLSetParam -> SQLBindParam */ -RETCODE SQL_API SQLBindParam(HSTMT StatementHandle, - SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, - SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, - SQLSMALLINT ParameterScale, PTR ParameterValue, - SQLINTEGER *StrLen_or_Ind) +RETCODE SQL_API +SQLBindParam(HSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, + SQLSMALLINT ParameterScale, PTR ParameterValue, + SQLINTEGER * StrLen_or_Ind) { - int BufferLength = 512; /* Is it OK ? */ + int BufferLength = 512; /* Is it OK ? */ + mylog("[[SQLBindParam]]"); return PGAPI_BindParameter(StatementHandle, ParameterNumber, SQL_PARAM_INPUT, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, BufferLength, StrLen_or_Ind); } + /* New function */ -RETCODE SQL_API SQLCloseCursor(HSTMT StatementHandle) +RETCODE SQL_API +SQLCloseCursor(HSTMT StatementHandle) { mylog("[[SQLCloseCursor]]"); return PGAPI_FreeStmt(StatementHandle, SQL_CLOSE); } /* SQLColAttributes -> SQLColAttribute */ -RETCODE SQL_API SQLColAttribute (HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, - PTR CharacterAttribute, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength, PTR NumericAttribute) +RETCODE SQL_API +SQLColAttribute(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, + PTR CharacterAttribute, SQLSMALLINT BufferLength, + SQLSMALLINT * StringLength, PTR NumericAttribute) { mylog("[[SQLColAttribute]]"); return PGAPI_ColAttributes(StatementHandle, ColumnNumber, - FieldIdentifier, CharacterAttribute, BufferLength, - StringLength, NumericAttribute); + FieldIdentifier, CharacterAttribute, BufferLength, + StringLength, NumericAttribute); } + /* new function */ -RETCODE SQL_API SQLCopyDesc(SQLHDESC SourceDescHandle, - SQLHDESC TargetDescHandle) +RETCODE SQL_API +SQLCopyDesc(SQLHDESC SourceDescHandle, + SQLHDESC TargetDescHandle) { mylog("[[SQLCopyDesc]]\n"); return SQL_ERROR; } -/* SQLTransact -> SQLEndTran */ -RETCODE SQL_API SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, - SQLSMALLINT CompletionType) + +/* SQLTransact -> SQLEndTran */ +RETCODE SQL_API +SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT CompletionType) { mylog("[[SQLEndTran]]"); switch (HandleType) { - case SQL_HANDLE_ENV: + case SQL_HANDLE_ENV: return PGAPI_Transact(Handle, SQL_NULL_HDBC, CompletionType); - case SQL_HANDLE_DBC: + case SQL_HANDLE_DBC: return PGAPI_Transact(SQL_NULL_HENV, Handle, CompletionType); - default:break; + default: + break; } - return SQL_ERROR; /* SQLSTATE HY092 ("Invalid attribute/option identifier")*/ + return SQL_ERROR; /* SQLSTATE HY092 ("Invalid + * attribute/option identifier") */ } + /* SQLExtendedFetch -> SQLFetchScroll */ -RETCODE SQL_API SQLFetchScroll(HSTMT StatementHandle, - SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset) +RETCODE SQL_API +SQLFetchScroll(HSTMT StatementHandle, + SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset) { static char *func = "SQLFetchScroll"; - StatementClass *stmt = (StatementClass *) StatementHandle; - RETCODE ret; - SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray; - SQLINTEGER *pcRow = stmt->options.rowsFetched; + StatementClass *stmt = (StatementClass *) StatementHandle; + RETCODE ret; + SQLUSMALLINT *rowStatusArray = stmt->options.rowStatusArray; + SQLINTEGER *pcRow = stmt->options.rowsFetched; + mylog("[[%s]] %d,%d\n", func, FetchOrientation, FetchOffset); if (FetchOrientation == SQL_FETCH_BOOKMARK) { @@ -120,13 +137,15 @@ RETCODE SQL_API SQLFetchScroll(HSTMT StatementHandle, } } ret = PGAPI_ExtendedFetch(StatementHandle, FetchOrientation, FetchOffset, - pcRow, rowStatusArray); + pcRow, rowStatusArray); if (ret != SQL_SUCCESS) mylog("%s return = %d\n", func, ret); return ret; } + /* SQLFree(Connect/Env/Stmt) -> SQLFreeHandle */ -RETCODE SQL_API SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) +RETCODE SQL_API +SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) { mylog("[[SQLFreeHandle]]"); switch (HandleType) @@ -137,83 +156,97 @@ RETCODE SQL_API SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) return PGAPI_FreeConnect(Handle); case SQL_HANDLE_STMT: return PGAPI_FreeStmt(Handle, SQL_DROP); - default: break; + default: + break; } return SQL_ERROR; } + /* new function */ -RETCODE SQL_API SQLGetDescField(SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, - PTR Value, SQLINTEGER BufferLength, - SQLINTEGER *StringLength) +RETCODE SQL_API +SQLGetDescField(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, + PTR Value, SQLINTEGER BufferLength, + SQLINTEGER * StringLength) { mylog("[[SQLGetDescField]]\n"); return SQL_ERROR; } + /* new function */ -RETCODE SQL_API SQLGetDescRec(SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, SQLCHAR *Name, - SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, - SQLSMALLINT *Type, SQLSMALLINT *SubType, - SQLINTEGER *Length, SQLSMALLINT *Precision, - SQLSMALLINT *Scale, SQLSMALLINT *Nullable) +RETCODE SQL_API +SQLGetDescRec(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, SQLCHAR * Name, + SQLSMALLINT BufferLength, SQLSMALLINT * StringLength, + SQLSMALLINT * Type, SQLSMALLINT * SubType, + SQLINTEGER * Length, SQLSMALLINT * Precision, + SQLSMALLINT * Scale, SQLSMALLINT * Nullable) { mylog("[[SQLGetDescRec]]\n"); return SQL_ERROR; } + /* new function */ -RETCODE SQL_API SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, - SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, - PTR DiagInfo, SQLSMALLINT BufferLength, - SQLSMALLINT *StringLength) +RETCODE SQL_API +SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, + PTR DiagInfo, SQLSMALLINT BufferLength, + SQLSMALLINT * StringLength) { mylog("[[SQLGetDiagField]]\n"); return SQL_ERROR; } + /* SQLError -> SQLDiagRec */ -RETCODE SQL_API SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, - SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, - SQLINTEGER *NativeError, SQLCHAR *MessageText, - SQLSMALLINT BufferLength, SQLSMALLINT *TextLength) +RETCODE SQL_API +SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, + SQLSMALLINT RecNumber, SQLCHAR * Sqlstate, + SQLINTEGER * NativeError, SQLCHAR * MessageText, + SQLSMALLINT BufferLength, SQLSMALLINT * TextLength) { - RETCODE ret; + RETCODE ret; + mylog("[[SQLGetDiagRec]]\n"); switch (HandleType) { case SQL_HANDLE_ENV: ret = PGAPI_Error(Handle, NULL, NULL, Sqlstate, NativeError, - MessageText, BufferLength, TextLength); + MessageText, BufferLength, TextLength); break; case SQL_HANDLE_DBC: - ret = PGAPI_Error(NULL, Handle, NULL, Sqlstate, NativeError, - MessageText, BufferLength, TextLength); + ret = PGAPI_Error(NULL, Handle, NULL, Sqlstate, NativeError, + MessageText, BufferLength, TextLength); break; case SQL_HANDLE_STMT: ret = PGAPI_Error(NULL, NULL, Handle, Sqlstate, NativeError, - MessageText, BufferLength, TextLength); + MessageText, BufferLength, TextLength); break; default: ret = SQL_ERROR; } if (ret == SQL_SUCCESS_WITH_INFO && - BufferLength == 0 && - *TextLength) + BufferLength == 0 && + *TextLength) { - SQLSMALLINT BufferLength = *TextLength + 4; - SQLCHAR *MessageText = malloc(BufferLength); + SQLSMALLINT BufferLength = *TextLength + 4; + SQLCHAR *MessageText = malloc(BufferLength); + ret = SQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate, - NativeError, MessageText, BufferLength, - TextLength); + NativeError, MessageText, BufferLength, + TextLength); free(MessageText); } return ret; } + /* new function */ -RETCODE SQL_API SQLGetEnvAttr(HENV EnvironmentHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER BufferLength, SQLINTEGER *StringLength) +RETCODE SQL_API +SQLGetEnvAttr(HENV EnvironmentHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER BufferLength, SQLINTEGER * StringLength) { EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle; + mylog("[[SQLGetEnvAttr]] %d\n", Attribute); switch (Attribute) { @@ -235,12 +268,15 @@ RETCODE SQL_API SQLGetEnvAttr(HENV EnvironmentHandle, } return SQL_SUCCESS; } + /* SQLGetConnectOption -> SQLGetconnectAttr */ -RETCODE SQL_API SQLGetConnectAttr(HDBC ConnectionHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER BufferLength, SQLINTEGER *StringLength) +RETCODE SQL_API +SQLGetConnectAttr(HDBC ConnectionHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER BufferLength, SQLINTEGER * StringLength) { - ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; + ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; + mylog("[[SQLGetConnectAttr]] %d\n", Attribute); switch (Attribute) { @@ -253,70 +289,79 @@ RETCODE SQL_API SQLGetConnectAttr(HDBC ConnectionHandle, conn->errormsg = "Unsupported connection option (Set)"; return SQL_ERROR; } - return PGAPI_GetConnectOption (ConnectionHandle, (UWORD) Attribute, Value); + return PGAPI_GetConnectOption(ConnectionHandle, (UWORD) Attribute, Value); } + /* SQLGetStmtOption -> SQLGetStmtAttr */ -RETCODE SQL_API SQLGetStmtAttr(HSTMT StatementHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER BufferLength, SQLINTEGER *StringLength) +RETCODE SQL_API +SQLGetStmtAttr(HSTMT StatementHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER BufferLength, SQLINTEGER * StringLength) { static char *func = "SQLGetStmtAttr"; - StatementClass *stmt = (StatementClass *) StatementHandle; - RETCODE ret = SQL_SUCCESS; - int len = 0; + StatementClass *stmt = (StatementClass *) StatementHandle; + RETCODE ret = SQL_SUCCESS; + int len = 0; + mylog("[[%s]] %d\n", func, Attribute); switch (Attribute) { - case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ + case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ Value = stmt->options.bookmark_ptr; + len = 4; - break; + break; case SQL_ATTR_ROW_STATUS_PTR: /* 25 */ Value = stmt->options.rowStatusArray; + len = 4; break; - case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ + case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ Value = stmt->options.rowsFetched; + len = 4; break; case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */ *((SQLUINTEGER *) Value) = stmt->options.rowset_size; len = 4; - break; - case SQL_ATTR_APP_ROW_DESC: /* 10010 */ - *((HSTMT *) Value) = StatementHandle; /* this is useless */ + break; + case SQL_ATTR_APP_ROW_DESC: /* 10010 */ + *((HSTMT *) Value) = StatementHandle; /* this is useless */ len = 4; - break; + break; case SQL_ATTR_APP_PARAM_DESC: /* 10011 */ - *((HSTMT *) Value) = StatementHandle; /* this is useless */ + *((HSTMT *) Value) = StatementHandle; /* this is useless */ len = 4; - break; - case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ - *((HSTMT *) Value) = StatementHandle; /* this is useless */ + break; + case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ + *((HSTMT *) Value) = StatementHandle; /* this is useless */ len = 4; - break; + break; case SQL_ATTR_IMP_PARAM_DESC: /* 10013 */ - *((HSTMT *) Value) = StatementHandle; /* this is useless */ + *((HSTMT *) Value) = StatementHandle; /* this is useless */ len = 4; - break; - case SQL_ATTR_AUTO_IPD: /* 10001 */ + break; + case SQL_ATTR_AUTO_IPD:/* 10001 */ case SQL_ATTR_ROW_BIND_TYPE: /* == SQL_BIND_TYPE */ case SQL_ATTR_PARAMSET_SIZE: /* 22 */ - case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ - case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ + case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ + case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ - case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ - case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ + case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ + case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ case SQL_ATTR_ENABLE_AUTO_IPD: /* 15 */ - case SQL_ATTR_METADATA_ID: /* 10014 */ - /* case SQL_ATTR_PREDICATE_PTR: - case SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: */ + case SQL_ATTR_METADATA_ID: /* 10014 */ + + /* + * case SQL_ATTR_PREDICATE_PTR: case + * SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: + */ case SQL_ATTR_PARAM_BIND_OFFSET_PTR: /* 17 */ - case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ - case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ - case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ - case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ + case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ + case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ + case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ + case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ stmt->errornumber = STMT_INVALID_OPTION_IDENTIFIER; stmt->errormsg = "Unsupported statement option (Get)"; SC_log_error(func, "", stmt); @@ -331,11 +376,12 @@ RETCODE SQL_API SQLGetStmtAttr(HSTMT StatementHandle, } /* SQLSetConnectOption -> SQLSetConnectAttr */ -RETCODE SQL_API SQLSetConnectAttr(HDBC ConnectionHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER StringLength) +RETCODE SQL_API +SQLSetConnectAttr(HDBC ConnectionHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER StringLength) { - ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; + ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; mylog("[[SQLSetConnectAttr]] %d\n", Attribute); switch (Attribute) @@ -351,31 +397,38 @@ RETCODE SQL_API SQLSetConnectAttr(HDBC ConnectionHandle, } return PGAPI_SetConnectOption(ConnectionHandle, (UWORD) Attribute, (UDWORD) Value); } + /* new function */ -RETCODE SQL_API SQLSetDescField(SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, - PTR Value, SQLINTEGER BufferLength) +RETCODE SQL_API +SQLSetDescField(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier, + PTR Value, SQLINTEGER BufferLength) { mylog("[[SQLSetDescField]]\n"); return SQL_ERROR; } + /* new fucntion */ -RETCODE SQL_API SQLSetDescRec(SQLHDESC DescriptorHandle, - SQLSMALLINT RecNumber, SQLSMALLINT Type, - SQLSMALLINT SubType, SQLINTEGER Length, - SQLSMALLINT Precision, SQLSMALLINT Scale, - PTR Data, SQLINTEGER *StringLength, - SQLINTEGER *Indicator) +RETCODE SQL_API +SQLSetDescRec(SQLHDESC DescriptorHandle, + SQLSMALLINT RecNumber, SQLSMALLINT Type, + SQLSMALLINT SubType, SQLINTEGER Length, + SQLSMALLINT Precision, SQLSMALLINT Scale, + PTR Data, SQLINTEGER * StringLength, + SQLINTEGER * Indicator) { mylog("[[SQLsetDescRec]]\n"); return SQL_ERROR; } + /* new function */ -RETCODE SQL_API SQLSetEnvAttr(HENV EnvironmentHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER StringLength) +RETCODE SQL_API +SQLSetEnvAttr(HENV EnvironmentHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER StringLength) { EnvironmentClass *env = (EnvironmentClass *) EnvironmentHandle; + mylog("[[SQLSetEnvAttr]] att=%d,%u\n", Attribute, Value); switch (Attribute) { @@ -402,59 +455,69 @@ RETCODE SQL_API SQLSetEnvAttr(HENV EnvironmentHandle, env->errormsg = "SetEnv changed to "; return SQL_SUCCESS_WITH_INFO; } + /* SQLSet(Param/Scroll/Stmt)Option -> SQLSetStmtAttr */ -RETCODE SQL_API SQLSetStmtAttr(HSTMT StatementHandle, - SQLINTEGER Attribute, PTR Value, - SQLINTEGER StringLength) +RETCODE SQL_API +SQLSetStmtAttr(HSTMT StatementHandle, + SQLINTEGER Attribute, PTR Value, + SQLINTEGER StringLength) { static char *func = "SQLSetStmtAttr"; - StatementClass *stmt = (StatementClass *) StatementHandle; - UDWORD rowcount; + StatementClass *stmt = (StatementClass *) StatementHandle; + UDWORD rowcount; + mylog("[[%s]] %d,%u\n", func, Attribute, Value); switch (Attribute) { case SQL_ATTR_PARAMSET_SIZE: /* 22 */ return PGAPI_ParamOptions(StatementHandle, (UWORD) Value, &rowcount); - case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ - case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ + case SQL_ATTR_PARAM_STATUS_PTR: /* 20 */ + case SQL_ATTR_PARAMS_PROCESSED_PTR: /* 21 */ - case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ - case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ + case SQL_ATTR_CURSOR_SCROLLABLE: /* -1 */ + case SQL_ATTR_CURSOR_SENSITIVITY: /* -2 */ case SQL_ATTR_ENABLE_AUTO_IPD: /* 15 */ - case SQL_ATTR_APP_ROW_DESC: /* 10010 */ + case SQL_ATTR_APP_ROW_DESC: /* 10010 */ case SQL_ATTR_APP_PARAM_DESC: /* 10011 */ - case SQL_ATTR_AUTO_IPD: /* 10001 */ - /*case SQL_ATTR_ROW_BIND_TYPE:*/ /* == SQL_BIND_TYPE */ - case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ + case SQL_ATTR_AUTO_IPD:/* 10001 */ + /* case SQL_ATTR_ROW_BIND_TYPE: *//* == SQL_BIND_TYPE */ + case SQL_ATTR_IMP_ROW_DESC: /* 10012 */ case SQL_ATTR_IMP_PARAM_DESC: /* 10013 */ - case SQL_ATTR_METADATA_ID: /* 10014 */ - /* case SQL_ATTR_PREDICATE_PTR: - case SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: */ + case SQL_ATTR_METADATA_ID: /* 10014 */ + + /* + * case SQL_ATTR_PREDICATE_PTR: case + * SQL_ATTR_PREDICATE_OCTET_LENGTH_PTR: + */ case SQL_ATTR_PARAM_BIND_OFFSET_PTR: /* 17 */ - case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ - case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ - case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ - case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ + case SQL_ATTR_PARAM_BIND_TYPE: /* 18 */ + case SQL_ATTR_PARAM_OPERATION_PTR: /* 19 */ + case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* 23 */ + case SQL_ATTR_ROW_OPERATION_PTR: /* 24 */ stmt->errornumber = STMT_INVALID_OPTION_IDENTIFIER; stmt->errormsg = "Unsupported statement option (Set)"; SC_log_error(func, "", stmt); return SQL_ERROR; - - case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ + + case SQL_ATTR_FETCH_BOOKMARK_PTR: /* 16 */ stmt->options.bookmark_ptr = Value; + break; case SQL_ATTR_ROW_STATUS_PTR: /* 25 */ stmt->options.rowStatusArray = (SQLUSMALLINT *) Value; + break; - case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ + case SQL_ATTR_ROWS_FETCHED_PTR: /* 26 */ stmt->options.rowsFetched = (SQLUINTEGER *) Value; + break; - case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */ + case SQL_ATTR_ROW_ARRAY_SIZE: /* 27 */ stmt->options.rowset_size = (SQLUINTEGER) Value; + break; - default: + default: return PGAPI_SetStmtOption(StatementHandle, (UWORD) Attribute, (UDWORD) Value); } return SQL_SUCCESS; @@ -464,8 +527,8 @@ RETCODE SQL_API SQLSetStmtAttr(HSTMT StatementHandle, (*(((UWORD*) (pfExists)) + ((uwAPI) >> 4)) \ |= (1 << ((uwAPI) & 0x000F)) \ ) -RETCODE SQL_API -PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR *pfExists) +RETCODE SQL_API +PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR * pfExists) { if (fFunction != SQL_API_ODBC3_ALL_FUNCTIONS) return SQL_ERROR; @@ -474,98 +537,119 @@ PGAPI_GetFunctions30(HDBC hdbc, UWORD fFunction, UWORD FAR *pfExists) /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCCONNECT); 1 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCENV); 2 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCSTMT); 3 deprecated */ - /* for (i = SQL_API_SQLBINDCOL; i <= 23; i++) - SQL_FUNC_ESET(pfExists, i); */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDCOL); /* 4 */ + + /* + * for (i = SQL_API_SQLBINDCOL; i <= 23; i++) SQL_FUNC_ESET(pfExists, + * i); + */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDCOL); /* 4 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLCANCEL); /* 5 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLATTRIBUTE); /* 6 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCONNECT); /* 7 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBECOL); /* 8 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDISCONNECT); /* 9 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLATTRIBUTE); /* 6 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCONNECT); /* 7 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBECOL); /* 8 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDISCONNECT); /* 9 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLERROR); 10 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECDIRECT); /* 11 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECUTE); /* 12 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCH); /* 13 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECDIRECT); /* 11 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLEXECUTE); /* 12 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCH); /* 13 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREECONNECT); 14 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEENV); 15 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFREESTMT); /* 16 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCURSORNAME); /* 17 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMRESULTCOLS); /* 18 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPREPARE); /* 19 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLROWCOUNT); /* 20 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCURSORNAME); /* 21 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFREESTMT); /* 16 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCURSORNAME); /* 17 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMRESULTCOLS); /* 18 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPREPARE); /* 19 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLROWCOUNT); /* 20 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCURSORNAME); /* 21 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPARAM); 22 deprecated */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLTRANSACT); 23 deprecated */ - /*for (i = 40; i < SQL_API_SQLEXTENDEDFETCH; i++) - SQL_FUNC_ESET(pfExists, i);*/ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNS); /* 40 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERCONNECT); /* 41 */ + + /* + * for (i = 40; i < SQL_API_SQLEXTENDEDFETCH; i++) + * SQL_FUNC_ESET(pfExists, i); + */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNS); /* 40 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERCONNECT); /* 41 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTOPTION); 42 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDATA); /* 43 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETFUNCTIONS); /* 44 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETINFO); /* 45 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDATA); /* 43 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETFUNCTIONS); /* 44 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETINFO); /* 45 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTOPTION); 46 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETTYPEINFO); /* 47 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMDATA); /* 48 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPUTDATA); /* 49 */ - /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTIONOPTION); 50 deprecated */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETTYPEINFO); /* 47 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMDATA); /* 48 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPUTDATA); /* 49 */ + + /* + * SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTIONOPTION); 50 + * deprecated + */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTOPTION); 51 deprecated */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSPECIALCOLUMNS); /* 52 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSTATISTICS); /* 53 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSTATISTICS); /* 53 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLES); /* 54 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBROWSECONNECT); /* 55 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNPRIVILEGES); /* 56 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDATASOURCES); /* 57 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBEPARAM); /* 58 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBROWSECONNECT); /* 55 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNPRIVILEGES); /* 56 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDATASOURCES); /* 57 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLDESCRIBEPARAM); /* 58 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLEXTENDEDFETCH); 59 deprecated */ - /*for (++i; i < SQL_API_SQLBINDPARAMETER; i++) - SQL_FUNC_ESET(pfExists, i);*/ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFOREIGNKEYS); /* 60 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLMORERESULTS); /* 61 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLNATIVESQL); /* 62 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMPARAMS); /* 63 */ + + /* + * for (++i; i < SQL_API_SQLBINDPARAMETER; i++) + * SQL_FUNC_ESET(pfExists, i); + */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFOREIGNKEYS); /* 60 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLMORERESULTS); /* 61 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLNATIVESQL); /* 62 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLNUMPARAMS); /* 63 */ /* SQL_FUNC_ESET(pfExists, SQL_API_SQLPARAMOPTIONS); 64 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPRIMARYKEYS); /* 65 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURECOLUMNS); /* 66 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURES); /* 67 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPRIMARYKEYS); /* 65 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURECOLUMNS); /* 66 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLPROCEDURES); /* 67 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETPOS); /* 68 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSCROLLOPTIONS); /* 69 deprecated */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLEPRIVILEGES); /* 70 */ - /*SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERS);*/ /* 71 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAMETER); /* 72 */ - - SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCHANDLE); /* 1001 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAM); /* 1002 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCLOSECURSOR); /* 1003 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLCOPYDESC);/* 1004 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLENDTRAN); /* 1005 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSCROLLOPTIONS); /* 69 deprecated */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLTABLEPRIVILEGES); /* 70 */ + /* SQL_FUNC_ESET(pfExists, SQL_API_SQLDRIVERS); *//* 71 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAMETER); /* 72 */ + + SQL_FUNC_ESET(pfExists, SQL_API_SQLALLOCHANDLE); /* 1001 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBINDPARAM); /* 1002 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCLOSECURSOR); /* 1003 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLCOPYDESC); /* 1004 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLENDTRAN); /* 1005 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTATTR); /* 1007 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD);/* 1008 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC);/* 1009 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD);/* 1010 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD); /* 1008 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC); /* 1009 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD); /* 1010 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */ SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTATTR); /* 1016 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 not implemeted yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented yet */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */ - SQL_FUNC_ESET(pfExists, SQL_API_SQLBULKOPERATIONS);/* 24 not implemented yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 not implemeted + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented + * yet */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */ + SQL_FUNC_ESET(pfExists, SQL_API_SQLBULKOPERATIONS); /* 24 not implemented + * yet */ return SQL_SUCCESS; } -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue, - SWORD cbInfoValueMax, SWORD FAR *pcbInfoValue) + SWORD cbInfoValueMax, SWORD FAR * pcbInfoValue) { static char *func = "PGAPI_GetInfo30"; ConnectionClass *conn = (ConnectionClass *) hdbc; - char *p = NULL; - int len = 0, value = 0; - RETCODE result; + char *p = NULL; + int len = 0, + value = 0; + RETCODE result; switch (fInfoType) { diff --git a/src/interfaces/odbc/options.c b/src/interfaces/odbc/options.c index bc221186ba..5668d8f2d1 100644 --- a/src/interfaces/odbc/options.c +++ b/src/interfaces/odbc/options.c @@ -24,21 +24,21 @@ -RETCODE set_statement_option(ConnectionClass *conn, - StatementClass *stmt, +RETCODE set_statement_option(ConnectionClass * conn, + StatementClass * stmt, UWORD fOption, UDWORD vParam); RETCODE -set_statement_option(ConnectionClass *conn, - StatementClass *stmt, +set_statement_option(ConnectionClass * conn, + StatementClass * stmt, UWORD fOption, UDWORD vParam) { static char *func = "set_statement_option"; char changed = FALSE; - ConnInfo *ci = NULL; + ConnInfo *ci = NULL; if (conn) ci = &(conn->connInfo); @@ -67,19 +67,19 @@ set_statement_option(ConnectionClass *conn, if (ci->drivers.lie || vParam == SQL_CONCUR_READ_ONLY || vParam == SQL_CONCUR_ROWVER) { if (conn) - conn->stmtOptions.scroll_concurrency = vParam; - if (stmt) - stmt->options.scroll_concurrency = vParam; + conn->stmtOptions.scroll_concurrency = vParam; + if (stmt) + stmt->options.scroll_concurrency = vParam; } - else + else { - if (conn) - conn->stmtOptions.scroll_concurrency = SQL_CONCUR_ROWVER; - if (stmt) - stmt->options.scroll_concurrency = SQL_CONCUR_ROWVER; - changed = TRUE; - } - break; + if (conn) + conn->stmtOptions.scroll_concurrency = SQL_CONCUR_ROWVER; + if (stmt) + stmt->options.scroll_concurrency = SQL_CONCUR_ROWVER; + changed = TRUE; + } + break; case SQL_CURSOR_TYPE: @@ -275,11 +275,11 @@ set_statement_option(ConnectionClass *conn, /* Implements only SQL_AUTOCOMMIT */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetConnectOption( - HDBC hdbc, - UWORD fOption, - UDWORD vParam) + HDBC hdbc, + UWORD fOption, + UDWORD vParam) { static char *func = "PGAPI_SetConnectOption"; ConnectionClass *conn = (ConnectionClass *) hdbc; @@ -296,7 +296,6 @@ PGAPI_SetConnectOption( switch (fOption) { - /* * Statement Options (apply to all stmts on the connection and * become defaults for new stmts) @@ -428,15 +427,15 @@ PGAPI_SetConnectOption( /* This function just can tell you whether you are in Autcommit mode or not */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetConnectOption( - HDBC hdbc, - UWORD fOption, - PTR pvParam) + HDBC hdbc, + UWORD fOption, + PTR pvParam) { static char *func = "PGAPI_GetConnectOption"; ConnectionClass *conn = (ConnectionClass *) hdbc; - ConnInfo *ci = &(conn->connInfo); + ConnInfo *ci = &(conn->connInfo); mylog("%s: entering...\n", func); @@ -505,11 +504,11 @@ PGAPI_GetConnectOption( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetStmtOption( - HSTMT hstmt, - UWORD fOption, - UDWORD vParam) + HSTMT hstmt, + UWORD fOption, + UDWORD vParam) { static char *func = "PGAPI_SetStmtOption"; StatementClass *stmt = (StatementClass *) hstmt; @@ -531,16 +530,16 @@ PGAPI_SetStmtOption( } -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetStmtOption( - HSTMT hstmt, - UWORD fOption, - PTR pvParam) + HSTMT hstmt, + UWORD fOption, + PTR pvParam) { static char *func = "PGAPI_GetStmtOption"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); mylog("%s: entering...\n", func); diff --git a/src/interfaces/odbc/parse.c b/src/interfaces/odbc/parse.c index 4fa7fffea5..60d16d5c1c 100644 --- a/src/interfaces/odbc/parse.c +++ b/src/interfaces/odbc/parse.c @@ -43,8 +43,8 @@ #define COL_INCR 16 char *getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dquote, char *numeric); -void getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k); -char searchColInfo(COL_INFO *col_info, FIELD_INFO *fi); +void getColInfo(COL_INFO * col_info, FIELD_INFO * fi, int k); +char searchColInfo(COL_INFO * col_info, FIELD_INFO * fi); char * @@ -90,7 +90,7 @@ getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dqu token[out++] = s[i++]; continue; } -#endif +#endif /* Handle quoted stuff */ if (out == 0 && (s[i] == '\"' || s[i] == '\'')) { @@ -115,13 +115,11 @@ getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dqu token[out++] = s[i++]; continue; } -#endif +#endif if (s[i] == qc && !in_escape) break; if (s[i] == '\\' && !in_escape) - { in_escape = TRUE; - } else { in_escape = FALSE; @@ -218,9 +216,10 @@ QR_set_field_info(stmt->result, 13, "FIELD_TYPE", PG_TYPE_INT4, 4); #endif void -getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k) +getColInfo(COL_INFO * col_info, FIELD_INFO * fi, int k) { - char *str; + char *str; + if (fi->name[0] == '\0') strcpy(fi->name, QR_get_value_manual(col_info->result, k, 3)); @@ -237,7 +236,7 @@ getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k) char -searchColInfo(COL_INFO *col_info, FIELD_INFO *fi) +searchColInfo(COL_INFO * col_info, FIELD_INFO * fi) { int k, cmp; @@ -266,7 +265,7 @@ searchColInfo(COL_INFO *col_info, FIELD_INFO *fi) char -parse_statement(StatementClass *stmt) +parse_statement(StatementClass * stmt) { static char *func = "parse_statement"; char token[256]; @@ -275,7 +274,8 @@ parse_statement(StatementClass *stmt) dquote, numeric, unquoted; - char *ptr, *pptr = NULL; + char *ptr, + *pptr = NULL; char in_select = FALSE, in_distinct = FALSE, in_on = FALSE, @@ -342,7 +342,7 @@ parse_statement(StatementClass *stmt) in_select = FALSE; in_from = TRUE; if (!from_found && - (!strnicmp(pptr, "from", 4))) + (!strnicmp(pptr, "from", 4))) { mylog("First "); from_found = TRUE; @@ -355,21 +355,21 @@ parse_statement(StatementClass *stmt) if (unquoted && blevel == 0) { if ((!stricmp(token, "where") || - !stricmp(token, "union") || - !stricmp(token, "intersect") || - !stricmp(token, "except") || - !stricmp(token, "order") || - !stricmp(token, "group") || - !stricmp(token, "having"))) + !stricmp(token, "union") || + !stricmp(token, "intersect") || + !stricmp(token, "except") || + !stricmp(token, "order") || + !stricmp(token, "group") || + !stricmp(token, "having"))) { in_select = FALSE; in_from = FALSE; in_where = TRUE; if (!first_where && - (!stricmp(token, "where"))) + (!stricmp(token, "where"))) first_where = ptr - stmt->statement; - + mylog("WHERE...\n"); break; } @@ -475,7 +475,7 @@ parse_statement(StatementClass *stmt) if (quote) { fi[stmt->nfld++]->quote = TRUE; -in_expr = TRUE; + in_expr = TRUE; continue; } else if (numeric) @@ -614,8 +614,8 @@ in_expr = TRUE; if ((unsigned char) *ptr >= 0x80) ptr++; else -#endif /* MULTIBYTE */ - *ptr = tolower((unsigned char) *ptr); +#endif /* MULTIBYTE */ + *ptr = tolower((unsigned char) *ptr); } } mylog("got table = '%s'\n", ti[stmt->ntab]->name); @@ -655,10 +655,11 @@ in_expr = TRUE; else if (fi[i]->quote) { /* handle as text */ fi[i]->ti = NULL; + /* - fi[i]->type = PG_TYPE_TEXT; - fi[i]->precision = 0; - the following may be better */ + * fi[i]->type = PG_TYPE_TEXT; fi[i]->precision = 0; the + * following may be better + */ fi[i]->type = PG_TYPE_UNKNOWN; fi[i]->precision = 254; continue; diff --git a/src/interfaces/odbc/pgapifunc.h b/src/interfaces/odbc/pgapifunc.h index 72a5286e9f..465808f0ea 100644 --- a/src/interfaces/odbc/pgapifunc.h +++ b/src/interfaces/odbc/pgapifunc.h @@ -3,241 +3,241 @@ * *------- */ -#ifndef _PG_API_FUNC_H__ -#define _PG_API_FUNC_H__ +#ifndef _PG_API_FUNC_H__ +#define _PG_API_FUNC_H__ #include "psqlodbc.h" #include <stdio.h> #include <string.h> -RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle, - HDBC FAR *ConnectionHandle); -RETCODE SQL_API PGAPI_AllocEnv(HENV FAR *EnvironmentHandle); -RETCODE SQL_API PGAPI_AllocStmt(HDBC ConnectionHandle, - HSTMT *StatementHandle); -RETCODE SQL_API PGAPI_BindCol(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, - PTR TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *StrLen_or_Ind); -RETCODE SQL_API PGAPI_Cancel(HSTMT StatementHandle); -RETCODE SQL_API PGAPI_Columns(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLCHAR *ColumnName, SQLSMALLINT NameLength4); -RETCODE SQL_API PGAPI_Connect(HDBC ConnectionHandle, - SQLCHAR *ServerName, SQLSMALLINT NameLength1, - SQLCHAR *UserName, SQLSMALLINT NameLength2, - SQLCHAR *Authentication, SQLSMALLINT NameLength3); -RETCODE SQL_API PGAPI_DriverConnect(HDBC hdbc, HWND hwnd, - UCHAR FAR *szConnStrIn, SWORD cbConnStrIn, - UCHAR FAR *szConnStrOut, SWORD cbConnStrOutMax, - SWORD FAR *pcbConnStrOut, UWORD fDriverCompletion); +RETCODE SQL_API PGAPI_AllocConnect(HENV EnvironmentHandle, + HDBC FAR * ConnectionHandle); +RETCODE SQL_API PGAPI_AllocEnv(HENV FAR * EnvironmentHandle); +RETCODE SQL_API PGAPI_AllocStmt(HDBC ConnectionHandle, + HSTMT * StatementHandle); +RETCODE SQL_API PGAPI_BindCol(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + PTR TargetValue, SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_Ind); +RETCODE SQL_API PGAPI_Cancel(HSTMT StatementHandle); +RETCODE SQL_API PGAPI_Columns(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLCHAR * ColumnName, SQLSMALLINT NameLength4); +RETCODE SQL_API PGAPI_Connect(HDBC ConnectionHandle, + SQLCHAR * ServerName, SQLSMALLINT NameLength1, + SQLCHAR * UserName, SQLSMALLINT NameLength2, + SQLCHAR * Authentication, SQLSMALLINT NameLength3); +RETCODE SQL_API PGAPI_DriverConnect(HDBC hdbc, HWND hwnd, + UCHAR FAR * szConnStrIn, SWORD cbConnStrIn, + UCHAR FAR * szConnStrOut, SWORD cbConnStrOutMax, + SWORD FAR * pcbConnStrOut, UWORD fDriverCompletion); RETCODE SQL_API PGAPI_BrowseConnect(HDBC hdbc, - SQLCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn, - SQLCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax, - SQLSMALLINT *pcbConnStrOut); -RETCODE SQL_API PGAPI_DataSources(HENV EnvironmentHandle, - SQLUSMALLINT Direction, SQLCHAR *ServerName, - SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1, - SQLCHAR *Description, SQLSMALLINT BufferLength2, - SQLSMALLINT *NameLength2); -RETCODE SQL_API PGAPI_DescribeCol(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName, - SQLSMALLINT BufferLength, SQLSMALLINT *NameLength, - SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize, - SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable); -RETCODE SQL_API PGAPI_Disconnect(HDBC ConnectionHandle); -RETCODE SQL_API PGAPI_Error(HENV EnvironmentHandle, - HDBC ConnectionHandle, HSTMT StatementHandle, - SQLCHAR *Sqlstate, SQLINTEGER *NativeError, - SQLCHAR *MessageText, SQLSMALLINT BufferLength, - SQLSMALLINT *TextLength); -RETCODE SQL_API PGAPI_ExecDirect(HSTMT StatementHandle, - SQLCHAR *StatementText, SQLINTEGER TextLength); -RETCODE SQL_API PGAPI_Execute(HSTMT StatementHandle); -RETCODE SQL_API PGAPI_Fetch(HSTMT StatementHandle); -RETCODE SQL_API PGAPI_FreeConnect(HDBC ConnectionHandle); -RETCODE SQL_API PGAPI_FreeEnv(HENV EnvironmentHandle); -RETCODE SQL_API PGAPI_FreeStmt(HSTMT StatementHandle, - SQLUSMALLINT Option); -RETCODE SQL_API PGAPI_GetConnectOption(HDBC ConnectionHandle, - SQLUSMALLINT Option, PTR Value); -RETCODE SQL_API PGAPI_GetCursorName(HSTMT StatementHandle, - SQLCHAR *CursorName, SQLSMALLINT BufferLength, - SQLSMALLINT *NameLength); -RETCODE SQL_API PGAPI_GetData(HSTMT StatementHandle, - SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, - PTR TargetValue, SQLINTEGER BufferLength, - SQLINTEGER *StrLen_or_Ind); -RETCODE SQL_API PGAPI_GetFunctions(HDBC ConnectionHandle, - SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported); -RETCODE SQL_API PGAPI_GetFunctions30(HDBC ConnectionHandle, - SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported); -RETCODE SQL_API PGAPI_GetInfo(HDBC ConnectionHandle, - SQLUSMALLINT InfoType, PTR InfoValue, - SQLSMALLINT BufferLength, SQLSMALLINT *StringLength); -RETCODE SQL_API PGAPI_GetInfo30(HDBC ConnectionHandle, - SQLUSMALLINT InfoType, PTR InfoValue, - SQLSMALLINT BufferLength, SQLSMALLINT *StringLength); -RETCODE SQL_API PGAPI_GetStmtOption(HSTMT StatementHandle, - SQLUSMALLINT Option, PTR Value); -RETCODE SQL_API PGAPI_GetTypeInfo(HSTMT StatementHandle, - SQLSMALLINT DataType); -RETCODE SQL_API PGAPI_NumResultCols(HSTMT StatementHandle, - SQLSMALLINT *ColumnCount); -RETCODE SQL_API PGAPI_ParamData(HSTMT StatementHandle, - PTR *Value); -RETCODE SQL_API PGAPI_Prepare(HSTMT StatementHandle, - SQLCHAR *StatementText, SQLINTEGER TextLength); -RETCODE SQL_API PGAPI_PutData(HSTMT StatementHandle, - PTR Data, SQLINTEGER StrLen_or_Ind); -RETCODE SQL_API PGAPI_RowCount(HSTMT StatementHandle, - SQLINTEGER *RowCount); -RETCODE SQL_API PGAPI_SetConnectOption(HDBC ConnectionHandle, - SQLUSMALLINT Option, SQLUINTEGER Value); -RETCODE SQL_API PGAPI_SetCursorName(HSTMT StatementHandle, - SQLCHAR *CursorName, SQLSMALLINT NameLength); -RETCODE SQL_API PGAPI_SetParam(HSTMT StatementHandle, - SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, - SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, - SQLSMALLINT ParameterScale, PTR ParameterValue, - SQLINTEGER *StrLen_or_Ind); -RETCODE SQL_API PGAPI_SetStmtOption(HSTMT StatementHandle, - SQLUSMALLINT Option, SQLUINTEGER Value); -RETCODE SQL_API PGAPI_SpecialColumns(HSTMT StatementHandle, - SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName, - SQLSMALLINT NameLength1, SQLCHAR *SchemaName, - SQLSMALLINT NameLength2, SQLCHAR *TableName, - SQLSMALLINT NameLength3, SQLUSMALLINT Scope, - SQLUSMALLINT Nullable); -RETCODE SQL_API PGAPI_Statistics(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLUSMALLINT Unique, SQLUSMALLINT Reserved); -RETCODE SQL_API PGAPI_Tables(HSTMT StatementHandle, - SQLCHAR *CatalogName, SQLSMALLINT NameLength1, - SQLCHAR *SchemaName, SQLSMALLINT NameLength2, - SQLCHAR *TableName, SQLSMALLINT NameLength3, - SQLCHAR *TableType, SQLSMALLINT NameLength4); -RETCODE SQL_API PGAPI_Transact(HENV EnvironmentHandle, - HDBC ConnectionHandle, SQLUSMALLINT CompletionType); + SQLCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn, + SQLCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, + SQLSMALLINT * pcbConnStrOut); +RETCODE SQL_API PGAPI_DataSources(HENV EnvironmentHandle, + SQLUSMALLINT Direction, SQLCHAR * ServerName, + SQLSMALLINT BufferLength1, SQLSMALLINT * NameLength1, + SQLCHAR * Description, SQLSMALLINT BufferLength2, + SQLSMALLINT * NameLength2); +RETCODE SQL_API PGAPI_DescribeCol(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLCHAR * ColumnName, + SQLSMALLINT BufferLength, SQLSMALLINT * NameLength, + SQLSMALLINT * DataType, SQLUINTEGER * ColumnSize, + SQLSMALLINT * DecimalDigits, SQLSMALLINT * Nullable); +RETCODE SQL_API PGAPI_Disconnect(HDBC ConnectionHandle); +RETCODE SQL_API PGAPI_Error(HENV EnvironmentHandle, + HDBC ConnectionHandle, HSTMT StatementHandle, + SQLCHAR * Sqlstate, SQLINTEGER * NativeError, + SQLCHAR * MessageText, SQLSMALLINT BufferLength, + SQLSMALLINT * TextLength); +RETCODE SQL_API PGAPI_ExecDirect(HSTMT StatementHandle, + SQLCHAR * StatementText, SQLINTEGER TextLength); +RETCODE SQL_API PGAPI_Execute(HSTMT StatementHandle); +RETCODE SQL_API PGAPI_Fetch(HSTMT StatementHandle); +RETCODE SQL_API PGAPI_FreeConnect(HDBC ConnectionHandle); +RETCODE SQL_API PGAPI_FreeEnv(HENV EnvironmentHandle); +RETCODE SQL_API PGAPI_FreeStmt(HSTMT StatementHandle, + SQLUSMALLINT Option); +RETCODE SQL_API PGAPI_GetConnectOption(HDBC ConnectionHandle, + SQLUSMALLINT Option, PTR Value); +RETCODE SQL_API PGAPI_GetCursorName(HSTMT StatementHandle, + SQLCHAR * CursorName, SQLSMALLINT BufferLength, + SQLSMALLINT * NameLength); +RETCODE SQL_API PGAPI_GetData(HSTMT StatementHandle, + SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, + PTR TargetValue, SQLINTEGER BufferLength, + SQLINTEGER * StrLen_or_Ind); +RETCODE SQL_API PGAPI_GetFunctions(HDBC ConnectionHandle, + SQLUSMALLINT FunctionId, SQLUSMALLINT * Supported); +RETCODE SQL_API PGAPI_GetFunctions30(HDBC ConnectionHandle, + SQLUSMALLINT FunctionId, SQLUSMALLINT * Supported); +RETCODE SQL_API PGAPI_GetInfo(HDBC ConnectionHandle, + SQLUSMALLINT InfoType, PTR InfoValue, + SQLSMALLINT BufferLength, SQLSMALLINT * StringLength); +RETCODE SQL_API PGAPI_GetInfo30(HDBC ConnectionHandle, + SQLUSMALLINT InfoType, PTR InfoValue, + SQLSMALLINT BufferLength, SQLSMALLINT * StringLength); +RETCODE SQL_API PGAPI_GetStmtOption(HSTMT StatementHandle, + SQLUSMALLINT Option, PTR Value); +RETCODE SQL_API PGAPI_GetTypeInfo(HSTMT StatementHandle, + SQLSMALLINT DataType); +RETCODE SQL_API PGAPI_NumResultCols(HSTMT StatementHandle, + SQLSMALLINT * ColumnCount); +RETCODE SQL_API PGAPI_ParamData(HSTMT StatementHandle, + PTR * Value); +RETCODE SQL_API PGAPI_Prepare(HSTMT StatementHandle, + SQLCHAR * StatementText, SQLINTEGER TextLength); +RETCODE SQL_API PGAPI_PutData(HSTMT StatementHandle, + PTR Data, SQLINTEGER StrLen_or_Ind); +RETCODE SQL_API PGAPI_RowCount(HSTMT StatementHandle, + SQLINTEGER * RowCount); +RETCODE SQL_API PGAPI_SetConnectOption(HDBC ConnectionHandle, + SQLUSMALLINT Option, SQLUINTEGER Value); +RETCODE SQL_API PGAPI_SetCursorName(HSTMT StatementHandle, + SQLCHAR * CursorName, SQLSMALLINT NameLength); +RETCODE SQL_API PGAPI_SetParam(HSTMT StatementHandle, + SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType, + SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision, + SQLSMALLINT ParameterScale, PTR ParameterValue, + SQLINTEGER * StrLen_or_Ind); +RETCODE SQL_API PGAPI_SetStmtOption(HSTMT StatementHandle, + SQLUSMALLINT Option, SQLUINTEGER Value); +RETCODE SQL_API PGAPI_SpecialColumns(HSTMT StatementHandle, + SQLUSMALLINT IdentifierType, SQLCHAR * CatalogName, + SQLSMALLINT NameLength1, SQLCHAR * SchemaName, + SQLSMALLINT NameLength2, SQLCHAR * TableName, + SQLSMALLINT NameLength3, SQLUSMALLINT Scope, + SQLUSMALLINT Nullable); +RETCODE SQL_API PGAPI_Statistics(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLUSMALLINT Unique, SQLUSMALLINT Reserved); +RETCODE SQL_API PGAPI_Tables(HSTMT StatementHandle, + SQLCHAR * CatalogName, SQLSMALLINT NameLength1, + SQLCHAR * SchemaName, SQLSMALLINT NameLength2, + SQLCHAR * TableName, SQLSMALLINT NameLength3, + SQLCHAR * TableType, SQLSMALLINT NameLength4); +RETCODE SQL_API PGAPI_Transact(HENV EnvironmentHandle, + HDBC ConnectionHandle, SQLUSMALLINT CompletionType); RETCODE SQL_API PGAPI_ColAttributes( - HSTMT hstmt, - SQLUSMALLINT icol, - SQLUSMALLINT fDescType, - PTR rgbDesc, - SQLSMALLINT cbDescMax, - SQLSMALLINT *pcbDesc, - SQLINTEGER *pfDesc); + HSTMT hstmt, + SQLUSMALLINT icol, + SQLUSMALLINT fDescType, + PTR rgbDesc, + SQLSMALLINT cbDescMax, + SQLSMALLINT * pcbDesc, + SQLINTEGER * pfDesc); RETCODE SQL_API PGAPI_ColumnPrivileges( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName, - SQLCHAR *szColumnName, - SQLSMALLINT cbColumnName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName, + SQLCHAR * szColumnName, + SQLSMALLINT cbColumnName); RETCODE SQL_API PGAPI_DescribeParam( - HSTMT hstmt, - SQLUSMALLINT ipar, - SQLSMALLINT *pfSqlType, - SQLUINTEGER *pcbParamDef, - SQLSMALLINT *pibScale, - SQLSMALLINT *pfNullable); + HSTMT hstmt, + SQLUSMALLINT ipar, + SQLSMALLINT * pfSqlType, + SQLUINTEGER * pcbParamDef, + SQLSMALLINT * pibScale, + SQLSMALLINT * pfNullable); RETCODE SQL_API PGAPI_ExtendedFetch( - HSTMT hstmt, - SQLUSMALLINT fFetchType, - SQLINTEGER irow, - SQLUINTEGER *pcrow, - SQLUSMALLINT *rgfRowStatus); + HSTMT hstmt, + SQLUSMALLINT fFetchType, + SQLINTEGER irow, + SQLUINTEGER * pcrow, + SQLUSMALLINT * rgfRowStatus); RETCODE SQL_API PGAPI_ForeignKeys( - HSTMT hstmt, - SQLCHAR *szPkCatalogName, - SQLSMALLINT cbPkCatalogName, - SQLCHAR *szPkSchemaName, - SQLSMALLINT cbPkSchemaName, - SQLCHAR *szPkTableName, - SQLSMALLINT cbPkTableName, - SQLCHAR *szFkCatalogName, - SQLSMALLINT cbFkCatalogName, - SQLCHAR *szFkSchemaName, - SQLSMALLINT cbFkSchemaName, - SQLCHAR *szFkTableName, - SQLSMALLINT cbFkTableName); + HSTMT hstmt, + SQLCHAR * szPkCatalogName, + SQLSMALLINT cbPkCatalogName, + SQLCHAR * szPkSchemaName, + SQLSMALLINT cbPkSchemaName, + SQLCHAR * szPkTableName, + SQLSMALLINT cbPkTableName, + SQLCHAR * szFkCatalogName, + SQLSMALLINT cbFkCatalogName, + SQLCHAR * szFkSchemaName, + SQLSMALLINT cbFkSchemaName, + SQLCHAR * szFkTableName, + SQLSMALLINT cbFkTableName); RETCODE SQL_API PGAPI_MoreResults( - HSTMT hstmt); + HSTMT hstmt); RETCODE SQL_API PGAPI_NativeSql( - HDBC hdbc, - SQLCHAR *szSqlStrIn, - SQLINTEGER cbSqlStrIn, - SQLCHAR *szSqlStr, - SQLINTEGER cbSqlStrMax, - SQLINTEGER *pcbSqlStr); + HDBC hdbc, + SQLCHAR * szSqlStrIn, + SQLINTEGER cbSqlStrIn, + SQLCHAR * szSqlStr, + SQLINTEGER cbSqlStrMax, + SQLINTEGER * pcbSqlStr); RETCODE SQL_API PGAPI_NumParams( - HSTMT hstmt, - SQLSMALLINT *pcpar); + HSTMT hstmt, + SQLSMALLINT * pcpar); RETCODE SQL_API PGAPI_ParamOptions( - HSTMT hstmt, - SQLUINTEGER crow, - SQLUINTEGER *pirow); + HSTMT hstmt, + SQLUINTEGER crow, + SQLUINTEGER * pirow); RETCODE SQL_API PGAPI_PrimaryKeys( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName); RETCODE SQL_API PGAPI_ProcedureColumns( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, - SQLSMALLINT cbProcName, - SQLCHAR *szColumnName, - SQLSMALLINT cbColumnName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szProcName, + SQLSMALLINT cbProcName, + SQLCHAR * szColumnName, + SQLSMALLINT cbColumnName); RETCODE SQL_API PGAPI_Procedures( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szProcName, - SQLSMALLINT cbProcName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szProcName, + SQLSMALLINT cbProcName); RETCODE SQL_API PGAPI_SetPos( - HSTMT hstmt, - SQLUSMALLINT irow, - SQLUSMALLINT fOption, - SQLUSMALLINT fLock); + HSTMT hstmt, + SQLUSMALLINT irow, + SQLUSMALLINT fOption, + SQLUSMALLINT fLock); RETCODE SQL_API PGAPI_TablePrivileges( - HSTMT hstmt, - SQLCHAR *szCatalogName, - SQLSMALLINT cbCatalogName, - SQLCHAR *szSchemaName, - SQLSMALLINT cbSchemaName, - SQLCHAR *szTableName, - SQLSMALLINT cbTableName); + HSTMT hstmt, + SQLCHAR * szCatalogName, + SQLSMALLINT cbCatalogName, + SQLCHAR * szSchemaName, + SQLSMALLINT cbSchemaName, + SQLCHAR * szTableName, + SQLSMALLINT cbTableName); RETCODE SQL_API PGAPI_BindParameter( - HSTMT hstmt, - SQLUSMALLINT ipar, - SQLSMALLINT fParamType, - SQLSMALLINT fCType, - SQLSMALLINT fSqlType, - SQLUINTEGER cbColDef, - SQLSMALLINT ibScale, - PTR rgbValue, - SQLINTEGER cbValueMax, - SQLINTEGER *pcbValue); + HSTMT hstmt, + SQLUSMALLINT ipar, + SQLSMALLINT fParamType, + SQLSMALLINT fCType, + SQLSMALLINT fSqlType, + SQLUINTEGER cbColDef, + SQLSMALLINT ibScale, + PTR rgbValue, + SQLINTEGER cbValueMax, + SQLINTEGER * pcbValue); RETCODE SQL_API PGAPI_SetScrollOptions( - HSTMT hstmt, - UWORD fConcurrency, - SDWORD crowKeyset, - UWORD crowRowset); -#endif /* define_PG_API_FUNC_H__ */ + HSTMT hstmt, + UWORD fConcurrency, + SDWORD crowKeyset, + UWORD crowRowset); +#endif /* define_PG_API_FUNC_H__ */ diff --git a/src/interfaces/odbc/pgtypes.c b/src/interfaces/odbc/pgtypes.c index d6995f8c46..6f1282a36c 100644 --- a/src/interfaces/odbc/pgtypes.c +++ b/src/interfaces/odbc/pgtypes.c @@ -25,7 +25,7 @@ -Int4 getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); +Int4 getCharPrecision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as); /* * these are the types we support. all of the pgtype_ functions should @@ -94,10 +94,10 @@ Int2 sqlTypes[] = { Int4 -sqltype_to_pgtype(StatementClass *stmt, SWORD fSqlType) +sqltype_to_pgtype(StatementClass * stmt, SWORD fSqlType) { Int4 pgType; - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); switch (fSqlType) { @@ -190,9 +190,10 @@ sqltype_to_pgtype(StatementClass *stmt, SWORD fSqlType) * types that are unknown. All other pg routines in here return a suitable default. */ Int2 -pgtype_to_sqltype(StatementClass *stmt, Int4 type) +pgtype_to_sqltype(StatementClass * stmt, Int4 type) { - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + switch (type) { case PG_TYPE_CHAR: @@ -265,9 +266,10 @@ pgtype_to_sqltype(StatementClass *stmt, Int4 type) Int2 -pgtype_to_ctype(StatementClass *stmt, Int4 type) +pgtype_to_ctype(StatementClass * stmt, Int4 type) { - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + switch (type) { case PG_TYPE_INT8: @@ -313,7 +315,7 @@ pgtype_to_ctype(StatementClass *stmt, Int4 type) char * -pgtype_to_name(StatementClass *stmt, Int4 type) +pgtype_to_name(StatementClass * stmt, Int4 type) { switch (type) { @@ -382,7 +384,7 @@ pgtype_to_name(StatementClass *stmt, Int4 type) static Int2 -getNumericScale(StatementClass *stmt, Int4 type, int col) +getNumericScale(StatementClass * stmt, Int4 type, int col) { Int4 atttypmod; QResultClass *result; @@ -419,7 +421,7 @@ getNumericScale(StatementClass *stmt, Int4 type, int col) static Int4 -getNumericPrecision(StatementClass *stmt, Int4 type, int col) +getNumericPrecision(StatementClass * stmt, Int4 type, int col) { Int4 atttypmod; QResultClass *result; @@ -456,13 +458,13 @@ getNumericPrecision(StatementClass *stmt, Int4 type, int col) Int4 -getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as) +getCharPrecision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as) { int p = -1, maxsize; QResultClass *result; ColumnInfoClass *flds; - ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); + ConnInfo *ci = &(SC_get_conn(stmt)->connInfo); mylog("getCharPrecision: type=%d, col=%d, unknown = %d\n", type, col, handle_unknown_size_as); @@ -497,7 +499,7 @@ getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si { if (PG_VERSION_GE(SC_get_conn(stmt), 7.1)) maxsize = 0; - else + else maxsize = TEXT_FIELD_SIZE; } if (col < 0) @@ -543,7 +545,7 @@ getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si * This is used for functions SQLDescribeCol and SQLColAttributes. */ Int4 -pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as) +pgtype_precision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as) { switch (type) { @@ -610,7 +612,7 @@ pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si Int4 -pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as) +pgtype_display_size(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as) { switch (type) { @@ -651,7 +653,7 @@ pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown * override this length with the atttypmod length from pg_attribute */ Int4 -pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as) +pgtype_length(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as) { switch (type) { @@ -678,12 +680,12 @@ pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_ case PG_TYPE_DATE: case PG_TYPE_TIME: - return 6; /* sizeof(DATE(TIME)_STRUCT) */ + return 6; /* sizeof(DATE(TIME)_STRUCT) */ case PG_TYPE_ABSTIME: case PG_TYPE_DATETIME: case PG_TYPE_TIMESTAMP: - return 16; /* sizeof(TIMESTAMP_STRUCT) */ + return 16; /* sizeof(TIMESTAMP_STRUCT) */ /* Character types (and NUMERIC) use the default precision */ case PG_TYPE_VARCHAR: @@ -695,8 +697,8 @@ pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_ else #else /* CR -> CR/LF */ - return 2 * pgtype_precision(stmt, type, col, handle_unknown_size_as); -#endif /* MULTIBYTE */ + return 2 * pgtype_precision(stmt, type, col, handle_unknown_size_as); +#endif /* MULTIBYTE */ default: return pgtype_precision(stmt, type, col, handle_unknown_size_as); } @@ -704,7 +706,7 @@ pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_ Int2 -pgtype_scale(StatementClass *stmt, Int4 type, int col) +pgtype_scale(StatementClass * stmt, Int4 type, int col) { switch (type) { @@ -738,7 +740,7 @@ pgtype_scale(StatementClass *stmt, Int4 type, int col) Int2 -pgtype_radix(StatementClass *stmt, Int4 type) +pgtype_radix(StatementClass * stmt, Int4 type) { switch (type) { @@ -758,14 +760,14 @@ pgtype_radix(StatementClass *stmt, Int4 type) Int2 -pgtype_nullable(StatementClass *stmt, Int4 type) +pgtype_nullable(StatementClass * stmt, Int4 type) { return SQL_NULLABLE; /* everything should be nullable */ } Int2 -pgtype_auto_increment(StatementClass *stmt, Int4 type) +pgtype_auto_increment(StatementClass * stmt, Int4 type) { switch (type) { @@ -794,7 +796,7 @@ pgtype_auto_increment(StatementClass *stmt, Int4 type) Int2 -pgtype_case_sensitive(StatementClass *stmt, Int4 type) +pgtype_case_sensitive(StatementClass * stmt, Int4 type) { switch (type) { @@ -817,7 +819,7 @@ pgtype_case_sensitive(StatementClass *stmt, Int4 type) Int2 -pgtype_money(StatementClass *stmt, Int4 type) +pgtype_money(StatementClass * stmt, Int4 type) { switch (type) { @@ -830,7 +832,7 @@ pgtype_money(StatementClass *stmt, Int4 type) Int2 -pgtype_searchable(StatementClass *stmt, Int4 type) +pgtype_searchable(StatementClass * stmt, Int4 type) { switch (type) { @@ -852,7 +854,7 @@ pgtype_searchable(StatementClass *stmt, Int4 type) Int2 -pgtype_unsigned(StatementClass *stmt, Int4 type) +pgtype_unsigned(StatementClass * stmt, Int4 type) { switch (type) { @@ -876,19 +878,20 @@ pgtype_unsigned(StatementClass *stmt, Int4 type) char * -pgtype_literal_prefix(StatementClass *stmt, Int4 type) +pgtype_literal_prefix(StatementClass * stmt, Int4 type) { switch (type) { - case PG_TYPE_INT2: - case PG_TYPE_OID: - case PG_TYPE_XID: - case PG_TYPE_INT4: - case PG_TYPE_INT8: - case PG_TYPE_NUMERIC: - case PG_TYPE_FLOAT4: - case PG_TYPE_FLOAT8: - case PG_TYPE_MONEY:return NULL; + case PG_TYPE_INT2: + case PG_TYPE_OID: + case PG_TYPE_XID: + case PG_TYPE_INT4: + case PG_TYPE_INT8: + case PG_TYPE_NUMERIC: + case PG_TYPE_FLOAT4: + case PG_TYPE_FLOAT8: + case PG_TYPE_MONEY: + return NULL; default: return "'"; @@ -897,19 +900,20 @@ pgtype_literal_prefix(StatementClass *stmt, Int4 type) char * -pgtype_literal_suffix(StatementClass *stmt, Int4 type) +pgtype_literal_suffix(StatementClass * stmt, Int4 type) { switch (type) { - case PG_TYPE_INT2: - case PG_TYPE_OID: - case PG_TYPE_XID: - case PG_TYPE_INT4: - case PG_TYPE_INT8: - case PG_TYPE_NUMERIC: - case PG_TYPE_FLOAT4: - case PG_TYPE_FLOAT8: - case PG_TYPE_MONEY:return NULL; + case PG_TYPE_INT2: + case PG_TYPE_OID: + case PG_TYPE_XID: + case PG_TYPE_INT4: + case PG_TYPE_INT8: + case PG_TYPE_NUMERIC: + case PG_TYPE_FLOAT4: + case PG_TYPE_FLOAT8: + case PG_TYPE_MONEY: + return NULL; default: return "'"; @@ -918,12 +922,13 @@ pgtype_literal_suffix(StatementClass *stmt, Int4 type) char * -pgtype_create_params(StatementClass *stmt, Int4 type) +pgtype_create_params(StatementClass * stmt, Int4 type) { switch (type) { - case PG_TYPE_CHAR: - case PG_TYPE_VARCHAR:return "max. length"; + case PG_TYPE_CHAR: + case PG_TYPE_VARCHAR: + return "max. length"; default: return NULL; } @@ -933,7 +938,6 @@ pgtype_create_params(StatementClass *stmt, Int4 type) Int2 sqltype_to_default_ctype(Int2 sqltype) { - /* * from the table on page 623 of ODBC 2.0 Programmer's Reference * (Appendix D) diff --git a/src/interfaces/odbc/pgtypes.h b/src/interfaces/odbc/pgtypes.h index 7bd33cf751..6761ec319e 100644 --- a/src/interfaces/odbc/pgtypes.h +++ b/src/interfaces/odbc/pgtypes.h @@ -68,30 +68,29 @@ extern Int2 sqlTypes[]; /* Defines for pgtype_precision */ #define PG_STATIC (-1) -Int4 sqltype_to_pgtype(StatementClass *stmt, Int2 fSqlType); +Int4 sqltype_to_pgtype(StatementClass * stmt, Int2 fSqlType); -Int2 pgtype_to_sqltype(StatementClass *stmt, Int4 type); -Int2 pgtype_to_ctype(StatementClass *stmt, Int4 type); -char *pgtype_to_name(StatementClass *stmt, Int4 type); +Int2 pgtype_to_sqltype(StatementClass * stmt, Int4 type); +Int2 pgtype_to_ctype(StatementClass * stmt, Int4 type); +char *pgtype_to_name(StatementClass * stmt, Int4 type); /* These functions can use static numbers or result sets(col parameter) */ -Int4 pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); -Int4 pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); -Int4 pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_as); +Int4 pgtype_precision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as); +Int4 pgtype_display_size(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as); +Int4 pgtype_length(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as); -Int2 pgtype_scale(StatementClass *stmt, Int4 type, int col); -Int2 pgtype_radix(StatementClass *stmt, Int4 type); -Int2 pgtype_nullable(StatementClass *stmt, Int4 type); -Int2 pgtype_auto_increment(StatementClass *stmt, Int4 type); -Int2 pgtype_case_sensitive(StatementClass *stmt, Int4 type); -Int2 pgtype_money(StatementClass *stmt, Int4 type); -Int2 pgtype_searchable(StatementClass *stmt, Int4 type); -Int2 pgtype_unsigned(StatementClass *stmt, Int4 type); -char *pgtype_literal_prefix(StatementClass *stmt, Int4 type); -char *pgtype_literal_suffix(StatementClass *stmt, Int4 type); -char *pgtype_create_params(StatementClass *stmt, Int4 type); +Int2 pgtype_scale(StatementClass * stmt, Int4 type, int col); +Int2 pgtype_radix(StatementClass * stmt, Int4 type); +Int2 pgtype_nullable(StatementClass * stmt, Int4 type); +Int2 pgtype_auto_increment(StatementClass * stmt, Int4 type); +Int2 pgtype_case_sensitive(StatementClass * stmt, Int4 type); +Int2 pgtype_money(StatementClass * stmt, Int4 type); +Int2 pgtype_searchable(StatementClass * stmt, Int4 type); +Int2 pgtype_unsigned(StatementClass * stmt, Int4 type); +char *pgtype_literal_prefix(StatementClass * stmt, Int4 type); +char *pgtype_literal_suffix(StatementClass * stmt, Int4 type); +char *pgtype_create_params(StatementClass * stmt, Int4 type); Int2 sqltype_to_default_ctype(Int2 sqltype); Int4 ctype_length(Int2 ctype); - #endif diff --git a/src/interfaces/odbc/psqlodbc.c b/src/interfaces/odbc/psqlodbc.c index 3c8ff2a53f..841360da34 100644 --- a/src/interfaces/odbc/psqlodbc.c +++ b/src/interfaces/odbc/psqlodbc.c @@ -114,9 +114,7 @@ _fini(void) { return TRUE; } - #endif /* not __GNUC__ */ - #endif /* not WIN32 */ @@ -127,7 +125,7 @@ _fini(void) * 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) { return SQL_SUCCESS; diff --git a/src/interfaces/odbc/psqlodbc.h b/src/interfaces/odbc/psqlodbc.h index 796b282af8..514922036b 100644 --- a/src/interfaces/odbc/psqlodbc.h +++ b/src/interfaces/odbc/psqlodbc.h @@ -5,7 +5,7 @@ * * Comments: See "notice.txt" for copyright and license information. * - * $Id: psqlodbc.h,v 1.51 2001/10/12 09:41:49 inoue Exp $ + * $Id: psqlodbc.h,v 1.52 2001/10/25 05:50:15 momjian Exp $ * */ @@ -25,7 +25,7 @@ #define ODBCVER ODBCVER_REP #else #define ODBCVER 0x0250 -#endif /* ODBCVER_REP */ +#endif /* ODBCVER_REP */ #if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC) @@ -185,7 +185,7 @@ typedef struct GlobalValues_ char extra_systable_prefixes[MEDIUM_REGISTRY_LEN]; char conn_settings[LARGE_REGISTRY_LEN]; char protocol[SMALL_REGISTRY_LEN]; -} GLOBAL_VALUES; +} GLOBAL_VALUES; typedef struct StatementOptions_ { @@ -199,10 +199,10 @@ typedef struct StatementOptions_ int bind_size; /* size of each structure if using Row * Binding */ int use_bookmarks; - UInt4 *rowsFetched; - UInt2 *rowStatusArray; - void *bookmark_ptr; -} StatementOptions; + UInt4 *rowsFetched; + UInt2 *rowStatusArray; + void *bookmark_ptr; +} StatementOptions; /* Used to pass extra query info to send_query */ typedef struct QueryInfo_ @@ -210,9 +210,9 @@ typedef struct QueryInfo_ int row_size; QResultClass *result_in; char *cursor; -} QueryInfo; +} QueryInfo; -void logs_on_off(int cnopen, int, int); +void logs_on_off(int cnopen, int, int); #define PG_TYPE_LO (-999) /* hack until permanent * type available */ @@ -231,20 +231,22 @@ void logs_on_off(int cnopen, int, int); #define PG_NUMERIC_MAX_PRECISION 1000 #define PG_NUMERIC_MAX_SCALE 1000 -#define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for -queries used in info.c inoue 2001/05/17 */ +#define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for + * queries used in info.c inoue + * 2001/05/17 */ #include "misc.h" #ifdef _MEMORY_DEBUG_ -void * debug_alloc(size_t); -void * debug_realloc(void *, size_t); -char * debug_strdup(const char *); -void debug_free(void *); -void debug_memory_check(void); -#define malloc debug_alloc -#define realloc debug_realloc -#define strdup debug_strdup -#define free debug_free -#endif /* _MEMORY_DEBUG_ */ +void *debug_alloc(size_t); +void *debug_realloc(void *, size_t); +char *debug_strdup(const char *); +void debug_free(void *); +void debug_memory_check(void); + +#define malloc debug_alloc +#define realloc debug_realloc +#define strdup debug_strdup +#define free debug_free +#endif /* _MEMORY_DEBUG_ */ #endif diff --git a/src/interfaces/odbc/qresult.c b/src/interfaces/odbc/qresult.c index b3c8f6fcc0..b9f088227f 100644 --- a/src/interfaces/odbc/qresult.c +++ b/src/interfaces/odbc/qresult.c @@ -39,7 +39,7 @@ * All info functions call this function to create the manual result set. */ void -QR_set_num_fields(QResultClass *self, int new_num_fields) +QR_set_num_fields(QResultClass * self, int new_num_fields) { mylog("in QR_set_num_fields\n"); @@ -54,28 +54,28 @@ QR_set_num_fields(QResultClass *self, int new_num_fields) void -QR_set_position(QResultClass *self, int pos) +QR_set_position(QResultClass * self, int pos) { self->tupleField = self->backend_tuples + ((self->base + pos) * self->num_fields); } void -QR_set_cache_size(QResultClass *self, int cache_size) +QR_set_cache_size(QResultClass * self, int cache_size) { self->cache_size = cache_size; } void -QR_set_rowset_size(QResultClass *self, int rowset_size) +QR_set_rowset_size(QResultClass * self, int rowset_size) { self->rowset_size = rowset_size; } void -QR_inc_base(QResultClass *self, int base_inc) +QR_inc_base(QResultClass * self, int base_inc) { self->base += base_inc; } @@ -128,7 +128,7 @@ QR_Constructor() void -QR_Destructor(QResultClass *self) +QR_Destructor(QResultClass * self) { mylog("QResult: in DESTRUCTOR\n"); @@ -168,7 +168,7 @@ QR_Destructor(QResultClass *self) void -QR_set_command(QResultClass *self, char *msg) +QR_set_command(QResultClass * self, char *msg) { if (self->command) free(self->command); @@ -178,7 +178,7 @@ QR_set_command(QResultClass *self, char *msg) void -QR_set_notice(QResultClass *self, char *msg) +QR_set_notice(QResultClass * self, char *msg) { if (self->notice) free(self->notice); @@ -188,7 +188,7 @@ QR_set_notice(QResultClass *self, char *msg) void -QR_free_memory(QResultClass *self) +QR_free_memory(QResultClass * self) { register int lf, row; @@ -211,7 +211,7 @@ QR_free_memory(QResultClass *self) free(tuple[lf].value); } } - tuple += num_fields;/* next row */ + tuple += num_fields; /* next row */ } free(self->backend_tuples); @@ -226,7 +226,7 @@ QR_free_memory(QResultClass *self) /* This function is called by send_query() */ char -QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor) +QR_fetch_tuples(QResultClass * self, ConnectionClass * conn, char *cursor) { int tuple_size; @@ -238,8 +238,9 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor) */ if (conn != NULL) { - ConnInfo *ci = &(conn->connInfo); - BOOL fetch_cursor = (ci->drivers.use_declarefetch && cursor && cursor[0]); + ConnInfo *ci = &(conn->connInfo); + BOOL fetch_cursor = (ci->drivers.use_declarefetch && cursor && cursor[0]); + self->conn = conn; mylog("QR_fetch_tuples: cursor = '%s', self->cursor=%u\n", (cursor == NULL) ? "" : cursor, self->cursor); @@ -305,7 +306,6 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor) } else { - /* * Always have to read the field attributes. But we dont have to * reallocate memory for them! @@ -327,7 +327,7 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor) * We only close cursor/end the transaction if a cursor was used. */ int -QR_close(QResultClass *self) +QR_close(QResultClass * self) { QResultClass *res; @@ -379,7 +379,7 @@ QR_close(QResultClass *self) /* This function is called by fetch_tuples() AND SQLFetch() */ int -QR_next_tuple(QResultClass *self) +QR_next_tuple(QResultClass * self) { int id; QResultClass *res; @@ -401,7 +401,7 @@ QR_next_tuple(QResultClass *self) char cmdbuffer[ERROR_MSG_LENGTH + 1]; char fetch[128]; QueryInfo qi; - ConnInfo *ci = NULL; + ConnInfo *ci = NULL; if (fetch_count < fcount) { @@ -423,7 +423,6 @@ QR_next_tuple(QResultClass *self) } else { - /* * See if we need to fetch another group of rows. We may be being * called from send_query(), and if so, don't send another fetch, @@ -539,12 +538,12 @@ QR_next_tuple(QResultClass *self) if ((!self->cursor || !ci->drivers.use_declarefetch) && self->fcount >= self->count_allocated) { - int tuple_size = self->count_allocated; + int tuple_size = self->count_allocated; mylog("REALLOC: old_count = %d, size = %d\n", tuple_size, self->num_fields * sizeof(TupleField) * tuple_size); tuple_size *= 2; self->backend_tuples = (TupleField *) realloc(self->backend_tuples, - tuple_size * self->num_fields * sizeof(TupleField)); + tuple_size * self->num_fields * sizeof(TupleField)); if (!self->backend_tuples) { self->status = PGRES_FATAL_ERROR; @@ -621,7 +620,7 @@ QR_next_tuple(QResultClass *self) char -QR_read_tuple(QResultClass *self, char binary) +QR_read_tuple(QResultClass * self, char binary) { Int2 field_lf; TupleField *this_tuplefield; @@ -664,7 +663,6 @@ QR_read_tuple(QResultClass *self, char binary) } else { - /* * NO, the field is not null. so get at first the length of * the field (four bytes) diff --git a/src/interfaces/odbc/qresult.h b/src/interfaces/odbc/qresult.h index 29e171bad8..23e125247c 100644 --- a/src/interfaces/odbc/qresult.h +++ b/src/interfaces/odbc/qresult.h @@ -19,22 +19,23 @@ enum QueryResultCode_ { - PGRES_EMPTY_QUERY = 0, - PGRES_COMMAND_OK, /* a query command that doesn't return */ + PGRES_EMPTY_QUERY = 0, + PGRES_COMMAND_OK, /* a query command that doesn't + * return */ /* anything was executed properly by the backend */ - PGRES_TUPLES_OK, /* a query command that returns tuples */ + PGRES_TUPLES_OK,/* a query command that returns tuples */ /* was executed properly by the backend, PGresult */ /* contains the resulttuples */ - PGRES_COPY_OUT, - PGRES_COPY_IN, - PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from - * the backend */ - PGRES_NONFATAL_ERROR, - PGRES_FATAL_ERROR, - PGRES_FIELDS_OK, /* field information from a query was + PGRES_COPY_OUT, + PGRES_COPY_IN, + PGRES_BAD_RESPONSE, /* an unexpected response was + * recv'd from the backend */ + PGRES_NONFATAL_ERROR, + PGRES_FATAL_ERROR, + PGRES_FIELDS_OK,/* field information from a query was * successful */ - PGRES_END_TUPLES, - PGRES_INTERNAL_ERROR + PGRES_END_TUPLES, + PGRES_INTERNAL_ERROR }; typedef enum QueryResultCode_ QueryResultCode; @@ -47,7 +48,7 @@ struct QResultClass_ * (backend) */ /* Stuff for declare/fetch tuples */ - int count_allocated; /* m(re)alloced count */ + int count_allocated; /* m(re)alloced count */ int fetch_count; /* logical rows read so far */ int fcount; /* actual rows read in the fetch */ int currTuple; @@ -112,20 +113,19 @@ struct QResultClass_ /* Core Functions */ QResultClass *QR_Constructor(void); -void QR_Destructor(QResultClass *self); -char QR_read_tuple(QResultClass *self, char binary); -int QR_next_tuple(QResultClass *self); -int QR_close(QResultClass *self); -char QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor); -void QR_free_memory(QResultClass *self); -void QR_set_command(QResultClass *self, char *msg); -void QR_set_notice(QResultClass *self, char *msg); - -void QR_set_num_fields(QResultClass *self, int new_num_fields); /* manual result only */ - -void QR_inc_base(QResultClass *self, int base_inc); -void QR_set_cache_size(QResultClass *self, int cache_size); -void QR_set_rowset_size(QResultClass *self, int rowset_size); -void QR_set_position(QResultClass *self, int pos); - +void QR_Destructor(QResultClass * self); +char QR_read_tuple(QResultClass * self, char binary); +int QR_next_tuple(QResultClass * self); +int QR_close(QResultClass * self); +char QR_fetch_tuples(QResultClass * self, ConnectionClass * conn, char *cursor); +void QR_free_memory(QResultClass * self); +void QR_set_command(QResultClass * self, char *msg); +void QR_set_notice(QResultClass * self, char *msg); + +void QR_set_num_fields(QResultClass * self, int new_num_fields); /* manual result only */ + +void QR_inc_base(QResultClass * self, int base_inc); +void QR_set_cache_size(QResultClass * self, int cache_size); +void QR_set_rowset_size(QResultClass * self, int rowset_size); +void QR_set_position(QResultClass * self, int pos); #endif diff --git a/src/interfaces/odbc/resource.h b/src/interfaces/odbc/resource.h index 452ff929fa..688ff7a6b9 100644 --- a/src/interfaces/odbc/resource.h +++ b/src/interfaces/odbc/resource.h @@ -1,65 +1,65 @@ -//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by psqlodbc.rc
-//
-#define IDS_BADDSN 1
-#define IDS_MSGTITLE 2
-#define DLG_OPTIONS_DRV 102
-#define DLG_OPTIONS_DS 103
-#define IDC_DSNAME 400
-#define IDC_DSNAMETEXT 401
-#define IDC_DESC 404
-#define IDC_SERVER 407
-#define IDC_DATABASE 408
-#define DLG_CONFIG 1001
-#define IDC_PORT 1002
-#define IDC_USER 1006
-#define IDC_PASSWORD 1009
-#define DS_READONLY 1011
-#define DS_SHOWOIDCOLUMN 1012
-#define DS_FAKEOIDINDEX 1013
-#define DRV_COMMLOG 1014
-#define DS_PG62 1016
-#define IDC_DATASOURCE 1018
-#define DRV_OPTIMIZER 1019
-#define DS_CONNSETTINGS 1020
-#define IDC_DRIVER 1021
-#define DRV_CONNSETTINGS 1031
-#define DRV_UNIQUEINDEX 1032
-#define DRV_UNKNOWN_MAX 1035
-#define DRV_UNKNOWN_DONTKNOW 1036
-#define DRV_READONLY 1037
-#define IDC_DESCTEXT 1039
-#define DRV_MSG_LABEL 1040
-#define DRV_UNKNOWN_LONGEST 1041
-#define DRV_TEXT_LONGVARCHAR 1043
-#define DRV_UNKNOWNS_LONGVARCHAR 1044
-#define DRV_CACHE_SIZE 1045
-#define DRV_VARCHAR_SIZE 1046
-#define DRV_LONGVARCHAR_SIZE 1047
-#define IDDEFAULTS 1048
-#define DRV_USEDECLAREFETCH 1049
-#define DRV_BOOLS_CHAR 1050
-#define DS_SHOWSYSTEMTABLES 1051
-#define DRV_EXTRASYSTABLEPREFIXES 1051
-#define DS_ROWVERSIONING 1052
-#define DRV_PARSE 1052
-#define DRV_CANCELASFREESTMT 1053
-#define IDC_OPTIONS 1054
-#define DRV_KSQO 1055
-#define DS_PG64 1057
-#define DS_PG63 1058
-#define DRV_OR_DSN 1059
+/* {{NO_DEPENDENCIES}}
*/ +/* Microsoft Developer Studio generated include file.
*/ +/* Used by psqlodbc.rc
*/ +/*
*/ +#define IDS_BADDSN 1
+#define IDS_MSGTITLE 2
+#define DLG_OPTIONS_DRV 102
+#define DLG_OPTIONS_DS 103
+#define IDC_DSNAME 400
+#define IDC_DSNAMETEXT 401
+#define IDC_DESC 404
+#define IDC_SERVER 407
+#define IDC_DATABASE 408
+#define DLG_CONFIG 1001
+#define IDC_PORT 1002
+#define IDC_USER 1006
+#define IDC_PASSWORD 1009
+#define DS_READONLY 1011
+#define DS_SHOWOIDCOLUMN 1012
+#define DS_FAKEOIDINDEX 1013
+#define DRV_COMMLOG 1014
+#define DS_PG62 1016
+#define IDC_DATASOURCE 1018
+#define DRV_OPTIMIZER 1019
+#define DS_CONNSETTINGS 1020
+#define IDC_DRIVER 1021
+#define DRV_CONNSETTINGS 1031
+#define DRV_UNIQUEINDEX 1032
+#define DRV_UNKNOWN_MAX 1035
+#define DRV_UNKNOWN_DONTKNOW 1036
+#define DRV_READONLY 1037
+#define IDC_DESCTEXT 1039
+#define DRV_MSG_LABEL 1040
+#define DRV_UNKNOWN_LONGEST 1041
+#define DRV_TEXT_LONGVARCHAR 1043
+#define DRV_UNKNOWNS_LONGVARCHAR 1044
+#define DRV_CACHE_SIZE 1045
+#define DRV_VARCHAR_SIZE 1046
+#define DRV_LONGVARCHAR_SIZE 1047
+#define IDDEFAULTS 1048
+#define DRV_USEDECLAREFETCH 1049
+#define DRV_BOOLS_CHAR 1050
+#define DS_SHOWSYSTEMTABLES 1051
+#define DRV_EXTRASYSTABLEPREFIXES 1051
+#define DS_ROWVERSIONING 1052
+#define DRV_PARSE 1052
+#define DRV_CANCELASFREESTMT 1053
+#define IDC_OPTIONS 1054
+#define DRV_KSQO 1055
+#define DS_PG64 1057
+#define DS_PG63 1058
+#define DRV_OR_DSN 1059
#define DRV_DEBUG 1060
#define DS_DISALLOWPREMATURE 1061
-// Next default values for new objects
-//
+/* Next default values for new objects
*/ +/*
*/ #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 105
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1062
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1062
+#define _APS_NEXT_SYMED_VALUE 101
+#endif /*
*/ +#endif /*
*/ diff --git a/src/interfaces/odbc/results.c b/src/interfaces/odbc/results.c index c5652ff984..3565e3f8d5 100644 --- a/src/interfaces/odbc/results.c +++ b/src/interfaces/odbc/results.c @@ -33,17 +33,17 @@ -RETCODE SQL_API +RETCODE SQL_API PGAPI_RowCount( - HSTMT hstmt, - SDWORD FAR *pcrow) + HSTMT hstmt, + SDWORD FAR * pcrow) { static char *func = "PGAPI_RowCount"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *res; char *msg, *ptr; - ConnInfo *ci; + ConnInfo *ci; if (!stmt) { @@ -104,16 +104,16 @@ PGAPI_RowCount( * This returns the number of columns associated with the database * attached to "hstmt". */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_NumResultCols( - HSTMT hstmt, - SWORD FAR *pccol) + HSTMT hstmt, + SWORD FAR * pccol) { static char *func = "PGAPI_NumResultCols"; StatementClass *stmt = (StatementClass *) hstmt; QResultClass *result; char parse_ok; - ConnInfo *ci; + ConnInfo *ci; if (!stmt) { @@ -159,10 +159,8 @@ PGAPI_NumResultCols( *pccol = QR_NumResultCols(result); /* updatable cursors */ if (ci->updatable_cursors && - stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) - { + stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) *pccol -= 2; - } } return SQL_SUCCESS; @@ -173,17 +171,17 @@ PGAPI_NumResultCols( * Return information about the database column the user wants * information about. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_DescribeCol( - HSTMT hstmt, - UWORD icol, - UCHAR FAR *szColName, - SWORD cbColNameMax, - SWORD FAR *pcbColName, - SWORD FAR *pfSqlType, - UDWORD FAR *pcbColDef, - SWORD FAR *pibScale, - SWORD FAR *pfNullable) + HSTMT hstmt, + UWORD icol, + UCHAR FAR * szColName, + SWORD cbColNameMax, + SWORD FAR * pcbColName, + SWORD FAR * pfSqlType, + UDWORD FAR * pcbColDef, + SWORD FAR * pibScale, + SWORD FAR * pfNullable) { static char *func = "PGAPI_DescribeCol"; @@ -192,7 +190,8 @@ PGAPI_DescribeCol( QResultClass *res; char *col_name = NULL; Int4 fieldtype = 0; - int precision = 0, scale = 0; + int precision = 0, + scale = 0; ConnInfo *ci; char parse_ok; char buf[255]; @@ -365,15 +364,15 @@ PGAPI_DescribeCol( /* Returns result column descriptor information for a result set. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ColAttributes( - HSTMT hstmt, - UWORD icol, - UWORD fDescType, - PTR rgbDesc, - SWORD cbDescMax, - SWORD FAR *pcbDesc, - SDWORD FAR *pfDesc) + HSTMT hstmt, + UWORD icol, + UWORD fDescType, + PTR rgbDesc, + SWORD cbDescMax, + SWORD FAR * pcbDesc, + SDWORD FAR * pfDesc) { static char *func = "PGAPI_ColAttributes"; StatementClass *stmt = (StatementClass *) hstmt; @@ -637,14 +636,14 @@ PGAPI_ColAttributes( /* Returns result data for a single column in the current row. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetData( - HSTMT hstmt, - UWORD icol, - SWORD fCType, - PTR rgbValue, - SDWORD cbValueMax, - SDWORD FAR *pcbValue) + HSTMT hstmt, + UWORD icol, + SWORD fCType, + PTR rgbValue, + SDWORD cbValueMax, + SDWORD FAR * pcbValue) { static char *func = "PGAPI_GetData"; QResultClass *res; @@ -655,7 +654,7 @@ PGAPI_GetData( void *value = NULL; int result; char get_bookmark = FALSE; - ConnInfo *ci; + ConnInfo *ci; mylog("PGAPI_GetData: enter, stmt=%u\n", stmt); @@ -824,9 +823,9 @@ PGAPI_GetData( * Returns data for bound columns in the current row ("hstmt->iCursor"), * advances the cursor. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_Fetch( - HSTMT hstmt) + HSTMT hstmt) { static char *func = "PGAPI_Fetch"; StatementClass *stmt = (StatementClass *) hstmt; @@ -893,13 +892,13 @@ PGAPI_Fetch( /* This fetchs a block of data (rowset). */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_ExtendedFetch( - HSTMT hstmt, - UWORD fFetchType, - SDWORD irow, - UDWORD FAR *pcrow, - UWORD FAR *rgfRowStatus) + HSTMT hstmt, + UWORD fFetchType, + SDWORD irow, + UDWORD FAR * pcrow, + UWORD FAR * rgfRowStatus) { static char *func = "PGAPI_ExtendedFetch"; StatementClass *stmt = (StatementClass *) hstmt; @@ -910,7 +909,7 @@ PGAPI_ExtendedFetch( RETCODE result; char truncated, error; - ConnInfo *ci; + ConnInfo *ci; mylog("PGAPI_ExtendedFetch: stmt=%u\n", stmt); @@ -1166,7 +1165,7 @@ PGAPI_ExtendedFetch( /* this should be refined */ else if (result > 10 && result < 20) *(rgfRowStatus + i) = result - 10; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ else *(rgfRowStatus + i) = SQL_ROW_SUCCESS; } @@ -1208,9 +1207,9 @@ PGAPI_ExtendedFetch( * the "hstmt". */ /* CC: return SQL_NO_DATA_FOUND since we do not support multiple result sets */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_MoreResults( - HSTMT hstmt) + HSTMT hstmt) { return SQL_NO_DATA_FOUND; } @@ -1218,14 +1217,14 @@ PGAPI_MoreResults( #ifdef DRIVER_CURSOR_IMPLEMENT /* - * Stuff for updatable cursors. + * Stuff for updatable cursors. */ static QResultClass * -positioned_load(StatementClass *stmt, BOOL latest, int res_cols, UInt4 oid, const char *tidval) +positioned_load(StatementClass * stmt, BOOL latest, int res_cols, UInt4 oid, const char *tidval) { - int i; - QResultClass *qres; - char selstr[4096]; + int i; + QResultClass *qres; + char selstr[4096]; sprintf(selstr, "select"); for (i = 0; i < res_cols; i++) @@ -1235,12 +1234,12 @@ positioned_load(StatementClass *stmt, BOOL latest, int res_cols, UInt4 oid, cons { if (latest) sprintf(selstr, "%s ctid = currtid2('%s', '%s') and", - selstr, stmt->ti[0]->name, tidval); + selstr, stmt->ti[0]->name, tidval); else sprintf(selstr, "%s ctid = '%s' and", selstr, tidval); } - sprintf(selstr, "%s oid = %u", selstr, oid), - mylog("selstr=%s\n", selstr); + sprintf(selstr, "%s oid = %u", selstr, oid), + mylog("selstr=%s\n", selstr); qres = CC_send_query(SC_get_conn(stmt), selstr, NULL); if (qres && QR_aborted(qres)) { @@ -1250,15 +1249,19 @@ positioned_load(StatementClass *stmt, BOOL latest, int res_cols, UInt4 oid, cons return qres; } -RETCODE SQL_API -SC_pos_reload(StatementClass *stmt, UWORD irow, UWORD *count) +RETCODE SQL_API +SC_pos_reload(StatementClass * stmt, UWORD irow, UWORD * count) { - int i, res_cols; - UWORD rcnt, global_ridx; - UInt4 oid; - QResultClass *res, *qres; - RETCODE ret = SQL_ERROR; - char *tidval, *oidval; + int i, + res_cols; + UWORD rcnt, + global_ridx; + UInt4 oid; + QResultClass *res, + *qres; + RETCODE ret = SQL_ERROR; + char *tidval, + *oidval; mylog("positioned load fi=%x ti=%x\n", stmt->fi, stmt->ti); rcnt = 0; @@ -1267,7 +1270,7 @@ SC_pos_reload(StatementClass *stmt, UWORD irow, UWORD *count) if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1276,15 +1279,14 @@ SC_pos_reload(StatementClass *stmt, UWORD irow, UWORD *count) global_ridx = irow + stmt->rowset_start; res_cols = QR_NumResultCols(res); if (!(oidval = QR_get_value_backend_row(res, global_ridx, res_cols - 1))) - { return SQL_SUCCESS_WITH_INFO; - } - sscanf(oidval, "%u", &oid); + sscanf(oidval, "%u", &oid); tidval = QR_get_value_backend_row(res, global_ridx, res_cols - 2); res_cols -= 2; if (qres = positioned_load(stmt, TRUE, res_cols, oid, tidval), qres) { - TupleField *tupleo, *tuplen; + TupleField *tupleo, + *tuplen; rcnt = QR_get_num_tuples(qres); tupleo = res->backend_tuples + res->num_fields * global_ridx; @@ -1325,41 +1327,45 @@ SC_pos_reload(StatementClass *stmt, UWORD irow, UWORD *count) return ret; } -RETCODE SQL_API -SC_pos_newload(StatementClass *stmt, UInt4 oid, const char *tidval) +RETCODE SQL_API +SC_pos_newload(StatementClass * stmt, UInt4 oid, const char *tidval) { - int i; - QResultClass *res, *qres; - RETCODE ret = SQL_ERROR; + int i; + QResultClass *res, + *qres; + RETCODE ret = SQL_ERROR; mylog("positioned new fi=%x ti=%x\n", stmt->fi, stmt->ti); if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; return SQL_ERROR; } if (qres = positioned_load(stmt, TRUE, QR_NumResultCols(res) - 2, oid, tidval), qres) - { - TupleField *tupleo, *tuplen; - int count = QR_get_num_tuples(qres); + { + TupleField *tupleo, + *tuplen; + int count = QR_get_num_tuples(qres); + QR_set_position(qres, 0); if (count == 1) { tuplen = qres->tupleField; if (res->fcount >= res->count_allocated) { - int tuple_size; + int tuple_size; + if (!res->count_allocated) tuple_size = TUPLE_MALLOC_INC; else tuple_size = res->count_allocated * 2; res->backend_tuples = (TupleField *) realloc( - res->backend_tuples, - res->num_fields * sizeof(TupleField) * tuple_size); + res->backend_tuples, + res->num_fields * sizeof(TupleField) * tuple_size); if (!res->backend_tuples) { stmt->errornumber = res->status = PGRES_FATAL_ERROR; @@ -1369,7 +1375,7 @@ SC_pos_newload(StatementClass *stmt, UInt4 oid, const char *tidval) } res->count_allocated = tuple_size; } - tupleo = res->backend_tuples + res->num_fields * res->fcount; + tupleo = res->backend_tuples + res->num_fields * res->fcount; for (i = 0; i < res->num_fields; i++) { tupleo[i].len = tuplen[i].len; @@ -1387,28 +1393,32 @@ SC_pos_newload(StatementClass *stmt, UInt4 oid, const char *tidval) ret = SQL_SUCCESS_WITH_INFO; } QR_Destructor(qres); - /*stmt->currTuple = stmt->rowset_start + irow;*/ + /* stmt->currTuple = stmt->rowset_start + irow; */ } return ret; } -RETCODE SQL_API -SC_pos_update(StatementClass *stmt, - UWORD irow) +RETCODE SQL_API +SC_pos_update(StatementClass * stmt, + UWORD irow) { - int i, res_cols, num_cols, upd_cols; - UWORD global_ridx; - QResultClass *res; + int i, + res_cols, + num_cols, + upd_cols; + UWORD global_ridx; + QResultClass *res; BindInfoClass *bindings = stmt->bindings; - char updstr[4096]; - RETCODE ret; - char *tidval, *oidval; + char updstr[4096]; + RETCODE ret; + char *tidval, + *oidval; mylog("POS UPDATE %d+%d fi=%x ti=%x\n", irow, stmt->result->base, stmt->fi, stmt->ti); if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1420,7 +1430,7 @@ SC_pos_update(StatementClass *stmt, { stmt->errormsg = "The row is already deleted"; return SQL_ERROR; - } + } tidval = QR_get_value_backend_row(res, global_ridx, res_cols - 2); sprintf(updstr, "update \"%s\" set", stmt->ti[0]->name); @@ -1444,13 +1454,13 @@ SC_pos_update(StatementClass *stmt, } if (upd_cols > 0) { - HSTMT hstmt; - int j; - int res_cols = QR_NumResultCols(res); - StatementClass *qstmt; + HSTMT hstmt; + int j; + int res_cols = QR_NumResultCols(res); + StatementClass *qstmt; sprintf(updstr, "%s where ctid = '%s' and oid = %s", updstr, - tidval, oidval); + tidval, oidval); mylog("updstr=%s\n", updstr); if (PGAPI_AllocStmt(SC_get_conn(stmt), &hstmt) != SQL_SUCCESS) return SQL_ERROR; @@ -1462,14 +1472,14 @@ SC_pos_update(StatementClass *stmt, mylog("%d used=%d\n", i, *bindings[i].used); if (*bindings[i].used != SQL_IGNORE) { - PGAPI_BindParameter(hstmt, (SQLUSMALLINT) ++j, - SQL_PARAM_INPUT, bindings[i].returntype, - pgtype_to_sqltype(stmt, QR_get_field_type(res, i)), - QR_get_fieldsize(res, i), - (SQLSMALLINT) stmt->fi[i]->precision, - bindings[i].buffer, - bindings[i].buflen, - bindings[i].used); + PGAPI_BindParameter(hstmt, (SQLUSMALLINT)++ j, + SQL_PARAM_INPUT, bindings[i].returntype, + pgtype_to_sqltype(stmt, QR_get_field_type(res, i)), + QR_get_fieldsize(res, i), + (SQLSMALLINT) stmt->fi[i]->precision, + bindings[i].buffer, + bindings[i].buflen, + bindings[i].used); } } } @@ -1479,7 +1489,7 @@ SC_pos_update(StatementClass *stmt, stmt->errornumber = qstmt->errornumber; stmt->errormsg = qstmt->errormsg; } - else if (ret == SQL_NEED_DATA) /* must be fixed */ + else if (ret == SQL_NEED_DATA) /* must be fixed */ { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; stmt->errornumber = STMT_INVALID_CURSOR_STATE_ERROR; @@ -1488,11 +1498,12 @@ SC_pos_update(StatementClass *stmt, } if (ret != SQL_ERROR) { - int updcnt; + int updcnt; const char *cmdstr = QR_get_command(qstmt->result); + if (cmdstr && - sscanf(cmdstr, "UPDATE %d", &updcnt) == 1) - { + sscanf(cmdstr, "UPDATE %d", &updcnt) == 1) + { if (updcnt == 1) SC_pos_reload(stmt, irow, (UWORD *) 0); else if (updcnt == 0) @@ -1506,7 +1517,7 @@ SC_pos_update(StatementClass *stmt, else ret = SQL_ERROR; stmt->currTuple = stmt->rowset_start + irow; - } + } else ret = SQL_ERROR; if (ret == SQL_ERROR && stmt->errornumber == 0) @@ -1521,23 +1532,24 @@ SC_pos_update(StatementClass *stmt, ret = SQL_SUCCESS_WITH_INFO; return ret; } -RETCODE SQL_API -SC_pos_delete(StatementClass *stmt, - UWORD irow) +RETCODE SQL_API +SC_pos_delete(StatementClass * stmt, + UWORD irow) { - int res_cols; - UWORD global_ridx; - QResultClass *res, *qres; + int res_cols; + UWORD global_ridx; + QResultClass *res, + *qres; BindInfoClass *bindings = stmt->bindings; - char dltstr[4096]; - RETCODE ret; - char *oidval; + char dltstr[4096]; + RETCODE ret; + char *oidval; mylog("POS DELETE fi=%x ti=%x\n", stmt->fi, stmt->ti); if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1549,20 +1561,21 @@ SC_pos_delete(StatementClass *stmt, { stmt->errormsg = "The row is already deleted"; return SQL_ERROR; - } + } sprintf(dltstr, "delete from \"%s\" where ctid = '%s' and oid = %s", stmt->ti[0]->name, - QR_get_value_backend_row(stmt->result, global_ridx, res_cols - 2), - oidval); + QR_get_value_backend_row(stmt->result, global_ridx, res_cols - 2), + oidval); mylog("dltstr=%s\n", dltstr); qres = CC_send_query(SC_get_conn(stmt), dltstr, NULL); if (qres && QR_command_successful(qres)) { - int dltcnt; + int dltcnt; const char *cmdstr = QR_get_command(qres); + if (cmdstr && - sscanf(cmdstr, "DELETE %d", &dltcnt) == 1) + sscanf(cmdstr, "DELETE %d", &dltcnt) == 1) { if (dltcnt == 1) SC_pos_reload(stmt, irow, (UWORD *) 0); @@ -1592,22 +1605,24 @@ SC_pos_delete(StatementClass *stmt, QR_Destructor(qres); return ret; } -RETCODE SQL_API -SC_pos_add(StatementClass *stmt, - UWORD irow) +RETCODE SQL_API +SC_pos_add(StatementClass * stmt, + UWORD irow) { - int num_cols, add_cols, i; - HSTMT hstmt; - QResultClass *res; + int num_cols, + add_cols, + i; + HSTMT hstmt; + QResultClass *res; BindInfoClass *bindings = stmt->bindings; - char addstr[4096]; - RETCODE ret; + char addstr[4096]; + RETCODE ret; mylog("POS ADD fi=%x ti=%x\n", stmt->fi, stmt->ti); if (!(res = stmt->result)) return SQL_ERROR; if (!stmt->ti) - parse_statement(stmt); /* not preferable */ + parse_statement(stmt); /* not preferable */ if (!stmt->ti || stmt->ntab != 1) { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; @@ -1628,14 +1643,14 @@ SC_pos_add(StatementClass *stmt, sprintf(addstr, "%s, \"%s\"", addstr, stmt->fi[i]->name); else sprintf(addstr, "%s\"%s\"", addstr, stmt->fi[i]->name); - PGAPI_BindParameter(hstmt, (SQLUSMALLINT) ++add_cols, - SQL_PARAM_INPUT, bindings[i].returntype, - pgtype_to_sqltype(stmt, QR_get_field_type(res, i)), - QR_get_fieldsize(res, i), - (SQLSMALLINT) stmt->fi[i]->precision, - bindings[i].buffer, - bindings[i].buflen, - bindings[i].used); + PGAPI_BindParameter(hstmt, (SQLUSMALLINT)++ add_cols, + SQL_PARAM_INPUT, bindings[i].returntype, + pgtype_to_sqltype(stmt, QR_get_field_type(res, i)), + QR_get_fieldsize(res, i), + (SQLSMALLINT) stmt->fi[i]->precision, + bindings[i].buffer, + bindings[i].buflen, + bindings[i].used); } } else @@ -1643,7 +1658,7 @@ SC_pos_add(StatementClass *stmt, } if (add_cols > 0) { - StatementClass *qstmt = (StatementClass *) hstmt; + StatementClass *qstmt = (StatementClass *) hstmt; sprintf(addstr, "%s) values (", addstr); for (i = 0; i < add_cols; i++) @@ -1656,7 +1671,7 @@ SC_pos_add(StatementClass *stmt, strcat(addstr, ")"); mylog("addstr=%s\n", addstr); ret = PGAPI_ExecDirect(hstmt, addstr, strlen(addstr)); - if (ret == SQL_NEED_DATA) /* must be fixed */ + if (ret == SQL_NEED_DATA) /* must be fixed */ { stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY; stmt->errornumber = STMT_INVALID_CURSOR_STATE_ERROR; @@ -1665,28 +1680,29 @@ SC_pos_add(StatementClass *stmt, } if (ret == SQL_ERROR) { - stmt->errornumber = qstmt->errornumber; - stmt->errormsg = qstmt->errormsg; + stmt->errornumber = qstmt->errornumber; + stmt->errormsg = qstmt->errormsg; } else { - int addcnt; - UInt4 oid; + int addcnt; + UInt4 oid; const char *cmdstr = QR_get_command(qstmt->result); + if (cmdstr && - sscanf(cmdstr, "INSERT %u %d", &oid, &addcnt) == 2 && - addcnt == 1) + sscanf(cmdstr, "INSERT %u %d", &oid, &addcnt) == 2 && + addcnt == 1) { SC_pos_newload(stmt, oid, NULL); - if (stmt->bookmark.buffer) - { - char buf[32]; - - sprintf(buf, "%ld", res->fcount); - copy_and_convert_field(stmt, 0, buf, - SQL_C_ULONG, stmt->bookmark.buffer, - 0, stmt->bookmark.used); - } + if (stmt->bookmark.buffer) + { + char buf[32]; + + sprintf(buf, "%ld", res->fcount); + copy_and_convert_field(stmt, 0, buf, + SQL_C_ULONG, stmt->bookmark.buffer, + 0, stmt->bookmark.used); + } } else { @@ -1701,21 +1717,22 @@ SC_pos_add(StatementClass *stmt, PGAPI_FreeStmt(hstmt, SQL_DROP); return ret; } + /* - * Stuff for updatable cursors end. + * Stuff for updatable cursors end. */ -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ /* * This positions the cursor within a rowset, that was positioned using SQLExtendedFetch. * This will be useful (so far) only when using SQLGetData after SQLExtendedFetch. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetPos( - HSTMT hstmt, - UWORD irow, - UWORD fOption, - UWORD fLock) + HSTMT hstmt, + UWORD irow, + UWORD fOption, + UWORD fLock) { static char *func = "PGAPI_SetPos"; StatementClass *stmt = (StatementClass *) hstmt; @@ -1735,7 +1752,7 @@ PGAPI_SetPos( if (stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY) ; else -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ if (fOption != SQL_POSITION && fOption != SQL_REFRESH) { stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR; @@ -1781,7 +1798,7 @@ PGAPI_SetPos( case SQL_ADD: return SC_pos_add(stmt, irow); } -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ /* Reset for SQLGetData */ for (i = 0; i < num_cols; i++) bindings[i].data_left = -1; @@ -1789,13 +1806,13 @@ PGAPI_SetPos( if (fOption == SQL_REFRESH) { /* save the last_fetch_count */ - int last_fetch = stmt->last_fetch_count; - int bind_save = stmt->bind_row; + int last_fetch = stmt->last_fetch_count; + int bind_save = stmt->bind_row; #ifdef DRIVER_CURSOR_IMPLEMENT if (stmt->options.cursor_type == SQL_CURSOR_KEYSET_DRIVEN) - SC_pos_reload(stmt, irow, (UWORD *) 0); -#endif /* DRIVER_CURSOR_IMPLEMENT */ + SC_pos_reload(stmt, irow, (UWORD *) 0); +#endif /* DRIVER_CURSOR_IMPLEMENT */ stmt->currTuple = stmt->rowset_start + irow - 1; stmt->bind_row = irow; SC_fetch(stmt); @@ -1812,17 +1829,18 @@ PGAPI_SetPos( /* Sets options that control the behavior of cursors. */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetScrollOptions( - HSTMT hstmt, - UWORD fConcurrency, - SDWORD crowKeyset, - UWORD crowRowset) + HSTMT hstmt, + UWORD fConcurrency, + SDWORD crowKeyset, + UWORD crowRowset) { static char *func = "PGAPI_SetScrollOptions"; StatementClass *stmt = (StatementClass *) hstmt; + mylog("PGAPI_SetScrollOptions fConcurrency=%d crowKeyset=%d crowRowset=%d\n", - fConcurrency, crowKeyset, crowRowset); + fConcurrency, crowKeyset, crowRowset); stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR; stmt->errormsg = "SetScroll option not implemeted"; @@ -1832,11 +1850,11 @@ PGAPI_SetScrollOptions( /* Set the cursor name on a statement handle */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_SetCursorName( - HSTMT hstmt, - UCHAR FAR *szCursor, - SWORD cbCursor) + HSTMT hstmt, + UCHAR FAR * szCursor, + SWORD cbCursor) { static char *func = "PGAPI_SetCursorName"; StatementClass *stmt = (StatementClass *) hstmt; @@ -1866,12 +1884,12 @@ PGAPI_SetCursorName( /* Return the cursor name for a statement handle */ -RETCODE SQL_API +RETCODE SQL_API PGAPI_GetCursorName( - HSTMT hstmt, - UCHAR FAR *szCursor, - SWORD cbCursorMax, - SWORD FAR *pcbCursor) + HSTMT hstmt, + UCHAR FAR * szCursor, + SWORD cbCursorMax, + SWORD FAR * pcbCursor) { static char *func = "PGAPI_GetCursorName"; StatementClass *stmt = (StatementClass *) hstmt; diff --git a/src/interfaces/odbc/setup.c b/src/interfaces/odbc/setup.c index 6b75840d98..c4562ab90d 100644 --- a/src/interfaces/odbc/setup.c +++ b/src/interfaces/odbc/setup.c @@ -25,7 +25,7 @@ #define INTFUNC __stdcall -extern HINSTANCE NEAR s_hModule;/* Saved module handle. */ +extern HINSTANCE NEAR s_hModule; /* Saved module handle. */ /* Constants */ #define MIN(x,y) ((x) < (y) ? (x) : (y)) @@ -50,7 +50,7 @@ typedef struct tagSETUPDLG BOOL fNewDSN; /* New data source flag */ BOOL fDefault; /* Default data source flag */ -} SETUPDLG, FAR *LPSETUPDLG; +} SETUPDLG, FAR * LPSETUPDLG; @@ -217,10 +217,11 @@ ConfigDlgProc(HWND hdlg, LPARAM lParam) { LPSETUPDLG lpsetupdlg; - ConnInfo *ci; + ConnInfo *ci; + switch (wMsg) { - /* Initialize the dialog */ + /* Initialize the dialog */ case WM_INITDIALOG: lpsetupdlg = (LPSETUPDLG) lParam; ci = &lpsetupdlg->ci; @@ -229,11 +230,10 @@ ConfigDlgProc(HWND hdlg, ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE); SetWindowLong(hdlg, DWL_USER, lParam); - CenterDialog(hdlg); /* Center dialog */ + CenterDialog(hdlg); /* Center dialog */ /* - * NOTE: Values supplied in the attribute string will - * always + * NOTE: Values supplied in the attribute string will always */ /* override settings in ODBC.INI */ @@ -253,17 +253,16 @@ ConfigDlgProc(HWND hdlg, } else SendDlgItemMessage(hdlg, IDC_DSNAME, - EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L); + EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L); SendDlgItemMessage(hdlg, IDC_DESC, - EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L); - return TRUE; /* Focus was not set */ + EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L); + return TRUE; /* Focus was not set */ /* Process buttons */ case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { - /* * Ensure the OK button is enabled only when a data * source name @@ -288,8 +287,8 @@ ConfigDlgProc(HWND hdlg, /* Retrieve dialog values */ if (!lpsetupdlg->fDefault) GetDlgItemText(hdlg, IDC_DSNAME, - lpsetupdlg->ci.dsn, - sizeof(lpsetupdlg->ci.dsn)); + lpsetupdlg->ci.dsn, + sizeof(lpsetupdlg->ci.dsn)); /* Get Dialog Values */ GetDlgStuff(hdlg, &lpsetupdlg->ci); @@ -304,14 +303,14 @@ ConfigDlgProc(HWND hdlg, case IDC_DRIVER: lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV), - hdlg, driver_optionsProc, (LPARAM) &lpsetupdlg->ci); + hdlg, driver_optionsProc, (LPARAM) & lpsetupdlg->ci); return TRUE; case IDC_DATASOURCE: lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER); DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DS), - hdlg, ds_optionsProc, (LPARAM) &lpsetupdlg->ci); + hdlg, ds_optionsProc, (LPARAM) & lpsetupdlg->ci); return TRUE; } @@ -344,7 +343,6 @@ ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg) for (lpsz = lpszAttributes; *lpsz; lpsz++) { - /* * Extract key name (e.g., DSN), it must be terminated by an * equals diff --git a/src/interfaces/odbc/socket.c b/src/interfaces/odbc/socket.c index 28a7af22bb..8250fc8738 100644 --- a/src/interfaces/odbc/socket.c +++ b/src/interfaces/odbc/socket.c @@ -35,7 +35,7 @@ extern GLOBAL_VALUES globals; void -SOCK_clear_error(SocketClass *self) +SOCK_clear_error(SocketClass * self) { self->errornumber = 0; self->errormsg = NULL; @@ -43,7 +43,7 @@ SOCK_clear_error(SocketClass *self) SocketClass * -SOCK_Constructor(const ConnectionClass *conn) +SOCK_Constructor(const ConnectionClass * conn) { SocketClass *rv; @@ -83,9 +83,9 @@ SOCK_Constructor(const ConnectionClass *conn) void -SOCK_Destructor(SocketClass *self) +SOCK_Destructor(SocketClass * self) { -mylog("SOCK_Destructor\n"); + mylog("SOCK_Destructor\n"); if (self->socket != -1) { SOCK_put_char(self, 'X'); @@ -104,7 +104,7 @@ mylog("SOCK_Destructor\n"); char -SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname) +SOCK_connect_to(SocketClass * self, unsigned short port, char *hostname) { struct hostent *host; struct sockaddr_in sadr; @@ -162,7 +162,7 @@ SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname) void -SOCK_get_n_char(SocketClass *self, char *buffer, int len) +SOCK_get_n_char(SocketClass * self, char *buffer, int len) { int lf; @@ -179,7 +179,7 @@ SOCK_get_n_char(SocketClass *self, char *buffer, int len) void -SOCK_put_n_char(SocketClass *self, char *buffer, int len) +SOCK_put_n_char(SocketClass * self, char *buffer, int len) { int lf; @@ -201,7 +201,7 @@ SOCK_put_n_char(SocketClass *self, char *buffer, int len) * returns TRUE if truncation occurs. */ BOOL -SOCK_get_string(SocketClass *self, char *buffer, int bufsize) +SOCK_get_string(SocketClass * self, char *buffer, int bufsize) { register int lf = 0; @@ -215,7 +215,7 @@ SOCK_get_string(SocketClass *self, char *buffer, int bufsize) void -SOCK_put_string(SocketClass *self, char *string) +SOCK_put_string(SocketClass * self, char *string) { register int lf; int len; @@ -228,11 +228,11 @@ SOCK_put_string(SocketClass *self, char *string) int -SOCK_get_int(SocketClass *self, short len) +SOCK_get_int(SocketClass * self, short len) { switch (len) { - case 2: + case 2: { unsigned short buf; @@ -263,7 +263,7 @@ SOCK_get_int(SocketClass *self, short len) void -SOCK_put_int(SocketClass *self, int value, short len) +SOCK_put_int(SocketClass * self, int value, short len) { unsigned int rv; @@ -288,7 +288,7 @@ SOCK_put_int(SocketClass *self, int value, short len) void -SOCK_flush_output(SocketClass *self) +SOCK_flush_output(SocketClass * self) { int written; @@ -303,11 +303,10 @@ SOCK_flush_output(SocketClass *self) unsigned char -SOCK_get_next_byte(SocketClass *self) +SOCK_get_next_byte(SocketClass * self) { if (self->buffer_read_in >= self->buffer_filled_in) { - /* * there are no more bytes left in the buffer so reload the buffer */ @@ -336,7 +335,7 @@ SOCK_get_next_byte(SocketClass *self) void -SOCK_put_next_byte(SocketClass *self, unsigned char next_byte) +SOCK_put_next_byte(SocketClass * self, unsigned char next_byte) { int bytes_sent; diff --git a/src/interfaces/odbc/socket.h b/src/interfaces/odbc/socket.h index b49bebea9b..828372d5cb 100644 --- a/src/interfaces/odbc/socket.h +++ b/src/interfaces/odbc/socket.h @@ -26,7 +26,6 @@ #ifndef _IN_ADDR_T #define _IN_ADDR_T typedef unsigned int in_addr_t; - #endif #define INADDR_NONE ((in_addr_t)-1) #endif @@ -78,18 +77,17 @@ struct SocketClass_ /* Socket prototypes */ -SocketClass *SOCK_Constructor(const ConnectionClass *conn); -void SOCK_Destructor(SocketClass *self); -char SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname); -void SOCK_get_n_char(SocketClass *self, char *buffer, int len); -void SOCK_put_n_char(SocketClass *self, char *buffer, int len); -BOOL SOCK_get_string(SocketClass *self, char *buffer, int bufsize); -void SOCK_put_string(SocketClass *self, char *string); -int SOCK_get_int(SocketClass *self, short len); -void SOCK_put_int(SocketClass *self, int value, short len); -void SOCK_flush_output(SocketClass *self); -unsigned char SOCK_get_next_byte(SocketClass *self); -void SOCK_put_next_byte(SocketClass *self, unsigned char next_byte); -void SOCK_clear_error(SocketClass *self); - +SocketClass *SOCK_Constructor(const ConnectionClass * conn); +void SOCK_Destructor(SocketClass * self); +char SOCK_connect_to(SocketClass * self, unsigned short port, char *hostname); +void SOCK_get_n_char(SocketClass * self, char *buffer, int len); +void SOCK_put_n_char(SocketClass * self, char *buffer, int len); +BOOL SOCK_get_string(SocketClass * self, char *buffer, int bufsize); +void SOCK_put_string(SocketClass * self, char *string); +int SOCK_get_int(SocketClass * self, short len); +void SOCK_put_int(SocketClass * self, int value, short len); +void SOCK_flush_output(SocketClass * self); +unsigned char SOCK_get_next_byte(SocketClass * self); +void SOCK_put_next_byte(SocketClass * self, unsigned char next_byte); +void SOCK_clear_error(SocketClass * self); #endif diff --git a/src/interfaces/odbc/statement.c b/src/interfaces/odbc/statement.c index ca5e8b1c31..f313f926f3 100644 --- a/src/interfaces/odbc/statement.c +++ b/src/interfaces/odbc/statement.c @@ -74,9 +74,9 @@ static struct }; -RETCODE SQL_API +RETCODE SQL_API PGAPI_AllocStmt(HDBC hdbc, - HSTMT FAR *phstmt) + HSTMT FAR * phstmt) { static char *func = "PGAPI_AllocStmt"; ConnectionClass *conn = (ConnectionClass *) hdbc; @@ -126,9 +126,9 @@ PGAPI_AllocStmt(HDBC hdbc, } -RETCODE SQL_API +RETCODE SQL_API PGAPI_FreeStmt(HSTMT hstmt, - UWORD fOption) + UWORD fOption) { static char *func = "PGAPI_FreeStmt"; StatementClass *stmt = (StatementClass *) hstmt; @@ -173,7 +173,6 @@ PGAPI_FreeStmt(HSTMT hstmt, SC_unbind_cols(stmt); else if (fOption == SQL_CLOSE) { - /* * this should discard all the results, but leave the statement * itself in place (it can be executed again) @@ -203,7 +202,7 @@ PGAPI_FreeStmt(HSTMT hstmt, * StatementClass implementation */ void -InitializeStatementOptions(StatementOptions *opt) +InitializeStatementOptions(StatementOptions * opt) { opt->maxRows = 0; /* driver returns all rows */ opt->maxLength = 0; /* driver returns all data for char/binary */ @@ -285,7 +284,7 @@ SC_Constructor(void) char -SC_Destructor(StatementClass *self) +SC_Destructor(StatementClass * self) { mylog("SC_Destructor: self=%u, self->result=%u, self->hdbc=%u\n", self, self->result, self->hdbc); SC_clear_error(self); @@ -357,7 +356,7 @@ SC_Destructor(StatementClass *self) * data-at-execution parameters that was allocated in SQLPutData. */ void -SC_free_params(StatementClass *self, char option) +SC_free_params(StatementClass * self, char option) { int i; @@ -422,7 +421,7 @@ statement_type(char *statement) * from SQLFreeStmt(SQL_CLOSE) */ char -SC_recycle_statement(StatementClass *self) +SC_recycle_statement(StatementClass * self) { ConnectionClass *conn; @@ -456,7 +455,7 @@ SC_recycle_statement(StatementClass *self) conn = SC_get_conn(self); if (!CC_is_in_autocommit(conn) && CC_is_in_trans(conn)) { - if (SC_is_pre_executable(self) && !conn->connInfo.disallow_premature) + if (SC_is_pre_executable(self) && !conn->connInfo.disallow_premature) CC_abort(conn); } break; @@ -508,7 +507,7 @@ SC_recycle_statement(StatementClass *self) * Reset only parameters that have anything to do with results */ self->status = STMT_READY; - self->manual_result = FALSE;/* very important */ + self->manual_result = FALSE; /* very important */ self->currTuple = -1; self->rowset_start = -1; @@ -538,7 +537,7 @@ SC_recycle_statement(StatementClass *self) /* Pre-execute a statement (SQLPrepare/SQLDescribeCol) */ void -SC_pre_execute(StatementClass *self) +SC_pre_execute(StatementClass * self) { mylog("SC_pre_execute: status = %d\n", self->status); @@ -577,7 +576,7 @@ SC_pre_execute(StatementClass *self) /* This is only called from SQLFreeStmt(SQL_UNBIND) */ char -SC_unbind_cols(StatementClass *self) +SC_unbind_cols(StatementClass * self) { Int2 lf; @@ -598,7 +597,7 @@ SC_unbind_cols(StatementClass *self) void -SC_clear_error(StatementClass *self) +SC_clear_error(StatementClass * self) { if (self->errormsg_malloced && self->errormsg) free(self->errormsg); @@ -614,7 +613,7 @@ SC_clear_error(StatementClass *self) * of the result, statement, connection, and socket messages. */ char * -SC_create_errormsg(StatementClass *self) +SC_create_errormsg(StatementClass * self) { QResultClass *res = self->result; ConnectionClass *conn = self->hdbc; @@ -653,7 +652,7 @@ SC_create_errormsg(StatementClass *self) char -SC_get_error(StatementClass *self, int *number, char **message) +SC_get_error(StatementClass * self, int *number, char **message) { char rv; @@ -685,29 +684,31 @@ SC_get_error(StatementClass *self, int *number, char **message) * someday, such as mapping a key to a 32 bit value */ unsigned long -SC_get_bookmark(StatementClass *self) +SC_get_bookmark(StatementClass * self) { return (self->currTuple + 1); } RETCODE -SC_fetch(StatementClass *self) +SC_fetch(StatementClass * self) { static char *func = "SC_fetch"; QResultClass *res = self->result; int retval, result; + #ifdef DRIVER_CURSOR_IMPLEMENT - int updret; -#endif /* DRIVER_CURSOR_IMPLEMENT */ + int updret; +#endif /* DRIVER_CURSOR_IMPLEMENT */ Int2 num_cols, lf; Oid type; char *value; ColumnInfoClass *coli; + /* TupleField *tupleField; */ - ConnInfo *ci = &(SC_get_conn(self)->connInfo); + ConnInfo *ci = &(SC_get_conn(self)->connInfo); self->last_fetch_count = 0; coli = QR_get_fields(res); /* the column info */ @@ -719,7 +720,6 @@ SC_fetch(StatementClass *self) if (self->currTuple >= QR_get_num_tuples(res) - 1 || (self->options.maxRows > 0 && self->currTuple == self->options.maxRows - 1)) { - /* * if at the end of the tuples, return "no data found" and set * the cursor past the end of the result set @@ -741,7 +741,7 @@ SC_fetch(StatementClass *self) return SQL_NO_DATA_FOUND; } else if (retval > 0) - (self->currTuple)++;/* all is well */ + (self->currTuple)++; /* all is well */ else { mylog("SC_fetch: error\n"); @@ -780,13 +780,13 @@ SC_fetch(StatementClass *self) updret = SQL_ROW_DELETED; num_cols -= 2; } -#endif /* DRIVER_CURSOR_IMPLEMENT */ - if (self->options.retrieve_data == SQL_RD_OFF) /* data isn't required */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ + if (self->options.retrieve_data == SQL_RD_OFF) /* data isn't required */ #ifdef DRIVER_CURSOR_IMPLEMENT return updret ? updret + 10 : SQL_SUCCESS; #else - return SQL_SUCCESS; -#endif /* DRIVER_CURSOR_IMPLEMENT */ + return SQL_SUCCESS; +#endif /* DRIVER_CURSOR_IMPLEMENT */ for (lf = 0; lf < num_cols; lf++) { mylog("fetch: cols=%d, lf=%d, self = %u, self->bindings = %u, buffer[] = %u\n", num_cols, lf, self, self->bindings, self->bindings[lf].buffer); @@ -799,7 +799,7 @@ SC_fetch(StatementClass *self) /* this column has a binding */ /* type = QR_get_field_type(res, lf); */ - type = CI_get_oid(coli, lf); /* speed things up */ + type = CI_get_oid(coli, lf); /* speed things up */ mylog("type = %d\n", type); @@ -841,7 +841,7 @@ SC_fetch(StatementClass *self) case COPY_RESULT_TRUNCATED: self->errornumber = STMT_TRUNCATED; self->errormsg = "Fetched item was truncated."; - qlog("The %dth item was truncated\n", lf + 1); + qlog("The %dth item was truncated\n", lf + 1); qlog("The buffer size = %d", self->bindings[lf].buflen); qlog(" and the value is '%s'\n", value); result = SQL_SUCCESS_WITH_INFO; @@ -870,13 +870,13 @@ SC_fetch(StatementClass *self) #ifdef DRIVER_CURSOR_IMPLEMENT if (updret) result = updret + 10; -#endif /* DRIVER_CURSOR_IMPLEMENT */ +#endif /* DRIVER_CURSOR_IMPLEMENT */ return result; } RETCODE -SC_execute(StatementClass *self) +SC_execute(StatementClass * self) { static char *func = "SC_execute"; ConnectionClass *conn; @@ -887,7 +887,7 @@ SC_execute(StatementClass *self) Int2 oldstatus, numcols; QueryInfo qi; - ConnInfo *ci; + ConnInfo *ci; conn = SC_get_conn(self); @@ -904,8 +904,8 @@ SC_execute(StatementClass *self) * OTHER. */ if (!self->internal && !CC_is_in_trans(conn) && - (SC_is_fetchcursor(self) || - (!CC_is_in_autocommit(conn) && self->statement_type != STMT_TYPE_OTHER))) + (SC_is_fetchcursor(self) || + (!CC_is_in_autocommit(conn) && self->statement_type != STMT_TYPE_OTHER))) { mylog(" about to begin a transaction on statement = %u\n", self); res = CC_send_query(conn, "BEGIN", NULL); @@ -1067,19 +1067,21 @@ SC_execute(StatementClass *self) } if (self->statement_type == STMT_TYPE_PROCCALL && - (self->errornumber == STMT_OK || - self->errornumber == STMT_INFO_ONLY) && - self->parameters && - self->parameters[0].buffer && - self->parameters[0].paramType == SQL_PARAM_OUTPUT) - { /* get the return value of the procedure call */ - RETCODE ret; - HSTMT hstmt = (HSTMT) self; + (self->errornumber == STMT_OK || + self->errornumber == STMT_INFO_ONLY) && + self->parameters && + self->parameters[0].buffer && + self->parameters[0].paramType == SQL_PARAM_OUTPUT) + { /* get the return value of the procedure + * call */ + RETCODE ret; + HSTMT hstmt = (HSTMT) self; + ret = SC_fetch(hstmt); if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) - { + { ret = PGAPI_GetData(hstmt, 1, self->parameters[0].CType, self->parameters[0].buffer, self->parameters[0].buflen, self->parameters[0].used); - if (ret != SQL_SUCCESS) + if (ret != SQL_SUCCESS) { self->errornumber = STMT_EXEC_ERROR; self->errormsg = "GetData to Procedure return failed."; @@ -1105,7 +1107,7 @@ SC_execute(StatementClass *self) void -SC_log_error(char *func, char *desc, StatementClass *self) +SC_log_error(char *func, char *desc, StatementClass * self) { #ifdef PRN_NULLCHECK #define nullcheck(a) (a ? a : "(NULL)") diff --git a/src/interfaces/odbc/statement.h b/src/interfaces/odbc/statement.h index c1a2152b0c..801c334bf3 100644 --- a/src/interfaces/odbc/statement.h +++ b/src/interfaces/odbc/statement.h @@ -23,10 +23,10 @@ typedef enum { - STMT_ALLOCATED, /* The statement handle is allocated, but + STMT_ALLOCATED, /* The statement handle is allocated, but * not used so far */ - STMT_READY, /* the statement is waiting to be executed */ - STMT_PREMATURE, /* ODBC states that it is legal to call + STMT_READY, /* the statement is waiting to be executed */ + STMT_PREMATURE, /* ODBC states that it is legal to call * e.g. SQLDescribeCol before a call to * SQLExecute, but after SQLPrepare. To * get all the necessary information in @@ -34,9 +34,9 @@ typedef enum * query _before_ the actual call to * SQLExecute, so that statement is * considered to be "premature". */ - STMT_FINISHED, /* statement execution has finished */ - STMT_EXECUTING /* statement execution is still going on */ -} STMT_Status; + STMT_FINISHED, /* statement execution has finished */ + STMT_EXECUTING /* statement execution is still going on */ +} STMT_Status; #define STMT_ROW_VERSION_CHANGED (-4) #define STMT_POS_BEFORE_RECORDSET (-3) @@ -79,18 +79,18 @@ typedef enum /* statement types */ enum { - STMT_TYPE_UNKNOWN = -2, - STMT_TYPE_OTHER = -1, - STMT_TYPE_SELECT = 0, - STMT_TYPE_INSERT, - STMT_TYPE_UPDATE, - STMT_TYPE_DELETE, - STMT_TYPE_CREATE, - STMT_TYPE_ALTER, - STMT_TYPE_DROP, - STMT_TYPE_GRANT, - STMT_TYPE_REVOKE, - STMT_TYPE_PROCCALL + STMT_TYPE_UNKNOWN = -2, + STMT_TYPE_OTHER = -1, + STMT_TYPE_SELECT = 0, + STMT_TYPE_INSERT, + STMT_TYPE_UPDATE, + STMT_TYPE_DELETE, + STMT_TYPE_CREATE, + STMT_TYPE_ALTER, + STMT_TYPE_DROP, + STMT_TYPE_GRANT, + STMT_TYPE_REVOKE, + STMT_TYPE_PROCCALL }; #define STMT_UPDATE(stmt) (stmt->statement_type > STMT_TYPE_SELECT) @@ -99,18 +99,18 @@ enum /* Parsing status */ enum { - STMT_PARSE_NONE = 0, - STMT_PARSE_COMPLETE, - STMT_PARSE_INCOMPLETE, - STMT_PARSE_FATAL, + STMT_PARSE_NONE = 0, + STMT_PARSE_COMPLETE, + STMT_PARSE_INCOMPLETE, + STMT_PARSE_FATAL, }; /* Result style */ enum { - STMT_FETCH_NONE = 0, - STMT_FETCH_NORMAL, - STMT_FETCH_EXTENDED, + STMT_FETCH_NONE = 0, + STMT_FETCH_NORMAL, + STMT_FETCH_EXTENDED, }; typedef struct @@ -118,7 +118,7 @@ typedef struct COL_INFO *col_info; /* cached SQLColumns info for this table */ char name[MAX_TABLE_LEN + 1]; char alias[MAX_TABLE_LEN + 1]; -} TABLE_INFO; +} TABLE_INFO; typedef struct { @@ -137,7 +137,7 @@ typedef struct char dot[MAX_TABLE_LEN + 1]; char name[MAX_COLUMN_LEN + 1]; char alias[MAX_COLUMN_LEN + 1]; -} FIELD_INFO; +} FIELD_INFO; /******** Statement Handle ***********/ @@ -204,15 +204,16 @@ struct StatementClass_ char cursor_name[MAX_CURSOR_LEN + 1]; - char *stmt_with_params; /* statement after - * parameter - * substitution */ - int stmt_size_limit; + char *stmt_with_params; /* statement after parameter + * substitution */ + int stmt_size_limit; char pre_executing; /* This statement is prematurely executing */ - char inaccurate_result; /* Current status is PREMATURE but + char inaccurate_result; /* Current status is PREMATURE but * result is inaccurate */ - char errormsg_malloced; /* Current error message is malloed (not in a static variable) ? */ + char errormsg_malloced; /* Current error message is + * malloed (not in a static + * variable) ? */ char miscinfo; }; @@ -225,30 +226,29 @@ struct StatementClass_ /* misc info */ #define SC_set_pre_executable(a) (a->miscinfo |= 1L) -#define SC_no_pre_executable(a) (a->miscinfo &= ~1L) -#define SC_is_pre_executable(a) ((a->miscinfo & 1L) != 0) +#define SC_no_pre_executable(a) (a->miscinfo &= ~1L) +#define SC_is_pre_executable(a) ((a->miscinfo & 1L) != 0) #define SC_set_fetchcursor(a) (a->miscinfo |= 2L) #define SC_no_fetchcursor(a) (a->miscinfo &= ~2L) #define SC_is_fetchcursor(a) ((a->miscinfo & 2L) != 0) /* Statement prototypes */ StatementClass *SC_Constructor(void); -void InitializeStatementOptions(StatementOptions *opt); -char SC_Destructor(StatementClass *self); +void InitializeStatementOptions(StatementOptions * opt); +char SC_Destructor(StatementClass * self); int statement_type(char *statement); -char parse_statement(StatementClass *stmt); -void SC_pre_execute(StatementClass *self); -char SC_unbind_cols(StatementClass *self); -char SC_recycle_statement(StatementClass *self); - -void SC_clear_error(StatementClass *self); -char SC_get_error(StatementClass *self, int *number, char **message); -char *SC_create_errormsg(StatementClass *self); -RETCODE SC_execute(StatementClass *self); -RETCODE SC_fetch(StatementClass *self); -void SC_free_params(StatementClass *self, char option); -void SC_log_error(char *func, char *desc, StatementClass *self); -unsigned long SC_get_bookmark(StatementClass *self); - +char parse_statement(StatementClass * stmt); +void SC_pre_execute(StatementClass * self); +char SC_unbind_cols(StatementClass * self); +char SC_recycle_statement(StatementClass * self); + +void SC_clear_error(StatementClass * self); +char SC_get_error(StatementClass * self, int *number, char **message); +char *SC_create_errormsg(StatementClass * self); +RETCODE SC_execute(StatementClass * self); +RETCODE SC_fetch(StatementClass * self); +void SC_free_params(StatementClass * self, char option); +void SC_log_error(char *func, char *desc, StatementClass * self); +unsigned long SC_get_bookmark(StatementClass * self); #endif diff --git a/src/interfaces/odbc/tuple.c b/src/interfaces/odbc/tuple.c index 512f36d2b2..94d0bc17d3 100644 --- a/src/interfaces/odbc/tuple.c +++ b/src/interfaces/odbc/tuple.c @@ -24,7 +24,7 @@ void -set_tuplefield_null(TupleField *tuple_field) +set_tuplefield_null(TupleField * tuple_field) { tuple_field->len = 0; tuple_field->value = NULL; /* strdup(""); */ @@ -32,7 +32,7 @@ set_tuplefield_null(TupleField *tuple_field) void -set_tuplefield_string(TupleField *tuple_field, char *string) +set_tuplefield_string(TupleField * tuple_field, char *string) { tuple_field->len = strlen(string); tuple_field->value = malloc(strlen(string) + 1); @@ -41,7 +41,7 @@ set_tuplefield_string(TupleField *tuple_field, char *string) void -set_tuplefield_int2(TupleField *tuple_field, Int2 value) +set_tuplefield_int2(TupleField * tuple_field, Int2 value) { char buffer[10]; @@ -54,7 +54,7 @@ set_tuplefield_int2(TupleField *tuple_field, Int2 value) void -set_tuplefield_int4(TupleField *tuple_field, Int4 value) +set_tuplefield_int4(TupleField * tuple_field, Int4 value) { char buffer[15]; diff --git a/src/interfaces/odbc/tuple.h b/src/interfaces/odbc/tuple.h index fdc1a5f9ea..6cd87cb9db 100644 --- a/src/interfaces/odbc/tuple.h +++ b/src/interfaces/odbc/tuple.h @@ -38,9 +38,8 @@ struct TupleNode_ #define set_nullfield_int2(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int2(FLD, (VAL)) : set_tuplefield_null(FLD)) #define set_nullfield_int4(FLD, VAL) ((VAL) != -1 ? set_tuplefield_int4(FLD, (VAL)) : set_tuplefield_null(FLD)) -void set_tuplefield_null(TupleField *tuple_field); -void set_tuplefield_string(TupleField *tuple_field, char *string); -void set_tuplefield_int2(TupleField *tuple_field, Int2 value); -void set_tuplefield_int4(TupleField *tuple_field, Int4 value); - +void set_tuplefield_null(TupleField * tuple_field); +void set_tuplefield_string(TupleField * tuple_field, char *string); +void set_tuplefield_int2(TupleField * tuple_field, Int2 value); +void set_tuplefield_int4(TupleField * tuple_field, Int4 value); #endif diff --git a/src/interfaces/odbc/tuplelist.c b/src/interfaces/odbc/tuplelist.c index 5f3871600d..e00ab43006 100644 --- a/src/interfaces/odbc/tuplelist.c +++ b/src/interfaces/odbc/tuplelist.c @@ -44,7 +44,7 @@ TL_Constructor(UInt4 fieldcnt) void -TL_Destructor(TupleListClass *self) +TL_Destructor(TupleListClass * self) { int lf; TupleNode *node, @@ -70,7 +70,7 @@ TL_Destructor(TupleListClass *self) void * -TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno) +TL_get_fieldval(TupleListClass * self, Int4 tupleno, Int2 fieldno) { Int4 lf; Int4 delta, @@ -138,7 +138,6 @@ TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno) } else if (start_is_closer) { - /* * the shortest way is to start the search from the head of the * list @@ -182,9 +181,8 @@ TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno) char -TL_add_tuple(TupleListClass *self, TupleNode *new_field) +TL_add_tuple(TupleListClass * self, TupleNode * new_field) { - /* * we append the tuple at the end of the doubly linked list of the * tuples we have already read in @@ -203,7 +201,6 @@ TL_add_tuple(TupleListClass *self, TupleNode *new_field) } else { - /* * there is already an element in the list, so add the new one at * the end of the list diff --git a/src/interfaces/odbc/tuplelist.h b/src/interfaces/odbc/tuplelist.h index 3dc98dd78f..5ce2613e86 100644 --- a/src/interfaces/odbc/tuplelist.h +++ b/src/interfaces/odbc/tuplelist.h @@ -28,8 +28,7 @@ struct TupleListClass_ /* Create a TupleList. Each tuple consits of fieldcnt columns */ TupleListClass *TL_Constructor(UInt4 fieldcnt); -void TL_Destructor(TupleListClass *self); -void *TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno); -char TL_add_tuple(TupleListClass *self, TupleNode *new_field); - +void TL_Destructor(TupleListClass * self); +void *TL_get_fieldval(TupleListClass * self, Int4 tupleno, Int2 fieldno); +char TL_add_tuple(TupleListClass * self, TupleNode * new_field); #endif diff --git a/src/interfaces/perl5/ppport.h b/src/interfaces/perl5/ppport.h index be5f99087a..e39b9f52a0 100644 --- a/src/interfaces/perl5/ppport.h +++ b/src/interfaces/perl5/ppport.h @@ -237,7 +237,6 @@ newRV_noinc(SV * sv) static #else extern void newCONSTSUB _((HV * stash, char *name, SV * sv)); - #endif #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) @@ -284,10 +283,7 @@ SV *sv; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } - #endif - #endif /* newCONSTSUB */ - #endif /* _P_P_PORTABILITY_H_ */ diff --git a/src/interfaces/python/pgmodule.c b/src/interfaces/python/pgmodule.c index 4bf0fa2aa2..38fc4f2d7c 100644 --- a/src/interfaces/python/pgmodule.c +++ b/src/interfaces/python/pgmodule.c @@ -94,16 +94,15 @@ const char *__movename[5] = static PyObject *pg_default_host; /* default database host */ static PyObject *pg_default_base; /* default database name */ -static PyObject *pg_default_opt;/* default connection options */ -static PyObject *pg_default_tty;/* default debug tty */ +static PyObject *pg_default_opt; /* default connection options */ +static PyObject *pg_default_tty; /* default debug tty */ static PyObject *pg_default_port; /* default connection port */ static PyObject *pg_default_user; /* default username */ static PyObject *pg_default_passwd; /* default password */ - #endif /* DEFAULT_VARS */ DL_EXPORT(void) init_pg(void); -int *get_type_array(PGresult *result, int nfields); +int *get_type_array(PGresult *result, int nfields); /* --------------------------------------------------------------------- */ /* OBJECTS DECLARATION */ @@ -112,7 +111,7 @@ int *get_type_array(PGresult *result, int nfields); typedef struct { - PyObject_HEAD + PyObject_HEAD int valid; /* validity flag */ PGconn *cnx; /* PostGres connection handle */ PGresult *last_result; /* last result content */ @@ -140,7 +139,7 @@ pgobject_New(void) typedef struct { - PyObject_HEAD + PyObject_HEAD PGresult *last_result; /* last result content */ int result_type; /* type of previous result */ long current_pos; /* current position in last result */ @@ -155,7 +154,7 @@ staticforward PyTypeObject PgQueryType; typedef struct { - PyObject_HEAD + PyObject_HEAD int valid; /* validity flag */ pgobject *pgcnx; /* parent connection object */ PGresult *last_result; /* last result content */ @@ -176,8 +175,8 @@ staticforward PyTypeObject PgSourceType; typedef struct { - PyObject_HEAD - pgobject * pgcnx; /* parent connection object */ + PyObject_HEAD + pgobject * pgcnx; /* parent connection object */ Oid lo_oid; /* large object oid */ int lo_fd; /* large object fd */ } pglargeobject; @@ -236,7 +235,6 @@ check_lo_obj(pglargeobject * self, int level) return 1; } - #endif /* LARGE_OBJECTS */ /* checks source object validity */ @@ -1452,7 +1450,6 @@ staticforward PyTypeObject PglargeType = { 0, /* tp_as_mapping */ 0, /* tp_hash */ }; - #endif /* LARGE_OBJECTS */ @@ -1848,32 +1845,33 @@ pgquery_getresult(pgqueryobject * self, PyObject * args) break; case 3: - { - int mult = 1; - - if (*s == '$') /* there's talk of getting rid of - * it */ - s++; - - if (*s == '-' || *s == '(') { - s++; - mult = -1; + int mult = 1; + + if (*s == '$') /* there's talk of getting + * rid of it */ + s++; + + if (*s == '-' || *s == '(') + { + s++; + mult = -1; + } + + /* get rid of the '$' and commas */ + if (*s == '$') /* Just in case we exposed + * one */ + s++; + + for (k = 0; *s; s++) + if (*s != ',') + cashbuf[k++] = *s; + + cashbuf[k] = 0; + val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult); + break; } - /* get rid of the '$' and commas */ - if (*s == '$') /* Just in case we exposed one */ - s++; - - for (k = 0; *s; s++) - if (*s != ',') - cashbuf[k++] = *s; - - cashbuf[k] = 0; - val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult); - break; - } - default: val = PyString_FromString(s); break; @@ -1996,32 +1994,33 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args) break; case 3: - { - int mult = 1; - - if (*s == '$') /* there's talk of getting rid of - * it */ - s++; - - if (*s == '-' || *s == '(') { - s++; - mult = -1; + int mult = 1; + + if (*s == '$') /* there's talk of getting + * rid of it */ + s++; + + if (*s == '-' || *s == '(') + { + s++; + mult = -1; + } + + /* get rid of the '$' and commas */ + if (*s == '$') /* Just in case we exposed + * one */ + s++; + + for (k = 0; *s; s++) + if (*s != ',') + cashbuf[k++] = *s; + + cashbuf[k] = 0; + val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult); + break; } - /* get rid of the '$' and commas */ - if (*s == '$') /* Just in case we exposed one */ - s++; - - for (k = 0; *s; s++) - if (*s != ',') - cashbuf[k++] = *s; - - cashbuf[k] = 0; - val = PyFloat_FromDouble(strtod(cashbuf, NULL) * mult); - break; - } - default: val = PyString_FromString(s); break; @@ -2336,7 +2335,6 @@ pg_endcopy(pgobject * self, PyObject * args) Py_INCREF(Py_None); return Py_None; } - #endif /* DIRECT_ACCESS */ @@ -2640,7 +2638,6 @@ static struct PyMethodDef pgobj_methods[] = { static PyObject * pg_getattr(pgobject * self, char *name) { - /* * Although we could check individually, there are only a few * attributes that don't require a live connection and unless someone @@ -3122,7 +3119,6 @@ pgsetdefport(PyObject * self, PyObject * args) return old; } - #endif /* DEFAULT_VARS */ /* List of functions defined in the module */ |