diff --git a/lang_helpers/gds_codes.ftn b/lang_helpers/gds_codes.ftn index 4e77120e1a..0f76dcfa46 100644 --- a/lang_helpers/gds_codes.ftn +++ b/lang_helpers/gds_codes.ftn @@ -1848,8 +1848,8 @@ C -- PARAMETER (GDS__dyn_duplicate_package_item = 336068894) INTEGER*4 GDS__dyn_cant_modify_sysobj PARAMETER (GDS__dyn_cant_modify_sysobj = 336068895) - INTEGER*4 GDS__dyn_cant_use_zero_step - PARAMETER (GDS__dyn_cant_use_zero_step = 336068896) + INTEGER*4 GDS__dyn_cant_use_zero_increment + PARAMETER (GDS__dyn_cant_use_zero_increment = 336068896) INTEGER*4 GDS__gbak_unknown_switch PARAMETER (GDS__gbak_unknown_switch = 336330753) INTEGER*4 GDS__gbak_page_size_missing diff --git a/lang_helpers/gds_codes.pas b/lang_helpers/gds_codes.pas index b2ced1d9b8..503529c22a 100644 --- a/lang_helpers/gds_codes.pas +++ b/lang_helpers/gds_codes.pas @@ -931,7 +931,7 @@ const gds_dyn_alter_user_no_clause = 336068891; gds_dyn_duplicate_package_item = 336068894; gds_dyn_cant_modify_sysobj = 336068895; - gds_dyn_cant_use_zero_step = 336068896; + gds_dyn_cant_use_zero_increment = 336068896; gds_gbak_unknown_switch = 336330753; gds_gbak_page_size_missing = 336330754; gds_gbak_page_size_toobig = 336330755; diff --git a/src/burp/backup.epp b/src/burp/backup.epp index 2291c919cf..c5ededcb2d 100644 --- a/src/burp/backup.epp +++ b/src/burp/backup.epp @@ -3171,7 +3171,7 @@ void write_generators() if (!X.RDB$INITIAL_VALUE.NULL) put_int64(att_gen_init_val, X.RDB$INITIAL_VALUE); - put_int32(att_gen_id_step, X.RDB$GENERATOR_STEP); + put_int32(att_gen_id_step, X.RDB$GENERATOR_INCREMENT); put(tdgbl, att_end); MISC_terminate (X.RDB$GENERATOR_NAME, temp, l, sizeof(temp)); diff --git a/src/burp/restore.epp b/src/burp/restore.epp index deefb1f7c9..348a5f4c71 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -10337,7 +10337,7 @@ void store_blr_gen_id(BurpGlobals* tdgbl, const TEXT* gen_name, SINT64 value, SI } X.RDB$INITIAL_VALUE.NULL = FALSE; X.RDB$INITIAL_VALUE = initial_value; - X.RDB$GENERATOR_STEP = step; + X.RDB$GENERATOR_INCREMENT = step; END_STORE; ON_ERROR general_on_error (); diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index f6a931e6d6..693e2dc320 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -4911,7 +4911,7 @@ void CreateAlterSequenceNode::executeCreate(thread_db* tdbb, DsqlCompilerScratch { initialStep = step.value; if (initialStep == 0) - status_exception::raise(Arg::Gds(isc_dyn_cant_use_zero_step) << Arg::Str(name)); + status_exception::raise(Arg::Gds(isc_dyn_cant_use_zero_increment) << Arg::Str(name)); } store(tdbb, transaction, name, fb_sysflag_user, val, initialStep); @@ -4936,7 +4936,7 @@ bool CreateAlterSequenceNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch* if (id < 0) return false; - if (forbidden) + if (forbidden && !tdbb->getAttachment()->isRWGbak()) status_exception::raise(Arg::Gds(isc_dyn_cant_modify_sysobj) << "generator" << Arg::Str(name)); executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE, DDL_TRIGGER_ALTER_SEQUENCE, name); @@ -4947,11 +4947,11 @@ bool CreateAlterSequenceNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch* { const SLONG newStep = step.value; if (newStep == 0) - status_exception::raise(Arg::Gds(isc_dyn_cant_use_zero_step) << Arg::Str(name)); + status_exception::raise(Arg::Gds(isc_dyn_cant_use_zero_increment) << Arg::Str(name)); // Perhaps it's better to move this to DFW? if (newStep != oldStep) - MET_update_generator_step(tdbb, id, newStep); + MET_update_generator_increment(tdbb, id, newStep); } transaction->getGenIdCache()->put(id, val); @@ -4987,12 +4987,12 @@ bool CreateAlterSequenceNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch* { const SLONG newStep = step.value; if (newStep == 0) - status_exception::raise(Arg::Gds(isc_dyn_cant_use_zero_step) << Arg::Str(name)); + status_exception::raise(Arg::Gds(isc_dyn_cant_use_zero_increment) << Arg::Str(name)); - if (newStep != X.RDB$GENERATOR_STEP) + if (newStep != X.RDB$GENERATOR_INCREMENT) { MODIFY X - X.RDB$GENERATOR_STEP = newStep; + X.RDB$GENERATOR_INCREMENT = newStep; END_MODIFY } } @@ -5049,7 +5049,7 @@ SSHORT CreateAlterSequenceNode::store(thread_db* tdbb, jrd_tra* transaction, con X.RDB$INITIAL_VALUE.NULL = FALSE; X.RDB$INITIAL_VALUE = val; - X.RDB$GENERATOR_STEP = step; + X.RDB$GENERATOR_INCREMENT = step; } END_STORE diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp index 7e3cddba2b..1cae25d6d2 100644 --- a/src/dsql/ExprNodes.cpp +++ b/src/dsql/ExprNodes.cpp @@ -5674,7 +5674,7 @@ ValueExprNode* GenIdNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) void GenIdNode::setParameterName(dsql_par* parameter) const { - parameter->par_name = parameter->par_alias = (implicit ? "GEN_ID2" : "GEN_ID"); + parameter->par_name = parameter->par_alias = (implicit ? "NEXT_VALUE" : "GEN_ID"); } bool GenIdNode::setParameterType(DsqlCompilerScratch* dsqlScratch, @@ -5796,7 +5796,7 @@ dsc* GenIdNode::execute(thread_db* tdbb, jrd_req* request) const change = MOV_get_int64(value, 0); } - if (sysGen && change != 0 && generator.id != 9) + if (sysGen && change != 0) { if (!request->hasInternalStatement() && !tdbb->getAttachment()->isRWGbak()) { diff --git a/src/dsql/parse.y b/src/dsql/parse.y index 55a84990e9..c2eb769b15 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -568,7 +568,7 @@ using namespace Firebird; %token TAGS %token PLUGIN %token SERVERWIDE -%token STEP +%token INCREMENT // precedence declarations for expression evaluation @@ -1496,7 +1496,11 @@ start_with %type step_option step_option : /* nothing */ { $$ = Nullable::empty(); } - | STEP signed_long_integer { $$ = Nullable::val($2); } + | INCREMENT by_noise signed_long_integer { $$ = Nullable::val($3); } + +by_noise + : // nothing + | BY %type replace_sequence_clause replace_sequence_clause @@ -7362,7 +7366,7 @@ non_reserved_word | TAGS | PLUGIN | SERVERWIDE - | STEP + | INCREMENT ; %% diff --git a/src/include/gen/codetext.h b/src/include/gen/codetext.h index 749b1cbe50..3ee6c69b7e 100644 --- a/src/include/gen/codetext.h +++ b/src/include/gen/codetext.h @@ -920,7 +920,7 @@ static const struct { {"dyn_alter_user_no_clause", 336068891}, {"dyn_duplicate_package_item", 336068894}, {"dyn_cant_modify_sysobj", 336068895}, - {"dyn_cant_use_zero_step", 336068896}, + {"dyn_cant_use_zero_increment", 336068896}, {"gbak_unknown_switch", 336330753}, {"gbak_page_size_missing", 336330754}, {"gbak_page_size_toobig", 336330755}, diff --git a/src/include/gen/iberror.h b/src/include/gen/iberror.h index f89a82fc06..20e5264060 100644 --- a/src/include/gen/iberror.h +++ b/src/include/gen/iberror.h @@ -954,7 +954,7 @@ const ISC_STATUS isc_dyn_domain_used_function = 336068890L; const ISC_STATUS isc_dyn_alter_user_no_clause = 336068891L; const ISC_STATUS isc_dyn_duplicate_package_item = 336068894L; const ISC_STATUS isc_dyn_cant_modify_sysobj = 336068895L; -const ISC_STATUS isc_dyn_cant_use_zero_step = 336068896L; +const ISC_STATUS isc_dyn_cant_use_zero_increment = 336068896L; const ISC_STATUS isc_gbak_unknown_switch = 336330753L; const ISC_STATUS isc_gbak_page_size_missing = 336330754L; const ISC_STATUS isc_gbak_page_size_toobig = 336330755L; @@ -2199,7 +2199,7 @@ const ISC_STATUS isc_err_max = 1219; #define isc_dyn_alter_user_no_clause 336068891L #define isc_dyn_duplicate_package_item 336068894L #define isc_dyn_cant_modify_sysobj 336068895L -#define isc_dyn_cant_use_zero_step 336068896L +#define isc_dyn_cant_use_zero_increment 336068896L #define isc_gbak_unknown_switch 336330753L #define isc_gbak_page_size_missing 336330754L #define isc_gbak_page_size_toobig 336330755L diff --git a/src/include/gen/ids.h b/src/include/gen/ids.h index af75936801..215737165d 100644 --- a/src/include/gen/ids.h +++ b/src/include/gen/ids.h @@ -315,7 +315,7 @@ const USHORT f_gen_class = 4; const USHORT f_gen_owner = 5; const USHORT f_gen_init_val = 6; - const USHORT f_gen_step = 7; + const USHORT f_gen_increment = 7; // Relation 21 (RDB$FIELD_DIMENSIONS) diff --git a/src/include/gen/msgs.h b/src/include/gen/msgs.h index d674545503..5e389cf2db 100644 --- a/src/include/gen/msgs.h +++ b/src/include/gen/msgs.h @@ -923,7 +923,7 @@ Data source : @4"}, /* eds_statement */ {336068891, "ALTER USER requires at least one clause to be specified"}, /* dyn_alter_user_no_clause */ {336068894, "Duplicate @1 @2"}, /* dyn_duplicate_package_item */ {336068895, "System @1 @2 cannot be modified"}, /* dyn_cant_modify_sysobj */ - {336068896, "STEP 0 is an illegal option for sequence @1"}, /* dyn_cant_use_zero_step */ + {336068896, "INCREMENT BY 0 is an illegal option for sequence @1"}, /* dyn_cant_use_zero_increment */ {336330753, "found unknown switch"}, /* gbak_unknown_switch */ {336330754, "page size parameter missing"}, /* gbak_page_size_missing */ {336330755, "Page size specified (@1) greater than limit (16384 bytes)"}, /* gbak_page_size_toobig */ diff --git a/src/include/gen/sql_code.h b/src/include/gen/sql_code.h index ceade86ed9..436bacdddf 100644 --- a/src/include/gen/sql_code.h +++ b/src/include/gen/sql_code.h @@ -919,7 +919,7 @@ static const struct { {336068891, -901}, /* 283 dyn_alter_user_no_clause */ {336068894, -901}, /* 286 dyn_duplicate_package_item */ {336068895, -901}, /* 287 dyn_cant_modify_sysobj */ - {336068896, -901}, /* 288 dyn_cant_use_zero_step */ + {336068896, -901}, /* 288 dyn_cant_use_zero_increment */ {336330753, -901}, /* 1 gbak_unknown_switch */ {336330754, -901}, /* 2 gbak_page_size_missing */ {336330755, -901}, /* 3 gbak_page_size_toobig */ diff --git a/src/include/gen/sql_state.h b/src/include/gen/sql_state.h index 082588eaef..8d04d5c423 100644 --- a/src/include/gen/sql_state.h +++ b/src/include/gen/sql_state.h @@ -919,7 +919,7 @@ static const struct { {336068891, "42000"}, // 283 dyn_alter_user_no_clause {336068894, "42000"}, // 286 dyn_duplicate_package_item {336068895, "42000"}, // 287 dyn_cant_modify_sysobj - {336068896, "42000"}, // 288 dyn_cant_use_zero_step + {336068896, "42000"}, // 288 dyn_cant_use_zero_increment {336330753, "00000"}, // 1 gbak_unknown_switch {336330754, "00000"}, // 2 gbak_page_size_missing {336330755, "00000"}, // 3 gbak_page_size_toobig diff --git a/src/isql/extract.epp b/src/isql/extract.epp index 46c5e91b29..0779da43e3 100644 --- a/src/isql/extract.epp +++ b/src/isql/extract.epp @@ -2823,8 +2823,8 @@ static void list_generators() if (!G2.RDB$INITIAL_VALUE.NULL && G2.RDB$INITIAL_VALUE != 0) isqlGlob.printf(" START WITH %" SQUADFORMAT, G2.RDB$INITIAL_VALUE); - if (G2.RDB$GENERATOR_STEP != 1) - isqlGlob.printf(" STEP %ld", G2.RDB$GENERATOR_STEP); + if (G2.RDB$GENERATOR_INCREMENT != 1) + isqlGlob.printf(" INCREMENT %ld", G2.RDB$GENERATOR_INCREMENT); END_FOR ON_ERROR diff --git a/src/isql/show.epp b/src/isql/show.epp index e2c582a1ba..e2ade036a8 100644 --- a/src/isql/show.epp +++ b/src/isql/show.epp @@ -4076,8 +4076,8 @@ static processing_state show_generators(const SCHAR* object) WITH G2.RDB$GENERATOR_NAME = GEN.RDB$GENERATOR_NAME ISC_INT64 initval = !G2.RDB$INITIAL_VALUE.NULL ? G2.RDB$INITIAL_VALUE : 0; - isqlGlob.printf(", initial value: %" QUADFORMAT "d%, step: %ld", - initval, G2.RDB$GENERATOR_STEP); + isqlGlob.printf(", initial value: %" QUADFORMAT "d%, increment: %ld", + initval, G2.RDB$GENERATOR_INCREMENT); END_FOR ON_ERROR diff --git a/src/jrd/drq.h b/src/jrd/drq.h index f9671efe8b..9fe4d34d6f 100644 --- a/src/jrd/drq.h +++ b/src/jrd/drq.h @@ -231,6 +231,7 @@ enum drq_type_t drq_e_xcp_prvs, // erase exception privileges drq_e_gen_prvs, // erase generator privileges drq_e_gfld_prvs, // erase domain privileges + drq_g_nxt_nbakhist_id, // generate next history ID for nbackup drq_MAX }; diff --git a/src/jrd/fields.h b/src/jrd/fields.h index ebc3e72a3d..0a7a57dc9d 100644 --- a/src/jrd/fields.h +++ b/src/jrd/fields.h @@ -189,5 +189,5 @@ FIELD(fld_map_from , nam_map_from , dtype_text , 255 , dsc_text_type_metadata , NULL , true) FIELD(fld_map_to , nam_map_to , dtype_text , MAX_SQL_IDENTIFIER_LEN , dsc_text_type_metadata , NULL , true) - FIELD(fld_gen_step , nam_gen_step , dtype_long , sizeof(SLONG) , 0 , NULL , false) + FIELD(fld_gen_step , nam_gen_increment , dtype_long , sizeof(SLONG) , 0 , NULL , false) diff --git a/src/jrd/ini.epp b/src/jrd/ini.epp index 12869c4dda..5961e6e72e 100644 --- a/src/jrd/ini.epp +++ b/src/jrd/ini.epp @@ -398,9 +398,8 @@ void INI_format(const MetaName& owner, const MetaName& charset) for (const gen* generator = generators; generator->gen_name; generator++) store_generator(tdbb, generator, handle1, ownerName); - // Redundant, VIO_store does the job. // Adjust the value of the hidden generator RDB$GENERATORS - //DPM_gen_id(tdbb, 0, true, FB_NELEM(generators) - 1); + DPM_gen_id(tdbb, 0, true, FB_NELEM(generators) - 1); // store system-defined triggers @@ -1192,7 +1191,7 @@ static void store_generator(thread_db* tdbb, const gen* generator, AutoRequest& else X.RDB$DESCRIPTION.NULL = TRUE; - X.RDB$GENERATOR_STEP = 0; // only sys gens have zero default increment + X.RDB$GENERATOR_INCREMENT = 0; // only sys gens have zero default increment } END_STORE } diff --git a/src/jrd/met.epp b/src/jrd/met.epp index fefc1de172..f503c87ab9 100644 --- a/src/jrd/met.epp +++ b/src/jrd/met.epp @@ -2306,7 +2306,7 @@ bool MET_load_generator(thread_db* tdbb, GeneratorItem& item, bool* sysGen, SLON if (sysGen) *sysGen = (X.RDB$SYSTEM_FLAG == fb_sysflag_system); if (step) - *step = X.RDB$GENERATOR_STEP; + *step = X.RDB$GENERATOR_INCREMENT; return true; } @@ -2347,7 +2347,7 @@ SLONG MET_lookup_generator(thread_db* tdbb, const MetaName& name, bool* sysGen, if (sysGen) *sysGen = (X.RDB$SYSTEM_FLAG == fb_sysflag_system); if (step) - *step = X.RDB$GENERATOR_STEP; + *step = X.RDB$GENERATOR_INCREMENT; return X.RDB$GENERATOR_ID; } @@ -2391,11 +2391,11 @@ bool MET_lookup_generator_id(thread_db* tdbb, SLONG gen_id, MetaName& name, bool return name.length() != 0; } -void MET_update_generator_step(thread_db* tdbb, SLONG gen_id, SLONG step) +void MET_update_generator_increment(thread_db* tdbb, SLONG gen_id, SLONG step) { /************************************** * - * M E T _ u p d a t e _ g e n e r a t o r _ s t e p + * M E T _ u p d a t e _ g e n e r a t o r _ i n c r e m e n t * ************************************** * @@ -2417,7 +2417,7 @@ void MET_update_generator_step(thread_db* tdbb, SLONG gen_id, SLONG step) return; MODIFY X - X.RDB$GENERATOR_STEP = step; + X.RDB$GENERATOR_INCREMENT = step; END_MODIFY END_FOR } diff --git a/src/jrd/met_proto.h b/src/jrd/met_proto.h index a4eea3ea7e..189cb0e158 100644 --- a/src/jrd/met_proto.h +++ b/src/jrd/met_proto.h @@ -104,7 +104,7 @@ Jrd::BlobFilter* MET_lookup_filter(Jrd::thread_db*, SSHORT, SSHORT); bool MET_load_generator(Jrd::thread_db*, Jrd::GeneratorItem&, bool* sysGen = 0, SLONG* step = 0); SLONG MET_lookup_generator(Jrd::thread_db*, const Firebird::MetaName&, bool* sysGen = 0, SLONG* step = 0); bool MET_lookup_generator_id(Jrd::thread_db*, SLONG, Firebird::MetaName&, bool* sysGen = 0); -void MET_update_generator_step(Jrd::thread_db* tdbb, SLONG gen_id, SLONG step); +void MET_update_generator_increment(Jrd::thread_db* tdbb, SLONG gen_id, SLONG step); void MET_lookup_index(Jrd::thread_db*, Firebird::MetaName&, const Firebird::MetaName&, USHORT); SLONG MET_lookup_index_name(Jrd::thread_db*, const Firebird::MetaName&, SLONG*, Jrd::IndexStatus* status); bool MET_lookup_partner(Jrd::thread_db*, Jrd::jrd_rel*, struct Jrd::index_desc*, const TEXT*); diff --git a/src/jrd/names.h b/src/jrd/names.h index 181b63e4df..6447e7f277 100644 --- a/src/jrd/names.h +++ b/src/jrd/names.h @@ -115,7 +115,7 @@ NAME("RDB$GENERATORS", nam_gens) NAME("RDB$GENERATOR_ID", nam_gen_id) NAME("RDB$GENERATOR_NAME", nam_gen_name) NAME("RDB$GENERATOR_VALUE", nam_gen_val) -NAME("RDB$GENERATOR_STEP", nam_gen_step) +NAME("RDB$GENERATOR_INCREMENT", nam_gen_increment) NAME("RDB$GENERIC_NAME", nam_gnr_name) NAME("RDB$GENERIC_TYPE", nam_gnr_type) NAME("RDB$GRANTOR", nam_grantor) diff --git a/src/jrd/relations.h b/src/jrd/relations.h index 397f8aba45..ede085c6e4 100644 --- a/src/jrd/relations.h +++ b/src/jrd/relations.h @@ -314,7 +314,7 @@ RELATION(nam_gens, rel_gens, ODS_8_0, rel_persistent) FIELD(f_gen_class, nam_class, fld_class, 1, ODS_12_0) FIELD(f_gen_owner, nam_owner, fld_user, 1, ODS_12_0) FIELD(f_gen_init_val, nam_init_val, fld_gen_val, 1, ODS_12_0) - FIELD(f_gen_step, nam_gen_step, fld_gen_step, 1, ODS_12_0) + FIELD(f_gen_increment, nam_gen_increment, fld_gen_step, 1, ODS_12_0) END_RELATION // Relation 21 (RDB$FIELD_DIMENSIONS) diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index 209dc84798..7df3349edb 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -3180,6 +3180,11 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction) DFW_post_work(transaction, dfw_grant, &desc, obj_exception); break; + case rel_backup_history: + set_metadata_id(tdbb, rpb->rpb_record, + f_backup_id, drq_g_nxt_nbakhist_id, "RDB$BACKUP_HISTORY"); + break; + default: // Shut up compiler warnings break; } diff --git a/src/msgs/messages2.sql b/src/msgs/messages2.sql index 026bb7cd67..1eecef94e2 100644 --- a/src/msgs/messages2.sql +++ b/src/msgs/messages2.sql @@ -1924,7 +1924,7 @@ COMMIT WORK; (NULL, 'DdlNodes.epp', 'AlterRelationNode::modifyField', NULL, 8, 285, NULL, 'Column @1 is not an identity column', NULL, NULL); ('dyn_duplicate_package_item', NULL, 'PackageNodes.epp', NULL, 8, 286, NULL, 'Duplicate @1 @2', NULL, NULL); ('dyn_cant_modify_sysobj', NULL, 'DdlNodes.epp', NULL, 8, 287, NULL, 'System @1 @2 cannot be modified', NULL, 'Ex: System generator rdb$... cannot be modified'); -('dyn_cant_use_zero_step', NULL, 'DdlNodes.epp', NULL, 8, 288, NULL, 'STEP 0 is an illegal option for sequence @1', NULL, NULL); +('dyn_cant_use_zero_increment', NULL, 'DdlNodes.epp', NULL, 8, 288, NULL, 'INCREMENT BY 0 is an illegal option for sequence @1', NULL, NULL); COMMIT WORK; -- TEST (NULL, 'main', 'test.c', NULL, 11, 0, NULL, 'This is a modified text message', NULL, NULL); diff --git a/src/msgs/system_errors2.sql b/src/msgs/system_errors2.sql index 5da351e1e6..8fbc48c049 100644 --- a/src/msgs/system_errors2.sql +++ b/src/msgs/system_errors2.sql @@ -908,7 +908,7 @@ set bulk_insert INSERT INTO SYSTEM_ERRORS (SQL_CODE, SQL_CLASS, SQL_SUBCLASS, FA (-901, '42', '000', 8, 283, 'dyn_alter_user_no_clause', NULL, NULL) (-901, '42', '000', 8, 286, 'dyn_duplicate_package_item', NULL, NULL) (-901, '42', '000', 8, 287, 'dyn_cant_modify_sysobj', NULL, NULL) -(-901, '42', '000', 8, 288, 'dyn_cant_use_zero_step', NULL, NULL) +(-901, '42', '000', 8, 288, 'dyn_cant_use_zero_increment', NULL, NULL) -- GBAK (-901, '00', '000', 12, 1, 'gbak_unknown_switch', NULL, NULL) (-901, '00', '000', 12, 2, 'gbak_page_size_missing', NULL, NULL) diff --git a/src/utilities/nbackup/nbackup.cpp b/src/utilities/nbackup/nbackup.cpp index 32a089889c..32ac482c76 100644 --- a/src/utilities/nbackup/nbackup.cpp +++ b/src/utilities/nbackup/nbackup.cpp @@ -270,7 +270,7 @@ public: : uSvc(_uSvc), newdb(0), trans(0), database(_database), username(_username), password(_password), /*trustedUser(_trustedUser),*/ run_db_triggers(_run_db_triggers), /*trustedRole(_trustedRole), */direct_io(_direct_io), - dbase(0), backup(0), db_size_pages(0), m_silent(false), m_printed(false) + dbase(0), backup(0), db_size_pages(0), m_odsNumber(0), m_silent(false), m_printed(false) { // Recognition of local prefix allows to work with // database using TCP/IP loopback while reading file locally. @@ -305,7 +305,7 @@ public: void backup_database(int level, const PathName& fname); void restore_database(const BackupFiles& files); - bool printed() + bool printed() const { return m_printed; } @@ -326,6 +326,7 @@ private: FILE_HANDLE dbase; FILE_HANDLE backup; ULONG db_size_pages; // In pages + USHORT m_odsNumber; bool m_silent; // are we already handling an exception? bool m_printed; // pr_error() was called to print status vector @@ -338,6 +339,7 @@ private: void internal_lock_database(); void get_database_size(); + void get_ods(); void internal_unlock_database(); void attach_database(); void detach_database(); @@ -716,6 +718,22 @@ void NBackup::get_database_size() } } +void NBackup::get_ods() +{ + m_odsNumber = 0; + const char db_version_info[] = { isc_info_ods_version }; + char res[128]; + if (isc_database_info(status, &newdb, sizeof(db_version_info), db_version_info, sizeof(res), res)) + { + pr_error(status, "ods info"); + } + else if (res[0] == isc_info_ods_version) + { + USHORT len = isc_vax_integer (&res[1], 2); + m_odsNumber = isc_vax_integer (&res[3], len); + } +} + void NBackup::internal_unlock_database() { if (m_silent) @@ -821,10 +839,10 @@ void NBackup::backup_database(int level, const PathName& fname) if (isc_dsql_allocate_statement(status, &newdb, &stmt)) pr_error(status, "allocate statement"); char str[200]; - sprintf(str, "select rdb$guid, rdb$scn from rdb$backup_history " - "where rdb$backup_id = " - "(select max(rdb$backup_id) from rdb$backup_history " - "where rdb$backup_level = %d)", level - 1); + sprintf(str, "SELECT RDB$GUID, RDB$SCN FROM RDB$BACKUP_HISTORY " + "WHERE RDB$BACKUP_ID = " + "(SELECT MAX(RDB$BACKUP_ID) FROM RDB$BACKUP_HISTORY " + "WHERE RDB$BACKUP_LEVEL = %d)", level - 1); if (isc_dsql_prepare(status, &trans, &stmt, 0, str, 1, NULL)) pr_error(status, "prepare history query"); if (isc_dsql_describe(status, &stmt, 1, out_sqlda)) @@ -1098,6 +1116,7 @@ void NBackup::backup_database(int level, const PathName& fname) // Write about successful backup to backup history table if (isc_start_transaction(status, &trans, 1, &newdb, 0, NULL)) pr_error(status, "start transaction"); + char in_sqlda_data[XSQLDA_LENGTH(4)]; XSQLDA *in_sqlda = (XSQLDA *)in_sqlda_data; in_sqlda->version = SQLDA_VERSION1; @@ -1105,11 +1124,25 @@ void NBackup::backup_database(int level, const PathName& fname) isc_stmt_handle stmt = 0; if (isc_dsql_allocate_statement(status, &newdb, &stmt)) pr_error(status, "allocate statement"); - if (isc_dsql_prepare(status, &trans, &stmt, 0, - "insert into rdb$backup_history(rdb$backup_id, rdb$timestamp, " - "rdb$backup_level, rdb$guid, rdb$scn, rdb$file_name) " - "values(gen_id(rdb$backup_history, 1), 'now', ?, ?, ?, ?)", - 1, NULL)) + + const char* insHistory; + get_ods(); + if (m_odsNumber >= ODS_VERSION12) + { + insHistory = + "INSERT INTO RDB$BACKUP_HISTORY(RDB$BACKUP_ID, RDB$TIMESTAMP, " + "RDB$BACKUP_LEVEL, RDB$GUID, RDB$SCN, RDB$FILE_NAME) " + "VALUES(NULL, 'NOW', ?, ?, ?, ?)"; + } + else + { + insHistory = + "INSERT INTO RDB$BACKUP_HISTORY(RDB$BACKUP_ID, RDB$TIMESTAMP, " + "RDB$BACKUP_LEVEL, RDB$GUID, RDB$SCN, RDB$FILE_NAME) " + "VALUES(GEN_ID(RDB$BACKUP_HISTORY, 1), 'NOW', ?, ?, ?, ?)"; + } + + if (isc_dsql_prepare(status, &trans, &stmt, 0, insHistory, 1, NULL)) { pr_error(status, "prepare history insert"); } diff --git a/src/yvalve/keywords.cpp b/src/yvalve/keywords.cpp index 3d1f4ca249..25d47105da 100644 --- a/src/yvalve/keywords.cpp +++ b/src/yvalve/keywords.cpp @@ -218,6 +218,7 @@ static const TOK tokens[] = {IIF, "IIF", 2, true}, {KW_IN, "IN", 1, false}, {INACTIVE, "INACTIVE", 1, false}, + {INCREMENT, "INCREMENT", 2, false}, {INDEX, "INDEX", 1, false}, {INNER, "INNER", 1, false}, {INPUT_TYPE, "INPUT_TYPE", 1, false}, @@ -386,7 +387,6 @@ static const TOK tokens[] = {STARTING, "STARTS", 1, false}, // Alias of STARTING {STATEMENT, "STATEMENT", 2, true}, {STATISTICS, "STATISTICS", 1, false}, - {STEP, "STEP", 2, false}, {SUBSTRING, "SUBSTRING", 2, true}, {SUB_TYPE, "SUB_TYPE", 1, false}, {SUM, "SUM", 1, false},