8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 21:23:03 +01:00

Fixed restore problem for databases having views that use procedures AND are used by procedures. General procedure metadata related cleanup.

This commit is contained in:
skidder 2002-11-16 18:48:01 +00:00
parent fc3c964522
commit 5a712a4fee
6 changed files with 39 additions and 39 deletions

View File

@ -40,7 +40,7 @@
*
*/
/*
$Id: cmp.cpp,v 1.20 2002-11-14 13:39:02 skidder Exp $
$Id: cmp.cpp,v 1.21 2002-11-16 18:48:00 skidder Exp $
*/
#include "firebird.h"
@ -2638,7 +2638,9 @@ static JRD_NOD copy(
remap[stream] = (UCHAR) new_stream;
node->nod_arg[e_prc_procedure] = input->nod_arg[e_prc_procedure];
element = CMP_csb_element(csb, new_stream);
element->csb_procedure = (PRC) node->nod_arg[e_prc_procedure];
// SKIDDER: Maybe we need to check if we really found a procedure ?
element->csb_procedure = MET_lookup_procedure_id(tdbb,
(SSHORT)node->nod_arg[e_prc_procedure],FALSE,FALSE,0);
(*csb)->csb_rpt[new_stream].csb_flags |=
(*csb)->csb_rpt[stream].csb_flags & csb_no_dbkey;
@ -3841,7 +3843,8 @@ static void pass1_source(
PRC procedure;
pass1(tdbb, csb, source, parent_view, view_stream, FALSE);
procedure = (PRC) source->nod_arg[e_prc_procedure];
procedure = MET_lookup_procedure_id(tdbb,
(SSHORT)source->nod_arg[e_prc_procedure], FALSE, FALSE, 0);
post_procedure_access(tdbb, *csb, procedure);
CMP_post_resource(tdbb, &(*csb)->csb_resources, (BLK) procedure,
rsc_procedure, procedure->prc_id);

View File

@ -804,10 +804,9 @@ int DBG_pretty(register NOD node, register int column)
return TRUE;
case nod_procedure:
procedure = (PRC) node->nod_arg[e_prc_procedure];
ib_fprintf(dbg_file, ", stream: %d, %s (%X)\n",
node->nod_arg[e_prc_stream], procedure->prc_name->str_data,
procedure);
SSHORT procedure_id = (SSHORT) node->nod_arg[e_prc_procedure];
ib_fprintf(dbg_file, ", stream: %d, prc_id: %d\n",
node->nod_arg[e_prc_stream], procedure_id);
if (node->nod_arg[e_prc_inputs])
DBG_pretty(node->nod_arg[e_prc_inputs], column);
return TRUE;

View File

@ -474,7 +474,7 @@ typedef att* ATT;
class prc : public pool_alloc_rpt<SCHAR, type_prc>
{
public:
USHORT prc_id;
USHORT prc_id; // Should be first field because MET_remove_procedure relies on that
USHORT prc_flags;
USHORT prc_inputs;
USHORT prc_outputs;

View File

@ -37,7 +37,7 @@
*
*/
/*
$Id: met.epp,v 1.34 2002-11-14 13:39:02 skidder Exp $
$Id: met.epp,v 1.35 2002-11-16 18:48:01 skidder Exp $
*/
// This MUST be at the top of the file
#ifdef DARWIN
@ -341,6 +341,7 @@ BOOLEAN MET_clear_cache(TDBB tdbb, PRC proc)
MET_remove_procedure(tdbb, procedure->prc_id, procedure);
}
}
}
return result;
}
@ -2002,26 +2003,24 @@ PRC MET_lookup_procedure(TDBB tdbb, SCHAR * name, BOOLEAN noscan)
PRC procedure;
vec::iterator ptr, end;
VEC procedures;
SCHAR *p, *q;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
/* See if we already know the relation by name */
/* See if we already know the procedure by name */
if ( (procedures = dbb->dbb_procedures) )
for (ptr = procedures->begin(), end = procedures->end();
ptr < end; ptr++) {
if ((procedure = PRC(*ptr))&& !(procedure->prc_flags & PRC_obsolete)
&& (procedure->prc_flags & PRC_scanned)
&& ((procedure->prc_flags & PRC_scanned) || noscan)
&& !(procedure->prc_flags & PRC_being_scanned)
&& !(procedure->prc_flags & PRC_being_altered)
&& (p = (SCHAR*)procedure->prc_name->str_data)) for (q = (SCHAR*)name;
*p == *q;
p++, q++)
if (*p == 0)
&& !(strcmp((SCHAR*)procedure->prc_name->str_data, (SCHAR*)name)))
{
return procedure;
}
}
/* We need to look up the procedure name in RDB$PROCEDURES */
@ -2062,22 +2061,20 @@ PRC MET_lookup_procedure_id(TDBB tdbb, SSHORT id,
DBB dbb;
BLK request;
PRC procedure;
vec::iterator ptr, end;
VEC procedures;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
/* See if we already know the relation by name */
if ( (procedures = dbb->dbb_procedures) )
for (ptr = procedures->begin(), end = procedures->end();
ptr < end; ptr++) {
if ((procedure = PRC(*ptr)) && procedure->prc_id == id
if ((procedures = dbb->dbb_procedures)
&& id < procedures->count()
&& (procedure = (PRC)(*procedures)[id])
&& procedure->prc_id == id
&& !(procedure->prc_flags & PRC_being_scanned)
&& ((procedure->prc_flags & PRC_scanned) || noscan)
&& !(procedure->prc_flags & PRC_being_altered)
&& (!(procedure->prc_flags & PRC_obsolete) || return_deleted))
{
return procedure;
}
@ -3105,8 +3102,8 @@ void MET_remove_procedure( TDBB tdbb, int id, PRC procedure)
else
{
save_proc_flags = procedure->prc_flags;
memset(((SCHAR *) procedure) + sizeof(struct blk), 0,
sizeof(struct prc) - sizeof(struct blk));
memset(((SCHAR *)&procedure->prc_id), 0,
sizeof(struct prc) - ((SCHAR *)&procedure->prc_id-(SCHAR *)procedure));
procedure->prc_flags = save_proc_flags;
}
}

View File

@ -3588,7 +3588,8 @@ static RSB gen_procedure(TDBB tdbb, OPT opt, JRD_NOD node)
DEV_BLKCHK(node, type_nod);
SET_TDBB(tdbb);
csb = opt->opt_csb;
procedure = (PRC) node->nod_arg[e_prc_procedure];
procedure = MET_lookup_procedure_id(tdbb,
(SSHORT)node->nod_arg[e_prc_procedure], FALSE, FALSE, 0);
rsb = FB_NEW_RPT(*tdbb->tdbb_default, RSB_PRC_count) Rsb();
rsb->rsb_type = rsb_procedure;
rsb->rsb_stream = (UCHAR) node->nod_arg[e_prc_stream];

View File

@ -34,7 +34,7 @@
*
*/
/*
$Id: par.cpp,v 1.21 2002-11-11 19:42:46 hippoman Exp $
$Id: par.cpp,v 1.22 2002-11-16 18:48:01 skidder Exp $
*/
#include "firebird.h"
@ -1783,7 +1783,7 @@ static JRD_NOD par_procedure(TDBB tdbb, CSB * csb, SSHORT operator_)
node = PAR_make_node(tdbb, e_prc_length);
node->nod_type = nod_procedure;
node->nod_count = count_table[blr_procedure];
node->nod_arg[e_prc_procedure] = (JRD_NOD) procedure;
node->nod_arg[e_prc_procedure] = (JRD_NOD) (SLONG) procedure->prc_id;
stream = par_context(csb, 0);
node->nod_arg[e_prc_stream] = (JRD_NOD) (SLONG) stream;