src/pl/tcl/pltcl.c
static void
pltcl_construct_errorCode(Tcl_Interp *interp, ErrorData *edata)
{
	Tcl_Obj    *obj = Tcl_NewObj();

	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj("POSTGRES", -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj(PG_VERSION, -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj("SQLSTATE", -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj(unpack_sql_state(edata->sqlerrcode), -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj("condition", -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj(pltcl_get_condition_name(edata->sqlerrcode), -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj("message", -1));
	UTF_BEGIN;
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj(UTF_E2U(edata->message), -1));
	UTF_END;
	if (edata->detail)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("detail", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->detail), -1));
		UTF_END;
	}
	if (edata->hint)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("hint", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->hint), -1));
		UTF_END;
	}
	if (edata->context)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("context", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->context), -1));
		UTF_END;
	}
	if (edata->schema_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("schema", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->schema_name), -1));
		UTF_END;
	}
	if (edata->table_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("table", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->table_name), -1));
		UTF_END;
	}
	if (edata->column_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("column", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->column_name), -1));
		UTF_END;
	}
	if (edata->datatype_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("datatype", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->datatype_name), -1));
		UTF_END;
	}
	if (edata->constraint_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("constraint", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->constraint_name), -1));
		UTF_END;
	}
	/* cursorpos is never interesting here; report internal query/pos */
	if (edata->internalquery)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("statement", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->internalquery), -1));
		UTF_END;
	}
	if (edata->internalpos > 0)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("cursor_position", -1));
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewIntObj(edata->internalpos));
	}
	if (edata->filename)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("filename", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->filename), -1));
		UTF_END;
	}
	if (edata->lineno > 0)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("lineno", -1));
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewIntObj(edata->lineno));
	}
	if (edata->funcname)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("funcname", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->funcname), -1));
		UTF_END;
	}

	Tcl_SetObjErrorCode(interp, obj);
}
/**********************************************************************
 * pltcl_construct_errorCode()		- construct a Tcl errorCode
 *		list with detailed information from the PostgreSQL server
 **********************************************************************/
pltcl_construct_errorCode()          - construct a Tcl errorCode
list with detailed information from the PostgreSQL server
pltcl_construct_errorCode () - construct a Tcl errorCode list with detailed information from the PostgreSQL server
static void
pltcl_construct_errorCode(Tcl_Interp *interp, ErrorData *edata)
{
	Tcl_Obj    *obj = Tcl_NewObj();
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj("POSTGRES", -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj(PG_VERSION, -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj("SQLSTATE", -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj(unpack_sql_state(edata->sqlerrcode), -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj("condition", -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj(pltcl_get_condition_name(edata->sqlerrcode), -1));
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj("message", -1));
	UTF_BEGIN;
	Tcl_ListObjAppendElement(interp, obj,
							 Tcl_NewStringObj(UTF_E2U(edata->message), -1));
	UTF_END;
	if (edata->detail)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("detail", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->detail), -1));
		UTF_END;
	}
	if (edata->hint)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("hint", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->hint), -1));
		UTF_END;
	}
	if (edata->context)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("context", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->context), -1));
		UTF_END;
	}
	if (edata->schema_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("schema", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->schema_name), -1));
		UTF_END;
	}
	if (edata->table_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("table", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->table_name), -1));
		UTF_END;
	}
	if (edata->column_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("column", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->column_name), -1));
		UTF_END;
	}
	if (edata->datatype_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("datatype", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->datatype_name), -1));
		UTF_END;
	}
	if (edata->constraint_name)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("constraint", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->constraint_name), -1));
		UTF_END;
	}
	if (edata->internalquery)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("statement", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->internalquery), -1));
		UTF_END;
	}
	if (edata->internalpos > 0)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("cursor_position", -1));
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewIntObj(edata->internalpos));
	}
	if (edata->filename)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("filename", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->filename), -1));
		UTF_END;
	}
	if (edata->lineno > 0)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("lineno", -1));
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewIntObj(edata->lineno));
	}
	if (edata->funcname)
	{
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj("funcname", -1));
		UTF_BEGIN;
		Tcl_ListObjAppendElement(interp, obj,
								 Tcl_NewStringObj(UTF_E2U(edata->funcname), -1));
		UTF_END;
	}
	Tcl_SetObjErrorCode(interp, obj);
}
static void pltcl_construct_errorCode ( Tcl_Interp * interp , ErrorData * edata ) { Tcl_Obj * obj = Tcl_NewObj ( ) ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( PG_VERSION , -1 ) ) ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( unpack_sql_state ( edata -> sqlerrcode ) , -1 ) ) ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( pltcl_get_condition_name ( edata -> sqlerrcode ) , -1 ) ) ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> message ) , -1 ) ) ; UTF_END ; if ( edata -> detail ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> detail ) , -1 ) ) ; UTF_END ; } if ( edata -> hint ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> hint ) , -1 ) ) ; UTF_END ; } if ( edata -> context ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> context ) , -1 ) ) ; UTF_END ; } if ( edata -> schema_name ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> schema_name ) , -1 ) ) ; UTF_END ; } if ( edata -> table_name ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> table_name ) , -1 ) ) ; UTF_END ; } if ( edata -> column_name ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> column_name ) , -1 ) ) ; UTF_END ; } if ( edata -> datatype_name ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> datatype_name ) , -1 ) ) ; UTF_END ; } if ( edata -> constraint_name ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> constraint_name ) , -1 ) ) ; UTF_END ; } if ( edata -> internalquery ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> internalquery ) , -1 ) ) ; UTF_END ; } if ( edata -> internalpos > 0 ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewIntObj ( edata -> internalpos ) ) ; } if ( edata -> filename ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> filename ) , -1 ) ) ; UTF_END ; } if ( edata -> lineno > 0 ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewIntObj ( edata -> lineno ) ) ; } if ( edata -> funcname ) { Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( " " , -1 ) ) ; UTF_BEGIN ; Tcl_ListObjAppendElement ( interp , obj , Tcl_NewStringObj ( UTF_E2U ( edata -> funcname ) , -1 ) ) ; UTF_END ; } Tcl_SetObjErrorCode ( interp , obj ) ; }
pltcl_construct_errorCode()          - construct a Tcl errorCode
              list with detailed information from the PostgreSQL server
pltcl_construct_errorCode () - construct a Tcl errorCode list with detailed information from the PostgreSQL server
/* cursorpos is never interesting here; report internal query/pos */