2

I created a new age_date() function using the following SQL and C code:

SQL:

CREATE FUNCTION ag_catalog.age_date()
RETURNS cstring
LANGUAGE c
STABLE
PARALLEL SAFE
AS 'MODULE_PATHNAME';

C Code:

Datum age_date(PG_FUNCTION_ARGS) {
  // Program Logic
}

After stopping and restarting the server, I attempted to run this function within a cypher query. However, I encountered an error stating that the function does not exist.

9 Answers9

1

Try make distclean on age and then re-install it. After that load it again in postgres and try again

0

When modifying the C code, the changes will take effect immediately upon restarting the server. However, when altering the SQL file, a server restart is required, along with dropping and recreating the extension.

Execute the following commands:

  • DROP EXTENSION age;

    Restart the server

  • CREATE EXTENSION age;

  • LOAD 'age';

  • SET search_path TO ag_catalog;

I hope this resolves the issue.

Mohayu Din
  • 433
  • 9
0

You have to run make install again after changing anything in the repo like adding or modifying functions for them to take effect.

Further you should run install check as well to see if it breaks anything.

Then as pointed out in other answers, you have to drop the extension and reload it.

Hope this helps!

han
  • 74
  • 7
0

It could be a number of reasons.

Did you compile and reinstalled the extension?

It could be that you forgotten the function registration above the function:

PG_FUNCTION_INFO_V1(age_date);

Datum age_date(PG_FUNCTION_ARGS) {
  // Program Logic
}

Either that, or you may be calling the function wrongly, which should be

SELECT ag_catalog.age_date;
-- or
SELECT ag_catalog.age_date();

Also, you may need to drop extension and creating it again if you altered the .sql file.

Please add more details so we can help you more assertively.

MarkSoulz
  • 33
  • 4
0

If you are writing function in new "C" file then you need to modify "MAKEFILE" as well.

Here is what to do:

#add the folloing line to the OBJS 
src/path/to/file/new_file_name.o 

Next, "clean" & "install" it again:

sudo make clean PG_CONFIG=/usr/local/pgsql/bin/pg_config
make PG_CONFIG=/usr/local/pgsql/bin/pg_config
make install PG_CONFIG=/usr/local/pgsql/bin/pg_config

Reference: https://dev.to/rrrokhtar/guide-to-age-contribution-and-modifying-the-source-code-to-add-new-functions-l7m

Huzaifa
  • 484
  • 4
  • 8
0

Sometimes these types of changes are only valid for the current session.

You would have to make them again after restarting.

For a permanent change, make respective changes in configuration files like postgresql.conf. But sometimes these revert too.

0

If you make any changes in the repository, such as adding or modifying functions, you need to run "make install" again for the changes to take effect.

Marcos Silva
  • 115
  • 5
0

You need to run make install command for the changes to take effect. Sometimes changes like these are only valid for the current session. If you have restarted the server, you may need to recreate the function again after the restart. This means re-executing the SQL code and C code to define the age_date() function. For a permanent change, you can consider modifying the configuration files 'postgresql.conf'.

Abdul Manan
  • 117
  • 5
0

You have created a new function age_date() so you need to run the make install command after that function addition and restart the server again.

adil shahid
  • 125
  • 4