From f32795fe1d63c002e6e841a8465579a78618bdd6 Mon Sep 17 00:00:00 2001 From: robocop Date: Sun, 1 Oct 2006 09:14:38 +0000 Subject: [PATCH] More improvements for CORE-945 because there are other confusing messages in DYN. --- src/jrd/dyn_def.epp | 43 ++++++++++++++++++++++------------------- src/msgs/facilities.sql | 2 +- src/msgs/history.sql | 2 ++ src/msgs/messages.sql | 7 ++++--- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/jrd/dyn_def.epp b/src/jrd/dyn_def.epp index 0706a438ec..0a28ac6c95 100644 --- a/src/jrd/dyn_def.epp +++ b/src/jrd/dyn_def.epp @@ -2256,23 +2256,20 @@ void DYN_define_index(Global* gbl, int list_index = -1; bool found = false; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) - X IN RDB$RELATION_CONSTRAINTS CROSS - Y IN RDB$INDICES OVER RDB$INDEX_NAME CROSS - Z IN RDB$INDEX_SEGMENTS OVER RDB$INDEX_NAME WITH - Y.RDB$RELATION_NAME EQ referenced_relation.c_str() AND - Y.RDB$UNIQUE_FLAG NOT MISSING AND - (X.RDB$CONSTRAINT_TYPE = PRIMARY_KEY OR - X.RDB$CONSTRAINT_TYPE = UNIQUE_CNSTRT) - SORTED BY Y.RDB$INDEX_NAME, - DESCENDING Z.RDB$FIELD_POSITION + RC IN RDB$RELATION_CONSTRAINTS CROSS + IND IN RDB$INDICES OVER RDB$INDEX_NAME CROSS + ISEG IN RDB$INDEX_SEGMENTS OVER RDB$INDEX_NAME WITH + IND.RDB$RELATION_NAME EQ referenced_relation.c_str() AND + IND.RDB$UNIQUE_FLAG NOT MISSING AND + (RC.RDB$CONSTRAINT_TYPE = PRIMARY_KEY OR + RC.RDB$CONSTRAINT_TYPE = UNIQUE_CNSTRT) + SORTED BY IND.RDB$INDEX_NAME, + DESCENDING ISEG.RDB$FIELD_POSITION if (!DYN_REQUEST(drq_l_unq_idx)) DYN_REQUEST(drq_l_unq_idx) = request; - /* create a control break on index name, in which we set up - to handle a new index, assuming it is the right one */ - - if (index_name != Y.RDB$INDEX_NAME) { + if (index_name != IND.RDB$INDEX_NAME) { if (list_index >= 0) found = false; if (found) { @@ -2280,7 +2277,7 @@ void DYN_define_index(Global* gbl, break; } list_index = field_list.getCount() - 1; - index_name = Y.RDB$INDEX_NAME; + index_name = IND.RDB$INDEX_NAME; found = true; } @@ -2288,8 +2285,8 @@ void DYN_define_index(Global* gbl, match, then this is not the correct index */ if (list_index >= 0) { - fb_utils::exact_name_limit(Z.RDB$FIELD_NAME, sizeof(Z.RDB$FIELD_NAME)); - if (field_list[list_index--] != Z.RDB$FIELD_NAME) + fb_utils::exact_name_limit(ISEG.RDB$FIELD_NAME, sizeof(ISEG.RDB$FIELD_NAME)); + if (field_list[list_index--] != ISEG.RDB$FIELD_NAME) { found = false; } @@ -2316,19 +2313,25 @@ void DYN_define_index(Global* gbl, else { jrd_req* request2 = NULL; found = false; + bool isView = false; FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$RELATIONS WITH X.RDB$RELATION_NAME EQ referenced_relation.c_str() found = true; + isView = !X.RDB$VIEW_BLR.NULL; END_FOR CMP_release(tdbb, request2); + if (isView) + DYN_error_punt(false, 242, referenced_relation.c_str(), NULL, NULL, NULL, NULL); + // msg 242: "attempt to reference a view (%s) in a foreign key" + if (found) { - DYN_error_punt(false, 18, NULL, NULL, NULL, NULL, NULL); - // msg 18: "could not find UNIQUE or PRIMARY KEY constraint with specified fields" + DYN_error_punt(false, 18, referenced_relation.c_str(), NULL, NULL, NULL, NULL); + // msg 18: "could not find UNIQUE or PRIMARY KEY constraint in table %s with specified columns" } else { @@ -2372,8 +2375,8 @@ void DYN_define_index(Global* gbl, id = old_id; if (IDX.RDB$FOREIGN_KEY.NULL) - DYN_error_punt(false, 20, NULL, NULL, NULL, NULL, NULL); - /* msg 20: "could not find primary key index in specified relation" */ + DYN_error_punt(false, 20, referenced_relation.c_str(), NULL, NULL, NULL, NULL); + /* msg 20: "could not find PRIMARY KEY index in specified table %s" */ } IDX.RDB$SEGMENT_COUNT = seg_count; diff --git a/src/msgs/facilities.sql b/src/msgs/facilities.sql index e2d2a4cd44..42b4a0d97b 100644 --- a/src/msgs/facilities.sql +++ b/src/msgs/facilities.sql @@ -9,7 +9,7 @@ INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES ('19 INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES ('1996-11-07 13:39:40', 'GRST', 6, 1); */ INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES ('2005-09-02 13:09:00', 'DSQL', 7, 30); -INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES ('2006-09-30 13:25:01', 'DYN', 8, 242); +INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES ('2006-10-01 03:20:51', 'DYN', 8, 243); /* INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES ('1996-11-07 13:39:40', 'FRED', 9, 1); */ diff --git a/src/msgs/history.sql b/src/msgs/history.sql index 1de6341fa4..200b280329 100644 --- a/src/msgs/history.sql +++ b/src/msgs/history.sql @@ -1184,5 +1184,7 @@ INSERT INTO HISTORY (CHANGE_NUMBER, CHANGE_WHO, CHANGE_DATE, FAC_CODE, NUMBER, O INSERT INTO HISTORY (CHANGE_NUMBER, CHANGE_WHO, CHANGE_DATE, FAC_CODE, NUMBER, OLD_TEXT, OLD_ACTION, OLD_EXPLANATION, LOCALE) VALUES (1181, 'cvc', '2006-07-28 04:58:25', 12, 250, 'Bad attributes for restoring SQL role', NULL, NULL, 'c_pg'); INSERT INTO HISTORY (CHANGE_NUMBER, CHANGE_WHO, CHANGE_DATE, FAC_CODE, NUMBER, OLD_TEXT, OLD_ACTION, OLD_EXPLANATION, LOCALE) VALUES (1182, 'cvc', '2006-07-28 06:38:03', 12, 63, ' %sM(ETA_DATA) backup metadata only', NULL, NULL, 'c_pg'); INSERT INTO HISTORY (CHANGE_NUMBER, CHANGE_WHO, CHANGE_DATE, FAC_CODE, NUMBER, OLD_TEXT, OLD_ACTION, OLD_EXPLANATION, LOCALE) VALUES (1183, 'cvc', '2006-08-31 04:21:42', 8, 43, 'column %s is used in table %s (local name %s) and cannot be dropped', NULL, NULL, 'c_pg'); +INSERT INTO HISTORY (CHANGE_NUMBER, CHANGE_WHO, CHANGE_DATE, FAC_CODE, NUMBER, OLD_TEXT, OLD_ACTION, OLD_EXPLANATION, LOCALE) VALUES (1184, 'cvc', '2006-10-01 03:18:30', 8, 18, 'could not find UNIQUE or PRIMARY KEY constraint with specified columns', NULL, NULL, 'c_pg'); +INSERT INTO HISTORY (CHANGE_NUMBER, CHANGE_WHO, CHANGE_DATE, FAC_CODE, NUMBER, OLD_TEXT, OLD_ACTION, OLD_EXPLANATION, LOCALE) VALUES (1185, 'cvc', '2006-10-01 03:20:51', 8, 20, 'could not find PRIMARY KEY index in specified table', NULL, NULL, 'c_pg'); COMMIT WORK; diff --git a/src/msgs/messages.sql b/src/msgs/messages.sql index 89f41a8da9..6a8aef2a91 100644 --- a/src/msgs/messages.sql +++ b/src/msgs/messages.sql @@ -1520,9 +1520,9 @@ INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FL INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES (NULL, NULL, 'dyn.c', NULL, 8, 15, NULL, 'STORE RDB$INDICES failed', NULL, NULL); INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES (NULL, NULL, 'dyn.c', NULL, 8, 16, NULL, 'unsupported DYN verb', NULL, NULL); INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('', '', 'dyn.c', NULL, 8, 17, NULL, 'PRIMARY KEY column lookup failed', NULL, NULL); -INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('', '', 'dyn_def.epp', NULL, 8, 18, NULL, 'could not find UNIQUE or PRIMARY KEY constraint with specified columns', NULL, NULL); +INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('', '', 'dyn_def.epp', NULL, 8, 18, NULL, 'could not find UNIQUE or PRIMARY KEY constraint in table %s with specified columns', NULL, NULL); INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('', '', 'dyn.c', NULL, 8, 19, NULL, 'PRIMARY KEY lookup failed', NULL, NULL); -INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('', '', 'dyn.c', NULL, 8, 20, NULL, 'could not find PRIMARY KEY index in specified table', NULL, NULL); +INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('', '', 'dyn.c', NULL, 8, 20, NULL, 'could not find PRIMARY KEY index in specified table %s', NULL, NULL); INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES (NULL, NULL, 'dyn.c', NULL, 8, 21, NULL, 'STORE RDB$INDICES failed', NULL, NULL); INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES (NULL, NULL, 'dyn.c', NULL, 8, 22, NULL, 'STORE RDB$FIELDS failed', NULL, NULL); INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES (NULL, NULL, 'dyn.c', NULL, 8, 23, NULL, 'STORE RDB$RELATION_FIELDS failed', NULL, NULL); @@ -3075,6 +3075,7 @@ INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FL INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('array_max_dimensions', 'scalar', 'evl.cpp', NULL, 0, 553, NULL, 'Array data type can use up to %d dimensions', NULL, NULL); INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('dsql_only_can_subscript_array', 'MAKE_field', 'make.cpp', NULL, 13, 926, NULL, 'scalar operator used on field %s which is not an array', NULL, NULL); INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('dsql_max_sort_items', 'pass1_sort', 'pass1.cpp', NULL, 13, 927, NULL, 'cannot sort on more than 255 items', NULL, NULL); -INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES ('', '', 'dyn_def.epp', NULL, 8, 241, NULL, 'Table %s not found', NULL, NULL); +INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES (NULL, 'DYN_define_index', 'dyn_def.epp', NULL, 8, 241, NULL, 'Table %s not found', NULL, NULL); +INSERT INTO MESSAGES (SYMBOL, ROUTINE, MODULE, TRANS_NOTES, FAC_CODE, NUMBER, FLAGS, TEXT, "ACTION", EXPLANATION) VALUES (NULL, 'DYN_define_index', 'dyn_def.epp', NULL, 8, 242, NULL, 'attempt to reference a view (%s) in a foreign key', NULL, NULL); COMMIT WORK;