1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Add SQL99 CONVERT() function.

This commit is contained in:
Tatsuo Ishii
2002-08-06 05:40:47 +00:00
parent 34f03b1630
commit 6206a880cf
15 changed files with 1237 additions and 211 deletions

View File

@@ -4,7 +4,7 @@
# Makefile for utils/mb
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.18 2002/07/18 02:02:30 ishii Exp $
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.19 2002/08/06 05:40:45 ishii Exp $
#
#-------------------------------------------------------------------------
@@ -24,7 +24,7 @@ clean distclean maintainer-clean:
SUBSYS.o: $(OBJS)
@for dir in $(DIRS); do $(MAKE) -C $$dir all || exit; done
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
$(LD) $(LDREL) $(LDOUT) $@ $^
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend

View File

@@ -4,7 +4,7 @@
# Makefile for utils/mb/conversion_procs
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/Makefile,v 1.2 2002/07/18 22:58:08 petere Exp $
# $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/Makefile,v 1.3 2002/08/06 05:40:45 ishii Exp $
#
#-------------------------------------------------------------------------
@@ -14,6 +14,9 @@ include $(top_builddir)/src/Makefile.global
SQLSCRIPT = conversion_create.sql
# This file can be placed as src/test/regress/conversion.sql
REGRESSION_SCRIPT = conversion.sql
DIRS = \
utf8_and_ascii utf8_and_iso8859_1 \
utf8_and_euc_jp utf8_and_euc_kr utf8_and_euc_cn utf8_and_euc_tw \
@@ -21,9 +24,7 @@ DIRS = \
utf8_and_uhc utf8_and_johab utf8_and_tcvn utf8_and_iso8859 \
euc_jp_and_sjis euc_tw_and_big5
# conversion_name source_encoding destination_encoding function object
$(SQLSCRIPT): Makefile
@set \
CONVERSIONS = \
utf8_to_ascii UNICODE SQL_ASCII utf8_to_ascii utf8_and_ascii \
ascii_to_utf8 SQL_ASCII UNICODE ascii_to_utf8 utf8_and_ascii \
utf8_to_iso8859_1 UNICODE LATIN1 utf8_to_iso8859_1 utf8_and_iso8859_1 \
@@ -87,8 +88,11 @@ $(SQLSCRIPT): Makefile
euc_tw_to_mic EUC_TW MULE_INTERNAL euc_tw_to_mic euc_tw_and_big5 \
big5_to_mic BIG5 MULE_INTERNAL big5_to_mic euc_tw_and_big5 \
mic_to_euc_tw MULE_INTERNAL EUC_TW mic_to_euc_tw euc_tw_and_big5 \
mic_to_big5 MULE_INTERNAL BIG5 mic_to_big5 euc_tw_and_big5 \
; \
mic_to_big5 MULE_INTERNAL BIG5 mic_to_big5 euc_tw_and_big5
# conversion_name source_encoding destination_encoding function object
$(SQLSCRIPT): Makefile
@set $(CONVERSIONS) ; \
while [ "$$#" -gt 0 ] ; \
do \
name=$$1;shift; \
@@ -102,6 +106,22 @@ $(SQLSCRIPT): Makefile
echo "CREATE DEFAULT CONVERSION pg_catalog.$$name FOR '$$se' TO '$$de' FROM $$func;"; \
done > $@
$(REGRESSION_SCRIPT): Makefile
@cp regress_prolog $@; \
set $(CONVERSIONS) ; \
while [ "$$#" -gt 0 ] ; \
do \
name=$$1;shift; \
se=$$1;shift; \
de=$$1; shift; \
func=$$1; shift; \
obj=$$1; shift; \
echo "-- $$se --> $$de"; \
echo "SELECT CONVERT('foo' USING $$name);"; \
echo "SELECT CONVERT('foo', '$$se', '$$de');"; \
done >> $@; \
cat regress_epilogue >> $@;
install: all installdirs
$(INSTALL_DATA) $(SQLSCRIPT) $(DESTDIR)$(datadir)
@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done

View File

@@ -0,0 +1,5 @@
--
-- return to the super user
--
RESET SESSION AUTHORIZATION;
DROP USER foo;

View File

@@ -0,0 +1,25 @@
--
-- create user defined conversion
--
CREATE USER foo WITH NOCREATEDB NOCREATEUSER;
SET SESSION AUTHORIZATION foo;
CREATE CONVERSION myconv FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
--
-- cannot make same name conversion in same schema
--
CREATE CONVERSION myconv FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
--
-- create default conversion with qualified name
--
CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
--
-- cannot make default conversion with same shcema/for_encoding/to_encoding
--
CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8;
--
-- drop user defined conversion
--
DROP CONVERSION myconv;
DROP CONVERSION mydef;
--
-- make sure all pre-defined conversions are fine.