Search Postgresql Archives

Calling a SQL function inside a C function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



How do I call a function defined using CREATE FUNCTION in SQL inside a C function in an extension? I feel this should be possible as the query parser is able to resolve the function names and arguments in a raw string query. I want to know if there is a standard way to look up for user-defined functions in the backend.

For example, I have a function defined in SQL:

```
CREATE FUNCTION times_two(x integer)
RETURNS integer AS $$
SELECT x*2
$$ LANGUAGE SQL;
```

Now I wish to call `times_two()` in a C extension similar to:

```
// Look up for the user-defined function times_two()
// ...

// Use the function.
Datum ret = DirectFunctionCall(times_two, Int32GetDatum(13));
```

Best,
Eric

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux