|
From: <ale...@us...> - 2014-04-18 15:33:16
|
Revision: 59452
http://sourceforge.net/p/firebird/code/59452
Author: alexpeshkoff
Date: 2014-04-18 15:33:11 +0000 (Fri, 18 Apr 2014)
Log Message:
-----------
Enhanced diagnostics in authentication mapping
Modified Paths:
--------------
firebird/trunk/lang_helpers/gds_codes.ftn
firebird/trunk/lang_helpers/gds_codes.pas
firebird/trunk/src/auth/SecureRemotePassword/manage/SrpManagement.cpp
firebird/trunk/src/common/utils.cpp
firebird/trunk/src/common/utils_proto.h
firebird/trunk/src/include/gen/codetext.h
firebird/trunk/src/include/gen/iberror.h
firebird/trunk/src/include/gen/msgs.h
firebird/trunk/src/include/gen/sql_code.h
firebird/trunk/src/include/gen/sql_state.h
firebird/trunk/src/isql/show.epp
firebird/trunk/src/jrd/Mapping.cpp
firebird/trunk/src/jrd/Mapping.h
firebird/trunk/src/msgs/facilities2.sql
firebird/trunk/src/msgs/messages2.sql
firebird/trunk/src/msgs/system_errors2.sql
Modified: firebird/trunk/lang_helpers/gds_codes.ftn
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.ftn 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/lang_helpers/gds_codes.ftn 2014-04-18 15:33:11 UTC (rev 59452)
@@ -1586,6 +1586,10 @@
PARAMETER (GDS__baddpb_buffers_range = 335545086)
INTEGER*4 GDS__baddpb_temp_buffers
PARAMETER (GDS__baddpb_temp_buffers = 335545087)
+ INTEGER*4 GDS__map_nodb
+ PARAMETER (GDS__map_nodb = 335545088)
+ INTEGER*4 GDS__map_notable
+ PARAMETER (GDS__map_notable = 335545089)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw
Modified: firebird/trunk/lang_helpers/gds_codes.pas
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.pas 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/lang_helpers/gds_codes.pas 2014-04-18 15:33:11 UTC (rev 59452)
@@ -800,6 +800,8 @@
gds_baddpb_damaged_mode = 335545085;
gds_baddpb_buffers_range = 335545086;
gds_baddpb_temp_buffers = 335545087;
+ gds_map_nodb = 335545088;
+ gds_map_notable = 335545089;
gds_gfix_db_name = 335740929;
gds_gfix_invalid_sw = 335740930;
gds_gfix_incmp_sw = 335740932;
Modified: firebird/trunk/src/auth/SecureRemotePassword/manage/SrpManagement.cpp
===================================================================
--- firebird/trunk/src/auth/SecureRemotePassword/manage/SrpManagement.cpp 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/auth/SecureRemotePassword/manage/SrpManagement.cpp 2014-04-18 15:33:11 UTC (rev 59452)
@@ -233,23 +233,13 @@
Firebird::status_exception::raise(status->get());
}
- const ISC_STATUS* v = status->get();
- while (v[0] == isc_arg_gds)
+ if (fb_utils::containsErrorCode(status->get(), isc_dsql_relation_err))
{
- if (v[1] == isc_dsql_relation_err)
- {
- prepareDataStructures();
- tra->commit(status);
- check(status);
- tra = att->startTransaction(status, 0, NULL);
- check(status);
- break;
- }
-
- do
- {
- v += 2;
- } while (v[0] != isc_arg_warning && v[0] != isc_arg_gds && v[0] != isc_arg_end);
+ prepareDataStructures();
+ tra->commit(status);
+ check(status);
+ tra = att->startTransaction(status, 0, NULL);
+ check(status);
}
}
Modified: firebird/trunk/src/common/utils.cpp
===================================================================
--- firebird/trunk/src/common/utils.cpp 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/common/utils.cpp 2014-04-18 15:33:11 UTC (rev 59452)
@@ -1381,4 +1381,20 @@
return runOffset + sizeof(SSHORT);
}
+bool containsErrorCode(const ISC_STATUS* v, ISC_STATUS code)
+{
+ while (v[0] == isc_arg_gds)
+ {
+ if (v[1] == code)
+ return true;
+
+ do
+ {
+ v += (v[0] == isc_arg_cstring ? 3 : 2);
+ } while (v[0] != isc_arg_warning && v[0] != isc_arg_gds && v[0] != isc_arg_end);
+ }
+
+ return false;
+}
+
} // namespace fb_utils
Modified: firebird/trunk/src/common/utils_proto.h
===================================================================
--- firebird/trunk/src/common/utils_proto.h 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/common/utils_proto.h 2014-04-18 15:33:11 UTC (rev 59452)
@@ -167,6 +167,9 @@
// Returns next offset value
unsigned sqlTypeToDsc(unsigned prevOffset, unsigned sqlType, unsigned sqlLength,
unsigned* dtype, unsigned* len, unsigned* offset, unsigned* nullOffset);
+
+ // Check does vector contain particular code or not
+ bool containsErrorCode(const ISC_STATUS* v, ISC_STATUS code);
} // namespace fb_utils
#endif // INCLUDE_UTILS_PROTO_H
Modified: firebird/trunk/src/include/gen/codetext.h
===================================================================
--- firebird/trunk/src/include/gen/codetext.h 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/include/gen/codetext.h 2014-04-18 15:33:11 UTC (rev 59452)
@@ -789,6 +789,8 @@
{"baddpb_damaged_mode", 335545085},
{"baddpb_buffers_range", 335545086},
{"baddpb_temp_buffers", 335545087},
+ {"map_nodb", 335545088},
+ {"map_notable", 335545089},
{"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932},
Modified: firebird/trunk/src/include/gen/iberror.h
===================================================================
--- firebird/trunk/src/include/gen/iberror.h 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/include/gen/iberror.h 2014-04-18 15:33:11 UTC (rev 59452)
@@ -823,6 +823,8 @@
const ISC_STATUS isc_baddpb_damaged_mode = 335545085L;
const ISC_STATUS isc_baddpb_buffers_range = 335545086L;
const ISC_STATUS isc_baddpb_temp_buffers = 335545087L;
+const ISC_STATUS isc_map_nodb = 335545088L;
+const ISC_STATUS isc_map_notable = 335545089L;
const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@@ -1275,7 +1277,7 @@
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
-const ISC_STATUS isc_err_max = 1219;
+const ISC_STATUS isc_err_max = 1221;
#else /* c definitions */
@@ -2068,6 +2070,8 @@
#define isc_baddpb_damaged_mode 335545085L
#define isc_baddpb_buffers_range 335545086L
#define isc_baddpb_temp_buffers 335545087L
+#define isc_map_nodb 335545088L
+#define isc_map_notable 335545089L
#define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L
@@ -2520,7 +2524,7 @@
#define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L
-#define isc_err_max 1219
+#define isc_err_max 1221
#endif
Modified: firebird/trunk/src/include/gen/msgs.h
===================================================================
--- firebird/trunk/src/include/gen/msgs.h 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/include/gen/msgs.h 2014-04-18 15:33:11 UTC (rev 59452)
@@ -792,6 +792,8 @@
{335545085, "Incompatible mode of attachment to damaged database"}, /* baddpb_damaged_mode */
{335545086, "Attempt to set in database number of buffers which is out of acceptable range [@1:@2]"}, /* baddpb_buffers_range */
{335545087, "Attempt to temporarily set number of buffers less than @1"}, /* baddpb_temp_buffers */
+ {335545088, "Global mapping is not available when database @1 is not present"}, /* map_nodb */
+ {335545089, "Global mapping is not available when table RDB$MAP is not present in database @1"}, /* map_notable */
{335740929, "data base file name (@1) already given"}, /* gfix_db_name */
{335740930, "invalid switch @1"}, /* gfix_invalid_sw */
{335740932, "incompatible switch combination"}, /* gfix_incmp_sw */
Modified: firebird/trunk/src/include/gen/sql_code.h
===================================================================
--- firebird/trunk/src/include/gen/sql_code.h 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/include/gen/sql_code.h 2014-04-18 15:33:11 UTC (rev 59452)
@@ -788,6 +788,8 @@
{335545085, -924}, /* 765 baddpb_damaged_mode */
{335545086, -924}, /* 766 baddpb_buffers_range */
{335545087, -924}, /* 767 baddpb_temp_buffers */
+ {335545088, -901}, /* 768 map_nodb */
+ {335545089, -901}, /* 769 map_notable */
{335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */
Modified: firebird/trunk/src/include/gen/sql_state.h
===================================================================
--- firebird/trunk/src/include/gen/sql_state.h 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/include/gen/sql_state.h 2014-04-18 15:33:11 UTC (rev 59452)
@@ -788,6 +788,8 @@
{335545085, "HY000"}, // 765 baddpb_damaged_mode
{335545086, "HY000"}, // 766 baddpb_buffers_range
{335545087, "HY000"}, // 767 baddpb_temp_buffers
+ {335545088, "0A000"}, // 768 map_nodb
+ {335545089, "0A000"}, // 769 map_notable
{335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw
Modified: firebird/trunk/src/isql/show.epp
===================================================================
--- firebird/trunk/src/isql/show.epp 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/isql/show.epp 2014-04-18 15:33:11 UTC (rev 59452)
@@ -4441,7 +4441,8 @@
}
END_FOR
ON_ERROR
- ISQL_errmsg(fbStatus); // report error but not return error on it
+ if (!extract)
+ ISQL_errmsg(fbStatus); // report error but not return error on it
END_ERROR;
return first ? OBJECT_NOT_FOUND : SKIP;
Modified: firebird/trunk/src/jrd/Mapping.cpp
===================================================================
--- firebird/trunk/src/jrd/Mapping.cpp 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/jrd/Mapping.cpp 2014-04-18 15:33:11 UTC (rev 59452)
@@ -279,15 +279,18 @@
" RDB$MAP_FROM, RDB$MAP_TO_TYPE, RDB$MAP_TO "
"FROM RDB$MAP",
3, NULL, NULL, mMap.getMetadata());
- // check("IAttachment::openCursor", &st);
if (!st.isSuccess())
{
- // errors when opening cursor - sooner of all table RDB$MAP is missing
- // in non-FB3 security DB
- tra->release();
- att->detach(&st);
- dataFlag = true;
- return;
+ if (fb_utils::containsErrorCode(st.get(), isc_dsql_relation_err))
+ {
+ // isc_dsql_relation_err when opening cursor - sooner of all table RDB$MAP
+ // is missing due to non-FB3 security DB
+ tra->release();
+ att->detach(&st);
+ dataFlag = true;
+ return;
+ }
+ check("IAttachment::openCursor", &st);
}
while (curs->fetchNext(&st, mMap.getBuffer()))
@@ -880,8 +883,10 @@
embeddedSysdba.getBufferLength(), embeddedSysdba.getBuffer());
if (!st.isSuccess())
{
+ if (!fb_utils::containsErrorCode(st.get(), isc_io_error))
+ check("IProvider::attachDatabase", &st);
+
// missing security DB is not a reason to fail mapping
- // do not check error code here - it may be something else for non-native provider
iSec = NULL;
}
}
@@ -896,9 +901,10 @@
embeddedSysdba.getBufferLength(), embeddedSysdba.getBuffer());
if (!st.isSuccess())
{
+ if (!fb_utils::containsErrorCode(st.get(), isc_io_error))
+ check("IProvider::attachDatabase", &st);
+
// missing DB is not a reason to fail mapping
- if (st.get()[1] != isc_io_error)
- check("IProvider::attachDatabase", &st);
iDb = NULL;
}
}
@@ -1006,7 +1012,6 @@
Found::What recordWeight =
(db && info.secDb == db) ? Found::FND_DB :
(info.secDb == securityDb) ? Found::FND_SEC :
- //(info.plugin.hasData() && info.secDb.isEmpty()) ? Found::FND_SWIDE :
Found::FND_NOTHING;
if (recordWeight != Found::FND_NOTHING)
@@ -1057,6 +1062,12 @@
: DataDump(*tra->tra_pool)
{ }
+RecordBuffer* MappingList::makeBuffer(thread_db* tdbb)
+{
+ MemoryPool* const pool = tdbb->getTransaction()->tra_pool;
+ allocBuffer(tdbb, *pool, rel_sec_global_map);
+ return getData(rel_sec_global_map);
+}
RecordBuffer* MappingList::getList(thread_db* tdbb, jrd_rel* relation)
{
@@ -1081,10 +1092,21 @@
MAX_DPB_SIZE, isc_dpb_version1);
embeddedSysdba.insertString(isc_dpb_user_name, SYSDBA_USER_NAME,
strlen(SYSDBA_USER_NAME));
- att = prov->attachDatabase(&st, tdbb->getDatabase()->dbb_config->getSecurityDatabase(),
+ const char* dbName = tdbb->getDatabase()->dbb_config->getSecurityDatabase();
+ att = prov->attachDatabase(&st, dbName,
embeddedSysdba.getBufferLength(), embeddedSysdba.getBuffer());
- check("IProvider::attachDatabase", &st);
+ if (!st.isSuccess())
+ {
+ if (!fb_utils::containsErrorCode(st.get(), isc_io_error))
+ check("IProvider::attachDatabase", &st);
+ // In embedded mode we are not raising any errors - silent return
+ if (MasterInterfacePtr()->serverMode(-1) < 0)
+ return makeBuffer(tdbb);
+
+ (Arg::Gds(isc_map_nodb) << dbName).raise();
+ }
+
ClumpletWriter readOnly(ClumpletWriter::Tpb, MAX_DPB_SIZE, isc_tpb_version1);
readOnly.insertTag(isc_tpb_read);
readOnly.insertTag(isc_tpb_wait);
@@ -1106,11 +1128,24 @@
" RDB$MAP_FROM_TYPE, RDB$MAP_FROM, RDB$MAP_TO_TYPE, RDB$MAP_TO "
"FROM RDB$MAP",
3, NULL, NULL, mMap.getMetadata());
- check("IAttachment::openCursor", &st);
+ if (!st.isSuccess())
+ {
+ if (!fb_utils::containsErrorCode(st.get(), isc_dsql_relation_err))
+ check("IAttachment::openCursor", &st);
- MemoryPool* const pool = tdbb->getTransaction()->tra_pool;
- allocBuffer(tdbb, *pool, rel_sec_global_map);
- buffer = getData(rel_sec_global_map);
+ // isc_dsql_relation_err when opening cursor - sooner of all table RDB$MAP
+ // is missing due to non-FB3 security DB
+ tra->release();
+ att->detach(&st);
+
+ // In embedded mode we are not raising any errors - silent return
+ if (MasterInterfacePtr()->serverMode(-1) < 0)
+ return makeBuffer(tdbb);
+
+ (Arg::Gds(isc_map_notable) << dbName).raise();
+ }
+
+ buffer = makeBuffer(tdbb);
Record* record = buffer->getTempRecord();
while (curs->fetchNext(&st, mMap.getBuffer()))
Modified: firebird/trunk/src/jrd/Mapping.h
===================================================================
--- firebird/trunk/src/jrd/Mapping.h 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/jrd/Mapping.h 2014-04-18 15:33:11 UTC (rev 59452)
@@ -60,6 +60,9 @@
explicit MappingList(jrd_tra* tra);
RecordBuffer* getList(thread_db* tdbb, jrd_rel* relation);
+
+private:
+ RecordBuffer* makeBuffer(thread_db* tdbb);
};
} // namespace Jrd
Modified: firebird/trunk/src/msgs/facilities2.sql
===================================================================
--- firebird/trunk/src/msgs/facilities2.sql 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/msgs/facilities2.sql 2014-04-18 15:33:11 UTC (rev 59452)
@@ -1,7 +1,7 @@
/* MAX_NUMBER is the next number to be used, always one more than the highest message number. */
set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES (?, ?, ?, ?);
--
-('2014-04-04 16:13:24', 'JRD', 0, 768)
+('2014-04-18 19:01:37', 'JRD', 0, 770)
('2012-01-23 20:10:30', 'QLI', 1, 532)
('2013-11-13 15:59:10', 'GFIX', 3, 122)
('1996-11-07 13:39:40', 'GPRE', 4, 1)
Modified: firebird/trunk/src/msgs/messages2.sql
===================================================================
--- firebird/trunk/src/msgs/messages2.sql 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/msgs/messages2.sql 2014-04-18 15:33:11 UTC (rev 59452)
@@ -875,6 +875,8 @@
('baddpb_damaged_mode', 'attachDatabase', 'jrd.cpp', NULL, 0, 765, NULL, 'Incompatible mode of attachment to damaged database', NULL, NULL);
('baddpb_buffers_range', 'DatabaseOptions::get', 'jrd.cpp', NULL, 0, 766, NULL, 'Attempt to set in database number of buffers which is out of acceptable range [@1:@2]', NULL, NULL);
('baddpb_temp_buffers', 'DatabaseOptions::get', 'jrd.cpp', NULL, 0, 767, NULL, 'Attempt to temporarily set number of buffers less than @1', NULL, NULL);
+('map_nodb', 'MappingList::getList', 'Mapping.cpp', NULL, 0, 768, NULL, 'Global mapping is not available when database @1 is not present', NULL, NULL);
+('map_notable', 'MappingList::getList', 'Mapping.cpp', NULL, 0, 769, NULL, 'Global mapping is not available when table RDB$MAP is not present in database @1', NULL, NULL);
-- QLI
(NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL);
(NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL);
Modified: firebird/trunk/src/msgs/system_errors2.sql
===================================================================
--- firebird/trunk/src/msgs/system_errors2.sql 2014-04-18 14:43:06 UTC (rev 59451)
+++ firebird/trunk/src/msgs/system_errors2.sql 2014-04-18 15:33:11 UTC (rev 59452)
@@ -774,6 +774,8 @@
(-924, 'HY', '000', 0, 765, 'baddpb_damaged_mode', NULL, NULL);
(-924, 'HY', '000', 0, 766, 'baddpb_buffers_range', NULL, NULL);
(-924, 'HY', '000', 0, 767, 'baddpb_temp_buffers', NULL, NULL);
+(-901, '0A', '000', 0, 768, 'map_nodb', NULL, NULL);
+(-901, '0A', '000', 0, 769, 'map_notable', NULL, NULL);
-- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|