From 63de95f1d9f3e280bbd9e4a025b67c9375e8d01f Mon Sep 17 00:00:00 2001 From: asfernandes Date: Thu, 27 Sep 2007 15:52:47 +0000 Subject: [PATCH] Fixed CORE-1451 - Using RDB$DB_KEY in where section while selecting from a procedure crashes the server --- src/dsql/pass1.cpp | 8 ++++++++ src/jrd/evl.cpp | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/dsql/pass1.cpp b/src/dsql/pass1.cpp index 4826eda839..9d78f55526 100644 --- a/src/dsql/pass1.cpp +++ b/src/dsql/pass1.cpp @@ -3983,6 +3983,14 @@ static dsql_nod* pass1_dbkey( dsql_req* request, dsql_nod* input) if (request->req_context->getCount() == 1) { dsql_ctx* context = request->req_context->object(); + + if (!context->ctx_relation) + { + ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, + isc_arg_gds, isc_dsql_dbkey_from_non_table, + 0); + } + dsql_nod* node = MAKE_node(nod_dbkey, 1); dsql_nod* rel_node = MAKE_node(nod_relation, e_rel_count); rel_node->nod_arg[0] = (dsql_nod*) context; diff --git a/src/jrd/evl.cpp b/src/jrd/evl.cpp index 773906a844..c8060511df 100644 --- a/src/jrd/evl.cpp +++ b/src/jrd/evl.cpp @@ -3237,15 +3237,15 @@ static dsc* dbkey(thread_db* tdbb, const jrd_nod* node, impure_value* impure) impure = (impure_value*) ((SCHAR *) request + node->nod_impure); const record_param* rpb = &request->req_rpb[(int) (IPTR) node->nod_arg[0]]; + const jrd_rel* relation = rpb->rpb_relation; + // If it doesn't point to a valid record, return NULL - if (!rpb->rpb_number.isValid()) + if (!rpb->rpb_number.isValid() || !relation) { request->req_flags |= req_null; return NULL; } - const jrd_rel* relation = rpb->rpb_relation; - // Format dbkey as vector of relation id, record number if (relation->rel_file) {