1 |
-- this is hopefully complete implementation of pg_recode in PL/pgSQL |
-- this is hopefully complete implementation of pg_recode in PL/pgSQL |
2 |
-- it's best for portability and I still have to check it's performance |
-- it's best for portability and I still have to check it's performance |
3 |
-- 2002-08-30 Dobrica Pavlinusic <dpavlin@rot13.org> |
-- 2002-08-30 Dobrica Pavlinusic <dpavlin@rot13.org> |
4 |
|
-- 2002-09-10 you will have to remove "with (iscachable)" if your |
5 |
|
-- PostgreSQL is not current enough (>7.2.x I think). But, if you leave |
6 |
|
-- it you will be able to create function index using this functions |
7 |
|
-- e.g. create index ind_osobe_ime on osobe ( toczs(ime) ) |
8 |
|
|
9 |
-- drop old implementation |
-- drop old implementation |
10 |
drop function to1250(text); |
drop function to1250(text); |
33 |
end loop; |
end loop; |
34 |
return new; |
return new; |
35 |
end |
end |
36 |
' language 'PLpgSQL'; |
' language 'PLpgSQL' with (iscachable) ; |
37 |
|
|
38 |
-- convert 8859-2 to 1250 |
-- convert 8859-2 to 1250 |
39 |
create function to1250(text) returns text as ' |
create function to1250(text) returns text as ' |
56 |
end loop; |
end loop; |
57 |
return new; |
return new; |
58 |
end |
end |
59 |
' language 'PLpgSQL'; |
' language 'PLpgSQL' with (iscachable) ; |
60 |
|
|
61 |
-- tocsz -- convert iso8859-2 or cp1250 to czs |
-- tocsz -- convert iso8859-2 or cp1250 to czs |
62 |
create function toczs(text) returns text as ' |
create function toczs(text) returns text as ' |
92 |
|
|
93 |
return new; |
return new; |
94 |
end |
end |
95 |
' language 'PLpgSQL'; |
' language 'PLpgSQL' with (iscachable) ; |
96 |
|
|
97 |
-- initcap2 -- initcap whith support for iso8859-2 or cp1250 |
-- initcap2 -- initcap whith support for iso8859-2 or cp1250 |
98 |
create function initcap2(text) returns text as ' |
create function initcap2(text) returns text as ' |
149 |
|
|
150 |
return new; |
return new; |
151 |
end |
end |
152 |
' language 'PLpgSQL'; |
' language 'PLpgSQL' with (iscachable) ; |
153 |
|
|