Skip to content

Commit 423a62e

Browse files
author
Alexander Zhdanov
committed
Merge branch 'firebird_master' into port2firebird_tablespaces2
2 parents 47d48a2 + 8ca2314 commit 423a62e

File tree

23 files changed

+602
-300
lines changed

23 files changed

+602
-300
lines changed

doc/sql.extensions/README.packages.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Syntax:
2828
PROCEDURE <name> [( <parameters> ) [RETURNS ( <parameters> )]]
2929

3030
<package_body> ::=
31-
{ CREATE | RECREATE } PACKAGE BODY <name>
31+
{ CREATE [OR ALTER] | ALTER | RECREATE } PACKAGE BODY <name>
3232
AS
3333
BEGIN
3434
[ <package_item> ... ]

src/common/tests/CvtTestUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class MockCallback : public Firebird::Callbacks
122122
return m_mockGetLocalDateFunc();
123123
}
124124

125-
ISC_TIMESTAMP getCurrentGmtTimeStamp() override { ISC_TIMESTAMP ts; return ts; }
125+
ISC_TIMESTAMP getCurrentGmtTimeStamp() override { return {0, 0}; }
126126
USHORT getSessionTimeZone() override { return 1439; } // 1439 is ONE_DAY, so we have no offset
127127
void isVersion4(bool& v4) override { }
128128

src/common/utils_proto.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@
3131

3232
#include <cctype>
3333
#include <string.h>
34+
#include <type_traits>
35+
3436
#include "../common/classes/fb_string.h"
3537
#include "../common/classes/array.h"
3638
#include "iberror.h"
3739
#include "firebird/Interface.h"
40+
#include "memory_routines.h"
3841

3942
#ifdef SFIO
4043
#include <stdio.h>
@@ -271,6 +274,51 @@ namespace fb_utils
271274
// Frequently used actions with clumplets
272275
bool isBpbSegmented(unsigned parLength, const unsigned char* par);
273276

277+
278+
// Workaround, to be removed with C++ 23
279+
template <typename... T>
280+
constexpr bool fb_always_false_v = false;
281+
282+
// Put integer value into info buffer
283+
template<typename T>
284+
inline unsigned char* putInfoItemInt(const unsigned char item, T value,
285+
unsigned char* ptr, const unsigned char* end)
286+
{
287+
static_assert(std::is_integral_v<T>, "Integral type expected");
288+
289+
constexpr auto len = sizeof(T);
290+
291+
if (ptr + len + 1 + 2 > end)
292+
{
293+
if (ptr < end)
294+
{
295+
*ptr++ = isc_info_truncated;
296+
if (ptr < end)
297+
*ptr++ = isc_info_end;
298+
}
299+
return nullptr;
300+
}
301+
302+
*ptr++ = item;
303+
*ptr++ = len;
304+
*ptr++ = 0;
305+
306+
if constexpr (len == sizeof(SINT64))
307+
put_vax_int64(ptr, value);
308+
else if constexpr (len == sizeof(SLONG))
309+
put_vax_long(ptr, value);
310+
else if constexpr (len == sizeof(SSHORT))
311+
put_vax_short(ptr, value);
312+
else if constexpr (len == sizeof(char))
313+
*ptr = value;
314+
else
315+
static_assert(fb_always_false_v<T>, "unknown data type");
316+
317+
ptr += len;
318+
return ptr;
319+
}
320+
321+
274322
// RAII to call fb_shutdown() in utilities
275323
class FbShutdown
276324
{

src/dsql/parse.y

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,7 @@ replace_clause
17321732
| FUNCTION replace_function_clause { $$ = $2; }
17331733
| TRIGGER replace_trigger_clause { $$ = $2; }
17341734
| PACKAGE replace_package_clause { $$ = $2; }
1735+
| PACKAGE BODY replace_package_body_clause { $$ = $3; }
17351736
| VIEW replace_view_clause { $$ = $2; }
17361737
| EXCEPTION replace_exception_clause { $$ = $2; }
17371738
| GENERATOR replace_sequence_clause { $$ = $2; }
@@ -3264,6 +3265,12 @@ package_body_item
32643265
;
32653266

32663267

3268+
%type <ddlNode> replace_package_body_clause
3269+
replace_package_body_clause
3270+
: package_body_clause
3271+
{ $$ = newNode<RecreatePackageBodyNode>($1); }
3272+
;
3273+
32673274
%type <localDeclarationsNode> local_declarations_opt
32683275
local_declarations_opt
32693276
: local_forward_declarations_opt local_nonforward_declarations_opt
@@ -4333,6 +4340,7 @@ alter_clause
43334340
| TRIGGER alter_trigger_clause { $$ = $2; }
43344341
| PROCEDURE alter_procedure_clause { $$ = $2; }
43354342
| PACKAGE alter_package_clause { $$ = $2; }
4343+
| PACKAGE BODY replace_package_body_clause { $$ = $3; }
43364344
| DATABASE
43374345
{ $<alterDatabaseNode>$ = newNode<AlterDatabaseNode>(); }
43384346
alter_db($<alterDatabaseNode>2)

src/jrd/Monitoring.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,10 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
507507
if (LCK_lock(tdbb, lock, LCK_EX, LCK_NO_WAIT))
508508
{
509509
LCK_release(tdbb, lock);
510+
511+
MonitoringData::Guard guard(dbb->dbb_monitoring_data);
510512
dbb->dbb_monitoring_data->cleanup(attId);
513+
511514
continue;
512515
}
513516

@@ -541,7 +544,6 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
541544
{ // scope for the guard
542545

543546
MonitoringData::Guard guard(dbb->dbb_monitoring_data);
544-
545547
dbb->dbb_monitoring_data->read(userNamePtr, temp_space);
546548
}
547549

src/jrd/SysFunction.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ const char
396396
CLIENT_VERSION_NAME[] = "CLIENT_VERSION",
397397
CURRENT_USER_NAME[] = "CURRENT_USER",
398398
CURRENT_ROLE_NAME[] = "CURRENT_ROLE",
399+
SERVER_PID_NAME[] = "SERVER_PID",
399400
SESSION_IDLE_TIMEOUT[] = "SESSION_IDLE_TIMEOUT",
400401
STATEMENT_TIMEOUT[] = "STATEMENT_TIMEOUT",
401402
EFFECTIVE_USER_NAME[] = "EFFECTIVE_USER",
@@ -4709,6 +4710,8 @@ dsc* evlGetContext(thread_db* tdbb, const SysFunction*, const NestValueArray& ar
47094710

47104711
resultStr = role.c_str();
47114712
}
4713+
else if (nameStr == SERVER_PID_NAME)
4714+
resultStr.printf("%d", getpid());
47124715
else if (nameStr == SESSION_IDLE_TIMEOUT)
47134716
resultStr.printf("%" ULONGFORMAT, attachment->getIdleTimeout());
47144717
else if (nameStr == STATEMENT_TIMEOUT)
@@ -5467,19 +5470,22 @@ dsc* evlMakeDbkey(Jrd::thread_db* tdbb, const SysFunction* function, const NestV
54675470

54685471

54695472
dsc* evlMaxMinValue(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
5470-
impure_value*)
5473+
impure_value* impure)
54715474
{
54725475
fb_assert(args.getCount() >= 1);
54735476
fb_assert(function->misc != NULL);
54745477

5475-
Request* request = tdbb->getRequest();
5476-
dsc* result = NULL;
5478+
const auto request = tdbb->getRequest();
5479+
HalfStaticArray<const dsc*, 2> argTypes(args.getCount());
5480+
dsc* result = nullptr;
54775481

54785482
for (FB_SIZE_T i = 0; i < args.getCount(); ++i)
54795483
{
5480-
dsc* value = EVL_expr(tdbb, request, args[i]);
5484+
const auto value = EVL_expr(tdbb, request, args[i]);
54815485
if (request->req_flags & req_null) // return NULL if value is NULL
5482-
return NULL;
5486+
return nullptr;
5487+
5488+
argTypes.add(value);
54835489

54845490
if (i == 0)
54855491
result = value;
@@ -5503,7 +5509,12 @@ dsc* evlMaxMinValue(thread_db* tdbb, const SysFunction* function, const NestValu
55035509
}
55045510
}
55055511

5506-
return result;
5512+
DataTypeUtil(tdbb).makeFromList(&impure->vlu_desc, function->name, argTypes.getCount(), argTypes.begin());
5513+
impure->vlu_desc.dsc_address = (UCHAR*) &impure->vlu_misc;
5514+
5515+
MOV_move(tdbb, result, &impure->vlu_desc);
5516+
5517+
return &impure->vlu_desc;
55075518
}
55085519

55095520

src/jrd/btr.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,10 @@ void IndexScanListIterator::makeKeys(thread_db* tdbb, temporary_key* lower, temp
769769
m_upperValues[m_segno] = *m_iterator;
770770

771771
const auto keyType =
772-
(m_retrieval->irb_desc.idx_flags & idx_unique) ? INTL_KEY_UNIQUE : INTL_KEY_SORT;
772+
(m_retrieval->irb_generic & irb_multi_starting) ? INTL_KEY_MULTI_STARTING :
773+
(m_retrieval->irb_generic & irb_starting) ? INTL_KEY_PARTIAL :
774+
(m_retrieval->irb_desc.idx_flags & idx_unique) ? INTL_KEY_UNIQUE :
775+
INTL_KEY_SORT;
773776

774777
// Make the lower bound key
775778

@@ -6947,7 +6950,7 @@ static bool scan(thread_db* tdbb, UCHAR* pointer, RecordBitmap** bitmap, RecordB
69476950
const bool partUpper = (retrieval->irb_upper_count < idx->idx_count);
69486951

69496952
// Reset flags this routine does not check in the loop below
6950-
flag &= ~(irb_equality | irb_ignore_null_value_key | irb_root_list_scan);
6953+
flag &= ~(irb_equality | irb_unique | irb_ignore_null_value_key | irb_root_list_scan);
69516954
flag &= ~(irb_exclude_lower | irb_exclude_upper);
69526955

69536956
IndexNode node;

src/jrd/btr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ const int irb_exclude_lower = 32; // exclude lower bound keys while scanning i
239239
const int irb_exclude_upper = 64; // exclude upper bound keys while scanning index
240240
const int irb_multi_starting = 128; // Use INTL_KEY_MULTI_STARTING
241241
const int irb_root_list_scan = 256; // Locate list items from the root
242+
const int irb_unique = 512; // Unique match (currently used only for plan output)
242243

243244
// Force include flags - always include appropriate key while scanning index
244245
const int irb_force_lower = irb_exclude_lower;

src/jrd/build_no.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
*** DO NOT EDIT ***
44
TO CHANGE ANY INFORMATION IN HERE PLEASE
55
EDIT src/misc/writeBuildNum.sh
6-
FORMAL BUILD NUMBER:511
6+
FORMAL BUILD NUMBER:523
77
*/
88

9-
#define PRODUCT_VER_STRING "6.0.0.511"
10-
#define FILE_VER_STRING "WI-T6.0.0.511"
11-
#define LICENSE_VER_STRING "WI-T6.0.0.511"
12-
#define FILE_VER_NUMBER 6, 0, 0, 511
9+
#define PRODUCT_VER_STRING "6.0.0.523"
10+
#define FILE_VER_STRING "WI-T6.0.0.523"
11+
#define LICENSE_VER_STRING "WI-T6.0.0.523"
12+
#define FILE_VER_NUMBER 6, 0, 0, 523
1313
#define FB_MAJOR_VER "6"
1414
#define FB_MINOR_VER "0"
1515
#define FB_REV_NO "0"
16-
#define FB_BUILD_NO "511"
16+
#define FB_BUILD_NO "523"
1717
#define FB_BUILD_TYPE "T"
1818
#define FB_BUILD_SUFFIX "Firebird 6.0 Initial"

src/jrd/optimizer/Optimizer.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,14 +1971,15 @@ void Optimizer::checkSorts()
19711971

19721972
unsigned Optimizer::distributeEqualities(BoolExprNodeStack& orgStack, unsigned baseCount)
19731973
{
1974-
// dimitr: Dumb protection against too many injected conjuncts (see CORE-5381).
1975-
// Don't produce more additional conjuncts than we originally had
1976-
// (i.e. this routine should never more than double the number of conjuncts).
1977-
// Ideally, we need two separate limits here:
1978-
// 1) number of injected conjuncts (affects required impure size)
1979-
// 2) number of input conjuncts (affects search time inside this routine)
1980-
1981-
if (baseCount * 2 > MAX_CONJUNCTS)
1974+
// dimitr: Simplified protection against too many injected conjuncts (see CORE-5381).
1975+
// Two separate limits are applied here:
1976+
// 1) number of input conjuncts (affects search time inside this routine)
1977+
// 2) number of injected conjuncts (affects required impure size)
1978+
1979+
constexpr unsigned MAX_CONJUNCTS_TO_PROCESS = 1024;
1980+
const unsigned MAX_CONJUNCTS_TO_INJECT = MAX(baseCount, 256);
1981+
1982+
if (baseCount > MAX_CONJUNCTS_TO_PROCESS)
19821983
return 0;
19831984

19841985
ObjectsArray<ValueExprNodeStack> classes;

0 commit comments

Comments
 (0)