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