lexeme.sql
849 Bytes
CREATE OR REPLACE FUNCTION reverse(TEXT) RETURNS TEXT AS '
DECLARE
original ALIAS FOR $1;
reversed TEXT := \'\';
onechar VARCHAR;
mypos INTEGER;
BEGIN
SELECT LENGTH(original) INTO mypos;
LOOP
EXIT WHEN mypos < 1;
SELECT substring(original FROM mypos FOR 1) INTO onechar;
reversed := reversed || onechar;
mypos := mypos -1;
END LOOP;
RETURN reversed;
END
' LANGUAGE plpgsql IMMUTABLE RETURNS NULL ON NULL INPUT;
CREATE INDEX leksemy_a_tergo ON leksemy (reverse(haslo));
ALTER TABLE odmieniasie DROP CONSTRAINT "odmieniasie_l_id_oind_key";
ALTER TABLE odmieniasie ADD UNIQUE (l_id, oind) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE zakonczenia DROP CONSTRAINT "zakonczenia_w_id_efobaz_zind_key";
ALTER TABLE zakonczenia ADD UNIQUE (w_id, efobaz, zind) DEFERRABLE INITIALLY DEFERRED;