2006-07-17 19:44:18 +02:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Initial
|
|
|
|
* Developer's Public License Version 1.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed AS IS,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing rights
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Dmitry Yemanov
|
|
|
|
* for the Firebird Open Source RDBMS project.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 Dmitry Yemanov <dimitr@users.sf.net>
|
|
|
|
* and all contributors signed below.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
2009-10-21 02:42:38 +02:00
|
|
|
* Adriano dos Santos Fernandes
|
2006-07-17 19:44:18 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "firebird.h"
|
2006-12-04 22:36:29 +01:00
|
|
|
#include "ids.h"
|
|
|
|
#include "../jrd/constants.h"
|
2010-10-13 12:39:52 +02:00
|
|
|
#include "../common/gdsassert.h"
|
2006-07-17 19:44:18 +02:00
|
|
|
#include "../jrd/jrd.h"
|
2010-10-12 10:02:57 +02:00
|
|
|
#include "../common/dsc.h"
|
2006-07-17 19:44:18 +02:00
|
|
|
#include "../jrd/exe.h"
|
2006-12-04 22:36:29 +01:00
|
|
|
#include "../jrd/ini.h"
|
2006-07-17 19:44:18 +02:00
|
|
|
#include "../jrd/req.h"
|
|
|
|
#include "../jrd/rse.h"
|
|
|
|
#include "../jrd/val.h"
|
2006-07-18 08:08:15 +02:00
|
|
|
#include "../jrd/cmp_proto.h"
|
2006-07-17 19:44:18 +02:00
|
|
|
#include "../jrd/err_proto.h"
|
2006-12-04 22:36:29 +01:00
|
|
|
#include "../jrd/evl_proto.h"
|
|
|
|
#include "../jrd/lck_proto.h"
|
2006-07-17 19:44:18 +02:00
|
|
|
#include "../jrd/met_proto.h"
|
2006-12-04 22:36:29 +01:00
|
|
|
#include "../jrd/mov_proto.h"
|
2006-07-17 19:44:18 +02:00
|
|
|
#include "../jrd/vio_proto.h"
|
|
|
|
|
2014-07-31 10:56:53 +02:00
|
|
|
#include "../jrd/Monitoring.h"
|
2006-07-17 19:44:18 +02:00
|
|
|
#include "../jrd/RecordBuffer.h"
|
|
|
|
#include "../jrd/VirtualTable.h"
|
|
|
|
|
|
|
|
using namespace Jrd;
|
2008-08-27 14:20:47 +02:00
|
|
|
using namespace Firebird;
|
2006-07-17 19:44:18 +02:00
|
|
|
|
2006-07-17 22:18:40 +02:00
|
|
|
|
2006-12-04 22:36:29 +01:00
|
|
|
void VirtualTable::erase(thread_db* tdbb, record_param* rpb)
|
2006-07-17 19:44:18 +02:00
|
|
|
{
|
2006-12-04 22:36:29 +01:00
|
|
|
SET_TDBB(tdbb);
|
|
|
|
|
2007-12-03 16:46:39 +01:00
|
|
|
Database* dbb = tdbb->getDatabase();
|
2006-12-04 22:36:29 +01:00
|
|
|
fb_assert(dbb);
|
|
|
|
|
|
|
|
jrd_rel* relation = rpb->rpb_relation;
|
|
|
|
fb_assert(relation);
|
|
|
|
|
|
|
|
dsc desc;
|
2008-04-23 10:00:27 +02:00
|
|
|
lck_t lock_type;
|
|
|
|
|
|
|
|
if (relation->rel_id == rel_mon_attachments)
|
|
|
|
{
|
|
|
|
// Get attachment id
|
|
|
|
if (!EVL_field(relation, rpb->rpb_record, f_mon_att_id, &desc))
|
|
|
|
return;
|
2014-01-11 10:10:44 +01:00
|
|
|
|
|
|
|
// Ignore attempt to stop system attachment
|
|
|
|
dsc sysFlag;
|
2014-01-13 03:02:28 +01:00
|
|
|
if (EVL_field(relation, rpb->rpb_record, f_mon_att_sys_flag, &sysFlag) &&
|
2016-11-11 15:59:55 +01:00
|
|
|
MOV_get_long(tdbb, &sysFlag, 0) != 0)
|
2014-01-11 10:10:44 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-23 10:00:27 +02:00
|
|
|
lock_type = LCK_attachment;
|
|
|
|
}
|
|
|
|
else if (relation->rel_id == rel_mon_statements)
|
|
|
|
{
|
2012-12-23 08:10:56 +01:00
|
|
|
// Get attachment id
|
|
|
|
if (!EVL_field(relation, rpb->rpb_record, f_mon_stmt_att_id, &desc))
|
2008-04-23 10:00:27 +02:00
|
|
|
return;
|
|
|
|
lock_type = LCK_cancel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-27 14:20:47 +02:00
|
|
|
ERR_post(Arg::Gds(isc_read_only));
|
2014-02-18 02:49:07 +01:00
|
|
|
return;
|
2008-04-23 10:00:27 +02:00
|
|
|
}
|
2007-01-07 16:15:06 +01:00
|
|
|
|
2016-11-11 15:59:55 +01:00
|
|
|
const SINT64 id = MOV_get_int64(tdbb, &desc, 0);
|
2006-12-04 22:36:29 +01:00
|
|
|
|
|
|
|
// Post a blocking request
|
2015-10-19 15:32:02 +02:00
|
|
|
Lock temp_lock(tdbb, sizeof(SINT64), lock_type);
|
2016-05-09 22:41:33 +02:00
|
|
|
temp_lock.setKey(id);
|
2006-12-04 22:36:29 +01:00
|
|
|
|
2008-04-26 12:29:52 +02:00
|
|
|
ThreadStatusGuard temp_status(tdbb);
|
2008-04-23 10:00:27 +02:00
|
|
|
|
2008-01-26 14:17:19 +01:00
|
|
|
if (LCK_lock(tdbb, &temp_lock, LCK_EX, -1))
|
2006-12-04 22:36:29 +01:00
|
|
|
LCK_release(tdbb, &temp_lock);
|
2006-07-17 19:44:18 +02:00
|
|
|
}
|
|
|
|
|
2006-07-17 22:18:40 +02:00
|
|
|
|
2009-11-01 11:58:16 +01:00
|
|
|
void VirtualTable::modify(thread_db* /*tdbb*/, record_param* /*org_rpb*/, record_param* /*new_rpb*/)
|
2006-07-17 19:44:18 +02:00
|
|
|
{
|
2009-10-21 02:42:38 +02:00
|
|
|
ERR_post(Arg::Gds(isc_read_only));
|
|
|
|
}
|
2006-07-17 19:44:18 +02:00
|
|
|
|
2006-07-21 11:31:19 +02:00
|
|
|
|
2009-11-01 11:58:16 +01:00
|
|
|
void VirtualTable::store(thread_db* /*tdbb*/, record_param* /*rpb*/)
|
2009-10-21 02:42:38 +02:00
|
|
|
{
|
|
|
|
ERR_post(Arg::Gds(isc_read_only));
|
2006-07-17 19:44:18 +02:00
|
|
|
}
|