From 2b0febc08baaf1e94b450366767a366ec2bbdda0 Mon Sep 17 00:00:00 2001 From: "xu.han01" Date: Tue, 2 Apr 2024 07:55:00 +0000 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81gms=5Foutput=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GNUmakefile.in | 1 + build/script/aarch64_opengauss_list | 3 + .../opengauss_release_list_ubuntu_single | 3 + build/script/x86_64_opengauss_list | 3 + contrib/CMakeLists.txt | 2 + contrib/gms_output/CMakeLists.txt | 21 + contrib/gms_output/Makefile | 25 + contrib/gms_output/data/dummy.txt | 1 + contrib/gms_output/expected/gms_output.out | 1658 +++++++++++++++++ contrib/gms_output/gms_output--1.0.sql | 54 + contrib/gms_output/gms_output.control | 5 + contrib/gms_output/gms_output.cpp | 416 +++++ contrib/gms_output/gms_output.h | 34 + contrib/gms_output/sql/gms_output.sql | 705 +++++++ src/common/backend/utils/error/elog.cpp | 34 +- src/include/utils/elog.h | 3 + 16 files changed, 2962 insertions(+), 6 deletions(-) create mode 100644 contrib/gms_output/CMakeLists.txt create mode 100644 contrib/gms_output/Makefile create mode 100644 contrib/gms_output/data/dummy.txt create mode 100644 contrib/gms_output/expected/gms_output.out create mode 100644 contrib/gms_output/gms_output--1.0.sql create mode 100644 contrib/gms_output/gms_output.control create mode 100644 contrib/gms_output/gms_output.cpp create mode 100644 contrib/gms_output/gms_output.h create mode 100644 contrib/gms_output/sql/gms_output.sql diff --git a/GNUmakefile.in b/GNUmakefile.in index 2403b0864b..eb5eb45c88 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -99,6 +99,7 @@ install: @if test -d contrib/dolphin; then $(MAKE) -C contrib/dolphin $@; fi @if test -d contrib/age; then $(MAKE) -C contrib/age $@; fi @if test -d contrib/datavec; then $(MAKE) -C contrib/datavec $@; fi + @if test -d contrib/gms_output; then $(MAKE) -C contrib/gms_output $@; fi +@echo "openGauss installation complete." endif endif diff --git a/build/script/aarch64_opengauss_list b/build/script/aarch64_opengauss_list index 4ce2170a87..dd37d9024b 100644 --- a/build/script/aarch64_opengauss_list +++ b/build/script/aarch64_opengauss_list @@ -110,6 +110,8 @@ ./share/postgresql/extension/dblink--1.0.sql ./share/postgresql/extension/dblink--unpackaged--1.0.sql ./share/postgresql/extension/dblink.control +./share/postgresql/extension/gms_output--1.0.sql +./share/postgresql/extension/gms_output.control ./share/postgresql/timezone/GB-Eire ./share/postgresql/timezone/Turkey ./share/postgresql/timezone/Kwajalein @@ -804,6 +806,7 @@ ./lib/postgresql/dblink.so ./lib/postgresql/pgoutput.so ./lib/postgresql/assessment.so +./lib/postgresql/gms_output.so ./lib/libpljava.so ./lib/libpq.a ./lib/libpq.so diff --git a/build/script/opengauss_release_list_ubuntu_single b/build/script/opengauss_release_list_ubuntu_single index 96154be844..cd5d300667 100644 --- a/build/script/opengauss_release_list_ubuntu_single +++ b/build/script/opengauss_release_list_ubuntu_single @@ -99,6 +99,8 @@ ./share/postgresql/extension/dblink--1.0.sql ./share/postgresql/extension/dblink--unpackaged--1.0.sql ./share/postgresql/extension/dblink.control +./share/postgresql/extension/gms_output--1.0.sql +./share/postgresql/extension/gms_output.control ./share/postgresql/timezone/GB-Eire ./share/postgresql/timezone/Turkey ./share/postgresql/timezone/Kwajalein @@ -775,6 +777,7 @@ ./lib/postgresql/java/pljava.jar ./lib/postgresql/postgres_fdw.so ./lib/postgresql/dblink.so +./lib/postgresql/gms_output.so ./lib/libpljava.so ./lib/libpq.a ./lib/libpq.so diff --git a/build/script/x86_64_opengauss_list b/build/script/x86_64_opengauss_list index 9fe973fd9d..835f46a018 100644 --- a/build/script/x86_64_opengauss_list +++ b/build/script/x86_64_opengauss_list @@ -110,6 +110,8 @@ ./share/postgresql/extension/dblink--1.0.sql ./share/postgresql/extension/dblink--unpackaged--1.0.sql ./share/postgresql/extension/dblink.control +./share/postgresql/extension/gms_output--1.0.sql +./share/postgresql/extension/gms_output.control ./share/postgresql/timezone/GB-Eire ./share/postgresql/timezone/Turkey ./share/postgresql/timezone/Kwajalein @@ -804,6 +806,7 @@ ./lib/postgresql/dblink.so ./lib/postgresql/pgoutput.so ./lib/postgresql/assessment.so +./lib/postgresql/gms_output.so ./lib/libpljava.so ./lib/libpq.a ./lib/libpq.so diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 8f8db20bf3..9207f8bb36 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -15,6 +15,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/spi ${CMAKE_CURRENT_SOURCE_DIR}/pg_upgrade_support ${CMAKE_CURRENT_SOURCE_DIR}/postgres_fdw + ${CMAKE_CURRENT_SOURCE_DIR}/gms_output ${CMAKE_CURRENT_SOURCE_DIR}/security_plugin ${CMAKE_CURRENT_SOURCE_DIR}/dummy_seclabel ${CMAKE_CURRENT_SOURCE_DIR}/pagehack @@ -35,6 +36,7 @@ if("${ENABLE_MULTIPLE_NODES}" STREQUAL "ON" OR "${ENABLE_PRIVATEGAUSS}" STREQUAL add_subdirectory(pg_upgrade_support) endif() add_subdirectory(postgres_fdw) +add_subdirectory(gms_output) add_subdirectory(security_plugin) add_subdirectory(dummy_seclabel) add_subdirectory(pagehack) diff --git a/contrib/gms_output/CMakeLists.txt b/contrib/gms_output/CMakeLists.txt new file mode 100644 index 0000000000..3d951e67de --- /dev/null +++ b/contrib/gms_output/CMakeLists.txt @@ -0,0 +1,21 @@ +#This is the main CMAKE for build all gms_output. +# gms_output +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TGT_gms_output_SRC) +set(TGT_gms_output_INC + ${PROJECT_OPENGS_DIR}/contrib/gms_output + ${PROJECT_OPENGS_DIR}/contrib +) + +set(gms_output_DEF_OPTIONS ${MACRO_OPTIONS}) +set(gms_output_COMPILE_OPTIONS ${OPTIMIZE_OPTIONS} ${OS_OPTIONS} ${PROTECT_OPTIONS} ${WARNING_OPTIONS} ${LIB_SECURE_OPTIONS} ${CHECK_OPTIONS}) +set(gms_output_LINK_OPTIONS ${LIB_LINK_OPTIONS}) +add_shared_libtarget(gms_output TGT_gms_output_SRC TGT_gms_output_INC "${gms_output_DEF_OPTIONS}" "${gms_output_COMPILE_OPTIONS}" "${gms_output_LINK_OPTIONS}") +set_target_properties(gms_output PROPERTIES PREFIX "") + +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_output.control + DESTINATION share/postgresql/extension/ +) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_output--1.0.sql + DESTINATION share/postgresql/extension/ +) +install(TARGETS gms_output DESTINATION lib/postgresql) diff --git a/contrib/gms_output/Makefile b/contrib/gms_output/Makefile new file mode 100644 index 0000000000..f0f8fbf8ea --- /dev/null +++ b/contrib/gms_output/Makefile @@ -0,0 +1,25 @@ +# contrib/gms_output/Makefile +MODULE_big = gms_output +OBJS = gms_output.o + +EXTENSION = gms_output +DATA = gms_output--1.0.sql + +REGRESS = gms_output + +ifdef USE_PGXS +PG_CONFIG = pg_config +PGXS := $(shell $(PG_CONFIG) --pgxs) +include $(PGXS) +else +subdir = contrib/gms_output +top_builddir = ../.. +include $(top_builddir)/src/Makefile.global +regress_home = $(top_builddir)/src/test/regress +REGRESS_OPTS = -c 0 -d 1 -r 1 -p 25632 --single_node -w --keep_last_data=false \ + --regconf=$(regress_home)/regress.conf \ + --temp-config=$(regress_home)/make_fastcheck_postgresql.conf +include $(top_srcdir)/contrib/contrib-global.mk +endif + +gms_output.o: gms_output.cpp \ No newline at end of file diff --git a/contrib/gms_output/data/dummy.txt b/contrib/gms_output/data/dummy.txt new file mode 100644 index 0000000000..7f015cede0 --- /dev/null +++ b/contrib/gms_output/data/dummy.txt @@ -0,0 +1 @@ +The openGauss regression needs this file to run. \ No newline at end of file diff --git a/contrib/gms_output/expected/gms_output.out b/contrib/gms_output/expected/gms_output.out new file mode 100644 index 0000000000..87a117b20a --- /dev/null +++ b/contrib/gms_output/expected/gms_output.out @@ -0,0 +1,1658 @@ +create extension gms_output; +create schema gms_output_test; +set search_path=gms_output_test; +-- test gms_output.disable +select gms_output.DISABLE; + disable +--------- + +(1 row) + +select gms_output.DISABLE(null); +ERROR: function gms_output.disable(unknown) does not exist +LINE 1: select gms_output.DISABLE(null); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: disable +select gms_output.DISABLE(); + disable +--------- + +(1 row) + +select gms_output.DISABLE(''); +ERROR: function gms_output.disable(unknown) does not exist +LINE 1: select gms_output.DISABLE(''); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: disable +select gms_output.DISABLE(0); +ERROR: function gms_output.disable(integer) does not exist +LINE 1: select gms_output.DISABLE(0); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: disable +select gms_output.DISABLE(""""); +ERROR: column """ does not exist +LINE 1: select gms_output.DISABLE(""""); + ^ +CONTEXT: referenced column: disable +select gms_output.DISABLE(@); +ERROR: syntax error at or near ")" +LINE 1: select gms_output.DISABLE(@); + ^ +select gms_output.DISABLE(あ); +ERROR: column "あ" does not exist +LINE 1: select gms_output.DISABLE(あ); + ^ +CONTEXT: referenced column: disable +select gms_output.DISABLE(%); +ERROR: syntax error at or near "%" +LINE 1: select gms_output.DISABLE(%); + ^ +select gms_output.DISABLE('qqqq'); +ERROR: function gms_output.disable(unknown) does not exist +LINE 1: select gms_output.DISABLE('qqqq'); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: disable +select gms_output.DISABLE; + disable +--------- + +(1 row) + +select gms_output.PUT_LINE('adsfds'); + put_line +---------- + +(1 row) + +select gms_output.GET_LINE(0,1); + get_line +---------- + (,1) +(1 row) + +-- test gms_output.enable +select gms_output.enable(1000000); + enable +-------- + +(1 row) + +select gms_output.enable(20000); + enable +-------- + +(1 row) + +select gms_output.enable(1000001); +WARNING: Limit decreased to 1000000 bytes. +CONTEXT: referenced column: enable + enable +-------- + +(1 row) + +select gms_output.enable(19999); + enable +-------- + +(1 row) + +select gms_output.enable(30000); + enable +-------- + +(1 row) + +select gms_output.enable(power(2,31)); +ERROR: integer out of range +CONTEXT: referenced column: enable +select gms_output.enable(-555.55); +WARNING: Limit increased to 2000 bytes. +CONTEXT: referenced column: enable + enable +-------- + +(1 row) + +select gms_output.enable(0.555.55); +ERROR: syntax error at or near "0.555.55" +LINE 1: select gms_output.enable(0.555.55); + ^ +select gms_output.enable(000.555); +WARNING: Limit increased to 2000 bytes. +CONTEXT: referenced column: enable + enable +-------- + +(1 row) + +select gms_output.enable(ssss); +ERROR: column "ssss" does not exist +LINE 1: select gms_output.enable(ssss); + ^ +CONTEXT: referenced column: enable +select gms_output.enable('ssss'); +ERROR: invalid input syntax for integer: "ssss" +LINE 1: select gms_output.enable('ssss'); + ^ +CONTEXT: referenced column: enable +select gms_output.enable(-power(2,32)); +ERROR: integer out of range +CONTEXT: referenced column: enable +select gms_output.enable(-power(2,21)); +WARNING: Limit increased to 2000 bytes. +CONTEXT: referenced column: enable + enable +-------- + +(1 row) + +select gms_output.enable(a); +ERROR: column "a" does not exist +LINE 1: select gms_output.enable(a); + ^ +CONTEXT: referenced column: enable +select gms_output.enable('a'); +ERROR: invalid input syntax for integer: "a" +LINE 1: select gms_output.enable('a'); + ^ +CONTEXT: referenced column: enable +select gms_output.enable(' '); +ERROR: invalid input syntax for integer: " " +LINE 1: select gms_output.enable(' '); + ^ +CONTEXT: referenced column: enable +select gms_output.enable(null); + enable +-------- + +(1 row) + +select gms_output.enable(0); +WARNING: Limit increased to 2000 bytes. +CONTEXT: referenced column: enable + enable +-------- + +(1 row) + +select gms_output.enable(あ); +ERROR: column "あ" does not exist +LINE 1: select gms_output.enable(あ); + ^ +CONTEXT: referenced column: enable +select gms_output.enable('あ'); +ERROR: invalid input syntax for integer: "あ" +LINE 1: select gms_output.enable('あ'); + ^ +CONTEXT: referenced column: enable +select gms_output.enable('@'); +ERROR: invalid input syntax for integer: "@" +LINE 1: select gms_output.enable('@'); + ^ +CONTEXT: referenced column: enable +select gms_output.enable(1000,1000); +ERROR: function gms_output.enable(integer, integer) does not exist +LINE 1: select gms_output.enable(1000,1000); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: enable +select gms_output.enable(1000,null); +ERROR: function gms_output.enable(integer, unknown) does not exist +LINE 1: select gms_output.enable(1000,null); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: enable +select gms_output.enable('null'); +ERROR: invalid input syntax for integer: "null" +LINE 1: select gms_output.enable('null'); + ^ +CONTEXT: referenced column: enable +select gms_output.enable('山东东海偶然打赏'); +ERROR: invalid input syntax for integer: "山东东海偶然打赏" +LINE 1: select gms_output.enable('山东东海偶然打赏'); + ^ +CONTEXT: referenced column: enable +select gms_output.enable(0); +WARNING: Limit increased to 2000 bytes. +CONTEXT: referenced column: enable + enable +-------- + +(1 row) + +create table t(a int, b int, c int); +insert into t values(111111,222222,333333); +insert into t values(444444,555555,666666); +insert into t values(777777,888888,999999); +create table tt(aa int,bb varchar2(100)); +declare +msg varchar2(120); +cursor t_cur is select * from t order by a; +v_line varchar2(100); + v_status integer := 0; +begin + gms_output.enable; +for i in t_cur loop + msg := i.a || ',' || i.b || ',' || i.c; + gms_output.put_line(msg); +end loop; + + gms_output.get_line(v_line, v_status); + while v_status = 0 loop + insert into tt values(v_status, v_line); + gms_output.get_line(v_line, v_status); +end loop; +end; +/ +111111,222222,333333 +444444,555555,666666 +777777,888888,999999 +--查看结果 +select * from tt; + aa | bb +----+---------------------- + 0 | 111111,222222,333333 + 0 | 444444,555555,666666 + 0 | 777777,888888,999999 +(3 rows) + +--清理资源 +drop table t; +drop table tt; +-- test gms_output.get_line +begin + gms_output.ENABLE(100); + gms_output.put('This '); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +This +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put(); +end; +/ +ERROR: function gms_output.put has no enough parameters +CONTEXT: compilation of PL/pgSQL function "inline_code_block" near line 2 +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put(null); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put(null); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put(-999888,pppp); +end; +/ +ERROR: when invoking function gms_output.put, expected ")", maybe input something superfluous. +CONTEXT: compilation of PL/pgSQL function "inline_code_block" near line 2 +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put(123213123); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +123213123 +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put('未来更快更高更强,hsdufdsnjfs,shfusdfjfjs,12313213'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +未来更快更高更强,hsdufdsnjfs,shfusdfjfjs,12313213 +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put('未来更快更高更强'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +未来更快更高更强 +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put('@#¥#@@#!@#!#¥@%%'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +@#¥#@@#!@#!#¥@%% +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put('2017-09-23'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +2017-09-23 +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line + +begin + gms_output.ENABLE(100); + gms_output.put('2017-09-23 12:23:29,2000/07/99'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +2017-09-23 12:23:29,2000/07/99 +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put('Time Started: ' || TO_CHAR('2001-09-28 01:00:00'::timestamp, 'DD-MON-YYYY HH24:MI:SS')); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +Time Started: 28-SEP-2001 01:00:00 +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put('Time Started: ' || TO_CHAR('2001-09-28 01:00:00'::timestamp, 'DD-MON-YYYY HH24:MI:SS')); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +Time Started: 28-SEP-2001 01:00:00 +begin + gms_output.ENABLE(100); + gms_output.put('∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻ +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put('This '); + gms_output.put('is '); + gms_output.new_line(); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +This +is +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +begin + gms_output.ENABLE(100); + gms_output.put('This '); + gms_output.put('is '); + gms_output.put('函数测试历史的反思的'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +This +is +函数测试历史的反思的 +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +select gms_output.GET_LINE(power(2,32)); +ERROR: function gms_output.get_line(double precision) does not exist +LINE 1: select gms_output.GET_LINE(power(2,32)); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +select gms_output.GET_LINE(power(2,9999)); +ERROR: function gms_output.get_line(double precision) does not exist +LINE 1: select gms_output.GET_LINE(power(2,9999)); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +select gms_output.GET_LINE(あ@ 、iohgfvcs大富大贵); +ERROR: column "あ" does not exist +LINE 1: select gms_output.GET_LINE(あ@ 、iohgfvcs大富大贵); + ^ +CONTEXT: referenced column: get_line +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +select gms_output.GET_LINE(''); +ERROR: function gms_output.get_line(unknown) does not exist +LINE 1: select gms_output.GET_LINE(''); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +select gms_output.GET_LINE(null); +ERROR: function gms_output.get_line(unknown) does not exist +LINE 1: select gms_output.GET_LINE(null); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +select gms_output.GET_LINE('aaaa'); +ERROR: function gms_output.get_line(unknown) does not exist +LINE 1: select gms_output.GET_LINE('aaaa'); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +select gms_output.GET_LINE('和士大夫大师傅即使对方'); +ERROR: function gms_output.get_line(unknown) does not exist +LINE 1: select gms_output.GET_LINE('和士大夫大师傅即使对方'); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +select gms_output.GET_LINE(111); +ERROR: function gms_output.get_line(integer) does not exist +LINE 1: select gms_output.GET_LINE(111); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +select gms_output.GET_LINE(0); +ERROR: function gms_output.get_line(integer) does not exist +LINE 1: select gms_output.GET_LINE(0); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +SET search_path to gms_output; +create table t(a int, b int, c int); +create table tt(aa int,bb varchar2(100)); +insert into t values(111111,222222,333333); +insert into t values(444444,555555,666666); +insert into t values(777777,888888,999999); +declare +msg varchar2(120); +cursor t_cur is select * from t order by a; +v_line varchar2(100); +v_status integer := 0; +begin +gms_output.disable(); +gms_output.enable; +for i in t_cur loop +msg := i.a || ',' || i.b || ',' || i.c; +raise notice 'msg=%',msg; +gms_output.put_line(msg); +end loop; + +gms_output.get_line(v_line, v_status); +while v_status = 0 loop +raise notice 'v_line=%,v_status=%',v_line,v_status; +insert into tt values(v_status, v_line); +gms_output.get_line(v_line, v_status); +end loop; +end; +/ +NOTICE: msg=111111,222222,333333 +111111,222222,333333 +NOTICE: msg=444444,555555,666666 +444444,555555,666666 +NOTICE: msg=777777,888888,999999 +777777,888888,999999 +NOTICE: v_line=111111,222222,333333,v_status=0 +NOTICE: v_line=444444,555555,666666,v_status=0 +NOTICE: v_line=777777,888888,999999,v_status=0 +select * from tt; + aa | bb +----+---------------------- + 0 | 111111,222222,333333 + 0 | 444444,555555,666666 + 0 | 777777,888888,999999 +(3 rows) + +delete from t; +delete from tt; +declare +v_line varchar2(100); +v_status integer := 0; +begin +gms_output.enable; +gms_output.put('This '); +gms_output.new_line; +gms_output.put('end '); + +gms_output.get_line(v_line, v_status); +while v_status = 0 loop +raise notice 'v_line=%,v_status=%',v_line,v_status; +insert into tt values(v_status, v_line); +gms_output.get_line(v_line, v_status); +end loop; +end; +/ +This +end +NOTICE: v_line=This ,v_status=0 +NOTICE: v_line=end ,v_status=0 +select * from tt; + aa | bb +----+------- + 0 | This + 0 | end +(2 rows) + +-- test gms_output.get_lines +begin + gms_output.enable(100); + gms_output.PUT_LINE('{131231321312313},{dhsfsdjfsdf}'); + gms_output.PUT_LINE('{好还是打发士大夫},{dhsfsdjfsdf}'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +{131231321312313},{dhsfsdjfsdf} +{好还是打发士大夫},{dhsfsdjfsdf} +select gms_output.get_lines('{lines}',3); + get_lines +---------------------------------------------------------------------------------- + ("{""{131231321312313},{dhsfsdjfsdf}"",""{好还是打发士大夫},{dhsfsdjfsdf}""}",2) +(1 row) + +begin + gms_output.enable(100); + gms_output.PUT_LINE('{131231321312313,wrewerwr,werwerw},{dhsfsdjfsdf}'); + gms_output.PUT_LINE('88无任何为维护差旅费{dhsfsdjfsdf}'); + gms_output.PUT_LINE('u威力五二年初的v下'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +{131231321312313,wrewerwr,werwerw},{dhsfsdjfsdf} +88无任何为维护差旅费{dhsfsdjfsdf} +u威力五二年初的v下 +select gms_output.get_lines('{lines}',3); + get_lines +----------------------------------------------------------------------------------------------------------------------- + ("{""{131231321312313,wrewerwr,werwerw},{dhsfsdjfsdf}"",""88无任何为维护差旅费{dhsfsdjfsdf}"",u威力五二年初的v下}",3) +(1 row) + +begin + gms_output.enable(100); + gms_output.PUT_LINE('[131231321312313,wrewerwr,werwerw},{dhsfsdjfsdf]'); + gms_output.PUT_LINE('∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +[131231321312313,wrewerwr,werwerw},{dhsfsdjfsdf] +∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻ +select gms_output.get_lines('{lines}',3); + get_lines +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + ("{""[131231321312313,wrewerwr,werwerw},{dhsfsdjfsdf]"",""∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻""}",2) +(1 row) + +begin + gms_output.enable(100); + gms_output.PUT_LINE('{[131231321312313,wrewerwr,werwerw]},{dhsfsdjfsdf]},{美丽泸沽湖}'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +{[131231321312313,wrewerwr,werwerw]},{dhsfsdjfsdf]},{美丽泸沽湖} +select gms_output.get_lines('{lines}',3); + get_lines +------------------------------------------------------------------------------ + ("{""{[131231321312313,wrewerwr,werwerw]},{dhsfsdjfsdf]},{美丽泸沽湖}""}",1) +(1 row) + +--设置v_data为int形式 +declare +v_data text[]; + v_numlines number; +begin + gms_output.enable(100); + gms_output.put_line('好好学习'); + gms_output.put_line('天天向上'); + gms_output.put_line('oh ye'); + v_numlines:=3; + gms_output.get_lines(v_data,v_numlines); +for v_counter in 1..v_numlines loop + gms_output.put_line(v_data(v_counter)); +end loop; +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 4 at PERFORM +好好学习 +天天向上 +oh ye +好好学习 +天天向上 +oh ye +select gms_output.get_lines('{lines}',3); + get_lines +------------------------------------- + ("{好好学习,天天向上,""oh ye""}",3) +(1 row) + +select gms_output.get_lines(3); +ERROR: function gms_output.get_lines(integer) does not exist +LINE 1: select gms_output.get_lines(3); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines('aaaa'); +ERROR: function gms_output.get_lines(unknown) does not exist +LINE 1: select gms_output.get_lines('aaaa'); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(); +ERROR: function gms_output.get_lines() does not exist +LINE 1: select gms_output.get_lines(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(0); +ERROR: function gms_output.get_lines(integer) does not exist +LINE 1: select gms_output.get_lines(0); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(-1); +ERROR: function gms_output.get_lines(integer) does not exist +LINE 1: select gms_output.get_lines(-1); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(-1.666); +ERROR: function gms_output.get_lines(numeric) does not exist +LINE 1: select gms_output.get_lines(-1.666); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines('-1.666'); +ERROR: function gms_output.get_lines(unknown) does not exist +LINE 1: select gms_output.get_lines('-1.666'); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(null); +ERROR: function gms_output.get_lines(unknown) does not exist +LINE 1: select gms_output.get_lines(null); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines({123432}); +ERROR: syntax error at or near "{" +LINE 1: select gms_output.get_lines({123432}); + ^ +select gms_output.get_lines('{123432}'); +ERROR: function gms_output.get_lines(unknown) does not exist +LINE 1: select gms_output.get_lines('{123432}'); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(3); +ERROR: function gms_output.get_lines(integer) does not exist +LINE 1: select gms_output.get_lines(3); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines('a'); +ERROR: function gms_output.get_lines(unknown) does not exist +LINE 1: select gms_output.get_lines('a'); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(null); +ERROR: function gms_output.get_lines(unknown) does not exist +LINE 1: select gms_output.get_lines(null); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(power(2,31)); +ERROR: function gms_output.get_lines(double precision) does not exist +LINE 1: select gms_output.get_lines(power(2,31)); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(3,99); +ERROR: function gms_output.get_lines(integer, integer) does not exist +LINE 1: select gms_output.get_lines(3,99); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines(); +ERROR: function gms_output.get_lines() does not exist +LINE 1: select gms_output.get_lines(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.GET_LINES('{hhh}',1); + get_lines +----------- + ({},0) +(1 row) + +select gms_output.get_lines('{123432}',3); + get_lines +----------- + ({},0) +(1 row) + +select gms_output.get_lines('{123432}','{12312312}'); +ERROR: invalid input syntax for integer: "{12312312}" +LINE 1: select gms_output.get_lines('{123432}','{12312312}'); + ^ +CONTEXT: referenced column: get_lines +select gms_output.get_lines('{入户为了未来}',1); + get_lines +----------- + ({},0) +(1 row) + +select gms_output.get_lines('{入户为了未来}','1'); + get_lines +----------- + ({},0) +(1 row) + +select gms_output.get_lines('{入户为了未来}','hhh'); +ERROR: invalid input syntax for integer: "hhh" +LINE 1: select gms_output.get_lines('{入户为了未来}','hhh'); + ^ +CONTEXT: referenced column: get_lines +select gms_output.get_lines('{}',''); + get_lines +----------- + ({},0) +(1 row) + +select gms_output.get_lines(null,null); + get_lines +----------- + ({},0) +(1 row) + +select gms_output.get_lines('',''); + get_lines +----------- + ({},0) +(1 row) + +select gms_output.get_lines(0,0); +ERROR: function gms_output.get_lines(integer, integer) does not exist +LINE 1: select gms_output.get_lines(0,0); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +--#61857668 [Oracle - gms_output.get_lines] Not support gms_output.chararr type +SET search_path to gms_output; +create table tt(aa int,bb varchar2(100)); +ERROR: relation "tt" already exists in schema "gms_output" +DETAIL: creating new table with existing name in the same schema +declare +lines gms_output.chararr; + v_numlines number; +begin + gms_output.put_line('line one'); + gms_output.put_line('line two'); + gms_output.new_line(); + gms_output.put_line('line three'); + v_numlines := 4; + gms_output.get_lines(lines, v_numlines); +for v_counter in 1..v_numlines loop + insert into tt values(v_counter, lines(v_counter)); + gms_output.put_line(lines(v_counter)); +end loop; +end; +/ +line one +line two +line three +line one +line two +line three +--查看结果 +select * from tt; + aa | bb +----+------------ + 0 | This + 0 | end + 1 | line one + 2 | line two + 3 | + 4 | line three +(6 rows) + +DECLARE +lines GMSOUTPUT_LINESARRAY; + v_numlines number; +begin + --gms_output.put('This '); + --gms_output.put('is '); + gms_output.put_line('line one'); + gms_output.put_line('line two'); + gms_output.new_line(); + --gms_output.put('end.'); + gms_output.put_line('line three'); + v_numlines := 4; + gms_output.get_lines(lines, v_numlines); +for v_counter in 1..v_numlines loop + insert into tt values(v_counter, lines(v_counter)); + gms_output.put_line(lines(v_counter)); +end loop; +end; +/ +ERROR: type "gmsoutput_linesarray" does not exist +LINE 1: DECLARE lines GMSOUTPUT_LINESARRAY; + ^ +QUERY: DECLARE lines GMSOUTPUT_LINESARRAY; + v_numlines number; +begin + --gms_output.put('This '); + --gms_output.put('is '); + gms_output.put_line('line one'); + gms_output.put_line('line two'); + gms_output.new_line(); + --gms_output.put('end.'); + gms_output.put_line('line three'); + v_numlines := 4; + gms_output.get_lines(lines, v_numlines); +for v_counter in 1..v_numlines loop + insert into tt values(v_counter, lines(v_counter)); + gms_output.put_line(lines(v_counter)); +end loop; +end +--查看结果 +select * from tt; + aa | bb +----+------------ + 0 | This + 0 | end + 1 | line one + 2 | line two + 3 | + 4 | line three +(6 rows) + +--#61857707 [Oracle - gms_output.get_lines] Accept with only one parameter +select gms_output.put_line('line one'); +line one + put_line +---------- + +(1 row) + +select gms_output.put_line('line two'); +line two + put_line +---------- + +(1 row) + +select gms_output.new_line(); + new_line +---------- + +(1 row) + +select gms_output.put_line('line three'); +line three + put_line +---------- + +(1 row) + +select gms_output.get_lines(4); +ERROR: function gms_output.get_lines(integer) does not exist +LINE 1: select gms_output.get_lines(4); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_lines +select gms_output.get_lines('{0}',4); + get_lines +------------------------------------------------------- + ("{""line one"",""line two"","""",""line three""}",4) +(1 row) + +--执行存储过程 +declare +lines varchar[]; + v_numlines number; +begin + --gms_output.put('This '); + --gms_output.put('is '); + gms_output.put_line('line one'); + gms_output.put_line('line two'); + gms_output.new_line(); + --gms_output.put('end.'); + gms_output.put_line('line three'); + v_numlines := 4; + gms_output.get_lines(4); +for v_counter in 1..v_numlines loop + insert into tt values(v_counter, lines(v_counter)); + gms_output.put_line(lines(v_counter)); +end loop; +end; +/ +ERROR: function gms_output.get_lines has no enough parameters +CONTEXT: compilation of PL/pgSQL function "inline_code_block" near line 11 +--查看结果 +select * from tt; + aa | bb +----+------------ + 0 | This + 0 | end + 1 | line one + 2 | line two + 3 | + 4 | line three +(6 rows) + +--清理资源 +drop table tt; +-- test gms_output.new_line +select gms_output.put('This '); +This + put +----- + +(1 row) + +select gms_output.new_line; + new_line +---------- + +(1 row) + +select gms_output.new_line(); + new_line +---------- + +(1 row) + +select gms_output.new_line(null); +ERROR: function gms_output.new_line(unknown) does not exist +LINE 1: select gms_output.new_line(null); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: new_line +select gms_output.new_line(''); +ERROR: function gms_output.new_line(unknown) does not exist +LINE 1: select gms_output.new_line(''); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: new_line +select gms_output.new_line('hhh'); +ERROR: function gms_output.new_line(unknown) does not exist +LINE 1: select gms_output.new_line('hhh'); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: new_line +select gms_output.new_line('""where,where"". :???????'); +ERROR: function gms_output.new_line(unknown) does not exist +LINE 1: select gms_output.new_line('""where,where"". :???????'); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: new_line +select gms_output.new_line(systime); +ERROR: column "systime" does not exist +LINE 1: select gms_output.new_line(systime); + ^ +CONTEXT: referenced column: new_line +select gms_output.new_line(8888); +ERROR: function gms_output.new_line(integer) does not exist +LINE 1: select gms_output.new_line(8888); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: new_line +select gms_output.new_line('Time Started: ' || TO_CHAR('2001-09-28 01:00:00'::timestamp, 'DD-MON-YYYY HH24:MI:SS')); +ERROR: function gms_output.new_line(text) does not exist +LINE 1: select gms_output.new_line('Time Started: ' || TO_CHAR('2001... + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: new_line +select gms_output.new_line(88889); +ERROR: missing FROM-clause entry for table "gms_output" +LINE 1: select gms_output.new_line(88889); + ^ +CONTEXT: referenced column: new_line(88889) +begin + gms_output.ENABLE(100); + gms_output.put('This '); + gms_output.put('is '); + gms_output.new_line(); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +This +is +select gms_output.GET_LINE(); +ERROR: function gms_output.get_line() does not exist +LINE 1: select gms_output.GET_LINE(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: get_line +-- test gms_output.put +select gms_output.put('This '); +This + put +----- + +(1 row) + +select gms_output.put(); +ERROR: function gms_output.put() does not exist +LINE 1: select gms_output.put(); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: put +select gms_output.put(null); + put +----- + +(1 row) + +select gms_output.put(''); + put +----- + +(1 row) + +select gms_output.put(-999888,pppp); +ERROR: column "pppp" does not exist +LINE 1: select gms_output.put(-999888,pppp); + ^ +CONTEXT: referenced column: put +select gms_output.put(1,21); +ERROR: function gms_output.put(integer, integer) does not exist +LINE 1: select gms_output.put(1,21); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: put +select gms_output.put(123213123); +123213123 + put +----- + +(1 row) + +select gms_output.put('未来更快更高更强','hsdufdsnjfs','shfusdfjfjs',12313213); +ERROR: function gms_output.put(unknown, unknown, unknown, integer) does not exist +LINE 1: select gms_output.put('未来更快更高更强','hsdufdsnjfs','shfu... + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: put +select gms_output.put('@#¥#@@#!@#!#¥@%%'); +@#¥#@@#!@#!#¥@%% + put +----- + +(1 row) + +select gms_output.put(2017-09-23); +1985 + put +----- + +(1 row) + +select gms_output.put(2017-09-23 12:23:29); +ERROR: syntax error at or near "12" +LINE 1: select gms_output.put(2017-09-23 12:23:29); + ^ +select gms_output.put(89%); +ERROR: syntax error at or near ")" +LINE 1: select gms_output.put(89%); + ^ +select gms_output.put(’あ@ ‘); +ERROR: column "’あ" does not exist +LINE 1: select gms_output.put(’あ@ ‘); + ^ +CONTEXT: referenced column: put +select gms_output.put(2000/07/99); +2.88600288600289 + put +----- + +(1 row) + +select gms_output.put(power(2,32)); +4294967296 + put +----- + +(1 row) + +select gms_output.put(power(2,9999)); +ERROR: value out of range: overflow +CONTEXT: referenced column: put +select gms_output.put('Time Started: ' || TO_CHAR('2001-09-28 01:00:00'::timestamp, 'DD-MON-YYYY HH24:MI:SS')); +Time Started: 28-SEP-2001 01:00:00 + put +----- + +(1 row) + +select gms_output.put(あ@ 、iohgfvcs大富大贵); +ERROR: column "あ" does not exist +LINE 1: select gms_output.put(あ@ 、iohgfvcs大富大贵); + ^ +CONTEXT: referenced column: put +select gms_output.put('、。·ˉˇ¨〃々—~‖…〔〕〈〉《》「」『』〖〗【】±+-×÷∧∨∑∏∪∩∈√⊥∥∠⌒⊙∫∮≡≌≈∽∝≠≮≯≤≥∞∶ ∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!#¥%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); +、。·ˉˇ¨〃々—~‖…〔〕〈〉《》「」『』〖〗【】±+-×÷∧∨∑∏∪∩∈√⊥∥∠⌒⊙∫∮≡≌≈∽∝≠≮≯≤≥∞∶ ∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!#¥%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻ + put +----- + +(1 row) + +select gms_output.put('123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 +'); +ERROR: buffer overflow +DETAIL: Buffer overflow, limit of 2000 bytes +HINT: Increase buffer size in gms_output.enable() next time +CONTEXT: referenced column: put +select gms_output.put('** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!#¥%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); +** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!#¥%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻ + put +----- + +(1 row) + +create table tt(aa int,bb varchar2(100)); +declare + v_line varchar2(100); + v_status integer := 0; +begin + gms_output.enable(100); + gms_output.put('This '); + gms_output.put('is '); + gms_output.new_line; + gms_output.put('end.'); + gms_output.get_line(v_line, v_status); + while v_status = 0 loop + insert into tt values(v_status, v_line); + gms_output.get_line(v_line, v_status); + end loop; +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 4 at PERFORM +This +is +end. +ERROR: value too long for type character varying(100) +CONTEXT: PL/pgSQL function inline_code_block line 9 at SQL statement +--清理资源 +drop table tt; +-- test gms_output.put_line +select gms_output.PUT_LINE('......'); +...... + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE(null); + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE(131231321312313); +131231321312313 + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE('akfdskfsf??Oooo&&&^%**('); +akfdskfsf??Oooo&&&^%**( + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE(''); + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE(89239432094%%&&*&&**&^); +ERROR: operator does not exist: bigint %%&&*&&**&^ +LINE 1: select gms_output.PUT_LINE(89239432094%%&&*&&**&^); + ^ +HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. +CONTEXT: referenced column: put_line +select gms_output.PUT_LINE(-0.99923332); +-.99923332 + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE(power(2,31)); +2147483648 + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE(max(2,3)); +ERROR: function max(integer, integer) does not exist +LINE 1: select gms_output.PUT_LINE(max(2,3)); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: put_line +select gms_output.PUT_LINE('2001-09-28 01:00:00'::timestamp); +Fri Sep 28 01:00:00 2001 + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE(0); +0 + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE('adsfds'); +adsfds + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE(adsfds); +ERROR: column "adsfds" does not exist +LINE 1: select gms_output.PUT_LINE(adsfds); + ^ +CONTEXT: referenced column: put_line +select gms_output.PUT_LINE(power(2,9999)); +ERROR: value out of range: overflow +CONTEXT: referenced column: put_line +select gms_output.PUT_LINE(power(2,9999)); +ERROR: function gms_output.put_line(power(integer, integer) does not exist +LINE 1: select gms_output.PUT_LINE(power(2,9999)); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: ) +select gms_output.PUT_LINE(131231321312313,24232432); +ERROR: function gms_output.put_line(bigint, integer) does not exist +LINE 1: select gms_output.PUT_LINE(131231321312313,24232432); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: put_line +select gms_output.PUT_LINE('疫情早日过去,国泰民安,风调雨顺,平安健康常在'); +疫情早日过去,国泰民安,风调雨顺,平安健康常在 + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE('123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 +'); +123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 + + put_line +---------- + +(1 row) + +select gms_output.PUT_LINE('** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!#¥%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); +ERROR: buffer overflow +DETAIL: Buffer overflow, limit of 2000 bytes +HINT: Increase buffer size in gms_output.enable() next time +CONTEXT: referenced column: put_line +drop database if exists testdb_utf8; +NOTICE: database "testdb_utf8" does not exist, skipping +create database testdb_utf8; +\c testdb_utf8; +create extension gms_output; +declare + a int := 10; + b varchar2(100) := 'abcdef'; + c text := '测试用例,,,,,,.. ..。。。。'; +begin + gms_output.enable(4000); + gms_output.put_line('test case'); + gms_output.put_line('test case' || a); + gms_output.put_line('test case' || b); + gms_output.put_line('test case' || c); + gms_output.put_line('测试用例'); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。'); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || a); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || b); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || c); +end; +/ +test case +test case10 +test caseabcdef +test case测试用例,,,,,,.. ..。。。。 +测试用例 +测试用例,,,,ABCD,,....。。。。 +测试用例,,,,ABCD,,....。。。。10 +测试用例,,,,ABCD,,....。。。。abcdef +测试用例,,,,ABCD,,....。。。。测试用例,,,,,,.. ..。。。。 +\c contrib_regression +drop database testdb_utf8; +drop database if exists testdb_gbk; +NOTICE: database "testdb_gbk" does not exist, skipping +create database testdb_gbk encoding='GBK' LC_COLLATE='C' LC_CTYPE='C'; +\c testdb_gbk +create extension gms_output; +set client_encoding to 'UTF8'; +declare + a int := 10; + b varchar2(100) := 'abcdef'; + c text := '测试用例,,,,,,.. ..。。。。'; +begin + gms_output.enable(4000); + gms_output.put_line('test case'); + gms_output.put_line('test case' || a); + gms_output.put_line('test case' || b); + gms_output.put_line('test case' || c); + gms_output.put_line('测试用例'); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。'); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || a); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || b); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || c); +end; +/ +test case +test case10 +test caseabcdef +test case测试用例,,,,,,.. ..。。。。 +测试用例 +测试用例,,,,ABCD,,....。。。。 +测试用例,,,,ABCD,,....。。。。10 +测试用例,,,,ABCD,,....。。。。abcdef +测试用例,,,,ABCD,,....。。。。测试用例,,,,,,.. ..。。。。 +reset client_encoding; +\c contrib_regression +drop database testdb_gbk; +-- test gms_output.serveroutput +set search_path=gms_output_test; +begin +gms_output.put('123'); +gms_output.put_line('abc'); +end; +/ +begin +gms_output.enable(4000); +gms_output.put('123'); +gms_output.new_line(); +gms_output.put_line('abc'); +end; +/ +123 +abc +begin +gms_output.put('222'); +gms_output.new_line(); +end; +/ +222 +begin +gms_output.enable(4000); +gms_output.put_line('abc'); +end; +/ +abc +begin +gms_output.disable(); +gms_output.enable(4000); +gms_output.put('456'); +gms_output.put('7'); +gms_output.new_line(); +gms_output.put('89'); +gms_output.put_line('abc'); +end; +/ +456 +7 +89 +abc +begin +gms_output.disable(); +gms_output.enable(4000); +gms_output.new_line(); +gms_output.put('456'); +gms_output.put('7'); +gms_output.put('89'); +gms_output.put_line('abc'); +gms_output.put_line('fff'); +gms_output.put_line('ggg'); +end; +/ +456 +7 +89 +abc +fff +ggg +begin +gms_output.enable(); +gms_output.put_l ine('abc'); +end; +/ +ERROR: syntax error at or near "ine" +LINE 3: gms_output.put_l ine('abc'); + ^ +QUERY: DECLARE +BEGIN gms_output.enable(); +gms_output.put_l ine('abc'); +end +begin +gms_output.put('123'); +gms_output.new_line(); +end; +/ +123 +begin +gms_output.put('123'); +end; +/ +123 +begin +gms_output.new_line(); +end; +/ +set gms_output.serveroutput to off; +show gms_output.serveroutput; + gms_output.serveroutput +------------------------- + off +(1 row) + +begin +gms_output.put_line('2'); +end; +/ +2 +begin +gms_output.enable(4000); +gms_output.put_line('abc'); +end; +/ +abc +set gms_output.serveroutput to on; +begin +gms_output.enable(4000); +gms_output.put('123'); +gms_output.put_line('YYY'); +end; +/ +123 +YYY +begin +gms_output.disable(); +gms_output.enable(4000); +gms_output.put('33'); +end; +/ +33 +begin +gms_output.put('44'); +gms_output.new_line(); +end; +/ +44 +create table gms_output_tt3(aa int,bb varchar2(100)); +declare +v_line varchar2(100); +v_status integer := 0; +begin +gms_output.put_line('55'); +gms_output.get_line(v_line, v_status); +insert into gms_output_tt3 values(v_status, v_line); +end; +/ +55 +select * from gms_output_tt3; + aa | bb +----+------ + 0 | 3344 +(1 row) + +begin + gms_output.ENABLE; + gms_output.put_line('This '); +end; +/ +This +select gms_output.GET_LINE(0,1); + get_line +------------- + ("This ",0) +(1 row) + +begin + gms_output.enable(100); + gms_output.PUT_LINE('{131231321312313},{dhsfsdjfsdf}'); + gms_output.PUT_LINE('{好还是打发士大夫},{dhsfsdjfsdf}'); +end; +/ +WARNING: Limit increased to 2000 bytes. +CONTEXT: SQL statement "CALL gms_output.enable(100)" +PL/pgSQL function inline_code_block line 2 at PERFORM +{131231321312313},{dhsfsdjfsdf} +{好还是打发士大夫},{dhsfsdjfsdf} +select gms_output.get_lines('{lines}',3); + get_lines +---------------------------------------------------------------------------------- + ("{""{131231321312313},{dhsfsdjfsdf}"",""{好还是打发士大夫},{dhsfsdjfsdf}""}",2) +(1 row) + +reset search_path; +drop schema gms_output_test cascade; +NOTICE: drop cascades to table gms_output_test.gms_output_tt3 diff --git a/contrib/gms_output/gms_output--1.0.sql b/contrib/gms_output/gms_output--1.0.sql new file mode 100644 index 0000000000..c6c621e4d9 --- /dev/null +++ b/contrib/gms_output/gms_output--1.0.sql @@ -0,0 +1,54 @@ +/* contrib/gms_output/gms_output--1.0.sql */ + +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "CREATE EXTENSION gms_output" to load this file. \quit + +CREATE SCHEMA gms_output; +GRANT USAGE ON SCHEMA gms_output TO PUBLIC; + +--SUPPORT TYPE CHARARR +CREATE TYPE gms_output.CHARARR IS TABLE OF VARCHAR2(32767); + +CREATE OR REPLACE FUNCTION gms_output.enable(buff_size int default 20000) +RETURNS void +AS 'MODULE_PATHNAME','gms_output_enable' +LANGUAGE C; +--COMMENT ON FUNCTION gms_output.enable(int) IS 'This function enables calls to PUT, PUT_LINE, NEW_LINE, GET_LINE, and GET_LINES.'; + +CREATE OR REPLACE FUNCTION gms_output.disable() +RETURNS void +AS 'MODULE_PATHNAME','gms_output_disable' +LANGUAGE C; +--COMMENT ON FUNCTION gms_output.disable() IS 'This function disables calls to PUT, PUT_LINE, NEW_LINE, GET_LINE, and GET_LINES.'; + +CREATE OR REPLACE FUNCTION gms_output.put(text) +RETURNS void +AS 'MODULE_PATHNAME','gms_output_put' +LANGUAGE C +RETURNS NULL ON NULL INPUT; +--COMMENT ON FUNCTION gms_output.put(text) IS 'This function places a partial line in the buffer.'; + +CREATE OR REPLACE FUNCTION gms_output.put_line(text) +RETURNS void +AS 'MODULE_PATHNAME','gms_output_put_line' +LANGUAGE C +RETURNS NULL ON NULL INPUT; +--COMMENT ON FUNCTION gms_output.put_line(text) IS 'This function places a line in the buffer.'; + +CREATE OR REPLACE FUNCTION gms_output.new_line() +RETURNS void +AS 'MODULE_PATHNAME','gms_output_new_line' +LANGUAGE C; +--COMMENT ON FUNCTION gms_output.new_line() IS 'This function puts an end-of-line marker.'; + +CREATE OR REPLACE FUNCTION gms_output.get_line(line INOUT text, status INOUT INTEGER) +RETURNS RECORD +AS 'MODULE_PATHNAME','gms_output_get_line' +LANGUAGE C; +--COMMENT ON FUNCTION gms_output.get_line(line INOUT text, status INOUT INTEGER) IS 'This function retrieves a single line of buffered information..'; + +CREATE OR REPLACE FUNCTION gms_output.get_lines(lines INOUT text[], numlines INOUT INTEGER) +RETURNS RECORD +AS 'MODULE_PATHNAME','gms_output_get_lines' +LANGUAGE C; +--COMMENT ON FUNCTION gms_output.get_lines(lines INOUT text[], numlines INOUT INTEGER) IS 'This function retrieves an array of lines from the buffer.'; diff --git a/contrib/gms_output/gms_output.control b/contrib/gms_output/gms_output.control new file mode 100644 index 0000000000..a0e27e440e --- /dev/null +++ b/contrib/gms_output/gms_output.control @@ -0,0 +1,5 @@ +# gms_output extension +comment = 'collection of output data for PL/SQL applications' +default_version = '1.0' +module_pathname = '$libdir/gms_output' +relocatable = true \ No newline at end of file diff --git a/contrib/gms_output/gms_output.cpp b/contrib/gms_output/gms_output.cpp new file mode 100644 index 0000000000..4f1f2c5efc --- /dev/null +++ b/contrib/gms_output/gms_output.cpp @@ -0,0 +1,416 @@ +#include "postgres.h" +#include "funcapi.h" +#include "commands/extension.h" +#include "libpq/libpq.h" +#include "libpq/pqformat.h" +#include "utils/builtins.h" +#include "utils/lsyscache.h" + +#include "gms_output.h" + +PG_MODULE_MAGIC; + +/* + * TODO: BUFSIZE_UNLIMITED to be truely unlimited (or INT_MAX), + * and allocate buffers on-demand. + */ +#define BUFSIZE_DEFAULT 20000 +#define BUFSIZE_MIN 2000 +#define BUFSIZE_MAX 1000000 +#define BUFSIZE_UNLIMITED BUFSIZE_MAX + +PG_FUNCTION_INFO_V1(gms_output_enable_default); +PG_FUNCTION_INFO_V1(gms_output_enable); +PG_FUNCTION_INFO_V1(gms_output_disable); +PG_FUNCTION_INFO_V1(gms_output_serveroutput); +PG_FUNCTION_INFO_V1(gms_output_put); +PG_FUNCTION_INFO_V1(gms_output_put_line); +PG_FUNCTION_INFO_V1(gms_output_new_line); +PG_FUNCTION_INFO_V1(gms_output_get_line); +PG_FUNCTION_INFO_V1(gms_output_get_lines); + +static uint32 output_index; + +static void add_str(const char *str, int len); +static void add_text(text *str); +static void add_newline(void); +static void send_buffer(void); + +void set_extension_index(uint32 index) +{ + output_index = index; +} + +void init_session_vars(void) { + RepallocSessionVarsArrayIfNecessary(); + OutputContext* psc = + (OutputContext*)MemoryContextAllocZero(u_sess->self_mem_cxt, sizeof(OutputContext)); + u_sess->attr.attr_common.extension_session_vars_array[output_index] = psc; + + psc->is_server_output = false; + psc->buffer = NULL; + psc->buffer_size = 0; + psc->buffer_len = 0; + psc->buffer_get = 0; +} + +OutputContext* get_session_context() { + if (u_sess->attr.attr_common.extension_session_vars_array[output_index] == NULL) { + init_session_vars(); + } + return (OutputContext*)u_sess->attr.attr_common.extension_session_vars_array[output_index]; +} + +/* + * Aux. buffer functionality + */ +static void +add_str(const char *str, int len) +{ + errno_t sret = EOK; + bool is_change = false; + if (strlen(str) != 0 && GetDatabaseEncoding() != pg_get_client_encoding()) { + char *p = pg_server_to_client(str, len); + if (p != str) { + unsigned int mb_len = 0; + const char *mb_str = p; + str = p; + is_change = true; + while (*mb_str++) + mb_len++; + len = mb_len; + } + } + + /* Discard all buffers if get_line was called. */ + if (get_session_context()->buffer_get > 0) + { + get_session_context()->buffer_get = 0; + get_session_context()->buffer_len = 0; + get_session_context()->gms_getline = false; + get_session_context()->gms_valid_num = 0; + } + + if (get_session_context()->buffer_len + len > get_session_context()->buffer_size) { + get_session_context()->buffer_len = 0; + get_session_context()->buffer_get = 0; + get_session_context()->gms_getline = false; + get_session_context()->gms_valid_num = 0; + get_session_context()->gms_serveroutput = true; + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_RESOURCES), + errmsg("buffer overflow"), + errdetail("Buffer overflow, limit of %d bytes", get_session_context()->buffer_size), + errhint("Increase buffer size in gms_output.enable() next time"))); + } + + if ( len != 0 ) { + sret = memcpy_s(get_session_context()->buffer + get_session_context()->buffer_len, + get_session_context()->buffer_size - get_session_context()->buffer_len, str, len); + securec_check(sret, "\0", "\0"); + + int tmplen = (len < (OUTPUTBUF_LEN-1)) ? len : (OUTPUTBUF_LEN-1); + sret = memcpy_s(get_session_context()->output_buf, OUTPUTBUF_LEN, get_session_context()->buffer + get_session_context()->buffer_len, tmplen); + securec_check(sret, "\0", "\0"); + get_session_context()->output_buf[tmplen] = '\0'; + if (pg_strcasecmp(str, "") != 0 && get_session_context()->gms_serveroutput) { + ereport(NOTICE, + (errmsg("%s", get_session_context()->output_buf), onlyfrontmsg(true))); + } + } + if (is_change) { + pfree_ext(str); + } + get_session_context()->buffer_len += len; + get_session_context()->buffer[get_session_context()->buffer_len] = '\0'; +} + +static void +add_text(text *str) +{ + add_str(VARDATA_ANY(str), VARSIZE_ANY_EXHDR(str)); +} + +static void +add_newline(void) +{ + add_str("", 1); /* add \0 */ + if (get_session_context()->is_server_output) + send_buffer(); +} + + +static void +send_buffer() +{ + if (get_session_context()->buffer_len > 0) + { + StringInfoData msgbuf; + char *cursor = get_session_context()->buffer; + + while (--get_session_context()->buffer_len > 0) + { + if (*cursor == '\0') + *cursor = '\n'; + cursor++; + } + + if (*cursor != '\0') + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("internal error"), + errdetail("Wrong message format detected"))); + + pq_beginmessage(&msgbuf, 'N'); + /* + * FrontendProtocol is not avalilable in MSVC because it is not + * PGDLLEXPORT'ed. So, we assume always the protocol >= 3. + */ +#ifndef _MSC_VER + if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3) + { +#endif + pq_sendbyte(&msgbuf, PG_DIAG_MESSAGE_PRIMARY); + pq_sendstring(&msgbuf, get_session_context()->buffer); + pq_sendbyte(&msgbuf, '\0'); +#ifndef _MSC_VER + } + else + { + *cursor++ = '\n'; + *cursor = '\0'; + pq_sendstring(&msgbuf, get_session_context()->buffer); + } +#endif + pq_endmessage(&msgbuf); + pq_flush(); + } +} + +/* + * Aux db functions + * + */ + +static void +gms_output_enable_internal(int32 n_buf_size) +{ + /* We allocate +2 bytes for an end-of-line and a string terminator. */ + if (get_session_context()->buffer == NULL) + { + get_session_context()->buffer = (char*)MemoryContextAlloc(u_sess->self_mem_cxt, n_buf_size + 2); + get_session_context()->buffer_size = n_buf_size; + get_session_context()->buffer_len = 0; + get_session_context()->buffer_get = 0; + get_session_context()->gms_getline = false; + get_session_context()->gms_valid_num = 0; + get_session_context()->gms_serveroutput = true; + } + else if (n_buf_size > get_session_context()->buffer_len) + { + /* We cannot shrink buffer less than current length. */ + get_session_context()->buffer = (char*)repalloc(get_session_context()->buffer, n_buf_size + 2); + get_session_context()->buffer_size = n_buf_size; + } + else + { + ereport(NOTICE, (errmsg("The buf size(%d) cannot be smaller than the used buf size(%d).", n_buf_size, get_session_context()->buffer_len))); + } +} + +Datum +gms_output_enable_default(PG_FUNCTION_ARGS) +{ + gms_output_enable_internal(BUFSIZE_DEFAULT); + PG_RETURN_VOID(); +} + +Datum +gms_output_enable(PG_FUNCTION_ARGS) +{ + int32 n_buf_size; + + if (PG_ARGISNULL(0)) + n_buf_size = BUFSIZE_UNLIMITED; + else + { + n_buf_size = PG_GETARG_INT32(0); + + if (n_buf_size > BUFSIZE_MAX) + { + n_buf_size = BUFSIZE_MAX; + elog(WARNING, "Limit decreased to %d bytes.", BUFSIZE_MAX); + } + else if (n_buf_size < BUFSIZE_MIN) + { + n_buf_size = BUFSIZE_MIN; + elog(WARNING, "Limit increased to %d bytes.", BUFSIZE_MIN); + } + } + + gms_output_enable_internal(n_buf_size); + PG_RETURN_VOID(); +} + +Datum +gms_output_disable(PG_FUNCTION_ARGS) +{ + if (get_session_context()->buffer) + pfree(get_session_context()->buffer); + + get_session_context()->buffer = NULL; + get_session_context()->buffer_size = 0; + get_session_context()->buffer_len = 0; + get_session_context()->buffer_get = 0; + get_session_context()->gms_getline = false; + get_session_context()->gms_valid_num = 0; + get_session_context()->gms_serveroutput = true; + PG_RETURN_VOID(); +} + +Datum +gms_output_serveroutput(PG_FUNCTION_ARGS) +{ + get_session_context()->is_server_output = PG_GETARG_BOOL(0); + if (get_session_context()->is_server_output && !get_session_context()->buffer) + gms_output_enable_internal(BUFSIZE_DEFAULT); + PG_RETURN_VOID(); +} + + +/* + * main functions + */ + +Datum +gms_output_put(PG_FUNCTION_ARGS) +{ + if (get_session_context()->buffer) + add_text(PG_GETARG_TEXT_PP(0)); + PG_RETURN_VOID(); +} + +Datum +gms_output_put_line(PG_FUNCTION_ARGS) +{ + if (get_session_context()->buffer) + { + add_text(PG_GETARG_TEXT_PP(0)); + add_newline(); + } + PG_RETURN_VOID(); +} + +Datum +gms_output_new_line(PG_FUNCTION_ARGS) +{ + if (get_session_context()->buffer) + add_newline(); + PG_RETURN_VOID(); +} + +static text * +gms_output_next(void) +{ + if (get_session_context()->buffer_get < get_session_context()->buffer_len) + { + text *line = cstring_to_text(get_session_context()->buffer + get_session_context()->buffer_get); + get_session_context()->buffer_get += VARSIZE_ANY_EXHDR(line) + 1; + return line; + } + else + return NULL; +} + +Datum +gms_output_get_line(PG_FUNCTION_ARGS) +{ + TupleDesc tupdesc; + Datum result; + HeapTuple tuple; + Datum values[2]; + bool nulls[2] = { false, false }; + text *line; + + /* Build a tuple descriptor for our result type */ + if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("function returning record called in context " + "that cannot accept type record"), + errhint("Try calling the function in the FROM clause " + "using a column definition list."))); + + if ((line = gms_output_next()) != NULL) + { + values[0] = PointerGetDatum(line); + values[1] = Int32GetDatum(0); /* 0: succeeded */ + } + else + { + nulls[0] = true; + values[1] = Int32GetDatum(1); /* 1: failed */ + } + + tuple = heap_form_tuple(tupdesc, values, nulls); + result = HeapTupleGetDatum(tuple); + + get_session_context()->gms_getline = true; + PG_RETURN_DATUM(result); +} + +Datum +gms_output_get_lines(PG_FUNCTION_ARGS) +{ + TupleDesc tupdesc; + Datum result; + HeapTuple tuple; + Datum values[2]; + bool nulls[2] = { false, false }; + text *line; + int32 max_lines = PG_GETARG_INT32(1); + int32 n; + ArrayBuildState *astate = NULL; + + /* Build a tuple descriptor for our result type */ + if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("function returning record called in context " + "that cannot accept type record"), + errhint("Try calling the function in the FROM clause " + "using a column definition list."))); + + for (n = 0; n < max_lines && (line = gms_output_next()) != NULL; n++) + { + astate = accumArrayResult(astate, PointerGetDatum(line), false, + TEXTOID, CurrentMemoryContext); + } + + /* 0: lines as text array */ + if (n > 0) + values[0] = makeArrayResult(astate, CurrentMemoryContext); + else + { + int16 typlen; + bool typbyval; + char typalign; + ArrayType *arr; + + get_typlenbyvalalign(TEXTOID, &typlen, &typbyval, &typalign); + arr = construct_md_array( + values, + NULL, + 0, NULL, NULL, TEXTOID, typlen, typbyval, typalign); + values[0] = PointerGetDatum(arr); + } + + get_session_context()->gms_getline = true; + /* 1: # of lines as integer */ + values[1] = Int32GetDatum(n); + + tuple = heap_form_tuple(tupdesc, values, nulls); + result = HeapTupleGetDatum(tuple); + + PG_RETURN_DATUM(result); +} diff --git a/contrib/gms_output/gms_output.h b/contrib/gms_output/gms_output.h new file mode 100644 index 0000000000..04dea64e12 --- /dev/null +++ b/contrib/gms_output/gms_output.h @@ -0,0 +1,34 @@ +#ifndef __GMS_OUTPUT__ +#define __GMS_OUTPUT__ + +#include "postgres.h" + +#define OUTPUTBUF_LEN 10240 + +typedef struct OutputContext { + bool is_server_output = false; + char *buffer = NULL; + int buffer_size = 0; /* allocated bytes in buffer */ + int buffer_len = 0; /* used bytes in buffer */ + int buffer_get = 0; /* retrieved bytes in buffer */ + uint32 gms_buf_get; /* retrieved bytes in buffer */ + bool gms_getline; /* in order to clean buffer */ + int64 gms_valid_num; + char output_buf[OUTPUTBUF_LEN]; + bool gms_serveroutput; +} OutputContext; + +extern "C" Datum gms_output_enable_default(PG_FUNCTION_ARGS); +extern "C" Datum gms_output_enable(PG_FUNCTION_ARGS); +extern "C" Datum gms_output_disable(PG_FUNCTION_ARGS); +extern "C" Datum gms_output_serveroutput(PG_FUNCTION_ARGS); +extern "C" Datum gms_output_put(PG_FUNCTION_ARGS); +extern "C" Datum gms_output_put_line(PG_FUNCTION_ARGS); +extern "C" Datum gms_output_new_line(PG_FUNCTION_ARGS); +extern "C" Datum gms_output_get_line(PG_FUNCTION_ARGS); +extern "C" Datum gms_output_get_lines(PG_FUNCTION_ARGS); +extern "C" void set_extension_index(uint32 index); +extern "C" void init_session_vars(void); +extern "C" OutputContext* get_session_context(); + +#endif // __GMS_OUTPUT__ \ No newline at end of file diff --git a/contrib/gms_output/sql/gms_output.sql b/contrib/gms_output/sql/gms_output.sql new file mode 100644 index 0000000000..984cf86d31 --- /dev/null +++ b/contrib/gms_output/sql/gms_output.sql @@ -0,0 +1,705 @@ +create extension gms_output; +create schema gms_output_test; +set search_path=gms_output_test; + +-- test gms_output.disable +select gms_output.DISABLE; +select gms_output.DISABLE(null); +select gms_output.DISABLE(); +select gms_output.DISABLE(''); +select gms_output.DISABLE(0); +select gms_output.DISABLE(""""); +select gms_output.DISABLE(@); +select gms_output.DISABLE(あ); +select gms_output.DISABLE(%); +select gms_output.DISABLE('qqqq'); +select gms_output.DISABLE; +select gms_output.PUT_LINE('adsfds'); +select gms_output.GET_LINE(0,1); + +-- test gms_output.enable +select gms_output.enable(1000000); +select gms_output.enable(20000); +select gms_output.enable(1000001); +select gms_output.enable(19999); +select gms_output.enable(30000); +select gms_output.enable(power(2,31)); +select gms_output.enable(-555.55); +select gms_output.enable(0.555.55); +select gms_output.enable(000.555); +select gms_output.enable(ssss); +select gms_output.enable('ssss'); +select gms_output.enable(-power(2,32)); +select gms_output.enable(-power(2,21)); +select gms_output.enable(a); +select gms_output.enable('a'); +select gms_output.enable(' '); +select gms_output.enable(null); +select gms_output.enable(0); +select gms_output.enable(あ); +select gms_output.enable('あ'); +select gms_output.enable('@'); +select gms_output.enable(1000,1000); +select gms_output.enable(1000,null); +select gms_output.enable('null'); +select gms_output.enable('山东东海偶然打赏'); +select gms_output.enable(0); + +create table t(a int, b int, c int); +insert into t values(111111,222222,333333); +insert into t values(444444,555555,666666); +insert into t values(777777,888888,999999); + +create table tt(aa int,bb varchar2(100)); +declare +msg varchar2(120); +cursor t_cur is select * from t order by a; +v_line varchar2(100); + v_status integer := 0; +begin + gms_output.enable; +for i in t_cur loop + msg := i.a || ',' || i.b || ',' || i.c; + gms_output.put_line(msg); +end loop; + + gms_output.get_line(v_line, v_status); + while v_status = 0 loop + insert into tt values(v_status, v_line); + gms_output.get_line(v_line, v_status); +end loop; +end; +/ +--查看结果 +select * from tt; + +--清理资源 +drop table t; +drop table tt; + +-- test gms_output.get_line +begin + gms_output.ENABLE(100); + gms_output.put('This '); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put(); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put(null); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put(null); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put(-999888,pppp); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put(123213123); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put('未来更快更高更强,hsdufdsnjfs,shfusdfjfjs,12313213'); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put('未来更快更高更强'); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put('@#¥#@@#!@#!#¥@%%'); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put('2017-09-23'); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put('2017-09-23 12:23:29,2000/07/99'); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put('Time Started: ' || TO_CHAR('2001-09-28 01:00:00'::timestamp, 'DD-MON-YYYY HH24:MI:SS')); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put('Time Started: ' || TO_CHAR('2001-09-28 01:00:00'::timestamp, 'DD-MON-YYYY HH24:MI:SS')); +end; +/ + +begin + gms_output.ENABLE(100); + gms_output.put('∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put('This '); + gms_output.put('is '); + gms_output.new_line(); +end; +/ +select gms_output.GET_LINE(); + +begin + gms_output.ENABLE(100); + gms_output.put('This '); + gms_output.put('is '); + gms_output.put('函数测试历史的反思的'); +end; +/ +select gms_output.GET_LINE(); + +select gms_output.GET_LINE(power(2,32)); +select gms_output.GET_LINE(power(2,9999)); +select gms_output.GET_LINE(あ@ 、iohgfvcs大富大贵); +select gms_output.GET_LINE(); +select gms_output.GET_LINE(''); +select gms_output.GET_LINE(null); +select gms_output.GET_LINE('aaaa'); +select gms_output.GET_LINE('和士大夫大师傅即使对方'); +select gms_output.GET_LINE(111); +select gms_output.GET_LINE(0); + +SET search_path to gms_output; +create table t(a int, b int, c int); +create table tt(aa int,bb varchar2(100)); +insert into t values(111111,222222,333333); +insert into t values(444444,555555,666666); +insert into t values(777777,888888,999999); + +declare +msg varchar2(120); +cursor t_cur is select * from t order by a; +v_line varchar2(100); +v_status integer := 0; +begin +gms_output.disable(); +gms_output.enable; +for i in t_cur loop +msg := i.a || ',' || i.b || ',' || i.c; +raise notice 'msg=%',msg; +gms_output.put_line(msg); +end loop; + +gms_output.get_line(v_line, v_status); +while v_status = 0 loop +raise notice 'v_line=%,v_status=%',v_line,v_status; +insert into tt values(v_status, v_line); +gms_output.get_line(v_line, v_status); +end loop; +end; +/ +select * from tt; + +delete from t; +delete from tt; + +declare +v_line varchar2(100); +v_status integer := 0; +begin +gms_output.enable; +gms_output.put('This '); +gms_output.new_line; +gms_output.put('end '); + +gms_output.get_line(v_line, v_status); +while v_status = 0 loop +raise notice 'v_line=%,v_status=%',v_line,v_status; +insert into tt values(v_status, v_line); +gms_output.get_line(v_line, v_status); +end loop; +end; +/ +select * from tt; + +-- test gms_output.get_lines +begin + gms_output.enable(100); + gms_output.PUT_LINE('{131231321312313},{dhsfsdjfsdf}'); + gms_output.PUT_LINE('{好还是打发士大夫},{dhsfsdjfsdf}'); +end; +/ + +select gms_output.get_lines('{lines}',3); + +begin + gms_output.enable(100); + gms_output.PUT_LINE('{131231321312313,wrewerwr,werwerw},{dhsfsdjfsdf}'); + gms_output.PUT_LINE('88无任何为维护差旅费{dhsfsdjfsdf}'); + gms_output.PUT_LINE('u威力五二年初的v下'); +end; +/ + +select gms_output.get_lines('{lines}',3); + +begin + gms_output.enable(100); + gms_output.PUT_LINE('[131231321312313,wrewerwr,werwerw},{dhsfsdjfsdf]'); + gms_output.PUT_LINE('∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); +end; +/ +select gms_output.get_lines('{lines}',3); +begin + gms_output.enable(100); + gms_output.PUT_LINE('{[131231321312313,wrewerwr,werwerw]},{dhsfsdjfsdf]},{美丽泸沽湖}'); +end; +/ +select gms_output.get_lines('{lines}',3); + +--设置v_data为int形式 +declare +v_data text[]; + v_numlines number; +begin + gms_output.enable(100); + gms_output.put_line('好好学习'); + gms_output.put_line('天天向上'); + gms_output.put_line('oh ye'); + v_numlines:=3; + gms_output.get_lines(v_data,v_numlines); +for v_counter in 1..v_numlines loop + gms_output.put_line(v_data(v_counter)); +end loop; +end; +/ +select gms_output.get_lines('{lines}',3); + +select gms_output.get_lines(3); +select gms_output.get_lines('aaaa'); +select gms_output.get_lines(); +select gms_output.get_lines(0); +select gms_output.get_lines(-1); +select gms_output.get_lines(-1.666); +select gms_output.get_lines('-1.666'); +select gms_output.get_lines(null); +select gms_output.get_lines({123432}); +select gms_output.get_lines('{123432}'); +select gms_output.get_lines(3); +select gms_output.get_lines('a'); +select gms_output.get_lines(null); +select gms_output.get_lines(power(2,31)); +select gms_output.get_lines(3,99); +select gms_output.get_lines(); +select gms_output.GET_LINES('{hhh}',1); +select gms_output.get_lines('{123432}',3); +select gms_output.get_lines('{123432}','{12312312}'); +select gms_output.get_lines('{入户为了未来}',1); +select gms_output.get_lines('{入户为了未来}','1'); +select gms_output.get_lines('{入户为了未来}','hhh'); +select gms_output.get_lines('{}',''); +select gms_output.get_lines(null,null); +select gms_output.get_lines('',''); +select gms_output.get_lines(0,0); + + +--#61857668 [Oracle - gms_output.get_lines] Not support gms_output.chararr type +SET search_path to gms_output; +create table tt(aa int,bb varchar2(100)); +declare +lines gms_output.chararr; + v_numlines number; +begin + gms_output.put_line('line one'); + gms_output.put_line('line two'); + gms_output.new_line(); + gms_output.put_line('line three'); + v_numlines := 4; + gms_output.get_lines(lines, v_numlines); +for v_counter in 1..v_numlines loop + insert into tt values(v_counter, lines(v_counter)); + gms_output.put_line(lines(v_counter)); +end loop; +end; +/ + +--查看结果 +select * from tt; + + +DECLARE +lines GMSOUTPUT_LINESARRAY; + v_numlines number; +begin + --gms_output.put('This '); + --gms_output.put('is '); + gms_output.put_line('line one'); + gms_output.put_line('line two'); + gms_output.new_line(); + --gms_output.put('end.'); + gms_output.put_line('line three'); + v_numlines := 4; + gms_output.get_lines(lines, v_numlines); +for v_counter in 1..v_numlines loop + insert into tt values(v_counter, lines(v_counter)); + gms_output.put_line(lines(v_counter)); +end loop; +end; +/ + +--查看结果 +select * from tt; + +--#61857707 [Oracle - gms_output.get_lines] Accept with only one parameter +select gms_output.put_line('line one'); +select gms_output.put_line('line two'); +select gms_output.new_line(); +select gms_output.put_line('line three'); +select gms_output.get_lines(4); +select gms_output.get_lines('{0}',4); + + +--执行存储过程 +declare +lines varchar[]; + v_numlines number; +begin + --gms_output.put('This '); + --gms_output.put('is '); + gms_output.put_line('line one'); + gms_output.put_line('line two'); + gms_output.new_line(); + --gms_output.put('end.'); + gms_output.put_line('line three'); + v_numlines := 4; + gms_output.get_lines(4); +for v_counter in 1..v_numlines loop + insert into tt values(v_counter, lines(v_counter)); + gms_output.put_line(lines(v_counter)); +end loop; +end; +/ + +--查看结果 +select * from tt; + +--清理资源 +drop table tt; + +-- test gms_output.new_line +select gms_output.put('This '); +select gms_output.new_line; +select gms_output.new_line(); +select gms_output.new_line(null); +select gms_output.new_line(''); +select gms_output.new_line('hhh'); +select gms_output.new_line('""where,where"". :???????'); +select gms_output.new_line(systime); +select gms_output.new_line(8888); +select gms_output.new_line('Time Started: ' || TO_CHAR('2001-09-28 01:00:00'::timestamp, 'DD-MON-YYYY HH24:MI:SS')); +select gms_output.new_line(88889); +begin + gms_output.ENABLE(100); + gms_output.put('This '); + gms_output.put('is '); + gms_output.new_line(); +end; +/ +select gms_output.GET_LINE(); + +-- test gms_output.put +select gms_output.put('This '); +select gms_output.put(); +select gms_output.put(null); +select gms_output.put(''); +select gms_output.put(-999888,pppp); +select gms_output.put(1,21); +select gms_output.put(123213123); +select gms_output.put('未来更快更高更强','hsdufdsnjfs','shfusdfjfjs',12313213); +select gms_output.put('@#¥#@@#!@#!#¥@%%'); +select gms_output.put(2017-09-23); +select gms_output.put(2017-09-23 12:23:29); +select gms_output.put(89%); +select gms_output.put(’あ@ ‘); +select gms_output.put(2000/07/99); +select gms_output.put(power(2,32)); +select gms_output.put(power(2,9999)); +select gms_output.put('Time Started: ' || TO_CHAR('2001-09-28 01:00:00'::timestamp, 'DD-MON-YYYY HH24:MI:SS')); +select gms_output.put(あ@ 、iohgfvcs大富大贵); +select gms_output.put('、。·ˉˇ¨〃々—~‖…〔〕〈〉《》「」『』〖〗【】±+-×÷∧∨∑∏∪∩∈√⊥∥∠⌒⊙∫∮≡≌≈∽∝≠≮≯≤≥∞∶ ∵∴∷♂♀°℃$¤¢£‰§№☆*〇○*◎** 回□*△▽⊿▲▼▁▂▃▄▆**▉▊▋▌▍▎▏※→←↑↓↖↗↘↙** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!#¥%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); +select gms_output.put('123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 +'); +select gms_output.put('** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!#¥%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); + + +create table tt(aa int,bb varchar2(100)); +declare + v_line varchar2(100); + v_status integer := 0; +begin + gms_output.enable(100); + gms_output.put('This '); + gms_output.put('is '); + gms_output.new_line; + gms_output.put('end.'); + gms_output.get_line(v_line, v_status); + while v_status = 0 loop + insert into tt values(v_status, v_line); + gms_output.get_line(v_line, v_status); + end loop; +end; +/ + +--清理资源 +drop table tt; + +-- test gms_output.put_line +select gms_output.PUT_LINE('......'); +select gms_output.PUT_LINE(null); +select gms_output.PUT_LINE(131231321312313); +select gms_output.PUT_LINE('akfdskfsf??Oooo&&&^%**('); +select gms_output.PUT_LINE(''); +select gms_output.PUT_LINE(89239432094%%&&*&&**&^); +select gms_output.PUT_LINE(-0.99923332); +select gms_output.PUT_LINE(power(2,31)); +select gms_output.PUT_LINE(max(2,3)); +select gms_output.PUT_LINE('2001-09-28 01:00:00'::timestamp); +select gms_output.PUT_LINE(0); +select gms_output.PUT_LINE('adsfds'); +select gms_output.PUT_LINE(adsfds); +select gms_output.PUT_LINE(power(2,9999)); +select gms_output.PUT_LINE(power(2,9999)); +select gms_output.PUT_LINE(131231321312313,24232432); +select gms_output.PUT_LINE('疫情早日过去,国泰民安,风调雨顺,平安健康常在'); +select gms_output.PUT_LINE('123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 +'); +select gms_output.PUT_LINE('** ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ①②③④⑤⑥⑦⑧⑨⑩⒈⒉⒊⒋ ⒌⒍⒎⒏⒐⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ!#¥%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθ ικλμνξοπρστυφχψ ω︵︶︹︺︿﹀︽︾﹁﹂﹃﹄︻'); + +drop database if exists testdb_utf8; +create database testdb_utf8; +\c testdb_utf8; +create extension gms_output; +declare + a int := 10; + b varchar2(100) := 'abcdef'; + c text := '测试用例,,,,,,.. ..。。。。'; +begin + gms_output.enable(4000); + gms_output.put_line('test case'); + gms_output.put_line('test case' || a); + gms_output.put_line('test case' || b); + gms_output.put_line('test case' || c); + gms_output.put_line('测试用例'); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。'); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || a); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || b); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || c); +end; +/ + +\c contrib_regression +drop database testdb_utf8; + +drop database if exists testdb_gbk; +create database testdb_gbk encoding='GBK' LC_COLLATE='C' LC_CTYPE='C'; +\c testdb_gbk +create extension gms_output; +set client_encoding to 'UTF8'; +declare + a int := 10; + b varchar2(100) := 'abcdef'; + c text := '测试用例,,,,,,.. ..。。。。'; +begin + gms_output.enable(4000); + gms_output.put_line('test case'); + gms_output.put_line('test case' || a); + gms_output.put_line('test case' || b); + gms_output.put_line('test case' || c); + gms_output.put_line('测试用例'); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。'); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || a); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || b); + gms_output.put_line('测试用例,,,,ABCD,,....。。。。' || c); +end; +/ +reset client_encoding; +\c contrib_regression +drop database testdb_gbk; + +-- test gms_output.serveroutput +set search_path=gms_output_test; +begin +gms_output.put('123'); +gms_output.put_line('abc'); +end; +/ + +begin +gms_output.enable(4000); +gms_output.put('123'); +gms_output.new_line(); +gms_output.put_line('abc'); +end; +/ + +begin +gms_output.put('222'); +gms_output.new_line(); +end; +/ + +begin +gms_output.enable(4000); +gms_output.put_line('abc'); +end; +/ + +begin +gms_output.disable(); +gms_output.enable(4000); +gms_output.put('456'); +gms_output.put('7'); +gms_output.new_line(); +gms_output.put('89'); +gms_output.put_line('abc'); +end; +/ + +begin +gms_output.disable(); +gms_output.enable(4000); +gms_output.new_line(); +gms_output.put('456'); +gms_output.put('7'); +gms_output.put('89'); +gms_output.put_line('abc'); +gms_output.put_line('fff'); +gms_output.put_line('ggg'); +end; +/ + +begin +gms_output.enable(); +gms_output.put_l ine('abc'); +end; +/ + +begin +gms_output.put('123'); +gms_output.new_line(); +end; +/ + +begin +gms_output.put('123'); +end; +/ + +begin +gms_output.new_line(); +end; +/ + + +set gms_output.serveroutput to off; +show gms_output.serveroutput; + +begin +gms_output.put_line('2'); +end; +/ + +begin +gms_output.enable(4000); +gms_output.put_line('abc'); +end; +/ + +set gms_output.serveroutput to on; +begin +gms_output.enable(4000); +gms_output.put('123'); +gms_output.put_line('YYY'); +end; +/ + + +begin +gms_output.disable(); +gms_output.enable(4000); +gms_output.put('33'); +end; +/ + +begin +gms_output.put('44'); +gms_output.new_line(); +end; +/ + +create table gms_output_tt3(aa int,bb varchar2(100)); +declare +v_line varchar2(100); +v_status integer := 0; +begin +gms_output.put_line('55'); +gms_output.get_line(v_line, v_status); +insert into gms_output_tt3 values(v_status, v_line); +end; +/ +select * from gms_output_tt3; + + +begin + gms_output.ENABLE; + gms_output.put_line('This '); +end; +/ +select gms_output.GET_LINE(0,1); + + +begin + gms_output.enable(100); + gms_output.PUT_LINE('{131231321312313},{dhsfsdjfsdf}'); + gms_output.PUT_LINE('{好还是打发士大夫},{dhsfsdjfsdf}'); +end; +/ +select gms_output.get_lines('{lines}',3); + + +reset search_path; +drop schema gms_output_test cascade; diff --git a/src/common/backend/utils/error/elog.cpp b/src/common/backend/utils/error/elog.cpp index 6e87e590fc..31ee6fdbb6 100644 --- a/src/common/backend/utils/error/elog.cpp +++ b/src/common/backend/utils/error/elog.cpp @@ -1815,6 +1815,23 @@ int ignore_interrupt(bool ignore) return 0; /* return value does not matter */ } +/* + * onlyfrontmsg + * outputflag, false -- output err level + * true -- don' output err level + */ +int onlyfrontmsg(bool onlyfront) +{ + ErrorData* edata = &t_thrd.log_cxt.errordata[t_thrd.log_cxt.errordata_stack_depth]; + + /* we don't bother incrementing t_thrd.log_cxt.recursion_depth */ + CHECK_STACK_DEPTH(); + + edata->onlyfrontmsg = onlyfront; + + return 0; /* return value does not matter */ +} + /* * elog_start --- startup for old-style API * @@ -3992,8 +4009,10 @@ void send_message_to_frontend(ErrorData* edata) char vbuf[256] = {0}; errno_t rc = 0; - pq_sendbyte(&msgbuf, PG_DIAG_SEVERITY); - err_sendstring(&msgbuf, error_severity(edata->elevel)); + if (!edata->onlyfrontmsg) { + pq_sendbyte(&msgbuf, PG_DIAG_SEVERITY); + err_sendstring(&msgbuf, error_severity(edata->elevel)); + } /* get mpp internal errcode */ if (edata->elevel >= ERROR) { @@ -4081,9 +4100,11 @@ void send_message_to_frontend(ErrorData* edata) err_sendstring(&msgbuf, edata->hint); } - if (edata->context) { - pq_sendbyte(&msgbuf, PG_DIAG_CONTEXT); - err_sendstring(&msgbuf, edata->context); + if (!edata->onlyfrontmsg) { + if (edata->context) { + pq_sendbyte(&msgbuf, PG_DIAG_CONTEXT); + err_sendstring(&msgbuf, edata->context); + } } if (edata->cursorpos > 0) { @@ -4146,7 +4167,8 @@ void send_message_to_frontend(ErrorData* edata) initStringInfo(&buf); - appendStringInfo(&buf, "%s: ", error_severity(edata->elevel)); + if (!edata->onlyfrontmsg) + appendStringInfo(&buf, "%s: ", error_severity(edata->elevel)); if (edata->show_funcname && edata->funcname) appendStringInfo(&buf, "%s: ", edata->funcname); diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 4f302958d2..c111c3fd77 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -269,6 +269,8 @@ extern void save_error_message(void); extern int handle_in_client(bool handle); extern int ignore_interrupt(bool ignore); +extern int onlyfrontmsg(bool onlyfront); + /* ---------- * Old-style error reporting API: to be used in this way: * elog(ERROR, "portal \"%s\" not found", stmt->portalname); @@ -546,6 +548,7 @@ typedef struct ErrorData { char* mysql_errno; /* mysql_errno for signal/resignal */ bool is_warnings_throw; int is_signal; + bool onlyfrontmsg; /* outputflag, 1-output err level, 0 (default) - don't output err level */ } ErrorData; /* The error data from remote */ -- Gitee