| 4825 | |
| 4826 | |
| 4827 | static void check_owner(thread_db* tdbb, |
| 4828 | jrd_tra* transaction, |
| 4829 | record_param* org_rpb, |
| 4830 | record_param* new_rpb, |
| 4831 | USHORT id) |
| 4832 | { |
| 4833 | /************************************** |
| 4834 | * |
| 4835 | * c h e c k _ o w n e r |
| 4836 | * |
| 4837 | ************************************** |
| 4838 | * |
| 4839 | * Functional description |
| 4840 | * A record in a system relation containing an owner is |
| 4841 | * being changed. Check to see if the owner has changed, |
| 4842 | * and if so, validate whether this action is allowed. |
| 4843 | * |
| 4844 | **************************************/ |
| 4845 | SET_TDBB(tdbb); |
| 4846 | |
| 4847 | dsc desc1, desc2; |
| 4848 | const bool flag_org = EVL_field(0, org_rpb->rpb_record, id, &desc1); |
| 4849 | const bool flag_new = EVL_field(0, new_rpb->rpb_record, id, &desc2); |
| 4850 | |
| 4851 | if (!flag_org && !flag_new) |
| 4852 | return; |
| 4853 | |
| 4854 | if (flag_org && flag_new) |
| 4855 | { |
| 4856 | if (!MOV_compare(tdbb, &desc1, &desc2)) |
| 4857 | return; |
| 4858 | |
| 4859 | const auto attachment = tdbb->getAttachment(); |
| 4860 | const MetaString& name = attachment->getEffectiveUserName(); |
| 4861 | |
| 4862 | if (name.hasData()) |
| 4863 | { |
| 4864 | desc2.makeText((USHORT) name.length(), CS_METADATA, (UCHAR*) name.c_str()); |
| 4865 | |
| 4866 | if (!MOV_compare(tdbb, &desc1, &desc2)) |
| 4867 | return; |
| 4868 | } |
| 4869 | } |
| 4870 | |
| 4871 | // Note: NULL->USER and USER->NULL changes also cause the error to be raised |
| 4872 | |
| 4873 | ERR_post(Arg::Gds(isc_protect_ownership)); |
| 4874 | } |
| 4875 | |
| 4876 | |
| 4877 | static void check_repl_state(thread_db* tdbb, |
no test coverage detected