amutu / zhparser

zhparser is a PostgreSQL extension for full-text search of Chinese language
Other
719 stars 86 forks source link

貌似如果数据库没有建立在默认位置,创建插件时会报错,找不到文件 #80

Closed CanYellow closed 9 months ago

CanYellow commented 1 year ago

Problem

When in my wikidb database. I already ALTER USER wikijs WITH SUPERUSER; and double enter the psql console. But I run CREATE EXTENSION zhparser;, it throw error as:

wikidb=# CREATE EXTENSION pg trgm;
ERROR: extension "pg trgm” already exists
wikidb=# CREATE EXTENSION zhparser;
ERROR: could not open file "/var/lib/postgresql/14/main/base/16387/zhprs dict wikidb.txt"f writing: No such file or directory
HINT: COPY TO instructs the Postgresol server process to write a file. You may want a clientside facility such as psql's copy.
ONTEXT: SOL statement "copy (select word, tf, idf, attr from zhparser.zhprs custom word) tc'/var/lib/postgresql/14/main/base/16387/zhprs_dict wikidb.txt’ encoding 'utf8"L/pgsoL function sync zhprs custom word() line 17 at EXECUTE

What I tried

https://github.com/amutu/zhparser/issues/33 said it is a user permission problem. but my folder in in the postgres folder. i checked the permission with ls -a -l, permission result is OK in my opinion.

postgres@brighthserver:~$ ls -a -l /var/lib/postgresql/14/main/base
total 20
drwX------5 postgres postgres 4096 0ct 18 09:19
drwX------19 postgres postgres 4096 0ct 16 13:58
drwX------2 postgrespostgres 4096 0ct 16 13:59 1
drwx------2 postgres postgres 4996 0ct 15 13:50 13760
drwX------2 postgres postgres 4096 0ct 17 12:20 13761

My question

I thought there was no permission problem in my database folder, But why psql still said 'could not open file'? May anyone professional know what's wrong with my process, or give my some suggestion?

thank you very much!

CanYellow commented 1 year ago

Amendment

https://github.com/amutu/zhparser/issues/41 filed a similar problem. But it seemed the patch was merged to master branch. I am still courious about the problem , and wish help from you. Thank you.

CanYellow commented 1 year ago

I tested some example in my local server. I thought I got the root cause, but the solution is beyond my ability.

As I tested on my local server. I create my database in a user defined tablespace, not in default space, maybe it's why zhparser could not find file.

here is some info for you to analysis.

the error info:

wikidb=# CREATE EXTENSION zhparser;
ERROR:  could not open file "/var/lib/postgresql/14/main/base/16387/zhprs_dict_wikidb.txt" for writing: No such file or directory

the defalut postgresql data directory tree:

postgres@brighthserver:~$ ls /var/lib/postgresql/14/main/base/
1  13760  13761

the directory tree in my ext disk(where tablespace defined)

postgres@brighthserver:~$ ls /mnt/filedisk/postgresql/PG_14_202107181/
16387

Could anybody get some solution for that, I am very appreciate for you help.

CanYellow commented 1 year ago

我自己修改了两个文件里的内容,加入了我的数据库的实际路径,让zhparser在我的情况下安装完成了,但是好像不具有普适性。希望大佬们看看是不是需要更新下版本,解决类似的问题。谢谢啦、

我修改了 zhparser--2.1.sql 与 zhparser--2.0--2.1.sql,将里面 的data_dir || '/base/' 改成了我的实际数据库路径'/mnt/filedisk/postgresql/PG_14_202107181/'

amutu commented 9 months ago

fixed at f9381aba2c16f0bedb3e17f840c2e774108b7430