From: <di...@us...> - 2013-01-25 12:34:23
|
Revision: 57623 http://sourceforge.net/p/firebird/code/57623 Author: dimitr Date: 2013-01-25 12:34:19 +0000 (Fri, 25 Jan 2013) Log Message: ----------- More work towards unlimited SQL/BLR lengths. Modified Paths: -------------- firebird/trunk/src/dsql/BlrWriter.cpp firebird/trunk/src/dsql/BlrWriter.h firebird/trunk/src/dsql/Nodes.h firebird/trunk/src/dsql/Parser.h firebird/trunk/src/dsql/StmtNodes.h firebird/trunk/src/dsql/dsql.cpp firebird/trunk/src/jrd/DebugInterface.cpp firebird/trunk/src/jrd/DebugInterface.h firebird/trunk/src/jrd/filters.cpp firebird/trunk/src/jrd/met.epp firebird/trunk/src/jrd/met_proto.h firebird/trunk/src/jrd/par.cpp firebird/trunk/src/jrd/req.h Modified: firebird/trunk/src/dsql/BlrWriter.cpp =================================================================== --- firebird/trunk/src/dsql/BlrWriter.cpp 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/dsql/BlrWriter.cpp 2013-01-25 12:34:19 UTC (rev 57623) @@ -55,70 +55,17 @@ appendBytes(reinterpret_cast<const UCHAR*>(string), length); } -// Input -// blr_ptr: current position of blr being generated -// verb: blr byte of which number is an argument -// number: value to be written to blr -// Function -// Write out a numeric valued attribute. -void BlrWriter::appendNumber(UCHAR verb, SSHORT number) -{ - if (verb) - appendUChar(verb); - - appendUShortWithLength(number); -} - -void BlrWriter::appendUShortWithLength(USHORT val) -{ - // append an USHORT value, prepended with the USHORT length of an USHORT - appendUShort(2); - appendUShort(val); -} - -void BlrWriter::appendULongWithLength(ULONG val) -{ - // append an ULONG value, prepended with the USHORT length of an ULONG - appendUShort(4); - appendULong(val); -} - -// Write out a string of blr as part of a ddl string, as in a view or computed field definition. -void BlrWriter::beginBlr(UCHAR verb) -{ - if (verb) - appendUChar(verb); - - baseOffset = blrData.getCount(); - - // put in a place marker for the size of the blr, since it is unknown - appendUShort(0); - appendUChar(isVersion4() ? blr_version4 : blr_version5); -} - -// Complete the stuffing of a piece of blr by going back and inserting the length. -void BlrWriter::endBlr() -{ - appendUChar(blr_eoc); - - // go back and stuff in the proper length - - UCHAR* blr_base = &blrData[baseOffset]; - const ULONG length = (blrData.getCount() - baseOffset) - 2; - - if (length > 0xFFFF) - ERRD_post(Arg::Gds(isc_too_big_blr) << Arg::Num(length) << Arg::Num(0xFFFF)); - - *blr_base++ = (UCHAR) length; - *blr_base = (UCHAR) (length >> 8); -} - void BlrWriter::beginDebug() { fb_assert(debugData.isEmpty()); + // Version 2 replaces 16-bit values inside the + // fb_dbg_map_src2blr tag with 32-bit ones. + // Also, it introduces some new tags. + const UCHAR CURRENT_DEBUG_INFO_VERSION = 2; + debugData.add(fb_dbg_version); - debugData.add(1); + debugData.add(CURRENT_DEBUG_INFO_VERSION); } void BlrWriter::endDebug() @@ -126,19 +73,25 @@ debugData.add(fb_dbg_end); } -void BlrWriter::putDebugSrcInfo(USHORT line, USHORT col) +void BlrWriter::putDebugSrcInfo(ULONG line, ULONG col) { debugData.add(fb_dbg_map_src2blr); debugData.add(line); debugData.add(line >> 8); + debugData.add(line >> 16); + debugData.add(line >> 24); debugData.add(col); debugData.add(col >> 8); + debugData.add(col >> 16); + debugData.add(col >> 24); - ULONG offset = (blrData.getCount() - baseOffset); + const ULONG offset = (blrData.getCount() - baseOffset); debugData.add(offset); debugData.add(offset >> 8); + debugData.add(offset >> 16); + debugData.add(offset >> 24); } void BlrWriter::putDebugVariable(USHORT number, const MetaName& name) @@ -204,25 +157,12 @@ debugData.add(reinterpret_cast<const UCHAR*>(name.c_str()), len); HalfStaticArray<UCHAR, 128>& subDebugData = subProcNode->blockScratch->debugData; - debugData.add(UCHAR(subDebugData.getCount())); - debugData.add(UCHAR(subDebugData.getCount() >> 8)); - debugData.add(UCHAR(subDebugData.getCount() >> 16)); - debugData.add(UCHAR(subDebugData.getCount() >> 24)); - debugData.add(subDebugData.begin(), ULONG(subDebugData.getCount())); + const ULONG count = ULONG(subDebugData.getCount()); + debugData.add(UCHAR(count)); + debugData.add(UCHAR(count >> 8)); + debugData.add(UCHAR(count >> 16)); + debugData.add(UCHAR(count >> 24)); + debugData.add(subDebugData.begin(), count); } -void BlrWriter::appendDebugInfo() -{ - endDebug(); - - const size_t len = blrData.getCount() + debugData.getCount(); - if (len + 4 < MAX_USHORT) - { - appendUChar(isc_dyn_debug_info); - appendUShort(debugData.getCount()); - appendBytes(debugData.begin(), debugData.getCount()); - } -} - - } // namespace Jrd Modified: firebird/trunk/src/dsql/BlrWriter.h =================================================================== --- firebird/trunk/src/dsql/BlrWriter.h 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/dsql/BlrWriter.h 2013-01-25 12:34:19 UTC (rev 57623) @@ -117,21 +117,13 @@ appendString(verb, name.c_str(), static_cast<USHORT>(name.length())); } - void appendNumber(UCHAR verb, SSHORT number); - void appendUShortWithLength(USHORT val); - void appendULongWithLength(ULONG val); - - void beginBlr(UCHAR verb); - void endBlr(); - void beginDebug(); void endDebug(); - void putDebugSrcInfo(USHORT, USHORT); + void putDebugSrcInfo(ULONG, ULONG); void putDebugVariable(USHORT, const Firebird::MetaName&); void putDebugArgument(UCHAR, USHORT, const TEXT*); void putDebugSubFunction(DeclareSubFuncNode* subFuncNode); void putDebugSubProcedure(DeclareSubProcNode* subProcNode); - void appendDebugInfo(); BlrData& getBlrData() { return blrData; } DebugData& getDebugData() { return debugData; } Modified: firebird/trunk/src/dsql/Nodes.h =================================================================== --- firebird/trunk/src/dsql/Nodes.h 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/dsql/Nodes.h 2013-01-25 12:34:19 UTC (rev 57623) @@ -167,8 +167,8 @@ } public: - USHORT line; - USHORT column; + ULONG line; + ULONG column; }; Modified: firebird/trunk/src/dsql/Parser.h =================================================================== --- firebird/trunk/src/dsql/Parser.h 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/dsql/Parser.h 2013-01-25 12:34:19 UTC (rev 57623) @@ -45,10 +45,10 @@ // User-defined text position type. struct Position { - USHORT firstLine; - USHORT firstColumn; - USHORT lastLine; - USHORT lastColumn; + ULONG firstLine; + ULONG firstColumn; + ULONG lastLine; + ULONG lastColumn; const char* firstPos; const char* lastPos; }; @@ -88,8 +88,8 @@ const TEXT* line_start; const TEXT* last_token_bk; const TEXT* line_start_bk; - SSHORT lines, att_charset; - SSHORT lines_bk; + SSHORT att_charset; + SLONG lines, lines_bk; int prev_keyword; USHORT param_number; }; @@ -188,8 +188,8 @@ private: template <typename T> T* setupNode(Node* node) { - node->line = (USHORT) lex.lines_bk; - node->column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); + node->line = (ULONG) lex.lines_bk; + node->column = (ULONG) (lex.last_token_bk - lex.line_start_bk + 1); return static_cast<T*>(node); } Modified: firebird/trunk/src/dsql/StmtNodes.h =================================================================== --- firebird/trunk/src/dsql/StmtNodes.h 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/dsql/StmtNodes.h 2013-01-25 12:34:19 UTC (rev 57623) @@ -949,7 +949,7 @@ class LineColumnNode : public TypedNode<DsqlOnlyStmtNode, StmtNode::TYPE_LINE_COLUMN> { public: - explicit LineColumnNode(MemoryPool& pool, USHORT aLine, USHORT aColumn, StmtNode* aStatement) + explicit LineColumnNode(MemoryPool& pool, ULONG aLine, ULONG aColumn, StmtNode* aStatement) : TypedNode<DsqlOnlyStmtNode, StmtNode::TYPE_LINE_COLUMN>(pool), statement(aStatement) { Modified: firebird/trunk/src/dsql/dsql.cpp =================================================================== --- firebird/trunk/src/dsql/dsql.cpp 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/dsql/dsql.cpp 2013-01-25 12:34:19 UTC (rev 57623) @@ -1534,13 +1534,12 @@ bool isInternalRequest) { if (text && textLength == 0) - { - size_t sqlLength = strlen(text); - if (sqlLength > MAX_USHORT) - sqlLength = MAX_USHORT; - textLength = static_cast<USHORT>(sqlLength); - } + textLength = static_cast<ULONG>(strlen(text)); + // just a safety check + const ULONG MAX_SQL_LENGTH = 10 * 1024 * 1024; // 10 MB + textLength = MIN(textLength, MAX_SQL_LENGTH); + TraceDSQLPrepare trace(database->dbb_attachment, transaction, textLength, text); if (clientDialect > SQL_DIALECT_CURRENT) @@ -1549,7 +1548,6 @@ Arg::Gds(isc_wish_list)); } - if (!text || textLength == 0) { ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << Modified: firebird/trunk/src/jrd/DebugInterface.cpp =================================================================== --- firebird/trunk/src/jrd/DebugInterface.cpp 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/jrd/DebugInterface.cpp 2013-01-25 12:34:19 UTC (rev 57623) @@ -72,12 +72,18 @@ MapBlrToSrcItem i; i.mbs_src_line = *data++; i.mbs_src_line |= *data++ << 8; + i.mbs_src_line |= *data++ << 16; + i.mbs_src_line |= *data++ << 24; i.mbs_src_col = *data++; i.mbs_src_col |= *data++ << 8; + i.mbs_src_col |= *data++ << 16; + i.mbs_src_col |= *data++ << 24; i.mbs_offset = *data++; i.mbs_offset |= *data++ << 8; + i.mbs_offset |= *data++ << 16; + i.mbs_offset |= *data++ << 24; dbgInfo.blrToSrc.add(i); } Modified: firebird/trunk/src/jrd/DebugInterface.h =================================================================== --- firebird/trunk/src/jrd/DebugInterface.h 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/jrd/DebugInterface.h 2013-01-25 12:34:19 UTC (rev 57623) @@ -33,18 +33,18 @@ class MapBlrToSrcItem { public: - USHORT mbs_offset; - USHORT mbs_src_line; - USHORT mbs_src_col; + ULONG mbs_offset; + ULONG mbs_src_line; + ULONG mbs_src_col; - static USHORT generate(const void*, const MapBlrToSrcItem& Item) + static ULONG generate(const void*, const MapBlrToSrcItem& Item) { return Item.mbs_offset; } }; typedef Firebird::SortedArray< MapBlrToSrcItem, Firebird::EmptyStorage<MapBlrToSrcItem>, - USHORT, + ULONG, MapBlrToSrcItem> MapBlrToSrc; typedef GenericMap<Pair<Right<USHORT, MetaName> > > MapVarIndexToName; Modified: firebird/trunk/src/jrd/filters.cpp =================================================================== --- firebird/trunk/src/jrd/filters.cpp 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/jrd/filters.cpp 2013-01-25 12:34:19 UTC (rev 57623) @@ -1348,14 +1348,14 @@ } string_put(control, "BLR to Source mapping:"); - str.printf("%10s %6s %6s", "BLR offset", "Line", "Column"); + str.printf("%10s %10s %10s", "BLR offset", "Line", "Column"); string_put(control, str.c_str()); str.replace(str.begin(), str.end(), str.length(), '-'); string_put(control, str.c_str()); for (const MapBlrToSrcItem* i = dbgInfo.blrToSrc.begin(); i < dbgInfo.blrToSrc.end(); i++) { - str.printf("%10d %6d %6d", i->mbs_offset, i->mbs_src_line, i->mbs_src_col); + str.printf("%10d %10d %10d", i->mbs_offset, i->mbs_src_line, i->mbs_src_col); string_put(control, str.c_str()); } Modified: firebird/trunk/src/jrd/met.epp =================================================================== --- firebird/trunk/src/jrd/met.epp 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/jrd/met.epp 2013-01-25 12:34:19 UTC (rev 57623) @@ -1376,7 +1376,7 @@ else { blb* blob = blb::open(tdbb, attachment->getSysTransaction(), &CL.RDB$SPECIFIC_ATTRIBUTES); - const SLONG length = blob->blb_length; + const ULONG length = blob->blb_length; // ASF: Here info->specificAttributes is in UNICODE_FSS charset. // It will be converted to the collation charset in intl.cpp @@ -2606,7 +2606,7 @@ Jrd::Attachment* attachment = tdbb->getAttachment(); blb* blob = blb::open(tdbb, attachment->getSysTransaction(), blob_id); - SLONG length = blob->blb_length + 10; + ULONG length = blob->blb_length + 10; HalfStaticArray<UCHAR, 512> tmp; UCHAR* temp = tmp.getBuffer(length); length = blob->BLB_get_data(tdbb, temp, length); @@ -2709,7 +2709,7 @@ if (ptr) { blb* blob = blb::open(tdbb, attachment->getSysTransaction(), &TRG.RDB$TRIGGER_BLR); - SLONG length = blob->blb_length + 10; + ULONG length = blob->blb_length + 10; HalfStaticArray<UCHAR, 128> blr; length = blob->BLB_get_data(tdbb, blr.getBuffer(length), length); @@ -4266,7 +4266,7 @@ CompilerScratch* csb = CompilerScratch::newCsb(*tdbb->getDefaultPool(), 5); blb* blob = blb::open(tdbb, attachment->getSysTransaction(), blob_id); - SLONG length = blob->blb_length + 10; + ULONG length = blob->blb_length + 10; HalfStaticArray<UCHAR, 512> temp; length = blob->BLB_get_data(tdbb, temp.getBuffer(length), length); @@ -4290,7 +4290,7 @@ CompilerScratch* csb = CompilerScratch::newCsb(*tdbb->getDefaultPool(), 5, name); blb* blob = blb::open(tdbb, attachment->getSysTransaction(), blob_id); - SLONG length = blob->blb_length + 10; + ULONG length = blob->blb_length + 10; HalfStaticArray<UCHAR, 512> temp; length = blob->BLB_get_data(tdbb, temp.getBuffer(length), length); @@ -4569,11 +4569,10 @@ else { blb* blob = blb::open(tdbb, attachment->getSysTransaction(), blob_id); - const SLONG length = blob->blb_length + 10; + ULONG length = blob->blb_length + 10; UCHAR* temp = tmp.getBuffer(length); - const ULONG realLen = blob->BLB_get_data(tdbb, temp, length); - fb_assert(realLen >= ULONG(length) - 10 && realLen <= ULONG(MAX_USHORT)); - tmp.resize(realLen); + length = blob->BLB_get_data(tdbb, temp, length); + tmp.resize(length); } MET_par_messages(tdbb, tmp.begin(), (ULONG) tmp.getCount(), routine, csb); @@ -4588,7 +4587,7 @@ // Parse the messages of a blr request. For specified message, allocate a format (Format) block. -void MET_par_messages(thread_db* tdbb, const UCHAR* const blr, USHORT blrLength, +void MET_par_messages(thread_db* tdbb, const UCHAR* const blr, ULONG blrLength, Routine* routine, CompilerScratch* csb) { SET_TDBB(tdbb); @@ -4889,7 +4888,7 @@ Trigger& t = vector->add(); if (blrBlob) { - const SLONG length = blrBlob->blb_length + 10; + const ULONG length = blrBlob->blb_length + 10; UCHAR* ptr2 = t.blr.getBuffer(length); t.blr.resize(blrBlob->BLB_get_data(tdbb, ptr2, length)); } Modified: firebird/trunk/src/jrd/met_proto.h =================================================================== --- firebird/trunk/src/jrd/met_proto.h 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/jrd/met_proto.h 2013-01-25 12:34:19 UTC (rev 57623) @@ -99,7 +99,7 @@ Jrd::jrd_prc* MET_lookup_procedure_id(Jrd::thread_db*, SSHORT, bool, bool, USHORT); Jrd::jrd_rel* MET_lookup_relation(Jrd::thread_db*, const Firebird::MetaName&); Jrd::jrd_rel* MET_lookup_relation_id(Jrd::thread_db*, SLONG, bool); -void MET_par_messages(Jrd::thread_db*, const UCHAR* const, USHORT, +void MET_par_messages(Jrd::thread_db*, const UCHAR* const, ULONG, Jrd::Routine* routine, Jrd::CompilerScratch*); Jrd::DmlNode* MET_parse_blob(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::bid*, Jrd::CompilerScratch**, Jrd::JrdStatement**, bool, bool); Modified: firebird/trunk/src/jrd/par.cpp =================================================================== --- firebird/trunk/src/jrd/par.cpp 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/jrd/par.cpp 2013-01-25 12:34:19 UTC (rev 57623) @@ -1561,7 +1561,7 @@ { SET_TDBB(tdbb); - const USHORT blr_offset = csb->csb_blr_reader.getOffset(); + const ULONG blr_offset = csb->csb_blr_reader.getOffset(); const SSHORT blr_operator = csb->csb_blr_reader.getByte(); if (blr_operator < 0 || blr_operator >= FB_NELEM(blr_parsers)) Modified: firebird/trunk/src/jrd/req.h =================================================================== --- firebird/trunk/src/jrd/req.h 2013-01-25 09:51:21 UTC (rev 57622) +++ firebird/trunk/src/jrd/req.h 2013-01-25 12:34:19 UTC (rev 57623) @@ -291,8 +291,8 @@ jrd_req* req_proc_caller; // Procedure's caller request const ValueListNode* req_proc_inputs; // and its node with input parameters - USHORT req_src_line; - USHORT req_src_column; + ULONG req_src_line; + ULONG req_src_column; dsc* req_domain_validation; // Current VALUE for constraint validation Firebird::Stack<jrd_tra*> req_auto_trans; // Autonomous transactions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |