本文整理汇总了C++中MetaName::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ MetaName::c_str方法的具体用法?C++ MetaName::c_str怎么用?C++ MetaName::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetaName
的用法示例。
在下文中一共展示了MetaName::c_str方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printInversion
void RecordSource::printInversion(thread_db* tdbb, const InversionNode* inversion,
string& plan, bool detailed, unsigned level, bool navigation)
{
if (detailed)
plan += printIndent(++level);
switch (inversion->type)
{
case InversionNode::TYPE_AND:
if (detailed)
plan += "Bitmap And";
printInversion(tdbb, inversion->node1, plan, detailed, level);
printInversion(tdbb, inversion->node2, plan, detailed, level);
break;
case InversionNode::TYPE_OR:
case InversionNode::TYPE_IN:
if (detailed)
plan += "Bitmap Or";
printInversion(tdbb, inversion->node1, plan, detailed, level);
printInversion(tdbb, inversion->node2, plan, detailed, level);
break;
case InversionNode::TYPE_DBKEY:
if (detailed)
plan += "DBKEY";
break;
case InversionNode::TYPE_INDEX:
{
MetaName indexName;
MET_lookup_index(tdbb, indexName, inversion->retrieval->irb_relation->rel_name,
(USHORT) (inversion->retrieval->irb_index + 1));
if (detailed)
{
if (!navigation)
plan += "Bitmap" + printIndent(++level);
plan += "Index \"" + printName(tdbb, indexName.c_str()) + "\" Scan";
}
else
{
plan += (plan.hasData() ? ", " : "") + printName(tdbb, indexName.c_str());
}
}
break;
default:
fb_assert(false);
}
}
示例2: MetaName
MetaName Jrd::Attachment::nameToUserCharSet(thread_db* tdbb, const MetaName& name)
{
if (att_charset == CS_METADATA || att_charset == CS_NONE)
return name;
UCHAR buffer[MAX_SQL_IDENTIFIER_SIZE];
ULONG len = INTL_convert_bytes(tdbb, att_charset, buffer, MAX_SQL_IDENTIFIER_LEN,
CS_METADATA, (const BYTE*) name.c_str(), name.length(), ERR_post);
buffer[len] = '\0';
return MetaName((const char*) buffer);
}
示例3: startSession
void TraceSvcJrd::startSession(TraceSession& session, bool interactive)
{
if (!TraceManager::pluginsCount())
{
m_svc.printf(false, "Can not start trace session. There are no trace plugins loaded\n");
return;
}
ConfigStorage* storage = TraceManager::getStorage();
{ // scope
StorageGuard guard(storage);
session.ses_auth = m_authBlock;
session.ses_user = m_user;
MetaName role = m_role;
UserId::makeRoleName(role, SQL_DIALECT_V6);
session.ses_role = role.c_str();
session.ses_flags = trs_active;
if (m_admin) {
session.ses_flags |= trs_admin;
}
if (interactive)
{
Guid guid;
GenerateGuid(&guid);
char* buff = session.ses_logfile.getBuffer(GUID_BUFF_SIZE);
GuidToString(buff, &guid);
session.ses_logfile.insert(0, "fb_trace.");
}
storage->addSession(session);
m_chg_number = storage->getChangeNumber();
}
m_svc.started();
m_svc.printf(false, "Trace session ID %ld started\n", session.ses_id);
if (interactive)
{
readSession(session);
{
StorageGuard guard(storage);
storage->removeSession(session.ses_id);
}
}
}
示例4: setSequence
void Applier::setSequence(thread_db* tdbb, const MetaName& genName, SINT64 value)
{
const auto attachment = tdbb->getAttachment();
auto gen_id = attachment->att_generators.lookup(genName);
if (gen_id < 0)
{
gen_id = MET_lookup_generator(tdbb, genName);
if (gen_id < 0)
raiseError("Generator %s is not found", genName.c_str());
attachment->att_generators.store(gen_id, genName);
}
if (DPM_gen_id(tdbb, gen_id, false, 0) < value)
DPM_gen_id(tdbb, gen_id, true, value);
}
示例5: checkCreateDatabaseGrant
bool checkCreateDatabaseGrant(const MetaName& userName, const MetaName& trustedRole,
const MetaName& sqlRole, const char* securityDb)
{
if (userName == SYSDBA_USER_NAME)
return true;
RefPtr<IAttachment> att;
RefPtr<ITransaction> tra;
if (!openDb(securityDb, att, tra))
return false;
FbLocalStatus st;
MetaName role(sqlRole);
if (role.hasData())
{
const UCHAR info[] = { isc_info_db_sql_dialect, isc_info_end };
UCHAR buffer[BUFFER_TINY];
att->getInfo(&st, sizeof(info), info, sizeof(buffer), buffer);
check("IAttachment::getInfo", &st);
int dialect = SQL_DIALECT_V5; // reasonable default
const UCHAR* p = buffer;
while (*p != isc_info_end && *p != isc_info_truncated && p < buffer + sizeof(buffer))
{
const UCHAR item = (UCHAR) *p++;
const USHORT length = gds__vax_integer(p, sizeof(USHORT));
p += sizeof(USHORT);
switch (item)
{
case isc_info_db_sql_dialect:
dialect = gds__vax_integer(p, length);
break;
}
p += length;
}
JRD_make_role_name(role, dialect);
// We need to check is admin role granted to userName in security DB
const char* sql = "select count(*) from RDB$USER_PRIVILEGES "
"where RDB$USER = ? and RDB$RELATION_NAME = ? and RDB$PRIVILEGE = 'M'";
Message prm;
Field<Varying> u(prm, MAX_SQL_IDENTIFIER_LEN);
Field<Varying> r(prm, MAX_SQL_IDENTIFIER_LEN);
u = userName.c_str();
r = role.c_str();
Message result;
Field<ISC_INT64> cnt(result);
att->execute(&st, tra, 0, sql, SQL_DIALECT_V6, prm.getMetadata(), prm.getBuffer(),
result.getMetadata(), result.getBuffer());
if (st->getState() & IStatus::STATE_ERRORS)
{
// isc_dsql_relation_err when exec SQL - i.e. table RDB$USER_PRIVILEGES
// is missing due to non-FB security DB
if (!fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err))
check("IAttachment::execute", &st);
role = "";
}
else if (cnt == 0)
role = "";
}
else
role = trustedRole;
if (role == ADMIN_ROLE)
return true;
Message gr;
Field<ISC_SHORT> uType(gr);
Field<Varying> u(gr, MAX_SQL_IDENTIFIER_LEN);
Field<ISC_SHORT> rType(gr);
Field<Varying> r(gr, MAX_SQL_IDENTIFIER_LEN);
uType = obj_user;
u = userName.c_str();
rType = role.hasData() ? obj_sql_role : 255;
r = role.c_str();
Message result;
Field<ISC_INT64> cnt(result);
att->execute(&st, tra, 0,
"select count(*) from RDB$DB_CREATORS"
" where (RDB$USER_TYPE = ? and RDB$USER = ?) or (RDB$USER_TYPE = ? and RDB$USER = ?)",
SQL_DIALECT_V6, gr.getMetadata(), gr.getBuffer(), result.getMetadata(), result.getBuffer());
if (st->getState() & IStatus::STATE_ERRORS)
{
if (fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err))
{
// isc_dsql_relation_err when exec SQL - i.e. table RDB$DB_CREATORS
// is missing due to non-FB3 security DB
return false;
}
check("IAttachment::execute", &st);
//.........这里部分代码省略.........
示例6: throw
Str::Str(const MetaName& text) throw() :
Base(isc_arg_string, (ISC_STATUS)(IPTR) text.c_str()) { }
示例7: deleteRecord
void Applier::deleteRecord(thread_db* tdbb, TraNumber traNum,
const MetaName& relName,
ULONG length, const UCHAR* data)
{
jrd_tra* transaction = NULL;
if (!m_txnMap.get(traNum, transaction))
raiseError("Transaction %" SQUADFORMAT" is not found", traNum);
LocalThreadContext context(tdbb, transaction, m_request);
TRA_attach_request(transaction, m_request);
const auto relation = MET_lookup_relation(tdbb, relName);
if (!relation)
raiseError("Table %s is not found", relName.c_str());
if (!(relation->rel_flags & REL_scanned))
MET_scan_relation(tdbb, relation);
const auto format = findFormat(tdbb, relation, length);
record_param rpb;
rpb.rpb_relation = relation;
rpb.rpb_record = m_record;
const auto record = m_record =
VIO_record(tdbb, &rpb, format, m_request->req_pool);
rpb.rpb_format_number = format->fmt_version;
rpb.rpb_address = record->getData();
rpb.rpb_length = length;
record->copyDataFrom(data);
index_desc idx;
const bool indexed = lookupRecord(tdbb, relation, record, m_bitmap, idx);
bool found = false;
AutoPtr<Record> cleanup;
if (m_bitmap->getFirst())
{
record_param tempRpb = rpb;
tempRpb.rpb_record = NULL;
do {
tempRpb.rpb_number.setValue(m_bitmap->current());
if (VIO_get(tdbb, &tempRpb, transaction, m_request->req_pool) &&
(!indexed || compareKey(tdbb, relation, idx, record, tempRpb.rpb_record)))
{
if (found)
raiseError("Record in table %s is ambiguously identified using the primary/unique key", relName.c_str());
rpb = tempRpb;
found = true;
}
} while (m_bitmap->getNext());
cleanup = tempRpb.rpb_record;
}
if (found)
{
doDelete(tdbb, &rpb, transaction);
}
else
{
#ifdef RESOLVE_CONFLICTS
logWarning("Record being deleted from table %s does not exist, ignoring", relName.c_str());
#else
raiseError("Record in table %s cannot be located via the primary/unique key", relName.c_str());
#endif
}
}
示例8: updateRecord
void Applier::updateRecord(thread_db* tdbb, TraNumber traNum,
const MetaName& relName,
ULONG orgLength, const UCHAR* orgData,
ULONG newLength, const UCHAR* newData)
{
jrd_tra* transaction = NULL;
if (!m_txnMap.get(traNum, transaction))
raiseError("Transaction %" SQUADFORMAT" is not found", traNum);
LocalThreadContext context(tdbb, transaction, m_request);
TRA_attach_request(transaction, m_request);
const auto relation = MET_lookup_relation(tdbb, relName);
if (!relation)
raiseError("Table %s is not found", relName.c_str());
if (!(relation->rel_flags & REL_scanned))
MET_scan_relation(tdbb, relation);
const auto orgFormat = findFormat(tdbb, relation, orgLength);
record_param orgRpb;
orgRpb.rpb_relation = relation;
orgRpb.rpb_record = m_record;
const auto orgRecord = m_record =
VIO_record(tdbb, &orgRpb, orgFormat, m_request->req_pool);
orgRpb.rpb_format_number = orgFormat->fmt_version;
orgRpb.rpb_address = orgRecord->getData();
orgRpb.rpb_length = orgLength;
orgRecord->copyDataFrom(orgData);
BlobList sourceBlobs(getPool());
sourceBlobs.resize(orgFormat->fmt_count);
for (USHORT id = 0; id < orgFormat->fmt_count; id++)
{
dsc desc;
if (DTYPE_IS_BLOB(orgFormat->fmt_desc[id].dsc_dtype) &&
EVL_field(NULL, orgRecord, id, &desc))
{
const auto source = (bid*) desc.dsc_address;
if (!source->isEmpty())
sourceBlobs[id] = *source;
}
}
index_desc idx;
const auto indexed = lookupRecord(tdbb, relation, orgRecord, m_bitmap, idx);
bool found = false;
AutoPtr<Record> cleanup;
if (m_bitmap->getFirst())
{
record_param tempRpb = orgRpb;
tempRpb.rpb_record = NULL;
do {
tempRpb.rpb_number.setValue(m_bitmap->current());
if (VIO_get(tdbb, &tempRpb, transaction, m_request->req_pool) &&
(!indexed || compareKey(tdbb, relation, idx, orgRecord, tempRpb.rpb_record)))
{
if (found)
raiseError("Record in table %s is ambiguously identified using the primary/unique key", relName.c_str());
orgRpb = tempRpb;
found = true;
}
} while (m_bitmap->getNext());
cleanup = tempRpb.rpb_record;
}
const auto newFormat = findFormat(tdbb, relation, newLength);
record_param newRpb;
newRpb.rpb_relation = relation;
newRpb.rpb_record = NULL;
AutoPtr<Record> newRecord(VIO_record(tdbb, &newRpb, newFormat, m_request->req_pool));
newRpb.rpb_format_number = newFormat->fmt_version;
newRpb.rpb_address = newRecord->getData();
newRpb.rpb_length = newLength;
newRecord->copyDataFrom(newData);
if (found)
{
doUpdate(tdbb, &orgRpb, &newRpb, transaction, &sourceBlobs);
}
else
{
#ifdef RESOLVE_CONFLICTS
logWarning("Record being updated in table %s does not exist, inserting instead", relName.c_str());
doInsert(tdbb, &newRpb, transaction);
#else
//.........这里部分代码省略.........
示例9: insertRecord
void Applier::insertRecord(thread_db* tdbb, TraNumber traNum,
const MetaName& relName,
ULONG length, const UCHAR* data)
{
jrd_tra* transaction = NULL;
if (!m_txnMap.get(traNum, transaction))
raiseError("Transaction %" SQUADFORMAT" is not found", traNum);
LocalThreadContext context(tdbb, transaction, m_request);
TRA_attach_request(transaction, m_request);
const auto relation = MET_lookup_relation(tdbb, relName);
if (!relation)
raiseError("Table %s is not found", relName.c_str());
if (!(relation->rel_flags & REL_scanned))
MET_scan_relation(tdbb, relation);
const auto format = findFormat(tdbb, relation, length);
record_param rpb;
rpb.rpb_relation = relation;
rpb.rpb_record = m_record;
const auto record = m_record =
VIO_record(tdbb, &rpb, format, m_request->req_pool);
rpb.rpb_format_number = format->fmt_version;
rpb.rpb_address = record->getData();
rpb.rpb_length = length;
record->copyDataFrom(data);
try
{
doInsert(tdbb, &rpb, transaction);
return;
}
catch (const status_exception& ex)
{
// Uniqueness violation is handled below, other exceptions are re-thrown
if (ex.value()[1] != isc_unique_key_violation &&
ex.value()[1] != isc_no_dup)
{
throw;
}
fb_utils::init_status(tdbb->tdbb_status_vector);
}
bool found = false;
#ifdef RESOLVE_CONFLICTS
index_desc idx;
const auto indexed = lookupRecord(tdbb, relation, record, m_bitmap, idx);
AutoPtr<Record> cleanup;
if (m_bitmap->getFirst())
{
record_param tempRpb = rpb;
tempRpb.rpb_record = NULL;
do {
tempRpb.rpb_number.setValue(m_bitmap->current());
if (VIO_get(tdbb, &tempRpb, transaction, m_request->req_pool) &&
(!indexed || compareKey(tdbb, relation, idx, record, tempRpb.rpb_record)))
{
if (found)
raiseError("Record in table %s is ambiguously identified using the primary/unique key", relName.c_str());
rpb = tempRpb;
found = true;
}
} while (m_bitmap->getNext());
cleanup = tempRpb.rpb_record;
}
#endif
if (found)
{
logWarning("Record being inserted into table %s already exists, updating instead", relName.c_str());
record_param newRpb;
newRpb.rpb_relation = relation;
newRpb.rpb_record = NULL;
AutoPtr<Record> newRecord(VIO_record(tdbb, &newRpb, format, m_request->req_pool));
newRpb.rpb_format_number = format->fmt_version;
newRpb.rpb_address = newRecord->getData();
newRpb.rpb_length = length;
newRecord->copyDataFrom(data);
doUpdate(tdbb, &rpb, &newRpb, transaction, NULL);
}
else
{
//.........这里部分代码省略.........
示例10: checkCreateDatabaseGrant
bool checkCreateDatabaseGrant(const MetaName& userName, const MetaName& trustedRole,
const MetaName& sqlRole, const char* securityDb)
{
if (userName == DBA_USER_NAME)
return true;
RefPtr<IAttachment> att;
RefPtr<ITransaction> tra;
bool hasDb = openDb(securityDb, att, tra);
FbLocalStatus st;
MetaName role(sqlRole);
if (hasDb && role.hasData())
{
const UCHAR info[] = { isc_info_db_sql_dialect, isc_info_end };
UCHAR buffer[BUFFER_TINY];
att->getInfo(&st, sizeof(info), info, sizeof(buffer), buffer);
check("IAttachment::getInfo", &st);
int dialect = SQL_DIALECT_V5; // reasonable default
const UCHAR* p = buffer;
while (*p != isc_info_end && *p != isc_info_truncated && p < buffer + sizeof(buffer))
{
const UCHAR item = (UCHAR) *p++;
const USHORT length = gds__vax_integer(p, sizeof(USHORT));
p += sizeof(USHORT);
switch (item)
{
case isc_info_db_sql_dialect:
dialect = gds__vax_integer(p, length);
break;
}
p += length;
}
UserId::makeRoleName(role, dialect);
// We need to check is role granted to userName in security DB
const char* sql = "select count(*) from RDB$USER_PRIVILEGES "
"where RDB$USER = ? and RDB$RELATION_NAME = ? and RDB$PRIVILEGE = 'M'";
Message prm;
Field<Varying> u(prm, MAX_SQL_IDENTIFIER_LEN);
Field<Varying> r(prm, MAX_SQL_IDENTIFIER_LEN);
u = userName.c_str();
r = role.c_str();
Message result;
Field<ISC_INT64> cnt(result);
att->execute(&st, tra, 0, sql, SQL_DIALECT_V6, prm.getMetadata(), prm.getBuffer(),
result.getMetadata(), result.getBuffer());
if (st->getState() & IStatus::STATE_ERRORS)
{
// isc_dsql_relation_err when exec SQL - i.e. table RDB$USER_PRIVILEGES
// is missing due to non-FB security DB
if (!fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err))
check("IAttachment::execute", &st);
role = "";
}
else if (cnt == 0)
role = "";
}
else
role = trustedRole;
if (role == ADMIN_ROLE)
return true;
if (!hasDb)
return false;
// check db creators table
Message gr;
Field<ISC_SHORT> uType(gr);
Field<Varying> u(gr, MAX_SQL_IDENTIFIER_LEN);
Field<ISC_SHORT> rType(gr);
Field<Varying> r(gr, MAX_SQL_IDENTIFIER_LEN);
uType = obj_user;
u = userName.c_str();
rType = role.hasData() ? obj_sql_role : 255;
r = role.c_str();
Message result;
Field<ISC_INT64> cnt(result);
att->execute(&st, tra, 0,
"select count(*) from RDB$DB_CREATORS"
" where (RDB$USER_TYPE = ? and RDB$USER = ?) or (RDB$USER_TYPE = ? and RDB$USER = ?)",
SQL_DIALECT_V6, gr.getMetadata(), gr.getBuffer(), result.getMetadata(), result.getBuffer());
if (st->getState() & IStatus::STATE_ERRORS)
{
if (fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err))
{
// isc_dsql_relation_err when exec SQL - i.e. table RDB$DB_CREATORS
// is missing due to non-FB3 security DB
//.........这里部分代码省略.........
示例11: printInversion
void RecordSource::printInversion(thread_db* tdbb, const InversionNode* inversion,
string& plan, bool detailed, unsigned level, bool navigation)
{
if (detailed)
plan += printIndent(++level);
switch (inversion->type)
{
case InversionNode::TYPE_AND:
if (detailed)
plan += "Bitmap And";
printInversion(tdbb, inversion->node1, plan, detailed, level);
printInversion(tdbb, inversion->node2, plan, detailed, level);
break;
case InversionNode::TYPE_OR:
case InversionNode::TYPE_IN:
if (detailed)
plan += "Bitmap Or";
printInversion(tdbb, inversion->node1, plan, detailed, level);
printInversion(tdbb, inversion->node2, plan, detailed, level);
break;
case InversionNode::TYPE_DBKEY:
if (detailed)
plan += "DBKEY";
break;
case InversionNode::TYPE_INDEX:
{
const IndexRetrieval* const retrieval = inversion->retrieval;
const jrd_rel* const relation = retrieval->irb_relation;
MetaName indexName;
if (retrieval->irb_name && retrieval->irb_name->hasData())
indexName = *retrieval->irb_name;
else
indexName.printf("<index id %d>", retrieval->irb_index + 1);
if (detailed)
{
if (!navigation)
plan += "Bitmap" + printIndent(++level);
const index_desc& idx = retrieval->irb_desc;
const bool uniqueIdx = (idx.idx_flags & idx_unique);
const USHORT segCount = idx.idx_count;
const USHORT minSegs = MIN(retrieval->irb_lower_count, retrieval->irb_upper_count);
const USHORT maxSegs = MAX(retrieval->irb_lower_count, retrieval->irb_upper_count);
const bool equality = (retrieval->irb_generic & irb_equality);
const bool partial = (retrieval->irb_generic & irb_partial);
const bool fullscan = (maxSegs == 0);
const bool unique = uniqueIdx && equality && (minSegs == segCount);
string bounds;
if (!unique && !fullscan)
{
if (retrieval->irb_lower_count && retrieval->irb_upper_count)
{
if (equality)
{
if (partial)
bounds.printf(" (partial match: %d/%d)", maxSegs, segCount);
else
bounds.printf(" (full match)");
}
else
{
bounds.printf(" (lower bound: %d/%d, upper bound: %d/%d)",
retrieval->irb_lower_count, segCount,
retrieval->irb_upper_count, segCount);
}
}
else if (retrieval->irb_lower_count)
{
bounds.printf(" (lower bound: %d/%d)",
retrieval->irb_lower_count, segCount);
}
else if (retrieval->irb_upper_count)
{
bounds.printf(" (upper bound: %d/%d)",
retrieval->irb_upper_count, segCount);
}
}
plan += "Index " + printName(tdbb, indexName.c_str()) +
(fullscan ? " Full" : unique ? " Unique" : " Range") + " Scan" + bounds;
}
else
{
plan += (plan.hasData() ? ", " : "") + printName(tdbb, indexName.c_str(), false);
}
}
break;
default:
fb_assert(false);
//.........这里部分代码省略.........