Re: [Firebird-devel] Unique constraint not working on first command after encryption
On 11/29/17 10:57, Jiří Činčura wrote: OK, the Firebird-4.0.0.816-0_Win32 behaves correctly. Will this go into 3.0.3 as well? As you can already see it's fixed in FB3 branch too. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
OK, the Firebird-4.0.0.816-0_Win32 behaves correctly. Will this go into 3.0.3 as well? -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
> Committed to master. Great. I'll check the snapshot build tomorrow and I'll let you know. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
On 11/28/17 17:03, Jiří Činčura wrote: Jiří, can you try with this patch? I'm 99% sure it will help you to but if you can check it will be great. Can you maybe commit it to some branch/master and I'll get the fresh build from CI/nightly when it's done? I'm currently not in front of a computer with toolset to build Firebird myself. Committed to master. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
> Jiří, can you try with this patch? I'm 99% sure it will help you to but > if you can check it will be great. Can you maybe commit it to some branch/master and I'll get the fresh build from CI/nightly when it's done? I'm currently not in front of a computer with toolset to build Firebird myself. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
On 11/27/17 20:39, Jiří Činčura wrote: I've reproduced an issue. Somewhere between catching error in looper and rethrowing it again when leaving looper tdbb_status_vector is cleaned Great to know, you found it. Jiří, can you try with this patch? I'm 99% sure it will help you to but if you can check it will be great. diff --git a/src/jrd/CryptoManager.cpp b/src/jrd/CryptoManager.cpp index 7aaca51d78..2e37752cf6 100644 --- a/src/jrd/CryptoManager.cpp +++ b/src/jrd/CryptoManager.cpp @@ -1047,10 +1047,14 @@ namespace Jrd { return FAILED_CRYPT; } - cryptPlugin->decrypt(sv, dbb.dbb_page_size - sizeof(Ods::pag), + FbLocalStatus ls; + cryptPlugin->decrypt(, dbb.dbb_page_size - sizeof(Ods::pag), [1], [1]); if (sv->getState() & IStatus::STATE_ERRORS) + { +ERR_post_nothrow(, sv); return FAILED_CRYPT; + } } return SUCCESS_ALL; @@ -1132,11 +1136,15 @@ namespace Jrd { return FAILED_CRYPT; } + FbLocalStatus ls; to[0] = page[0]; - cryptPlugin->encrypt(sv, dbb.dbb_page_size - sizeof(Ods::pag), + cryptPlugin->encrypt(, dbb.dbb_page_size - sizeof(Ods::pag), [1], [1]); if (sv->getState() & IStatus::STATE_ERRORS) + { +ERR_post_nothrow(, sv); return FAILED_CRYPT; + } to->pag_flags |= Ods::crypted_page; // Mark page that is going to be written as encrypted page->pag_flags |= Ods::crypted_page; // Set the mark for page in cache as well diff --git a/src/jrd/err.cpp b/src/jrd/err.cpp index 0f428ac2d4..4c6291bcf7 100644 --- a/src/jrd/err.cpp +++ b/src/jrd/err.cpp @@ -55,6 +55,7 @@ using namespace Firebird; static void internal_error(ISC_STATUS status, int number, const TEXT* file = NULL, int line = 0); +static void post_nothrow(const unsigned lenToAdd, const ISC_STATUS* toAdd, FbStatusVector* statusVector); void ERR_bugcheck(int number, const TEXT* file, int line) @@ -204,14 +205,45 @@ void ERR_post_nothrow(const Arg::StatusVector& v, FbStatusVector* statusVector) * **/ { - // calculate length of the status - unsigned lenToAdd = v.length(); + post_nothrow(v.length(), v.value(), statusVector); +} + + +void ERR_post_nothrow(const IStatus* v, FbStatusVector* statusVector) +/** + * + * E R R _ p o s t _ n o t h r o w + * + ** + * + * Functional description + * Populate a status vector. + * + **/ +{ + const ISC_STATUS* toAdd = v->getErrors(); + post_nothrow(fb_utils::statusLength(toAdd), toAdd, statusVector); +} + + +static void post_nothrow(const unsigned lenToAdd, const ISC_STATUS* toAdd, FbStatusVector* statusVector) +/** + * + * E R R _ p o s t _ n o t h r o w + * + ** + * + * Functional description + * Populate a status vector. + * + **/ +{ + // check status to add if (lenToAdd == 0) // nothing to do return; - const ISC_STATUS* toAdd = v.value(); fb_assert(toAdd[0] == isc_arg_gds); - // Use default from tdbb when no vector specified + // use default from tdbb when no vector specified if (!statusVector) statusVector = JRD_get_thread_data()->tdbb_status_vector; diff --git a/src/jrd/err_proto.h b/src/jrd/err_proto.h index c5964b6592..7ee27bb3bd 100644 --- a/src/jrd/err_proto.h +++ b/src/jrd/err_proto.h @@ -54,6 +54,7 @@ void ERR_corrupt(int); void ERR_error(int); void ERR_post(const Firebird::Arg::StatusVector& v); void ERR_post_nothrow(const Firebird::Arg::StatusVector& v, Jrd::FbStatusVector* statusVector = NULL); +void ERR_post_nothrow(const Firebird::IStatus* v, Jrd::FbStatusVector* statusVector = NULL); void ERR_punt(); void ERR_warning(const Firebird::Arg::StatusVector& v); void ERR_log(int, int, const TEXT*); -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdotFirebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
> I've reproduced an issue. Somewhere between catching error in looper and > rethrowing it again when leaving looper tdbb_status_vector is cleaned Great to know, you found it. > up. BTW, for me it's reproduced each time I logoff/logon from/to isql. Yes. For me as well. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
On 11/27/17 17:17, Jiří Činčura wrote: Any ideas what could be wrong and where to look at? I've reproduced an issue. Somewhere between catching error in looper and rethrowing it again when leaving looper tdbb_status_vector is cleaned up. BTW, for me it's reproduced each time I logoff/logon from/to isql. Will proceed with it tomorrow. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
>gfix -v -f ? $ .\gfix.exe -v -fu -user sysdba -password masterkey C:\Users\Jiri\Downloads\aaa\aaa\aaa.FDB $ Nothing. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
27.11.2017 16:50, Jiří Činčura wrote: But mostly wierd is that even in theory crypt plugin can not affect integrity constraints - encryption works a few logical levels deeper than constraints violation, that's absolutely different parts of code. Yeah. I though the database was somewhat corrupted, but b went absolutely fine. gfix -v -f ? Regards, Vlad -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
On 11/27/17 18:08, Jiří Činčura wrote: What is the size of compressed database backup? 52 264 210 bytes, why? Will not fit into email (32M limit on mail.ru), please put it to some reasonable share. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
> AES128 plugin also works fine for me: Yeah, as I said. On a new database it works fine. It's something with this database that triggers some undefined behavior. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
On 11/27/17 17:17, Jiří Činčura wrote: Any ideas what could be wrong and where to look at? AES128 plugin also works fine for me: localhost bin # localhost bin # ./isql e1.fdb Database: e1.fdb, User: SYSDBA SQL> alter database encrypt with AES128; SQL> insert into country values('Russia', 'Rub'); Statement failed, SQLSTATE = 23000 violation of PRIMARY or UNIQUE KEY constraint "INTEG_2" on table "COUNTRY" -Problematic key value is ("COUNTRY" = 'Russia') SQL> -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
> What is the size of compressed database backup? 52 264 210 bytes, why? -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
On 11/27/17 17:55, Jiří Činčura wrote: To be precise - it's IBSurgeon plugin. Hmm. Of course, could be. Wondering why it fails only on this database? Even more. Test table on this database works fine. What is the size of compressed database backup? -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Unique constraint not working on first command after encryption
On 11/27/17 17:43, Alex Peshkoff via Firebird-devel wrote: Wierd - I could not reproduce it with . plugin. To be precise - it's IBSurgeon plugin. -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
[Firebird-devel] Unique constraint not working on first command after encryption
Hi, I have a weird behavior here. Database after b, no errors. I try to insert non-unique value into table with unique constraint and it fails as it should. I encrypt it (AES128 from IBPhoenix) and the same statement does not fail. Only the next one will throw unique violation. Here's a snap from console: $ .\isql.exe Use CONNECT or CREATE DATABASE to specify a database SQL> connect 'localhost:C:\Users\Jiri\Downloads\aaa\aaa\aaa.FDB' user 'sysdba' password 'masterkey'; Database: 'localhost:C:\Users\Jiri\Downloads\aaa\aaa\aaa.FDB', User: SYSDBA SQL> insert into product2suppdoc(productid, supportingdocumentid) values (17,1); Statement failed, SQLSTATE = 23000 violation of PRIMARY or UNIQUE KEY constraint "UNQ_PRODUCT2SUPPDOC" on table "PRODUCT2SUPPDOC" -Problematic key value is ("PRODUCTID" = 17, "SUPPORTINGDOCUMENTID" = 1) SQL> alter database encrypt with aes128; SQL> commit; SQL> exit; $ .\isql.exe Use CONNECT or CREATE DATABASE to specify a database SQL> connect 'localhost:C:\Users\Jiri\Downloads\aaa\aaa\aaa.FDB' user 'sysdba' password 'masterkey'; Database: 'localhost:C:\Users\Jiri\Downloads\aaa\aaa\aaa.FDB', User: SYSDBA SQL> insert into product2suppdoc(productid, supportingdocumentid) values (17,1); SQL> insert into product2suppdoc(productid, supportingdocumentid) values (17,1); Statement failed, SQLSTATE = 23000 violation of PRIMARY or UNIQUE KEY constraint "UNQ_PRODUCT2SUPPDOC" on table "PRODUCT2SUPPDOC" -Problematic key value is ("PRODUCTID" = 17, "SUPPORTINGDOCUMENTID" = 1) SQL> Any ideas what could be wrong and where to look at? -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel