42 #define NCBI_USE_ERRCODE_X Dbapi_CTlib_Cmds
44 #undef NCBI_DATABASE_THROW
45 #define NCBI_DATABASE_THROW(ex_class, message, err_code, severity) \
46 NCBI_DATABASE_THROW_ANNOTATED(ex_class, message, err_code, severity, \
47 GetDbgInfo(), GetConnection(), GetLastParams())
53 namespace NCBI_NS_FTDS_CTLIB
70 if (
conn.m_ActiveCmd) {
71 conn.m_ActiveCmd->m_IsActive =
false;
73 conn.m_ActiveCmd =
this;
86 if (
conn.m_ActiveCmd) {
87 conn.m_ActiveCmd->m_IsActive =
false;
89 conn.m_ActiveCmd =
this;
118 if (
conn.m_ActiveCmd) {
119 conn.m_ActiveCmd->m_IsActive =
false;
121 conn.m_ActiveCmd =
this;
151 "Connection is not open or already dead." +
GetDbgInfo(),
159 "ct_cmd_alloc failed", 110001
231 const string& param_name,
239 param_fmt.
name[l] =
'\0';
252 if ( declare_only ) {
264 if ( declare_only ) {
276 if ( declare_only ) {
288 if ( declare_only ) {
301 if ( declare_only ) {
308 value.precision = 19;
325 if ( declare_only ) {
343 if ( declare_only ) {
368 CUtf8::AsBasicString<TCharUCS2>(str_check);
372 if ( declare_only ) {
400 if ( declare_only ) {
436 if ( declare_only ) {
449 #if defined(FTDS_IN_USE) && defined(CS_TDS_72)
460 if ( declare_only ) {
475 if ( declare_only ) {
491 if ( declare_only ) {
507 if ( declare_only ) {
512 if (param.IsNULL()) {
531 if ( declare_only ) {
536 if (param.IsNULL()) {
557 if ( !param.IsNULL() ) {
572 lt.SetNanoSecond(
lt.NanoSecond() / 100 * 100);
574 (GetConnection().GetDateTimeSyntax(),
598 }
else if (par.
IsNULL()) {
602 size_t n = par.
Size();
608 buf.get(), n2, indicator));
618 if ( declare_only ) {
702 "You need to send a command first." +
GetDbgInfo(),
714 unique_ptr<CTL_Connection::CAsyncCancelGuard> async_guard
785 "Your command has been canceled due to timeout",
800 switch ( res_type ) {
811 "executing a command", 120016 );
854 if (
conn.AsyncCancel(*
this)) {
859 conn.m_CancelRequested =
true;
876 TGuard::EContext guard_ctx;
877 switch (cancel_type) {
878 case eAsyncCancel: guard_ctx = TGuard::eAsyncCancel;
break;
879 case eSyncCancel: guard_ctx = TGuard::eSyncCancel;
break;
882 if ( !guard.IsForCancelInProgress() ) {
887 CS_INT ignored_results_type;
987 const string& lang_query
1005 if (dyn_id.
empty()) {
1008 const_cast<char*
>(
GetQuery().data()),
1010 "ct_command failed", 120001);
1011 }
else if (dyn_id ==
"!") {
1016 const_cast<char*
>(dyn_id.
data()),
1018 "ct_dynamic(CS_EXECUTE) failed", 120004);
1053 "ct_dynamic(CS_DEALLOC) failed", 120005);
1056 unique_ptr<CDB_Result>
r(
Result());
1090 memset(¶m_fmt, 0,
sizeof(param_fmt));
1123 static const char kValid[] =
1124 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@$#_";
1137 <<
" contains both ? and @. Treating @ as the"
1138 " parameter indicator because there are more"
1139 " parameters than question marks.");
1150 pos =
query.find(
'@', pos2);
1152 }
while (pos !=
NPOS);
1156 if (used.
find(name) == used.
end()) {
1164 <<
" contains both ? and @. Treating @ as the"
1165 " parameter indicator because all supplied parameter"
1171 <<
" contains both ? and @. Treating ? as the"
1172 " parameter indicator because there are enough"
1173 " question marks and some or all supplied"
1174 " parameter names are absent: "
1184 const_cast<char*
>(
query.data()),
1186 "ct_dynamic(CS_PREPARE) failed", 120002);
1191 unique_ptr<CDB_Result>
r(
Result());
void SetValue(const CTempString &s)
CTempString GetValue(void) const
void SetDead(bool flag=true)
void SetTimedOut(bool val)
void DropCmd(impl::CCommand &cmd)
virtual ~CTL_CmdBase(void)
void SetRetriable(ERetriable val)
CS_RETCODE Check(CS_RETCODE rc)
CTL_Connection & GetConnection(void)
void EnsureActiveStatus(void)
CTL_CmdBase(CTL_Connection &conn, const string &query)
ERetriable GetRetriable(void) const
bool GetTimedOut(void) const
virtual void SetHasFailed(bool flag=true)
void SetExecCntxInfo(const string &info)
const TDbgInfo & GetDbgInfo(void) const
CTL_RowResult * MakeStatusResult(void)
void SetResult(CTL_RowResult *result)
CTL_RowResult * MakeRowResult(void)
bool AssignCmdParam(CDB_Object ¶m, const string ¶m_name, CS_DATAFMT ¶m_fmt, bool declare_only=false)
void MarkEndOfReply(void)
bool ProcessResultInternal(CDB_Result &res)
CTL_RowResult * MakeComputeResult(void)
CTL_Cmd(CTL_Connection &conn, const string &query)
CS_COMMAND * x_GetSybaseCmd(void) const
void GetRowCount(int *cnt)
void DeleteResultInternal(void)
CTL_RowResult & GetResult(void)
CTL_RowResult * MakeParamResult(void)
CS_RETCODE CheckSFB_Internal(CS_RETCODE rc, const char *msg, unsigned int msg_num)
const CTLibContext & GetCTLibContext(void) const
CS_RETCODE Check(CS_RETCODE rc)
size_t PrepareToCancel(void)
void CancelFinished(size_t was_timeout)
CTL_CmdBase * m_ActiveCmd
CS_RETCODE CheckSFB(CS_RETCODE rc, const char *msg, unsigned int msg_num)
bool x_Cancel(ECancelType cancel_type) override
CTL_RowResult * MakeResultInternal(void)
CTL_LRCmd(CTL_Connection &conn, const string &query)
CDB_Result * MakeResult(void)
bool Cancel(void) override
Cancel the command execution.
virtual bool Send(void)
Send command to the server.
virtual CDB_Result * Result(void)
Get result set.
bool x_AssignParams(void)
virtual int RowCount(void) const
Get the number of rows affected by the command Special case: negative on error or if there is no way ...
CTL_LangCmd(CTL_Connection &conn, const string &lang_query)
CTempString x_GetDynamicID(void)
virtual ~CTL_LangCmd(void)
virtual bool HasMoreResults(void) const
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
const string & GetQuery(void) const
virtual bool HasFailed(void) const
const CDB_Params & GetBindParamsImpl(void) const
void DetachInterface(void)
void SetWasSent(bool flag=true)
static CDB_Result * Create_Result(CResult &result)
CDB_ResultProcessor * GetResultProcessor(void) const
CDBConnParams::EServerType GetServerType(void)
void SetClosingConnect(bool value)
CDB_Object * GetParam(unsigned int param_no) const
const string & GetParamName(unsigned int param_no) const
TStatus GetParamStatus(unsigned int param_no) const
unsigned int NofParams() const
EEncoding GetClientEncoding(void) const
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
#define CS_DATETIME4_TYPE
#define CS_COMPUTEFMT_RESULT
#define CS_LONGBINARY_TYPE
#define CS_COMPUTE_RESULT
static CS_CONNECTION * conn
impl::CDBExceptionStorage & GetCTLExceptionStorage(void)
CS_RETCODE ct_dynamic(CS_COMMAND *cmd, CS_INT type, CS_CHAR *id, CS_INT idlen, CS_CHAR *buffer, CS_INT buflen)
CS_RETCODE ct_command(CS_COMMAND *cmd, CS_INT type, const CS_VOID *buffer, CS_INT buflen, CS_INT option)
CS_RETCODE ct_results(CS_COMMAND *cmd, CS_INT *result_type)
CS_RETCODE ct_res_info(CS_COMMAND *cmd, CS_INT type, CS_VOID *buffer, CS_INT buflen, CS_INT *out_len)
CS_RETCODE ct_cmd_drop(CS_COMMAND *cmd)
CS_RETCODE ct_cmd_alloc(CS_CONNECTION *con, CS_COMMAND **cmd)
CS_RETCODE ct_param(CS_COMMAND *cmd, CS_DATAFMT *datafmt, CS_VOID *data, CS_INT datalen, CS_SMALLINT indicator)
CS_RETCODE ct_send(CS_COMMAND *cmd)
CS_RETCODE ct_cancel(CS_CONNECTION *conn, CS_COMMAND *cmd, CS_INT type)
#define NCBI_CS_STRING_TYPE
@ eRetriable_Unknown
It is unknown if the action can succeed if retried.
#define DATABASE_DRIVER_ERROR(message, err_code)
#define DATABASE_DRIVER_INFO(message, err_code)
#define CHECK_DRIVER_ERROR(failed, message, err_code)
#define DATABASE_DRIVER_WARNING(message, err_code)
#define DATABASE_DRIVER_FATAL(message, err_code)
virtual void ProcessResult(CDB_Result &res)
The default implementation just dumps all rows.
Uint2 GetMinutes(void) const
const void * Value() const
static EBlobType GetBlobType(EDB_Type db_type)
const TOffset & GetOffset(void) const
const char * Value(void) const
virtual EDB_Type GetType() const =0
const CTime & GetCTime(void) const
virtual bool MoveTo(size_t byte_number)
Uint2 GetDays(void) const
ESQLType GetSQLType(void) const
const string & AsString(void) const
static CTimeFormat GetTimeFormat(ESyntax syntax, ESQLType sql_type=eDateTime, TOffset offset=null)
virtual size_t Read(void *buff, size_t nof_bytes)
Int4 Get300Secs(void) const
const char * Data(void) const
virtual size_t Size() const
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
#define NCBI_CURRENT_FUNCTION
Get current function name.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
@ eDiag_Error
Error message.
#define NCBI_CATCH_ALL_X(err_subcode, message)
void Info(CExceptionArgs_Base &args)
int64_t Int8
8-byte (64-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
NCBI_NS_STD::string::size_type SIZE_TYPE
CTempString & assign(const char *src_str, size_type len)
Assign new values to the content of the a string.
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
const char * data(void) const
Return a pointer to the array represented.
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
static CStringUTF8 AsUTF8(const CTempString &src, EEncoding encoding, EValidate validate=eNoValidate)
Convert into UTF8 from a C/C++ string.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
static string CEncode(const CTempString str, EQuoted quoted=eQuoted)
Encode a string for C/C++.
size_type size(void) const
Return the length of the represented array.
Int4 days
days from 1/1/1900
CTime & SetTimeDBI(const TDBTimeI &t)
Set time using database format time, TDBTimeI.
Int4 time
x/300 seconds from the beginning of current day
unsigned int
A callback function used to compare two keys in a database.
Definition of all error codes used in dbapi libraries (dbapi_driver.lib and others).
if(yy_accept[yy_current_state])
void Check(const string &value)
const struct ncbi::grid::netcache::search::fields::SIZE size
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
unsigned char * longlong_to_numeric(Int8 l_num, unsigned int prec, unsigned char *cs_num)
Database format for time where day and time is signed 32 bit.