Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @@ -85,23 +85,20 @@ BEGIN
- CONTINUE WHEN ind_data.sort_value IS NULL;
- value_prepped := metabib.browse_normalize(ind_data.value, ind_data.field);
- - IF ind_data.browse_nocase THEN
- + IF ind_data.browse_nocase THEN -- for "nocase" browse definions, look for a preexisting row that matches case-insensitively on value and use that
- SELECT INTO mbe_row * FROM metabib.browse_entry
- WHERE evergreen.lowercase(value) = evergreen.lowercase(value_prepped) AND sort_value = ind_data.sort_value
- ORDER BY sort_value, value LIMIT 1; -- gotta pick something, I guess
- - ELSE
- - SELECT INTO mbe_row * FROM metabib.browse_entry
- - WHERE value = value_prepped AND sort_value = ind_data.sort_value;
- END IF;
- - IF FOUND THEN
- + IF mbe_row.id IS NOT NULL THEN -- asked to check for, and found, a "nocase" version to use
- mbe_id := mbe_row.id;
- - ELSE
- + ELSE -- otherwise, an UPSERT-protected variant
- INSERT INTO metabib.browse_entry
- ( value, sort_value ) VALUES
- - ( value_prepped, ind_data.sort_value );
- -
- - mbe_id := CURRVAL('metabib.browse_entry_id_seq'::REGCLASS);
- + ( value_prepped, ind_data.sort_value )
- + ON CONFLICT (sort_value, value) DO UPDATE SET id = EXCLUDED.id -- must update a row to return an existing id
- + RETURNING id INTO mbe_id;
- END IF;
- INSERT INTO metabib.browse_entry_def_map (entry, def, source, authority)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement