diesel-rs / diesel_full_text_search

MIT License
69 stars 33 forks source link

TsConfiguration integer values cause cache miss #39

Open jakob-lilliemarck opened 1 year ago

jakob-lilliemarck commented 1 year ago

While trying to insert a row using a struct with a TsConfiguration field, i run into the following error:

cache lookup failed for text search configuration 12832

The issue seems to be the integer value doesn't refer to any regconfig oid on my system. I used to following query to check which valid regconfig oid values exist:

SELECT oid, cfgname FROM pg_ts_config;

That returned:

3748    simple
13156   arabic
13158   armenian
13160   basque
13162   catalan
13164   danish
13166   dutch
13168   english
13170   finnish
13172   french
13174   german
13176   greek
13178   hindi
13180   hungarian
13182   indonesian
13184   irish
13186   italian
13188   lithuanian
13190   nepali
13192   norwegian
13194   portuguese
13196   romanian
13198   russian
13200   serbian
13202   spanish
13204   swedish
13206   tamil
13208   turkish
13210   yiddish

Using any of those integers directly in an INSERT like below works just fine, but if I use the integers defined on the TsConfiguration in this crate then I run into just the same issue as I get while running the query through rust & diesel.

INSERT INTO tag(name, description, lang, is_public)
VALUES ('test-lang', 'this is my english description', 13178, false);

I'm using postgres version:

psql (PostgreSQL) 15.3

I'm unsure if these oid values are expected to vary across different systems or if they can be expected to be the same, atleast with major versions, I'll try and look into it. If oid integers are not consistent or are expected to change often or , perhaps using a string value for inserting TsConfiguration would be more stable?

jakob-lilliemarck commented 1 year ago

I ran the query on another machine using postgres 14.9 and then the integer oid integers were different than in the above result for postgres 15.3. I guess that's not very unexpected given there's a major version in between.

A third attempt running it on my server using postgres:

psql (PostgreSQL) 15.4 (Debian 15.4-1.pgdg110+1)

I get the following list, which is also different altough there's no major version change:

  oid  |  cfgname   
-------+------------
  3748 | simple
 13131 | arabic
 13133 | armenian
 13135 | basque
 13137 | catalan
 13139 | danish
 13141 | dutch
 13143 | english
 13145 | finnish
 13147 | french
 13149 | german
 13151 | greek
 13153 | hindi
 13155 | hungarian
 13157 | indonesian
 13159 | irish
 13161 | italian
 13163 | lithuanian
 13165 | nepali
 13167 | norwegian
 13169 | portuguese
 13171 | romanian
 13173 | russian
 13175 | serbian
 13177 | spanish
 13179 | swedish
 13181 | tamil
 13183 | turkish
 13185 | yiddish

That leads me to believe the integer values of the regconfig oid are not very stable :thinking: and that representing them as string values in rust code is possible will be less sensitive.