Re: unixODBC again :-( - Mailing list pgsql-patches
From | Bruce Momjian |
---|---|
Subject | Re: unixODBC again :-( |
Date | |
Msg-id | 200101241353.IAA12907@candle.pha.pa.us Whole thread Raw |
List | pgsql-patches |
Here is the actual ODBC patch he is suggesting. > Bruce Momjian wrote: > > > Sure, send them over, but I recommend getting the most recent snapshot. > > I think some of your changes did make it in, so I bet your job will be > > easier. > > > > > Hello Bruce, > > > > > > Sorry to bother you again, the state of the patches I sent some time ago > > > never seemed to be resolved, I did appear to break things, so I guess > > > from the lack of response you don't want to intergrate the changes into > > > your CVS. I can understand that considering the chaos it seemed to > > > produce, but I have had a couple of people who want to use the driver in > > > 7.0.2 with unixODBC, what would you suggest. I can provide them the > > > patches I made against 7.0.2, would you prefer me to do that ? > > > > > > -- > > > Nick Gorham > > > Easysoft Ltd > > > > > > > > > > > > > > > > -- > > Bruce Momjian | http://candle.pha.pa.us > > pgman@candle.pha.pa.us | (610) 853-3000 > > + If your life is a hard drive, | 830 Blythe Avenue > > + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 > > Ok, here it is, against todays snapshot. > > > > -- > Nick Gorham > Easysoft Ltd > > > diff -u -r pgsql/configure.in pgsql.new/configure.in > --- pgsql/configure.in Fri Jul 28 08:00:07 2000 > +++ pgsql.new/configure.in Tue Aug 1 15:55:17 2000 > @@ -608,8 +608,65 @@ > AC_MSG_RESULT(no) > fi], > [AC_MSG_RESULT(no)]) > + > +dnl check if we want to use unixODBC to provide access to the odbc.ini > +dnl files > + > +use_unixODBC=no > +AC_MSG_CHECKING(setting USE_UNIXODBC) > +AC_ARG_WITH( > + unixODBC, > + [ --with-unixODBC[=DIR] Use unixODBC located in DIR], > + [ > + use_unixODBC=yes; > + unixODBC="$withval"; > + USE_ODBC=true; > + enable_odbc=yes; > + AC_MSG_RESULT(enabled); > + ], > + [ USE_ODBC=false; use_unixODBC=no; AC_MSG_RESULT(disabled) ] > +) > + > AC_SUBST(enable_odbc) > +AC_SUBST(use_unixODBC) > + > +dnl check for unixODBC libs > + > +if test "x$use_unixODBC" = "xyes" > +then > + > + # default to /usr/local if not specified > + if test "x$unixODBC" = "x" > + then > + unixODBC="/usr/local"; > + fi > + > + unixODBC_libs="$unixODBC/lib" > + unixODBC_includes="$unixODBC/include" > + > + CPPFLAGS="$CPPFLAGS -I$unixODBC_includes" > + AC_CHECK_HEADERS(sql.h sqlext.h odbcinst.h, > + unixODBC_ok=yes; > + odbc_headers="$odbc_headers $ac_hdr", > + unixODBC_ok=no ) > + > + if test "x$unixODBC_ok" != "xyes" > + then > + AC_MSG_ERROR([Unable to find the unixODBC headers in $1]) > + fi > + > + save_LIBS="$LIBS" > + LIBS="-L$unixODBC_libs $LIBS" > + > + AC_CHECK_LIB(odbcinst,SQLGetPrivateProfileString, > + [AC_DEFINE(HAVE_SQLGETPRIVATEPROFILESTRING) > + SHLIB_ODBC="$SHFLAGS_ODBC -L$unixODBC_libs -lodbcinst" ], > + [LIBS="$save_LIBS"] ) > + > + echo "using SHLIB_ODBC=$SHLIB_ODBC" > +fi > > +AC_SUBST(SHLIB_ODBC) > > dnl Allow for overriding the default location of the odbcinst.ini > dnl file which is normally ${datadir} (i.e., ${prefix}/share). > diff -u -r pgsql/src/Makefile.global.in pgsql.new/src/Makefile.global.in > --- pgsql/src/Makefile.global.in Sat Jul 22 08:00:18 2000 > +++ pgsql.new/src/Makefile.global.in Tue Aug 1 15:53:37 2000 > @@ -129,6 +129,8 @@ > with_perl = @with_perl@ > enable_odbc = @enable_odbc@ > > +SHLIB_ODBC = @SHLIB_ODBC@ > + > with_python = @with_python@ > PYTHON = @PYTHON@ > python_extmakefile = @python_extmakefile@ > @@ -181,7 +183,7 @@ > CFLAGS = -I$(SRCDIR)/include $(CPPFLAGS) @CFLAGS@ > CFLAGS_SL= @SHARED_LIB@ > LIBS= @LIBS@ > -LDFLAGS= @LDFLAGS@ $(LIBS) > +LDFLAGS= @LDFLAGS@ $(LIBS) $(SHLIB_ODBC) > KRB_LIBS = @KRB_LIBS@ > LDREL= -r > LDOUT= -o > diff -u -r pgsql/src/Makefile.shlib pgsql.new/src/Makefile.shlib > --- pgsql/src/Makefile.shlib Fri Jul 7 08:00:26 2000 > +++ pgsql.new/src/Makefile.shlib Tue Aug 1 15:29:53 2000 > @@ -145,7 +145,7 @@ > shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) > LD := $(CC) > LDFLAGS_SL := -shared -Wl,-soname,$(shlib) > - LDFLAGS_ODBC := -lm > + LDFLAGS_ODBC := -lm $(SHLIB_ODBC) > CFLAGS += $(CFLAGS_SL) > endif > > diff -u -r pgsql/src/include/config.h.in pgsql.new/src/include/config.h.in > --- pgsql/src/include/config.h.in Fri Jul 28 08:00:20 2000 > +++ pgsql.new/src/include/config.h.in Tue Aug 1 15:13:16 2000 > @@ -545,6 +545,9 @@ > /* Define if C++ compiler accepts "#include <string>" */ > #undef HAVE_CXX_STRING_HEADER > > +/* Can we support SQLGetPrivateProfileString */ > +#undef HAVE_SQLGETPRIVATEPROFILESTRING > + > > /* > *------------------------------------------------------------------------ > diff -u -r pgsql/src/interfaces/odbc/Makefile.global pgsql.new/src/interfaces/odbc/Makefile.global > --- pgsql/src/interfaces/odbc/Makefile.global Mon Jun 19 08:01:26 2000 > +++ pgsql.new/src/interfaces/odbc/Makefile.global Tue Aug 1 15:46:25 2000 > @@ -128,7 +128,7 @@ > AROPT= cq > CFLAGS= -I$(ODBCSRCDIR) -O2 -m486 -pipe > CFLAGS_SL= -fpic -DPIC > -LDFLAGS= -lcrypt -lcompat -lln -lm -lutil -lreadline -ltermcap -lncurses > +LDFLAGS= -lcrypt -lcompat -lln -lm -lutil -lreadline -ltermcap -lncurses $(SHLIB_ODBC) > DLSUFFIX= .so > LN_S = ln -s > > diff -u -r pgsql/src/interfaces/odbc/bind.c pgsql.new/src/interfaces/odbc/bind.c > --- pgsql/src/interfaces/odbc/bind.c Tue May 30 08:00:29 2000 > +++ pgsql.new/src/interfaces/odbc/bind.c Tue Aug 1 15:08:50 2000 > @@ -36,7 +36,7 @@ > > /* Bind parameters on a statement handle */ > > -RETCODE SQL_API SQLBindParameter( > +RETCODE SQL_API PG__SQLBindParameter( > HSTMT hstmt, > UWORD ipar, > SWORD fParamType, > @@ -140,10 +140,34 @@ > return SQL_SUCCESS; > } > > +RETCODE SQL_API SQLBindParameter( > + HSTMT hstmt, > + UWORD ipar, > + SWORD fParamType, > + SWORD fCType, > + SWORD fSqlType, > + UDWORD cbColDef, > + SWORD ibScale, > + PTR rgbValue, > + SDWORD cbValueMax, > + SDWORD FAR *pcbValue) > +{ > + return PG__SQLBindParameter( hstmt, > + ipar, > + fParamType, > + fCType, > + fSqlType, > + cbColDef, > + ibScale, > + rgbValue, > + cbValueMax, > + pcbValue ); > +} > + > /* - - - - - - - - - */ > > /* Associate a user-supplied buffer with a database column. */ > -RETCODE SQL_API SQLBindCol( > +RETCODE SQL_API PG__SQLBindCol( > HSTMT hstmt, > UWORD icol, > SWORD fCType, > @@ -232,6 +256,22 @@ > } > > return SQL_SUCCESS; > +} > + > +RETCODE SQL_API SQLBindCol( > + HSTMT hstmt, > + UWORD icol, > + SWORD fCType, > + PTR rgbValue, > + SDWORD cbValueMax, > + SDWORD FAR *pcbValue) > +{ > + return PG__SQLBindCol( hstmt, > + icol, > + fCType, > + rgbValue, > + cbValueMax, > + pcbValue ); > } > > /* - - - - - - - - - */ > diff -u -r pgsql/src/interfaces/odbc/connection.c pgsql.new/src/interfaces/odbc/connection.c > --- pgsql/src/interfaces/odbc/connection.c Sat May 27 08:00:25 2000 > +++ pgsql.new/src/interfaces/odbc/connection.c Tue Aug 1 14:38:10 2000 > @@ -1223,7 +1223,7 @@ > has not transitioned to "connected" yet. > */ > > - result = SQLAllocStmt( self, &hstmt); > + result = PG__SQLAllocStmt( self, &hstmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > return FALSE; > } > @@ -1232,7 +1232,7 @@ > stmt->internal = TRUE; /* ensure no BEGIN/COMMIT/ABORT stuff */ > > /* Set the Datestyle to the format the driver expects it to be in */ > - result = SQLExecDirect(hstmt, "set DateStyle to 'ISO'", SQL_NTS); > + result = PG__SQLExecDirect(hstmt, "set DateStyle to 'ISO'", SQL_NTS); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) > status = FALSE; > > @@ -1240,7 +1240,7 @@ > > /* Disable genetic optimizer based on global flag */ > if (globals.disable_optimizer) { > - result = SQLExecDirect(hstmt, "set geqo to 'OFF'", SQL_NTS); > + result = PG__SQLExecDirect(hstmt, "set geqo to 'OFF'", SQL_NTS); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) > status = FALSE; > > @@ -1250,7 +1250,7 @@ > > /* KSQO */ > if (globals.ksqo) { > - result = SQLExecDirect(hstmt, "set ksqo to 'ON'", SQL_NTS); > + result = PG__SQLExecDirect(hstmt, "set ksqo to 'ON'", SQL_NTS); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) > status = FALSE; > > @@ -1263,7 +1263,7 @@ > cs = strdup(globals.conn_settings); > ptr = strtok(cs, ";"); > while (ptr) { > - result = SQLExecDirect(hstmt, ptr, SQL_NTS); > + result = PG__SQLExecDirect(hstmt, ptr, SQL_NTS); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) > status = FALSE; > > @@ -1280,7 +1280,7 @@ > cs = strdup(ci->conn_settings); > ptr = strtok(cs, ";"); > while (ptr) { > - result = SQLExecDirect(hstmt, ptr, SQL_NTS); > + result = PG__SQLExecDirect(hstmt, ptr, SQL_NTS); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) > status = FALSE; > > @@ -1293,7 +1293,7 @@ > } > > > - SQLFreeStmt(hstmt, SQL_DROP); > + PG__SQLFreeStmt(hstmt, SQL_DROP); > > return status; > } > @@ -1315,34 +1315,34 @@ > /* This function must use the local odbc API functions since the odbc state > has not transitioned to "connected" yet. > */ > - result = SQLAllocStmt( self, &hstmt); > + result = PG__SQLAllocStmt( self, &hstmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > return; > } > stmt = (StatementClass *) hstmt; > > - result = SQLExecDirect(hstmt, "select oid from pg_type where typname='" PG_TYPE_LO_NAME "'", SQL_NTS); > + result = PG__SQLExecDirect(hstmt, "select oid from pg_type where typname='" PG_TYPE_LO_NAME "'", SQL_NTS); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > - SQLFreeStmt(hstmt, SQL_DROP); > + PG__SQLFreeStmt(hstmt, SQL_DROP); > return; > } > > - result = SQLFetch(hstmt); > + result = PG__SQLFetch(hstmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > - SQLFreeStmt(hstmt, SQL_DROP); > + PG__SQLFreeStmt(hstmt, SQL_DROP); > return; > } > > - result = SQLGetData(hstmt, 1, SQL_C_SLONG, &self->lobj_type, sizeof(self->lobj_type), NULL); > + result = PG__SQLGetData(hstmt, 1, SQL_C_SLONG, &self->lobj_type, sizeof(self->lobj_type), NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > - SQLFreeStmt(hstmt, SQL_DROP); > + PG__SQLFreeStmt(hstmt, SQL_DROP); > return; > } > > mylog("Got the large object oid: %d\n", self->lobj_type); > qlog(" [ Large Object oid = %d ]\n", self->lobj_type); > > - result = SQLFreeStmt(hstmt, SQL_DROP); > + result = PG__SQLFreeStmt(hstmt, SQL_DROP); > } > > void > diff -u -r pgsql/src/interfaces/odbc/dlg_specific.c pgsql.new/src/interfaces/odbc/dlg_specific.c > --- pgsql/src/interfaces/odbc/dlg_specific.c Tue Jun 20 08:00:21 2000 > +++ pgsql.new/src/interfaces/odbc/dlg_specific.c Tue Aug 1 14:44:04 2000 > @@ -23,8 +23,10 @@ > #ifndef WIN32 > # include <string.h> > # include "gpps.h" > +#ifndef HAVE_SQLGETPRIVATEPROFILESTRING > # define SQLGetPrivateProfileString(a,b,c,d,e,f) GetPrivateProfileString(a,b,c,d,e,f) > # define SQLWritePrivateProfileString(a,b,c,d) WritePrivateProfileString(a,b,c,d) > +#endif > # ifndef HAVE_STRICMP > # define stricmp(s1,s2) strcasecmp(s1,s2) > # define strnicmp(s1,s2,n) strncasecmp(s1,s2,n) > diff -u -r pgsql/src/interfaces/odbc/execute.c pgsql.new/src/interfaces/odbc/execute.c > --- pgsql/src/interfaces/odbc/execute.c Sat May 27 08:00:25 2000 > +++ pgsql.new/src/interfaces/odbc/execute.c Tue Aug 1 15:58:38 2000 > @@ -125,7 +125,7 @@ > > /* Performs the equivalent of SQLPrepare, followed by SQLExecute. */ > > -RETCODE SQL_API SQLExecDirect( > +RETCODE SQL_API PG__SQLExecDirect( > HSTMT hstmt, > UCHAR FAR *szSqlStr, > SDWORD cbSqlStr) > @@ -176,14 +176,14 @@ > > mylog("%s: calling SQLExecute...\n", func); > > - result = SQLExecute(hstmt); > + result = PG__SQLExecute(hstmt); > > mylog("%s: returned %hd from SQLExecute\n", func, result); > return result; > } > > /* Execute a prepared SQL statement */ > -RETCODE SQL_API SQLExecute( > +RETCODE SQL_API PG__SQLExecute( > HSTMT hstmt) > { > static char *func="SQLExecute"; > @@ -293,11 +293,23 @@ > > } > > - > - > +RETCODE SQL_API SQLExecDirect( > + HSTMT hstmt, > + UCHAR FAR *szSqlStr, > + SDWORD cbSqlStr ) > +{ > + return PG__SQLExecDirect( hstmt, szSqlStr, cbSqlStr ); > +} > + > +RETCODE SQL_API SQLExecute( > + HSTMT hstmt ) > +{ > + return PG__SQLExecute( hstmt ); > +} > + > > /* - - - - - - - - - */ > -RETCODE SQL_API SQLTransact( > +RETCODE SQL_API PG__SQLTransact( > HENV henv, > HDBC hdbc, > UWORD fType) > @@ -324,7 +336,7 @@ > conn = conns[lf]; > > if (conn && conn->henv == henv) > - if ( SQLTransact(henv, (HDBC) conn, fType) != SQL_SUCCESS) > + if ( PG__SQLTransact(henv, (HDBC) conn, fType) != SQL_SUCCESS) > return SQL_ERROR; > > } > @@ -371,6 +383,14 @@ > return SQL_SUCCESS; > } > > +RETCODE SQL_API SQLTransact( > + HENV henv, > + HDBC hdbc, > + UWORD fType) > +{ > + return PG__SQLTransact( henv, hdbc, fType ); > +} > + > /* - - - - - - - - - */ > > RETCODE SQL_API SQLCancel( > @@ -411,10 +431,10 @@ > result = addr( (char *) (stmt->phstmt) - 96, SQL_CLOSE); > } > else { > - result = SQLFreeStmt( hstmt, SQL_CLOSE); > + result = PG__SQLFreeStmt( hstmt, SQL_CLOSE); > } > #else > - result = SQLFreeStmt( hstmt, SQL_CLOSE); > + result = PG__SQLFreeStmt( hstmt, SQL_CLOSE); > #endif > > mylog("SQLCancel: SQLFreeStmt returned %d\n", result); > diff -u -r pgsql/src/interfaces/odbc/info.c pgsql.new/src/interfaces/odbc/info.c > --- pgsql/src/interfaces/odbc/info.c Sat May 27 08:00:26 2000 > +++ pgsql.new/src/interfaces/odbc/info.c Tue Aug 1 14:49:54 2000 > @@ -926,7 +926,7 @@ > > ci = &stmt->hdbc->connInfo; > > - result = SQLAllocStmt( stmt->hdbc, &htbl_stmt); > + result = PG__SQLAllocStmt( stmt->hdbc, &htbl_stmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't allocate statement for SQLTables result."; > @@ -1014,41 +1014,41 @@ > > /* ********************************************************************** */ > > - result = SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query)); > + result = PG__SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query)); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = SC_create_errormsg(htbl_stmt); > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 1, SQL_C_CHAR, > + result = PG__SQLBindCol(htbl_stmt, 1, SQL_C_CHAR, > table_name, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 2, SQL_C_CHAR, > + result = PG__SQLBindCol(htbl_stmt, 2, SQL_C_CHAR, > table_owner, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > - result = SQLBindCol(htbl_stmt, 3, SQL_C_CHAR, > + result = PG__SQLBindCol(htbl_stmt, 3, SQL_C_CHAR, > relhasrules, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -1057,7 +1057,7 @@ > stmt->errormsg = "Couldn't allocate memory for SQLTables result."; > stmt->errornumber = STMT_NO_MEMORY_ERROR; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -1074,7 +1074,7 @@ > QR_set_field_info(stmt->result, 4, "REMARKS", PG_TYPE_TEXT, 254); > > /* add the tuples */ > - result = SQLFetch(htbl_stmt); > + result = PG__SQLFetch(htbl_stmt); > while((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { > > /* Determine if this table name is a system table. > @@ -1133,13 +1133,13 @@ > > QR_add_tuple(stmt->result, row); > } > - result = SQLFetch(htbl_stmt); > + result = PG__SQLFetch(htbl_stmt); > } > if(result != SQL_NO_DATA_FOUND) { > stmt->errormsg = SC_create_errormsg(htbl_stmt); > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -1152,7 +1152,7 @@ > stmt->rowset_start = -1; > stmt->current_col = -1; > > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > mylog("SQLTables(): EXIT, stmt=%u\n", stmt); > return SQL_SUCCESS; > } > @@ -1160,7 +1160,7 @@ > > > > -RETCODE SQL_API SQLColumns( > +RETCODE SQL_API PG__SQLColumns( > HSTMT hstmt, > UCHAR FAR * szTableQualifier, > SWORD cbTableQualifier, > @@ -1217,7 +1217,7 @@ > strcat(columns_query, " order by attnum"); > /* ********************************************************************** */ > > - result = SQLAllocStmt( stmt->hdbc, &hcol_stmt); > + result = PG__SQLAllocStmt( stmt->hdbc, &hcol_stmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't allocate statement for SQLColumns result."; > @@ -1228,113 +1228,113 @@ > > mylog("SQLColumns: hcol_stmt = %u, col_stmt = %u\n", hcol_stmt, col_stmt); > > - result = SQLExecDirect(hcol_stmt, columns_query, > + result = PG__SQLExecDirect(hcol_stmt, columns_query, > strlen(columns_query)); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = SC_create_errormsg(hcol_stmt); > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 1, SQL_C_CHAR, > + result = PG__SQLBindCol(hcol_stmt, 1, SQL_C_CHAR, > table_owner, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 2, SQL_C_CHAR, > + result = PG__SQLBindCol(hcol_stmt, 2, SQL_C_CHAR, > table_name, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 3, SQL_C_CHAR, > + result = PG__SQLBindCol(hcol_stmt, 3, SQL_C_CHAR, > field_name, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 4, SQL_C_LONG, > + result = PG__SQLBindCol(hcol_stmt, 4, SQL_C_LONG, > &field_type, 4, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 5, SQL_C_CHAR, > + result = PG__SQLBindCol(hcol_stmt, 5, SQL_C_CHAR, > field_type_name, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 6, SQL_C_SHORT, > + result = PG__SQLBindCol(hcol_stmt, 6, SQL_C_SHORT, > &field_number, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 7, SQL_C_LONG, > + result = PG__SQLBindCol(hcol_stmt, 7, SQL_C_LONG, > &field_length, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 8, SQL_C_LONG, > + result = PG__SQLBindCol(hcol_stmt, 8, SQL_C_LONG, > &mod_length, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 9, SQL_C_CHAR, > + result = PG__SQLBindCol(hcol_stmt, 9, SQL_C_CHAR, > not_null, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 10, SQL_C_CHAR, > + result = PG__SQLBindCol(hcol_stmt, 10, SQL_C_CHAR, > relhasrules, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -1343,7 +1343,7 @@ > stmt->errormsg = "Couldn't allocate memory for SQLColumns result."; > stmt->errornumber = STMT_NO_MEMORY_ERROR; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -1372,7 +1372,7 @@ > QR_set_field_info(stmt->result, 13, "FIELD_TYPE", PG_TYPE_INT4, 4); > > > - result = SQLFetch(hcol_stmt); > + result = PG__SQLFetch(hcol_stmt); > > > /* Only show oid if option AND there are other columns AND > @@ -1503,14 +1503,14 @@ > QR_add_tuple(stmt->result, row); > > > - result = SQLFetch(hcol_stmt); > + result = PG__SQLFetch(hcol_stmt); > > } > if(result != SQL_NO_DATA_FOUND) { > stmt->errormsg = SC_create_errormsg(hcol_stmt); > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -1550,11 +1550,33 @@ > stmt->rowset_start = -1; > stmt->current_col = -1; > > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > mylog("SQLColumns(): EXIT, stmt=%u\n", stmt); > return SQL_SUCCESS; > } > > +RETCODE SQL_API SQLColumns( > + HSTMT hstmt, > + UCHAR FAR * szTableQualifier, > + SWORD cbTableQualifier, > + UCHAR FAR * szTableOwner, > + SWORD cbTableOwner, > + UCHAR FAR * szTableName, > + SWORD cbTableName, > + UCHAR FAR * szColumnName, > + SWORD cbColumnName) > +{ > + return PG__SQLColumns( hstmt, > + szTableQualifier, > + cbTableQualifier, > + szTableOwner, > + cbTableOwner, > + szTableName, > + cbTableName, > + szColumnName, > + cbColumnName ); > +} > + > RETCODE SQL_API SQLSpecialColumns( > HSTMT hstmt, > UWORD fColType, > @@ -1601,7 +1623,7 @@ > my_strcat(columns_query, " and u.usename like '%.*s'", szTableOwner, cbTableOwner); > > > - result = SQLAllocStmt( stmt->hdbc, &hcol_stmt); > + result = PG__SQLAllocStmt( stmt->hdbc, &hcol_stmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't allocate statement for SQLSpecialColumns result."; > @@ -1612,28 +1634,28 @@ > > mylog("SQLSpecialColumns: hcol_stmt = %u, col_stmt = %u\n", hcol_stmt, col_stmt); > > - result = SQLExecDirect(hcol_stmt, columns_query, > + result = PG__SQLExecDirect(hcol_stmt, columns_query, > strlen(columns_query)); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = SC_create_errormsg(hcol_stmt); > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(hcol_stmt, 1, SQL_C_CHAR, > + result = PG__SQLBindCol(hcol_stmt, 1, SQL_C_CHAR, > relhasrules, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = col_stmt->errormsg; > stmt->errornumber = col_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLFetch(hcol_stmt); > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + result = PG__SQLFetch(hcol_stmt); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > > stmt->result = QR_Constructor(); > extend_bindings(stmt, 8); > @@ -1815,7 +1837,7 @@ > > } > > - result = SQLFetch(hcol_stmt); > + result = PG__SQLFetch(hcol_stmt); > while((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { > total_columns++; > > @@ -1828,7 +1850,7 @@ > > mylog("SQLStatistics: column_name = '%s'\n", column_name); > > - result = SQLFetch(hcol_stmt); > + result = PG__SQLFetch(hcol_stmt); > } > if(result != SQL_NO_DATA_FOUND || total_columns == 0) { > stmt->errormsg = SC_create_errormsg(hcol_stmt); /* "Couldn't get column names in SQLStatistics."; */ > @@ -1838,10 +1860,10 @@ > > } > > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > > /* get a list of indexes on this table */ > - result = SQLAllocStmt( stmt->hdbc, &hindx_stmt); > + result = PG__SQLAllocStmt( stmt->hdbc, &hindx_stmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = "SQLAllocStmt failed in SQLStatistics for indices."; > stmt->errornumber = STMT_NO_MEMORY_ERROR; > @@ -1856,7 +1878,7 @@ > " where c.oid = i.indexrelid and d.relname = '%s'" > " and d.oid = i.indrelid", table_name); > > - result = SQLExecDirect(hindx_stmt, index_query, strlen(index_query)); > + result = PG__SQLExecDirect(hindx_stmt, index_query, strlen(index_query)); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = SC_create_errormsg(hindx_stmt); /* "Couldn't execute index query (w/SQLExecDirect) in SQLStatistics.";*/ > stmt->errornumber = indx_stmt->errornumber; > @@ -1866,7 +1888,7 @@ > } > > /* bind the index name column */ > - result = SQLBindCol(hindx_stmt, 1, SQL_C_CHAR, > + result = PG__SQLBindCol(hindx_stmt, 1, SQL_C_CHAR, > 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 in SQLStatistics."; */ > @@ -1876,7 +1898,7 @@ > > } > /* bind the vector column */ > - result = SQLBindCol(hindx_stmt, 2, SQL_C_DEFAULT, > + result = PG__SQLBindCol(hindx_stmt, 2, SQL_C_DEFAULT, > fields_vector, 16, &fields_vector_len); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column in SQLStatistics."; */ > @@ -1886,7 +1908,7 @@ > > } > /* bind the "is unique" column */ > - result = SQLBindCol(hindx_stmt, 3, SQL_C_CHAR, > + result = PG__SQLBindCol(hindx_stmt, 3, SQL_C_CHAR, > isunique, sizeof(isunique), NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column in SQLStatistics."; */ > @@ -1896,7 +1918,7 @@ > } > > /* bind the "is clustered" column */ > - result = SQLBindCol(hindx_stmt, 4, SQL_C_CHAR, > + result = PG__SQLBindCol(hindx_stmt, 4, SQL_C_CHAR, > isclustered, sizeof(isclustered), NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column in SQLStatistics."; */ > @@ -1906,7 +1928,7 @@ > > } > > - result = SQLBindCol(hindx_stmt, 5, SQL_C_CHAR, > + result = PG__SQLBindCol(hindx_stmt, 5, SQL_C_CHAR, > relhasrules, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = indx_stmt->errormsg; > @@ -1948,7 +1970,7 @@ > QR_add_tuple(stmt->result, row); > } > > - result = SQLFetch(hindx_stmt); > + result = PG__SQLFetch(hindx_stmt); > while((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { > > /* If only requesting unique indexs, then just return those. */ > @@ -2004,7 +2026,7 @@ > } > } > > - result = SQLFetch(hindx_stmt); > + result = PG__SQLFetch(hindx_stmt); > } > if(result != SQL_NO_DATA_FOUND) { > stmt->errormsg = SC_create_errormsg(hindx_stmt); /* "SQLFetch failed in SQLStatistics."; */ > @@ -2013,7 +2035,7 @@ > goto SEEYA; > } > > - SQLFreeStmt(hindx_stmt, SQL_DROP); > + PG__SQLFreeStmt(hindx_stmt, SQL_DROP); > > /* also, things need to think that this statement is finished so */ > /* the results can be retrieved. */ > @@ -2069,7 +2091,7 @@ > /* SQLPrimaryKeys() > * Retrieve the primary key columns for the specified table. > */ > -RETCODE SQL_API SQLPrimaryKeys( > +RETCODE SQL_API PG__SQLPrimaryKeys( > HSTMT hstmt, > UCHAR FAR * szTableQualifier, > SWORD cbTableQualifier, > @@ -2123,7 +2145,7 @@ > QR_set_field_info(stmt->result, 5, "PK_NAME", PG_TYPE_TEXT, MAX_INFO_STRING); > > > - result = SQLAllocStmt( stmt->hdbc, &htbl_stmt); > + result = PG__SQLAllocStmt( stmt->hdbc, &htbl_stmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't allocate statement for Primary Key result."; > @@ -2138,7 +2160,7 @@ > stmt->errormsg = "No Table specified to SQLPrimaryKeys."; > stmt->errornumber = STMT_INTERNAL_ERROR; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -2162,26 +2184,26 @@ > > mylog("SQLPrimaryKeys: tables_query='%s'\n", tables_query); > > - result = SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query)); > + result = PG__SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query)); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = SC_create_errormsg(htbl_stmt); > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 1, SQL_C_CHAR, > + result = PG__SQLBindCol(htbl_stmt, 1, SQL_C_CHAR, > attname, MAX_INFO_STRING, &attname_len); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLFetch(htbl_stmt); > + result = PG__SQLFetch(htbl_stmt); > > while((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) { > > @@ -2204,18 +2226,18 @@ > > mylog(">> primaryKeys: pktab = '%s', attname = '%s', seq = %d\n", pktab, attname, seq); > > - result = SQLFetch(htbl_stmt); > + result = PG__SQLFetch(htbl_stmt); > } > > if(result != SQL_NO_DATA_FOUND) { > stmt->errormsg = SC_create_errormsg(htbl_stmt); > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > > > /* also, things need to think that this statement is finished so */ > @@ -2231,7 +2253,25 @@ > return SQL_SUCCESS; > } > > -RETCODE SQL_API SQLForeignKeys( > +RETCODE SQL_API SQLPrimaryKeys( > + HSTMT hstmt, > + UCHAR FAR * szTableQualifier, > + SWORD cbTableQualifier, > + UCHAR FAR * szTableOwner, > + SWORD cbTableOwner, > + UCHAR FAR * szTableName, > + SWORD cbTableName) > +{ > + return PG__SQLPrimaryKeys( hstmt, > + szTableQualifier, > + cbTableQualifier, > + szTableOwner, > + cbTableOwner, > + szTableName, > + cbTableName ); > +} > + > +RETCODE SQL_API PG__SQLForeignKeys( > HSTMT hstmt, > UCHAR FAR * szPkTableQualifier, > SWORD cbPkTableQualifier, > @@ -2277,7 +2317,7 @@ > stmt->errormsg = "Couldn't allocate memory for SQLForeignKeys result."; > stmt->errornumber = STMT_NO_MEMORY_ERROR; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -2313,7 +2353,7 @@ > stmt->current_col = -1; > > > - result = SQLAllocStmt( stmt->hdbc, &htbl_stmt); > + result = PG__SQLAllocStmt( stmt->hdbc, &htbl_stmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't allocate statement for SQLForeignKeys result."; > @@ -2341,46 +2381,46 @@ > " AND pg_proc.proname = 'check_primary_key' AND pg_class.relname = '%s'", > fktab); > > - result = SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query)); > + result = PG__SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query)); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = SC_create_errormsg(htbl_stmt); > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 1, SQL_C_BINARY, > + result = PG__SQLBindCol(htbl_stmt, 1, SQL_C_BINARY, > args, MAX_INFO_STRING, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 2, SQL_C_SHORT, > + result = PG__SQLBindCol(htbl_stmt, 2, SQL_C_SHORT, > &nargs, 0, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 3, SQL_C_CHAR, > + result = PG__SQLBindCol(htbl_stmt, 3, SQL_C_CHAR, > tgname, sizeof(tgname), NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLFetch(htbl_stmt); > + result = PG__SQLFetch(htbl_stmt); > if (result == SQL_NO_DATA_FOUND) > return SQL_SUCCESS; > > @@ -2388,11 +2428,11 @@ > stmt->errormsg = SC_create_errormsg(htbl_stmt); > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - keyresult = SQLAllocStmt( stmt->hdbc, &hpkey_stmt); > + keyresult = PG__SQLAllocStmt( stmt->hdbc, &hpkey_stmt); > if((keyresult != SQL_SUCCESS) && (keyresult != SQL_SUCCESS_WITH_INFO)) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't allocate statement for SQLForeignKeys (pkeys) result."; > @@ -2400,13 +2440,13 @@ > return SQL_ERROR; > } > > - keyresult = SQLBindCol(hpkey_stmt, 4, SQL_C_CHAR, > + keyresult = PG__SQLBindCol(hpkey_stmt, 4, SQL_C_CHAR, > pkey, sizeof(pkey), NULL); > if (keyresult != SQL_SUCCESS) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't bindcol for primary keys for SQLForeignKeys result."; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hpkey_stmt, SQL_DROP); > + PG__SQLFreeStmt(hpkey_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -2432,23 +2472,23 @@ > > /* If it doesn't match, then continue */ > if ( strcmp(prel, pktab)) { > - result = SQLFetch(htbl_stmt); > + result = PG__SQLFetch(htbl_stmt); > continue; > } > } > > - keyresult = SQLPrimaryKeys(hpkey_stmt, NULL, 0, NULL, 0, prel, SQL_NTS); > + keyresult = PG__SQLPrimaryKeys(hpkey_stmt, NULL, 0, NULL, 0, prel, SQL_NTS); > if (keyresult != SQL_SUCCESS) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't get primary keys for SQLForeignKeys result."; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hpkey_stmt, SQL_DROP); > + PG__SQLFreeStmt(hpkey_stmt, SQL_DROP); > return SQL_ERROR; > } > > > /* Check that the key listed is the primary key */ > - keyresult = SQLFetch(hpkey_stmt); > + keyresult = PG__SQLFetch(hpkey_stmt); > for (k = 0; k < pkeys; k++) { > > ptr += strlen(ptr) + 1; > @@ -2456,7 +2496,7 @@ > pkeys = 0; > break; > } > - keyresult = SQLFetch(hpkey_stmt); > + keyresult = PG__SQLFetch(hpkey_stmt); > } > ptr = prel; > > @@ -2504,7 +2544,7 @@ > > } > > - result = SQLFetch(htbl_stmt); > + result = PG__SQLFetch(htbl_stmt); > } > } > > @@ -2520,56 +2560,56 @@ > " AND pg_proc.proname = 'check_foreign_key' AND pg_class.relname = '%s'", > pktab); > > - result = SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query)); > + result = PG__SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query)); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = SC_create_errormsg(htbl_stmt); > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 1, SQL_C_BINARY, > + result = PG__SQLBindCol(htbl_stmt, 1, SQL_C_BINARY, > args, sizeof(args), NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 2, SQL_C_SHORT, > + result = PG__SQLBindCol(htbl_stmt, 2, SQL_C_SHORT, > &nargs, 0, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 3, SQL_C_SHORT, > + result = PG__SQLBindCol(htbl_stmt, 3, SQL_C_SHORT, > &rule_type, 0, NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLBindCol(htbl_stmt, 4, SQL_C_CHAR, > + result = PG__SQLBindCol(htbl_stmt, 4, SQL_C_CHAR, > tgname, sizeof(tgname), NULL); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = tbl_stmt->errormsg; > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - result = SQLFetch(htbl_stmt); > + result = PG__SQLFetch(htbl_stmt); > if (result == SQL_NO_DATA_FOUND) > return SQL_SUCCESS; > > @@ -2577,11 +2617,11 @@ > stmt->errormsg = SC_create_errormsg(htbl_stmt); > stmt->errornumber = tbl_stmt->errornumber; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - keyresult = SQLAllocStmt( stmt->hdbc, &hpkey_stmt); > + keyresult = PG__SQLAllocStmt( stmt->hdbc, &hpkey_stmt); > if((keyresult != SQL_SUCCESS) && (keyresult != SQL_SUCCESS_WITH_INFO)) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't allocate statement for SQLForeignKeys (pkeys) result."; > @@ -2589,22 +2629,22 @@ > return SQL_ERROR; > } > > - keyresult = SQLPrimaryKeys(hpkey_stmt, NULL, 0, NULL, 0, pktab, SQL_NTS); > + keyresult = PG__SQLPrimaryKeys(hpkey_stmt, NULL, 0, NULL, 0, pktab, SQL_NTS); > if (keyresult != SQL_SUCCESS) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't get primary keys for SQLForeignKeys result."; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hpkey_stmt, SQL_DROP); > + PG__SQLFreeStmt(hpkey_stmt, SQL_DROP); > return SQL_ERROR; > } > > - keyresult = SQLBindCol(hpkey_stmt, 4, SQL_C_CHAR, > + keyresult = PG__SQLBindCol(hpkey_stmt, 4, SQL_C_CHAR, > pkey, sizeof(pkey), NULL); > if (keyresult != SQL_SUCCESS) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > stmt->errormsg = "Couldn't bindcol for primary keys for SQLForeignKeys result."; > SC_log_error(func, "", stmt); > - SQLFreeStmt(hpkey_stmt, SQL_DROP); > + PG__SQLFreeStmt(hpkey_stmt, SQL_DROP); > return SQL_ERROR; > } > > @@ -2639,7 +2679,7 @@ > pkey_ptr = ptr; > > > - keyresult = SQLExtendedFetch(hpkey_stmt, SQL_FETCH_FIRST, -1, NULL, NULL); > + keyresult = PG__SQLExtendedFetch(hpkey_stmt, SQL_FETCH_FIRST, -1, NULL, NULL); > if ( keyresult != SQL_SUCCESS || strcmp(pkey, ptr)) { > ntabs = 0; > } > @@ -2654,7 +2694,7 @@ > } > ptr += strlen(ptr) + 1; > > - keyresult = SQLExtendedFetch(hpkey_stmt, SQL_FETCH_NEXT, -1, NULL, NULL); > + keyresult = PG__SQLExtendedFetch(hpkey_stmt, SQL_FETCH_NEXT, -1, NULL, NULL); > } > > mylog("Foreign Key Case#1: nargs = %d, ntabs = %d, pkeys = %d\n", nargs, ntabs, pkeys); > @@ -2712,24 +2752,53 @@ > > } > > - result = SQLFetch(htbl_stmt); > + result = PG__SQLFetch(htbl_stmt); > } > } > else { > stmt->errormsg = "No tables specified to SQLForeignKeys."; > stmt->errornumber = STMT_INTERNAL_ERROR; > SC_log_error(func, "", stmt); > - SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > return SQL_ERROR; > } > > - SQLFreeStmt(htbl_stmt, SQL_DROP); > - SQLFreeStmt(hpkey_stmt, SQL_DROP); > + PG__SQLFreeStmt(htbl_stmt, SQL_DROP); > + PG__SQLFreeStmt(hpkey_stmt, SQL_DROP); > > mylog("SQLForeignKeys(): EXIT, stmt=%u\n", stmt); > return SQL_SUCCESS; > } > > +RETCODE SQL_API SQLForeignKeys( > + 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) > +{ > + return PG__SQLForeignKeys( hstmt, > + szPkTableQualifier, > + cbPkTableQualifier, > + szPkTableOwner, > + cbPkTableOwner, > + szPkTableName, > + cbPkTableName, > + szFkTableQualifier, > + cbFkTableQualifier, > + szFkTableOwner, > + cbFkTableOwner, > + szFkTableName, > + cbFkTableName ); > +} > > > RETCODE SQL_API SQLProcedureColumns( > diff -u -r pgsql/src/interfaces/odbc/misc.h pgsql.new/src/interfaces/odbc/misc.h > --- pgsql/src/interfaces/odbc/misc.h Tue Jun 20 08:00:21 2000 > +++ pgsql.new/src/interfaces/odbc/misc.h Tue Aug 1 14:54:32 2000 > @@ -16,8 +16,10 @@ > > #ifndef WIN32 > #include "gpps.h" > +#ifndef HAVE_SQLGETPRIVATEPROFILESTRING > #define SQLGetPrivateProfileString(a,b,c,d,e,f) GetPrivateProfileString(a,b,c,d,e,f) > #endif > +#endif > > #include <stdio.h> > > @@ -101,4 +103,114 @@ > > int my_strcpy(char *dst, int dst_len, char *src, int src_len); > > + > +/* > + * prototypes for the internal versions of ODBC functions. > + * We need to do this because when used under a unix driver manager the DM exports > + * the same function entry points, so the application calls SQLExecDirect in the DM > + * the DM calls SQLExecDirect in the driver, which then calls SQLPrepare, this > + * however calls SQLPrepare in the DM not the driver. Prefixing all the calls used > + * internally by PG__ fixes this problem. Both unixODBC and iODBC will show this > + * problem > + */ > + > +#ifndef WIN32 > +#include "iodbc.h" > +#include "isqlext.h" > +#else > +#include <windows.h> > +#include <sqlext.h> > +#endif > + > +RETCODE SQL_API PG__SQLExecDirect( > + HSTMT hstmt, > + UCHAR FAR *szSqlStr, > + SDWORD cbSqlStr); > + > +RETCODE SQL_API PG__SQLAllocStmt(HDBC hdbc, > + HSTMT FAR *phstmt); > + > +RETCODE SQL_API PG__SQLExecute( > + HSTMT hstmt); > + > +RETCODE SQL_API PG__SQLTransact( > + HENV henv, > + HDBC hdbc, > + UWORD fType); > + > +RETCODE SQL_API PG__SQLFreeStmt(HSTMT hstmt, > + UWORD fOption); > + > +RETCODE SQL_API PG__SQLBindParameter( > + HSTMT hstmt, > + UWORD ipar, > + SWORD fParamType, > + SWORD fCType, > + SWORD fSqlType, > + UDWORD cbColDef, > + SWORD ibScale, > + PTR rgbValue, > + SDWORD cbValueMax, > + SDWORD FAR *pcbValue); > + > +RETCODE SQL_API PG__SQLBindCol( > + HSTMT hstmt, > + UWORD icol, > + SWORD fCType, > + PTR rgbValue, > + SDWORD cbValueMax, > + SDWORD FAR *pcbValue); > + > +RETCODE SQL_API PG__SQLColumns( > + HSTMT hstmt, > + UCHAR FAR * szTableQualifier, > + SWORD cbTableQualifier, > + UCHAR FAR * szTableOwner, > + SWORD cbTableOwner, > + UCHAR FAR * szTableName, > + SWORD cbTableName, > + UCHAR FAR * szColumnName, > + SWORD cbColumnName); > + > +RETCODE SQL_API PG__SQLFetch( > + HSTMT hstmt); > + > +RETCODE SQL_API PG__SQLGetData( > + HSTMT hstmt, > + UWORD icol, > + SWORD fCType, > + PTR rgbValue, > + SDWORD cbValueMax, > + SDWORD FAR *pcbValue); > + > +RETCODE SQL_API PG__SQLPrimaryKeys( > + HSTMT hstmt, > + UCHAR FAR * szTableQualifier, > + SWORD cbTableQualifier, > + UCHAR FAR * szTableOwner, > + SWORD cbTableOwner, > + UCHAR FAR * szTableName, > + SWORD cbTableName); > + > +RETCODE SQL_API PG__SQLForeignKeys( > + 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); > + > +RETCODE SQL_API PG__SQLExtendedFetch( > + HSTMT hstmt, > + UWORD fFetchType, > + SDWORD irow, > + UDWORD FAR *pcrow, > + UWORD FAR *rgfRowStatus); > #endif > diff -u -r pgsql/src/interfaces/odbc/parse.c pgsql.new/src/interfaces/odbc/parse.c > --- pgsql/src/interfaces/odbc/parse.c Sat May 27 08:00:26 2000 > +++ pgsql.new/src/interfaces/odbc/parse.c Tue Aug 1 14:38:10 2000 > @@ -576,7 +576,7 @@ > > mylog("PARSE: Getting SQLColumns for table[%d]='%s'\n", i, ti[i]->name); > > - result = SQLAllocStmt( stmt->hdbc, &hcol_stmt); > + result = PG__SQLAllocStmt( stmt->hdbc, &hcol_stmt); > if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) { > stmt->errormsg = "SQLAllocStmt failed in parse_statement for columns."; > stmt->errornumber = STMT_NO_MEMORY_ERROR; > @@ -587,7 +587,7 @@ > col_stmt = (StatementClass *) hcol_stmt; > col_stmt->internal = TRUE; > > - result = SQLColumns(hcol_stmt, "", 0, "", 0, > + result = PG__SQLColumns(hcol_stmt, "", 0, "", 0, > ti[i]->name, (SWORD) strlen(ti[i]->name), "", 0); > > mylog(" Past SQLColumns\n"); > @@ -622,11 +622,11 @@ > > conn->ntables++; > > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > mylog("Created col_info table='%s', ntables=%d\n", ti[i]->name, conn->ntables); > } > else { > - SQLFreeStmt(hcol_stmt, SQL_DROP); > + PG__SQLFreeStmt(hcol_stmt, SQL_DROP); > break; > } > } > diff -u -r pgsql/src/interfaces/odbc/results.c pgsql.new/src/interfaces/odbc/results.c > --- pgsql/src/interfaces/odbc/results.c Sat May 27 08:00:26 2000 > +++ pgsql.new/src/interfaces/odbc/results.c Tue Aug 1 14:52:56 2000 > @@ -595,7 +595,7 @@ > > /* Returns result data for a single column in the current row. */ > > -RETCODE SQL_API SQLGetData( > +RETCODE SQL_API PG__SQLGetData( > HSTMT hstmt, > UWORD icol, > SWORD fCType, > @@ -763,12 +763,26 @@ > } > } > > - > +RETCODE SQL_API SQLGetData( > + HSTMT hstmt, > + UWORD icol, > + SWORD fCType, > + PTR rgbValue, > + SDWORD cbValueMax, > + SDWORD FAR *pcbValue) > +{ > + return PG__SQLGetData( hstmt, > + icol, > + fCType, > + rgbValue, > + cbValueMax, > + pcbValue ); > +} > > /* Returns data for bound columns in the current row ("hstmt->iCursor"), */ > /* advances the cursor. */ > > -RETCODE SQL_API SQLFetch( > +RETCODE SQL_API PG__SQLFetch( > HSTMT hstmt) > { > static char *func = "SQLFetch"; > @@ -829,9 +843,16 @@ > return SC_fetch(stmt); > } > > +RETCODE SQL_API SQLFetch( > + HSTMT hstmt) > +{ > + return PG__SQLFetch( hstmt ); > +} > + > + > /* This fetchs a block of data (rowset). */ > > -RETCODE SQL_API SQLExtendedFetch( > +RETCODE SQL_API PG__SQLExtendedFetch( > HSTMT hstmt, > UWORD fFetchType, > SDWORD irow, > @@ -1097,6 +1118,20 @@ > else > return SQL_SUCCESS; > > +} > + > +RETCODE SQL_API SQLExtendedFetch( > + HSTMT hstmt, > + UWORD fFetchType, > + SDWORD irow, > + UDWORD FAR *pcrow, > + UWORD FAR *rgfRowStatus) > +{ > + return PG__SQLExtendedFetch( hstmt, > + fFetchType, > + irow, > + pcrow, > + rgfRowStatus ); > } > > > diff -u -r pgsql/src/interfaces/odbc/statement.c pgsql.new/src/interfaces/odbc/statement.c > --- pgsql/src/interfaces/odbc/statement.c Sat May 27 08:00:26 2000 > +++ pgsql.new/src/interfaces/odbc/statement.c Tue Aug 1 14:38:10 2000 > @@ -61,7 +61,7 @@ > }; > > > -RETCODE SQL_API SQLAllocStmt(HDBC hdbc, > +RETCODE SQL_API PG__SQLAllocStmt(HDBC hdbc, > HSTMT FAR *phstmt) > { > static char *func="SQLAllocStmt"; > @@ -109,8 +109,14 @@ > return SQL_SUCCESS; > } > > +RETCODE SQL_API SQLAllocStmt(HDBC hdbc, > + HSTMT FAR *phstmt) > +{ > + return PG__SQLAllocStmt( hdbc, phstmt ); > +} > > -RETCODE SQL_API SQLFreeStmt(HSTMT hstmt, > + > +RETCODE SQL_API PG__SQLFreeStmt(HSTMT hstmt, > UWORD fOption) > { > static char *func="SQLFreeStmt"; > @@ -170,6 +176,11 @@ > return SQL_SUCCESS; > } > > +RETCODE SQL_API SQLFreeStmt(HSTMT hstmt, > + UWORD fOption) > +{ > + return PG__SQLFreeStmt( hstmt, fOption ); > +} > > > /********************************************************************** > @@ -479,7 +490,7 @@ > if (self->status == STMT_READY) { > mylog(" preprocess: status = READY\n"); > > - SQLExecute(self); > + PG__SQLExecute(self); > > if (self->status == STMT_FINISHED) { > mylog(" preprocess: after status = FINISHED, so set PREMATURE\n"); -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
pgsql-patches by date: