-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add v2.2 install sql,so will not update from 2.1 to 2.2 and get error…
… when run 2.1 sql for tablespace involved
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
CREATE FUNCTION zhprs_start(internal, int4) | ||
RETURNS internal | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; | ||
|
||
CREATE FUNCTION zhprs_getlexeme(internal, internal, internal) | ||
RETURNS internal | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; | ||
|
||
CREATE FUNCTION zhprs_end(internal) | ||
RETURNS void | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; | ||
|
||
CREATE FUNCTION zhprs_lextype(internal) | ||
RETURNS internal | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; | ||
|
||
CREATE TEXT SEARCH PARSER zhparser ( | ||
START = zhprs_start, | ||
GETTOKEN = zhprs_getlexeme, | ||
END = zhprs_end, | ||
HEADLINE = pg_catalog.prsd_headline, | ||
LEXTYPES = zhprs_lextype | ||
); | ||
|
||
|
||
CREATE SCHEMA zhparser; | ||
CREATE TABLE zhparser.zhprs_custom_word(word text primary key, tf float default '1.0', idf float default '1.0', attr char default '@', check(attr = '@' or attr = '!')); | ||
|
||
CREATE FUNCTION sync_zhprs_custom_word() RETURNS void LANGUAGE plpgsql AS | ||
$$ | ||
declare | ||
database_oid text; | ||
data_dir text; | ||
dict_path text; | ||
time_tag_path text; | ||
query text; | ||
begin | ||
select setting from pg_settings where name='data_directory' into data_dir; | ||
|
||
select data_dir || '/base/' || '/zhprs_dict_' || current_database() || '.txt' into dict_path; | ||
select data_dir || '/base/' || '/zhprs_dict_' || current_database() || '.tag' into time_tag_path; | ||
|
||
query = 'copy (select word, tf, idf, attr from zhparser.zhprs_custom_word) to ' || chr(39) || dict_path || chr(39) || ' encoding ' || chr(39) || 'utf8' || chr(39) ; | ||
execute query; | ||
query = 'copy (select now()) to ' || chr(39) || time_tag_path || chr(39) ; | ||
execute query; | ||
end; | ||
$$; | ||
|
||
select sync_zhprs_custom_word(); |