Hi,
The debugger, when it is invoked on a function or a procedure, provides a
dialogue box to fill up values for the arguments. In case the user has
created them with some default values assigned to some of the parameters,
then they would expect that the debugger pre-populates them with those
default values. This is not happening currently.
The attached patch provides this functionality.
We check if the "argdefvals" column exists in the output for the func/proc.
If it does, it gets tokenized and added to the corresponding wsArgInfo
object. These values then get displayed appropriately.
One side-effect of this feature is that earlier where non-default variables
appeared as empty, they will now appear with values "". This will happen
only if some arguments have defvals and some don't. We could have added code
to do away with "" entries, but then I thought it is possible for people to
provide "" as default values too. So we can live with this I think..
Regards,
Nikhils
diff --git a/pgadmin/debugger/dbgTargetInfo.cpp b/pgadmin/debugger/dbgTargetInfo.cpp
index fe50297..4016981 100644
--- a/pgadmin/debugger/dbgTargetInfo.cpp
+++ b/pgadmin/debugger/dbgTargetInfo.cpp
@@ -32,6 +32,7 @@ WX_DEFINE_OBJARRAY( wsArgInfoArray );
#define COL_ARG_MODES "argmodes"
#define COL_ARG_TYPES "argtypenames"
#define COL_ARG_TYPEOIDS "argtypeoids"
+#define COL_ARG_DEFVALS "argdefvals"
#define COL_IS_FUNCTION "isfunc"
#define COL_TARGET_OID "target"
#define COL_PACKAGE_OID "pkg"
@@ -86,6 +87,10 @@ dbgTargetInfo::dbgTargetInfo( const wxString &target, dbgPgConn *conn, char tar
m_argTypes = result->getString( wxString(COL_ARG_TYPES, wxConvUTF8));
m_argTypeOids = result->getString( wxString(COL_ARG_TYPEOIDS, wxConvUTF8));
+ // get arg defvals if they exist
+ if (result->columnExists(wxString(COL_ARG_DEFVALS, wxConvUTF8)))
+ m_argDefVals = result->getString( wxString(COL_ARG_DEFVALS, wxConvUTF8));
+
if (result->columnExists(wxString(COL_PACKAGE_OID, wxConvUTF8)))
m_isFunction = result->getBool( wxString(COL_IS_FUNCTION, wxConvUTF8));
else
@@ -112,6 +117,7 @@ dbgTargetInfo::dbgTargetInfo( const wxString &target, dbgPgConn *conn, char tar
wxStringTokenizer types(m_argTypes, wxT( ",{}" ), wxTOKEN_STRTOK);
wxStringTokenizer typeOids(m_argTypeOids, wxT( ",{}" ), wxTOKEN_STRTOK);
wxStringTokenizer modes(m_argModes, wxT( ",{}" ), wxTOKEN_STRTOK);
+ wxStringTokenizer defvals(m_argDefVals, wxT( ",{}" ), wxTOKEN_STRTOK);
// Create one wsArgInfo for each target argument
@@ -136,6 +142,12 @@ dbgTargetInfo::dbgTargetInfo( const wxString &target, dbgPgConn *conn, char tar
else if( argInfo.getMode() == wxT( "b" ))
m_argInOutCount++;
+ // see if this arg has a def value and add if so. If we see an empty
+ // string "", what should we do? Infact "" might be a valid default
+ // value in some cases, so for now store "" too. Note that this will
+ // occur only if some args have defvals and some don't.
+ argInfo.setValue( (defvals.GetNextToken()).Strip( wxString::both ));
+
m_argInfo.Add( argInfo );
}
diff --git a/pgadmin/debugger/dlgDirectDbg.cpp b/pgadmin/debugger/dlgDirectDbg.cpp
index c3f6240..be31dbe 100644
--- a/pgadmin/debugger/dlgDirectDbg.cpp
+++ b/pgadmin/debugger/dlgDirectDbg.cpp
@@ -783,10 +783,15 @@ void dlgDirectDbg::OnTargetComplete( wxCommandEvent &event )
char *state = PQresultErrorField(result, PG_DIAG_SQLSTATE);
// Don't bother telling the user that he aborted - he already knows!
- if (state != NULL && strcmp(state, "57014"))
- wxLogError( wxT( "%s\n" ), wxString(PQerrorMessage(m_conn->getConnection()), wxConvUTF8).c_str());
- else
- wxLogInfo( wxT( "%s\n" ), wxString(PQerrorMessage(m_conn->getConnection()), wxConvUTF8).c_str());
+ // Depending on the stage, m_conn might not be set all! so check for
+ // that first
+ if (m_conn)
+ {
+ if (state != NULL && strcmp(state, "57014"))
+ wxLogError( wxT( "%s\n" ), wxString(PQerrorMessage(m_conn->getConnection()), wxConvUTF8).c_str());
+ else
+ wxLogInfo( wxT( "%s\n" ), wxString(PQerrorMessage(m_conn->getConnection()), wxConvUTF8).c_str());
+ }
}
else
{
diff --git a/pgadmin/include/debugger/dbgTargetInfo.h b/pgadmin/include/debugger/dbgTargetInfo.h
index e3fb9f8..db2edd5 100644
--- a/pgadmin/include/debugger/dbgTargetInfo.h
+++ b/pgadmin/include/debugger/dbgTargetInfo.h
@@ -157,6 +157,7 @@ private:
wxString m_argModes; // Argument modes
wxString m_argTypes; // Argument types
wxString m_argTypeOids; // Argument type OIDs
+ wxString m_argDefVals; // Argument default values
wxString m_fqName; // Fully-qualified name (schema.package.func or package.func)
wxString m_returnType;// Return type
bool m_isFunction; // true->target is a function, false->target is a procedure
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers