Compare commits
417 Commits
Author | SHA1 | Date | |
---|---|---|---|
798b1578c7 | |||
e639c93745 | |||
aee4abd5a9 | |||
4598c5a0e2 | |||
39b731c3c9 | |||
69ce41441f | |||
9f3bbe1498 | |||
7131cfdf69 | |||
4cd9fb39b6 | |||
53f30c3480 | |||
e1fc50a11e | |||
aa47121f0c | |||
95e91ee009 | |||
667bd6e18a | |||
55e96153ba | |||
ebf2c30906 | |||
791ae609c3 | |||
03244e9bf4 | |||
e0c591eead | |||
378145616e | |||
497716f055 | |||
da08958ae1 | |||
d3141a539a | |||
c6ebce3448 | |||
ed61b63d51 | |||
8a65ab5c97 | |||
72796eb739 | |||
93e2794d97 | |||
380893b848 | |||
2c7ec7d438 | |||
be640a6f3e | |||
05684cd58c | |||
aeb9d95f03 | |||
741f36137f | |||
38c4d3c927 | |||
863f6e28a1 | |||
b71d52e068 | |||
c4d9c5a935 | |||
9b224ace74 | |||
07e15d9b8e | |||
46d687a7d6 | |||
13434bbd6c | |||
cc283b1a62 | |||
537754b19a | |||
f65194263d | |||
58fa9e7a9c | |||
3623d0d7d4 | |||
99f5fbe830 | |||
57b6f5b268 | |||
85275e7afe | |||
9c06a4e035 | |||
ea8b5d0e81 | |||
ad090a92ad | |||
032fe44d2c | |||
970aa0b7f4 | |||
c819d322b2 | |||
49eb6a7c73 | |||
63ec10a5b1 | |||
0cc2650091 | |||
c56f1b1e61 | |||
37c4053802 | |||
206d898b7c | |||
81102d0bed | |||
92fe57498b | |||
a9ea07a515 | |||
fb059f1bf4 | |||
7fbf409ca3 | |||
ef742776a3 | |||
f502278bd6 | |||
0b8779bd92 | |||
5ec9f92edc | |||
5a6a8fca6d | |||
a7bc90d8a0 | |||
5a50138d4a | |||
495043de60 | |||
0e5b4fb5d8 | |||
d8bcc06cb5 | |||
dc8201832e | |||
d4115a3fef | |||
77fba827a8 | |||
dbbc6c0411 | |||
fc9e24fd68 | |||
06dc380e92 | |||
105521c7d2 | |||
3ddb5e18e5 | |||
ef4a42bd92 | |||
f8fab22fe7 | |||
720611da87 | |||
94b25a82a9 | |||
cfd695f68b | |||
6e66c5593f | |||
7e074c1bbe | |||
6118e3101b | |||
a15ced4cb3 | |||
5699a19ec9 | |||
73a3b12aaf | |||
175b0bfe6e | |||
f10fe94e73 | |||
e2c3d0f7b3 | |||
b3ef96ed98 | |||
62306b3659 | |||
1bb33c8b0c | |||
3f20f0ec97 | |||
1dd223bfad | |||
f7dfe3c8ee | |||
a0b11e8598 | |||
b3a66b9a2f | |||
6820d256d5 | |||
86db729f15 | |||
29c1beae43 | |||
d628ab0287 | |||
d1c7237392 | |||
6e10acf42d | |||
fc16cd266b | |||
a1f8849c2d | |||
b05ee46193 | |||
621e1a08eb | |||
9773a93348 | |||
00031fa002 | |||
da413cd32b | |||
340213c02f | |||
f7f29f8616 | |||
1d01ca2322 | |||
03e6cefbed | |||
3f69dced1f | |||
0f4950c5c1 | |||
89f38655fd | |||
0069e279d7 | |||
bf3301a877 | |||
d9005042dc | |||
d1106f60ce | |||
603b2b229a | |||
70771ca8f9 | |||
ffdb495ae9 | |||
4abe729a34 | |||
e14da8e932 | |||
dc73a34ec0 | |||
d42a002b45 | |||
2b43adf079 | |||
930a4a50b7 | |||
629b42c146 | |||
c5e3a42ff4 | |||
852b9b1992 | |||
828915d218 | |||
ff0c539173 | |||
bd89025f62 | |||
72477084f6 | |||
df3650b379 | |||
a420ff5864 | |||
0eccf73fd3 | |||
6015a73174 | |||
d1bb32e19e | |||
fb1998108c | |||
fab02519e5 | |||
a5cec5691d | |||
e6f2d78a71 | |||
16e864c8a8 | |||
d689194a3b | |||
81a21961a6 | |||
0a552bc4a1 | |||
7718b74760 | |||
9b3761886b | |||
67b2a26c83 | |||
990fe21892 | |||
1d8d5bc181 | |||
7a7ed89fa8 | |||
b436e223dc | |||
61df640bd2 | |||
5e1cef64e4 | |||
dff0950d15 | |||
601554b70d | |||
03b6b1133d | |||
eac925faf3 | |||
661b839d65 | |||
93760a1cf0 | |||
9d526dc226 | |||
4567180c9b | |||
c85f7816cf | |||
2b3b91de17 | |||
97606c5f74 | |||
5689528668 | |||
0a66e218ab | |||
3f5ec8615f | |||
a1b6de0221 | |||
e33ca8c8df | |||
4ac0249a02 | |||
90359d51a2 | |||
44a910597c | |||
9e74feea7c | |||
e6640f7537 | |||
0d75f54943 | |||
494b4e1354 | |||
091ed11fe7 | |||
bead01529d | |||
ede18e6fa7 | |||
67f332fbe7 | |||
8db8872ab3 | |||
7e7815ac26 | |||
f1bb6ed4cf | |||
529f7d1c08 | |||
d17ef9186a | |||
3a01e52099 | |||
482f3b22c5 | |||
5c3b91c614 | |||
2d6540c09d | |||
6daf703e8b | |||
4dc7320616 | |||
05c0c713c8 | |||
28fcdf6021 | |||
f697021c3e | |||
c7629cdc5b | |||
ed878bad84 | |||
1c9b80dd9c | |||
b539c916e4 | |||
2090e54336 | |||
fc9f6133d6 | |||
04d959f2e9 | |||
5fda8312ae | |||
e13da19b10 | |||
67702f955d | |||
33cc11e19c | |||
23dfdb252c | |||
4df62c7a71 | |||
a40c22e0da | |||
ad4fda5161 | |||
818123d1b2 | |||
864a80feeb | |||
6bfff953a1 | |||
56326674c3 | |||
08adf068a5 | |||
ef695a4ff1 | |||
45af8e8b6d | |||
bd7ee588ae | |||
2cb3c26242 | |||
59532faa2f | |||
0e63729052 | |||
03ff529a9f | |||
9a83ea0d9b | |||
1d179d6d10 | |||
ca86a61c83 | |||
870f395b78 | |||
8abbc43db1 | |||
21ac1baedb | |||
a4018fa9ad | |||
aa922b7d16 | |||
1544bbd6a6 | |||
9ed9edd162 | |||
88ceb61dbb | |||
6e0800f762 | |||
8f32c4fc9f | |||
307b67f584 | |||
8da20f24e4 | |||
c3b3dd1ba7 | |||
abff4b07ea | |||
c797d0f781 | |||
ff88b05008 | |||
5f620997e3 | |||
c1b6c3f679 | |||
26d0d62226 | |||
afced4a454 | |||
7d862324c4 | |||
6f1014f4a6 | |||
954a190698 | |||
b8a8381bf3 | |||
6ad97146b7 | |||
2007923231 | |||
23d72172dd | |||
5c2e952d68 | |||
2768c58a70 | |||
5e2c10cf94 | |||
0affe97dab | |||
f39e926d7c | |||
a83b2231e9 | |||
9045a72a96 | |||
22e67d7d83 | |||
b25189e014 | |||
129e40ba93 | |||
e42d3bc1b4 | |||
51f6f536e5 | |||
5b3f49a811 | |||
ce83d33ead | |||
e2c1837fdb | |||
9fc0c60333 | |||
c1255aea25 | |||
f9efb3801f | |||
e1ada5908f | |||
1d428758d2 | |||
9da6ba4934 | |||
9e98f1b986 | |||
faf284427a | |||
5d1bd1a24b | |||
89bd6d692b | |||
eaa5ceb828 | |||
bd17be7e89 | |||
169d76ecf9 | |||
d89f731511 | |||
dc3d590d42 | |||
d6e88e46ff | |||
fa3fd32295 | |||
01b6c890ac | |||
46ad2f3762 | |||
ed9a6ed9a6 | |||
7d55eae53b | |||
650185a6a9 | |||
6f6ffa16de | |||
40ce35a699 | |||
ab766232d9 | |||
d06c2647ab | |||
8310f00665 | |||
98ff0047b9 | |||
53bc767d0a | |||
c874174c84 | |||
ae8519169b | |||
e964345927 | |||
a8e1cb9eb5 | |||
fbfd47253c | |||
4c098a3b45 | |||
a300083710 | |||
31c773531a | |||
a40b6aa307 | |||
32c40d4d3a | |||
024e7d3db8 | |||
920adcf851 | |||
4997c8f4a6 | |||
3797839c9c | |||
c1af2e6b39 | |||
a88bcd7233 | |||
9f68af5fe0 | |||
8e6c03f231 | |||
e0375f06a8 | |||
4873cfee07 | |||
a1643f3d40 | |||
c035d918cd | |||
034246cd92 | |||
5eaf0ef473 | |||
a187682387 | |||
d1cf22ed91 | |||
29481a478b | |||
5ef0092453 | |||
835244bb91 | |||
e1fafef32c | |||
630c80123c | |||
f7c7210363 | |||
327a0577af | |||
76dc3b41ac | |||
5c93a0b8db | |||
bd89cca28d | |||
991f55d6fd | |||
c43386a5ff | |||
5a64689742 | |||
ede1efa323 | |||
3563b7ee66 | |||
b2ce87c80b | |||
a8f6a23f50 | |||
18411c1b42 | |||
fb09a5d890 | |||
d49a4ec6b5 | |||
c1499a1a29 | |||
1c8aaf633b | |||
4992f2c3a2 | |||
b78a170b41 | |||
a1481b3659 | |||
20743d5b46 | |||
208ad93f24 | |||
27846aaed8 | |||
cc45497719 | |||
b0fc50b304 | |||
a80037e196 | |||
7d216903a5 | |||
22492a48dc | |||
24bb00de46 | |||
7b691eed29 | |||
8a88ae5ae0 | |||
90b4234ac0 | |||
ecef881857 | |||
338a9aa049 | |||
3e55a1f4df | |||
19970f6aa8 | |||
f792af0477 | |||
bb6c8021da | |||
1daa5d3f1a | |||
08185db85e | |||
bf6c1d8f0d | |||
aa5ac47501 | |||
24f1d6e46b | |||
a1f7ef3c80 | |||
710ba955d2 | |||
d9f593397d | |||
cec8a80320 | |||
be34dc2c25 | |||
26fb4a237b | |||
d3e4ddbc48 | |||
e4c3e01cb2 | |||
08a5db7c58 | |||
428ee7d27e | |||
73b9ecc263 | |||
2ca24dcbc9 | |||
deb8e6def1 | |||
7b194a09bf | |||
3b8138c3d2 | |||
00fb678a69 | |||
54853fd25f | |||
a04eaf4082 | |||
924af9e9f6 | |||
4c9ff79cff | |||
5cc61ab49e | |||
8c9e9d422e | |||
7e4897cab5 | |||
bffec6fd18 | |||
94fce5b325 | |||
338ba16595 | |||
81a82a9f69 | |||
c9ae15ec72 | |||
f7844f5ae6 | |||
0d1f8df897 | |||
3d5f50b012 | |||
b8992f5cff |
@ -36,15 +36,6 @@ endif()
|
||||
if("${ENABLE_PRIVATEGAUSS}" STREQUAL "ON")
|
||||
MESSAGE(FATAL_ERROR " The option ENABLE_PRIVATEGAUSS is not supported thus should be turned off.")
|
||||
endif()
|
||||
if("${ENABLE_LITE_MODE}" STREQUAL "")
|
||||
set(ENABLE_LITE_MODE "OFF")
|
||||
endif()
|
||||
if("${ENABLE_MOT}" STREQUAL "")
|
||||
set(ENABLE_MOT "OFF")
|
||||
endif()
|
||||
if("${ENABLE_HTAP}" STREQUAL "")
|
||||
set(ENABLE_HTAP "ON")
|
||||
endif()
|
||||
|
||||
#FIXME: make it an argument
|
||||
set(openGauss ".")
|
||||
@ -116,11 +107,11 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/pg_plugin DESTINATION lib/postgresql)
|
||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/libsimsearch DESTINATION lib)
|
||||
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/contrib/dolphin)
|
||||
install(CODE "execute_process(COMMAND bash cmake.sh ${BUILD_TUPLE} ${ENABLE_LITE_MODE} ${ENABLE_MOT} ${ENABLE_HTAP} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/contrib/dolphin)")
|
||||
install(CODE "execute_process(COMMAND bash cmake.sh WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/contrib/dolphin)")
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/dolphin/dolphin.control
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/dolphin/dolphin--5.0.sql
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/dolphin/dolphin--4.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/dolphin/dolphin--1.0--1.1.sql
|
||||
@ -147,12 +138,6 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/contrib/dolphin)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/dolphin/dolphin--4.0--3.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/dolphin/dolphin--4.0--5.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/dolphin/dolphin--5.0--4.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/contrib/dolphin/dolphin--2.0--2.0.1.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
|
@ -102,28 +102,11 @@ install:
|
||||
@if test -d contrib/spq_plugin; then $(MAKE) -C contrib/spq_plugin $@; fi
|
||||
@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 clean; fi
|
||||
@if test -d contrib/datavec; then $(MAKE) -C contrib/datavec $@; fi
|
||||
@if test -d contrib/gms_compress; then $(MAKE) -C contrib/gms_compress $@; fi
|
||||
@if test -d contrib/gms_utility; then $(MAKE) -C contrib/gms_utility $@; fi
|
||||
@if test -d contrib/gms_stats; then $(MAKE) -C contrib/gms_stats $@; fi
|
||||
@if test -d contrib/gms_tcp; then $(MAKE) -C contrib/gms_tcp $@; fi
|
||||
@if test -d contrib/gms_profiler; then $(MAKE) -C contrib/gms_profiler $@; fi
|
||||
@if test -d contrib/gms_xmlgen; then $(MAKE) -C contrib/gms_xmlgen $@; fi
|
||||
@if test -d contrib/gms_output; then $(MAKE) -C contrib/gms_output $@; fi
|
||||
@if test -d contrib/gms_i18n; then $(MAKE) -C contrib/gms_i18n $@; fi
|
||||
@if test -d contrib/gms_inaddr; then $(MAKE) -C contrib/gms_inaddr $@; fi
|
||||
@if test -d contrib/timescaledb; then (./contrib/timescaledb/run_to_build.sh && $(MAKE) -C contrib/timescaledb/build $@); fi
|
||||
@if test -d contrib/chparser; then \
|
||||
if command -v scws &> /dev/null; then \
|
||||
$(MAKE) -C contrib/chparser $@; \
|
||||
else \
|
||||
echo "SCWS is not installed, skipping chparser build."; \
|
||||
fi \
|
||||
fi
|
||||
@if test -d contrib/gms_lob; then $(MAKE) -C contrib/gms_lob $@; fi
|
||||
@if test -d contrib/gms_sql; then $(MAKE) -C contrib/gms_sql $@; fi
|
||||
@if test -d contrib/gms_debug; then $(MAKE) -C contrib/gms_debug $@; fi
|
||||
+@echo "openGauss installation complete."
|
||||
endif
|
||||
endif
|
||||
|
17
README.md
17
README.md
@ -498,22 +498,9 @@ https://opengauss.org/zh/
|
||||
<strong>openEuler 22.03 arm:</strong> <a href="https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_arm.tar.gz">https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_arm.tar.gz</a><br/>
|
||||
<strong>openEuler 22.03 x86:</strong> <a href="https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_x86_64.tar.gz">https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_x86_64.tar.gz</a></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan=1>6.0.0</td>
|
||||
<td rowspan=1></td>
|
||||
<td>gcc10.3</td>
|
||||
<td rowspan=1>
|
||||
<strong>openEuler_arm:</strong> <a href="https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_arm.tar.gz">https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_arm.tar.gz</a><br/>
|
||||
<strong>openEuler_x86:</strong> <a href="https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz">https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz</a><br/>
|
||||
<strong>Centos_x86:</strong> <a href="https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz">https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz</a><br/>
|
||||
<strong>openEuler 22.03 arm:</strong> <a href="https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_arm.tar.gz">https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_arm.tar.gz</a><br/>
|
||||
<strong>openEuler 22.03 x86:</strong> <a href="https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_x86_64.tar.gz">https://opengauss.obs.cn-south-1.myhuaweicloud.com/6.0.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_x86_64.tar.gz</a></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan=1>master</td>
|
||||
<td rowspan=1></td>
|
||||
<td rowspan=2>master</td>
|
||||
<td rowspan=2></td>
|
||||
<td>gcc10.3</td>
|
||||
<td rowspan=1>
|
||||
<strong>openEuler_arm:</strong> <a href="https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_arm.tar.gz">https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_arm.tar.gz</a><br/>
|
||||
|
3
build/.gitignore
vendored
3
build/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
||||
!script/
|
@ -1,7 +1,6 @@
|
||||
[server]
|
||||
./bin/dsscmd
|
||||
./bin/dssserver
|
||||
./bin/dsstbox
|
||||
./bin/perctrl
|
||||
./bin/dms_contrl.sh
|
||||
./bin/dss_clear.sh
|
||||
@ -77,7 +76,7 @@
|
||||
./share/postgresql/extension/spqplugin.control
|
||||
./share/postgresql/extension/spqplugin--1.0.sql
|
||||
./share/postgresql/extension/dolphin.control
|
||||
./share/postgresql/extension/dolphin--5.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/dolphin--1.1--2.0.sql
|
||||
@ -86,8 +85,6 @@
|
||||
./share/postgresql/extension/dolphin--3.0--2.0.sql
|
||||
./share/postgresql/extension/dolphin--3.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--3.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--5.0.sql
|
||||
./share/postgresql/extension/dolphin--5.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--2.0--2.0.1.sql
|
||||
./share/postgresql/extension/dolphin--2.0.1--2.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--4.0.1.sql
|
||||
|
@ -34,7 +34,7 @@
|
||||
./share/postgresql/extension/security_plugin.control
|
||||
./share/postgresql/extension/security_plugin--1.0.sql
|
||||
./share/postgresql/extension/dolphin.control
|
||||
./share/postgresql/extension/dolphin--5.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/dolphin--1.1--2.0.sql
|
||||
@ -43,14 +43,10 @@
|
||||
./share/postgresql/extension/dolphin--3.0--2.0.sql
|
||||
./share/postgresql/extension/dolphin--3.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--3.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--5.0.sql
|
||||
./share/postgresql/extension/dolphin--5.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--2.0--2.0.1.sql
|
||||
./share/postgresql/extension/dolphin--2.0.1--2.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--4.0.1.sql
|
||||
./share/postgresql/extension/dolphin--4.0.1--4.0.sql
|
||||
./share/postgresql/extension/gms_compress--1.0.sql
|
||||
./share/postgresql/extension/gms_compress.control
|
||||
./share/postgresql/extension/openGauss_expr_dolphin.ir
|
||||
./share/postgresql/extension/file_fdw--1.0.sql
|
||||
./share/postgresql/extension/plpgsql.control
|
||||
@ -63,24 +59,6 @@
|
||||
./share/postgresql/extension/hstore--1.0--1.1.sql
|
||||
./share/postgresql/extension/log_fdw--1.0.sql
|
||||
./share/postgresql/extension/log_fdw.control
|
||||
./share/postgresql/extension/gms_utility--1.0.sql
|
||||
./share/postgresql/extension/gms_utility.control
|
||||
./share/postgresql/extension/gms_output--1.0.sql
|
||||
./share/postgresql/extension/gms_output.control
|
||||
./share/postgresql/extension/gms_stats--1.0.sql
|
||||
./share/postgresql/extension/gms_stats.control
|
||||
./share/postgresql/extension/gms_profiler--1.0.sql
|
||||
./share/postgresql/extension/gms_profiler.control
|
||||
./share/postgresql/extension/gms_debug--1.0.sql
|
||||
./share/postgresql/extension/gms_debug.control
|
||||
./share/postgresql/extension/gms_lob--1.0.sql
|
||||
./share/postgresql/extension/gms_lob.control
|
||||
./share/postgresql/extension/gms_sql--1.0.sql
|
||||
./share/postgresql/extension/gms_sql.control
|
||||
./share/postgresql/extension/gms_i18n--1.0.sql
|
||||
./share/postgresql/extension/gms_i18n.control
|
||||
./share/postgresql/extension/gms_inaddr--1.0.sql
|
||||
./share/postgresql/extension/gms_inaddr.control
|
||||
./share/postgresql/timezone/GB-Eire
|
||||
./share/postgresql/timezone/Turkey
|
||||
./share/postgresql/timezone/Kwajalein
|
||||
@ -765,20 +743,10 @@
|
||||
./lib/postgresql/proc_srclib
|
||||
./lib/postgresql/security_plugin.so
|
||||
./lib/postgresql/dolphin.so
|
||||
./lib/postgresql/gms_compress.so
|
||||
./lib/postgresql/pg_upgrade_support.so
|
||||
./lib/postgresql/latin2_and_win1250.so
|
||||
./lib/postgresql/euc2004_sjis2004.so
|
||||
./lib/postgresql/pgoutput.so
|
||||
./lib/postgresql/gms_utility.so
|
||||
./lib/postgresql/gms_output.so
|
||||
./lib/postgresql/gms_stats.so
|
||||
./lib/postgresql/gms_profiler.so
|
||||
./lib/postgresql/gms_lob.so
|
||||
./lib/postgresql/gms_sql.so
|
||||
./lib/postgresql/gms_i18n.so
|
||||
./lib/postgresql/gms_debug.so
|
||||
./lib/postgresql/gms_inaddr.so
|
||||
./include/postgresql/server/postgres_ext.h
|
||||
./include/postgresql/server/pg_config_os.h
|
||||
./include/postgresql/server/pgtime.h
|
||||
@ -955,4 +923,4 @@
|
||||
./include/pqcomm.h
|
||||
./include/pqexpbuffer.h
|
||||
[version]
|
||||
7.0.0-RC1
|
||||
6.0.0
|
||||
|
@ -1,7 +1,6 @@
|
||||
[server]
|
||||
./bin/dsscmd
|
||||
./bin/dssserver
|
||||
./bin/dsstbox
|
||||
./bin/perctrl
|
||||
./bin/dms_contrl.sh
|
||||
./bin/dss_clear.sh
|
||||
@ -80,7 +79,7 @@
|
||||
./share/postgresql/extension/timescaledb.control
|
||||
./share/postgresql/extension/timescaledb--1.7.4.sql
|
||||
./share/postgresql/extension/dolphin.control
|
||||
./share/postgresql/extension/dolphin--5.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/dolphin--1.1--2.0.sql
|
||||
@ -89,8 +88,6 @@
|
||||
./share/postgresql/extension/dolphin--3.0--2.0.sql
|
||||
./share/postgresql/extension/dolphin--3.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--3.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--5.0.sql
|
||||
./share/postgresql/extension/dolphin--5.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--2.0--2.0.1.sql
|
||||
./share/postgresql/extension/dolphin--2.0.1--2.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--4.0.1.sql
|
||||
@ -98,10 +95,8 @@
|
||||
./share/postgresql/extension/openGauss_expr_dolphin.ir
|
||||
./share/postgresql/extension/age--1.0.0.sql
|
||||
./share/postgresql/extension/age.control
|
||||
./share/postgresql/extension/datavec--1.0.sql
|
||||
./share/postgresql/extension/datavec--0.4.4.sql
|
||||
./share/postgresql/extension/datavec.control
|
||||
./share/postgresql/extension/chparser--1.0.sql
|
||||
./share/postgresql/extension/chparser.control
|
||||
./share/postgresql/extension/assessment--1.0.sql
|
||||
./share/postgresql/extension/assessment.control
|
||||
./share/postgresql/extension/file_fdw--1.0.sql
|
||||
@ -122,30 +117,12 @@
|
||||
./share/postgresql/extension/dblink--1.0.sql
|
||||
./share/postgresql/extension/dblink--unpackaged--1.0.sql
|
||||
./share/postgresql/extension/dblink.control
|
||||
./share/postgresql/extension/gms_compress--1.0.sql
|
||||
./share/postgresql/extension/gms_compress.control
|
||||
./share/postgresql/extension/gms_utility--1.0.sql
|
||||
./share/postgresql/extension/gms_utility.control
|
||||
./share/postgresql/extension/gms_output--1.0.sql
|
||||
./share/postgresql/extension/gms_output.control
|
||||
./share/postgresql/extension/gms_inaddr--1.0.sql
|
||||
./share/postgresql/extension/gms_inaddr.control
|
||||
./share/postgresql/extension/gms_lob--1.0.sql
|
||||
./share/postgresql/extension/gms_lob.control
|
||||
./share/postgresql/extension/gms_stats--1.0.sql
|
||||
./share/postgresql/extension/gms_stats.control
|
||||
./share/postgresql/extension/gms_tcp--1.0.sql
|
||||
./share/postgresql/extension/gms_tcp.control
|
||||
./share/postgresql/extension/gms_profiler--1.0.sql
|
||||
./share/postgresql/extension/gms_profiler.control
|
||||
./share/postgresql/extension/gms_debug--1.0.sql
|
||||
./share/postgresql/extension/gms_debug.control
|
||||
./share/postgresql/extension/gms_sql--1.0.sql
|
||||
./share/postgresql/extension/gms_sql.control
|
||||
./share/postgresql/extension/gms_xmlgen--1.0.sql
|
||||
./share/postgresql/extension/gms_xmlgen.control
|
||||
./share/postgresql/extension/gms_i18n--1.0.sql
|
||||
./share/postgresql/extension/gms_i18n.control
|
||||
./share/postgresql/timezone/GB-Eire
|
||||
./share/postgresql/timezone/Turkey
|
||||
./share/postgresql/timezone/Kwajalein
|
||||
@ -758,7 +735,6 @@
|
||||
./share/postgresql/tsearch_data/swedish.stop
|
||||
./share/postgresql/tsearch_data/ispell_sample.dict
|
||||
./share/postgresql/tsearch_data/italian.stop
|
||||
./share/postgresql/tsearch_data/dict.utf8.xdb
|
||||
./share/postgresql/information_schema.sql
|
||||
./share/postgresql/timezonesets/Antarctica.txt
|
||||
./share/postgresql/timezonesets/Australia.txt
|
||||
@ -838,25 +814,15 @@
|
||||
./lib/postgresql/dolphin.so
|
||||
./lib/postgresql/age.so
|
||||
./lib/postgresql/datavec.so
|
||||
./lib/postgresql/chparser.so
|
||||
./lib/postgresql/pg_upgrade_support.so
|
||||
./lib/postgresql/java/pljava.jar
|
||||
./lib/postgresql/postgres_fdw.so
|
||||
./lib/postgresql/dblink.so
|
||||
./lib/postgresql/gms_utility.so
|
||||
./lib/postgresql/pgoutput.so
|
||||
./lib/postgresql/assessment.so
|
||||
./lib/postgresql/gms_compress.so
|
||||
./lib/postgresql/gms_output.so
|
||||
./lib/postgresql/gms_inaddr.so
|
||||
./lib/postgresql/gms_lob.so
|
||||
./lib/postgresql/gms_stats.so
|
||||
./lib/postgresql/gms_tcp.so
|
||||
./lib/postgresql/gms_profiler.so
|
||||
./lib/postgresql/gms_debug.so
|
||||
./lib/postgresql/gms_sql.so
|
||||
./lib/postgresql/gms_xmlgen.so
|
||||
./lib/postgresql/gms_i18n.so
|
||||
./lib/libpljava.so
|
||||
./lib/libpq.a
|
||||
./lib/libpq.so
|
||||
|
@ -350,9 +350,16 @@ function read_mpp_number()
|
||||
version_num=$(echo $version_num1 | tr -d ";")
|
||||
#remove the blank
|
||||
version_num=$(echo $version_num)
|
||||
form=${version_num:0:2}
|
||||
latter=${version_num:2}
|
||||
echo "${form}.${latter}" >>${SCRIPT_DIR}/version.cfg
|
||||
|
||||
if echo $version_num | grep -qE '^92[0-9]+$'
|
||||
then
|
||||
# get the last three number
|
||||
latter=${version_num:2}
|
||||
echo "92.${latter}" >>${SCRIPT_DIR}/version.cfg
|
||||
else
|
||||
echo "Cannot get the version number from globals.cpp."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
read_mpp_number
|
||||
|
||||
@ -466,10 +473,6 @@ function install_gaussdb()
|
||||
CMAKE_OPT="$CMAKE_OPT -DENABLE_OPENEULER_MAJOR=ON"
|
||||
fi
|
||||
|
||||
if [[ -e "/etc/openEuler-release" && "$(cat /etc/openEuler-release | awk '{print $3}')" == "24.03" ]]; then
|
||||
CMAKE_OPT="$CMAKE_OPT -DENABLE_OPENEULER_MAJOR=ON"
|
||||
fi
|
||||
|
||||
if [ "${PLATFORM_ARCH}"x == "loongarch64"x ]; then
|
||||
CMAKE_OPT="$CMAKE_OPT -DENABLE_BBOX=OFF -DENABLE_JEMALLOC=OFF"
|
||||
fi
|
||||
|
@ -1,2 +1,2 @@
|
||||
PRODUCT=openGauss
|
||||
VERSION=7.0.0-RC1
|
||||
VERSION=6.0.0
|
@ -45,8 +45,6 @@
|
||||
./share/postgresql/extension/plpgsql.control
|
||||
./share/postgresql/extension/dist_fdw.control
|
||||
./share/postgresql/extension/dist_fdw--1.0.sql
|
||||
./share/postgresql/extension/gms_compress--1.0.sql
|
||||
./share/postgresql/extension/gms_compress.control
|
||||
./share/postgresql/extension/hstore--1.1.sql
|
||||
./share/postgresql/extension/plpgsql--unpackaged--1.0.sql
|
||||
./share/postgresql/extension/file_fdw.control
|
||||
@ -54,24 +52,6 @@
|
||||
./share/postgresql/extension/hstore--1.0--1.1.sql
|
||||
./share/postgresql/extension/log_fdw--1.0.sql
|
||||
./share/postgresql/extension/log_fdw.control
|
||||
./share/postgresql/extension/gms_output--1.0.sql
|
||||
./share/postgresql/extension/gms_output.control
|
||||
./share/postgresql/extension/gms_inaddr--1.0.sql
|
||||
./share/postgresql/extension/gms_inaddr.control
|
||||
./share/postgresql/extension/gms_stats--1.0.sql
|
||||
./share/postgresql/extension/gms_stats.control
|
||||
./share/postgresql/extension/gms_profiler--1.0.sql
|
||||
./share/postgresql/extension/gms_profiler.control
|
||||
./share/postgresql/extension/gms_lob--1.0.sql
|
||||
./share/postgresql/extension/gms_lob.control
|
||||
./share/postgresql/extension/gms_sql--1.0.sql
|
||||
./share/postgresql/extension/gms_sql.control
|
||||
./share/postgresql/extension/gms_i18n--1.0.sql
|
||||
./share/postgresql/extension/gms_i18n.control
|
||||
./share/postgresql/extension/gms_utility--1.0.sql
|
||||
./share/postgresql/extension/gms_utility.control
|
||||
./share/postgresql/extension/gms_debug--1.0.sql
|
||||
./share/postgresql/extension/gms_debug.control
|
||||
./share/postgresql/timezone/GB-Eire
|
||||
./share/postgresql/timezone/Turkey
|
||||
./share/postgresql/timezone/Kwajalein
|
||||
@ -734,7 +714,6 @@
|
||||
./lib/postgresql/utf8_and_sjis.so
|
||||
./lib/postgresql/utf8_and_cyrillic.so
|
||||
./lib/postgresql/hstore.so
|
||||
./lib/postgresql/gms_compress.so
|
||||
./lib/postgresql/packages.so
|
||||
./lib/postgresql/utf8_and_euc_kr.so
|
||||
./lib/postgresql/ascii_and_mic.so
|
||||
@ -759,15 +738,6 @@
|
||||
./lib/postgresql/latin2_and_win1250.so
|
||||
./lib/postgresql/euc2004_sjis2004.so
|
||||
./lib/postgresql/pgoutput.so
|
||||
./lib/postgresql/gms_output.so
|
||||
./lib/postgresql/gms_inaddr.so
|
||||
./lib/postgresql/gms_stats.so
|
||||
./lib/postgresql/gms_profiler.so
|
||||
./lib/postgresql/gms_lob.so
|
||||
./lib/postgresql/gms_sql.so
|
||||
./lib/postgresql/gms_i18n.so
|
||||
./lib/postgresql/gms_utility.so
|
||||
./lib/postgresql/gms_debug.so
|
||||
./include/postgresql/server/postgres_ext.h
|
||||
./include/postgresql/server/pg_config_os.h
|
||||
./include/postgresql/server/pgtime.h
|
||||
|
@ -1,7 +1,6 @@
|
||||
[server]
|
||||
./bin/dsscmd
|
||||
./bin/dssserver
|
||||
./bin/dsstbox
|
||||
./bin/perctrl
|
||||
./bin/dms_contrl.sh
|
||||
./bin/dss_clear.sh
|
||||
@ -98,8 +97,6 @@
|
||||
./share/postgresql/extension/mot_fdw.control
|
||||
./share/postgresql/extension/postgres_fdw--1.0.sql
|
||||
./share/postgresql/extension/postgres_fdw.control
|
||||
./share/postgresql/extension/gms_compress--1.0.sql
|
||||
./share/postgresql/extension/gms_compress.control
|
||||
./share/postgresql/extension/dblink--1.0.sql
|
||||
./share/postgresql/extension/dblink--unpackaged--1.0.sql
|
||||
./share/postgresql/extension/dblink.control
|
||||
@ -778,7 +775,6 @@
|
||||
./lib/postgresql/pg_upgrade_support.so
|
||||
./lib/postgresql/java/pljava.jar
|
||||
./lib/postgresql/postgres_fdw.so
|
||||
./lib/postgresql/gms_compress.so
|
||||
./lib/postgresql/dblink.so
|
||||
./lib/postgresql/pgoutput.so
|
||||
./lib/postgresql/assessment.so
|
||||
|
@ -79,29 +79,9 @@
|
||||
./share/postgresql/extension/gsredistribute--unpackaged--1.0.sql
|
||||
./share/postgresql/extension/postgres_fdw--1.0.sql
|
||||
./share/postgresql/extension/postgres_fdw.control
|
||||
./share/postgresql/extension/gms_compress--1.0.sql
|
||||
./share/postgresql/extension/gms_compress.control
|
||||
./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/extension/gms_inaddr--1.0.sql
|
||||
./share/postgresql/extension/gms_inaddr.control
|
||||
./share/postgresql/extension/gms_stats--1.0.sql
|
||||
./share/postgresql/extension/gms_stats.control
|
||||
./share/postgresql/extension/gms_profiler--1.0.sql
|
||||
./share/postgresql/extension/gms_profiler.control
|
||||
./share/postgresql/extension/gms_lob--1.0.sql
|
||||
./share/postgresql/extension/gms_lob.control
|
||||
./share/postgresql/extension/gms_sql--1.0.sql
|
||||
./share/postgresql/extension/gms_sql.control
|
||||
./share/postgresql/extension/gms_i18n--1.0.sql
|
||||
./share/postgresql/extension/gms_i18n.control
|
||||
./share/postgresql/extension/gms_utility--1.0.sql
|
||||
./share/postgresql/extension/gms_utility.control
|
||||
./share/postgresql/extension/gms_debug--1.0.sql
|
||||
./share/postgresql/extension/gms_debug.control
|
||||
./share/postgresql/timezone/GB-Eire
|
||||
./share/postgresql/timezone/Turkey
|
||||
./share/postgresql/timezone/Kwajalein
|
||||
@ -775,17 +755,7 @@
|
||||
./lib/postgresql/pg_upgrade_support.so
|
||||
./lib/postgresql/java/pljava.jar
|
||||
./lib/postgresql/postgres_fdw.so
|
||||
./lib/postgresql/gms_compress.so
|
||||
./lib/postgresql/dblink.so
|
||||
./lib/postgresql/gms_output.so
|
||||
./lib/postgresql/gms_inaddr.so
|
||||
./lib/postgresql/gms_stats.so
|
||||
./lib/postgresql/gms_profiler.so
|
||||
./lib/postgresql/gms_lob.so
|
||||
./lib/postgresql/gms_sql.so
|
||||
./lib/postgresql/gms_i18n.so
|
||||
./lib/postgresql/gms_utility.so
|
||||
./lib/postgresql/gms_debug.so
|
||||
./lib/libpljava.so
|
||||
./lib/libpq.a
|
||||
./lib/libpq.so
|
||||
|
@ -64,7 +64,7 @@
|
||||
./share/postgresql/extension/timescaledb.control
|
||||
./share/postgresql/extension/timescaledb--1.7.4.sql
|
||||
./share/postgresql/extension/dolphin.control
|
||||
./share/postgresql/extension/dolphin--5.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/dolphin--1.1--2.0.sql
|
||||
@ -73,8 +73,6 @@
|
||||
./share/postgresql/extension/dolphin--3.0--2.0.sql
|
||||
./share/postgresql/extension/dolphin--3.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--3.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--5.0.sql
|
||||
./share/postgresql/extension/dolphin--5.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--2.0--2.0.1.sql
|
||||
./share/postgresql/extension/dolphin--2.0.1--2.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--4.0.1.sql
|
||||
@ -82,10 +80,8 @@
|
||||
./share/postgresql/extension/openGauss_expr_dolphin.ir
|
||||
./share/postgresql/extension/age--1.0.0.sql
|
||||
./share/postgresql/extension/age.control
|
||||
./share/postgresql/extension/datavec--1.0.sql
|
||||
./share/postgresql/extension/datavec--0.4.4.sql
|
||||
./share/postgresql/extension/datavec.control
|
||||
./share/postgresql/extension/chparser--1.0.sql
|
||||
./share/postgresql/extension/chparser.control
|
||||
./share/postgresql/extension/file_fdw--1.0.sql
|
||||
./share/postgresql/extension/plpgsql.control
|
||||
./share/postgresql/extension/dist_fdw.control
|
||||
@ -109,30 +105,12 @@
|
||||
./share/postgresql/extension/dblink--1.0.sql
|
||||
./share/postgresql/extension/dblink--unpackaged--1.0.sql
|
||||
./share/postgresql/extension/dblink.control
|
||||
./share/postgresql/extension/gms_compress--1.0.sql
|
||||
./share/postgresql/extension/gms_compress.control
|
||||
./share/postgresql/extension/gms_output--1.0.sql
|
||||
./share/postgresql/extension/gms_output.control
|
||||
./share/postgresql/extension/gms_inaddr--1.0.sql
|
||||
./share/postgresql/extension/gms_inaddr.control
|
||||
./share/postgresql/extension/gms_lob--1.0.sql
|
||||
./share/postgresql/extension/gms_lob.control
|
||||
./share/postgresql/extension/gms_stats--1.0.sql
|
||||
./share/postgresql/extension/gms_stats.control
|
||||
./share/postgresql/extension/gms_utility--1.0.sql
|
||||
./share/postgresql/extension/gms_utility.control
|
||||
./share/postgresql/extension/gms_profiler--1.0.sql
|
||||
./share/postgresql/extension/gms_profiler.control
|
||||
./share/postgresql/extension/gms_debug--1.0.sql
|
||||
./share/postgresql/extension/gms_debug.control
|
||||
./share/postgresql/extension/gms_sql--1.0.sql
|
||||
./share/postgresql/extension/gms_sql.control
|
||||
./share/postgresql/extension/gms_tcp--1.0.sql
|
||||
./share/postgresql/extension/gms_tcp.control
|
||||
./share/postgresql/extension/gms_xmlgen--1.0.sql
|
||||
./share/postgresql/extension/gms_xmlgen.control
|
||||
./share/postgresql/extension/gms_i18n--1.0.sql
|
||||
./share/postgresql/extension/gms_i18n.control
|
||||
./share/postgresql/timezone/GB-Eire
|
||||
./share/postgresql/timezone/Turkey
|
||||
./share/postgresql/timezone/Kwajalein
|
||||
@ -744,7 +722,6 @@
|
||||
./share/postgresql/tsearch_data/swedish.stop
|
||||
./share/postgresql/tsearch_data/ispell_sample.dict
|
||||
./share/postgresql/tsearch_data/italian.stop
|
||||
./share/postgresql/tsearch_data/dict.utf8.xdb
|
||||
./share/postgresql/information_schema.sql
|
||||
./share/postgresql/timezonesets/Antarctica.txt
|
||||
./share/postgresql/timezonesets/Australia.txt
|
||||
@ -809,23 +786,13 @@
|
||||
./lib/postgresql/dolphin.so
|
||||
./lib/postgresql/age.so
|
||||
./lib/postgresql/datavec.so
|
||||
./lib/postgresql/chparser.so
|
||||
./lib/postgresql/pg_upgrade_support.so
|
||||
./lib/postgresql/java/pljava.jar
|
||||
./lib/postgresql/postgres_fdw.so
|
||||
./lib/postgresql/dblink.so
|
||||
./lib/postgresql/gms_compress.so
|
||||
./lib/postgresql/gms_output.so
|
||||
./lib/postgresql/gms_inaddr.so
|
||||
./lib/postgresql/gms_lob.so
|
||||
./lib/postgresql/gms_stats.so
|
||||
./lib/postgresql/gms_utility.so
|
||||
./lib/postgresql/gms_profiler.so
|
||||
./lib/postgresql/gms_debug.so
|
||||
./lib/postgresql/gms_sql.so
|
||||
./lib/postgresql/gms_tcp.so
|
||||
./lib/postgresql/gms_xmlgen.so
|
||||
./lib/postgresql/gms_i18n.so
|
||||
./lib/libpljava.so
|
||||
./lib/libpq.a
|
||||
./lib/libpq.so
|
||||
|
@ -39,9 +39,16 @@ function read_gaussdb_number()
|
||||
version_num=$(echo $version_num1 | tr -d ";")
|
||||
#remove the blank
|
||||
version_num=$(echo $version_num)
|
||||
form=${version_num:0:2}
|
||||
latter=${version_num:2}
|
||||
echo "${form}.${latter}" >>${SCRIPT_DIR}/version.cfg
|
||||
|
||||
if echo $version_num | grep -qE '^92[0-9]+$'
|
||||
then
|
||||
# get the last three number
|
||||
latter=${version_num:2}
|
||||
echo "92.${latter}" >>${SCRIPT_DIR}/version.cfg
|
||||
else
|
||||
echo "Cannot get the version number from globals.cpp."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
|
@ -47,9 +47,16 @@ function read_gaussdb_number()
|
||||
version_num=$(echo $version_num1 | tr -d ";")
|
||||
#remove the blank
|
||||
version_num=$(echo $version_num)
|
||||
form=${version_num:0:2}
|
||||
latter=${version_num:2}
|
||||
echo "${form}.${latter}" >>${SCRIPT_DIR}/version.cfg
|
||||
|
||||
if echo $version_num | grep -qE '^92[0-9]+$'
|
||||
then
|
||||
# get the last three number
|
||||
latter=${version_num:2}
|
||||
echo "92.${latter}" >>${SCRIPT_DIR}/version.cfg
|
||||
else
|
||||
echo "Cannot get the version number from globals.cpp."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
@ -164,7 +171,7 @@ function install_gaussdb()
|
||||
GAUSSDB_EXTRA_FLAGS=" "
|
||||
|
||||
if [[ "$PLATFORM_ARCH"x == "x86_64"x || "$PLATFORM_ARCH"x == "aarch64"x ]] ; then
|
||||
extra_config_opt+=" --enable-mot --enable-bbox --enable-htap"
|
||||
extra_config_opt+=" --enable-mot --enable-bbox "
|
||||
fi
|
||||
|
||||
if [ "$PLATFORM_ARCH"x = "loongarch64"x ] ; then
|
||||
|
@ -1,7 +1,6 @@
|
||||
[server]
|
||||
./bin/dsscmd
|
||||
./bin/dssserver
|
||||
./bin/dsstbox
|
||||
./bin/perctrl
|
||||
./bin/dms_contrl.sh
|
||||
./bin/dss_clear.sh
|
||||
@ -77,7 +76,7 @@
|
||||
./share/postgresql/extension/spqplugin.control
|
||||
./share/postgresql/extension/spqplugin--1.0.sql
|
||||
./share/postgresql/extension/dolphin.control
|
||||
./share/postgresql/extension/dolphin--5.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/dolphin--1.1--2.0.sql
|
||||
@ -86,8 +85,6 @@
|
||||
./share/postgresql/extension/dolphin--3.0--2.0.sql
|
||||
./share/postgresql/extension/dolphin--3.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--3.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--5.0.sql
|
||||
./share/postgresql/extension/dolphin--5.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--2.0--2.0.1.sql
|
||||
./share/postgresql/extension/dolphin--2.0.1--2.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--4.0.1.sql
|
||||
|
@ -34,7 +34,7 @@
|
||||
./share/postgresql/extension/security_plugin.control
|
||||
./share/postgresql/extension/security_plugin--1.0.sql
|
||||
./share/postgresql/extension/dolphin.control
|
||||
./share/postgresql/extension/dolphin--5.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/dolphin--1.1--2.0.sql
|
||||
@ -43,14 +43,10 @@
|
||||
./share/postgresql/extension/dolphin--3.0--2.0.sql
|
||||
./share/postgresql/extension/dolphin--3.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--3.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--5.0.sql
|
||||
./share/postgresql/extension/dolphin--5.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--2.0--2.0.1.sql
|
||||
./share/postgresql/extension/dolphin--2.0.1--2.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--4.0.1.sql
|
||||
./share/postgresql/extension/dolphin--4.0.1--4.0.sql
|
||||
./share/postgresql/extension/gms_compress--1.0.sql
|
||||
./share/postgresql/extension/gms_compress.control
|
||||
./share/postgresql/extension/openGauss_expr_dolphin.ir
|
||||
./share/postgresql/extension/file_fdw--1.0.sql
|
||||
./share/postgresql/extension/plpgsql.control
|
||||
@ -63,24 +59,6 @@
|
||||
./share/postgresql/extension/hstore--1.0--1.1.sql
|
||||
./share/postgresql/extension/log_fdw--1.0.sql
|
||||
./share/postgresql/extension/log_fdw.control
|
||||
./share/postgresql/extension/gms_utility--1.0.sql
|
||||
./share/postgresql/extension/gms_utility.control
|
||||
./share/postgresql/extension/gms_output--1.0.sql
|
||||
./share/postgresql/extension/gms_output.control
|
||||
./share/postgresql/extension/gms_stats--1.0.sql
|
||||
./share/postgresql/extension/gms_stats.control
|
||||
./share/postgresql/extension/gms_profiler--1.0.sql
|
||||
./share/postgresql/extension/gms_profiler.control
|
||||
./share/postgresql/extension/gms_lob--1.0.sql
|
||||
./share/postgresql/extension/gms_lob.control
|
||||
./share/postgresql/extension/gms_sql--1.0.sql
|
||||
./share/postgresql/extension/gms_sql.control
|
||||
./share/postgresql/extension/gms_i18n--1.0.sql
|
||||
./share/postgresql/extension/gms_i18n.control
|
||||
./share/postgresql/extension/gms_inaddr--1.0.sql
|
||||
./share/postgresql/extension/gms_inaddr.control
|
||||
./share/postgresql/extension/gms_debug--1.0.sql
|
||||
./share/postgresql/extension/gms_debug.control
|
||||
./share/postgresql/timezone/GB-Eire
|
||||
./share/postgresql/timezone/Turkey
|
||||
./share/postgresql/timezone/Kwajalein
|
||||
@ -764,20 +742,10 @@
|
||||
./lib/postgresql/proc_srclib
|
||||
./lib/postgresql/security_plugin.so
|
||||
./lib/postgresql/dolphin.so
|
||||
./lib/postgresql/gms_compress.so
|
||||
./lib/postgresql/pg_upgrade_support.so
|
||||
./lib/postgresql/latin2_and_win1250.so
|
||||
./lib/postgresql/euc2004_sjis2004.so
|
||||
./lib/postgresql/pgoutput.so
|
||||
./lib/postgresql/gms_utility.so
|
||||
./lib/postgresql/gms_output.so
|
||||
./lib/postgresql/gms_stats.so
|
||||
./lib/postgresql/gms_profiler.so
|
||||
./lib/postgresql/gms_lob.so
|
||||
./lib/postgresql/gms_sql.so
|
||||
./lib/postgresql/gms_i18n.so
|
||||
./lib/postgresql/gms_inaddr.so
|
||||
./lib/postgresql/gms_debug.so
|
||||
./lib/libxgboost.so
|
||||
./include/postgresql/server/postgres_ext.h
|
||||
./include/postgresql/server/pg_config_os.h
|
||||
@ -954,4 +922,4 @@
|
||||
./include/pqcomm.h
|
||||
./include/pqexpbuffer.h
|
||||
[version]
|
||||
7.0.0-RC1
|
||||
6.0.0
|
||||
|
@ -1,7 +1,6 @@
|
||||
[server]
|
||||
./bin/dsscmd
|
||||
./bin/dssserver
|
||||
./bin/dsstbox
|
||||
./bin/perctrl
|
||||
./bin/dms_contrl.sh
|
||||
./bin/dss_clear.sh
|
||||
@ -78,7 +77,7 @@
|
||||
./share/postgresql/extension/spqplugin.control
|
||||
./share/postgresql/extension/spqplugin--1.0.sql
|
||||
./share/postgresql/extension/dolphin.control
|
||||
./share/postgresql/extension/dolphin--5.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0.sql
|
||||
./share/postgresql/extension/dolphin--1.0--1.1.sql
|
||||
./share/postgresql/extension/dolphin--1.1--1.0.sql
|
||||
./share/postgresql/extension/dolphin--1.1--2.0.sql
|
||||
@ -87,8 +86,6 @@
|
||||
./share/postgresql/extension/dolphin--3.0--2.0.sql
|
||||
./share/postgresql/extension/dolphin--3.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--3.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--5.0.sql
|
||||
./share/postgresql/extension/dolphin--5.0--4.0.sql
|
||||
./share/postgresql/extension/dolphin--2.0--2.0.1.sql
|
||||
./share/postgresql/extension/dolphin--2.0.1--2.0.sql
|
||||
./share/postgresql/extension/dolphin--4.0--4.0.1.sql
|
||||
@ -98,10 +95,8 @@
|
||||
./share/postgresql/extension/age.control
|
||||
./share/postgresql/extension/timescaledb.control
|
||||
./share/postgresql/extension/timescaledb--1.7.4.sql
|
||||
./share/postgresql/extension/datavec--1.0.sql
|
||||
./share/postgresql/extension/datavec--0.4.4.sql
|
||||
./share/postgresql/extension/datavec.control
|
||||
./share/postgresql/extension/chparser--1.0.sql
|
||||
./share/postgresql/extension/chparser.control
|
||||
./share/postgresql/extension/assessment--1.0.sql
|
||||
./share/postgresql/extension/assessment.control
|
||||
./share/postgresql/extension/file_fdw--1.0.sql
|
||||
@ -122,30 +117,12 @@
|
||||
./share/postgresql/extension/dblink--1.0.sql
|
||||
./share/postgresql/extension/dblink--unpackaged--1.0.sql
|
||||
./share/postgresql/extension/dblink.control
|
||||
./share/postgresql/extension/gms_compress--1.0.sql
|
||||
./share/postgresql/extension/gms_compress.control
|
||||
./share/postgresql/extension/gms_utility--1.0.sql
|
||||
./share/postgresql/extension/gms_utility.control
|
||||
./share/postgresql/extension/gms_output--1.0.sql
|
||||
./share/postgresql/extension/gms_output.control
|
||||
./share/postgresql/extension/gms_inaddr--1.0.sql
|
||||
./share/postgresql/extension/gms_inaddr.control
|
||||
./share/postgresql/extension/gms_lob--1.0.sql
|
||||
./share/postgresql/extension/gms_lob.control
|
||||
./share/postgresql/extension/gms_stats--1.0.sql
|
||||
./share/postgresql/extension/gms_stats.control
|
||||
./share/postgresql/extension/gms_tcp--1.0.sql
|
||||
./share/postgresql/extension/gms_tcp.control
|
||||
./share/postgresql/extension/gms_profiler--1.0.sql
|
||||
./share/postgresql/extension/gms_profiler.control
|
||||
./share/postgresql/extension/gms_debug--1.0.sql
|
||||
./share/postgresql/extension/gms_debug.control
|
||||
./share/postgresql/extension/gms_sql--1.0.sql
|
||||
./share/postgresql/extension/gms_sql.control
|
||||
./share/postgresql/extension/gms_xmlgen--1.0.sql
|
||||
./share/postgresql/extension/gms_xmlgen.control
|
||||
./share/postgresql/extension/gms_i18n--1.0.sql
|
||||
./share/postgresql/extension/gms_i18n.control
|
||||
./share/postgresql/timezone/GB-Eire
|
||||
./share/postgresql/timezone/Turkey
|
||||
./share/postgresql/timezone/Kwajalein
|
||||
@ -758,7 +735,6 @@
|
||||
./share/postgresql/tsearch_data/swedish.stop
|
||||
./share/postgresql/tsearch_data/ispell_sample.dict
|
||||
./share/postgresql/tsearch_data/italian.stop
|
||||
./share/postgresql/tsearch_data/dict.utf8.xdb
|
||||
./share/postgresql/information_schema.sql
|
||||
./share/postgresql/timezonesets/Antarctica.txt
|
||||
./share/postgresql/timezonesets/Australia.txt
|
||||
@ -838,25 +814,15 @@
|
||||
./lib/postgresql/dolphin.so
|
||||
./lib/postgresql/age.so
|
||||
./lib/postgresql/datavec.so
|
||||
./lib/postgresql/chparser.so
|
||||
./lib/postgresql/pg_upgrade_support.so
|
||||
./lib/postgresql/java/pljava.jar
|
||||
./lib/postgresql/postgres_fdw.so
|
||||
./lib/postgresql/dblink.so
|
||||
./lib/postgresql/gms_utility.so
|
||||
./lib/postgresql/gms_lob.so
|
||||
./lib/postgresql/gms_stats.so
|
||||
./lib/postgresql/gms_tcp.so
|
||||
./lib/postgresql/pgoutput.so
|
||||
./lib/postgresql/assessment.so
|
||||
./lib/postgresql/gms_compress.so
|
||||
./lib/postgresql/gms_output.so
|
||||
./lib/postgresql/gms_inaddr.so
|
||||
./lib/postgresql/gms_profiler.so
|
||||
./lib/postgresql/gms_sql.so
|
||||
./lib/postgresql/gms_xmlgen.so
|
||||
./lib/postgresql/gms_i18n.so
|
||||
./lib/postgresql/gms_debug.so
|
||||
./lib/libpljava.so
|
||||
./lib/libpq.a
|
||||
./lib/libpq.so
|
||||
|
@ -198,7 +198,7 @@ ENDMACRO(CHECK_CC_ENABLE)
|
||||
|
||||
function(GET_VERSIONSTR_FROMGIT ret)
|
||||
set(PG_VERSION "9.2.4")
|
||||
set(OPENGAUSS_VERSION "7.0.0-RC1")
|
||||
set(OPENGAUSS_VERSION "6.0.0")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/${openGauss}/cmake/src/buildfunction.sh --s ${PROJECT_TRUNK_DIR} OUTPUT_VARIABLE GS_VERSION_STR)
|
||||
set(PG_VERSION "${PG_VERSION}" PARENT_SCOPE)
|
||||
|
@ -69,7 +69,6 @@ option(BUILD_BY_CMAKE "the BUILD_BY_CMAKE is new,used in distribute pg_regress.c
|
||||
option(DEBUG_UHEAP "collect USTORE statistics" OFF)
|
||||
option(MAX_ALLOC_SEGNUM "max alloc xlog seg num in extreme_rto" 4)
|
||||
option(USE_TASSL "build with tassl, the old is --with-tassl" OFF)#ON
|
||||
option(ENABLE_HTAP "enable HTAP in single/distribute mode,the old is --enable-htap" ON)
|
||||
|
||||
#No matter what to set, the old mppdb aways use ENABLE_THREAD_SAFETY=yes by default defined.
|
||||
option(ENABLE_THREAD_SAFETY "enable thread safety, the old is --enable-thread-safety" ON)
|
||||
@ -234,10 +233,6 @@ if(${USE_SPQ})
|
||||
set(GAUSSDB_CONFIGURE "${GAUSSDB_CONFIGURE} -DUSE_SPQ")
|
||||
endif()
|
||||
|
||||
if(${ENABLE_HTAP})
|
||||
set(GAUSSDB_CONFIGURE "${GAUSSDB_CONFIGURE} -DENABLE_HTAP")
|
||||
endif()
|
||||
|
||||
if(${USE_LDAP})
|
||||
set(HAVE_LIBLDAP 1)
|
||||
set(LIBS "${LIBS} -lldap")
|
||||
|
@ -714,7 +714,7 @@
|
||||
#define PGXC_VERSION_NUM
|
||||
|
||||
/* openGauss version as a number string */
|
||||
#define OPENGAUSS_VERSION_NUM_STR "7.0.0-RC1"
|
||||
#define OPENGAUSS_VERSION_NUM_STR "6.0.0"
|
||||
|
||||
/* A string containing the version number, platform, and C compiler */
|
||||
#define PG_VERSION_STR "@PG_VERSION_STR@"
|
||||
@ -949,7 +949,3 @@
|
||||
/* Define to 1 if you want to build opengauss rpm package on openeuler os.
|
||||
* (--with-openeuler-os) */
|
||||
#cmakedefine WITH_OPENEULER_OS
|
||||
|
||||
/* Define to 1 if you want to use htap
|
||||
* --enable-htap */
|
||||
#cmakedefine ENABLE_HTAP
|
@ -695,7 +695,7 @@
|
||||
#define PG_VERSION "9.2.4"
|
||||
|
||||
/* openGauss version as a string */
|
||||
#define OPENGAUSS_VERSION "7.0.0-RC1"
|
||||
#define OPENGAUSS_VERSION "6.0.0"
|
||||
|
||||
/* Gaussdb version as a string*/
|
||||
#define DEF_GS_VERSION "(GaussDB A 8.0.0 build 21f07aff) compiled at 2020-03-17 10:59:07 commit 7431 last mr 12039 debug"
|
||||
|
43
configure
vendored
43
configure
vendored
@ -758,7 +758,6 @@ enable_lite_mode
|
||||
enable_relocation
|
||||
enable_finance_mode
|
||||
enable_mot
|
||||
enable_htap
|
||||
enable_bbox
|
||||
enable_memory_check
|
||||
enable_mysql_fdw
|
||||
@ -848,7 +847,6 @@ enable_lite_mode
|
||||
enable_relocation
|
||||
enable_finance_mode
|
||||
enable_mot
|
||||
enable_htap
|
||||
enable_bbox
|
||||
enable_memory_check
|
||||
enable_mysql_fdw
|
||||
@ -1562,7 +1560,6 @@ Optional Features:
|
||||
--enable-memory-check build with memory checking feature
|
||||
--disable-spinlocks do not use spinlocks
|
||||
--enable-debug build with debugging symbols (-g)
|
||||
--enable-htap enable htap feture
|
||||
--enable-qunit enable query driven unit test framework(QUnit)
|
||||
--enable-profiling build with profiling enabled
|
||||
--enable-coverage build with coverage testing instrumentation
|
||||
@ -2212,7 +2209,7 @@ PACKAGE_VERSION='9.2.4'
|
||||
# Postgres-XC 1.1devel is based on PostgreSQL 9.2.4
|
||||
PACKAGE_XC_VERSION='1.1'
|
||||
# openGauss is based on PostgreSQL 9.2.4 and it will be the Kernel of GaussDB database
|
||||
OPENGAUSS_VERSION='7.0.0-RC1'
|
||||
OPENGAUSS_VERSION='6.0.0'
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define PG_VERSION "$PACKAGE_VERSION"
|
||||
@ -3340,40 +3337,6 @@ else
|
||||
|
||||
fi
|
||||
|
||||
# Check whether --enable-htap was given.
|
||||
if test "${enable_htap+set}" = set; then
|
||||
enableval=$enable_htap;
|
||||
case $enableval in
|
||||
yes)
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define ENABLE_HTAP 1
|
||||
_ACEOF
|
||||
|
||||
;;
|
||||
no)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
{ { $as_echo "$as_me:$LINENO: error: no argument expected for --enable-htap option" >&5
|
||||
$as_echo "$as_me: error: no argument expected for --enable-htap option" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
;;
|
||||
esac
|
||||
|
||||
else
|
||||
enable_htap=no
|
||||
|
||||
fi
|
||||
|
||||
if test "$enable_htap" = yes; then
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define ENABLE_HTAP 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
if test "$enable_bbox" = yes; then
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
@ -3428,10 +3391,6 @@ if [[ "$(cat /etc/system-release)" =~ ^"openEuler release 22.03".* ]]; then
|
||||
with_openeuler_major=yes
|
||||
fi
|
||||
|
||||
if [[ "$(cat /etc/system-release)" =~ ^"openEuler release 24.03".* ]]; then
|
||||
with_openeuler_major=yes
|
||||
fi
|
||||
|
||||
if [[ "$(cat /etc/system-release)" =~ ^"CSIOS release 1.0".* ]]; then
|
||||
with_openeuler_major=yes
|
||||
fi
|
||||
|
@ -16,7 +16,6 @@ set(CMAKE_MODULE_PATH
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pg_upgrade_support
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/postgres_fdw
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_output
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_inaddr
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/security_plugin
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dummy_seclabel
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pagehack
|
||||
@ -27,32 +26,10 @@ set(CMAKE_MODULE_PATH
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ndpplugin
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spq_plugin
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datavec
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/chparser
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_stats
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_utility
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_profiler
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_lob
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_sql
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_tcp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_i18n
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gms_debug
|
||||
|
||||
)
|
||||
|
||||
if(NOT "${ENABLE_LITE_MODE}" STREQUAL "ON")
|
||||
INCLUDE_DIRECTORIES(${LIBODBC_INCLUDE_PATH})
|
||||
INCLUDE_DIRECTORIES(${LIBODBC_LIB_PATH})
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/dblink)
|
||||
add_subdirectory(dblink)
|
||||
endif()
|
||||
|
||||
if("${USE_LIBXML}" STREQUAL "ON")
|
||||
INCLUDE_DIRECTORIES(${LIBXML_INCLUDE_PATH}/libxml2)
|
||||
INCLUDE_DIRECTORIES(${LIBXML_LIB_PATH})
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/gms_xmlgen)
|
||||
add_subdirectory(gms_xmlgen)
|
||||
endif()
|
||||
|
||||
add_subdirectory(hstore)
|
||||
add_subdirectory(test_decoding)
|
||||
add_subdirectory(mppdb_decoding)
|
||||
@ -63,18 +40,13 @@ if("${ENABLE_MULTIPLE_NODES}" STREQUAL "ON" OR "${ENABLE_PRIVATEGAUSS}" STREQUAL
|
||||
endif()
|
||||
add_subdirectory(postgres_fdw)
|
||||
add_subdirectory(gms_output)
|
||||
add_subdirectory(gms_inaddr)
|
||||
add_subdirectory(security_plugin)
|
||||
add_subdirectory(dummy_seclabel)
|
||||
add_subdirectory(pagehack)
|
||||
add_subdirectory(pg_xlogdump)
|
||||
add_subdirectory(file_fdw)
|
||||
add_subdirectory(log_fdw)
|
||||
add_subdirectory(gms_utility)
|
||||
add_subdirectory(gms_stats)
|
||||
add_subdirectory(gms_sql)
|
||||
add_subdirectory(gms_tcp)
|
||||
add_subdirectory(gms_debug)
|
||||
if("${ENABLE_MULTIPLE_NODES}" STREQUAL "OFF")
|
||||
add_subdirectory(gc_fdw)
|
||||
endif()
|
||||
@ -85,9 +57,4 @@ endif()
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/datavec)
|
||||
add_subdirectory(datavec)
|
||||
endif()
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/chparser)
|
||||
add_subdirectory(chparser)
|
||||
endif()
|
||||
add_subdirectory(gms_profiler)
|
||||
add_subdirectory(gms_lob)
|
||||
add_subdirectory(gms_i18n)
|
||||
|
@ -57,15 +57,8 @@ SUBDIRS = \
|
||||
vacuumlo \
|
||||
security_plugin \
|
||||
ndpplugin \
|
||||
gms_utility \
|
||||
gms_profiler \
|
||||
gms_inaddr \
|
||||
gms_output \
|
||||
gms_stats \
|
||||
gms_lob \
|
||||
gms_sql \
|
||||
gms_i18n \
|
||||
gms_debug
|
||||
gms_output
|
||||
|
||||
ifeq ($(with_openssl),yes)
|
||||
SUBDIRS += sslinfo
|
||||
@ -75,10 +68,8 @@ endif
|
||||
|
||||
ifeq ($(with_libxml),yes)
|
||||
SUBDIRS += xml2
|
||||
SUBDIRS += gms_xmlgen
|
||||
else
|
||||
ALWAYS_SUBDIRS += xml2
|
||||
ALWAYS_SUBDIRS += gms_xmlgen
|
||||
endif
|
||||
|
||||
ifeq ($(with_selinux),yes)
|
||||
|
@ -1,23 +0,0 @@
|
||||
#This is the main CMAKE for build all gms_stats.
|
||||
# gms_stats
|
||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TGT_dblink_SRC)
|
||||
set(TGT_dblink_INC
|
||||
${PROJECT_OPENGS_DIR}/contrib/dblink
|
||||
${PROJECT_OPENGS_DIR}/contrib
|
||||
)
|
||||
|
||||
set(dblink_DEF_OPTIONS ${MACRO_OPTIONS})
|
||||
set(dblink_COMPILE_OPTIONS ${OPTIMIZE_OPTIONS} ${OS_OPTIONS} ${PROTECT_OPTIONS} ${WARNING_OPTIONS} ${LIB_SECURE_OPTIONS} ${CHECK_OPTIONS})
|
||||
set(dblink_LINK_OPTIONS ${LIB_LINK_OPTIONS})
|
||||
add_shared_libtarget(dblink TGT_dblink_SRC TGT_dblink_INC "${dblink_DEF_OPTIONS}" "${dblink_COMPILE_OPTIONS}" "${dblink_LINK_OPTIONS}")
|
||||
target_link_libraries(dblink PUBLIC -lodbc)
|
||||
target_link_directories(dblink PUBLIC ${ODBC_HOME}/lib)
|
||||
set_target_properties(dblink PROPERTIES PREFIX "")
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dblink.control
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dblink--1.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(TARGETS dblink DESTINATION lib/postgresql)
|
@ -1,21 +0,0 @@
|
||||
#This is the main CMAKE for build all gms_compress.
|
||||
# gms_compress
|
||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TGT_gms_compress_SRC)
|
||||
set(TGT_gms_compress_INC
|
||||
${PROJECT_OPENGS_DIR}/contrib/gms_compress
|
||||
${PROJECT_OPENGS_DIR}/contrib
|
||||
)
|
||||
|
||||
set(gms_compress_DEF_OPTIONS ${MACRO_OPTIONS})
|
||||
set(gms_compress_COMPILE_OPTIONS ${OPTIMIZE_OPTIONS} ${OS_OPTIONS} ${PROTECT_OPTIONS} ${WARNING_OPTIONS} ${LIB_SECURE_OPTIONS} ${CHECK_OPTIONS})
|
||||
set(gms_compress_LINK_OPTIONS ${LIB_LINK_OPTIONS})
|
||||
add_shared_libtarget(gms_compress TGT_gms_compress_SRC TGT_gms_compress_INC "${gms_compress_DEF_OPTIONS}" "${gms_compress_COMPILE_OPTIONS}" "${gms_compress_LINK_OPTIONS}")
|
||||
set_target_properties(gms_compress PROPERTIES PREFIX "")
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_compress.control
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_compress--1.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(TARGETS gms_compress DESTINATION lib/postgresql)
|
@ -1,26 +0,0 @@
|
||||
# contrib/gms_compress/Makefile
|
||||
MODULE_big = gms_compress
|
||||
OBJS = gms_compress.o
|
||||
|
||||
EXTENSION = gms_compress
|
||||
DATA = gms_compress--1.0.sql
|
||||
|
||||
exclude_option = -fPIE
|
||||
override CPPFLAGS := -fstack-protector-strong $(filter-out $(exclude_option),$(CPPFLAGS))
|
||||
|
||||
REGRESS = gms_compress
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/gms_compress
|
||||
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
|
@ -1 +0,0 @@
|
||||
The openGauss regression needs this file to run.
|
@ -1,967 +0,0 @@
|
||||
create extension gms_compress;
|
||||
create schema gms_compress_test;
|
||||
set search_path=gms_compress_test;
|
||||
-- test gms_compress.compress
|
||||
select gms_compress.lz_compress('123'::raw);
|
||||
lz_compress
|
||||
----------------------------------------------
|
||||
1F8B080000000000000363540600CC52A5FA02000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('df'::raw);
|
||||
lz_compress
|
||||
--------------------------------------------
|
||||
1F8B0800000000000003BB0F00C8206EC401000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('12ab56'::raw);
|
||||
lz_compress
|
||||
------------------------------------------------
|
||||
1F8B0800000000000003135A1D0600EF3F182F03000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('123'::raw, 1);
|
||||
lz_compress
|
||||
----------------------------------------------
|
||||
1F8B080000000000040363540600CC52A5FA02000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('df'::raw, 6);
|
||||
lz_compress
|
||||
--------------------------------------------
|
||||
1F8B0800000000000003BB0F00C8206EC401000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('12ab56'::raw, 9);
|
||||
lz_compress
|
||||
------------------------------------------------
|
||||
1F8B0800000000000203135A1D0600EF3F182F03000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('123'::blob);
|
||||
lz_compress
|
||||
----------------------------------------------
|
||||
1F8B080000000000000363540600CC52A5FA02000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('df'::blob);
|
||||
lz_compress
|
||||
--------------------------------------------
|
||||
1F8B0800000000000003BB0F00C8206EC401000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('12ab56'::blob);
|
||||
lz_compress
|
||||
------------------------------------------------
|
||||
1F8B0800000000000003135A1D0600EF3F182F03000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('123'::blob, 1);
|
||||
lz_compress
|
||||
----------------------------------------------
|
||||
1F8B080000000000040363540600CC52A5FA02000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('df'::blob, 6);
|
||||
lz_compress
|
||||
--------------------------------------------
|
||||
1F8B0800000000000003BB0F00C8206EC401000000
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_compress('12ab56'::blob, 9);
|
||||
lz_compress
|
||||
------------------------------------------------
|
||||
1F8B0800000000000203135A1D0600EF3F182F03000000
|
||||
(1 row)
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
r_raw raw;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_raw := '12345';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
r_raw := GMS_COMPRESS.LZ_COMPRESS(v_raw);
|
||||
RAISE NOTICE 'r_content=%,r_raw=%', r_content, r_raw;
|
||||
r_content := '111';
|
||||
GMS_COMPRESS.LZ_COMPRESS(content, r_content);
|
||||
RAISE NOTICE 'r_content=%', r_content;
|
||||
END;
|
||||
/
|
||||
NOTICE: r_content=1F8B080000000000000363540600CC52A5FA02000000,r_raw=1F8B080000000000000363547605005B719C4603000000
|
||||
NOTICE: r_content=1F8B080000000000000363540600CC52A5FA02000000
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
r_raw raw;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := 'abc';
|
||||
v_raw := 'df';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content, 1);
|
||||
r_raw := GMS_COMPRESS.LZ_COMPRESS(v_raw, 9);
|
||||
RAISE NOTICE 'r_content=%,r_raw=%', r_content, r_raw;
|
||||
r_content := '111';
|
||||
GMS_COMPRESS.LZ_COMPRESS(content, r_content, 5);
|
||||
RAISE NOTICE 'r_content=%', r_content;
|
||||
END;
|
||||
/
|
||||
NOTICE: r_content=1F8B0800000000000403E3DA0300D205E17902000000,r_raw=1F8B0800000000000203BB0F00C8206EC401000000
|
||||
NOTICE: r_content=1F8B0800000000000003E3DA0300D205E17902000000
|
||||
-- abnormal scenario
|
||||
select gms_compress.lz_compress(null::raw);
|
||||
ERROR: compressed data cannot be NULL
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress(''::raw);
|
||||
ERROR: compressed data cannot be NULL
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress('dfg'::raw);
|
||||
ERROR: invalid hexadecimal digit: "g"
|
||||
LINE 1: select gms_compress.lz_compress('dfg'::raw);
|
||||
^
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress('dfg'::raw, 5);
|
||||
ERROR: invalid hexadecimal digit: "g"
|
||||
LINE 1: select gms_compress.lz_compress('dfg'::raw, 5);
|
||||
^
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress('123'::raw, 0);
|
||||
ERROR: compression quality must be within the range of 1 to 9
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress('123'::raw, 10);
|
||||
ERROR: compression quality must be within the range of 1 to 9
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress(null::blob);
|
||||
ERROR: compressed data cannot be NULL
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress(''::blob);
|
||||
ERROR: compressed data cannot be NULL
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress('dfg'::blob);
|
||||
ERROR: invalid hexadecimal digit: "g"
|
||||
LINE 1: select gms_compress.lz_compress('dfg'::blob);
|
||||
^
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress('dfg'::blob, 5);
|
||||
ERROR: invalid hexadecimal digit: "g"
|
||||
LINE 1: select gms_compress.lz_compress('dfg'::blob, 5);
|
||||
^
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress('123'::blob, 0);
|
||||
ERROR: compression quality must be within the range of 1 to 9
|
||||
CONTEXT: referenced column: lz_compress
|
||||
select gms_compress.lz_compress('123'::blob, 10);
|
||||
ERROR: compression quality must be within the range of 1 to 9
|
||||
CONTEXT: referenced column: lz_compress
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_raw raw;
|
||||
r_raw raw;
|
||||
BEGIN
|
||||
content := '';
|
||||
v_raw := 'dfg';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
r_raw := GMS_COMPRESS.LZ_COMPRESS(v_raw);
|
||||
RAISE NOTICE 'r_content=%,r_raw=%', r_content, r_raw;
|
||||
r_content := '111';
|
||||
GMS_COMPRESS.LZ_COMPRESS(content, r_content);
|
||||
RAISE NOTICE 'r_content=%', r_content;
|
||||
END;
|
||||
/
|
||||
ERROR: invalid hexadecimal digit: "g"
|
||||
CONTEXT: PL/pgSQL function inline_code_block line 7 at assignment
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_raw raw;
|
||||
r_raw raw;
|
||||
BEGIN
|
||||
content := 'abc';
|
||||
v_raw := 'df';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content, 0);
|
||||
r_raw := GMS_COMPRESS.LZ_COMPRESS(v_raw, 10);
|
||||
RAISE NOTICE 'r_content=%,r_raw=%', r_content, r_raw;
|
||||
r_content := '111';
|
||||
GMS_COMPRESS.LZ_COMPRESS(content, r_content, -1);
|
||||
RAISE NOTICE 'r_content=%', r_content;
|
||||
END;
|
||||
/
|
||||
ERROR: compression quality must be within the range of 1 to 9
|
||||
CONTEXT: PL/pgSQL function inline_code_block line 8 at assignment
|
||||
-- test gms_compress.lz_uncompress
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('123'::raw));
|
||||
lz_uncompress
|
||||
---------------
|
||||
0123
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('df'::raw));
|
||||
lz_uncompress
|
||||
---------------
|
||||
DF
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('12ab56'::raw));
|
||||
lz_uncompress
|
||||
---------------
|
||||
12AB56
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('123'::raw, 1));
|
||||
lz_uncompress
|
||||
---------------
|
||||
0123
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('df'::raw, 6));
|
||||
lz_uncompress
|
||||
---------------
|
||||
DF
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('12ab56'::raw, 9));
|
||||
lz_uncompress
|
||||
---------------
|
||||
12AB56
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('123'::blob));
|
||||
lz_uncompress
|
||||
---------------
|
||||
0123
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('df'::blob));
|
||||
lz_uncompress
|
||||
---------------
|
||||
DF
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('12ab56'::blob));
|
||||
lz_uncompress
|
||||
---------------
|
||||
12AB56
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('123'::blob, 1));
|
||||
lz_uncompress
|
||||
---------------
|
||||
0123
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('df'::blob, 6));
|
||||
lz_uncompress
|
||||
---------------
|
||||
DF
|
||||
(1 row)
|
||||
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('12ab56'::blob, 9));
|
||||
lz_uncompress
|
||||
---------------
|
||||
12AB56
|
||||
(1 row)
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_content BLOB;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_content := '123';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS(r_content, v_content);
|
||||
RAISE NOTICE 'content=%,r_content=%,v_content=%', content, r_content, v_content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=0123,r_content=1F8B080000000000000363540600CC52A5FA02000000,v_content=0123
|
||||
-- abnormal scenario
|
||||
select gms_compress.lz_uncompress(null::raw);
|
||||
ERROR: uncompressed data cannot be NULL
|
||||
CONTEXT: referenced column: lz_uncompress
|
||||
select gms_compress.lz_uncompress(''::raw);
|
||||
ERROR: uncompressed data cannot be NULL
|
||||
CONTEXT: referenced column: lz_uncompress
|
||||
select gms_compress.lz_uncompress('dfg'::raw);
|
||||
ERROR: invalid hexadecimal digit: "g"
|
||||
LINE 1: select gms_compress.lz_uncompress('dfg'::raw);
|
||||
^
|
||||
CONTEXT: referenced column: lz_uncompress
|
||||
select gms_compress.lz_uncompress('123'::raw);
|
||||
ERROR: too small, minimum length of gzip format is 14 bytes
|
||||
CONTEXT: referenced column: lz_uncompress
|
||||
select gms_compress.lz_uncompress(null::blob);
|
||||
ERROR: uncompressed data cannot be NULL
|
||||
CONTEXT: referenced column: lz_uncompress
|
||||
select gms_compress.lz_uncompress(''::blob);
|
||||
ERROR: uncompressed data cannot be NULL
|
||||
CONTEXT: referenced column: lz_uncompress
|
||||
select gms_compress.lz_uncompress('dfg'::blob);
|
||||
ERROR: invalid hexadecimal digit: "g"
|
||||
LINE 1: select gms_compress.lz_uncompress('dfg'::blob);
|
||||
^
|
||||
CONTEXT: referenced column: lz_uncompress
|
||||
select gms_compress.lz_uncompress('123'::blob);
|
||||
ERROR: too small, minimum length of gzip format is 14 bytes
|
||||
CONTEXT: referenced column: lz_uncompress
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_content BLOB;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
r_content := NULL;
|
||||
v_content := '123';
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS(r_content, v_content);
|
||||
RAISE NOTICE 'content=%,r_content=%,v_content=%', content, r_content, v_content;
|
||||
END;
|
||||
/
|
||||
ERROR: parameter cannot be NULL
|
||||
CONTEXT: SQL statement "CALL gms_compress.lz_uncompress(r_content,v_content)"
|
||||
PL/pgSQL function inline_code_block line 8 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_content BLOB;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
r_content := '123';
|
||||
v_content := '123';
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS(r_content, v_content);
|
||||
RAISE NOTICE 'content=%,r_content=%,v_content=%', content, r_content, v_content;
|
||||
END;
|
||||
/
|
||||
ERROR: too small, minimum length of gzip format is 14 bytes
|
||||
CONTEXT: PL/pgSQL function gms_compress.lz_uncompress(blob,blob) line 5 at assignment
|
||||
SQL statement "CALL gms_compress.lz_uncompress(r_content,v_content)"
|
||||
PL/pgSQL function inline_code_block line 8 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_content BLOB;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_content := NULL;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS(r_content, v_content);
|
||||
RAISE NOTICE 'content=%,r_content=%,v_content=%', content, r_content, v_content;
|
||||
END;
|
||||
/
|
||||
ERROR: parameter cannot be NULL
|
||||
CONTEXT: SQL statement "CALL gms_compress.lz_uncompress(r_content,v_content)"
|
||||
PL/pgSQL function inline_code_block line 9 at SQL statement
|
||||
-- test gms_compress.lz_compress_open and ms_compress.lz_compress_close
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=<NULL>
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content,5);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=<NULL>
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(2,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(3,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(4,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(5,content);
|
||||
END;
|
||||
/
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
ERROR: NULL input for detoast datum packed
|
||||
CONTEXT: PL/pgSQL function inline_code_block line 5 at assignment
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content, 0);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
ERROR: compression quality must be within the range of 1 to 9
|
||||
CONTEXT: PL/pgSQL function inline_code_block line 5 at assignment
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(0,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
ERROR: invalid handle, it be within the range of 1 to 5
|
||||
CONTEXT: PL/pgSQL function gms_compress.lz_compress_close(integer,blob) line 2 at assignment
|
||||
SQL statement "CALL gms_compress.lz_compress_close(0,content)"
|
||||
PL/pgSQL function inline_code_block line 6 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=<NULL>
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle+1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
ERROR: handle 2 is not be used
|
||||
CONTEXT: PL/pgSQL function gms_compress.lz_compress_close(integer,blob) line 2 at assignment
|
||||
SQL statement "CALL gms_compress.lz_compress_close(v_handle+1,content)"
|
||||
PL/pgSQL function inline_code_block line 6 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=<NULL>
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
ERROR: no handle free, the maximum number of handles is 5
|
||||
CONTEXT: PL/pgSQL function inline_code_block line 10 at assignment
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(2,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(3,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(4,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(5,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
ERROR: handle 1 is not be used
|
||||
CONTEXT: PL/pgSQL function gms_compress.lz_compress_close(integer,blob) line 2 at assignment
|
||||
SQL statement "CALL gms_compress.lz_compress_close(1,content)"
|
||||
PL/pgSQL function inline_code_block line 10 at SQL statement
|
||||
-- test gms_compress.lz_compress_add
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=1F8B080000000000000363540600CC52A5FA02000000
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=1F8B0800000000000003635466540600F3008F1804000000
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle,content,NULL);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
ERROR: parameter cannot be NULL
|
||||
CONTEXT: SQL statement "CALL gms_compress.lz_compress_add(v_handle,content,NULL)"
|
||||
PL/pgSQL function inline_code_block line 8 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=<NULL>
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(0,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
ERROR: invalid handle, it be within the range of 1 to 5
|
||||
CONTEXT: SQL statement "CALL gms_compress.compress_add(handle,src)"
|
||||
PL/pgSQL function gms_compress.lz_compress_add(integer,blob,raw) line 5 at PERFORM
|
||||
SQL statement "CALL gms_compress.lz_compress_add(0,content,src)"
|
||||
PL/pgSQL function inline_code_block line 8 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=<NULL>
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle+1,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
ERROR: handle 2 is not be used
|
||||
CONTEXT: SQL statement "CALL gms_compress.compress_add(handle,src)"
|
||||
PL/pgSQL function gms_compress.lz_compress_add(integer,blob,raw) line 5 at PERFORM
|
||||
SQL statement "CALL gms_compress.lz_compress_add(v_handle+1,content,src)"
|
||||
PL/pgSQL function inline_code_block line 8 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=<NULL>
|
||||
-- test gms_compress.lz_uncompress_open and ms_compress.lz_uncompress_close
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
NOTICE: v_handle=1
|
||||
NOTICE: content=1F8B080000000000000363540600CC52A5FA02000000
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(3);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(4);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(5);
|
||||
END;
|
||||
/
|
||||
NOTICE: v_handle=1
|
||||
NOTICE: v_handle=2
|
||||
NOTICE: v_handle=3
|
||||
NOTICE: v_handle=4
|
||||
NOTICE: v_handle=5
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
END;
|
||||
/
|
||||
ERROR: uncompress_data can not be NULL
|
||||
CONTEXT: PL/pgSQL function inline_code_block line 5 at assignment
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
END;
|
||||
/
|
||||
ERROR: handle 1 is not be used
|
||||
CONTEXT: SQL statement "CALL gms_compress.uncompress_close(handle)"
|
||||
PL/pgSQL function gms_compress.lz_uncompress_close(integer) line 2 at PERFORM
|
||||
SQL statement "CALL gms_compress.lz_uncompress_close(v_handle)"
|
||||
PL/pgSQL function inline_code_block line 7 at PERFORM
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(0);
|
||||
END;
|
||||
/
|
||||
ERROR: invalid handle, it be within the range of 1 to 5
|
||||
CONTEXT: SQL statement "CALL gms_compress.uncompress_close(handle)"
|
||||
PL/pgSQL function gms_compress.lz_uncompress_close(integer) line 2 at PERFORM
|
||||
SQL statement "CALL gms_compress.lz_uncompress_close(0)"
|
||||
PL/pgSQL function inline_code_block line 7 at PERFORM
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
END;
|
||||
/
|
||||
ERROR: handle 2 is not be used
|
||||
CONTEXT: SQL statement "CALL gms_compress.uncompress_close(handle)"
|
||||
PL/pgSQL function gms_compress.lz_uncompress_close(integer) line 2 at PERFORM
|
||||
SQL statement "CALL gms_compress.lz_uncompress_close(2)"
|
||||
PL/pgSQL function inline_code_block line 7 at PERFORM
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
END;
|
||||
/
|
||||
ERROR: handle 1 is a compressed handle
|
||||
CONTEXT: SQL statement "CALL gms_compress.uncompress_close(handle)"
|
||||
PL/pgSQL function gms_compress.lz_uncompress_close(integer) line 2 at PERFORM
|
||||
SQL statement "CALL gms_compress.lz_uncompress_close(v_handle)"
|
||||
PL/pgSQL function inline_code_block line 6 at PERFORM
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1, content);
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(3);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(4);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(5);
|
||||
END;
|
||||
/
|
||||
NOTICE: v_handle=1
|
||||
NOTICE: v_handle=2
|
||||
NOTICE: v_handle=3
|
||||
NOTICE: v_handle=4
|
||||
NOTICE: v_handle=5
|
||||
ERROR: no handle free, the maximum number of handles is 5
|
||||
CONTEXT: PL/pgSQL function inline_code_block line 16 at assignment
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(3);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(4);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(5);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(6);
|
||||
END;
|
||||
/
|
||||
ERROR: invalid handle, it be within the range of 1 to 5
|
||||
CONTEXT: SQL statement "CALL gms_compress.uncompress_close(handle)"
|
||||
PL/pgSQL function gms_compress.lz_uncompress_close(integer) line 2 at PERFORM
|
||||
SQL statement "CALL gms_compress.lz_uncompress_close(6)"
|
||||
PL/pgSQL function inline_code_block line 9 at PERFORM
|
||||
-- test gms_compress.lz_uncompress_extract
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
NOTICE: content=1F8B080000000000000363540600CC52A5FA02000000
|
||||
NOTICE: v_raw=0123
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(0, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
ERROR: invalid handle, it be within the range of 1 to 5
|
||||
CONTEXT: PL/pgSQL function gms_compress.lz_uncompress_extract(integer,raw) line 2 at assignment
|
||||
SQL statement "CALL gms_compress.lz_uncompress_extract(0,v_raw)"
|
||||
PL/pgSQL function inline_code_block line 8 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(1, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
ERROR: handle 1 is not be used
|
||||
CONTEXT: PL/pgSQL function gms_compress.lz_uncompress_extract(integer,raw) line 2 at assignment
|
||||
SQL statement "CALL gms_compress.lz_uncompress_extract(1,v_raw)"
|
||||
PL/pgSQL function inline_code_block line 7 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
ERROR: no compressed data found in handle 1
|
||||
CONTEXT: PL/pgSQL function gms_compress.lz_uncompress_extract(integer,raw) line 2 at assignment
|
||||
SQL statement "CALL gms_compress.lz_uncompress_extract(v_handle,v_raw)"
|
||||
PL/pgSQL function inline_code_block line 7 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1);
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
ERROR: no compressed data found in handle 1
|
||||
CONTEXT: PL/pgSQL function gms_compress.lz_uncompress_extract(integer,raw) line 2 at assignment
|
||||
SQL statement "CALL gms_compress.lz_uncompress_extract(v_handle,v_raw)"
|
||||
PL/pgSQL function inline_code_block line 9 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
ERROR: too small, minimum length of gzip format is 14 bytes
|
||||
CONTEXT: PL/pgSQL function gms_compress.lz_uncompress_extract(integer,raw) line 2 at assignment
|
||||
SQL statement "CALL gms_compress.lz_uncompress_extract(v_handle,v_raw)"
|
||||
PL/pgSQL function inline_code_block line 7 at SQL statement
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
END;
|
||||
/
|
||||
-- test gms_compress.lz_isopen
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_bool := false;
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_bool := GMS_COMPRESS.ISOPEN(v_handle);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
v_bool := GMS_COMPRESS.ISOPEN(v_handle);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
END;
|
||||
/
|
||||
NOTICE: v_bool=t
|
||||
NOTICE: v_bool=f
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_bool := false;
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
v_bool := GMS_COMPRESS.ISOPEN(v_handle);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
v_bool := GMS_COMPRESS.ISOPEN(v_handle);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
END;
|
||||
/
|
||||
NOTICE: v_bool=t
|
||||
NOTICE: v_bool=f
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
v_bool := true;
|
||||
v_bool := GMS_COMPRESS.ISOPEN(0);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
END;
|
||||
/
|
||||
NOTICE: v_bool=f
|
||||
DECLARE
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
v_bool := true;
|
||||
v_bool := GMS_COMPRESS.ISOPEN(1);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
END;
|
||||
/
|
||||
NOTICE: v_bool=f
|
||||
reset search_path;
|
||||
drop schema gms_compress_test cascade;
|
@ -1,102 +0,0 @@
|
||||
/* contrib/gms_compress/gms_compress--1.0.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION gms_compress" to load this file. \quit
|
||||
|
||||
CREATE SCHEMA gms_compress;
|
||||
GRANT USAGE ON SCHEMA gms_compress TO PUBLIC;
|
||||
|
||||
set behavior_compat_options='proc_outparam_override';
|
||||
--These functions and procedures compress data using Lempel-Ziv compression algorithm.
|
||||
CREATE OR REPLACE FUNCTION gms_compress.lz_compress(src IN raw, quality IN integer := 6)
|
||||
RETURNS raw PACKAGE
|
||||
AS 'MODULE_PATHNAME','gms_lz_compress'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.lz_compress(src IN blob, quality IN integer := 6)
|
||||
RETURNS blob PACKAGE
|
||||
AS 'MODULE_PATHNAME','gms_lz_compress'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE gms_compress.lz_compress(src IN blob, dst INOUT blob, quality IN integer := 6) PACKAGE as
|
||||
begin
|
||||
dst := gms_compress.lz_compress(src, quality);
|
||||
end;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.lz_compress_open(src INOUT blob, quality IN integer := 6)
|
||||
RETURNS integer
|
||||
AS 'MODULE_PATHNAME','gms_lz_compress_open'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.lz_compress_close(handle IN integer)
|
||||
RETURNS blob PACKAGE
|
||||
AS '$libdir/gms_compress', 'gms_lz_compress_close'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE gms_compress.lz_compress_close(handle IN integer, dst INOUT blob) PACKAGE AS
|
||||
begin
|
||||
dst := gms_compress.lz_compress_close(handle);
|
||||
end;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.lz_uncompress_open(src IN blob)
|
||||
RETURNS integer
|
||||
AS 'MODULE_PATHNAME','gms_lz_uncompress_open'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.uncompress_close(handle IN integer)
|
||||
RETURNS void
|
||||
AS '$libdir/gms_compress', 'gms_lz_uncompress_close'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE gms_compress.lz_uncompress_close(handle IN integer) AS
|
||||
begin
|
||||
gms_compress.uncompress_close(handle);
|
||||
end;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.compress_add(handle IN integer, src IN raw)
|
||||
RETURNS void PACKAGE
|
||||
AS '$libdir/gms_compress', 'gms_lz_compress_add'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE gms_compress.lz_compress_add(handle IN integer, dst INOUT blob, src IN raw) PACKAGE AS
|
||||
begin
|
||||
IF src IS NULL THEN
|
||||
RAISE EXCEPTION 'parameter cannot be NULL';
|
||||
END IF;
|
||||
gms_compress.compress_add(handle, src);
|
||||
end;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.uncompress_extract(handle IN integer)
|
||||
RETURNS raw PACKAGE
|
||||
AS '$libdir/gms_compress', 'gms_lz_uncompress_extract'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE gms_compress.lz_uncompress_extract(handle IN integer, dst INOUT raw) PACKAGE AS
|
||||
begin
|
||||
dst := gms_compress.uncompress_extract(handle);
|
||||
end;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.isopen(handle IN integer)
|
||||
RETURNS boolean
|
||||
AS '$libdir/gms_compress', 'gms_isopen'
|
||||
LANGUAGE C;
|
||||
|
||||
----These functions and procedures decompress data using the Lempel-Ziv decompression algorithm.
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.lz_uncompress(src IN raw)
|
||||
RETURNS raw PACKAGE
|
||||
AS 'MODULE_PATHNAME','gms_lz_uncompress'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_compress.lz_uncompress(src IN blob)
|
||||
RETURNS blob PACKAGE
|
||||
AS 'MODULE_PATHNAME','gms_lz_uncompress'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE gms_compress.lz_uncompress(src IN blob, dst INOUT blob) PACKAGE as
|
||||
begin
|
||||
IF src IS NULL OR dst IS NULL THEN
|
||||
RAISE EXCEPTION 'parameter cannot be NULL';
|
||||
END IF;
|
||||
dst := gms_compress.lz_uncompress(src);
|
||||
end;
|
@ -1,5 +0,0 @@
|
||||
# gms_compress extension
|
||||
comment = 'provides a set of data compression utilities'
|
||||
default_version = '1.0'
|
||||
module_pathname = '$libdir/gms_compress'
|
||||
relocatable = true
|
@ -1,400 +0,0 @@
|
||||
#include <cstdlib>
|
||||
#include <zlib.h>
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
#include "commands/extension.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/varbit.h"
|
||||
#include "utils/memutils.h"
|
||||
|
||||
#include "gms_compress.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
#define MIN_QUALITY 1
|
||||
#define MAX_QUALITY 9
|
||||
#define MIN_HANDLE 0
|
||||
#define MAX_HANDLE 4
|
||||
#define HANDLE_OFFSET 1
|
||||
#define UNCOMPRESS_LEVEL 0
|
||||
|
||||
PG_FUNCTION_INFO_V1(gms_lz_compress);
|
||||
PG_FUNCTION_INFO_V1(gms_lz_uncompress);
|
||||
PG_FUNCTION_INFO_V1(gms_lz_compress_open);
|
||||
PG_FUNCTION_INFO_V1(gms_lz_compress_close);
|
||||
PG_FUNCTION_INFO_V1(gms_lz_compress_add);
|
||||
PG_FUNCTION_INFO_V1(gms_lz_uncompress_open);
|
||||
PG_FUNCTION_INFO_V1(gms_lz_uncompress_close);
|
||||
PG_FUNCTION_INFO_V1(gms_lz_uncompress_extract);
|
||||
PG_FUNCTION_INFO_V1(gms_isopen);
|
||||
|
||||
static void gzip_compress(void* src, Size src_len, void** dst, Size* dst_len, int quality);
|
||||
static void gzip_uncompress(void* src, Size src_len, void** dst, Size* dst_len);
|
||||
static void free_context(int handle);
|
||||
static inline void Check_Invalid_Input(gms_compress_context* compress_cxt, int handle);
|
||||
|
||||
static uint32 compress_index;
|
||||
|
||||
void set_extension_index(uint32 index)
|
||||
{
|
||||
compress_index = index;
|
||||
}
|
||||
|
||||
void init_session_vars(void) {
|
||||
RepallocSessionVarsArrayIfNecessary();
|
||||
gms_compress_context* psc =
|
||||
(gms_compress_context*)MemoryContextAlloc(u_sess->self_mem_cxt, sizeof(gms_compress_context));
|
||||
u_sess->attr.attr_common.extension_session_vars_array[compress_index] = psc;
|
||||
|
||||
for (int i =0;i < UTLCOMP_MAX_HANDLE;i++) {
|
||||
psc->context[i].compress_level = -1;
|
||||
psc->context[i].compressed_data = NULL;
|
||||
psc->context[i].uncompressed_data = NULL;
|
||||
psc->context[i].used = false;
|
||||
}
|
||||
}
|
||||
|
||||
gms_compress_context* get_session_context() {
|
||||
if (u_sess->attr.attr_common.extension_session_vars_array[compress_index] == NULL) {
|
||||
init_session_vars();
|
||||
}
|
||||
return (gms_compress_context*)u_sess->attr.attr_common.extension_session_vars_array[compress_index];
|
||||
}
|
||||
|
||||
Datum gms_lz_compress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (PG_ARGISNULL(0)) {
|
||||
ereport(ERROR, (errmsg("compressed data cannot be NULL")));
|
||||
}
|
||||
|
||||
bytea *input_bytea = PG_GETARG_BYTEA_PP(0);
|
||||
int quality = PG_GETARG_INT32(1);
|
||||
Size src_len = VARSIZE_ANY_EXHDR(input_bytea);
|
||||
bytea *dst = NULL;
|
||||
Size dst_len = 0;
|
||||
|
||||
/* Call gzip_compress function for compression */
|
||||
gzip_compress(input_bytea, src_len, (void**)&dst, &dst_len, quality);
|
||||
|
||||
SET_VARSIZE(dst, VARHDRSZ + dst_len);
|
||||
PG_RETURN_BYTEA_P(dst);
|
||||
}
|
||||
|
||||
Datum gms_lz_uncompress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (PG_ARGISNULL(0)) {
|
||||
ereport(ERROR, (errmsg("uncompressed data cannot be NULL")));
|
||||
}
|
||||
|
||||
bytea *input_bytea = PG_GETARG_BYTEA_PP(0);
|
||||
Size src_len = VARSIZE_ANY_EXHDR(input_bytea);
|
||||
bytea *dst = NULL;
|
||||
Size dst_len = 0;
|
||||
|
||||
/* Call gzip_uncompress function for uncompression */
|
||||
gzip_uncompress(input_bytea, src_len, (void**)&dst, &dst_len);
|
||||
|
||||
SET_VARSIZE(dst, VARHDRSZ + dst_len);
|
||||
PG_RETURN_TEXT_P(dst);
|
||||
}
|
||||
|
||||
/* Open a handle and initialize it */
|
||||
Datum gms_lz_compress_open(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bytea *input_bytea = PG_GETARG_BYTEA_PP(0);
|
||||
int quality = PG_GETARG_INT32(1);
|
||||
|
||||
if (quality < MIN_QUALITY || quality > MAX_QUALITY) {
|
||||
ereport(ERROR, (errmsg("compression quality must be within the range of %d to %d", MIN_QUALITY, MAX_QUALITY)));
|
||||
}
|
||||
|
||||
gms_compress_context *compress_cxt = get_session_context();
|
||||
for(int i = 0;i < UTLCOMP_MAX_HANDLE;i++) {
|
||||
if (!compress_cxt->context[i].used) {
|
||||
compress_cxt->context[i].compress_level = quality;
|
||||
compress_cxt->context[i].used = true;
|
||||
PG_RETURN_INT32(i + HANDLE_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
ereport(ERROR, (errmsg("no handle free, the maximum number of handles is %d", MAX_HANDLE + HANDLE_OFFSET)));
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/* Close a handle and compress the data back */
|
||||
Datum gms_lz_compress_close(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int handle = PG_GETARG_INT32(0) - HANDLE_OFFSET;
|
||||
gms_compress_context *compress_cxt = get_session_context();
|
||||
|
||||
Check_Invalid_Input(compress_cxt, handle);
|
||||
|
||||
if (compress_cxt->context[handle].uncompressed_data == NULL) {
|
||||
free_context(handle);
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
|
||||
if (compress_cxt->context[handle].compress_level == UNCOMPRESS_LEVEL) {
|
||||
ereport(ERROR, (errmsg("handle %d is a uncompressed handle", handle + HANDLE_OFFSET)));
|
||||
}
|
||||
|
||||
bytea *input_bytea = (bytea *)compress_cxt->context[handle].uncompressed_data;
|
||||
Assert((char*)input_bytea + VARHDRSZ == VARDATA_ANY(input_bytea));
|
||||
Size src_len = VARSIZE_ANY_EXHDR(input_bytea);
|
||||
if (src_len > MaxAllocSize - VARHDRSZ) {
|
||||
free_context(handle);
|
||||
ereport(ERROR, (errmsg("data too long, data size cannot exceed 1GB")));
|
||||
}
|
||||
|
||||
bytea *dst = NULL;
|
||||
Size dst_len = 0;
|
||||
int quality = compress_cxt->context[handle].compress_level;
|
||||
/* Call gzip_compress function for compression */
|
||||
gzip_compress(input_bytea, src_len, (void**)&dst, &dst_len, quality);
|
||||
|
||||
SET_VARSIZE(dst, VARHDRSZ + dst_len);
|
||||
|
||||
free_context(handle);
|
||||
PG_RETURN_BYTEA_P(dst);
|
||||
}
|
||||
|
||||
/* Open a handle and store data into it */
|
||||
Datum gms_lz_compress_add(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int handle = PG_GETARG_INT32(0) - HANDLE_OFFSET;
|
||||
gms_compress_context *compress_cxt = get_session_context();
|
||||
bytea *input_bytea = PG_GETARG_BYTEA_PP(1);
|
||||
Size src_len = VARSIZE_ANY_EXHDR(input_bytea);
|
||||
|
||||
Check_Invalid_Input(compress_cxt, handle);
|
||||
|
||||
if (compress_cxt->context[handle].compress_level == UNCOMPRESS_LEVEL) {
|
||||
ereport(ERROR, (errmsg("handle %d is a uncompressed handle", handle + HANDLE_OFFSET)));
|
||||
}
|
||||
|
||||
if (src_len > MaxAllocSize - VARHDRSZ) {
|
||||
ereport(ERROR, (errmsg("data too long, data size cannot exceed 1GB")));
|
||||
}
|
||||
|
||||
bytea *new_data = (bytea *)compress_cxt->context[handle].uncompressed_data;
|
||||
if (new_data == NULL) {
|
||||
new_data = (bytea *)MemoryContextAlloc(u_sess->self_mem_cxt, src_len + VARHDRSZ);
|
||||
SET_VARSIZE(new_data, src_len + VARHDRSZ);
|
||||
Assert((char*)new_data + VARHDRSZ == VARDATA_ANY(new_data));
|
||||
errno_t rc = memcpy_s(VARDATA(new_data), src_len, VARDATA(input_bytea), src_len);
|
||||
securec_check(rc, "\0", "\0");
|
||||
compress_cxt->context[handle].uncompressed_data = new_data;
|
||||
} else {
|
||||
Size dst_len = VARSIZE_ANY_EXHDR(new_data);
|
||||
Size uncompressed_size = src_len + dst_len + VARHDRSZ;
|
||||
if (uncompressed_size > MaxAllocSize) {
|
||||
ereport(ERROR, (errmsg("data too long, data size cannot exceed 1GB")));
|
||||
}
|
||||
new_data = (bytea *)repalloc(new_data, uncompressed_size);
|
||||
SET_VARSIZE(new_data, uncompressed_size);
|
||||
Assert((char*)new_data + VARHDRSZ == VARDATA_ANY(new_data));
|
||||
errno_t rc = memcpy_s(VARDATA(new_data) + dst_len, src_len, VARDATA(input_bytea), src_len);
|
||||
securec_check(rc, "\0", "\0");
|
||||
compress_cxt->context[handle].uncompressed_data = new_data;
|
||||
}
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/* Open a handle and initialize it */
|
||||
Datum gms_lz_uncompress_open(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (PG_ARGISNULL(0)) {
|
||||
ereport(ERROR, (errmsg("uncompress_data can not be NULL")));
|
||||
}
|
||||
|
||||
bytea *input_bytea = PG_GETARG_BYTEA_PP(0);
|
||||
gms_compress_context *compress_cxt = get_session_context();
|
||||
|
||||
for(int i = 0;i < UTLCOMP_MAX_HANDLE;i++) {
|
||||
if (!compress_cxt->context[i].used) {
|
||||
compress_cxt->context[i].compressed_data = input_bytea;
|
||||
compress_cxt->context[i].compress_level = UNCOMPRESS_LEVEL;
|
||||
compress_cxt->context[i].used = true;
|
||||
|
||||
PG_RETURN_INT32(i + HANDLE_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
ereport(ERROR, (errmsg("no handle free, the maximum number of handles is %d", MAX_HANDLE + HANDLE_OFFSET)));
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/* Close and free the handle */
|
||||
Datum gms_lz_uncompress_close(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int handle = PG_GETARG_INT32(0) - HANDLE_OFFSET;
|
||||
gms_compress_context *compress_cxt = get_session_context();
|
||||
|
||||
Check_Invalid_Input(compress_cxt, handle);
|
||||
|
||||
if (compress_cxt->context[handle].compress_level != UNCOMPRESS_LEVEL) {
|
||||
ereport(ERROR, (errmsg("handle %d is a compressed handle", handle + HANDLE_OFFSET)));
|
||||
}
|
||||
|
||||
free_context(handle);
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/* Open a handle and uncompress the data back */
|
||||
Datum gms_lz_uncompress_extract(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int handle = PG_GETARG_INT32(0) - HANDLE_OFFSET;
|
||||
gms_compress_context *compress_cxt = get_session_context();
|
||||
|
||||
Check_Invalid_Input(compress_cxt, handle);
|
||||
|
||||
if (compress_cxt->context[handle].compressed_data == NULL) {
|
||||
ereport(ERROR, (errmsg("no compressed data found in handle %d", handle + HANDLE_OFFSET)));
|
||||
}
|
||||
|
||||
if (compress_cxt->context[handle].compress_level != UNCOMPRESS_LEVEL) {
|
||||
ereport(ERROR, (errmsg("handle %d is a compressed handle", handle + HANDLE_OFFSET)));
|
||||
}
|
||||
|
||||
bytea *src = (bytea *)compress_cxt->context[handle].compressed_data;
|
||||
Size src_len = VARSIZE_ANY_EXHDR(src);
|
||||
Size dst_len = 0;
|
||||
bytea *dst = NULL;
|
||||
|
||||
compress_cxt->context[handle].compressed_data = NULL;
|
||||
gzip_uncompress(src, src_len, (void**)&dst, &dst_len);
|
||||
|
||||
SET_VARSIZE(dst, VARHDRSZ + dst_len);
|
||||
|
||||
PG_RETURN_BYTEA_P(dst);
|
||||
}
|
||||
|
||||
/* Check if a handle has been opened */
|
||||
Datum gms_isopen(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int handle = PG_GETARG_INT32(0) - HANDLE_OFFSET;
|
||||
if (handle < MIN_HANDLE || handle > MAX_HANDLE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return get_session_context()->context[handle].used;
|
||||
}
|
||||
|
||||
/* Using the zlib library and Lemoel Xiv algorithm to implement compression functionality */
|
||||
static void gzip_compress(void* src, Size src_len, void** dst, Size* dst_len, int quality)
|
||||
{
|
||||
/* The compression quality is limited between 1 and 9 */
|
||||
if (quality < MIN_QUALITY || quality > MAX_QUALITY) {
|
||||
ereport(ERROR, (errmsg("compression quality must be within the range of %d to %d", MIN_QUALITY, MAX_QUALITY)));
|
||||
}
|
||||
|
||||
bytea *input_bytea = (bytea*)src;
|
||||
Size compressed_size = compressBound(src_len) + GZIP_COMPRESS_EXTRA_LENGTH;
|
||||
bytea *result = (bytea*)palloc(VARHDRSZ + compressed_size);
|
||||
SET_VARSIZE(result, VARHDRSZ + compressed_size);
|
||||
|
||||
z_stream c_stream;
|
||||
c_stream.zalloc = NULL;
|
||||
c_stream.zfree = NULL;
|
||||
c_stream.opaque = NULL;
|
||||
// MAX_WBITS + 16 for gzip
|
||||
if (deflateInit2(&c_stream, quality, Z_DEFLATED, MAX_WBITS + 16, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
|
||||
pfree_ext(result);
|
||||
ereport(ERROR, (errmsg("zlib compression initialization failed")));
|
||||
}
|
||||
|
||||
c_stream.avail_out = compressed_size; // output size
|
||||
c_stream.next_out = (Bytef*)VARDATA_ANY(result); // output buffer
|
||||
c_stream.avail_in = src_len; // input size
|
||||
c_stream.next_in = (Bytef*)VARDATA_ANY(input_bytea); // input buffer
|
||||
|
||||
if (deflate(&c_stream, Z_FINISH) != Z_STREAM_END) {
|
||||
pfree_ext(result);
|
||||
ereport(ERROR, (errmsg("zlib compression failed")));
|
||||
}
|
||||
|
||||
if (deflateEnd(&c_stream) != Z_OK) {
|
||||
pfree_ext(result);
|
||||
ereport(ERROR, (errmsg("zlib cleaning up compression stream failed")));
|
||||
}
|
||||
*dst_len = c_stream.total_out;
|
||||
*dst = result;
|
||||
}
|
||||
|
||||
/* Using the zlib library and Lemoel Xiv algorithm to implement uncompression functionality */
|
||||
static void gzip_uncompress(void* src, Size src_len, void** dst, Size* dst_len)
|
||||
{
|
||||
bytea *input_bytea = (bytea*)src;
|
||||
if (src_len < GZIP_MIN_LENGTH) {
|
||||
ereport(ERROR, (errmsg("too small, minimum length of gzip format is %d bytes", GZIP_MIN_LENGTH)));
|
||||
}
|
||||
unsigned char *gzip_content = (unsigned char*)VARDATA_ANY(input_bytea);
|
||||
if (gzip_content[0] != GZIP_HEADER_1 || gzip_content[1] != GZIP_HEADER_2) {
|
||||
ereport(ERROR, (errmsg("data corrupt, invalid compressed data head")));
|
||||
}
|
||||
uint4 uncompressed_size = *(uint4*)(gzip_content + src_len - sizeof(int));
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
uncompressed_size = BSWAP32(uncompressed_size);
|
||||
#endif
|
||||
if (uncompressed_size > MaxAllocSize - VARHDRSZ) {
|
||||
ereport(ERROR, (errmsg("data too long, data size cannot exceed 1GB")));
|
||||
}
|
||||
bytea *result = (bytea*)palloc(VARHDRSZ + uncompressed_size);
|
||||
SET_VARSIZE(result, VARHDRSZ + uncompressed_size);
|
||||
|
||||
z_stream d_stream = { 0 };
|
||||
d_stream.zalloc = NULL;
|
||||
d_stream.zfree = NULL;
|
||||
d_stream.opaque = NULL;
|
||||
d_stream.next_in = (Bytef*)VARDATA_ANY(input_bytea);
|
||||
d_stream.avail_in = src_len;
|
||||
d_stream.avail_out = VARSIZE_ANY_EXHDR(result);
|
||||
d_stream.next_out = (Bytef*)VARDATA_ANY(result);
|
||||
// MAX_WBITS + 16 for gzip
|
||||
if (inflateInit2(&d_stream, 16 + MAX_WBITS) != Z_OK) {
|
||||
pfree_ext(result);
|
||||
ereport(ERROR, (errmsg("zlib uncompression initialization failed")));
|
||||
}
|
||||
if (inflate(&d_stream, Z_FINISH) != Z_STREAM_END) {
|
||||
pfree_ext(result);
|
||||
ereport(ERROR, (errmsg("zlib uncompression failed")));
|
||||
}
|
||||
|
||||
if (inflateEnd(&d_stream) != Z_OK) {
|
||||
pfree_ext(result);
|
||||
ereport(ERROR, (errmsg("zlib cleaning up uncompression stream failed")));
|
||||
}
|
||||
*dst_len = d_stream.total_out;
|
||||
*dst = result;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Because compressed_data is the data source address and
|
||||
* uncompressed_data is the newly created data address,
|
||||
* it is necessary to point compressed_data to null and release uncompressed_data
|
||||
*/
|
||||
static void free_context(int handle)
|
||||
{
|
||||
if (handle < MIN_HANDLE || handle > MAX_HANDLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
gms_compress_context *compress_cxt = get_session_context();
|
||||
compress_cxt->context[handle].compressed_data =NULL;
|
||||
pfree_ext(compress_cxt->context[handle].uncompressed_data);
|
||||
compress_cxt->context[handle].compress_level = -1;
|
||||
compress_cxt->context[handle].used = false;
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void Check_Invalid_Input(gms_compress_context* compress_cxt, int handle) {
|
||||
if (handle < MIN_HANDLE || handle > MAX_HANDLE) {
|
||||
ereport(ERROR, (errmsg("invalid handle, it be within the range of %d to %d",
|
||||
MIN_HANDLE + HANDLE_OFFSET, MAX_HANDLE + HANDLE_OFFSET)));
|
||||
}
|
||||
|
||||
if (!compress_cxt->context[handle].used) {
|
||||
ereport(ERROR, (errmsg("handle %d is not be used", handle + HANDLE_OFFSET)));
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
#ifndef __GMS_COMPRESS__
|
||||
#define __GMS_COMPRESS__
|
||||
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#define GZIP_COMPRESS_EXTRA_LENGTH 18
|
||||
#define GZIP_MIN_LENGTH 14
|
||||
#define GZIP_HEADER_1 ((unsigned char)0x1f)
|
||||
#define GZIP_HEADER_2 ((unsigned char)0x8b)
|
||||
#define UTLCOMP_MAX_HANDLE 5
|
||||
|
||||
typedef struct gms_context {
|
||||
void *uncompressed_data; /* data to be compressed */
|
||||
void *compressed_data; /* data after compressed or data to be uncompressed */
|
||||
int2 compress_level; /* 0 for uncompress, 1~9 for compress */
|
||||
bool used;
|
||||
} gms_context;
|
||||
typedef struct gms_compress_context {
|
||||
gms_context context[UTLCOMP_MAX_HANDLE];
|
||||
} gms_compress_context;
|
||||
|
||||
extern "C" Datum gms_lz_compress(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lz_uncompress(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lz_compress_open(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lz_compress_close(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lz_compress_add(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lz_uncompress_open(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lz_uncompress_close(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lz_uncompress_extract(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_isopen(PG_FUNCTION_ARGS);
|
||||
extern "C" void set_extension_index(uint32 index);
|
||||
extern "C" void init_session_vars(void);
|
||||
|
||||
|
||||
#endif // __GMS_COMPRESS__
|
@ -1,715 +0,0 @@
|
||||
create extension gms_compress;
|
||||
create schema gms_compress_test;
|
||||
set search_path=gms_compress_test;
|
||||
|
||||
-- test gms_compress.compress
|
||||
select gms_compress.lz_compress('123'::raw);
|
||||
select gms_compress.lz_compress('df'::raw);
|
||||
select gms_compress.lz_compress('12ab56'::raw);
|
||||
select gms_compress.lz_compress('123'::raw, 1);
|
||||
select gms_compress.lz_compress('df'::raw, 6);
|
||||
select gms_compress.lz_compress('12ab56'::raw, 9);
|
||||
select gms_compress.lz_compress('123'::blob);
|
||||
select gms_compress.lz_compress('df'::blob);
|
||||
select gms_compress.lz_compress('12ab56'::blob);
|
||||
select gms_compress.lz_compress('123'::blob, 1);
|
||||
select gms_compress.lz_compress('df'::blob, 6);
|
||||
select gms_compress.lz_compress('12ab56'::blob, 9);
|
||||
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
r_raw raw;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_raw := '12345';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
r_raw := GMS_COMPRESS.LZ_COMPRESS(v_raw);
|
||||
RAISE NOTICE 'r_content=%,r_raw=%', r_content, r_raw;
|
||||
r_content := '111';
|
||||
GMS_COMPRESS.LZ_COMPRESS(content, r_content);
|
||||
RAISE NOTICE 'r_content=%', r_content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
r_raw raw;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := 'abc';
|
||||
v_raw := 'df';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content, 1);
|
||||
r_raw := GMS_COMPRESS.LZ_COMPRESS(v_raw, 9);
|
||||
RAISE NOTICE 'r_content=%,r_raw=%', r_content, r_raw;
|
||||
r_content := '111';
|
||||
GMS_COMPRESS.LZ_COMPRESS(content, r_content, 5);
|
||||
RAISE NOTICE 'r_content=%', r_content;
|
||||
END;
|
||||
/
|
||||
|
||||
-- abnormal scenario
|
||||
select gms_compress.lz_compress(null::raw);
|
||||
select gms_compress.lz_compress(''::raw);
|
||||
select gms_compress.lz_compress('dfg'::raw);
|
||||
select gms_compress.lz_compress('dfg'::raw, 5);
|
||||
select gms_compress.lz_compress('123'::raw, 0);
|
||||
select gms_compress.lz_compress('123'::raw, 10);
|
||||
select gms_compress.lz_compress(null::blob);
|
||||
select gms_compress.lz_compress(''::blob);
|
||||
select gms_compress.lz_compress('dfg'::blob);
|
||||
select gms_compress.lz_compress('dfg'::blob, 5);
|
||||
select gms_compress.lz_compress('123'::blob, 0);
|
||||
select gms_compress.lz_compress('123'::blob, 10);
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_raw raw;
|
||||
r_raw raw;
|
||||
BEGIN
|
||||
content := '';
|
||||
v_raw := 'dfg';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
r_raw := GMS_COMPRESS.LZ_COMPRESS(v_raw);
|
||||
RAISE NOTICE 'r_content=%,r_raw=%', r_content, r_raw;
|
||||
r_content := '111';
|
||||
GMS_COMPRESS.LZ_COMPRESS(content, r_content);
|
||||
RAISE NOTICE 'r_content=%', r_content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_raw raw;
|
||||
r_raw raw;
|
||||
BEGIN
|
||||
content := 'abc';
|
||||
v_raw := 'df';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content, 0);
|
||||
r_raw := GMS_COMPRESS.LZ_COMPRESS(v_raw, 10);
|
||||
RAISE NOTICE 'r_content=%,r_raw=%', r_content, r_raw;
|
||||
r_content := '111';
|
||||
GMS_COMPRESS.LZ_COMPRESS(content, r_content, -1);
|
||||
RAISE NOTICE 'r_content=%', r_content;
|
||||
END;
|
||||
/
|
||||
|
||||
-- test gms_compress.lz_uncompress
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('123'::raw));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('df'::raw));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('12ab56'::raw));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('123'::raw, 1));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('df'::raw, 6));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('12ab56'::raw, 9));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('123'::blob));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('df'::blob));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('12ab56'::blob));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('123'::blob, 1));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('df'::blob, 6));
|
||||
select gms_compress.lz_uncompress(gms_compress.lz_compress('12ab56'::blob, 9));
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_content BLOB;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_content := '123';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS(r_content, v_content);
|
||||
RAISE NOTICE 'content=%,r_content=%,v_content=%', content, r_content, v_content;
|
||||
END;
|
||||
/
|
||||
|
||||
-- abnormal scenario
|
||||
select gms_compress.lz_uncompress(null::raw);
|
||||
select gms_compress.lz_uncompress(''::raw);
|
||||
select gms_compress.lz_uncompress('dfg'::raw);
|
||||
select gms_compress.lz_uncompress('123'::raw);
|
||||
select gms_compress.lz_uncompress(null::blob);
|
||||
select gms_compress.lz_uncompress(''::blob);
|
||||
select gms_compress.lz_uncompress('dfg'::blob);
|
||||
select gms_compress.lz_uncompress('123'::blob);
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_content BLOB;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
r_content := NULL;
|
||||
v_content := '123';
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS(r_content, v_content);
|
||||
RAISE NOTICE 'content=%,r_content=%,v_content=%', content, r_content, v_content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_content BLOB;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
r_content := '123';
|
||||
v_content := '123';
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS(r_content, v_content);
|
||||
RAISE NOTICE 'content=%,r_content=%,v_content=%', content, r_content, v_content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
r_content BLOB;
|
||||
v_content BLOB;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
r_content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_content := NULL;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS(r_content, v_content);
|
||||
RAISE NOTICE 'content=%,r_content=%,v_content=%', content, r_content, v_content;
|
||||
END;
|
||||
/
|
||||
|
||||
-- test gms_compress.lz_compress_open and ms_compress.lz_compress_close
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content,5);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(2,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(3,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(4,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(5,content);
|
||||
END;
|
||||
/
|
||||
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content, 0);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(0,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle+1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(2,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(3,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(4,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(5,content);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
-- test gms_compress.lz_compress_add
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle,content,NULL);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(0,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
src raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
src := '123';
|
||||
GMS_COMPRESS.LZ_COMPRESS_ADD(v_handle+1,content,src);
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1,content);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
-- test gms_compress.lz_uncompress_open and ms_compress.lz_uncompress_close
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(3);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(4);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(5);
|
||||
END;
|
||||
/
|
||||
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(0);
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1, content);
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
RAISE NOTICE 'v_handle=%', v_handle;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(3);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(4);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(5);
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(2);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(3);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(4);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(5);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(6);
|
||||
END;
|
||||
/
|
||||
|
||||
-- test gms_compress.lz_uncompress_extract
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(0, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(1, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(1);
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_raw raw;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_EXTRACT(v_handle, v_raw);
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
RAISE NOTICE 'content=%', content;
|
||||
RAISE NOTICE 'v_raw=%', v_raw;
|
||||
END;
|
||||
/
|
||||
DECLARE
|
||||
content BLOB;
|
||||
BEGIN
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(1);
|
||||
END;
|
||||
/
|
||||
|
||||
-- test gms_compress.lz_isopen
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_bool := false;
|
||||
v_handle := GMS_COMPRESS.LZ_COMPRESS_OPEN(content);
|
||||
v_bool := GMS_COMPRESS.ISOPEN(v_handle);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
GMS_COMPRESS.LZ_COMPRESS_CLOSE(v_handle,content);
|
||||
v_bool := GMS_COMPRESS.ISOPEN(v_handle);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
content BLOB;
|
||||
v_handle int;
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
content := '123';
|
||||
v_bool := false;
|
||||
content := GMS_COMPRESS.LZ_COMPRESS(content);
|
||||
v_handle := GMS_COMPRESS.LZ_UNCOMPRESS_OPEN(content);
|
||||
v_bool := GMS_COMPRESS.ISOPEN(v_handle);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
GMS_COMPRESS.LZ_UNCOMPRESS_CLOSE(v_handle);
|
||||
v_bool := GMS_COMPRESS.ISOPEN(v_handle);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
END;
|
||||
/
|
||||
|
||||
-- abnormal scenario
|
||||
DECLARE
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
v_bool := true;
|
||||
v_bool := GMS_COMPRESS.ISOPEN(0);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
END;
|
||||
/
|
||||
|
||||
DECLARE
|
||||
v_bool boolean;
|
||||
BEGIN
|
||||
v_bool := true;
|
||||
v_bool := GMS_COMPRESS.ISOPEN(1);
|
||||
RAISE NOTICE 'v_bool=%', v_bool;
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
reset search_path;
|
||||
drop schema gms_compress_test cascade;
|
@ -1,21 +0,0 @@
|
||||
#This is the main CMAKE for build all gms_debug.
|
||||
# gms_debug
|
||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TGT_gms_debug_SRC)
|
||||
set(TGT_gms_debug_INC
|
||||
${PROJECT_OPENGS_DIR}/contrib/gms_debug
|
||||
${PROJECT_OPENGS_DIR}/contrib
|
||||
)
|
||||
|
||||
set(gms_debug_DEF_OPTIONS ${MACRO_OPTIONS})
|
||||
set(gms_debug_COMPILE_OPTIONS ${OPTIMIZE_OPTIONS} ${OS_OPTIONS} ${PROTECT_OPTIONS} ${WARNING_OPTIONS} ${LIB_SECURE_OPTIONS} ${CHECK_OPTIONS})
|
||||
set(gms_debug_LINK_OPTIONS ${LIB_LINK_OPTIONS})
|
||||
add_shared_libtarget(gms_debug TGT_gms_debug_SRC TGT_gms_debug_INC "${gms_debug_DEF_OPTIONS}" "${gms_debug_COMPILE_OPTIONS}" "${gms_debug_LINK_OPTIONS}")
|
||||
set_target_properties(gms_debug PROPERTIES PREFIX "")
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_debug.control
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_debug--1.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(TARGETS gms_debug DESTINATION lib/postgresql)
|
@ -1,29 +0,0 @@
|
||||
# contrib/gms_debug/Makefile
|
||||
MODULE_big = gms_debug
|
||||
OBJS = gms_debug.o
|
||||
|
||||
EXTENSION = gms_debug
|
||||
DATA = gms_debug--1.0.sql
|
||||
|
||||
exclude_option = -fPIE
|
||||
override CPPFLAGS := -fstack-protector-strong $(filter-out $(exclude_option),$(CPPFLAGS))
|
||||
|
||||
REGRESS = gms_debug
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/gms_debug
|
||||
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_debug.o: gms_debug.cpp
|
||||
|
@ -1 +0,0 @@
|
||||
The openGauss regression needs this file to run.
|
@ -1,269 +0,0 @@
|
||||
-- wait for server establishment
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
set search_path = gms_debugger_test1;
|
||||
CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int)
|
||||
returns void as $$
|
||||
declare
|
||||
pro_info gms_debug.program_info;
|
||||
bkline binary_integer;
|
||||
ret binary_integer;
|
||||
begin
|
||||
pro_info.name := funcname;
|
||||
ret := gms_debug.set_breakpoint(pro_info, lineno, bkline,1,1);
|
||||
RAISE NOTICE 'ret= %', ret;
|
||||
RAISE NOTICE 'ret= %', bkline;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_next()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 2, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_step()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 4, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_info()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.get_runtime_info(1, run_info);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
attach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(3);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_breakpoint('test_debug', 0); -- negative
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
gms_breakpoint
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_breakpoint('test_debug', 15); -- ok
|
||||
NOTICE: ret= 1
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
gms_breakpoint
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_breakpoint('test_debug', 17); -- invalid
|
||||
NOTICE: ret= 2
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
gms_breakpoint
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_breakpoint('test_debug', 22); -- ok
|
||||
NOTICE: ret= 3
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
gms_breakpoint
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_breakpoint('test_debug', 15); -- ok
|
||||
WARNING: the given line number already contains a valid breakpoint.
|
||||
CONTEXT: SQL statement "CALL gms_debug.add_breakpoint(proid,line#,breakpoint#,fuzzy,iterations,sts)"
|
||||
PL/pgSQL function gms_debug.set_breakpoint(gms_debug.program_info,integer,integer,integer) line 8 at SQL statement
|
||||
SQL statement "CALL gms_debug.set_breakpoint(pro_info,lineno,bkline,1,1)"
|
||||
PL/pgSQL function gms_breakpoint(text,integer) line 8 at assignment
|
||||
referenced column: gms_breakpoint
|
||||
NOTICE: ret= -1
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
NOTICE: ret= -3
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
gms_breakpoint
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 16
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 19
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 19
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= 3
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 22
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 2
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_continue();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: line= 46
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: reason= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
gms_continue
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_continue();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: line= 46
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: reason= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
gms_continue
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_debug.detach_session();
|
||||
connection to server was lost
|
@ -1,144 +0,0 @@
|
||||
-- wait for server establishment
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
set search_path = gms_debugger_test2;
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_next()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 2, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
attach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(3);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 3
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 4
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 5
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_continue();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: line= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: reason= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
gms_continue
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_debug.detach_session();
|
||||
detach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
@ -1,144 +0,0 @@
|
||||
-- wait for server establishment
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
set search_path = gms_debugger_test3;
|
||||
CREATE or REPLACE FUNCTION gms_next()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 2, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
attach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(3);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 10
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_continue();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: line= 14
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: reason= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
gms_continue
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_debug.detach_session();
|
||||
detach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
@ -1,192 +0,0 @@
|
||||
-- wait for server establishment
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
set search_path = gms_debugger_test4;
|
||||
CREATE or REPLACE FUNCTION gms_step()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 4, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
attach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(3);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_step();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: line= 6
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: reason= 3
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_step
|
||||
gms_step
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_step();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: line= 7
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: reason= 3
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_step
|
||||
gms_step
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_step();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: stackdepth= 1
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: line= 15
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: reason= 3
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_step
|
||||
gms_step
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_step();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: stackdepth= 1
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: line= 16
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: reason= 3
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_step
|
||||
gms_step
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_step();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: stackdepth= 1
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: line= 19
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: reason= 3
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_step
|
||||
gms_step
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_continue();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: line= 14
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: reason= 3
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
gms_continue
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_continue();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: line= 15
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: reason= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
gms_continue
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_debug.detach_session();
|
||||
detach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
@ -1,200 +0,0 @@
|
||||
-- wait for server establishment
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
set search_path = gms_debugger_test5;
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_step()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 4, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_next()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 2, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_finish()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 8, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
attach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(3);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 7
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_next();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: line= 14
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: reason= 6
|
||||
CONTEXT: referenced column: gms_next
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_next
|
||||
gms_next
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_step();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: line= 15
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: reason= 3
|
||||
CONTEXT: referenced column: gms_step
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_step
|
||||
gms_step
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_finish();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: line= 15
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: reason= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
gms_finish
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_finish();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: line= 15
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: reason= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
gms_finish
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_debug.detach_session();
|
||||
connection to server was lost
|
@ -1,177 +0,0 @@
|
||||
-- wait for server establishment
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
set search_path = gms_debugger_test6;
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int)
|
||||
returns void as $$
|
||||
declare
|
||||
pro_info gms_debug.program_info;
|
||||
bkline binary_integer;
|
||||
ret binary_integer;
|
||||
begin
|
||||
pro_info.name := funcname;
|
||||
ret := gms_debug.set_breakpoint(pro_info, lineno, bkline,1,1);
|
||||
RAISE NOTICE 'ret= %', ret;
|
||||
RAISE NOTICE 'ret= %', bkline;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE or REPLACE FUNCTION gms_finish()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 8, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
attach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(3);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_breakpoint('test_debug', 31);
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
gms_breakpoint
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_breakpoint('test_debug', 44);
|
||||
NOTICE: ret= 1
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_breakpoint
|
||||
gms_breakpoint
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_finish();
|
||||
NOTICE: breakpoint= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: stackdepth= 1
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: line= 31
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: reason= 2
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
gms_finish
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_finish();
|
||||
NOTICE: breakpoint= 1
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: stackdepth= 1
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: line= 44
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: reason= 2
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
gms_finish
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_finish();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: line= 14
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: reason= 3
|
||||
CONTEXT: referenced column: gms_finish
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_finish
|
||||
gms_finish
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_continue();
|
||||
NOTICE: breakpoint= -1
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: stackdepth= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: line= 15
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: reason= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
NOTICE: ret= 0
|
||||
CONTEXT: referenced column: gms_continue
|
||||
gms_continue
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_debug.detach_session();
|
||||
detach_session
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
@ -1,181 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test1 cascade;
|
||||
NOTICE: schema "gms_debugger_test1" does not exist, skipping
|
||||
create schema gms_debugger_test1;
|
||||
set search_path = gms_debugger_test1;
|
||||
create table test(a int, b varchar(40), c timestamp);
|
||||
insert into test values (2, 'Giving to the Needy', '2020-02-02');
|
||||
insert into test values (3, 'Prayer', '2021-12-02');
|
||||
insert into test values (5, 'Fasting', '2030-03-02');
|
||||
insert into test values (7, 'Treasures in Heaven', '2040-04-02');
|
||||
CREATE OR REPLACE FUNCTION test_debug(x int) RETURNS SETOF test AS
|
||||
$BODY$
|
||||
DECLARE
|
||||
sql_stmt VARCHAR2(500);
|
||||
r test%rowtype;
|
||||
rec record;
|
||||
b_tmp text;
|
||||
cnt int;
|
||||
a_tmp int;
|
||||
cur refcursor;
|
||||
n_tmp NUMERIC(24,6);
|
||||
t_tmp tsquery;
|
||||
CURSOR cur_arg(criterion INTEGER) IS
|
||||
SELECT * FROM test WHERE a < criterion;
|
||||
BEGIN
|
||||
cnt := 0;
|
||||
FOR r IN SELECT * FROM test
|
||||
WHERE a > x
|
||||
LOOP
|
||||
RETURN NEXT r;
|
||||
END LOOP;
|
||||
|
||||
FOR rec in SELECT * FROM test
|
||||
WHERE a < x
|
||||
LOOP
|
||||
RETURN NEXT rec;
|
||||
END LOOP;
|
||||
|
||||
FORALL index_1 IN 0..1
|
||||
INSERT INTO test VALUES (index_1, 'Happy Children''s Day!', '2021-6-1');
|
||||
|
||||
SELECT b FROM test where a = 7 INTO b_tmp;
|
||||
sql_stmt := 'select a from test where b = :1;';
|
||||
OPEN cur FOR sql_stmt USING b_tmp;
|
||||
IF cur%isopen then LOOP
|
||||
FETCH cur INTO a_tmp;
|
||||
EXIT WHEN cur%notfound;
|
||||
END LOOP;
|
||||
END IF;
|
||||
CLOSE cur;
|
||||
WHILE cnt < 3 LOOP
|
||||
cnt := cnt + 1;
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO 'cnt is %', cnt;
|
||||
|
||||
RETURN;
|
||||
|
||||
END
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
create table show_code_table(lineno int, code text, canBreak bool);
|
||||
do $$
|
||||
declare
|
||||
funcoid oid;
|
||||
begin
|
||||
select oid from pg_proc into funcoid where proname = 'test_debug';
|
||||
INSERT INTO show_code_table SELECT * FROM dbe_pldebugger.info_code(funcoid);
|
||||
end;
|
||||
$$;
|
||||
select * from show_code_table;
|
||||
lineno | code | canbreak
|
||||
--------+----------------------------------------------------------------------------------+----------
|
||||
| CREATE OR REPLACE FUNCTION gms_debugger_test1.test_debug(x integer) | f
|
||||
| RETURNS SETOF test | f
|
||||
| LANGUAGE plpgsql | f
|
||||
| NOT FENCED NOT SHIPPABLE | f
|
||||
1 | AS $function$ | f
|
||||
2 | DECLARE | f
|
||||
3 | sql_stmt VARCHAR2(500); | f
|
||||
4 | r test%rowtype; | f
|
||||
5 | rec record; | f
|
||||
6 | b_tmp text; | f
|
||||
7 | cnt int; | f
|
||||
8 | a_tmp int; | f
|
||||
9 | cur refcursor; | f
|
||||
10 | n_tmp NUMERIC(24,6); | f
|
||||
11 | t_tmp tsquery; | f
|
||||
12 | CURSOR cur_arg(criterion INTEGER) IS | f
|
||||
13 | SELECT * FROM test WHERE a < criterion; | f
|
||||
14 | BEGIN | f
|
||||
15 | cnt := 0; | t
|
||||
16 | FOR r IN SELECT * FROM test | t
|
||||
17 | WHERE a > x | f
|
||||
18 | LOOP | f
|
||||
19 | RETURN NEXT r; | t
|
||||
20 | END LOOP; | f
|
||||
21 | | f
|
||||
22 | FOR rec in SELECT * FROM test | t
|
||||
23 | WHERE a < x | f
|
||||
24 | LOOP | f
|
||||
25 | RETURN NEXT rec; | t
|
||||
26 | END LOOP; | f
|
||||
27 | | f
|
||||
28 | FORALL index_1 IN 0..1 | t
|
||||
29 | INSERT INTO test VALUES (index_1, 'Happy Children''s Day!', '2021-6-1'); | t
|
||||
30 | | f
|
||||
31 | SELECT b FROM test where a = 7 INTO b_tmp; | t
|
||||
32 | sql_stmt := 'select a from test where b = :1;'; | t
|
||||
33 | OPEN cur FOR sql_stmt USING b_tmp; | t
|
||||
34 | IF cur%isopen then LOOP | t
|
||||
35 | FETCH cur INTO a_tmp; | t
|
||||
36 | EXIT WHEN cur%notfound; | t
|
||||
37 | END LOOP; | f
|
||||
38 | END IF; | f
|
||||
39 | CLOSE cur; | t
|
||||
40 | WHILE cnt < 3 LOOP | t
|
||||
41 | cnt := cnt + 1; | t
|
||||
42 | END LOOP; | f
|
||||
43 | | f
|
||||
44 | RAISE INFO 'cnt is %', cnt; | t
|
||||
45 | | f
|
||||
46 | RETURN; | t
|
||||
47 | | f
|
||||
48 | END | f
|
||||
49 | $function$; | f
|
||||
(53 rows)
|
||||
|
||||
-- attach fail (target not turned on)
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
ERROR: target session should be init first.
|
||||
-- turn off without turn on
|
||||
select * from gms_debug.debug_off();
|
||||
ERROR: target session should be init first
|
||||
select * from gms_debug.initialize();
|
||||
initialize
|
||||
-------------
|
||||
datanode1-0
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(1);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- start debug - 1st run
|
||||
select * from test_debug(4);
|
||||
INFO: cnt is 3
|
||||
a | b | c
|
||||
---+---------------------+--------------------------
|
||||
5 | Fasting | Sat Mar 02 00:00:00 2030
|
||||
7 | Treasures in Heaven | Mon Apr 02 00:00:00 2040
|
||||
2 | Giving to the Needy | Sun Feb 02 00:00:00 2020
|
||||
3 | Prayer | Thu Dec 02 00:00:00 2021
|
||||
(4 rows)
|
||||
|
||||
-- start debug - 2nd run - to be aborted
|
||||
select * from test_debug(4);
|
||||
INFO: cnt is 3
|
||||
a | b | c
|
||||
---+-----------------------+--------------------------
|
||||
5 | Fasting | Sat Mar 02 00:00:00 2030
|
||||
7 | Treasures in Heaven | Mon Apr 02 00:00:00 2040
|
||||
2 | Giving to the Needy | Sun Feb 02 00:00:00 2020
|
||||
3 | Prayer | Thu Dec 02 00:00:00 2021
|
||||
0 | Happy Children's Day! | Tue Jun 01 00:00:00 2021
|
||||
1 | Happy Children's Day! | Tue Jun 01 00:00:00 2021
|
||||
(6 rows)
|
||||
|
||||
drop schema gms_debugger_test1 cascade;
|
||||
NOTICE: drop cascades to 8 other objects
|
||||
DETAIL: drop cascades to table test
|
||||
drop cascades to function test_debug(integer)
|
||||
drop cascades to table show_code_table
|
||||
drop cascades to function gms_breakpoint(text,integer)
|
||||
drop cascades to function gms_continue()
|
||||
drop cascades to function gms_next()
|
||||
drop cascades to function gms_step()
|
||||
drop cascades to function gms_info()
|
@ -1,46 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test2 cascade;
|
||||
NOTICE: schema "gms_debugger_test2" does not exist, skipping
|
||||
create schema gms_debugger_test2;
|
||||
set search_path = gms_debugger_test2;
|
||||
-- commit/rollback in procedure
|
||||
create table tb1(a int);
|
||||
create or replace procedure test_debug2 as
|
||||
begin
|
||||
insert into tb1 values (1000);
|
||||
commit;
|
||||
insert into tb1 values (2000);
|
||||
rollback;
|
||||
end;
|
||||
/
|
||||
-- start debug
|
||||
select * from gms_debug.initialize();
|
||||
initialize
|
||||
-------------
|
||||
datanode1-0
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(1);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- start debug - 1st run
|
||||
select * from test_debug2();
|
||||
test_debug2
|
||||
-------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- start debug - 2nd run - to be aborted
|
||||
select * from test_debug2();
|
||||
ERROR: receive abort message
|
||||
CONTEXT: PL/pgSQL function test_debug2() line 2 at SQL statement
|
||||
drop schema gms_debugger_test2 cascade;
|
||||
NOTICE: drop cascades to 4 other objects
|
||||
DETAIL: drop cascades to table tb1
|
||||
drop cascades to function test_debug2()
|
||||
drop cascades to function gms_continue()
|
||||
drop cascades to function gms_next()
|
@ -1,53 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test3 cascade;
|
||||
NOTICE: schema "gms_debugger_test3" does not exist, skipping
|
||||
create schema gms_debugger_test3;
|
||||
set search_path = gms_debugger_test3;
|
||||
-- test for implicit variables
|
||||
CREATE OR REPLACE function test_debug3(a in integer) return integer
|
||||
AS
|
||||
declare
|
||||
b int;
|
||||
BEGIN
|
||||
CASE a
|
||||
WHEN 1 THEN
|
||||
b := 111;
|
||||
ELSE
|
||||
b := 999;
|
||||
END CASE;
|
||||
raise info 'pi_return : %',pi_return ;
|
||||
return b;
|
||||
EXCEPTION WHEN others THEN
|
||||
b := 101;
|
||||
return b;
|
||||
END;
|
||||
/
|
||||
select * from gms_debug.initialize();
|
||||
initialize
|
||||
-------------
|
||||
datanode1-0
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(1);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- start debug - 1st run
|
||||
select * from test_debug3(1);
|
||||
test_debug3
|
||||
-------------
|
||||
101
|
||||
(1 row)
|
||||
|
||||
-- start debug - 2nd run - to be aborted
|
||||
select * from test_debug3(1);
|
||||
ERROR: receive abort message
|
||||
CONTEXT: PL/pgSQL function test_debug3(integer) line 13 at assignment
|
||||
drop schema gms_debugger_test3 cascade;
|
||||
NOTICE: drop cascades to 3 other objects
|
||||
DETAIL: drop cascades to function test_debug3(integer)
|
||||
drop cascades to function gms_next()
|
||||
drop cascades to function gms_continue()
|
@ -1,114 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test4 cascade;
|
||||
NOTICE: schema "gms_debugger_test4" does not exist, skipping
|
||||
create schema gms_debugger_test4;
|
||||
set search_path = gms_debugger_test4;
|
||||
create table test(a int, b varchar(40), c timestamp);
|
||||
insert into test values (2, 'Giving to the Needy', '2020-02-02');
|
||||
insert into test values (3, 'Prayer', '2021-12-02');
|
||||
insert into test values (5, 'Fasting', '2030-03-02');
|
||||
insert into test values (7, 'Treasures in Heaven', '2040-04-02');
|
||||
CREATE OR REPLACE FUNCTION test_debug(x int) RETURNS SETOF test AS
|
||||
$BODY$
|
||||
DECLARE
|
||||
sql_stmt VARCHAR2(500);
|
||||
r test%rowtype;
|
||||
rec record;
|
||||
b_tmp text;
|
||||
cnt int;
|
||||
a_tmp int;
|
||||
cur refcursor;
|
||||
n_tmp NUMERIC(24,6);
|
||||
t_tmp tsquery;
|
||||
CURSOR cur_arg(criterion INTEGER) IS
|
||||
SELECT * FROM test WHERE a < criterion;
|
||||
BEGIN
|
||||
cnt := 0;
|
||||
FOR r IN SELECT * FROM test
|
||||
WHERE a > x
|
||||
LOOP
|
||||
RETURN NEXT r;
|
||||
END LOOP;
|
||||
|
||||
FOR rec in SELECT * FROM test
|
||||
WHERE a < x
|
||||
LOOP
|
||||
RETURN NEXT rec;
|
||||
END LOOP;
|
||||
|
||||
FORALL index_1 IN 0..1
|
||||
INSERT INTO test VALUES (index_1, 'Happy Children''s Day!', '2021-6-1');
|
||||
|
||||
SELECT b FROM test where a = 7 INTO b_tmp;
|
||||
sql_stmt := 'select a from test where b = :1;';
|
||||
OPEN cur FOR sql_stmt USING b_tmp;
|
||||
IF cur%isopen then LOOP
|
||||
FETCH cur INTO a_tmp;
|
||||
EXIT WHEN cur%notfound;
|
||||
END LOOP;
|
||||
END IF;
|
||||
CLOSE cur;
|
||||
WHILE cnt < 3 LOOP
|
||||
cnt := cnt + 1;
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO 'cnt is %', cnt;
|
||||
|
||||
RETURN;
|
||||
|
||||
END
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
-- test for step into
|
||||
CREATE OR REPLACE FUNCTION test_debug4(a in integer) return integer
|
||||
AS
|
||||
declare
|
||||
b int;
|
||||
BEGIN
|
||||
CASE a
|
||||
WHEN 1 THEN
|
||||
b := 111;
|
||||
call test_debug(a);
|
||||
ELSE
|
||||
b := 999;
|
||||
END CASE;
|
||||
return b;
|
||||
raise info 'pi_return : %',pi_return ;
|
||||
EXCEPTION WHEN others THEN
|
||||
b := 101;
|
||||
return b;
|
||||
END;
|
||||
/
|
||||
select * from gms_debug.initialize();
|
||||
initialize
|
||||
-------------
|
||||
datanode1-0
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(1);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select * from test_debug4(1);
|
||||
INFO: cnt is 3
|
||||
CONTEXT: SQL statement "call test_debug(a)"
|
||||
PL/pgSQL function test_debug4(integer) line 7 at SQL statement
|
||||
test_debug4
|
||||
-------------
|
||||
101
|
||||
(1 row)
|
||||
|
||||
-- test with client error in exception
|
||||
select * from test_debug4(1);
|
||||
ERROR: receive abort message
|
||||
CONTEXT: PL/pgSQL function test_debug4(integer) line 14 at assignment
|
||||
drop schema gms_debugger_test4 cascade;
|
||||
NOTICE: drop cascades to 5 other objects
|
||||
DETAIL: drop cascades to table test
|
||||
drop cascades to function test_debug(integer)
|
||||
drop cascades to function test_debug4(integer)
|
||||
drop cascades to function gms_step()
|
||||
drop cascades to function gms_continue()
|
@ -1,122 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test5 cascade;
|
||||
NOTICE: schema "gms_debugger_test5" does not exist, skipping
|
||||
create schema gms_debugger_test5;
|
||||
set search_path = gms_debugger_test5;
|
||||
create table test(a int, b varchar(40), c timestamp);
|
||||
insert into test values (2, 'Giving to the Needy', '2020-02-02');
|
||||
insert into test values (3, 'Prayer', '2021-12-02');
|
||||
insert into test values (5, 'Fasting', '2030-03-02');
|
||||
insert into test values (7, 'Treasures in Heaven', '2040-04-02');
|
||||
CREATE OR REPLACE FUNCTION test_debug(x int) RETURNS SETOF test AS
|
||||
$BODY$
|
||||
DECLARE
|
||||
sql_stmt VARCHAR2(500);
|
||||
r test%rowtype;
|
||||
rec record;
|
||||
b_tmp text;
|
||||
cnt int;
|
||||
a_tmp int;
|
||||
cur refcursor;
|
||||
n_tmp NUMERIC(24,6);
|
||||
t_tmp tsquery;
|
||||
CURSOR cur_arg(criterion INTEGER) IS
|
||||
SELECT * FROM test WHERE a < criterion;
|
||||
BEGIN
|
||||
cnt := 0;
|
||||
FOR r IN SELECT * FROM test
|
||||
WHERE a > x
|
||||
LOOP
|
||||
RETURN NEXT r;
|
||||
END LOOP;
|
||||
|
||||
FOR rec in SELECT * FROM test
|
||||
WHERE a < x
|
||||
LOOP
|
||||
RETURN NEXT rec;
|
||||
END LOOP;
|
||||
|
||||
FORALL index_1 IN 0..1
|
||||
INSERT INTO test VALUES (index_1, 'Happy Children''s Day!', '2021-6-1');
|
||||
|
||||
SELECT b FROM test where a = 7 INTO b_tmp;
|
||||
sql_stmt := 'select a from test where b = :1;';
|
||||
OPEN cur FOR sql_stmt USING b_tmp;
|
||||
IF cur%isopen then LOOP
|
||||
FETCH cur INTO a_tmp;
|
||||
EXIT WHEN cur%notfound;
|
||||
END LOOP;
|
||||
END IF;
|
||||
CLOSE cur;
|
||||
WHILE cnt < 3 LOOP
|
||||
cnt := cnt + 1;
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO 'cnt is %', cnt;
|
||||
|
||||
RETURN;
|
||||
|
||||
END
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
-- test for step into
|
||||
CREATE OR REPLACE FUNCTION test_debug4(a in integer) return integer
|
||||
AS
|
||||
declare
|
||||
b int;
|
||||
BEGIN
|
||||
CASE a
|
||||
WHEN 1 THEN
|
||||
b := 111;
|
||||
call test_debug(a);
|
||||
ELSE
|
||||
b := 999;
|
||||
END CASE;
|
||||
return b;
|
||||
raise info 'pi_return : %',pi_return ;
|
||||
EXCEPTION WHEN others THEN
|
||||
b := 101;
|
||||
return b;
|
||||
END;
|
||||
/
|
||||
select * from gms_debug.initialize();
|
||||
initialize
|
||||
-------------
|
||||
datanode1-0
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(1);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select * from test_debug4(1);
|
||||
INFO: cnt is 3
|
||||
CONTEXT: SQL statement "call test_debug(a)"
|
||||
PL/pgSQL function test_debug4(integer) line 7 at SQL statement
|
||||
test_debug4
|
||||
-------------
|
||||
101
|
||||
(1 row)
|
||||
|
||||
-- test with client error in exception
|
||||
select * from test_debug4(1);
|
||||
INFO: cnt is 3
|
||||
CONTEXT: SQL statement "call test_debug(a)"
|
||||
PL/pgSQL function test_debug4(integer) line 7 at SQL statement
|
||||
test_debug4
|
||||
-------------
|
||||
101
|
||||
(1 row)
|
||||
|
||||
drop schema gms_debugger_test5 cascade;
|
||||
NOTICE: drop cascades to 7 other objects
|
||||
DETAIL: drop cascades to table test
|
||||
drop cascades to function test_debug(integer)
|
||||
drop cascades to function test_debug4(integer)
|
||||
drop cascades to function gms_continue()
|
||||
drop cascades to function gms_step()
|
||||
drop cascades to function gms_next()
|
||||
drop cascades to function gms_finish()
|
@ -1,114 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test6 cascade;
|
||||
NOTICE: schema "gms_debugger_test6" does not exist, skipping
|
||||
create schema gms_debugger_test6;
|
||||
set search_path = gms_debugger_test6;
|
||||
create table test(a int, b varchar(40), c timestamp);
|
||||
insert into test values (2, 'Giving to the Needy', '2020-02-02');
|
||||
insert into test values (3, 'Prayer', '2021-12-02');
|
||||
insert into test values (5, 'Fasting', '2030-03-02');
|
||||
insert into test values (7, 'Treasures in Heaven', '2040-04-02');
|
||||
CREATE OR REPLACE FUNCTION test_debug(x int) RETURNS SETOF test AS
|
||||
$BODY$
|
||||
DECLARE
|
||||
sql_stmt VARCHAR2(500);
|
||||
r test%rowtype;
|
||||
rec record;
|
||||
b_tmp text;
|
||||
cnt int;
|
||||
a_tmp int;
|
||||
cur refcursor;
|
||||
n_tmp NUMERIC(24,6);
|
||||
t_tmp tsquery;
|
||||
CURSOR cur_arg(criterion INTEGER) IS
|
||||
SELECT * FROM test WHERE a < criterion;
|
||||
BEGIN
|
||||
cnt := 0;
|
||||
FOR r IN SELECT * FROM test
|
||||
WHERE a > x
|
||||
LOOP
|
||||
RETURN NEXT r;
|
||||
END LOOP;
|
||||
|
||||
FOR rec in SELECT * FROM test
|
||||
WHERE a < x
|
||||
LOOP
|
||||
RETURN NEXT rec;
|
||||
END LOOP;
|
||||
|
||||
FORALL index_1 IN 0..1
|
||||
INSERT INTO test VALUES (index_1, 'Happy Children''s Day!', '2021-6-1');
|
||||
|
||||
SELECT b FROM test where a = 7 INTO b_tmp;
|
||||
sql_stmt := 'select a from test where b = :1;';
|
||||
OPEN cur FOR sql_stmt USING b_tmp;
|
||||
IF cur%isopen then LOOP
|
||||
FETCH cur INTO a_tmp;
|
||||
EXIT WHEN cur%notfound;
|
||||
END LOOP;
|
||||
END IF;
|
||||
CLOSE cur;
|
||||
WHILE cnt < 3 LOOP
|
||||
cnt := cnt + 1;
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO 'cnt is %', cnt;
|
||||
|
||||
RETURN;
|
||||
|
||||
END
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
-- test for step into
|
||||
CREATE OR REPLACE FUNCTION test_debug4(a in integer) return integer
|
||||
AS
|
||||
declare
|
||||
b int;
|
||||
BEGIN
|
||||
CASE a
|
||||
WHEN 1 THEN
|
||||
b := 111;
|
||||
call test_debug(a);
|
||||
ELSE
|
||||
b := 999;
|
||||
END CASE;
|
||||
return b;
|
||||
raise info 'pi_return : %',pi_return ;
|
||||
EXCEPTION WHEN others THEN
|
||||
b := 101;
|
||||
return b;
|
||||
END;
|
||||
/
|
||||
select * from gms_debug.initialize();
|
||||
initialize
|
||||
-------------
|
||||
datanode1-0
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(1);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
select * from test_debug4(1);
|
||||
INFO: cnt is 3
|
||||
CONTEXT: SQL statement "call test_debug(a)"
|
||||
PL/pgSQL function test_debug4(integer) line 7 at SQL statement
|
||||
test_debug4
|
||||
-------------
|
||||
101
|
||||
(1 row)
|
||||
|
||||
-- test with client error in exception
|
||||
select * from test_debug4(1);
|
||||
ERROR: Debug Comm 0 has been released or not turned on yet.
|
||||
drop schema gms_debugger_test6 cascade;
|
||||
NOTICE: drop cascades to 6 other objects
|
||||
DETAIL: drop cascades to table test
|
||||
drop cascades to function test_debug(integer)
|
||||
drop cascades to function test_debug4(integer)
|
||||
drop cascades to function gms_continue()
|
||||
drop cascades to function gms_breakpoint(text,integer)
|
||||
drop cascades to function gms_finish()
|
@ -1,387 +0,0 @@
|
||||
/* contrib/gms_debug/gms_debug--1.0.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION gms_debug" to load this file. \quit
|
||||
|
||||
-- gms_debug package begin
|
||||
set behavior_compat_options='proc_outparam_override';
|
||||
CREATE SCHEMA gms_debug;
|
||||
GRANT USAGE ON SCHEMA gms_debug TO PUBLIC;
|
||||
|
||||
CREATE TYPE gms_debug.program_info AS (
|
||||
namespace oid,
|
||||
name varchar2(30),
|
||||
owner varchar2(30),
|
||||
dblink varchar2(30),
|
||||
line# binary_integer,
|
||||
libunittype binary_integer,
|
||||
entrypointname varchar2(30));
|
||||
|
||||
CREATE TYPE gms_debug.runtime_info AS (
|
||||
line# binary_integer,
|
||||
terminated binary_integer,
|
||||
breakpoint binary_integer,
|
||||
stackdepth binary_integer,
|
||||
interpreterdepth binary_integer,
|
||||
reason binary_integer,
|
||||
program gms_debug.program_info);
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.initialize(
|
||||
IN debug_session_id varchar2(30) DEFAULT '' ,
|
||||
IN diagnostics binary_integer DEFAULT 0)
|
||||
returns varchar2
|
||||
AS 'MODULE_PATHNAME', 'gms_debug_initialize'
|
||||
LANGUAGE C VOLATILE NOT FENCED;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.debug_on(
|
||||
IN no_client_side_plsql_engine BOOLEAN DEFAULT TRUE ,
|
||||
IN immediate BOOLEAN DEFAULT FALSE)
|
||||
returns void AS $$
|
||||
BEGIN
|
||||
return;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.attach_session(
|
||||
IN debug_session_id varchar2(30) ,
|
||||
IN diagnostics binary_integer DEFAULT 0)
|
||||
returns void
|
||||
AS 'MODULE_PATHNAME', 'gms_debug_attach_session'
|
||||
LANGUAGE C VOLATILE NOT FENCED;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.add_breakpoint(
|
||||
IN proid oid,
|
||||
IN line# binary_integer ,
|
||||
OUT breakpoint# binary_integer,
|
||||
IN fuzzy binary_integer,
|
||||
IN iterations binary_integer,
|
||||
OUT sts binary_integer)
|
||||
AS 'MODULE_PATHNAME', 'gms_debug_set_breakpoint'
|
||||
LANGUAGE C VOLATILE NOT FENCED;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.set_breakpoint(
|
||||
IN program gms_debug.program_info,
|
||||
IN line# binary_integer,
|
||||
OUT breakpoint# binary_integer,
|
||||
IN fuzzy binary_integer,
|
||||
IN iterations binary_integer)
|
||||
returns binary_integer AS $$
|
||||
DECLARE
|
||||
proid oid;
|
||||
sts binary_integer;
|
||||
BEGIN
|
||||
select oid from pg_proc where proname = program.name limit 1 into proid;
|
||||
set behavior_compat_options='';
|
||||
gms_debug.add_breakpoint(proid, line#, breakpoint#, fuzzy, iterations, sts);
|
||||
set behavior_compat_options='proc_outparam_override';
|
||||
return sts;
|
||||
END;
|
||||
$$ language plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.call_continue(
|
||||
IN breakflags binary_integer ,
|
||||
IN info_requested binary_integer DEFAULT NULL,
|
||||
OUT err_code binary_integer,
|
||||
OUT run_line binary_integer,
|
||||
OUT run_breakpoint binary_integer,
|
||||
OUT run_stackdepth binary_integer,
|
||||
OUT run_reason binary_integer,
|
||||
OUT pro_namespace oid,
|
||||
OUT pro_name varchar2(30),
|
||||
OUT pro_owner oid)
|
||||
AS 'MODULE_PATHNAME', 'gms_debug_continue'
|
||||
LANGUAGE C VOLATILE NOT FENCED;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.continue(
|
||||
OUT run_info gms_debug.runtime_info ,
|
||||
IN breakflags binary_integer ,
|
||||
IN info_requested binary_integer DEFAULT NULL)
|
||||
returns binary_integer AS $$
|
||||
DECLARE
|
||||
err_code binary_integer;
|
||||
run_line binary_integer;
|
||||
run_terminated binary_integer;
|
||||
run_breakpoint binary_integer;
|
||||
run_stackdepth binary_integer;
|
||||
run_interpreterdepth binary_integer;
|
||||
run_reason binary_integer;
|
||||
pro_namespace oid;
|
||||
pro_name varchar2(30);
|
||||
pro_owner oid;
|
||||
pro_ownername varchar2(30);
|
||||
pro gms_debug.program_info;
|
||||
BEGIN
|
||||
set behavior_compat_options='';
|
||||
gms_debug.call_continue(breakflags, info_requested, err_code, run_line,
|
||||
run_breakpoint, run_stackdepth, run_reason, pro_namespace,
|
||||
pro_name, pro_owner);
|
||||
set behavior_compat_options='proc_outparam_override';
|
||||
select usename from pg_user where usesysid = pro_owner into pro_ownername;
|
||||
run_info.line# = run_line;
|
||||
run_info.terminated = 0;
|
||||
run_info.breakpoint = run_breakpoint;
|
||||
run_info.stackdepth = run_stackdepth;
|
||||
run_info.interpreterdepth = -1;
|
||||
run_info.reason = run_reason;
|
||||
pro.namespace = pro_namespace;
|
||||
pro.name = pro_name;
|
||||
pro.owner = pro_ownername;
|
||||
pro.dblink = '';
|
||||
pro.line# = run_line;
|
||||
pro.libunittype = 0;
|
||||
pro.entrypointname = '';
|
||||
run_info.program = pro;
|
||||
return err_code;
|
||||
END;
|
||||
$$ language plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.get_debug_runtime_info(
|
||||
IN info_requested binary_integer,
|
||||
OUT err_code binary_integer,
|
||||
OUT run_line binary_integer,
|
||||
OUT run_breakpoint binary_integer,
|
||||
OUT run_stackdepth binary_integer,
|
||||
OUT run_reason binary_integer,
|
||||
OUT pro_namespace oid,
|
||||
OUT pro_name varchar2(30),
|
||||
OUT pro_owner oid)
|
||||
AS 'MODULE_PATHNAME', 'gms_debug_get_runtime_info'
|
||||
LANGUAGE C VOLATILE NOT FENCED;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.get_runtime_info(
|
||||
IN info_requested binary_integer,
|
||||
OUT run_info gms_debug.runtime_info)
|
||||
returns binary_integer AS $$
|
||||
DECLARE
|
||||
err_code binary_integer;
|
||||
run_line binary_integer;
|
||||
run_terminated binary_integer;
|
||||
run_breakpoint binary_integer;
|
||||
run_stackdepth binary_integer;
|
||||
run_interpreterdepth binary_integer;
|
||||
run_reason binary_integer;
|
||||
pro_namespace oid;
|
||||
pro_name varchar2(30);
|
||||
pro_owner oid;
|
||||
pro_ownername varchar2(30);
|
||||
pro gms_debug.program_info;
|
||||
BEGIN
|
||||
set behavior_compat_options='';
|
||||
gms_debug.get_debug_runtime_info(info_requested, err_code, run_line,
|
||||
run_breakpoint, run_stackdepth, run_reason, pro_namespace,
|
||||
pro_name, pro_owner);
|
||||
set behavior_compat_options='proc_outparam_override';
|
||||
select usename from pg_user where usesysid = pro_owner into pro_ownername;
|
||||
run_info.line# = run_line;
|
||||
run_info.terminated = 0;
|
||||
run_info.breakpoint = run_breakpoint;
|
||||
run_info.stackdepth = run_stackdepth;
|
||||
run_info.interpreterdepth = -1;
|
||||
run_info.reason = run_reason;
|
||||
pro.namespace = pro_namespace;
|
||||
pro.name = pro_name;
|
||||
pro.owner = pro_ownername;
|
||||
pro.dblink = '';
|
||||
pro.line# = run_line;
|
||||
pro.libunittype = 0;
|
||||
pro.entrypointname = '';
|
||||
run_info.program = pro;
|
||||
return err_code;
|
||||
END;
|
||||
$$ language plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.debug_off()
|
||||
returns void
|
||||
AS 'MODULE_PATHNAME', 'gms_debug_off'
|
||||
LANGUAGE C VOLATILE NOT FENCED;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_debug.detach_session()
|
||||
returns void
|
||||
AS 'MODULE_PATHNAME', 'gms_debug_detach_session'
|
||||
LANGUAGE C VOLATILE NOT FENCED;
|
||||
|
||||
CREATE or REPLACE PROCEDURE gms_debug.probe_version(OUT major binary_integer, OUT minor binary_integer)
|
||||
AS
|
||||
BEGIN
|
||||
major := 1;
|
||||
minor := 0;
|
||||
END;
|
||||
|
||||
CREATE FUNCTION gms_debug.success() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 0;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.error_illegal_line() RETURNS int AS $$
|
||||
BEGIN
|
||||
return -1;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.error_bad_handle() RETURNS int AS $$
|
||||
BEGIN
|
||||
return -2;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.error_already_exists() RETURNS int AS $$
|
||||
BEGIN
|
||||
return -3;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.error_communication() RETURNS int AS $$
|
||||
BEGIN
|
||||
return -4;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.info_getstackdepth() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 0;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.info_getbreakpoint() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 2;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.info_getlineinfo() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 4;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.break_next_line() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 2;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.break_any_call() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 4;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.break_any_return() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 8;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.break_return() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 16;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.break_exception() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 32;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.break_handler() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 64;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.abort_execution() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 128;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_none() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 0;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_breakpoint() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 1;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_enter() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 2;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_return() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 3;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_finish() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 4;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_line() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 5;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_interrupt() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 6;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_exception() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 7;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_exit() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 8;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_knl_exit() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 9;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_handler() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 10;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_timeout() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 11;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_instantiate() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 12;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gms_debug.reason_abort() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 13;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
||||
|
||||
|
||||
|
||||
-- gms_debug package end
|
@ -1,5 +0,0 @@
|
||||
# gms_debug extension
|
||||
comment = 'provides the interface to initiate and control the debugging of PL/SQL applications'
|
||||
default_version = '1.0'
|
||||
module_pathname = '$libdir/gms_debug'
|
||||
relocatable = true
|
@ -1,519 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Technologies Co.,Ltd.
|
||||
*
|
||||
* openGauss is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
* --------------------------------------------------------------------------------------
|
||||
*
|
||||
* gms_debug.cpp
|
||||
* gms_debug can effectively estimate statistical data.
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/gms_debug/gms_debug.cpp
|
||||
*
|
||||
* --------------------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "utils/plpgsql_domain.h"
|
||||
#include "commands/copy.h"
|
||||
#include "funcapi.h"
|
||||
#include "utils/plpgsql.h"
|
||||
#include <sys/socket.h>
|
||||
#include "utils/pl_debug.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "catalog/pg_authid.h"
|
||||
#include "miscadmin.h"
|
||||
#include "gms_debug.h"
|
||||
|
||||
#include <bitset>
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
PG_FUNCTION_INFO_V1(gms_debug_attach_session);
|
||||
PG_FUNCTION_INFO_V1(gms_debug_detach_session);
|
||||
PG_FUNCTION_INFO_V1(gms_debug_get_runtime_info);
|
||||
PG_FUNCTION_INFO_V1(gms_debug_initialize);
|
||||
PG_FUNCTION_INFO_V1(gms_debug_off);
|
||||
PG_FUNCTION_INFO_V1(gms_debug_continue);
|
||||
PG_FUNCTION_INFO_V1(gms_debug_set_breakpoint);
|
||||
|
||||
|
||||
static void gms_attach_session(int commidx, uint64 sid)
|
||||
{
|
||||
PlDebuggerComm* debug_comm = &g_instance.pldebug_cxt.debug_comm[commidx];
|
||||
AutoMutexLock debuglock(&debug_comm->mutex);
|
||||
debuglock.lock();
|
||||
if (debug_comm->Used()) {
|
||||
if (debug_comm->hasClient()) {
|
||||
debuglock.unLock();
|
||||
ereport(ERROR, (errmodule(MOD_PLDEBUGGER), errcode(ERRCODE_TARGET_SERVER_ALREADY_ATTACHED),
|
||||
(errmsg("target session already attached on other client."))));
|
||||
}
|
||||
if (debug_comm->hasClientErrorOccured || debug_comm->hasServerErrorOccured) {
|
||||
debuglock.unLock();
|
||||
ereport(ERROR, (errmodule(MOD_PLDEBUGGER), errcode(ERRCODE_INVALID_OPERATION),
|
||||
(errmsg("target function is not running in expected way."))));
|
||||
}
|
||||
debug_comm->clientId = sid;
|
||||
} else {
|
||||
debuglock.unLock();
|
||||
ereport(ERROR, (errmodule(MOD_PLDEBUGGER), errcode(ERRCODE_INVALID_OPERATION),
|
||||
(errmsg("target session should be init first."))));
|
||||
}
|
||||
debuglock.unLock();
|
||||
}
|
||||
|
||||
static bool GMSInterfaceCheck(const char* funcname, bool needAttach)
|
||||
{
|
||||
#ifdef ENABLE_MULTIPLE_NODES
|
||||
PLDEBUG_FEATURE_NOT_SUPPORT_IN_DISTRIBUTED();
|
||||
#endif
|
||||
if (!superuser() && !is_member_of_role(GetUserId(), DEFAULT_ROLE_PLDEBUGGER)) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("must be system admin to execute", funcname))));
|
||||
return false;
|
||||
}
|
||||
if (u_sess->plsql_cxt.debug_client != NULL && needAttach){
|
||||
int commIdx = u_sess->plsql_cxt.debug_client->comm_idx;
|
||||
CHECK_DEBUG_COMM_VALID(commIdx);
|
||||
/* if current debug index is not myself during debug, clean up my self */
|
||||
PlDebuggerComm* debug_comm = &g_instance.pldebug_cxt.debug_comm[commIdx];
|
||||
DebugClientInfo* client = u_sess->plsql_cxt.debug_client;
|
||||
AutoMutexLock debuglock(&debug_comm->mutex);
|
||||
debuglock.lock();
|
||||
if (debug_comm == nullptr) {
|
||||
client->comm_idx = -1;
|
||||
MemoryContextDelete(client->context);
|
||||
u_sess->plsql_cxt.debug_client = NULL;
|
||||
debuglock.unLock();
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED),
|
||||
errmsg("must attach a execute func before execute", funcname),
|
||||
errhint("attach a execute func and retry")));
|
||||
return false;
|
||||
}
|
||||
if (!debug_comm->isRunning()) {
|
||||
debuglock.unLock();
|
||||
return false;
|
||||
}
|
||||
debuglock.unLock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function initializes the target session for debugging.
|
||||
*/
|
||||
Datum gms_debug_initialize(PG_FUNCTION_ARGS)
|
||||
{
|
||||
StringInfoData buf;
|
||||
bool found = false;
|
||||
// TupleDesc tupdesc;
|
||||
int commIdx = -1;
|
||||
const int DEBUG_TURN_ON_ATTR_NUM = 1;
|
||||
GMSInterfaceCheck("gms_debug.initialize", false);
|
||||
if (unlikely(u_sess->plsql_cxt.debug_proc_htbl == NULL)) {
|
||||
init_pldebug_htcl();
|
||||
}
|
||||
/* return nodename & socket idx as port */
|
||||
if (!PG_ARGISNULL(0)) {
|
||||
// check if the debug_session_id valid
|
||||
char *debug_session_id = text_to_cstring(PG_GETARG_VARCHAR_PP(0));
|
||||
char *psave = NULL;
|
||||
char *nodename = strtok_r(debug_session_id, "-", &psave);
|
||||
char *fir = AssignStr(psave, false);
|
||||
char *new_fir = TrimStr(fir);
|
||||
if (new_fir == NULL) {
|
||||
ereport(ERROR, ( (errmsg("invalid debug_session_id %s", debug_session_id))));
|
||||
}
|
||||
commIdx = pg_strtoint32(new_fir);
|
||||
if (commIdx < 0 || commIdx >= PG_MAX_DEBUG_CONN) {
|
||||
ereport(ERROR, ( (errmsg("invalid debug_session_id %s", debug_session_id))));
|
||||
}
|
||||
if (!AcquireDebugCommIdx(commIdx)) {
|
||||
ereport(ERROR,
|
||||
( errmsg("debug_session_id %s has already been used", debug_session_id)));
|
||||
}
|
||||
} else {
|
||||
commIdx = GetValidDebugCommIdx();
|
||||
if (commIdx == -1) {
|
||||
ereport(ERROR, (
|
||||
(errmsg("max debug function is %d, turn_on function is out of range", PG_MAX_DEBUG_CONN))));
|
||||
}
|
||||
}
|
||||
|
||||
SetDebugCommGmsUsed(commIdx, true);
|
||||
// dms_debug indicates that session debugging functionality should be enabled.
|
||||
u_sess->plsql_cxt.gms_debug_idx = commIdx;
|
||||
initStringInfo(&buf);
|
||||
// simple concatenate node_name and port with an underscore
|
||||
appendStringInfo(&buf, "%s-%d", g_instance.attr.attr_common.PGXCNodeName, commIdx);
|
||||
PG_RETURN_VARCHAR_P(cstring_to_text(buf.data));
|
||||
}
|
||||
|
||||
/*
|
||||
* This procedure notifies the debug session about the target program.
|
||||
*/
|
||||
Datum gms_debug_attach_session(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GMSInterfaceCheck("gms_debug.attach_session", false);
|
||||
char *debug_session_id = text_to_cstring(PG_GETARG_VARCHAR_PP(0));
|
||||
int32 diagnostics = PG_GETARG_INT32(1);
|
||||
char *psave = NULL;
|
||||
int commidx = -1;
|
||||
char *nodename = strtok_r(debug_session_id, "-", &psave);
|
||||
char *fir = AssignStr(psave, false);
|
||||
char *new_fir = TrimStr(fir);
|
||||
if (new_fir == NULL) {
|
||||
ereport(ERROR, ( (errmsg("invalid debug_session_id %s", debug_session_id))));
|
||||
}
|
||||
commidx = pg_strtoint32(new_fir);
|
||||
|
||||
/* if is attach to some other function, just clean up it */
|
||||
clean_up_debug_client(true);
|
||||
/* this nodename check is only for single node */
|
||||
nodename = TrimStr(nodename);
|
||||
if (nodename == NULL || strcasecmp(nodename, g_instance.attr.attr_common.PGXCNodeName) != 0) {
|
||||
ereport(ERROR, ( errcode(ERRCODE_AMBIGUOUS_PARAMETER),
|
||||
(errmsg("wrong debug nodename, should be %s.", g_instance.attr.attr_common.PGXCNodeName))));
|
||||
}
|
||||
if (commidx < 0 || commidx >= PG_MAX_DEBUG_CONN) {
|
||||
ereport(ERROR, ( errcode(ERRCODE_AMBIGUOUS_PARAMETER),
|
||||
(errmsg("invalid debug port id %d.", commidx))));
|
||||
}
|
||||
/* only can attach when comm satisfy contidion */
|
||||
gms_attach_session(commidx, u_sess->session_id);
|
||||
u_sess->plsql_cxt.debug_client = InitDebugClient(commidx);
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function sets a breakpoint in a program unit, which persists for the current session.
|
||||
*/
|
||||
Datum gms_debug_set_breakpoint(PG_FUNCTION_ARGS)
|
||||
{
|
||||
const int DEBUG_BREAK_TUPLE_ATTR_NUM = 2;
|
||||
Oid funcOid = PG_GETARG_OID(0);
|
||||
int32 lineno = PG_GETARG_INT32(1);
|
||||
int32 fuzzy = PG_GETARG_INT32(2);
|
||||
int32 iterations = PG_GETARG_INT32(3);
|
||||
int headerlines = 0;
|
||||
uint32 nLine = 0;
|
||||
CodeLine *lines = NULL;
|
||||
CodeLine cl;
|
||||
cl.code = NULL;
|
||||
bool found = false;
|
||||
DebugClientInfo *client = u_sess->plsql_cxt.debug_client;
|
||||
StringInfoData str;
|
||||
|
||||
if(client == nullptr) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED),
|
||||
errmsg("error happened in debug session, please reattach target session and try")));
|
||||
}
|
||||
|
||||
TupleDesc tupdesc;
|
||||
MemoryContext oldcontext = MemoryContextSwitchTo(client->context);
|
||||
|
||||
tupdesc = CreateTemplateTupleDesc(DEBUG_BREAK_TUPLE_ATTR_NUM, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)1, "status", INT4OID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)2, "breakpoint", INT4OID, -1, 0);
|
||||
TupleDesc tuple_desc = BlessTupleDesc(tupdesc);
|
||||
|
||||
Datum values[DEBUG_BREAK_TUPLE_ATTR_NUM];
|
||||
bool nulls[DEBUG_BREAK_TUPLE_ATTR_NUM];
|
||||
HeapTuple tuple;
|
||||
errno_t rc = 0;
|
||||
|
||||
rc = memset_s(values, sizeof(values), 0, sizeof(values));
|
||||
securec_check(rc, "\0", "\0");
|
||||
rc = memset_s(nulls, sizeof(nulls), 0, sizeof(nulls));
|
||||
securec_check(rc, "\0", "\0");
|
||||
|
||||
(void)MemoryContextSwitchTo(oldcontext);
|
||||
|
||||
values[0] = Int32GetDatum(0);
|
||||
values[1] = Int32GetDatum(-1);
|
||||
if (OidIsValid(funcOid)) {
|
||||
bool checked = GMSInterfaceCheck("gms_debug.add_breakpoint", true);
|
||||
if(!checked) {
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED),
|
||||
errmsg("target func not attached")));
|
||||
values[0] = Int32GetDatum(ERROR_BAD_HANDLE);
|
||||
tuple = heap_form_tuple(tuple_desc, values, nulls);
|
||||
PG_RETURN_DATUM(HeapTupleGetDatum(tuple));
|
||||
}
|
||||
} else {
|
||||
ereport(WARNING, (errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("pl debugger only support function with language plpgsql"),
|
||||
errdetail("the given function is %lu", funcOid),
|
||||
errcause("pl debugger do not support the given function"),
|
||||
erraction("use pl debugger with only plpgsql function")));
|
||||
values[0] = Int32GetDatum(ERROR_BAD_HANDLE);
|
||||
tuple = heap_form_tuple(tuple_desc, values, nulls);
|
||||
PG_RETURN_DATUM(HeapTupleGetDatum(tuple));
|
||||
}
|
||||
|
||||
if (unlikely(u_sess->plsql_cxt.debug_proc_htbl == NULL)) {
|
||||
init_pldebug_htcl();
|
||||
}
|
||||
|
||||
PlDebugEntry *entry =
|
||||
(PlDebugEntry *)hash_search(u_sess->plsql_cxt.debug_proc_htbl, (void *)(&funcOid), HASH_ENTER, &found);
|
||||
entry->key = funcOid;
|
||||
if (!found) {
|
||||
entry->commIdx = client->comm_idx;
|
||||
entry->func = NULL;
|
||||
}
|
||||
initStringInfo(&str);
|
||||
uint64 sid = ENABLE_THREAD_POOL ? u_sess->session_id : t_thrd.proc_cxt.MyProcPid;
|
||||
appendStringInfo(&str, "%lu:%u:%d:%s", sid, funcOid, lineno, cl.code == NULL ? "NULL" : cl.code);
|
||||
debug_client_send_msg(client, GMS_DEBUG_ADDBREAKPOINT_HEADER, str.data, str.len);
|
||||
debug_client_rec_msg(client);
|
||||
int32 ans = pg_strtoint32(client->rec_buffer);
|
||||
pfree_ext(lines);
|
||||
pfree_ext(str.data);
|
||||
|
||||
if (ans == ADD_BP_ERR_ALREADY_EXISTS) {
|
||||
ereport(WARNING, (errcode(ERRCODE_WARNING),
|
||||
errmsg("the given line number already contains a valid breakpoint.")));
|
||||
values[0] = Int32GetDatum(ERROR_ALREADY_EXISTS);
|
||||
tuple = heap_form_tuple(tuple_desc, values, nulls);
|
||||
PG_RETURN_DATUM(HeapTupleGetDatum(tuple));
|
||||
} else if (ans == ADD_BP_ERR_OUT_OF_RANGE) {
|
||||
ereport(WARNING, (errcode(ERRCODE_WARNING),
|
||||
errmsg("lineno must be within the range of [1, MaxLineNumber]." )));
|
||||
values[0] = Int32GetDatum(ERROR_ILLEGAL_LINE);
|
||||
tuple = heap_form_tuple(tuple_desc, values, nulls);
|
||||
PG_RETURN_DATUM(HeapTupleGetDatum(tuple));
|
||||
} else if (ans == ADD_BP_ERR_INVALID_BP_POS) {
|
||||
ereport(WARNING, (errcode(ERRCODE_WARNING),
|
||||
errmsg("the given line number does not name a valid breakpoint.")));
|
||||
values[0] = Int32GetDatum(ERROR_ILLEGAL_LINE);
|
||||
tuple = heap_form_tuple(tuple_desc, values, nulls);
|
||||
PG_RETURN_DATUM(HeapTupleGetDatum(tuple));
|
||||
}
|
||||
values[0] = Int32GetDatum(0);
|
||||
values[1] = Int32GetDatum(ans);
|
||||
tuple = heap_form_tuple(tuple_desc, values, nulls);
|
||||
PG_RETURN_DATUM(HeapTupleGetDatum(tuple));
|
||||
}
|
||||
|
||||
static char* parse_and_valid(char **psave, const char* rec_buf)
|
||||
{
|
||||
char *fir = strtok_r(NULL, ":", psave);
|
||||
char *new_fir = TrimStr(fir);
|
||||
if (new_fir == NULL) {
|
||||
ReportInvalidMsg(rec_buf);
|
||||
return NULL;
|
||||
}
|
||||
return new_fir;
|
||||
}
|
||||
|
||||
static Datum build_runtime_info(DebugClientInfo *client, int err_code)
|
||||
{
|
||||
const int DEBUG_RUNTIME_TUPLE_ATTR_NUM = 8;
|
||||
int i = 0;
|
||||
TupleDesc tupdesc;
|
||||
MemoryContext oldcontext = MemoryContextSwitchTo(client->context);
|
||||
|
||||
tupdesc = CreateTemplateTupleDesc(DEBUG_RUNTIME_TUPLE_ATTR_NUM, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "err_code", INT4OID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "run_line", INT4OID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "run_breakpoint", INT4OID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "run_stackdepth", INT4OID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "run_reason", INT4OID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "pro_namespace", OIDOID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "pro_name", TEXTOID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "pro_owner", OIDOID, -1, 0);
|
||||
TupleDesc tuple_desc = BlessTupleDesc(tupdesc);
|
||||
|
||||
/* Received buffer will be in the form of <namespaceoid, owneroid, lineno, breakpoint, stackdepth, reason,
|
||||
* pkgfuncname> */
|
||||
char *psave = NULL;
|
||||
char *fir = strtok_r(client->rec_buffer, ":", &psave);
|
||||
const int int64Size = 10;
|
||||
Oid namespaceoid;
|
||||
Oid funcoid;
|
||||
Oid owneroid;
|
||||
int run_line = -1;
|
||||
int run_breakpoint = -1;
|
||||
int run_stackdepth = -1;
|
||||
int run_reason = 0;
|
||||
char *pro_name = NULL;
|
||||
Datum values[DEBUG_RUNTIME_TUPLE_ATTR_NUM];
|
||||
bool nulls[DEBUG_RUNTIME_TUPLE_ATTR_NUM];
|
||||
HeapTuple tuple;
|
||||
errno_t rc = 0;
|
||||
|
||||
if(err_code == 0) {
|
||||
char *new_fir = TrimStr(fir);
|
||||
if (new_fir == NULL) {
|
||||
ReportInvalidMsg(client->rec_buffer);
|
||||
PG_RETURN_DATUM(0);
|
||||
}
|
||||
funcoid = (Oid)pg_strtouint64(new_fir, NULL, int64Size);
|
||||
new_fir = parse_and_valid(&psave, client->rec_buffer);
|
||||
CHECK_RETURN_DATUM(new_fir);
|
||||
namespaceoid = (Oid)pg_strtouint64(new_fir, NULL, int64Size);
|
||||
new_fir = parse_and_valid(&psave, client->rec_buffer);
|
||||
CHECK_RETURN_DATUM(new_fir);
|
||||
owneroid = (Oid)pg_strtouint64(new_fir, NULL, int64Size);
|
||||
new_fir = parse_and_valid(&psave, client->rec_buffer);
|
||||
CHECK_RETURN_DATUM(new_fir);
|
||||
run_line = pg_strtoint32(new_fir);
|
||||
new_fir = parse_and_valid(&psave, client->rec_buffer);
|
||||
CHECK_RETURN_DATUM(new_fir);
|
||||
run_breakpoint = pg_strtoint32(new_fir);
|
||||
new_fir = parse_and_valid(&psave, client->rec_buffer);
|
||||
CHECK_RETURN_DATUM(new_fir);
|
||||
run_stackdepth = pg_strtoint32(new_fir);
|
||||
new_fir = parse_and_valid(&psave, client->rec_buffer);
|
||||
CHECK_RETURN_DATUM(new_fir);
|
||||
run_reason = pg_strtoint32(new_fir);
|
||||
pro_name = AssignStr(psave, false);
|
||||
}
|
||||
|
||||
(void)MemoryContextSwitchTo(oldcontext);
|
||||
|
||||
rc = memset_s(values, sizeof(values), 0, sizeof(values));
|
||||
securec_check(rc, "\0", "\0");
|
||||
rc = memset_s(nulls, sizeof(nulls), 0, sizeof(nulls));
|
||||
securec_check(rc, "\0", "\0");
|
||||
|
||||
i = 0;
|
||||
values[i++] = Int32GetDatum(err_code);
|
||||
values[i++] = Int32GetDatum(run_line);
|
||||
values[i++] = Int32GetDatum(run_breakpoint);
|
||||
values[i++] = Int32GetDatum(run_stackdepth);
|
||||
values[i++] = Int32GetDatum(run_reason);
|
||||
values[i++] = ObjectIdGetDatum(namespaceoid);
|
||||
values[i++] = CStringGetTextDatum(pro_name);
|
||||
values[i++] = ObjectIdGetDatum(owneroid);
|
||||
tuple = heap_form_tuple(tuple_desc, values, nulls);
|
||||
PG_RETURN_DATUM(HeapTupleGetDatum(tuple));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function passes the given breakflags
|
||||
* (a mask of the events that are of interest) to Probe in the target process.
|
||||
* It tells Probe to continue execution of the target process,
|
||||
* and it waits until the target process runs to completion or signals an event.
|
||||
* If info_requested is not NULL, then calls GET_RUNTIME_INFO.
|
||||
*/
|
||||
Datum gms_debug_continue(PG_FUNCTION_ARGS)
|
||||
{
|
||||
DebugClientInfo *client = u_sess->plsql_cxt.debug_client;
|
||||
if(client == nullptr) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED),
|
||||
errmsg("error happened in debug session, please reattach target session and try")));
|
||||
}
|
||||
const int DEBUG_ACTION_ATTR_NUM = 5;
|
||||
const char actions[DEBUG_ACTION_ATTR_NUM] = {
|
||||
GMS_DEBUG_CONTINUE_HEADER,
|
||||
GMS_DEBUG_NEXT_HEADER,
|
||||
GMS_DEBUG_STEP_INTO_HEADER,
|
||||
GMS_DEBUG_FINISH_HEADER,
|
||||
GMS_DEBUG_ABORT_HEADER
|
||||
};
|
||||
int err_code = 0;
|
||||
bool checked = GMSInterfaceCheck("gms_debug.continue", true);
|
||||
if(!checked) {
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED),
|
||||
errmsg("target func not attached")));
|
||||
err_code = ERROR_FUNC_NOT_ATTACHED;
|
||||
return build_runtime_info(client,err_code);
|
||||
}
|
||||
int32 breakflags = PG_GETARG_INT32(0);
|
||||
int32 info_requested = PG_GETARG_INT32(1);
|
||||
char action;
|
||||
std::bitset<DEBUG_ACTION_ATTR_NUM> breakflags_bitset(breakflags);
|
||||
for (int i = 0; i < breakflags_bitset.size(); ++i) {
|
||||
if (breakflags_bitset.test(i)) {
|
||||
action = actions[i];
|
||||
}
|
||||
}
|
||||
debug_client_send_msg(client, action, NULL, 0);
|
||||
debug_client_rec_msg(client);
|
||||
return build_runtime_info(client,err_code);
|
||||
}
|
||||
|
||||
/***
|
||||
* This function returns information about the current program.
|
||||
* It is only needed if the info_requested parameter to SYNCHRONIZE
|
||||
* or CONTINUE was set to 0.
|
||||
*/
|
||||
Datum gms_debug_get_runtime_info(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int err_code = 0;
|
||||
DebugClientInfo *client = u_sess->plsql_cxt.debug_client;
|
||||
if(client == nullptr) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED),
|
||||
errmsg("error happened in debug session, please reattach target session and try")));
|
||||
}
|
||||
bool checked = GMSInterfaceCheck("gms_debug.runtime_info",true);
|
||||
if(!checked) {
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED),
|
||||
errmsg("target func not attached")));
|
||||
err_code = ERROR_FUNC_NOT_ATTACHED;
|
||||
return build_runtime_info(client, err_code);
|
||||
}
|
||||
int32 info_requested = PG_GETARG_INT32(0);
|
||||
debug_client_send_msg(client, GMS_DEBUG_RUNTIMEINFO_HEADER, NULL, 0);
|
||||
debug_client_rec_msg(client);
|
||||
return build_runtime_info(client, err_code);
|
||||
}
|
||||
|
||||
/***
|
||||
* This procedure notifies the target session that
|
||||
* debugging should no longer take place in that session.
|
||||
* It is not necessary to call this function before ending the session.
|
||||
*/
|
||||
Datum gms_debug_off(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GMSInterfaceCheck("gms_debug.debug_off",false);
|
||||
// dms_debug indicates that session debugging functionality should be enabled.
|
||||
SetDebugCommGmsUsed(u_sess->plsql_cxt.gms_debug_idx, false);
|
||||
u_sess->plsql_cxt.gms_debug_idx = -1;
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/***
|
||||
* This procedure stops debugging the target program.
|
||||
* This procedure may be called at any time,
|
||||
* but it does not notify the target session that the debug session is detaching itself,
|
||||
* and it does not terminate execution of the target session.
|
||||
* Therefore, care should be taken to ensure that the target session does not hang itself.
|
||||
*/
|
||||
Datum gms_debug_detach_session(PG_FUNCTION_ARGS)
|
||||
{
|
||||
DebugClientInfo *client = u_sess->plsql_cxt.debug_client;
|
||||
if(client == nullptr) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED),
|
||||
errmsg("error happened in debug session, please reattach target session and try")));
|
||||
}
|
||||
GMSInterfaceCheck("gms_debug.detach_session",true);
|
||||
debug_client_send_msg(client, DEBUG_ABORT_HEADER, NULL, 0);
|
||||
debug_client_rec_msg(client);
|
||||
clean_up_debug_client();
|
||||
PG_RETURN_VOID();
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------*
|
||||
* gms_debug.h
|
||||
*
|
||||
* Definition about gms_debug package.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/gms_debug/gms_debug.h
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef GMS_DEBUG_H
|
||||
#define GMS_DEBUG_H
|
||||
|
||||
#define BREAK_NEXT_LINE 2
|
||||
#define BREAK_ANY_CALL 4
|
||||
#define BREAK_ANY_RETURN 8
|
||||
#define BREAK_RETURN 16
|
||||
#define BREAK_EXCEPTION 32
|
||||
#define BREAK_HANDLER 64
|
||||
#define BREAK_ABORT_EXECUTION 128
|
||||
|
||||
#define ERROR_ILLEGAL_LINE -1
|
||||
#define ERROR_BAD_HANDLE -2
|
||||
#define ERROR_ALREADY_EXISTS -3
|
||||
#define ERROR_COMMUNICATION -4
|
||||
#define ERROR_FUNC_NOT_ATTACHED -9
|
||||
|
||||
/* from gms_debug.cpp */
|
||||
extern "C" Datum gms_debug_attach_session(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_debug_detach_session(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_debug_get_runtime_info(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_debug_probe_version(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_debug_initialize(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_debug_on(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_debug_off(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_debug_continue(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_debug_set_breakpoint(PG_FUNCTION_ARGS);
|
||||
|
||||
|
||||
#define CHECK_RETURN_DATUM(mask_string) \
|
||||
do { \
|
||||
if (mask_string == NULL) \
|
||||
PG_RETURN_DATUM(0); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
@ -1,138 +0,0 @@
|
||||
-- wait for server establishment
|
||||
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
set search_path = gms_debugger_test1;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int)
|
||||
returns void as $$
|
||||
declare
|
||||
pro_info gms_debug.program_info;
|
||||
bkline binary_integer;
|
||||
ret binary_integer;
|
||||
begin
|
||||
pro_info.name := funcname;
|
||||
ret := gms_debug.set_breakpoint(pro_info, lineno, bkline,1,1);
|
||||
RAISE NOTICE 'ret= %', ret;
|
||||
RAISE NOTICE 'ret= %', bkline;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_next()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 2, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_step()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 4, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_info()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.get_runtime_info(1, run_info);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
|
||||
select pg_sleep(3);
|
||||
|
||||
select gms_breakpoint('test_debug', 0); -- negative
|
||||
|
||||
select gms_breakpoint('test_debug', 15); -- ok
|
||||
|
||||
select gms_breakpoint('test_debug', 17); -- invalid
|
||||
select gms_breakpoint('test_debug', 22); -- ok
|
||||
select gms_breakpoint('test_debug', 15); -- ok
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_continue();
|
||||
|
||||
select gms_continue();
|
||||
|
||||
select gms_debug.detach_session();
|
@ -1,82 +0,0 @@
|
||||
-- wait for server establishment
|
||||
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
set search_path = gms_debugger_test2;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_next()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 2, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
|
||||
select pg_sleep(3);
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_continue();
|
||||
|
||||
select gms_debug.detach_session();
|
@ -1,82 +0,0 @@
|
||||
-- wait for server establishment
|
||||
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
set search_path = gms_debugger_test3;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_next()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 2, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
|
||||
select pg_sleep(3);
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_continue();
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_debug.detach_session();
|
@ -1,88 +0,0 @@
|
||||
-- wait for server establishment
|
||||
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
set search_path = gms_debugger_test4;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_step()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 4, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
|
||||
select pg_sleep(3);
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_continue();
|
||||
|
||||
select gms_continue();
|
||||
|
||||
select gms_debug.detach_session();
|
@ -1,116 +0,0 @@
|
||||
-- wait for server establishment
|
||||
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
set search_path = gms_debugger_test5;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_step()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 4, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_next()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 2, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_finish()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 8, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
|
||||
select pg_sleep(3);
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_next();
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_finish();
|
||||
|
||||
select gms_finish();
|
||||
|
||||
select gms_debug.detach_session();
|
@ -1,99 +0,0 @@
|
||||
-- wait for server establishment
|
||||
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
set search_path = gms_debugger_test6;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int)
|
||||
returns void as $$
|
||||
declare
|
||||
pro_info gms_debug.program_info;
|
||||
bkline binary_integer;
|
||||
ret binary_integer;
|
||||
begin
|
||||
pro_info.name := funcname;
|
||||
ret := gms_debug.set_breakpoint(pro_info, lineno, bkline,1,1);
|
||||
RAISE NOTICE 'ret= %', ret;
|
||||
RAISE NOTICE 'ret= %', bkline;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_finish()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 8, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
|
||||
select pg_sleep(3);
|
||||
|
||||
select gms_breakpoint('test_debug', 31);
|
||||
select gms_breakpoint('test_debug', 44);
|
||||
|
||||
select gms_finish();
|
||||
|
||||
select gms_finish();
|
||||
|
||||
select gms_finish();
|
||||
|
||||
select gms_continue();
|
||||
|
||||
select gms_debug.detach_session();
|
@ -1,103 +0,0 @@
|
||||
-- wait for server establishment
|
||||
|
||||
CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension()
|
||||
RETURNS BOOLEAN AS $$
|
||||
DECLARE
|
||||
extension_exists BOOLEAN;
|
||||
BEGIN
|
||||
-- 初始化变量
|
||||
extension_exists := FALSE;
|
||||
|
||||
-- 循环查询扩展是否存在
|
||||
WHILE NOT extension_exists LOOP
|
||||
-- 查询扩展是否存在
|
||||
PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug';
|
||||
IF FOUND THEN
|
||||
-- 如果扩展存在,则退出循环
|
||||
extension_exists := TRUE;
|
||||
ELSE
|
||||
-- 如果扩展不存在,则等待一段时间再重试
|
||||
PERFORM pg_sleep(1); -- 等待1秒
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
-- 返回扩展存在的标志
|
||||
RETURN extension_exists;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF wait_for_gms_debug_extension() THEN
|
||||
-- 扩展存在,执行下一步操作
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
set search_path = gms_debugger_test7;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_step()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 4, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_continue()
|
||||
returns void as $$
|
||||
declare
|
||||
run_info gms_debug.runtime_info;
|
||||
ret binary_integer;
|
||||
begin
|
||||
ret := gms_debug.continue(run_info, 0, 2);
|
||||
RAISE NOTICE 'breakpoint= %', run_info.breakpoint;
|
||||
RAISE NOTICE 'stackdepth= %', run_info.stackdepth;
|
||||
RAISE NOTICE 'line= %', run_info.line#;
|
||||
RAISE NOTICE 'reason= %', run_info.reason;
|
||||
RAISE NOTICE 'ret= %',ret;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int)
|
||||
returns void as $$
|
||||
declare
|
||||
pro_info gms_debug.program_info;
|
||||
bkline binary_integer;
|
||||
ret binary_integer;
|
||||
begin
|
||||
pro_info.name := funcname;
|
||||
ret := gms_debug.set_breakpoint(pro_info, lineno, bkline,1,1);
|
||||
RAISE NOTICE 'ret= %', ret;
|
||||
RAISE NOTICE 'ret= %', bkline;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- attach debug server
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
|
||||
select pg_sleep(3);
|
||||
|
||||
select gms_breakpoint('test_debug_recursive', 5);
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_step();
|
||||
|
||||
select gms_continue();
|
||||
|
||||
select gms_continue();
|
||||
|
||||
select gms_debug.detach_session();
|
@ -1,95 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test1 cascade;
|
||||
create schema gms_debugger_test1;
|
||||
set search_path = gms_debugger_test1;
|
||||
create table test(a int, b varchar(40), c timestamp);
|
||||
insert into test values (2, 'Giving to the Needy', '2020-02-02');
|
||||
insert into test values (3, 'Prayer', '2021-12-02');
|
||||
insert into test values (5, 'Fasting', '2030-03-02');
|
||||
insert into test values (7, 'Treasures in Heaven', '2040-04-02');
|
||||
|
||||
CREATE OR REPLACE FUNCTION test_debug(x int) RETURNS SETOF test AS
|
||||
$BODY$
|
||||
DECLARE
|
||||
sql_stmt VARCHAR2(500);
|
||||
r test%rowtype;
|
||||
rec record;
|
||||
b_tmp text;
|
||||
cnt int;
|
||||
a_tmp int;
|
||||
cur refcursor;
|
||||
n_tmp NUMERIC(24,6);
|
||||
t_tmp tsquery;
|
||||
CURSOR cur_arg(criterion INTEGER) IS
|
||||
SELECT * FROM test WHERE a < criterion;
|
||||
BEGIN
|
||||
cnt := 0;
|
||||
FOR r IN SELECT * FROM test
|
||||
WHERE a > x
|
||||
LOOP
|
||||
RETURN NEXT r;
|
||||
END LOOP;
|
||||
|
||||
FOR rec in SELECT * FROM test
|
||||
WHERE a < x
|
||||
LOOP
|
||||
RETURN NEXT rec;
|
||||
END LOOP;
|
||||
|
||||
FORALL index_1 IN 0..1
|
||||
INSERT INTO test VALUES (index_1, 'Happy Children''s Day!', '2021-6-1');
|
||||
|
||||
SELECT b FROM test where a = 7 INTO b_tmp;
|
||||
sql_stmt := 'select a from test where b = :1;';
|
||||
OPEN cur FOR sql_stmt USING b_tmp;
|
||||
IF cur%isopen then LOOP
|
||||
FETCH cur INTO a_tmp;
|
||||
EXIT WHEN cur%notfound;
|
||||
END LOOP;
|
||||
END IF;
|
||||
CLOSE cur;
|
||||
WHILE cnt < 3 LOOP
|
||||
cnt := cnt + 1;
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO 'cnt is %', cnt;
|
||||
|
||||
RETURN;
|
||||
|
||||
END
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
create table show_code_table(lineno int, code text, canBreak bool);
|
||||
|
||||
do $$
|
||||
declare
|
||||
funcoid oid;
|
||||
begin
|
||||
select oid from pg_proc into funcoid where proname = 'test_debug';
|
||||
INSERT INTO show_code_table SELECT * FROM dbe_pldebugger.info_code(funcoid);
|
||||
end;
|
||||
$$;
|
||||
|
||||
select * from show_code_table;
|
||||
|
||||
-- attach fail (target not turned on)
|
||||
select * from gms_debug.attach_session('datanode1-0');
|
||||
|
||||
-- turn off without turn on
|
||||
select * from gms_debug.debug_off();
|
||||
|
||||
select * from gms_debug.initialize();
|
||||
|
||||
select pg_sleep(1);
|
||||
|
||||
-- start debug - 1st run
|
||||
select * from test_debug(4);
|
||||
|
||||
-- start debug - 2nd run - to be aborted
|
||||
select * from test_debug(4);
|
||||
|
||||
select * from gms_debug.debug_off();
|
||||
|
||||
drop schema gms_debugger_test1 cascade;
|
@ -1,32 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test2 cascade;
|
||||
create schema gms_debugger_test2;
|
||||
set search_path = gms_debugger_test2;
|
||||
|
||||
-- commit/rollback in procedure
|
||||
create table tb1(a int);
|
||||
create or replace procedure test_debug2 as
|
||||
begin
|
||||
insert into tb1 values (1000);
|
||||
commit;
|
||||
insert into tb1 values (2000);
|
||||
rollback;
|
||||
end;
|
||||
/
|
||||
|
||||
|
||||
-- start debug
|
||||
select * from gms_debug.initialize();
|
||||
|
||||
select pg_sleep(1);
|
||||
|
||||
-- start debug - 1st run
|
||||
select * from test_debug2();
|
||||
|
||||
-- start debug - 2nd run - to be aborted
|
||||
select * from test_debug2();
|
||||
|
||||
select * from gms_debug.debug_off();
|
||||
|
||||
drop schema gms_debugger_test2 cascade;
|
@ -1,39 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test3 cascade;
|
||||
create schema gms_debugger_test3;
|
||||
set search_path = gms_debugger_test3;
|
||||
|
||||
-- test for implicit variables
|
||||
CREATE OR REPLACE function test_debug3(a in integer) return integer
|
||||
AS
|
||||
declare
|
||||
b int;
|
||||
BEGIN
|
||||
CASE a
|
||||
WHEN 1 THEN
|
||||
b := 111;
|
||||
ELSE
|
||||
b := 999;
|
||||
END CASE;
|
||||
raise info 'pi_return : %',pi_return ;
|
||||
return b;
|
||||
EXCEPTION WHEN others THEN
|
||||
b := 101;
|
||||
return b;
|
||||
END;
|
||||
/
|
||||
|
||||
select * from gms_debug.initialize();
|
||||
|
||||
select pg_sleep(1);
|
||||
|
||||
-- start debug - 1st run
|
||||
select * from test_debug3(1);
|
||||
|
||||
-- start debug - 2nd run - to be aborted
|
||||
select * from test_debug3(1);
|
||||
|
||||
select * from gms_debug.debug_off();
|
||||
|
||||
drop schema gms_debugger_test3 cascade;
|
@ -1,97 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test4 cascade;
|
||||
create schema gms_debugger_test4;
|
||||
set search_path = gms_debugger_test4;
|
||||
|
||||
create table test(a int, b varchar(40), c timestamp);
|
||||
insert into test values (2, 'Giving to the Needy', '2020-02-02');
|
||||
insert into test values (3, 'Prayer', '2021-12-02');
|
||||
insert into test values (5, 'Fasting', '2030-03-02');
|
||||
insert into test values (7, 'Treasures in Heaven', '2040-04-02');
|
||||
|
||||
CREATE OR REPLACE FUNCTION test_debug(x int) RETURNS SETOF test AS
|
||||
$BODY$
|
||||
DECLARE
|
||||
sql_stmt VARCHAR2(500);
|
||||
r test%rowtype;
|
||||
rec record;
|
||||
b_tmp text;
|
||||
cnt int;
|
||||
a_tmp int;
|
||||
cur refcursor;
|
||||
n_tmp NUMERIC(24,6);
|
||||
t_tmp tsquery;
|
||||
CURSOR cur_arg(criterion INTEGER) IS
|
||||
SELECT * FROM test WHERE a < criterion;
|
||||
BEGIN
|
||||
cnt := 0;
|
||||
FOR r IN SELECT * FROM test
|
||||
WHERE a > x
|
||||
LOOP
|
||||
RETURN NEXT r;
|
||||
END LOOP;
|
||||
|
||||
FOR rec in SELECT * FROM test
|
||||
WHERE a < x
|
||||
LOOP
|
||||
RETURN NEXT rec;
|
||||
END LOOP;
|
||||
|
||||
FORALL index_1 IN 0..1
|
||||
INSERT INTO test VALUES (index_1, 'Happy Children''s Day!', '2021-6-1');
|
||||
|
||||
SELECT b FROM test where a = 7 INTO b_tmp;
|
||||
sql_stmt := 'select a from test where b = :1;';
|
||||
OPEN cur FOR sql_stmt USING b_tmp;
|
||||
IF cur%isopen then LOOP
|
||||
FETCH cur INTO a_tmp;
|
||||
EXIT WHEN cur%notfound;
|
||||
END LOOP;
|
||||
END IF;
|
||||
CLOSE cur;
|
||||
WHILE cnt < 3 LOOP
|
||||
cnt := cnt + 1;
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO 'cnt is %', cnt;
|
||||
|
||||
RETURN;
|
||||
|
||||
END
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
-- test for step into
|
||||
CREATE OR REPLACE FUNCTION test_debug4(a in integer) return integer
|
||||
AS
|
||||
declare
|
||||
b int;
|
||||
BEGIN
|
||||
CASE a
|
||||
WHEN 1 THEN
|
||||
b := 111;
|
||||
call test_debug(a);
|
||||
ELSE
|
||||
b := 999;
|
||||
END CASE;
|
||||
return b;
|
||||
raise info 'pi_return : %',pi_return ;
|
||||
EXCEPTION WHEN others THEN
|
||||
b := 101;
|
||||
return b;
|
||||
END;
|
||||
/
|
||||
|
||||
select * from gms_debug.initialize();
|
||||
|
||||
select pg_sleep(1);
|
||||
|
||||
select * from test_debug4(1);
|
||||
|
||||
-- test with client error in exception
|
||||
select * from test_debug4(1);
|
||||
|
||||
select * from gms_debug.debug_off();
|
||||
|
||||
drop schema gms_debugger_test4 cascade;
|
@ -1,97 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test5 cascade;
|
||||
create schema gms_debugger_test5;
|
||||
set search_path = gms_debugger_test5;
|
||||
|
||||
create table test(a int, b varchar(40), c timestamp);
|
||||
insert into test values (2, 'Giving to the Needy', '2020-02-02');
|
||||
insert into test values (3, 'Prayer', '2021-12-02');
|
||||
insert into test values (5, 'Fasting', '2030-03-02');
|
||||
insert into test values (7, 'Treasures in Heaven', '2040-04-02');
|
||||
|
||||
CREATE OR REPLACE FUNCTION test_debug(x int) RETURNS SETOF test AS
|
||||
$BODY$
|
||||
DECLARE
|
||||
sql_stmt VARCHAR2(500);
|
||||
r test%rowtype;
|
||||
rec record;
|
||||
b_tmp text;
|
||||
cnt int;
|
||||
a_tmp int;
|
||||
cur refcursor;
|
||||
n_tmp NUMERIC(24,6);
|
||||
t_tmp tsquery;
|
||||
CURSOR cur_arg(criterion INTEGER) IS
|
||||
SELECT * FROM test WHERE a < criterion;
|
||||
BEGIN
|
||||
cnt := 0;
|
||||
FOR r IN SELECT * FROM test
|
||||
WHERE a > x
|
||||
LOOP
|
||||
RETURN NEXT r;
|
||||
END LOOP;
|
||||
|
||||
FOR rec in SELECT * FROM test
|
||||
WHERE a < x
|
||||
LOOP
|
||||
RETURN NEXT rec;
|
||||
END LOOP;
|
||||
|
||||
FORALL index_1 IN 0..1
|
||||
INSERT INTO test VALUES (index_1, 'Happy Children''s Day!', '2021-6-1');
|
||||
|
||||
SELECT b FROM test where a = 7 INTO b_tmp;
|
||||
sql_stmt := 'select a from test where b = :1;';
|
||||
OPEN cur FOR sql_stmt USING b_tmp;
|
||||
IF cur%isopen then LOOP
|
||||
FETCH cur INTO a_tmp;
|
||||
EXIT WHEN cur%notfound;
|
||||
END LOOP;
|
||||
END IF;
|
||||
CLOSE cur;
|
||||
WHILE cnt < 3 LOOP
|
||||
cnt := cnt + 1;
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO 'cnt is %', cnt;
|
||||
|
||||
RETURN;
|
||||
|
||||
END
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
-- test for step into
|
||||
CREATE OR REPLACE FUNCTION test_debug4(a in integer) return integer
|
||||
AS
|
||||
declare
|
||||
b int;
|
||||
BEGIN
|
||||
CASE a
|
||||
WHEN 1 THEN
|
||||
b := 111;
|
||||
call test_debug(a);
|
||||
ELSE
|
||||
b := 999;
|
||||
END CASE;
|
||||
return b;
|
||||
raise info 'pi_return : %',pi_return ;
|
||||
EXCEPTION WHEN others THEN
|
||||
b := 101;
|
||||
return b;
|
||||
END;
|
||||
/
|
||||
|
||||
select * from gms_debug.initialize();
|
||||
|
||||
select pg_sleep(1);
|
||||
|
||||
select * from test_debug4(1);
|
||||
|
||||
-- test with client error in exception
|
||||
select * from test_debug4(1);
|
||||
|
||||
select * from gms_debug.debug_off();
|
||||
|
||||
drop schema gms_debugger_test5 cascade;
|
@ -1,97 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test6 cascade;
|
||||
create schema gms_debugger_test6;
|
||||
set search_path = gms_debugger_test6;
|
||||
|
||||
create table test(a int, b varchar(40), c timestamp);
|
||||
insert into test values (2, 'Giving to the Needy', '2020-02-02');
|
||||
insert into test values (3, 'Prayer', '2021-12-02');
|
||||
insert into test values (5, 'Fasting', '2030-03-02');
|
||||
insert into test values (7, 'Treasures in Heaven', '2040-04-02');
|
||||
|
||||
CREATE OR REPLACE FUNCTION test_debug(x int) RETURNS SETOF test AS
|
||||
$BODY$
|
||||
DECLARE
|
||||
sql_stmt VARCHAR2(500);
|
||||
r test%rowtype;
|
||||
rec record;
|
||||
b_tmp text;
|
||||
cnt int;
|
||||
a_tmp int;
|
||||
cur refcursor;
|
||||
n_tmp NUMERIC(24,6);
|
||||
t_tmp tsquery;
|
||||
CURSOR cur_arg(criterion INTEGER) IS
|
||||
SELECT * FROM test WHERE a < criterion;
|
||||
BEGIN
|
||||
cnt := 0;
|
||||
FOR r IN SELECT * FROM test
|
||||
WHERE a > x
|
||||
LOOP
|
||||
RETURN NEXT r;
|
||||
END LOOP;
|
||||
|
||||
FOR rec in SELECT * FROM test
|
||||
WHERE a < x
|
||||
LOOP
|
||||
RETURN NEXT rec;
|
||||
END LOOP;
|
||||
|
||||
FORALL index_1 IN 0..1
|
||||
INSERT INTO test VALUES (index_1, 'Happy Children''s Day!', '2021-6-1');
|
||||
|
||||
SELECT b FROM test where a = 7 INTO b_tmp;
|
||||
sql_stmt := 'select a from test where b = :1;';
|
||||
OPEN cur FOR sql_stmt USING b_tmp;
|
||||
IF cur%isopen then LOOP
|
||||
FETCH cur INTO a_tmp;
|
||||
EXIT WHEN cur%notfound;
|
||||
END LOOP;
|
||||
END IF;
|
||||
CLOSE cur;
|
||||
WHILE cnt < 3 LOOP
|
||||
cnt := cnt + 1;
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO 'cnt is %', cnt;
|
||||
|
||||
RETURN;
|
||||
|
||||
END
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
-- test for step into
|
||||
CREATE OR REPLACE FUNCTION test_debug4(a in integer) return integer
|
||||
AS
|
||||
declare
|
||||
b int;
|
||||
BEGIN
|
||||
CASE a
|
||||
WHEN 1 THEN
|
||||
b := 111;
|
||||
call test_debug(a);
|
||||
ELSE
|
||||
b := 999;
|
||||
END CASE;
|
||||
return b;
|
||||
raise info 'pi_return : %',pi_return ;
|
||||
EXCEPTION WHEN others THEN
|
||||
b := 101;
|
||||
return b;
|
||||
END;
|
||||
/
|
||||
|
||||
select * from gms_debug.initialize();
|
||||
|
||||
select pg_sleep(1);
|
||||
|
||||
select * from test_debug4(1);
|
||||
|
||||
-- test with client error in exception
|
||||
select * from test_debug4(1);
|
||||
|
||||
select * from gms_debug.debug_off();
|
||||
|
||||
drop schema gms_debugger_test6 cascade;
|
@ -1,29 +0,0 @@
|
||||
-- setups
|
||||
create extension if not exists gms_debug;
|
||||
drop schema if exists gms_debugger_test7 cascade;
|
||||
create schema gms_debugger_test7;
|
||||
set search_path = gms_debugger_test7;
|
||||
|
||||
create or replace function test_debug_recursive (ct int, pr int)
|
||||
returns table (counter int, product int)
|
||||
language plpgsql
|
||||
as $$
|
||||
begin
|
||||
return query select ct, pr;
|
||||
if ct < 5 then
|
||||
return query select * from test_debug_recursive(ct+ 1, pr * (ct+ 1));
|
||||
end if;
|
||||
end $$;
|
||||
|
||||
select * from gms_debug.initialize();
|
||||
|
||||
select pg_sleep(1);
|
||||
|
||||
select * from test_debug_recursive (1, 1);
|
||||
|
||||
-- test with client error in exception
|
||||
select * from test_debug_recursive (1, 1);
|
||||
|
||||
select * from gms_debug.debug_off();
|
||||
|
||||
drop schema gms_debugger_test7 cascade;
|
@ -1,21 +0,0 @@
|
||||
#This is the main CMAKE for build all gms_i18n.
|
||||
# gms_i18n
|
||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TGT_gms_i18n_SRC)
|
||||
set(TGT_gms_i18n_INC
|
||||
${PROJECT_OPENGS_DIR}/contrib/gms_i18n
|
||||
${PROJECT_OPENGS_DIR}/contrib
|
||||
)
|
||||
|
||||
set(gms_i18n_DEF_OPTIONS ${MACRO_OPTIONS})
|
||||
set(gms_i18n_COMPILE_OPTIONS ${OPTIMIZE_OPTIONS} ${OS_OPTIONS} ${PROTECT_OPTIONS} ${WARNING_OPTIONS} ${LIB_SECURE_OPTIONS} ${CHECK_OPTIONS})
|
||||
set(gms_i18n_LINK_OPTIONS ${LIB_LINK_OPTIONS})
|
||||
add_shared_libtarget(gms_i18n TGT_gms_i18n_SRC TGT_gms_i18n_INC "${gms_i18n_DEF_OPTIONS}" "${gms_i18n_COMPILE_OPTIONS}" "${gms_i18n_LINK_OPTIONS}")
|
||||
set_target_properties(gms_i18n PROPERTIES PREFIX "")
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_i18n.control
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_i18n--1.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(TARGETS gms_i18n DESTINATION lib/postgresql)
|
@ -1,26 +0,0 @@
|
||||
# contrib/gms_i18n/Makefile
|
||||
MODULE_big = gms_i18n
|
||||
OBJS = gms_i18n.o
|
||||
|
||||
EXTENSION = gms_i18n
|
||||
DATA = gms_i18n--1.0.sql
|
||||
|
||||
exclude_option = -fPIE
|
||||
override CPPFLAGS := $(filter-out $(exclude_option),$(CPPFLAGS))
|
||||
|
||||
REGRESS = gms_i18n
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/gms_i18n
|
||||
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
|
@ -1 +0,0 @@
|
||||
The openGauss regression needs this file to run.
|
@ -1,145 +0,0 @@
|
||||
create extension gms_i18n;
|
||||
create schema gms_i18n_test;
|
||||
set search_path=gms_i18n_test;
|
||||
-- test gms_i18n.raw_to_char
|
||||
select gms_i18n.raw_to_char(hextoraw('616263646566C2AA'), 'utf8');
|
||||
raw_to_char
|
||||
-------------
|
||||
abcdefª
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char(hextoraw('e6b58be8af95'), 'utf8');
|
||||
raw_to_char
|
||||
-------------
|
||||
测试
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char(hextoraw('e6b58be8af95'), '');
|
||||
raw_to_char
|
||||
-------------
|
||||
测试
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char(hextoraw('e6b58be8af95'));
|
||||
raw_to_char
|
||||
-------------
|
||||
测试
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char('', 'utf8');
|
||||
raw_to_char
|
||||
-------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char('', '');
|
||||
raw_to_char
|
||||
-------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char('');
|
||||
raw_to_char
|
||||
-------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char(hextoraw('e6b58be8af95'), 'unvalid_charset');
|
||||
ERROR: invalid source encoding name "unvalid_charset"
|
||||
CONTEXT: referenced column: raw_to_char
|
||||
select gms_i18n.raw_to_char(hextoraw('b2e2cad4'), 'gbk');
|
||||
raw_to_char
|
||||
-------------
|
||||
测试
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char(hextoraw('b2e2cad4'), 'euc_cn');
|
||||
raw_to_char
|
||||
-------------
|
||||
测试
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char(hextoraw('b4fab8d5'), 'big5');
|
||||
raw_to_char
|
||||
-------------
|
||||
測試
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.raw_to_char();
|
||||
ERROR: function gms_i18n.raw_to_char() does not exist
|
||||
LINE 1: select gms_i18n.raw_to_char();
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
CONTEXT: referenced column: raw_to_char
|
||||
-- test gms_i18n.string_to_raw
|
||||
select gms_i18n.string_to_raw('abcdefª', 'utf8');
|
||||
string_to_raw
|
||||
------------------
|
||||
616263646566C2AA
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw('测试', 'utf8');
|
||||
string_to_raw
|
||||
---------------
|
||||
E6B58BE8AF95
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw('测试', '');
|
||||
string_to_raw
|
||||
---------------
|
||||
E6B58BE8AF95
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw('测试');
|
||||
string_to_raw
|
||||
---------------
|
||||
E6B58BE8AF95
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw('', 'utf8');
|
||||
string_to_raw
|
||||
---------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw('', '');
|
||||
string_to_raw
|
||||
---------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw('');
|
||||
string_to_raw
|
||||
---------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw('测试', 'unvalid_charset');
|
||||
ERROR: invalid destination encoding name "unvalid_charset"
|
||||
CONTEXT: referenced column: string_to_raw
|
||||
select gms_i18n.string_to_raw('测试', 'gbk');
|
||||
string_to_raw
|
||||
---------------
|
||||
B2E2CAD4
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw('测试', 'euc_cn');
|
||||
string_to_raw
|
||||
---------------
|
||||
B2E2CAD4
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw('測試', 'big5');
|
||||
string_to_raw
|
||||
---------------
|
||||
B4FAB8D5
|
||||
(1 row)
|
||||
|
||||
select gms_i18n.string_to_raw();
|
||||
ERROR: function gms_i18n.string_to_raw() does not exist
|
||||
LINE 1: select gms_i18n.string_to_raw();
|
||||
^
|
||||
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
|
||||
CONTEXT: referenced column: string_to_raw
|
||||
reset search_path;
|
||||
drop schema gms_i18n_test cascade;
|
@ -1,17 +0,0 @@
|
||||
/* contrib/gms_i18n/gms_i18n--1.0.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION gms_i18n" to load this file. \quit
|
||||
|
||||
CREATE SCHEMA gms_i18n;
|
||||
GRANT USAGE ON SCHEMA gms_i18n TO PUBLIC;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_i18n.raw_to_char(IN rawdata raw, IN charset varchar2 DEFAULT NULL)
|
||||
RETURNS varchar2
|
||||
AS 'MODULE_PATHNAME', 'gms_i18n_raw_to_char'
|
||||
LANGUAGE C IMMUTABLE;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_i18n.string_to_raw(IN strdata varchar2, IN charset varchar2 DEFAULT NULL)
|
||||
RETURNS raw
|
||||
AS 'MODULE_PATHNAME', 'gms_i18n_string_to_raw'
|
||||
LANGUAGE C IMMUTABLE;
|
@ -1,5 +0,0 @@
|
||||
# gms_i18n extension
|
||||
comment = 'collection of i18n for PL/SQL applications'
|
||||
default_version = '1.0'
|
||||
module_pathname = '$libdir/gms_i18n'
|
||||
relocatable = true
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Technologies Co.,Ltd.
|
||||
*
|
||||
* openGauss is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
* --------------------------------------------------------------------------------------
|
||||
*
|
||||
* gms_i18n.cpp
|
||||
* gms_i18n package
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/gms_i18n/gms_i18n.cpp
|
||||
*
|
||||
* --------------------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "utils/builtins.h"
|
||||
|
||||
#include "gms_i18n.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
PG_FUNCTION_INFO_V1(gms_i18n_raw_to_char);
|
||||
PG_FUNCTION_INFO_V1(gms_i18n_string_to_raw);
|
||||
|
||||
Datum gms_i18n_raw_to_char(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum raw = PG_GETARG_DATUM(0);
|
||||
Datum src_encoding_name;
|
||||
Datum dest_encoding_name;
|
||||
Datum result;
|
||||
|
||||
if (PG_ARGISNULL(0)) {
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
|
||||
dest_encoding_name = DirectFunctionCall1(namein, CStringGetDatum(u_sess->mb_cxt.DatabaseEncoding->name));
|
||||
|
||||
if (PG_ARGISNULL(1)) {
|
||||
src_encoding_name = dest_encoding_name;
|
||||
} else {
|
||||
src_encoding_name = DirectFunctionCall1(text_name, PG_GETARG_DATUM(1));
|
||||
}
|
||||
|
||||
/*
|
||||
* pg_convert expects a bytea as its first argument. We're passing it a
|
||||
* raw argument here, relying on the fact that they are both in fact
|
||||
* varlena types, and thus structurally identical.
|
||||
*/
|
||||
result = DirectFunctionCall3(pg_convert, raw, src_encoding_name, dest_encoding_name);
|
||||
|
||||
PG_RETURN_DATUM(result);
|
||||
}
|
||||
|
||||
Datum gms_i18n_string_to_raw(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum string = PG_GETARG_DATUM(0);
|
||||
Datum dest_encoding_name;
|
||||
Datum src_encoding_name;
|
||||
Datum result;
|
||||
|
||||
if (PG_ARGISNULL(0)) {
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
|
||||
src_encoding_name = DirectFunctionCall1(namein, CStringGetDatum(u_sess->mb_cxt.DatabaseEncoding->name));
|
||||
|
||||
if (PG_ARGISNULL(1)) {
|
||||
dest_encoding_name = src_encoding_name;
|
||||
} else {
|
||||
dest_encoding_name = DirectFunctionCall1(text_name, PG_GETARG_DATUM(1));
|
||||
}
|
||||
|
||||
/*
|
||||
* pg_convert expects a bytea as its first argument. We're passing it a
|
||||
* varchar2 argument here, relying on the fact that they are both in fact
|
||||
* varlena types, and thus structurally identical.
|
||||
*/
|
||||
result = DirectFunctionCall3(pg_convert, string, src_encoding_name, dest_encoding_name);
|
||||
|
||||
PG_RETURN_DATUM(result);
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------*
|
||||
* gms_i18n.h
|
||||
*
|
||||
* Definition about gms_i18n package.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/gms_i18n/gms_i18n.h
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __GMS_I18N__
|
||||
#define __GMS_I18N__
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
extern "C" Datum gms_i18n_raw_to_char(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_i18n_string_to_raw(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif // __GMS_I18N__
|
@ -1,34 +0,0 @@
|
||||
create extension gms_i18n;
|
||||
create schema gms_i18n_test;
|
||||
set search_path=gms_i18n_test;
|
||||
|
||||
-- test gms_i18n.raw_to_char
|
||||
select gms_i18n.raw_to_char(hextoraw('616263646566C2AA'), 'utf8');
|
||||
select gms_i18n.raw_to_char(hextoraw('e6b58be8af95'), 'utf8');
|
||||
select gms_i18n.raw_to_char(hextoraw('e6b58be8af95'), '');
|
||||
select gms_i18n.raw_to_char(hextoraw('e6b58be8af95'));
|
||||
select gms_i18n.raw_to_char('', 'utf8');
|
||||
select gms_i18n.raw_to_char('', '');
|
||||
select gms_i18n.raw_to_char('');
|
||||
select gms_i18n.raw_to_char(hextoraw('e6b58be8af95'), 'unvalid_charset');
|
||||
select gms_i18n.raw_to_char(hextoraw('b2e2cad4'), 'gbk');
|
||||
select gms_i18n.raw_to_char(hextoraw('b2e2cad4'), 'euc_cn');
|
||||
select gms_i18n.raw_to_char(hextoraw('b4fab8d5'), 'big5');
|
||||
select gms_i18n.raw_to_char();
|
||||
|
||||
-- test gms_i18n.string_to_raw
|
||||
select gms_i18n.string_to_raw('abcdefª', 'utf8');
|
||||
select gms_i18n.string_to_raw('测试', 'utf8');
|
||||
select gms_i18n.string_to_raw('测试', '');
|
||||
select gms_i18n.string_to_raw('测试');
|
||||
select gms_i18n.string_to_raw('', 'utf8');
|
||||
select gms_i18n.string_to_raw('', '');
|
||||
select gms_i18n.string_to_raw('');
|
||||
select gms_i18n.string_to_raw('测试', 'unvalid_charset');
|
||||
select gms_i18n.string_to_raw('测试', 'gbk');
|
||||
select gms_i18n.string_to_raw('测试', 'euc_cn');
|
||||
select gms_i18n.string_to_raw('測試', 'big5');
|
||||
select gms_i18n.string_to_raw();
|
||||
|
||||
reset search_path;
|
||||
drop schema gms_i18n_test cascade;
|
@ -1,18 +0,0 @@
|
||||
#This is the main CMAKE for build all components.
|
||||
# gms_inaddr.so
|
||||
AUX_SOURCE_DIRECTORY(${PROJECT_OPENGS_DIR}/contrib/gms_inaddr TGT_gms_inaddr_SRC)
|
||||
|
||||
set(gms_inaddr_DEF_OPTIONS ${MACRO_OPTIONS})
|
||||
set(gms_inaddr_COMPILE_OPTIONS ${OPTIMIZE_OPTIONS} ${OS_OPTIONS} ${PROTECT_OPTIONS} ${WARNING_OPTIONS} ${LIB_SECURE_OPTIONS} ${CHECK_OPTIONS})
|
||||
set(gms_inaddr_LINK_OPTIONS ${LIB_LINK_OPTIONS})
|
||||
add_shared_libtarget(gms_inaddr TGT_gms_inaddr_SRC "" "${gms_inaddr_DEF_OPTIONS}" "${gms_inaddr_COMPILE_OPTIONS}" "${gms_inaddr_LINK_OPTIONS}")
|
||||
set_target_properties(gms_inaddr PROPERTIES PREFIX "")
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_inaddr.control
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_inaddr--1.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(TARGETS gms_inaddr LIBRARY DESTINATION lib/postgresql)
|
||||
|
@ -1,25 +0,0 @@
|
||||
# contrib/gms_inaddr/Makefile
|
||||
MODULE_big = gms_inaddr
|
||||
OBJS = gms_inaddr.o
|
||||
|
||||
EXTENSION = gms_inaddr
|
||||
DATA = gms_inaddr--1.0.sql
|
||||
|
||||
exclude_option = -fPIE
|
||||
override CPPFLAGS := -fstack-protector-strong $(filter-out $(exclude_option),$(CPPFLAGS))
|
||||
|
||||
REGRESS = gms_inaddr
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/gms_inaddr
|
||||
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
|
@ -1 +0,0 @@
|
||||
The openGauss regression needs this file to run.
|
@ -1,29 +0,0 @@
|
||||
create extension gms_output;
|
||||
create extension gms_inaddr;
|
||||
begin
|
||||
gms_output.enable;
|
||||
gms_output.put_line(gms_inaddr.get_host_address('localhost'));
|
||||
gms_output.put_line(gms_inaddr.get_host_name('127.0.0.1'));
|
||||
end
|
||||
/
|
||||
127.0.0.1
|
||||
localhost
|
||||
begin
|
||||
gms_output.enable;
|
||||
gms_output.put_line(gms_inaddr.get_host_address('localhostxx'));
|
||||
gms_output.put_line(gms_inaddr.get_host_name('127.0.0.1'));
|
||||
end;
|
||||
/
|
||||
ERROR: could not translate host name "localhostxx" to address: Name or service not known
|
||||
CONTEXT: SQL statement "CALL gms_output.put_line(gms_inaddr.get_host_address('localhostxx'))"
|
||||
PL/pgSQL function inline_code_block line 3 at PERFORM
|
||||
begin
|
||||
gms_output.enable;
|
||||
gms_output.put_line(gms_inaddr.get_host_name('10.254.180.400'));
|
||||
end;
|
||||
/
|
||||
ERROR: error happen when fetch hostname: Name or service not known
|
||||
CONTEXT: SQL statement "CALL gms_output.put_line(gms_inaddr.get_host_name('10.254.180.400'))"
|
||||
PL/pgSQL function inline_code_block line 3 at PERFORM
|
||||
drop extension gms_output;
|
||||
drop extension gms_inaddr;
|
@ -1,17 +0,0 @@
|
||||
/* 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_inaddr;
|
||||
GRANT USAGE ON SCHEMA gms_inaddr TO PUBLIC;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_inaddr.get_host_address(text default 'localhost')
|
||||
RETURNS text
|
||||
AS 'MODULE_PATHNAME','gms_inaddr_get_host_address'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_inaddr.get_host_name(text default '127.0.0.1')
|
||||
RETURNS text
|
||||
AS 'MODULE_PATHNAME','gms_inaddr_get_host_name'
|
||||
LANGUAGE C;
|
@ -1,5 +0,0 @@
|
||||
# gms_inaddr extension
|
||||
comment = 'gms_inaddr package'
|
||||
default_version = '1.0'
|
||||
module_pathname = '$libdir/gms_inaddr'
|
||||
relocatable = false
|
@ -1,99 +0,0 @@
|
||||
#include <arpa/inet.h>
|
||||
#include "postgres.h"
|
||||
#include "funcapi.h"
|
||||
#include "commands/extension.h"
|
||||
#include "libpq/libpq.h"
|
||||
#include "libpq/pqformat.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "getaddrinfo.h"
|
||||
|
||||
#include "gms_inaddr.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
PG_FUNCTION_INFO_V1(gms_inaddr_get_host_address);
|
||||
PG_FUNCTION_INFO_V1(gms_inaddr_get_host_name);
|
||||
|
||||
#define MAXLINE 8192
|
||||
#define ADDRESSSIZE 40
|
||||
|
||||
Datum
|
||||
gms_inaddr_get_host_address(PG_FUNCTION_ARGS)
|
||||
{
|
||||
struct addrinfo *gai_result = NULL, *gai = NULL;
|
||||
int ret = -1;
|
||||
char result[ADDRESSSIZE] = {0};
|
||||
|
||||
char* hostname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||
if(PG_ARGISNULL(0)){
|
||||
char hostname[256] = {0};
|
||||
|
||||
(void)gethostname(hostname, 255);
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_WARNING),
|
||||
errmsg("hostname %s!", hostname)));
|
||||
}
|
||||
|
||||
ret = getaddrinfo(hostname, NULL, NULL, &gai_result);
|
||||
if (ret != 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CONFIG_FILE_ERROR),
|
||||
errmsg(
|
||||
"could not translate host name \"%s\" to address: %s", hostname, gai_strerror(ret))));
|
||||
}
|
||||
for (gai = gai_result; gai; gai = gai->ai_next) {
|
||||
errno_t rt;
|
||||
if (gai->ai_addr->sa_family == AF_INET) {
|
||||
struct sockaddr_in* h = (struct sockaddr_in*)gai->ai_addr;
|
||||
char* address = inet_ntoa(h->sin_addr);
|
||||
rt = strcpy_s(result, ADDRESSSIZE, address);
|
||||
securec_check(rt, "\0", "\0");
|
||||
break;
|
||||
}
|
||||
#ifdef HAVE_IPV6
|
||||
else if (gai->ai_addr->sa_family == AF_INET6) {
|
||||
struct sockaddr_in6* h = (struct sockaddr_in6*)gai->ai_addr;
|
||||
inet_net_ntop(AF_INET6, &(h)->sin6_addr, 128, result, ADDRESSSIZE);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (gai_result != NULL)
|
||||
freeaddrinfo(gai_result);
|
||||
|
||||
text* result_text = cstring_to_text(result);
|
||||
PG_RETURN_TEXT_P(result_text);
|
||||
}
|
||||
|
||||
|
||||
Datum
|
||||
gms_inaddr_get_host_name(PG_FUNCTION_ARGS){
|
||||
char* ip_address = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||
|
||||
if(PG_ARGISNULL(0)){
|
||||
ip_address = "127.0.0.1";
|
||||
}
|
||||
|
||||
struct sockaddr_in addr;
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = inet_addr(ip_address);
|
||||
|
||||
char buf[MAXLINE];
|
||||
|
||||
int rc = getnameinfo((struct sockaddr *)&addr,sizeof(struct sockaddr_in),buf,MAXLINE,NULL,0,NI_NAMEREQD);
|
||||
|
||||
|
||||
if(rc != 0){
|
||||
elog(ERROR,
|
||||
"error happen when fetch hostname: %s",
|
||||
gai_strerror(rc));
|
||||
}
|
||||
|
||||
text* result_text = cstring_to_text(buf);
|
||||
|
||||
PG_RETURN_TEXT_P(result_text);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#ifndef __GMS_INADDR__
|
||||
#define __GMS_INADDR__
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
extern "C" Datum gms_inaddr_get_host_address(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_inaddr_get_host_name(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif // __GMS_INADDR__
|
@ -1,25 +0,0 @@
|
||||
create extension gms_output;
|
||||
create extension gms_inaddr;
|
||||
|
||||
begin
|
||||
gms_output.enable;
|
||||
gms_output.put_line(gms_inaddr.get_host_address('localhost'));
|
||||
gms_output.put_line(gms_inaddr.get_host_name('127.0.0.1'));
|
||||
end
|
||||
/
|
||||
|
||||
begin
|
||||
gms_output.enable;
|
||||
gms_output.put_line(gms_inaddr.get_host_address('localhostxx'));
|
||||
gms_output.put_line(gms_inaddr.get_host_name('127.0.0.1'));
|
||||
end;
|
||||
/
|
||||
|
||||
begin
|
||||
gms_output.enable;
|
||||
gms_output.put_line(gms_inaddr.get_host_name('10.254.180.400'));
|
||||
end;
|
||||
/
|
||||
|
||||
drop extension gms_output;
|
||||
drop extension gms_inaddr;
|
@ -1,21 +0,0 @@
|
||||
#This is the main CMAKE for build all gms_stats.
|
||||
# gms_stats
|
||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TGT_gms_lob_SRC)
|
||||
set(TGT_gms_lob_INC
|
||||
${PROJECT_OPENGS_DIR}/contrib/gms_lob
|
||||
${PROJECT_OPENGS_DIR}/contrib
|
||||
)
|
||||
|
||||
set(gms_lob_DEF_OPTIONS ${MACRO_OPTIONS})
|
||||
set(gms_lob_COMPILE_OPTIONS ${OPTIMIZE_OPTIONS} ${OS_OPTIONS} ${PROTECT_OPTIONS} ${WARNING_OPTIONS} ${LIB_SECURE_OPTIONS} ${CHECK_OPTIONS})
|
||||
set(gms_lob_LINK_OPTIONS ${LIB_LINK_OPTIONS})
|
||||
add_shared_libtarget(gms_lob TGT_gms_lob_SRC TGT_gms_lob_INC "${gms_lob_DEF_OPTIONS}" "${gms_lob_COMPILE_OPTIONS}" "${gms_lob_LINK_OPTIONS}")
|
||||
set_target_properties(gms_lob PROPERTIES PREFIX "")
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_lob.control
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_lob--1.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(TARGETS gms_lob DESTINATION lib/postgresql)
|
@ -1,28 +0,0 @@
|
||||
# contrib/gms_lob/Makefile
|
||||
MODULE_big = gms_lob
|
||||
OBJS = gms_lob.o
|
||||
|
||||
EXTENSION = gms_lob
|
||||
DATA = gms_lob--1.0.sql
|
||||
|
||||
exclude_option = -fPIE
|
||||
override CPPFLAGS := -fstack-protector-strong $(filter-out $(exclude_option),$(CPPFLAGS))
|
||||
|
||||
REGRESS = gms_lob
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/gms_lob
|
||||
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_lob.o: gms_lob.cpp
|
@ -1 +0,0 @@
|
||||
The openGauss regression needs this file to run.
|
File diff suppressed because it is too large
Load Diff
@ -1,139 +0,0 @@
|
||||
/* contrib/gms_lob/gms_lob--1.0.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION gms_lob" to load this file. \quit
|
||||
create schema gms_lob;
|
||||
GRANT USAGE ON SCHEMA gms_lob TO PUBLIC;
|
||||
|
||||
-- GMS_LOB Constants - Basic
|
||||
CREATE OR REPLACE FUNCTION gms_lob."CALL"() returns int
|
||||
as $$
|
||||
begin
|
||||
return 12;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.FILE_READONLY() returns int
|
||||
as $$
|
||||
begin
|
||||
return 0;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.LOB_READONLY() returns BINARY_INTEGER
|
||||
as $$
|
||||
begin
|
||||
return 0;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.LOB_READWRITE() returns BINARY_INTEGER
|
||||
as $$
|
||||
begin
|
||||
return 1;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.LOBMAXSIZE() returns numeric
|
||||
as $$
|
||||
begin
|
||||
return 18446744073709551615;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.SESSION() returns INTEGER
|
||||
as $$
|
||||
begin
|
||||
return 10;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.createtemporary(INOUT lob_loc BLOB, cache boolean, dur INTEGER DEFAULT 10, lobname text DEFAULT ':')
|
||||
RETURNS BLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_createtemporary'
|
||||
LANGUAGE C IMMUTABLE NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.createtemporary(INOUT lob_loc CLOB, cache boolean, dur INTEGER DEFAULT 10, lobname text DEFAULT ':')
|
||||
RETURNS CLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_createtemporary'
|
||||
LANGUAGE C IMMUTABLE NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.freetemporary(INOUT lob_loc BLOB, lobname text DEFAULT ':')
|
||||
RETURNS BLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_freetemporary'
|
||||
LANGUAGE C STRICT NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.freetemporary(INOUT lob_loc CLOB, lobname text DEFAULT ':')
|
||||
RETURNS CLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_freetemporary'
|
||||
LANGUAGE C STRICT NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.read(lob_loc BLOB, INOUT amount INTEGER, "offset" bigint, INOUT buffer raw, lobname text DEFAULT ':')
|
||||
RETURNS record
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_read_blob'
|
||||
LANGUAGE C NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.read(lob_loc CLOB, INOUT amount INTEGER, "offset" bigint, INOUT buffer varchar, lobname text DEFAULT ':')
|
||||
RETURNS record
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_read_clob'
|
||||
LANGUAGE C NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.write(INOUT lob_loc BLOB, amount numeric, "offset" numeric, buffer raw, lobname text DEFAULT ':')
|
||||
RETURNS BLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_write_blob'
|
||||
LANGUAGE C IMMUTABLE NOT FENCED;
|
||||
CREATE OR REPLACE FUNCTION gms_lob.write(INOUT lob_loc CLOB, amount numeric, "offset" numeric, buffer varchar, lobname text DEFAULT ':')
|
||||
RETURNS CLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_write_clob'
|
||||
LANGUAGE C IMMUTABLE NOT FENCED;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.isopen(lob_loc BLOB, lobname text DEFAULT ':')
|
||||
RETURNS INTEGER
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_isopen'
|
||||
LANGUAGE C STRICT NOT FENCED;
|
||||
CREATE OR REPLACE FUNCTION gms_lob.isopen(lob_loc CLOB, lobname text DEFAULT ':')
|
||||
RETURNS INTEGER
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_isopen'
|
||||
LANGUAGE C STRICT NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.open(INOUT lob_loc BLOB, open_mode INTEGER, lobname text DEFAULT ':')
|
||||
RETURNS BLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_open'
|
||||
LANGUAGE C NOT FENCED;
|
||||
CREATE OR REPLACE FUNCTION gms_lob.open(INOUT lob_loc CLOB, open_mode INTEGER, lobname text DEFAULT ':')
|
||||
RETURNS CLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_open'
|
||||
LANGUAGE C NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.append(INOUT dest_lob BLOB, src_lob BLOB, lobname text DEFAULT ':')
|
||||
RETURNS BLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_append_blob'
|
||||
LANGUAGE C IMMUTABLE NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.append(INOUT dest_lob CLOB, src_lob CLOB, lobname text DEFAULT ':')
|
||||
RETURNS CLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_append_clob'
|
||||
LANGUAGE C IMMUTABLE NOT FENCED;
|
||||
CREATE OR REPLACE FUNCTION gms_lob.close(INOUT lob_loc BLOB, lobname text DEFAULT ':')
|
||||
RETURNS BLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_close'
|
||||
LANGUAGE C STRICT NOT FENCED;
|
||||
CREATE OR REPLACE FUNCTION gms_lob.close(INOUT lob_loc CLOB, lobname text DEFAULT ':')
|
||||
RETURNS CLOB
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_close'
|
||||
LANGUAGE C STRICT NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.getlength(lob_loc BLOB, lobname text DEFAULT ':')
|
||||
RETURNS INTEGER
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_bloblength'
|
||||
LANGUAGE C IMMUTABLE STRICT NOT FENCED;
|
||||
CREATE OR REPLACE FUNCTION gms_lob.getlength(lob_loc CLOB, lobname text DEFAULT ':')
|
||||
RETURNS INTEGER
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_cloblength'
|
||||
LANGUAGE C IMMUTABLE STRICT NOT FENCED;
|
||||
|
||||
CREATE OR REPLACE FUNCTION gms_lob.getlength(lobname text DEFAULT ':')
|
||||
RETURNS void
|
||||
AS 'MODULE_PATHNAME', 'gms_lob_og_null'
|
||||
LANGUAGE C IMMUTABLE STRICT NOT FENCED;
|
@ -1,5 +0,0 @@
|
||||
# gms_lob extension
|
||||
comment = 'collection of stats data for PL/SQL applications'
|
||||
default_version = '1.0'
|
||||
module_pathname = '$libdir/gms_lob'
|
||||
relocatable = true
|
@ -1,899 +0,0 @@
|
||||
/*------------------------------------------------------------------------------
|
||||
* gms_lob.cpp
|
||||
*
|
||||
* gms_lob内置包的实现
|
||||
*
|
||||
* Copyright (c) 2002-2012, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 2021, openGauss Contributors
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/gms_stats/gms_lob.cpp
|
||||
*
|
||||
*------------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include "knl/knl_session.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "c.h"
|
||||
#include "miscadmin.h"
|
||||
#include "access/xact.h"
|
||||
#include "access/hash.h"
|
||||
#include "utils/rel.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "access/genam.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "executor/spi.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "executor/executor.h"
|
||||
#include "catalog/storage_gtt.h"
|
||||
#include "utils/numeric.h"
|
||||
#include "access/tuptoaster.h"
|
||||
|
||||
#include "funcapi.h"
|
||||
#include "fmgr.h"
|
||||
#include "catalog/pg_directory.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "libpq/pqformat.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "utils/acl.h"
|
||||
#include "utils/bytea.h"
|
||||
#include "libpq/be-fsstubs.h"
|
||||
#include "libpq/libpq-fs.h"
|
||||
#include "commands/extension.h"
|
||||
#include "gms_lob.h"
|
||||
#include "utils/palloc.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
#define NUMLOB 64
|
||||
static uint32 gmslob_index;
|
||||
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_createtemporary);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_freetemporary);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_read_blob);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_read_clob);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_write_blob);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_write_clob);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_isopen);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_open);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_append_blob);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_append_clob);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_close);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_cloblength);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_bloblength);
|
||||
PG_FUNCTION_INFO_V1(gms_lob_og_null);
|
||||
|
||||
void init_session_vars(void) {
|
||||
RepallocSessionVarsArrayIfNecessary();
|
||||
GmsLobContext* psc =
|
||||
(GmsLobContext*)MemoryContextAllocZero(u_sess->self_mem_cxt, sizeof(GmsLobContext));
|
||||
u_sess->attr.attr_common.extension_session_vars_array[gmslob_index] = psc;
|
||||
psc->gmsLobNameHash = NULL;
|
||||
}
|
||||
|
||||
GmsLobContext* get_session_context() {
|
||||
if (u_sess->attr.attr_common.extension_session_vars_array[gmslob_index] == NULL) {
|
||||
init_session_vars();
|
||||
}
|
||||
return (GmsLobContext*)u_sess->attr.attr_common.extension_session_vars_array[gmslob_index];
|
||||
}
|
||||
|
||||
static int32 getVarSize(varlena* var)
|
||||
{
|
||||
if (VARATT_IS_HUGE_TOAST_POINTER(var)) {
|
||||
struct varatt_lob_external large_toast_pointer;
|
||||
|
||||
VARATT_EXTERNAL_GET_HUGE_POINTER(large_toast_pointer, var);
|
||||
return large_toast_pointer.va_rawsize;
|
||||
} else {
|
||||
return VARSIZE_ANY_EXHDR(var);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* charlen_to_bytelen()
|
||||
* Compute the number of bytes occupied by n characters starting at *p
|
||||
*
|
||||
* It is caller's responsibility that there actually are n characters;
|
||||
* the string need not be null-terminated.
|
||||
*/
|
||||
static int charlen_to_bytelen(const char* p, int n)
|
||||
{
|
||||
if (pg_database_encoding_max_length() == 1) {
|
||||
/* Optimization for single-byte encodings */
|
||||
return n;
|
||||
} else {
|
||||
const char* s = NULL;
|
||||
|
||||
for (s = p; n > 0; n--)
|
||||
s += pg_mblen(s);
|
||||
|
||||
return s - p;
|
||||
}
|
||||
}
|
||||
|
||||
/* numeric 向下取整转成int4 */
|
||||
int32 numericFloorToInt4(Numeric num)
|
||||
{
|
||||
Datum datumnum = DirectFunctionCall1(numeric_floor, NumericGetDatum(num));
|
||||
return DatumGetInt32(DirectFunctionCall1(numeric_int4, datumnum));
|
||||
}
|
||||
/*****************************************************************************
|
||||
* LOB哈希表相关
|
||||
*****************************************************************************/
|
||||
struct GmsLobHashKey {
|
||||
char* keyvalue;
|
||||
int length;
|
||||
};
|
||||
|
||||
typedef struct LobHashEnt {
|
||||
GmsLobHashKey key; /* hash表key值 */
|
||||
int open_mode; /* 打开方式 */
|
||||
} LobHashEnt;
|
||||
/*
|
||||
* lob数据的hash值生成函数
|
||||
*/
|
||||
uint32 lob_hash(const void* key, Size kwysize)
|
||||
{
|
||||
const GmsLobHashKey* hash_key = (const GmsLobHashKey*)key;
|
||||
return DatumGetUInt32(hash_any((const unsigned char*)hash_key->keyvalue, hash_key->length));
|
||||
}
|
||||
/*
|
||||
* lob数据的hash比较函数
|
||||
*/
|
||||
int lob_match(const void* key1, const void* key2, Size kwysize)
|
||||
{
|
||||
const GmsLobHashKey* k1 = (const GmsLobHashKey*)key1;
|
||||
const GmsLobHashKey* k2 = (const GmsLobHashKey*)key2;
|
||||
|
||||
if (k1->length > k2->length) {
|
||||
return 1;
|
||||
} else if (k1->length < k2->length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return strncmp(k1->keyvalue, k2->keyvalue, k1->length);
|
||||
}
|
||||
/*
|
||||
* 创建hash表
|
||||
*/
|
||||
static HTAB* createlobHash()
|
||||
{
|
||||
HASHCTL hash_ctl;
|
||||
|
||||
hash_ctl.keysize = sizeof(GmsLobHashKey);
|
||||
hash_ctl.entrysize = sizeof(LobHashEnt);
|
||||
hash_ctl.hash = lob_hash;
|
||||
hash_ctl.match = lob_match;
|
||||
|
||||
return hash_create("Lob hash", NUMLOB, &hash_ctl, HASH_ELEM | HASH_FUNCTION | HASH_COMPARE);
|
||||
}
|
||||
|
||||
/*
|
||||
* 程序退出时的清理函数
|
||||
* 作为回调函数添加到proc_exit()调用的函数列表中
|
||||
*/
|
||||
static void gms_lob_og_lob_exit(int code, Datum arg)
|
||||
{
|
||||
HASH_SEQ_STATUS scan;
|
||||
LobHashEnt *hentry = NULL;
|
||||
|
||||
if (get_session_context()->gmsLobNameHash == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
hash_seq_init(&scan, get_session_context()->gmsLobNameHash);
|
||||
while ((hentry = (LobHashEnt *)hash_seq_search(&scan))) {
|
||||
if (hentry->key.keyvalue) {
|
||||
pfree(hentry->key.keyvalue);
|
||||
}
|
||||
}
|
||||
/* 清理hash表 */
|
||||
hash_destroy(get_session_context()->gmsLobNameHash);
|
||||
get_session_context()->gmsLobNameHash = NULL;
|
||||
}
|
||||
|
||||
char* generateLobKey(char* argname)
|
||||
{
|
||||
char* key = NULL;
|
||||
int keylen = 0;
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
|
||||
TransactionId currentTransactionId = GetCurrentTransactionId();
|
||||
// TransactionId采用16进制方式打印,逗号末尾结束符各占一个字节
|
||||
keylen = strlen(argname) + sizeof(TransactionId) * 2 + 1 + 1;
|
||||
key = (char*)palloc0(keylen);
|
||||
errno_t errorno = snprintf_s(key, keylen, keylen - 1, "%16x,%s", currentTransactionId, argname);
|
||||
securec_check_ss(errorno, "\0", "\0");
|
||||
return key;
|
||||
}
|
||||
|
||||
int searchLob(char* argname, bool* found)
|
||||
{
|
||||
LobHashEnt* hentry = NULL;
|
||||
GmsLobHashKey hash_key;
|
||||
if (get_session_context()->gmsLobNameHash) {
|
||||
hash_key.keyvalue = generateLobKey(argname);
|
||||
hash_key.length = strlen(hash_key.keyvalue) + 1;
|
||||
hentry = (LobHashEnt*)hash_search(get_session_context()->gmsLobNameHash, &hash_key, HASH_FIND, NULL);
|
||||
if (hentry) {
|
||||
*found = true;
|
||||
return hentry->open_mode;
|
||||
}
|
||||
|
||||
if (hash_key.keyvalue) {
|
||||
pfree(hash_key.keyvalue);
|
||||
}
|
||||
} else {
|
||||
get_session_context()->gmsLobNameHash = createlobHash();
|
||||
on_proc_exit(&gms_lob_og_lob_exit, PointerGetDatum(NULL));
|
||||
}
|
||||
*found = false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void closeLob(char* argname)
|
||||
{
|
||||
bool found;
|
||||
LobHashEnt* hentry = NULL;
|
||||
GmsLobHashKey hash_key;
|
||||
|
||||
searchLob(argname, &found);
|
||||
if (found) {
|
||||
hash_key.keyvalue = generateLobKey(argname);
|
||||
hash_key.length = strlen(hash_key.keyvalue) + 1;
|
||||
hentry = (LobHashEnt*)hash_search(get_session_context()->gmsLobNameHash, &hash_key, HASH_REMOVE, NULL);
|
||||
if (!hentry) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("undefined lob.")));
|
||||
}
|
||||
|
||||
if (hash_key.keyvalue) {
|
||||
pfree(hash_key.keyvalue);
|
||||
}
|
||||
|
||||
if (hentry->key.keyvalue) {
|
||||
pfree(hentry->key.keyvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void openLob(char* argname, int openmode)
|
||||
{
|
||||
bool found;
|
||||
LobHashEnt* hentry = NULL;
|
||||
GmsLobHashKey hash_key;
|
||||
|
||||
hash_key.keyvalue = generateLobKey(argname);
|
||||
hash_key.length = strlen(hash_key.keyvalue) + 1;
|
||||
hentry = (LobHashEnt*)hash_search(get_session_context()->gmsLobNameHash, &hash_key, HASH_ENTER, &found);
|
||||
if (found) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("duplicate lob(%s) openned", argname)));
|
||||
}
|
||||
|
||||
hentry->key.keyvalue = (char*)MemoryContextAlloc(THREAD_GET_MEM_CXT_GROUP(MEMORY_CONTEXT_EXECUTOR), hash_key.length);
|
||||
int rc = memcpy_s(hentry->key.keyvalue, hash_key.length, hash_key.keyvalue, hash_key.length);
|
||||
securec_check(rc, "\0", "\0");
|
||||
hentry->key.length = hash_key.length;
|
||||
hentry->open_mode = openmode;
|
||||
|
||||
if (hash_key.keyvalue) {
|
||||
pfree(hash_key.keyvalue);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* GMS_LOB.CREATETEMPORARY (
|
||||
* lob_loc IN OUT BLOB/CLOB, --blob/clob对象
|
||||
* cache IN BOOLEAN, --是否将LOB读取到缓冲区(不生效)
|
||||
* dur IN PLS_INTEGER := GMS_LOB.SESSION); --指定何时清除临时LOB(10/ SESSION:会话结束时;12/ CALL:调用结束时)(不生效
|
||||
)
|
||||
*/
|
||||
Datum gms_lob_og_createtemporary(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char* argname = text_to_cstring(PG_GETARG_TEXT_P(3));
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
|
||||
varlena* res = NULL;
|
||||
if (PG_ARGISNULL(0)) {
|
||||
res = (varlena*)palloc(VARHDRSZ);
|
||||
SET_VARSIZE(res, VARHDRSZ);
|
||||
PG_RETURN_POINTER(res);
|
||||
}
|
||||
|
||||
PG_RETURN_DATUM(PG_GETARG_DATUM(0));
|
||||
}
|
||||
|
||||
/*
|
||||
* GMS_LOB.FREETEMPORARY (
|
||||
* lob_loc IN OUT BLOB/CLOB); --blob/clob对象
|
||||
*/
|
||||
Datum gms_lob_og_freetemporary(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char* argname = text_to_cstring(PG_GETARG_TEXT_P(1));
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
/* lob如果没关闭,将其关闭 */
|
||||
closeLob(argname);
|
||||
|
||||
/* 返回一个空值的varlena */
|
||||
varlena* res = (varlena*)palloc0(VARHDRSZ);
|
||||
SET_VARSIZE(res, VARHDRSZ);
|
||||
|
||||
PG_RETURN_DATUM(PointerGetDatum(res));
|
||||
}
|
||||
|
||||
/*
|
||||
* lob_loc IN BLOB,
|
||||
* amount IN OUT NOCOPY BINARY_INTEGER,
|
||||
* offset IN INTEGER,
|
||||
* buffer INOUT RAW
|
||||
*/
|
||||
Datum gms_lob_og_read_blob(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (PG_ARGISNULL(0))
|
||||
ereport(ERROR,(errcode(ERRCODE_INVALID_PARAMETER_VALUE),errmsg("invalid LOB object specified")));
|
||||
|
||||
if (PG_ARGISNULL(1) || PG_ARGISNULL(2)) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("numeric or value error")));
|
||||
}
|
||||
|
||||
bytea *src_lob = PG_GETARG_BYTEA_P(0);
|
||||
int32 amount = PG_GETARG_INT32(1);
|
||||
int32 offset = PG_GETARG_INT32(2);
|
||||
|
||||
if (amount < 1 || amount > AMOUNT_MAX_SIZE) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("amount is invalid or out of range")));
|
||||
}
|
||||
if (offset < 1 || offset > LOBMAXSIZE) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("offset is invalid or out of range")));
|
||||
}
|
||||
|
||||
int32 srclen = VARSIZE(src_lob) - VARHDRSZ;
|
||||
|
||||
if (offset > srclen) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("no data found")));
|
||||
}
|
||||
|
||||
int32 srcamount = amount > (srclen - offset + 1) ? (srclen - offset + 1) : amount; //src实际复制的字节数
|
||||
bytea* res = NULL;
|
||||
int rc = 0;
|
||||
res = (bytea*)palloc0(srcamount + VARHDRSZ);
|
||||
SET_VARSIZE(res, srcamount + VARHDRSZ);
|
||||
rc = memcpy_s(VARDATA(res), srcamount, VARDATA(src_lob) + offset - 1, srcamount);
|
||||
securec_check(rc, "\0", "\0");
|
||||
|
||||
TupleDesc tupdesc;
|
||||
Datum result;
|
||||
HeapTuple tuple;
|
||||
Datum values[2];
|
||||
bool nulls[2] = { false, false };
|
||||
/* 构造返回结果集 */
|
||||
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
|
||||
elog(ERROR, "return type must be a row type");
|
||||
}
|
||||
|
||||
/*拼接结果*/
|
||||
values[0] = Int32GetDatum(srcamount);
|
||||
values[1] = PointerGetDatum(res);
|
||||
tuple = heap_form_tuple(tupdesc, values, nulls);
|
||||
result = HeapTupleGetDatum(tuple);
|
||||
|
||||
PG_RETURN_DATUM(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* lob_loc IN CLOB,
|
||||
* amount IN OUT NOCOPY BINARY_INTEGER,
|
||||
* offset IN INTEGER,
|
||||
* buffer INOUT VARCHAR2
|
||||
*/
|
||||
Datum gms_lob_og_read_clob(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (PG_ARGISNULL(0))
|
||||
ereport(ERROR,(errcode(ERRCODE_INVALID_PARAMETER_VALUE),errmsg("invalid LOB object specified")));
|
||||
|
||||
if (PG_ARGISNULL(1) || PG_ARGISNULL(2)) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("numeric or value error")));
|
||||
}
|
||||
|
||||
text* src_lob = PG_GETARG_TEXT_P(0);
|
||||
int32 amount = PG_GETARG_INT32(1);
|
||||
int32 offset = PG_GETARG_INT32(2);
|
||||
|
||||
if (amount < 1 || amount > AMOUNT_MAX_SIZE) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("amount is invalid or out of range")));
|
||||
}
|
||||
|
||||
if (offset < 1 || offset > LOBMAXSIZE) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("offset is invalid or out of range")));
|
||||
}
|
||||
|
||||
int32 srclen = DirectFunctionCall1(textlen, PointerGetDatum(src_lob));
|
||||
|
||||
if (offset > srclen) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("no data found")));
|
||||
}
|
||||
|
||||
int32 srcamount = amount > (srclen - offset + 1) ? (srclen - offset + 1) : amount; //src实际复制的字符数
|
||||
int32 srcbytestart = charlen_to_bytelen(VARDATA(src_lob), offset - 1); //src复制起点
|
||||
int32 copybyte = charlen_to_bytelen(VARDATA(src_lob) + srcbytestart, srcamount); //src实际复制的字节数
|
||||
text* res = NULL;
|
||||
int rc = 0;
|
||||
|
||||
res = (text*)palloc0(copybyte + VARHDRSZ);
|
||||
SET_VARSIZE(res, copybyte + VARHDRSZ);
|
||||
rc = memcpy_s(VARDATA(res), copybyte, VARDATA(src_lob) + srcbytestart, copybyte);
|
||||
securec_check(rc, "\0", "\0");
|
||||
|
||||
TupleDesc tupdesc;
|
||||
Datum result;
|
||||
HeapTuple tuple;
|
||||
Datum values[2];
|
||||
bool nulls[2] = { false, false };
|
||||
/* 构造返回结果集 */
|
||||
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
|
||||
elog(ERROR, "return type must be a row type");
|
||||
}
|
||||
|
||||
/*拼接结果*/
|
||||
values[0] = Int32GetDatum(srcamount);
|
||||
values[1] = PointerGetDatum(res);
|
||||
|
||||
tuple = heap_form_tuple(tupdesc, values, nulls);
|
||||
result = HeapTupleGetDatum(tuple);
|
||||
|
||||
PG_RETURN_DATUM(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* GMS_LOB.WRITE (
|
||||
* lob_loc IN OUT NOCOPY BLOB, --目标blob对象
|
||||
* amount IN INTEGER, --指定的传入字节数
|
||||
* offset IN INTEGER, --开始读取blob的字节数的偏移量(原点在1)
|
||||
* buffer IN RAW); --用于写的输入缓冲区
|
||||
*/
|
||||
Datum gms_lob_og_write_blob(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char* argname = text_to_cstring(PG_GETARG_TEXT_P(4));
|
||||
/* check input args */
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
if (PG_ARGISNULL(0)) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid LOB object specified")));
|
||||
}
|
||||
if (PG_ARGISNULL(1) || PG_ARGISNULL(2)) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("Any of the input parameters are NULL")));
|
||||
}
|
||||
|
||||
bytea* destlob = PG_GETARG_BYTEA_P(0);
|
||||
int32 amount = numericFloorToInt4(PG_GETARG_NUMERIC(1));
|
||||
int32 offset = numericFloorToInt4(PG_GETARG_NUMERIC(2));
|
||||
bytea* buffer = PG_GETARG_BYTEA_P(3);
|
||||
int32 bufsize = getVarSize(buffer);
|
||||
|
||||
if (amount < 1 || amount > 32767 || amount > bufsize) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("amount is invalid or out of range")));
|
||||
}
|
||||
if (offset < 1 || offset > LOBMAXSIZE) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("Invalid argument value for dest_offset.")));
|
||||
}
|
||||
|
||||
/* check lob's write and read permissions */
|
||||
bool found;
|
||||
int32 openmode = searchLob(argname, &found);
|
||||
if (found && openmode == 0) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OPERATION),
|
||||
errmsg("cannot update a LOB opened in read-only mode.")));
|
||||
}
|
||||
|
||||
int32 destlen = getVarSize(destlob);
|
||||
int destbytestart = (offset - 1) > destlen ? destlen : (offset - 1);
|
||||
int32 spacecnt = (offset - 1) > destlen ? (offset - destlen - 1) : 0;
|
||||
int32 appendbyte = amount;
|
||||
int32 destbyteend = (offset - 1 + appendbyte) > destlen ? destlen : (offset - 1 + appendbyte);
|
||||
int64 reslen = destbytestart + spacecnt + appendbyte + (destlen - destbyteend);
|
||||
bytea* res = NULL;
|
||||
char* resdata = NULL;
|
||||
int rc = 0;
|
||||
|
||||
if (reslen != destlen || buffer == destlob) {
|
||||
/* dest is lack of space, or displaced copy when
|
||||
* buffer is the same as destlob, to avoid errors
|
||||
* in memcpy_s checking, reapply
|
||||
*/
|
||||
if (reslen > MAX_TOAST_CHUNK_SIZE - VARHDRSZ) {
|
||||
#ifdef ENABLE_MULTIPLE_NODES
|
||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("Un-support clob/blob type more than 1GB for distributed system")));
|
||||
#endif
|
||||
}
|
||||
res = (bytea*)palloc(reslen + VARHDRSZ);
|
||||
SET_VARSIZE(res, reslen + VARHDRSZ);
|
||||
} else {
|
||||
res = destlob;
|
||||
}
|
||||
resdata = VARDATA(res);
|
||||
if (destbytestart > 0 && res != destlob) {
|
||||
rc = memcpy_s(resdata, destbytestart, VARDATA(destlob), destbytestart);
|
||||
securec_check(rc, "\0", "\0");
|
||||
}
|
||||
resdata += destbytestart;
|
||||
if (spacecnt > 0) {
|
||||
rc = memset_s(resdata, spacecnt, ' ', spacecnt);
|
||||
securec_check(rc, "\0", "\0");
|
||||
}
|
||||
resdata += spacecnt;
|
||||
if (appendbyte > 0) {
|
||||
rc = memcpy_s(resdata, appendbyte, VARDATA(buffer), appendbyte);
|
||||
securec_check(rc, "\0", "\0");
|
||||
}
|
||||
resdata += appendbyte;
|
||||
if (destbyteend < destlen && res != destlob) {
|
||||
rc = memcpy_s(resdata, destlen - destbyteend, VARDATA(destlob) + destbyteend, destlen - destbyteend);
|
||||
securec_check(rc, "\0", "\0");
|
||||
}
|
||||
PG_RETURN_BYTEA_P(res);
|
||||
}
|
||||
|
||||
/*
|
||||
* GMS_LOB.WRITE (
|
||||
* lob_loc IN OUT NOCOPY CLOB CHARACTER SET ANY_CS, --目标clob对象
|
||||
* amount IN INTEGER, --指定传入的字符数
|
||||
* offset IN INTEGER, --开始读取blob的字符数的偏移量(原点在1)
|
||||
* buffer IN VARCHAR2 CHARACTER SET lob_loc%CHARSET); --用于写入的缓冲区
|
||||
*/
|
||||
Datum gms_lob_og_write_clob(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char* argname = text_to_cstring(PG_GETARG_TEXT_P(4));
|
||||
/* check input args */
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
if (PG_ARGISNULL(0)) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid LOB object specified")));
|
||||
}
|
||||
if (PG_ARGISNULL(1) || PG_ARGISNULL(2)) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("Any of the input parameters are NULL")));
|
||||
}
|
||||
|
||||
text* destlob = PG_GETARG_TEXT_P(0);
|
||||
int32 amount = numericFloorToInt4(PG_GETARG_NUMERIC(1));
|
||||
int32 offset = numericFloorToInt4(PG_GETARG_NUMERIC(2));
|
||||
text* buffer = PG_GETARG_TEXT_P(3);
|
||||
int32 bufsize = DirectFunctionCall1(textlen, (Datum)buffer);
|
||||
|
||||
if (amount < 1 || amount > 32767 || amount > bufsize) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("amount is invalid or out of range")));
|
||||
}
|
||||
if (offset < 1 || offset > LOBMAXSIZE) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("Invalid argument value for dest_offset.")));
|
||||
}
|
||||
|
||||
/* check lob's write and read permissions */
|
||||
bool found;
|
||||
int32 openmode = searchLob(argname, &found);
|
||||
if (found && openmode == 0) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OPERATION),
|
||||
errmsg("cannot update a LOB opened in read-only mode.")));
|
||||
}
|
||||
|
||||
int32 destlen = DirectFunctionCall1(textlen, (Datum)destlob);
|
||||
int32 srcamount = amount;
|
||||
int32 destbytestart = 0;
|
||||
int32 spacecnt = 0;
|
||||
int32 appendbyte = charlen_to_bytelen(VARDATA(buffer), srcamount);
|
||||
int32 destamount = 0;
|
||||
int32 destbyteend = 0;
|
||||
int32 destbytecnt = VARSIZE(destlob) - VARHDRSZ;
|
||||
int64 reslen = 0;
|
||||
text* res = NULL;
|
||||
char* resdata = NULL;
|
||||
int rc = 0;
|
||||
|
||||
if (destlen < offset - 1) {
|
||||
destamount = destlen;
|
||||
spacecnt = offset - 1 - destamount;
|
||||
destbytestart = destbytecnt;
|
||||
destbyteend = destbytecnt;
|
||||
} else {
|
||||
destamount = srcamount > (destlen - offset + 1) ? (destlen - offset + 1) : srcamount;
|
||||
destbytestart = charlen_to_bytelen(VARDATA(destlob), offset - 1);
|
||||
destbyteend = charlen_to_bytelen(VARDATA(destlob) + destbytestart, destamount) + destbytestart;
|
||||
}
|
||||
reslen = destbytestart + spacecnt + appendbyte + (destbytecnt - destbyteend);
|
||||
|
||||
if (reslen != destbytecnt || buffer == destlob) {
|
||||
/* dest is lack of space, or displaced copy when
|
||||
* buffer is the same as destlob, to avoid errors
|
||||
* in memcpy_s checking, reapply
|
||||
*/
|
||||
if (reslen > MAX_TOAST_CHUNK_SIZE - VARHDRSZ) {
|
||||
#ifdef ENABLE_MULTIPLE_NODES
|
||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("Un-support clob/blob type more than 1GB for distributed system")));
|
||||
#endif
|
||||
}
|
||||
res = (text*)palloc(reslen + VARHDRSZ);
|
||||
SET_VARSIZE(res, reslen + VARHDRSZ);
|
||||
} else {
|
||||
res = destlob;
|
||||
}
|
||||
resdata = VARDATA(res);
|
||||
if (destbytestart > 0 && res != destlob) {
|
||||
rc = memcpy_s(resdata, destbytestart, VARDATA(destlob), destbytestart);
|
||||
securec_check(rc, "\0", "\0");
|
||||
}
|
||||
resdata += destbytestart;
|
||||
if (spacecnt > 0) {
|
||||
rc = memset_s(resdata, spacecnt, ' ', spacecnt);
|
||||
securec_check(rc, "\0", "\0");
|
||||
}
|
||||
resdata += spacecnt;
|
||||
if (appendbyte > 0) {
|
||||
rc = memcpy_s(resdata, appendbyte, VARDATA(buffer), appendbyte);
|
||||
securec_check(rc, "\0", "\0");
|
||||
}
|
||||
resdata += appendbyte;
|
||||
if (destbyteend < destbytecnt && res != destlob) {
|
||||
rc = memcpy_s(resdata, destbytecnt - destbyteend, VARDATA(destlob) + destbyteend, destbytecnt - destbyteend);
|
||||
securec_check(rc, "\0", "\0");
|
||||
}
|
||||
PG_RETURN_TEXT_P(res);
|
||||
}
|
||||
|
||||
/*
|
||||
* GMS_LOB.ISOPEN (
|
||||
* lob_loc IN OUT BLOB/CLOB); --blob/clob对象
|
||||
*/
|
||||
Datum gms_lob_og_isopen(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bool found;
|
||||
char* argname = text_to_cstring(PG_GETARG_TEXT_P(1));
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
searchLob(argname, &found);
|
||||
if (found) {
|
||||
PG_RETURN_UINT8(1);
|
||||
} else {
|
||||
PG_RETURN_UINT8(0);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* GMS_LOB.OPEN (
|
||||
* lob_loc IN OUT BLOB/CLOB,
|
||||
* open_mode IN BINARY_INTEGER);
|
||||
*/
|
||||
Datum gms_lob_og_open(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if PG_ARGISNULL(0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid LOB object specified")));
|
||||
}
|
||||
bool found;
|
||||
int openmode = PG_GETARG_INT32(1);
|
||||
if (openmode != 0 && openmode != 1) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid open_mode")));
|
||||
}
|
||||
char* argname = text_to_cstring(PG_GETARG_TEXT_P(2));
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
|
||||
searchLob(argname, &found);
|
||||
if (found) {
|
||||
ereport(NOTICE, (errmsg("Lob(%s) already opened in the same transaction", argname)));
|
||||
PG_RETURN_DATUM(PG_GETARG_DATUM(0));
|
||||
}
|
||||
openLob(argname, openmode);
|
||||
|
||||
PG_RETURN_DATUM(PG_GETARG_DATUM(0));
|
||||
}
|
||||
|
||||
/*
|
||||
GMS_LOB.APPEND (
|
||||
dest_lob IN OUT NOCOPY BLOB, --目标blob对象
|
||||
src_lob IN BLOB); --源blob对象
|
||||
*/
|
||||
Datum gms_lob_og_append_blob(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char* argname = text_to_cstring(PG_GETARG_TEXT_P(2));
|
||||
/* check input args */
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid LOB object specified")));
|
||||
}
|
||||
|
||||
/* check lob's write and read permissions */
|
||||
bool found;
|
||||
int32 openmode = searchLob(argname, &found);
|
||||
if (found && openmode == 0) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OPERATION),
|
||||
errmsg("cannot update a LOB opened in read-only mode.")));
|
||||
}
|
||||
|
||||
Datum destlob = PG_GETARG_DATUM(0);
|
||||
Datum srclob = PG_GETARG_DATUM(1);
|
||||
Datum result = DirectFunctionCall2(byteacat, destlob, srclob);
|
||||
|
||||
PG_RETURN_BYTEA_P(DatumGetPointer(result));
|
||||
}
|
||||
|
||||
/*
|
||||
GMS_LOB.APPEND (
|
||||
dest_lob IN OUT NOCOPY CLOB CHARACTER SET ANY_CS, --目标clob对象
|
||||
src_lob IN CLOB CHARACTER SET dest_lob%CHARSET); --源clob对象
|
||||
*/
|
||||
Datum gms_lob_og_append_clob(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char* argname = text_to_cstring(PG_GETARG_TEXT_P(2));
|
||||
/* check input args */
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid LOB object specified")));
|
||||
}
|
||||
|
||||
/* check lob's write and read permissions */
|
||||
bool found;
|
||||
int32 openmode = searchLob(argname, &found);
|
||||
if (found && openmode == 0) {
|
||||
closeLob(argname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OPERATION),
|
||||
errmsg("cannot update a LOB opened in read-only mode.")));
|
||||
}
|
||||
|
||||
Datum destlob = PG_GETARG_DATUM(0);
|
||||
Datum srclob = PG_GETARG_DATUM(1);
|
||||
Datum result = DirectFunctionCall2(textcat, destlob, srclob);
|
||||
|
||||
PG_RETURN_TEXT_P(DatumGetPointer(result));
|
||||
}
|
||||
|
||||
/*
|
||||
* GMS_LOB.CLOSE (
|
||||
* lob_loc IN OUT BLOB/CLOB); --blob/clob对象
|
||||
*/
|
||||
Datum gms_lob_og_close(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char* argname = text_to_cstring(PG_GETARG_TEXT_P(1));
|
||||
if (strcmp(argname, ":") == 0) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("output parameter not a bind variable")));
|
||||
}
|
||||
bool found;
|
||||
searchLob(argname, &found);
|
||||
if (!found) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("cannot perform operation on an unopened file or LOB")));
|
||||
}
|
||||
closeLob(argname);
|
||||
|
||||
PG_RETURN_DATUM(PG_GETARG_DATUM(0));
|
||||
}
|
||||
|
||||
/*
|
||||
* GMS_LOB.getlength (
|
||||
* lob_loc IN OUT CLOB); --clob对象
|
||||
*/
|
||||
Datum gms_lob_og_cloblength(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum data = PG_GETARG_DATUM(0);
|
||||
int datalen = 0;
|
||||
|
||||
datalen = DirectFunctionCall1(textlen, data);
|
||||
PG_RETURN_INT32(datalen);
|
||||
}
|
||||
/*
|
||||
* GMS_LOB.getlength (
|
||||
* lob_loc IN OUT BLOB); --blob对象
|
||||
*/
|
||||
Datum gms_lob_og_bloblength(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bytea* data = PG_GETARG_BYTEA_P(0);
|
||||
int datalen = 0;
|
||||
|
||||
datalen = VARSIZE(data) - VARHDRSZ;
|
||||
PG_RETURN_INT32(datalen);
|
||||
}
|
||||
|
||||
/*
|
||||
* GMS_LOB.getlength (); --NULL对象
|
||||
*/
|
||||
Datum gms_lob_og_null(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_VOID();
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------*
|
||||
* gms_lob.h
|
||||
*
|
||||
* Definition about gms_lob package.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/gms_stats/gms_lob.h
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef GMS_LOB_H
|
||||
#define GMS_LOB_H
|
||||
/* blob/clob最大存储长度1G*/
|
||||
#define LOBMAXSIZE (int64)0x3fffffff
|
||||
#define AMOUNT_MAX_SIZE 32767
|
||||
typedef struct GmsLobContext {
|
||||
struct HTAB* gmsLobNameHash;
|
||||
} GmsLobContext;
|
||||
|
||||
extern "C" Datum gms_lob_og_createtemporary(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_freetemporary(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_read_blob(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_read_clob(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_write_blob(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_write_clob(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_isopen(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_open(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_append_blob(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_append_clob(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_close(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_cloblength(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_bloblength(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gms_lob_og_null(PG_FUNCTION_ARGS);
|
||||
extern "C" void set_extension_index(uint32 index);
|
||||
extern "C" void init_session_vars(void);
|
||||
extern "C" GmsLobContext* get_session_context();
|
||||
#endif
|
@ -1,990 +0,0 @@
|
||||
drop database if exists testlob;
|
||||
create database testlob;
|
||||
\c testlob
|
||||
create extension gms_lob;
|
||||
create extension gms_output;
|
||||
select gms_output.enable(4000);
|
||||
create or replace function cast_to_raw(strdata varchar2) returns raw
|
||||
as 'select encode(cast($1 as bytea), ''hex'')::raw;'LANGUAGE SQL;
|
||||
|
||||
--测试blob类型长度
|
||||
CREATE TABLE testblob(id INT, b BLOB);
|
||||
--cast_to_raw
|
||||
INSERT INTO testblob VALUES(1, cast_to_raw('Blob'));
|
||||
INSERT INTO testblob VALUES(2, cast_to_raw('中文测试'));
|
||||
INSERT INTO testblob VALUES(3, cast_to_raw(''));
|
||||
INSERT INTO testblob VALUES(4, cast_to_raw('test
|
||||
test'));
|
||||
|
||||
SELECT id, gms_lob.getlength(b) FROM testblob;
|
||||
|
||||
DROP TABLE testblob;
|
||||
|
||||
--测试clob类型的长度
|
||||
CREATE TABLE testclob(id INT, b CLOB);
|
||||
INSERT INTO testclob VALUES(1, ('Blob'));
|
||||
INSERT INTO testclob VALUES(2, ('中文测试'));
|
||||
INSERT INTO testclob VALUES(3, (''));
|
||||
INSERT INTO testclob VALUES(4, ('test
|
||||
test'));
|
||||
|
||||
SELECT *,gms_lob.getlength(b) FROM testclob;
|
||||
|
||||
DROP TABLE testclob;
|
||||
|
||||
--在函数中调用
|
||||
CREATE OR REPLACE FUNCTION fun_blob() RETURNS INTEGER LANGUAGE plpgsql AS $$
|
||||
DECLARE
|
||||
lob_object BLOB := cast_to_raw('中文1');
|
||||
offset INTEGER;
|
||||
BEGIN
|
||||
RETURN gms_lob.getlength(lob_object);
|
||||
END;
|
||||
$$;
|
||||
|
||||
SELECT fun_blob();
|
||||
|
||||
CREATE OR REPLACE FUNCTION fun_clob() RETURNS INTEGER LANGUAGE plpgsql AS $$
|
||||
DECLARE
|
||||
lob_object CLOB := ('中文1');
|
||||
offset INTEGER;
|
||||
BEGIN
|
||||
RETURN gms_lob.getlength(lob_object);
|
||||
END;
|
||||
$$;
|
||||
|
||||
SELECT fun_clob();
|
||||
|
||||
CREATE OR REPLACE FUNCTION fun_null() RETURNS INTEGER LANGUAGE plpgsql AS $$
|
||||
DECLARE
|
||||
lob_object CLOB;
|
||||
offset INTEGER;
|
||||
BEGIN
|
||||
RETURN gms_lob.getlength(lob_object);
|
||||
END;
|
||||
$$;
|
||||
|
||||
SELECT fun_null();
|
||||
|
||||
DROP FUNCTION fun_blob;
|
||||
DROP FUNCTION fun_clob;
|
||||
DROP FUNCTION fun_null;
|
||||
|
||||
--测试输入为空的场景
|
||||
SELECT gms_lob.getlength();
|
||||
|
||||
create table tbl_testlob(id int, c_lob clob, b_lob blob);
|
||||
insert into tbl_testlob values(1, 'clob', cast_to_raw('blob'));
|
||||
insert into tbl_testlob values(2, '中文clobobject测试', cast_to_raw('中文blobobject测试'));
|
||||
|
||||
create or replace function func_clob() returns void
|
||||
AS $$
|
||||
DECLARE
|
||||
v_clob1 clob;
|
||||
v_clob2 clob;
|
||||
v_clob3 clob;
|
||||
len1 int;
|
||||
len3 int;
|
||||
BEGIN
|
||||
select c_lob into v_clob1 from tbl_testlob where id = 1;
|
||||
gms_lob.open(v_clob1, gms_lob.LOB_READWRITE);
|
||||
gms_lob.append(v_clob1, ' test');
|
||||
len1 := gms_lob.getlength(v_clob1);
|
||||
gms_output.put_line('clob2:' || v_clob2);
|
||||
gms_lob.read(v_clob1, len1, 1, v_clob2);
|
||||
gms_output.put_line('clob1:' || v_clob1);
|
||||
gms_output.put_line('clob2:' || v_clob2);
|
||||
|
||||
select c_lob into v_clob3 from tbl_testlob where id = 2;
|
||||
len3 := gms_lob.getlength(v_clob3);
|
||||
|
||||
gms_output.put_line('clob3:' || v_clob3);
|
||||
--不调用open函数。默认权限为读写
|
||||
gms_lob.write(v_clob3, len1, len3, v_clob1);
|
||||
gms_output.put_line('clob3:' || v_clob3);
|
||||
|
||||
gms_lob.close(v_clob1);
|
||||
gms_lob.freetemporary(v_clob2);
|
||||
END;
|
||||
$$LANGUAGE plpgsql;
|
||||
|
||||
create or replace function func_blob() returns void
|
||||
AS $$
|
||||
DECLARE
|
||||
v_blob1 blob;
|
||||
v_blob2 blob;
|
||||
v_blob3 blob;
|
||||
len1 int;
|
||||
len3 int;
|
||||
BEGIN
|
||||
select b_lob into v_blob1 from tbl_testlob where id = 1;
|
||||
gms_lob.open(v_blob1, gms_lob.LOB_READWRITE);
|
||||
|
||||
len1 := gms_lob.getlength(v_blob1);
|
||||
gms_output.put_line('blob1:' || v_blob1::text);
|
||||
gms_output.put_line('blob2:' || v_blob2::text);
|
||||
gms_lob.read(v_blob1, len1, 1, v_blob2);
|
||||
gms_output.put_line('blob1:' || v_blob1::text);
|
||||
gms_output.put_line('blob2:' || v_blob2::text);
|
||||
|
||||
select b_lob into v_blob3 from tbl_testlob where id = 2;
|
||||
len3 := gms_lob.getlength(v_blob3);
|
||||
--不调用open函数。默认权限为读写
|
||||
gms_output.put_line('blob3:' || v_blob3::text);
|
||||
gms_lob.write(v_blob3, len1, len3, v_blob1);
|
||||
gms_output.put_line('blob3:' || v_blob3::text);
|
||||
|
||||
gms_lob.close(v_blob1);
|
||||
gms_lob.freetemporary(v_blob2);
|
||||
END;
|
||||
$$LANGUAGE plpgsql;
|
||||
|
||||
select func_clob();
|
||||
select func_blob();
|
||||
|
||||
----------open函数-----------
|
||||
--(1)打开无效的lob
|
||||
DECLARE
|
||||
v_clob clob;
|
||||
BEGIN
|
||||
gms_lob.open(v_clob, gms_lob.LOB_READWRITE);
|
||||
gms_lob.close(v_clob);
|
||||
END;
|
||||
/
|
||||
--(2)open_mode为数值
|
||||
DECLARE
|
||||
v_clob clob;
|
||||
BEGIN
|
||||
gms_lob.createtemporary(v_clob, false, 10);
|
||||
gms_lob.open(v_clob, 1);
|
||||
gms_lob.close(v_clob);
|
||||
gms_lob.freetemporary(v_clob);
|
||||
END;
|
||||
/
|
||||
--(3)open_mode为其他值
|
||||
DECLARE
|
||||
v_clob clob;
|
||||
BEGIN
|
||||
gms_lob.createtemporary(v_clob, false);
|
||||
gms_lob.open(v_clob, 100);
|
||||
gms_lob.close(v_clob);
|
||||
gms_lob.freetemporary(v_clob);
|
||||
END;
|
||||
/
|
||||
|
||||
--重复打开
|
||||
DECLARE
|
||||
v_clob clob;
|
||||
BEGIN
|
||||
gms_lob.createtemporary(v_clob, false);
|
||||
gms_lob.open(v_clob, gms_lob.LOB_READONLY);
|
||||
gms_lob.open(v_clob, gms_lob.LOB_READWRITE);
|
||||
gms_lob.close(v_clob);
|
||||
gms_lob.freetemporary(v_clob);
|
||||
END;
|
||||
/
|
||||
|
||||
-- 大写名称
|
||||
declare
|
||||
"MYLOB" CLOB;
|
||||
begin
|
||||
gms_lob.createtemporary("MYLOB",true);
|
||||
gms_lob.open("MYLOB",gms_lob.lob_readwrite);
|
||||
"MYLOB":='foo';
|
||||
raise notice '%',"MYLOB";
|
||||
end;
|
||||
/
|
||||
|
||||
----------isopen函数-----------
|
||||
DECLARE
|
||||
v_clob clob;
|
||||
BEGIN
|
||||
gms_lob.createtemporary(v_clob, false);
|
||||
gms_lob.open(v_clob, gms_lob.LOB_READWRITE);
|
||||
gms_output.put_line('isopen: ' || gms_lob.isopen(v_clob));
|
||||
gms_lob.close(v_clob);
|
||||
gms_output.put_line('isopen: ' || gms_lob.isopen(v_clob));
|
||||
gms_lob.freetemporary(v_clob);
|
||||
END;
|
||||
/
|
||||
|
||||
-----------freetemporary函数-----------
|
||||
DECLARE
|
||||
v_clob CLOB;
|
||||
v_char VARCHAR2(100);
|
||||
BEGIN
|
||||
v_char := 'Chinese中国人';
|
||||
gms_lob.createtemporary(v_clob,TRUE,12);
|
||||
gms_lob.append(v_clob,v_char);
|
||||
gms_output.put_line(v_clob||' 字符长度:'||gms_lob.getlength(v_clob));
|
||||
gms_lob.freetemporary(v_clob);
|
||||
gms_output.put_line(' 释放后再输出:'||v_clob);
|
||||
END;
|
||||
/
|
||||
|
||||
drop table tbl_testlob;
|
||||
drop function func_clob;
|
||||
drop function func_blob;
|
||||
|
||||
declare
|
||||
lob1 clob := '123';
|
||||
lob2 clob := '456';
|
||||
lob3 clob := '789';
|
||||
begin
|
||||
gms_lob.open (lob_loc => lob1,open_mode => 1);
|
||||
gms_lob.open (lob_loc => lob2,open_mode => gms_lob.lob_readwrite);
|
||||
gms_lob.open (lob_loc => lob3,open_mode => gms_lob.lob_readonly);
|
||||
raise notice '%,%,%',lob1,lob2,lob3;
|
||||
end;
|
||||
/
|
||||
|
||||
-- 支持GMS_LOB.WRITE/READ/APPEND函数
|
||||
|
||||
-----------read函数-----------
|
||||
--gms_lob.gms_lob_read_blob
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
gms_output.put_line(r1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
-- float
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount float :=3.2;
|
||||
off_set float :=2.1;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
gms_output.put_line(r1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount float :=3.8;
|
||||
off_set float :=2.9;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
gms_output.put_line(r1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount float :=3.8;
|
||||
off_set float :=2.9;
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
gms_output.put_line(r1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=8;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
gms_output.put_line(r1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=20;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_lob.read(b1, amount, off_set, b2);
|
||||
gms_output.put_line(r1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--VALUEERROR
|
||||
--lob为空
|
||||
declare
|
||||
b1 blob;
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
end;
|
||||
/
|
||||
|
||||
--amount为空
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
amount INTEGER;
|
||||
off_set INTEGER :=9;
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
end;
|
||||
/
|
||||
|
||||
--offset为空
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER;
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob无效
|
||||
declare
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.read(cast_to_raw('111111'), amount, off_set, r1);
|
||||
end;
|
||||
/
|
||||
|
||||
--amount大于buffer大小
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
amount INTEGER :=15;
|
||||
off_set INTEGER :=2;
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
end;
|
||||
/
|
||||
|
||||
--offset超出范围
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=30;
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob只读
|
||||
declare
|
||||
b1 blob :=cast_to_raw('1111');
|
||||
amount INTEGER :=2;
|
||||
off_set INTEGER :=2;
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.open(b1, gms_lob.LOB_READONLY);
|
||||
gms_lob.read(b1, amount, off_set, r1);
|
||||
gms_output.put_line(r1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--gms_lob.gms_lob_read_clob
|
||||
declare
|
||||
c1 clob :='abcdefgh';
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=1;
|
||||
var_buf varchar2(10);
|
||||
begin
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
c1 clob :='abcdefgh';
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=9;
|
||||
var_buf varchar2(10);
|
||||
begin
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
c1 clob :='abcdefgh';
|
||||
amount INTEGER :=10;
|
||||
off_set INTEGER :=2;
|
||||
var_buf varchar2(10);
|
||||
begin
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--VALUEERROR
|
||||
--lob为空
|
||||
declare
|
||||
c1 clob;
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
var_buf varchar2(10);
|
||||
begin
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--amount为空
|
||||
declare
|
||||
c1 clob :='abcdefgh';
|
||||
amount INTEGER;
|
||||
off_set INTEGER :=1;
|
||||
var_buf varchar2(10);
|
||||
begin
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--offset为空
|
||||
declare
|
||||
c1 clob :='abcdefgh';
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER;
|
||||
var_buf varchar2(10);
|
||||
begin
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob无效
|
||||
declare
|
||||
c1 clob;
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
var_buf varchar2(10);
|
||||
begin
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--amount大于buffer大小
|
||||
declare
|
||||
c1 clob :='abcdefgh';
|
||||
amount INTEGER :=6;
|
||||
off_set INTEGER :=2;
|
||||
var_buf varchar2(3);
|
||||
begin
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--offset超出范围
|
||||
declare
|
||||
c1 clob :='abcdefgh';
|
||||
amount INTEGER :=2;
|
||||
off_set INTEGER :=0;
|
||||
var_buf varchar2(3);
|
||||
begin
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob只读
|
||||
declare
|
||||
c1 clob :='1111';
|
||||
amount INTEGER :=2;
|
||||
off_set INTEGER :=2;
|
||||
var_buf varchar2(10);
|
||||
begin
|
||||
gms_lob.open(c1, gms_lob.LOB_READONLY);
|
||||
gms_lob.read(c1, amount, off_set, var_buf);
|
||||
gms_output.put_line('clob read: ' || var_buf::text);
|
||||
end;
|
||||
/
|
||||
|
||||
-----------write函数-----------
|
||||
--gms_lob.gms_lob_write_blob
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_output.put_line(b1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=8;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_output.put_line(b1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=20;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_output.put_line(b1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--buffer等于destlob
|
||||
declare
|
||||
b1 blob :=cast_to_raw('1234');
|
||||
amount INTEGER :=2;
|
||||
off_set INTEGER :=2;
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b1);
|
||||
gms_output.put_line(b1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--VALUEERROR
|
||||
--lob为空
|
||||
declare
|
||||
b1 blob;
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--amount为空
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
amount INTEGER;
|
||||
off_set INTEGER :=9;
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
end;
|
||||
/
|
||||
--amount,offset向下取整
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount float :=3.9; -- 3
|
||||
off_set float :=5.6; -- 5
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
r1 raw;
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_output.put_line(b1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount float :=2.2; -- 2
|
||||
off_set float :=5.1; -- 5
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_output.put_line(b1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABCDEFGH');
|
||||
amount INTEGER :=4;
|
||||
off_set INTEGER :=8;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
gms_output.put_line(b1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--offset为空
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER;
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob无效
|
||||
declare
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.write(cast_to_raw('111111'), amount, off_set, b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--amount大于buffer大小
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
amount INTEGER :=5;
|
||||
off_set INTEGER :=2;
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--offset超出范围
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=0;
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob只读
|
||||
declare
|
||||
b1 blob :=cast_to_raw('1111');
|
||||
amount INTEGER :=2;
|
||||
off_set INTEGER :=2;
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.open(b1, gms_lob.LOB_READONLY);
|
||||
gms_lob.write(b1, amount, off_set, b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--gms_lob.gms_lob_write_clob
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=1;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
gms_output.put_line(c1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
-- amount, off_set 不向下取整
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
amount INTEGER :=3.9;
|
||||
off_set INTEGER :=1.8;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
gms_output.put_line(c1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=1.8;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
gms_output.put_line(c1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=9;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
gms_output.put_line(c1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=10;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
gms_output.put_line(c1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--buffer等于destlob
|
||||
declare
|
||||
c1 clob :='1234';
|
||||
amount INTEGER :=2;
|
||||
off_set INTEGER :=2;
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c1);
|
||||
gms_output.put_line(c1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--VALUEERROR
|
||||
--lob为空
|
||||
declare
|
||||
c1 clob;
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
--amount为空
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
amount INTEGER;
|
||||
off_set INTEGER :=10;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
--offset为空
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob无效
|
||||
declare
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=2;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write('11111111', amount, off_set, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
--amount大于buffer大小
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
amount INTEGER :=5;
|
||||
off_set INTEGER :=2;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
--offset超出范围
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
amount INTEGER :=2;
|
||||
off_set INTEGER :=0;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob只读
|
||||
declare
|
||||
c1 clob :='1111';
|
||||
amount INTEGER :=2;
|
||||
off_set INTEGER :=2;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.open(c1, gms_lob.LOB_READONLY);
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
-----------append函数-----------
|
||||
--gms_lob.gms_lob_append_blob
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.append(b1, b2);
|
||||
gms_output.put_line(b1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--VALUEERROR
|
||||
--destlob为空
|
||||
declare
|
||||
b1 blob;
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.append(b1, b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--srclob为空
|
||||
declare
|
||||
b1 blob :=cast_to_raw('11111111');
|
||||
b2 blob;
|
||||
begin
|
||||
gms_lob.append(b1, b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob无效
|
||||
declare
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.append(cast_to_raw('1111'), b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob只读
|
||||
declare
|
||||
b1 blob :=cast_to_raw('1111');
|
||||
b2 blob :=cast_to_raw('222');
|
||||
begin
|
||||
gms_lob.open(b1, gms_lob.LOB_READONLY);
|
||||
gms_lob.append(b1, b2);
|
||||
end;
|
||||
/
|
||||
|
||||
--gms_lob.gms_lob_append_clob
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.append(c1, c2);
|
||||
gms_output.put_line(c1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
--VALUEERROR
|
||||
--destlob为空
|
||||
declare
|
||||
c1 clob;
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.append(c1, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
--srclob为空
|
||||
declare
|
||||
c1 clob :='11111111';
|
||||
c2 clob;
|
||||
begin
|
||||
gms_lob.append(c1, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob无效
|
||||
declare
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.append('1111', c2);
|
||||
end;
|
||||
/
|
||||
|
||||
--lob只读
|
||||
declare
|
||||
c1 clob :='1111';
|
||||
c2 clob :='222';
|
||||
begin
|
||||
gms_lob.open(c1, gms_lob.LOB_READONLY);
|
||||
gms_lob.append(c1, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=cast_to_raw('ABC123');
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=100;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
c1 int;
|
||||
BEGIN
|
||||
gms_lob.write(b1,amount,off_set,b2);
|
||||
gms_output.put_line(b1::text);
|
||||
c1:=gms_lob.getlength(b1);
|
||||
gms_output.put_line(c1);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
c1 clob :='ABC123';
|
||||
amount INTEGER :=3;
|
||||
off_set INTEGER :=100;
|
||||
c2 clob :='abc';
|
||||
begin
|
||||
gms_lob.write(c1, amount, off_set, c2);
|
||||
gms_output.put_line(c1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
b1 blob :=null;
|
||||
b2 blob :=cast_to_raw('abc');
|
||||
BEGIN
|
||||
gms_lob.append(b1,b2);
|
||||
gms_output.put_line(b1::text);
|
||||
end;
|
||||
/
|
||||
|
||||
drop table if exists lob_mvcc;
|
||||
create table lob_mvcc(id int, c_lob clob, b_lob blob);
|
||||
insert into lob_mvcc values(1, 'clob', cast_to_raw('blob'));
|
||||
insert into lob_mvcc values(2, '中文clobobject测试', cast_to_raw('中文blobobject测试'));
|
||||
|
||||
select * from lob_mvcc order by id;
|
||||
|
||||
declare
|
||||
c1 clob;
|
||||
c2 clob :='222test';
|
||||
begin
|
||||
select c_lob into c1 from lob_mvcc where id=1 for update;
|
||||
gms_lob.append(c1, c2);
|
||||
end;
|
||||
/
|
||||
|
||||
select * from lob_mvcc order by id;
|
||||
drop table lob_mvcc;
|
||||
|
||||
create or replace procedure proc_1034970
|
||||
as
|
||||
b1 clob :='测试';
|
||||
b2 clob :='测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试';
|
||||
begin
|
||||
gms_lob.open(b1,gms_lob.lob_readwrite);
|
||||
for i in 1..100 loop
|
||||
gms_lob.append(b1,b2);
|
||||
end loop;
|
||||
end;
|
||||
/
|
||||
|
||||
call proc_1034970();
|
||||
drop procedure proc_1034970;
|
||||
\c contrib_regression
|
||||
drop database if exists testlob;
|
||||
|
@ -1,21 +0,0 @@
|
||||
#This is the main CMAKE for build all gms_sql.
|
||||
# gms_sql
|
||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} TGT_gms_sql_SRC)
|
||||
set(TGT_gms_sql_INC
|
||||
${PROJECT_OPENGS_DIR}/contrib/gms_sql
|
||||
${PROJECT_OPENGS_DIR}/contrib
|
||||
)
|
||||
|
||||
set(gms_sql_DEF_OPTIONS ${MACRO_OPTIONS})
|
||||
set(gms_sql_COMPILE_OPTIONS ${OPTIMIZE_OPTIONS} ${OS_OPTIONS} ${PROTECT_OPTIONS} ${WARNING_OPTIONS} ${LIB_SECURE_OPTIONS} ${CHECK_OPTIONS})
|
||||
set(gms_sql_LINK_OPTIONS ${LIB_LINK_OPTIONS})
|
||||
add_shared_libtarget(gms_sql TGT_gms_sql_SRC TGT_gms_sql_INC "${gms_sql_DEF_OPTIONS}" "${gms_sql_COMPILE_OPTIONS}" "${gms_sql_LINK_OPTIONS}")
|
||||
set_target_properties(gms_sql PROPERTIES PREFIX "")
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_sql.control
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gms_sql--1.0.sql
|
||||
DESTINATION share/postgresql/extension/
|
||||
)
|
||||
install(TARGETS gms_sql DESTINATION lib/postgresql)
|
@ -1,28 +0,0 @@
|
||||
# contrib/gms_sql/Makefile
|
||||
MODULE_big = gms_sql
|
||||
OBJS = gms_sql.o
|
||||
|
||||
EXTENSION = gms_sql
|
||||
DATA = gms_sql--1.0.sql
|
||||
|
||||
exclude_option = -fPIE
|
||||
override CPPFLAGS := -fstack-protector-strong $(filter-out $(exclude_option),$(CPPFLAGS))
|
||||
|
||||
REGRESS = gms_sql
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/gms_sql
|
||||
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_sql.o: gms_sql.cpp
|
@ -1 +0,0 @@
|
||||
The openGauss regression needs this file to run.
|
@ -1,753 +0,0 @@
|
||||
CREATE EXTENSION gms_sql;
|
||||
set gms_sql_max_open_cursor_count = 501;
|
||||
ERROR: 501 is outside the valid range for parameter "gms_sql_max_open_cursor_count" (10 .. 500)
|
||||
reset gms_sql_max_open_cursor_count;
|
||||
show gms_sql_max_open_cursor_count;
|
||||
gms_sql_max_open_cursor_count
|
||||
-------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
do $$
|
||||
declare
|
||||
c int;
|
||||
strval varchar;
|
||||
intval int;
|
||||
nrows int default 30;
|
||||
begin
|
||||
c := gms_sql.open_cursor();
|
||||
gms_sql.parse(c, 'select ''ahoj'' || i, i from generate_series(1, :nrows) g(i)', gms_sql.v6);
|
||||
gms_sql.bind_variable(c, 'nrows', nrows);
|
||||
gms_sql.define_column(c, 1, strval);
|
||||
gms_sql.define_column(c, 2, intval);
|
||||
perform gms_sql.execute(c);
|
||||
while gms_sql.fetch_rows(c) > 0
|
||||
loop
|
||||
gms_sql.column_value(c, 1, strval);
|
||||
gms_sql.column_value(c, 2, intval);
|
||||
raise notice 'c1: %, c2: %', strval, intval;
|
||||
end loop;
|
||||
gms_sql.close_cursor(c);
|
||||
end;
|
||||
$$;
|
||||
NOTICE: c1: ahoj1, c2: 1
|
||||
NOTICE: c1: ahoj2, c2: 2
|
||||
NOTICE: c1: ahoj3, c2: 3
|
||||
NOTICE: c1: ahoj4, c2: 4
|
||||
NOTICE: c1: ahoj5, c2: 5
|
||||
NOTICE: c1: ahoj6, c2: 6
|
||||
NOTICE: c1: ahoj7, c2: 7
|
||||
NOTICE: c1: ahoj8, c2: 8
|
||||
NOTICE: c1: ahoj9, c2: 9
|
||||
NOTICE: c1: ahoj10, c2: 10
|
||||
NOTICE: c1: ahoj11, c2: 11
|
||||
NOTICE: c1: ahoj12, c2: 12
|
||||
NOTICE: c1: ahoj13, c2: 13
|
||||
NOTICE: c1: ahoj14, c2: 14
|
||||
NOTICE: c1: ahoj15, c2: 15
|
||||
NOTICE: c1: ahoj16, c2: 16
|
||||
NOTICE: c1: ahoj17, c2: 17
|
||||
NOTICE: c1: ahoj18, c2: 18
|
||||
NOTICE: c1: ahoj19, c2: 19
|
||||
NOTICE: c1: ahoj20, c2: 20
|
||||
NOTICE: c1: ahoj21, c2: 21
|
||||
NOTICE: c1: ahoj22, c2: 22
|
||||
NOTICE: c1: ahoj23, c2: 23
|
||||
NOTICE: c1: ahoj24, c2: 24
|
||||
NOTICE: c1: ahoj25, c2: 25
|
||||
NOTICE: c1: ahoj26, c2: 26
|
||||
NOTICE: c1: ahoj27, c2: 27
|
||||
NOTICE: c1: ahoj28, c2: 28
|
||||
NOTICE: c1: ahoj29, c2: 29
|
||||
NOTICE: c1: ahoj30, c2: 30
|
||||
do $$
|
||||
declare
|
||||
c int;
|
||||
strval varchar;
|
||||
intval int;
|
||||
nrows int default 30;
|
||||
begin
|
||||
c := gms_sql.open_cursor();
|
||||
gms_sql.parse(c, 'select ''ahoj'' || i, i from generate_series(1, :nrows) g(i)', gms_sql.v7);
|
||||
gms_sql.bind_variable(c, 'nrows', nrows);
|
||||
gms_sql.define_column(c, 1, strval);
|
||||
gms_sql.define_column(c, 2, intval);
|
||||
perform gms_sql.execute(c);
|
||||
while gms_sql.fetch_rows(c) > 0
|
||||
loop
|
||||
strval := gms_sql.column_value_f(c, 1, strval);
|
||||
intval := gms_sql.column_value_f(c, 2, intval);
|
||||
raise notice 'c1: %, c2: %', strval, intval;
|
||||
end loop;
|
||||
gms_sql.close_cursor(c);
|
||||
end;
|
||||
$$;
|
||||
NOTICE: c1: ahoj1, c2: 1
|
||||
NOTICE: c1: ahoj2, c2: 2
|
||||
NOTICE: c1: ahoj3, c2: 3
|
||||
NOTICE: c1: ahoj4, c2: 4
|
||||
NOTICE: c1: ahoj5, c2: 5
|
||||
NOTICE: c1: ahoj6, c2: 6
|
||||
NOTICE: c1: ahoj7, c2: 7
|
||||
NOTICE: c1: ahoj8, c2: 8
|
||||
NOTICE: c1: ahoj9, c2: 9
|
||||
NOTICE: c1: ahoj10, c2: 10
|
||||
NOTICE: c1: ahoj11, c2: 11
|
||||
NOTICE: c1: ahoj12, c2: 12
|
||||
NOTICE: c1: ahoj13, c2: 13
|
||||
NOTICE: c1: ahoj14, c2: 14
|
||||
NOTICE: c1: ahoj15, c2: 15
|
||||
NOTICE: c1: ahoj16, c2: 16
|
||||
NOTICE: c1: ahoj17, c2: 17
|
||||
NOTICE: c1: ahoj18, c2: 18
|
||||
NOTICE: c1: ahoj19, c2: 19
|
||||
NOTICE: c1: ahoj20, c2: 20
|
||||
NOTICE: c1: ahoj21, c2: 21
|
||||
NOTICE: c1: ahoj22, c2: 22
|
||||
NOTICE: c1: ahoj23, c2: 23
|
||||
NOTICE: c1: ahoj24, c2: 24
|
||||
NOTICE: c1: ahoj25, c2: 25
|
||||
NOTICE: c1: ahoj26, c2: 26
|
||||
NOTICE: c1: ahoj27, c2: 27
|
||||
NOTICE: c1: ahoj28, c2: 28
|
||||
NOTICE: c1: ahoj29, c2: 29
|
||||
NOTICE: c1: ahoj30, c2: 30
|
||||
drop table if exists foo;
|
||||
NOTICE: table "foo" does not exist, skipping
|
||||
create table foo(a int, b varchar, c numeric);
|
||||
do $$
|
||||
declare c int;
|
||||
begin
|
||||
c := gms_sql.open_cursor();
|
||||
gms_sql.parse(c, 'insert into foo values(:a, :b, :c)', gms_sql.native);
|
||||
for i in 1..100
|
||||
loop
|
||||
gms_sql.bind_variable(c, 'a', i);
|
||||
gms_sql.bind_variable(c, 'b', 'Ahoj ' || i);
|
||||
gms_sql.bind_variable(c, 'c', i + 0.033);
|
||||
perform gms_sql.execute(c);
|
||||
end loop;
|
||||
gms_sql.close_cursor(c);
|
||||
end;
|
||||
$$;
|
||||
select * from foo;
|
||||
a | b | c
|
||||
-----+----------+---------
|
||||
1 | Ahoj 1 | 1.033
|
||||
2 | Ahoj 2 | 2.033
|
||||
3 | Ahoj 3 | 3.033
|
||||
4 | Ahoj 4 | 4.033
|
||||
5 | Ahoj 5 | 5.033
|
||||
6 | Ahoj 6 | 6.033
|
||||
7 | Ahoj 7 | 7.033
|
||||
8 | Ahoj 8 | 8.033
|
||||
9 | Ahoj 9 | 9.033
|
||||
10 | Ahoj 10 | 10.033
|
||||
11 | Ahoj 11 | 11.033
|
||||
12 | Ahoj 12 | 12.033
|
||||
13 | Ahoj 13 | 13.033
|
||||
14 | Ahoj 14 | 14.033
|
||||
15 | Ahoj 15 | 15.033
|
||||
16 | Ahoj 16 | 16.033
|
||||
17 | Ahoj 17 | 17.033
|
||||
18 | Ahoj 18 | 18.033
|
||||
19 | Ahoj 19 | 19.033
|
||||
20 | Ahoj 20 | 20.033
|
||||
21 | Ahoj 21 | 21.033
|
||||
22 | Ahoj 22 | 22.033
|
||||
23 | Ahoj 23 | 23.033
|
||||
24 | Ahoj 24 | 24.033
|
||||
25 | Ahoj 25 | 25.033
|
||||
26 | Ahoj 26 | 26.033
|
||||
27 | Ahoj 27 | 27.033
|
||||
28 | Ahoj 28 | 28.033
|
||||
29 | Ahoj 29 | 29.033
|
||||
30 | Ahoj 30 | 30.033
|
||||
31 | Ahoj 31 | 31.033
|
||||
32 | Ahoj 32 | 32.033
|
||||
33 | Ahoj 33 | 33.033
|
||||
34 | Ahoj 34 | 34.033
|
||||
35 | Ahoj 35 | 35.033
|
||||
36 | Ahoj 36 | 36.033
|
||||
37 | Ahoj 37 | 37.033
|
||||
38 | Ahoj 38 | 38.033
|
||||
39 | Ahoj 39 | 39.033
|
||||
40 | Ahoj 40 | 40.033
|
||||
41 | Ahoj 41 | 41.033
|
||||
42 | Ahoj 42 | 42.033
|
||||
43 | Ahoj 43 | 43.033
|
||||
44 | Ahoj 44 | 44.033
|
||||
45 | Ahoj 45 | 45.033
|
||||
46 | Ahoj 46 | 46.033
|
||||
47 | Ahoj 47 | 47.033
|
||||
48 | Ahoj 48 | 48.033
|
||||
49 | Ahoj 49 | 49.033
|
||||
50 | Ahoj 50 | 50.033
|
||||
51 | Ahoj 51 | 51.033
|
||||
52 | Ahoj 52 | 52.033
|
||||
53 | Ahoj 53 | 53.033
|
||||
54 | Ahoj 54 | 54.033
|
||||
55 | Ahoj 55 | 55.033
|
||||
56 | Ahoj 56 | 56.033
|
||||
57 | Ahoj 57 | 57.033
|
||||
58 | Ahoj 58 | 58.033
|
||||
59 | Ahoj 59 | 59.033
|
||||
60 | Ahoj 60 | 60.033
|
||||
61 | Ahoj 61 | 61.033
|
||||
62 | Ahoj 62 | 62.033
|
||||
63 | Ahoj 63 | 63.033
|
||||
64 | Ahoj 64 | 64.033
|
||||
65 | Ahoj 65 | 65.033
|
||||
66 | Ahoj 66 | 66.033
|
||||
67 | Ahoj 67 | 67.033
|
||||
68 | Ahoj 68 | 68.033
|
||||
69 | Ahoj 69 | 69.033
|
||||
70 | Ahoj 70 | 70.033
|
||||
71 | Ahoj 71 | 71.033
|
||||
72 | Ahoj 72 | 72.033
|
||||
73 | Ahoj 73 | 73.033
|
||||
74 | Ahoj 74 | 74.033
|
||||
75 | Ahoj 75 | 75.033
|
||||
76 | Ahoj 76 | 76.033
|
||||
77 | Ahoj 77 | 77.033
|
||||
78 | Ahoj 78 | 78.033
|
||||
79 | Ahoj 79 | 79.033
|
||||
80 | Ahoj 80 | 80.033
|
||||
81 | Ahoj 81 | 81.033
|
||||
82 | Ahoj 82 | 82.033
|
||||
83 | Ahoj 83 | 83.033
|
||||
84 | Ahoj 84 | 84.033
|
||||
85 | Ahoj 85 | 85.033
|
||||
86 | Ahoj 86 | 86.033
|
||||
87 | Ahoj 87 | 87.033
|
||||
88 | Ahoj 88 | 88.033
|
||||
89 | Ahoj 89 | 89.033
|
||||
90 | Ahoj 90 | 90.033
|
||||
91 | Ahoj 91 | 91.033
|
||||
92 | Ahoj 92 | 92.033
|
||||
93 | Ahoj 93 | 93.033
|
||||
94 | Ahoj 94 | 94.033
|
||||
95 | Ahoj 95 | 95.033
|
||||
96 | Ahoj 96 | 96.033
|
||||
97 | Ahoj 97 | 97.033
|
||||
98 | Ahoj 98 | 98.033
|
||||
99 | Ahoj 99 | 99.033
|
||||
100 | Ahoj 100 | 100.033
|
||||
(100 rows)
|
||||
|
||||
truncate foo;
|
||||
do $$
|
||||
declare c int;
|
||||
begin
|
||||
c := gms_sql.open_cursor();
|
||||
gms_sql.parse(c, 'insert into foo values(:a, :b, :c)', gms_sql.native);
|
||||
for i in 1..100
|
||||
loop
|
||||
gms_sql.bind_variable_f(c, 'a', i);
|
||||
gms_sql.bind_variable_f(c, 'b', 'Ahoj ' || i);
|
||||
gms_sql.bind_variable_f(c, 'c', i + 0.033);
|
||||
perform gms_sql.execute(c);
|
||||
end loop;
|
||||
gms_sql.close_cursor(c);
|
||||
end;
|
||||
$$;
|
||||
select * from foo;
|
||||
a | b | c
|
||||
-----+----------+---------
|
||||
1 | Ahoj 1 | 1.033
|
||||
2 | Ahoj 2 | 2.033
|
||||
3 | Ahoj 3 | 3.033
|
||||
4 | Ahoj 4 | 4.033
|
||||
5 | Ahoj 5 | 5.033
|
||||
6 | Ahoj 6 | 6.033
|
||||
7 | Ahoj 7 | 7.033
|
||||
8 | Ahoj 8 | 8.033
|
||||
9 | Ahoj 9 | 9.033
|
||||
10 | Ahoj 10 | 10.033
|
||||
11 | Ahoj 11 | 11.033
|
||||
12 | Ahoj 12 | 12.033
|
||||
13 | Ahoj 13 | 13.033
|
||||
14 | Ahoj 14 | 14.033
|
||||
15 | Ahoj 15 | 15.033
|
||||
16 | Ahoj 16 | 16.033
|
||||
17 | Ahoj 17 | 17.033
|
||||
18 | Ahoj 18 | 18.033
|
||||
19 | Ahoj 19 | 19.033
|
||||
20 | Ahoj 20 | 20.033
|
||||
21 | Ahoj 21 | 21.033
|
||||
22 | Ahoj 22 | 22.033
|
||||
23 | Ahoj 23 | 23.033
|
||||
24 | Ahoj 24 | 24.033
|
||||
25 | Ahoj 25 | 25.033
|
||||
26 | Ahoj 26 | 26.033
|
||||
27 | Ahoj 27 | 27.033
|
||||
28 | Ahoj 28 | 28.033
|
||||
29 | Ahoj 29 | 29.033
|
||||
30 | Ahoj 30 | 30.033
|
||||
31 | Ahoj 31 | 31.033
|
||||
32 | Ahoj 32 | 32.033
|
||||
33 | Ahoj 33 | 33.033
|
||||
34 | Ahoj 34 | 34.033
|
||||
35 | Ahoj 35 | 35.033
|
||||
36 | Ahoj 36 | 36.033
|
||||
37 | Ahoj 37 | 37.033
|
||||
38 | Ahoj 38 | 38.033
|
||||
39 | Ahoj 39 | 39.033
|
||||
40 | Ahoj 40 | 40.033
|
||||
41 | Ahoj 41 | 41.033
|
||||
42 | Ahoj 42 | 42.033
|
||||
43 | Ahoj 43 | 43.033
|
||||
44 | Ahoj 44 | 44.033
|
||||
45 | Ahoj 45 | 45.033
|
||||
46 | Ahoj 46 | 46.033
|
||||
47 | Ahoj 47 | 47.033
|
||||
48 | Ahoj 48 | 48.033
|
||||
49 | Ahoj 49 | 49.033
|
||||
50 | Ahoj 50 | 50.033
|
||||
51 | Ahoj 51 | 51.033
|
||||
52 | Ahoj 52 | 52.033
|
||||
53 | Ahoj 53 | 53.033
|
||||
54 | Ahoj 54 | 54.033
|
||||
55 | Ahoj 55 | 55.033
|
||||
56 | Ahoj 56 | 56.033
|
||||
57 | Ahoj 57 | 57.033
|
||||
58 | Ahoj 58 | 58.033
|
||||
59 | Ahoj 59 | 59.033
|
||||
60 | Ahoj 60 | 60.033
|
||||
61 | Ahoj 61 | 61.033
|
||||
62 | Ahoj 62 | 62.033
|
||||
63 | Ahoj 63 | 63.033
|
||||
64 | Ahoj 64 | 64.033
|
||||
65 | Ahoj 65 | 65.033
|
||||
66 | Ahoj 66 | 66.033
|
||||
67 | Ahoj 67 | 67.033
|
||||
68 | Ahoj 68 | 68.033
|
||||
69 | Ahoj 69 | 69.033
|
||||
70 | Ahoj 70 | 70.033
|
||||
71 | Ahoj 71 | 71.033
|
||||
72 | Ahoj 72 | 72.033
|
||||
73 | Ahoj 73 | 73.033
|
||||
74 | Ahoj 74 | 74.033
|
||||
75 | Ahoj 75 | 75.033
|
||||
76 | Ahoj 76 | 76.033
|
||||
77 | Ahoj 77 | 77.033
|
||||
78 | Ahoj 78 | 78.033
|
||||
79 | Ahoj 79 | 79.033
|
||||
80 | Ahoj 80 | 80.033
|
||||
81 | Ahoj 81 | 81.033
|
||||
82 | Ahoj 82 | 82.033
|
||||
83 | Ahoj 83 | 83.033
|
||||
84 | Ahoj 84 | 84.033
|
||||
85 | Ahoj 85 | 85.033
|
||||
86 | Ahoj 86 | 86.033
|
||||
87 | Ahoj 87 | 87.033
|
||||
88 | Ahoj 88 | 88.033
|
||||
89 | Ahoj 89 | 89.033
|
||||
90 | Ahoj 90 | 90.033
|
||||
91 | Ahoj 91 | 91.033
|
||||
92 | Ahoj 92 | 92.033
|
||||
93 | Ahoj 93 | 93.033
|
||||
94 | Ahoj 94 | 94.033
|
||||
95 | Ahoj 95 | 95.033
|
||||
96 | Ahoj 96 | 96.033
|
||||
97 | Ahoj 97 | 97.033
|
||||
98 | Ahoj 98 | 98.033
|
||||
99 | Ahoj 99 | 99.033
|
||||
100 | Ahoj 100 | 100.033
|
||||
(100 rows)
|
||||
|
||||
truncate foo;
|
||||
do $$
|
||||
declare
|
||||
c int;
|
||||
a int[];
|
||||
b varchar[];
|
||||
ca numeric[];
|
||||
begin
|
||||
c := gms_sql.open_cursor();
|
||||
gms_sql.parse(c, 'insert into foo values(:a, :b, :c)', gms_sql.v6);
|
||||
a := ARRAY[1, 2, 3, 4, 5];
|
||||
b := ARRAY['Ahoj', 'Nazdar', 'Bazar'];
|
||||
ca := ARRAY[3.14, 2.22, 3.8, 4];
|
||||
|
||||
perform gms_sql.bind_array(c, 'a', a);
|
||||
perform gms_sql.bind_array(c, 'b', b);
|
||||
perform gms_sql.bind_array(c, 'c', ca);
|
||||
raise notice 'inserted rows %d', gms_sql.execute(c);
|
||||
gms_sql.close_cursor(c);
|
||||
end;
|
||||
$$;
|
||||
NOTICE: inserted rows 3d
|
||||
select * from foo;
|
||||
a | b | c
|
||||
---+--------+------
|
||||
1 | Ahoj | 3.14
|
||||
2 | Nazdar | 2.22
|
||||
3 | Bazar | 3.8
|
||||
(3 rows)
|
||||
|
||||
truncate foo;
|
||||
do $$
|
||||
declare
|
||||
c int;
|
||||
a int[];
|
||||
b varchar[];
|
||||
ca numeric[];
|
||||
begin
|
||||
c := gms_sql.open_cursor();
|
||||
gms_sql.parse(c, 'insert into foo values(:a, :b, :c)', gms_sql.v7);
|
||||
a := ARRAY[1, 2, 3, 4, 5];
|
||||
b := ARRAY['Ahoj', 'Nazdar', 'Bazar'];
|
||||
ca := ARRAY[3.14, 2.22, 3.8, 4];
|
||||
|
||||
perform gms_sql.bind_array(c, 'a', a, 2, 3);
|
||||
perform gms_sql.bind_array(c, 'b', b, 3, 4);
|
||||
perform gms_sql.bind_array(c, 'c', ca);
|
||||
raise notice 'inserted rows %d', gms_sql.execute(c);
|
||||
gms_sql.close_cursor(c);
|
||||
end;
|
||||
$$;
|
||||
NOTICE: inserted rows 1d
|
||||
select * from foo;
|
||||
a | b | c
|
||||
---+-------+-----
|
||||
3 | Bazar | 3.8
|
||||
(1 row)
|
||||
|
||||
truncate foo;
|
||||
do $$
|
||||
declare
|
||||
c int;
|
||||
a int[];
|
||||
b varchar[];
|
||||
ca numeric[];
|
||||
begin
|
||||
c := gms_sql.open_cursor();
|
||||
gms_sql.parse(c, 'select i, ''Ahoj'' || i, i + 0.003 from generate_series(1, 35) g(i)', 0);
|
||||
gms_sql.define_array(c, 1, a, 10, 1);
|
||||
gms_sql.define_array(c, 2, b, 10, 1);
|
||||
gms_sql.define_array(c, 3, ca, 10, 1);
|
||||
|
||||
perform gms_sql.execute(c);
|
||||
while gms_sql.fetch_rows(c) > 0
|
||||
loop
|
||||
gms_sql.column_value(c, 1, a);
|
||||
gms_sql.column_value(c, 2, b);
|
||||
gms_sql.column_value(c, 3, ca);
|
||||
raise notice 'a = %', a;
|
||||
raise notice 'b = %', b;
|
||||
raise notice 'c = %', ca;
|
||||
end loop;
|
||||
gms_sql.close_cursor(c);
|
||||
end;
|
||||
$$;
|
||||
NOTICE: a = {1,2,3,4,5,6,7,8,9,10}
|
||||
NOTICE: b = {Ahoj1,Ahoj2,Ahoj3,Ahoj4,Ahoj5,Ahoj6,Ahoj7,Ahoj8,Ahoj9,Ahoj10}
|
||||
NOTICE: c = {1.003,2.003,3.003,4.003,5.003,6.003,7.003,8.003,9.003,10.003}
|
||||
NOTICE: a = {11,12,13,14,15,16,17,18,19,20}
|
||||
NOTICE: b = {Ahoj11,Ahoj12,Ahoj13,Ahoj14,Ahoj15,Ahoj16,Ahoj17,Ahoj18,Ahoj19,Ahoj20}
|
||||
NOTICE: c = {11.003,12.003,13.003,14.003,15.003,16.003,17.003,18.003,19.003,20.003}
|
||||
NOTICE: a = {21,22,23,24,25,26,27,28,29,30}
|
||||
NOTICE: b = {Ahoj21,Ahoj22,Ahoj23,Ahoj24,Ahoj25,Ahoj26,Ahoj27,Ahoj28,Ahoj29,Ahoj30}
|
||||
NOTICE: c = {21.003,22.003,23.003,24.003,25.003,26.003,27.003,28.003,29.003,30.003}
|
||||
NOTICE: a = {31,32,33,34,35}
|
||||
NOTICE: b = {Ahoj31,Ahoj32,Ahoj33,Ahoj34,Ahoj35}
|
||||
NOTICE: c = {31.003,32.003,33.003,34.003,35.003}
|
||||
drop table foo;
|
||||
do $$
|
||||
declare
|
||||
l_curid int;
|
||||
l_cnt int;
|
||||
l_desctab gms_sql.desc_tab;
|
||||
l_sqltext varchar(2000);
|
||||
begin
|
||||
l_sqltext='select * from pg_object;';
|
||||
l_curid := gms_sql.open_cursor();
|
||||
gms_sql.parse(l_curid, l_sqltext, 0);
|
||||
gms_sql.describe_columns(l_curid, l_cnt, l_desctab);
|
||||
for i in 1 .. l_desctab.count loop
|
||||
raise notice '%,% ', l_desctab(i).col_name,l_desctab(i).col_type;
|
||||
end loop;
|
||||
gms_sql.close_cursor(l_curid);
|
||||
end;
|
||||
$$;
|
||||
NOTICE: object_oid,109
|
||||
NOTICE: object_type,96
|
||||
NOTICE: creator,109
|
||||
NOTICE: ctime,181
|
||||
NOTICE: mtime,181
|
||||
NOTICE: createcsn,2
|
||||
NOTICE: changecsn,2
|
||||
NOTICE: valid,109
|
||||
create table t1(id int, name varchar(20));
|
||||
insert into t1 select generate_series(1,3), 'abcddd';
|
||||
create table t2(a int, b date);
|
||||
insert into t2 values(1, '2022-12-11 10:00:01.123');
|
||||
insert into t2 values(3, '2022-12-12 12:00:11.13');
|
||||
do $$
|
||||
declare
|
||||
c1 refcursor;
|
||||
c2 refcursor;
|
||||
begin
|
||||
open c1 for select * from t1;
|
||||
gms_sql.return_result(c1);
|
||||
open c2 for select * from t2;
|
||||
gms_sql.return_result(c2);
|
||||
end;
|
||||
$$;
|
||||
ResultSet #1
|
||||
|
||||
id | name
|
||||
----+--------
|
||||
1 | abcddd
|
||||
2 | abcddd
|
||||
3 | abcddd
|
||||
(3 rows)
|
||||
|
||||
ResultSet #2
|
||||
|
||||
a | b
|
||||
---+--------------------------
|
||||
1 | Sun Dec 11 10:00:01 2022
|
||||
3 | Mon Dec 12 12:00:11 2022
|
||||
(2 rows)
|
||||
|
||||
create procedure test_result() as
|
||||
declare
|
||||
c1 refcursor;
|
||||
c2 refcursor;
|
||||
begin
|
||||
open c1 for select * from t1;
|
||||
gms_sql.return_result(c1);
|
||||
open c2 for select * from t2;
|
||||
gms_sql.return_result(c2);
|
||||
end;
|
||||
/
|
||||
call test_result();
|
||||
ResultSet #1
|
||||
|
||||
id | name
|
||||
----+--------
|
||||
1 | abcddd
|
||||
2 | abcddd
|
||||
3 | abcddd
|
||||
(3 rows)
|
||||
|
||||
ResultSet #2
|
||||
|
||||
a | b
|
||||
---+--------------------------
|
||||
1 | Sun Dec 11 10:00:01 2022
|
||||
3 | Mon Dec 12 12:00:11 2022
|
||||
(2 rows)
|
||||
|
||||
test_result
|
||||
-------------
|
||||
|
||||
(1 row)
|
||||
|
||||
drop procedure test_result;
|
||||
create procedure aam() as
|
||||
declare
|
||||
id1 int;
|
||||
id2 int;
|
||||
begin
|
||||
id1 :=gms_sql.open_cursor();
|
||||
gms_sql.parse(id1,'select * from t1', 1);
|
||||
perform gms_sql.execute(id1);
|
||||
gms_sql.return_result(id1);
|
||||
gms_sql.close_cursor(id1);
|
||||
id2 :=gms_sql.open_cursor();
|
||||
gms_sql.parse(id2,'select * from t2', 2);
|
||||
perform gms_sql.execute(id2);
|
||||
gms_sql.return_result(id2);
|
||||
gms_sql.close_cursor(id2);
|
||||
end;
|
||||
/
|
||||
call aam();
|
||||
ResultSet #1
|
||||
|
||||
id | name
|
||||
----+--------
|
||||
1 | abcddd
|
||||
2 | abcddd
|
||||
3 | abcddd
|
||||
(3 rows)
|
||||
|
||||
ResultSet #2
|
||||
|
||||
a | b
|
||||
---+--------------------------
|
||||
1 | Sun Dec 11 10:00:01 2022
|
||||
3 | Mon Dec 12 12:00:11 2022
|
||||
(2 rows)
|
||||
|
||||
aam
|
||||
-----
|
||||
|
||||
(1 row)
|
||||
|
||||
drop procedure aam;
|
||||
create table col_name_too_long(aaaaabbbbbcccccdddddeeeeefffffggg int, col2 text);
|
||||
do $$
|
||||
declare
|
||||
l_curid int;
|
||||
l_cnt int;
|
||||
l_desctab gms_sql.desc_tab;
|
||||
l_desctab2 gms_sql.desc_tab2;
|
||||
l_sqltext varchar(2000);
|
||||
begin
|
||||
l_sqltext='select * from t1;';
|
||||
l_curid := gms_sql.open_cursor();
|
||||
gms_sql.parse(l_curid, l_sqltext, 1);
|
||||
gms_sql.describe_columns(l_curid, l_cnt, l_desctab);
|
||||
for i in 1 .. l_desctab.count loop
|
||||
raise notice '%', l_desctab(i).col_name;
|
||||
end loop;
|
||||
-- output col_name
|
||||
l_sqltext='select * from col_name_too_long;';
|
||||
gms_sql.parse(l_curid, l_sqltext, 1);
|
||||
gms_sql.describe_columns2(l_curid, l_cnt, l_desctab2);
|
||||
for i in 1 .. l_desctab2.count loop
|
||||
raise notice '%', l_desctab2(i).col_name;
|
||||
end loop;
|
||||
-- error
|
||||
l_sqltext='select * from col_name_too_long;';
|
||||
gms_sql.parse(l_curid, l_sqltext, 1);
|
||||
gms_sql.describe_columns(l_curid, l_cnt, l_desctab);
|
||||
for i in 1 .. l_desctab.count loop
|
||||
raise notice '%', l_desctab(i).col_name;
|
||||
end loop;
|
||||
end;
|
||||
$$;
|
||||
NOTICE: id
|
||||
NOTICE: name
|
||||
NOTICE: aaaaabbbbbcccccdddddeeeeefffffggg
|
||||
NOTICE: col2
|
||||
ERROR: desc_rec.col_name(33) is more than 32
|
||||
CONTEXT: SQL statement "CALL gms_sql.describe_columns(l_curid,l_cnt,l_desctab)"
|
||||
PL/pgSQL function inline_code_block line 26 at SQL statement
|
||||
select gms_sql.is_open(0);
|
||||
is_open
|
||||
---------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
select gms_sql.close_cursor(0);
|
||||
close_cursor
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
do $$
|
||||
declare
|
||||
l_curid int;
|
||||
l_cnt int;
|
||||
l_desctab3 gms_sql.desc_tab3;
|
||||
l_desctab4 gms_sql.desc_tab4;
|
||||
l_sqltext varchar(2000);
|
||||
begin
|
||||
l_sqltext='select * from col_name_too_long;';
|
||||
l_curid := gms_sql.open_cursor();
|
||||
gms_sql.parse(l_curid, l_sqltext, 1);
|
||||
gms_sql.describe_columns3(l_curid, l_cnt, l_desctab3);
|
||||
for i in 1 .. l_desctab3.count loop
|
||||
raise notice '%,%,%', l_desctab3(i).col_type,l_desctab3(i).col_type_name,l_desctab3(i).col_name;
|
||||
end loop;
|
||||
gms_sql.parse(l_curid, l_sqltext, 1);
|
||||
gms_sql.describe_columns3(l_curid, l_cnt, l_desctab4);
|
||||
for i in 1 .. l_desctab4.count loop
|
||||
raise notice '%,%,%,%', l_desctab3(i).col_type,l_desctab4(i).col_type_name,l_desctab4(i).col_type_name_len,l_desctab4(i).col_name_len;
|
||||
end loop;
|
||||
gms_sql.close_cursor(l_curid);
|
||||
end;
|
||||
$$;
|
||||
NOTICE: 2,<NULL>,aaaaabbbbbcccccdddddeeeeefffffggg
|
||||
NOTICE: 109,text,col2
|
||||
NOTICE: 2,<NULL>,<NULL>,33
|
||||
NOTICE: 109,text,4,4
|
||||
drop table t1,t2, col_name_too_long;
|
||||
select gms_sql.open_cursor();
|
||||
open_cursor
|
||||
-------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
select gms_sql.is_open(0);
|
||||
is_open
|
||||
---------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
select gms_sql.open_cursor();
|
||||
open_cursor
|
||||
-------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
select gms_sql.is_open(1);
|
||||
is_open
|
||||
---------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
select gms_sql.open_cursor();
|
||||
open_cursor
|
||||
-------------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
select gms_sql.is_open(2);
|
||||
is_open
|
||||
---------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
select gms_sql.open_cursor();
|
||||
open_cursor
|
||||
-------------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
select gms_sql.is_open(3);
|
||||
is_open
|
||||
---------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
select gms_sql.close_cursor(0);
|
||||
close_cursor
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_sql.close_cursor(1);
|
||||
close_cursor
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_sql.close_cursor(2);
|
||||
close_cursor
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_sql.close_cursor(3);
|
||||
close_cursor
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select gms_sql.is_open(3);
|
||||
is_open
|
||||
---------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
select gms_sql.close_cursor(10000);
|
||||
ERROR: cursor 10000 value of cursor id is out of range
|
||||
CONTEXT: referenced column: close_cursor
|
||||
select gms_sql.close_cursor(-1);
|
||||
ERROR: cursor -1 value of cursor id is out of range
|
||||
CONTEXT: referenced column: close_cursor
|
@ -1,117 +0,0 @@
|
||||
/* contrib/gms_sql/gms_sql--1.0.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION gms_sql" to load this file. \quit
|
||||
|
||||
-- gms_sql package begin
|
||||
-- gms_sql schema
|
||||
CREATE SCHEMA gms_sql;
|
||||
GRANT USAGE ON SCHEMA gms_sql TO PUBLIC;
|
||||
CREATE FUNCTION gms_sql.is_open(c int) RETURNS bool AS 'MODULE_PATHNAME', 'gms_sql_is_open' LANGUAGE c STABLE NOT FENCED;
|
||||
CREATE FUNCTION gms_sql.open_cursor() RETURNS int AS 'MODULE_PATHNAME', 'gms_sql_open_cursor' LANGUAGE c STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.close_cursor(c int) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_close_cursor' STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.debug_cursor(c int) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_debug_cursor' STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.parse(c int, stmt varchar2, ver int) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_parse' STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.bind_variable(c int, name varchar2, value "any") LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_bind_variable' STABLE NOT FENCED;
|
||||
CREATE FUNCTION gms_sql.bind_variable_f(c int, name varchar2, value "any") RETURNS void AS 'MODULE_PATHNAME', 'gms_sql_bind_variable_f' LANGUAGE c STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.bind_array(c int, name varchar2, value anyarray) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_bind_array_3' package STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.bind_array(c int, name varchar2, value anyarray, index1 int, index2 int) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_bind_array_5' package STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.define_column(c int, col int, value "any", column_size int DEFAULT -1) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_define_column' STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.define_array(c int, col int, value "anyarray", cnt int, lower_bnd int) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_define_array' STABLE NOT FENCED;
|
||||
CREATE FUNCTION gms_sql.execute(c int) RETURNS bigint AS 'MODULE_PATHNAME', 'gms_sql_execute' LANGUAGE c STABLE NOT FENCED;
|
||||
CREATE FUNCTION gms_sql.fetch_rows(c int) RETURNS int AS 'MODULE_PATHNAME', 'gms_sql_fetch_rows' LANGUAGE c STABLE NOT FENCED;
|
||||
CREATE FUNCTION gms_sql.execute_and_fetch(c int, exact bool DEFAULT false) RETURNS int AS 'MODULE_PATHNAME', 'gms_sql_execute_and_fetch' LANGUAGE c STABLE NOT FENCED;
|
||||
CREATE FUNCTION gms_sql.last_row_count() RETURNS int AS 'MODULE_PATHNAME', 'gms_sql_last_row_count' LANGUAGE c STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.column_value(c int, pos int, INOUT value anyelement) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_column_value' STABLE NOT FENCED;
|
||||
CREATE FUNCTION gms_sql.column_value_f(c int, pos int, value anyelement) RETURNS anyelement AS 'MODULE_PATHNAME', 'gms_sql_column_value_f' LANGUAGE c STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.return_result(c refcursor, to_client bool DEFAULT false) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_return_result' PACKAGE STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.return_result(c int, to_client bool DEFAULT false) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_return_result_i' PACKAGE STABLE NOT FENCED;
|
||||
CREATE FUNCTION gms_sql.v6() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 0;
|
||||
END;
|
||||
$$ language plpgsql;
|
||||
|
||||
CREATE FUNCTION gms_sql.native() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 1;
|
||||
END;
|
||||
$$ language plpgsql;
|
||||
|
||||
CREATE FUNCTION gms_sql.v7() RETURNS int AS $$
|
||||
BEGIN
|
||||
return 2;
|
||||
END;
|
||||
$$ language plpgsql;
|
||||
|
||||
CREATE TYPE gms_sql.desc_rec AS (
|
||||
col_type int,
|
||||
col_max_len int,
|
||||
col_name varchar2(32),
|
||||
col_name_len int,
|
||||
col_schema_name text,
|
||||
col_schema_name_len int,
|
||||
col_precision int,
|
||||
col_scale int,
|
||||
col_charsetid int,
|
||||
col_charsetform int,
|
||||
col_null_ok boolean);
|
||||
CREATE TYPE gms_sql.desc_rec2 AS (
|
||||
col_type int,
|
||||
col_max_len int,
|
||||
col_name text,
|
||||
col_name_len int,
|
||||
col_schema_name text,
|
||||
col_schema_name_len int,
|
||||
col_precision int,
|
||||
col_scale int,
|
||||
col_charsetid int,
|
||||
col_charsetform int,
|
||||
col_null_ok boolean);
|
||||
CREATE TYPE gms_sql.desc_rec3 AS (
|
||||
col_type int,
|
||||
col_max_len int,
|
||||
col_name text,
|
||||
col_name_len int,
|
||||
col_schema_name text,
|
||||
col_schema_name_len int,
|
||||
col_precision int,
|
||||
col_scale int,
|
||||
col_charsetid int,
|
||||
col_charsetform int,
|
||||
col_null_ok boolean,
|
||||
col_type_name text,
|
||||
col_type_name_len int);
|
||||
CREATE TYPE gms_sql.desc_rec4 AS (
|
||||
col_type int,
|
||||
col_max_len int,
|
||||
col_name text,
|
||||
col_name_len int,
|
||||
col_schema_name text,
|
||||
col_schema_name_len int,
|
||||
col_precision int,
|
||||
col_scale int,
|
||||
col_charsetid int,
|
||||
col_charsetform int,
|
||||
col_null_ok boolean,
|
||||
col_type_name text,
|
||||
col_type_name_len int);
|
||||
|
||||
|
||||
CREATE TYPE gms_sql.desc_tab IS TABLE OF gms_sql.desc_rec;
|
||||
CREATE TYPE gms_sql.desc_tab2 IS TABLE OF gms_sql.desc_rec2;
|
||||
CREATE TYPE gms_sql.desc_tab3 IS TABLE OF gms_sql.desc_rec3;
|
||||
CREATE TYPE gms_sql.desc_tab4 IS TABLE OF gms_sql.desc_rec4;
|
||||
CREATE TYPE gms_sql.number_table IS TABLE OF number;
|
||||
CREATE TYPE gms_sql.varchar2_table IS TABLE OF varchar2;
|
||||
CREATE TYPE gms_sql.date_table IS TABLE OF date;
|
||||
CREATE TYPE gms_sql.blob_table IS TABLE OF blob;
|
||||
CREATE TYPE gms_sql.clob_table IS TABLE OF clob;
|
||||
CREATE TYPE gms_sql.binary_double_table IS TABLE OF number;
|
||||
|
||||
CREATE FUNCTION gms_sql.describe_columns_f(c int, OUT col_cnt int, OUT desc_t gms_sql.desc_rec3[]) AS 'MODULE_PATHNAME', 'gms_sql_describe_columns_f' LANGUAGE c STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.describe_columns(c int, INOUT col_cnt int, INOUT desc_t gms_sql.desc_rec[]) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_describe_columns_f' STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.describe_columns2(c int, INOUT col_cnt int, INOUT desc_t gms_sql.desc_rec2[]) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_describe_columns_f' STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.describe_columns3(c int, INOUT col_cnt int, INOUT desc_t gms_sql.desc_rec3[]) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_describe_columns_f' PACKAGE STABLE NOT FENCED;
|
||||
CREATE PROCEDURE gms_sql.describe_columns3(c int, INOUT col_cnt int, INOUT desc_t gms_sql.desc_rec4[]) LANGUAGE c AS 'MODULE_PATHNAME', 'gms_sql_describe_columns_f' PACKAGE STABLE NOT FENCED;
|
||||
-- gms_sql package end
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user