--- /dev/null
+BEGIN;
+
+SELECT plan(1);
+
+-- Attempt to insert an authority record that triggers the bug:
+SELECT lives_ok(
+$$INSERT INTO authority.record_entry
+(last_xact_id, heading, simple_heading, marc)
+VALUES
+('IMPORT-1337697309.74328',
+'100_-_lcsh a arenburg ile1ii ai d 1891 1967',
+'100 a arenburg ile1ii ai d 1891 1967',
+$_$<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns="http://www.loc.gov/MARC21/slim"><leader>09719cz a2200781n 4500</leader><controlfield tag="001">n 50030508 </controlfield><controlfield tag="003">DLC</controlfield><controlfield tag="005">20210213070057.0</controlfield><controlfield tag="008">800613n| azannaabn |b aaa </controlfield><datafield tag="010" ind1=" " ind2=" "><subfield code="a">n 50030508 </subfield></datafield><datafield tag="024" ind1="7" ind2=" "><subfield code="a">000000010813807X</subfield><subfield code="2">isni</subfield><subfield code="1">https://isni.org/isni/000000010813807X</subfield></datafield><datafield tag="024" ind1="7" ind2=" "><subfield code="a">40169930</subfield><subfield code="2">viaf</subfield><subfield code="1">http://www.viaf.org/viaf/40169930</subfield></datafield><datafield tag="024" ind1="7" ind2=" "><subfield code="a">Q348497</subfield><subfield code="2">wikidata</subfield><subfield code="1">http://www.wikidata.org/entity/Q348497</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(OCoLC)oca00065876</subfield></datafield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">DLC</subfield><subfield code="b">eng</subfield><subfield code="e">rda</subfield><subfield code="c">DLC</subfield><subfield code="d">DLC</subfield><subfield code="d">NjP</subfield><subfield code="d">DLC</subfield><subfield code="d">OCoLC</subfield><subfield code="d">InU</subfield><subfield code="d">CLU</subfield><subfield code="d">WU</subfield><subfield code="d">CLU</subfield></datafield><datafield tag="046" ind1=" " ind2=" "><subfield code="f">1891-01-27</subfield><subfield code="g">1967-08-31</subfield><subfield code="2">edtf</subfield></datafield><datafield tag="053" ind1=" " ind2="0"><subfield code="a">PG3476.E5</subfield></datafield><datafield tag="100" ind1="1" ind2=" "><subfield code="a">Ärenburg, Ilʹi︠a︡,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="370" ind1=" " ind2=" "><subfield code="c">Soviet Union</subfield><subfield code="2">naf</subfield><subfield code="0">http://id.loc.gov/authorities/names/n80126312</subfield><subfield code="1">http://id.loc.gov/rwo/agents/n80126312</subfield></datafield><datafield tag="370" ind1=" " ind2=" "><subfield code="a">Kyïv (Ukraine)</subfield><subfield code="2">naf</subfield><subfield code="0">http://id.loc.gov/authorities/names/n81022031</subfield><subfield code="1">http://id.loc.gov/rwo/agents/n81022031</subfield></datafield><datafield tag="370" ind1=" " ind2=" "><subfield code="c">Ukraine</subfield><subfield code="2">naf</subfield><subfield code="0">http://id.loc.gov/authorities/names/n81017756</subfield><subfield code="1">http://id.loc.gov/rwo/agents/n81017756</subfield></datafield><datafield tag="372" ind1=" " ind2=" "><subfield code="a">Journalism--Soviet Union</subfield><subfield code="2">lcsh</subfield><subfield code="0">http://id.loc.gov/authorities/subjects/sh2008106181</subfield></datafield><datafield tag="372" ind1=" " ind2=" "><subfield code="a">Russian literature</subfield><subfield code="2">lcsh</subfield><subfield code="0">http://id.loc.gov/authorities/subjects/sh85115986</subfield></datafield><datafield tag="372" ind1=" " ind2=" "><subfield code="a">Soviet literature</subfield><subfield code="2">lcsh</subfield><subfield code="0">http://id.loc.gov/authorities/subjects/sh85125831</subfield></datafield><datafield tag="374" ind1=" " ind2=" "><subfield code="a">Authors, Russian</subfield><subfield code="2">lcsh</subfield><subfield code="0">http://id.loc.gov/authorities/subjects/sh85009984</subfield></datafield><datafield tag="374" ind1=" " ind2=" "><subfield code="a">Journalists</subfield><subfield code="2">lcsh</subfield><subfield code="0">http://id.loc.gov/authorities/subjects/sh85070788</subfield></datafield><datafield tag="375" ind1=" " ind2=" "><subfield code="a">Males</subfield><subfield code="2">lcdgt</subfield></datafield><datafield tag="377" ind1=" " ind2=" "><subfield code="a">rus</subfield><subfield code="0">https://id.loc.gov/vocabulary/languages/rus</subfield></datafield><datafield tag="400" ind1="0" ind2=" "><subfield code="a">Ai-lun-pao,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="0" ind2=" "><subfield code="a">Ailunbao,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Ehrenbourg, Ilya,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="w">nnaa</subfield><subfield code="a">Ehrenburg, Ilʹi︠a︡ Grigorʹevich,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Ehrenburg, Ilja,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Ehrenburg, Ilya,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Ehrenburg, Ilya Grigorievich,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Ehrenburg, Ilya Grigoryevich,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Ärenburg, I.</subfield><subfield code="q">(Ilʹi︠a︡),</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Ärenburg, Ilʹi︠a︡ Grigorʹevich,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Erenburg, Ilya,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Erenburg, Ilyah,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">Erenmpourgk, Älia,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">ЭÑенбÑÑг, Ð.</subfield><subfield code="q">(ÐлÑÑ),</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">ЭÑенбÑÑг, ÐлÑÑ,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">ЭÑенбÑÑг, ÐлÑÑ ÐÑигоÑÑевиÑ,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">×רנ××ר×, ×.,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">×רנ××ר×, ×××××,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">×רנ××ר×, ×××××,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">×רנ××ר×, ×××××,</subfield><subfield code="d">1891-1967. â¬</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">×רנ××ר×, ×××××,</subfield><subfield code="d">1981Ö¾7691</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">××רנ××ר×, ×××××,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">ערנ××ר×, ×××××,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">ערענ××ר×, ××,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="400" ind1="1" ind2=" "><subfield code="a">ערענ××ר×, ×××××,</subfield><subfield code="d">1891-1967</subfield></datafield><datafield tag="667" ind1=" " ind2=" "><subfield code="a">URIs added to 3XX and/or 5XX fields in this record for the PCC URI MARC Pilot. Please do not remove or edit these URIs</subfield></datafield><datafield tag="667" ind1=" " ind2=" "><subfield code="a">Non-Latin script references not evaluated.</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Black book, c1981:</subfield><subfield code="b">t.p. (Ilya Ehrenburg)</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Encyc. Americana:</subfield><subfield code="b">(Ehrenburg, Ilya Grigorievich)</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Encyc. Brit. 15th:</subfield><subfield code="b">(Ehrenburg, Ilya (Grigoryevich))</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Kan, Y.T. Ai-lun-pao, 1891-1967, 1984:</subfield><subfield code="b">t.p. (Ai-lun-pao) colophon (Ailunbao)</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Chernai︠a︡ kniga. Yiddish. Dos shṿartse bukh, 1984:</subfield><subfield code="b">t.p. (Ilya Erenburg) t.p. verso (Ilyah Erenburg)</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">nuc90-29696: His Lik voÄ­ny (vo frant︠s︡īi) [MI] 1920</subfield><subfield code="b">(usage on CU rept.: I. Ärenburg)</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Ob Armenii i armi︠a︡nskoÄ­ kulʹture, 1988:</subfield><subfield code="b">t.p. (Ilʹi︠a︡ Ärenburg) added t.p. (Ilya Ärenburg)</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Literatur nach Stalins Tod, c1995:</subfield><subfield code="b">t.p. (Ilja Ehrenburg)</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Kuneva, V. Ili︠a︡ Erenburg i Li︠u︡dmil Stoi︠a︡nov, 1991.</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">To dentro, 1971:</subfield><subfield code="b">t.p. (Älia Erenmpourgk)</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">MoÄ­ Parizh, 1933:</subfield><subfield code="b">t.p. (Ilʹi Ärenburga) p. 5 (ÐлÑÑ Ð­ÑенбÑÑг = Ilʹi︠a︡ Ärenburg)</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Wikipedia, Nov. 26, 2014</subfield><subfield code="b">(Ilʹi︠a︡ Ärenburg; January 27 [O.S. January 15] 1891-31 August 1967; Soviet writer, journalist, translator, and cultural figure; among the most prolific and notable authors of the Soviet Union; he published around one hundred titles. He became known first and foremost as a novelist and a journalist--in particular, as a reporter in three wars (First World War, Spanish Civil War and the Second World War))</subfield></datafield><datafield tag="670" ind1=" " ind2=" "><subfield code="a">Wikidata, February 12, 2021</subfield><subfield code="b">(location of burial: Novodevichy Cemetery; award received: Knight of the Legion of Honour, Order of Lenin, Order of the Red Banner of Labour, Order of the Red Star, Medal \, Medal \, Medal \, Stalin Prize, International Stalin Prize for Peace, Order of Lenin, Lenin Peace Prize; Commons category: Ilya Ehrenburg; place of birth: Kyiv; place of death: Moscow; date of birth: +1891-01-14T00:00:00Z, +1891-01-26T00:00:00Z; instance of: human; date of death: +1967-08-31T00:00:00Z; member of: Jewish Anti-Fascist Committee, USSR Union of Writers, World Peace Council, Supreme Soviet of the Soviet Union; occupation: journalist, writer, poet, novelist, screenwriter, translator, politician, children's writer; country of citizenship: Russian Empire, Soviet Union; cause of death: myocardial infarction; given name: Ilya; notable work: The Extraordinary Adventures of Julio Jurenito, The Thaw, Black Book, People, Years and Life; described by source: Great Soviet Encyclopedia (1969-1978), Bio-bibliographic dictionary of Russian writers of the XX century, Obalky knih.cz; languages spoken or published: French, Russian; manner of death: natural causes; child: Irina Erenburg; spouse: Lyubov Kozintseva; position held: member of the Supreme Council of the Soviet Union; native language: Russian; archives at: Central State Archives of Bulgaria; significant event: Nazi book burnings; educated at: First Moscow gymnasium; topic's main category: Category:Ilya Ehrenburg; conflict: Eastern Front; genre: novel, short story, short novel, sketch story, essay, poetry; owner of: аÑÑив на ÐÐ»Ñ ÐÑенбÑÑг; member of political party: Russian Social Democratic Labour Party; writing language: Russian; sex or gender: male; alias: Ehrenburg, Erenburg, Ilia Ehrenburg, Ilia Erenburg, Ilia Grigórievich Ehrenburg, Ilya Grigoryevich Ehrenburg, Iliáa Erenburg, Ilja Ehrenburg, Il'ja Erenburg, Ilja G. Ehrenburg, Ilja Grigor Ehrenburg, Il'ja Grigor'eviÄ Erenburg, Iľja GrigorieviÄ Ehrenburg, Iľja GrigorjeviÄ Erenburg, Ilja Grigorjevitsj Ehrenburg, Ilja Grigorjewitsch Erenburg, Ilya Ehrenberg, Ilya Ehrenburg, Il'ya Erenburg, Ilya Gregoryevich Ehrenburg, Ilya Grigorievich Ehrenburg, Ä°lya Grigoryeviç Ehrenburg, Ilya Grigoryevich Ehrenburg, Ilya Grigoryevich Erenburg, Lya Grigoryevich Ehrenburg, ЭÑенбÑÑг, ЭÑенбÑÑг Ð., ЭÑенбÑÑг Ð. Ð.; abART person ID: 15652; Amazon author ID: B006VYQGIO; ArhivX LOD: 79626; Babelio author ID: 18045; BAnQ author ID: 0000048970; BAV (Vatican Library: identifier) ADV12641572; BHCL ID: 91305; BHCL UUID: 76818205-3126-47ed-a204-df5ae670f73f; BIBSYS identifier: 90064171; BNE identifier: XX950248; BnF identifier: 11901820x; Brockhaus Enzyklopädie online ID: ehrenburg-ilja-grigorjewitsch; BVMC person ID: 43521; CANTIC: a10078010; CiNii author identifier: DA00837084; CONOR.BG ID: 23544677; CONOR identifier: 102645603, 15712611; CONOR.SR ID: 17956711; DBNL ID: ehre001; Deutsche Biographie ID: 118529269; Dialnet author ID: 1892237; EGAXA identifier: vtls000890085; Encyclopædia Britannica Online ID: biography/Ilya-Grigoryevich-Ehrenburg; Encyclopædia Universalis ID: ilia-grigorievitch-ehrenbourg; Encyclopedia of Modern Ukraine ID: 17978; FantLab author ID: 4598; FAST-ID: 10153; Filmportal ID: 18512cefc40d4d93aa76c6e482889369; Find a Grave ID: 21425; Freebase identifier: /m/027_qc; GND identifier: 118529269; Goodreads author ID: 155894; Gran Enciclopèdia Catalana ID: 0024311; Great Russian Encyclopedia Online ID: 4937559; GTAA id: 96302; Hrvatska enciklopedija ID: 18234; IDU person ID: 24804; IMDb identifier: nm0251280; Interlingual Index ID: i95016; iTunes artist ID: 1271947273; Jewish Encyclopedia ID (Russian: ) 15105; LAC identifier: 0104H8549; LCAuth identifier: n50030508; LibraryThing author ID: ehrenburgilya; Libris-URI: xv8bb9lg4vbjrrj; Librivox author ID: 12019; LIMIS person ID: 5383497; LNB identifier: 000029527; Munzinger IBA: 00000000396; National Library of Korea ID: KAC201728656; National Portrait Gallery (London: person identifier) mp95108; NDL identifier: 00438691; NE.se ID: ilja-ehrenburg; NKC identifier: jn19990210194; NLA identifier: 36555544; NLI (Israel: identifier) 000044049; NLP identifier: A11787867; NLR (Romania: identifier) 000075913; NSK identifier: 000059527; NTA identifier (Netherlands: ) 070136238; NUKAT authorities: n94204187; Open Library identifier: OL170489A; Open Library subject ID: person:ilya_grigorevich_ehrenburg_; People Australia identifier: 1289938; Perlentaucher ID: ilja-ehrenburg; PLWABN ID: 9810646542105606; PM20 folder ID: pe/004780; PTBNP identifier: 26150; Rijksmuseum Research Library authority ID: 32301; RKDartists: 271549; Runeberg author ID: ehrenilj; SELIBR: 184634; SHARE Catalogue author ID: 158169; SNAC Ark ID: w6jd7k9n; Store norske leksikon ID: Ilja_Erenburg; SUDOC authorities: 02685211X; The Paris Review interviewee ID: 4636; Union Catalog of Armenian Libraries authority ID: 20366; Unione Romana Biblioteche Scientifiche ID: 298725; University of Barcelona authority ID: a1343179; Vatican Library VcBA ID: 495/336226; WorldCat Identities ID: lccn-n50030508)</subfield><subfield code="u">https://www.wikidata.org/wiki/Q348497</subfield></datafield></record>$_$)$$,
+'Able to insert authority record with long subfield value'
+);
+
+-- If the bug it not patched, the above will fail with an error.
+
+SELECT * FROM finish();
+
+ROLLBACK;
--- /dev/null
+Fix for Authority Records with Long Subfields
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Importing or updating authority records with long subfields, i.e. in
+the vicinity of 5,000 characters or more in length, can cause database
+errors that will prevent the update or import from happening. The
+error occurs because non-full text indexes in PostgreSQL have a
+limited length, and long fields sometimes lead to index entries that
+exceed this maximum value.
+
+In order to rectify this issue, two database indexes on the
+`authority.full_rec` table's `value` column have been redefined to
+match their counterparts in the `metabib.real_full_rec` table. After
+this update, only the first 1024 characters of an authority field or
+subfield will be considered by these indexes.
+
+NOTE: These indexes are not used for authority record search, though
+they are used for sorting and paging.