tldm-universe/Ardent/UV/gcidir/include/UVODBC.h
2024-09-09 17:51:08 -04:00

1050 lines
37 KiB
C
Executable File

#ifndef UVODBC_H
#define UVODBC_H
/******************************************************************************
*
* Header files for UCI (Universe Call Interface)
*
* Module %M% Version %I% Date %H%
*
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
* This is unpublished proprietary source code of Ardent Software Inc.
* The copyright notice above does not evidence any actual or intented
* publication of such source code.
*
*******************************************************************************
*
* Maintenence log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description.........................................
* 04/07/99 24790 CSM Enhance UCI config file for OLEDB configuration
* 03/30/99 24764 CSM recognize Ardent UCI applications
* 03/25/99 24411 JBG Add SQDefBindExecp set, *pirow, field in hstmt
* 03/16/99 23637 JBG Add colautoinc in column desc
* 02/12/99 24502 CSM new func SQLUseCfgFile & SQLDataSources for OLEDB
* 02/12/99 24501 CSM Add support for Unidata DBMStype
* 11/19/98 24000 CSM Add fields to hdbc structure for UVODBC licensing
* 10/22/98 23801 SAP Change company name to Ardent
* 10/14/98 23801 SAP Change copyrights.
* 10/02/98 23765 CSM Add dev subkey option to SetConnectOption for license
* 06/08/98 22557 CSM add isaselect and isadatam flags
* 09/08/97 21173 MJC Add is_local_connect and scon... flags
* 07/31/97 20912 ECS fieldwidth to unsigned int for MS SQLServer
* 06/17/97 20748 MJC Expand dbc for NLS
* 06/03/97 20748 MJC Add CLT/LS_SQGetInfo; SETERRINFO
* 04/29/97 20395 MJC Change msg now that we try ODBC if not DSN found
* 11/20/96 19548 ENF Add fields for TX isolevel and default iso level
* 11/18/96 19622 ENF Rename fataltx bit to nonumparams bit;
* Added a 'markerbound' bit to pmark structure
* 11/05/96 19512 ENF Add cell to marker holding amt space allocated
* 10/30/96 19512 ENF SQLParamOptions changes
* 08/08/96 18994 ENF Add flags for empty_null and tx_private
* 07/26/96 18758 MJC fix printresult and bit counts
* 07/25/96 18758 MJC flag for UCI_COLUMN_PRINT_RESULT
* 07/22/96 18854 ENF Changes for ODBC middleware project
* 06/10/96 18162 ENF Mods for procedure OUTPUT params
* 06/04/96 18162 ENF Added valmax to both pmarker and bcol structs
* 05/22/96 18423 GMM Added iflags.h
* 05/17/96 18460 HSB Define flags for UVSQLError.
* 05/15/96 18162 ENF Add ERRBLK *setdiag to HENV and HDBC structs
* 05/14/96 18162 ENF Add ERRBLK *setdiag AGAIN..accidentally erased
* 05/13/96 17689 ENF Mods to allow finding config file in Windows
* 04/09/96 18162 ENF Add bit identifying an @HSTMT assignment
* 03/29/96 18162 ENF Additions for CALL; lots of re-organization
* 03/15/95 17689 ENF Port to 32 bit Windows
* 12/01/95 17490 ENF Add PWD_H to define struct passwd
* 08/21/95 17199 MJC add SETERRBAD for uci_bconvert
* 07/11/95 16489 FRA Port to IBM RS6000 (define uchar rather than typedef)
* 06/19/95 15921 ENF Add execinprog to hdc struct
* 06/14/95 15921 ENF Define ODrealloc; add place for server PID
* 06/13/95 15921 ENF Add version numbers to hdbc, exec in progress flag
* 06/02/95 15921 ENF Change definition of MAXFETCHROWS to MAXFETCHCOLS
* 05/30/95 15921 ENF Add nest, isolation levels to Fetch structures
* 05/23/95 16489 FRA Back change out
* 05/19/95 16489 FRA Port to IBM RS6000
* 05/09/95 16358 AGM Rename FCONTROL as it clashes with NT system name
* 04/28/95 15921 ENF Remove () from around CLT_xxx EXTERNs
* 04/26/95 15921 ENF Fix DESCLISTFLAGS for hp compile
* 04/25/95 15921 ENF Initial submission.
*
*
*****************************************************************************/
#ifdef SQLINK /***** If SequeLink is present ****/
#include "SequeLink.h"
#endif
/********************************************************************/
#ifndef UV /*************** We're linked with UniVerse ***************/
#include "uv.h"
#include "iflags.h"
#define SQLNKCONERR -3103
#ifndef Xfree
#define Xfree(mem) {Rfree(mem); mem = (char *)0; }
#endif
#ifndef Ufree
#define Ufree(mem) {Rfree(mem); mem = (uchar *)0; }
#endif
#ifndef SQLINK
#define TRUE 1
#define FALSE 0
#endif
#endif
/*********************************************************
* Include a bunch of standard definitions like SQL
* datatypes and application datatypes
*********************************************************/
#ifndef UV /* UniVerse compile includes real ODBC */
#define __SQL /* Make it look like we're using REAL ODBC */
#ifdef MSWIN
#include <windows.h>
#endif
#endif
#include "UCI.h"
#ifdef UV /***************We're linked stand-alone *******************/
#ifdef _WINNT /**************** We're on NT ********************/
#include "nt.h"
#define PWD_H "uid.h"
#else
#define PWD_H <pwd.h>
#endif
#define TRUE 1
#define FALSE 0
#define SQLNKCONERR -3103
#define CTYPE_H <ctype.h>
extern char *ODmalloc();
extern int ODfree();
#ifndef PUB_RW
#define PUB_RW
#endif
#ifndef PRI_RO
#define PRI_RO static
#endif
#ifndef PUB_RO
#define PUB_RO
#endif
#ifndef PRI_RW
#define PRI_RW static
#endif
#ifndef EXTERN
#define EXTERN extern
#endif
#define Rmalloc(size) (uchar *)ODmalloc(size,__LINE__,__MODULE__)
#define Rcalloc(x,y) ((uchar*)calloc((x),(y)))
#ifdef Rrealloc
#undef Rrealloc
#endif
#define Rrealloc(x,y) ((UCHAR *)ODrealloc((x),(y)))
#define Rfree(txt) if (txt) {ODfree(txt);}
#define Xfree(txt) {ODfree(txt); txt = (char *)0; }
#define Ufree(txt) {ODfree(txt); txt = (uchar *)0; }
#define Mfopen fopen
#define MMAP(a,b,c)
#define Ienable()
#define Idisable()
#ifndef uchar
#define uchar unsigned char
#endif
# define BITMAP unsigned int
#define TRUE 1
#define FALSE 0
#endif
/*******************************************
* Define a structure to contain error code
* and SQLSTATE information
*******************************************/
typedef struct { /* Define SSTXT to contain addresses of */
char *tag; /* the ODBC err code and the internal code */
char *ODtag;
} SSTXT;
/*******************************************
* Define data types used at the middleware
******************************************/
typedef SWORD UCIRefNum; /* Context reference numbers */
typedef char * UCIName; /* C string */
typedef char * UCIString; /* C string */
typedef char * UCIStmt; /* C string */
typedef char * UCIData; /* Unlimited byte buffer */
typedef SDWORD UCIErr; /* Status return code v2.0 */
typedef SDWORD UCISrvRtn; /* server status return code */
typedef SWORD UCIParse; /* Parser Offset */
typedef UWORD UCISize; /* data size */
typedef SWORD UCIIndicator; /* data presence/NULL val indicator */
typedef UWORD UCICount; /* number of rows affected/fetched */
typedef enum
{
UCIUnDef, /* Initialisation default */
UCIBinary, /* Unformatted bytes */
UCILong = 3, /* Long Integer */
UCIChar = 5, /* C string */
UCIFloat = 7, /* IEEE extended precision float */
UCIPckdDecimal = 9 /* Binary Coded Decimal */
} UCIType;
typedef struct {
BITMAP
spares:(8*sizeof(BITMAP)-3), /*18758*/
printresult:1, /* 1 => This col is a Procedure print result *18758*/
colnullable:1, /* 1 => column is nullable */
colmultivalued:1; /* 1 => column is multi-valued */
} DESCLISTBITS;
#define COLNULLABLE desclistbits.colnullable
#define COLMULTIVALUED desclistbits.colmultivalued
#define PRINTRESULT desclistbits.printresult /*18758*/
typedef union
{
DESCLISTBITS desclistbits;
unsigned int desclistint;
} DESCLISTFLAGS;
typedef struct
{
DESCLISTFLAGS desclistflags;
int sqltype;
int precision;
int scale;
int displaysize;
int nullable;
STRING collabel;
int collength;
STRING colname;
STRING colowner;
STRING colqualifier;
int colsearchable;
STRING coltable;
STRING coltypename;
int colupdatable;
STRING colformat;
STRING colconv;
int colautoinc; /* 23637; support NEXT.AVAILABLE */
/*** This part for SequeLink operation ***/
int dbType; /* Internal database type */
UCIType SqlnkType; /* Type to deliver over transport */
UCISize Size; /* Size of SequeLink datum */
/*** Above part for SequeLink operation ***/
} UCIDescList;
/*******************************************
* Define DBMS id codes for the databases
* we support:
*******************************************/
#define DBMS_GENERIC 0
#define DBMS_ORACLE 1
#define DBMS_INFORMIX 2
#define DBMS_INGRES 3
#define DBMS_SYBASE 4
#define DBMS_DB2 5
#define DBMS_RDB 6
#define DBMS_UNIVERSE 7
#define DBMS_ODBC 8
#define DBMS_UNIDATA 9
/************************************
* Common defines for dealing with
* hstmt structures.
************************************/
#define MWSTMT hstmt->MWstmt
#define MWSTMTFLAGS hstmt->MWstmt.MWStmtFlags
#define HSTMTFLAGS hstmt->StmtFlags
#define SETERR(addr,err) {SetErr(&addr->error,err); return(SQL_ERROR);}
#define SETERRINFO(addr,err) {SetErr(&addr->error,err); return(SQL_SUCCESS_WITH_INFO);}
#define SETERRBAD(addr,err) {SetErr(&addr->error,err);\
udptr->fIndicator = SQL_BAD_DATA; return(SQL_ERROR);}
#define HSTMT_TRANS_ERR hstmt->ownerdbc->Dsnet->transport_err
#define HSTMT_ISTOUV hstmt->ownerdbc->dbcflags.istouv
#define HSTMT_ISTOUDT hstmt->ownerdbc->dbcflags.istoudt
#define HSTMT_ISTOUNI hstmt->ownerdbc->dbcflags.istouni
#define HSTMT_ISTOODBC hstmt->ownerdbc->dbcflags.istoodbc /* enf */
#define TRANSTYPE hdbc->MWdbc.Ttype
/*** Define local and remote transport constants ***/
#define LOCAL_TRANSPORT 0
#define REMOTE_TRANSPORT 1
#define LOCAL_CALL 2 /* 24411; nested call in localsrv */
/***************************************
* Defines for error message headers
***************************************/
#define NOERRTXT "Unable to retrieve server error text"
#define NOODBCTXT "Data source name not found, or ODBC is not installed on the system"
#define VENDORHDR "[Ardent]"
#define LBRACKET "["
#define RBRACKET "]"
#define UCIHDR "[UCI Client]"
#define ODBCHDR "[SQL Client]"
#define SQLINKHDR "[SequeLink] error code = "
#define SQLINKCONHDR "[SequeLink] Connect error, subcode: %d"
#define RPCHDR "[RPC] error code = "
#define RPCCONHDR "[RPC] Connect error, subcode: %d"
/*************************************
* Defines for UVSQLError flags
*************************************/
#define GET_DIAGNOSTICS 0x01 /* Tell UVSQLError that it is being called by
GetDiagnostics */
#define NO_HEADER 0x02 /* Tell UVSQLError not not include header info */
/****************************************
* Items required for operation with
* SequeLink middleware
****************************************/
#ifdef SQLINK
#ifdef ODBC_MAIN
SSPTransLitTab CodeTable[] =
{
{ "", (SSPTransLit)NULL }
};
#else
extern SSPTransLitTab CodeTable[];
#endif
#endif
/*** Define a structure used to keep track of each column of a row in
*** a result set.
***/
typedef struct
{
UDWORD offset; /* Offset of this column in data buffer */
UDWORD width; /* How big is this column's data */
UDWORD valcount; /* How many values this column has */
} PERCOL;
/*****************************************************************
* Define new structures to handle uniVerse database
*****************************************************************/
/*** For now, fix the sizes of fetch header and data buffer ***/
#define FETCH_HDR_SIZE 4800
#define FETCH_DATA_SIZE 16000
/*** Define a fetch header buffer structure ***/
typedef struct
{
UDWORD rowsofdata; /* Number of rows in data area */
UDWORD datasize; /* Amount of data in the buffer */
UDWORD moredata; /* 1=> there are more rows to be fetched */
UDWORD colentries; /* Number of PERCOL entries in the header */
} FETCHHDR;
/*** Define a structure used in fetching data. ***/
typedef struct
{
STRING fhdr; /* Where fetch header gets allocated */
STRING fdata; /* Address of fetch data buffer */
} FETCHCTRL;
/******************************
* Structures for middleware -
*
* Define a Middleware component
* for each of DBC and STMT and
* a middleware BITMAP for the
* mwstmt structure
******************************/
struct mwdbc {
UCIRefNum ConRef; /* Middleware server reference # */
UCIRefNum LogRefNum; /* Middleware login reference num */
UCIRefNum TXcursrefnum; /* Cursor used for TX control */
UCIRefNum Ttype; /* Transport type. 0 => local */
UCIParse TXparseoffset; /* Returned data source syntax error ptr */
int srvpid; /* UV: Server's PID number */
int cltuvversion; /* UV: client uniVerse version */
int srvuvversion; /* UV: server uniVerse version */
int cltuciversion; /* UV: client rev of UCI */
int cltmwversion; /* UV: Client's level of middleware support */
int srvmwversion; /* UV: Client's level of middleware support */
UDWORD txisomask; /* ODBC: Holds bits for which isolation
levels are supported */
UDWORD txdefisolvl; /* ODBC: holds default isolation level of driver */
};
struct mwstmtflags {
BITMAP
spares:(8*sizeof(BITMAP)-10), /*18758*/
mwcursoropen:1, /* 1 => midldeware cursor open */
binddefined:1, /* 1 => SELECT columns are defined */
pmarkdefined:1, /* 1 => marker variables are defined */
sqdescribe:1, /* 1 => SQnDescribe has been done */
sqexec:1, /* 1 => SQExec has been done */
sqassoc:1, /* 1 => SQAssociate done */
reassociate:1, /* 1 => SQAssociate before SQDefine */
cancelled:1, /* 1 => Cursor has been cancelled */
execinprog:1, /* 1 => Execute in progress at uv server */
fetcheod:1; /* 1 => End of data seen */
};
/**** Define a structure to represent the per column items in the header
**** block coming back from Fetch from uniVerse.
****/
typedef struct
{
int offset; /* Offset into data stream */
int width; /* Width of this column */
int nvalues; /* Number of values in cell */
} ColHdr;
struct mwstmt {
UCIRefNum CursRefNum; /* Cursor reference number */
UCIParse ParseOffset; /* Returned data source syntax error ptr */
int updcount; /* # updated rows Returned from SQExec */
int colcount; /* Returned from SQnDescribe */
int rowwidth; /* Total width of all row data + indicators */
int rowcount; /* # rows we can fetch at once */
int rowsfetched; /* # rows that came back from Fetch */
UWORD fetchisolevel; /* Iso level at which server fetched data */
UWORD fetchnestlevel; /* Nest level at which server fetched data */
FETCHCTRL fetchctrl; /* UV: control area for fetched data */
PERCOL *fhdrcolp; /* UV: pointer to per column entries */
struct mwstmtflags MWStmtFlags; /* Flags for mw STMT block */
UCIDescList (*desclist)[]; /* Pointers to Describe blocks */
};
/******************************
* Define HENV and HDBC states
* for state transitions
******************************/
#define STATE0 0
#define STATE1 1
#define STATE2 2
#define STATE3 3
#define STATE4 4
/******************************
* Define a structure to map
* a native error number to
* an ODBC error code
******************************/
struct errmapblk {
SDWORD natvcode;
char *odbcerr;
struct errmapblk *next;
};
/******************************************************
* Define a struct to hold how to map this data source's
* internal data types into our SQL types
******************************************************/
struct sqltype {
int sqltype; /* The valid SQL_type */
int dbtype; /* The data source internal code */
/* The type and length of data to
* request from the server. This comes from
* the syntax:
* SQLTYPE = SQL_type = dbtype (SSPtype,SSPlen)
*/
int SSPdatatype;
int SSPdatalen;
struct sqltype *next;
};
/******************************
* Define an Error structure
******************************/
struct errblk {
char *sqlstate; /* Holds ODBC state string */
SDWORD natvcode; /* Native DBMS error code */
SDWORD sqlcode; /* Code for SQLink error */
char *natvtxt; /* Native DBMS error text. Got in SQLError */
char *srvrtxt; /* Native error text..got in SQLConnect */
STRING hltext; /* High level returns malloc'ed string */
struct errblk *next; /* There may be more than one... */
};
/******************************
* Define numeric types for
* data structures and linking
******************************/
#define ENV_TYPE 21
#define DBC_TYPE 32
#define STMT_TYPE 43
#define ERR_TYPE 100
#define SYNONYM_TYPE 102
#define PMARKER_TYPE 104
#define BINDCOL_TYPE 106
#define ERRMAP_TYPE 107
#define SQLCODE_TYPE 108
/******************************
* Typedefs
******************************/
typedef struct errblk ERRBLK;
typedef struct sqltype SQLCODE;
typedef struct errmapblk ERRMAPBLK;
typedef struct env ENV;
typedef ENV *UHENV;
typedef struct dbc DBC;
typedef DBC *UHDBC;
typedef struct stmt STMT;
typedef STMT *UHSTMT;
typedef struct bindcol BINDCOL;
typedef struct pmarker PMARKER;
typedef UCIRETCODE (*CBFUNC)();
typedef struct synonym SYNONYM;
/******************************************************
* Define ALLOCADDR, which is simply a linked list
* of char *
******************************************************/
struct synonym {
char *datumaddr;
struct synonym *next;
};
/******************************************************
* BITMAP of status flags for all three structure types
******************************************************/
struct statusflags {
BITMAP
spares:(8*sizeof(BITMAP)-3),
is_local_connect:1, /* 1 => for @HENV */
nopasswd:1, /* 1 => no password is required to connect */
isuci:1; /* Environment setter is uci, not bci */
};
/******************************************************
* Define the ENVironment structure
******************************************************/
struct env {
int intype; /* Must contain ENV_TYPE for validity */
int state;
int refcnt;
SYNONYM *Synonym; /* Synonyms for this HENV */
CBFUNC Cbfunc;
struct statusflags statusflags;
ERRBLK *error;
ERRBLK *setdiag; /* Area to hold SET.DIAGNOSTICS blocks */
int rmid; /* Id we got when registering with TX mgr */
int dbccnt; /* Count of attached connect blocks */
DBC *dbchdr;
char *ucicfgfil; /* user (OLEDB) has explicit config file */
char **cfgstart; /* Start of config file for this env */
char **cfgtext; /* Text ptr to config file for this env */
HENV odhenv; /* Oddly, a REAL ODBC HENV! */
ENV *next;
};
/******************************************************
* DBC (Datbase Connection) flags bitmap
******************************************************/
struct dbcflags {
BITMAP
spares:((8*sizeof(BITMAP))-23),
scontime:1, /* 1 => SetConn overrode locale time */
sconnumeric:1, /* 1 => SetConn overrode locale numeric */
sconmonetary:1, /* 1 => SetConn overrode locale monetary */
sconctype:1, /* 1 => SetConn overrode locale ctype */
sconcollate:1, /* 1 => SetConn overrode locale collate */
empty_null:1, /* 1 => Map emptys to NULLS */
tx_private:1, /* 1 => Don't play with UV TX manager */
ignore:1, /* 1 => Ignore SQLink errors */
autocommit:1, /* 1 => Commit every statement */
txstarted:1, /* 1 => transaction has started */
odbc_precision:1, /* 1 => Use ODBC defs of Precision */
trunc_round:1, /* 0 => round results, 1 => truncate */
send_tround:1, /* 1 => Send truncated/rounded data */
scondateprec:1, /* 1 => SetConn overrorde date precision */
scondateform:1, /* 1 => SetConn overrode date format */
istouv:1, /* 1 => connection is to uniVerse */
istoudt:1, /* 1 => connection is to uniData */
istouni:1, /* 1 => connection is to uniVerse or uniData */
istoodbc:1, /* 1 => connection is to real ODBC */
nf1client:1, /* 1 => This client in NF1 mode */
nonumparams:1, /* 1 => ODBC driver doesn't support SQLNumParams */
senddevinfo:1, /* 1 => client is UCI on NT or client is
>94 UVODBC on NT to (UNIX/NT) server
0 => client is (UCI on UNIX) or (<95 UVODBC
on NT) or (UVODBC on UNIX) */
execinprog:1; /* 1 => Connection has an executing hstmt */
};
/* Define some option bits for ConnectOpts function. Some of these
* may find their way across the path to the server
*/
#define OPTS_EMPTY_NULL 1
#define OPTS_TX_PRIVATE 2
/******************************************************
* Define the network connection block for the data
* source. ss_tran_err will contain a transport
* sepecific status code.
******************************************************/
struct dsnet {
int netcode; /* Network code type */
UCIName hostname; /* Server name or IP address */
UCIName service; /* Name of service */
SSTXT transport_err; /* Will hold code for transport error */
};
/******************************************************
* Define the DBC database connection structure
******************************************************/
struct dbc {
int intype; /* Must contain DBC_TYPE for validity */
int state;
int refcnt;
SYNONYM *Synonym; /* Holds synonym list for this HDBC */
CBFUNC Cbfunc;
struct statusflags statusflags;
struct dbcflags dbcflags;
char *osuid; /* Userid for OS login */
char *ospwd; /* passwd for OS login */
char *dsname; /* Data source we're connected to */
char *driver; /* Generic name of db we're connected to */
struct dsdefs *Dsdefs; /* Pointer to block with source defaults */
struct dsnet *Dsnet; /* Ptr to network area for this server */
struct mwdbc MWdbc; /* Middleware block with connect stuff */
ERRBLK *error;
ERRBLK *setdiag; /* Area to hold SET.DIAGNOSTICS blocks */
ERRMAPBLK *errmap; /* Map table of native -> ODBC errors */
ENV *ownerenv; /* Owner ENV */
HDBC odhdbc; /* Oddly, A REAL ODBC HDBC */
DBC *next; /* Next DBC */
STMT *stmthdr; /* Pointer to statement blocks */
char *NLSmap; /* NLS map name */
char *NLSLCtime; /* NLS TIME locale */
char *NLSLCnumeric; /* NLS NUMERIC locale */
char *NLSLCmonetary; /* NLS MONETARY locale */
char *NLSLCctype; /* NLS CTYPE locale */
char *NLSLCcollate; /* NLS COLLATE locale */
int mrkseqnum; /* Sequence number for marker names */
int stmtcnt; /* Count of this connection's hstmts */
UWORD TXnestlevel; /* Counts BEGIN TX */
UWORD procisolevel; /* process isolation level set by SetConnOpt */
UWORD actisolevel; /* active isolation level set by SQLTransact */
char *macaddr; /* macaddr of UCI/UVODBC client */
char *devname; /* device name of UCI/UVODBC client */
char *devsubkey; /* device sub key given by user for licensing */
unsigned long ipaddr; /* IP address of UCI/UVODBC client */
int ardtuciclt; /* Ardent UCI client: UVODBC,UDODBC,OLEDB */
};
/* Define a common structure for flags for both pmarkers and bind cols
* We do this so that we can have maximum commonality between the
* two structures
*/
struct pmbcolflags {
BITMAP
spares:(8*sizeof(BITMAP)-11), /*18758*/
marker:1, /* 1 => This is a marker */
bindcol:1, /* 1 => This is a bound column */
userdefined:1, /* user has defined this column */
invalid:1, /* column is invalidated */
getdata:1, /* truncated data waiting */
badtype:1, /* Unsupported SQL data type */
truncated:1, /* 1 => SQLFetch saw truncated data */
bindmvcol:1, /* 1 => Column bound with BindMvCol */
bindmvparam:1, /* 1 => Parameter bound with BindMvParam */
inputparam:1, /* 1 => Input parameter */
outputparam:1; /* 1 => Output parameter */
};
/******************************************************
* BIND column structure
* One of these gets allocated for each SQLBind
* done on an STMT. The first part of the structure is
* IDENTICAL to the pmarker structure. LEAVE IT THAT WAY
******************************************************/
struct bindcol {
int icol; /* Column number. */
struct pmbcolflags Colflags;
PTR pval; /* Where to store final column data */
int sqltype; /* SQL type at the source */
SWORD dtype; /* data type to fetch into */
STRING strval; /* Area for incoming data */
SDWORD longval; /* place for incoming [long] integer */
double dblval; /* place for incoming float, double */
SDWORD valmax; /* Space available in pval */
SDWORD *pvalret; /* Where to put returned data length */
UCIIndicator indicator; /* Indicator variable for NULL */
C_ARRAY **carray; /* UCI: ptr to param/column object */
STRING getdata; /* UCI: place to save where we are for GetData */
SDWORD pcbValue; /* ODBC: Where actual col leength goes */
unsigned int fieldwidth; /* How wide is raw data for this field */
int charpad; /* If this is a char field gets 1 for null byte pad */
UDWORD precision; /* Precision according to SQL type */
char *TBCaddr; /* For BASIC...pointer to TBC item */
CBFUNC Cbfunc; /* Callback address for BindCol */
UCIDescList MWdesc; /* MW descriptor for this column */
uchar *rawdata; /* Pointer to raw data from server */
char *indicatordata; /* Pointer to indicator data */
BINDCOL *next; /* Link to next Bind column */
};
/******************************************************
* PMARKER structure for a parameter marker.
* Language module will fill this in and
* send it to UVSQLSetParam.
* The first part of the structure is IDENTICAL to the
* bindcol structure. LEAVE IT THAT WAY!
******************************************************/
struct pmarker {
int pnum; /* Marker number */
struct pmbcolflags pmarkflags;
PTR valaddr; /* Where incoming data is */
int sqltype; /* SQL type to convert to */
SWORD dtype; /* Data type going out */
STRING strval; /* Area for outgoing string data. */
SDWORD longval; /* place for outgoing [long] integer */
double dblval; /* place for outgoing float, double */
SDWORD valmax; /* Space available in valaddr */
SDWORD *vallen; /* Where length of data is */
UCIIndicator indicator; /* indicator variable for NULL */
C_ARRAY *carray; /* UCI: ptr to parameter/column object */
STRING getdata; /* Not used for marker. Here for case of
procedure ouput markers, which look like
bound columns in a lot of ways. */
SDWORD pcbValue; /* ODBC: Where actual col length goes */
char *name; /* Param name if dbms uses forms ':var' */
SWORD paramtype; /* Paramter type */
UDWORD prec; /* Precision value */
SWORD scale;
char *TBCaddr; /* For BASIC...pointer to TBC item */
CBFUNC Cbfunc; /* Callback address for Setparam */
UCIType sqlnktype; /* SQlink data type */
SDWORD *pcbvaluep; /* Pointer to array of pcbvalues for ParamOptions */
SDWORD allocsize; /* Holds amt space allocated for each value */
PMARKER *next; /* Link to next parmaeter */
};
/******************************************************
* STMT flags bitmap
******************************************************/
struct stmtflags {
BITMAP /* Meaning if bit is SET */
spares:(8*sizeof(BITMAP)-13),
paramoptions:1, /* SQLParamOptions issued 24411 */
ignore:1, /* If set, ignore SQLink errors */
badtype:1, /* A column has an illegal data type */
fetching:1, /* We're Fetching on this HSTMT */
destroy:1, /* Free hstmt and return INV_HANDLE */
prepared:1, /* Pepare was issued */
exectype:1, /* 1=>Direct, 0=>Execute */
descbok:1, /* Set when Describe is legal */
cursoropen:1, /* Cursor open..same as saying a result set
was created */
isacall:1, /* 1 => HSTMT is for a CALL */
isaselect:1, /* 1 => HSTMT is for a SELECT */
isadatam:1, /* 1 => HSTMT is for a INSERT/UPDATE/DELETE */
athstmt:1; /* 1 => This is an @HSTMT..DON"T DELETE IT! */
};
/***************************
* Define the STMT structure
***************************/
struct stmt {
int intype;
int state;
int refcnt;
SYNONYM *Synonym; /* Synonyms for this HSTMT */
CBFUNC Cbfunc; /* callback function. See BindCol, SetParam */
struct statusflags statusflags;
struct stmtflags StmtFlags;
struct mwstmt MWstmt; /* Middleware block for STMT struct */
char *insql; /* The SQL that came in */
char *outsql; /* SQL transformed by paramater markers */
ERRBLK *error;
ERRBLK *setdiag; /* Area to hold SET.DIAGNOSTICS blocks */
char *cursorname; /* Filled in if SetCursorName given */
UWORD maxuserbind; /* Max col number user bound */
UWORD bindcolcnt; /* # bound columns */
int fetchptr; /* Number of the row we'll get next */
BINDCOL *bindcols; /* List of bound columns */
UWORD paramcnt; /* Count of ? seen in sql */
UWORD resolvedinparams; /* Count of resolved input parameters */
UWORD resolvedoutparams; /* Count of resolved output parameters */
PMARKER *markers; /* List of parameter markers */
UWORD execnestlevel; /* Nest depth at which cursor was opened */
UWORD execisolevel; /* Iso level at which execute was done */
DBC *ownerdbc; /* Owning connect block */
HSTMT odhstmt; /* A REAL ODBC HSTMT for ODBC transport */
UDWORD paramrows_count; /* Count of parameter rows to do */
UDWORD paramrows_done; /* Count of parameter rows processed */
STMT *next; /* Next statement */
UDWORD *pirow; /* location to store rowcount if ParamOptions issued 24411 */
};
/******************************************************
* Define the dsdefs block, which contains defaults
* for each type of DBMS
******************************************************/
struct dsdflg {
BITMAP
spares:(8*sizeof(BITMAP)-4), /*18758*/
markername:1, /* Set if pmarkers use name */
descb4exec:1, /* Set if Describe valid before execute */
usetgitx:1, /* Set if we need to use TGI commit/rback */
txbehavior:1; /* 0=> Manual normal, 1=>Autocommit normal */ /*18758*/
};
struct attrbits { /* Bits for ColAttributes, describing */
BITMAP /* Which (if any) attributes this vendor */
spares:(8*sizeof(BITMAP)-11),
knowprecision:1, /* can supply for us. */
knownullable:1,
knowscale:1,
knowdspsize:1,
knowunsigned:1,
knowmoney:1,
knowupdate:1,
knowautoinc:1,
knowcase:1,
knowsearch:1,
knowtypename:1;
};
struct dsdefs {
int dbid; /* Code identifying each data source */
struct dsdflg Dsflags; /* Flag bits for this data source */
struct attrbits Attrbits; /* Bits for which Attributes this ds does */
int sspportnumber; /* port to use for connection */
int maxfetchbuff;
int maxfetchcols;
short maxchar; /* Max size of CHAR */
short maxvarchar; /* max size of varchar */
unsigned int maxlongvarchar;
short smintprec; /* precision for smallint,int,float,double */
short intprec;
short floatprec;
short realprec;
short dblprec;
unsigned int bigintprec; /* precision for big integers */
short dateprec; /* # digits in a dATE representation */
short svdateprec; /* saved (original) date precision */
short datefetch; /* amount to read from host for DATEs */
char *txstart; /* Text to begin a transaction */
char *txroll; /* Text to roll back transaction */
char *txcommit; /* Text to commit a tx */
char *dateform; /* Format of this DBMS date format */
char *svdateform; /* saved (original) date format */
char *account; /* use as schema, if Connect did not specify */
char *username; /* if OS_UID not specified, use this value */
int eodcode; /* source error code for no more data */
SQLCODE *Sqltypes; /* Ptr to list of mapped sql type codes */
};
extern UCIRETCODE UVSQLAllocConnect(), UVSQLAllocEnv(), UVSQLAllocStmt();
extern UCIRETCODE UVSQLError();
extern int SetErr();
/******************************************************
* Define various maxima for ODBC things
******************************************************/
#define MAX_CURSOR_NAME 18 /* Max cursor name length */
#define MAX_SQLINK_ROW 4050 /* Max for one SQLink row */
#define MAX_OPTION_TOKEN 128 /* Max size of a token in get_option() */
/*************************************************
* EXTERN refs to commonly used routines
*************************************************/
extern SDWORD UVaddsyn(),
Slink(),
UVdelsyn(),
Ulink(),
SetErrFull(),
SetErrFuller();
extern UCIRETCODE UVSQLFreeStmt();
extern void flush_errors();
/*************************************************
* EXTERN refs to the local server entry points
*************************************************/
EXTERN UCIRETCODE LS_SQAssociate();
EXTERN UCIRETCODE LS_SQBind();
EXTERN UCIRETCODE LS_SQCancel();
EXTERN UCIRETCODE LS_SQClose();
EXTERN UCIRETCODE LS_SQCommit();
EXTERN UCIRETCODE LS_SQConnect();
EXTERN UCIRETCODE LS_SQConnectOpts();
EXTERN UCIRETCODE LS_SQDefine();
EXTERN UCIRETCODE LS_SQnDescribe();
EXTERN UCIRETCODE LS_SQDisconnect();
EXTERN UCIRETCODE LS_SQErrorMessage();
EXTERN UCIRETCODE LS_SQExec();
EXTERN UCIRETCODE LS_SQFetch();
EXTERN UCIRETCODE LS_SQGetInfo();
EXTERN UCIRETCODE LS_SQLogoff();
EXTERN UCIRETCODE LS_SQLogon();
EXTERN UCIRETCODE LS_SQOpen();
EXTERN UCIRETCODE LS_SQOutParams();
EXTERN UCIRETCODE LS_SQRollback();
EXTERN UCIRETCODE LS_SQTXBegin();
EXTERN UCIRETCODE LS_SQDefBindExec();
/*************************************************
* EXTERN refs to the RPC client routines
*************************************************/
EXTERN UCIRETCODE CLT_SQAssociate();
EXTERN UCIRETCODE CLT_SQBind();
EXTERN UCIRETCODE CLT_SQCancel();
EXTERN UCIRETCODE CLT_SQClose();
EXTERN UCIRETCODE CLT_SQCommit();
EXTERN UCIRETCODE CLT_SQConnect();
EXTERN UCIRETCODE CLT_SQConnectOpts();
EXTERN UCIRETCODE CLT_SQDefine();
EXTERN UCIRETCODE CLT_SQnDescribe();
EXTERN UCIRETCODE CLT_SQDisconnect();
EXTERN UCIRETCODE CLT_SQErrorMessage();
EXTERN UCIRETCODE CLT_SQExec();
EXTERN UCIRETCODE CLT_SQFetch();
EXTERN UCIRETCODE CLT_SQGetInfo();
EXTERN UCIRETCODE CLT_SQLogoff();
EXTERN UCIRETCODE CLT_SQLogon();
EXTERN UCIRETCODE CLT_SQOpen();
EXTERN UCIRETCODE CLT_SQOutParams();
EXTERN UCIRETCODE CLT_SQRollback();
EXTERN UCIRETCODE CLT_SQTXBegin();
EXTERN UCIRETCODE CLT_SQDefBindExec();
#ifdef ODBC_MAIN
#define gentxt(sqlstate,tag,ODtxt) SSTXT tag = {sqlstate, ODtxt};
/*************************************************
* Define pointer to the local server routines.
* They will be initilaized for access to the
* local server. For the stand-alone UCI, the
* pointer will remain 0.
*************************************************/
UCIRETCODE (*LS_SQAssociatep)();
UCIRETCODE (*LS_SQBindp)();
UCIRETCODE (*LS_SQCancelp)();
UCIRETCODE (*LS_SQClosep)();
UCIRETCODE (*LS_SQCommitp)();
UCIRETCODE (*LS_SQConnectp)();
UCIRETCODE (*LS_SQConnectOptsp)();
UCIRETCODE (*LS_SQDefinep)();
UCIRETCODE (*LS_SQnDescribep)();
UCIRETCODE (*LS_SQDisconnectp)();
UCIRETCODE (*LS_SQErrorMessagep)();
UCIRETCODE (*LS_SQExecp)();
UCIRETCODE (*LS_SQFetchp)();
UCIRETCODE (*LS_SQGetInfop)();
UCIRETCODE (*LS_SQLogoffp)();
UCIRETCODE (*LS_SQLogonp)();
UCIRETCODE (*LS_SQOutParamsp)();
UCIRETCODE (*LS_SQOpenp)();
UCIRETCODE (*LS_SQRollbackp)();
UCIRETCODE (*LS_SQTXBeginp)();
UCIRETCODE (*LS_SQDefBindExecp)();
/****************************
* Configuration file stuff
***************************/
PUB_RO char _uvhome[] = "/.uvhome";
PUB_RO char _etc[] = "/etc/";
PUB_RO char _dot[] = "./";
PUB_RO char _odbc[] = "uv.odbc.config";
PUB_RO char _ucicfg[] = "uvodbc.config";
#else
#define gentxt(sqlstate,tag,ODtxt) extern SSTXT tag;
EXTERN UCIRETCODE (*LS_SQAssociatep)();
EXTERN UCIRETCODE (*LS_SQBindp)();
EXTERN UCIRETCODE (*LS_SQCancelp)();
EXTERN UCIRETCODE (*LS_SQClosep)();
EXTERN UCIRETCODE (*LS_SQCommitp)();
EXTERN UCIRETCODE (*LS_SQConnectp)();
EXTERN UCIRETCODE (*LS_SQConnectOptsp)();
EXTERN UCIRETCODE (*LS_SQDefinep)();
EXTERN UCIRETCODE (*LS_SQnDescribep)();
EXTERN UCIRETCODE (*LS_SQDisconnectp)();
EXTERN UCIRETCODE (*LS_SQErrorMessagep)();
EXTERN UCIRETCODE (*LS_SQExecp)();
EXTERN UCIRETCODE (*LS_SQFetchp)();
EXTERN UCIRETCODE (*LS_SQGetInfop)();
EXTERN UCIRETCODE (*LS_SQLogoffp)();
EXTERN UCIRETCODE (*LS_SQLogonp)();
EXTERN UCIRETCODE (*LS_SQOutParamsp)();
EXTERN UCIRETCODE (*LS_SQOpenp)();
EXTERN UCIRETCODE (*LS_SQRollbackp)();
EXTERN UCIRETCODE (*LS_SQTXBeginp)();
EXTERN UCIRETCODE (*LS_SQDefBindExecp)();
EXTERN char _uvhome[];
EXTERN char _etc[];
EXTERN char _dot[];
EXTERN char _odbc[];
EXTERN char _ucicfg[];
#endif
#include "GENTXT.h" /* Include file gernerated from UVOD_SSERR.h */
#endif /* UVODBC_H */