首页 > 文章列表 > Age Go 驱动程序在Windows上出现错误:age_prepare_cypher函数不存在(未知,未知)

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

241 2024-02-05
问题内容

我正在尝试使用 apache age 的 golang 驱动程序在 windows 上运行密码查询。 对于 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 服务器上运行查询时,它们工作正常。另外,其他年龄命令(如 load 'age'; 等)正在从驱动程序运行,但 execcypher() 函数不起作用。

当调用 age_prepare_cypher() 函数时,该错误似乎源自 execcypher() 中的 age.go 文件。

注意:我在 linux 上没有遇到此错误。在那里,使用 age go 驱动程序时查询工作正常,并且我得到了预期的输出。


正确答案


最近在此提交中添加了函数 age_prepare_cypher 。它没有添加到图像 apache/age:v1.1.0 中。因此,如果您在提交 42f94e7f36dc084b74ec335536a18173c6fca4cd 处运行示例并连接到镜像 apache/age:v1.1.0 ,你会得到错误 panic: pq: function age_prepare_cypher(unknown,unknown) 不存在

我使用以下命令运行容器:

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)

如果情况并非如此,请描述重现该问题的确切步骤。谢谢!