first commit for openGauss server
This commit is contained in:
23
.gitee/ISSUE_TEMPLATE.en.md
Normal file
23
.gitee/ISSUE_TEMPLATE.en.md
Normal file
@ -0,0 +1,23 @@
|
||||
**Is this a BUG REPORT or FEATURE REQUEST?**:
|
||||
|
||||
> Uncomment only one, leave it on its own line:
|
||||
>
|
||||
> - bug
|
||||
>
|
||||
> - feature
|
||||
|
||||
|
||||
**What happened**:
|
||||
|
||||
**What you expected to happen**:
|
||||
|
||||
**How to reproduce it (as minimally and precisely as possible)**:
|
||||
|
||||
**Anything else we need to know?**:
|
||||
|
||||
**Environment**:
|
||||
- Version:
|
||||
- OS (e.g. from /etc/os-release):
|
||||
- Kernel (e.g. `uname -a`):
|
||||
- Install tools:
|
||||
- Others:
|
||||
15
.gitee/PULL_REQUEST_TEMPLATE.en.md
Normal file
15
.gitee/PULL_REQUEST_TEMPLATE.en.md
Normal file
@ -0,0 +1,15 @@
|
||||
<!-- Thanks for sending a pull request! -->
|
||||
|
||||
**What this PR does / why we need it**:
|
||||
|
||||
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
|
||||
|
||||
**Special notes for your reviewer**:
|
||||
|
||||
**Release note**:
|
||||
<!-- Steps to write your release note:
|
||||
1. Use the release-note-* labels to set the release note state (if you have access)
|
||||
2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`.
|
||||
-->
|
||||
```release-note
|
||||
```
|
||||
76
CONTRIBUTING.md
Normal file
76
CONTRIBUTING.md
Normal file
@ -0,0 +1,76 @@
|
||||
# How to contribute
|
||||
|
||||
## Report issues
|
||||
|
||||
A great way to contribute to the project is to send a detailed report when you encounter an issue. We always appreciate a well-written, thorough bug report and feature propose, and will appreciate you for it!
|
||||
|
||||
### Issues format
|
||||
|
||||
When reporting issues, refer to this format:
|
||||
|
||||
- Is this a BUG REPORT or FEATURE REQUEST?
|
||||
- What happened?
|
||||
- What you expected to happen?
|
||||
- What happened?
|
||||
- How to reproduce it (as minimally and precisely as possible)
|
||||
- Anything else we need to know?
|
||||
- Environment
|
||||
|
||||
See more about [ISSUE_TEMPLATE](.gitee/ISSUE_TEMPLATE.en.md).
|
||||
|
||||
## Submit pull requests
|
||||
|
||||
If you are a beginner and expect this project as the gate to open source world, this tutorial is one of the best choices for you. Just follow the guidance and you will find the pleasure to become a contributor.
|
||||
|
||||
### Step 1: Fork repository
|
||||
|
||||
Before making modifications of this project, you need to make sure that this project have been forked to your own
|
||||
repository. It means that there will be parallel development between this repo and your own repo, so be careful
|
||||
to avoid the inconsistency between these two repos.
|
||||
|
||||
### Step 2: Clone the remote repository
|
||||
|
||||
If you want to download the code to the local machine, ```git``` is the best way:
|
||||
```
|
||||
git clone https://your_repo_url/community.git
|
||||
```
|
||||
|
||||
### Step 3: Develop code locally
|
||||
|
||||
To avoid inconsistency between multiple branches, we SUGGEST checking out to a new branch:
|
||||
```
|
||||
git checkout -b new_branch_name origin/master
|
||||
```
|
||||
Then you can change the code arbitrarily.
|
||||
|
||||
### Step 4: Push the code to the remote repository
|
||||
|
||||
After updating the code, you should push the update in the formal way:
|
||||
```
|
||||
git add .
|
||||
git status (Check the update status)
|
||||
git commit -m "Your commit description"
|
||||
git commit --amend (Add the concrete description of your commit)
|
||||
git push origin new_branch_name
|
||||
```
|
||||
|
||||
### Step 5: Pull a request to repository
|
||||
|
||||
In the last step, your need to pull a compare request between your new branch and development branch. After
|
||||
finishing the pull request, the CI will be automatically set up for building test.
|
||||
|
||||
### Pull requests format
|
||||
|
||||
When submitting pull requests, refer to this format:
|
||||
|
||||
- What this PR does / why we need it?
|
||||
- Which issue this PR fixes?
|
||||
- Special notes for your reviewer
|
||||
- Release note
|
||||
|
||||
See more about [PULL_REQUEST_TEMPLATE](.gitee/PULL_REQUEST_TEMPLATE.en.md).
|
||||
|
||||
### Code style
|
||||
|
||||
```TO BE DEFINED```
|
||||
|
||||
52
COPYRIGHT
Normal file
52
COPYRIGHT
Normal file
@ -0,0 +1,52 @@
|
||||
Portions Copyright (c) 2020 Huawei Technologies Co.,Ltd.
|
||||
|
||||
openGauss is a database licensed under Mulan PSL v2 (see LICENSE),
|
||||
which is developed by Huawei and based on the Postgres-XC Cluster Database Management System.
|
||||
|
||||
Postgres-XC Cluster Database Management System
|
||||
|
||||
Portions Copyright (c) 2010-2013, Postgres-XC Development Group
|
||||
Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
|
||||
|
||||
Portions Copyright (c) 1994, The Regents of the University of California
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose, without fee, and without a written agreement
|
||||
is hereby granted, provided that the above copyright notice and this
|
||||
paragraph and the following two paragraphs appear in all copies.
|
||||
|
||||
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
||||
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
|
||||
IN NO EVENT SHALL POSTGRESQL GLOBAL DEVELOPMENT GROUP BE LIABLE TO ANY
|
||||
PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS
|
||||
SOFTWARE AND ITS DOCUMENTATION, EVEN IF POSTGRESQL GLOBAL DEVELOPMENT
|
||||
GROUP HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
POSTGRESQL GLOBAL DEVELOPMENT GROUP SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE POSTGRESQL GLOBAL DEVELOPMENT GROUP HAS NO OBLIGATIONS TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
|
||||
IN NO EVENT SHALL POSTGRES-XC DEVELOPMENT GROUP BE LIABLE TO ANY
|
||||
PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS
|
||||
SOFTWARE AND ITS DOCUMENTATION, EVEN IF POSTGRES-XC DEVELOPMENT
|
||||
GROUP HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
POSTGRES-XC DEVELOPMENT GROUP SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE POSTGRES-XC DEVELOPMENT GROUP HAS NO OBLIGATIONS TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
229
GNUmakefile.in
Normal file
229
GNUmakefile.in
Normal file
@ -0,0 +1,229 @@
|
||||
#
|
||||
# PostgreSQL top level makefile
|
||||
#
|
||||
# GNUmakefile.in
|
||||
#
|
||||
|
||||
subdir =
|
||||
top_builddir = .
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
$(call recurse,all install,src config)
|
||||
|
||||
all:
|
||||
+@echo "All of openGauss successfully made. Ready to install."
|
||||
|
||||
docs:
|
||||
$(MAKE) -C doc all
|
||||
|
||||
$(call recurse,world,doc src config contrib,all)
|
||||
world:
|
||||
+@echo "openGauss, contrib, and documentation successfully made. Ready to install."
|
||||
|
||||
# build src/ before contrib/
|
||||
world-contrib-recurse: world-src-recurse
|
||||
|
||||
html man:
|
||||
$(MAKE) -C doc $@
|
||||
|
||||
ifeq ($(enable_multiple_nodes), yes)
|
||||
install:
|
||||
$(MAKE) -C contrib/hstore $@
|
||||
$(MAKE) -C src/distribute/kernel/extension/packages $@
|
||||
$(MAKE) -C contrib/pagehack $@
|
||||
$(MAKE) -C contrib/pg_xlogdump $@
|
||||
$(MAKE) -C contrib/gsredistribute $@
|
||||
$(MAKE) -C src/distribute/kernel/extension/dimsearch $@
|
||||
$(MAKE) -C src/distribute/kernel/extension/tsdb $@
|
||||
+@echo "PostgreSQL installation complete."
|
||||
else
|
||||
install:
|
||||
+@echo "openGauss installation complete."
|
||||
endif
|
||||
|
||||
install-docs:
|
||||
$(MAKE) -C doc install
|
||||
|
||||
$(call recurse,install-world,,doc src config contrib,install)
|
||||
install-world:
|
||||
+@echo "openGauss, contrib, and documentation installation complete."
|
||||
|
||||
# build src/ before contrib/
|
||||
install-world-contrib-recurse: install-world-src-recurse
|
||||
|
||||
$(call recurse,installdirs uninstall coverage,doc src config)
|
||||
|
||||
$(call recurse,distprep,doc src config contrib)
|
||||
|
||||
# clean, distclean, etc should apply to contrib too, even though
|
||||
# it's not built by default
|
||||
$(call recurse,clean,doc contrib src config)
|
||||
clean:
|
||||
# Garbage from autoconf:
|
||||
@rm -rf autom4te.cache/
|
||||
|
||||
# Important: distclean `src' last, otherwise Makefile.global
|
||||
# will be gone too soon.
|
||||
distclean maintainer-clean:
|
||||
$(MAKE) -C doc $@
|
||||
$(MAKE) -C contrib $@
|
||||
$(MAKE) -C config $@
|
||||
$(MAKE) -C src $@
|
||||
rm -f config.cache config.log config.status GNUmakefile
|
||||
# Garbage from autoconf:
|
||||
@rm -rf autom4te.cache/
|
||||
|
||||
check: all
|
||||
|
||||
fastcheck: all
|
||||
|
||||
ifeq ($(enable_multiple_nodes), yes)
|
||||
fastcheck_inplace: all
|
||||
|
||||
fastcheck_parallel_initdb: all
|
||||
|
||||
qunitcheck: all
|
||||
|
||||
fastcheck_single: all
|
||||
|
||||
fastcheck_single_mot: all
|
||||
|
||||
redocheck: all
|
||||
|
||||
redochecksmall: all
|
||||
|
||||
redischeck: all
|
||||
|
||||
dfsredischeck: all
|
||||
|
||||
orccheckxian: all
|
||||
|
||||
orccheckusa: all
|
||||
|
||||
orcchecksmall: all
|
||||
|
||||
dfscheck: all
|
||||
|
||||
obscheck: all
|
||||
|
||||
obsorccheck: all
|
||||
|
||||
securitycheck: all
|
||||
|
||||
parquetchecksmall: all
|
||||
|
||||
check fastcheck fastcheck_inplace fastcheck_parallel_initdb qunitcheck redischeck redocheck redochecksmall orccheckxian orccheckusa orcchecksmall parquetchecksmall dfscheck obscheck obsorccheck securitycheck dfsredischeck installcheck installcheck-parallel 2pccheck fastcheck_single fastcheck_single_mot:
|
||||
$(MAKE) -C src/distribute/test/regress $@
|
||||
|
||||
#llt include all low level test
|
||||
llt: reg ut
|
||||
|
||||
reg: all
|
||||
|
||||
reg:
|
||||
@echo "begin regression test..."
|
||||
$(MAKE) -C src/distribute/test reg
|
||||
@echo "end regression test"
|
||||
|
||||
hacheck:
|
||||
make install
|
||||
@echo "begin hacheck test..."
|
||||
$(MAKE) -C src/distribute/test/ha hacheck
|
||||
@echo "end hacheck test"
|
||||
|
||||
commcheck:
|
||||
make install -sj "CPPFLAGS += -DLIBCOMM_CHECK"
|
||||
@echo "begin commcheck test..."
|
||||
$(MAKE) -C src/distribute/test/commcheck commcheck
|
||||
@echo "end commcheck test"
|
||||
|
||||
upcheck upgradecheck:
|
||||
@echo "Attention: please make sure GAUSSHOME , prefix, PATH and LD_LIBRARY_PATH have been set right."; \
|
||||
echo "If encounting port conflicts, please change base_port in src/distribute/test/upgrade/upgradeCheck.py."; \
|
||||
sleep 5; \
|
||||
make install; \
|
||||
echo "begin upgrade test..."; \
|
||||
python src/distribute/test/upgrade/upgradeCheck.py; \
|
||||
echo "end upgrade test";
|
||||
|
||||
ut:
|
||||
@echo "begin unit test..."
|
||||
$(MAKE) -C src/distribute/test/ut ut
|
||||
@echo "end unit test"
|
||||
|
||||
$(call recurse,check-world,src/distribute/test src/pl src/interfaces/ecpg contrib,check)
|
||||
|
||||
$(call recurse,installcheck-world,src/distribute/test src/pl src/interfaces/ecpg contrib,installcheck)
|
||||
|
||||
else
|
||||
check fastcheck fastcheck_parallel_initdb fastcheck_single fastcheck_single_mot:
|
||||
$(MAKE) -C src/test/regress $@
|
||||
|
||||
$(call recurse,check-world,src/test src/pl src/interfaces/ecpg contrib,check)
|
||||
|
||||
$(call recurse,installcheck-world,src/test src/pl src/interfaces/ecpg contrib,installcheck)
|
||||
|
||||
endif
|
||||
|
||||
$(call recurse,maintainer-check,doc src config contrib)
|
||||
|
||||
GNUmakefile: GNUmakefile.in $(top_builddir)/config.status
|
||||
./config.status $@
|
||||
|
||||
|
||||
##########################################################################
|
||||
|
||||
distdir = postgresql-$(VERSION)
|
||||
dummy = =install=
|
||||
garbage = =* "#"* ."#"* *~* *.orig *.rej core postgresql-*
|
||||
|
||||
dist: $(distdir).tar.gz $(distdir).tar.bz2
|
||||
rm -rf $(distdir)
|
||||
|
||||
$(distdir).tar: distdir
|
||||
$(TAR) chf $@ $(distdir)
|
||||
|
||||
.INTERMEDIATE: $(distdir).tar
|
||||
|
||||
distdir-location:
|
||||
@echo $(distdir)
|
||||
|
||||
distdir:
|
||||
rm -rf $(distdir)* $(dummy)
|
||||
for x in `cd $(top_srcdir) && find . \( -name CVS -prune \) -o \( -name .git -prune \) -o -print`; do \
|
||||
file=`expr X$$x : 'X\./\(.*\)'`; \
|
||||
if test -d "$(top_srcdir)/$$file" ; then \
|
||||
mkdir "$(distdir)/$$file" && chmod 777 "$(distdir)/$$file"; \
|
||||
else \
|
||||
ln "$(top_srcdir)/$$file" "$(distdir)/$$file" >/dev/null 2>&1 \
|
||||
|| cp "$(top_srcdir)/$$file" "$(distdir)/$$file"; \
|
||||
fi || exit; \
|
||||
done
|
||||
$(MAKE) -C $(distdir) distprep
|
||||
$(MAKE) -C $(distdir)/doc/src/sgml/ HISTORY INSTALL regress_README
|
||||
cp $(distdir)/doc/src/sgml/HISTORY $(distdir)/
|
||||
cp $(distdir)/doc/src/sgml/INSTALL $(distdir)/
|
||||
cp $(distdir)/doc/src/sgml/regress_README $(distdir)/src/test/regress/README
|
||||
$(MAKE) -C $(distdir) distclean
|
||||
rm -f $(distdir)/README.git
|
||||
|
||||
distcheck: dist
|
||||
rm -rf $(dummy)
|
||||
mkdir $(dummy)
|
||||
$(GZIP) -d -c $(distdir).tar.gz | $(TAR) xf -
|
||||
install_prefix=`cd $(dummy) && pwd`; \
|
||||
cd $(distdir) \
|
||||
&& ./configure --prefix="$$install_prefix"
|
||||
$(MAKE) -C $(distdir) -q distprep
|
||||
$(MAKE) -C $(distdir)
|
||||
$(MAKE) -C $(distdir) install
|
||||
$(MAKE) -C $(distdir) uninstall
|
||||
@echo "checking whether \`$(MAKE) uninstall' works"
|
||||
test `find $(dummy) ! -type d | wc -l` -eq 0
|
||||
$(MAKE) -C $(distdir) dist
|
||||
# Room for improvement: Check here whether this distribution tarball
|
||||
# is sufficiently similar to the original one.
|
||||
rm -rf $(distdir) $(dummy)
|
||||
@echo "Distribution integrity checks out."
|
||||
|
||||
.PHONY: dist distdir distcheck docs install-docs world check-world install-world installcheck-world
|
||||
125
License
Normal file
125
License
Normal file
@ -0,0 +1,125 @@
|
||||
木兰宽松许可证, 第2版
|
||||
木兰宽松许可证, 第2版
|
||||
|
||||
2020年1月 http://license.coscl.org.cn/MulanPSL2
|
||||
|
||||
您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
|
||||
|
||||
0. 定义
|
||||
|
||||
“软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
|
||||
|
||||
“贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
|
||||
|
||||
“贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
|
||||
|
||||
“法人实体” 是指提交贡献的机构及其“关联实体”。
|
||||
|
||||
“关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
|
||||
|
||||
1. 授予版权许可
|
||||
|
||||
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
|
||||
|
||||
2. 授予专利许可
|
||||
|
||||
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
|
||||
|
||||
3. 无商标许可
|
||||
|
||||
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
|
||||
|
||||
4. 分发限制
|
||||
|
||||
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
|
||||
|
||||
5. 免责声明与责任限制
|
||||
|
||||
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
|
||||
|
||||
6. 语言
|
||||
|
||||
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
|
||||
|
||||
条款结束
|
||||
|
||||
如何将木兰宽松许可证,第2版,应用到您的软件
|
||||
|
||||
如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
|
||||
|
||||
1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
|
||||
|
||||
2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
|
||||
|
||||
3, 请将如下声明文本放入每个源文件的头部注释中。
|
||||
|
||||
Copyright (c) [Year] [name of copyright holder]
|
||||
[Software Name] 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.
|
||||
Mulan Permissive Software License,Version 2
|
||||
Mulan Permissive Software License,Version 2 (Mulan PSL v2)
|
||||
|
||||
January 2020 http://license.coscl.org.cn/MulanPSL2
|
||||
|
||||
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
|
||||
|
||||
0. Definition
|
||||
|
||||
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
|
||||
|
||||
Contribution means the copyrightable work licensed by a particular Contributor under this License.
|
||||
|
||||
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
|
||||
|
||||
Legal Entity means the entity making a Contribution and all its Affiliates.
|
||||
|
||||
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
|
||||
|
||||
1. Grant of Copyright License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
|
||||
|
||||
2. Grant of Patent License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
|
||||
|
||||
3. No Trademark License
|
||||
|
||||
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4.
|
||||
|
||||
4. Distribution Restriction
|
||||
|
||||
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
|
||||
|
||||
5. Disclaimer of Warranty and Limitation of Liability
|
||||
|
||||
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
6. Language
|
||||
|
||||
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
|
||||
|
||||
END OF THE TERMS AND CONDITIONS
|
||||
|
||||
How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
|
||||
|
||||
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
|
||||
|
||||
Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
|
||||
Create a file named "LICENSE" which contains the whole context of this License in the first directory of your software package;
|
||||
Attach the statement to the appropriate annotated syntax at the beginning of each source file.
|
||||
Copyright (c) [Year] [name of copyright holder]
|
||||
[Software Name] 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.
|
||||
36
Makefile
Normal file
36
Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
# The PostgreSQL make files exploit features of GNU make that other
|
||||
# makes do not have. Because it is a common mistake for users to try
|
||||
# to build Postgres with a different make, we have this make file
|
||||
# that, as a service, will look for a GNU make and invoke it, or show
|
||||
# an error message if none could be found.
|
||||
|
||||
# If the user were using GNU make now, this file would not get used
|
||||
# because GNU make uses a make file named "GNUmakefile" in preference
|
||||
# to "Makefile" if it exists. PostgreSQL is shipped with a
|
||||
# "GNUmakefile". If the user hasn't run the configure script yet, the
|
||||
# GNUmakefile won't exist yet, so we catch that case as well.
|
||||
|
||||
|
||||
all check install installdirs installcheck installcheck-parallel uninstall clean distclean maintainer-clean dist distcheck world check-world install-world installcheck-world:
|
||||
@if [ ! -f GNUmakefile ] ; then \
|
||||
echo "You need to run the 'configure' program first. See the file"; \
|
||||
echo "'INSTALL' for installation instructions." ; \
|
||||
false ; \
|
||||
fi
|
||||
@IFS=':' ; \
|
||||
for dir in $$PATH; do \
|
||||
for prog in gmake gnumake make; do \
|
||||
if [ -f $$dir/$$prog ] && ( $$dir/$$prog -f /dev/null --version 2>/dev/null | grep GNU >/dev/null 2>&1 ) ; then \
|
||||
GMAKE=$$dir/$$prog; \
|
||||
break 2; \
|
||||
fi; \
|
||||
done; \
|
||||
done; \
|
||||
\
|
||||
if [ x"$${GMAKE+set}" = xset ]; then \
|
||||
echo "Using GNU make found at $${GMAKE}"; \
|
||||
$${GMAKE} $@ ; \
|
||||
else \
|
||||
echo "You must use GNU make to build PostgreSQL." ; \
|
||||
false; \
|
||||
fi
|
||||
36
README.en.md
36
README.en.md
@ -1,36 +0,0 @@
|
||||
# openGauss-server
|
||||
|
||||
#### Description
|
||||
openGauss kernel
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
583
README.md
583
README.md
@ -1,37 +1,570 @@
|
||||
# openGauss-server
|
||||

|
||||
|
||||
#### 介绍
|
||||
openGauss kernel
|
||||
- [What Is openGauss](#what-is-opengauss)
|
||||
- [Installation](#installation)
|
||||
- [Creating a Configuration File](#creating-a-configuration-file)
|
||||
- [Initializing the Installation Environment](#initializing-the-installation-environment)
|
||||
- [Executing Installation](#executing-installation)
|
||||
[Uninstalling the opeinGauss](#uninstalling-the-openGauss)
|
||||
- [Compilation](#compilation)
|
||||
- [Overview](#overview)
|
||||
- [OS and Software Dependency Requirements](#os-and-software-dependency-requirements)
|
||||
- [Downloading openGauss](#downloading-openGauss)
|
||||
- [Compiling Third-Party Software](#compiling-third-party-software)
|
||||
- [Compiling by build.sh](#compiling-by-build.sh)
|
||||
- [Compiling by Command](#compiling-by-command)
|
||||
- [Compiling the Installation Package](#compiling-the-installation-package)
|
||||
- [Quick Start](#quick-start)
|
||||
- [Docs](#docs)
|
||||
- [Community](#community)
|
||||
- [Governance](#governance)
|
||||
- [Communication](#communication)
|
||||
- [Contribution](#contribution)
|
||||
- [Release Notes](#release-notes)
|
||||
- [License](#license)
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
## What Is openGauss
|
||||
|
||||
openGauss is an open source relational database management system. It has multi-core high-performance, full link security, intelligent operation and maintenance for enterprise features. openGauss, which is early originated from PostgreSQL, integrates Huawei's core experience in database field for many years. It optimizes the architecture, transaction, storage engine, optimizer and ARM architecture. At the meantime, openGauss as a global database open source community, aims to further advance the development and enrichment of the database software/hardware application ecosystem.
|
||||
|
||||
<img src="doc/openGauss-architecture.png" alt="openGauss Architecture" width="600"/>
|
||||
|
||||
**High Performance**
|
||||
|
||||
openGauss breaks through the bottleneck of multi-core CPU, 2-way Kunpeng 128 core 1.5 million TPMC.
|
||||
|
||||
**Partitions**
|
||||
|
||||
Divide key data structure shared by internal threads into different partitions to reduce lock access conflicts. For example, CLOG uses partition optimization to solve the bottleneck of ClogControlLock.
|
||||
|
||||
**NUMA Structure**
|
||||
|
||||
Malloc key data structures help reduce cross CPU access. The global PGPROC array is divided into several parts according to the number of NUMA nodes, solving the bottleneck of ProcArrayLock.
|
||||
|
||||
**Binding Cores**
|
||||
|
||||
Bind NIC interrupts to different cores and bind cores to different background threads to avoid performance instability due to thread migration between cores.
|
||||
|
||||
**ARM Optimization**
|
||||
|
||||
Optimize atomic operations based on ARM platform LSE instructions, impletmenting efficient operation of critical sections.
|
||||
|
||||
**SQL Bypass**
|
||||
|
||||
Optimize SQL execution process through SQL bypass, reducing CPU execution overhead.
|
||||
|
||||
**High Reliability**
|
||||
|
||||
Under normal service loads, the RTO is less than 10 seconds, reducing the service interruption time caused by node failure.
|
||||
|
||||
**Parallel Recovery**
|
||||
|
||||
When the Xlog is transferred to the standby node, the standby node flushs the Xlog to storage medium. At the mean time, the Xlog is sent to the redo recovery dispatch thread. The dispatch thread sends the Xlog to multiple parallel recovery threads to replay. Ensure that the redo speed of the standby node keeps up with the generation speed of the primary host. The standby node is ready in real time, which can be promoted to primary instantly.
|
||||
|
||||
**Security**
|
||||
|
||||
openGauss supports account management, account authentication, account locking, password complexity check, privilege management and verification, transmission encryption, and operation audit, protecting service data security.
|
||||
|
||||
**Easy Operation and Maintenance**
|
||||
|
||||
openGauss integrates AI algorithms into databases, reducing the burden of database maintenance.
|
||||
|
||||
- **SQL Prediction**
|
||||
|
||||
openGauss supports SQL execution time prediction based on collected historical performance data.
|
||||
|
||||
- **SQL Diagnoser**
|
||||
|
||||
openGauss supports the diagnoser for SQL execution statements, finding out slow queries in advance..
|
||||
|
||||
- **Automatical Parameter Adjustment**
|
||||
|
||||
openGauss supports automatically adjusting database parameters, reducing the cost and time of parameter adjustment.
|
||||
|
||||
## Installation
|
||||
|
||||
### Creating a Configuration File
|
||||
|
||||
Before installing the openGauss, you need to create a configuration file. The configuration file in the XML format contains the information about the server where the openGauss is deployed, installation path, IP address, and port number. This file is used to guide how to deploy the openGauss. You need to configure the configuration file according to the actual deployment requirements.
|
||||
|
||||
The following describes how to create an XML configuration file based on the deployment solution of one primary node and one standby node.
|
||||
The information of value is only an example. You can replace it as required. Each line of information is commented out.
|
||||
|
||||
```
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ROOT>
|
||||
<!-- Overall information -->
|
||||
<CLUSTER>
|
||||
<!-- Database name -->
|
||||
<PARAM name="clusterName" value="Cluster_template" />
|
||||
<!-- Database node name (hostname) -->
|
||||
<PARAM name="nodeNames" value="node1_hostname,node2_hostname"/>
|
||||
<!-- Database installation path -->
|
||||
<PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
|
||||
<!-- Log directory -->
|
||||
<PARAM name="gaussdbLogPath" value="/var/log/omm" />
|
||||
<!-- Temporary file directory -->
|
||||
<PARAM name="tmpMppdbPath" value="/opt/huawei/tmp"/>
|
||||
<!-- Database tool directory -->
|
||||
<PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
|
||||
<!--Directory of the core file of the database -->
|
||||
<PARAM name="corePath" value="/opt/huawei/corefile"/>
|
||||
<!-- Node IP addresses corresponding to the node names, respectively -->
|
||||
<PARAM name="backIp1s" value="192.168.0.1,192.168.0.2"/>
|
||||
</CLUSTER>
|
||||
<!-- Information about node deployment on each server -->
|
||||
<DEVICELIST>
|
||||
<!-- Information about the node deployment on node1 -->
|
||||
<DEVICE sn="node1_hostname">
|
||||
<!-- Host name of node1 -->
|
||||
<PARAM name="name" value="node1_hostname"/>
|
||||
<!-- AZ where node1 is located and AZ priority -->
|
||||
<PARAM name="azName" value="AZ1"/>
|
||||
<PARAM name="azPriority" value="1"/>
|
||||
<!-- IP address of node1. If only one NIC is available for the server, set backIP1 and sshIP1 to the same IP address. -->
|
||||
<PARAM name="backIp1" value="192.168.0.1"/>
|
||||
<PARAM name="sshIp1" value="192.168.0.1"/>
|
||||
<!--DBnode-->
|
||||
<PARAM name="dataNum" value="1"/>
|
||||
<!-- Database node port number -->
|
||||
<PARAM name="dataPortBase" value="15400"/>
|
||||
<!-- Data directory on the primary database node and data directories of standby nodes -->
|
||||
<PARAM name="dataNode1" value="/opt/huawei/install/data/dn,node2_hostname,/opt/huawei/install/data/dn"/>
|
||||
<!-- Number of nodes for which the synchronization mode is set on the database node -->
|
||||
<PARAM name="dataNode1_syncNum" value="0"/>
|
||||
</DEVICE>
|
||||
<!-- Information about the node deployment on node2 -->
|
||||
<DEVICE sn="node2_hostname">
|
||||
<!-- Host name of node2 -->
|
||||
<PARAM name="name" value="node2_hostname"/>
|
||||
<!-- AZ where node1 is located and AZ priority -->
|
||||
<PARAM name="azName" value="AZ1"/>
|
||||
<PARAM name="azPriority" value="1"/>
|
||||
<!-- IP address of node1. If only one NIC is available for the server, set backIP1 and sshIP1 to the same IP address. -->
|
||||
<PARAM name="backIp1" value="192.168.0.2"/>
|
||||
<PARAM name="sshIp1" value="192.168.0.2"/>
|
||||
</DEVICE>
|
||||
</DEVICELIST>
|
||||
</ROOT>
|
||||
```
|
||||
|
||||
### Initializing the Installation Environment
|
||||
|
||||
After the openGauss configuration file is created, you need to run the gs_preinstall script to prepare the account and environment so that you can perform openGauss installation and management operations with the minimum permission, ensuring system security.
|
||||
|
||||
**Precautions**
|
||||
|
||||
- You must check the upper-layer directory permissions to ensure that the user has the read, write, and execution permissions on the installation package and configuration file directory.
|
||||
- The mapping between each host name and IP address in the XML configuration file must be correct.
|
||||
- Only user root is authorized to run the gs_preinstall command.
|
||||
|
||||
**Procedure**
|
||||
|
||||
1. Log in to any host where the openGauss is to be installed as user root and create a directory for storing the installation package as planned.
|
||||
|
||||
```
|
||||
mkdir -p /opt/software/openGauss
|
||||
chmod 755 -R /opt/software
|
||||
```
|
||||
|
||||
> **NOTE:**
|
||||
>
|
||||
> - Do not create the directory in the home directory or subdirectory of any openGauss user because you may lack permissions for such directories.
|
||||
> - The openGauss user must have the read and write permissions on the /opt/software/openGauss directory.
|
||||
|
||||
2. The release package is used as an example. Upload the installation package openGauss_x.x.x_PACKAGES_RELEASE.tar.gz and the configuration file clusterconfig.xml to the directory created in the previous step.
|
||||
|
||||
3. Go to the directory for storing the uploaded software package and decompress the package.
|
||||
|
||||
```
|
||||
cd /opt/software/openGauss
|
||||
tar -zxvf openGauss_x.x.x_PACKAGES_RELEASE.tar.gz
|
||||
```
|
||||
|
||||
4. Decompress the openGauss-x.x.x-openEULER-64bit.tar.gz package.
|
||||
|
||||
```
|
||||
tar -zxvf openGauss-x.x.x-openEULER-64bit.tar.gz
|
||||
```
|
||||
|
||||
After the installation package is decompressed, the script subdirectory is automatically generated in /opt/software/openGauss. OM tool scripts such as gs_preinstall are generated in the script subdirectory.
|
||||
|
||||
5. Go to the directory for storing tool scripts.
|
||||
|
||||
```
|
||||
cd /opt/software/openGauss/script
|
||||
```
|
||||
|
||||
6. To ensure that the OpenSSL version is correct, load the lib library in the installation package before preinstallation. Run the following command. {packagePath} indicates the path where the installation package is stored. In this example, the path is /opt/software/openGauss.
|
||||
|
||||
```
|
||||
export LD_LIBRARY_PATH={packagePath}/script/gspylib/clib:$LD_LIBRARY_PATH
|
||||
```
|
||||
|
||||
|
||||
#### 安装教程
|
||||
7. To ensure successful installation, check whether the values of hostname and /etc/hostname are the same. During preinstallation, the host name is checked.
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
8. Execute gs_preinstall to configure the installation environment. If the shared environment is used, add the --sep-env-file=ENVFILE parameter to separate environment variables to avoid mutual impact with other users. The environment variable separation file path is specified by users.
|
||||
Execute gs_preinstall in interactive mode. During the execution, the mutual trust between users root and between clusteropenGauss users is automatically established.
|
||||
|
||||
#### 使用说明
|
||||
```
|
||||
./gs_preinstall -U omm -G dbgrp -X /opt/software/ openGauss/clusterconfig.xml
|
||||
```
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
omm is the database administrator (also the OS user running the openGauss), dbgrp is the group name of the OS user running the openGauss, and /opt/software/ openGauss/clusterconfig.xml is the path of the openGauss configuration file. During the execution, you need to determine whether to establish mutual trust as prompted and enter the password of user root or the openGauss user.
|
||||
|
||||
#### 参与贡献
|
||||
### Executing Installation
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
After the openGauss installation environment is prepared by executing the pre-installation script, deploy openGauss based on the installation process.
|
||||
|
||||
**Prerequisites**
|
||||
|
||||
- You have successfully executed the gs_preinstall script.
|
||||
- All the server OSs and networks are functioning properly.
|
||||
- You have checked that the locale parameter for each server is set to the same value.
|
||||
|
||||
**Procedure**
|
||||
|
||||
1. (Optional) Check whether the installation package and openGauss configuration file exist in the planned directories. If no such package or file exists, perform the preinstallation again..
|
||||
|
||||
2. Log in to any host of the openGauss and switch to the omm user.
|
||||
|
||||
```
|
||||
su - omm
|
||||
```
|
||||
|
||||
> **NOTE:**
|
||||
>
|
||||
> - omm indicates the user specified by the -U parameter in the gs_preinstall script.
|
||||
> - You need to execute the gs_install script as user omm specified in the gs_preinstall script. Otherwise, an execution error will be reported.
|
||||
|
||||
3. Use gs_install to install the openGauss. If the openGauss is installed in environment variable separation mode, run the source command to obtain the environment variable separation file ENVFILE.
|
||||
|
||||
```
|
||||
gs_install -X /opt/software/ openGauss/clusterconfig.xml
|
||||
```
|
||||
|
||||
The password must meet the following complexity requirements:
|
||||
|
||||
- Contain at least eight characters.
|
||||
- Cannot be the same as the username, the current password (ALTER), or the current password in an inverted sequence.
|
||||
- Contain at least three of the following: uppercase characters (A to Z), lowercase characters (a to z), digits (0 to 9), and other characters (limited to ~!@#$%^&*()-_=+\|[{}];:,<.>/?).
|
||||
|
||||
4. After the installation is successful, manually delete the trust between users root on the host, that is, delete the mutual trust file on each openGauss database node.
|
||||
|
||||
```
|
||||
rm –rf ~/.ssh
|
||||
```
|
||||
|
||||
### Uninstalling the openGauss
|
||||
|
||||
The process of uninstalling the openGauss includes uninstalling the openGauss and clearing the environment of the openGauss server.
|
||||
|
||||
#### **Executing Uninstallation**
|
||||
|
||||
The openGauss provides an uninstallation script to help users uninstall the openGauss.
|
||||
|
||||
**Procedure**
|
||||
|
||||
1. Log in as the OS user omm to the host where the CN is located.
|
||||
|
||||
2. Execute the gs_uninstall script to uninstall the database cluster.
|
||||
|
||||
```
|
||||
gs_uninstall --delete-data
|
||||
```
|
||||
|
||||
Alternatively, execute uninstallation on each openGauss node.
|
||||
|
||||
```
|
||||
gs_uninstall --delete-data -L
|
||||
```
|
||||
|
||||
#### **Deleting openGauss Configurations**
|
||||
|
||||
After the openGauss is uninstalled, execute the gs_postuninstall script to delete configurations from all servers in the openGauss if you do not need to re-deploy the openGauss using these configurations. These configurations are made by the gs_preinstall script.
|
||||
**Prerequisites**
|
||||
|
||||
- The openGauss uninstallation task has been successfully executed.
|
||||
- User root is trustworthy and available.
|
||||
- Only user root is authorized to run the gs_postuninstall command.
|
||||
|
||||
**Procedure**
|
||||
|
||||
1. Log in to the openGauss server as user root.
|
||||
|
||||
2. Run the ssh Host name command to check whether mutual trust has been successfully established. Then, enter exit.
|
||||
|
||||
```
|
||||
plat1:~ # ssh plat2
|
||||
Last login: Tue Jan 5 10:28:18 2016 from plat1
|
||||
plat2:~ # exit
|
||||
logout
|
||||
Connection to plat2 closed.
|
||||
plat1:~ #
|
||||
```
|
||||
|
||||
3. Go to the following path:
|
||||
|
||||
```
|
||||
cd /opt/software/openGauss/script
|
||||
```
|
||||
|
||||
4. Run the gs_postuninstall command to clear the environment. If the openGauss is installed in environment variable separation mode, run the source command to obtain the environment variable separation file ENVFILE.
|
||||
|
||||
```
|
||||
./gs_postuninstall -U omm -X /opt/software/openGauss/clusterconfig.xml --delete-user --delete-group
|
||||
```
|
||||
|
||||
Alternatively, locally use the gs_postuninstall tool to clear each openGauss node.
|
||||
|
||||
```
|
||||
./gs_postuninstall -U omm -X /opt/software/openGauss/clusterconfig.xml --delete-user --delete-group -L
|
||||
```
|
||||
|
||||
omm is the name of the OS user who runs the openGauss, and the path of the openGauss configuration file is /opt/software/openGauss/clusterconfig.xml.
|
||||
If the cluster is installed in environment variable separation mode, delete the environment variable separation parameter ENV obtained by running the source command.
|
||||
|
||||
```
|
||||
unset MPPDB_ENV_SEPARATE_PATH
|
||||
```
|
||||
|
||||
5. Delete the mutual trust between the users root on each openGauss database node.
|
||||
|
||||
|
||||
#### 码云特技
|
||||
## Compilation
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
|
||||
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
### Overview
|
||||
|
||||
To compile openGauss, you need two components: openGauss-server and binarylibs.
|
||||
|
||||
- openGauss-server: main code of openGauss. You can obtain it from the open source community.
|
||||
|
||||
- binarylibs: third party open source software that openGauss depends on. You can obtain it by compiling the openGauss-third_party code or downloading from the open source community on which we have compiled a copy and uploaded it . The first method will be introduced in the following chapter.
|
||||
|
||||
Before you compile openGauss,please check the OS and software dependency requirements.
|
||||
|
||||
You can compile openGauss by build.sh, a one-click shell tool, which we will introduce later, or compile by command. Also, an installation package is produced by build.sh.
|
||||
|
||||
### OS and Software Dependency Requirements
|
||||
|
||||
The following OSs are supported:
|
||||
|
||||
- CentOS 7.6 (x86 architecture)
|
||||
|
||||
- openEuler-20.03-LTS (aarch64 architecture)
|
||||
|
||||
|
||||
The following table lists the software requirements for compiling the openGauss.
|
||||
|
||||
You are advised to use the default installation packages of the following dependent software in the listed OS installation CD-ROMs or sources. If the following software does not exist, refer to the recommended versions of the software.
|
||||
|
||||
Software dependency requirements are as follows:
|
||||
|
||||
| Software | Recommended Version |
|
||||
| ------------- | ------------------- |
|
||||
| libaio-devel | 0.3.109-13 |
|
||||
| flex | 2.5.31 or later |
|
||||
| bison | 2.7-4 |
|
||||
| ncurses-devel | 5.9-13.20130511 |
|
||||
| glibc.devel | 2.17-111 |
|
||||
| patch | 2.7.1-10 |
|
||||
| lsb_release | 4.1 |
|
||||
|
||||
### Downloading openGauss
|
||||
|
||||
You can download openGauss-server and openGauss-third_party from open source community.
|
||||
|
||||
https://opengauss.org/zh/
|
||||
|
||||
From the following website, you can obtain the binarylibs we have compiled. Please unzip it and rename to **binarylibs** after you download.
|
||||
|
||||
https://opengauss.obs.cn-south-1.myhuaweicloud.com/1.0.0/openGauss-third_party_binarylibs.tar.gz
|
||||
|
||||
|
||||
Now we have completed openGauss code, for example, we store it in following directories.
|
||||
|
||||
- /sda/openGauss-server
|
||||
- /sda/binarylibs
|
||||
- /sda/openGauss-third_party
|
||||
|
||||
### Compiling Third-Party Software
|
||||
|
||||
Before compiling the openGauss, compile and build the open-source and third-party software on which the openGauss depends. These open-source and third-party software is stored in the openGauss-third_party code repository and usually needs to be built only once. If the open-source software is updated, rebuild the software.
|
||||
|
||||
You can also directly obtain the output file of the open-source software compilation and build from the **binarylibs** repository.
|
||||
|
||||
If you want to compile third-party by yourself, please go to openGauss-third_party repository to see details.
|
||||
|
||||
After the preceding script is executed, the final compilation and build result is stored in the **binarylibs** directory at the same level as **openGauss-third_party**. These files will be used during the compilation of **openGauss-server**.
|
||||
|
||||
### Compiling by build.sh
|
||||
|
||||
build.sh in openGauss-server is an important script tool during compilation. It integrates software installation and compilation and product installation package compilation functions to quickly compile and package code.
|
||||
|
||||
The following table describes the parameters.
|
||||
|
||||
| Option | Default Value | Parameter | Description |
|
||||
| :----- | :--------------------------- | :----------------------------- | :--------------------------------------- |
|
||||
| -h | Do not use this option. | - | Help menu. |
|
||||
| -m | release | [debug \| release \| memcheck] | Selects the target version. |
|
||||
| -3rd | ${Code directory}/binarylibs | [binarylibs path] | Specifies the path of binarylibs. The path must be an absolute path. |
|
||||
| -pkg | Do not use this option. | - | Compresses the code compilation result into an installation package. |
|
||||
| -nopt | Do not use this option. | - | On kunpeng platform, like 1616 version, without LSE optimized. |
|
||||
|
||||
> **NOTICE:**
|
||||
>
|
||||
> 1. **-m [debug | release | memcheck]** indicates that three target versions can be selected:
|
||||
> - **release**: indicates that the binary program of the release version is generated. During compilation of this version, the GCC high-level optimization option is configured to remove the kernel debugging code. This option is usually used in the generation environment or performance test environment.
|
||||
> - **debug**: indicates that a binary program of the debug version is generated. During compilation of this version, the kernel code debugging function is added, which is usually used in the development self-test environment.
|
||||
> - **memcheck**: indicates that a binary program of the memcheck version is generated. During compilation of this version, the ASAN function is added based on the debug version to locate memory problems.
|
||||
> 2. **-3rd [binarylibs path]** is the path of **binarylibs**. By default, **binarylibs** exists in the current code folder. If **binarylibs** is moved to **openGauss-server** or a soft link to **binarylibs** is created in **openGauss-server**, you do not need to specify the parameter. However, if you do so, please note that the file is easy to be deleted by the **git clean** command.
|
||||
> 3. Each option in this script has a default value. The number of options is small and the dependency is simple. Therefore, this script is easy to use. If the required value is different from the default value, set this parameter based on the actual requirements.
|
||||
|
||||
Now you know the usage of build.sh, so you can compile the openGauss-server by one command with build.sh.
|
||||
|
||||
```
|
||||
[user@linux openGauss-server]$ sh build.sh -m [debug | release | memcheck] -3rd [binarylibs path]
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
[user@linux openGauss-server]$ sh build.sh # Compile openGauss of the release version. The binarylibs or its soft link must exist in the code directory. Otherwise, the operation fails.
|
||||
[user@linux openGauss-server]$ sh build.sh -m debug -3rd /sda/binarylibs # Compilate openGauss of the debug version using binarylibs we put on /sda/
|
||||
```
|
||||
|
||||
The software installation path after compilation is **/sda/openGauss-server/dest**.
|
||||
|
||||
The compiled binary files are stored in **/sda/openGauss-server/dest/bin**.
|
||||
|
||||
Compilation log: **make_compile.log**
|
||||
|
||||
|
||||
|
||||
### Compiling by Command
|
||||
|
||||
1. Run the following script to obtain the system version:
|
||||
|
||||
```
|
||||
[user@linux openGauss-server]$ sh src/get_PlatForm_str.sh
|
||||
```
|
||||
|
||||
> **NOTICE:**
|
||||
>
|
||||
> - The command output indicates the OSs supported by the openGauss. The OSs supported by the openGauss are centos7.6_x86_64 and openeuler_aarch64.
|
||||
> - If **Failed** or another version is displayed, the openGauss does not support the current operating system.
|
||||
|
||||
2. Configure environment variables, add **____** based on the code download location, and replace *** with the result obtained in the previous step.
|
||||
|
||||
```
|
||||
export CODE_BASE=________ # Path of the openGauss-server file
|
||||
export BINARYLIBS=________ # Path of the binarylibs file
|
||||
export GAUSSHOME=$CODE_BASE/dest/
|
||||
export GCC_PATH=$BINARYLIBS/buildtools/***/gcc8.2/
|
||||
export CC=$GCC_PATH/gcc/bin/gccexport CXX=$GCC_PATH/gcc/bin/g++
|
||||
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$GCC_PATH/gcc/lib64:$GCC_PATH/isl/lib:$GCC_PATH/mpc/lib/:$GCC_PATH/mpfr/lib/:$GCC_PATH/gmp/lib/:$LD_LIBRARY_PATH
|
||||
export PATH=$GAUSSHOME/bin:$GCC_PATH/gcc/bin:$PATH
|
||||
|
||||
```
|
||||
|
||||
3. Select a version and configure it.
|
||||
|
||||
**debug** version:
|
||||
|
||||
```
|
||||
./configure --gcc-version=8.2.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --without-readline --without-zlib
|
||||
```
|
||||
|
||||
**release** version:
|
||||
|
||||
```
|
||||
./configure --gcc-version=8.2.0 CC=g++ CFLAGS="-O2 -g3" --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-thread-safety --without-readline --without-zlib
|
||||
```
|
||||
|
||||
**memcheck** version:
|
||||
|
||||
```
|
||||
./configure --gcc-version=8.2.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --without-readline --without-zlib --enable-memory-check
|
||||
```
|
||||
|
||||
> **NOTICE:**
|
||||
>
|
||||
> 1. *[debug | release | memcheck]* indicates that three target versions are available.
|
||||
> 2. On the ARM-based platform, **-D__USE_NUMA** needs to be added to **CFLAGS**.
|
||||
> 3. On the **ARMv8.1** platform or a later version (for example, Kunpeng 920), **-D__ARM_LSE** needs to be added to **CFLAGS**.
|
||||
> 4. If **binarylibs** is moved to **openGauss-server** or a soft link to **binarylibs** is created in **openGauss-server**, you do not need to specify the **--3rd** parameter. However, if you do so, please note that the file is easy to be deleted by the `git clean` command.
|
||||
|
||||
4. Run the following commands to compile openGauss:
|
||||
|
||||
```
|
||||
[user@linux openGauss-server]$ make -sj
|
||||
[user@linux openGauss-server]$ make install -sj
|
||||
```
|
||||
|
||||
5. If the following information is displayed, the compilation and installation are successful:
|
||||
|
||||
```
|
||||
openGauss installation complete.
|
||||
```
|
||||
|
||||
The software installation path after compilation is **$GAUSSHOME**.
|
||||
|
||||
The compiled binary files are stored in **$GAUSSHOME/bin**.
|
||||
|
||||
|
||||
|
||||
### Compiling the Installation Package
|
||||
|
||||
Please read the chapter **Compiling by build.sh** first to understand the usage of build.sh and how to compile openGauss by using the script.
|
||||
|
||||
Now you can compile the installation package with just adding a option `-pkg`.
|
||||
|
||||
```
|
||||
[user@linux openGauss-server]$ sh build.sh -m [debug | release | memcheck] -3rd [binarylibs path] -pkg
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
[user@linux openGauss-server]$ sh build.sh -pkg # Compile openGauss installation package of the release version. The binarylibs or its soft link must exist in the code directory. Otherwise, the operation fails.
|
||||
[user@linux openGauss-server]$ sh build.sh -m debug -3rd /sda/binarylibs -pkg # Compile openGauss installation package of the debug version using binarylibs we put on /sda/
|
||||
```
|
||||
|
||||
The generated installation package is stored in the **./package** directory.
|
||||
|
||||
Compilation log: **make_compile.log**
|
||||
|
||||
Installation package packaging log: **./package/make_package.log**
|
||||
|
||||
## Quick Start
|
||||
|
||||
See the [Quick Start](https://opengauss.org/en/docs/1.0.0/docs/Quickstart/Quickstart.html) to implement the image classification.
|
||||
|
||||
## Docs
|
||||
|
||||
For more details about the installation guide, tutorials, and APIs, please see the [User Documentation](https://gitee.com/opengauss/docs).
|
||||
|
||||
## Community
|
||||
|
||||
### Governance
|
||||
|
||||
Check out how openGauss implements open governance [works](https://gitee.com/opengauss/community/blob/master/governance.md).
|
||||
|
||||
### Communication
|
||||
|
||||
- WeLink- Communication platform for developers.
|
||||
- IRC channel at `#opengauss-meeting` (only for meeting minutes logging purpose)
|
||||
- Mailing-list: https://opengauss.org/en/community/onlineCommunication.html
|
||||
|
||||
## Contribution
|
||||
|
||||
Welcome contributions. See our [Contributor](https://opengauss.org/en/contribution.html) for more details.
|
||||
|
||||
## Release Notes
|
||||
|
||||
For the release notes, see our [RELEASE](https://opengauss.org/en/docs/1.0.0/docs/Releasenotes/Releasenotes.html).
|
||||
|
||||
## License
|
||||
|
||||
[MulanPSL-2.0](http://license.coscl.org.cn/MulanPSL2/)
|
||||
|
||||
7690
Third_Party_Open_Source_Software_Notice
Normal file
7690
Third_Party_Open_Source_Software_Notice
Normal file
File diff suppressed because it is too large
Load Diff
12
aclocal.m4
vendored
Normal file
12
aclocal.m4
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
dnl aclocal.m4
|
||||
m4_include([config/ac_func_accept_argtypes.m4])
|
||||
m4_include([config/acx_pthread.m4])
|
||||
m4_include([config/c-compiler.m4])
|
||||
m4_include([config/c-library.m4])
|
||||
m4_include([config/docbook.m4])
|
||||
m4_include([config/general.m4])
|
||||
m4_include([config/libtool.m4])
|
||||
m4_include([config/perl.m4])
|
||||
m4_include([config/programs.m4])
|
||||
m4_include([config/python.m4])
|
||||
m4_include([config/tcl.m4])
|
||||
197
build.sh
Executable file
197
build.sh
Executable file
@ -0,0 +1,197 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare build_version_mode='release'
|
||||
declare build_binarylib_dir='None'
|
||||
declare to_package='NO'
|
||||
declare optimized='true'
|
||||
#########################################################################
|
||||
##read command line paramenters
|
||||
#######################################################################
|
||||
|
||||
function print_help()
|
||||
{
|
||||
echo "Usage: $0 [OPTION]
|
||||
-h|--help show help information
|
||||
-m|--version_mode this values of paramenter is debug, release or memcheck, the default value is release
|
||||
-3rd|--binarylib_dir the parent directory of binarylibs
|
||||
-pkg|--package package the project,by default, only compile the project
|
||||
-nopt|--not_optimized on kunpeng platform, like 1616 version, without LSE optimized
|
||||
"
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
print_help
|
||||
exit 1
|
||||
;;
|
||||
-m|--version_mode)
|
||||
if [ "$2"X = X ]; then
|
||||
echo "no given correct version information, such as: debug/release/memcheck"
|
||||
exit 1
|
||||
fi
|
||||
build_version_mode=$2
|
||||
shift 2
|
||||
;;
|
||||
-pkg|--package)
|
||||
to_package='YES'
|
||||
shift 1
|
||||
;;
|
||||
-3rd|--binarylib_dir)
|
||||
if [ "$2"X = X ]; then
|
||||
echo "no given binarylib directory values"
|
||||
exit 1
|
||||
fi
|
||||
build_binarylib_dir=$2
|
||||
shift 2
|
||||
;;
|
||||
|
||||
-nopt|--not_optimized)
|
||||
optimized='false'
|
||||
shift 1
|
||||
;;
|
||||
*)
|
||||
echo "Internal Error: option processing error: $1" 1>&2
|
||||
echo "please input right paramtenter, the following command may help you"
|
||||
echo "./package.sh --help or ./package.sh -h"
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$build_version_mode" != "debug" ] && [ "$build_version_mode" != "release" ] && [ "$build_version_mode" != "memcheck" ]; then
|
||||
echo "no given correct version information, such as: debug/release/memcheck"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ROOT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
|
||||
echo "ROOT_DIR : $ROOT_DIR"
|
||||
|
||||
declare ERR_MKGS_FAILED=1
|
||||
declare LOG_FILE="${ROOT_DIR}/make_compile.log"
|
||||
declare BUILD_DIR="${ROOT_DIR}/dest"
|
||||
|
||||
PLAT_FORM_STR=$(sh "${ROOT_DIR}/src/get_PlatForm_str.sh")
|
||||
if [ "${PLAT_FORM_STR}"x == "Failed"x ]
|
||||
then
|
||||
echo "We only support OPENEULER(aarch64), CentOS(x86-64) platform."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##add platform architecture information
|
||||
PLATFORM_ARCH=$(uname -p)
|
||||
if [ "$PLATFORM_ARCH"X == "aarch64"X ] ; then
|
||||
GAUSSDB_EXTRA_FLAGS=" -D__USE_NUMA -D__ARM_LSE"
|
||||
fi
|
||||
|
||||
gcc_version="8.2"
|
||||
|
||||
if [ ${build_binarylib_dir} != 'None' ] && [ -d ${build_binarylib_dir} ]; then
|
||||
BUILD_TOOLS_PATH="${build_binarylib_dir}/buildtools/${PLAT_FORM_STR}"
|
||||
else
|
||||
BUILD_TOOLS_PATH="${ROOT_DIR}/binarylibs/buildtools/${PLAT_FORM_STR}"
|
||||
fi
|
||||
|
||||
export CC=$BUILD_TOOLS_PATH/gcc$gcc_version/gcc/bin/gcc
|
||||
export CXX=$BUILD_TOOLS_PATH/gcc$gcc_version/gcc/bin/g++
|
||||
export LD_LIBRARY_PATH=$BUILD_TOOLS_PATH/gcc$gcc_version/gcc/lib64:$BUILD_TOOLS_PATH/gcc$gcc_version/isl/lib:$BUILD_TOOLS_PATH/gcc$gcc_version/mpc/lib/:$BUILD_TOOLS_PATH/gcc$gcc_version/mpfr/lib/:$BUILD_TOOLS_PATH/gcc$gcc_version/gmp/lib/:$LD_LIBRARY_PATH
|
||||
export PATH=$BUILD_TOOLS_PATH/gcc$gcc_version/gcc/bin:$PATH
|
||||
|
||||
log()
|
||||
{
|
||||
echo "[makegaussdb] $(date +%y-%m-%d' '%T): $@"
|
||||
echo "[makegaussdb] $(date +%y-%m-%d' '%T): $@" >> "$LOG_FILE" 2>&1
|
||||
}
|
||||
|
||||
die()
|
||||
{
|
||||
log "$@"
|
||||
echo "$@"
|
||||
exit $ERR_MKGS_FAILED
|
||||
}
|
||||
|
||||
function srv_pkg_pre_check()
|
||||
{
|
||||
if [ -d "$BUILD_DIR" ]; then
|
||||
rm -rf $BUILD_DIR
|
||||
fi
|
||||
if [ -d "$LOG_FILE" ]; then
|
||||
rm -rf $LOG_FILE
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Everything is ready."
|
||||
else
|
||||
echo "clean enviroment failed."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# 1. clean install path and log file
|
||||
srv_pkg_pre_check
|
||||
|
||||
function getExtraFlags()
|
||||
{
|
||||
if [ "$PLATFORM_ARCH"X == "aarch64"X ] ; then
|
||||
if [ "$dist_version" == "openEuler" ]; then
|
||||
GAUSSDB_EXTRA_FLAGS=" -D__USE_NUMA"
|
||||
if [ "${optimized}"x == "true"x ] ; then
|
||||
GAUSSDB_EXTRA_FLAGS=" -D__USE_NUMA -D__ARM_LSE"
|
||||
echo "Attention: Make sure your target platforms support LSE."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function compile_gaussdb()
|
||||
{
|
||||
cd "$ROOT_DIR"
|
||||
echo "begin to make distclean"
|
||||
if [ $? -ne 0 ]; then
|
||||
die "change dir to $SRC_DIR failed."
|
||||
fi
|
||||
with_3rd=${ROOT_DIR}/binarylibs
|
||||
if [ "${build_binarylib_dir}"x != "None"x ]; then
|
||||
with_3rd=${build_binarylib_dir}
|
||||
fi
|
||||
getExtraFlags
|
||||
#configure
|
||||
make distclean -sj >> "$LOG_FILE" 2>&1
|
||||
echo "Begin configure, Please wait a few minutes..."
|
||||
chmod 755 configure
|
||||
|
||||
if [ "${build_version_mode}"x == "release"x ]; then
|
||||
./configure --prefix="${BUILD_DIR}" --3rd=${with_3rd} CFLAGS="-O2 -g3 ${GAUSSDB_EXTRA_FLAGS}" --enable-thread-safety --without-readline --without-zlib CC=g++ >> "$LOG_FILE" 2>&1
|
||||
elif [ "${build_version_mode}"x == "memcheck"x ]; then
|
||||
./configure --prefix="${BUILD_DIR}" --3rd=${with_3rd} CFLAGS='-O0' --enable-debug --enable-cassert --enable-thread-safety --without-readline --without-zlib --enable-memory-check CC=g++ >> "$LOG_FILE" 2>&1
|
||||
else
|
||||
./configure --prefix="${BUILD_DIR}" --3rd=${with_3rd} CFLAGS="-O0 ${GAUSSDB_EXTRA_FLAGS}" --enable-debug --enable-cassert --enable-thread-safety --without-readline --without-zlib CC=g++ >> "$LOG_FILE" 2>&1
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
die "configure failed."
|
||||
fi
|
||||
echo "End configure"
|
||||
|
||||
echo "Begin make compile database, Please wait a few minutes..."
|
||||
export GAUSSHOME=${BUILD_DIR}
|
||||
export LD_LIBRARY_PATH=${BUILD_DIR}/lib:${BUILD_DIR}/lib/postgresql:${LD_LIBRARY_PATH}
|
||||
make -sj >> "$LOG_FILE" 2>&1
|
||||
make install -sj>> "$LOG_FILE" 2>&1
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
die "make compile failed."
|
||||
fi
|
||||
echo "make compile sucessfully!"
|
||||
}
|
||||
compile_gaussdb
|
||||
|
||||
if [ "${to_package}"X = "YES"X ]
|
||||
then
|
||||
chmod +x ${ROOT_DIR}/package/package.sh
|
||||
if [ "${build_binarylib_dir}"x != "None"x ]
|
||||
then
|
||||
${ROOT_DIR}/package/package.sh -m ${build_version_mode} --binarylibs_dir ${build_binarylib_dir}
|
||||
else
|
||||
${ROOT_DIR}/package/package.sh -m ${build_version_mode}
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
15
config/Makefile
Normal file
15
config/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
# config/Makefile
|
||||
|
||||
subdir = config
|
||||
top_builddir = ..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
|
||||
install: all installdirs
|
||||
$(INSTALL_SCRIPT) $(srcdir)/install-sh '$(DESTDIR)$(pgxsdir)/config/install-sh'
|
||||
|
||||
installdirs:
|
||||
$(MKDIR_P) '$(DESTDIR)$(pgxsdir)/config'
|
||||
|
||||
uninstall:
|
||||
rm -f '$(DESTDIR)$(pgxsdir)/config/install-sh'
|
||||
85
config/ac_func_accept_argtypes.m4
Normal file
85
config/ac_func_accept_argtypes.m4
Normal file
@ -0,0 +1,85 @@
|
||||
# config/ac_func_accept_argtypes.m4
|
||||
# This comes from the official Autoconf macro archive at
|
||||
# <http://research.cys.de/autoconf-archive/>
|
||||
|
||||
|
||||
dnl @synopsis AC_FUNC_ACCEPT_ARGTYPES
|
||||
dnl
|
||||
dnl Checks the data types of the three arguments to accept(). Results are
|
||||
dnl placed into the symbols ACCEPT_TYPE_RETURN and ACCEPT_TYPE_ARG[123],
|
||||
dnl consistent with the following example:
|
||||
dnl
|
||||
dnl #define ACCEPT_TYPE_RETURN int
|
||||
dnl #define ACCEPT_TYPE_ARG1 int
|
||||
dnl #define ACCEPT_TYPE_ARG2 struct sockaddr *
|
||||
dnl #define ACCEPT_TYPE_ARG3 socklen_t
|
||||
dnl
|
||||
dnl This macro requires AC_CHECK_HEADERS to have already verified the
|
||||
dnl presence or absence of sys/types.h and sys/socket.h.
|
||||
dnl
|
||||
dnl NOTE: This is just a modified version of the AC_FUNC_SELECT_ARGTYPES
|
||||
dnl macro. Credit for that one goes to David MacKenzie et. al.
|
||||
dnl
|
||||
dnl @version $Id: ac_func_accept_argtypes.m4,v 1.1 1999/12/03 11:29:29 simons Exp $
|
||||
dnl @author Daniel Richard G. <skunk@mit.edu>
|
||||
dnl
|
||||
|
||||
# PostgreSQL local changes: In the original version ACCEPT_TYPE_ARG3
|
||||
# is a pointer type. That's kind of useless because then you can't
|
||||
# use the macro to define a corresponding variable. We also make the
|
||||
# reasonable(?) assumption that you can use arg3 for getsocktype etc.
|
||||
# as well (i.e., anywhere POSIX.2 has socklen_t).
|
||||
#
|
||||
# arg2 can also be `const' (e.g., RH 4.2). Change the order of tests
|
||||
# for arg3 so that `int' is first, in case there is no prototype at all.
|
||||
#
|
||||
# Solaris 7 and 8 have arg3 as 'void *' (disguised as 'Psocklen_t'
|
||||
# which is *not* 'socklen_t *'). If we detect that, then we assume
|
||||
# 'int' as the result, because that ought to work best.
|
||||
#
|
||||
# On Win32, accept() returns 'unsigned int PASCAL'
|
||||
# Win64 uses SOCKET for return and arg1
|
||||
|
||||
AC_DEFUN([AC_FUNC_ACCEPT_ARGTYPES],
|
||||
[AC_MSG_CHECKING([types of arguments for accept()])
|
||||
AC_CACHE_VAL(ac_cv_func_accept_return,dnl
|
||||
[AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
|
||||
[AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
|
||||
[AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
|
||||
[for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL' 'SOCKET WSAAPI'; do
|
||||
for ac_cv_func_accept_arg1 in 'int' 'unsigned int' 'SOCKET'; do
|
||||
for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
|
||||
for ac_cv_func_accept_arg3 in 'socklen_t' 'int' 'size_t' 'unsigned int' 'void'; do
|
||||
AC_TRY_COMPILE(
|
||||
[#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
extern $ac_cv_func_accept_return accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);],
|
||||
[], [ac_not_found=no; break 4], [ac_not_found=yes])
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
if test "$ac_not_found" = yes; then
|
||||
AC_MSG_ERROR([could not determine argument types])
|
||||
fi
|
||||
if test "$ac_cv_func_accept_arg3" = "void"; then
|
||||
ac_cv_func_accept_arg3=int
|
||||
fi
|
||||
])dnl AC_CACHE_VAL
|
||||
])dnl AC_CACHE_VAL
|
||||
])dnl AC_CACHE_VAL
|
||||
])dnl AC_CACHE_VAL
|
||||
AC_MSG_RESULT([$ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *])
|
||||
AC_DEFINE_UNQUOTED(ACCEPT_TYPE_RETURN, $ac_cv_func_accept_return,
|
||||
[Define to the return type of 'accept'])
|
||||
AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG1, $ac_cv_func_accept_arg1,
|
||||
[Define to the type of arg 1 of 'accept'])
|
||||
AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG2, $ac_cv_func_accept_arg2,
|
||||
[Define to the type of arg 2 of 'accept'])
|
||||
AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG3, $ac_cv_func_accept_arg3,
|
||||
[Define to the type of arg 3 of 'accept'])
|
||||
])
|
||||
228
config/acx_pthread.m4
Normal file
228
config/acx_pthread.m4
Normal file
@ -0,0 +1,228 @@
|
||||
dnl PGSGL: When updating, comment out port-specific part below;
|
||||
dnl see the comment below with the word "PostgreSQL".
|
||||
dnl
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.html
|
||||
dnl
|
||||
AC_DEFUN([ACX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
acx_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on True64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
||||
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
fi
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
# names; the ordering is very important because some systems
|
||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||
# libraries is broken (non-POSIX).
|
||||
|
||||
# Create a list of thread flags to try. Items starting with a "-" are
|
||||
# C compiler flags, and other items are library names, except for "none"
|
||||
# which indicates that we try without any flags at all, and "pthread-config"
|
||||
# which is a program returning the flags for the Pth emulation library.
|
||||
|
||||
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config pthreadGC2"
|
||||
|
||||
# The ordering *is* (sometimes) important. Some notes on the
|
||||
# individual items follow:
|
||||
|
||||
# pthreads: AIX (must check this before -lpthread)
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
||||
# -pthreads: Solaris/gcc
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||
# doesn't hurt to check since this sometimes defines pthreads too;
|
||||
# also defines -D_REENTRANT)
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*solaris*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (We need to link with -pthread or
|
||||
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||
# a function called by this macro, so we could check for that, but
|
||||
# who knows whether they'll stub that too in a future libc.) So,
|
||||
# we'll just look for -pthreads and -lpthread first:
|
||||
|
||||
acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
for flag in $acx_pthread_flags; do
|
||||
|
||||
tryPTHREAD_CFLAGS=""
|
||||
tryPTHREAD_LIBS=""
|
||||
case $flag in
|
||||
none)
|
||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||
;;
|
||||
|
||||
-*)
|
||||
AC_MSG_CHECKING([whether pthreads work with $flag])
|
||||
tryPTHREAD_CFLAGS="$flag"
|
||||
;;
|
||||
|
||||
pthread-config)
|
||||
# skip this if we already have flags defined, for PostgreSQL
|
||||
if test x"$PTHREAD_CFLAGS" != x -o x"$PTHREAD_LIBS" != x; then continue; fi
|
||||
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
|
||||
if test x"$acx_pthread_config" = xno; then continue; fi
|
||||
tryPTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||
tryPTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
||||
tryPTHREAD_LIBS="-l$flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
LIBS="$tryPTHREAD_LIBS $PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"
|
||||
|
||||
# Check for various functions. We must include pthread.h,
|
||||
# since some functions may be macros. (On the Sequent, we
|
||||
# need a special flag -Kthread to make this header compile.)
|
||||
# We check for pthread_join because it is in -lpthread on IRIX
|
||||
# while pthread_create is in libc. We check for pthread_attr_init
|
||||
# due to DEC craziness with -lpthreads. We check for
|
||||
# pthread_cleanup_push because it is one of the few pthread
|
||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||
# We try pthread_create on general principles.
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[pthread_t th; pthread_join(th, 0);
|
||||
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
||||
[acx_pthread_ok=yes], [acx_pthread_ok=no])
|
||||
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
# Don't use options that are ignored by the compiler.
|
||||
# We find them by checking stderror.
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
# Check both linking and compiling, because they might tolerate different options.
|
||||
if test "`(eval $ac_link 2>&1 1>&5)`" = "" && test "`(eval $ac_compile 2>&1 1>&5)`" = ""; then
|
||||
# we continue with more flags because Linux needs -lpthread
|
||||
# for libpq builds on PostgreSQL. The test above only
|
||||
# tests for building binaries, not shared libraries.
|
||||
PTHREAD_LIBS=" $tryPTHREAD_LIBS $PTHREAD_LIBS"
|
||||
PTHREAD_CFLAGS="$PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"
|
||||
else acx_pthread_ok=no
|
||||
fi
|
||||
fi
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
done
|
||||
fi
|
||||
|
||||
# Various other checks:
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Detect AIX lossage: threads are created detached by default
|
||||
# and the JOINABLE attribute has a nonstandard name (UNDETACHED).
|
||||
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[int attr=PTHREAD_CREATE_JOINABLE;],
|
||||
ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
|
||||
if test x"$ok" = xunknown; then
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[int attr=PTHREAD_CREATE_UNDETACHED;],
|
||||
ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
|
||||
fi
|
||||
if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
|
||||
AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
|
||||
[Define to the necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
fi
|
||||
AC_MSG_RESULT(${ok})
|
||||
if test x"$ok" = xunknown; then
|
||||
AC_MSG_WARN([we do not know how to create joinable pthreads])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||
flag=no
|
||||
# We always add these in PostgreSQL
|
||||
# case "${host_cpu}-${host_os}" in
|
||||
# *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
|
||||
# *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
|
||||
# esac
|
||||
AC_MSG_RESULT(${flag})
|
||||
if test "x$flag" != xno; then
|
||||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||
fi
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
# Supporting cc_r would require a special CC in all places that
|
||||
# use libpq, and that is ugly, so we don't do it. Users can still
|
||||
# define their compiler as cc_r to do thread builds of everything.
|
||||
# More AIX lossage: must compile with cc_r
|
||||
AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
|
||||
else
|
||||
PTHREAD_CC="$CC"
|
||||
fi
|
||||
|
||||
AC_SUBST(PTHREAD_LIBS)
|
||||
AC_SUBST(PTHREAD_CFLAGS)
|
||||
AC_SUBST(PTHREAD_CC)
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test x"$acx_pthread_ok" = xyes; then
|
||||
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
|
||||
:
|
||||
else
|
||||
acx_pthread_ok=no
|
||||
$2
|
||||
fi
|
||||
AC_LANG_RESTORE
|
||||
])dnl ACX_PTHREAD
|
||||
169
config/c-compiler.m4
Normal file
169
config/c-compiler.m4
Normal file
@ -0,0 +1,169 @@
|
||||
# Macros to detect C compiler features
|
||||
# config/c-compiler.m4
|
||||
|
||||
|
||||
# PGAC_C_SIGNED
|
||||
# -------------
|
||||
# Check if the C compiler understands signed types.
|
||||
AC_DEFUN([PGAC_C_SIGNED],
|
||||
[AC_CACHE_CHECK(for signed types, pgac_cv_c_signed,
|
||||
[AC_TRY_COMPILE([],
|
||||
[signed char c; signed short s; signed int i;],
|
||||
[pgac_cv_c_signed=yes],
|
||||
[pgac_cv_c_signed=no])])
|
||||
if test x"$pgac_cv_c_signed" = xno ; then
|
||||
AC_DEFINE(signed,, [Define to empty if the C compiler does not understand signed types.])
|
||||
fi])# PGAC_C_SIGNED
|
||||
|
||||
|
||||
|
||||
# PGAC_C_INLINE
|
||||
# -------------
|
||||
# Check if the C compiler understands inline functions.
|
||||
# Defines: inline, USE_INLINE
|
||||
AC_DEFUN([PGAC_C_INLINE],
|
||||
[AC_C_INLINE
|
||||
AC_CACHE_CHECK([for quiet inline (no complaint if unreferenced)], pgac_cv_c_inline_quietly,
|
||||
[pgac_cv_c_inline_quietly=no
|
||||
if test "$ac_cv_c_inline" != no; then
|
||||
pgac_c_inline_save_werror=$ac_c_werror_flag
|
||||
ac_c_werror_flag=yes
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([static inline int fun () {return 0;}],[])],
|
||||
[pgac_cv_c_inline_quietly=yes])
|
||||
ac_c_werror_flag=$pgac_c_inline_save_werror
|
||||
fi])
|
||||
if test "$pgac_cv_c_inline_quietly" != no; then
|
||||
AC_DEFINE_UNQUOTED([USE_INLINE], 1,
|
||||
[Define to 1 if "static inline" works without unwanted warnings from ]
|
||||
[compilations where static inline functions are defined but not called.])
|
||||
fi
|
||||
])# PGAC_C_INLINE
|
||||
|
||||
|
||||
|
||||
# PGAC_TYPE_64BIT_INT(TYPE)
|
||||
# -------------------------
|
||||
# Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
|
||||
# yes or no respectively, and define HAVE_TYPE_64 if yes.
|
||||
AC_DEFUN([PGAC_TYPE_64BIT_INT],
|
||||
[define([Ac_define], [translit([have_$1_64], [a-z *], [A-Z_P])])dnl
|
||||
define([Ac_cachevar], [translit([pgac_cv_type_$1_64], [ *], [_p])])dnl
|
||||
AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar],
|
||||
[AC_TRY_RUN(
|
||||
[typedef $1 ac_int64;
|
||||
|
||||
/*
|
||||
* These are globals to discourage the compiler from folding all the
|
||||
* arithmetic tests down to compile-time constants.
|
||||
*/
|
||||
ac_int64 a = 20000001;
|
||||
ac_int64 b = 40000005;
|
||||
|
||||
int does_int64_work()
|
||||
{
|
||||
ac_int64 c,d;
|
||||
|
||||
if (sizeof(ac_int64) != 8)
|
||||
return 0; /* definitely not the right size */
|
||||
|
||||
/* Do perfunctory checks to see if 64-bit arithmetic seems to work */
|
||||
c = a * b;
|
||||
d = (c + b) / b;
|
||||
if (d != a+1)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
main() {
|
||||
return(! does_int64_work());
|
||||
}],
|
||||
[Ac_cachevar=yes],
|
||||
[Ac_cachevar=no],
|
||||
[# If cross-compiling, check the size reported by the compiler and
|
||||
# trust that the arithmetic works.
|
||||
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([], [sizeof($1) == 8])],
|
||||
Ac_cachevar=yes,
|
||||
Ac_cachevar=no)])])
|
||||
|
||||
Ac_define=$Ac_cachevar
|
||||
if test x"$Ac_cachevar" = xyes ; then
|
||||
AC_DEFINE(Ac_define, 1, [Define to 1 if `]$1[' works and is 64 bits.])
|
||||
fi
|
||||
undefine([Ac_define])dnl
|
||||
undefine([Ac_cachevar])dnl
|
||||
])# PGAC_TYPE_64BIT_INT
|
||||
|
||||
|
||||
|
||||
# PGAC_C_FUNCNAME_SUPPORT
|
||||
# -----------------------
|
||||
# Check if the C compiler understands __func__ (C99) or __FUNCTION__ (gcc).
|
||||
# Define HAVE_FUNCNAME__FUNC or HAVE_FUNCNAME__FUNCTION accordingly.
|
||||
AC_DEFUN([PGAC_C_FUNCNAME_SUPPORT],
|
||||
[AC_CACHE_CHECK(for __func__, pgac_cv_funcname_func_support,
|
||||
[AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[printf("%s\n", __func__);],
|
||||
[pgac_cv_funcname_func_support=yes],
|
||||
[pgac_cv_funcname_func_support=no])])
|
||||
if test x"$pgac_cv_funcname_func_support" = xyes ; then
|
||||
AC_DEFINE(HAVE_FUNCNAME__FUNC, 1,
|
||||
[Define to 1 if your compiler understands __func__.])
|
||||
else
|
||||
AC_CACHE_CHECK(for __FUNCTION__, pgac_cv_funcname_function_support,
|
||||
[AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[printf("%s\n", __FUNCTION__);],
|
||||
[pgac_cv_funcname_function_support=yes],
|
||||
[pgac_cv_funcname_function_support=no])])
|
||||
if test x"$pgac_cv_funcname_function_support" = xyes ; then
|
||||
AC_DEFINE(HAVE_FUNCNAME__FUNCTION, 1,
|
||||
[Define to 1 if your compiler understands __FUNCTION__.])
|
||||
fi
|
||||
fi])# PGAC_C_FUNCNAME_SUPPORT
|
||||
|
||||
|
||||
|
||||
# PGAC_PROG_CC_CFLAGS_OPT
|
||||
# -----------------------
|
||||
# Given a string, check if the compiler supports the string as a
|
||||
# command-line option. If it does, add the string to CFLAGS.
|
||||
AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT],
|
||||
[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_cflags_$1])])dnl
|
||||
AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar],
|
||||
[pgac_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="$pgac_save_CFLAGS $1"
|
||||
ac_save_c_werror_flag=$ac_c_werror_flag
|
||||
ac_c_werror_flag=yes
|
||||
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
|
||||
[Ac_cachevar=yes],
|
||||
[Ac_cachevar=no])
|
||||
ac_c_werror_flag=$ac_save_c_werror_flag
|
||||
CFLAGS="$pgac_save_CFLAGS"])
|
||||
if test x"$Ac_cachevar" = x"yes"; then
|
||||
CFLAGS="$CFLAGS $1"
|
||||
fi
|
||||
undefine([Ac_cachevar])dnl
|
||||
])# PGAC_PROG_CC_CFLAGS_OPT
|
||||
|
||||
|
||||
|
||||
# PGAC_PROG_CC_LDFLAGS_OPT
|
||||
# ------------------------
|
||||
# Given a string, check if the compiler supports the string as a
|
||||
# command-line option. If it does, add the string to LDFLAGS.
|
||||
# For reasons you'd really rather not know about, this checks whether
|
||||
# you can link to a particular function, not just whether you can link.
|
||||
# In fact, we must actually check that the resulting program runs :-(
|
||||
AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT],
|
||||
[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_ldflags_$1])])dnl
|
||||
AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar],
|
||||
[pgac_save_LDFLAGS=$LDFLAGS
|
||||
LDFLAGS="$pgac_save_LDFLAGS $1"
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM([extern void $2 (); void (*fptr) () = $2;],[])],
|
||||
[Ac_cachevar=yes],
|
||||
[Ac_cachevar=no],
|
||||
[Ac_cachevar="assuming no"])
|
||||
LDFLAGS="$pgac_save_LDFLAGS"])
|
||||
if test x"$Ac_cachevar" = x"yes"; then
|
||||
LDFLAGS="$LDFLAGS $1"
|
||||
fi
|
||||
undefine([Ac_cachevar])dnl
|
||||
])# PGAC_PROG_CC_LDFLAGS_OPT
|
||||
330
config/c-library.m4
Normal file
330
config/c-library.m4
Normal file
@ -0,0 +1,330 @@
|
||||
# Macros that test various C library quirks
|
||||
# config/c-library.m4
|
||||
|
||||
|
||||
# PGAC_VAR_INT_TIMEZONE
|
||||
# ---------------------
|
||||
# Check if the global variable `timezone' exists. If so, define
|
||||
# HAVE_INT_TIMEZONE.
|
||||
AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
|
||||
[AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
|
||||
[AC_TRY_LINK([#include <time.h>
|
||||
int res;],
|
||||
[#ifndef __CYGWIN__
|
||||
res = timezone / 60;
|
||||
#else
|
||||
res = _timezone / 60;
|
||||
#endif],
|
||||
[pgac_cv_var_int_timezone=yes],
|
||||
[pgac_cv_var_int_timezone=no])])
|
||||
if test x"$pgac_cv_var_int_timezone" = xyes ; then
|
||||
AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global variable 'int timezone'.])
|
||||
fi])# PGAC_VAR_INT_TIMEZONE
|
||||
|
||||
|
||||
# PGAC_STRUCT_TIMEZONE
|
||||
# ------------------
|
||||
# Figure out how to get the current timezone. If `struct tm' has a
|
||||
# `tm_zone' member, define `HAVE_TM_ZONE'. Also, if the
|
||||
# external array `tzname' is found, define `HAVE_TZNAME'.
|
||||
# This is the same as the standard macro AC_STRUCT_TIMEZONE, except that
|
||||
# tzname[] is checked for regardless of whether we find tm_zone.
|
||||
AC_DEFUN([PGAC_STRUCT_TIMEZONE],
|
||||
[AC_REQUIRE([AC_STRUCT_TM])dnl
|
||||
AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
|
||||
#include <$ac_cv_struct_tm>
|
||||
])
|
||||
if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
|
||||
AC_DEFINE(HAVE_TM_ZONE, 1,
|
||||
[Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
|
||||
`HAVE_STRUCT_TM_TM_ZONE' instead.])
|
||||
fi
|
||||
AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
|
||||
[AC_TRY_LINK(
|
||||
[#include <time.h>
|
||||
#ifndef tzname /* For SGI. */
|
||||
extern char *tzname[]; /* RS6000 and others reject char **tzname. */
|
||||
#endif
|
||||
],
|
||||
[atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
|
||||
if test $ac_cv_var_tzname = yes; then
|
||||
AC_DEFINE(HAVE_TZNAME, 1,
|
||||
[Define to 1 if you have the external array `tzname'.])
|
||||
fi
|
||||
])# PGAC_STRUCT_TIMEZONE
|
||||
|
||||
|
||||
# PGAC_FUNC_GETTIMEOFDAY_1ARG
|
||||
# ---------------------------
|
||||
# Check if gettimeofday() has only one arguments. (Normal is two.)
|
||||
# If so, define GETTIMEOFDAY_1ARG.
|
||||
AC_DEFUN([PGAC_FUNC_GETTIMEOFDAY_1ARG],
|
||||
[AC_CACHE_CHECK(whether gettimeofday takes only one argument,
|
||||
pgac_cv_func_gettimeofday_1arg,
|
||||
[AC_TRY_COMPILE([#include <sys/time.h>],
|
||||
[struct timeval *tp;
|
||||
struct timezone *tzp;
|
||||
gettimeofday(tp,tzp);],
|
||||
[pgac_cv_func_gettimeofday_1arg=no],
|
||||
[pgac_cv_func_gettimeofday_1arg=yes])])
|
||||
if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then
|
||||
AC_DEFINE(GETTIMEOFDAY_1ARG,, [Define to 1 if gettimeofday() takes only 1 argument.])
|
||||
fi
|
||||
AH_VERBATIM(GETTIMEOFDAY_1ARG_,
|
||||
[@%:@ifdef GETTIMEOFDAY_1ARG
|
||||
@%:@ define gettimeofday(a,b) gettimeofday(a)
|
||||
@%:@endif])dnl
|
||||
])# PGAC_FUNC_GETTIMEOFDAY_1ARG
|
||||
|
||||
|
||||
# PGAC_FUNC_GETPWUID_R_5ARG
|
||||
# ---------------------------
|
||||
# Check if getpwuid_r() takes a fifth argument (later POSIX standard, not draft version)
|
||||
# If so, define GETPWUID_R_5ARG
|
||||
AC_DEFUN([PGAC_FUNC_GETPWUID_R_5ARG],
|
||||
[AC_CACHE_CHECK(whether getpwuid_r takes a fifth argument,
|
||||
pgac_cv_func_getpwuid_r_5arg,
|
||||
[AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#include <pwd.h>],
|
||||
[uid_t uid;
|
||||
struct passwd *space;
|
||||
char *buf;
|
||||
size_t bufsize;
|
||||
struct passwd **result;
|
||||
getpwuid_r(uid, space, buf, bufsize, result);],
|
||||
[pgac_cv_func_getpwuid_r_5arg=yes],
|
||||
[pgac_cv_func_getpwuid_r_5arg=no])])
|
||||
if test x"$pgac_cv_func_getpwuid_r_5arg" = xyes ; then
|
||||
AC_DEFINE(GETPWUID_R_5ARG,, [Define to 1 if getpwuid_r() takes a 5th argument.])
|
||||
fi
|
||||
])# PGAC_FUNC_GETPWUID_R_5ARG
|
||||
|
||||
|
||||
# PGAC_FUNC_STRERROR_R_INT
|
||||
# ---------------------------
|
||||
# Check if strerror_r() returns an int (SUSv3) rather than a char * (GNU libc)
|
||||
# If so, define STRERROR_R_INT.
|
||||
# We have to change here for using c++ compiler.check if strerror_r() returns a char * firstly.
|
||||
# if so, undefine STRERROR_R_INT.
|
||||
AC_DEFUN([PGAC_FUNC_STRERROR_R_INT],
|
||||
[AC_CACHE_CHECK(whether strerror_r returns int,
|
||||
pgac_cv_func_strerror_r_int,
|
||||
[AC_TRY_COMPILE([#include <string.h>],
|
||||
[#ifndef _AIX
|
||||
char * strerror_r(int, char *, size_t);
|
||||
#else
|
||||
/* Older AIX has 'int' for the third argument so we don't test the args. */
|
||||
char * strerror_r();
|
||||
#endif],
|
||||
[pgac_cv_func_strerror_r_int=no],
|
||||
[pgac_cv_func_strerror_r_int=yes])])
|
||||
if test x"$pgac_cv_func_strerror_r_int" = xyes ; then
|
||||
AC_DEFINE(STRERROR_R_INT,, [Define to 1 if strerror_r() returns a int.])
|
||||
fi
|
||||
])# PGAC_FUNC_STRERROR_R_INT
|
||||
|
||||
|
||||
# PGAC_UNION_SEMUN
|
||||
# ----------------
|
||||
# Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
|
||||
# If it doesn't then one could define it as
|
||||
# union semun { int val; struct semid_ds *buf; unsigned short *array; }
|
||||
AC_DEFUN([PGAC_UNION_SEMUN],
|
||||
[AC_CHECK_TYPES([union semun], [], [],
|
||||
[#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>])])# PGAC_UNION_SEMUN
|
||||
|
||||
|
||||
# PGAC_STRUCT_SOCKADDR_UN
|
||||
# -----------------------
|
||||
# If `struct sockaddr_un' exists, define HAVE_UNIX_SOCKETS.
|
||||
# (Requires test for <sys/un.h>!)
|
||||
AC_DEFUN([PGAC_STRUCT_SOCKADDR_UN],
|
||||
[AC_CHECK_TYPE([struct sockaddr_un], [AC_DEFINE(HAVE_UNIX_SOCKETS, 1, [Define to 1 if you have unix sockets.])], [],
|
||||
[#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
])])# PGAC_STRUCT_SOCKADDR_UN
|
||||
|
||||
|
||||
# PGAC_STRUCT_SOCKADDR_STORAGE
|
||||
# ----------------------------
|
||||
# If `struct sockaddr_storage' exists, define HAVE_STRUCT_SOCKADDR_STORAGE.
|
||||
# If it is missing then one could define it.
|
||||
AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE],
|
||||
[AC_CHECK_TYPES([struct sockaddr_storage], [], [],
|
||||
[#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
])])# PGAC_STRUCT_SOCKADDR_STORAGE
|
||||
|
||||
# PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
|
||||
# --------------------------------------
|
||||
# Check the members of `struct sockaddr_storage'. We need to know about
|
||||
# ss_family and ss_len. (Some platforms follow RFC 2553 and call them
|
||||
# __ss_family and __ss_len.) We also check struct sockaddr's sa_len;
|
||||
# if we have to define our own `struct sockaddr_storage', this tells us
|
||||
# whether we need to provide an ss_len field.
|
||||
AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS],
|
||||
[AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family,
|
||||
struct sockaddr_storage.__ss_family,
|
||||
struct sockaddr_storage.ss_len,
|
||||
struct sockaddr_storage.__ss_len,
|
||||
struct sockaddr.sa_len], [], [],
|
||||
[#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
])])# PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
|
||||
|
||||
|
||||
# PGAC_STRUCT_ADDRINFO
|
||||
# -----------------------
|
||||
# If `struct addrinfo' exists, define HAVE_STRUCT_ADDRINFO.
|
||||
AC_DEFUN([PGAC_STRUCT_ADDRINFO],
|
||||
[AC_CHECK_TYPES([struct addrinfo], [], [],
|
||||
[#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
])])# PGAC_STRUCT_ADDRINFO
|
||||
|
||||
|
||||
# PGAC_FUNC_POSIX_SIGNALS
|
||||
# -----------------------
|
||||
# Check to see if the machine has the POSIX signal interface. Define
|
||||
# HAVE_POSIX_SIGNALS if so. Also set the output variable HAVE_POSIX_SIGNALS
|
||||
# to yes or no.
|
||||
#
|
||||
# Note that this test only compiles a test program, it doesn't check
|
||||
# whether the routines actually work. If that becomes a problem, make
|
||||
# a fancier check.
|
||||
AC_DEFUN([PGAC_FUNC_POSIX_SIGNALS],
|
||||
[AC_CACHE_CHECK(for POSIX signal interface, pgac_cv_func_posix_signals,
|
||||
[AC_TRY_LINK([#include <signal.h>
|
||||
],
|
||||
[struct sigaction act, oact;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = SA_RESTART;
|
||||
sigaction(0, &act, &oact);],
|
||||
[pgac_cv_func_posix_signals=yes],
|
||||
[pgac_cv_func_posix_signals=no])])
|
||||
if test x"$pgac_cv_func_posix_signals" = xyes ; then
|
||||
AC_DEFINE(HAVE_POSIX_SIGNALS,, [Define to 1 if you have the POSIX signal interface.])
|
||||
fi
|
||||
HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
|
||||
AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS
|
||||
|
||||
|
||||
# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
|
||||
# ---------------------------------------
|
||||
# Determine which format snprintf uses for long long int. We handle
|
||||
# %lld, %qd, %I64d. The result is in shell variable
|
||||
# LONG_LONG_INT_FORMAT.
|
||||
#
|
||||
# MinGW uses '%I64d', though gcc throws an warning with -Wall,
|
||||
# while '%lld' doesn't generate a warning, but doesn't work.
|
||||
#
|
||||
AC_DEFUN([PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT],
|
||||
[AC_MSG_CHECKING([snprintf format for long long int])
|
||||
AC_CACHE_VAL(pgac_cv_snprintf_long_long_int_format,
|
||||
[for pgac_format in '%lld' '%qd' '%I64d'; do
|
||||
AC_TRY_RUN([#include <stdio.h>
|
||||
typedef long long int ac_int64;
|
||||
#define INT64_FORMAT "$pgac_format"
|
||||
|
||||
ac_int64 a = 20000001;
|
||||
ac_int64 b = 40000005;
|
||||
|
||||
int does_int64_snprintf_work()
|
||||
{
|
||||
ac_int64 c;
|
||||
char buf[100];
|
||||
|
||||
if (sizeof(ac_int64) != 8)
|
||||
return 0; /* doesn't look like the right size */
|
||||
|
||||
c = a * b;
|
||||
snprintf(buf, 100, INT64_FORMAT, c);
|
||||
if (strcmp(buf, "800000140000005") != 0)
|
||||
return 0; /* either multiply or snprintf is busted */
|
||||
return 1;
|
||||
}
|
||||
main() {
|
||||
exit(! does_int64_snprintf_work());
|
||||
}],
|
||||
[pgac_cv_snprintf_long_long_int_format=$pgac_format; break],
|
||||
[],
|
||||
[pgac_cv_snprintf_long_long_int_format=cross; break])
|
||||
done])dnl AC_CACHE_VAL
|
||||
|
||||
LONG_LONG_INT_FORMAT=''
|
||||
|
||||
case $pgac_cv_snprintf_long_long_int_format in
|
||||
cross) AC_MSG_RESULT([cannot test (not on host machine)]);;
|
||||
?*) AC_MSG_RESULT([$pgac_cv_snprintf_long_long_int_format])
|
||||
LONG_LONG_INT_FORMAT=$pgac_cv_snprintf_long_long_int_format;;
|
||||
*) AC_MSG_RESULT(none);;
|
||||
esac])# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
|
||||
|
||||
|
||||
# PGAC_FUNC_PRINTF_ARG_CONTROL
|
||||
# ---------------------------------------
|
||||
# Determine if printf supports %1$ argument selection, e.g. %5$ selects
|
||||
# the fifth argument after the printf print string.
|
||||
# This is not in the C99 standard, but in the Single Unix Specification (SUS).
|
||||
# It is used in our language translation strings.
|
||||
#
|
||||
AC_DEFUN([PGAC_FUNC_PRINTF_ARG_CONTROL],
|
||||
[AC_MSG_CHECKING([whether printf supports argument control])
|
||||
AC_CACHE_VAL(pgac_cv_printf_arg_control,
|
||||
[AC_TRY_RUN([#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
/* can it swap arguments? */
|
||||
snprintf(buf, 100, "%2\$d %1\$d", 3, 4);
|
||||
if (strcmp(buf, "4 3") != 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}],
|
||||
[pgac_cv_printf_arg_control=yes],
|
||||
[pgac_cv_printf_arg_control=no],
|
||||
[pgac_cv_printf_arg_control=cross])
|
||||
])dnl AC_CACHE_VAL
|
||||
AC_MSG_RESULT([$pgac_cv_printf_arg_control])
|
||||
])# PGAC_FUNC_PRINTF_ARG_CONTROL
|
||||
|
||||
|
||||
# PGAC_TYPE_LOCALE_T
|
||||
# ------------------
|
||||
# Check for the locale_t type and find the right header file. Mac OS
|
||||
# X needs xlocale.h; standard is locale.h, but glibc also has an
|
||||
# xlocale.h file that we should not use.
|
||||
#
|
||||
AC_DEFUN([PGAC_TYPE_LOCALE_T],
|
||||
[AC_CACHE_CHECK([for locale_t], pgac_cv_type_locale_t,
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
||||
[#include <locale.h>
|
||||
locale_t x;],
|
||||
[])],
|
||||
[pgac_cv_type_locale_t=yes],
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
||||
[#include <xlocale.h>
|
||||
locale_t x;],
|
||||
[])],
|
||||
[pgac_cv_type_locale_t='yes (in xlocale.h)'],
|
||||
[pgac_cv_type_locale_t=no])])])
|
||||
if test "$pgac_cv_type_locale_t" != no; then
|
||||
AC_DEFINE(HAVE_LOCALE_T, 1,
|
||||
[Define to 1 if the system has the type `locale_t'.])
|
||||
fi
|
||||
if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
|
||||
AC_DEFINE(LOCALE_T_IN_XLOCALE, 1,
|
||||
[Define to 1 if `locale_t' requires <xlocale.h>.])
|
||||
fi])])# PGAC_HEADER_XLOCALE
|
||||
1530
config/config.guess
vendored
Normal file
1530
config/config.guess
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1777
config/config.sub
vendored
Normal file
1777
config/config.sub
vendored
Normal file
File diff suppressed because it is too large
Load Diff
102
config/docbook.m4
Normal file
102
config/docbook.m4
Normal file
@ -0,0 +1,102 @@
|
||||
# config/docbook.m4
|
||||
|
||||
# PGAC_PROG_JADE
|
||||
# --------------
|
||||
AC_DEFUN([PGAC_PROG_JADE],
|
||||
[AC_CHECK_PROGS([JADE], [openjade jade])])
|
||||
|
||||
|
||||
# PGAC_PROG_NSGMLS
|
||||
# ----------------
|
||||
AC_DEFUN([PGAC_PROG_NSGMLS],
|
||||
[AC_CHECK_PROGS([NSGMLS], [onsgmls nsgmls])])
|
||||
|
||||
|
||||
# PGAC_CHECK_DOCBOOK(VERSION)
|
||||
# ---------------------------
|
||||
AC_DEFUN([PGAC_CHECK_DOCBOOK],
|
||||
[AC_REQUIRE([PGAC_PROG_NSGMLS])
|
||||
AC_CACHE_CHECK([for DocBook V$1], [pgac_cv_check_docbook],
|
||||
[cat >conftest.sgml <<EOF
|
||||
<!doctype book PUBLIC "-//OASIS//DTD DocBook V$1//EN">
|
||||
<book>
|
||||
<title>test</title>
|
||||
<chapter>
|
||||
<title>random</title>
|
||||
<sect1>
|
||||
<title>testsect</title>
|
||||
<para>text</para>
|
||||
</sect1>
|
||||
</chapter>
|
||||
</book>
|
||||
EOF
|
||||
|
||||
pgac_cv_check_docbook=no
|
||||
|
||||
if test -n "$NSGMLS"; then
|
||||
$NSGMLS -s conftest.sgml 1>&AS_MESSAGE_LOG_FD 2>&1
|
||||
if test $? -eq 0; then
|
||||
pgac_cv_check_docbook=yes
|
||||
fi
|
||||
fi
|
||||
rm -f conftest.sgml])
|
||||
|
||||
have_docbook=$pgac_cv_check_docbook
|
||||
AC_SUBST([have_docbook])
|
||||
])# PGAC_CHECK_DOCBOOK
|
||||
|
||||
|
||||
# PGAC_PATH_DOCBOOK_STYLESHEETS
|
||||
# -----------------------------
|
||||
AC_DEFUN([PGAC_PATH_DOCBOOK_STYLESHEETS],
|
||||
[AC_ARG_VAR(DOCBOOKSTYLE, [location of DocBook stylesheets])dnl
|
||||
AC_MSG_CHECKING([for DocBook stylesheets])
|
||||
AC_CACHE_VAL([pgac_cv_path_stylesheets],
|
||||
[if test -n "$DOCBOOKSTYLE"; then
|
||||
pgac_cv_path_stylesheets=$DOCBOOKSTYLE
|
||||
else
|
||||
for pgac_prefix in /usr /usr/local /opt /sw; do
|
||||
for pgac_infix in share lib; do
|
||||
for pgac_postfix in \
|
||||
sgml/stylesheets/nwalsh-modular \
|
||||
sgml/stylesheets/docbook \
|
||||
sgml/stylesheets/dsssl/docbook \
|
||||
sgml/docbook-dsssl \
|
||||
sgml/docbook/dsssl/modular \
|
||||
sgml/docbook/stylesheet/dsssl/modular \
|
||||
sgml/docbook/dsssl-stylesheets \
|
||||
sgml/dsssl/docbook-dsssl-nwalsh
|
||||
do
|
||||
pgac_candidate=$pgac_prefix/$pgac_infix/$pgac_postfix
|
||||
if test -r "$pgac_candidate/html/docbook.dsl" \
|
||||
&& test -r "$pgac_candidate/print/docbook.dsl"
|
||||
then
|
||||
pgac_cv_path_stylesheets=$pgac_candidate
|
||||
break 3
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
fi])
|
||||
DOCBOOKSTYLE=$pgac_cv_path_stylesheets
|
||||
AC_SUBST([DOCBOOKSTYLE])
|
||||
if test -n "$DOCBOOKSTYLE"; then
|
||||
AC_MSG_RESULT([$DOCBOOKSTYLE])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi])# PGAC_PATH_DOCBOOK_STYLESHEETS
|
||||
|
||||
|
||||
# PGAC_PATH_COLLATEINDEX
|
||||
# ----------------------
|
||||
# Some DocBook installations provide collateindex.pl in $DOCBOOKSTYLE/bin,
|
||||
# but it's not necessarily marked executable, so we can't use AC_PATH_PROG
|
||||
# to check for it there. Other installations just put it in the PATH.
|
||||
AC_DEFUN([PGAC_PATH_COLLATEINDEX],
|
||||
[AC_REQUIRE([PGAC_PATH_DOCBOOK_STYLESHEETS])dnl
|
||||
if test -n "$DOCBOOKSTYLE" -a -r "$DOCBOOKSTYLE/bin/collateindex.pl"; then
|
||||
COLLATEINDEX="$DOCBOOKSTYLE/bin/collateindex.pl"
|
||||
AC_SUBST([COLLATEINDEX])
|
||||
else
|
||||
AC_PATH_PROG(COLLATEINDEX, collateindex.pl)
|
||||
fi])# PGAC_PATH_COLLATEINDEX
|
||||
149
config/general.m4
Normal file
149
config/general.m4
Normal file
@ -0,0 +1,149 @@
|
||||
# config/general.m4
|
||||
|
||||
# This file defines new macros to process configure command line
|
||||
# arguments, to replace the brain-dead AC_ARG_WITH and AC_ARG_ENABLE.
|
||||
# The flaw in these is particularly that they only differentiate
|
||||
# between "given" and "not given" and do not provide enough help to
|
||||
# process arguments that only accept "yes/no", that require an
|
||||
# argument (other than "yes/no"), etc.
|
||||
#
|
||||
# The point of this implementation is to reduce code size and
|
||||
# redundancy in configure.in and to improve robustness and consistency
|
||||
# in the option evaluation code.
|
||||
|
||||
|
||||
# Convert type and name to shell variable name (e.g., "enable_long_strings")
|
||||
m4_define([pgac_arg_to_variable],
|
||||
[$1[]_[]patsubst($2, -, _)])
|
||||
|
||||
|
||||
# PGAC_ARG(TYPE, NAME, HELP-STRING-LHS-EXTRA, HELP-STRING-RHS,
|
||||
# [ACTION-IF-YES], [ACTION-IF-NO], [ACTION-IF-ARG],
|
||||
# [ACTION-IF-OMITTED])
|
||||
# ------------------------------------------------------------
|
||||
# This is the base layer. TYPE is either "with" or "enable", depending
|
||||
# on what you like. NAME is the rest of the option name.
|
||||
# HELP-STRING-LHS-EXTRA is a string to append to the option name on
|
||||
# the left-hand side of the help output, e.g., an argument name. If
|
||||
# set to "-", append nothing, but let the option appear in the
|
||||
# negative form (disable/without). HELP-STRING-RHS is the option
|
||||
# description, for the right-hand side of the help output.
|
||||
# ACTION-IF-YES is executed if the option is given without an argument
|
||||
# (or "yes", which is the same); similar for ACTION-IF-NO.
|
||||
|
||||
AC_DEFUN([PGAC_ARG],
|
||||
[
|
||||
m4_case([$1],
|
||||
|
||||
enable, [
|
||||
AC_ARG_ENABLE([$2], [AS_HELP_STRING([--]m4_if($3, -, disable, enable)[-$2]m4_if($3, -, , $3), [$4])], [
|
||||
case [$]enableval in
|
||||
yes)
|
||||
m4_default([$5], :)
|
||||
;;
|
||||
no)
|
||||
m4_default([$6], :)
|
||||
;;
|
||||
*)
|
||||
$7
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[$8])[]dnl AC_ARG_ENABLE
|
||||
],
|
||||
|
||||
with, [
|
||||
AC_ARG_WITH([$2], [AS_HELP_STRING([--]m4_if($3, -, without, with)[-$2]m4_if($3, -, , $3), [$4])], [
|
||||
case [$]withval in
|
||||
yes)
|
||||
m4_default([$5], :)
|
||||
;;
|
||||
no)
|
||||
m4_default([$6], :)
|
||||
;;
|
||||
*)
|
||||
$7
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[$8])[]dnl AC_ARG_WITH
|
||||
],
|
||||
|
||||
[m4_fatal([first argument of $0 must be 'enable' or 'with', not '$1'])]
|
||||
)
|
||||
])# PGAC_ARG
|
||||
|
||||
|
||||
# PGAC_ARG_BOOL(TYPE, NAME, DEFAULT, HELP-STRING-RHS,
|
||||
# [ACTION-IF-YES], [ACTION-IF-NO])
|
||||
# ---------------------------------------------------
|
||||
# Accept a boolean option, that is, one that only takes yes or no.
|
||||
# ("no" is equivalent to "disable" or "without"). DEFAULT is what
|
||||
# should be done if the option is omitted; it should be "yes" or "no".
|
||||
# (Consequently, one of ACTION-IF-YES and ACTION-IF-NO will always
|
||||
# execute.)
|
||||
|
||||
AC_DEFUN([PGAC_ARG_BOOL],
|
||||
[dnl The following hack is necessary because in a few instances this
|
||||
dnl macro is called twice for the same option with different default
|
||||
dnl values. But we only want it to appear once in the help. We achieve
|
||||
dnl that by making the help string look the same, which is why we need to
|
||||
dnl save the default that was passed in previously.
|
||||
m4_define([_pgac_helpdefault], m4_ifdef([pgac_defined_$1_$2_bool], [m4_defn([pgac_defined_$1_$2_bool])], [$3]))dnl
|
||||
PGAC_ARG([$1], [$2], [m4_if(_pgac_helpdefault, yes, -)], [$4], [$5], [$6],
|
||||
[AC_MSG_ERROR([no argument expected for --$1-$2 option])],
|
||||
[m4_case([$3],
|
||||
yes, [pgac_arg_to_variable([$1], [$2])=yes
|
||||
$5],
|
||||
no, [pgac_arg_to_variable([$1], [$2])=no
|
||||
$6],
|
||||
[m4_fatal([third argument of $0 must be 'yes' or 'no', not '$3'])])])[]dnl
|
||||
m4_define([pgac_defined_$1_$2_bool], [$3])dnl
|
||||
])# PGAC_ARG_BOOL
|
||||
|
||||
|
||||
# PGAC_ARG_REQ(TYPE, NAME, HELP-ARGNAME, HELP-STRING-RHS,
|
||||
# [ACTION-IF-GIVEN], [ACTION-IF-NOT-GIVEN])
|
||||
# -------------------------------------------------------
|
||||
# This option will require an argument; "yes" or "no" will not be
|
||||
# accepted. HELP-ARGNAME is a name for the argument for the help output.
|
||||
|
||||
AC_DEFUN([PGAC_ARG_REQ],
|
||||
[PGAC_ARG([$1], [$2], [=$3], [$4],
|
||||
[AC_MSG_ERROR([argument required for --$1-$2 option])],
|
||||
[AC_MSG_ERROR([argument required for --$1-$2 option])],
|
||||
[$5],
|
||||
[$6])])# PGAC_ARG_REQ
|
||||
|
||||
|
||||
# PGAC_ARG_OPTARG(TYPE, NAME, HELP-ARGNAME, HELP-STRING-RHS,
|
||||
# [DEFAULT-ACTION], [ARG-ACTION],
|
||||
# [ACTION-ENABLED], [ACTION-DISABLED])
|
||||
# ----------------------------------------------------------
|
||||
# This will create an option that behaves as follows: If omitted, or
|
||||
# called with "no", then set the enable_variable to "no" and do
|
||||
# nothing else. If called with "yes", then execute DEFAULT-ACTION. If
|
||||
# called with argument, set enable_variable to "yes" and execute
|
||||
# ARG-ACTION. Additionally, execute ACTION-ENABLED if we ended up with
|
||||
# "yes" either way, else ACTION-DISABLED.
|
||||
#
|
||||
# The intent is to allow enabling a feature, and optionally pass an
|
||||
# additional piece of information.
|
||||
|
||||
AC_DEFUN([PGAC_ARG_OPTARG],
|
||||
[PGAC_ARG([$1], [$2], [@<:@=$3@:>@], [$4], [$5], [],
|
||||
[pgac_arg_to_variable([$1], [$2])=yes
|
||||
$6],
|
||||
[pgac_arg_to_variable([$1], [$2])=no])
|
||||
dnl Add this code only if there's a ACTION-ENABLED or ACTION-DISABLED.
|
||||
m4_ifval([$7[]$8],
|
||||
[
|
||||
if test "[$]pgac_arg_to_variable([$1], [$2])" = yes; then
|
||||
m4_default([$7], :)
|
||||
m4_ifval([$8],
|
||||
[else
|
||||
$8
|
||||
])[]dnl
|
||||
fi
|
||||
])[]dnl
|
||||
])# PGAC_ARG_OPTARG
|
||||
527
config/install-sh
Executable file
527
config/install-sh
Executable file
@ -0,0 +1,527 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
# config/install-sh
|
||||
|
||||
scriptversion=2009-08-26.20
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
# Darwin normal strip removes symbols from shared libraries that are
|
||||
# later needed for dynamic linking, so use strip -x.
|
||||
# http://archives.postgresql.org/pgsql-hackers/2007-10/msg01470.php
|
||||
case `uname -s` in
|
||||
Darwin) stripprog="${STRIPPROG-strip -x}";;
|
||||
esac
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
case $src in
|
||||
-*) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dst_arg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
-*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test -z "$d" && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
||||
119
config/libtool.m4
vendored
Normal file
119
config/libtool.m4
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
## libtool.m4 - Configure libtool for the host system. -*-Shell-script-*-
|
||||
## Copyright (C) 1996-1999,2000 Free Software Foundation, Inc.
|
||||
## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but
|
||||
## WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## As a special exception to the GNU General Public License, if you
|
||||
## distribute this file as part of a program that contains a
|
||||
## configuration script generated by Autoconf, you may include it under
|
||||
## the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# No, PostgreSQL doesn't use libtool (yet), we just borrow stuff from it.
|
||||
# This file was taken on 2000-10-20 from the multi-language branch (since
|
||||
# that is the branch that PostgreSQL would most likely adopt anyway).
|
||||
# --petere
|
||||
|
||||
# ... bunch of stuff removed here ...
|
||||
|
||||
# PGAC_PROG_LD - find the path to the GNU or non-GNU linker
|
||||
AC_DEFUN([PGAC_PROG_LD],
|
||||
[AC_ARG_WITH(gnu-ld,
|
||||
[ --with-gnu-ld assume the C compiler uses GNU ld [[default=no]]],
|
||||
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
|
||||
AC_REQUIRE([AC_PROG_CC])dnl
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
dnl ###not for PostgreSQL### AC_REQUIRE([AC_CANONICAL_BUILD])dnl
|
||||
ac_prog=ld
|
||||
if test "$GCC" = yes; then
|
||||
# Check if gcc -print-prog-name=ld gives a path.
|
||||
AC_MSG_CHECKING([for ld used by GCC])
|
||||
case $host in
|
||||
*-*-mingw*)
|
||||
# gcc leaves a trailing carriage return which upsets mingw
|
||||
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
|
||||
*)
|
||||
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
|
||||
esac
|
||||
case "$ac_prog" in
|
||||
# Accept absolute paths.
|
||||
changequote(,)dnl
|
||||
[\\/]* | [A-Za-z]:[\\/]*)
|
||||
re_direlt='/[^/][^/]*/\.\./'
|
||||
changequote([,])dnl
|
||||
# Canonicalize the path of ld
|
||||
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
|
||||
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
|
||||
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
|
||||
done
|
||||
test -z "$LD" && LD="$ac_prog"
|
||||
;;
|
||||
"")
|
||||
# If it fails, then pretend we aren't using GCC.
|
||||
ac_prog=ld
|
||||
;;
|
||||
*)
|
||||
# If it is relative, then search for the first ld in PATH.
|
||||
with_gnu_ld=unknown
|
||||
;;
|
||||
esac
|
||||
elif test "$with_gnu_ld" = yes; then
|
||||
AC_MSG_CHECKING([for GNU ld])
|
||||
else
|
||||
AC_MSG_CHECKING([for non-GNU ld])
|
||||
fi
|
||||
AC_CACHE_VAL(ac_cv_path_LD,
|
||||
[if test -z "$LD"; then
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
|
||||
ac_cv_path_LD="$ac_dir/$ac_prog"
|
||||
# Check to see if the program is GNU ld. I'd rather use --version,
|
||||
# but apparently some GNU ld's only accept -v.
|
||||
# Break only if it was the GNU/non-GNU ld that we prefer.
|
||||
if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
|
||||
test "$with_gnu_ld" != no && break
|
||||
else
|
||||
test "$with_gnu_ld" != yes && break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
else
|
||||
ac_cv_path_LD="$LD" # Let the user override the test with a path.
|
||||
fi])
|
||||
LD="$ac_cv_path_LD"
|
||||
if test -n "$LD"; then
|
||||
AC_MSG_RESULT($LD)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
|
||||
PGAC_PROG_LD_GNU
|
||||
])
|
||||
|
||||
AC_DEFUN([PGAC_PROG_LD_GNU],
|
||||
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
|
||||
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
|
||||
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
|
||||
ac_cv_prog_gnu_ld=yes
|
||||
else
|
||||
ac_cv_prog_gnu_ld=no
|
||||
fi])
|
||||
with_gnu_ld=$ac_cv_prog_gnu_ld
|
||||
])
|
||||
|
||||
# ... more stuff removed ...
|
||||
54
config/missing
Normal file
54
config/missing
Normal file
@ -0,0 +1,54 @@
|
||||
#! /bin/sh
|
||||
|
||||
# config/missing
|
||||
|
||||
# This is *not* the GNU `missing' script, although it is similar in
|
||||
# concept. You can call it from the makefiles to get consistent
|
||||
# behavior when certain utility programs are missing.
|
||||
|
||||
case $1 in
|
||||
flex|bison)
|
||||
# `missing flex|bison <input> <output>'
|
||||
input=$2
|
||||
output=$3
|
||||
if test -f "$output"; then
|
||||
echo "\
|
||||
***
|
||||
WARNING: \`$1' is missing on your system. You should only need it
|
||||
if you changed the file \`$input'; these changes will not take effect.
|
||||
You can get $1 from a GNU mirror site.
|
||||
***" >&2
|
||||
echo "touch $output"
|
||||
touch "$output"
|
||||
exit 0
|
||||
else # ! test -f $output
|
||||
echo "\
|
||||
***
|
||||
ERROR: \`$1' is missing on your system. It is needed to create the
|
||||
file \`$output'. You can either get $1 from a GNU mirror site
|
||||
or download an official distribution of PostgreSQL, which contains
|
||||
pre-packaged $1 output.
|
||||
***" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
perl)
|
||||
# `missing perl'
|
||||
echo "\
|
||||
***
|
||||
ERROR: Perl is missing on your system. It is needed unless you are building
|
||||
from an unmodified official distribution of PostgreSQL.
|
||||
***" >&2
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
# `missing something-or-other'
|
||||
echo "\
|
||||
***
|
||||
ERROR: \`$1' is missing on your system.
|
||||
***" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
72
config/perl.m4
Normal file
72
config/perl.m4
Normal file
@ -0,0 +1,72 @@
|
||||
# config/perl.m4
|
||||
|
||||
|
||||
# PGAC_PATH_PERL
|
||||
# --------------
|
||||
AC_DEFUN([PGAC_PATH_PERL],
|
||||
[# Let the user override the search
|
||||
if test -z "$PERL"; then
|
||||
AC_PATH_PROG(PERL, perl)
|
||||
fi
|
||||
|
||||
if test "$PERL"; then
|
||||
pgac_perl_version=`$PERL -v 2>/dev/null | sed -n ['s/This is perl.*v[a-z ]*\([0-9]\.[0-9][0-9.]*\).*$/\1/p']`
|
||||
AC_MSG_NOTICE([using perl $pgac_perl_version])
|
||||
if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
|
||||
$AWK '{ if ([$]1 = 5 && [$]2 >= 8) exit 1; else exit 0;}'
|
||||
then
|
||||
AC_MSG_WARN([
|
||||
*** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
|
||||
*** Perl version 5.8 or later is required, but this is $pgac_perl_version.])
|
||||
PERL=""
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$PERL"; then
|
||||
AC_MSG_WARN([
|
||||
*** Without Perl you will not be able to build PostgreSQL from Git.
|
||||
*** You can obtain Perl from any CPAN mirror site.
|
||||
*** (If you are using the official distribution of PostgreSQL then you do not
|
||||
*** need to worry about this, because the Perl output is pre-generated.)])
|
||||
fi
|
||||
])# PGAC_PATH_PERL
|
||||
|
||||
|
||||
# PGAC_CHECK_PERL_CONFIG(NAME)
|
||||
# ----------------------------
|
||||
AC_DEFUN([PGAC_CHECK_PERL_CONFIG],
|
||||
[AC_REQUIRE([PGAC_PATH_PERL])
|
||||
AC_MSG_CHECKING([for Perl $1])
|
||||
perl_$1=`$PERL -MConfig -e 'print $Config{$1}'`
|
||||
AC_SUBST(perl_$1)dnl
|
||||
AC_MSG_RESULT([$perl_$1])])
|
||||
|
||||
|
||||
# PGAC_CHECK_PERL_CONFIGS(NAMES)
|
||||
# ------------------------------
|
||||
AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
|
||||
[m4_foreach([pgac_item], [$1], [PGAC_CHECK_PERL_CONFIG(pgac_item)])])
|
||||
|
||||
|
||||
# PGAC_CHECK_PERL_EMBED_LDFLAGS
|
||||
# -----------------------------
|
||||
# We are after Embed's ldopts, but without the subset mentioned in
|
||||
# Config's ccdlflags; and also without any -arch flags, which recent
|
||||
# Apple releases put in unhelpfully. (If you want a multiarch build
|
||||
# you'd better be specifying it in more places than plperl's final link.)
|
||||
AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
|
||||
[AC_REQUIRE([PGAC_PATH_PERL])
|
||||
AC_MSG_CHECKING(for flags to link embedded Perl)
|
||||
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
|
||||
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
|
||||
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
|
||||
AC_SUBST(perl_embed_ldflags)dnl
|
||||
if test -z "$perl_embed_ldflags" ; then
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([could not determine flags for linking embedded Perl.
|
||||
This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not
|
||||
installed.])
|
||||
else
|
||||
AC_MSG_RESULT([$perl_embed_ldflags])
|
||||
fi
|
||||
])# PGAC_CHECK_PERL_EMBED_LDFLAGS
|
||||
45
config/prep_buildtree
Normal file
45
config/prep_buildtree
Normal file
@ -0,0 +1,45 @@
|
||||
#! /bin/sh
|
||||
|
||||
# This script prepares a PostgreSQL build tree. It is intended
|
||||
# to be run by the configure script.
|
||||
|
||||
me=`basename $0`
|
||||
|
||||
help="\
|
||||
Usage: $me sourcetree [buildtree]"
|
||||
|
||||
if test -z "$1"; then
|
||||
echo "$help" 1>&2
|
||||
exit 1
|
||||
elif test x"$1" = x"--help"; then
|
||||
echo "$help"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
unset CDPATH
|
||||
|
||||
sourcetree=`cd $1 && pwd`
|
||||
|
||||
buildtree=`cd ${2:-'.'} && pwd`
|
||||
|
||||
# We must not auto-create the subdirectories holding built documentation.
|
||||
# If we did, it would interfere with installation of prebuilt docs from
|
||||
# the source tree, if a VPATH build is done from a distribution tarball.
|
||||
# See bug #5595.
|
||||
for item in `find "$sourcetree" -type d \( \( -name CVS -prune \) -o \( -name .git -prune \) -o -print \) | grep -v "$sourcetree/doc/src/sgml/\+"`; do
|
||||
subdir=`expr "$item" : "$sourcetree\(.*\)"`
|
||||
if test ! -d "$buildtree/$subdir"; then
|
||||
mkdir -p "$buildtree/$subdir" || exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
|
||||
filename=`expr "$item" : "$sourcetree\(.*\)"`
|
||||
if test ! -f "${item}.in"; then
|
||||
if cmp "$item" "$buildtree/$filename" >/dev/null 2>&1; then : ; else
|
||||
ln -fs "$item" "$buildtree/$filename" || exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
227
config/programs.m4
Normal file
227
config/programs.m4
Normal file
@ -0,0 +1,227 @@
|
||||
# config/programs.m4
|
||||
|
||||
|
||||
# PGAC_PATH_BISON
|
||||
# ---------------
|
||||
# Look for Bison, set the output variable BISON to its path if found.
|
||||
# Reject versions before 1.875 (they have bugs or capacity limits).
|
||||
# Note we do not accept other implementations of yacc.
|
||||
|
||||
AC_DEFUN([PGAC_PATH_BISON],
|
||||
[# Let the user override the search
|
||||
if test -z "$BISON"; then
|
||||
AC_PATH_PROGS(BISON, bison)
|
||||
fi
|
||||
|
||||
if test "$BISON"; then
|
||||
pgac_bison_version=`$BISON --version 2>/dev/null | sed q`
|
||||
AC_MSG_NOTICE([using $pgac_bison_version])
|
||||
if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 1.875) exit 0; else exit 1;}'
|
||||
then
|
||||
AC_MSG_WARN([
|
||||
*** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
|
||||
*** Bison version 1.875 or later is required, but this is $pgac_bison_version.])
|
||||
BISON=""
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$BISON"; then
|
||||
AC_MSG_WARN([
|
||||
*** Without Bison you will not be able to build PostgreSQL from Git nor
|
||||
*** change any of the parser definition files. You can obtain Bison from
|
||||
*** a GNU mirror site. (If you are using the official distribution of
|
||||
*** PostgreSQL then you do not need to worry about this, because the Bison
|
||||
*** output is pre-generated.)])
|
||||
fi
|
||||
# We don't need AC_SUBST(BISON) because AC_PATH_PROG did it
|
||||
AC_SUBST(BISONFLAGS)
|
||||
])# PGAC_PATH_BISON
|
||||
|
||||
|
||||
|
||||
# PGAC_PATH_FLEX
|
||||
# --------------
|
||||
# Look for Flex, set the output variable FLEX to its path if found.
|
||||
# Reject versions before 2.5.31, as we need a reasonably non-buggy reentrant
|
||||
# scanner. (Note: the well-publicized security problem in 2.5.31 does not
|
||||
# affect Postgres, and there are still distros shipping patched 2.5.31,
|
||||
# so allow it.) Also find Flex if its installed under `lex', but do not
|
||||
# accept other Lex programs.
|
||||
|
||||
AC_DEFUN([PGAC_PATH_FLEX],
|
||||
[AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
|
||||
[# Let the user override the test
|
||||
if test -n "$FLEX"; then
|
||||
pgac_cv_path_flex=$FLEX
|
||||
else
|
||||
pgac_save_IFS=$IFS
|
||||
IFS=$PATH_SEPARATOR
|
||||
for pgac_dir in $PATH; do
|
||||
IFS=$pgac_save_IFS
|
||||
if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
|
||||
pgac_dir=`pwd`
|
||||
fi
|
||||
for pgac_prog in flex lex; do
|
||||
pgac_candidate="$pgac_dir/$pgac_prog"
|
||||
if test -f "$pgac_candidate" \
|
||||
&& $pgac_candidate --version </dev/null >/dev/null 2>&1
|
||||
then
|
||||
echo '%%' > conftest.l
|
||||
if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
|
||||
pgac_flex_version=`$pgac_candidate --version 2>/dev/null`
|
||||
if echo "$pgac_flex_version" | sed ['s/[.a-z]/ /g'] | $AWK '{ if ([$]1 = 2 && [$]2 = 5 && [$]3 >= 31) exit 0; else exit 1;}'
|
||||
then
|
||||
pgac_cv_path_flex=$pgac_candidate
|
||||
break 2
|
||||
else
|
||||
AC_MSG_WARN([
|
||||
*** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
|
||||
*** Flex version 2.5.31 or later is required, but this is $pgac_flex_version.])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
rm -f conftest.l lex.yy.c
|
||||
: ${pgac_cv_path_flex=no}
|
||||
fi
|
||||
])[]dnl AC_CACHE_CHECK
|
||||
|
||||
if test x"$pgac_cv_path_flex" = x"no"; then
|
||||
AC_MSG_WARN([
|
||||
*** Without Flex you will not be able to build PostgreSQL from Git nor
|
||||
*** change any of the scanner definition files. You can obtain Flex from
|
||||
*** a GNU mirror site. (If you are using the official distribution of
|
||||
*** PostgreSQL then you do not need to worry about this because the Flex
|
||||
*** output is pre-generated.)])
|
||||
|
||||
FLEX=
|
||||
else
|
||||
FLEX=$pgac_cv_path_flex
|
||||
pgac_flex_version=`$FLEX --version 2>/dev/null`
|
||||
AC_MSG_NOTICE([using $pgac_flex_version])
|
||||
fi
|
||||
|
||||
AC_SUBST(FLEX)
|
||||
AC_SUBST(FLEXFLAGS)
|
||||
])# PGAC_PATH_FLEX
|
||||
|
||||
|
||||
|
||||
# PGAC_CHECK_READLINE
|
||||
# -------------------
|
||||
# Check for the readline library and dependent libraries, either
|
||||
# termcap or curses. Also try libedit, since NetBSD's is compatible.
|
||||
# Add the required flags to LIBS, define HAVE_LIBREADLINE.
|
||||
|
||||
AC_DEFUN([PGAC_CHECK_READLINE],
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
|
||||
AC_CACHE_CHECK([for library containing readline], [pgac_cv_check_readline],
|
||||
[pgac_cv_check_readline=no
|
||||
pgac_save_LIBS=$LIBS
|
||||
if test x"$with_libedit_preferred" != x"yes"
|
||||
then READLINE_ORDER="-lreadline -ledit"
|
||||
else READLINE_ORDER="-ledit -lreadline"
|
||||
fi
|
||||
for pgac_rllib in $READLINE_ORDER ; do
|
||||
for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
|
||||
LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS"
|
||||
AC_TRY_LINK_FUNC([readline], [[
|
||||
# Older NetBSD, OpenBSD, and Irix have a broken linker that does not
|
||||
# recognize dependent libraries; assume curses is needed if we didn't
|
||||
# find any dependency.
|
||||
case $host_os in
|
||||
netbsd* | openbsd* | irix*)
|
||||
if test x"$pgac_lib" = x"" ; then
|
||||
pgac_lib=" -lcurses"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
|
||||
break
|
||||
]])
|
||||
done
|
||||
if test "$pgac_cv_check_readline" != no ; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
LIBS=$pgac_save_LIBS
|
||||
])[]dnl AC_CACHE_CHECK
|
||||
|
||||
if test "$pgac_cv_check_readline" != no ; then
|
||||
LIBS="$pgac_cv_check_readline $LIBS"
|
||||
AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have a function readline library])
|
||||
fi
|
||||
|
||||
])# PGAC_CHECK_READLINE
|
||||
|
||||
|
||||
|
||||
# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
|
||||
# ---------------------------------------
|
||||
# Readline versions < 2.1 don't have rl_completion_append_character
|
||||
|
||||
AC_DEFUN([PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER],
|
||||
[AC_CACHE_CHECK([for rl_completion_append_character], pgac_cv_var_rl_completion_append_character,
|
||||
[AC_TRY_LINK([#include <stdio.h>
|
||||
#ifdef HAVE_READLINE_READLINE_H
|
||||
# include <readline/readline.h>
|
||||
#elif defined(HAVE_READLINE_H)
|
||||
# include <readline.h>
|
||||
#endif
|
||||
],
|
||||
[rl_completion_append_character = 'x';],
|
||||
[pgac_cv_var_rl_completion_append_character=yes],
|
||||
[pgac_cv_var_rl_completion_append_character=no])])
|
||||
if test x"$pgac_cv_var_rl_completion_append_character" = x"yes"; then
|
||||
AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
|
||||
[Define to 1 if you have the global variable 'rl_completion_append_character'.])
|
||||
fi])# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
|
||||
|
||||
|
||||
|
||||
# PGAC_CHECK_GETTEXT
|
||||
# ------------------
|
||||
# We check for bind_textdomain_codeset() not just gettext(). GNU gettext
|
||||
# before 0.10.36 does not have that function, and is generally too incomplete
|
||||
# to be usable.
|
||||
|
||||
AC_DEFUN([PGAC_CHECK_GETTEXT],
|
||||
[
|
||||
AC_SEARCH_LIBS(bind_textdomain_codeset, intl, [],
|
||||
[AC_MSG_ERROR([a gettext implementation is required for NLS])])
|
||||
AC_CHECK_HEADER([libintl.h], [],
|
||||
[AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
|
||||
AC_CHECK_PROGS(MSGFMT, msgfmt)
|
||||
if test -z "$MSGFMT"; then
|
||||
AC_MSG_ERROR([msgfmt is required for NLS])
|
||||
fi
|
||||
AC_CHECK_PROGS(MSGMERGE, msgmerge)
|
||||
AC_CHECK_PROGS(XGETTEXT, xgettext)
|
||||
])# PGAC_CHECK_GETTEXT
|
||||
|
||||
|
||||
|
||||
# PGAC_CHECK_STRIP
|
||||
# ----------------
|
||||
# Check for a 'strip' program, and figure out if that program can
|
||||
# strip libraries.
|
||||
|
||||
AC_DEFUN([PGAC_CHECK_STRIP],
|
||||
[
|
||||
AC_CHECK_TOOL(STRIP, strip, :)
|
||||
|
||||
AC_MSG_CHECKING([whether it is possible to strip libraries])
|
||||
if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
|
||||
STRIP_STATIC_LIB="$STRIP -x"
|
||||
STRIP_SHARED_LIB="$STRIP --strip-unneeded"
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
STRIP_STATIC_LIB=:
|
||||
STRIP_SHARED_LIB=:
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
AC_SUBST(STRIP_STATIC_LIB)
|
||||
AC_SUBST(STRIP_SHARED_LIB)
|
||||
])# PGAC_CHECK_STRIP
|
||||
102
config/python.m4
Normal file
102
config/python.m4
Normal file
@ -0,0 +1,102 @@
|
||||
#
|
||||
# Autoconf macros for configuring the build of Python extension modules
|
||||
#
|
||||
# config/python.m4
|
||||
#
|
||||
|
||||
# PGAC_PATH_PYTHON
|
||||
# ----------------
|
||||
# Look for Python and set the output variable 'PYTHON'
|
||||
# to 'python' if found, empty otherwise.
|
||||
AC_DEFUN([PGAC_PATH_PYTHON],
|
||||
[AC_PATH_PROG(PYTHON, python)
|
||||
if test x"$PYTHON" = x""; then
|
||||
AC_MSG_ERROR([Python not found])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
# _PGAC_CHECK_PYTHON_DIRS
|
||||
# -----------------------
|
||||
# Determine the name of various directories of a given Python installation.
|
||||
AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
|
||||
[AC_REQUIRE([PGAC_PATH_PYTHON])
|
||||
AC_MSG_CHECKING([for Python distutils module])
|
||||
if "${PYTHON}" -c 'import distutils' 2>&AS_MESSAGE_LOG_FD
|
||||
then
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([distutils module not found])
|
||||
fi
|
||||
AC_MSG_CHECKING([Python configuration directory])
|
||||
python_majorversion=`${PYTHON} -c "import sys; print(sys.version[[0]])"`
|
||||
python_version=`${PYTHON} -c "import sys; print(sys.version[[:3]])"`
|
||||
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
|
||||
python_includespec=`${PYTHON} -c "import distutils.sysconfig; print('-I'+distutils.sysconfig.get_python_inc())"`
|
||||
|
||||
AC_SUBST(python_majorversion)[]dnl
|
||||
AC_SUBST(python_version)[]dnl
|
||||
AC_SUBST(python_configdir)[]dnl
|
||||
AC_SUBST(python_includespec)[]dnl
|
||||
# This should be enough of a message.
|
||||
AC_MSG_RESULT([$python_configdir])
|
||||
])# _PGAC_CHECK_PYTHON_DIRS
|
||||
|
||||
|
||||
# PGAC_CHECK_PYTHON_EMBED_SETUP
|
||||
# -----------------------------
|
||||
#
|
||||
# Note: selecting libpython from python_configdir works in all Python
|
||||
# releases, but it generally finds a non-shared library, which means
|
||||
# that we are binding the python interpreter right into libplpython.so.
|
||||
# In Python 2.3 and up there should be a shared library available in
|
||||
# the main library location.
|
||||
AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
|
||||
[AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
|
||||
AC_MSG_CHECKING([how to link an embedded Python application])
|
||||
|
||||
python_libdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBDIR'))))"`
|
||||
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"`
|
||||
python_so=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('SO'))))"`
|
||||
ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
|
||||
|
||||
if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
|
||||
then
|
||||
# New way: use the official shared library
|
||||
ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
|
||||
python_libspec="-L${python_libdir} -l${ldlibrary}"
|
||||
else
|
||||
# Old way: use libpython from python_configdir
|
||||
python_libdir="${python_configdir}"
|
||||
# LDVERSION was introduced in Python 3.2.
|
||||
python_ldversion=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDVERSION'))))"`
|
||||
if test x"${python_ldversion}" = x""; then
|
||||
python_ldversion=$python_version
|
||||
fi
|
||||
python_libspec="-L${python_libdir} -lpython${python_ldversion}"
|
||||
fi
|
||||
|
||||
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
|
||||
|
||||
AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
|
||||
|
||||
AC_SUBST(python_libdir)[]dnl
|
||||
AC_SUBST(python_libspec)[]dnl
|
||||
AC_SUBST(python_additional_libs)[]dnl
|
||||
|
||||
# threaded python is not supported on OpenBSD
|
||||
AC_MSG_CHECKING(whether Python is compiled with thread support)
|
||||
pythreads=`${PYTHON} -c "import sys; print(int('thread' in sys.builtin_module_names))"`
|
||||
if test "$pythreads" = "1"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
case $host_os in
|
||||
openbsd*)
|
||||
AC_MSG_ERROR([threaded Python not supported on this platform])
|
||||
;;
|
||||
esac
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
])# PGAC_CHECK_PYTHON_EMBED_SETUP
|
||||
93
config/tcl.m4
Normal file
93
config/tcl.m4
Normal file
@ -0,0 +1,93 @@
|
||||
# config/tcl.m4
|
||||
|
||||
# Autoconf macros to check for Tcl related things
|
||||
|
||||
|
||||
AC_DEFUN([PGAC_PATH_TCLSH],
|
||||
[AC_PATH_PROGS(TCLSH, [tclsh tcl tclsh8.5 tclsh85 tclsh8.4 tclsh84 tclsh8.3 tclsh83])
|
||||
if test x"$TCLSH" = x""; then
|
||||
AC_MSG_ERROR([Tcl shell not found])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
# PGAC_PATH_TCLCONFIGSH([SEARCH-PATH])
|
||||
# ------------------------------------
|
||||
AC_DEFUN([PGAC_PATH_TCLCONFIGSH],
|
||||
[AC_REQUIRE([PGAC_PATH_TCLSH])[]dnl
|
||||
AC_BEFORE([$0], [PGAC_PATH_TKCONFIGSH])[]dnl
|
||||
AC_MSG_CHECKING([for tclConfig.sh])
|
||||
# Let user override test
|
||||
if test -z "$TCL_CONFIG_SH"; then
|
||||
pgac_test_dirs="$1"
|
||||
|
||||
set X $pgac_test_dirs; shift
|
||||
if test $[#] -eq 0; then
|
||||
test -z "$TCLSH" && AC_MSG_ERROR([unable to locate tclConfig.sh because no Tcl shell was found])
|
||||
set X `echo 'puts $auto_path' | $TCLSH`; shift
|
||||
fi
|
||||
|
||||
for pgac_dir do
|
||||
if test -r "$pgac_dir/tclConfig.sh"; then
|
||||
TCL_CONFIG_SH=$pgac_dir/tclConfig.sh
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -z "$TCL_CONFIG_SH"; then
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([file 'tclConfig.sh' is required for Tcl])
|
||||
else
|
||||
AC_MSG_RESULT([$TCL_CONFIG_SH])
|
||||
fi
|
||||
|
||||
AC_SUBST([TCL_CONFIG_SH])
|
||||
])# PGAC_PATH_TCLCONFIGSH
|
||||
|
||||
|
||||
# PGAC_PATH_TKCONFIGSH([SEARCH-PATH])
|
||||
# ------------------------------------
|
||||
AC_DEFUN([PGAC_PATH_TKCONFIGSH],
|
||||
[AC_REQUIRE([PGAC_PATH_TCLSH])[]dnl
|
||||
AC_MSG_CHECKING([for tkConfig.sh])
|
||||
# Let user override test
|
||||
if test -z "$TK_CONFIG_SH"; then
|
||||
pgac_test_dirs="$1"
|
||||
|
||||
set X $pgac_test_dirs; shift
|
||||
if test $[#] -eq 0; then
|
||||
test -z "$TCLSH" && AC_MSG_ERROR([unable to locate tkConfig.sh because no Tcl shell was found])
|
||||
set X `echo 'puts $auto_path' | $TCLSH`; shift
|
||||
fi
|
||||
|
||||
for pgac_dir do
|
||||
if test -r "$pgac_dir/tkConfig.sh"; then
|
||||
TK_CONFIG_SH=$pgac_dir/tkConfig.sh
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -z "$TK_CONFIG_SH"; then
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([file 'tkConfig.sh' is required for Tk])
|
||||
else
|
||||
AC_MSG_RESULT([$TK_CONFIG_SH])
|
||||
fi
|
||||
|
||||
AC_SUBST([TK_CONFIG_SH])
|
||||
])# PGAC_PATH_TKCONFIGSH
|
||||
|
||||
|
||||
# PGAC_EVAL_TCLCONFIGSH(FILE, WANTED-VARS)
|
||||
# ----------------------------------------
|
||||
# Assigns variables listed in WANTED-VARS by reading FILE and
|
||||
# evaluating it according to the quoting scheme of tclConfig.sh and
|
||||
# tkConfig.sh. Calls AC_SUBST for each variable.
|
||||
|
||||
AC_DEFUN([PGAC_EVAL_TCLCONFIGSH],
|
||||
[. "$1"
|
||||
m4_foreach([pgac_item], [$2],
|
||||
[eval pgac_item=\"[$]pgac_item\"
|
||||
AC_SUBST(pgac_item)])])
|
||||
84
contrib/Makefile
Executable file
84
contrib/Makefile
Executable file
@ -0,0 +1,84 @@
|
||||
# contrib/Makefile
|
||||
|
||||
subdir = contrib
|
||||
top_builddir = ..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
SUBDIRS = \
|
||||
adminpack \
|
||||
auth_delay \
|
||||
auto_explain \
|
||||
btree_gin \
|
||||
btree_gist \
|
||||
chkpass \
|
||||
citext \
|
||||
cube \
|
||||
dblink \
|
||||
dict_int \
|
||||
dict_xsyn \
|
||||
dummy_seclabel \
|
||||
earthdistance \
|
||||
file_fdw \
|
||||
fuzzystrmatch \
|
||||
hstore \
|
||||
log_fdw \
|
||||
intagg \
|
||||
intarray \
|
||||
isn \
|
||||
lo \
|
||||
ltree \
|
||||
oid2name \
|
||||
pagehack \
|
||||
pageinspect \
|
||||
passwordcheck \
|
||||
pg_archivecleanup \
|
||||
pg_buffercache \
|
||||
pg_freespacemap \
|
||||
pg_standby \
|
||||
pg_stat_statements \
|
||||
pg_test_fsync \
|
||||
pg_test_timing \
|
||||
pg_trgm \
|
||||
pg_upgrade \
|
||||
pg_upgrade_support \
|
||||
pg_xlogdump \
|
||||
pgbench \
|
||||
pgcrypto \
|
||||
pgrowlocks \
|
||||
pgstattuple \
|
||||
seg \
|
||||
spi \
|
||||
tablefunc \
|
||||
tcn \
|
||||
test_decoding \
|
||||
mppdb_decoding \
|
||||
test_parser \
|
||||
tsearch2 \
|
||||
unaccent \
|
||||
vacuumlo \
|
||||
gsredistribute
|
||||
|
||||
ifeq ($(with_openssl),yes)
|
||||
SUBDIRS += sslinfo
|
||||
else
|
||||
ALWAYS_SUBDIRS += sslinfo
|
||||
endif
|
||||
|
||||
ifeq ($(with_libxml),yes)
|
||||
SUBDIRS += xml2
|
||||
else
|
||||
ALWAYS_SUBDIRS += xml2
|
||||
endif
|
||||
|
||||
ifeq ($(with_selinux),yes)
|
||||
SUBDIRS += sepgsql
|
||||
else
|
||||
ALWAYS_SUBDIRS += sepgsql
|
||||
endif
|
||||
|
||||
# Missing:
|
||||
# start-scripts \ (does not have a makefile)
|
||||
|
||||
|
||||
$(recurse)
|
||||
$(recurse_always)
|
||||
28
contrib/README
Normal file
28
contrib/README
Normal file
@ -0,0 +1,28 @@
|
||||
The PostgreSQL contrib tree
|
||||
---------------------------
|
||||
|
||||
This subtree contains porting tools, analysis utilities, and plug-in
|
||||
features that are not part of the core PostgreSQL system, mainly
|
||||
because they address a limited audience or are too experimental to be
|
||||
part of the main source tree. This does not preclude their
|
||||
usefulness.
|
||||
|
||||
User documentation for each module appears in the main SGML
|
||||
documentation.
|
||||
|
||||
When building from the source distribution, these modules are not
|
||||
built automatically, unless you build the "world" target. You can
|
||||
also build and install them all by running "gmake all" and "gmake
|
||||
install" in this directory; or to build and install just one selected
|
||||
module, do the same in that module's subdirectory.
|
||||
|
||||
Some directories supply new user-defined functions, operators, or
|
||||
types. To make use of one of these modules, after you have installed
|
||||
the code you need to register the new SQL objects in the database
|
||||
system by executing a CREATE EXTENSION command. In a fresh database,
|
||||
you can simply do
|
||||
|
||||
CREATE EXTENSION module_name;
|
||||
|
||||
See the PostgreSQL documentation for more information about this
|
||||
procedure.
|
||||
19
contrib/adminpack/Makefile
Normal file
19
contrib/adminpack/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
# contrib/adminpack/Makefile
|
||||
|
||||
MODULE_big = adminpack
|
||||
OBJS = adminpack.o
|
||||
PG_CPPFLAGS = -I$(libpq_srcdir)
|
||||
|
||||
EXTENSION = adminpack
|
||||
DATA = adminpack--1.0.sql
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/adminpack
|
||||
top_builddir = ../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
53
contrib/adminpack/adminpack--1.0.sql
Normal file
53
contrib/adminpack/adminpack--1.0.sql
Normal file
@ -0,0 +1,53 @@
|
||||
/* contrib/adminpack/adminpack--1.0.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION adminpack" to load this file. \quit
|
||||
|
||||
/* ***********************************************
|
||||
* Administrative functions for PostgreSQL
|
||||
* *********************************************** */
|
||||
|
||||
/* generic file access functions */
|
||||
|
||||
CREATE FUNCTION pg_catalog.pg_file_write(text, text, bool)
|
||||
RETURNS bigint
|
||||
AS 'MODULE_PATHNAME', 'pg_file_write'
|
||||
LANGUAGE C VOLATILE STRICT;
|
||||
|
||||
CREATE FUNCTION pg_catalog.pg_file_rename(text, text, text)
|
||||
RETURNS bool
|
||||
AS 'MODULE_PATHNAME', 'pg_file_rename'
|
||||
LANGUAGE C VOLATILE;
|
||||
|
||||
CREATE FUNCTION pg_catalog.pg_file_rename(text, text)
|
||||
RETURNS bool
|
||||
AS 'SELECT pg_catalog.pg_file_rename($1, $2, NULL::pg_catalog.text);'
|
||||
LANGUAGE SQL VOLATILE STRICT;
|
||||
|
||||
CREATE FUNCTION pg_catalog.pg_file_unlink(text)
|
||||
RETURNS bool
|
||||
AS 'MODULE_PATHNAME', 'pg_file_unlink'
|
||||
LANGUAGE C VOLATILE STRICT;
|
||||
|
||||
CREATE FUNCTION pg_catalog.pg_logdir_ls()
|
||||
RETURNS setof record
|
||||
AS 'MODULE_PATHNAME', 'pg_logdir_ls'
|
||||
LANGUAGE C VOLATILE STRICT;
|
||||
|
||||
|
||||
/* Renaming of existing backend functions for pgAdmin compatibility */
|
||||
|
||||
CREATE FUNCTION pg_catalog.pg_file_read(text, bigint, bigint)
|
||||
RETURNS text
|
||||
AS 'pg_read_file'
|
||||
LANGUAGE INTERNAL VOLATILE STRICT;
|
||||
|
||||
CREATE FUNCTION pg_catalog.pg_file_length(text)
|
||||
RETURNS bigint
|
||||
AS 'SELECT size FROM pg_catalog.pg_stat_file($1)'
|
||||
LANGUAGE SQL VOLATILE STRICT;
|
||||
|
||||
CREATE FUNCTION pg_catalog.pg_logfile_rotate()
|
||||
RETURNS int4
|
||||
AS 'pg_rotate_logfile'
|
||||
LANGUAGE INTERNAL VOLATILE STRICT;
|
||||
6
contrib/adminpack/adminpack.control
Normal file
6
contrib/adminpack/adminpack.control
Normal file
@ -0,0 +1,6 @@
|
||||
# adminpack extension
|
||||
comment = 'administrative functions for PostgreSQL'
|
||||
default_version = '1.0'
|
||||
module_pathname = '$libdir/adminpack'
|
||||
relocatable = false
|
||||
schema = pg_catalog
|
||||
310
contrib/adminpack/adminpack.cpp
Normal file
310
contrib/adminpack/adminpack.cpp
Normal file
@ -0,0 +1,310 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* adminpack.c
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2002-2012, PostgreSQL Global Development Group
|
||||
*
|
||||
* Author: Andreas Pflug <pgadmin@pse-consulting.de>
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/adminpack/adminpack.c
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "catalog/pg_type.h"
|
||||
#include "funcapi.h"
|
||||
#include "miscadmin.h"
|
||||
#include "postmaster/syslogger.h"
|
||||
#include "storage/fd.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/datetime.h"
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#ifdef rename
|
||||
#undef rename
|
||||
#endif
|
||||
|
||||
#ifdef unlink
|
||||
#undef unlink
|
||||
#endif
|
||||
#endif
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
extern "C" Datum pg_file_write(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum pg_file_rename(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum pg_file_unlink(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum pg_logdir_ls(PG_FUNCTION_ARGS);
|
||||
|
||||
PG_FUNCTION_INFO_V1(pg_file_write);
|
||||
PG_FUNCTION_INFO_V1(pg_file_rename);
|
||||
PG_FUNCTION_INFO_V1(pg_file_unlink);
|
||||
PG_FUNCTION_INFO_V1(pg_logdir_ls);
|
||||
|
||||
typedef struct {
|
||||
char* location;
|
||||
DIR* dirdesc;
|
||||
} directory_fctx;
|
||||
|
||||
/*-----------------------
|
||||
* some helper functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Convert a "text" filename argument to C string, and check it's allowable.
|
||||
*
|
||||
* Filename may be absolute or relative to the t_thrd.proc_cxt.DataDir, but we only allow
|
||||
* absolute paths that match t_thrd.proc_cxt.DataDir or u_sess->attr.attr_common.Log_directory.
|
||||
*/
|
||||
static char* convert_and_check_filename(text* arg, bool logAllowed)
|
||||
{
|
||||
char* filename = text_to_cstring(arg);
|
||||
|
||||
canonicalize_path(filename); /* filename can change length here */
|
||||
|
||||
if (is_absolute_path(filename)) {
|
||||
/* Disallow '/a/b/data/..' */
|
||||
if (path_contains_parent_reference(filename))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("reference to parent directory (\"..\") not allowed"))));
|
||||
|
||||
/*
|
||||
* Allow absolute paths if within t_thrd.proc_cxt.DataDir or u_sess->attr.attr_common.Log_directory, even
|
||||
* though u_sess->attr.attr_common.Log_directory might be outside t_thrd.proc_cxt.DataDir.
|
||||
*/
|
||||
if (!path_is_prefix_of_path(t_thrd.proc_cxt.DataDir, filename) &&
|
||||
(!logAllowed || !is_absolute_path(u_sess->attr.attr_common.Log_directory) ||
|
||||
!path_is_prefix_of_path(u_sess->attr.attr_common.Log_directory, filename)))
|
||||
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("absolute path not allowed"))));
|
||||
} else if (!path_is_relative_and_below_cwd(filename))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("path must be in or below the current directory"))));
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
/*
|
||||
* check for superuser, bark if not.
|
||||
*/
|
||||
static void requireSuperuser(void)
|
||||
{
|
||||
if (!superuser())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("only system admin may access generic file functions"))));
|
||||
}
|
||||
|
||||
/* ------------------------------------
|
||||
* generic file handling functions
|
||||
*/
|
||||
|
||||
Datum pg_file_write(PG_FUNCTION_ARGS)
|
||||
{
|
||||
FILE* f = NULL;
|
||||
char* filename = NULL;
|
||||
text* data = NULL;
|
||||
int64 count = 0;
|
||||
|
||||
requireSuperuser();
|
||||
|
||||
filename = convert_and_check_filename(PG_GETARG_TEXT_P(0), false);
|
||||
data = PG_GETARG_TEXT_P(1);
|
||||
|
||||
if (!PG_GETARG_BOOL(2)) {
|
||||
struct stat fst;
|
||||
|
||||
if (stat(filename, &fst) >= 0)
|
||||
ereport(ERROR, (ERRCODE_DUPLICATE_FILE, errmsg("file \"%s\" exists", filename)));
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
} else
|
||||
f = fopen(filename, "ab");
|
||||
|
||||
if (!f)
|
||||
ereport(ERROR, (errcode_for_file_access(), errmsg("could not open file \"%s\" for writing: %m", filename)));
|
||||
|
||||
if (VARSIZE(data) != 0) {
|
||||
count = fwrite(VARDATA(data), 1, VARSIZE(data) - VARHDRSZ, f);
|
||||
|
||||
if (count != VARSIZE(data) - VARHDRSZ)
|
||||
ereport(ERROR, (errcode_for_file_access(), errmsg("could not write file \"%s\": %m", filename)));
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
PG_RETURN_INT64(count);
|
||||
}
|
||||
|
||||
Datum pg_file_rename(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char *fn1, *fn2, *fn3;
|
||||
int rc;
|
||||
|
||||
requireSuperuser();
|
||||
|
||||
if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
|
||||
PG_RETURN_NULL();
|
||||
|
||||
fn1 = convert_and_check_filename(PG_GETARG_TEXT_P(0), false);
|
||||
fn2 = convert_and_check_filename(PG_GETARG_TEXT_P(1), false);
|
||||
if (PG_ARGISNULL(2))
|
||||
fn3 = 0;
|
||||
else
|
||||
fn3 = convert_and_check_filename(PG_GETARG_TEXT_P(2), false);
|
||||
|
||||
if (access(fn1, W_OK) < 0) {
|
||||
ereport(WARNING, (errcode_for_file_access(), errmsg("file \"%s\" is not accessible: %m", fn1)));
|
||||
|
||||
PG_RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
if (fn3 && access(fn2, W_OK) < 0) {
|
||||
ereport(WARNING, (errcode_for_file_access(), errmsg("file \"%s\" is not accessible: %m", fn2)));
|
||||
|
||||
PG_RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
rc = access(fn3 ? fn3 : fn2, 2);
|
||||
if (rc >= 0 || errno != ENOENT) {
|
||||
ereport(ERROR, (ERRCODE_DUPLICATE_FILE, errmsg("cannot rename to target file \"%s\"", fn3 ? fn3 : fn2)));
|
||||
}
|
||||
|
||||
if (fn3) {
|
||||
if (rename(fn2, fn3) != 0) {
|
||||
ereport(ERROR, (errcode_for_file_access(), errmsg("could not rename \"%s\" to \"%s\": %m", fn2, fn3)));
|
||||
}
|
||||
if (rename(fn1, fn2) != 0) {
|
||||
ereport(WARNING, (errcode_for_file_access(), errmsg("could not rename \"%s\" to \"%s\": %m", fn1, fn2)));
|
||||
|
||||
if (rename(fn3, fn2) != 0) {
|
||||
ereport(
|
||||
ERROR, (errcode_for_file_access(), errmsg("could not rename \"%s\" back to \"%s\": %m", fn3, fn2)));
|
||||
} else {
|
||||
ereport(ERROR, (ERRCODE_UNDEFINED_FILE, errmsg("renaming \"%s\" to \"%s\" was reverted", fn2, fn3)));
|
||||
}
|
||||
}
|
||||
} else if (rename(fn1, fn2) != 0) {
|
||||
ereport(ERROR, (errcode_for_file_access(), errmsg("could not rename \"%s\" to \"%s\": %m", fn1, fn2)));
|
||||
}
|
||||
|
||||
PG_RETURN_BOOL(true);
|
||||
}
|
||||
|
||||
Datum pg_file_unlink(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char* filename = NULL;
|
||||
|
||||
requireSuperuser();
|
||||
|
||||
filename = convert_and_check_filename(PG_GETARG_TEXT_P(0), false);
|
||||
|
||||
if (access(filename, W_OK) < 0) {
|
||||
if (errno == ENOENT)
|
||||
PG_RETURN_BOOL(false);
|
||||
else
|
||||
ereport(ERROR, (errcode_for_file_access(), errmsg("file \"%s\" is not accessible: %m", filename)));
|
||||
}
|
||||
|
||||
if (unlink(filename) < 0) {
|
||||
ereport(WARNING, (errcode_for_file_access(), errmsg("could not unlink file \"%s\": %m", filename)));
|
||||
|
||||
PG_RETURN_BOOL(false);
|
||||
}
|
||||
PG_RETURN_BOOL(true);
|
||||
}
|
||||
|
||||
Datum pg_logdir_ls(PG_FUNCTION_ARGS)
|
||||
{
|
||||
FuncCallContext* funcctx = NULL;
|
||||
struct dirent* de;
|
||||
directory_fctx* fctx = NULL;
|
||||
|
||||
if (!superuser())
|
||||
ereport(
|
||||
ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("only system admin can list the log directory"))));
|
||||
|
||||
if (strcmp(u_sess->attr.attr_common.Log_filename, "postgresql-%Y-%m-%d_%H%M%S.log") != 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
(errmsg("the log_filename parameter must equal 'postgresql-%%Y-%%m-%%d_%%H%%M%%S.log'"))));
|
||||
|
||||
if (SRF_IS_FIRSTCALL()) {
|
||||
MemoryContext oldcontext;
|
||||
TupleDesc tupdesc;
|
||||
|
||||
funcctx = SRF_FIRSTCALL_INIT();
|
||||
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
||||
|
||||
fctx = (directory_fctx*)palloc(sizeof(directory_fctx));
|
||||
|
||||
tupdesc = CreateTemplateTupleDesc(2, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)1, "starttime", TIMESTAMPOID, -1, 0);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber)2, "filename", TEXTOID, -1, 0);
|
||||
|
||||
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
||||
|
||||
fctx->location = pstrdup(u_sess->attr.attr_common.Log_directory);
|
||||
fctx->dirdesc = AllocateDir(fctx->location);
|
||||
|
||||
if (!fctx->dirdesc)
|
||||
ereport(ERROR, (errcode_for_file_access(), errmsg("could not read directory \"%s\": %m", fctx->location)));
|
||||
|
||||
funcctx->user_fctx = fctx;
|
||||
(void)MemoryContextSwitchTo(oldcontext);
|
||||
}
|
||||
|
||||
funcctx = SRF_PERCALL_SETUP();
|
||||
fctx = (directory_fctx*)funcctx->user_fctx;
|
||||
|
||||
while ((de = ReadDir(fctx->dirdesc, fctx->location)) != NULL) {
|
||||
char* values[2];
|
||||
HeapTuple tuple;
|
||||
char timestampbuf[32];
|
||||
char* field[MAXDATEFIELDS];
|
||||
char lowstr[MAXDATELEN + 1];
|
||||
int dtype;
|
||||
int nf, ftype[MAXDATEFIELDS];
|
||||
fsec_t fsec;
|
||||
int tz = 0;
|
||||
struct pg_tm date;
|
||||
|
||||
/*
|
||||
* Default format: postgresql-YYYY-MM-DD_HHMMSS.log
|
||||
*/
|
||||
if (strlen(de->d_name) != 32 || strncmp(de->d_name, "postgresql-", 11) != 0 || de->d_name[21] != '_' ||
|
||||
strcmp(de->d_name + 28, ".log") != 0)
|
||||
continue;
|
||||
|
||||
/* extract timestamp portion of filename */
|
||||
strcpy(timestampbuf, de->d_name + 11);
|
||||
timestampbuf[17] = '\0';
|
||||
|
||||
/* parse and decode expected timestamp to verify it's OK format */
|
||||
if (ParseDateTime(timestampbuf, lowstr, MAXDATELEN, field, ftype, MAXDATEFIELDS, &nf))
|
||||
continue;
|
||||
|
||||
if (DecodeDateTime(field, ftype, nf, &dtype, &date, &fsec, &tz))
|
||||
continue;
|
||||
|
||||
/* Seems the timestamp is OK; prepare and return tuple */
|
||||
|
||||
values[0] = timestampbuf;
|
||||
values[1] = (char*)palloc(strlen(fctx->location) + strlen(de->d_name) + 2);
|
||||
sprintf(values[1], "%s/%s", fctx->location, de->d_name);
|
||||
|
||||
tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
|
||||
|
||||
SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(tuple));
|
||||
}
|
||||
|
||||
FreeDir(fctx->dirdesc);
|
||||
SRF_RETURN_DONE(funcctx);
|
||||
}
|
||||
14
contrib/auth_delay/Makefile
Normal file
14
contrib/auth_delay/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
# contrib/auth_delay/Makefile
|
||||
|
||||
MODULES = auth_delay
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/auth_delay
|
||||
top_builddir = ../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
70
contrib/auth_delay/auth_delay.cpp
Normal file
70
contrib/auth_delay/auth_delay.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
*
|
||||
* auth_delay.c
|
||||
*
|
||||
* Copyright (C) 2010-2011, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/auth_delay/auth_delay.c
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include "libpq/auth.h"
|
||||
#include "port.h"
|
||||
#include "utils/guc.h"
|
||||
#include "utils/timestamp.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
void _PG_init(void);
|
||||
|
||||
/* GUC Variables */
|
||||
static int auth_delay_milliseconds;
|
||||
|
||||
/* Original Hook */
|
||||
static ClientAuthentication_hook_type original_client_auth_hook = NULL;
|
||||
|
||||
/*
|
||||
* Check authentication
|
||||
*/
|
||||
static void auth_delay_checks(Port* port, int status)
|
||||
{
|
||||
/*
|
||||
* Any other plugins which use ClientAuthentication_hook.
|
||||
*/
|
||||
if (original_client_auth_hook)
|
||||
original_client_auth_hook(port, status);
|
||||
|
||||
/*
|
||||
* Inject a short delay if authentication failed.
|
||||
*/
|
||||
if (status != STATUS_OK) {
|
||||
pg_usleep(1000L * auth_delay_milliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Module Load Callback
|
||||
*/
|
||||
void _PG_init(void)
|
||||
{
|
||||
/* Define custom GUC variables */
|
||||
DefineCustomIntVariable("auth_delay.milliseconds",
|
||||
"Milliseconds to delay before reporting authentication failure",
|
||||
NULL,
|
||||
&auth_delay_milliseconds,
|
||||
0,
|
||||
0,
|
||||
INT_MAX / 1000,
|
||||
PGC_SIGHUP,
|
||||
GUC_UNIT_MS,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
/* Install Hooks */
|
||||
original_client_auth_hook = ClientAuthentication_hook;
|
||||
ClientAuthentication_hook = auth_delay_checks;
|
||||
}
|
||||
15
contrib/auto_explain/Makefile
Normal file
15
contrib/auto_explain/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
# contrib/auto_explain/Makefile
|
||||
|
||||
MODULE_big = auto_explain
|
||||
OBJS = auto_explain.o
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/auto_explain
|
||||
top_builddir = ../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
307
contrib/auto_explain/auto_explain.cpp
Executable file
307
contrib/auto_explain/auto_explain.cpp
Executable file
@ -0,0 +1,307 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* auto_explain.c
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2008-2012, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* contrib/auto_explain/auto_explain.c
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include "commands/explain.h"
|
||||
#include "executor/instrument.h"
|
||||
#include "utils/guc.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
/* GUC variables */
|
||||
static int auto_explain_log_min_duration = -1; /* msec or -1 */
|
||||
static bool auto_explain_log_analyze = false;
|
||||
static bool auto_explain_log_verbose = false;
|
||||
static bool auto_explain_log_buffers = false;
|
||||
static bool auto_explain_log_timing = false;
|
||||
static int auto_explain_log_format = EXPLAIN_FORMAT_TEXT;
|
||||
static bool auto_explain_log_nested_statements = false;
|
||||
|
||||
static const struct config_enum_entry format_options[] = {{"text", EXPLAIN_FORMAT_TEXT, false},
|
||||
{"xml", EXPLAIN_FORMAT_XML, false},
|
||||
{"json", EXPLAIN_FORMAT_JSON, false},
|
||||
{"yaml", EXPLAIN_FORMAT_YAML, false},
|
||||
{NULL, 0, false}};
|
||||
|
||||
/* Current nesting depth of ExecutorRun calls */
|
||||
static int nesting_level = 0;
|
||||
|
||||
/* Saved hook values in case of unload */
|
||||
static ExecutorStart_hook_type prev_ExecutorStart = NULL;
|
||||
static ExecutorRun_hook_type prev_ExecutorRun = NULL;
|
||||
static ExecutorFinish_hook_type prev_ExecutorFinish = NULL;
|
||||
static ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
|
||||
|
||||
#define auto_explain_enabled() \
|
||||
(auto_explain_log_min_duration >= 0 && (nesting_level == 0 || auto_explain_log_nested_statements))
|
||||
|
||||
void _PG_init(void);
|
||||
void _PG_fini(void);
|
||||
|
||||
static void explain_ExecutorStart(QueryDesc* queryDesc, int eflags);
|
||||
static void explain_ExecutorRun(QueryDesc* queryDesc, ScanDirection direction, long count);
|
||||
static void explain_ExecutorFinish(QueryDesc* queryDesc);
|
||||
static void explain_ExecutorEnd(QueryDesc* queryDesc);
|
||||
|
||||
/*
|
||||
* Module load callback
|
||||
*/
|
||||
void _PG_init(void)
|
||||
{
|
||||
/* Define custom GUC variables. */
|
||||
DefineCustomIntVariable("auto_explain.log_min_duration",
|
||||
"Sets the minimum execution time above which plans will be logged.",
|
||||
"Zero prints all plans. -1 turns this feature off.",
|
||||
&auto_explain_log_min_duration,
|
||||
-1,
|
||||
-1,
|
||||
INT_MAX / 1000,
|
||||
PGC_SUSET,
|
||||
GUC_UNIT_MS,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("auto_explain.log_analyze",
|
||||
"Use EXPLAIN ANALYZE for plan logging.",
|
||||
NULL,
|
||||
&auto_explain_log_analyze,
|
||||
false,
|
||||
PGC_SUSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("auto_explain.log_verbose",
|
||||
"Use EXPLAIN VERBOSE for plan logging.",
|
||||
NULL,
|
||||
&auto_explain_log_verbose,
|
||||
false,
|
||||
PGC_SUSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("auto_explain.log_buffers",
|
||||
"Log buffers usage.",
|
||||
NULL,
|
||||
&auto_explain_log_buffers,
|
||||
false,
|
||||
PGC_SUSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomEnumVariable("auto_explain.log_format",
|
||||
"EXPLAIN format to be used for plan logging.",
|
||||
NULL,
|
||||
&auto_explain_log_format,
|
||||
EXPLAIN_FORMAT_TEXT,
|
||||
format_options,
|
||||
PGC_SUSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("auto_explain.log_nested_statements",
|
||||
"Log nested statements.",
|
||||
NULL,
|
||||
&auto_explain_log_nested_statements,
|
||||
false,
|
||||
PGC_SUSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("auto_explain.log_timing",
|
||||
"Collect timing data, not just row counts.",
|
||||
NULL,
|
||||
&auto_explain_log_timing,
|
||||
true,
|
||||
PGC_SUSET,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
EmitWarningsOnPlaceholders("auto_explain");
|
||||
|
||||
/* Install hooks. */
|
||||
prev_ExecutorStart = ExecutorStart_hook;
|
||||
ExecutorStart_hook = explain_ExecutorStart;
|
||||
prev_ExecutorRun = ExecutorRun_hook;
|
||||
ExecutorRun_hook = explain_ExecutorRun;
|
||||
prev_ExecutorFinish = ExecutorFinish_hook;
|
||||
ExecutorFinish_hook = explain_ExecutorFinish;
|
||||
prev_ExecutorEnd = ExecutorEnd_hook;
|
||||
ExecutorEnd_hook = explain_ExecutorEnd;
|
||||
}
|
||||
|
||||
/*
|
||||
* Module unload callback
|
||||
*/
|
||||
void _PG_fini(void)
|
||||
{
|
||||
/* Uninstall hooks. */
|
||||
ExecutorStart_hook = prev_ExecutorStart;
|
||||
ExecutorRun_hook = prev_ExecutorRun;
|
||||
ExecutorFinish_hook = prev_ExecutorFinish;
|
||||
ExecutorEnd_hook = prev_ExecutorEnd;
|
||||
}
|
||||
|
||||
/*
|
||||
* ExecutorStart hook: start up logging if needed
|
||||
*/
|
||||
static void explain_ExecutorStart(QueryDesc* queryDesc, int eflags)
|
||||
{
|
||||
if (auto_explain_enabled()) {
|
||||
/* Enable per-node instrumentation iff log_analyze is required. */
|
||||
if (auto_explain_log_analyze && (eflags & EXEC_FLAG_EXPLAIN_ONLY) == 0) {
|
||||
if (auto_explain_log_timing)
|
||||
queryDesc->instrument_options |= INSTRUMENT_TIMER;
|
||||
else
|
||||
queryDesc->instrument_options |= INSTRUMENT_ROWS;
|
||||
|
||||
if (auto_explain_log_buffers)
|
||||
queryDesc->instrument_options |= INSTRUMENT_BUFFERS;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_ExecutorStart)
|
||||
prev_ExecutorStart(queryDesc, eflags);
|
||||
else
|
||||
standard_ExecutorStart(queryDesc, eflags);
|
||||
|
||||
if (auto_explain_enabled()) {
|
||||
/*
|
||||
* Set up to track total elapsed time in ExecutorRun. Make sure the
|
||||
* space is allocated in the per-query context so it will go away at
|
||||
* ExecutorEnd.
|
||||
*/
|
||||
if (queryDesc->totaltime == NULL) {
|
||||
MemoryContext oldcxt;
|
||||
|
||||
oldcxt = MemoryContextSwitchTo(queryDesc->estate->es_query_cxt);
|
||||
queryDesc->totaltime = InstrAlloc(1, INSTRUMENT_ALL);
|
||||
MemoryContextSwitchTo(oldcxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ExecutorRun hook: all we need do is track nesting depth
|
||||
*/
|
||||
static void explain_ExecutorRun(QueryDesc* queryDesc, ScanDirection direction, long count)
|
||||
{
|
||||
nesting_level++;
|
||||
PG_TRY();
|
||||
{
|
||||
if (prev_ExecutorRun)
|
||||
prev_ExecutorRun(queryDesc, direction, count);
|
||||
else
|
||||
standard_ExecutorRun(queryDesc, direction, count);
|
||||
nesting_level--;
|
||||
}
|
||||
PG_CATCH();
|
||||
{
|
||||
nesting_level--;
|
||||
PG_RE_THROW();
|
||||
}
|
||||
PG_END_TRY();
|
||||
}
|
||||
|
||||
/*
|
||||
* ExecutorFinish hook: all we need do is track nesting depth
|
||||
*/
|
||||
static void explain_ExecutorFinish(QueryDesc* queryDesc)
|
||||
{
|
||||
nesting_level++;
|
||||
PG_TRY();
|
||||
{
|
||||
if (prev_ExecutorFinish)
|
||||
prev_ExecutorFinish(queryDesc);
|
||||
else
|
||||
standard_ExecutorFinish(queryDesc);
|
||||
nesting_level--;
|
||||
}
|
||||
PG_CATCH();
|
||||
{
|
||||
nesting_level--;
|
||||
PG_RE_THROW();
|
||||
}
|
||||
PG_END_TRY();
|
||||
}
|
||||
|
||||
/*
|
||||
* ExecutorEnd hook: log results if needed
|
||||
*/
|
||||
static void explain_ExecutorEnd(QueryDesc* queryDesc)
|
||||
{
|
||||
if (queryDesc->totaltime && auto_explain_enabled()) {
|
||||
double msec;
|
||||
|
||||
/*
|
||||
* Make sure stats accumulation is done. (Note: it's okay if several
|
||||
* levels of hook all do this.)
|
||||
*/
|
||||
InstrEndLoop(queryDesc->totaltime);
|
||||
|
||||
/* Log plan if duration is exceeded. */
|
||||
msec = queryDesc->totaltime->total * 1000.0;
|
||||
if (msec >= auto_explain_log_min_duration) {
|
||||
ExplainState es;
|
||||
|
||||
ExplainInitState(&es);
|
||||
es.analyze = (queryDesc->instrument_options && auto_explain_log_analyze);
|
||||
es.verbose = auto_explain_log_verbose;
|
||||
es.buffers = (es.analyze && auto_explain_log_buffers);
|
||||
es.format = (ExplainFormat)auto_explain_log_format;
|
||||
|
||||
ExplainBeginOutput(&es);
|
||||
ExplainQueryText(&es, queryDesc);
|
||||
ExplainPrintPlan(&es, queryDesc);
|
||||
ExplainEndOutput(&es);
|
||||
|
||||
/* Remove last line break */
|
||||
if (es.str->len > 0 && es.str->data[es.str->len - 1] == '\n')
|
||||
es.str->data[--es.str->len] = '\0';
|
||||
|
||||
/* Fix JSON to output an object */
|
||||
if (auto_explain_log_format == EXPLAIN_FORMAT_JSON) {
|
||||
es.str->data[0] = '{';
|
||||
es.str->data[es.str->len - 1] = '}';
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: we rely on the existing logging of context or
|
||||
* debug_query_string to identify just which statement is being
|
||||
* reported. This isn't ideal but trying to do it here would
|
||||
* often result in duplication.
|
||||
*/
|
||||
ereport(LOG, (errmsg("duration: %.3f ms plan:\n%s", msec, es.str->data), errhidestmt(true)));
|
||||
|
||||
pfree(es.str->data);
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_ExecutorEnd)
|
||||
prev_ExecutorEnd(queryDesc);
|
||||
else
|
||||
standard_ExecutorEnd(queryDesc);
|
||||
}
|
||||
23
contrib/btree_gin/Makefile
Normal file
23
contrib/btree_gin/Makefile
Normal file
@ -0,0 +1,23 @@
|
||||
# contrib/btree_gin/Makefile
|
||||
|
||||
MODULE_big = btree_gin
|
||||
OBJS = btree_gin.o
|
||||
|
||||
EXTENSION = btree_gin
|
||||
DATA = btree_gin--1.0.sql btree_gin--unpackaged--1.0.sql
|
||||
|
||||
REGRESS = install_btree_gin int2 int4 int8 float4 float8 money oid \
|
||||
timestamp timestamptz time timetz date interval \
|
||||
macaddr inet cidr text varchar char bytea bit varbit \
|
||||
numeric
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/btree_gin
|
||||
top_builddir = ../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
690
contrib/btree_gin/btree_gin--1.0.sql
Normal file
690
contrib/btree_gin/btree_gin--1.0.sql
Normal file
@ -0,0 +1,690 @@
|
||||
/* contrib/btree_gin/btree_gin--1.0.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION btree_gin" to load this file. \quit
|
||||
|
||||
CREATE FUNCTION gin_btree_consistent(internal, int2, anyelement, int4, internal, internal)
|
||||
RETURNS bool
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_int2(int2, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_int2(int2, int2, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_int2(int2, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS int2_ops
|
||||
DEFAULT FOR TYPE int2 USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 btint2cmp(int2,int2),
|
||||
FUNCTION 2 gin_extract_value_int2(int2, internal),
|
||||
FUNCTION 3 gin_extract_query_int2(int2, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_int2(int2,int2,int2, internal),
|
||||
STORAGE int2;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_int4(int4, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_int4(int4, int4, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_int4(int4, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS int4_ops
|
||||
DEFAULT FOR TYPE int4 USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 btint4cmp(int4,int4),
|
||||
FUNCTION 2 gin_extract_value_int4(int4, internal),
|
||||
FUNCTION 3 gin_extract_query_int4(int4, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_int4(int4,int4,int2, internal),
|
||||
STORAGE int4;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_int8(int8, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_int8(int8, int8, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_int8(int8, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS int8_ops
|
||||
DEFAULT FOR TYPE int8 USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 btint8cmp(int8,int8),
|
||||
FUNCTION 2 gin_extract_value_int8(int8, internal),
|
||||
FUNCTION 3 gin_extract_query_int8(int8, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_int8(int8,int8,int2, internal),
|
||||
STORAGE int8;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_float4(float4, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_float4(float4, float4, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_float4(float4, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS float4_ops
|
||||
DEFAULT FOR TYPE float4 USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 btfloat4cmp(float4,float4),
|
||||
FUNCTION 2 gin_extract_value_float4(float4, internal),
|
||||
FUNCTION 3 gin_extract_query_float4(float4, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_float4(float4,float4,int2, internal),
|
||||
STORAGE float4;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_float8(float8, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_float8(float8, float8, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_float8(float8, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS float8_ops
|
||||
DEFAULT FOR TYPE float8 USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 btfloat8cmp(float8,float8),
|
||||
FUNCTION 2 gin_extract_value_float8(float8, internal),
|
||||
FUNCTION 3 gin_extract_query_float8(float8, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_float8(float8,float8,int2, internal),
|
||||
STORAGE float8;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_money(money, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_money(money, money, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_money(money, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS money_ops
|
||||
DEFAULT FOR TYPE money USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 cash_cmp(money,money),
|
||||
FUNCTION 2 gin_extract_value_money(money, internal),
|
||||
FUNCTION 3 gin_extract_query_money(money, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_money(money,money,int2, internal),
|
||||
STORAGE money;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_oid(oid, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_oid(oid, oid, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_oid(oid, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS oid_ops
|
||||
DEFAULT FOR TYPE oid USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 btoidcmp(oid,oid),
|
||||
FUNCTION 2 gin_extract_value_oid(oid, internal),
|
||||
FUNCTION 3 gin_extract_query_oid(oid, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_oid(oid,oid,int2, internal),
|
||||
STORAGE oid;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_timestamp(timestamp, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_timestamp(timestamp, timestamp, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_timestamp(timestamp, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS timestamp_ops
|
||||
DEFAULT FOR TYPE timestamp USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 timestamp_cmp(timestamp,timestamp),
|
||||
FUNCTION 2 gin_extract_value_timestamp(timestamp, internal),
|
||||
FUNCTION 3 gin_extract_query_timestamp(timestamp, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_timestamp(timestamp,timestamp,int2, internal),
|
||||
STORAGE timestamp;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_timestamptz(timestamptz, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_timestamptz(timestamptz, timestamptz, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_timestamptz(timestamptz, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS timestamptz_ops
|
||||
DEFAULT FOR TYPE timestamptz USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 timestamptz_cmp(timestamptz,timestamptz),
|
||||
FUNCTION 2 gin_extract_value_timestamptz(timestamptz, internal),
|
||||
FUNCTION 3 gin_extract_query_timestamptz(timestamptz, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_timestamptz(timestamptz,timestamptz,int2, internal),
|
||||
STORAGE timestamptz;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_time(time, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_time(time, time, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_time(time, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS time_ops
|
||||
DEFAULT FOR TYPE time USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 time_cmp(time,time),
|
||||
FUNCTION 2 gin_extract_value_time(time, internal),
|
||||
FUNCTION 3 gin_extract_query_time(time, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_time(time,time,int2, internal),
|
||||
STORAGE time;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_timetz(timetz, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_timetz(timetz, timetz, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_timetz(timetz, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS timetz_ops
|
||||
DEFAULT FOR TYPE timetz USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 timetz_cmp(timetz,timetz),
|
||||
FUNCTION 2 gin_extract_value_timetz(timetz, internal),
|
||||
FUNCTION 3 gin_extract_query_timetz(timetz, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_timetz(timetz,timetz,int2, internal),
|
||||
STORAGE timetz;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_date(date, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_date(date, date, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_date(date, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
-- Now we make date the same to timestamp. so date_ops has to be removed.
|
||||
--
|
||||
-- CREATE OPERATOR CLASS date_ops
|
||||
-- DEFAULT FOR TYPE date USING gin
|
||||
-- AS
|
||||
-- OPERATOR 1 <,
|
||||
-- OPERATOR 2 <=,
|
||||
-- OPERATOR 3 =,
|
||||
-- OPERATOR 4 >=,
|
||||
-- OPERATOR 5 >,
|
||||
-- FUNCTION 2 gin_extract_value_date(date, internal),
|
||||
-- FUNCTION 3 gin_extract_query_date(date, internal, int2, internal, internal),
|
||||
-- FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
-- FUNCTION 5 gin_compare_prefix_date(date,date,int2, internal),
|
||||
-- STORAGE date;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_interval(interval, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_interval(interval, interval, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_interval(interval, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS interval_ops
|
||||
DEFAULT FOR TYPE interval USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 interval_cmp(interval,interval),
|
||||
FUNCTION 2 gin_extract_value_interval(interval, internal),
|
||||
FUNCTION 3 gin_extract_query_interval(interval, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_interval(interval,interval,int2, internal),
|
||||
STORAGE interval;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_macaddr(macaddr, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_macaddr(macaddr, macaddr, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_macaddr(macaddr, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS macaddr_ops
|
||||
DEFAULT FOR TYPE macaddr USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 macaddr_cmp(macaddr,macaddr),
|
||||
FUNCTION 2 gin_extract_value_macaddr(macaddr, internal),
|
||||
FUNCTION 3 gin_extract_query_macaddr(macaddr, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_macaddr(macaddr,macaddr,int2, internal),
|
||||
STORAGE macaddr;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_inet(inet, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_inet(inet, inet, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_inet(inet, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS inet_ops
|
||||
DEFAULT FOR TYPE inet USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 network_cmp(inet,inet),
|
||||
FUNCTION 2 gin_extract_value_inet(inet, internal),
|
||||
FUNCTION 3 gin_extract_query_inet(inet, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_inet(inet,inet,int2, internal),
|
||||
STORAGE inet;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_cidr(cidr, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_cidr(cidr, cidr, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_cidr(cidr, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS cidr_ops
|
||||
DEFAULT FOR TYPE cidr USING gin
|
||||
AS
|
||||
OPERATOR 1 <(inet,inet),
|
||||
OPERATOR 2 <=(inet,inet),
|
||||
OPERATOR 3 =(inet,inet),
|
||||
OPERATOR 4 >=(inet,inet),
|
||||
OPERATOR 5 >(inet,inet),
|
||||
FUNCTION 1 network_cmp(inet,inet),
|
||||
FUNCTION 2 gin_extract_value_cidr(cidr, internal),
|
||||
FUNCTION 3 gin_extract_query_cidr(cidr, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_cidr(cidr,cidr,int2, internal),
|
||||
STORAGE cidr;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_text(text, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_text(text, text, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_text(text, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS text_ops
|
||||
DEFAULT FOR TYPE text USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 bttextcmp(text,text),
|
||||
FUNCTION 2 gin_extract_value_text(text, internal),
|
||||
FUNCTION 3 gin_extract_query_text(text, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_text(text,text,int2, internal),
|
||||
STORAGE text;
|
||||
|
||||
CREATE OPERATOR CLASS varchar_ops
|
||||
DEFAULT FOR TYPE varchar USING gin
|
||||
AS
|
||||
OPERATOR 1 <(text,text),
|
||||
OPERATOR 2 <=(text,text),
|
||||
OPERATOR 3 =(text,text),
|
||||
OPERATOR 4 >=(text,text),
|
||||
OPERATOR 5 >(text,text),
|
||||
FUNCTION 1 bttextcmp(text,text),
|
||||
FUNCTION 2 gin_extract_value_text(text, internal),
|
||||
FUNCTION 3 gin_extract_query_text(text, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_text(text,text,int2, internal),
|
||||
STORAGE varchar;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_char("char", internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_char("char", "char", int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_char("char", internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS char_ops
|
||||
DEFAULT FOR TYPE "char" USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 btcharcmp("char","char"),
|
||||
FUNCTION 2 gin_extract_value_char("char", internal),
|
||||
FUNCTION 3 gin_extract_query_char("char", internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_char("char","char",int2, internal),
|
||||
STORAGE "char";
|
||||
|
||||
CREATE FUNCTION gin_extract_value_bytea(bytea, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_bytea(bytea, bytea, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_bytea(bytea, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS bytea_ops
|
||||
DEFAULT FOR TYPE bytea USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 byteacmp(bytea,bytea),
|
||||
FUNCTION 2 gin_extract_value_bytea(bytea, internal),
|
||||
FUNCTION 3 gin_extract_query_bytea(bytea, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_bytea(bytea,bytea,int2, internal),
|
||||
STORAGE bytea;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_bit(bit, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_bit(bit, bit, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_bit(bit, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS bit_ops
|
||||
DEFAULT FOR TYPE bit USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 bitcmp(bit,bit),
|
||||
FUNCTION 2 gin_extract_value_bit(bit, internal),
|
||||
FUNCTION 3 gin_extract_query_bit(bit, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_bit(bit,bit,int2, internal),
|
||||
STORAGE bit;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_varbit(varbit, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_varbit(varbit, varbit, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_varbit(varbit, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS varbit_ops
|
||||
DEFAULT FOR TYPE varbit USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 varbitcmp(varbit,varbit),
|
||||
FUNCTION 2 gin_extract_value_varbit(varbit, internal),
|
||||
FUNCTION 3 gin_extract_query_varbit(varbit, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_varbit(varbit,varbit,int2, internal),
|
||||
STORAGE varbit;
|
||||
|
||||
CREATE FUNCTION gin_extract_value_numeric(numeric, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_compare_prefix_numeric(numeric, numeric, int2, internal)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_extract_query_numeric(numeric, internal, int2, internal, internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE FUNCTION gin_numeric_cmp(numeric, numeric)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C STRICT IMMUTABLE;
|
||||
|
||||
CREATE OPERATOR CLASS numeric_ops
|
||||
DEFAULT FOR TYPE numeric USING gin
|
||||
AS
|
||||
OPERATOR 1 <,
|
||||
OPERATOR 2 <=,
|
||||
OPERATOR 3 =,
|
||||
OPERATOR 4 >=,
|
||||
OPERATOR 5 >,
|
||||
FUNCTION 1 gin_numeric_cmp(numeric,numeric),
|
||||
FUNCTION 2 gin_extract_value_numeric(numeric, internal),
|
||||
FUNCTION 3 gin_extract_query_numeric(numeric, internal, int2, internal, internal),
|
||||
FUNCTION 4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
|
||||
FUNCTION 5 gin_compare_prefix_numeric(numeric,numeric,int2, internal),
|
||||
STORAGE numeric;
|
||||
117
contrib/btree_gin/btree_gin--unpackaged--1.0.sql
Normal file
117
contrib/btree_gin/btree_gin--unpackaged--1.0.sql
Normal file
@ -0,0 +1,117 @@
|
||||
/* contrib/btree_gin/btree_gin--unpackaged--1.0.sql */
|
||||
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION btree_gin" to load this file. \quit
|
||||
|
||||
ALTER EXTENSION btree_gin ADD function gin_btree_consistent(internal,smallint,anyelement,integer,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_int2(smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_int2(smallint,smallint,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_int2(smallint,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family int2_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class int2_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_int4(integer,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_int4(integer,integer,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_int4(integer,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family int4_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class int4_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_int8(bigint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_int8(bigint,bigint,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_int8(bigint,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family int8_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class int8_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_float4(real,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_float4(real,real,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_float4(real,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family float4_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class float4_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_float8(double precision,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_float8(double precision,double precision,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_float8(double precision,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family float8_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class float8_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_money(money,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_money(money,money,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_money(money,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family money_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class money_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_oid(oid,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_oid(oid,oid,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_oid(oid,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family oid_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class oid_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_timestamp(timestamp without time zone,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_timestamp(timestamp without time zone,timestamp without time zone,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_timestamp(timestamp without time zone,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family timestamp_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class timestamp_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_timestamptz(timestamp with time zone,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_timestamptz(timestamp with time zone,timestamp with time zone,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_timestamptz(timestamp with time zone,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family timestamptz_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class timestamptz_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_time(time without time zone,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_time(time without time zone,time without time zone,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_time(time without time zone,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family time_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class time_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_timetz(time with time zone,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_timetz(time with time zone,time with time zone,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_timetz(time with time zone,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family timetz_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class timetz_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_date(date,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_date(date,date,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_date(date,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_interval(interval,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_interval(interval,interval,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_interval(interval,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family interval_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class interval_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_macaddr(macaddr,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_macaddr(macaddr,macaddr,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_macaddr(macaddr,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family macaddr_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class macaddr_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_inet(inet,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_inet(inet,inet,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_inet(inet,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family inet_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class inet_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_cidr(cidr,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_cidr(cidr,cidr,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_cidr(cidr,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family cidr_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class cidr_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_text(text,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_text(text,text,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_text(text,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family text_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class text_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator family varchar_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class varchar_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_char("char",internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_char("char","char",smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_char("char",internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family char_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class char_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_bytea(bytea,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_bytea(bytea,bytea,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_bytea(bytea,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family bytea_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class bytea_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_bit(bit,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_bit(bit,bit,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_bit(bit,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family bit_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class bit_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_varbit(bit varying,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_varbit(bit varying,bit varying,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_varbit(bit varying,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD operator family varbit_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class varbit_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_value_numeric(numeric,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_compare_prefix_numeric(numeric,numeric,smallint,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_extract_query_numeric(numeric,internal,smallint,internal,internal);
|
||||
ALTER EXTENSION btree_gin ADD function gin_numeric_cmp(numeric,numeric);
|
||||
ALTER EXTENSION btree_gin ADD operator family numeric_ops using gin;
|
||||
ALTER EXTENSION btree_gin ADD operator class numeric_ops using gin;
|
||||
5
contrib/btree_gin/btree_gin.control
Normal file
5
contrib/btree_gin/btree_gin.control
Normal file
@ -0,0 +1,5 @@
|
||||
# btree_gin extension
|
||||
comment = 'support for indexing common datatypes in GIN'
|
||||
default_version = '1.0'
|
||||
module_pathname = '$libdir/btree_gin'
|
||||
relocatable = true
|
||||
394
contrib/btree_gin/btree_gin.cpp
Executable file
394
contrib/btree_gin/btree_gin.cpp
Executable file
@ -0,0 +1,394 @@
|
||||
/*
|
||||
* contrib/btree_gin/btree_gin.c
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "access/skey.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/bytea.h"
|
||||
#include "utils/cash.h"
|
||||
#include "utils/date.h"
|
||||
#include "utils/inet.h"
|
||||
#include "utils/numeric.h"
|
||||
#include "utils/numeric_gs.h"
|
||||
#include "utils/timestamp.h"
|
||||
#include "utils/varbit.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
typedef struct TypeInfo {
|
||||
bool is_varlena;
|
||||
Datum (*leftmostvalue)(void);
|
||||
Datum (*typecmp)(FunctionCallInfo);
|
||||
} TypeInfo;
|
||||
|
||||
typedef struct QueryInfo {
|
||||
StrategyNumber strategy;
|
||||
Datum datum;
|
||||
} QueryInfo;
|
||||
|
||||
#define GIN_EXTRACT_VALUE(type) \
|
||||
PG_FUNCTION_INFO_V1(gin_extract_value_##type); \
|
||||
extern "C" Datum gin_extract_value_##type(PG_FUNCTION_ARGS); \
|
||||
Datum gin_extract_value_##type(PG_FUNCTION_ARGS) \
|
||||
{ \
|
||||
Datum datum = PG_GETARG_DATUM(0); \
|
||||
int32* nentries = (int32*)PG_GETARG_POINTER(1); \
|
||||
Datum* entries = (Datum*)palloc(sizeof(Datum)); \
|
||||
\
|
||||
if (TypeInfo_##type.is_varlena) \
|
||||
datum = PointerGetDatum(PG_DETOAST_DATUM(datum)); \
|
||||
entries[0] = datum; \
|
||||
*nentries = 1; \
|
||||
\
|
||||
PG_RETURN_POINTER(entries); \
|
||||
}
|
||||
|
||||
/*
|
||||
* For BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, and
|
||||
* BTEqualStrategyNumber we want to start the index scan at the
|
||||
* supplied query datum, and work forward. For BTLessStrategyNumber
|
||||
* and BTLessEqualStrategyNumber, we need to start at the leftmost
|
||||
* key, and work forward until the supplied query datum (which must be
|
||||
* sent along inside the QueryInfo structure).
|
||||
*/
|
||||
|
||||
#define GIN_EXTRACT_QUERY(type) \
|
||||
PG_FUNCTION_INFO_V1(gin_extract_query_##type); \
|
||||
extern "C" Datum gin_extract_query_##type(PG_FUNCTION_ARGS); \
|
||||
Datum gin_extract_query_##type(PG_FUNCTION_ARGS) \
|
||||
{ \
|
||||
Datum datum = PG_GETARG_DATUM(0); \
|
||||
int32* nentries = (int32*)PG_GETARG_POINTER(1); \
|
||||
StrategyNumber strategy = PG_GETARG_UINT16(2); \
|
||||
bool** partialmatch = (bool**)PG_GETARG_POINTER(3); \
|
||||
Pointer** extra_data = (Pointer**)PG_GETARG_POINTER(4); \
|
||||
Datum* entries = (Datum*)palloc(sizeof(Datum)); \
|
||||
QueryInfo* data = (QueryInfo*)palloc(sizeof(QueryInfo)); \
|
||||
bool* ptr_partialmatch; \
|
||||
\
|
||||
*nentries = 1; \
|
||||
ptr_partialmatch = *partialmatch = (bool*)palloc(sizeof(bool)); \
|
||||
*ptr_partialmatch = false; \
|
||||
if (TypeInfo_##type.is_varlena) \
|
||||
datum = PointerGetDatum(PG_DETOAST_DATUM(datum)); \
|
||||
data->strategy = strategy; \
|
||||
data->datum = datum; \
|
||||
*extra_data = (Pointer*)palloc(sizeof(Pointer)); \
|
||||
**extra_data = (Pointer)data; \
|
||||
\
|
||||
switch (strategy) { \
|
||||
case BTLessStrategyNumber: \
|
||||
case BTLessEqualStrategyNumber: \
|
||||
entries[0] = TypeInfo_##type.leftmostvalue(); \
|
||||
*ptr_partialmatch = true; \
|
||||
break; \
|
||||
case BTGreaterEqualStrategyNumber: \
|
||||
case BTGreaterStrategyNumber: \
|
||||
*ptr_partialmatch = true; \
|
||||
case BTEqualStrategyNumber: \
|
||||
entries[0] = datum; \
|
||||
break; \
|
||||
default: \
|
||||
elog(ERROR, "unrecognized strategy number: %d", strategy); \
|
||||
} \
|
||||
\
|
||||
PG_RETURN_POINTER(entries); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Datum a is a value from extract_query method and for BTLess*
|
||||
* strategy it is a left-most value. So, use original datum from QueryInfo
|
||||
* to decide to stop scanning or not. Datum b is always from index.
|
||||
*/
|
||||
#define GIN_COMPARE_PREFIX(type) \
|
||||
PG_FUNCTION_INFO_V1(gin_compare_prefix_##type); \
|
||||
extern "C" Datum gin_compare_prefix_##type(PG_FUNCTION_ARGS); \
|
||||
Datum gin_compare_prefix_##type(PG_FUNCTION_ARGS) \
|
||||
{ \
|
||||
Datum a = PG_GETARG_DATUM(0); \
|
||||
Datum b = PG_GETARG_DATUM(1); \
|
||||
QueryInfo* data = (QueryInfo*)PG_GETARG_POINTER(3); \
|
||||
int32 res, cmp; \
|
||||
\
|
||||
cmp = DatumGetInt32(DirectFunctionCall2Coll(TypeInfo_##type.typecmp, \
|
||||
PG_GET_COLLATION(), \
|
||||
(data->strategy == BTLessStrategyNumber || data->strategy == BTLessEqualStrategyNumber) ? data->datum : a, \
|
||||
b)); \
|
||||
\
|
||||
switch (data->strategy) { \
|
||||
case BTLessStrategyNumber: \
|
||||
/* If original datum > indexed one then return match */ \
|
||||
if (cmp > 0) \
|
||||
res = 0; \
|
||||
else \
|
||||
res = 1; \
|
||||
break; \
|
||||
case BTLessEqualStrategyNumber: \
|
||||
/* The same except equality */ \
|
||||
if (cmp >= 0) \
|
||||
res = 0; \
|
||||
else \
|
||||
res = 1; \
|
||||
break; \
|
||||
case BTEqualStrategyNumber: \
|
||||
if (cmp != 0) \
|
||||
res = 1; \
|
||||
else \
|
||||
res = 0; \
|
||||
break; \
|
||||
case BTGreaterEqualStrategyNumber: \
|
||||
/* If original datum <= indexed one then return match */ \
|
||||
if (cmp <= 0) \
|
||||
res = 0; \
|
||||
else \
|
||||
res = 1; \
|
||||
break; \
|
||||
case BTGreaterStrategyNumber: \
|
||||
/* If original datum <= indexed one then return match */ \
|
||||
/* If original datum == indexed one then continue scan */ \
|
||||
if (cmp < 0) \
|
||||
res = 0; \
|
||||
else if (cmp == 0) \
|
||||
res = -1; \
|
||||
else \
|
||||
res = 1; \
|
||||
break; \
|
||||
default: \
|
||||
elog(ERROR, "unrecognized strategy number: %d", data->strategy); \
|
||||
res = 0; \
|
||||
} \
|
||||
\
|
||||
PG_RETURN_INT32(res); \
|
||||
}
|
||||
|
||||
#define GIN_SUPPORT(type) \
|
||||
GIN_EXTRACT_VALUE(type) \
|
||||
GIN_EXTRACT_QUERY(type) \
|
||||
GIN_COMPARE_PREFIX(type)
|
||||
|
||||
PG_FUNCTION_INFO_V1(gin_btree_consistent);
|
||||
extern "C" Datum gin_btree_consistent(PG_FUNCTION_ARGS);
|
||||
Datum gin_btree_consistent(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bool* recheck = (bool*)PG_GETARG_POINTER(5);
|
||||
|
||||
*recheck = false;
|
||||
PG_RETURN_BOOL(true);
|
||||
}
|
||||
|
||||
static Datum leftmostvalue_int2(void)
|
||||
{
|
||||
return Int16GetDatum(SHRT_MIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_int2 = {false, leftmostvalue_int2, btint2cmp};
|
||||
|
||||
GIN_SUPPORT(int2)
|
||||
|
||||
static Datum leftmostvalue_int4(void)
|
||||
{
|
||||
return Int32GetDatum(INT_MIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_int4 = {false, leftmostvalue_int4, btint4cmp};
|
||||
|
||||
GIN_SUPPORT(int4)
|
||||
|
||||
static Datum leftmostvalue_int8(void)
|
||||
{
|
||||
/*
|
||||
* Use sequence's definition to keep compatibility.
|
||||
*/
|
||||
return Int64GetDatum(SEQ_MINVALUE);
|
||||
}
|
||||
static TypeInfo TypeInfo_int8 = {false, leftmostvalue_int8, btint8cmp};
|
||||
|
||||
GIN_SUPPORT(int8)
|
||||
|
||||
static Datum leftmostvalue_float4(void)
|
||||
{
|
||||
return Float4GetDatum(-get_float4_infinity());
|
||||
}
|
||||
static TypeInfo TypeInfo_float4 = {false, leftmostvalue_float4, btfloat4cmp};
|
||||
|
||||
GIN_SUPPORT(float4)
|
||||
|
||||
static Datum leftmostvalue_float8(void)
|
||||
{
|
||||
return Float8GetDatum(-get_float8_infinity());
|
||||
}
|
||||
static TypeInfo TypeInfo_float8 = {false, leftmostvalue_float8, btfloat8cmp};
|
||||
|
||||
GIN_SUPPORT(float8)
|
||||
|
||||
static Datum leftmostvalue_money(void)
|
||||
{
|
||||
/*
|
||||
* Use sequence's definition to keep compatibility.
|
||||
*/
|
||||
return Int64GetDatum(SEQ_MINVALUE);
|
||||
}
|
||||
static TypeInfo TypeInfo_money = {false, leftmostvalue_money, cash_cmp};
|
||||
|
||||
GIN_SUPPORT(money)
|
||||
|
||||
static Datum leftmostvalue_oid(void)
|
||||
{
|
||||
return ObjectIdGetDatum(0);
|
||||
}
|
||||
static TypeInfo TypeInfo_oid = {false, leftmostvalue_oid, btoidcmp};
|
||||
|
||||
GIN_SUPPORT(oid)
|
||||
|
||||
static Datum leftmostvalue_timestamp(void)
|
||||
{
|
||||
return TimestampGetDatum(DT_NOBEGIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_timestamp = {false, leftmostvalue_timestamp, timestamp_cmp};
|
||||
|
||||
GIN_SUPPORT(timestamp)
|
||||
|
||||
static TypeInfo TypeInfo_timestamptz = {false, leftmostvalue_timestamp, timestamp_cmp};
|
||||
|
||||
GIN_SUPPORT(timestamptz)
|
||||
|
||||
static Datum leftmostvalue_time(void)
|
||||
{
|
||||
return TimeADTGetDatum(0);
|
||||
}
|
||||
static TypeInfo TypeInfo_time = {false, leftmostvalue_time, time_cmp};
|
||||
|
||||
GIN_SUPPORT(time)
|
||||
|
||||
static Datum leftmostvalue_timetz(void)
|
||||
{
|
||||
TimeTzADT* v = (TimeTzADT*)palloc(sizeof(TimeTzADT));
|
||||
|
||||
v->time = 0;
|
||||
v->zone = -24 * 3600; /* XXX is that true? */
|
||||
|
||||
return TimeTzADTPGetDatum(v);
|
||||
}
|
||||
static TypeInfo TypeInfo_timetz = {false, leftmostvalue_timetz, timetz_cmp};
|
||||
|
||||
GIN_SUPPORT(timetz)
|
||||
|
||||
static Datum leftmostvalue_date(void)
|
||||
{
|
||||
return DateADTGetDatum(DATEVAL_NOBEGIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_date = {false, leftmostvalue_date, date_cmp};
|
||||
|
||||
GIN_SUPPORT(date)
|
||||
|
||||
static Datum leftmostvalue_interval(void)
|
||||
{
|
||||
Interval* v = (Interval*)palloc(sizeof(Interval));
|
||||
|
||||
v->time = DT_NOBEGIN;
|
||||
v->day = 0;
|
||||
v->month = 0;
|
||||
return IntervalPGetDatum(v);
|
||||
}
|
||||
static TypeInfo TypeInfo_interval = {false, leftmostvalue_interval, interval_cmp};
|
||||
|
||||
GIN_SUPPORT(interval)
|
||||
|
||||
static Datum leftmostvalue_macaddr(void)
|
||||
{
|
||||
macaddr* v = (macaddr*)palloc0(sizeof(macaddr));
|
||||
|
||||
return MacaddrPGetDatum(v);
|
||||
}
|
||||
static TypeInfo TypeInfo_macaddr = {false, leftmostvalue_macaddr, macaddr_cmp};
|
||||
|
||||
GIN_SUPPORT(macaddr)
|
||||
|
||||
static Datum leftmostvalue_inet(void)
|
||||
{
|
||||
return DirectFunctionCall3(inet_in, CStringGetDatum("0.0.0.0/0"), ObjectIdGetDatum(0), Int32GetDatum(-1));
|
||||
}
|
||||
static TypeInfo TypeInfo_inet = {true, leftmostvalue_inet, network_cmp};
|
||||
|
||||
GIN_SUPPORT(inet)
|
||||
|
||||
static TypeInfo TypeInfo_cidr = {true, leftmostvalue_inet, network_cmp};
|
||||
|
||||
GIN_SUPPORT(cidr)
|
||||
|
||||
static Datum leftmostvalue_text(void)
|
||||
{
|
||||
return PointerGetDatum(cstring_to_text_with_len("", 0));
|
||||
}
|
||||
static TypeInfo TypeInfo_text = {true, leftmostvalue_text, bttextcmp};
|
||||
|
||||
GIN_SUPPORT(text)
|
||||
|
||||
static Datum leftmostvalue_char(void)
|
||||
{
|
||||
return CharGetDatum(SCHAR_MIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_char = {false, leftmostvalue_char, btcharcmp};
|
||||
|
||||
GIN_SUPPORT(char)
|
||||
|
||||
static TypeInfo TypeInfo_bytea = {true, leftmostvalue_text, byteacmp};
|
||||
|
||||
GIN_SUPPORT(bytea)
|
||||
|
||||
static Datum leftmostvalue_bit(void)
|
||||
{
|
||||
return DirectFunctionCall3(bit_in, CStringGetDatum(""), ObjectIdGetDatum(0), Int32GetDatum(-1));
|
||||
}
|
||||
static TypeInfo TypeInfo_bit = {true, leftmostvalue_bit, bitcmp};
|
||||
|
||||
GIN_SUPPORT(bit)
|
||||
|
||||
static Datum leftmostvalue_varbit(void)
|
||||
{
|
||||
return DirectFunctionCall3(varbit_in, CStringGetDatum(""), ObjectIdGetDatum(0), Int32GetDatum(-1));
|
||||
}
|
||||
static TypeInfo TypeInfo_varbit = {true, leftmostvalue_varbit, bitcmp};
|
||||
|
||||
GIN_SUPPORT(varbit)
|
||||
|
||||
/*
|
||||
* Numeric type hasn't a real left-most value, so we use PointerGetDatum(NULL)
|
||||
* (*not* a SQL NULL) to represent that. We can get away with that because
|
||||
* the value returned by our leftmostvalue function will never be stored in
|
||||
* the index nor passed to anything except our compare and prefix-comparison
|
||||
* functions. The same trick could be used for other pass-by-reference types.
|
||||
*/
|
||||
|
||||
#define NUMERIC_IS_LEFTMOST(x) ((x) == NULL)
|
||||
|
||||
PG_FUNCTION_INFO_V1(gin_numeric_cmp);
|
||||
extern "C" Datum gin_numeric_cmp(PG_FUNCTION_ARGS);
|
||||
|
||||
Datum gin_numeric_cmp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Numeric a = (Numeric)PG_GETARG_POINTER(0);
|
||||
Numeric b = (Numeric)PG_GETARG_POINTER(1);
|
||||
int res = 0;
|
||||
|
||||
if (NUMERIC_IS_LEFTMOST(a)) {
|
||||
res = (NUMERIC_IS_LEFTMOST(b)) ? 0 : -1;
|
||||
} else if (NUMERIC_IS_LEFTMOST(b)) {
|
||||
res = 1;
|
||||
} else {
|
||||
res = DatumGetInt32(DirectFunctionCall2(numeric_cmp, NumericGetDatum(a), NumericGetDatum(b)));
|
||||
}
|
||||
|
||||
PG_RETURN_INT32(res);
|
||||
}
|
||||
|
||||
static Datum leftmostvalue_numeric(void)
|
||||
{
|
||||
return PointerGetDatum(NULL);
|
||||
}
|
||||
|
||||
static TypeInfo TypeInfo_numeric = {true, leftmostvalue_numeric, gin_numeric_cmp};
|
||||
|
||||
GIN_SUPPORT(numeric)
|
||||
44
contrib/btree_gin/expected/bit.out
Normal file
44
contrib/btree_gin/expected/bit.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_bit (
|
||||
i bit(3)
|
||||
);
|
||||
INSERT INTO test_bit VALUES ('001'),('010'),('011'),('100'),('101'),('110');
|
||||
CREATE INDEX idx_bit ON test_bit USING gin (i);
|
||||
SELECT * FROM test_bit WHERE i<'100'::bit(3) ORDER BY i;
|
||||
i
|
||||
-----
|
||||
001
|
||||
010
|
||||
011
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_bit WHERE i<='100'::bit(3) ORDER BY i;
|
||||
i
|
||||
-----
|
||||
001
|
||||
010
|
||||
011
|
||||
100
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_bit WHERE i='100'::bit(3) ORDER BY i;
|
||||
i
|
||||
-----
|
||||
100
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_bit WHERE i>='100'::bit(3) ORDER BY i;
|
||||
i
|
||||
-----
|
||||
100
|
||||
101
|
||||
110
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_bit WHERE i>'100'::bit(3) ORDER BY i;
|
||||
i
|
||||
-----
|
||||
101
|
||||
110
|
||||
(2 rows)
|
||||
|
||||
46
contrib/btree_gin/expected/bytea.out
Normal file
46
contrib/btree_gin/expected/bytea.out
Normal file
@ -0,0 +1,46 @@
|
||||
set enable_seqscan=off;
|
||||
-- ensure consistent test output regardless of the default bytea format
|
||||
SET bytea_output TO escape;
|
||||
CREATE TABLE test_bytea (
|
||||
i bytea
|
||||
);
|
||||
INSERT INTO test_bytea VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
||||
CREATE INDEX idx_bytea ON test_bytea USING gin (i);
|
||||
SELECT * FROM test_bytea WHERE i<'abc'::bytea ORDER BY i;
|
||||
i
|
||||
-----
|
||||
a
|
||||
aaa
|
||||
abb
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_bytea WHERE i<='abc'::bytea ORDER BY i;
|
||||
i
|
||||
-----
|
||||
a
|
||||
aaa
|
||||
abb
|
||||
abc
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_bytea WHERE i='abc'::bytea ORDER BY i;
|
||||
i
|
||||
-----
|
||||
abc
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_bytea WHERE i>='abc'::bytea ORDER BY i;
|
||||
i
|
||||
-----
|
||||
abc
|
||||
axy
|
||||
xyz
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_bytea WHERE i>'abc'::bytea ORDER BY i;
|
||||
i
|
||||
-----
|
||||
axy
|
||||
xyz
|
||||
(2 rows)
|
||||
|
||||
37
contrib/btree_gin/expected/char.out
Normal file
37
contrib/btree_gin/expected/char.out
Normal file
@ -0,0 +1,37 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_char (
|
||||
i "char"
|
||||
);
|
||||
INSERT INTO test_char VALUES ('a'),('b'),('c'),('d'),('e'),('f');
|
||||
CREATE INDEX idx_char ON test_char USING gin (i);
|
||||
SELECT * FROM test_char WHERE i<'d'::"char" ORDER BY i;
|
||||
i
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_char WHERE i<='d'::"char" ORDER BY i;
|
||||
i
|
||||
---
|
||||
(0 rows)
|
||||
|
||||
SELECT * FROM test_char WHERE i='d'::"char" ORDER BY i;
|
||||
i
|
||||
---
|
||||
d
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_char WHERE i>='d'::"char" ORDER BY i;
|
||||
i
|
||||
---
|
||||
d
|
||||
e
|
||||
f
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_char WHERE i>'d'::"char" ORDER BY i;
|
||||
i
|
||||
---
|
||||
e
|
||||
f
|
||||
(2 rows)
|
||||
|
||||
51
contrib/btree_gin/expected/cidr.out
Normal file
51
contrib/btree_gin/expected/cidr.out
Normal file
@ -0,0 +1,51 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_cidr (
|
||||
i cidr
|
||||
);
|
||||
INSERT INTO test_cidr VALUES
|
||||
( '1.2.3.4' ),
|
||||
( '1.2.4.4' ),
|
||||
( '1.2.5.4' ),
|
||||
( '1.2.6.4' ),
|
||||
( '1.2.7.4' ),
|
||||
( '1.2.8.4' )
|
||||
;
|
||||
CREATE INDEX idx_cidr ON test_cidr USING gin (i);
|
||||
SELECT * FROM test_cidr WHERE i<'1.2.6.4'::cidr ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.3.4/32
|
||||
1.2.4.4/32
|
||||
1.2.5.4/32
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_cidr WHERE i<='1.2.6.4'::cidr ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.3.4/32
|
||||
1.2.4.4/32
|
||||
1.2.5.4/32
|
||||
1.2.6.4/32
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_cidr WHERE i='1.2.6.4'::cidr ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.6.4/32
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_cidr WHERE i>='1.2.6.4'::cidr ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.6.4/32
|
||||
1.2.7.4/32
|
||||
1.2.8.4/32
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_cidr WHERE i>'1.2.6.4'::cidr ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.7.4/32
|
||||
1.2.8.4/32
|
||||
(2 rows)
|
||||
|
||||
52
contrib/btree_gin/expected/date.out
Normal file
52
contrib/btree_gin/expected/date.out
Normal file
@ -0,0 +1,52 @@
|
||||
SET DATESTYLE=ISO;
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_date (
|
||||
i date
|
||||
);
|
||||
INSERT INTO test_date VALUES
|
||||
( '2004-10-23' ),
|
||||
( '2004-10-24' ),
|
||||
( '2004-10-25' ),
|
||||
( '2004-10-26' ),
|
||||
( '2004-10-27' ),
|
||||
( '2004-10-28' )
|
||||
;
|
||||
CREATE INDEX idx_date ON test_date USING gin (i);
|
||||
SELECT * FROM test_date WHERE i<'2004-10-26'::date ORDER BY i;
|
||||
i
|
||||
---------------------
|
||||
2004-10-23 00:00:00
|
||||
2004-10-24 00:00:00
|
||||
2004-10-25 00:00:00
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_date WHERE i<='2004-10-26'::date ORDER BY i;
|
||||
i
|
||||
---------------------
|
||||
2004-10-23 00:00:00
|
||||
2004-10-24 00:00:00
|
||||
2004-10-25 00:00:00
|
||||
2004-10-26 00:00:00
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_date WHERE i='2004-10-26'::date ORDER BY i;
|
||||
i
|
||||
---------------------
|
||||
2004-10-26 00:00:00
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_date WHERE i>='2004-10-26'::date ORDER BY i;
|
||||
i
|
||||
---------------------
|
||||
2004-10-26 00:00:00
|
||||
2004-10-27 00:00:00
|
||||
2004-10-28 00:00:00
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_date WHERE i>'2004-10-26'::date ORDER BY i;
|
||||
i
|
||||
---------------------
|
||||
2004-10-27 00:00:00
|
||||
2004-10-28 00:00:00
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/float4.out
Normal file
44
contrib/btree_gin/expected/float4.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_float4 (
|
||||
i float4
|
||||
);
|
||||
INSERT INTO test_float4 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
CREATE INDEX idx_float4 ON test_float4 USING gin (i);
|
||||
SELECT * FROM test_float4 WHERE i<1::float4 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_float4 WHERE i<=1::float4 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
1
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_float4 WHERE i=1::float4 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_float4 WHERE i>=1::float4 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
2
|
||||
3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_float4 WHERE i>1::float4 ORDER BY i;
|
||||
i
|
||||
---
|
||||
2
|
||||
3
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/float8.out
Normal file
44
contrib/btree_gin/expected/float8.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_float8 (
|
||||
i float8
|
||||
);
|
||||
INSERT INTO test_float8 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
CREATE INDEX idx_float8 ON test_float8 USING gin (i);
|
||||
SELECT * FROM test_float8 WHERE i<1::float8 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_float8 WHERE i<=1::float8 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
1
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_float8 WHERE i=1::float8 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_float8 WHERE i>=1::float8 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
2
|
||||
3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_float8 WHERE i>1::float8 ORDER BY i;
|
||||
i
|
||||
---
|
||||
2
|
||||
3
|
||||
(2 rows)
|
||||
|
||||
51
contrib/btree_gin/expected/inet.out
Normal file
51
contrib/btree_gin/expected/inet.out
Normal file
@ -0,0 +1,51 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_inet (
|
||||
i inet
|
||||
);
|
||||
INSERT INTO test_inet VALUES
|
||||
( '1.2.3.4/16' ),
|
||||
( '1.2.4.4/16' ),
|
||||
( '1.2.5.4/16' ),
|
||||
( '1.2.6.4/16' ),
|
||||
( '1.2.7.4/16' ),
|
||||
( '1.2.8.4/16' )
|
||||
;
|
||||
CREATE INDEX idx_inet ON test_inet USING gin (i);
|
||||
SELECT * FROM test_inet WHERE i<'1.2.6.4/16'::inet ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.3.4/16
|
||||
1.2.4.4/16
|
||||
1.2.5.4/16
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_inet WHERE i<='1.2.6.4/16'::inet ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.3.4/16
|
||||
1.2.4.4/16
|
||||
1.2.5.4/16
|
||||
1.2.6.4/16
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_inet WHERE i='1.2.6.4/16'::inet ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.6.4/16
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_inet WHERE i>='1.2.6.4/16'::inet ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.6.4/16
|
||||
1.2.7.4/16
|
||||
1.2.8.4/16
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_inet WHERE i>'1.2.6.4/16'::inet ORDER BY i;
|
||||
i
|
||||
------------
|
||||
1.2.7.4/16
|
||||
1.2.8.4/16
|
||||
(2 rows)
|
||||
|
||||
1
contrib/btree_gin/expected/install_btree_gin.out
Normal file
1
contrib/btree_gin/expected/install_btree_gin.out
Normal file
@ -0,0 +1 @@
|
||||
CREATE EXTENSION btree_gin;
|
||||
44
contrib/btree_gin/expected/int2.out
Normal file
44
contrib/btree_gin/expected/int2.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_int2 (
|
||||
i int2
|
||||
);
|
||||
INSERT INTO test_int2 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
CREATE INDEX idx_int2 ON test_int2 USING gin (i);
|
||||
SELECT * FROM test_int2 WHERE i<1::int2 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_int2 WHERE i<=1::int2 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
1
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_int2 WHERE i=1::int2 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_int2 WHERE i>=1::int2 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
2
|
||||
3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_int2 WHERE i>1::int2 ORDER BY i;
|
||||
i
|
||||
---
|
||||
2
|
||||
3
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/int4.out
Normal file
44
contrib/btree_gin/expected/int4.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_int4 (
|
||||
i int4
|
||||
);
|
||||
INSERT INTO test_int4 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
CREATE INDEX idx_int4 ON test_int4 USING gin (i);
|
||||
SELECT * FROM test_int4 WHERE i<1::int4 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_int4 WHERE i<=1::int4 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
1
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_int4 WHERE i=1::int4 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_int4 WHERE i>=1::int4 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
2
|
||||
3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_int4 WHERE i>1::int4 ORDER BY i;
|
||||
i
|
||||
---
|
||||
2
|
||||
3
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/int8.out
Normal file
44
contrib/btree_gin/expected/int8.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_int8 (
|
||||
i int8
|
||||
);
|
||||
INSERT INTO test_int8 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
CREATE INDEX idx_int8 ON test_int8 USING gin (i);
|
||||
SELECT * FROM test_int8 WHERE i<1::int8 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_int8 WHERE i<=1::int8 ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
1
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_int8 WHERE i=1::int8 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_int8 WHERE i>=1::int8 ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
2
|
||||
3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_int8 WHERE i>1::int8 ORDER BY i;
|
||||
i
|
||||
---
|
||||
2
|
||||
3
|
||||
(2 rows)
|
||||
|
||||
51
contrib/btree_gin/expected/interval.out
Normal file
51
contrib/btree_gin/expected/interval.out
Normal file
@ -0,0 +1,51 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_interval (
|
||||
i interval
|
||||
);
|
||||
INSERT INTO test_interval VALUES
|
||||
( '03:55:08' ),
|
||||
( '04:55:08' ),
|
||||
( '05:55:08' ),
|
||||
( '08:55:08' ),
|
||||
( '09:55:08' ),
|
||||
( '10:55:08' )
|
||||
;
|
||||
CREATE INDEX idx_interval ON test_interval USING gin (i);
|
||||
SELECT * FROM test_interval WHERE i<'08:55:08'::interval ORDER BY i;
|
||||
i
|
||||
--------------------------
|
||||
@ 3 hours 55 mins 8 secs
|
||||
@ 4 hours 55 mins 8 secs
|
||||
@ 5 hours 55 mins 8 secs
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_interval WHERE i<='08:55:08'::interval ORDER BY i;
|
||||
i
|
||||
--------------------------
|
||||
@ 3 hours 55 mins 8 secs
|
||||
@ 4 hours 55 mins 8 secs
|
||||
@ 5 hours 55 mins 8 secs
|
||||
@ 8 hours 55 mins 8 secs
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_interval WHERE i='08:55:08'::interval ORDER BY i;
|
||||
i
|
||||
--------------------------
|
||||
@ 8 hours 55 mins 8 secs
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_interval WHERE i>='08:55:08'::interval ORDER BY i;
|
||||
i
|
||||
---------------------------
|
||||
@ 8 hours 55 mins 8 secs
|
||||
@ 9 hours 55 mins 8 secs
|
||||
@ 10 hours 55 mins 8 secs
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_interval WHERE i>'08:55:08'::interval ORDER BY i;
|
||||
i
|
||||
---------------------------
|
||||
@ 9 hours 55 mins 8 secs
|
||||
@ 10 hours 55 mins 8 secs
|
||||
(2 rows)
|
||||
|
||||
51
contrib/btree_gin/expected/macaddr.out
Normal file
51
contrib/btree_gin/expected/macaddr.out
Normal file
@ -0,0 +1,51 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_macaddr (
|
||||
i macaddr
|
||||
);
|
||||
INSERT INTO test_macaddr VALUES
|
||||
( '22:00:5c:03:55:08' ),
|
||||
( '22:00:5c:04:55:08' ),
|
||||
( '22:00:5c:05:55:08' ),
|
||||
( '22:00:5c:08:55:08' ),
|
||||
( '22:00:5c:09:55:08' ),
|
||||
( '22:00:5c:10:55:08' )
|
||||
;
|
||||
CREATE INDEX idx_macaddr ON test_macaddr USING gin (i);
|
||||
SELECT * FROM test_macaddr WHERE i<'22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
i
|
||||
-------------------
|
||||
22:00:5c:03:55:08
|
||||
22:00:5c:04:55:08
|
||||
22:00:5c:05:55:08
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_macaddr WHERE i<='22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
i
|
||||
-------------------
|
||||
22:00:5c:03:55:08
|
||||
22:00:5c:04:55:08
|
||||
22:00:5c:05:55:08
|
||||
22:00:5c:08:55:08
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_macaddr WHERE i='22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
i
|
||||
-------------------
|
||||
22:00:5c:08:55:08
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_macaddr WHERE i>='22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
i
|
||||
-------------------
|
||||
22:00:5c:08:55:08
|
||||
22:00:5c:09:55:08
|
||||
22:00:5c:10:55:08
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_macaddr WHERE i>'22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
i
|
||||
-------------------
|
||||
22:00:5c:09:55:08
|
||||
22:00:5c:10:55:08
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/money.out
Normal file
44
contrib/btree_gin/expected/money.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_money (
|
||||
i money
|
||||
);
|
||||
INSERT INTO test_money VALUES ('-2'),('-1'),('0'),('1'),('2'),('3');
|
||||
CREATE INDEX idx_money ON test_money USING gin (i);
|
||||
SELECT * FROM test_money WHERE i<'1'::money ORDER BY i;
|
||||
i
|
||||
--------
|
||||
-$2.00
|
||||
-$1.00
|
||||
$0.00
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_money WHERE i<='1'::money ORDER BY i;
|
||||
i
|
||||
--------
|
||||
-$2.00
|
||||
-$1.00
|
||||
$0.00
|
||||
$1.00
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_money WHERE i='1'::money ORDER BY i;
|
||||
i
|
||||
-------
|
||||
$1.00
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_money WHERE i>='1'::money ORDER BY i;
|
||||
i
|
||||
-------
|
||||
$1.00
|
||||
$2.00
|
||||
$3.00
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_money WHERE i>'1'::money ORDER BY i;
|
||||
i
|
||||
-------
|
||||
$2.00
|
||||
$3.00
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/numeric.out
Normal file
44
contrib/btree_gin/expected/numeric.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_numeric (
|
||||
i numeric
|
||||
);
|
||||
INSERT INTO test_numeric VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
CREATE INDEX idx_numeric ON test_numeric USING gin (i);
|
||||
SELECT * FROM test_numeric WHERE i<'1'::numeric ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_numeric WHERE i<='1'::numeric ORDER BY i;
|
||||
i
|
||||
----
|
||||
-2
|
||||
-1
|
||||
0
|
||||
1
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_numeric WHERE i='1'::numeric ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_numeric WHERE i>='1'::numeric ORDER BY i;
|
||||
i
|
||||
---
|
||||
1
|
||||
2
|
||||
3
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_numeric WHERE i>'1'::numeric ORDER BY i;
|
||||
i
|
||||
---
|
||||
2
|
||||
3
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/oid.out
Normal file
44
contrib/btree_gin/expected/oid.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_oid (
|
||||
i oid
|
||||
);
|
||||
INSERT INTO test_oid VALUES (0),(1),(2),(3),(4),(5);
|
||||
CREATE INDEX idx_oid ON test_oid USING gin (i);
|
||||
SELECT * FROM test_oid WHERE i<3::oid ORDER BY i;
|
||||
i
|
||||
---
|
||||
0
|
||||
1
|
||||
2
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_oid WHERE i<=3::oid ORDER BY i;
|
||||
i
|
||||
---
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_oid WHERE i=3::oid ORDER BY i;
|
||||
i
|
||||
---
|
||||
3
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_oid WHERE i>=3::oid ORDER BY i;
|
||||
i
|
||||
---
|
||||
3
|
||||
4
|
||||
5
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_oid WHERE i>3::oid ORDER BY i;
|
||||
i
|
||||
---
|
||||
4
|
||||
5
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/text.out
Normal file
44
contrib/btree_gin/expected/text.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_text (
|
||||
i text
|
||||
);
|
||||
INSERT INTO test_text VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
||||
CREATE INDEX idx_text ON test_text USING gin (i);
|
||||
SELECT * FROM test_text WHERE i<'abc' ORDER BY i;
|
||||
i
|
||||
-----
|
||||
a
|
||||
aaa
|
||||
abb
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_text WHERE i<='abc' ORDER BY i;
|
||||
i
|
||||
-----
|
||||
a
|
||||
aaa
|
||||
abb
|
||||
abc
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_text WHERE i='abc' ORDER BY i;
|
||||
i
|
||||
-----
|
||||
abc
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_text WHERE i>='abc' ORDER BY i;
|
||||
i
|
||||
-----
|
||||
abc
|
||||
axy
|
||||
xyz
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_text WHERE i>'abc' ORDER BY i;
|
||||
i
|
||||
-----
|
||||
axy
|
||||
xyz
|
||||
(2 rows)
|
||||
|
||||
51
contrib/btree_gin/expected/time.out
Normal file
51
contrib/btree_gin/expected/time.out
Normal file
@ -0,0 +1,51 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_time (
|
||||
i time
|
||||
);
|
||||
INSERT INTO test_time VALUES
|
||||
( '03:55:08' ),
|
||||
( '04:55:08' ),
|
||||
( '05:55:08' ),
|
||||
( '08:55:08' ),
|
||||
( '09:55:08' ),
|
||||
( '10:55:08' )
|
||||
;
|
||||
CREATE INDEX idx_time ON test_time USING gin (i);
|
||||
SELECT * FROM test_time WHERE i<'08:55:08'::time ORDER BY i;
|
||||
i
|
||||
----------
|
||||
03:55:08
|
||||
04:55:08
|
||||
05:55:08
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_time WHERE i<='08:55:08'::time ORDER BY i;
|
||||
i
|
||||
----------
|
||||
03:55:08
|
||||
04:55:08
|
||||
05:55:08
|
||||
08:55:08
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_time WHERE i='08:55:08'::time ORDER BY i;
|
||||
i
|
||||
----------
|
||||
08:55:08
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_time WHERE i>='08:55:08'::time ORDER BY i;
|
||||
i
|
||||
----------
|
||||
08:55:08
|
||||
09:55:08
|
||||
10:55:08
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_time WHERE i>'08:55:08'::time ORDER BY i;
|
||||
i
|
||||
----------
|
||||
09:55:08
|
||||
10:55:08
|
||||
(2 rows)
|
||||
|
||||
51
contrib/btree_gin/expected/timestamp.out
Normal file
51
contrib/btree_gin/expected/timestamp.out
Normal file
@ -0,0 +1,51 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_timestamp (
|
||||
i timestamp
|
||||
);
|
||||
INSERT INTO test_timestamp VALUES
|
||||
( '2004-10-26 03:55:08' ),
|
||||
( '2004-10-26 04:55:08' ),
|
||||
( '2004-10-26 05:55:08' ),
|
||||
( '2004-10-26 08:55:08' ),
|
||||
( '2004-10-26 09:55:08' ),
|
||||
( '2004-10-26 10:55:08' )
|
||||
;
|
||||
CREATE INDEX idx_timestamp ON test_timestamp USING gin (i);
|
||||
SELECT * FROM test_timestamp WHERE i<'2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
i
|
||||
--------------------------
|
||||
Tue Oct 26 03:55:08 2004
|
||||
Tue Oct 26 04:55:08 2004
|
||||
Tue Oct 26 05:55:08 2004
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_timestamp WHERE i<='2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
i
|
||||
--------------------------
|
||||
Tue Oct 26 03:55:08 2004
|
||||
Tue Oct 26 04:55:08 2004
|
||||
Tue Oct 26 05:55:08 2004
|
||||
Tue Oct 26 08:55:08 2004
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_timestamp WHERE i='2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
i
|
||||
--------------------------
|
||||
Tue Oct 26 08:55:08 2004
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_timestamp WHERE i>='2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
i
|
||||
--------------------------
|
||||
Tue Oct 26 08:55:08 2004
|
||||
Tue Oct 26 09:55:08 2004
|
||||
Tue Oct 26 10:55:08 2004
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_timestamp WHERE i>'2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
i
|
||||
--------------------------
|
||||
Tue Oct 26 09:55:08 2004
|
||||
Tue Oct 26 10:55:08 2004
|
||||
(2 rows)
|
||||
|
||||
51
contrib/btree_gin/expected/timestamptz.out
Normal file
51
contrib/btree_gin/expected/timestamptz.out
Normal file
@ -0,0 +1,51 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_timestamptz (
|
||||
i timestamptz
|
||||
);
|
||||
INSERT INTO test_timestamptz VALUES
|
||||
( '2004-10-26 03:55:08' ),
|
||||
( '2004-10-26 04:55:08' ),
|
||||
( '2004-10-26 05:55:08' ),
|
||||
( '2004-10-26 08:55:08' ),
|
||||
( '2004-10-26 09:55:08' ),
|
||||
( '2004-10-26 10:55:08' )
|
||||
;
|
||||
CREATE INDEX idx_timestamptz ON test_timestamptz USING gin (i);
|
||||
SELECT * FROM test_timestamptz WHERE i<'2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
i
|
||||
------------------------------
|
||||
Tue Oct 26 03:55:08 2004 PDT
|
||||
Tue Oct 26 04:55:08 2004 PDT
|
||||
Tue Oct 26 05:55:08 2004 PDT
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_timestamptz WHERE i<='2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
i
|
||||
------------------------------
|
||||
Tue Oct 26 03:55:08 2004 PDT
|
||||
Tue Oct 26 04:55:08 2004 PDT
|
||||
Tue Oct 26 05:55:08 2004 PDT
|
||||
Tue Oct 26 08:55:08 2004 PDT
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_timestamptz WHERE i='2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
i
|
||||
------------------------------
|
||||
Tue Oct 26 08:55:08 2004 PDT
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_timestamptz WHERE i>='2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
i
|
||||
------------------------------
|
||||
Tue Oct 26 08:55:08 2004 PDT
|
||||
Tue Oct 26 09:55:08 2004 PDT
|
||||
Tue Oct 26 10:55:08 2004 PDT
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_timestamptz WHERE i>'2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
i
|
||||
------------------------------
|
||||
Tue Oct 26 09:55:08 2004 PDT
|
||||
Tue Oct 26 10:55:08 2004 PDT
|
||||
(2 rows)
|
||||
|
||||
51
contrib/btree_gin/expected/timetz.out
Normal file
51
contrib/btree_gin/expected/timetz.out
Normal file
@ -0,0 +1,51 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_timetz (
|
||||
i timetz
|
||||
);
|
||||
INSERT INTO test_timetz VALUES
|
||||
( '03:55:08 GMT+2' ),
|
||||
( '04:55:08 GMT+2' ),
|
||||
( '05:55:08 GMT+2' ),
|
||||
( '08:55:08 GMT+2' ),
|
||||
( '09:55:08 GMT+2' ),
|
||||
( '10:55:08 GMT+2' )
|
||||
;
|
||||
CREATE INDEX idx_timetz ON test_timetz USING gin (i);
|
||||
SELECT * FROM test_timetz WHERE i<'08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
i
|
||||
-------------
|
||||
03:55:08-02
|
||||
04:55:08-02
|
||||
05:55:08-02
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_timetz WHERE i<='08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
i
|
||||
-------------
|
||||
03:55:08-02
|
||||
04:55:08-02
|
||||
05:55:08-02
|
||||
08:55:08-02
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_timetz WHERE i='08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
i
|
||||
-------------
|
||||
08:55:08-02
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_timetz WHERE i>='08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
i
|
||||
-------------
|
||||
08:55:08-02
|
||||
09:55:08-02
|
||||
10:55:08-02
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_timetz WHERE i>'08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
i
|
||||
-------------
|
||||
09:55:08-02
|
||||
10:55:08-02
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/varbit.out
Normal file
44
contrib/btree_gin/expected/varbit.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_varbit (
|
||||
i varbit
|
||||
);
|
||||
INSERT INTO test_varbit VALUES ('001'),('010'),('011'),('100'),('101'),('110');
|
||||
CREATE INDEX idx_varbit ON test_varbit USING gin (i);
|
||||
SELECT * FROM test_varbit WHERE i<'100'::varbit ORDER BY i;
|
||||
i
|
||||
-----
|
||||
001
|
||||
010
|
||||
011
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_varbit WHERE i<='100'::varbit ORDER BY i;
|
||||
i
|
||||
-----
|
||||
001
|
||||
010
|
||||
011
|
||||
100
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_varbit WHERE i='100'::varbit ORDER BY i;
|
||||
i
|
||||
-----
|
||||
100
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_varbit WHERE i>='100'::varbit ORDER BY i;
|
||||
i
|
||||
-----
|
||||
100
|
||||
101
|
||||
110
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_varbit WHERE i>'100'::varbit ORDER BY i;
|
||||
i
|
||||
-----
|
||||
101
|
||||
110
|
||||
(2 rows)
|
||||
|
||||
44
contrib/btree_gin/expected/varchar.out
Normal file
44
contrib/btree_gin/expected/varchar.out
Normal file
@ -0,0 +1,44 @@
|
||||
set enable_seqscan=off;
|
||||
CREATE TABLE test_varchar (
|
||||
i varchar
|
||||
);
|
||||
INSERT INTO test_varchar VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
||||
CREATE INDEX idx_varchar ON test_varchar USING gin (i);
|
||||
SELECT * FROM test_varchar WHERE i<'abc'::varchar ORDER BY i;
|
||||
i
|
||||
-----
|
||||
a
|
||||
aaa
|
||||
abb
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_varchar WHERE i<='abc'::varchar ORDER BY i;
|
||||
i
|
||||
-----
|
||||
a
|
||||
aaa
|
||||
abb
|
||||
abc
|
||||
(4 rows)
|
||||
|
||||
SELECT * FROM test_varchar WHERE i='abc'::varchar ORDER BY i;
|
||||
i
|
||||
-----
|
||||
abc
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM test_varchar WHERE i>='abc'::varchar ORDER BY i;
|
||||
i
|
||||
-----
|
||||
abc
|
||||
axy
|
||||
xyz
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM test_varchar WHERE i>'abc'::varchar ORDER BY i;
|
||||
i
|
||||
-----
|
||||
axy
|
||||
xyz
|
||||
(2 rows)
|
||||
|
||||
15
contrib/btree_gin/sql/bit.sql
Normal file
15
contrib/btree_gin/sql/bit.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_bit (
|
||||
i bit(3)
|
||||
);
|
||||
|
||||
INSERT INTO test_bit VALUES ('001'),('010'),('011'),('100'),('101'),('110');
|
||||
|
||||
CREATE INDEX idx_bit ON test_bit USING gin (i);
|
||||
|
||||
SELECT * FROM test_bit WHERE i<'100'::bit(3) ORDER BY i;
|
||||
SELECT * FROM test_bit WHERE i<='100'::bit(3) ORDER BY i;
|
||||
SELECT * FROM test_bit WHERE i='100'::bit(3) ORDER BY i;
|
||||
SELECT * FROM test_bit WHERE i>='100'::bit(3) ORDER BY i;
|
||||
SELECT * FROM test_bit WHERE i>'100'::bit(3) ORDER BY i;
|
||||
17
contrib/btree_gin/sql/bytea.sql
Normal file
17
contrib/btree_gin/sql/bytea.sql
Normal file
@ -0,0 +1,17 @@
|
||||
set enable_seqscan=off;
|
||||
-- ensure consistent test output regardless of the default bytea format
|
||||
SET bytea_output TO escape;
|
||||
|
||||
CREATE TABLE test_bytea (
|
||||
i bytea
|
||||
);
|
||||
|
||||
INSERT INTO test_bytea VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
||||
|
||||
CREATE INDEX idx_bytea ON test_bytea USING gin (i);
|
||||
|
||||
SELECT * FROM test_bytea WHERE i<'abc'::bytea ORDER BY i;
|
||||
SELECT * FROM test_bytea WHERE i<='abc'::bytea ORDER BY i;
|
||||
SELECT * FROM test_bytea WHERE i='abc'::bytea ORDER BY i;
|
||||
SELECT * FROM test_bytea WHERE i>='abc'::bytea ORDER BY i;
|
||||
SELECT * FROM test_bytea WHERE i>'abc'::bytea ORDER BY i;
|
||||
15
contrib/btree_gin/sql/char.sql
Normal file
15
contrib/btree_gin/sql/char.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_char (
|
||||
i "char"
|
||||
);
|
||||
|
||||
INSERT INTO test_char VALUES ('a'),('b'),('c'),('d'),('e'),('f');
|
||||
|
||||
CREATE INDEX idx_char ON test_char USING gin (i);
|
||||
|
||||
SELECT * FROM test_char WHERE i<'d'::"char" ORDER BY i;
|
||||
SELECT * FROM test_char WHERE i<='d'::"char" ORDER BY i;
|
||||
SELECT * FROM test_char WHERE i='d'::"char" ORDER BY i;
|
||||
SELECT * FROM test_char WHERE i>='d'::"char" ORDER BY i;
|
||||
SELECT * FROM test_char WHERE i>'d'::"char" ORDER BY i;
|
||||
22
contrib/btree_gin/sql/cidr.sql
Normal file
22
contrib/btree_gin/sql/cidr.sql
Normal file
@ -0,0 +1,22 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_cidr (
|
||||
i cidr
|
||||
);
|
||||
|
||||
INSERT INTO test_cidr VALUES
|
||||
( '1.2.3.4' ),
|
||||
( '1.2.4.4' ),
|
||||
( '1.2.5.4' ),
|
||||
( '1.2.6.4' ),
|
||||
( '1.2.7.4' ),
|
||||
( '1.2.8.4' )
|
||||
;
|
||||
|
||||
CREATE INDEX idx_cidr ON test_cidr USING gin (i);
|
||||
|
||||
SELECT * FROM test_cidr WHERE i<'1.2.6.4'::cidr ORDER BY i;
|
||||
SELECT * FROM test_cidr WHERE i<='1.2.6.4'::cidr ORDER BY i;
|
||||
SELECT * FROM test_cidr WHERE i='1.2.6.4'::cidr ORDER BY i;
|
||||
SELECT * FROM test_cidr WHERE i>='1.2.6.4'::cidr ORDER BY i;
|
||||
SELECT * FROM test_cidr WHERE i>'1.2.6.4'::cidr ORDER BY i;
|
||||
23
contrib/btree_gin/sql/date.sql
Normal file
23
contrib/btree_gin/sql/date.sql
Normal file
@ -0,0 +1,23 @@
|
||||
SET DATESTYLE=ISO;
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_date (
|
||||
i date
|
||||
);
|
||||
|
||||
INSERT INTO test_date VALUES
|
||||
( '2004-10-23' ),
|
||||
( '2004-10-24' ),
|
||||
( '2004-10-25' ),
|
||||
( '2004-10-26' ),
|
||||
( '2004-10-27' ),
|
||||
( '2004-10-28' )
|
||||
;
|
||||
|
||||
CREATE INDEX idx_date ON test_date USING gin (i);
|
||||
|
||||
SELECT * FROM test_date WHERE i<'2004-10-26'::date ORDER BY i;
|
||||
SELECT * FROM test_date WHERE i<='2004-10-26'::date ORDER BY i;
|
||||
SELECT * FROM test_date WHERE i='2004-10-26'::date ORDER BY i;
|
||||
SELECT * FROM test_date WHERE i>='2004-10-26'::date ORDER BY i;
|
||||
SELECT * FROM test_date WHERE i>'2004-10-26'::date ORDER BY i;
|
||||
15
contrib/btree_gin/sql/float4.sql
Normal file
15
contrib/btree_gin/sql/float4.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_float4 (
|
||||
i float4
|
||||
);
|
||||
|
||||
INSERT INTO test_float4 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
|
||||
CREATE INDEX idx_float4 ON test_float4 USING gin (i);
|
||||
|
||||
SELECT * FROM test_float4 WHERE i<1::float4 ORDER BY i;
|
||||
SELECT * FROM test_float4 WHERE i<=1::float4 ORDER BY i;
|
||||
SELECT * FROM test_float4 WHERE i=1::float4 ORDER BY i;
|
||||
SELECT * FROM test_float4 WHERE i>=1::float4 ORDER BY i;
|
||||
SELECT * FROM test_float4 WHERE i>1::float4 ORDER BY i;
|
||||
15
contrib/btree_gin/sql/float8.sql
Normal file
15
contrib/btree_gin/sql/float8.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_float8 (
|
||||
i float8
|
||||
);
|
||||
|
||||
INSERT INTO test_float8 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
|
||||
CREATE INDEX idx_float8 ON test_float8 USING gin (i);
|
||||
|
||||
SELECT * FROM test_float8 WHERE i<1::float8 ORDER BY i;
|
||||
SELECT * FROM test_float8 WHERE i<=1::float8 ORDER BY i;
|
||||
SELECT * FROM test_float8 WHERE i=1::float8 ORDER BY i;
|
||||
SELECT * FROM test_float8 WHERE i>=1::float8 ORDER BY i;
|
||||
SELECT * FROM test_float8 WHERE i>1::float8 ORDER BY i;
|
||||
22
contrib/btree_gin/sql/inet.sql
Normal file
22
contrib/btree_gin/sql/inet.sql
Normal file
@ -0,0 +1,22 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_inet (
|
||||
i inet
|
||||
);
|
||||
|
||||
INSERT INTO test_inet VALUES
|
||||
( '1.2.3.4/16' ),
|
||||
( '1.2.4.4/16' ),
|
||||
( '1.2.5.4/16' ),
|
||||
( '1.2.6.4/16' ),
|
||||
( '1.2.7.4/16' ),
|
||||
( '1.2.8.4/16' )
|
||||
;
|
||||
|
||||
CREATE INDEX idx_inet ON test_inet USING gin (i);
|
||||
|
||||
SELECT * FROM test_inet WHERE i<'1.2.6.4/16'::inet ORDER BY i;
|
||||
SELECT * FROM test_inet WHERE i<='1.2.6.4/16'::inet ORDER BY i;
|
||||
SELECT * FROM test_inet WHERE i='1.2.6.4/16'::inet ORDER BY i;
|
||||
SELECT * FROM test_inet WHERE i>='1.2.6.4/16'::inet ORDER BY i;
|
||||
SELECT * FROM test_inet WHERE i>'1.2.6.4/16'::inet ORDER BY i;
|
||||
1
contrib/btree_gin/sql/install_btree_gin.sql
Normal file
1
contrib/btree_gin/sql/install_btree_gin.sql
Normal file
@ -0,0 +1 @@
|
||||
CREATE EXTENSION btree_gin;
|
||||
15
contrib/btree_gin/sql/int2.sql
Normal file
15
contrib/btree_gin/sql/int2.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_int2 (
|
||||
i int2
|
||||
);
|
||||
|
||||
INSERT INTO test_int2 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
|
||||
CREATE INDEX idx_int2 ON test_int2 USING gin (i);
|
||||
|
||||
SELECT * FROM test_int2 WHERE i<1::int2 ORDER BY i;
|
||||
SELECT * FROM test_int2 WHERE i<=1::int2 ORDER BY i;
|
||||
SELECT * FROM test_int2 WHERE i=1::int2 ORDER BY i;
|
||||
SELECT * FROM test_int2 WHERE i>=1::int2 ORDER BY i;
|
||||
SELECT * FROM test_int2 WHERE i>1::int2 ORDER BY i;
|
||||
15
contrib/btree_gin/sql/int4.sql
Normal file
15
contrib/btree_gin/sql/int4.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_int4 (
|
||||
i int4
|
||||
);
|
||||
|
||||
INSERT INTO test_int4 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
|
||||
CREATE INDEX idx_int4 ON test_int4 USING gin (i);
|
||||
|
||||
SELECT * FROM test_int4 WHERE i<1::int4 ORDER BY i;
|
||||
SELECT * FROM test_int4 WHERE i<=1::int4 ORDER BY i;
|
||||
SELECT * FROM test_int4 WHERE i=1::int4 ORDER BY i;
|
||||
SELECT * FROM test_int4 WHERE i>=1::int4 ORDER BY i;
|
||||
SELECT * FROM test_int4 WHERE i>1::int4 ORDER BY i;
|
||||
15
contrib/btree_gin/sql/int8.sql
Normal file
15
contrib/btree_gin/sql/int8.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_int8 (
|
||||
i int8
|
||||
);
|
||||
|
||||
INSERT INTO test_int8 VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
|
||||
CREATE INDEX idx_int8 ON test_int8 USING gin (i);
|
||||
|
||||
SELECT * FROM test_int8 WHERE i<1::int8 ORDER BY i;
|
||||
SELECT * FROM test_int8 WHERE i<=1::int8 ORDER BY i;
|
||||
SELECT * FROM test_int8 WHERE i=1::int8 ORDER BY i;
|
||||
SELECT * FROM test_int8 WHERE i>=1::int8 ORDER BY i;
|
||||
SELECT * FROM test_int8 WHERE i>1::int8 ORDER BY i;
|
||||
22
contrib/btree_gin/sql/interval.sql
Normal file
22
contrib/btree_gin/sql/interval.sql
Normal file
@ -0,0 +1,22 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_interval (
|
||||
i interval
|
||||
);
|
||||
|
||||
INSERT INTO test_interval VALUES
|
||||
( '03:55:08' ),
|
||||
( '04:55:08' ),
|
||||
( '05:55:08' ),
|
||||
( '08:55:08' ),
|
||||
( '09:55:08' ),
|
||||
( '10:55:08' )
|
||||
;
|
||||
|
||||
CREATE INDEX idx_interval ON test_interval USING gin (i);
|
||||
|
||||
SELECT * FROM test_interval WHERE i<'08:55:08'::interval ORDER BY i;
|
||||
SELECT * FROM test_interval WHERE i<='08:55:08'::interval ORDER BY i;
|
||||
SELECT * FROM test_interval WHERE i='08:55:08'::interval ORDER BY i;
|
||||
SELECT * FROM test_interval WHERE i>='08:55:08'::interval ORDER BY i;
|
||||
SELECT * FROM test_interval WHERE i>'08:55:08'::interval ORDER BY i;
|
||||
22
contrib/btree_gin/sql/macaddr.sql
Normal file
22
contrib/btree_gin/sql/macaddr.sql
Normal file
@ -0,0 +1,22 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_macaddr (
|
||||
i macaddr
|
||||
);
|
||||
|
||||
INSERT INTO test_macaddr VALUES
|
||||
( '22:00:5c:03:55:08' ),
|
||||
( '22:00:5c:04:55:08' ),
|
||||
( '22:00:5c:05:55:08' ),
|
||||
( '22:00:5c:08:55:08' ),
|
||||
( '22:00:5c:09:55:08' ),
|
||||
( '22:00:5c:10:55:08' )
|
||||
;
|
||||
|
||||
CREATE INDEX idx_macaddr ON test_macaddr USING gin (i);
|
||||
|
||||
SELECT * FROM test_macaddr WHERE i<'22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
SELECT * FROM test_macaddr WHERE i<='22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
SELECT * FROM test_macaddr WHERE i='22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
SELECT * FROM test_macaddr WHERE i>='22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
SELECT * FROM test_macaddr WHERE i>'22:00:5c:08:55:08'::macaddr ORDER BY i;
|
||||
15
contrib/btree_gin/sql/money.sql
Normal file
15
contrib/btree_gin/sql/money.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_money (
|
||||
i money
|
||||
);
|
||||
|
||||
INSERT INTO test_money VALUES ('-2'),('-1'),('0'),('1'),('2'),('3');
|
||||
|
||||
CREATE INDEX idx_money ON test_money USING gin (i);
|
||||
|
||||
SELECT * FROM test_money WHERE i<'1'::money ORDER BY i;
|
||||
SELECT * FROM test_money WHERE i<='1'::money ORDER BY i;
|
||||
SELECT * FROM test_money WHERE i='1'::money ORDER BY i;
|
||||
SELECT * FROM test_money WHERE i>='1'::money ORDER BY i;
|
||||
SELECT * FROM test_money WHERE i>'1'::money ORDER BY i;
|
||||
15
contrib/btree_gin/sql/numeric.sql
Normal file
15
contrib/btree_gin/sql/numeric.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_numeric (
|
||||
i numeric
|
||||
);
|
||||
|
||||
INSERT INTO test_numeric VALUES (-2),(-1),(0),(1),(2),(3);
|
||||
|
||||
CREATE INDEX idx_numeric ON test_numeric USING gin (i);
|
||||
|
||||
SELECT * FROM test_numeric WHERE i<'1'::numeric ORDER BY i;
|
||||
SELECT * FROM test_numeric WHERE i<='1'::numeric ORDER BY i;
|
||||
SELECT * FROM test_numeric WHERE i='1'::numeric ORDER BY i;
|
||||
SELECT * FROM test_numeric WHERE i>='1'::numeric ORDER BY i;
|
||||
SELECT * FROM test_numeric WHERE i>'1'::numeric ORDER BY i;
|
||||
15
contrib/btree_gin/sql/oid.sql
Normal file
15
contrib/btree_gin/sql/oid.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_oid (
|
||||
i oid
|
||||
);
|
||||
|
||||
INSERT INTO test_oid VALUES (0),(1),(2),(3),(4),(5);
|
||||
|
||||
CREATE INDEX idx_oid ON test_oid USING gin (i);
|
||||
|
||||
SELECT * FROM test_oid WHERE i<3::oid ORDER BY i;
|
||||
SELECT * FROM test_oid WHERE i<=3::oid ORDER BY i;
|
||||
SELECT * FROM test_oid WHERE i=3::oid ORDER BY i;
|
||||
SELECT * FROM test_oid WHERE i>=3::oid ORDER BY i;
|
||||
SELECT * FROM test_oid WHERE i>3::oid ORDER BY i;
|
||||
15
contrib/btree_gin/sql/text.sql
Normal file
15
contrib/btree_gin/sql/text.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_text (
|
||||
i text
|
||||
);
|
||||
|
||||
INSERT INTO test_text VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
||||
|
||||
CREATE INDEX idx_text ON test_text USING gin (i);
|
||||
|
||||
SELECT * FROM test_text WHERE i<'abc' ORDER BY i;
|
||||
SELECT * FROM test_text WHERE i<='abc' ORDER BY i;
|
||||
SELECT * FROM test_text WHERE i='abc' ORDER BY i;
|
||||
SELECT * FROM test_text WHERE i>='abc' ORDER BY i;
|
||||
SELECT * FROM test_text WHERE i>'abc' ORDER BY i;
|
||||
22
contrib/btree_gin/sql/time.sql
Normal file
22
contrib/btree_gin/sql/time.sql
Normal file
@ -0,0 +1,22 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_time (
|
||||
i time
|
||||
);
|
||||
|
||||
INSERT INTO test_time VALUES
|
||||
( '03:55:08' ),
|
||||
( '04:55:08' ),
|
||||
( '05:55:08' ),
|
||||
( '08:55:08' ),
|
||||
( '09:55:08' ),
|
||||
( '10:55:08' )
|
||||
;
|
||||
|
||||
CREATE INDEX idx_time ON test_time USING gin (i);
|
||||
|
||||
SELECT * FROM test_time WHERE i<'08:55:08'::time ORDER BY i;
|
||||
SELECT * FROM test_time WHERE i<='08:55:08'::time ORDER BY i;
|
||||
SELECT * FROM test_time WHERE i='08:55:08'::time ORDER BY i;
|
||||
SELECT * FROM test_time WHERE i>='08:55:08'::time ORDER BY i;
|
||||
SELECT * FROM test_time WHERE i>'08:55:08'::time ORDER BY i;
|
||||
22
contrib/btree_gin/sql/timestamp.sql
Normal file
22
contrib/btree_gin/sql/timestamp.sql
Normal file
@ -0,0 +1,22 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_timestamp (
|
||||
i timestamp
|
||||
);
|
||||
|
||||
INSERT INTO test_timestamp VALUES
|
||||
( '2004-10-26 03:55:08' ),
|
||||
( '2004-10-26 04:55:08' ),
|
||||
( '2004-10-26 05:55:08' ),
|
||||
( '2004-10-26 08:55:08' ),
|
||||
( '2004-10-26 09:55:08' ),
|
||||
( '2004-10-26 10:55:08' )
|
||||
;
|
||||
|
||||
CREATE INDEX idx_timestamp ON test_timestamp USING gin (i);
|
||||
|
||||
SELECT * FROM test_timestamp WHERE i<'2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
SELECT * FROM test_timestamp WHERE i<='2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
SELECT * FROM test_timestamp WHERE i='2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
SELECT * FROM test_timestamp WHERE i>='2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
SELECT * FROM test_timestamp WHERE i>'2004-10-26 08:55:08'::timestamp ORDER BY i;
|
||||
22
contrib/btree_gin/sql/timestamptz.sql
Normal file
22
contrib/btree_gin/sql/timestamptz.sql
Normal file
@ -0,0 +1,22 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_timestamptz (
|
||||
i timestamptz
|
||||
);
|
||||
|
||||
INSERT INTO test_timestamptz VALUES
|
||||
( '2004-10-26 03:55:08' ),
|
||||
( '2004-10-26 04:55:08' ),
|
||||
( '2004-10-26 05:55:08' ),
|
||||
( '2004-10-26 08:55:08' ),
|
||||
( '2004-10-26 09:55:08' ),
|
||||
( '2004-10-26 10:55:08' )
|
||||
;
|
||||
|
||||
CREATE INDEX idx_timestamptz ON test_timestamptz USING gin (i);
|
||||
|
||||
SELECT * FROM test_timestamptz WHERE i<'2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
SELECT * FROM test_timestamptz WHERE i<='2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
SELECT * FROM test_timestamptz WHERE i='2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
SELECT * FROM test_timestamptz WHERE i>='2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
SELECT * FROM test_timestamptz WHERE i>'2004-10-26 08:55:08'::timestamptz ORDER BY i;
|
||||
22
contrib/btree_gin/sql/timetz.sql
Normal file
22
contrib/btree_gin/sql/timetz.sql
Normal file
@ -0,0 +1,22 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_timetz (
|
||||
i timetz
|
||||
);
|
||||
|
||||
INSERT INTO test_timetz VALUES
|
||||
( '03:55:08 GMT+2' ),
|
||||
( '04:55:08 GMT+2' ),
|
||||
( '05:55:08 GMT+2' ),
|
||||
( '08:55:08 GMT+2' ),
|
||||
( '09:55:08 GMT+2' ),
|
||||
( '10:55:08 GMT+2' )
|
||||
;
|
||||
|
||||
CREATE INDEX idx_timetz ON test_timetz USING gin (i);
|
||||
|
||||
SELECT * FROM test_timetz WHERE i<'08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
SELECT * FROM test_timetz WHERE i<='08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
SELECT * FROM test_timetz WHERE i='08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
SELECT * FROM test_timetz WHERE i>='08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
SELECT * FROM test_timetz WHERE i>'08:55:08 GMT+2'::timetz ORDER BY i;
|
||||
15
contrib/btree_gin/sql/varbit.sql
Normal file
15
contrib/btree_gin/sql/varbit.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_varbit (
|
||||
i varbit
|
||||
);
|
||||
|
||||
INSERT INTO test_varbit VALUES ('001'),('010'),('011'),('100'),('101'),('110');
|
||||
|
||||
CREATE INDEX idx_varbit ON test_varbit USING gin (i);
|
||||
|
||||
SELECT * FROM test_varbit WHERE i<'100'::varbit ORDER BY i;
|
||||
SELECT * FROM test_varbit WHERE i<='100'::varbit ORDER BY i;
|
||||
SELECT * FROM test_varbit WHERE i='100'::varbit ORDER BY i;
|
||||
SELECT * FROM test_varbit WHERE i>='100'::varbit ORDER BY i;
|
||||
SELECT * FROM test_varbit WHERE i>'100'::varbit ORDER BY i;
|
||||
15
contrib/btree_gin/sql/varchar.sql
Normal file
15
contrib/btree_gin/sql/varchar.sql
Normal file
@ -0,0 +1,15 @@
|
||||
set enable_seqscan=off;
|
||||
|
||||
CREATE TABLE test_varchar (
|
||||
i varchar
|
||||
);
|
||||
|
||||
INSERT INTO test_varchar VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
|
||||
|
||||
CREATE INDEX idx_varchar ON test_varchar USING gin (i);
|
||||
|
||||
SELECT * FROM test_varchar WHERE i<'abc'::varchar ORDER BY i;
|
||||
SELECT * FROM test_varchar WHERE i<='abc'::varchar ORDER BY i;
|
||||
SELECT * FROM test_varchar WHERE i='abc'::varchar ORDER BY i;
|
||||
SELECT * FROM test_varchar WHERE i>='abc'::varchar ORDER BY i;
|
||||
SELECT * FROM test_varchar WHERE i>'abc'::varchar ORDER BY i;
|
||||
29
contrib/btree_gist/Makefile
Normal file
29
contrib/btree_gist/Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
# contrib/btree_gist/Makefile
|
||||
|
||||
MODULE_big = btree_gist
|
||||
|
||||
OBJS = btree_gist.o btree_utils_num.o btree_utils_var.o btree_int2.o \
|
||||
btree_int4.o btree_int8.o btree_float4.o btree_float8.o btree_cash.o \
|
||||
btree_oid.o btree_ts.o btree_time.o btree_date.o btree_interval.o \
|
||||
btree_macaddr.o btree_inet.o btree_text.o btree_bytea.o btree_bit.o \
|
||||
btree_numeric.o
|
||||
|
||||
EXTENSION = btree_gist
|
||||
DATA = btree_gist--1.0.sql btree_gist--unpackaged--1.0.sql
|
||||
|
||||
REGRESS = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz \
|
||||
time timetz date interval macaddr inet cidr text varchar char bytea \
|
||||
bit varbit numeric not_equal
|
||||
|
||||
SHLIB_LINK += $(filter -lm, $(LIBS))
|
||||
|
||||
ifdef USE_PGXS
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/btree_gist
|
||||
top_builddir = ../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
160
contrib/btree_gist/btree_bit.cpp
Normal file
160
contrib/btree_gist/btree_bit.cpp
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* contrib/btree_gist/btree_bit.c
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include "btree_gist.h"
|
||||
#include "btree_utils_var.h"
|
||||
#include "utils/bytea.h"
|
||||
#include "utils/varbit.h"
|
||||
|
||||
/*
|
||||
** Bit ops
|
||||
*/
|
||||
PG_FUNCTION_INFO_V1(gbt_bit_compress);
|
||||
PG_FUNCTION_INFO_V1(gbt_bit_union);
|
||||
PG_FUNCTION_INFO_V1(gbt_bit_picksplit);
|
||||
PG_FUNCTION_INFO_V1(gbt_bit_consistent);
|
||||
PG_FUNCTION_INFO_V1(gbt_bit_penalty);
|
||||
PG_FUNCTION_INFO_V1(gbt_bit_same);
|
||||
|
||||
extern "C" Datum gbt_bit_compress(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bit_union(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bit_picksplit(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bit_consistent(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bit_penalty(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bit_same(PG_FUNCTION_ARGS);
|
||||
|
||||
/* define for comparison */
|
||||
|
||||
static bool gbt_bitgt(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(bitgt, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool gbt_bitge(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(bitge, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool gbt_biteq(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(biteq, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool gbt_bitle(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(bitle, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool gbt_bitlt(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(bitlt, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static int32 gbt_bitcmp(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetInt32(DirectFunctionCall2(byteacmp, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bytea* gbt_bit_xfrm(bytea* leaf)
|
||||
{
|
||||
bytea* out = leaf;
|
||||
int s = INTALIGN(VARBITBYTES(leaf) + VARHDRSZ);
|
||||
|
||||
out = (bytea*)palloc(s);
|
||||
SET_VARSIZE(out, s);
|
||||
memcpy((void*)VARDATA(out), (void*)VARBITS(leaf), VARBITBYTES(leaf));
|
||||
return out;
|
||||
}
|
||||
|
||||
static GBT_VARKEY* gbt_bit_l2n(GBT_VARKEY* leaf)
|
||||
{
|
||||
|
||||
GBT_VARKEY* out = leaf;
|
||||
GBT_VARKEY_R r = gbt_var_key_readable(leaf);
|
||||
bytea* o = NULL;
|
||||
|
||||
o = gbt_bit_xfrm(r.lower);
|
||||
r.upper = r.lower = o;
|
||||
out = gbt_var_key_copy(&r, TRUE);
|
||||
pfree(o);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static const gbtree_vinfo tinfo = {
|
||||
gbt_t_bit, 0, TRUE, gbt_bitgt, gbt_bitge, gbt_biteq, gbt_bitle, gbt_bitlt, gbt_bitcmp, gbt_bit_l2n};
|
||||
|
||||
/**************************************************
|
||||
* Bit ops
|
||||
**************************************************/
|
||||
|
||||
Datum gbt_bit_compress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
|
||||
PG_RETURN_POINTER(gbt_var_compress(entry, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_bit_consistent(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
void* query = (void*)DatumGetByteaP(PG_GETARG_DATUM(1));
|
||||
StrategyNumber strategy = (StrategyNumber)PG_GETARG_UINT16(2);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
bool* recheck = (bool*)PG_GETARG_POINTER(4);
|
||||
bool retval = false;
|
||||
GBT_VARKEY* key = (GBT_VARKEY*)DatumGetPointer(entry->key);
|
||||
GBT_VARKEY_R r = gbt_var_key_readable(key);
|
||||
|
||||
/* All cases served by this function are exact */
|
||||
*recheck = false;
|
||||
|
||||
if (GIST_LEAF(entry))
|
||||
retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(), TRUE, &tinfo);
|
||||
else {
|
||||
bytea* q = gbt_bit_xfrm((bytea*)query);
|
||||
|
||||
retval = gbt_var_consistent(&r, q, strategy, PG_GET_COLLATION(), FALSE, &tinfo);
|
||||
}
|
||||
PG_RETURN_BOOL(retval);
|
||||
}
|
||||
|
||||
Datum gbt_bit_union(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector* entryvec = (GistEntryVector*)PG_GETARG_POINTER(0);
|
||||
int32* size = (int*)PG_GETARG_POINTER(1);
|
||||
|
||||
PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_bit_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector* entryvec = (GistEntryVector*)PG_GETARG_POINTER(0);
|
||||
GIST_SPLITVEC* v = (GIST_SPLITVEC*)PG_GETARG_POINTER(1);
|
||||
|
||||
gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(), &tinfo);
|
||||
PG_RETURN_POINTER(v);
|
||||
}
|
||||
|
||||
Datum gbt_bit_same(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum d1 = PG_GETARG_DATUM(0);
|
||||
Datum d2 = PG_GETARG_DATUM(1);
|
||||
bool* result = (bool*)PG_GETARG_POINTER(2);
|
||||
|
||||
*result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo);
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
Datum gbt_bit_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* o = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
GISTENTRY* n = (GISTENTRY*)PG_GETARG_POINTER(1);
|
||||
float* result = (float*)PG_GETARG_POINTER(2);
|
||||
|
||||
PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(), &tinfo));
|
||||
}
|
||||
127
contrib/btree_gist/btree_bytea.cpp
Normal file
127
contrib/btree_gist/btree_bytea.cpp
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* contrib/btree_gist/btree_bytea.c
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include "btree_gist.h"
|
||||
#include "btree_utils_var.h"
|
||||
#include "utils/bytea.h"
|
||||
|
||||
/*
|
||||
** Bytea ops
|
||||
*/
|
||||
PG_FUNCTION_INFO_V1(gbt_bytea_compress);
|
||||
PG_FUNCTION_INFO_V1(gbt_bytea_union);
|
||||
PG_FUNCTION_INFO_V1(gbt_bytea_picksplit);
|
||||
PG_FUNCTION_INFO_V1(gbt_bytea_consistent);
|
||||
PG_FUNCTION_INFO_V1(gbt_bytea_penalty);
|
||||
PG_FUNCTION_INFO_V1(gbt_bytea_same);
|
||||
|
||||
extern "C" Datum gbt_bytea_compress(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bytea_union(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bytea_picksplit(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bytea_consistent(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bytea_penalty(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_bytea_same(PG_FUNCTION_ARGS);
|
||||
|
||||
/* define for comparison */
|
||||
|
||||
static bool gbt_byteagt(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(byteagt, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool gbt_byteage(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(byteage, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool gbt_byteaeq(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(byteaeq, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool gbt_byteale(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(byteale, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool gbt_bytealt(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetBool(DirectFunctionCall2(bytealt, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static int32 gbt_byteacmp(const void* a, const void* b, Oid collation)
|
||||
{
|
||||
return DatumGetInt32(DirectFunctionCall2(byteacmp, PointerGetDatum(a), PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static const gbtree_vinfo tinfo = {
|
||||
gbt_t_bytea, 0, TRUE, gbt_byteagt, gbt_byteage, gbt_byteaeq, gbt_byteale, gbt_bytealt, gbt_byteacmp, NULL};
|
||||
|
||||
/**************************************************
|
||||
* Text ops
|
||||
**************************************************/
|
||||
|
||||
Datum gbt_bytea_compress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
|
||||
PG_RETURN_POINTER(gbt_var_compress(entry, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_bytea_consistent(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
void* query = (void*)DatumGetByteaP(PG_GETARG_DATUM(1));
|
||||
StrategyNumber strategy = (StrategyNumber)PG_GETARG_UINT16(2);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
bool* recheck = (bool*)PG_GETARG_POINTER(4);
|
||||
bool retval = false;
|
||||
GBT_VARKEY* key = (GBT_VARKEY*)DatumGetPointer(entry->key);
|
||||
GBT_VARKEY_R r = gbt_var_key_readable(key);
|
||||
|
||||
/* All cases served by this function are exact */
|
||||
*recheck = false;
|
||||
|
||||
retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(), GIST_LEAF(entry), &tinfo);
|
||||
PG_RETURN_BOOL(retval);
|
||||
}
|
||||
|
||||
Datum gbt_bytea_union(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector* entryvec = (GistEntryVector*)PG_GETARG_POINTER(0);
|
||||
int32* size = (int*)PG_GETARG_POINTER(1);
|
||||
|
||||
PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_bytea_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector* entryvec = (GistEntryVector*)PG_GETARG_POINTER(0);
|
||||
GIST_SPLITVEC* v = (GIST_SPLITVEC*)PG_GETARG_POINTER(1);
|
||||
|
||||
gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(), &tinfo);
|
||||
PG_RETURN_POINTER(v);
|
||||
}
|
||||
|
||||
Datum gbt_bytea_same(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum d1 = PG_GETARG_DATUM(0);
|
||||
Datum d2 = PG_GETARG_DATUM(1);
|
||||
bool* result = (bool*)PG_GETARG_POINTER(2);
|
||||
|
||||
*result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo);
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
Datum gbt_bytea_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* o = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
GISTENTRY* n = (GISTENTRY*)PG_GETARG_POINTER(1);
|
||||
float* result = (float*)PG_GETARG_POINTER(2);
|
||||
|
||||
PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(), &tinfo));
|
||||
}
|
||||
186
contrib/btree_gist/btree_cash.cpp
Normal file
186
contrib/btree_gist/btree_cash.cpp
Normal file
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* contrib/btree_gist/btree_cash.c
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include "btree_gist.h"
|
||||
#include "btree_utils_num.h"
|
||||
#include "utils/cash.h"
|
||||
|
||||
typedef struct {
|
||||
Cash lower;
|
||||
Cash upper;
|
||||
} cashKEY;
|
||||
|
||||
/*
|
||||
** Cash ops
|
||||
*/
|
||||
PG_FUNCTION_INFO_V1(gbt_cash_compress);
|
||||
PG_FUNCTION_INFO_V1(gbt_cash_union);
|
||||
PG_FUNCTION_INFO_V1(gbt_cash_picksplit);
|
||||
PG_FUNCTION_INFO_V1(gbt_cash_consistent);
|
||||
PG_FUNCTION_INFO_V1(gbt_cash_distance);
|
||||
PG_FUNCTION_INFO_V1(gbt_cash_penalty);
|
||||
PG_FUNCTION_INFO_V1(gbt_cash_same);
|
||||
|
||||
extern "C" Datum gbt_cash_compress(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_cash_union(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_cash_picksplit(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_cash_consistent(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_cash_distance(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_cash_penalty(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_cash_same(PG_FUNCTION_ARGS);
|
||||
|
||||
static bool gbt_cashgt(const void* a, const void* b)
|
||||
{
|
||||
return (*((const Cash*)a) > *((const Cash*)b));
|
||||
}
|
||||
static bool gbt_cashge(const void* a, const void* b)
|
||||
{
|
||||
return (*((const Cash*)a) >= *((const Cash*)b));
|
||||
}
|
||||
static bool gbt_casheq(const void* a, const void* b)
|
||||
{
|
||||
return (*((const Cash*)a) == *((const Cash*)b));
|
||||
}
|
||||
static bool gbt_cashle(const void* a, const void* b)
|
||||
{
|
||||
return (*((const Cash*)a) <= *((const Cash*)b));
|
||||
}
|
||||
static bool gbt_cashlt(const void* a, const void* b)
|
||||
{
|
||||
return (*((const Cash*)a) < *((const Cash*)b));
|
||||
}
|
||||
|
||||
static int gbt_cashkey_cmp(const void* a, const void* b)
|
||||
{
|
||||
cashKEY* ia = (cashKEY*)(((const Nsrt*)a)->t);
|
||||
cashKEY* ib = (cashKEY*)(((const Nsrt*)b)->t);
|
||||
|
||||
if (ia->lower == ib->lower) {
|
||||
if (ia->upper == ib->upper)
|
||||
return 0;
|
||||
|
||||
return (ia->upper > ib->upper) ? 1 : -1;
|
||||
}
|
||||
|
||||
return (ia->lower > ib->lower) ? 1 : -1;
|
||||
}
|
||||
|
||||
static float8 gbt_cash_dist(const void* a, const void* b)
|
||||
{
|
||||
return GET_FLOAT_DISTANCE(Cash, a, b);
|
||||
}
|
||||
|
||||
static const gbtree_ninfo tinfo = {gbt_t_cash,
|
||||
sizeof(Cash),
|
||||
gbt_cashgt,
|
||||
gbt_cashge,
|
||||
gbt_casheq,
|
||||
gbt_cashle,
|
||||
gbt_cashlt,
|
||||
gbt_cashkey_cmp,
|
||||
gbt_cash_dist};
|
||||
|
||||
PG_FUNCTION_INFO_V1(cash_dist);
|
||||
extern "C" Datum cash_dist(PG_FUNCTION_ARGS);
|
||||
Datum cash_dist(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Cash a = PG_GETARG_CASH(0);
|
||||
Cash b = PG_GETARG_CASH(1);
|
||||
Cash r;
|
||||
Cash ra;
|
||||
|
||||
r = a - b;
|
||||
ra = Abs(r);
|
||||
|
||||
/* Overflow check. */
|
||||
if (ra < 0 || (!SAMESIGN(a, b) && !SAMESIGN(r, a)))
|
||||
ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("money out of range")));
|
||||
|
||||
PG_RETURN_CASH(ra);
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* Cash ops
|
||||
**************************************************/
|
||||
|
||||
Datum gbt_cash_compress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
GISTENTRY* retval = NULL;
|
||||
|
||||
PG_RETURN_POINTER(gbt_num_compress(retval, entry, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_cash_consistent(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
Cash query = PG_GETARG_CASH(1);
|
||||
StrategyNumber strategy = (StrategyNumber)PG_GETARG_UINT16(2);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
bool* recheck = (bool*)PG_GETARG_POINTER(4);
|
||||
cashKEY* kkk = (cashKEY*)DatumGetPointer(entry->key);
|
||||
GBT_NUMKEY_R key;
|
||||
|
||||
/* All cases served by this function are exact */
|
||||
*recheck = false;
|
||||
|
||||
key.lower = (GBT_NUMKEY*)&kkk->lower;
|
||||
key.upper = (GBT_NUMKEY*)&kkk->upper;
|
||||
|
||||
PG_RETURN_BOOL(gbt_num_consistent(&key, (void*)&query, &strategy, GIST_LEAF(entry), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_cash_distance(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
Cash query = PG_GETARG_CASH(1);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
cashKEY* kkk = (cashKEY*)DatumGetPointer(entry->key);
|
||||
GBT_NUMKEY_R key;
|
||||
|
||||
key.lower = (GBT_NUMKEY*)&kkk->lower;
|
||||
key.upper = (GBT_NUMKEY*)&kkk->upper;
|
||||
|
||||
PG_RETURN_FLOAT8(gbt_num_distance(&key, (void*)&query, GIST_LEAF(entry), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_cash_union(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector* entryvec = (GistEntryVector*)PG_GETARG_POINTER(0);
|
||||
void* out = palloc(sizeof(cashKEY));
|
||||
|
||||
*(int*)PG_GETARG_POINTER(1) = sizeof(cashKEY);
|
||||
PG_RETURN_POINTER(gbt_num_union((GBT_NUMKEY*)out, entryvec, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_cash_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
cashKEY* origentry = (cashKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(0))->key);
|
||||
cashKEY* newentry = (cashKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
|
||||
float* result = (float*)PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
Datum gbt_cash_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(
|
||||
gbt_num_picksplit((GistEntryVector*)PG_GETARG_POINTER(0), (GIST_SPLITVEC*)PG_GETARG_POINTER(1), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_cash_same(PG_FUNCTION_ARGS)
|
||||
{
|
||||
cashKEY* b1 = (cashKEY*)PG_GETARG_POINTER(0);
|
||||
cashKEY* b2 = (cashKEY*)PG_GETARG_POINTER(1);
|
||||
bool* result = (bool*)PG_GETARG_POINTER(2);
|
||||
|
||||
*result = gbt_num_same((GBT_NUMKEY*)b1, (GBT_NUMKEY*)b2, &tinfo);
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
207
contrib/btree_gist/btree_date.cpp
Normal file
207
contrib/btree_gist/btree_date.cpp
Normal file
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* contrib/btree_gist/btree_date.c
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include "btree_gist.h"
|
||||
#include "btree_utils_num.h"
|
||||
#include "utils/date.h"
|
||||
|
||||
typedef struct {
|
||||
DateADT lower;
|
||||
DateADT upper;
|
||||
} dateKEY;
|
||||
|
||||
/*
|
||||
** date ops
|
||||
*/
|
||||
PG_FUNCTION_INFO_V1(gbt_date_compress);
|
||||
PG_FUNCTION_INFO_V1(gbt_date_union);
|
||||
PG_FUNCTION_INFO_V1(gbt_date_picksplit);
|
||||
PG_FUNCTION_INFO_V1(gbt_date_consistent);
|
||||
PG_FUNCTION_INFO_V1(gbt_date_distance);
|
||||
PG_FUNCTION_INFO_V1(gbt_date_penalty);
|
||||
PG_FUNCTION_INFO_V1(gbt_date_same);
|
||||
|
||||
extern "C" Datum gbt_date_compress(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_date_union(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_date_picksplit(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_date_consistent(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_date_distance(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_date_penalty(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_date_same(PG_FUNCTION_ARGS);
|
||||
|
||||
static bool gbt_dategt(const void* a, const void* b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(date_gt, DateADTGetDatum(*((const DateADT*)a)), DateADTGetDatum(*((const DateADT*)b))));
|
||||
}
|
||||
|
||||
static bool gbt_datege(const void* a, const void* b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(date_ge, DateADTGetDatum(*((const DateADT*)a)), DateADTGetDatum(*((const DateADT*)b))));
|
||||
}
|
||||
|
||||
static bool gbt_dateeq(const void* a, const void* b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(date_eq, DateADTGetDatum(*((const DateADT*)a)), DateADTGetDatum(*((const DateADT*)b))));
|
||||
}
|
||||
|
||||
static bool gbt_datele(const void* a, const void* b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(date_le, DateADTGetDatum(*((const DateADT*)a)), DateADTGetDatum(*((const DateADT*)b))));
|
||||
}
|
||||
|
||||
static bool gbt_datelt(const void* a, const void* b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(date_lt, DateADTGetDatum(*((const DateADT*)a)), DateADTGetDatum(*((const DateADT*)b))));
|
||||
}
|
||||
|
||||
static int gbt_datekey_cmp(const void* a, const void* b)
|
||||
{
|
||||
dateKEY* ia = (dateKEY*)(((const Nsrt*)a)->t);
|
||||
dateKEY* ib = (dateKEY*)(((const Nsrt*)b)->t);
|
||||
int res;
|
||||
|
||||
res = DatumGetInt32(DirectFunctionCall2(date_cmp, DateADTGetDatum(ia->lower), DateADTGetDatum(ib->lower)));
|
||||
if (res == 0)
|
||||
return DatumGetInt32(DirectFunctionCall2(date_cmp, DateADTGetDatum(ia->upper), DateADTGetDatum(ib->upper)));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static float8 gdb_date_dist(const void* a, const void* b)
|
||||
{
|
||||
/* we assume the difference can't overflow */
|
||||
Datum diff =
|
||||
DirectFunctionCall2(date_mi, DateADTGetDatum(*((const DateADT*)a)), DateADTGetDatum(*((const DateADT*)b)));
|
||||
|
||||
return (float8)Abs(DatumGetInt32(diff));
|
||||
}
|
||||
|
||||
static const gbtree_ninfo tinfo = {gbt_t_date,
|
||||
sizeof(DateADT),
|
||||
gbt_dategt,
|
||||
gbt_datege,
|
||||
gbt_dateeq,
|
||||
gbt_datele,
|
||||
gbt_datelt,
|
||||
gbt_datekey_cmp,
|
||||
gdb_date_dist};
|
||||
|
||||
PG_FUNCTION_INFO_V1(date_dist);
|
||||
extern "C" Datum date_dist(PG_FUNCTION_ARGS);
|
||||
Datum date_dist(PG_FUNCTION_ARGS)
|
||||
{
|
||||
/* we assume the difference can't overflow */
|
||||
Datum diff = DirectFunctionCall2(date_mi, PG_GETARG_DATUM(0), PG_GETARG_DATUM(1));
|
||||
|
||||
PG_RETURN_INT32(Abs(DatumGetInt32(diff)));
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* date ops
|
||||
**************************************************/
|
||||
|
||||
Datum gbt_date_compress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
GISTENTRY* retval = NULL;
|
||||
|
||||
PG_RETURN_POINTER(gbt_num_compress(retval, entry, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_date_consistent(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
DateADT query = PG_GETARG_DATEADT(1);
|
||||
StrategyNumber strategy = (StrategyNumber)PG_GETARG_UINT16(2);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
bool* recheck = (bool*)PG_GETARG_POINTER(4);
|
||||
dateKEY* kkk = (dateKEY*)DatumGetPointer(entry->key);
|
||||
GBT_NUMKEY_R key;
|
||||
|
||||
/* All cases served by this function are exact */
|
||||
*recheck = false;
|
||||
|
||||
key.lower = (GBT_NUMKEY*)&kkk->lower;
|
||||
key.upper = (GBT_NUMKEY*)&kkk->upper;
|
||||
|
||||
PG_RETURN_BOOL(gbt_num_consistent(&key, (void*)&query, &strategy, GIST_LEAF(entry), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_date_distance(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
DateADT query = PG_GETARG_DATEADT(1);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
dateKEY* kkk = (dateKEY*)DatumGetPointer(entry->key);
|
||||
GBT_NUMKEY_R key;
|
||||
|
||||
key.lower = (GBT_NUMKEY*)&kkk->lower;
|
||||
key.upper = (GBT_NUMKEY*)&kkk->upper;
|
||||
|
||||
PG_RETURN_FLOAT8(gbt_num_distance(&key, (void*)&query, GIST_LEAF(entry), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_date_union(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector* entryvec = (GistEntryVector*)PG_GETARG_POINTER(0);
|
||||
void* out = palloc(sizeof(dateKEY));
|
||||
|
||||
*(int*)PG_GETARG_POINTER(1) = sizeof(dateKEY);
|
||||
PG_RETURN_POINTER(gbt_num_union((GBT_NUMKEY*)out, entryvec, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_date_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
dateKEY* origentry = (dateKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(0))->key);
|
||||
dateKEY* newentry = (dateKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
|
||||
float* result = (float*)PG_GETARG_POINTER(2);
|
||||
int32 diff, res;
|
||||
|
||||
diff = DatumGetInt32(
|
||||
DirectFunctionCall2(date_mi, DateADTGetDatum(newentry->upper), DateADTGetDatum(origentry->upper)));
|
||||
|
||||
res = Max(diff, 0);
|
||||
|
||||
diff = DatumGetInt32(
|
||||
DirectFunctionCall2(date_mi, DateADTGetDatum(origentry->lower), DateADTGetDatum(newentry->lower)));
|
||||
|
||||
res += Max(diff, 0);
|
||||
|
||||
*result = 0.0;
|
||||
|
||||
if (res > 0) {
|
||||
diff = DatumGetInt32(
|
||||
DirectFunctionCall2(date_mi, DateADTGetDatum(origentry->upper), DateADTGetDatum(origentry->lower)));
|
||||
*result += FLT_MIN;
|
||||
*result += (float)(res / ((double)(res + diff)));
|
||||
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
|
||||
}
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
Datum gbt_date_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(
|
||||
gbt_num_picksplit((GistEntryVector*)PG_GETARG_POINTER(0), (GIST_SPLITVEC*)PG_GETARG_POINTER(1), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_date_same(PG_FUNCTION_ARGS)
|
||||
{
|
||||
dateKEY* b1 = (dateKEY*)PG_GETARG_POINTER(0);
|
||||
dateKEY* b2 = (dateKEY*)PG_GETARG_POINTER(1);
|
||||
bool* result = (bool*)PG_GETARG_POINTER(2);
|
||||
|
||||
*result = gbt_num_same((GBT_NUMKEY*)b1, (GBT_NUMKEY*)b2, &tinfo);
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
180
contrib/btree_gist/btree_float4.cpp
Normal file
180
contrib/btree_gist/btree_float4.cpp
Normal file
@ -0,0 +1,180 @@
|
||||
/*
|
||||
* contrib/btree_gist/btree_float4.c
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include "btree_gist.h"
|
||||
#include "btree_utils_num.h"
|
||||
|
||||
typedef struct float4key {
|
||||
float4 lower;
|
||||
float4 upper;
|
||||
} float4KEY;
|
||||
|
||||
/*
|
||||
** float4 ops
|
||||
*/
|
||||
PG_FUNCTION_INFO_V1(gbt_float4_compress);
|
||||
PG_FUNCTION_INFO_V1(gbt_float4_union);
|
||||
PG_FUNCTION_INFO_V1(gbt_float4_picksplit);
|
||||
PG_FUNCTION_INFO_V1(gbt_float4_consistent);
|
||||
PG_FUNCTION_INFO_V1(gbt_float4_distance);
|
||||
PG_FUNCTION_INFO_V1(gbt_float4_penalty);
|
||||
PG_FUNCTION_INFO_V1(gbt_float4_same);
|
||||
|
||||
extern "C" Datum gbt_float4_compress(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float4_union(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float4_picksplit(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float4_consistent(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float4_distance(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float4_penalty(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float4_same(PG_FUNCTION_ARGS);
|
||||
|
||||
static bool gbt_float4gt(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float4*)a) > *((const float4*)b));
|
||||
}
|
||||
static bool gbt_float4ge(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float4*)a) >= *((const float4*)b));
|
||||
}
|
||||
static bool gbt_float4eq(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float4*)a) == *((const float4*)b));
|
||||
}
|
||||
static bool gbt_float4le(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float4*)a) <= *((const float4*)b));
|
||||
}
|
||||
static bool gbt_float4lt(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float4*)a) < *((const float4*)b));
|
||||
}
|
||||
|
||||
static int gbt_float4key_cmp(const void* a, const void* b)
|
||||
{
|
||||
float4KEY* ia = (float4KEY*)(((const Nsrt*)a)->t);
|
||||
float4KEY* ib = (float4KEY*)(((const Nsrt*)b)->t);
|
||||
|
||||
if (ia->lower == ib->lower) {
|
||||
if (ia->upper == ib->upper)
|
||||
return 0;
|
||||
|
||||
return (ia->upper > ib->upper) ? 1 : -1;
|
||||
}
|
||||
|
||||
return (ia->lower > ib->lower) ? 1 : -1;
|
||||
}
|
||||
|
||||
static float8 gbt_float4_dist(const void* a, const void* b)
|
||||
{
|
||||
return GET_FLOAT_DISTANCE(float4, a, b);
|
||||
}
|
||||
|
||||
static const gbtree_ninfo tinfo = {gbt_t_float4,
|
||||
sizeof(float4),
|
||||
gbt_float4gt,
|
||||
gbt_float4ge,
|
||||
gbt_float4eq,
|
||||
gbt_float4le,
|
||||
gbt_float4lt,
|
||||
gbt_float4key_cmp,
|
||||
gbt_float4_dist};
|
||||
|
||||
PG_FUNCTION_INFO_V1(float4_dist);
|
||||
extern "C" Datum float4_dist(PG_FUNCTION_ARGS);
|
||||
Datum float4_dist(PG_FUNCTION_ARGS)
|
||||
{
|
||||
float4 a = PG_GETARG_FLOAT4(0);
|
||||
float4 b = PG_GETARG_FLOAT4(1);
|
||||
float4 r;
|
||||
|
||||
r = a - b;
|
||||
CHECKFLOATVAL(r, isinf(a) || isinf(b), true);
|
||||
|
||||
PG_RETURN_FLOAT4(Abs(r));
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* float4 ops
|
||||
**************************************************/
|
||||
|
||||
Datum gbt_float4_compress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
GISTENTRY* retval = NULL;
|
||||
|
||||
PG_RETURN_POINTER(gbt_num_compress(retval, entry, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float4_consistent(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
float4 query = PG_GETARG_FLOAT4(1);
|
||||
StrategyNumber strategy = (StrategyNumber)PG_GETARG_UINT16(2);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
bool* recheck = (bool*)PG_GETARG_POINTER(4);
|
||||
float4KEY* kkk = (float4KEY*)DatumGetPointer(entry->key);
|
||||
GBT_NUMKEY_R key;
|
||||
|
||||
/* All cases served by this function are exact */
|
||||
*recheck = false;
|
||||
|
||||
key.lower = (GBT_NUMKEY*)&kkk->lower;
|
||||
key.upper = (GBT_NUMKEY*)&kkk->upper;
|
||||
|
||||
PG_RETURN_BOOL(gbt_num_consistent(&key, (void*)&query, &strategy, GIST_LEAF(entry), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float4_distance(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
float4 query = PG_GETARG_FLOAT4(1);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
float4KEY* kkk = (float4KEY*)DatumGetPointer(entry->key);
|
||||
GBT_NUMKEY_R key;
|
||||
|
||||
key.lower = (GBT_NUMKEY*)&kkk->lower;
|
||||
key.upper = (GBT_NUMKEY*)&kkk->upper;
|
||||
|
||||
PG_RETURN_FLOAT8(gbt_num_distance(&key, (void*)&query, GIST_LEAF(entry), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float4_union(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector* entryvec = (GistEntryVector*)PG_GETARG_POINTER(0);
|
||||
void* out = palloc(sizeof(float4KEY));
|
||||
|
||||
*(int*)PG_GETARG_POINTER(1) = sizeof(float4KEY);
|
||||
PG_RETURN_POINTER(gbt_num_union((GBT_NUMKEY*)out, entryvec, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float4_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
float4KEY* origentry = (float4KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(0))->key);
|
||||
float4KEY* newentry = (float4KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
|
||||
float* result = (float*)PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
Datum gbt_float4_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(
|
||||
gbt_num_picksplit((GistEntryVector*)PG_GETARG_POINTER(0), (GIST_SPLITVEC*)PG_GETARG_POINTER(1), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float4_same(PG_FUNCTION_ARGS)
|
||||
{
|
||||
float4KEY* b1 = (float4KEY*)PG_GETARG_POINTER(0);
|
||||
float4KEY* b2 = (float4KEY*)PG_GETARG_POINTER(1);
|
||||
bool* result = (bool*)PG_GETARG_POINTER(2);
|
||||
|
||||
*result = gbt_num_same((GBT_NUMKEY*)b1, (GBT_NUMKEY*)b2, &tinfo);
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
187
contrib/btree_gist/btree_float8.cpp
Normal file
187
contrib/btree_gist/btree_float8.cpp
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* contrib/btree_gist/btree_float8.c
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "knl/knl_variable.h"
|
||||
|
||||
#include "btree_gist.h"
|
||||
#include "btree_utils_num.h"
|
||||
|
||||
typedef struct float8key {
|
||||
float8 lower;
|
||||
float8 upper;
|
||||
} float8KEY;
|
||||
|
||||
/*
|
||||
** float8 ops
|
||||
*/
|
||||
PG_FUNCTION_INFO_V1(gbt_float8_compress);
|
||||
PG_FUNCTION_INFO_V1(gbt_float8_union);
|
||||
PG_FUNCTION_INFO_V1(gbt_float8_picksplit);
|
||||
PG_FUNCTION_INFO_V1(gbt_float8_consistent);
|
||||
PG_FUNCTION_INFO_V1(gbt_float8_distance);
|
||||
PG_FUNCTION_INFO_V1(gbt_float8_penalty);
|
||||
PG_FUNCTION_INFO_V1(gbt_float8_same);
|
||||
|
||||
extern "C" Datum gbt_float8_compress(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float8_union(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float8_picksplit(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float8_consistent(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float8_distance(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float8_penalty(PG_FUNCTION_ARGS);
|
||||
extern "C" Datum gbt_float8_same(PG_FUNCTION_ARGS);
|
||||
|
||||
static bool gbt_float8gt(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float8*)a) > *((const float8*)b));
|
||||
}
|
||||
static bool gbt_float8ge(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float8*)a) >= *((const float8*)b));
|
||||
}
|
||||
static bool gbt_float8eq(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float8*)a) == *((const float8*)b));
|
||||
}
|
||||
static bool gbt_float8le(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float8*)a) <= *((const float8*)b));
|
||||
}
|
||||
static bool gbt_float8lt(const void* a, const void* b)
|
||||
{
|
||||
return (*((const float8*)a) < *((const float8*)b));
|
||||
}
|
||||
|
||||
static int gbt_float8key_cmp(const void* a, const void* b)
|
||||
{
|
||||
float8KEY* ia = (float8KEY*)(((const Nsrt*)a)->t);
|
||||
float8KEY* ib = (float8KEY*)(((const Nsrt*)b)->t);
|
||||
|
||||
if (ia->lower == ib->lower) {
|
||||
if (ia->upper == ib->upper)
|
||||
return 0;
|
||||
|
||||
return (ia->upper > ib->upper) ? 1 : -1;
|
||||
}
|
||||
|
||||
return (ia->lower > ib->lower) ? 1 : -1;
|
||||
}
|
||||
|
||||
static float8 gbt_float8_dist(const void* a, const void* b)
|
||||
{
|
||||
float8 arg1 = *(const float8*)a;
|
||||
float8 arg2 = *(const float8*)b;
|
||||
float8 r;
|
||||
|
||||
r = arg1 - arg2;
|
||||
CHECKFLOATVAL(r, isinf(arg1) || isinf(arg2), true);
|
||||
|
||||
return Abs(r);
|
||||
}
|
||||
|
||||
static const gbtree_ninfo tinfo = {gbt_t_float8,
|
||||
sizeof(float8),
|
||||
gbt_float8gt,
|
||||
gbt_float8ge,
|
||||
gbt_float8eq,
|
||||
gbt_float8le,
|
||||
gbt_float8lt,
|
||||
gbt_float8key_cmp,
|
||||
gbt_float8_dist};
|
||||
|
||||
PG_FUNCTION_INFO_V1(float8_dist);
|
||||
extern "C" Datum float8_dist(PG_FUNCTION_ARGS);
|
||||
Datum float8_dist(PG_FUNCTION_ARGS)
|
||||
{
|
||||
float8 a = PG_GETARG_FLOAT8(0);
|
||||
float8 b = PG_GETARG_FLOAT8(1);
|
||||
float8 r;
|
||||
|
||||
r = a - b;
|
||||
CHECKFLOATVAL(r, isinf(a) || isinf(b), true);
|
||||
|
||||
PG_RETURN_FLOAT8(Abs(r));
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* float8 ops
|
||||
**************************************************/
|
||||
|
||||
Datum gbt_float8_compress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
GISTENTRY* retval = NULL;
|
||||
|
||||
PG_RETURN_POINTER(gbt_num_compress(retval, entry, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float8_consistent(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
float8 query = PG_GETARG_FLOAT8(1);
|
||||
StrategyNumber strategy = (StrategyNumber)PG_GETARG_UINT16(2);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
bool* recheck = (bool*)PG_GETARG_POINTER(4);
|
||||
float8KEY* kkk = (float8KEY*)DatumGetPointer(entry->key);
|
||||
GBT_NUMKEY_R key;
|
||||
|
||||
/* All cases served by this function are exact */
|
||||
*recheck = false;
|
||||
|
||||
key.lower = (GBT_NUMKEY*)&kkk->lower;
|
||||
key.upper = (GBT_NUMKEY*)&kkk->upper;
|
||||
|
||||
PG_RETURN_BOOL(gbt_num_consistent(&key, (void*)&query, &strategy, GIST_LEAF(entry), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float8_distance(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY* entry = (GISTENTRY*)PG_GETARG_POINTER(0);
|
||||
float8 query = PG_GETARG_FLOAT8(1);
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
float8KEY* kkk = (float8KEY*)DatumGetPointer(entry->key);
|
||||
GBT_NUMKEY_R key;
|
||||
|
||||
key.lower = (GBT_NUMKEY*)&kkk->lower;
|
||||
key.upper = (GBT_NUMKEY*)&kkk->upper;
|
||||
|
||||
PG_RETURN_FLOAT8(gbt_num_distance(&key, (void*)&query, GIST_LEAF(entry), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float8_union(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector* entryvec = (GistEntryVector*)PG_GETARG_POINTER(0);
|
||||
void* out = palloc(sizeof(float8KEY));
|
||||
|
||||
*(int*)PG_GETARG_POINTER(1) = sizeof(float8KEY);
|
||||
PG_RETURN_POINTER(gbt_num_union((GBT_NUMKEY*)out, entryvec, &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float8_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
float8KEY* origentry = (float8KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(0))->key);
|
||||
float8KEY* newentry = (float8KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
|
||||
float* result = (float*)PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
Datum gbt_float8_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(
|
||||
gbt_num_picksplit((GistEntryVector*)PG_GETARG_POINTER(0), (GIST_SPLITVEC*)PG_GETARG_POINTER(1), &tinfo));
|
||||
}
|
||||
|
||||
Datum gbt_float8_same(PG_FUNCTION_ARGS)
|
||||
{
|
||||
float8KEY* b1 = (float8KEY*)PG_GETARG_POINTER(0);
|
||||
float8KEY* b2 = (float8KEY*)PG_GETARG_POINTER(1);
|
||||
bool* result = (bool*)PG_GETARG_POINTER(2);
|
||||
|
||||
*result = gbt_num_same((GBT_NUMKEY*)b1, (GBT_NUMKEY*)b2, &tinfo);
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user