Syntax error when trying to drop function in postgresql (pgsql)

[expired user #8705]'s profile image [expired user #8705] posted 9 years ago in General Permalink
I'm using GUI (right click -> drop) but I also tried to copy DROP FUNCTION to the query window, same result.


[expired user #8705]'s profile image [expired user #8705] posted 9 years ago Permalink
Also when trying to save a function using editor

ansgar's profile image ansgar posted 9 years ago Permalink
Yes, the function editor has much MySQL stuff in it. But information_schema.routines should exist on PostgreSQL too, or?

The "DROP FUNCTION xyz" is MySQL and PostgreSQL syntax, according to the documentation. Which server version is it on your side? Probably we need a version conditional here.
[expired user #8705]'s profile image [expired user #8705] posted 9 years ago Permalink
Version is 9.1

About the drop function, I found out that the problem is that it expects the parameters to be given. So not DROP FUNCTION func_name; but DROP FUNCTION func_name(param_type);

The routines table do exist in information_schema.
ansgar's profile image ansgar posted 9 years ago Permalink
Ah.. I guess PostgreSQL supports function overloading, and you can have two functions with the same name but different parameters:
* func_name(xyz INT)
* func_name(xyz TEXT)

Means I have to append the parameter declaration to the DROP query.
[expired user #8705]'s profile image [expired user #8705] posted 9 years ago Permalink
Precisely, it does support it. Alrighty. I clearly understand that pgsql is experimental and not your priority. You developed a wonderful software.

Also for some reason function editor says that "CREATE code" that
CREATE FUNCTION "check1a"("student_id" UNKNOWN)
where it should be
CREATE FUNCTION "check1a"("student_id" VARCHAR(5))
so it incorrectly recognizes the data type, without it, you won't be able to drop function properly. Same happens (also shows UNKNOWN) in "Parameters" tab
Code modification/commit from ansgarbecker, 9 years ago, revision 9.1.0.4943
Support dropping functions and procedures on PostgreSQL, which requires the parameters list in parentheses. See http://www.heidisql.com/forum.php?t=18198
ansgar's profile image ansgar posted 9 years ago Permalink
r4943 now adds the parameters list to the DROP FUNCTION query.

This also solves another problem:
* Very first and very last parameters in PG function were never detected. This most probably includes your VARCHAR(5) parameter.

Unfortunately, this does not yet solve another problem:
* HeidiSQL always uses the first physically available function, when having two or more functions with the same name but different parameters

Please login to leave a reply, or register at first.