Hi,
With the latest refactorings in the EDBAS90 source base, procedures (CREATE
PROCEDURE objects) can have non void return types in some cases. For
example:
edb=# create or replace procedure set_Order (
v_index INOUT integer
) AS
counter integer;
BEGIN
counter := 0;
v_index := counter;
END;
CREATE PROCEDURE
edb=# select protype, prorettype from pg_proc where proname = 'set_order';
protype | prorettype
---------+------------
1 | 23
Here the prorettype is "int4" and protype is set to 1 to indicate that this
is a procedure.
The existing pgadmin source currently expects procedures to have "void"
return types only. Now that the "protype" column (which can differentiate
between functions and procedures) is available since 8.1, we can use it to
identify such objects without resorting to "void" type checks. Ofcourse we
need to retain existing checks for older versions.
PFA, patch which does the same.
Regards,
Nikhils
diff --git a/pgadmin/schema/pgFunction.cpp b/pgadmin/schema/pgFunction.cpp
index e5537ce..d646d5f 100644
--- a/pgadmin/schema/pgFunction.cpp
+++ b/pgadmin/schema/pgFunction.cpp
@@ -648,7 +648,14 @@ pgFunction *pgFunctionFactory::AppendFunctions(pgObject *obj, pgSchema *schema,
wxString typname = functions->GetVal(wxT("typname"));
// Is this an EDB Stored Procedure?
- if (obj->GetConnection()->EdbMinimumVersion(8, 0) && lanname == wxT("edbspl") && typname == wxT("void"))
+ if (obj->GetConnection()->EdbMinimumVersion(8, 1))
+ {
+ wxString protype = functions->GetVal(wxT("protype"));
+ if (protype == wxT("1"))
+ isProcedure = true;
+ }
+ else if (obj->GetConnection()->EdbMinimumVersion(8, 0) &&
+ lanname == wxT("edbspl") && typname == wxT("void"))
isProcedure = true;
// Create the new object
@@ -950,7 +957,9 @@ pgObject *pgFunctionFactory::CreateObjects(pgCollection *collection, ctlTree *br
" WHERE proisagg = FALSE AND pronamespace = ") + NumToStr(collection->GetSchema()->GetOid())
+ wxT("::oid\n AND typname <> 'trigger'\n");
- if (collection->GetConnection()->EdbMinimumVersion(8, 0))
+ if (collection->GetConnection()->EdbMinimumVersion(8, 1))
+ funcRestriction += wxT(" AND NOT (lanname = 'edbspl' AND protype = 1)\n");
+ else if (collection->GetConnection()->EdbMinimumVersion(8, 0))
funcRestriction += wxT(" AND NOT (lanname = 'edbspl' AND typname = 'void')\n");
// Get the Functions
@@ -979,7 +988,12 @@ pgObject *pgProcedureFactory::CreateObjects(pgCollection *collection, ctlTree *b
{
wxString funcRestriction = wxT(
" WHERE proisagg = FALSE AND pronamespace = ") + NumToStr(collection->GetSchema()->GetOid())
- + wxT("::oid AND lanname = 'edbspl' AND typname = 'void'\n");
+ + wxT("::oid AND lanname = 'edbspl'\n");
+
+ if (collection->GetConnection()->EdbMinimumVersion(8, 1))
+ funcRestriction += wxT(" AND protype = 1\n");
+ else
+ funcRestriction += wxT(" AND typname = 'void'\n");
// Get the Functions
return AppendFunctions(collection, collection->GetSchema(), browser, funcRestriction);
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers