|
From: <ro...@us...> - 2014-04-04 06:39:13
|
Revision: 59351
http://sourceforge.net/p/firebird/code/59351
Author: robocop
Date: 2014-04-04 06:39:09 +0000 (Fri, 04 Apr 2014)
Log Message:
-----------
The 0th generator becomes unnamed. Only internal requests can access it (zero length names are not allowed from outside). RDB$GENERATORS is no longer a reserved name.System generators cannot be changed by user requests, but can be queried with gen_id(g, 0) if the permissions (ACL) allow that. We don't track dependencies on sys generators, it's not necessary.
Modified Paths:
--------------
firebird/trunk/lang_helpers/gds_codes.ftn
firebird/trunk/lang_helpers/gds_codes.pas
firebird/trunk/src/dsql/DdlNodes.epp
firebird/trunk/src/dsql/ExprNodes.cpp
firebird/trunk/src/dsql/ExprNodes.h
firebird/trunk/src/dsql/StmtNodes.cpp
firebird/trunk/src/dsql/StmtNodes.h
firebird/trunk/src/include/gen/codetext.h
firebird/trunk/src/include/gen/iberror.h
firebird/trunk/src/include/gen/msgs.h
firebird/trunk/src/include/gen/sql_code.h
firebird/trunk/src/include/gen/sql_state.h
firebird/trunk/src/jrd/Attachment.h
firebird/trunk/src/jrd/constants.h
firebird/trunk/src/jrd/dfw.epp
firebird/trunk/src/jrd/ini.epp
firebird/trunk/src/jrd/jrd.cpp
firebird/trunk/src/jrd/met.epp
firebird/trunk/src/jrd/met_proto.h
firebird/trunk/src/jrd/vio.cpp
firebird/trunk/src/msgs/facilities2.sql
firebird/trunk/src/msgs/messages2.sql
firebird/trunk/src/msgs/system_errors2.sql
Modified: firebird/trunk/lang_helpers/gds_codes.ftn
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.ftn 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/lang_helpers/gds_codes.ftn 2014-04-04 06:39:09 UTC (rev 59351)
@@ -1562,6 +1562,8 @@
PARAMETER (GDS__forupdate_systbl = 335545074)
INTEGER*4 GDS__forupdate_temptbl
PARAMETER (GDS__forupdate_temptbl = 335545075)
+ INTEGER*4 GDS__cant_modify_sysobj
+ PARAMETER (GDS__cant_modify_sysobj = 335545076)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw
@@ -1822,6 +1824,8 @@
PARAMETER (GDS__dyn_alter_user_no_clause = 336068891)
INTEGER*4 GDS__dyn_duplicate_package_item
PARAMETER (GDS__dyn_duplicate_package_item = 336068894)
+ INTEGER*4 GDS__dyn_cant_modify_sysobj
+ PARAMETER (GDS__dyn_cant_modify_sysobj = 336068895)
INTEGER*4 GDS__gbak_unknown_switch
PARAMETER (GDS__gbak_unknown_switch = 336330753)
INTEGER*4 GDS__gbak_page_size_missing
Modified: firebird/trunk/lang_helpers/gds_codes.pas
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.pas 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/lang_helpers/gds_codes.pas 2014-04-04 06:39:09 UTC (rev 59351)
@@ -788,6 +788,7 @@
gds_forupdate_virtualtbl = 335545073;
gds_forupdate_systbl = 335545074;
gds_forupdate_temptbl = 335545075;
+ gds_cant_modify_sysobj = 335545076;
gds_gfix_db_name = 335740929;
gds_gfix_invalid_sw = 335740930;
gds_gfix_incmp_sw = 335740932;
@@ -918,6 +919,7 @@
gds_dyn_domain_used_function = 336068890;
gds_dyn_alter_user_no_clause = 336068891;
gds_dyn_duplicate_package_item = 336068894;
+ gds_dyn_cant_modify_sysobj = 336068895;
gds_gbak_unknown_switch = 336330753;
gds_gbak_page_size_missing = 336330754;
gds_gbak_page_size_toobig = 336330755;
Modified: firebird/trunk/src/dsql/DdlNodes.epp
===================================================================
--- firebird/trunk/src/dsql/DdlNodes.epp 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/dsql/DdlNodes.epp 2014-04-04 06:39:09 UTC (rev 59351)
@@ -4881,6 +4881,8 @@
bool CreateAlterSequenceNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
jrd_tra* transaction)
{
+ bool forbidden = false;
+
if (legacy)
{
// The only need for this code is that for the sake of backward compatibility
@@ -4889,10 +4891,13 @@
// that the generator created in another transaction can be found here. This is done
// using MET_lookup_generator() which works in the system transaction.
- const SLONG id = MET_lookup_generator(tdbb, name);
+ const SLONG id = MET_lookup_generator(tdbb, name, &forbidden);
if (id < 0)
return false;
+ if (forbidden)
+ status_exception::raise(Arg::Gds(isc_dyn_cant_modify_sysobj) << "generator" << Arg::Str(name));
+
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE, DDL_TRIGGER_ALTER_SEQUENCE, name);
fb_assert(value.specified);
@@ -4918,6 +4923,12 @@
{
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE, DDL_TRIGGER_ALTER_SEQUENCE, name);
+ if (!X.RDB$SYSTEM_FLAG.NULL && X.RDB$SYSTEM_FLAG == 1)
+ {
+ forbidden = true;
+ break;
+ }
+
const SLONG id = X.RDB$GENERATOR_ID;
const SINT64 val = value.specified ?
value.value : (!X.RDB$INITIAL_VALUE.NULL ? X.RDB$INITIAL_VALUE : 0);
@@ -4933,6 +4944,9 @@
}
END_FOR
+ if (forbidden)
+ status_exception::raise(Arg::Gds(isc_dyn_cant_modify_sysobj) << "generator" << Arg::Str(name));
+
return found;
}
@@ -4952,7 +4966,7 @@
{
try
{
- SINT64 id = DYN_UTIL_gen_unique_id(tdbb, drq_g_nxt_gen_id, "RDB$GENERATORS");
+ SINT64 id = DYN_UTIL_gen_unique_id(tdbb, drq_g_nxt_gen_id, MASTER_GENERATOR);
id %= MAX_SSHORT + 1;
if (id == 0)
Modified: firebird/trunk/src/dsql/ExprNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/ExprNodes.cpp 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/dsql/ExprNodes.cpp 2014-04-04 06:39:09 UTC (rev 59351)
@@ -5615,7 +5615,8 @@
: TypedNode<ValueExprNode, ExprNode::TYPE_GEN_ID>(pool),
dialect1(aDialect1),
generator(pool, name),
- arg(aArg)
+ arg(aArg),
+ sysGen(false)
{
addChildNode(arg, arg);
}
@@ -5628,7 +5629,16 @@
GenIdNode* const node =
FB_NEW(pool) GenIdNode(pool, (csb->blrVersion == 4), name, PAR_parse_value(tdbb, csb));
- if (!MET_load_generator(tdbb, node->generator))
+ // This check seems faster than ==, but assumes the special generator is named ""
+ if (name.length() == 0) //(name == MASTER_GENERATOR)
+ {
+ fb_assert(!MASTER_GENERATOR[0]);
+ if (!(csb->csb_g_flags & csb_internal))
+ PAR_error(csb, Arg::Gds(isc_gennotdef) << Arg::Str(name));
+
+ node->generator.id = 0;
+ }
+ else if (!MET_load_generator(tdbb, node->generator, &node->sysGen))
PAR_error(csb, Arg::Gds(isc_gennotdef) << Arg::Str(name));
if (csb->csb_g_flags & csb_get_dependencies)
@@ -5652,6 +5662,7 @@
GenIdNode* const node = FB_NEW(getPool())
GenIdNode(getPool(), dialect1, generator.name, doDsqlPass(dsqlScratch, arg));
node->generator = generator;
+ node->sysGen = sysGen;
return node;
}
@@ -5699,6 +5710,7 @@
GenIdNode* const node = FB_NEW(*tdbb->getDefaultPool()) GenIdNode(
*tdbb->getDefaultPool(), dialect1, generator.name, copier.copy(tdbb, arg));
node->generator = generator;
+ node->sysGen = sysGen;
return node;
}
@@ -5755,8 +5767,19 @@
if (request->req_flags & req_null)
return NULL;
- const SINT64 new_val = DPM_gen_id(tdbb, generator.id, false, MOV_get_int64(value, 0));
+ const SINT64 change = MOV_get_int64(value, 0);
+ if (sysGen && change != 0)
+ {
+ const ULONG aflags = ATT_gbak_attachment | ATT_creator;
+ if (!request->hasInternalStatement() &&
+ (tdbb->getAttachment()->att_flags & aflags) != aflags)
+ {
+ status_exception::raise(Arg::Gds(isc_cant_modify_sysobj) << "generator" << generator.name);
+ }
+ }
+ const SINT64 new_val = DPM_gen_id(tdbb, generator.id, false, change);
+
if (dialect1)
impure->make_long((SLONG) new_val);
else
Modified: firebird/trunk/src/dsql/ExprNodes.h
===================================================================
--- firebird/trunk/src/dsql/ExprNodes.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/dsql/ExprNodes.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -679,6 +679,8 @@
bool dialect1;
GeneratorItem generator;
NestConst<ValueExprNode> arg;
+private:
+ bool sysGen;
};
Modified: firebird/trunk/src/dsql/StmtNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/StmtNodes.cpp 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/dsql/StmtNodes.cpp 2014-04-04 06:39:09 UTC (rev 59351)
@@ -6513,9 +6513,13 @@
GenIdNode* const genNode = FB_NEW(csb->csb_pool)
GenIdNode(csb->csb_pool, (csb->blrVersion == 4), generatorName, literal);
- if (!MET_load_generator(tdbb, genNode->generator))
+ bool sysGen = false;
+ if (!MET_load_generator(tdbb, genNode->generator, &sysGen))
PAR_error(csb, Arg::Gds(isc_gennotdef) << Arg::Str(generatorName));
+ if (sysGen)
+ PAR_error(csb, Arg::Gds(isc_cant_modify_sysobj) << "generator" << generatorName);
+
assign->asgnFrom = genNode;
}
else //if (value)
@@ -7139,9 +7143,13 @@
SetGeneratorNode* const node = FB_NEW(pool) SetGeneratorNode(pool, name);
- if (!MET_load_generator(tdbb, node->generator))
+ bool sysGen = false;
+ if (!MET_load_generator(tdbb, node->generator, &sysGen))
PAR_error(csb, Arg::Gds(isc_gennotdef) << Arg::Str(name));
+ if (sysGen)
+ PAR_error(csb, Arg::Gds(isc_cant_modify_sysobj) << "generator" << name);
+
node->value = PAR_parse_value(tdbb, csb);
return node;
Modified: firebird/trunk/src/dsql/StmtNodes.h
===================================================================
--- firebird/trunk/src/dsql/StmtNodes.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/dsql/StmtNodes.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -1321,7 +1321,7 @@
public:
SetGeneratorNode(MemoryPool& pool, const Firebird::MetaName& name, ValueExprNode* aValue = NULL)
: TypedNode<StmtNode, StmtNode::TYPE_SET_GENERATOR>(pool),
- generator(pool, name), value(aValue)
+ generator(pool, name), value(aValue), sysGen(false)
{
}
@@ -1343,6 +1343,9 @@
public:
GeneratorItem generator;
NestConst<ValueExprNode> value;
+
+private:
+ bool sysGen;
};
Modified: firebird/trunk/src/include/gen/codetext.h
===================================================================
--- firebird/trunk/src/include/gen/codetext.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/include/gen/codetext.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -777,6 +777,7 @@
{"forupdate_virtualtbl", 335545073},
{"forupdate_systbl", 335545074},
{"forupdate_temptbl", 335545075},
+ {"cant_modify_sysobj", 335545076},
{"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932},
@@ -907,6 +908,7 @@
{"dyn_domain_used_function", 336068890},
{"dyn_alter_user_no_clause", 336068891},
{"dyn_duplicate_package_item", 336068894},
+ {"dyn_cant_modify_sysobj", 336068895},
{"gbak_unknown_switch", 336330753},
{"gbak_page_size_missing", 336330754},
{"gbak_page_size_toobig", 336330755},
Modified: firebird/trunk/src/include/gen/iberror.h
===================================================================
--- firebird/trunk/src/include/gen/iberror.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/include/gen/iberror.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -811,6 +811,7 @@
const ISC_STATUS isc_forupdate_virtualtbl = 335545073L;
const ISC_STATUS isc_forupdate_systbl = 335545074L;
const ISC_STATUS isc_forupdate_temptbl = 335545075L;
+const ISC_STATUS isc_cant_modify_sysobj = 335545076L;
const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@@ -941,6 +942,7 @@
const ISC_STATUS isc_dyn_domain_used_function = 336068890L;
const ISC_STATUS isc_dyn_alter_user_no_clause = 336068891L;
const ISC_STATUS isc_dyn_duplicate_package_item = 336068894L;
+const ISC_STATUS isc_dyn_cant_modify_sysobj = 336068895L;
const ISC_STATUS isc_gbak_unknown_switch = 336330753L;
const ISC_STATUS isc_gbak_page_size_missing = 336330754L;
const ISC_STATUS isc_gbak_page_size_toobig = 336330755L;
@@ -1257,7 +1259,7 @@
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
-const ISC_STATUS isc_err_max = 1201;
+const ISC_STATUS isc_err_max = 1203;
#else /* c definitions */
@@ -2038,6 +2040,7 @@
#define isc_forupdate_virtualtbl 335545073L
#define isc_forupdate_systbl 335545074L
#define isc_forupdate_temptbl 335545075L
+#define isc_cant_modify_sysobj 335545076L
#define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L
@@ -2168,6 +2171,7 @@
#define isc_dyn_domain_used_function 336068890L
#define isc_dyn_alter_user_no_clause 336068891L
#define isc_dyn_duplicate_package_item 336068894L
+#define isc_dyn_cant_modify_sysobj 336068895L
#define isc_gbak_unknown_switch 336330753L
#define isc_gbak_page_size_missing 336330754L
#define isc_gbak_page_size_toobig 336330755L
@@ -2484,7 +2488,7 @@
#define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L
-#define isc_err_max 1201
+#define isc_err_max 1203
#endif
Modified: firebird/trunk/src/include/gen/msgs.h
===================================================================
--- firebird/trunk/src/include/gen/msgs.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/include/gen/msgs.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -780,6 +780,7 @@
{335545073, "Cannot select virtual table @1 for update WITH LOCK"}, /* forupdate_virtualtbl */
{335545074, "Cannot select system table @1 for update WITH LOCK"}, /* forupdate_systbl */
{335545075, "Cannot select temporary table @1 for update WITH LOCK"}, /* forupdate_temptbl */
+ {335545076, "System @1 @2 cannot be modified"}, /* cant_modify_sysobj */
{335740929, "data base file name (@1) already given"}, /* gfix_db_name */
{335740930, "invalid switch @1"}, /* gfix_invalid_sw */
{335740932, "incompatible switch combination"}, /* gfix_incmp_sw */
@@ -910,6 +911,7 @@
{336068890, "Domain @1 is used in function @2 (parameter name @3) and cannot be dropped"}, /* dyn_domain_used_function */
{336068891, "ALTER USER requires at least one clause to be specified"}, /* dyn_alter_user_no_clause */
{336068894, "Duplicate @1 @2"}, /* dyn_duplicate_package_item */
+ {336068895, "System @1 @2 cannot be modified"}, /* dyn_cant_modify_sysobj */
{336330753, "found unknown switch"}, /* gbak_unknown_switch */
{336330754, "page size parameter missing"}, /* gbak_page_size_missing */
{336330755, "Page size specified (@1) greater than limit (16384 bytes)"}, /* gbak_page_size_toobig */
Modified: firebird/trunk/src/include/gen/sql_code.h
===================================================================
--- firebird/trunk/src/include/gen/sql_code.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/include/gen/sql_code.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -776,6 +776,7 @@
{335545073, -901}, /* 753 forupdate_virtualtbl */
{335545074, -901}, /* 754 forupdate_systbl */
{335545075, -901}, /* 755 forupdate_temptbl */
+ {335545076, -901}, /* 756 cant_modify_sysobj */
{335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */
@@ -906,6 +907,7 @@
{336068890, -901}, /* 282 dyn_domain_used_function */
{336068891, -901}, /* 283 dyn_alter_user_no_clause */
{336068894, -901}, /* 286 dyn_duplicate_package_item */
+ {336068895, -901}, /* 287 dyn_cant_modify_sysobj */
{336330753, -901}, /* 1 gbak_unknown_switch */
{336330754, -901}, /* 2 gbak_page_size_missing */
{336330755, -901}, /* 3 gbak_page_size_toobig */
Modified: firebird/trunk/src/include/gen/sql_state.h
===================================================================
--- firebird/trunk/src/include/gen/sql_state.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/include/gen/sql_state.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -776,6 +776,7 @@
{335545073, "HY000"}, // 753 forupdate_virtualtbl
{335545074, "HY000"}, // 754 forupdate_systbl
{335545075, "HY000"}, // 755 forupdate_temptbl
+ {335545076, "42000"}, // 756 cant_modify_sysobj
{335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw
@@ -906,6 +907,7 @@
{336068890, "HY000"}, // 282 dyn_domain_used_function
{336068891, "42000"}, // 283 dyn_alter_user_no_clause
{336068894, "42000"}, // 286 dyn_duplicate_package_item
+ {336068895, "42000"}, // 287 dyn_cant_modify_sysobj
{336330753, "00000"}, // 1 gbak_unknown_switch
{336330754, "00000"}, // 2 gbak_page_size_missing
{336330755, "00000"}, // 3 gbak_page_size_toobig
Modified: firebird/trunk/src/jrd/Attachment.h
===================================================================
--- firebird/trunk/src/jrd/Attachment.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/jrd/Attachment.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -391,6 +391,7 @@
const ULONG ATT_async_manual_lock = 0x08000L; // Async mutex was locked manually
const ULONG ATT_purge_started = 0x10000L; // Purge already started - avoid 2 purges at once
const ULONG ATT_system = 0x20000L; // Special system attachment
+const ULONG ATT_creator = 0x40000L; // This attachment created the DB.
const ULONG ATT_NO_CLEANUP = (ATT_no_cleanup | ATT_notify_gc);
Modified: firebird/trunk/src/jrd/constants.h
===================================================================
--- firebird/trunk/src/jrd/constants.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/jrd/constants.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -123,6 +123,10 @@
const char* const IMPLICIT_PK_PREFIX = "RDB$PRIMARY";
const int IMPLICIT_PK_PREFIX_LEN = 11;
+// The invisible "id zero" generator.
+const char* const MASTER_GENERATOR = ""; //Was "RDB$GENERATORS";
+
+
// Automatically created security classes for SQL objects.
// Keep in sync with trig.h
const char* const DEFAULT_CLASS = "SQL$DEFAULT";
Modified: firebird/trunk/src/jrd/dfw.epp
===================================================================
--- firebird/trunk/src/jrd/dfw.epp 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/jrd/dfw.epp 2014-04-04 06:39:09 UTC (rev 59351)
@@ -3573,6 +3573,10 @@
DPM_gen_id(tdbb, id, true, value);
}
}
+#ifdef DEV_BUILD
+ else // This is a test only
+ status_exception::raise(Arg::Gds(isc_cant_modify_sysobj) << "generator" << work->dfw_name);
+#endif
}
break;
}
Modified: firebird/trunk/src/jrd/ini.epp
===================================================================
--- firebird/trunk/src/jrd/ini.epp 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/jrd/ini.epp 2014-04-04 06:39:09 UTC (rev 59351)
@@ -398,8 +398,9 @@
for (const gen* generator = generators; generator->gen_name; generator++)
store_generator(tdbb, generator, handle1, ownerName);
+ // Redundant, VIO_store does the job.
// Adjust the value of the hidden generator RDB$GENERATORS
- DPM_gen_id(tdbb, 0, true, FB_NELEM(generators) - 1);
+ //DPM_gen_id(tdbb, 0, true, FB_NELEM(generators) - 1);
// store system-defined triggers
Modified: firebird/trunk/src/jrd/jrd.cpp
===================================================================
--- firebird/trunk/src/jrd/jrd.cpp 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/jrd/jrd.cpp 2014-04-04 06:39:09 UTC (rev 59351)
@@ -950,7 +950,7 @@
Jrd::Attachment* attachment, Database* dbb);
static JAttachment* init(thread_db*, const PathName&, const PathName&, RefPtr<Config>, bool,
const DatabaseOptions&, RefMutexUnlock&, IPluginConfig*);
-static JAttachment* create_attachment(const PathName&, Database*, const DatabaseOptions&);
+static JAttachment* create_attachment(const PathName&, Database*, const DatabaseOptions&, bool newDb);
static void prepare_tra(thread_db*, jrd_tra*, USHORT, const UCHAR*);
static void start_transaction(thread_db* tdbb, bool transliterate, jrd_tra** tra_handle,
Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb);
@@ -5906,7 +5906,7 @@
fb_assert(!(dbb->dbb_flags & DBB_new));
tdbb->setDatabase(dbb);
- jAtt = create_attachment(alias_name, dbb, options);
+ jAtt = create_attachment(alias_name, dbb, options, !attach_flag);
if (dbb->dbb_linger_timer)
dbb->dbb_linger_timer->reset();
@@ -5960,9 +5960,9 @@
dbbGuard.lock(SYNC_EXCLUSIVE);
tdbb->setDatabase(dbb);
- jAtt = create_attachment(alias_name, dbb, options);
+ jAtt = create_attachment(alias_name, dbb, options, !attach_flag);
tdbb->setAttachment(jAtt->getHandle());
- }
+ } // end scope
// provide context pool for the rest stuff
Jrd::ContextPoolHolder context(tdbb, dbb->dbb_permanent);
@@ -6003,7 +6003,8 @@
static JAttachment* create_attachment(const PathName& alias_name,
Database* dbb,
- const DatabaseOptions& options)
+ const DatabaseOptions& options,
+ bool newDb)
{
/**************************************
*
@@ -6045,6 +6046,8 @@
jAtt->addRef(); // See also REF_NO_INCR RefPtr in unwindAttach()
attachment->att_interface = jAtt;
jAtt->manualLock(attachment->att_flags);
+ if (newDb)
+ attachment->att_flags |= ATT_creator;
return jAtt;
}
Modified: firebird/trunk/src/jrd/met.epp
===================================================================
--- firebird/trunk/src/jrd/met.epp 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/jrd/met.epp 2014-04-04 06:39:09 UTC (rev 59351)
@@ -2271,7 +2271,7 @@
}
-bool MET_load_generator(thread_db* tdbb, GeneratorItem& item)
+bool MET_load_generator(thread_db* tdbb, GeneratorItem& item, bool* sysGen)
{
/**************************************
*
@@ -2286,9 +2286,11 @@
SET_TDBB(tdbb);
Attachment* attachment = tdbb->getAttachment();
- if (item.name == "RDB$GENERATORS")
+ if (item.name == MASTER_GENERATOR)
{
item.id = 0;
+ if (sysGen)
+ *sysGen = true;
return true;
}
@@ -2299,6 +2301,8 @@
{
item.id = X.RDB$GENERATOR_ID;
item.secName = X.RDB$SECURITY_CLASS;
+ if (sysGen)
+ *sysGen = (!X.RDB$SYSTEM_FLAG.NULL && X.RDB$SYSTEM_FLAG == 1);
return true;
}
END_FOR
@@ -2306,7 +2310,7 @@
return false;
}
-SLONG MET_lookup_generator(thread_db* tdbb, const MetaName& name)
+SLONG MET_lookup_generator(thread_db* tdbb, const MetaName& name, bool* sysGen)
{
/**************************************
*
@@ -2321,14 +2325,21 @@
SET_TDBB(tdbb);
Attachment* attachment = tdbb->getAttachment();
- if (name == "RDB$GENERATORS")
+ if (name == MASTER_GENERATOR)
+ {
+ if (sysGen)
+ *sysGen = true;
return 0;
+ }
AutoCacheRequest request(tdbb, irq_l_gen_id, IRQ_REQUESTS);
FOR(REQUEST_HANDLE request)
X IN RDB$GENERATORS WITH X.RDB$GENERATOR_NAME EQ name.c_str()
{
+ if (sysGen)
+ *sysGen = (!X.RDB$SYSTEM_FLAG.NULL && X.RDB$SYSTEM_FLAG == 1);
+
return X.RDB$GENERATOR_ID;
}
END_FOR
@@ -2336,7 +2347,7 @@
return -1;
}
-void MET_lookup_generator_id(thread_db* tdbb, SLONG gen_id, MetaName& name)
+bool MET_lookup_generator_id(thread_db* tdbb, SLONG gen_id, MetaName& name, bool* sysGen)
{
/**************************************
*
@@ -2352,11 +2363,7 @@
SET_TDBB (tdbb);
Attachment* attachment = tdbb->getAttachment();
- if (!gen_id)
- {
- name = "RDB$GENERATORS";
- return;
- }
+ fb_assert(gen_id != 0);
name = "";
@@ -2365,9 +2372,14 @@
FOR (REQUEST_HANDLE request)
X IN RDB$GENERATORS WITH X.RDB$GENERATOR_ID EQ gen_id
{
+ if (sysGen)
+ *sysGen = (!X.RDB$SYSTEM_FLAG.NULL && X.RDB$SYSTEM_FLAG == 1);
+
name = X.RDB$GENERATOR_NAME;
}
END_FOR
+
+ return name.length() != 0;
}
void MET_lookup_index(thread_db* tdbb,
@@ -5012,11 +5024,14 @@
case obj_field:
dpdo_name = dependency.name;
break;
- // CVC: Here I'm going to track those pesky things named generators and UDFs.
case obj_generator:
{
+ // CVC: Here I'm going to track those pesky things named generators and UDFs.
+ // But don't track sys gens.
+ bool sysGen = false;
const SLONG number = dependency.number;
- MET_lookup_generator_id (tdbb, number, name);
+ if (number == 0 || !MET_lookup_generator_id(tdbb, number, name, &sysGen) || sysGen)
+ continue;
dpdo_name = &name;
}
break;
Modified: firebird/trunk/src/jrd/met_proto.h
===================================================================
--- firebird/trunk/src/jrd/met_proto.h 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/jrd/met_proto.h 2014-04-04 06:39:09 UTC (rev 59351)
@@ -91,9 +91,9 @@
void MET_lookup_exception(Jrd::thread_db*, SLONG, /* OUT */ Firebird::MetaName&, /* OUT */ Firebird::string*);
int MET_lookup_field(Jrd::thread_db*, Jrd::jrd_rel*, const Firebird::MetaName&);
Jrd::BlobFilter* MET_lookup_filter(Jrd::thread_db*, SSHORT, SSHORT);
-bool MET_load_generator(Jrd::thread_db*, Jrd::GeneratorItem&);
-SLONG MET_lookup_generator(Jrd::thread_db*, const Firebird::MetaName&);
-void MET_lookup_generator_id(Jrd::thread_db*, SLONG, Firebird::MetaName&);
+bool MET_load_generator(Jrd::thread_db*, Jrd::GeneratorItem&, bool* sysGen = 0);
+SLONG MET_lookup_generator(Jrd::thread_db*, const Firebird::MetaName&, bool* sysGen = 0);
+bool MET_lookup_generator_id(Jrd::thread_db*, SLONG, Firebird::MetaName&, bool* sysGen = 0);
void MET_lookup_index(Jrd::thread_db*, Firebird::MetaName&, const Firebird::MetaName&, USHORT);
SLONG MET_lookup_index_name(Jrd::thread_db*, const Firebird::MetaName&, SLONG*, SSHORT*);
bool MET_lookup_partner(Jrd::thread_db*, Jrd::jrd_rel*, struct Jrd::index_desc*, const TEXT*);
Modified: firebird/trunk/src/jrd/vio.cpp
===================================================================
--- firebird/trunk/src/jrd/vio.cpp 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/jrd/vio.cpp 2014-04-04 06:39:09 UTC (rev 59351)
@@ -3145,7 +3145,7 @@
EVL_field(0, rpb->rpb_record, f_gen_name, &desc);
EVL_field(0, rpb->rpb_record, f_gen_id, &desc2);
object_id = set_metadata_id(tdbb, rpb->rpb_record,
- f_gen_id, drq_g_nxt_gen_id, "RDB$GENERATORS");
+ f_gen_id, drq_g_nxt_gen_id, MASTER_GENERATOR);
transaction->getGenIdCache()->put(object_id, 0);
DFW_post_work(transaction, dfw_set_generator, &desc, object_id);
set_system_flag(tdbb, rpb->rpb_record, f_gen_sys_flag);
@@ -5323,7 +5323,7 @@
if (force_flag ||
(!(attachment->att_flags & ATT_gbak_attachment) &&
- !(request->getStatement()->flags & JrdStatement::FLAG_INTERNAL)))
+ !request->hasInternalStatement()))
{
fb_assert(relation->rel_flags & REL_scanned);
Modified: firebird/trunk/src/msgs/facilities2.sql
===================================================================
--- firebird/trunk/src/msgs/facilities2.sql 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/msgs/facilities2.sql 2014-04-04 06:39:09 UTC (rev 59351)
@@ -1,12 +1,12 @@
/* MAX_NUMBER is the next number to be used, always one more than the highest message number. */
set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES (?, ?, ?, ?);
--
-('2014-03-26 22:42:01', 'JRD', 0, 756)
+('2014-03-31 20:48:34', 'JRD', 0, 757)
('2012-01-23 20:10:30', 'QLI', 1, 532)
('2013-11-13 15:59:10', 'GFIX', 3, 122)
('1996-11-07 13:39:40', 'GPRE', 4, 1)
('2012-08-27 21:26:00', 'DSQL', 7, 33)
-('2014-03-26 12:27:00', 'DYN', 8, 287)
+('2014-03-31 18:46:42', 'DYN', 8, 288)
('1996-11-07 13:39:40', 'INSTALL', 10, 1)
('1996-11-07 13:38:41', 'TEST', 11, 4)
('2014-03-03 19:17:14', 'GBAK', 12, 353)
Modified: firebird/trunk/src/msgs/messages2.sql
===================================================================
--- firebird/trunk/src/msgs/messages2.sql 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/msgs/messages2.sql 2014-04-04 06:39:09 UTC (rev 59351)
@@ -863,6 +863,7 @@
('forupdate_virtualtbl', 'PAR_rse', 'par.cpp', NULL, 0, 753, NULL, 'Cannot select virtual table @1 for update WITH LOCK', NULL, NULL)
('forupdate_systbl', 'PAR_rse', 'par.cpp', NULL, 0, 754, NULL, 'Cannot select system table @1 for update WITH LOCK', NULL, NULL)
('forupdate_temptbl', 'PAR_rse', 'par.cpp', NULL, 0, 755, NULL, 'Cannot select temporary table @1 for update WITH LOCK', NULL, NULL)
+('cant_modify_sysobj', NULL, 'ExprNodes.cpp', NULL, 0, 756, NULL, 'System @1 @2 cannot be modified', NULL, 'Ex: System generator rdb$... cannot be modified')
-- QLI
(NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL);
(NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL);
@@ -1911,6 +1912,7 @@
(NULL, 'DYN_delete_role', 'dyn_del.epp', NULL, 8, 284, NULL, 'Cannot delete system SQL role @1', NULL, NULL);
(NULL, 'DdlNodes.epp', 'AlterRelationNode::modifyField', NULL, 8, 285, NULL, 'Column @1 is not an identity column', NULL, NULL);
('dyn_duplicate_package_item', NULL, 'PackageNodes.epp', NULL, 8, 286, NULL, 'Duplicate @1 @2', NULL, NULL);
+('dyn_cant_modify_sysobj', NULL, 'DdlNodes.epp', NULL, 8, 287, NULL, 'System @1 @2 cannot be modified', NULL, 'Ex: System generator rdb$... cannot be modified');
COMMIT WORK;
-- TEST
(NULL, 'main', 'test.c', NULL, 11, 0, NULL, 'This is a modified text message', NULL, NULL);
Modified: firebird/trunk/src/msgs/system_errors2.sql
===================================================================
--- firebird/trunk/src/msgs/system_errors2.sql 2014-04-03 12:33:08 UTC (rev 59350)
+++ firebird/trunk/src/msgs/system_errors2.sql 2014-04-04 06:39:09 UTC (rev 59351)
@@ -762,6 +762,7 @@
(-901, 'HY', '000', 0, 753, 'forupdate_virtualtbl', NULL, NULL)
(-901, 'HY', '000', 0, 754, 'forupdate_systbl', NULL, NULL)
(-901, 'HY', '000', 0, 755, 'forupdate_temptbl', NULL, NULL)
+(-901, '42', '000', 0, 756, 'cant_modify_sysobj', NULL, NULL)
-- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)
@@ -895,6 +896,7 @@
(-901, 'HY', '000', 8, 282, 'dyn_domain_used_function', NULL, NULL)
(-901, '42', '000', 8, 283, 'dyn_alter_user_no_clause', NULL, NULL)
(-901, '42', '000', 8, 286, 'dyn_duplicate_package_item', NULL, NULL)
+(-901, '42', '000', 8, 287, 'dyn_cant_modify_sysobj', NULL, NULL)
-- GBAK
(-901, '00', '000', 12, 1, 'gbak_unknown_switch', NULL, NULL)
(-901, '00', '000', 12, 2, 'gbak_page_size_missing', NULL, NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|