NCBI C++ ToolKit
|
#include <config.h>
#include <stdarg.h>
#include <freetds/time.h>
#include <assert.h>
#include <stdio.h>
#include <freetds/tds.h>
#include <freetds/thread.h>
#include <freetds/convert.h>
#include <freetds/string.h>
#include <replacements.h>
#include <sybfront.h>
#include <sybdb.h>
#include <syberror.h>
#include <dblib.h>
Go to the source code of this file.
Go to the SVN repository for this file.
Classes | |
struct | col_t |
struct | KEY_T |
struct | agg_t |
struct | metadata_t |
struct | pivot_t |
struct | name_t |
Macros | |
#define | TDS_FIND(k, b, c) tds_find(k, b, sizeof(b)/sizeof(b[0]), sizeof(b[0]), c) |
#define | TEST_MALLOC(dest, type) {if (!(dest = (type*)calloc(1, sizeof(type)))) goto Cleanup;} |
#define | TEST_CALLOC(dest, type, n) {if (!(dest = (type*)calloc((n), sizeof(type)))) goto Cleanup;} |
#define | tds_alloc_column() ((TDSCOLUMN*) calloc(1, sizeof(TDSCOLUMN))) |
Typedefs | |
typedef bool(* | compare_func) (const void *, const void *) |
typedef struct KEY_T | KEY_T |
typedef struct agg_t | AGG_T |
typedef struct pivot_t | PIVOT_T |
Variables | |
static PIVOT_T * | pivots = NULL |
static size_t | npivots = 0 |
static const struct name_t | names [] |
Definition at line 623 of file dbpivot.c.
References assert, col_equal(), agg_t::col_key, i, KEY_T::keys, KEY_T::nkeys, and agg_t::row_key.
Referenced by dbpivot().
Definition at line 615 of file dbpivot.c.
References col_free(), agg_t::col_key, key_free(), agg_t::row_key, and agg_t::value.
Referenced by dbpivot().
Definition at line 574 of file dbpivot.c.
References assert, col_equal(), agg_t::col_key, i, KEY_T::keys, KEY_T::nkeys, NULL, agg_t::row_key, and col_t::type.
Referenced by dbnextrow_pivoted().
|
static |
Definition at line 657 of file dbpivot.c.
References tds_result_info::columns, NULL, tds_result_info::num_cols, tds_result_info::ref_count, tds_result_info::row_size, tds_alloc_column, tds_free_results, TEST_CALLOC, and TEST_MALLOC.
Referenced by reinit_results().
Definition at line 424 of file dbpivot.c.
References assert, FLT8BIND, INTBIND, NTBSTRINGBIND, REALBIND, SMALLBIND, SYBBINARY, SYBBIT, SYBBITN, SYBCHAR, SYBDATETIME, SYBDATETIME4, SYBDATETIMN, SYBDECIMAL, SYBFLT8, SYBFLTN, SYBIMAGE, SYBINT1, SYBINT2, SYBINT4, SYBINTN, SYBMONEY, SYBMONEY4, SYBMONEYN, SYBNTEXT, SYBNUMERIC, SYBREAL, SYBTEXT, SYBVARBINARY, SYBVARCHAR, SYBVOID, and TINYBIND.
Referenced by dbpivot(), select_rows(), and test().
Definition at line 183 of file dbpivot.c.
References assert, col_t::data, col_t::f, col_t::i, NULL, col_t::r, col_t::s, col_t::si, SYBBINARY, SYBBIT, SYBBITN, SYBCHAR, SYBDATETIME, SYBDATETIME4, SYBDATETIMN, SYBDECIMAL, SYBFLT8, SYBFLTN, SYBIMAGE, SYBINT1, SYBINT2, SYBINT4, SYBINTN, SYBMONEY, SYBMONEY4, SYBMONEYN, SYBNTEXT, SYBNUMERIC, SYBREAL, SYBTEXT, SYBVARBINARY, SYBVARCHAR, SYBVOID, col_t::ti, and col_t::type.
Referenced by dbnextrow_pivoted(), and dbpivot().
Definition at line 276 of file dbpivot.c.
References assert, col_t::len, NULL, col_t::null_indicator, col_t::s, and tds_new.
Definition at line 132 of file dbpivot.c.
References assert, pc1, pc2, util::strncmp(), SYBBINARY, SYBBIT, SYBBITN, SYBCHAR, SYBDATETIME, SYBDATETIME4, SYBDATETIMN, SYBDECIMAL, SYBFLT8, SYBFLTN, SYBIMAGE, SYBINT1, SYBINT2, SYBINT4, SYBINTN, SYBMONEY, SYBMONEY4, SYBMONEYN, SYBNTEXT, SYBNUMERIC, SYBREAL, SYBTEXT, SYBVARBINARY, SYBVARCHAR, SYBVOID, and true.
Referenced by agg_equal(), agg_next(), and key_equal().
Definition at line 125 of file dbpivot.c.
References free(), and col_t::s.
Referenced by agg_free(), and key_free().
Definition at line 93 of file dbpivot.c.
References assert, infer_col_type(), col_t::len, NULL, col_t::s, SYBCHAR, SYBDATETIME, SYBDATETIME4, SYBDATETIMN, SYBNTEXT, SYBTEXT, SYBVARCHAR, TDS_INVALID_TYPE, tds_new, and col_t::type.
Referenced by dbpivot().
Definition at line 295 of file dbpivot.c.
References assert, col_t::null_indicator, and true.
Referenced by dbnextrow_pivoted(), dbpivot_count(), dbpivot_max(), dbpivot_min(), and dbpivot_sum().
Definition at line 810 of file dbpivot.c.
References _DB_RES_NEXT_RESULT, agg_next(), assert, tds_column::bcp_terminator, col_buffer(), agg_t::col_key, col_null(), tds_column::column_bindlen, tds_column::column_bindtype, tds_column::column_cur_size, tds_column::column_data, tds_column::column_nullbind, tds_column::column_size, tds_column::column_type, tds_column::column_varaddr, tds_result_info::columns, copy_data_to_host_var, dbgetnull, dbproc, tds_dblib_dbprocess::dbresults_state, i, key_cpy(), KEY_T::keys, col_t::len, NO_MORE_ROWS, pivot_t::nout, NULL, tds_result_info::num_cols, pivot_t::output, output, REG_ROW, tds_socket::res_info, agg_t::row_key, col_t::si, TDS_DBG_ERROR, TDS_DBG_FUNC, tds_find(), tds_dblib_dbprocess::tds_socket, tdsdump_log, col_t::ti, col_t::type, and agg_t::value.
Referenced by dbnextrow().
RETCODE dbpivot | ( | DBPROCESS * | dbproc, |
int | nkeys, | ||
int * | keys, | ||
int | ncols, | ||
int * | cols, | ||
DBPIVOT_FUNC | func, | ||
int | val | ||
) |
Pivot the rows, creating a new resultset.
Call dbpivot() immediately after dbresults(). It calls dbnextrow() as long as it returns REG_ROW, transforming the results into a cross-tab report. dbpivot() modifies the metadata such that DB-Library can be used tranparently: retrieve the rows as usual with dbnumcols(), dbnextrow(), etc.
@dbproc, our old friend @nkeys the number of left-edge columns to group by @keys an array of left-edge columns to group by @ncols the number of top-edge columns to group by @cols an array of top-edge columns to group by @func the aggregation function to use @val the number of the column to which @func is applied
Definition at line 926 of file dbpivot.c.
References _DB_RES_RESULTSET_EMPTY, _DB_RES_RESULTSET_ROWS, pivot_t::across, agg_equal(), agg_free(), assert, bind_type(), buffer, metadata_t::col, col_buffer(), col_cpy(), col_init(), agg_t::col_key, dbbind(), dbcollen(), dbcolname(), dbcoltype(), dbnextrow(), dbnullbind(), dbperror, pivot_t::dbproc, dbproc, tds_dblib_dbprocess::dbresults_state, pivot_t::dbresults_state, exit(), FAIL, i, input(), key_cpy(), key_equal(), key_free(), KEY_T::keys, len, make_col_name(), pivot_t::nacross, metadata_t::name, names, pivot_t::nout, npivots, NULL, pivot_t::output, P, metadata_t::pacross, pivot_key_equal(), pivots, REG_ROW, reinit_results(), agg_t::row_key, pivot_t::status, strdup, SUCCEED, SYBEMEM, SYBFLT8, TDS_DBG_FUNC, tds_find(), tds_new0, TDS_RESIZE, tds_dblib_dbprocess::tds_socket, tdsdump_log, val, and agg_t::value.
Definition at line 1120 of file dbpivot.c.
References assert, col_null(), col_t::data, col_t::i, SYBINT4, and col_t::type.
DBPIVOT_FUNC dbpivot_lookup_name | ( | const char | name[] | ) |
Definition at line 1317 of file dbpivot.c.
References n, name_t::name, name_equal(), names, NULL, and TDS_FIND.
Definition at line 1244 of file dbpivot.c.
References assert, col_null(), col_t::data, col_t::f, col_t::i, col_t::r, col_t::si, SYBBINARY, SYBBIT, SYBBITN, SYBCHAR, SYBDATETIME, SYBDATETIME4, SYBDATETIMN, SYBDECIMAL, SYBFLT8, SYBFLTN, SYBIMAGE, SYBINT1, SYBINT2, SYBINT4, SYBINTN, SYBMONEY, SYBMONEY4, SYBMONEYN, SYBNTEXT, SYBNUMERIC, SYBREAL, SYBTEXT, SYBVARBINARY, SYBVARCHAR, SYBVOID, TDS_DBG_INFO1, tdsdump_log, col_t::ti, and col_t::type.
Definition at line 1188 of file dbpivot.c.
References assert, col_null(), col_t::data, col_t::f, col_t::i, col_t::r, col_t::si, SYBBINARY, SYBBIT, SYBBITN, SYBCHAR, SYBDATETIME, SYBDATETIME4, SYBDATETIMN, SYBDECIMAL, SYBFLT8, SYBFLTN, SYBIMAGE, SYBINT1, SYBINT2, SYBINT4, SYBINTN, SYBMONEY, SYBMONEY4, SYBMONEYN, SYBNTEXT, SYBNUMERIC, SYBREAL, SYBTEXT, SYBVARBINARY, SYBVARCHAR, SYBVOID, TDS_DBG_INFO1, tdsdump_log, col_t::ti, and col_t::type.
Definition at line 1132 of file dbpivot.c.
References assert, col_null(), col_t::data, col_t::f, col_t::i, col_t::r, col_t::si, SYBBINARY, SYBBIT, SYBBITN, SYBCHAR, SYBDATETIME, SYBDATETIME4, SYBDATETIMN, SYBDECIMAL, SYBFLT8, SYBFLTN, SYBIMAGE, SYBINT1, SYBINT2, SYBINT4, SYBINTN, SYBMONEY, SYBMONEY4, SYBMONEYN, SYBNTEXT, SYBNUMERIC, SYBREAL, SYBTEXT, SYBVARBINARY, SYBVARCHAR, SYBVOID, TDS_DBG_INFO1, tdsdump_log, col_t::ti, and col_t::type.
Definition at line 799 of file dbpivot.c.
References assert, dbproc, npivots, P, pivot_key_equal(), pivots, and tds_find().
Referenced by dbnextrow().
|
static |
Definition at line 381 of file dbpivot.c.
References assert, SYBBINARY, SYBBIT, SYBBITN, SYBCHAR, SYBDATETIME, SYBDATETIME4, SYBDATETIMN, SYBDECIMAL, SYBFLT8, SYBFLTN, SYBIMAGE, SYBINT1, SYBINT2, SYBINT4, SYBINTN, SYBMONEY, SYBMONEY4, SYBMONEYN, SYBNTEXT, SYBNUMERIC, SYBREAL, SYBTEXT, SYBVARBINARY, SYBVARCHAR, SYBVOID, and TDS_INVALID_TYPE.
Referenced by col_init().
Definition at line 359 of file dbpivot.c.
References len, output, strcat, and tds_new0.
Referenced by EasySeqLocMerge(), make_col_name(), ScannGeneName(), and bm::thread_pool< QValue, Lock >::~thread_pool().
Definition at line 497 of file dbpivot.c.
References assert, col_cpy(), i, KEY_T::keys, KEY_T::nkeys, NULL, and tds_new0.
Referenced by dbnextrow_pivoted(), and dbpivot().
Definition at line 472 of file dbpivot.c.
References a, assert, b, col_equal(), and i.
Referenced by __WORKAROUND_RENAME(), dbpivot(), and CSourceModParser::GetModAllowedValues().
Definition at line 489 of file dbpivot.c.
References col_free(), free(), and KEY_T::keys.
Referenced by agg_free(), and dbpivot().
Definition at line 1310 of file dbpivot.c.
References assert, name_t::name, and util::strcmp().
Referenced by dbpivot_lookup_name().
|
static |
Definition at line 720 of file dbpivot.c.
References alloc_results(), assert, metadata_t::col, tds_column::column_name, tds_column::column_size, tds_column::column_type, tds_column::column_usertype, tds_socket::cur_cursor, i, info, metadata_t::name, NULL, tds_column::on_server, tds_cursor::res_info, tds_socket::res_info, tds_socket::rows_affected, set_result_column(), tds, tds_alloc_row, TDS_DBG_INFO1, tds_dstr_cstr(), TDS_FAILED, tds_free_all_results, tds_free_results, TDS_NO_COUNT, tds_set_current_results, and tdsdump_log.
Referenced by dbpivot().
|
static |
Definition at line 679 of file dbpivot.c.
References assert, tds_column::column_identity, tds_column::column_name, tds_column::column_nullable, tds_column::column_size, tds_column::column_timestamp, tds_column::column_type, tds_column::column_usertype, tds_column::column_varint_size, tds_column::column_writeable, tds_socket::conn, tds_column::funcs, tds_column_funcs::get_info, tds_column::on_server, SYBBINARY, tds, TDS_DBG_INFO1, tds_dstr_copy(), tds_dstr_cstr(), TDS_FAIL, tds_prtype, tds_set_column_type, TDS_SUCCESS, TDS_UT_TIMESTAMP, tdsdump_log, and col_t::type.
Referenced by reinit_results().
Definition at line 302 of file dbpivot.c.
References asprintf, assert, col_t::data, col_t::f, col_t::i, len, col_t::len, NULL, output, col_t::r, col_t::s, col_t::si, SYBBINARY, SYBBIT, SYBBITN, SYBCHAR, SYBDATETIME, SYBDATETIME4, SYBDATETIMN, SYBDECIMAL, SYBFLT8, SYBFLTN, SYBIMAGE, SYBINT1, SYBINT2, SYBINT4, SYBINTN, SYBMONEY, SYBMONEY4, SYBMONEYN, SYBNTEXT, SYBNUMERIC, SYBREAL, SYBTEXT, SYBVARBINARY, SYBVARCHAR, SYBVOID, tds_new0, col_t::ti, and col_t::type.
Referenced by make_col_name().
|
static |
Definition at line 61 of file dbpivot.c.
References i, ncbi::grid::netcache::search::fields::key, and NULL.
Referenced by dbnextrow_pivoted(), dbpivot(), and dbrows_pivoted().
Referenced by CTabDelimitedValidator::_MakeColumns(), CTableNames::AllTableNames(), AppendNamesParameter(), CExplodeRNAFeats::apply(), NMacroUtil::ApplyAuthorNames(), CRemoveSeqFromAlignDlg::ApplyToCSeq_entry(), BOOST_AUTO_TEST_CASE(), CHugeMacroContext::CacheTaxnames(), CCgiEnvHolder::CCgiEnvHolder(), CheckDelGbblockSource(), CheckDelGbblockSourceFromDescrs(), CCodeGenerator::CheckFileNames(), CInvalidChoiceSelection::CInvalidChoiceSelection(), CCleanup::CleanupAuthList(), CSubjectsSequenceCoverage::Create(), CDriverManager::CreateDsFrom(), dbpivot(), dbpivot_lookup_name(), pub_report::DoHydraSearch(), CNcbiEnvironment::Enumerate(), CNSTDatabase::ExecSP_GetClients(), fix_pub::ExtractConsortiums(), FindOrgNames(), pub_report::FirstOrLastAuthorMatches(), fta_fix_affil(), CClassTypeStrings::GenerateClassCode(), CChoiceTypeStrings::GenerateClassCode(), CEnumTypeStrings::GenerateTypeCode(), CSynRegistry::Get(), CSGFeatureJob::GetAnnotNames(), CSGAlignmentJob::GetAnnotNames(), CSGSeqGraphJob::GetAnnotNames(), CSGFeatureDS::GetAnnotNames(), CSGSegmentMapDS::GetAnnotNames(), CSGAlignmentDS::GetAnnotNames(), CSGGraphDS::GetAnnotNames(), CSGFeatureJob::GetAnnotNames_var(), CSGFeatureDS::GetAnnotNames_var(), SNetStorageObjectRPC::GetAttributeList(), CCgiSession_NetCache::GetAttributeNames(), CReferenceItem::GetAuthNames(), GetAuthorMatchStrings(), pub_report::GetAuthorsFromList(), CColumnarVCFReader::GetChromosomeNames(), CRawSeqDBSource::GetColumnNames(), CClusterDBSource::GetColumnNames(), CRemoveSeqFromAlignDlg::GetCommand(), CProjectViewBase::GetCompatibleToolBars(), CTableView::GetCompatibleToolBars(), CFeatTableView::GetCompatibleToolBars(), CViewGraphic::GetCompatibleToolBars(), CSequinDesktopView::GetCompatibleToolBars(), CTextView::GetCompatibleToolBars(), CVcfTableView::GetCompatibleToolBars(), CTableViewWithTextViewNav::GetCompatibleToolBars(), CDDTypedAnnotDialog::GetData(), CEntrezDB::GetDbNames(), GetDiscrepancyNames(), GetDiscrepancyTests(), CAppEnvHolder::GetEnv(), CMacroEditorContext::GetFeatQualifiers(), CSeqGraphicPane::GetFeatureNames(), fix_pub::GetFirstTenNames(), CAuth_list::GetLabelV1(), CAuth_list::GetLabelV2(), CTypeStrings::GetModuleName(), CFileCode::GetModuleNames(), CInvalidChoiceSelection::GetName(), CGBDataLoader_Native::GetNamedAnnotAccessions(), CPSGDataLoader::GetNamedAnnotAccessions(), SRequestBuilder::SReader< CJson_ConstObject >::GetNamedAnnots(), CWithdrawSequences::GetNames(), CCSRAFileInfo::GetPossibleAnnotNames(), CSNPFileInfo::GetPossibleAnnotNames(), CBAMDataLoader_Impl::GetPossibleAnnotNames(), CCSRADataLoader_Impl::GetPossibleAnnotNames(), CSNPDataLoader_Impl::GetPossibleAnnotNames(), CVDBGraphDataLoader_Impl::GetPossibleAnnotNames(), GetPrimerSetNameValues(), GetProtRefAnnot(), CQueueDataBase::GetQueueNames(), CClassTypeInfoBase::GetRegisteredClassNames(), CObjectManager::GetRegisteredNames(), CPhyloTreeWidget::GetRenderersNames(), CVariantDescriptors::GetSampleNames(), CHitMatrixDataSource::GetScoreNames(), CSGSeqGraphJob::GetSeqtableAnnots(), CSGGraphDS::GetSeqtableAnnots(), ShowHideManager::GetShowHideInfo(), CCdDbPriority::GetSourceNames(), CCSraDb_Impl::GetSpotGroups(), GetTaxnameName(), GetTaxnameNameFromDescrs(), CProjectViewToolBatFactory::GetToolBarNames(), CFrameworkDemoToolBarFactory::GetToolBarNames(), CDataMiningService::GetToolNames(), CUIToolRegistry::GetToolNames(), CBinsDS::GetTrackNames(), CSGHapmapDS::GetTrackNames(), CLDBlockDS::GetTrackNames(), CFeatTableDS::GetTypeNames(), GetVDBScope(), CAlnMultiRenderer::GetVisibleColumns(), CSynRegistry::Has(), CValidError_imp::HasName(), CTextTableModel::Init(), SRemoteCgi::Input(), CStdAnnotTypes::IsPredefinedDescr(), CStdAnnotTypes::IsPredefinedDescrForType(), CCompoundRWRegistry::LoadBaseRegistries(), CProcessor_AnnotInfo::LoadBlob(), CReader::LoadBlobs(), CDataTool::LoadDefinitions(), CUIToolRegistry::LoadSettings(), CWidgetDisplayStyle::LoadSettings(), CStdAnnotTypes::LoadTypes(), CCgiApplication::LogRequest(), make_col_name(), MaybeCutGbblockSource(), mdb_txn_end(), CDataMiningPanel::OnAutorun(), CHitMatrixWidget::OnColorByScore(), CProjectTreeViewDropTarget::OnData(), CMultiFileInput::CDropTarget::OnData(), CFrameworkDemoGUIDropTarget::OnData(), CPubseqGatewayApp::OnGetNA(), StructureWindow::OnSelect(), OrderQual(), CColumnValidatorRegistry::PrintSupported(), CDiscRepArgDescriptions::PrintUsage(), CCgiSampleApplication::ProcessPrintEnvironment(), CCgiSessionSampleApplication::ProcessRequest(), CDistanceMatrix::Read(), RemoveConsortium(), CWindowManagerService::RemoveToolBarContext(), CCleanup::ResetAuthorNames(), CExplodeRNAFeats::RNAWordsFromString(), CNcbiApplogApp::Run(), CDemoApp::Run(), s_AddLatencyOptions(), s_AddPrimers(), s_AppendPrimerNames(), s_AuthListEmpty(), s_CreateNAChunk(), CFeatureFieldNamePanel::s_FillFeatQualList(), s_GetNameForDescription(), CMacroFunction_PubFields::s_GetObjectsFromAuthListNames(), CMacroFunction_PubFields::s_GetObjectsFromPersonID(), s_GetPrimerInfo(), CMacroFunction_AuthorFix::s_MoveMiddleToFirst(), s_NamesNotSet(), s_NumAuthors(), s_ParseEnabledFlags(), s_SetLogFilesDir(), s_SetPrimerNames(), CCacheWriter::SaveSeq_idBlob_ids(), CWidgetDisplayStyle::SaveSettings(), CDataMiningPanel::SelectToolByName(), SPSGS_AnnotRequest::Serialize(), SetAuthorNames(), CDataMiningPanel::SetService(), CHttpCookies::sx_RevertDomain(), tds7_get_instance_ports(), tds_iconv_open(), tds_process_colinfo(), tds_process_tabname(), tds_set_server(), CSynRegistry::TGet(), CMacroFunction_ReplaceStopWithSelenocysteine::TheFunction(), CIndexedDb_New::TraceNames(), CDiscrepancyContext::TypeName(), CValidError_imp::ValidateAuthorList(), CValidError_imp::ValidateAuthorsInPubequiv(), CSequenceEditingEventHandler::WithdrawSequences(), WriteEnvironment(), CMacroFunction_AddPubAuthor::x_AddAuthor(), CReferenceItem::x_AddAuthors(), CFeatureItem::x_AddQualCdsProduct(), CFeatureItem::x_AddQualsProt(), CMakeBlastDBApp::x_BuildDatabase(), CSubmitBlockDlg::x_CopyAuthors(), CSubmitBlockDlg::x_CreateBlock(), CQueueDataBase::x_DumpQueueOrClass(), CPSGS_AnnotProcessor::x_FilterNames(), CAnnot_Collector::x_GetAnnotNames(), CPubseqGatewayApp::x_GetNames(), CEditingActionBiosourceTaxnameAfterBinomial::x_GetTextAfterNomial(), CSrcTaxnameAfterBinomialColumn::x_GetTextAfterNomial(), CRequestContext::x_LoadEnvContextProperties(), CMacroFunction_AuthorFix::x_MakeAuthorChanges(), CPSGDataLoader_Impl::x_MakeLoadLocalCDDEntryRequest(), CSettingsSet::x_MakeUniqueStyleName(), CPSGS_CDDProcessor::x_NameIncluded(), CTable2AsnValidator::x_PopulateDiscrepancy(), CNetStorageHandler::x_ProcessGetAttrList(), CMakeBlastDBApp::x_ProcessInputData(), CFastCgiApplicationMT::x_ProcessThreadedRequest(), CQueueDataBase::x_ReadDumpQueueDesrc(), CWindowManagerService::x_ShowToolBar(), CAlignTabExportPage2::x_StartAlignNamesJob(), CAlignTabExportPage2::x_StartNAAlignNamesJob(), CDescrModApply::x_TryPCRPrimerMod(), CFeatModApply::x_TryProtRefMod(), CWindowsDlg::x_UpdateTable(), CGff2Writer::xAssignFeatureAttributeProduct(), CSrcWriter::xGather(), and CSrcWriter::xPrimerSetNames().
|
static |
Definition at line 796 of file dbpivot.c.
Referenced by dbpivot(), and dbrows_pivoted().