From 597cd7844c6b54b9222c7c7d235bbbb70a5e7db6 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Sat, 30 Sep 2006 16:17:24 +0000 Subject: [PATCH] Fixed CORE-945 - Bad error message when trying to create FK to non-existent table --- src/jrd/dyn_def.epp | 23 +++++++++++++++++++++-- src/msgs/facilities.sql | 2 +- src/msgs/messages.sql | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/jrd/dyn_def.epp b/src/jrd/dyn_def.epp index 4340f977b4..0706a438ec 100644 --- a/src/jrd/dyn_def.epp +++ b/src/jrd/dyn_def.epp @@ -2314,8 +2314,27 @@ void DYN_define_index(Global* gbl, } } else { - DYN_error_punt(false, 18, NULL, NULL, NULL, NULL, NULL); - // msg 18: "could not find UNIQUE or PRIMARY KEY constraint with specified fields" + jrd_req* request2 = NULL; + found = 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; + END_FOR + + CMP_release(tdbb, request2); + + 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" + } + else + { + DYN_error_punt(false, 241, referenced_relation.c_str(), NULL, NULL, NULL, NULL); + // msg 241: "Table %s not found" + } } } else if (referenced_relation.length()) { diff --git a/src/msgs/facilities.sql b/src/msgs/facilities.sql index bc81d4eb09..e2d2a4cd44 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-05 04:53:01', 'DYN', 8, 241); +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 ('1996-11-07 13:39:40', 'FRED', 9, 1); */ diff --git a/src/msgs/messages.sql b/src/msgs/messages.sql index 6586a301cb..89f41a8da9 100644 --- a/src/msgs/messages.sql +++ b/src/msgs/messages.sql @@ -3075,5 +3075,6 @@ 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); COMMIT WORK;