From 844631b0ee473fd94dab61558f146a8268c0967b Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Tue, 27 Jun 2023 22:57:16 -0300 Subject: [PATCH] Fix #7638 - OVERRIDING USER VALUE should be allowed for GENERATED ALWAYS AS IDENTITY. --- doc/sql.extensions/README.identity_columns.txt | 3 +-- src/common/classes/MsgPrint.cpp | 3 +-- src/dsql/StmtNodes.cpp | 5 +---- src/include/firebird/impl/msg/jrd.h | 4 ++-- src/include/gen/Firebird.pas | 3 +-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/doc/sql.extensions/README.identity_columns.txt b/doc/sql.extensions/README.identity_columns.txt index 1f68eb1661..8bce914302 100644 --- a/doc/sql.extensions/README.identity_columns.txt +++ b/doc/sql.extensions/README.identity_columns.txt @@ -100,7 +100,6 @@ following: insert into objects (id, name) overriding system value values (11, 'Laptop'); -OVERRIDING also supports a subclause to be used with BY DEFAULT columns, to ignore the value passed in INSERT and use -the defined sequence: +OVERRIDING also supports a subclause to ignore the value passed in INSERT and use the defined sequence: insert into objects (id, name) overriding user value values (12, 'Laptop'); -- 12 is not used diff --git a/src/common/classes/MsgPrint.cpp b/src/common/classes/MsgPrint.cpp index 66d6af97f6..f5a451ccf7 100644 --- a/src/common/classes/MsgPrint.cpp +++ b/src/common/classes/MsgPrint.cpp @@ -359,9 +359,8 @@ int MsgPrintErr(const char* format, const SafeArg& arg, bool userFormatting) int fb_msg_format(void* handle, USHORT facility, USHORT number, unsigned int bsize, TEXT* buffer, const MsgFormat::SafeArg& arg) { - // The field MESSAGES.TEXT is 138 bytes long. int total_msg = 0; - char msg[138 + 2] = ""; + char msg[BUFFER_SMALL] = ""; const int n = gds__msg_lookup(handle, facility, number, sizeof(msg), msg, NULL); if (n > 0 && unsigned(n) < sizeof(msg)) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 5aeffe58c9..ca35ec992f 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -10929,14 +10929,11 @@ static void preprocessAssignments(thread_db* tdbb, CompilerScratch* csb, if (identityType == IDENT_TYPE_BY_DEFAULT && *insertOverride == OverrideClause::SYSTEM_VALUE) ERR_post(Arg::Gds(isc_overriding_system_invalid) << relation->rel_name); - - if (identityType == IDENT_TYPE_ALWAYS && *insertOverride == OverrideClause::USER_VALUE) - ERR_post(Arg::Gds(isc_overriding_user_invalid) << relation->rel_name); } else { if (identityType == IDENT_TYPE_ALWAYS) - ERR_post(Arg::Gds(isc_overriding_system_missing) << relation->rel_name); + ERR_post(Arg::Gds(isc_overriding_missing) << relation->rel_name); } } diff --git a/src/include/firebird/impl/msg/jrd.h b/src/include/firebird/impl/msg/jrd.h index 2eac02501d..7314691bcb 100644 --- a/src/include/firebird/impl/msg/jrd.h +++ b/src/include/firebird/impl/msg/jrd.h @@ -814,8 +814,8 @@ FB_IMPL_MSG(JRD, 812, att_shut_db_down, -902, "08", "003", "Database is shutdown FB_IMPL_MSG(JRD, 813, att_shut_engine, -902, "08", "003", "Engine is shutdown.") FB_IMPL_MSG(JRD, 814, overriding_without_identity, -902, "42", "000", "OVERRIDING clause can be used only when an identity column is present in the INSERT's field list for table/view @1") FB_IMPL_MSG(JRD, 815, overriding_system_invalid, -902, "42", "000", "OVERRIDING SYSTEM VALUE can be used only for identity column defined as 'GENERATED ALWAYS' in INSERT for table/view @1") -FB_IMPL_MSG(JRD, 816, overriding_user_invalid, -902, "42", "000", "OVERRIDING USER VALUE can be used only for identity column defined as 'GENERATED BY DEFAULT' in INSERT for table/view @1") -FB_IMPL_MSG(JRD, 817, overriding_system_missing, -902, "42", "000", "OVERRIDING SYSTEM VALUE should be used to override the value of an identity column defined as 'GENERATED ALWAYS' in table/view @1") +// Incorrect - FB_IMPL_MSG(JRD, 816, overriding_user_invalid, -902, "42", "000", "OVERRIDING USER VALUE can be used only for identity column defined as 'GENERATED BY DEFAULT' in INSERT for table/view @1") +FB_IMPL_MSG(JRD, 817, overriding_missing, -902, "42", "000", "OVERRIDING clause should be used when an identity column defined as 'GENERATED ALWAYS' is present in the INSERT's field list for table table/view @1") FB_IMPL_MSG(JRD, 818, decprecision_err, -842, "HY", "104", "DecFloat precision must be 16 or 34") FB_IMPL_MSG(JRD, 819, decfloat_divide_by_zero, -901, "22", "012", "Decimal float divide by zero. The code attempted to divide a DECFLOAT value by zero.") FB_IMPL_MSG(JRD, 820, decfloat_inexact_result, -901, "22", "000", "Decimal float inexact result. The result of an operation cannot be represented as a decimal fraction.") diff --git a/src/include/gen/Firebird.pas b/src/include/gen/Firebird.pas index cd1d8d018f..73142051fd 100644 --- a/src/include/gen/Firebird.pas +++ b/src/include/gen/Firebird.pas @@ -5496,8 +5496,7 @@ const isc_att_shut_engine = 335545133; isc_overriding_without_identity = 335545134; isc_overriding_system_invalid = 335545135; - isc_overriding_user_invalid = 335545136; - isc_overriding_system_missing = 335545137; + isc_overriding_missing = 335545137; isc_decprecision_err = 335545138; isc_decfloat_divide_by_zero = 335545139; isc_decfloat_inexact_result = 335545140;