Skip to content

Commit a7b3f39

Browse files
committed
Setting UpdateOverwriteMode (integer) renamed to AllowUpdateOverwrite (boolean).
1 parent fe0cc14 commit a7b3f39

5 files changed

Lines changed: 19 additions & 20 deletions

File tree

builds/install/misc/firebird.conf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,18 @@
524524

525525

526526
# ----------------------------
527-
# Defines how UPDATE should handle the case when a record was updated by trigger.
527+
# Defines how UPDATE should handle the case when a record was already updated by
528+
# trigger or by the another positional UPDATE in the same cursor.
528529
#
529530
# It is possible that BEFORE or AFTER UPDATE trigger was fired previously by the
530531
# current UPDATE statement for the other record and has already changed the
531532
# current record being updated. Due to cursor stability, UPDATE should not see
532533
# such changes, and could silently overwrite them.
533534
#
534-
# If set to 0 (default), trigger changes will be overwritten by the UPDATE.
535-
# If set to 1, error "UPDATE will overwrite changes made by trigger" will be raised.
535+
# Setting AllowUpdateOverwrite manage how engine should handle such cases:
536+
# - if set to true (default), prior changes will be overwritten,
537+
# - if set to false, error "UPDATE will overwrite changes made by the trigger or
538+
# by the another UPDATE in the same cursor" will be raised.
536539
#
537540
# CAUTION!
538541
# There is no guarantee that this setting will be available in future Firebird
@@ -542,7 +545,8 @@
542545
#
543546
# Type: integer
544547
#
545-
#UpdateOverwriteMode = 0
548+
#AllowUpdateOverwrite = true
549+
546550

547551
# ============================
548552
# Plugin settings

src/common/config/config.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,6 @@ void Config::checkValues()
434434

435435
checkIntForLoBound(KEY_PARALLEL_WORKERS, 1, true);
436436
checkIntForHiBound(KEY_PARALLEL_WORKERS, values[KEY_MAX_PARALLEL_WORKERS].intVal, false);
437-
438-
checkIntForLoBound(KEY_UPDATE_OVERWRITE_MODE, 0, true);
439-
checkIntForHiBound(KEY_UPDATE_OVERWRITE_MODE, 1, false);
440437
}
441438

442439

src/common/config/config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ enum ConfigKey
194194
KEY_OPTIMIZE_FOR_FIRST_ROWS,
195195
KEY_OUTER_JOIN_CONVERSION,
196196
KEY_SUBQUERY_CONVERSION,
197-
KEY_UPDATE_OVERWRITE_MODE,
197+
KEY_ALLOW_UPDATE_OVERWRITE,
198198
MAX_CONFIG_KEY // keep it last
199199
};
200200

@@ -316,7 +316,7 @@ constexpr ConfigEntry entries[MAX_CONFIG_KEY] =
316316
{TYPE_BOOLEAN, "OptimizeForFirstRows", false, false},
317317
{TYPE_BOOLEAN, "OuterJoinConversion", false, true},
318318
{TYPE_BOOLEAN, "SubQueryConversion", false, false},
319-
{TYPE_INTEGER, "UpdateOverwriteMode", false, 0}
319+
{TYPE_BOOLEAN, "AllowUpdateOverwrite", false, true}
320320
};
321321

322322

@@ -655,7 +655,7 @@ class Config : public RefCounted, public GlobalStorage
655655

656656
CONFIG_GET_PER_DB_BOOL(getSubQueryConversion, KEY_SUBQUERY_CONVERSION);
657657

658-
CONFIG_GET_PER_DB_INT(getUpdateOverwriteMode, KEY_UPDATE_OVERWRITE_MODE);
658+
CONFIG_GET_PER_DB_BOOL(getAllowUpdateOverwrite, KEY_ALLOW_UPDATE_OVERWRITE);
659659
};
660660

661661
// Implementation of interface to access master configuration file

src/include/firebird/impl/msg/jrd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,4 +976,4 @@ FB_IMPL_MSG(JRD, 991, sweep_attach_no_cleanup, -901, "42", "000", "Attachment ha
976976
// Codes 992..997 are used in v6
977977
FB_IMPL_MSG(JRD, 998, no_user_att_while_restore, -901, "HY", "000", "User attachments are not allowed for the database being restored")
978978
// Codes 999..1004 are used in v6
979-
FB_IMPL_MSG(JRD, 1005, update_overwrite_trigger, -901, "27", "000", "UPDATE will overwrite changes made by trigger")
979+
FB_IMPL_MSG(JRD, 1005, update_overwrite, -901, "27", "000", "UPDATE will overwrite changes made by the trigger or by the another UPDATE in the same cursor")

src/jrd/vio.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6617,16 +6617,16 @@ static void refresh_changed_fields(thread_db* tdbb, Record* old_rec, record_para
66176617
* Functional description
66186618
* Update new_rpb with foreign key fields values changed by cascade triggers.
66196619
* Consider self-referenced foreign keys only.
6620-
* Also, if UpdateOverwriteMode is set to 1, raise error when non self-referenced
6621-
* foreign key fields were changed by user triggers.
6620+
* Also, if AllowUpdateOverwrite is set to false, raise error when non
6621+
* self-referenced foreign key fields were changed by user triggers.
66226622
*
66236623
* old_rec - old record before modify
66246624
* cur_rpb - just read record with possibly changed fields
66256625
* new_rpb - new record evaluated by modify statement and before-triggers
66266626
*
66276627
**************************************/
66286628
const Database* dbb = tdbb->getDatabase();
6629-
const auto overwriteMode = dbb->dbb_config->getUpdateOverwriteMode();
6629+
const auto allowOverwrite = dbb->dbb_config->getAllowUpdateOverwrite();
66306630

66316631
jrd_rel* relation = cur_rpb->rpb_relation;
66326632

@@ -6664,16 +6664,15 @@ static void refresh_changed_fields(thread_db* tdbb, Record* old_rec, record_para
66646664

66656665
if (fields.isEmpty())
66666666
{
6667-
if (overwriteMode == 0)
6667+
if (allowOverwrite)
66686668
return;
66696669

66706670
if (cur_rpb->rpb_record->getFormat()->fmt_version == old_rec->getFormat()->fmt_version)
66716671
{
66726672
if (memcmp(cur_rpb->rpb_address, old_rec->getData(), cur_rpb->rpb_length) == 0)
66736673
return;
66746674

6675-
fb_assert(overwriteMode == 1);
6676-
ERR_post(Arg::Gds(isc_update_overwrite_trigger)); // UPDATE will overwrite changes made by trigger
6675+
ERR_post(Arg::Gds(isc_update_overwrite)); // UPDATE will overwrite changes made by the trigger or by another UPDATE in the same cursor
66776676
}
66786677
// Else compare field-by-field
66796678
}
@@ -6686,7 +6685,7 @@ static void refresh_changed_fields(thread_db* tdbb, Record* old_rec, record_para
66866685
const bool is_fk = (frn < fields.getCount() && fields[frn] == fld);
66876686
if (!is_fk)
66886687
{
6689-
if (overwriteMode == 0)
6688+
if (allowOverwrite)
66906689
continue;
66916690

66926691
dsc dsc_cur;
@@ -6697,8 +6696,7 @@ static void refresh_changed_fields(thread_db* tdbb, Record* old_rec, record_para
66976696
(flag_cur && flag_old && MOV_compare(tdbb, &dsc_old, &dsc_cur) != 0))
66986697
{
66996698
// Record was modified by trigger.
6700-
fb_assert(overwriteMode == 1);
6701-
ERR_post(Arg::Gds(isc_update_overwrite_trigger)); // UPDATE will overwrite changes made by trigger
6699+
ERR_post(Arg::Gds(isc_update_overwrite)); // UPDATE will overwrite changes made by the trigger or by another UPDATE in the same cursor
67026700
}
67036701
}
67046702
else

0 commit comments

Comments
 (0)