diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..5032ddd --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,2 @@ +# These members will be default reviewers for each repo +* @IgorTodorovskiIBM @MikeFultonDev @DevonianTeuchter @HarithaIBM @v1gnesh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f133ac6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,74 @@ +# Contributing + +## Issues + +Log an issue for any question or problem you might have. When in doubt, log an issue, and +any additional policies about what to include will be provided in the responses. The only +exception is security disclosures which should be sent privately. + +Committers may direct you to another repository, ask for additional clarifications, and +add appropriate metadata before the issue is addressed. + +## Contributions + +Any change to resources in this repository must be through pull requests. This applies to all changes +to documentation, code, binary files, etc. + +No pull request can be merged without being reviewed and approved. + +## Validate your changes + +Verify that the project is working by running `zopen build`. + +## Coding Guidelines + +When contributing your changes, please follow the following coding guidelines: +* patches: patches should adhere to the coding guidelines from the original project repository. Make sure to add the original project's LICENSE file within the patches +directory. +* zopen framework files: (e.g. buildenv) - It is recommended that you follow the [Google Shell Style Guide](https://google.github.io/styleguide/shellguide.html) + +If you are generating a new project, we recommend that you use `zopen generate` to create the correct zopen file and directory structure. + +### Commit message + +A good commit message should describe what changed and why. + +It should: + * contain a short description of the change + * be entirely in lowercase with the exception of proper nouns, acronyms, and the words that refer to code, like function/variable names + * be prefixed with one of the following words: + * fix: bug fix + * hotfix: urgent bug fix + * feat: new or updated feature + * docs: documentation updates + * refactor: code refactoring (no functional change) + * perf: performance improvement + * test: tests and CI updates + +### Developer's Certificate of Origin 1.1 + +
+By making a contribution to this project, I certify that:
+
+ (a) The contribution was created in whole or in part by me and I
+     have the right to submit it under the open source license
+     indicated in the file; or
+
+ (b) The contribution is based upon previous work that, to the best
+     of my knowledge, is covered under an appropriate open source
+     license and I have the right under that license to submit that
+     work with modifications, whether created in whole or in part
+     by me, under the same open source license (unless I am
+     permitted to submit under a different license), as indicated
+     in the file; or
+
+ (c) The contribution was provided directly to me by some other
+     person who certified (a), (b) or (c) and I have not modified
+     it.
+
+ (d) I understand and agree that this project and the contribution
+     are public and that a record of the contribution (including all
+     personal information I submit with it, including my sign-off) is
+     maintained indefinitely and may be redistributed consistent with
+     this project or the open source license(s) involved.
+
diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 4e81fa0..d158e25 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,49 @@ # postgresport PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions + +## Invoking the postgresql database +With the current implementation we can invoke the postgresql database in the following way, execute the commands from the --prefix path +1. Initializing the database cluster + `$ bin/initdb -D mydb` +2. Change the `io_method` parameter(in file mydb/postgresql.conf) to `sync` from `worker` +3. Execute the postgres command in single user mode + `$ bin/postgres --single -D tempdb postgres` +4. This is prompt us a interactive terminal to execute SQL commands +``` +backend> CREATE TABLE test_table (id INT, name TEXT); +backend> +backend> INSERT INTO test_table VALUES (1, 'Alice'), (2, 'Bob'); +backend> SELECT * FROM test_table + 1: id (typeid = 23, len = 4, typmod = -1, byval = t) + 2: name (typeid = 25, len = -1, typmod = -1, byval = f) + ---- + 1: id = "1" (typeid = 23, len = 4, typmod = -1, byval = t) + 2: name = "Alice" (typeid = 25, len = -1, typmod = -1, byval = f) + ---- + 1: id = "2" (typeid = 23, len = 4, typmod = -1, byval = t) + 2: name = "Bob" (typeid = 25, len = -1, typmod = -1, byval = f) + ---- +backend> SELECT current_database(); + 1: current_database (typeid = 19, len = 64, typmod = -1, byval = f) + ---- + 1: current_database = "template1" (typeid = 19, len = 64, typmod = -1, byval = f) + ---- +backend> SELECT version(); + 1: version (typeid = 25, len = -1, typmod = -1, byval = f) + ---- + 1: version = "PostgreSQL 18beta1 on i370-ibm-openedition, compiled by C/C++ for Open Enterprise Languages on z/OS 2.0.0, clang version 14.0.0 (build 985f418), 64-bit" (typeid = 25, len = -1, typmod = -1, byval = f) + ---- +backend> SELECT pg_backend_pid(); + 1: pg_backend_pid (typeid = 23, len = 4, typmod = -1, byval = t) + ---- + 1: pg_backend_pid = "2160" (typeid = 23, len = 4, typmod = -1, byval = t) + ---- +backend> SHOW work_mem; + 1: work_mem (typeid = 25, len = -1, typmod = -1, byval = f) + ---- + 1: work_mem = "4MB" (typeid = 25, len = -1, typmod = -1, byval = f) + ---- +backend> SELECT * FROM non_existent_table; + 2025-07-23 09:30:04.641 EDT [2160] ERROR: relation "non_existent_table" does not exist at character 15 + 2025-07-23 09:30:04.641 EDT [2160] STATEMENT: SELECT * FROM non_existent_table; +``` diff --git a/buildenv b/buildenv new file mode 100644 index 0000000..d57916e --- /dev/null +++ b/buildenv @@ -0,0 +1,184 @@ +# Update bump details accordingly. Use bump check to confirm. +# bump: postgres-version /POSTGRES_VERSION="(.*)"/ https://github.com/postgres/postgres.git|semver:* +# POSTGRES_VERSION="V.R.M" # Specify a stable release +export ZOPEN_STABLE_TAG="REL_18_BETA2" +export ZOPEN_DEV_TAG="REL_18_BETA1" + +### +### Build control file for the postgres port +### + +### +### Required Environment Variables +### + +## Specify the default build line, either 'DEV' or 'STABLE' (default: STABLE) +export ZOPEN_BUILD_LINE="DEV" + +## Required IF ZOPEN_BUILD_LINE='STABLE' +export ZOPEN_STABLE_URL="" # Specify the stable build URL (either git or tarball) +export ZOPEN_STABLE_DEPS="curl git make m4 perl autoconf automake help2man texinfo xz zlib openssl expat gettext gzip tar coreutils zoslib diffutils ncurses bash sed libpcre2 tar check_python gawk" # Specify the stable build dependencies. + +## Required IF ZOPEN_BUILD_LINE='DEV' +export ZOPEN_DEV_URL="https://github.com/postgres/postgres.git" # Specify the dev build URL +export ZOPEN_DEV_DEPS="curl git make m4 perl autoconf automake help2man texinfo xz zlib openssl expat gettext gzip tar coreutils zoslib diffutils ncurses bash sed libpcre2 tar check_python gawk pkgconfig bison flex" # Specify the dev build dependencies + +## Specify a space-delimited list of applicable categories. +## See tool_categories.txt for valid options +export ZOPEN_CATEGORIES="database" + +## Runtime zopen tool dependencies to be installed alongside the tool. +export ZOPEN_RUNTIME_DEPS="zlib libxml2 libxslt lz4 systemd tcl python perl" + +## Runtime system prerequisites; supply the name of the system pre-requisties. +## Current available prerequisites: zos24 zos25 zos31 procfs (see https://github.com/zopencommunity/meta/blob/main/include/prereq.sh for a current list) +export ZOPEN_SYSTEM_PREREQ="" + + +### +### Build stage control environment variables +### + +#export ZOPEN_BOOTSTRAP="skip" ## Bootstrap program to run (defaults to './bootstrap') +#export ZOPEN_CHECK="skip" ## Check program to run (defaults to 'make') +#export ZOPEN_CONFIGURE="skip" ## Configuration program to run (defaults to './configure') +#export ZOPEN_INSTALL="skip" ## Installation program to run (defaults to 'make') +#export ZOPEN_MAKE="skip" ## Build program to run (defaults to 'make') +#export ZOPEN_CLEAN="" ## Clean up program to run (defaults to 'make') + + +### +### Required user-supplied functions +### + +zopen_check_results() +{ + dir="$1" + pfx="$2" + chk="$1/$2_check.log" + + # Echo the following information to gauge build health + echo "actualFailures:0" + echo "totalTests:1" + echo "expectedFailures:0" + echo "expectedTotalTests:1" +} + +zopen_get_version() +{ + # Modify to echo the version of your tool/library + # Rather than hardcoding the version, obtain the version by running the tool/library + echo "1.0.0" +} + + +### +### Optional user-supplied functions for zopen-build +### + +#zopen_append_to_env() { + ## This function runs as part of generation of the .env file. The output of the + ## function is appended to .env. +#} + +#zopen_append_to_setup(){ + ## This function runs as part of generation of the setup.sh file. The output of + ## the function is appended to setup.sh. +#} + +#zopen_append_to_validate_install(){ + ## This function runs as part of generation of the install_test.sh file. The + ## output of the function is appended to install_test.sh script. +#} + +#zopen_install_caveats(){ + ## This function is run post install. All stdout messages are captured and + ## added to the metadata.json as installation caveats. +#} + +#zopen_append_to_zoslib_env(){ + ## This function runs as part of generation of the C function zoslib_env_hook, + ## which can be used to set environment variables before main is run. +#} + +#zopen_init(){ + ## This function runs after code is downloaded and patched but before the code + ## is built. +#} + +#zopen_post_buildenv(){ + ## This function runs after the 'buildenv' is processed. +#} + +#zopen_pre_build(){ + ## This function runs before the 'make' step of the build is run. +#} + +#zopen_pre_check(){ + ## This function runs before the 'check' step of the build is run. +#} + +#zopen_pre_configure(){ + ## This function runs before the 'configure' step of the build is run. +#} + +#zopen_pre_install(){ + ## This function runs before the 'install' step of the build is run. +#} + +#zopen_post_install(){ + ## This function runs after the 'install' step of the build is run. +#} + +#zopen_pre_patch(){ + ## This function runs before the 'patch' step of the build is run. +#} + +#zopen_pre_terminate(){ + ## This function runs before 'zopen build' terminates. +#} + + +### +### Optional build control variables +### + +export ZOPEN_EXTRA_CFLAGS="-mzos-target=zosv3r1 -DO_CLOEXEC=0 -UZOSLIB_USE_CLIB_LOCALE -D_OPEN_SYS_IF_EXT -fvisibility=default -O0 -g" ## C compiler flags to append to CFLAGS (defaults to ''). +export ZOPEN_EXTRA_CPPFLAGS="-ferror-limit=1000 -fPIC -m64" ## C,C++ pre-processor flags to append to CPPFLAGS (defaults to '') +export ZOPEN_EXTRA_CXXFLAGS="-fPIC -m64" ## C++ compiler flags to append to CXXFLAGS (defaults to '') +#export ZOPEN_EXTRA_LDFLAGS="" ## C,C++ linker flags to append to LDFLAGS (defaults to '') +#export ZOPEN_EXTRA_LIBS="" ## C,C++ libraries to append to LIBS (defaults to '') +#export ZOPEN_BOOTSTRAP_OPTS="" ## Options to pass to bootstrap program (defaults to '') +#export ZOPEN_CHECK_MINIMAL="" ## Check program will not be passed CFLAGS, LDFLAGS, CPPFLAGS options but will get them from env vars. +#export ZOPEN_CHECK_OPTS="" ## Options to pass to check program (defaults to 'check') +#export ZOPEN_CHECK_TIMEOUT="" ## Timeout limit in seconds for the check program (defaults to '12600' # 3.5 hours) +#export ZOPEN_CLEAN_OPTS="" ## Options to pass to clean up program (defaults to 'clean') +#export ZOPEN_CONFIGURE_MINIMAL="" ## Configuration program will not be passed CFLAGS, LDFLAGS, CPPFLAGS options but will get them from env vars. +export ZOPEN_CONFIGURE_OPTS="--prefix=/home/sravani/postgresbin --without-icu --without-readline --disable-rpath --enable-debug" ## Options to pass to configuration program (defaults to '--prefix=') +export ZOPEN_EXTRA_CONFIGURE_OPTS="--with-template=linux" ## Extra configure options to pass to configuration program. (defaults to '') +#export ZOPEN_INSTALL_OPTS="" ## Options to pass to installation program (defaults to 'install') +#export ZOPEN_MAKE_MINIMAL="" ## Build program will not be passed CFLAGS, LDFLAGS, CPPFLAGS options but will get them from env vars. +#export ZOPEN_MAKE_OPTS="" ## Options to pass to build program (defaults to '-j') +#export ZOPEN_PATCH_DIR="" ## Specify directory from which patches should be applied. + + +### +### Restricted Usage - only set in ports if necessary +### + +## Don't add zoslib as a dependency; most ports should keep this unset +#export ZOPEN_DONT_ADD_ZOSLIB_DEP=1 + + +### +### Additional user-defined custom code - runs during script source +### + +## Add user-defined functions and code +zopen_pre_patch() +{ +# if [ "${ZOPEN_BUILD_LINE}x" = "DEVx" ]; then + export CFLAGS="${CFLAGS} -UZOSLIB_USE_CLIB_LOCALE" + export CPPFLAGS="${CPPFLAGS} -UZOSLIB_USE_CLIB_LOCALE" +# fi +} diff --git a/cicd-dev.groovy b/cicd-dev.groovy new file mode 100644 index 0000000..aaa3d3f --- /dev/null +++ b/cicd-dev.groovy @@ -0,0 +1,14 @@ +node('linux') +{ + stage ('Poll') { + checkout([ + $class: 'GitSCM', + branches: [[name: '*/main']], + doGenerateSubmoduleConfigurations: false, + extensions: [], + userRemoteConfigs: [[url: 'https://github.com/zopencommunity/postgresport.git']]]) + } + stage('Build') { + build job: 'Port-Pipeline', parameters: [string(name: 'PORT_GITHUB_REPO', value: 'https://github.com/zopencommunity/postgresport.git'), string(name: 'PORT_DESCRIPTION', value: 'advanced rdbms' ), string(name: 'BUILD_LINE', value: 'DEV') ] + } +} diff --git a/cicd-stable.groovy b/cicd-stable.groovy new file mode 100644 index 0000000..3b8046a --- /dev/null +++ b/cicd-stable.groovy @@ -0,0 +1,14 @@ +node('linux') +{ + stage ('Poll') { + checkout([ + $class: 'GitSCM', + branches: [[name: '*/main']], + doGenerateSubmoduleConfigurations: false, + extensions: [], + userRemoteConfigs: [[url: 'https://github.com/zopencommunity/postgresport.git']]]) + } + stage('Build') { + build job: 'Port-Pipeline', parameters: [string(name: 'PORT_GITHUB_REPO', value: 'https://github.com/zopencommunity/postgresport.git'), string(name: 'PORT_DESCRIPTION', value: 'advanced rdbms' ), string(name: 'BUILD_LINE', value: 'STABLE') ] + } +} diff --git a/patches/LICENSE b/patches/LICENSE new file mode 100644 index 0000000..670baeb --- /dev/null +++ b/patches/LICENSE @@ -0,0 +1,2 @@ +"The Unlicense" +View license contents at "https://api.github.com/licenses/unlicense" diff --git a/patches/Makefile_common_patch.patch b/patches/Makefile_common_patch.patch new file mode 100644 index 0000000..79f938b --- /dev/null +++ b/patches/Makefile_common_patch.patch @@ -0,0 +1,13 @@ +diff --git a/src/backend/access/common/Makefile b/src/backend/access/common/Makefile +index e78de312659..637fd251859 100644 +--- a/src/backend/access/common/Makefile ++++ b/src/backend/access/common/Makefile +@@ -29,6 +29,7 @@ OBJS = \ + toast_compression.o \ + toast_internals.o \ + tupconvert.o \ +- tupdesc.o ++ tupdesc.o \ ++ file.o + + include $(top_srcdir)/src/backend/common.mk diff --git a/patches/Makefile_global_in_patch.patch b/patches/Makefile_global_in_patch.patch new file mode 100644 index 0000000..d6342db --- /dev/null +++ b/patches/Makefile_global_in_patch.patch @@ -0,0 +1,14 @@ +diff --git a/src/Makefile.global.in b/src/Makefile.global.in +index 04952b533de..15a77f6c0ad 100644 +--- a/src/Makefile.global.in ++++ b/src/Makefile.global.in +@@ -789,7 +789,8 @@ LIBOBJS = @LIBOBJS@ + # files needed for the chosen CRC-32C implementation + PG_CRC32C_OBJS = @PG_CRC32C_OBJS@ + +-LIBS := -lpgcommon -lpgport $(LIBS) ++#LIBS := -lpgcommon -lpgport $(LIBS) ++LIBS := -L$(top_builddir)/src/common -lpgcommon -L$(top_builddir)/src/common -lpgcommon_shlib -L$(top_builddir)/src/common -lpgcommon_srv -L$(top_builddir)/src/port -lpgport -L$(top_builddir)/src/port -lpgport_shlib -L$(top_builddir)/src/port -lpgport_srv -lzoslib -lzoslib-supp -lz + + # to make ws2_32.lib the last library + ifeq ($(PORTNAME),win32) diff --git a/patches/Makefile_shlib_patch.patch b/patches/Makefile_shlib_patch.patch new file mode 100755 index 0000000..a20a031 --- /dev/null +++ b/patches/Makefile_shlib_patch.patch @@ -0,0 +1,53 @@ +diff --git a/src/Makefile.shlib b/src/Makefile.shlib +index fa81f6f..e58220e 100644 +--- a/src/Makefile.shlib ++++ b/src/Makefile.shlib +@@ -183,6 +183,13 @@ ifeq ($(PORTNAME), linux) + endif + endif + ++ifeq ($(PORTNAME), zos) ++ LINK.shared = $(COMPILER) ++ ifdef SHLIB_EXPORTS ++ exports_file = $(SHLIB_EXPORTS:%.txt=%.x) ++ endif ++endif ++ + ifeq ($(PORTNAME), solaris) + LINK.shared = $(COMPILER) -shared + ifdef soname +@@ -256,9 +263,32 @@ endif #haslibarule + + ifeq (,$(filter cygwin win32,$(PORTNAME))) + ++ifeq ($(PORTNAME), zos) ++# get all the objfiles.txt in $(top_srcdir)/src/ ++OBJFILES_TXT=$(shell find $(top_srcdir)/src/ -name objfiles.txt) ++ ++# remove any newlines or tabs in the objfiles.txt files ++FORMATED_OBJFILES_TXT=$(strip \ ++ $(foreach file,$(OBJFILES_TXT), \ ++ $(shell tr ' \t\r\n' '\n\n\n\n' < $(file) | awk 'NF') \ ++ ) \ ++) ++ ++# combile all the object files names ++ALL_OBJFILES_TXT=$(foreach obj,$(OBJS_NEW),$(top_builddir)/$(obj)) ++ ++# this target will create a file allobjfiles.txt in teh $(top_srcdir) ++# which contains all the object files from all the subdirectories in ++# $(top_srcdir)/src/ ++allobjfiles.txt: ++ @if [ ! -f allobjfiles.txt ]; then \ ++ echo $(ALL_OBJFILES_TXT) > $(top_srcdir)/allobjfiles.txt; \ ++ fi ++endif ++ + # Normal case +-$(shlib): $(OBJS) | $(SHLIB_PREREQS) +- $(LINK.shared) -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) ++$(shlib): $(OBJS) | $(SHLIB_PREREQS) allobjfiles.txt ++ $(LINK.shared) -o $@ $(OBJS) @$(top_srcdir)/allobjfiles.txt $(LIBS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(SHLIB_LINK_INTERNAL) -Wl,-bMSGLEVEL=8 + ifdef shlib_major + # If we're using major and minor versions, then make a symlink to major-version-only. + ifneq ($(shlib), $(shlib_major)) diff --git a/patches/Makefile_zos_patch.patch b/patches/Makefile_zos_patch.patch new file mode 100755 index 0000000..ec71561 --- /dev/null +++ b/patches/Makefile_zos_patch.patch @@ -0,0 +1,27 @@ +diff --git a/src/makefiles/Makefile.zos b/src/makefiles/Makefile.zos +new file mode 100755 +index 00000000000..269314232d6 +--- /dev/null ++++ b/src/makefiles/Makefile.zos +@@ -0,0 +1,17 @@ ++# Use --enable-new-dtags to generate DT_RUNPATH instead of DT_RPATH. ++# This allows LD_LIBRARY_PATH to still work when needed. ++rpath = -Wl,-rpath,'$(rpathdir)',--enable-new-dtags ++ ++OBJFILES_TXT=$(shell find $(top_builddir)/src/ -name objfiles.txt) ++OBJS_NEW=$(strip \ ++ $(foreach file,$(OBJFILES_TXT), \ ++ $(shell tr ' \t\r\n' '\n\n\n\n' < $(file) | awk 'NF') \ ++ ) \ ++) ++OBJS_NEW_1=$(foreach obj,$(OBJS_NEW),$(top_builddir)/$(obj)) ++allobjfiles.txt: ++ @if [ ! -f allobjfiles.txt ]; then \ ++ echo $(OBJS_NEW_1) > $(top_srcdir)/allobjfiles.txt; \ ++ fi ++ # OBJS+=$(OBJS_NEW_1) ++# ++# Rule for building a shared library from a single .o file ++%.so: %.o ++ $(CC) $(CFLAGS) $(OBJS) @$(top_srcdir)/allobjfiles.txt $< $(LDFLAGS) $(LIBS) $(LDFLAGS_SL) -shared -o $@ -Wl,-bMSGLEVEL=8 ++ diff --git a/patches/chklocale_patch.patch b/patches/chklocale_patch.patch new file mode 100644 index 0000000..d80bf57 --- /dev/null +++ b/patches/chklocale_patch.patch @@ -0,0 +1,17 @@ +diff --git a/src/port/chklocale.c b/src/port/chklocale.c +index 034939f7fd2..6e36b2ae16a 100644 +--- a/src/port/chklocale.c ++++ b/src/port/chklocale.c +@@ -322,8 +322,11 @@ pg_get_encoding_from_locale(const char *ctype, bool write_message) + loc = newlocale(LC_CTYPE_MASK, ctype, (locale_t) 0); + if (loc == (locale_t) 0) + return -1; /* bogus ctype passed in? */ +- ++#ifndef __MVS__ + sys = nl_langinfo_l(CODESET, loc); ++#else ++ sys = nl_langinfo(CODESET); ++#endif + if (sys) + sys = strdup(sys); + diff --git a/patches/configure_patch.patch b/patches/configure_patch.patch new file mode 100644 index 0000000..685e50d --- /dev/null +++ b/patches/configure_patch.patch @@ -0,0 +1,12 @@ +diff --git a/configure b/configure +index 6d7c22e153f..e1c9925036e 100755 +--- a/configure ++++ b/configure +@@ -3028,6 +3028,7 @@ dragonfly*) template=netbsd ;; + freebsd*) template=freebsd ;; + linux*|gnu*|k*bsd*-gnu) + template=linux ;; ++ openedition*) template=zos ;; + mingw*) template=win32 ;; + netbsd*) template=netbsd ;; + openbsd*) template=openbsd ;; diff --git a/patches/date_c_patch.patch b/patches/date_c_patch.patch new file mode 100644 index 0000000..40397df --- /dev/null +++ b/patches/date_c_patch.patch @@ -0,0 +1,15 @@ +diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c +index 4227ab1..0ed9e01 100644 +--- a/src/backend/utils/adt/date.c ++++ b/src/backend/utils/adt/date.c +@@ -37,6 +37,10 @@ + #include "utils/skipsupport.h" + #include "utils/sortsupport.h" + ++#ifdef __MVS__ ++#define tzname _tzname ++#endif ++ + /* + * gcc's -ffast-math switch breaks routines that expect exact results from + * expressions like timeval / SECS_PER_HOUR, where timeval is double. diff --git a/patches/dsm_impl_c_patch.patch b/patches/dsm_impl_c_patch.patch new file mode 100644 index 0000000..c47736a --- /dev/null +++ b/patches/dsm_impl_c_patch.patch @@ -0,0 +1,44 @@ +diff --git a/src/backend/storage/ipc/dsm_impl.c b/src/backend/storage/ipc/dsm_impl.c +index 6bf8ab5bb5b..88d2f0e9783 100644 +--- a/src/backend/storage/ipc/dsm_impl.c ++++ b/src/backend/storage/ipc/dsm_impl.c +@@ -254,7 +254,7 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size, + * ReserveExternalFD rather than AcquireExternalFD, though. + */ + ReserveExternalFD(); +- ++#if defined(HAVE_SHM_OPEN) && !defined(__MVS__) + flags = O_RDWR | (op == DSM_OP_CREATE ? O_CREAT | O_EXCL : 0); + if ((fd = shm_open(name, flags, PG_FILE_MODE_OWNER)) == -1) + { +@@ -266,7 +266,29 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size, + name))); + return false; + } +- ++#endif ++#if defined(__MVS__) ++ /* On z/OS, test for System V shared memory availability */ ++ int shmid; ++ void *addr; ++ shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT | IPC_EXCL | 0600); ++ if (shmid != -1) ++ { ++ addr = shmat(shmid, NULL, 0); ++ if (addr != (void *) -1) ++ { ++ shmdt(addr); ++ shmctl(shmid, IPC_RMID, NULL); ++ // return "sysv"; ++ return false; ++ } ++ else ++ { ++ shmctl(shmid, IPC_RMID, NULL); ++ return true; ++ } ++ } ++#endif + /* + * If we're attaching the segment, determine the current size; if we are + * creating the segment, set the size to the requested value. diff --git a/patches/fd_c_patch.patch b/patches/fd_c_patch.patch new file mode 100644 index 0000000..d9baea3 --- /dev/null +++ b/patches/fd_c_patch.patch @@ -0,0 +1,16 @@ +diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c +index 0e8299d..02e62a6 100644 +--- a/src/backend/storage/file/fd.c ++++ b/src/backend/storage/file/fd.c +@@ -485,7 +485,11 @@ pg_fdatasync(int fd) + return 0; + + retry: ++#ifndef __MVS__ + rc = fdatasync(fd); ++#else ++ rc = fsync(fd); ++#endif + + if (rc == -1 && errno == EINTR) + goto retry; diff --git a/patches/file_c_patch.patch b/patches/file_c_patch.patch new file mode 100644 index 0000000..36d4ff8 --- /dev/null +++ b/patches/file_c_patch.patch @@ -0,0 +1,76 @@ +diff --git a/src/backend/access/common/file.c b/src/backend/access/common/file.c +new file mode 100755 +index 00000000000..1d7eb32716e +--- /dev/null ++++ b/src/backend/access/common/file.c +@@ -0,0 +1,70 @@ ++#undef ZOSLIB_USE_CLIB_LOCALE ++#include ++#include ++#include ++#include ++int isalnum_l(int c, locale_t locale) { return isalnum(c); } ++int isalpha_l(int c, locale_t locale) { return isalpha(c); } ++int isdigit_l(int c, locale_t locale) { return isdigit(c); } ++int isgraph_l(int c, locale_t locale) { return isgraph(c); } ++int islower_l(int c, locale_t locale) { return islower(c); } ++int isprint_l(int c, locale_t locale) { return isprint(c); } ++ ++int ispunct_l(int c, locale_t locale) { return ispunct(c); } ++int isspace_l(int c, locale_t locale) { return isspace(c); } ++int isupper_l(int c, locale_t locale) { return isupper(c); } ++ ++int iswalnum_l(wchar_t wc, locale_t locale) { ++ return iswalnum(wc); ++} ++int iswalpha_l(wchar_t wc, locale_t locale) { ++ return iswalpha(wc); ++} ++int iswblank_l(wchar_t wc, locale_t locale) { ++ return iswblank(wc); ++} ++int iswlower_l(wchar_t wc, locale_t locale) { ++ return iswlower(wc); ++} ++int iswgraph_l(wchar_t wc, locale_t locale) { ++ return iswgraph(wc); ++} ++int iswprint_l(wchar_t wc, locale_t locale) { ++ return iswprint(wc); ++} ++int iswpunct_l(wchar_t wc, locale_t locale) { ++ return iswpunct(wc); ++} ++int iswspace_l(wchar_t wc, locale_t locale) { ++ return iswspace(wc); ++} ++ ++int iswupper_l(wchar_t wc, locale_t locale) { ++ return iswupper(wc); ++} ++ ++int iswdigit_l(wchar_t wc, locale_t locale) { ++ return iswdigit(wc); ++} ++ ++int toupper_l(int c, locale_t locale) { return toupper(c); } ++int tolower_l(int c, locale_t locale) { return tolower(c); } ++ ++wint_t towupper_l(wint_t wc, locale_t locale) { ++ return towupper(wc); ++} ++wint_t towlower_l(wint_t wc, locale_t locale) { ++ return towlower(wc); ++} ++int strcoll_l(const char *__s1, const char *__s2, ++ locale_t locale) { ++ return strcoll(__s1, __s2); ++} ++size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, ++ locale_t locale) { ++ return strxfrm(__s1, __s2, __n); ++} ++size_t strftime_l(char *dst, size_t dstlen, const char *format, const struct tm *tm, ++ locale_t locale) { ++ return strftime(dst, dstlen, format, tm); ++} diff --git a/patches/findtimezone_patch.patch b/patches/findtimezone_patch.patch new file mode 100644 index 0000000..d586398 --- /dev/null +++ b/patches/findtimezone_patch.patch @@ -0,0 +1,15 @@ +diff --git a/src/bin/initdb/findtimezone.c b/src/bin/initdb/findtimezone.c +index 2b2ae39..5910356 100644 +--- a/src/bin/initdb/findtimezone.c ++++ b/src/bin/initdb/findtimezone.c +@@ -19,6 +19,10 @@ + + #include "pgtz.h" + ++#ifdef __MVS__ ++#define tzname _tzname ++#endif ++ + /* Ideally this would be in a .h file, but it hardly seems worth the trouble */ + extern const char *select_default_timezone(const char *share_path); + diff --git a/patches/initdb_Makefile_patch.patch b/patches/initdb_Makefile_patch.patch new file mode 100644 index 0000000..32a96b0 --- /dev/null +++ b/patches/initdb_Makefile_patch.patch @@ -0,0 +1,14 @@ +diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile +index 997e0a013e9..1f240713970 100644 +--- a/src/bin/initdb/Makefile ++++ b/src/bin/initdb/Makefile +@@ -23,7 +23,8 @@ include $(top_builddir)/src/Makefile.global + override CPPFLAGS := -DUSE_PRIVATE_ENCODING_FUNCS -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone $(ICU_CFLAGS) $(CPPFLAGS) + + # We need libpq only because fe_utils does. +-LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) $(ICU_LIBS) ++LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) -L$(top_srcdir)/src/common -lpgcommon $(ICU_LIBS) ++LIBS+=$(LDFLAGS_INTERNAL) + + # use system timezone data? + ifneq (,$(with_system_tzdata)) diff --git a/patches/initdb_c_patch.patch b/patches/initdb_c_patch.patch new file mode 100644 index 0000000..672ba18 --- /dev/null +++ b/patches/initdb_c_patch.patch @@ -0,0 +1,13 @@ +diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c +index 62bbd08d9f6..2d91db8b02d 100644 +--- a/src/bin/initdb/initdb.c ++++ b/src/bin/initdb/initdb.c +@@ -1075,7 +1075,7 @@ set_null_conf(void) + static const char * + choose_dsm_implementation(void) + { +-#if defined(HAVE_SHM_OPEN) && !defined(__sun__) ++#if defined(HAVE_SHM_OPEN) && !defined(__sun__) && !defined(__MVS__) + int ntries = 10; + pg_prng_state prng_state; + diff --git a/patches/pg_amcheck_Makefile_patch.patch b/patches/pg_amcheck_Makefile_patch.patch new file mode 100644 index 0000000..1f111fc --- /dev/null +++ b/patches/pg_amcheck_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_amcheck/Makefile b/src/bin/pg_amcheck/Makefile +index fa6071f97c1..73f3fe6bcfc 100644 +--- a/src/bin/pg_amcheck/Makefile ++++ b/src/bin/pg_amcheck/Makefile +@@ -20,6 +20,7 @@ include $(top_builddir)/src/Makefile.global + + override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/pg_basebackup_Makefile_patch.patch b/patches/pg_basebackup_Makefile_patch.patch new file mode 100644 index 0000000..d5e202a --- /dev/null +++ b/patches/pg_basebackup_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile +index a9557c0789f..2cc04de0938 100644 +--- a/src/bin/pg_basebackup/Makefile ++++ b/src/bin/pg_basebackup/Makefile +@@ -28,6 +28,7 @@ export GZIP_PROGRAM=$(GZIP) + + override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/pg_checksums_Makefile_patch.patch b/patches/pg_checksums_Makefile_patch.patch new file mode 100644 index 0000000..ba80042 --- /dev/null +++ b/patches/pg_checksums_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_checksums/Makefile b/src/bin/pg_checksums/Makefile +index a7f6d9c7c5c..ddb3b09ef93 100644 +--- a/src/bin/pg_checksums/Makefile ++++ b/src/bin/pg_checksums/Makefile +@@ -17,6 +17,7 @@ include $(top_builddir)/src/Makefile.global + + # We need libpq only because fe_utils does. + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/pg_combinebackup_Makefile_patch.patch b/patches/pg_combinebackup_Makefile_patch.patch new file mode 100644 index 0000000..3d29933 --- /dev/null +++ b/patches/pg_combinebackup_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_combinebackup/Makefile b/src/bin/pg_combinebackup/Makefile +index 33a1f4483bf..ca8120c9650 100644 +--- a/src/bin/pg_combinebackup/Makefile ++++ b/src/bin/pg_combinebackup/Makefile +@@ -18,6 +18,7 @@ include $(top_builddir)/src/Makefile.global + + override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/pg_dump_Makefile_patch.patch b/patches/pg_dump_Makefile_patch.patch new file mode 100644 index 0000000..6f0aad9 --- /dev/null +++ b/patches/pg_dump_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile +index fa795883e9f..214cc002bec 100644 +--- a/src/bin/pg_dump/Makefile ++++ b/src/bin/pg_dump/Makefile +@@ -23,6 +23,7 @@ export with_icu + + override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/pg_resetwal_Makefile_patch.patch b/patches/pg_resetwal_Makefile_patch.patch new file mode 100644 index 0000000..ad4d875 --- /dev/null +++ b/patches/pg_resetwal_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_resetwal/Makefile b/src/bin/pg_resetwal/Makefile +index 82bea06dee5..1c20e9c8089 100644 +--- a/src/bin/pg_resetwal/Makefile ++++ b/src/bin/pg_resetwal/Makefile +@@ -16,6 +16,7 @@ top_builddir = ../../.. + include $(top_builddir)/src/Makefile.global + + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/pg_rewind_Makefile_patch.patch b/patches/pg_rewind_Makefile_patch.patch new file mode 100644 index 0000000..a1e632e --- /dev/null +++ b/patches/pg_rewind_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile +index cbd000b686d..11f25c89737 100644 +--- a/src/bin/pg_rewind/Makefile ++++ b/src/bin/pg_rewind/Makefile +@@ -17,6 +17,7 @@ include $(top_builddir)/src/Makefile.global + + override CPPFLAGS := -I$(libpq_srcdir) -DFRONTEND $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/pg_test_fsync_c_patch.patch b/patches/pg_test_fsync_c_patch.patch new file mode 100644 index 0000000..89a804b --- /dev/null +++ b/patches/pg_test_fsync_c_patch.patch @@ -0,0 +1,16 @@ +diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c +index 0060ea1..eb0f049 100644 +--- a/src/bin/pg_test_fsync/pg_test_fsync.c ++++ b/src/bin/pg_test_fsync/pg_test_fsync.c +@@ -346,7 +346,11 @@ test_sync(int writes_per_op) + XLOG_BLCKSZ, + writes * XLOG_BLCKSZ) != XLOG_BLCKSZ) + die("write failed"); ++#ifndef __MVS__ + fdatasync(tmpfile); ++#else ++ fsync(tmpfile); ++#endif + } + STOP_TIMER; + close(tmpfile); diff --git a/patches/pg_upgrade_Makefile_patch.patch b/patches/pg_upgrade_Makefile_patch.patch new file mode 100644 index 0000000..4c7bd7a --- /dev/null +++ b/patches/pg_upgrade_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile +index f83d2b5d309..dceeb77bbd0 100644 +--- a/src/bin/pg_upgrade/Makefile ++++ b/src/bin/pg_upgrade/Makefile +@@ -31,6 +31,7 @@ OBJS = \ + + override CPPFLAGS := -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ++LIBS+=$(LDFLAGS_INTERNAL) + + # required for 002_pg_upgrade.pl + REGRESS_SHLIB=$(abs_top_builddir)/src/test/regress/regress$(DLSUFFIX) diff --git a/patches/pg_verifybackup_Makefile_patch.patch b/patches/pg_verifybackup_Makefile_patch.patch new file mode 100644 index 0000000..2d54604 --- /dev/null +++ b/patches/pg_verifybackup_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_verifybackup/Makefile b/src/bin/pg_verifybackup/Makefile +index 374d4a8afd1..036cdf5e379 100644 +--- a/src/bin/pg_verifybackup/Makefile ++++ b/src/bin/pg_verifybackup/Makefile +@@ -19,6 +19,7 @@ include $(top_builddir)/src/Makefile.global + # We need libpq only because fe_utils does. + override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/pg_walsummary_Makefile_patch.patch b/patches/pg_walsummary_Makefile_patch.patch new file mode 100644 index 0000000..297a5e4 --- /dev/null +++ b/patches/pg_walsummary_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pg_walsummary/Makefile b/src/bin/pg_walsummary/Makefile +index 1bc620572d2..ff01fd5365d 100644 +--- a/src/bin/pg_walsummary/Makefile ++++ b/src/bin/pg_walsummary/Makefile +@@ -18,6 +18,7 @@ include $(top_builddir)/src/Makefile.global + + override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/pgbench_Makefile_patch.patch b/patches/pgbench_Makefile_patch.patch new file mode 100644 index 0000000..ee8643e --- /dev/null +++ b/patches/pgbench_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile +index 987bf64df9d..ca39852b407 100644 +--- a/src/bin/pgbench/Makefile ++++ b/src/bin/pgbench/Makefile +@@ -15,6 +15,7 @@ OBJS = \ + + override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ++LIBS+=$(LDFLAGS_INTERNAL) + + ifneq ($(PORTNAME), win32) + override CFLAGS += $(PTHREAD_CFLAGS) diff --git a/patches/pgtime_h_patch.patch b/patches/pgtime_h_patch.patch new file mode 100644 index 0000000..a91b344 --- /dev/null +++ b/patches/pgtime_h_patch.patch @@ -0,0 +1,13 @@ +diff --git a/src/include/pgtime.h b/src/include/pgtime.h +index 5fc9f223de3..a782776f41b 100644 +--- a/src/include/pgtime.h ++++ b/src/include/pgtime.h +@@ -91,7 +91,7 @@ extern PGDLLIMPORT pg_tz *session_timezone; + extern PGDLLIMPORT pg_tz *log_timezone; + + extern void pg_timezone_initialize(void); +-extern pg_tz *pg_tzset(const char *tzname); ++extern pg_tz *pg_tzset(const char *tzname_); + extern pg_tz *pg_tzset_offset(long gmtoffset); + + extern pg_tzenum *pg_tzenumerate_start(void); diff --git a/patches/pgtz_patch.patch b/patches/pgtz_patch.patch new file mode 100644 index 0000000..c1734bc --- /dev/null +++ b/patches/pgtz_patch.patch @@ -0,0 +1,59 @@ +diff --git a/src/timezone/pgtz.c b/src/timezone/pgtz.c +index 671b4d76237..f5a35b1317f 100644 +--- a/src/timezone/pgtz.c ++++ b/src/timezone/pgtz.c +@@ -231,7 +231,7 @@ init_timezone_hashtable(void) + * default timezone setting is later overridden from postgresql.conf. + */ + pg_tz * +-pg_tzset(const char *tzname) ++pg_tzset(const char *tzname_) + { + pg_tz_cache *tzp; + struct state tzstate; +@@ -239,7 +239,7 @@ pg_tzset(const char *tzname) + char canonname[TZ_STRLEN_MAX + 1]; + char *p; + +- if (strlen(tzname) > TZ_STRLEN_MAX) ++ if (strlen(tzname_) > TZ_STRLEN_MAX) + return NULL; /* not going to fit */ + + if (!timezone_cache) +@@ -253,8 +253,8 @@ pg_tzset(const char *tzname) + * a POSIX-style timezone spec.) + */ + p = uppername; +- while (*tzname) +- *p++ = pg_toupper((unsigned char) *tzname++); ++ while (*tzname_) ++ *p++ = pg_toupper((unsigned char) *tzname_++); + *p = '\0'; + + tzp = (pg_tz_cache *) hash_search(timezone_cache, +@@ -321,7 +321,7 @@ pg_tzset_offset(long gmtoffset) + { + long absoffset = (gmtoffset < 0) ? -gmtoffset : gmtoffset; + char offsetstr[64]; +- char tzname[128]; ++ char tzname_[128]; + + snprintf(offsetstr, sizeof(offsetstr), + "%02ld", absoffset / SECS_PER_HOUR); +@@ -338,13 +338,13 @@ pg_tzset_offset(long gmtoffset) + ":%02ld", absoffset); + } + if (gmtoffset > 0) +- snprintf(tzname, sizeof(tzname), "<-%s>+%s", ++ snprintf(tzname_, sizeof(tzname_), "<-%s>+%s", + offsetstr, offsetstr); + else +- snprintf(tzname, sizeof(tzname), "<+%s>-%s", ++ snprintf(tzname_, sizeof(tzname_), "<+%s>-%s", + offsetstr, offsetstr); + +- return pg_tzset(tzname); ++ return pg_tzset(tzname_); + } + + diff --git a/patches/pl_handler_c_patch.patch b/patches/pl_handler_c_patch.patch new file mode 100755 index 0000000..2ceecad --- /dev/null +++ b/patches/pl_handler_c_patch.patch @@ -0,0 +1,23 @@ +diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c +index e9a7292..0931fd7 100644 +--- a/src/pl/plpgsql/src/pl_handler.c ++++ b/src/pl/plpgsql/src/pl_handler.c +@@ -152,7 +152,9 @@ _PG_init(void) + + if (inited) + return; +- ++// MemoryContextInit(); ++// InitializeGUCOptions(); ++ build_guc_variables(); + pg_bindtextdomain(TEXTDOMAIN); + + DefineCustomEnumVariable("plpgsql.variable_conflict", +@@ -202,6 +204,7 @@ _PG_init(void) + + MarkGUCPrefixReserved("plpgsql"); + ++ MemoryContextInit(); + RegisterXactCallback(plpgsql_xact_cb, NULL); + RegisterSubXactCallback(plpgsql_subxact_cb, NULL); + diff --git a/patches/postgres_patch.patch b/patches/postgres_patch.patch new file mode 100644 index 0000000..87a1d7d --- /dev/null +++ b/patches/postgres_patch.patch @@ -0,0 +1,13 @@ +diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c +index 1ae51b1b391..e3e179fa89e 100644 +--- a/src/backend/tcop/postgres.c ++++ b/src/backend/tcop/postgres.c +@@ -5110,7 +5110,7 @@ ShowUsage(const char *title) + (long) user.tv_usec, + (long) sys.tv_sec, + (long) sys.tv_usec); +-#ifndef WIN32 ++#if !defined(WIN32) && !defined(__MVS__) + + /* + * The following rusage fields are not defined by POSIX, but they're diff --git a/patches/psql_Makefile_patch.patch b/patches/psql_Makefile_patch.patch new file mode 100644 index 0000000..76b2d9a --- /dev/null +++ b/patches/psql_Makefile_patch.patch @@ -0,0 +1,12 @@ +diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile +index 5b1545d9948..0cfb5423c75 100644 +--- a/src/bin/psql/Makefile ++++ b/src/bin/psql/Makefile +@@ -23,6 +23,7 @@ REFDOCDIR= $(top_srcdir)/doc/src/sgml/ref + + override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ++LIBS+=$(LDFLAGS_INTERNAL) + + OBJS = \ + $(WIN32RES) \ diff --git a/patches/scripts_Makefile_patch.patch b/patches/scripts_Makefile_patch.patch new file mode 100644 index 0000000..c4cffec --- /dev/null +++ b/patches/scripts_Makefile_patch.patch @@ -0,0 +1,13 @@ +diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile +index f6b4d40810b..ad1ad9c0538 100644 +--- a/src/bin/scripts/Makefile ++++ b/src/bin/scripts/Makefile +@@ -20,7 +20,7 @@ PROGRAMS = createdb createuser dropdb dropuser clusterdb vacuumdb reindexdb pg_i + + override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) + LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) +- ++LIBS+=$(LDFLAGS_INTERNAL) + all: $(PROGRAMS) + + createdb: createdb.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils diff --git a/patches/sysv_shmem_c_patch.patch b/patches/sysv_shmem_c_patch.patch new file mode 100644 index 0000000..eb457ac --- /dev/null +++ b/patches/sysv_shmem_c_patch.patch @@ -0,0 +1,62 @@ +diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c +index 197926d44f6..448bb36a039 100644 +--- a/src/backend/port/sysv_shmem.c ++++ b/src/backend/port/sysv_shmem.c +@@ -619,8 +619,12 @@ CreateAnonymousSegment(Size *size) + if (allocsize % hugepagesize != 0) + allocsize += hugepagesize - (allocsize % hugepagesize); + ++#ifdef __MVS__ ++ ptr = anon_mmap(NULL, allocsize); ++#else + ptr = mmap(NULL, allocsize, PROT_READ | PROT_WRITE, + PG_MMAP_FLAGS | mmap_flags, -1, 0); ++#endif + mmap_errno = errno; + if (huge_pages == HUGE_PAGES_TRY && ptr == MAP_FAILED) + elog(DEBUG1, "mmap(%zu) with MAP_HUGETLB failed, huge pages disabled: %m", +@@ -643,8 +647,12 @@ CreateAnonymousSegment(Size *size) + * to non-huge pages. + */ + allocsize = *size; ++#ifdef __MVS__ ++ ptr = anon_mmap(NULL, allocsize); ++#else + ptr = mmap(NULL, allocsize, PROT_READ | PROT_WRITE, + PG_MMAP_FLAGS, -1, 0); ++#endif + mmap_errno = errno; + } + +@@ -677,7 +685,14 @@ AnonymousShmemDetach(int status, Datum arg) + /* Release anonymous shared memory block, if any. */ + if (AnonymousShmem != NULL) + { +- if (munmap(AnonymousShmem, AnonymousShmemSize) < 0) ++ int retcode; ++#ifdef __MVS__ ++ retcode = anon_munmap(AnonymousShmem, AnonymousShmemSize); ++#else ++ retcode = munmap(AnonymousShmem, AnonymousShmemSize); ++#endif ++// if (munmap(AnonymousShmem, AnonymousShmemSize) < 0) ++ if (retcode < 0) + elog(LOG, "munmap(%p, %zu) failed: %m", + AnonymousShmem, AnonymousShmemSize); + AnonymousShmem = NULL; +@@ -983,7 +998,14 @@ PGSharedMemoryDetach(void) + + if (AnonymousShmem != NULL) + { +- if (munmap(AnonymousShmem, AnonymousShmemSize) < 0) ++ int retcode; ++#ifdef __MVS__ ++ retcode = anon_munmap(AnonymousShmem, AnonymousShmemSize); ++#else ++ retcode = munmap(AnonymousShmem, AnonymousShmemSize); ++#endif ++// if (munmap(AnonymousShmem, AnonymousShmemSize) < 0) ++ if (retcode < 0) + elog(LOG, "munmap(%p, %zu) failed: %m", + AnonymousShmem, AnonymousShmemSize); + AnonymousShmem = NULL; diff --git a/patches/timestamp_c_patch.patch b/patches/timestamp_c_patch.patch new file mode 100644 index 0000000..3d2205c --- /dev/null +++ b/patches/timestamp_c_patch.patch @@ -0,0 +1,137 @@ +diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c +index 347089b..ff4eeec 100644 +--- a/src/backend/utils/adt/timestamp.c ++++ b/src/backend/utils/adt/timestamp.c +@@ -490,11 +490,11 @@ timestamptz_in(PG_FUNCTION_ARGS) + static int + parse_sane_timezone(struct pg_tm *tm, text *zone) + { +- char tzname[TZ_STRLEN_MAX + 1]; ++ char tzname_[TZ_STRLEN_MAX + 1]; + int dterr; + int tz; + +- text_to_cstring_buffer(zone, tzname, sizeof(tzname)); ++ text_to_cstring_buffer(zone, tzname_, sizeof(tzname_)); + + /* + * Look up the requested timezone. First we try to interpret it as a +@@ -506,14 +506,14 @@ parse_sane_timezone(struct pg_tm *tm, text *zone) + * as invalid, it's enough to disallow having a digit in the first + * position of our input string. + */ +- if (isdigit((unsigned char) *tzname)) ++ if (isdigit((unsigned char) *tzname_)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("invalid input syntax for type %s: \"%s\"", +- "numeric time zone", tzname), ++ "numeric time zone", tzname_), + errhint("Numeric time zones must have \"-\" or \"+\" as first character."))); + +- dterr = DecodeTimezone(tzname, &tz); ++ dterr = DecodeTimezone(tzname_, &tz); + if (dterr != 0) + { + int type, +@@ -523,13 +523,13 @@ parse_sane_timezone(struct pg_tm *tm, text *zone) + if (dterr == DTERR_TZDISP_OVERFLOW) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), +- errmsg("numeric time zone \"%s\" out of range", tzname))); ++ errmsg("numeric time zone \"%s\" out of range", tzname_))); + else if (dterr != DTERR_BAD_FORMAT) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), +- errmsg("time zone \"%s\" not recognized", tzname))); ++ errmsg("time zone \"%s\" not recognized", tzname_))); + +- type = DecodeTimezoneName(tzname, &val, &tzp); ++ type = DecodeTimezoneName(tzname_, &val, &tzp); + + if (type == TZNAME_FIXED_OFFSET) + { +@@ -539,7 +539,7 @@ parse_sane_timezone(struct pg_tm *tm, text *zone) + else if (type == TZNAME_DYNTZ) + { + /* dynamic-offset abbreviation, resolve using specified time */ +- tz = DetermineTimeZoneAbbrevOffset(tm, tzname, tzp); ++ tz = DetermineTimeZoneAbbrevOffset(tm, tzname_, tzp); + } + else + { +@@ -559,11 +559,11 @@ parse_sane_timezone(struct pg_tm *tm, text *zone) + static pg_tz * + lookup_timezone(text *zone) + { +- char tzname[TZ_STRLEN_MAX + 1]; ++ char tzname_[TZ_STRLEN_MAX + 1]; + +- text_to_cstring_buffer(zone, tzname, sizeof(tzname)); ++ text_to_cstring_buffer(zone, tzname_, sizeof(tzname_)); + +- return DecodeTimezoneNameToTz(tzname); ++ return DecodeTimezoneNameToTz(tzname_); + } + + /* +@@ -6329,7 +6329,7 @@ timestamp_zone(PG_FUNCTION_ARGS) + Timestamp timestamp = PG_GETARG_TIMESTAMP(1); + TimestampTz result; + int tz; +- char tzname[TZ_STRLEN_MAX + 1]; ++ char tzname_[TZ_STRLEN_MAX + 1]; + int type, + val; + pg_tz *tzp; +@@ -6342,9 +6342,9 @@ timestamp_zone(PG_FUNCTION_ARGS) + /* + * Look up the requested timezone. + */ +- text_to_cstring_buffer(zone, tzname, sizeof(tzname)); ++ text_to_cstring_buffer(zone, tzname_, sizeof(tzname_)); + +- type = DecodeTimezoneName(tzname, &val, &tzp); ++ type = DecodeTimezoneName(tzname_, &val, &tzp); + + if (type == TZNAME_FIXED_OFFSET) + { +@@ -6359,7 +6359,7 @@ timestamp_zone(PG_FUNCTION_ARGS) + ereport(ERROR, + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg("timestamp out of range"))); +- tz = -DetermineTimeZoneAbbrevOffset(&tm, tzname, tzp); ++ tz = -DetermineTimeZoneAbbrevOffset(&tm, tzname_, tzp); + result = dt2local(timestamp, tz); + } + else +@@ -6567,7 +6567,7 @@ timestamptz_zone(PG_FUNCTION_ARGS) + TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(1); + Timestamp result; + int tz; +- char tzname[TZ_STRLEN_MAX + 1]; ++ char tzname_[TZ_STRLEN_MAX + 1]; + int type, + val; + pg_tz *tzp; +@@ -6578,9 +6578,9 @@ timestamptz_zone(PG_FUNCTION_ARGS) + /* + * Look up the requested timezone. + */ +- text_to_cstring_buffer(zone, tzname, sizeof(tzname)); ++ text_to_cstring_buffer(zone, tzname_, sizeof(tzname_)); + +- type = DecodeTimezoneName(tzname, &val, &tzp); ++ type = DecodeTimezoneName(tzname_, &val, &tzp); + + if (type == TZNAME_FIXED_OFFSET) + { +@@ -6593,7 +6593,7 @@ timestamptz_zone(PG_FUNCTION_ARGS) + /* dynamic-offset abbreviation, resolve using specified time */ + int isdst; + +- tz = DetermineTimeZoneAbbrevOffsetTS(timestamp, tzname, tzp, &isdst); ++ tz = DetermineTimeZoneAbbrevOffsetTS(timestamp, tzname_, tzp, &isdst); + result = dt2local(timestamp, tz); + } + else diff --git a/patches/waiteventset_patch.patch b/patches/waiteventset_patch.patch new file mode 100644 index 0000000..61bbb06 --- /dev/null +++ b/patches/waiteventset_patch.patch @@ -0,0 +1,139 @@ +diff --git a/src/backend/storage/ipc/waiteventset.c b/src/backend/storage/ipc/waiteventset.c +index 7c0e66900f9..574ced67132 100644 +--- a/src/backend/storage/ipc/waiteventset.c ++++ b/src/backend/storage/ipc/waiteventset.c +@@ -86,7 +86,7 @@ + #if defined(WAIT_USE_EPOLL) || defined(WAIT_USE_POLL) || \ + defined(WAIT_USE_KQUEUE) || defined(WAIT_USE_WIN32) + /* don't overwrite manual choice */ +-#elif defined(HAVE_SYS_EPOLL_H) ++#elif defined(HAVE_SYS_EPOLL_H) && ! defined (__MVS__) + #define WAIT_USE_EPOLL + #elif defined(HAVE_KQUEUE) + #define WAIT_USE_KQUEUE +@@ -142,7 +142,7 @@ struct WaitEventSet + */ + bool exit_on_postmaster_death; + +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + int epoll_fd; + /* epoll_wait returns events in a user provided arrays, allocate once */ + struct epoll_event *epoll_ret_events; +@@ -192,7 +192,7 @@ static void sendSelfPipeByte(void); + static void drain(void); + #endif + +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + static void WaitEventAdjustEpoll(WaitEventSet *set, WaitEvent *event, int action); + #elif defined(WAIT_USE_KQUEUE) + static void WaitEventAdjustKqueue(WaitEventSet *set, WaitEvent *event, int old_events); +@@ -202,7 +202,7 @@ static void WaitEventAdjustPoll(WaitEventSet *set, WaitEvent *event); + static void WaitEventAdjustWin32(WaitEventSet *set, WaitEvent *event); + #endif + +-static inline int WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout, ++int WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout, + WaitEvent *occurred_events, int nevents); + + /* ResourceOwner support to hold WaitEventSets */ +@@ -375,7 +375,7 @@ CreateWaitEventSet(ResourceOwner resowner, int nevents) + sz += MAXALIGN(sizeof(WaitEventSet)); + sz += MAXALIGN(sizeof(WaitEvent) * nevents); + +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + sz += MAXALIGN(sizeof(struct epoll_event) * nevents); + #elif defined(WAIT_USE_KQUEUE) + sz += MAXALIGN(sizeof(struct kevent) * nevents); +@@ -397,7 +397,7 @@ CreateWaitEventSet(ResourceOwner resowner, int nevents) + set->events = (WaitEvent *) data; + data += MAXALIGN(sizeof(WaitEvent) * nevents); + +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + set->epoll_ret_events = (struct epoll_event *) data; + data += MAXALIGN(sizeof(struct epoll_event) * nevents); + #elif defined(WAIT_USE_KQUEUE) +@@ -421,7 +421,7 @@ CreateWaitEventSet(ResourceOwner resowner, int nevents) + set->owner = resowner; + } + +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + if (!AcquireExternalFD()) + elog(ERROR, "AcquireExternalFD, for epoll_create1, failed: %m"); + set->epoll_fd = epoll_create1(EPOLL_CLOEXEC); +@@ -485,7 +485,7 @@ FreeWaitEventSet(WaitEventSet *set) + set->owner = NULL; + } + +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + close(set->epoll_fd); + ReleaseExternalFD(); + #elif defined(WAIT_USE_KQUEUE) +@@ -522,7 +522,7 @@ FreeWaitEventSet(WaitEventSet *set) + void + FreeWaitEventSetAfterFork(WaitEventSet *set) + { +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + close(set->epoll_fd); + ReleaseExternalFD(); + #elif defined(WAIT_USE_KQUEUE) +@@ -631,7 +631,7 @@ AddWaitEventToSet(WaitEventSet *set, uint32 events, pgsocket fd, Latch *latch, + } + + /* perform wait primitive specific initialization, if needed */ +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + WaitEventAdjustEpoll(set, event, EPOLL_CTL_ADD); + #elif defined(WAIT_USE_KQUEUE) + WaitEventAdjustKqueue(set, event, 0); +@@ -718,7 +718,7 @@ ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch) + #endif + } + +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + WaitEventAdjustEpoll(set, event, EPOLL_CTL_MOD); + #elif defined(WAIT_USE_KQUEUE) + WaitEventAdjustKqueue(set, event, old_events); +@@ -729,7 +729,7 @@ ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch) + #endif + } + +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + /* + * action can be one of EPOLL_CTL_ADD | EPOLL_CTL_MOD | EPOLL_CTL_DEL + */ +@@ -1167,7 +1167,7 @@ WaitEventSetWait(WaitEventSet *set, long timeout, + } + + +-#if defined(WAIT_USE_EPOLL) ++#if defined(WAIT_USE_EPOLL) && !defined (__MVS__) + + /* + * Wait using linux's epoll_wait(2). +@@ -1177,7 +1177,7 @@ WaitEventSetWait(WaitEventSet *set, long timeout, + * epoll_event struct contain a pointer to our events, making association + * easy. + */ +-static inline int ++int + WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout, + WaitEvent *occurred_events, int nevents) + { +@@ -1466,7 +1466,7 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout, + * This allows to receive readiness notifications for several events at once, + * but requires iterating through all of set->pollfds. + */ +-static inline int ++int + WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout, + WaitEvent *occurred_events, int nevents) + { diff --git a/patches/zos_h_patch.patch b/patches/zos_h_patch.patch new file mode 100644 index 0000000..57b844c --- /dev/null +++ b/patches/zos_h_patch.patch @@ -0,0 +1,7 @@ +diff --git a/src/include/port/zos.h b/src/include/port/zos.h +new file mode 100644 +index 00000000000..5b8810ed3d0 +--- /dev/null ++++ b/src/include/port/zos.h +@@ -0,0 +1 @@ ++//created empty file as postgres configure step requires the zos.h diff --git a/patches/zos_template_patch.patch b/patches/zos_template_patch.patch new file mode 100644 index 0000000..4958cfb --- /dev/null +++ b/patches/zos_template_patch.patch @@ -0,0 +1,46 @@ +diff --git a/src/template/zos b/src/template/zos +new file mode 100644 +index 00000000000..7ee01f92df0 +--- /dev/null ++++ b/src/template/zos +@@ -0,0 +1,40 @@ ++# src/template/zos ++# currently copied from src/template/linux ++ ++# Prefer unnamed POSIX semaphores if available, unless user overrides choice ++if test x"$PREFERRED_SEMAPHORES" = x"" ; then ++ PREFERRED_SEMAPHORES=UNNAMED_POSIX ++fi ++ ++# Force _GNU_SOURCE on; plperl is broken with Perl 5.8.0 otherwise ++# This is also required for ppoll(2), and perhaps other things ++CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" ++ ++# Extra CFLAGS for code that will go into a shared library ++CFLAGS_SL="-fPIC" ++ ++# If --enable-profiling is specified, we need -DLINUX_PROFILE ++PLATFORM_PROFILE_FLAGS="-DLINUX_PROFILE" ++ ++if test "$SUN_STUDIO_CC" = "yes" ; then ++ CC="$CC -Xa" # relaxed ISO C mode ++ CFLAGS="-v" # -v is like gcc -Wall ++ if test "$enable_debug" != yes; then ++ CFLAGS="$CFLAGS -O" # any optimization breaks debug ++ fi ++ ++ # Pick the right test-and-set (TAS) code for the Sun compiler. ++ # We would like to use in-line assembler, but the compiler ++ # requires *.il files to be on every compile line, making ++ # the build system too fragile. ++ case $host_cpu in ++ sparc) ++ need_tas=yes ++ tas_file=sunstudio_sparc.s ++ ;; ++ i?86|x86_64) ++ need_tas=yes ++ tas_file=sunstudio_x86.s ++ ;; ++ esac ++fi