On Sun, Nov 21, 2021 at 7:15 PM Billy Zheng <[email protected]> wrote:
>
> Sad, in my ability, there is no way can reproduce this if not use
> zhparser.
>
Unfortunately, I won't be able to help debug in that case.
>
> i still consider some incompatible things exists when do UPDATE use
> DB.run on sequel, e.g. pg function, triggers or others,
> because use pg gem always work.
>
You can do:
DB.synchronize do |conn|
# conn here is the PG::Connection instance
end
I'm not sure why behavior would be different, but that is a simple way to
use the connection directly if you need to.
>
> the last try, maybe there exists some clue on "DB.run("SELECT
> sync_zhprs_custom_word();")"
>
> could you please check this function?
>
> ```
> CREATE or REPLACE FUNCTION sync_zhprs_custom_word() RETURNS void LANGUAGE
> plpgsql AS
> $$
> declare
> 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;
> $$;
>
> ```
>
This executes a query twice, maybe that has something to do with it?
> i think debug this issue is easy if we can know the exactly SQL send to
> pg when do `DB.run("????")`, if i can suppose it must not same as
> `pg_conn.exec("????")`, right? so, could you please help on print the real
> SQL when use with DB.run ?
>
In order not to block the interpreter, Sequel uses #async_exec and not
#exec on the PG::Connection. Perhaps that's the cause of the problem? Do
you get the same results as Sequel if you use #async_exec on the
PG::Connection (with #block afterward)?
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/CADGZSScCBhiCve83f2sxdKGW28gVCF%3D39iQKHinN5YDN%3DM2hZQ%40mail.gmail.com.