Windows上的Age Go驱动程序错误:函数age_prepare_cypher(未知,未知)不存在

kyxcudwk  于 2023-04-03  发布在  Go
关注(0)|答案(2)|浏览(133)

我尝试使用golang driver for apache age在Windows上运行密码查询。对于postgres服务器,我使用Apache-Age docker image
在运行sample时,我得到以下错误:

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服务器上运行它们时,查询工作正常。还有其他的年龄命令,如LOAD 'age';等,可以从驱动程序**工作,但ExecCypher()函数不工作。
当调用age_prepare_cypher()函数时,错误似乎源自execCypher()中的age.go文件。
注意:我在Linux上没有遇到这个错误。在那里,当使用age go驱动程序时,查询工作正常,我得到了预期的输出。

xdnvmnnf

xdnvmnnf1#

函数age_prepare_cypher是最近在this commit中添加的。它没有添加到图像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)

如果不是这样,请描述重现问题的确切步骤。谢谢!

pkwftd7m

pkwftd7m2#

你可能使用的是一个旧的docker镜像,它没有age_prepare_cypher()功能。我在windows上使用latest docker image测试了go驱动程序示例,它工作得很好。

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]}
.....

我还检查了age_prepare_cypher()函数是否存在于这个docker镜像中。

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)

相关问题