mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 00:43:03 +01:00
Use debug informations in EXECUTE BLOCK
This commit is contained in:
parent
829cdda060
commit
f30ee6b63e
@ -2736,6 +2736,7 @@ void DDL_gen_block(dsql_req* request, dsql_nod* node)
|
||||
**************************************/
|
||||
SSHORT inputs = 0, outputs = 0, locals = 0;
|
||||
request->req_blk_node = node;
|
||||
request->begin_debug();
|
||||
|
||||
tsql* tdsql = DSQL_get_thread_data();
|
||||
|
||||
@ -2862,6 +2863,8 @@ void DDL_gen_block(dsql_req* request, dsql_nod* node)
|
||||
request->append_uchar(blr_end);
|
||||
GEN_return(request, node->nod_arg[e_exe_blk_outputs], true);
|
||||
request->append_uchar(blr_end);
|
||||
|
||||
request->end_debug();
|
||||
}
|
||||
|
||||
|
||||
|
@ -4809,10 +4809,13 @@ static dsql_req* prepare(
|
||||
}
|
||||
|
||||
THREAD_EXIT();
|
||||
const ISC_STATUS status = isc_compile_request(tdsql->tsql_status,
|
||||
&request->req_dbb->dbb_database_handle,
|
||||
&request->req_handle, length,
|
||||
(const char*)(request->req_blr_data.begin()));
|
||||
const ISC_STATUS status = gds__internal_compile_request(
|
||||
tdsql->tsql_status,
|
||||
&request->req_dbb->dbb_database_handle,
|
||||
&request->req_handle, length,
|
||||
(const char*)(request->req_blr_data.begin()),
|
||||
string_length, string,
|
||||
request->req_debug_data.getCount(), request->req_debug_data.begin());
|
||||
THREAD_ENTER();
|
||||
|
||||
// restore warnings (if there are any)
|
||||
@ -4840,11 +4843,6 @@ static dsql_req* prepare(
|
||||
if (status)
|
||||
punt();
|
||||
|
||||
THREAD_EXIT();
|
||||
gds__sql_text(tdsql->tsql_status, &request->req_handle,
|
||||
string_length, string);
|
||||
THREAD_ENTER();
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
|
@ -37,36 +37,41 @@ void DBG_parse_debug_info(thread_db* tdbb, bid *blob_id, Firebird::DbgInfo& dbgI
|
||||
UCHAR* temp = tmp.getBuffer(length);
|
||||
BLB_get_data(tdbb, blob, temp, length);
|
||||
|
||||
const UCHAR* end = temp + length;
|
||||
DBG_parse_debug_info(length, temp, dbgInfo);
|
||||
}
|
||||
|
||||
void DBG_parse_debug_info(USHORT length, const UCHAR* data, Firebird::DbgInfo& dbgInfo)
|
||||
{
|
||||
const UCHAR* end = data + length;
|
||||
bool bad_format = false;
|
||||
|
||||
if ((*temp++ != fb_dbg_version) ||
|
||||
if ((*data++ != fb_dbg_version) ||
|
||||
(end[-1] != fb_dbg_end) ||
|
||||
(*temp++ != 1))
|
||||
(*data++ != 1))
|
||||
{
|
||||
bad_format = true;
|
||||
}
|
||||
|
||||
while (!bad_format && (temp < end))
|
||||
while (!bad_format && (data < end))
|
||||
{
|
||||
switch (*temp++)
|
||||
switch (*data++)
|
||||
{
|
||||
case fb_dbg_map_src2blr:
|
||||
{
|
||||
if (temp + 6 > end) {
|
||||
if (data + 6 > end) {
|
||||
bad_format = true;
|
||||
break;
|
||||
}
|
||||
|
||||
MapBlrToSrcItem i;
|
||||
i.mbs_src_line = *temp++;
|
||||
i.mbs_src_line |= *temp++ << 8;
|
||||
i.mbs_src_line = *data++;
|
||||
i.mbs_src_line |= *data++ << 8;
|
||||
|
||||
i.mbs_src_col = *temp++;
|
||||
i.mbs_src_col |= *temp++ << 8;
|
||||
i.mbs_src_col = *data++;
|
||||
i.mbs_src_col |= *data++ << 8;
|
||||
|
||||
i.mbs_offset = *temp++;
|
||||
i.mbs_offset |= *temp++ << 8;
|
||||
i.mbs_offset = *data++;
|
||||
i.mbs_offset |= *data++ << 8;
|
||||
|
||||
dbgInfo.blrToSrc.add(i);
|
||||
}
|
||||
@ -74,33 +79,33 @@ void DBG_parse_debug_info(thread_db* tdbb, bid *blob_id, Firebird::DbgInfo& dbgI
|
||||
|
||||
case fb_dbg_map_varname:
|
||||
{
|
||||
if (temp + 3 > end) {
|
||||
if (data + 3 > end) {
|
||||
bad_format = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// variable number
|
||||
USHORT index = *temp++;
|
||||
index |= *temp++;
|
||||
USHORT index = *data++;
|
||||
index |= *data++;
|
||||
|
||||
// variable name string length
|
||||
USHORT length = *temp++;
|
||||
USHORT length = *data++;
|
||||
|
||||
if (temp + length > end) {
|
||||
if (data + length > end) {
|
||||
bad_format = true;
|
||||
break;
|
||||
}
|
||||
|
||||
dbgInfo.varIndexToName.put(index, MetaName((const TEXT*) temp, length));
|
||||
dbgInfo.varIndexToName.put(index, MetaName((const TEXT*) data, length));
|
||||
|
||||
// variable name string
|
||||
temp += length;
|
||||
data += length;
|
||||
}
|
||||
break;
|
||||
|
||||
case fb_dbg_map_argument:
|
||||
{
|
||||
if (temp + 4 > end) {
|
||||
if (data + 4 > end) {
|
||||
bad_format = true;
|
||||
break;
|
||||
}
|
||||
@ -108,29 +113,29 @@ void DBG_parse_debug_info(thread_db* tdbb, bid *blob_id, Firebird::DbgInfo& dbgI
|
||||
ArgumentInfo info;
|
||||
|
||||
// argument type
|
||||
info.type = *temp++;
|
||||
info.type = *data++;
|
||||
|
||||
// argument number
|
||||
info.index = *temp++;
|
||||
info.index |= *temp++;
|
||||
info.index = *data++;
|
||||
info.index |= *data++;
|
||||
|
||||
// argument name string length
|
||||
USHORT length = *temp++;
|
||||
USHORT length = *data++;
|
||||
|
||||
if (temp + length > end) {
|
||||
if (data + length > end) {
|
||||
bad_format = true;
|
||||
break;
|
||||
}
|
||||
|
||||
dbgInfo.argInfoToName.put(info, MetaName((const TEXT*) temp, length));
|
||||
dbgInfo.argInfoToName.put(info, MetaName((const TEXT*) data, length));
|
||||
|
||||
// variable name string
|
||||
temp += length;
|
||||
data += length;
|
||||
}
|
||||
break;
|
||||
|
||||
case fb_dbg_end:
|
||||
if (temp != end)
|
||||
if (data != end)
|
||||
bad_format = true;
|
||||
break;
|
||||
|
||||
@ -139,12 +144,12 @@ void DBG_parse_debug_info(thread_db* tdbb, bid *blob_id, Firebird::DbgInfo& dbgI
|
||||
}
|
||||
}
|
||||
|
||||
if (!bad_format && (temp != end))
|
||||
if (!bad_format && (data != end))
|
||||
bad_format = true;
|
||||
|
||||
if (bad_format)
|
||||
{
|
||||
dbgInfo.blrToSrc.clear();
|
||||
dbgInfo.clear();
|
||||
ERR_post_warning(isc_bad_debug_format, 0);
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +90,13 @@ struct DbgInfo
|
||||
{
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
blrToSrc.clear();
|
||||
varIndexToName.clear();
|
||||
argInfoToName.clear();
|
||||
}
|
||||
|
||||
MapBlrToSrc blrToSrc; // mapping between blr offsets and source text position
|
||||
MapVarIndexToName varIndexToName; // mapping between variable index and name
|
||||
MapArgumentInfoToName argInfoToName; // mapping between argument info (type, index) and name
|
||||
@ -98,5 +105,6 @@ struct DbgInfo
|
||||
}; // namespace Firebird
|
||||
|
||||
void DBG_parse_debug_info(Jrd::thread_db*, Jrd::bid*, Firebird::DbgInfo&);
|
||||
void DBG_parse_debug_info(USHORT, const UCHAR*, Firebird::DbgInfo&);
|
||||
|
||||
#endif //DEBUG_INTERFACE_H
|
||||
|
@ -540,7 +540,8 @@ jrd_req* CMP_compile(USHORT blr_length, const UCHAR* blr, USHORT internal_flag)
|
||||
}
|
||||
|
||||
|
||||
jrd_req* CMP_compile2(thread_db* tdbb, const UCHAR* blr, USHORT internal_flag)
|
||||
jrd_req* CMP_compile2(thread_db* tdbb, const UCHAR* blr, USHORT internal_flag,
|
||||
USHORT dbginfo_length, const UCHAR* dbginfo)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -565,7 +566,7 @@ jrd_req* CMP_compile2(thread_db* tdbb, const UCHAR* blr, USHORT internal_flag)
|
||||
new_pool = JrdMemoryPool::createPool();
|
||||
Jrd::ContextPoolHolder context(tdbb, new_pool);
|
||||
|
||||
CompilerScratch* csb = PAR_parse(tdbb, blr, internal_flag);
|
||||
CompilerScratch* csb = PAR_parse(tdbb, blr, internal_flag, dbginfo_length, dbginfo);
|
||||
request = CMP_make_request(tdbb, csb);
|
||||
|
||||
if (internal_flag) {
|
||||
|
@ -32,7 +32,7 @@ bool CMP_clone_is_active(const Jrd::jrd_req*);
|
||||
Jrd::jrd_nod* CMP_clone_node(Jrd::thread_db*, Jrd::CompilerScratch*, Jrd::jrd_nod*);
|
||||
Jrd::jrd_req* CMP_clone_request(Jrd::thread_db*, Jrd::jrd_req*, USHORT, bool);
|
||||
Jrd::jrd_req* CMP_compile(USHORT, const UCHAR*, USHORT);
|
||||
Jrd::jrd_req* CMP_compile2(Jrd::thread_db*, const UCHAR*, USHORT);
|
||||
Jrd::jrd_req* CMP_compile2(Jrd::thread_db*, const UCHAR*, USHORT, USHORT = 0, const UCHAR* = NULL);
|
||||
Jrd::CompilerScratch::csb_repeat* CMP_csb_element(Jrd::CompilerScratch*, USHORT);
|
||||
void CMP_decrement_prc_use_count(Jrd::thread_db*, Jrd::jrd_prc*);
|
||||
Jrd::jrd_req* CMP_find_request(Jrd::thread_db*, USHORT, USHORT);
|
||||
|
@ -1501,17 +1501,17 @@ ENTRYPOINT( "gds_dsql_cache",
|
||||
/*** "_jrd8_dsql_cache" ***/ NULL,
|
||||
/*** IPI_dsql_cache ***/ no_entrypoint)
|
||||
|
||||
ENTRYPOINT( "gds_sql_text",
|
||||
jrd8_sql_text,
|
||||
/*** "jrd5_sql_text" ***/ NULL,
|
||||
/*** REM_sql_text ***/ no_entrypoint,
|
||||
/*** "REM_sql_text" ***/ NULL,
|
||||
/*** CSI_sql_text ***/ no_entrypoint,
|
||||
/*** RDB_sql_text ***/ no_entrypoint,
|
||||
/*** PSI_sql_text ***/ no_entrypoint,
|
||||
/*** PSI5_sql_text ***/ no_entrypoint,
|
||||
/*** "_jrd8_sql_text" ***/ NULL,
|
||||
/*** IPI_sql_text ***/ no_entrypoint)
|
||||
ENTRYPOINT( "gds_internal_compile_request",
|
||||
jrd8_internal_compile_request,
|
||||
/*** "jrd5_internal_compile_request" ***/ NULL,
|
||||
/*** REM_internal_compile_request ***/ no_entrypoint,
|
||||
/*** "REM_internal_compile_request" ***/ NULL,
|
||||
/*** CSI_internal_compile_request ***/ no_entrypoint,
|
||||
/*** RDB_internal_compile_request ***/ no_entrypoint,
|
||||
/*** PSI_internal_compile_request ***/ no_entrypoint,
|
||||
/*** PSI5_internal_compile_request ***/ no_entrypoint,
|
||||
/*** "_jrd8_internal_compile_request" ***/ NULL,
|
||||
/*** IPI_internal_compile_request ***/ no_entrypoint)
|
||||
|
||||
#undef ENTRYPOINT
|
||||
#endif // 0/1
|
||||
|
@ -740,6 +740,7 @@ public:
|
||||
csb_invariants(p),
|
||||
csb_current_nodes(p),
|
||||
csb_pool(p),
|
||||
csb_dbg_info(p),
|
||||
csb_map_field_info(p),
|
||||
csb_map_item_info(p),
|
||||
csb_domain_validation(domain_validation),
|
||||
@ -780,7 +781,7 @@ public:
|
||||
SLONG csb_impure; /* Next offset into impure area */
|
||||
USHORT csb_g_flags;
|
||||
MemoryPool& csb_pool; // Memory pool to be used by csb
|
||||
Firebird::DbgInfo* csb_dbg_info; // Debug information
|
||||
Firebird::DbgInfo csb_dbg_info; // Debug information
|
||||
MapFieldInfo csb_map_field_info; // Map field name to field info
|
||||
MapItemInfo csb_map_item_info; // Map item to item info
|
||||
Firebird::MetaName csb_domain_validation; // Parsing domain constraint in PSQL
|
||||
|
148
src/jrd/jrd.cpp
148
src/jrd/jrd.cpp
@ -244,13 +244,11 @@ void Jrd::Trigger::compile(thread_db* tdbb)
|
||||
try {
|
||||
Jrd::ContextPoolHolder context(tdbb, new_pool);
|
||||
|
||||
Firebird::DbgInfo dbgInfo;
|
||||
if (!dbg_blob_id.isEmpty())
|
||||
DBG_parse_debug_info(tdbb, &dbg_blob_id, dbgInfo);
|
||||
|
||||
csb = CompilerScratch::newCsb(*tdbb->getDefaultPool(), 5);
|
||||
csb->csb_g_flags |= par_flags;
|
||||
csb->csb_dbg_info = &dbgInfo;
|
||||
|
||||
if (!dbg_blob_id.isEmpty())
|
||||
DBG_parse_debug_info(tdbb, &dbg_blob_id, csb->csb_dbg_info);
|
||||
|
||||
PAR_blr(tdbb, relation, blr.begin(), NULL, &csb, &request, (relation ? true : false),
|
||||
par_flags);
|
||||
@ -396,6 +394,7 @@ static blb* check_blob(thread_db*, ISC_STATUS*, blb**);
|
||||
static ISC_STATUS check_database(thread_db*, Attachment*, ISC_STATUS*);
|
||||
static void cleanup(void*);
|
||||
static ISC_STATUS commit(ISC_STATUS*, jrd_tra**, const bool);
|
||||
static ISC_STATUS compile_request(ISC_STATUS*, Attachment**, jrd_req**, SSHORT, const SCHAR*, USHORT, const char*, USHORT, const UCHAR*);
|
||||
static bool drop_files(const jrd_file*);
|
||||
static ISC_STATUS error(ISC_STATUS*, const Firebird::Exception& ex);
|
||||
static ISC_STATUS error(ISC_STATUS*);
|
||||
@ -520,7 +519,7 @@ bool invalid_client_SQL_dialect = false;
|
||||
#define GDS_DROP_DATABASE jrd8_drop_database
|
||||
#define GDS_INTL_FUNCTION jrd8_intl_function
|
||||
#define GDS_DSQL_CACHE jrd8_dsql_cache
|
||||
#define GDS_SQL_TEXT jrd8_sql_text
|
||||
#define GDS_INTERNAL_COMPILE jrd8_internal_compile_request
|
||||
#define GDS_GET_SEGMENT jrd8_get_segment
|
||||
#define GDS_GET_SLICE jrd8_get_slice
|
||||
#define GDS_OPEN_BLOB2 jrd8_open_blob2
|
||||
@ -1670,44 +1669,7 @@ ISC_STATUS GDS_COMPILE(ISC_STATUS* user_status,
|
||||
* Functional description
|
||||
*
|
||||
**************************************/
|
||||
api_entry_point_init(user_status);
|
||||
|
||||
thread_db thd_context;
|
||||
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
|
||||
|
||||
NULL_CHECK(req_handle, isc_bad_req_handle);
|
||||
Attachment* attachment = *db_handle;
|
||||
|
||||
if (check_database(tdbb, attachment, user_status))
|
||||
return user_status[1];
|
||||
|
||||
#ifdef REPLAY_OSRI_API_CALLS_SUBSYSTEM
|
||||
LOG_call(log_compile, *db_handle, *req_handle, blr_length, blr);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
tdbb->tdbb_status_vector = user_status;
|
||||
|
||||
jrd_req* request =
|
||||
CMP_compile2(tdbb, reinterpret_cast<const UCHAR*>(blr), FALSE);
|
||||
request->req_attachment = attachment;
|
||||
request->req_request = attachment->att_requests;
|
||||
attachment->att_requests = request;
|
||||
request->req_stats.setParent(&attachment->att_stats);
|
||||
|
||||
DEBUG;
|
||||
*req_handle = request;
|
||||
#ifdef REPLAY_OSRI_API_CALLS_SUBSYSTEM
|
||||
LOG_call(log_handle_returned, *req_handle);
|
||||
#endif
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
return error(user_status, ex);
|
||||
}
|
||||
|
||||
return return_success(tdbb);
|
||||
return compile_request(user_status, db_handle, req_handle, blr_length, blr, 0, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -2753,42 +2715,27 @@ ISC_STATUS GDS_DSQL_CACHE(ISC_STATUS* user_status, Attachment** handle,
|
||||
}
|
||||
|
||||
|
||||
ISC_STATUS GDS_SQL_TEXT(ISC_STATUS* user_status, jrd_req** req_handle,
|
||||
USHORT length, const char* string)
|
||||
ISC_STATUS GDS_INTERNAL_COMPILE(ISC_STATUS* user_status,
|
||||
Attachment** db_handle,
|
||||
jrd_req** req_handle,
|
||||
SSHORT blr_length,
|
||||
const SCHAR* blr,
|
||||
USHORT string_length, const char* string,
|
||||
USHORT dbginfo_length, const UCHAR* dbginfo)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* g d s _ s q l _ t e x t
|
||||
* g d s _ $ i n t e r n a l _ c o m p i l e
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Stores the SQL text of the given request.
|
||||
* Compile a request passing the SQL text and debug information.
|
||||
* (candidate for removal when engine functions can be called by DSQL)
|
||||
*
|
||||
**************************************/
|
||||
api_entry_point_init(user_status);
|
||||
|
||||
thread_db thd_context;
|
||||
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
|
||||
|
||||
jrd_req* request = *req_handle;
|
||||
CHECK_HANDLE(request, type_req, isc_bad_req_handle);
|
||||
|
||||
if (check_database(tdbb, request->req_attachment, user_status))
|
||||
return user_status[1];
|
||||
|
||||
try
|
||||
{
|
||||
tdbb->tdbb_status_vector = user_status;
|
||||
request->req_sql_text = Firebird::string(string, length);
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
return error(user_status, ex);
|
||||
}
|
||||
|
||||
return return_success(tdbb);
|
||||
return compile_request(user_status, db_handle, req_handle, blr_length, blr,
|
||||
string_length, string, dbginfo_length, dbginfo);
|
||||
}
|
||||
|
||||
|
||||
@ -5111,6 +5058,67 @@ static ISC_STATUS commit(
|
||||
}
|
||||
|
||||
|
||||
ISC_STATUS compile_request(ISC_STATUS* user_status,
|
||||
Attachment** db_handle,
|
||||
jrd_req** req_handle,
|
||||
SSHORT blr_length,
|
||||
const SCHAR* blr,
|
||||
USHORT string_length, const char* string,
|
||||
USHORT dbginfo_length, const UCHAR* dbginfo)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* compile_request
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
*
|
||||
**************************************/
|
||||
api_entry_point_init(user_status);
|
||||
|
||||
thread_db thd_context;
|
||||
thread_db* tdbb = JRD_MAIN_set_thread_data(thd_context);
|
||||
|
||||
NULL_CHECK(req_handle, isc_bad_req_handle);
|
||||
Attachment* attachment = *db_handle;
|
||||
|
||||
if (check_database(tdbb, attachment, user_status))
|
||||
return user_status[1];
|
||||
|
||||
#ifdef REPLAY_OSRI_API_CALLS_SUBSYSTEM
|
||||
LOG_call(log_compile, *db_handle, *req_handle, blr_length, blr);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
tdbb->tdbb_status_vector = user_status;
|
||||
|
||||
jrd_req* request = CMP_compile2(tdbb, reinterpret_cast<const UCHAR*>(blr), FALSE,
|
||||
dbginfo_length, dbginfo);
|
||||
|
||||
request->req_attachment = attachment;
|
||||
request->req_request = attachment->att_requests;
|
||||
attachment->att_requests = request;
|
||||
|
||||
request->req_sql_text = Firebird::string(string, string_length);
|
||||
request->req_stats.setParent(&attachment->att_stats);
|
||||
|
||||
DEBUG;
|
||||
*req_handle = request;
|
||||
#ifdef REPLAY_OSRI_API_CALLS_SUBSYSTEM
|
||||
LOG_call(log_handle_returned, *req_handle);
|
||||
#endif
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
return error(user_status, ex);
|
||||
}
|
||||
|
||||
return return_success(tdbb);
|
||||
}
|
||||
|
||||
|
||||
static bool drop_files(const jrd_file* file)
|
||||
{
|
||||
/**************************************
|
||||
|
@ -78,7 +78,11 @@ ISC_STATUS jrd8_intl_function(ISC_STATUS *, Jrd::Attachment**,
|
||||
USHORT, UCHAR, USHORT, const UCHAR*, USHORT*);
|
||||
ISC_STATUS jrd8_dsql_cache(ISC_STATUS *, Jrd::Attachment**,
|
||||
USHORT, int, const char*, bool*);
|
||||
ISC_STATUS jrd8_sql_text(ISC_STATUS *, Jrd::jrd_req**, USHORT, const char*);
|
||||
ISC_STATUS jrd8_internal_compile_request(ISC_STATUS*, Jrd::Attachment**,
|
||||
Jrd::jrd_req**,
|
||||
SSHORT, const SCHAR*,
|
||||
USHORT, const char*,
|
||||
USHORT, const UCHAR*);
|
||||
ISC_STATUS jrd8_get_segment(ISC_STATUS *, Jrd::blb**, USHORT *,
|
||||
USHORT, UCHAR *);
|
||||
ISC_STATUS jrd8_get_slice(ISC_STATUS*, Jrd::Attachment**,
|
||||
|
@ -3102,48 +3102,41 @@ jrd_prc* MET_procedure(thread_db* tdbb, int id, bool noscan, USHORT flags)
|
||||
prc_t prc_type = prc_legacy;
|
||||
|
||||
JrdMemoryPool *csb_pool = JrdMemoryPool::createPool();
|
||||
Firebird::DbgInfo* dbgInfo = NULL;
|
||||
|
||||
if (ENCODE_ODS(dbb->dbb_ods_version, dbb->dbb_minor_original) >= ODS_11_1)
|
||||
{
|
||||
FOR(REQUEST_HANDLE request4)
|
||||
PT IN RDB$PROCEDURES
|
||||
WITH PT.RDB$PROCEDURE_ID EQ procedure->prc_id
|
||||
|
||||
if (!REQUEST(irq_p_type))
|
||||
{
|
||||
REQUEST(irq_p_type) = request4;
|
||||
}
|
||||
|
||||
if (PT.RDB$PROCEDURE_TYPE.NULL == FALSE)
|
||||
prc_type = (prc_t) PT.RDB$PROCEDURE_TYPE;
|
||||
|
||||
if (PT.RDB$DEBUG_INFO.NULL == FALSE)
|
||||
{
|
||||
dbgInfo = FB_NEW(*csb_pool) Firebird::DbgInfo(*csb_pool);
|
||||
DBG_parse_debug_info(tdbb, &PT.RDB$DEBUG_INFO, *dbgInfo);
|
||||
}
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_p_type)) {
|
||||
REQUEST(irq_p_type) = request4;
|
||||
}
|
||||
}
|
||||
|
||||
procedure->prc_type = prc_type;
|
||||
|
||||
{
|
||||
Jrd::ContextPoolHolder context(tdbb, csb_pool);
|
||||
CompilerScratch* csb = CompilerScratch::newCsb(*tdbb->getDefaultPool(), 5);
|
||||
|
||||
csb->csb_dbg_info = dbgInfo;
|
||||
|
||||
if (ENCODE_ODS(dbb->dbb_ods_version, dbb->dbb_minor_original) >= ODS_11_1)
|
||||
{
|
||||
FOR(REQUEST_HANDLE request4)
|
||||
PT IN RDB$PROCEDURES
|
||||
WITH PT.RDB$PROCEDURE_ID EQ procedure->prc_id
|
||||
|
||||
if (!REQUEST(irq_p_type))
|
||||
{
|
||||
REQUEST(irq_p_type) = request4;
|
||||
}
|
||||
|
||||
if (PT.RDB$PROCEDURE_TYPE.NULL == FALSE)
|
||||
prc_type = (prc_t) PT.RDB$PROCEDURE_TYPE;
|
||||
|
||||
if (PT.RDB$DEBUG_INFO.NULL == FALSE)
|
||||
DBG_parse_debug_info(tdbb, &PT.RDB$DEBUG_INFO, csb->csb_dbg_info);
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_p_type)) {
|
||||
REQUEST(irq_p_type) = request4;
|
||||
}
|
||||
}
|
||||
|
||||
procedure->prc_type = prc_type;
|
||||
|
||||
// Now, check the result of this function here! Null pointer means failure.
|
||||
// Or should parse_procedure_blr and its callee throw exceptions instead?
|
||||
if (!parse_procedure_blr(tdbb, procedure, &P.RDB$PROCEDURE_BLR, csb))
|
||||
{
|
||||
delete dbgInfo;
|
||||
delete csb;
|
||||
|
||||
if (procedure->prc_request) {
|
||||
@ -3174,7 +3167,6 @@ jrd_prc* MET_procedure(thread_db* tdbb, int id, bool noscan, USHORT flags)
|
||||
}
|
||||
}
|
||||
}
|
||||
delete dbgInfo;
|
||||
delete csb;
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,8 @@ jrd_nod* PAR_make_node(thread_db* tdbb, int size)
|
||||
}
|
||||
|
||||
|
||||
CompilerScratch* PAR_parse(thread_db* tdbb, const UCHAR* blr, USHORT internal_flag)
|
||||
CompilerScratch* PAR_parse(thread_db* tdbb, const UCHAR* blr, USHORT internal_flag,
|
||||
USHORT dbginfo_length, const UCHAR* dbginfo)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -663,6 +664,9 @@ CompilerScratch* PAR_parse(thread_db* tdbb, const UCHAR* blr, USHORT internal_fl
|
||||
csb->csb_g_flags |= csb_blr_version4;
|
||||
}
|
||||
|
||||
if (dbginfo_length > 0)
|
||||
DBG_parse_debug_info(dbginfo_length, dbginfo, csb->csb_dbg_info);
|
||||
|
||||
jrd_nod* node = parse(tdbb, csb, OTHER);
|
||||
csb->csb_node = node;
|
||||
|
||||
@ -1621,13 +1625,8 @@ static jrd_nod* par_message(thread_db* tdbb, CompilerScratch* csb)
|
||||
|
||||
if (itemInfo.isSpecial() && index % 2 == 0)
|
||||
{
|
||||
bool exist = false;
|
||||
|
||||
if (csb->csb_dbg_info)
|
||||
{
|
||||
exist = csb->csb_dbg_info->argInfoToName.get(
|
||||
Firebird::ArgumentInfo(csb->csb_msg_number, index / 2), itemInfo.name);
|
||||
}
|
||||
csb->csb_dbg_info.argInfoToName.get(
|
||||
Firebird::ArgumentInfo(csb->csb_msg_number, index / 2), itemInfo.name);
|
||||
|
||||
csb->csb_map_item_info.put(
|
||||
Item(nod_argument, csb->csb_msg_number, index), itemInfo);
|
||||
@ -2936,11 +2935,7 @@ static jrd_nod* parse(thread_db* tdbb, CompilerScratch* csb, USHORT expected,
|
||||
|
||||
if (itemInfo.isSpecial())
|
||||
{
|
||||
bool exist = false;
|
||||
|
||||
if (csb->csb_dbg_info)
|
||||
exist = csb->csb_dbg_info->varIndexToName.get(n, itemInfo.name);
|
||||
|
||||
csb->csb_dbg_info.varIndexToName.get(n, itemInfo.name);
|
||||
csb->csb_map_item_info.put(Item(nod_variable, n), itemInfo);
|
||||
}
|
||||
|
||||
@ -3130,21 +3125,18 @@ static jrd_nod* parse(thread_db* tdbb, CompilerScratch* csb, USHORT expected,
|
||||
node->nod_type = (NOD_T) (USHORT) blr_table[(int) blr_operator];
|
||||
}
|
||||
|
||||
if (csb->csb_dbg_info)
|
||||
size_t pos = 0;
|
||||
if (csb->csb_dbg_info.blrToSrc.find(blr_offset, pos))
|
||||
{
|
||||
size_t pos = 0;
|
||||
if (csb->csb_dbg_info->blrToSrc.find(blr_offset, pos))
|
||||
{
|
||||
Firebird::MapBlrToSrcItem& i = csb->csb_dbg_info->blrToSrc[pos];
|
||||
jrd_nod* node_src = PAR_make_node(tdbb, e_src_info_length);
|
||||
Firebird::MapBlrToSrcItem& i = csb->csb_dbg_info.blrToSrc[pos];
|
||||
jrd_nod* node_src = PAR_make_node(tdbb, e_src_info_length);
|
||||
|
||||
node_src->nod_type = nod_src_info;
|
||||
node_src->nod_arg[e_src_info_line] = (jrd_nod*) (IPTR) i.mbs_src_line;
|
||||
node_src->nod_arg[e_src_info_col] = (jrd_nod*) (IPTR) i.mbs_src_col;
|
||||
node_src->nod_arg[e_src_info_node] = node;
|
||||
node_src->nod_type = nod_src_info;
|
||||
node_src->nod_arg[e_src_info_line] = (jrd_nod*) (IPTR) i.mbs_src_line;
|
||||
node_src->nod_arg[e_src_info_col] = (jrd_nod*) (IPTR) i.mbs_src_col;
|
||||
node_src->nod_arg[e_src_info_node] = node;
|
||||
|
||||
return node_src;
|
||||
}
|
||||
return node_src;
|
||||
}
|
||||
|
||||
return node;
|
||||
|
@ -42,7 +42,7 @@ Jrd::jrd_nod* PAR_gen_field(Jrd::thread_db*, USHORT, USHORT);
|
||||
Jrd::jrd_nod* PAR_make_field(Jrd::thread_db*, Jrd::CompilerScratch*, USHORT, const Firebird::MetaName&);
|
||||
Jrd::jrd_nod* PAR_make_list(Jrd::thread_db*, Jrd::NodeStack&);
|
||||
Jrd::jrd_nod* PAR_make_node(Jrd::thread_db*, int);
|
||||
Jrd::CompilerScratch* PAR_parse(Jrd::thread_db*, const UCHAR*, USHORT);
|
||||
Jrd::CompilerScratch* PAR_parse(Jrd::thread_db*, const UCHAR*, USHORT, USHORT = 0, const UCHAR* = NULL);
|
||||
SLONG PAR_symbol_to_gdscode(const Firebird::MetaName&);
|
||||
|
||||
#endif // JRD_PAR_PROTO_H
|
||||
|
@ -435,7 +435,7 @@ static const TEXT glbunknown[10] = "<unknown>";
|
||||
//#define GDS_EVENT_WAIT gds__event_wait
|
||||
#define GDS_INTL_FUNCTION gds__intl_function
|
||||
#define GDS_DSQL_CACHE gds__dsql_cache
|
||||
#define GDS_SQL_TEXT gds__sql_text
|
||||
#define GDS_INTERNAL_COMPILE gds__internal_compile_request
|
||||
#define GDS_GET_SEGMENT isc_get_segment
|
||||
#define GDS_GET_SLICE isc_get_slice
|
||||
#define GDS_OPEN_BLOB isc_open_blob
|
||||
@ -565,7 +565,7 @@ const int PROC_ROLLBACK_RETAINING = 52;
|
||||
const int PROC_CANCEL_OPERATION = 53;
|
||||
const int PROC_INTL_FUNCTION = 54; // internal call
|
||||
const int PROC_DSQL_CACHE = 55; // internal call
|
||||
const int PROC_SQL_TEXT = 56; // internal call
|
||||
const int PROC_INTERNAL_COMPILE = 56; // internal call
|
||||
|
||||
const int PROC_count = 57;
|
||||
|
||||
@ -3830,27 +3830,51 @@ ISC_STATUS API_ROUTINE GDS_DSQL_CACHE(ISC_STATUS * user_status,
|
||||
}
|
||||
|
||||
|
||||
ISC_STATUS API_ROUTINE GDS_SQL_TEXT(ISC_STATUS * user_status,
|
||||
FB_API_HANDLE* handle,
|
||||
USHORT length,
|
||||
const char* string)
|
||||
ISC_STATUS API_ROUTINE GDS_INTERNAL_COMPILE(ISC_STATUS* user_status,
|
||||
FB_API_HANDLE* db_handle,
|
||||
FB_API_HANDLE* req_handle,
|
||||
USHORT blr_length,
|
||||
const SCHAR* blr,
|
||||
USHORT string_length,
|
||||
const char* string,
|
||||
USHORT dbginfo_length,
|
||||
const UCHAR* dbginfo)
|
||||
{
|
||||
ISC_STATUS *status;
|
||||
ISC_STATUS_ARRAY local;
|
||||
WHY_REQ request;
|
||||
WHY_ATT dbb;
|
||||
WHY_REQ request = NULL;
|
||||
|
||||
GET_STATUS;
|
||||
TRANSLATE_HANDLE(*handle, request, HANDLE_request, isc_bad_req_handle);
|
||||
NULL_CHECK(req_handle, isc_bad_req_handle, HANDLE_request);
|
||||
TRANSLATE_HANDLE(*db_handle, dbb, HANDLE_database, isc_bad_db_handle);
|
||||
subsystem_enter();
|
||||
|
||||
if (CALL(PROC_SQL_TEXT, request->implementation) (status,
|
||||
&request->handle,
|
||||
length,
|
||||
string))
|
||||
if (CALL(PROC_INTERNAL_COMPILE, dbb->implementation) (status, &dbb->handle,
|
||||
&request, blr_length,
|
||||
blr,
|
||||
string_length, string,
|
||||
dbginfo_length, dbginfo))
|
||||
{
|
||||
return error(status, local);
|
||||
}
|
||||
|
||||
request = allocate_handle(dbb->implementation, request, HANDLE_request);
|
||||
if (!request) {
|
||||
/* No memory. Make a half-hearted attempt to release request. */
|
||||
|
||||
CALL(PROC_RELEASE_REQUEST, dbb->implementation) (status, request->handle.h_why);
|
||||
status[0] = isc_arg_gds;
|
||||
status[1] = isc_virmemexh;
|
||||
status[2] = isc_arg_end;
|
||||
return error(status, local);
|
||||
}
|
||||
|
||||
*req_handle = request->public_handle;
|
||||
request->parent = dbb;
|
||||
request->next = dbb->requests;
|
||||
dbb->requests = request;
|
||||
|
||||
RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,9 @@ ISC_STATUS API_ROUTINE gds__intl_function(ISC_STATUS*, FB_API_HANDLE*, USHORT, U
|
||||
#define DSQL_CACHE_RELEASE 2
|
||||
ISC_STATUS API_ROUTINE gds__dsql_cache(ISC_STATUS*, FB_API_HANDLE*, USHORT, int, const char*, bool*);
|
||||
|
||||
ISC_STATUS API_ROUTINE gds__sql_text(ISC_STATUS*, FB_API_HANDLE*, USHORT, const char*);
|
||||
ISC_STATUS API_ROUTINE gds__internal_compile_request(
|
||||
ISC_STATUS*, FB_API_HANDLE*, FB_API_HANDLE*, USHORT,
|
||||
const SCHAR*, USHORT, const char*, USHORT, const UCHAR*);
|
||||
|
||||
typedef void TransactionCleanupRoutine(FB_API_HANDLE, void*);
|
||||
ISC_STATUS API_ROUTINE gds__transaction_cleanup(ISC_STATUS*, FB_API_HANDLE*,
|
||||
|
Loading…
Reference in New Issue
Block a user