Hi Martin,

I create custom function signatures with a createdb/functions.sql script.

Now say that 20 projects are running Spinque release 1.2.3 (several Spinque releases can be based on the same official MonetDB release).
I make a new release 1.2.4, where my UDF signatures change.

By simply upgrading the existing MonetDB deployments, the script won't be loaded, so I will have old signatures for new implementations, possibly breaking everything.

I don't think it's fair to say that this should be handled by an application. It has to do with internal consistency. If I change an implementation, I should be able to change the signature as part of a MonetDB upgrade, it has nothing to do with applications. Just as MonetDB allows to upgrade from a previous release with incompatible catalog. In other words, now MonetDB is allowing me to break it.
I know it's not SQL standard. Still, many DB vendors have this, because it's useful.

What I did so far is to manually run that script on all 20 projects right after they are upgraded.

In a previous conversation in this channel, Sjoerd has made clear that there currently is no mechanism to run a SQL script at every MonetDB restart.

What I did recently is to tap in SQLinit() and add that possibility. For a quick PoC I did it for just the one script I need and hard-coded its name.

That works, because my script has lots of CREATE OR REPLACE FUNCTION. So every time they get recreated. I was hoping to avoid that recreation though, and that's why I was looking for conditional DDL. Then I can check the internal (Spinque) release and run recreate those functions only upon a release change.

Roberto




On Wed, 22 Apr 2020 at 18:01, Martin van Dinther <dinther@monetdbsolutions.com> wrote:
It is not possible in MonetDB SQL. Also not in the SQL standard.
You will need to do such conditional DDL statements from an external
program/script.

Normally you would create all DB objects (schemas, tables, views,
functions, procedures, etc) once (as monetdb admin) and next use/call
them from your application.
Is it not possible in your case to create all the needed functions once
upfront?
Why do you need to create them conditionally?

Martin vD

On 22-04-2020 15:58, Roberto Cornacchia wrote:
> Hi,
>
> I am afraid I know the answer to this already ("not supported"), but I
> wanted to check with you guys. Perhaps someone has smart workaround?
>
> Essentially what I would like to do is something like:
>
> IF condition THEN CREATE FUNCTION ....;
>
> As far as I know, flow control statements are only allowed inside
> functions/procedures.
> However, CREATE statements are not allowed inside functions/procedure.
> So I don't see any way to do what I wrote above.
>
> Notice, I am aware of CREATE OR REPLACE. What I'm looking for is an
> arbitrary condition test.
>
> Any trick? And/or, any plan to implement something in this direction?
>
> Roberto
>
>
> _______________________________________________
> users-list mailing list
> users-list@monetdb.org
> https://www.monetdb.org/mailman/listinfo/users-list
>
_______________________________________________
users-list mailing list
users-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/users-list