GithubHelp home page GithubHelp logo

Comments (14)

fboulnois avatar fboulnois commented on July 27, 2024 3

Yes, to clarify the issue, the releases are built for x86_64 and not for ARM (like the M1, M2, and M3 Macs), hence the error with loading the library if you download the release directly from GitHub.

The correct solution for other architectures is indeed to build the extension from source. You'll want to follow the local build process outlined in the README.md:

# assumes that libpq-dev and postgres are correctly set up
make
make install

I'll add a note in the docs about installing on other architectures.

from pg_uuidv7.

Samuelodan avatar Samuelodan commented on July 27, 2024 2

@matthiasbayer I hope we find a neat solution, cos I think it's a nice implementation.
For now, I've fallen back to generating the UUIDv7 values in the application before creating resources. This should suffice until a database solution is found.

Oh, being relatively new to all this, I found out today that we can define a function in the database and use that as the default value for a column. Here's a cool one for UUIDv7 generation:

from pg_uuidv7.

fboulnois avatar fboulnois commented on July 27, 2024 2

I added a note in #25 , hopefully that should help future developers.

from pg_uuidv7.

nataliachodelski avatar nataliachodelski commented on July 27, 2024 2

I'm new to docker & found the process to download and build the pg_uuidv7 extension confusing, so I wanted to share my resulting Dockerfile for the postgres container in which i want to use this extension.

FROM postgres:16.2

RUN apt-get update && apt-get -y install git build-essential postgresql-server-dev-16
RUN postgres --version
RUN git clone https://github.com/fboulnois/pg_uuidv7
RUN cd pg_uuidv7 && make && make install && ls -la

COPY ./init.sql /docker-entrypoint-initdb.d/init.sql

from pg_uuidv7.

matthiasbayer avatar matthiasbayer commented on July 27, 2024 1

I was able to solve this by building the extension from source using the Makefile.

from pg_uuidv7.

fboulnois avatar fboulnois commented on July 27, 2024

What process are you using to install?

from pg_uuidv7.

Samuelodan avatar Samuelodan commented on July 27, 2024

Hi, I used a bash script based on the example script in the README. My machine doesn't have sha256sum installed, so I added the line below to the script:
function sha256sum() { openssl sha256 "$@" | awk '{print $2}'; }

Here's the full script just in case.

#! /bin/bash
cd "$(mktemp -d)"
curl -LO "https://github.com/fboulnois/pg_uuidv7/releases/download/v1.4.1/{pg_uuidv7.tar.gz,SHA256SUMS}"
tar xf pg_uuidv7.tar.gz

function sha256sum() { openssl sha256 "$@" | awk '{print $2}'; }
sha256sum -c SHA256SUMS
PG_MAJOR=$(pg_config --version | sed 's/^.* \([0-9]\{1,\}\).*$/\1/')
cp "$PG_MAJOR/pg_uuidv7.so" "$(pg_config --pkglibdir)"
cp pg_uuidv7--1.4.sql pg_uuidv7.control "$(pg_config --sharedir)/extension"
# the CREATE EXTENSION command will be run in a (Rails) migration with `enable_extension`

Thanks.

from pg_uuidv7.

matthiasbayer avatar matthiasbayer commented on July 27, 2024

Similar error here on M3, but not sure if that's the root cause.

could not load library "/usr/lib/postgresql/16/lib/pg_uuidv7.so": /usr/lib/postgresql/16/lib/pg_uuidv7.so: cannot open shared object file: No such file or directory

even though the file exists:

root@3add0a82ddf9:/# ls -al /usr/lib/postgresql/16/lib/pg_uuidv7.so
-rwxr-xr-x 1 root root 21952 Jan 24 18:26 /usr/lib/postgresql/16/lib/pg_uuidv7.so

I'm using pg_uuidv7 at version 1.0.0.

from pg_uuidv7.

Samuelodan avatar Samuelodan commented on July 27, 2024

@matthiasbayer oh wow! That's great news. Is this something I can do in a script too? I'd like to make our application fairly straightforward.

from pg_uuidv7.

Samuelodan avatar Samuelodan commented on July 27, 2024

Thank you so much @fboulnois
Yeah, I'll appreciate it if you add more details to the README. But it's mostly a skill issue. If I knew about using Makefiles, the solution would've been obvious to me.
Anyways, I'm happy to try it out and become somewhat comfortable with make. 😊

Thank you for the help. I'll let you know how it goes.

from pg_uuidv7.

Samuelodan avatar Samuelodan commented on July 27, 2024

Thank you so much for sharing.
I considered the likelihood of switching to a managed postgres database for my app and realized that I wouldn't be able to use this extension with any of the services, so I stuck to generating and assigning the UUIDv7 values within the application itself using a callback.

It doesn't seem like the most elegant solution, but it works my situation right now.

from pg_uuidv7.

conradwt avatar conradwt commented on July 27, 2024

@Samuelodan It's always most important to get something working and iterate on that solution. It looks like UUIDv7 feature is targeted at PostgreSQL 17:

https://commitfest.postgresql.org/47/4388

from pg_uuidv7.

Samuelodan avatar Samuelodan commented on July 27, 2024

Thanks @conradwt
I saw that it was coming to v17 so that's another thing that helped me to wait. I'll switch to the native extension as soon as I upgrade.

from pg_uuidv7.

dotZak avatar dotZak commented on July 27, 2024

Thread summary w/ a solution

I got this working today. I'll summarize the info in this thread.

⚠️ Don't use the release version on MacOS

Per the author in the README, the release version is for x86_64, not ARM (M1, M2, M3…).

👍 Install on MacOS for any M-series Macs

⚠️ Prerequisite/warning

Make sure your pg_config command is the one that you think it is. I was struggling because I would install and nothing would happen. It turns out I had two copies of Postgres installed: One from brew and one from the desktop app.

I had to update my $PATH variable so the "correct" version came first. ("Correct" is whichever version you intend to use).

$ whereis pg_config
pg_config: /Applications/Postgres.app/Contents/Versions/latest/bin/pg_config /Applications/Postgres.app/Contents/Versions/latest/share/man/man1/pg_config.1

Clone the repo

1️⃣ Use git to clone the repository to your machine. It doesn't matter where since you can delete it after install. e.g I used the Downloads directory.

cd ~/Downloads && \
git clone https://github.com/fboulnois/pg_uuidv7.git

Once that's done you can cd into the directory

cd pg_uuidv7

Make and install the extension

2️⃣ Run make, then make install.

make

You should get some output like this…

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro  -Os -mmacosx-version-min=10.13 -arch arm64 -arch x86_64  -fvisibility=hidden -I. -I./ -I/Applications/Postgres.app/Contents/Versions/16/include/postgresql/server -I/Applications/Postgres.app/Contents/Versions/16/include/postgresql/internal -I/Applications/Postgres.app/Contents/Versions/16/share/icu -I/Applications/Postgres.app/Contents/Versions/16/include/libxml2 -I/Applications/Postgres.app/Contents/Versions/16/include -I/Applications/Postgres.app/Contents/Versions/16/include  -I/Applications/Postgres.app/Contents/Versions/16/include  -c -o pg_uuidv7.o pg_uuidv7.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro  -Os -mmacosx-version-min=10.13 -arch arm64 -arch x86_64  -fvisibility=hidden pg_uuidv7.o -L/Applications/Postgres.app/Contents/Versions/16/lib  -L/Applications/Postgres.app/Contents/Versions/16/lib -L/Applications/Postgres.app/Contents/Versions/16/lib -L/Applications/Postgres.app/Contents/Versions/16/lib  -L/Applications/Postgres.app/Contents/Versions/16/lib -Wl,-dead_strip_dylibs   -fvisibility=hidden -bundle -bundle_loader /Applications/Postgres.app/Contents/Versions/16/bin/postgres -o pg_uuidv7.dylib

Notice the pg_uuidv7.dylib at the end there? That's the thing the release doesn't do for you.

3️⃣ If that's all good you can run the install.

make install

You should get a message similar to this:

/bin/sh /Applications/Postgres.app/Contents/Versions/16/lib/postgresql/pgxs/src/makefiles/../../config/install-sh -c -d '/Applications/Postgres.app/Contents/Versions/16/share/postgresql/extension'
/bin/sh /Applications/Postgres.app/Contents/Versions/16/lib/postgresql/pgxs/src/makefiles/../../config/install-sh -c -d '/Applications/Postgres.app/Contents/Versions/16/share/postgresql/extension'
/bin/sh /Applications/Postgres.app/Contents/Versions/16/lib/postgresql/pgxs/src/makefiles/../../config/install-sh -c -d '/Applications/Postgres.app/Contents/Versions/16/lib/postgresql'

Verify and cleanup

To check that it installed correctly, attempt to use the CREATE function using the cli. If you don't get an error, then you're done and ready to use the extension.

4️⃣ You can use psql to see if there's an issue.

psql -c "CREATE EXTENSION pg_uuidv7;"

It should just echo the command back to you…

CREATE EXTENSION

5️⃣ Now you can remove the directory you cloned.

cd ~/Downloads && \
rm -rf ~/Downloads/pg_uuidv7

from pg_uuidv7.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.