diff --git a/methods/array_ops/src/pg_gp/array_ops.c b/methods/array_ops/src/pg_gp/array_ops.c index 574a9571e..c6e0a3014 100644 --- a/methods/array_ops/src/pg_gp/array_ops.c +++ b/methods/array_ops/src/pg_gp/array_ops.c @@ -13,6 +13,9 @@ #else #include "utils/int8.h" #endif +#if PG_VERSION_NUM >= 160000 +#include +#endif #include "utils/datum.h" #include "utils/lsyscache.h" #include "utils/typcache.h" diff --git a/methods/kmeans/src/pg_gp/kmeans.c b/methods/kmeans/src/pg_gp/kmeans.c index a9d0cc0d8..04bad8050 100644 --- a/methods/kmeans/src/pg_gp/kmeans.c +++ b/methods/kmeans/src/pg_gp/kmeans.c @@ -5,6 +5,9 @@ #else #include #endif +#if PG_VERSION_NUM >= 160000 +#include +#endif #include #include #include "../../../svec/src/pg_gp/sparse_vector.h" diff --git a/methods/sketch/src/pg_gp/countmin.c b/methods/sketch/src/pg_gp/countmin.c index 8b70ec6bf..dc7d8be66 100644 --- a/methods/sketch/src/pg_gp/countmin.c +++ b/methods/sketch/src/pg_gp/countmin.c @@ -35,6 +35,9 @@ #include #include #include +#if PG_VERSION_NUM >= 160000 +#include +#endif #include #include "sketch_support.h" #include "countmin.h" diff --git a/methods/sketch/src/pg_gp/fm.c b/methods/sketch/src/pg_gp/fm.c index 39f34130a..88b140598 100644 --- a/methods/sketch/src/pg_gp/fm.c +++ b/methods/sketch/src/pg_gp/fm.c @@ -38,6 +38,9 @@ #else #include #endif +#if PG_VERSION_NUM >= 160000 +#include +#endif #include #include #include @@ -592,7 +595,7 @@ bytea *fmsketch_sortasort_insert(bytea *transblob, Datum dat, size_t len) sortasort *s_in = (sortasort *)(transval->storage); bytea * newblob; - bool success = false; + int success = 0; size_t new_storage_sz; size_t newsize; diff --git a/methods/sketch/src/pg_gp/mfvsketch.c b/methods/sketch/src/pg_gp/mfvsketch.c index 57e8c5d7f..2e60f33ee 100644 --- a/methods/sketch/src/pg_gp/mfvsketch.c +++ b/methods/sketch/src/pg_gp/mfvsketch.c @@ -33,6 +33,9 @@ #include #include #include +#if PG_VERSION_NUM >= 160000 +#include +#endif #include #include #include diff --git a/methods/sketch/src/pg_gp/sketch_support.c b/methods/sketch/src/pg_gp/sketch_support.c index f8baf6a68..14abb8a17 100644 --- a/methods/sketch/src/pg_gp/sketch_support.c +++ b/methods/sketch/src/pg_gp/sketch_support.c @@ -47,6 +47,9 @@ #else #include #endif +#if PG_VERSION_NUM >= 160000 +#include +#endif #include #include "sketch_support.h" diff --git a/methods/svec/src/pg_gp/sparse_vector.c b/methods/svec/src/pg_gp/sparse_vector.c index 794441974..c3862bba9 100644 --- a/methods/svec/src/pg_gp/sparse_vector.c +++ b/methods/svec/src/pg_gp/sparse_vector.c @@ -25,6 +25,9 @@ #include "utils/fmgroids.h" #include "lib/stringinfo.h" #include "utils/memutils.h" +#if PG_VERSION_NUM >= 160000 +#include +#endif #include "sparse_vector.h" /** diff --git a/src/ports/postgres/16/CMakeLists.txt b/src/ports/postgres/16/CMakeLists.txt new file mode 100644 index 000000000..9c4678002 --- /dev/null +++ b/src/ports/postgres/16/CMakeLists.txt @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------------ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ------------------------------------------------------------------------------ + +add_current_postgresql_version() +add_extension_support() diff --git a/src/ports/postgres/17/CMakeLists.txt b/src/ports/postgres/17/CMakeLists.txt new file mode 100644 index 000000000..9c4678002 --- /dev/null +++ b/src/ports/postgres/17/CMakeLists.txt @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------------ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ------------------------------------------------------------------------------ + +add_current_postgresql_version() +add_extension_support() diff --git a/src/ports/postgres/18/CMakeLists.txt b/src/ports/postgres/18/CMakeLists.txt new file mode 100644 index 000000000..9c4678002 --- /dev/null +++ b/src/ports/postgres/18/CMakeLists.txt @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------------ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ------------------------------------------------------------------------------ + +add_current_postgresql_version() +add_extension_support() diff --git a/src/ports/postgres/cmake/FindPostgreSQL_16.cmake b/src/ports/postgres/cmake/FindPostgreSQL_16.cmake new file mode 100644 index 000000000..43ba0e430 --- /dev/null +++ b/src/ports/postgres/cmake/FindPostgreSQL_16.cmake @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------------ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ------------------------------------------------------------------------------ + +set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") +include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") diff --git a/src/ports/postgres/cmake/FindPostgreSQL_17.cmake b/src/ports/postgres/cmake/FindPostgreSQL_17.cmake new file mode 100644 index 000000000..43ba0e430 --- /dev/null +++ b/src/ports/postgres/cmake/FindPostgreSQL_17.cmake @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------------ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ------------------------------------------------------------------------------ + +set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") +include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") diff --git a/src/ports/postgres/cmake/FindPostgreSQL_18.cmake b/src/ports/postgres/cmake/FindPostgreSQL_18.cmake new file mode 100644 index 000000000..43ba0e430 --- /dev/null +++ b/src/ports/postgres/cmake/FindPostgreSQL_18.cmake @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------------ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ------------------------------------------------------------------------------ + +set(_FIND_PACKAGE_FILE "${CMAKE_CURRENT_LIST_FILE}") +include("${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake") diff --git a/src/ports/postgres/dbconnector/Backend.hpp b/src/ports/postgres/dbconnector/Backend.hpp index 138136c47..1b90aca78 100644 --- a/src/ports/postgres/dbconnector/Backend.hpp +++ b/src/ports/postgres/dbconnector/Backend.hpp @@ -19,9 +19,20 @@ namespace { MADLIB_WRAP_PG_FUNC( bool, type_is_array, (Oid typid), (typid)) +// PostgreSQL 16+ replaced pg_proc_aclcheck with object_aclcheck +#if PG_VERSION_NUM >= 160000 +MADLIB_WRAP_PG_FUNC( + AclResult, object_aclcheck, (Oid classid, Oid objectid, Oid roleid, AclMode mode), + (classid, objectid, roleid, mode)) + +inline AclResult madlib_pg_proc_aclcheck(Oid proc_oid, Oid roleid, AclMode mode) { + return madlib_object_aclcheck(ProcedureRelationId, proc_oid, roleid, mode); +} +#else MADLIB_WRAP_PG_FUNC( AclResult, pg_proc_aclcheck, (Oid proc_oid, Oid roleid, AclMode mode), (proc_oid, roleid, mode)) +#endif MADLIB_WRAP_PG_FUNC( void*, MemoryContextAlloc, (MemoryContext context, Size size), diff --git a/src/ports/postgres/dbconnector/Compatibility.hpp b/src/ports/postgres/dbconnector/Compatibility.hpp index 45d66332a..745c4d2c9 100644 --- a/src/ports/postgres/dbconnector/Compatibility.hpp +++ b/src/ports/postgres/dbconnector/Compatibility.hpp @@ -14,6 +14,12 @@ extern "C" { #if PG_VERSION_NUM >= 90300 #include #endif + + // PostgreSQL 16+ compatibility + #if PG_VERSION_NUM >= 160000 + #include + #include + #endif } diff --git a/tool/docker/base/Dockerfile_postgres_15_Jenkins b/tool/docker/base/Dockerfile_postgres_15_Jenkins index 760a67872..6e15e1d0f 100644 --- a/tool/docker/base/Dockerfile_postgres_15_Jenkins +++ b/tool/docker/base/Dockerfile_postgres_15_Jenkins @@ -16,19 +16,31 @@ # specific language governing permissions and limitations # under the License. -FROM gcr.io/data-gpdb-public-images/gpdb7-ubuntu20.04-test +FROM ubuntu:22.04 + +# Argument for configuring the timezone +ARG TIMEZONE_VAR="Europe/London" +ENV TZ=${TIMEZONE_VAR} +ENV DEBIAN_FRONTEND=noninteractive + +# Set the LOCALE +ENV LANG=en_US.UTF-8 +RUN apt-get update && apt-get install -y locales && \ + locale-gen en_US.UTF-8 && \ + update-locale LANG=en_US.UTF-8 && \ + apt-get clean && rm -rf /var/lib/apt/lists/* ### Get postgres specific add-ons -RUN apt-get update && apt-get install -y wget \ +RUN apt-get update && apt-get install -y wget \ build-essential \ openssl \ libssl-dev \ + lsb-release \ libboost-all-dev \ m4 \ rpm \ python3-pip \ python3-dev \ - build-essential \ cmake \ libspatialindex-dev \ vim \ @@ -41,11 +53,11 @@ RUN apt-get update && apt-get install -y wget \ iputils-ping \ iproute2 \ net-tools \ - libspatialindex-dev \ - ca-certificates + ca-certificates && \ + apt-get clean && rm -rf /var/lib/apt/lists/* RUN add-apt-repository -y ppa:deadsnakes/ppa -RUN echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - RUN apt-get update && apt-get install -y \ @@ -53,9 +65,10 @@ RUN apt-get update && apt-get install -y \ postgresql-plpython3-15 \ postgresql-15 \ postgresql-client-15 \ - libpq-dev - + libpq-dev && \ + apt-get clean && rm -rf /var/lib/apt/lists/* +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 RUN python3 -m pip install dill rtree xgboost mock pandas numpy scikit-learn pyxb-x ## To build an image from this docker file, from madlib folder, run: -# docker build -t madlib/postgres_15:jenkins -f tool/docker/base/Dockerfile_postgres_15_Jenkins . +# docker build -t madlib/postgres_15:jenkins -f tool/docker/base/Dockerfile_postgres_15_Jenkins . \ No newline at end of file diff --git a/tool/docker/base/Dockerfile_postgres_16_Jenkins b/tool/docker/base/Dockerfile_postgres_16_Jenkins new file mode 100644 index 000000000..4b1288e94 --- /dev/null +++ b/tool/docker/base/Dockerfile_postgres_16_Jenkins @@ -0,0 +1,74 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +FROM ubuntu:22.04 + +# Argument for configuring the timezone +ARG TIMEZONE_VAR="Europe/London" +ENV TZ=${TIMEZONE_VAR} +ENV DEBIAN_FRONTEND=noninteractive + +# Set the LOCALE +ENV LANG=en_US.UTF-8 +RUN apt-get update && apt-get install -y locales && \ + locale-gen en_US.UTF-8 && \ + update-locale LANG=en_US.UTF-8 && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +### Get postgres specific add-ons +RUN apt-get update && apt-get install -y wget \ + build-essential \ + openssl \ + libssl-dev \ + lsb-release \ + libboost-all-dev \ + m4 \ + rpm \ + python3-pip \ + python3-dev \ + cmake \ + libspatialindex-dev \ + vim \ + sudo \ + software-properties-common \ + lsb-core \ + libyaml-dev \ + libpython3-dev \ + python3-distutils \ + iputils-ping \ + iproute2 \ + net-tools \ + ca-certificates && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +RUN add-apt-repository -y ppa:deadsnakes/ppa +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list + +RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - +RUN apt-get update && apt-get install -y \ + postgresql-server-dev-16 \ + postgresql-plpython3-16 \ + postgresql-16 \ + postgresql-client-16 \ + libpq-dev && \ + apt-get clean && rm -rf /var/lib/apt/lists/* +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 +RUN python3 -m pip install dill rtree xgboost mock pandas numpy scikit-learn pyxb-x + +## To build an image from this docker file, from madlib folder, run: +# docker build -t madlib/postgres_16:jenkins -f tool/docker/base/Dockerfile_postgres_16_Jenkins . diff --git a/tool/docker/base/Dockerfile_postgres_17_Jenkins b/tool/docker/base/Dockerfile_postgres_17_Jenkins new file mode 100644 index 000000000..102ce6123 --- /dev/null +++ b/tool/docker/base/Dockerfile_postgres_17_Jenkins @@ -0,0 +1,74 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +FROM ubuntu:22.04 + +# Argument for configuring the timezone +ARG TIMEZONE_VAR="Europe/London" +ENV TZ=${TIMEZONE_VAR} +ENV DEBIAN_FRONTEND=noninteractive + +# Set the LOCALE +ENV LANG=en_US.UTF-8 +RUN apt-get update && apt-get install -y locales && \ + locale-gen en_US.UTF-8 && \ + update-locale LANG=en_US.UTF-8 && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +### Get postgres specific add-ons +RUN apt-get update && apt-get install -y wget \ + build-essential \ + openssl \ + libssl-dev \ + lsb-release \ + libboost-all-dev \ + m4 \ + rpm \ + python3-pip \ + python3-dev \ + cmake \ + libspatialindex-dev \ + vim \ + sudo \ + software-properties-common \ + lsb-core \ + libyaml-dev \ + libpython3-dev \ + python3-distutils \ + iputils-ping \ + iproute2 \ + net-tools \ + ca-certificates && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +RUN add-apt-repository -y ppa:deadsnakes/ppa +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list + +RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - +RUN apt-get update && apt-get install -y \ + postgresql-server-dev-17 \ + postgresql-plpython3-17 \ + postgresql-17 \ + postgresql-client-17 \ + libpq-dev && \ + apt-get clean && rm -rf /var/lib/apt/lists/* +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 +RUN python3 -m pip install dill rtree xgboost mock pandas numpy scikit-learn pyxb-x + +## To build an image from this docker file, from madlib folder, run: +# docker build -t madlib/postgres_17:jenkins -f tool/docker/base/Dockerfile_postgres_17_Jenkins .