8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-02-02 09:20:39 +01:00
This commit is contained in:
robocop 2015-03-13 15:26:22 +00:00
parent 51a6b75a9a
commit 939feab036
25 changed files with 66 additions and 56 deletions

View File

@ -2,7 +2,7 @@
* PROGRAM: Object oriented API samples.
* MODULE: 01.create.cpp
* DESCRIPTION: A sample of creating new database and new table in it.
* Run second time (whene database already exists) to see
* Run second time (when database already exists) to see
* how FbException is caught and handled by this code.
*
* Example for the following interfaces:

View File

@ -71,7 +71,8 @@ StatusVector::ImplStatusVector::ImplStatusVector(const ISC_STATUS* s) throw() :
}
}
StatusVector::ImplStatusVector::ImplStatusVector(const IStatus* s) throw() : Base::ImplBase(0, 0)
StatusVector::ImplStatusVector::ImplStatusVector(const IStatus* s) throw() :
Base::ImplBase(0, 0)
{
fb_assert(s);
@ -84,7 +85,8 @@ StatusVector::ImplStatusVector::ImplStatusVector(const IStatus* s) throw() : Bas
append(s->getWarnings(), FB_NELEM(m_status_vector) - 1);
}
StatusVector::ImplStatusVector::ImplStatusVector(const Exception& ex) throw() : Base::ImplBase(0, 0)
StatusVector::ImplStatusVector::ImplStatusVector(const Exception& ex) throw() :
Base::ImplBase(0, 0)
{
assign(ex);
}

View File

@ -49,7 +49,7 @@ public:
: HalfStaticArray<ISC_STATUS, S>()
{ }
SimpleStatusVector(MemoryPool& p)
explicit SimpleStatusVector(MemoryPool& p)
: HalfStaticArray<ISC_STATUS, S>(p)
{ }
};
@ -60,7 +60,7 @@ template <unsigned S>
class DynamicVector : private SimpleStatusVector<S>
{
public:
DynamicVector(MemoryPool& p)
explicit DynamicVector(MemoryPool& p)
: SimpleStatusVector<S>(p)
{
fb_utils::init_status(this->getBuffer(3));
@ -192,7 +192,7 @@ public:
}
public:
BaseStatus(MemoryPool& p)
explicit BaseStatus(MemoryPool& p)
: errors(p), warnings(p)
{
init();

View File

@ -1398,7 +1398,7 @@ bool Mnt::get()
TEXT device[128], mount_point[128], m_type[16], opts[256], ftime[128];
const int n = fscanf(mnt_tab.mtab, "%s %s %s %s %s ", device, mount_point, type, opts, ftime);
if (n<5)
if (n < 5)
return false;
mount = mount_point;

View File

@ -234,7 +234,7 @@ bool touchFile(const char* pathname)
#endif
}
// check if OS have support for IPv6 protocol
// check if OS has support for IPv6 protocol
bool isIPv6supported()
{
#ifdef ANDROID
@ -281,7 +281,7 @@ FILE* fopen(const char* pathname, const char* mode)
return f;
}
static void makeUniqueFileId(struct stat& statistics, UCharBuffer& id)
static void makeUniqueFileId(const struct stat& statistics, UCharBuffer& id)
{
const size_t len1 = sizeof(statistics.st_dev);
const size_t len2 = sizeof(statistics.st_ino);

View File

@ -1137,7 +1137,7 @@ unsigned int mergeStatus(ISC_STATUS* const dest, unsigned int space,
{
const ISC_STATUS* s;
unsigned int copied = 0;
int state = from->getState();
const int state = from->getState();
ISC_STATUS* to = dest;
if (state & Firebird::IStatus::STATE_ERRORS)

View File

@ -124,6 +124,7 @@ void ExecInSecurityDb::executeInSecurityDb(jrd_tra* localTransaction)
if (!secDbContext)
{
Attachment* lAtt = localTransaction->getAttachment();
fb_assert(lAtt && lAtt->att_database && lAtt->att_database->dbb_config); // paranoid check
const char* secDb = lAtt->att_database->dbb_config->getSecurityDatabase();
ClumpletWriter dpb(ClumpletWriter::WideTagged, MAX_DPB_SIZE, isc_dpb_version2);
if (lAtt->att_user)
@ -7061,7 +7062,7 @@ void AlterRelationNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratc
dsql_rel* relation;
relation = METD_get_relation(dsqlScratch->getTransaction(), dsqlScratch, name);
if (!relation || (relation && (relation->rel_flags & REL_view)))
if (!relation || (relation->rel_flags & REL_view))
{
status_exception::raise(
Arg::Gds(isc_sqlerr) << Arg::Num(-607) <<

View File

@ -6843,7 +6843,7 @@ void DerivedFieldNode::genBlr(DsqlCompilerScratch* dsqlScratch)
(context->ctx_flags & CTX_cursor) &&
val->is<FieldNode>())
{
// ASF: FieldNode::execute do not verify rpb_number.isValid(), and due to system triggers
// ASF: FieldNode::execute does not verify rpb_number.isValid(), and due to system triggers
// and also singular queries, we cannot start to do it. So to fix CORE-4488, we introduce
// the usage of blr_derived_expr for cursor fields, which in practice prefixes the
// FieldNode::execute by a test of rpb_number.isValid().

View File

@ -442,8 +442,9 @@ void CMP_t_start( gpre_tra* trans)
{
*p++ = lock_block->rrl_lock_mode;
const char* q = lock_block->rrl_relation->rel_symbol->sym_string;
*p++ = static_cast<char>(strlen(q));
while (*q)
UCHAR temp = static_cast<UCHAR>(strlen(q));
*p++ = temp;
while (*q && temp-- > 0)
*p++ = *q++;
*p++ = lock_block->rrl_lock_level;
}
@ -1016,18 +1017,19 @@ static void cmp_loop( gpre_req* request)
CME_rse(selection, request);
request->add_byte(blr_begin);
const bool isReturning = request->req_flags & REQ_sql_returning;
gpre_nod* node = (req_node->nod_type == nod_list) ? req_node->nod_arg[0] : req_node;
switch (node->nod_type)
{
case nod_modify:
{
const int blr_op = (request->req_flags & REQ_sql_returning) ? blr_modify2 : blr_modify;
const int blr_op = isReturning ? blr_modify2 : blr_modify;
request->add_byte(blr_op);
request->add_byte(for_context->ctx_internal);
request->add_byte(update_context->ctx_internal);
cmp_assignment_list(node->nod_arg[0], request);
if (request->req_flags & REQ_sql_returning)
if (isReturning)
cmp_returning(request, node->nod_arg[1]);
}
break;
@ -1035,7 +1037,7 @@ static void cmp_loop( gpre_req* request)
cmp_store(request, node);
break;
case nod_erase:
if (request->req_flags & REQ_sql_returning)
if (isReturning)
{
request->add_byte(blr_begin);
cmp_returning(request, node->nod_arg[0]);

View File

@ -4817,7 +4817,7 @@ static act* act_upsert(void)
gpre_req* request = MSC_request(REQ_mass_update);
request->req_trans = transaction;
gpre_ctx* context = SQE_context(request);
gpre_ctx* const context = SQE_context(request);
gpre_rel* relation = context->ctx_relation;
int count = 0;

View File

@ -164,7 +164,7 @@ const int UNKNOWN_LEN = 20; // Unknown type: %d
const int MAX_TERMS = 10; // max # of terms in an interactive cmd
const char* ISQL_COUNTERS_SET = "CurrentMemory, MaxMemory, RealTime, UserTime, Buffers, Reads, Writes, Fetches";
#define ISQL_COUNTERS 8
const int ISQL_COUNTERS = 8;
namespace IcuUtil
@ -2596,9 +2596,12 @@ static processing_state bulk_insert_hack(const char* command)
return (SKIP);
}
unsigned prepFlags = Firebird::IStatement::PREPARE_PREFETCH_METADATA |
(setValues.Plan ? Firebird::IStatement::PREPARE_PREFETCH_DETAILED_PLAN : 0);
global_Stmt = DB->prepare(fbStatus, setValues.Autocommit ? D__trans : M__trans, 0, command,
isqlGlob.SQL_dialect, Firebird::IStatement::PREPARE_PREFETCH_METADATA |
(setValues.Plan ? Firebird::IStatement::PREPARE_PREFETCH_DETAILED_PLAN : 0));
isqlGlob.SQL_dialect, prepFlags);
if (failed())
{
if (isqlGlob.SQL_dialect == SQL_DIALECT_V6_TRANSITION && Input_file)
@ -3272,7 +3275,7 @@ static processing_state bulk_insert_hack(const char* command)
if (done)
{
// Save whatever we were able to pump, except when the failed was the commit itself.
// Save whatever we were able to pump, except when the failure was the commit itself.
if (M__trans)
{
if (commit_failedM)
@ -4383,7 +4386,7 @@ static processing_state edit(const TEXT* const* cmd)
Ofp.close();
PathName tmpfile = Ofp.fileName(false);
gds__edit(tmpfile.c_str(), 0);
Ofp.init(fopen(tmpfile.c_str(), "r+"), tmpfile.c_str(), tmpfile.c_str()); // We don't check for failed.
Ofp.init(fopen(tmpfile.c_str(), "r+"), tmpfile.c_str(), tmpfile.c_str()); // We don't check for failure.
Filelist->Ifp().init(Ofp);
Input_file = true;
getColumn = -1;
@ -4406,7 +4409,7 @@ static processing_state end_trans()
* either commit or rollback
*
* Called by newtrans, createdb, newdb;
* Returns success or failed.
* Returns success or failure.
*
**************************************/
@ -7745,7 +7748,7 @@ static processing_state print_line(Firebird::IMessageMetadata* message, UCHAR* b
isqlGlob.printf("%s%s", line, NEWLINE);
// If blobdisplay is not wanted, set varnum back to -1
// If blobdisplay is not wanted, set varnum back to 0
if (setValues.Doblob == NO_BLOBS)
varnum = 0;
@ -7932,7 +7935,7 @@ static void process_header(Firebird::IMessageMetadata* msg, const unsigned pad[]
// p r o c e s s _ p l a n
// ***********************
// Retrieve and show the server's execution plan.
// We don't consider critical a failed to get the plan, so we don't return
// We don't consider critical a failure to get the plan, so we don't return
// any result to the caller.
static void process_plan()
{
@ -8064,7 +8067,7 @@ static SLONG process_record_count(const int statement_type)
// p r o c e s s _ r e q u e s t _ t y p e
// ***************************************
// Retrieve the statement type according to the DSQL layer.
// A failed is indicated by returning zero.
// A failure is indicated by returning zero.
static int process_request_type()
{
if (!global_Stmt)

View File

@ -126,7 +126,7 @@ namespace Jrd
memcpy(getData(), data, getLength());
}
void copyDataTo(UCHAR* data)
void copyDataTo(UCHAR* data) const
{
memcpy(data, getData(), getLength());
}
@ -179,7 +179,7 @@ namespace Jrd
class AutoTempRecord
{
public:
AutoTempRecord(Record* record = NULL)
explicit AutoTempRecord(Record* record = NULL)
: m_record(record)
{
// validate record and its flag

View File

@ -3841,7 +3841,7 @@ static BufferDesc* get_buffer(thread_db* tdbb, const PageNumber page, SyncType s
QUE_DELETE(bdb->bdb_que);
QUE_INSERT(bcb->bcb_pending, bdb->bdb_que);
const bool needCleanup = bdb->bdb_flags & (BDB_dirty | BDB_db_dirty) ||
const bool needCleanup = (bdb->bdb_flags & (BDB_dirty | BDB_db_dirty)) ||
QUE_NOT_EMPTY(bdb->bdb_higher) || QUE_NOT_EMPTY(bdb->bdb_lower);
if (needCleanup)

View File

@ -3116,7 +3116,7 @@ static rhd* locate_space(thread_db* tdbb,
// Look for space anywhere
// Make few tries to lock consecutive data pages without waiting. In highly
// concurrent environment with shared page cache it could be faster then wait
// concurrent environment with shared page cache it could be faster than wait
// in OS for first candidate page.
int tries = dbb->dbb_config->getSharedCache() ? 8 : 0;

View File

@ -6016,7 +6016,7 @@ static JAttachment* initAttachment(thread_db* tdbb, const PathName& expanded_nam
{
/**************************************
*
* i n i t
* i n i t A t t a c h m e n t
*
**************************************
*
@ -6025,7 +6025,7 @@ static JAttachment* initAttachment(thread_db* tdbb, const PathName& expanded_nam
* Upon entry mutex dbInitMutex must be locked.
*
**************************************/
RefDeb(DEB_AR_JATT, "jrd/init()");
RefDeb(DEB_AR_JATT, "jrd/initAttachment()");
SET_TDBB(tdbb);
fb_assert(dbInitMutex->locked());

View File

@ -909,7 +909,7 @@ void OPT_compile_relation(thread_db* tdbb, jrd_rel* relation, CompilerScratch* c
if (needIndices && !relation->rel_file && !relation->isVirtual())
{
csb->csb_rpt[stream].csb_indices = BTR_all(tdbb, relation, &tail->csb_idx, relPages);
tail->csb_indices = BTR_all(tdbb, relation, &tail->csb_idx, relPages);
if (tail->csb_plan)
mark_indices(tail, relation->rel_id);
@ -917,9 +917,9 @@ void OPT_compile_relation(thread_db* tdbb, jrd_rel* relation, CompilerScratch* c
sort_indices_by_selectivity(tail);
}
else
csb->csb_rpt[stream].csb_indices = 0;
tail->csb_indices = 0;
csb->csb_rpt[stream].csb_cardinality =
tail->csb_cardinality =
get_cardinality(tdbb, relation, CMP_format(tdbb, csb, stream));
}
@ -2282,7 +2282,7 @@ static RecordSource* gen_retrieval(thread_db* tdbb,
else if (relation->isVirtual())
{
// Virtual table: monitoring or security
switch(relation->rel_id)
switch (relation->rel_id)
{
case rel_global_auth_mapping:
rsb = FB_NEW(*tdbb->getDefaultPool()) GlobalMappingScan(csb, alias, stream, relation);
@ -3070,7 +3070,7 @@ static double get_cardinality(thread_db* tdbb, jrd_rel* relation, const Format*
if (relation->isVirtual())
{
// Just a dumb estimation
return (double) 100;
return 100.0;
}
if (relation->rel_file)

View File

@ -2333,7 +2333,7 @@ USHORT PageManager::getTempPageSpaceID(thread_db* tdbb)
}
}
return tempPageSpaceID;
};
}
ULONG PAG_page_count(Database* database, PageCountCallback* cb)
{

View File

@ -508,7 +508,7 @@ ITraceLogWriter* TraceInitInfoImpl::getLogWriter()
void* TraceServiceImpl::getServiceID()
{
return (void*)m_svc;
return (void*) m_svc;
}
const char* TraceServiceImpl::getServiceMgr()

View File

@ -143,7 +143,8 @@ inline unsigned short SockAddr::family() const
inline unsigned short SockAddr::port() const
{
const struct sockaddr* sa = (const struct sockaddr*) data;
switch(sa->sa_family) {
switch (sa->sa_family)
{
case AF_INET:
return ntohs(((const struct sockaddr_in*) data)->sin_port);
case AF_INET6:
@ -156,7 +157,8 @@ inline unsigned short SockAddr::port() const
inline void SockAddr::setPort(unsigned short x)
{
const struct sockaddr* sa = (const struct sockaddr*) data;
switch(sa->sa_family) {
switch (sa->sa_family)
{
case AF_INET:
((struct sockaddr_in*) data)->sin_port = htons(x);
return;

View File

@ -1855,7 +1855,7 @@ Firebird::ITransaction* Statement::execute(CheckStatusWrapper* status, Firebird:
ResultSet* Statement::openCursor(CheckStatusWrapper* status, Firebird::ITransaction* apiTra,
IMessageMetadata* inMetadata, void* inBuffer, IMessageMetadata* outFormat, unsigned int flags)
IMessageMetadata* inMetadata, void* inBuffer, IMessageMetadata* outFormat, unsigned int /*flags*/)
{
/**************************************
*

View File

@ -1779,10 +1779,8 @@ THREAD_ENTRY_DECLARE forkThread(THREAD_ENTRY_PARAM arg)
return 0;
}
#endif
#ifdef WIN_NT
// Windows does not have an inet_aton function.
bool inet_aton(const char* name, in_addr* address)
{

View File

@ -1360,7 +1360,7 @@ Firebird::ICryptKey* SrvAuthBlock::newKey(Firebird::CheckStatusWrapper* status)
return NULL;
}
void rem_port::versionInfo(Firebird::string& version)
void rem_port::versionInfo(Firebird::string& version) const
{
version.printf("%s/%s", FB_VERSION, port_version->str_data);
#ifndef WIRE_COMPRESS_SUPPORT
@ -1382,7 +1382,7 @@ namespace {
class ZLib
{
public:
ZLib(Firebird::MemoryPool&)
explicit ZLib(Firebird::MemoryPool&)
{
#ifdef WIN_NT
const char* name = "zlib1.dll";
@ -1520,10 +1520,11 @@ bool REMOTE_inflate(rem_port* port, PacketReceive* packet_receive, UCHAR* buffer
return false;
}
if (strm.next_in != &port->port_compressed[REM_RECV_OFFSET(port->port_buff_size)])
UCHAR* compressed = &port->port_compressed[REM_RECV_OFFSET(port->port_buff_size)];
if (strm.next_in != compressed)
{
memmove(&port->port_compressed[REM_RECV_OFFSET(port->port_buff_size)], strm.next_in, strm.avail_in);
strm.next_in = &port->port_compressed[REM_RECV_OFFSET(port->port_buff_size)];
memmove(compressed, strm.next_in, strm.avail_in);
strm.next_in = compressed;
}
}
else
@ -1560,7 +1561,7 @@ bool REMOTE_deflate(XDR* xdrs, ProtoWrite* proto_write, PacketSend* packet_send,
z_stream& strm = port->port_send_stream;
strm.avail_in = xdrs->x_private - xdrs->x_base;
strm.next_in = (Bytef*)xdrs->x_base;
strm.next_in = (Bytef*) xdrs->x_base;
if (!strm.next_out)
{
@ -1666,6 +1667,7 @@ void rem_port::initCompression()
zlib().inflateEnd(&port_recv_stream);
throw;
}
memset(port_compressed, 0, port_buff_size * 2);
port_recv_stream.next_in = &port_compressed[REM_RECV_OFFSET(port_buff_size)];

View File

@ -664,10 +664,10 @@ public:
void set(unsigned keyLength, const void* key)
{
assign(reinterpret_cast<const UCHAR*>(key), keyLength);
assign(static_cast<const UCHAR*>(key), keyLength);
}
const void* get(unsigned* length)
const void* get(unsigned* length) const
{
if (getCount() > 0)
{
@ -1019,7 +1019,7 @@ public:
void linkParent(rem_port* const parent);
void unlinkParent();
const Firebird::RefPtr<Config>& getPortConfig() const;
void versionInfo(Firebird::string& version);
void versionInfo(Firebird::string& version) const;
bool extractNewKeys(CSTRING* to, bool flagPlugList = false)
{

View File

@ -3220,7 +3220,7 @@ ISC_STATUS rem_port::execute_statement(P_OP op, P_SQLDATA* sqldata, PACKET* send
this->port_statement->rsr_format = this->port_statement->rsr_select_format;
sendL->p_operation = op_sql_response;
sendL->p_sqldata.p_sqldata_messages = (status_vector.getState() & Firebird::IStatus::STATE_ERRORS || !out_msg) ? 0 : 1;
sendL->p_sqldata.p_sqldata_messages = ((status_vector.getState() & Firebird::IStatus::STATE_ERRORS) || !out_msg) ? 0 : 1;
this->send_partial(sendL);
}

View File

@ -727,7 +727,7 @@ namespace
RefPtr<ConfigFile> conf;
bool required;
PluginLoadInfo(const char* pluginName)
explicit PluginLoadInfo(const char* pluginName)
{
// define default values for plugin ...
curModule = fb_utils::getPrefix(IConfigManager::DIR_PLUGINS, pluginName);