Commit 8c3a7963 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Incorporate fixes from Date and Darwen, 1997.

Did not check the function declarations as carefully as the other parts,
 though all of the function names *do* match up with D&D.
parent 371a9d7a
......@@ -6,6 +6,10 @@
* This file is adapted for PostgreSQL
* from the SQL98 August 1994 draft standard.
* Thomas G. Lockhart 1999-06-16
*
* Updated from Date and Darwen, 1997, with some definitions
* not in the SQL3 August 1994 draft standard
* - Thomas Lockhart 1999-06-17
*/
/* API declaration data types */
......@@ -49,14 +53,17 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
#define SQL_NTS -3
#define SQL_NTSL -3L
/* maximum message length */
#define SQL_MAX_MESSAGE_LENGTH 255
/* maximum message length from Date and Darwen
* was 255 in the August 1994 draft standard
* - Thomas Lockhart 1999-06-17
*/
#define SQL_MAX_MESSAGE_LENGTH 512
/* maximum identifier length */
#define SQL_MAX_ID_LENGTH 18
/* date/time length constants */
/* add p+1 for time and timestamp if precision is nonzero
/* add p+1 for time and timestamp if precision is nonzero */
#define SQL_DATE_LEN 10
#define SQL_TIME_LEN 8
#define SQL_TIMESTAMP_LEN 19
......@@ -78,23 +85,44 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
#define SQL_ATTR_APP_PARAM_DESC 10011
#define SQL_ATTR_IMP_ROW_DESC 10012
#define SQL_ATTR_IMP_PARAM_DESC 10013
#define SQL_ATTR_CURSOR_SCROLLABLE -1
#define SQL_ATTR_CURSOR_SENSITIVITY -2
/* identifiers of fields in the SQL descriptor */
#define SQL_DESC_COUNT 1
#define SQL_DESC_TYPE 2
#define SQL_DESC_LENGTH 3
#define SQL_DESC_LENGTH_PTR 4
#define SQL_DESC_PRECISION 5
#define SQL_DESC_SCALE 6
#define SQL_DESC_DATETIME_INTERVAL_CODE 7
#define SQL_DESC_NULLABLE 8
#define SQL_DESC_INDICATOR_PTR 9
#define SQL_DESC_DATA_PTR 10
#define SQL_DESC_NAME 11
#define SQL_DESC_UNNAMED 12
#define SQL_DESC_ALLOC_TYPE 99
/* These ran 1-99 in the August 1994 draft standard
* - Thomas Lockhart 1999-06-17
*/
#define SQL_DESC_COUNT 1001
#define SQL_DESC_TYPE 1002
#define SQL_DESC_LENGTH 1003
#define SQL_DESC_OCTET_LENGTH_POINTER 1004
#define SQL_DESC_PRECISION 1005
#define SQL_DESC_SCALE 1006
#define SQL_DESC_DATETIME_INTERVAL_CODE 1007
#define SQL_DESC_NULLABLE 1008
#define SQL_DESC_INDICATOR_POINTER 1009
#define SQL_DESC_DATA_POINTER 1010
#define SQL_DESC_NAME 1011
#define SQL_DESC_UNNAMED 1012
#define SQL_DESC_OCTET_LENGTH 1013
#define SQL_DESC_DATETIME_INTERVAL_PRECISION 1014
#define SQL_DESC_COLLATION_CATALOG 1015
#define SQL_DESC_COLLATION_SCHEMA 1016
#define SQL_DESC_COLLATION_NAME 1017
#define SQL_DESC_CHARACTER_SET_CATALOG 1018
#define SQL_DESC_CHARACTER_SET_SCHEMA 1019
#define SQL_DESC_CHARACTER_SET_NAME 1020
#define SQL_DESC_PARAMETER_MODE 1021
#define SQL_DESC_PARAMETER_ORDINAL_POSITION 1022
#define SQL_DESC_PARAMETER_SPECIFIC_CATALOG 1023
#define SQL_DESC_PARAMETER_SPECIFIC_SCHEMA 1024
#define SQL_DESC_PARAMETER_SPECIFIC_NAME 1025
#define SQL_DESC_ALLOC_TYPE 1099
/* identifiers of fields in the diagnostics area */
/* Many new definitions since August 1994 draft standard
* - Thomas Lockhart 1999-06-17
*/
#define SQL_DIAG_RETURNCODE 1
#define SQL_DIAG_NUMBER 2
#define SQL_DIAG_ROW_COUNT 3
......@@ -107,8 +135,20 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
#define SQL_DIAG_CONNECTION_NAME 10
#define SQL_DIAG_SERVER_NAME 11
#define SQL_DIAG_DYNAMIC_FUNCTION_CODE 12
/* dynamic function codes returned in diagnostics area*/
#define SQL_DIAG_MORE 13
#define SQL_DIAG_CONDITION_NUMBER 14
#define SQL_DIAG_CONSTRAINT_CATALOG 15
#define SQL_DIAG_CONSTRAINT_SCHEMA 16
#define SQL_DIAG_CONSTRAINT_NAME 17
#define SQL_DIAG_CATALOG_NAME 18
#define SQL_DIAG_SCHEMA_NAME 19
#define SQL_DIAG_TABLE_NAME 20
#define SQL_DIAG_COLUMN_NAME 21
#define SQL_DIAG_CURSOR_NAME 22
#define SQL_DIAG_MESSAGE_LENGTH 23
#define SQL_DIAG_MESSAGE_OCTET_LENGTH 24
/* dynamic function codes returned in diagnostics area */
#define SQL_DIAG_ALTER_DOMAIN 3
#define SQL_DIAG_ALTER_TABLE 4
#define SQL_DIAG_CREATE_ASSERTION 6
......@@ -163,7 +203,22 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
/* One-parameter shortcuts for datetime data types */
#define SQL_TYPE_DATE 91
#define SQL_TYPE_TIME 92
#define SQL_TYPE_TIMESTAMP 93
#define SQL_TYPE_TIME_WITH_TIMEZONE 93
#define SQL_TYPE_TIMESTAMP 94
#define SQL_TYPE_TIMESTAMP_WITH_TIMEZONE 95
#define SQL_INTERVAL_DAY 103
#define SQL_INTERVAL_DAY_TO_HOUR 108
#define SQL_INTERVAL_DAY_TO_MINUTE 109
#define SQL_INTERVAL_DAY_TO_SECOND 110
#define SQL_INTERVAL_HOUR 104
#define SQL_INTERVAL_HOUR_TO_MINUTE 111
#define SQL_INTERVAL_HOUR_TO_SECOND 112
#define SQL_INTERVAL_MINUTE 105
#define SQL_INTERVAL_MINUTE_TO_SECOND 113
#define SQL_INTERVAL_MONTH 102
#define SQL_INTERVAL_SECOND 106
#define SQL_INTERVAL_YEAR 101
#define SQL_INTERVAL_YEAR_TO_MONTH 107
/* GetTypeInfo request for all data types */
#define SQL_ALL_TYPES 0
......@@ -183,23 +238,31 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
#define SQL_CODE_TIMESTAMP_ZONE 5
/* interval qualifier codes */
#define SQL_DAY 1
#define SQL_DAY_TO_HOUR 2
#define SQL_DAY_TO_MINUTE 3
#define SQL_DAY_TO_SECOND 4
#define SQL_HOUR 5
#define SQL_HOUR_TO_MINUTE 6
#define SQL_HOUR_TO_SECOND 7
#define SQL_MINUTE 8
#define SQL_MINUTE_TO_SECOND 9
#define SQL_MONTH 10
#define SQL_SECOND 11
#define SQL_YEAR 12
#define SQL_YEAR_TO_MONTH 13
#define SQL_DAY 3
#define SQL_DAY_TO_HOUR 8
#define SQL_DAY_TO_MINUTE 9
#define SQL_DAY_TO_SECOND 10
#define SQL_HOUR 4
#define SQL_HOUR_TO_MINUTE 11
#define SQL_HOUR_TO_SECOND 12
#define SQL_MINUTE 5
#define SQL_MINUTE_TO_SECOND 13
#define SQL_MONTH 2
#define SQL_SECOND 6
#define SQL_YEAR 1
#define SQL_YEAR_TO_MONTH 7
/* CLI option values */
#define SQL_FALSE 0
#define SQL_TRUE 1
#define SQL_NONSCROLLABLE 0
#define SQL_SCROLLABLE 1
/* parameter modes */
#define SQL_PARAM_MODE_IN 1
#define SQL_PARAM_MODE_OUT 4
#define SQL_PARAM_MODE_INOUT 2
#define SQL_PARAM_MODE_NONE 0
/* values of NULLABLE field in descriptor */
#define SQL_NO_NULLS 0
......@@ -243,9 +306,10 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
#define SQL_API_SQLBINDPARAM 1002
#define SQL_API_SQLCANCEL 5
#define SQL_API_SQLCLOSECURSOR 1003
#define SQL_API_SQLCOLATTRIBUTE 6
#define SQL_API_SQLCONNECT 7
#define SQL_API_SQLCOPYDESC 1004
#define SQL_API_SQLCOLATTRIBUTE 6
#define SQL_API_SQLDATASOURCES 57
#define SQL_API_SQLDESCRIBECOL 8
#define SQL_API_SQLDISCONNECT 9
#define SQL_API_SQLENDTRAN 1005
......@@ -253,11 +317,11 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
#define SQL_API_SQLEXECDIRECT 11
#define SQL_API_SQLEXECUTE 12
#define SQL_API_SQLFETCH 13
#define SQL_API_SQLFETCHSCROLL 1021
#define SQL_API_SQLFREECONNECT 14
#define SQL_API_SQLFREEENV 15
#define SQL_API_SQLFREEHANDLE 1006
#define SQL_API_SQLFREESTMT 16
#define SQL_API_SQLFUNCTIONS 44
#define SQL_API_SQLGETCONNECTATTR 1007
#define SQL_API_SQLGETCURSORNAME 17
#define SQL_API_SQLGETDATA 43
......@@ -266,6 +330,7 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
#define SQL_API_SQLGETDIAGFIELD 1010
#define SQL_API_SQLGETDIAGREC 1011
#define SQL_API_SQLGETENVATTR 1012
#define SQL_API_SQLGETFUNCTIONS 44
#define SQL_API_SQLGETINFO 45
#define SQL_API_SQLGETSTMTATTR 1014
#define SQL_API_SQLGETTYPEINFO 47
......@@ -273,9 +338,9 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
#define SQL_API_SQLPARAMDATA 48
#define SQL_API_SQLPREPARE 19
#define SQL_API_SQLPUTDATA 49
#define SQL_API_SQLRELEASEENV 1015
#define SQL_API_SQLRELEASEENV 1015 /* Obsolete? */
#define SQL_API_SQLROWCOUNT 20
#define SQL_API_SQLSCROLLFETCH 1021
#define SQL_API_SQLSCROLLFETCH 1021 /* Obsolete? */
#define SQL_API_SQLSETCONNECTATTR 1016
#define SQL_API_SQLSETCURSORNAME 21
#define SQL_API_SQLSETDESCFIELD 1017
......@@ -284,17 +349,123 @@ typedef SQLINTEGER SQLHDESC; /* descriptor handle */
#define SQL_API_SQLSETSTMTATTR 1020
/* information requested by GetInfo */
#define SQL_MAX_DRIVER_CONNECTIONS 0
#define SQL_MAX_RESULT_SETS 1
#define SQL_MAXIMUM_DRIVER_CONNECTIONS 0
#define SQL_MAXIMUM_CONCURRENT_ACTIVITIES 1
#define SQL_DATA_SOURCE_NAME 2
#define SQL_FETCH_DIRECTION 8
#define SQL_SERVER_NAME 13
#define SQL_DBMS_NAME 17
#define SQL_DBMS_VER 18
#define SQL_MAX_COLUMN_NAME_LEN 30
#define SQL_MAX_CURSOR_NAME_LEN 31
#define SQL_MAX_TABLE_NAME_LEN 35
#define SQL_DBMS_VERSION 18
#define SQL_CURSOR_COMMIT_BEHAVIOR 23
#define SQL_DATA_SOURCE_READ_ONLY 25
#define SQL_DEFAULT_TRANSACTION_ISOLATION 26
#define SQL_IDENTIFIER_CASE 28
#define SQL_MAXIMUM_COLUMN_NAME_LENGTH 30
#define SQL_MAXIMUM_CURSOR_NAME_LENGTH 31
#define SQL_MAXIMUM_SCHEMA_NAME_LENGTH 32
#define SQL_MAXIMUM_CATALOG_NAME_LENGTH 34
#define SQL_MAXIMUM_TABLE_NAME_LENGTH 35
#define SQL_SCROLL_CONCURRENCY 43
#define SQL_TRANSACTION_CAPABLE 46
#define SQL_USER_NAME 47
#define SQL_TRANSACTION_ISOLATION_OPTION 72
#define SQL_INTEGRITY 73
#define SQL_GETDATA_EXTENSIONS 81
#define SQL_NULL_COLLATION 85
#define SQL_ALTER_TABLE 86
#define SQL_ORDER_BY_COLUMNS_IN_SELECT 90
#define SQL_SPECIAL_CHARACTERS 94
#define SQL_MAXIMUM_COLUMNS_IN_GROUP_BY 97
#define SQL_MAXIMUM_COLUMNS_IN_ORDER_BY 99
#define SQL_MAXIMUM_COLUMNS_IN_SELECT 100
#define SQL_MAXIMUM_COLUMNS_IN_TABLE 101
#define SQL_MAXIMUM_STATEMENT_LENGTH 105
#define SQL_MAXIMUM_TABLES_IN_SELECT 106
#define SQL_MAXIMUM_USER_NAME_LENGTH 107
#define SQL_OUTER_JOIN_CAPABILITIES 115
#define SQL_CURSOR_SENSITIVITY 10001
#define SQL_DESCRIBE_PARAMETER 10002
#define SQL_CATALOG_NAME 10003
#define SQL_COLLATING_SEQUENCE 10004
#define SQL_MAXIMUM_IDENTIFIER_LENGTH 10005
/* S-resource attribute values for cursor sensitivity */
#define SQL_UNSPECIFIED 0x00000000L
#define SQL_INSENSITIVE 0x00000001L
/* null handle used when allocating HENV */
#define SQL_NULL_HANDLE 0L
/* SQL_ALTER_TABLE bitmasks */
#define SQL_AT_ADD_COLUMN 0x00000001L
#define SQL_AT_DROP_COLUMN 0x00000002L
#define SQL_AT_ALTER_COLUMN 0x00000004L
#define SQL_AT_ADD_CONSTRAINT 0x00000008L
#define SQL_AT_DROP_CONSTRAINT 0x00000010L
/* SQL_CURSOR_COMMIT_BEHAVIOR values */
#define SQL_CB_DELETE 0
#define SQL_CB_CLOSE 1
#define SQL_CB_PRESERVE 2
/* SQL_FETCH_DIRECTION bitmasks */
#define SQL_FD_FETCH_NEXT 0x00000001L
#define SQL_FD_FETCH_FIRST 0x00000002L
#define SQL_FD_FETCH_LAST 0x00000004L
#define SQL_FD_FETCH_PRIOR 0x00000008L
#define SQL_FD_FETCH_ABSOLUTE 0x00000010L
#define SQL_FD_FETCH_RELATIVE 0x00000020L
/* SQL_GETDATA_EXTENSIONS bitmasks */
#define SQL_GD_ANY_COLUMN 0x00000001L
#define SQL_FD_ANY_ORDER 0x00000002L
/* SQL_IDENTIFIER_CASE values */
#define SQL_IC_UPPER 1
#define SQL_IC_LOWER 2
#define SQL_IC_SENSITIVE 3
#define SQL_IC_MIXED 4
/* SQL_IDENTIFIER_CASE values */
#define SQL_NC_HIGH 1
#define SQL_NC_LOW 2
/* SQL_OUTER_JOIN_CAPABILITIES bitmasks */
#define SQL_OUTER_JOIN_LEFT 0x00000001L
#define SQL_OUTER_JOIN_RIGHT 0x00000002L
#define SQL_OUTER_JOIN_FULL 0x00000004L
#define SQL_OUTER_JOIN_NESTED 0x00000008L
#define SQL_OUTER_JOIN_NOT_ORDERED 0x00000010L
#define SQL_OUTER_JOIN_INNER 0x00000020L
#define SQL_OUTER_JOIN_ALL_COMPARISION_OPS 0x00000040L
/* SQL_SCROLL_CONCURRENCY bitmasks */
#define SQL_SCCO_READ_ONLY 0x00000001L
#define SQL_SCCO_LOCK 0x00000002L
#define SQL_SCCO_OPT_ROWVER 0x00000004L
#define SQL_SCCO_OPT_VALUES 0x00000008L
/* SQL_IDENTIFIER_CASE values */
#define SQL_TC_NONE 0
#define SQL_TC_DML 1
#define SQL_TC_ALL 2
#define SQL_TC_DDL_COMMIT 3
#define SQL_TC_DDL_IGNORE 4
/* SQL_TRANSACTION_ISOLATION bitmasks */
#define SQL_TRANSACTION_READ_UNCOMMITTED 0x00000001L
#define SQL_TRANSACTION_READ_COMMITTED 0x00000002L
#define SQL_TRANSACTION_READ_REPEATABLE_READ 0x00000004L
#define SQL_TRANSACTION_READ_SERIALIZABLE 0x00000008L
#define SQL_TRANSACTION_READ_UNCOMMITTED 0x00000001L
#define SQL_TRANSACTION_READ_UNCOMMITTED 0x00000001L
#define SQL_FD_FETCH_NEXT 0x00000001L
/* CLI function signatures */
SQLRETURN SQLAllocConnect(SQLHENV EnvironmentHandle,
SQLHDBC *ConnectionHandle);
......@@ -304,7 +475,6 @@ SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType,
SQLINTEGER InputHandle,
SQLINTEGER *OutputHandle);
SQLRETURN SQLAllocStmt(SQLHDBC ConnectionHandle,
SQLSTMT *StatementHandle);
......@@ -328,7 +498,7 @@ SQLRETURN SQLCancel(SQLHSTMT StatementHandle);
SQLRETURN SQLCloseCursor(SQLHSTMT StatementHandle);
SQLRETURN SQLColAttribute(SQLHENV StatementHandle,
SQLRETURN SQLColAttribute(SQLHSTMT StatementHandle,
SQLSMALLINT ColumnNumber,
SQLSMALLINT FieldIdentifier,
SQLCHAR *CharacterAttribute,
......@@ -336,7 +506,6 @@ SQLRETURN SQLColAttribute(SQLHENV StatementHandle,
SQLINTEGER *AttributetLength,
SQLINTEGER *NumericAttribute);
SQLRETURN SQLConnect(SQLHDBC ConnectionHandle,
SQLCHAR *ServerName,
SQLSMALLINT NameLength1,
......@@ -345,10 +514,18 @@ SQLRETURN SQLConnect(SQLHDBC ConnectionHandle,
SQLCHAR *Authentication,
SQLSMALLINT NameLength3);
SQLRETURN SQLCopyDesc(SQLHDESC SourceDescHandle,
SQLHDESC TargetDescHandle);
SQLRETURN SQLDataSources(SQLHENV EnvironmentHandle,
SQLSMALLINT Direction,
SQLCHAR *ServerName,
SQLSMALLINT BufferLength1,
SQLSMALLINT *NameLength1,
SQLCHAR *Description,
SQLSMALLINT BufferLength2,
SQLSMALLINT *NameLength2);
SQLRETURN SQLDescribeCol(SQLHSTMT StatementHandle,
SQLSMALLINT ColumnNumber,
SQLCHAR *ColumnName,
......@@ -378,11 +555,14 @@ SQLRETURN SQLExecDirect(SQLHSTMT StatementHandle,
SQLCHAR *StatementText,
SQLSMALLINT StringLength);
SQLRETURN SQLExecute(SQLHSTMT StatementHandle);
SQLRETURN SQLFetch(SQLHSTMT StatementHandle);
SQLRETURN SQLFetchScroll(SQLHSTMT StatementHandle,
SQLSMALLINT FetchOrientation,
SQLINTEGER FetchOffset);
SQLRETURN SQLFreeConnect(SQLHDBC ConnectionHandle);
SQLRETURN SQLFreeEnv(SQLHENV EnvironmentHandle);
......@@ -398,7 +578,6 @@ SQLRETURN SQLGetConnectAttr(SQLHDBC ConnectionHandle,
SQLINTEGER BufferLength,
SQLINTEGER *StringLength);
SQLRETURN SQLGetCursorName(SQLHSTMT StatementHandle,
SQLCHAR *CursorName,
SQLSMALLINT BufferLength,
......@@ -411,19 +590,6 @@ SQLRETURN SQLGetData(SQLHSTMT StatementHandle,
SQLINTEGER BufferLength,
SQLINTEGER *IndicatorValue);
SQLRETURN SQLGetFunctions(SQLHDBC ConnectionHandle,
SQLSMALLINT FunctionId,
SQLSMALLINT *Supported);
SQLRETURN SQLGetInfo(SQLHDBC ConnectionHandle,
SQLSMALLINT InfoType,
SQLPOINTER InfoValue,
SQLSMALLINT BufferLength,
SQLSMALLINT *StringLength);
SQLRETURN SQLGetTypeInfo(SQLHSTMT StatementHandle,
SQLSMALLINT DataType);
SQLRETURN SQLGetDescField(SQLHDESC DescriptorHandle,
SQLSMALLINT RecordNumber,
SQLSMALLINT FieldIdentifier,
......@@ -467,13 +633,24 @@ SQLRETURN SQLGetEnvAttr(SQLHENV EnvironmentHandle,
SQLINTEGER BufferLength,
SQLINTEGER *StringLength);
SQLRETURN SQLGetFunctions(SQLHDBC ConnectionHandle,
SQLSMALLINT FunctionId,
SQLSMALLINT *Supported);
SQLRETURN SQLGetInfo(SQLHDBC ConnectionHandle,
SQLSMALLINT InfoType,
SQLPOINTER InfoValue,
SQLSMALLINT BufferLength,
SQLSMALLINT *StringLength);
SQLRETURN SQLGetStmtAttr(SQLHSTMT StatementHandle,
SQLINTEGER Attribute,
SQLPOINTER Value,
SQLINTEGER BufferLength,
SQLINTEGER *StringLength);
SQLRETURN SQLLanguages(SQLHSTMT StatementHandle);
SQLRETURN SQLGetTypeInfo(SQLHSTMT StatementHandle,
SQLSMALLINT DataType);
SQLRETURN SQLNumResultCols(SQLHSTMT StatementHandle,
SQLINTEGER *ColumnCount);
......@@ -490,15 +667,9 @@ SQLRETURN SQLPutData(SQLHSTMT StatementHandle,
SQLPOINTER Data,
SQLINTEGER StringLength);
SQLRETURN SQLReleaseEnv(SQLHENV EnvironmentHandle);
SQLRETURN SQLRowCount(SQLHSTMT StatementHandle,
SQLINTEGER *RowCount);
SQLRETURN SQLScrollFetch(SQLHSTMT StatementHandle,
SQLINTEGER FetchOrientation,
SQLINTEGER FetchOffset);
SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle,
SQLINTEGER AttributeCursorName,
SQLPOINTER Value,
......@@ -533,3 +704,16 @@ SQLRETURN SQLSetStmtAttr(SQLHSTMT StatementHandle,
SQLINTEGER Attribute,
SQLPOINTER Value,
SQLINTEGER StringLength);
/* These are in SQL3 from August 1994
* but not in Date and Darwen, 1997
* - Thomas Lockhart 1999-06-17
SQLRETURN SQLLanguages(SQLHSTMT StatementHandle);
SQLRETURN SQLReleaseEnv(SQLHENV EnvironmentHandle);
SQLRETURN SQLScrollFetch(SQLHSTMT StatementHandle,
SQLINTEGER FetchOrientation,
SQLINTEGER FetchOffset);
*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment