MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / register_sql_statement

Method register_sql_statement

src/utilities/ntrace/TracePluginImpl.cpp:1803–1861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1801}
1802
1803void TracePluginImpl::register_sql_statement(ITraceSQLStatement* statement)
1804{
1805 StatementData stmt_data;
1806 stmt_data.id = statement->getStmtID();
1807
1808 bool need_statement = true;
1809
1810 const char* sql = statement->getText();
1811 if (!sql)
1812 return;
1813
1814 size_t sql_length = strlen(sql);
1815 if (!sql_length)
1816 return;
1817
1818 if (config.include_filter.hasData())
1819 need_statement = include_matcher->matches(sql, sql_length);
1820
1821 if (need_statement && config.exclude_filter.hasData())
1822 need_statement = !exclude_matcher->matches(sql, sql_length);
1823
1824 if (need_statement)
1825 {
1826 stmt_data.description = FB_NEW_POOL(*getDefaultMemoryPool()) string(*getDefaultMemoryPool());
1827
1828 if (stmt_data.id) {
1829 stmt_data.description->printf(NEWLINE "Statement %" SQUADFORMAT":", stmt_data.id);
1830 }
1831
1832 string temp(*getDefaultMemoryPool());
1833 if (config.max_sql_length && sql_length > config.max_sql_length)
1834 {
1835 // Truncate too long SQL printing it out with ellipsis
1836 sql_length = (config.max_sql_length < 3) ? 0 : (config.max_sql_length - 3);
1837 temp.printf(NEWLINE
1838 "-------------------------------------------------------------------------------" NEWLINE
1839 "%.*s...", sql_length, sql);
1840 }
1841 else
1842 {
1843 temp.printf(NEWLINE
1844 "-------------------------------------------------------------------------------" NEWLINE
1845 "%.*s", sql_length, sql);
1846 }
1847 *stmt_data.description += temp;
1848
1849 *stmt_data.description += getPlan(statement);
1850 }
1851 else
1852 {
1853 stmt_data.description = NULL;
1854 }
1855
1856 // Remember statement
1857 {
1858 WriteLockGuard lock(statementsLock, FB_FUNCTION);
1859 statements.add(stmt_data);
1860 }

Callers

nothing calls this directly

Calls 7

getDefaultMemoryPoolFunction · 0.85
getStmtIDMethod · 0.45
getTextMethod · 0.45
hasDataMethod · 0.45
matchesMethod · 0.45
printfMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected