新创建的 age_date() 函数在 Cypher 查询中未被识别。

huangapple go评论59阅读模式
英文:

Newly Created age_date() Function Not Recognized in Cypher Query

问题

我使用以下的SQL和C代码创建了一个新的age_date()函数:

SQL:

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

C代码:

Datum age_date(PG_FUNCTION_ARGS) {
  // 程序逻辑
}

在停止并重新启动服务器后,我尝试在cypher查询中运行此函数。然而,我遇到了一个错误,指出该函数不存在。

英文:

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.

答案1

得分: 1

尝试在age上运行make distclean,然后重新安装它。然后在PostgreSQL中再次加载它,然后再次尝试。

英文:

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

答案2

得分: 0

当修改 C 代码时,在重新启动服务器后,更改将立即生效。但是,如果要修改 SQL 文件,则需要重新启动服务器,同时需要删除并重新创建扩展。

执行以下命令:

  • 删除扩展 age;

    重新启动服务器

  • 创建扩展 age;

  • 加载 'age';

  • 设置搜索路径为 ag_catalog;

我希望这可以解决问题。

英文:

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.

答案3

得分: 0

你必须在更改存储库中的任何内容后再次运行make install,例如添加或修改函数,以使其生效。

此外,您还应该运行安装检查,以查看是否会出现任何问题。

然后,如其他答案所指出的,您必须删除扩展并重新加载它。

希望这有所帮助!

英文:

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!

答案4

得分: 0

以下是翻译好的部分:

  • 可能有多种原因。
  • 您是否编译并重新安装了扩展?
  • 可能是您忘记在函数之上进行函数注册:
    PG_FUNCTION_INFO_V1(age_date);
    
    Datum age_date(PG_FUNCTION_ARGS) {
      // 程序逻辑
    }
    
  • 要么是您可能错误调用了函数,应该是:
    SELECT ag_catalog.age_date;
    -- 或者
    SELECT ag_catalog.age_date();
    
  • 此外,如果您修改了 .sql 文件,可能需要删除扩展并再次创建它。

请提供更多详细信息,以便我们可以更有把握地帮助您。

英文:

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.

答案5

得分: 0

如果您正在编写新的"C"文件中的函数,则还需要修改"MAKEFILE"。以下是要执行的步骤:

#将以下行添加到OBJS中
src/path/to/file/new_file_name.o

接下来,再次运行"clean"和"install":

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

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

英文:

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

答案6

得分: 0

有时这些更改只对当前会话有效。

重启后,您需要再次进行这些更改。

要进行永久更改,请在配置文件(如postgresql.conf)中进行相应更改。但有时这些更改也会被还原。

英文:

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.

答案7

得分: 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."

英文:

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.

答案8

得分: 0

你需要运行make install命令以使更改生效。有时类似这样的更改仅在当前会话中有效。如果您已重新启动服务器,可能需要在重新启动后重新创建该函数。这意味着重新执行SQL代码和C代码来定义age_date()函数。
要进行永久更改,您可以考虑修改配置文件'postgresql.conf'。

英文:

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'.

答案9

得分: 0

你已经创建了一个新函数 age_date(),所以在添加该函数后,需要运行 make install 命令,然后再次重启服务器。

英文:

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.

huangapple
  • 本文由 发表于 2023年5月29日 20:43:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76357494.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定