MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / setError

Method setError

src/dsql/StmtNodes.cpp:4824–4951  ·  view source on GitHub ↗

Set status vector according to specified error condition and jump to handle error accordingly.

Source from the content-addressed store, hash-verified

4822
4823// Set status vector according to specified error condition and jump to handle error accordingly.
4824void ExceptionNode::setError(thread_db* tdbb) const
4825{
4826 SET_TDBB(tdbb);
4827
4828 Request* request = tdbb->getRequest();
4829
4830 if (!exception)
4831 {
4832 // Retrieve the status vector and punt.
4833 request->req_last_xcp.copyTo(tdbb->tdbb_status_vector);
4834 request->req_last_xcp.clear();
4835 ERR_punt();
4836 }
4837
4838 MetaName exName;
4839 MetaName relationName;
4840 string message;
4841
4842 if (messageExpr)
4843 {
4844 // Evaluate exception message and convert it to string.
4845 const dsc* const desc = EVL_expr(tdbb, request, messageExpr);
4846
4847 if (desc && !(request->req_flags & req_null))
4848 {
4849 MoveBuffer temp;
4850 UCHAR* string = NULL;
4851 const USHORT length = MOV_make_string2(tdbb, desc, CS_METADATA, &string, temp);
4852 message.assign(string, MIN(length, XCP_MESSAGE_LENGTH));
4853 }
4854 }
4855
4856 const SLONG xcpCode = exception->code;
4857
4858 switch (exception->type)
4859 {
4860 case ExceptionItem::GDS_CODE:
4861 if (xcpCode == isc_check_constraint)
4862 {
4863 MET_lookup_cnstrt_for_trigger(tdbb, exName, relationName,
4864 request->getStatement()->triggerName);
4865 ERR_post(Arg::Gds(xcpCode) << Arg::Str(exName) << Arg::Str(relationName));
4866 }
4867 else
4868 ERR_post(Arg::Gds(xcpCode));
4869
4870 case ExceptionItem::XCP_CODE:
4871 {
4872 string tempStr;
4873 const TEXT* s;
4874
4875 // CVC: If we have the exception name, use it instead of the number.
4876 // Solves SF Bug #494981.
4877 MET_lookup_exception(tdbb, xcpCode, exName, &tempStr);
4878
4879 if (message.hasData())
4880 s = message.c_str();
4881 else if (tempStr.hasData())

Callers

nothing calls this directly

Calls 15

SET_TDBBFunction · 0.85
ERR_puntFunction · 0.85
EVL_exprFunction · 0.85
MOV_make_string2Function · 0.85
GdsClass · 0.85
StrClass · 0.85
NumClass · 0.85
MsgPrintFunction · 0.85
ERR_postFunction · 0.50
getRequestMethod · 0.45
copyToMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected