📄 info.c
字号:
/* These values can be NULL */ set_nullfield_int4(&tuple[2], pgtype_column_size(stmt, pgType, PG_STATIC, PG_STATIC)); set_nullfield_string(&tuple[3], pgtype_literal_prefix(stmt, pgType)); set_nullfield_string(&tuple[4], pgtype_literal_suffix(stmt, pgType)); set_nullfield_string(&tuple[5], pgtype_create_params(stmt, pgType)); if (1 < pgtcount) set_tuplefield_int2(&tuple[9], SQL_TRUE); else set_nullfield_int2(&tuple[9], pgtype_unsigned(stmt, pgType)); if (aunq_match == cnt) set_tuplefield_int2(&tuple[11], SQL_TRUE); else set_nullfield_int2(&tuple[11], pgtype_auto_increment(stmt, pgType)); set_nullfield_int2(&tuple[13], pgtype_min_decimal_digits(stmt, pgType)); set_nullfield_int2(&tuple[14], pgtype_max_decimal_digits(stmt, pgType));#if (ODBCVER >=0x0300) set_nullfield_int2(&tuple[15], pgtype_to_sqldesctype(stmt, pgType, PG_STATIC)); set_nullfield_int2(&tuple[16], pgtype_to_datetime_sub(stmt, pgType)); set_nullfield_int4(&tuple[17], pgtype_radix(stmt, pgType)); set_nullfield_int4(&tuple[18], 0);#endif /* ODBCVER */ } } }cleanup:#undef return /* * also, things need to think that this statement is finished so the * results can be retrieved. */ stmt->status = STMT_FINISHED; stmt->currTuple = -1; SC_set_rowset_start(stmt, -1, FALSE); SC_set_current_col(stmt, -1); if (stmt->internal) result = DiscardStatementSvp(stmt, result, FALSE); return result;}RETCODE SQL_APIPGAPI_GetFunctions( HDBC hdbc, SQLUSMALLINT fFunction, SQLUSMALLINT FAR * pfExists){ CSTR func = "PGAPI_GetFunctions"; ConnectionClass *conn = (ConnectionClass *) hdbc; ConnInfo *ci = &(conn->connInfo); mylog("%s: entering...%u\n", func, fFunction); if (fFunction == SQL_API_ALL_FUNCTIONS) {#if (ODBCVER < 0x0300) if (ci->drivers.lie) { int i; memset(pfExists, 0, sizeof(pfExists[0]) * 100); pfExists[SQL_API_SQLALLOCENV] = TRUE; pfExists[SQL_API_SQLFREEENV] = TRUE; for (i = SQL_API_SQLALLOCCONNECT; i <= SQL_NUM_FUNCTIONS; i++) pfExists[i] = TRUE; for (i = SQL_EXT_API_START; i <= SQL_EXT_API_LAST; i++) pfExists[i] = TRUE; } else#endif { memset(pfExists, 0, sizeof(pfExists[0]) * 100); /* ODBC core functions */ pfExists[SQL_API_SQLALLOCCONNECT] = TRUE; pfExists[SQL_API_SQLALLOCENV] = TRUE; pfExists[SQL_API_SQLALLOCSTMT] = TRUE; pfExists[SQL_API_SQLBINDCOL] = TRUE; pfExists[SQL_API_SQLCANCEL] = TRUE; pfExists[SQL_API_SQLCOLATTRIBUTES] = TRUE; pfExists[SQL_API_SQLCONNECT] = TRUE; pfExists[SQL_API_SQLDESCRIBECOL] = TRUE; /* partial */ pfExists[SQL_API_SQLDISCONNECT] = TRUE; pfExists[SQL_API_SQLERROR] = TRUE; pfExists[SQL_API_SQLEXECDIRECT] = TRUE; pfExists[SQL_API_SQLEXECUTE] = TRUE; pfExists[SQL_API_SQLFETCH] = TRUE; pfExists[SQL_API_SQLFREECONNECT] = TRUE; pfExists[SQL_API_SQLFREEENV] = TRUE; pfExists[SQL_API_SQLFREESTMT] = TRUE; pfExists[SQL_API_SQLGETCURSORNAME] = TRUE; pfExists[SQL_API_SQLNUMRESULTCOLS] = TRUE; pfExists[SQL_API_SQLPREPARE] = TRUE; /* complete? */ pfExists[SQL_API_SQLROWCOUNT] = TRUE; pfExists[SQL_API_SQLSETCURSORNAME] = TRUE; pfExists[SQL_API_SQLSETPARAM] = FALSE; /* odbc 1.0 */ pfExists[SQL_API_SQLTRANSACT] = TRUE; /* ODBC level 1 functions */ pfExists[SQL_API_SQLBINDPARAMETER] = TRUE; pfExists[SQL_API_SQLCOLUMNS] = TRUE; pfExists[SQL_API_SQLDRIVERCONNECT] = TRUE; pfExists[SQL_API_SQLGETCONNECTOPTION] = TRUE; /* partial */ pfExists[SQL_API_SQLGETDATA] = TRUE; pfExists[SQL_API_SQLGETFUNCTIONS] = TRUE; pfExists[SQL_API_SQLGETINFO] = TRUE; pfExists[SQL_API_SQLGETSTMTOPTION] = TRUE; /* partial */ pfExists[SQL_API_SQLGETTYPEINFO] = TRUE; pfExists[SQL_API_SQLPARAMDATA] = TRUE; pfExists[SQL_API_SQLPUTDATA] = TRUE; pfExists[SQL_API_SQLSETCONNECTOPTION] = TRUE; /* partial */ pfExists[SQL_API_SQLSETSTMTOPTION] = TRUE; pfExists[SQL_API_SQLSPECIALCOLUMNS] = TRUE; pfExists[SQL_API_SQLSTATISTICS] = TRUE; pfExists[SQL_API_SQLTABLES] = TRUE; /* ODBC level 2 functions */ pfExists[SQL_API_SQLBROWSECONNECT] = FALSE; if (PG_VERSION_GE(conn, 7.4)) pfExists[SQL_API_SQLCOLUMNPRIVILEGES] = FALSE; else pfExists[SQL_API_SQLCOLUMNPRIVILEGES] = FALSE; pfExists[SQL_API_SQLDATASOURCES] = FALSE; /* only implemented by * DM */ if (SUPPORT_DESCRIBE_PARAM(ci)) pfExists[SQL_API_SQLDESCRIBEPARAM] = TRUE; else pfExists[SQL_API_SQLDESCRIBEPARAM] = FALSE; /* not properly * implemented */ pfExists[SQL_API_SQLDRIVERS] = FALSE; /* only implemented by * DM */ pfExists[SQL_API_SQLEXTENDEDFETCH] = TRUE; pfExists[SQL_API_SQLFOREIGNKEYS] = TRUE; pfExists[SQL_API_SQLMORERESULTS] = TRUE; pfExists[SQL_API_SQLNATIVESQL] = TRUE; pfExists[SQL_API_SQLNUMPARAMS] = TRUE; pfExists[SQL_API_SQLPARAMOPTIONS] = TRUE; pfExists[SQL_API_SQLPRIMARYKEYS] = TRUE; if (PG_VERSION_LT(conn, 6.5)) pfExists[SQL_API_SQLPROCEDURECOLUMNS] = FALSE; else pfExists[SQL_API_SQLPROCEDURECOLUMNS] = TRUE; if (PG_VERSION_LT(conn, 6.5)) pfExists[SQL_API_SQLPROCEDURES] = FALSE; else pfExists[SQL_API_SQLPROCEDURES] = TRUE; pfExists[SQL_API_SQLSETPOS] = TRUE; pfExists[SQL_API_SQLSETSCROLLOPTIONS] = TRUE; /* odbc 1.0 */ pfExists[SQL_API_SQLTABLEPRIVILEGES] = TRUE;#if (ODBCVER >= 0x0300) if (0 == ci->updatable_cursors) pfExists[SQL_API_SQLBULKOPERATIONS] = FALSE; else pfExists[SQL_API_SQLBULKOPERATIONS] = TRUE;#endif /* ODBCVER */ } } else { if (ci->drivers.lie) *pfExists = TRUE; else { switch (fFunction) {#if (ODBCVER < 0x0300) case SQL_API_SQLALLOCCONNECT: *pfExists = TRUE; break; case SQL_API_SQLALLOCENV: *pfExists = TRUE; break; case SQL_API_SQLALLOCSTMT: *pfExists = TRUE; break;#endif /* ODBCVER */ case SQL_API_SQLBINDCOL: *pfExists = TRUE; break; case SQL_API_SQLCANCEL: *pfExists = TRUE; break;#if (ODBCVER >= 0x0300) case SQL_API_SQLCOLATTRIBUTE:#else case SQL_API_SQLCOLATTRIBUTES:#endif /* ODBCVER */ *pfExists = TRUE; break; case SQL_API_SQLCONNECT: *pfExists = TRUE; break; case SQL_API_SQLDESCRIBECOL: *pfExists = TRUE; break; /* partial */ case SQL_API_SQLDISCONNECT: *pfExists = TRUE; break;#if (ODBCVER < 0x0300) case SQL_API_SQLERROR: *pfExists = TRUE; break;#endif /* ODBCVER */ case SQL_API_SQLEXECDIRECT: *pfExists = TRUE; break; case SQL_API_SQLEXECUTE: *pfExists = TRUE; break; case SQL_API_SQLFETCH: *pfExists = TRUE; break;#if (ODBCVER < 0x0300) case SQL_API_SQLFREECONNECT: *pfExists = TRUE; break; case SQL_API_SQLFREEENV: *pfExists = TRUE; break;#endif /* ODBCVER */ case SQL_API_SQLFREESTMT: *pfExists = TRUE; break; case SQL_API_SQLGETCURSORNAME: *pfExists = TRUE; break; case SQL_API_SQLNUMRESULTCOLS: *pfExists = TRUE; break; case SQL_API_SQLPREPARE: *pfExists = TRUE; break; case SQL_API_SQLROWCOUNT: *pfExists = TRUE; break; case SQL_API_SQLSETCURSORNAME: *pfExists = TRUE; break;#if (ODBCVER < 0x0300) case SQL_API_SQLSETPARAM: *pfExists = FALSE; break; /* odbc 1.0 */ case SQL_API_SQLTRANSACT: *pfExists = TRUE; break;#endif /* ODBCVER */ /* ODBC level 1 functions */ case SQL_API_SQLBINDPARAMETER: *pfExists = TRUE; break; case SQL_API_SQLCOLUMNS: *pfExists = TRUE; break; case SQL_API_SQLDRIVERCONNECT: *pfExists = TRUE; break;#if (ODBCVER < 0x0300) case SQL_API_SQLGETCONNECTOPTION: *pfExists = TRUE; break; /* partial */#endif /* ODBCVER */ case SQL_API_SQLGETDATA: *pfExists = TRUE; break; case SQL_API_SQLGETFUNCTIONS: *pfExists = TRUE; break; case SQL_API_SQLGETINFO: *pfExists = TRUE; break;#if (ODBCVER < 0x0300) case SQL_API_SQLGETSTMTOPTION: *pfExists = TRUE; break; /* partial */#endif /* ODBCVER */ case SQL_API_SQLGETTYPEINFO: *pfExists = TRUE; break; case SQL_API_SQLPARAMDATA: *pfExists = TRUE; break; case SQL_API_SQLPUTDATA: *pfExists = TRUE; break;#if (ODBCVER < 0x0300) case SQL_API_SQLSETCONNECTOPTION: *pfExists = TRUE; break; /* partial */ case SQL_API_SQLSETSTMTOPTION: *pfExists = TRUE; break;#endif /* ODBCVER */ case SQL_API_SQLSPECIALCOLUMNS: *pfExists = TRUE; break; case SQL_API_SQLSTATISTICS: *pfExists = TRUE; break; case SQL_API_SQLTABLES: *pfExists = TRUE; break; /* ODBC level 2 functions */ case SQL_API_SQLBROWSECONNECT: *pfExists = FALSE; break; case SQL_API_SQLCOLUMNPRIVILEGES: *pfExists = FALSE; break; case SQL_API_SQLDATASOURCES: *pfExists = FALSE; break; /* only implemented by DM */ case SQL_API_SQLDESCRIBEPARAM: if (SUPPORT_DESCRIBE_PARAM(ci)) *pfExists = TRUE; else *pfExists = FALSE; break; /* not properly implemented */ case SQL_API_SQLDRIVERS: *pfExists = FALSE; break; /* only implemented by DM */ case SQL_API_SQLEXTENDEDFETCH: *pfExists = TRUE; break; case SQL_API_SQLFOREIGNKEYS: *pfExists = TRUE; break; case SQL_API_SQLMORERESULTS: *pfExists = TRUE; break; case SQL_API_SQLNATIVESQL: *pfExists = TRUE; break; case SQL_API_SQLNUMPARAMS: *pfExists = TRUE; break;#if (ODBCVER < 0x0300) case SQL_API_SQLPARAMOPTIONS: *pfExists = TRUE; break;#endif /* ODBCVER */ case SQL_API_SQLPRIMARYKEYS: *pfExists = TRUE; break; case SQL_API_SQLPROCEDURECOLUMNS: if (PG_VERSION_LT(conn, 6.5)) *pfExists = FALSE; else *pfExists = TRUE; break; case SQL_API_SQLPROCEDURES: if (PG_VERSION_LT(conn, 6.5)) *pfExists = FALSE; else *pfExists = TRUE; break; case SQL_API_SQLSETPOS: *pfExists = TRUE; break;#if (ODBCVER < 0x0300) case SQL_API_SQLSETSCROLLOPTIONS: *pfExists = TRUE; break; /* odbc 1.0 */#endif /* ODBCVER */ case SQL_API_SQLTABLEPRIVILEGES: *pfExists = TRUE; break;#if (ODBCVER >= 0x0300) case SQL_API_SQLBULKOPERATIONS: /* 24 */ case SQL_API_SQLALLOCHANDLE: /* 1001 */ case SQL_API_SQLBINDPARAM: /* 1002 */ case SQL_API_SQLCLOSECURSOR: /* 1003 */ case SQL_API_SQLENDTRAN: /* 1005 */ case SQL_API_SQLFETCHSCROLL: /* 1021 */ case SQL_API_SQLFREEHANDLE: /* 1006 */ case SQL_API_SQLGETCONNECTATTR: /* 1007 */ case SQL_API_SQLGETDESCFIELD: /* 1008 */ case SQL_API_SQLGETDIAGFIELD: /* 1010 */ case SQL_API_SQLGETDIAGREC: /* 1011 */ case SQL_API_SQLGETENVATTR: /* 1012 */ case SQL_API_SQLGETSTMTATTR: /* 1014 */ case SQL_API_SQLSETCONNECTATTR: /* 1016 */ case SQL_API_SQLSETDESCFIELD: /* 1017 */ case SQL_API_SQLSETENVATTR: /* 1019 */ case SQL_API_SQLSETSTMTATTR: /* 1020 */ *pfExists = TRUE; break; case SQL_API_SQLGETDESCREC: /* 1009 */ case SQL_API_SQLSETDESCREC: /* 1018 */ case SQL_API_SQLCOPYDESC: /* 1004 */ *pfExists = FALSE; break;#endif /* ODBCVER */ default: *pfExists = FALSE; break; } } } return SQL_SUCCESS;}static char *simpleCatalogEscape(const char *src, int srclen, int *result_len, const ConnectionClass *conn){ int i, outlen; const char *in; char *dest = NULL, escape_ch = CC_get_escape(conn); encoded_str encstr; if (result_len) *result_len = 0; if (!src || srclen == SQL_NULL_DATA) return dest; else if (srclen == SQL_NTS) srclen = (int) strlen(src); if (srclen <= 0) return dest;mylog("simple in=%s(%d)\n", src, srclen); encoded_str_constr(&encstr, conn->ccsc, src); dest = malloc(2 * srclen + 1); for (i = 0, in = src, outlen = 0; i < srclen; i++, in++) { encoded_nextchar(&encstr); if (ENCODE_STATUS(encstr) != 0) { dest[outlen++] = *in; continue; } if (LITERAL_QUOTE == *in || escape_ch == *in) dest[outlen++] = *in; dest[outlen++] = *in; } dest[outlen] = '\0'; if (result_len) *result_len = outlen;mylog("simple output=%s(%d)\n", dest, outlen); return dest;}/* * PostgreSQL needs 2 '\\' to escape '_' and '%'. */static char *adjustLikePattern(const char *src, int srclen, char escape_ch, int *result_len, const ConnectionClass *conn){ int i, outlen; const char *in; char *dest = NULL, escape_in_literal = CC_get_escape(conn); BOOL escape_in = FALSE; encoded_str encstr; if (result_len) *result_len = 0; if (!src || srclen == SQL_NULL_DATA) return dest; else if (srclen == SQL_NTS) srclen = (int) strlen(src); /* if (srclen <= 0) */ if (srclen < 0) return dest;mylog("adjust in=%.*s(%d)\n", srclen, src, srclen); encoded_str_constr(&encstr, conn->ccsc, src); dest = malloc(2 * srclen + 1); for (i = 0, in = src, outlen = 0; i < srclen; i++, in++) { encoded_nextchar(&encstr); if (ENCODE_STATUS(encstr) != 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -