8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-02-02 10:00:38 +01:00
This commit is contained in:
Adriano dos Santos Fernandes 2017-03-09 00:49:23 -03:00
parent de0654aa8f
commit 6b06320fdc
24 changed files with 92 additions and 79 deletions

View File

@ -236,9 +236,7 @@ void DbCrypt::setKey(CheckStatusWrapper* status, unsigned int length, IKeyHolder
return;
if (callback && callback->callback(0, NULL, 1, &key) == 1)
{
return;
}
}
key = 0;

View File

@ -69,13 +69,15 @@ public:
}
}
/* It was a kind of getting ready for changing config remotely...
/***
It was a kind of getting ready for changing config remotely...
void changeDefaultConfig(Config* newConfig)
{
defaultConfig = newConfig;
}
*/
***/
Firebird::RefPtr<const Config>& getDefaultConfig()
{
return defaultConfig;

View File

@ -228,25 +228,27 @@ bool ISC_analyze_nfs(tstring& expanded_filename, tstring& node_name)
// If we are ignoring NFS remote mounts then do not bother checking here
// and pretend it's only local. MOD 16-Nov-2002
if (Config::getRemoteFileOpenAbility()) {
if (Config::getRemoteFileOpenAbility())
return false;
}
#ifdef LINUX
// In order to avoid analyzing mtab in most cases check for non-device mounts first
struct stat fileStat;
unsigned m = 1; // use something that is known to be not non-device major
if (os_utils::stat(expanded_filename.c_str(), &fileStat) == 0) {
if (os_utils::stat(expanded_filename.c_str(), &fileStat) == 0)
m = major(fileStat.st_dev);
}
else { // stat error - let's try with path component
else // stat error - let's try with path component
{
tstring path, name;
PathUtils::splitLastComponent(path, name, expanded_filename);
if (path.hasData() && os_utils::stat(path.c_str(), &fileStat) == 0)
m = major(fileStat.st_dev);
}
if (m != 0 && m != 144 && m != 145 && m != 146) {
if (m != 0 && m != 144 && m != 145 && m != 146)
{
// device mount or stat for file/path is impossible - definitely not NFS
return false;
}

View File

@ -143,4 +143,3 @@ void* DlfcnModule::findSymbol(const Firebird::string& symName)
return result;
}

View File

@ -284,7 +284,7 @@ public:
class SetSessionNode : public Node
{
public:
enum Type {TYPE_IDLE_TIMEOUT, TYPE_STMT_TIMEOUT};
enum Type { TYPE_IDLE_TIMEOUT, TYPE_STMT_TIMEOUT };
SetSessionNode(MemoryPool& pool, Type aType, ULONG aVal, UCHAR blr_timepart);
@ -294,8 +294,8 @@ public:
virtual void execute(thread_db* tdbb, dsql_req* request) const;
private:
Type m_type;
ULONG m_value;
Type m_type;
ULONG m_value;
};

View File

@ -7984,10 +7984,12 @@ void SetRoleNode::execute(thread_db* tdbb, dsql_req* request, jrd_tra** transact
//--------------------
SetSessionNode::SetSessionNode(MemoryPool& pool, Type aType, ULONG aVal, UCHAR blr_timepart)
: Node(pool),
m_type(aType),
m_value(0)
m_type(aType),
m_value(0)
{
// TYPE_IDLE_TIMEOUT should be set in seconds
// TYPE_STMT_TIMEOUT should be set in milliseconds
@ -8018,6 +8020,7 @@ SetSessionNode::SetSessionNode(MemoryPool& pool, Type aType, ULONG aVal, UCHAR b
Arg::Gds(isc_invalid_extractpart_time).raise();
break;
}
m_value = aVal * mult;
}
@ -8031,17 +8034,16 @@ string SetSessionNode::internalPrint(NodePrinter& printer) const
return "SetSessionNode";
}
SetSessionNode* SetSessionNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
dsqlScratch->getStatement()->setType(DsqlCompiledStatement::TYPE_SET_SESSION);
return this;
}
void SetSessionNode::execute(thread_db* tdbb, dsql_req* request) const
{
Attachment* att = tdbb->getAttachment();
switch (m_type)
{
case TYPE_IDLE_TIMEOUT:

View File

@ -149,7 +149,8 @@ void DSQL_execute(thread_db* tdbb,
// Only allow NULL trans_handle if we're starting a transaction or set session properties
if (!*tra_handle && statement->getType() != DsqlCompiledStatement::TYPE_START_TRANS &&
if (!*tra_handle &&
statement->getType() != DsqlCompiledStatement::TYPE_START_TRANS &&
statement->getType() != DsqlCompiledStatement::TYPE_SET_SESSION)
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) <<
@ -545,7 +546,8 @@ void DSQL_execute_immediate(thread_db* tdbb, Jrd::Attachment* attachment, jrd_tr
// Only allow NULL trans_handle if we're starting a transaction or set session properties
if (!*tra_handle && statement->getType() != DsqlCompiledStatement::TYPE_START_TRANS &&
if (!*tra_handle &&
statement->getType() != DsqlCompiledStatement::TYPE_START_TRANS &&
statement->getType() != DsqlCompiledStatement::TYPE_SET_SESSION)
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) <<
@ -910,7 +912,6 @@ void DsqlTransactionRequest::dsqlPass(thread_db* tdbb, DsqlCompilerScratch* scra
req_traced = false;
}
// Execute a dynamic SQL statement.
void DsqlTransactionRequest::execute(thread_db* tdbb, jrd_tra** traHandle,
IMessageMetadata* /*inMetadata*/, const UCHAR* /*inMsg*/,
@ -929,7 +930,6 @@ void SetSessionRequest::execute(thread_db* tdbb, jrd_tra** /*traHandle*/,
node->execute(tdbb, this);
}
void SetSessionRequest::dsqlPass(thread_db* tdbb, DsqlCompilerScratch* scratch,
ntrace_result_t* /*traceResult*/)
{
@ -1599,7 +1599,6 @@ bool dsql_req::fetch(thread_db* /*tdbb*/, UCHAR* /*msgBuffer*/)
return false; // avoid warning
}
unsigned int dsql_req::getTimeout()
{
return req_timeout;
@ -1613,7 +1612,6 @@ unsigned int dsql_req::getActualTimeout()
return 0;
}
void dsql_req::setTimeout(unsigned int timeOut)
{
req_timeout = timeOut;
@ -1952,8 +1950,7 @@ static void sql_info(thread_db* tdbb,
case isc_info_sql_stmt_timeout_user:
case isc_info_sql_stmt_timeout_run:
value = (item == isc_info_sql_stmt_timeout_user) ?
request->getTimeout() : request->getActualTimeout();
value = (item == isc_info_sql_stmt_timeout_user) ? request->getTimeout() : request->getActualTimeout();
length = put_vax_long(buffer, value);
if (!(info = put_item(item, length, buffer, info, end_info)))

View File

@ -560,6 +560,7 @@ public:
// Get session-level timeout, milliseconds
unsigned int getTimeout();
// Set session-level timeout, milliseconds
void setTimeout(unsigned int timeOut);
@ -690,7 +691,7 @@ class SetSessionRequest : public dsql_req
public:
explicit SetSessionRequest(MemoryPool& pool, SetSessionNode* aNode)
: dsql_req(pool),
node(aNode)
node(aNode)
{
req_traced = false;
}

View File

@ -596,6 +596,7 @@ using namespace Firebird;
%token <metaNamePtr> DEFINER
%token <metaNamePtr> EXCLUDE
%token <metaNamePtr> FOLLOWING
%token <metaNamePtr> IDLE
%token <metaNamePtr> INVOKER
%token <metaNamePtr> MESSAGE
%token <metaNamePtr> NTILE
@ -609,14 +610,13 @@ using namespace Firebird;
%token <metaNamePtr> RDB_ROLE_IN_USE
%token <metaNamePtr> RDB_SYSTEM_PRIVILEGE
%token <metaNamePtr> SECURITY
%token <metaNamePtr> SESSION
%token <metaNamePtr> SQL
%token <metaNamePtr> SYSTEM
%token <metaNamePtr> TIES
%token <metaNamePtr> UNBOUNDED
%token <metaNamePtr> VARBINARY
%token <metaNamePtr> WINDOW
%token <metaNamePtr> IDLE
%token <metaNamePtr> SESSION
// precedence declarations for expression evaluation
@ -5026,7 +5026,7 @@ session_statement
%type <blrOp> timepart_sesion_idle_tout
timepart_sesion_idle_tout
: { $$ = blr_extract_minute; }
: /* nothing */ { $$ = blr_extract_minute; }
| HOUR { $$ = blr_extract_hour; }
| MINUTE { $$ = blr_extract_minute; }
| SECOND { $$ = blr_extract_second; }
@ -5034,7 +5034,7 @@ timepart_sesion_idle_tout
%type <blrOp> timepart_ses_stmt_tout
timepart_ses_stmt_tout
: { $$ = blr_extract_second; }
: /* nothing */ { $$ = blr_extract_second; }
| HOUR { $$ = blr_extract_hour; }
| MINUTE { $$ = blr_extract_minute; }
| SECOND { $$ = blr_extract_second; }
@ -8286,6 +8286,7 @@ non_reserved_word
| DEFINER
| EXCLUDE
| FOLLOWING
| IDLE
| INVOKER
| MESSAGE
| NTILE
@ -8296,11 +8297,10 @@ non_reserved_word
| PRIVILEGE
| RANGE
| SECURITY
| SESSION
| SQL
| SYSTEM
| TIES
| SESSION
| IDLE
;
%%

View File

@ -442,8 +442,8 @@ typedef ISC_STATUS API_ROUTINE prototype_fb_cancel_operation(ISC_STATUS *,
typedef ISC_STATUS API_ROUTINE prototype_fb_database_crypt_callback(ISC_STATUS *,
void *);
typedef ISC_STATUS API_ROUTINE prototype_fb_dsql_set_timeout(ISC_STATUS*,
isc_stmt_handle*,
typedef ISC_STATUS API_ROUTINE prototype_fb_dsql_set_timeout(ISC_STATUS*,
isc_stmt_handle*,
ULONG);

View File

@ -613,6 +613,7 @@ interface Server : Auth
{
[notImplemented(Auth::AUTH_FAILED)]
int authenticate(Status status, ServerBlock sBlock, Writer writerInterface);
version: // 3.0.1 => 4.0
void setDbCryptCallback(Status status, CryptKeyCallback cryptCallback);
}

View File

@ -8153,7 +8153,6 @@ static processing_state process_statement(const TEXT* str2)
if (ISQL_errmsg(fbStatus))
setValues.StmtTimeout = 0;
// Find out what kind of statement this is
const int statement_type = process_request_type();
if (!statement_type)

View File

@ -860,7 +860,7 @@ int Attachment::IdleTimer::release()
void Attachment::IdleTimer::reset(unsigned int timeout)
{
// Start timer if necessary. If timer was already started, don't restart
// Start timer if necessary. If timer was already started, don't restart
// (or stop) it - handler() will take care about it.
if (!timeout)

View File

@ -426,11 +426,11 @@ public:
JAttachment* getInterface() throw();
unsigned int getIdleTimeout() const
{
return att_idle_timeout;
{
return att_idle_timeout;
}
void setIdleTimeout(unsigned int timeOut)
void setIdleTimeout(unsigned int timeOut)
{
att_idle_timeout = timeOut;
}
@ -438,11 +438,11 @@ public:
unsigned int getActualIdleTimeout() const;
unsigned int getStatementTimeout() const
{
return att_stmt_timeout;
{
return att_stmt_timeout;
}
void setStatementTimeout(unsigned int timeOut)
void setStatementTimeout(unsigned int timeOut)
{
att_stmt_timeout = timeOut;
}
@ -485,7 +485,6 @@ private:
time_t m_expTime; // when actual idle timeout will expire
};
unsigned int att_idle_timeout; // seconds
unsigned int att_stmt_timeout; // milliseconds
Firebird::RefPtr<IdleTimer> att_idle_timer;

View File

@ -140,7 +140,7 @@ void IscConnection::attach(thread_db* tdbb, const PathName& dbName, const MetaNa
raise(&status, tdbb, "attach");
}
}
catch(const Exception&)
catch (const Exception&)
{
m_iscProvider.fb_database_crypt_callback(&status, NULL);
throw;
@ -496,13 +496,15 @@ void IscStatement::doPrepare(thread_db* tdbb, const string& sql)
void IscStatement::doSetTimeout(thread_db* tdbb, unsigned int timeout)
{
FbLocalStatus status;
{
EngineCallbackGuard guard(tdbb, *this, FB_FUNCTION);
m_iscProvider.fb_dsql_set_timeout(&status, &m_handle, timeout);
}
if (status->getState() & IStatus::STATE_ERRORS)
{
// silently ignore error if timeouts is not supported by remote server
// silently ignore error if timeouts is not supported by remote server
// or loaded client library
if (status[0] == isc_arg_gds && (status[1] == isc_wish_list || status[1] == isc_unavailable))
return;

View File

@ -475,8 +475,8 @@ ISC_STATUS ISC_EXPORT isc_dsql_sql_info(ISC_STATUS*,
short,
ISC_SCHAR*);
ISC_STATUS ISC_EXPORT fb_dsql_set_timeout(ISC_STATUS*,
isc_stmt_handle*,
ISC_STATUS ISC_EXPORT fb_dsql_set_timeout(ISC_STATUS*,
isc_stmt_handle*,
ISC_ULONG);
void ISC_EXPORT isc_encode_date(const void*,

View File

@ -354,11 +354,11 @@ class TimeoutTimer FB_FINAL :
public Firebird::RefCntIface<Firebird::ITimerImpl<TimeoutTimer, Firebird::CheckStatusWrapper> >
{
public:
explicit TimeoutTimer() :
m_started(0),
m_expired(false),
m_value(0),
m_error(0)
explicit TimeoutTimer()
: m_started(0),
m_expired(false),
m_value(0),
m_error(0)
{ }
// ITimer implementation
@ -383,7 +383,7 @@ public:
// milliseconds left before timer expiration
unsigned int timeToExpire() const;
// evaluate expire timestamp using start timestamp
// evaluate expire timestamp using start timestamp
bool getExpireTimestamp(const ISC_TIMESTAMP start, ISC_TIMESTAMP& exp) const;
// set timeout value in milliseconds and secondary error code
@ -406,10 +406,10 @@ private:
class TimeoutTimer : public Firebird::RefCounted
{
public:
explicit TimeoutTimer() :
m_start(0),
m_value(0),
m_error(0)
explicit TimeoutTimer()
: m_start(0),
m_value(0),
m_error(0)
{ }
bool expired() const;
@ -427,7 +427,7 @@ public:
// milliseconds left before timer expiration
unsigned int timeToExpire() const;
// evaluate expire timestamp using start timestamp
// evaluate expire timestamp using start timestamp
bool getExpireTimestamp(const ISC_TIMESTAMP start, ISC_TIMESTAMP& exp) const;
// set timeout value in milliseconds and secondary error code
@ -699,9 +699,9 @@ public:
class TimerGuard
{
public:
TimerGuard(thread_db* tdbb, TimeoutTimer* timer, bool autoStop) :
m_tdbb(tdbb),
m_autoStop(autoStop && timer)
TimerGuard(thread_db* tdbb, TimeoutTimer* timer, bool autoStop)
: m_tdbb(tdbb),
m_autoStop(autoStop && timer)
{
fb_assert(m_tdbb->tdbb_reqTimer == NULL);

View File

@ -868,7 +868,7 @@ static SSHORT adjust_wait(thread_db* tdbb, SSHORT wait)
**************************************
*
* Functional description
* If wait is cancellable and if statement timer was started - calc new wait
* If wait is cancellable and if statement timer was started - calc new wait
* time to ensure it will not take longer than rest of timeout.
*
**************************************/

View File

@ -1802,7 +1802,7 @@ void Attachment::execWithCheck(CheckStatusWrapper* status, const string& stmt)
if (!(status->getState() & IStatus::STATE_ERRORS))
return;
// handle isc_dsql_token_unk_err
// handle isc_dsql_token_unk_err
const ISC_STATUS* errs = status->getErrors();
if (!fb_utils::containsErrorCode(errs, isc_sqlerr) ||
@ -1813,6 +1813,7 @@ void Attachment::execWithCheck(CheckStatusWrapper* status, const string& stmt)
status->init();
}
status->setErrors(Arg::Gds(isc_wish_list).value());
}

View File

@ -638,7 +638,7 @@ rem_port* INET_analyze(ClntAuthBlock* cBlock,
rem_port* port = inet_try_connect(packet, rdb, file_name, node_name, dpb, config, ref_db_name, af);
P_ACPT* accept;
for(;;)
for (;;)
{
accept = NULL;
switch (packet->p_operation)

View File

@ -647,7 +647,7 @@ bool_t xdr_protocol(XDR* xdrs, PACKET* p)
MAP(xdr_short, reinterpret_cast<SSHORT&>(sqldata->p_sqldata_out_message_number));
}
{ // scope
rem_port* port = (rem_port*)xdrs->x_public;
rem_port* port = (rem_port*) xdrs->x_public;
if (port->port_protocol >= PROTOCOL_VERSION15)
MAP(xdr_u_long, sqldata->p_sqldata_timeout);
}

View File

@ -83,7 +83,7 @@ const USHORT PROTOCOL_VERSION13 = (FB_PROTOCOL_FLAG | 13);
const USHORT PROTOCOL_VERSION14 = (FB_PROTOCOL_FLAG | 14);
// Protocol 15:
// - supports crypt key callback at connect phaze
// - supports crypt key callback at connect phase
// - supports statement timeouts
const USHORT PROTOCOL_VERSION15 = (FB_PROTOCOL_FLAG | 15);

View File

@ -166,7 +166,7 @@ TracePluginImpl::TracePluginImpl(IPluginBase* plugin,
}
}
// parse filters for gds error codes
// parse filters for gds error codes
if (!config.include_gds_codes.isEmpty())
str2Array(config.include_gds_codes, include_codes);
@ -515,7 +515,8 @@ void TracePluginImpl::appendTableCounts(const PerformanceInfo *info)
FB_SIZE_T len = fb_strlen(trc->trc_relation_name);
if (max_len < len)
max_len = len;
};
}
if (max_len < 32)
max_len = 32;
@ -573,9 +574,11 @@ void TracePluginImpl::formatStringArgument(string& result, const UCHAR* str, siz
bool TracePluginImpl::filterStatus(const ISC_STATUS* status, GdsCodesArray& arr)
{
FB_SIZE_T pos;
while (*status != isc_arg_end)
{
const ISC_STATUS s = *status;
switch (s)
{
case isc_arg_gds:
@ -629,7 +632,7 @@ private:
GenericMap<Pair<NonPooled<const char*, ISC_STATUS> >, NocaseCmp > m_map;
};
}; // namespace
} // namespace
static InitInstance<GdsName2CodeMap> gdsNamesMap;
@ -652,11 +655,13 @@ void TracePluginImpl::str2Array(const Firebird::string& str, GdsCodesArray& arr)
ISC_STATUS code = atol(s.c_str());
if (!code && !gdsNamesMap().find(s.c_str(), code))
{
fatal_exception::raiseFmt(
"Error parsing error codes filter: \n"
"\t%s\n"
"\tbad item is: %s, at position: %d",
str.c_str(), s.c_str(), p1 + 1);
}
// avoid duplicates
@ -1054,7 +1059,8 @@ void TracePluginImpl::log_init()
{
if (config.log_initfini)
{
record.printf("\tSESSION_%d %s" NEWLINE "\t%s" NEWLINE, session_id, session_name.c_str(), config.db_filename.c_str());
record.printf("\tSESSION_%d %s" NEWLINE "\t%s" NEWLINE,
session_id, session_name.c_str(), config.db_filename.c_str());
logRecord("TRACE_INIT");
}
}
@ -1063,7 +1069,8 @@ void TracePluginImpl::log_finalize()
{
if (config.log_initfini)
{
record.printf("\tSESSION_%d %s" NEWLINE "\t%s" NEWLINE, session_id, session_name.c_str(), config.db_filename.c_str());
record.printf("\tSESSION_%d %s" NEWLINE "\t%s" NEWLINE,
session_id, session_name.c_str(), config.db_filename.c_str());
logRecord("TRACE_FINI");
}

View File

@ -1192,24 +1192,27 @@ namespace Why
explicit IscStatement(YAttachment* aAttachment)
: cursorName(getPool()),
attachment(aAttachment),
statement(NULL),
userHandle(NULL),
pseudoOpened(false),
delayedFormat(false)
attachment(aAttachment),
statement(NULL),
userHandle(NULL),
pseudoOpened(false),
delayedFormat(false)
{ }
~IscStatement() override;
FB_API_HANDLE& getHandle();
void destroy(unsigned);
void openCursor(CheckStatusWrapper* status, FB_API_HANDLE* traHandle,
IMessageMetadata* inMetadata, UCHAR* buffer, IMessageMetadata* outMetadata);
void closeCursor(CheckStatusWrapper* status, bool raise);
void closeStatement(CheckStatusWrapper* status);
void execute(CheckStatusWrapper* status, FB_API_HANDLE* traHandle,
IMessageMetadata* inMetadata, UCHAR* inBuffer, IMessageMetadata* outMetadata, UCHAR* outBuffer);
FB_BOOLEAN fetch(CheckStatusWrapper* status, IMessageMetadata* outMetadata, UCHAR* outBuffer);
void checkPrepared(ISC_STATUS code = isc_unprepared_stmt) const
@ -4375,6 +4378,7 @@ IscStatement::~IscStatement()
*userHandle = 0;
userHandle = nullptr;
}
removeHandle(&statements, handle);
}
@ -4469,8 +4473,7 @@ void IscStatement::execute(CheckStatusWrapper* status, FB_API_HANDLE* traHandle,
}
}
FB_BOOLEAN IscStatement::fetch(CheckStatusWrapper* status, IMessageMetadata* outMetadata,
UCHAR* outBuffer)
FB_BOOLEAN IscStatement::fetch(CheckStatusWrapper* status, IMessageMetadata* outMetadata, UCHAR* outBuffer)
{
checkCursorOpened();