英文:
Age Go Driver Error on Windows: function age_prepare_cypher(unknown, unknown) does not exist
问题
我正在尝试在Windows上使用golang驱动程序来运行Apache Age的Cypher查询。
对于Postgres服务器,我正在使用Apache-Age Docker镜像。
在运行示例时,我遇到了以下错误:
ahmar> go run main.go age_wrapper_sample.go sql_api_sample.go
# Do cypher query with Age API
SELECT * FROM age_prepare_cypher($1, $2); testGraph CREATE (n:Person {name: '%s'})
panic: pq: function age_prepare_cypher(unknown, unknown) does not exist
goroutine 1 [running]:
main.doWithAgeWrapper({0x1004e94?, 0xc00000a018?}, {0xff0efb?, 0x1?})
C:/Users/ahmar/Desktop/GOlang drivers/samples/age_wrapper_sample.go:43 +0xcb4
main.main()
C:/Users/ahmar/Desktop/GOlang drivers/samples/main.go:41 +0x77
exit status 2
当我直接在Postgres服务器上运行这些查询时,它们可以正常工作。而且,其他的age命令,如LOAD 'age';
等,也可以从驱动程序中正常工作,但是ExecCypher()
函数却无法工作。
错误似乎是在age.go
文件的execCypher()
函数中发生的,当调用age_prepare_cypher()
函数时。
注意:我在Linux上没有遇到这个错误。在那里,使用age go驱动程序运行查询时一切正常,并且我得到了预期的输出。
英文:
I'm trying to use the golang driver for apache age to run cypher queries on Windows.
For the postgres server I'm using the the Apache-Age docker image.
While running the sample, I get the following error:
ahmar> go run main.go age_wrapper_sample.go sql_api_sample.go
# Do cypher query with Age API
SELECT * FROM age_prepare_cypher($1, $2); testGraph CREATE (n:Person {name: '%s'})
panic: pq: function age_prepare_cypher(unknown, unknown) does not exist
goroutine 1 [running]:
main.doWithAgeWrapper({0x1004e94?, 0xc00000a018?}, {0xff0efb?, 0x1?})
C:/Users/ahmar/Desktop/GOlang drivers/samples/age_wrapper_sample.go:43 +0xcb4
main.main()
C:/Users/ahmar/Desktop/GOlang drivers/samples/main.go:41 +0x77
exit status 2
The queries are working fine when I run them on the postgres server directly. Also other age commands like LOAD 'age';
etc, are working from the driver but the ExecCypher()
function is not working.
The error seems to be originating from the age.go
file in execCypher()
, when the age_prepare_cypher()
function is called.
Note: I'm not facing this error on Linux. There, the queries are working fine when using the age go driver and I'm getting the expected output.
答案1
得分: 1
最近在这个提交中添加了age_prepare_cypher
函数。但它没有添加到apache/age:v1.1.0
镜像中。因此,如果你在提交42f94e7f36dc084b74ec335536a18173c6fca4cd上运行示例,并连接到由apache/age:v1.1.0
镜像提供的数据库,你将会得到错误信息panic: pq: function age_prepare_cypher(unknown, unknown) does not exist
。
我使用以下命令运行容器:
docker run \
--name age \
-p 5432:5432 \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=agens \
-e POSTGRES_DB=postgres \
-d \
apache/age:v1.1.0
然后在提交42f94e7f36dc084b74ec335536a18173c6fca4cd上运行示例,没有做任何更改:
$ go run main.go age_wrapper_sample.go sql_api_sample.go
# Do cypher query with SQL API
SELECT * FROM age_prepare_cypher($1, $2); testGraph CREATE (n:Person {name: '%s', weight:%f})
panic: pq: function age_prepare_cypher(unknown, unknown) does not exist
你可以看到sql_api_sample首先失败了,而在你的问题中,只有age_wrapper_sample失败了。所以看起来你已经修改了源代码,这两个示例连接到了不同的数据库。请仔细检查失败示例连接的是哪个数据库,并查看该数据库中是否定义了该函数。你可以使用\df
命令来检查函数是否存在。当函数不存在时,输出如下:
postgres=# \df ag_catalog.age_prepare_cypher
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+------+------------------+---------------------+------
(0 rows)
如果不是这种情况,请描述重现问题的确切步骤。谢谢!
英文:
The function age_prepare_cypher
was added recently in this commit. It's not added to the image apache/age:v1.1.0
. So if you run the sample at the commit 42f94e7f36dc084b74ec335536a18173c6fca4cd and connect to the database provided by the image apache/age:v1.1.0
, you will get the error panic: pq: function age_prepare_cypher(unknown, unknown) does not exist
.
I run the container with this command:
docker run \
--name age \
-p 5432:5432 \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=agens \
-e POSTGRES_DB=postgres \
-d \
apache/age:v1.1.0
And then run the sample at the commit 42f94e7f36dc084b74ec335536a18173c6fca4cd without any change:
$ go run main.go age_wrapper_sample.go sql_api_sample.go
# Do cypher query with SQL API
SELECT * FROM age_prepare_cypher($1, $2); testGraph CREATE (n:Person {name: '%s', weight:%f})
panic: pq: function age_prepare_cypher(unknown, unknown) does not exist
You see that the sql_api_sample fails first; while in your question, only the age_wrapper_sample fails. So it seems that you have modified the source code and the two examples connect to different databases. Please check carefully which database the failed example connecting to, and see whether the function is defined in that database. You can check the existence of a function with \df
. Here is the output when the functions is not found:
postgres=# \df ag_catalog.age_prepare_cypher
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+------+------------------+---------------------+------
(0 rows)
If this is not the case, please describe the exact steps to reproduce the issue. Thank you!
答案2
得分: 1
您可能正在使用一个旧的 Docker 镜像,该镜像中没有 age_prepare_cypher()
函数。我在 Windows 上使用最新的 Docker 镜像测试了 Go 驱动程序示例,它可以正常工作。
我还检查了这个 Docker 镜像中是否存在 age_prepare_cypher()
函数。
postgresDB=# \df ag_catalog.age_prepare_cypher
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+--------------------+------------------+---------------------+------
ag_catalog | age_prepare_cypher | boolean | cstring, cstring | func
(1 row)
英文:
You might be using an old docker image which does not have age_prepare_cypher()
function.
I tested the go driver sample on windows using the latest docker image and it was working fine.
go run main.go age_wrapper_sample.go sql_api_sample.go ﳑ00:52:12
# Do cypher query with SQL API
844424930131969 Person map[name:Joe weight:67.3]
844424930131970 Person map[name:Jack roles:[Dev marketing] weight:77.3]
844424930131971 Person map[name:Andy weight:59]
V{id:844424930131970, label:Person, props:map[name:Jack roles:[Dev marketing] weight:77.3]} E{id:1125899906842625, label:workWith, start:844424930131970, end:844424930131969, props:map[weight:3]} V{id:844424930131969, label:Person, props:map[name:Joe weight:67.3]}
V{id:844424930131971, label:Person, props:map[name:Andy weight:59]} E{id:1125899906842626, label:workWith, start:844424930131969, end:844424930131971, props:map[weight:7]} V{id:844424930131969, label:Person, props:map[name:Joe weight:67.3]}
V{id:844424930131969, label:Person, props:map[name:Joe weight:67.3]} E{id:1125899906842625, label:workWith, start:844424930131970, end:844424930131969, props:map[weight:3]} V{id:844424930131970, label:Person, props:map[name:Jack roles:[Dev marketing] weight:77.3]}
V{id:844424930131969, label:Person, props:map[name:Joe weight:67.3]} E{id:1125899906842626, label:workWith, start:844424930131969, end:844424930131971, props:map[weight:7]} V{id:844424930131971, label:Person, props:map[name:Andy weight:59]}
ROW 1 >>
V{id:844424930131969, label:Person, props:map[name:Joe weight:67.3]}
E{id:1125899906842625, label:workWith, start:844424930131970, end:844424930131969, props:map[weight:3]}
V{id:844424930131970, label:Person, props:map[name:Jack roles:[Dev marketing] weight:77.3]}
.....
I also checked that age_prepare_cypher()
function is present in this docker image.
postgresDB=# \df ag_catalog.age_prepare_cypher
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+--------------------+------------------+---------------------+------
ag_catalog | age_prepare_cypher | boolean | cstring, cstring | func
(1 row)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论