New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consider adding hash operator and commutator #13
Comments
Hello, We appreciate your enthusiasm to contribute to this open-source project and to help make it better. Unfortunately, there's not enough information in your bug report for me to understand what this issue is about. Can you please add clear-cut steps on how to reproduce this error? To make effective usage of the maintainers' time, we will be closing this issue until further information as requested is provided. Thanks |
I received a similar error when trying to migrate from a simpler function based ulid generator to this extension (very excited to use it by the way). Personally, I was getting an error of Very simple tables, creating a join between them causes an error of Open a SQL script to a postgres database with the ulid extension installed (will add steps if this is necessary, but I feel you already have a postgres instance with this available) Run the following SQL CREATE TABLE foo (
id ulid DEFAULT gen_ulid()
,data TEXT
);
CREATE TABLE foobar (
id ulid DEFAULT gen_ulid()
,foo_id ulid
);
INSERT INTO foo
(data)
VALUES
('hello')
,('world');
INSERT INTO foobar
(foo_id)
VALUES
((SELECT id FROM foo WHERE data = 'hello'))
,((SELECT id FROM foo WHERE data = 'world'));
SELECT
foobar.id
, foo.data
FROM foobar
JOIN foo ON foobar.foo_id = foo.id; Notice the error |
for my case it is many-to-many relationship table ReproducingCREATE EXTENSION ulid;
CREATE TABLE foo (
id ulid DEFAULT gen_ulid() PRIMARY KEY
,data TEXT
);
CREATE TABLE bar (
id ulid DEFAULT gen_ulid() PRIMARY KEY
,data TEXT
);
CREATE TABLE foo_bar_mapping (
foo_id ulid,
bar_id ulid,
PRIMARY KEY (foo_id, bar_id),
FOREIGN KEY (foo_id) REFERENCES foo(id),
FOREIGN KEY (bar_id) REFERENCES bar(id)
);
INSERT INTO foo
(data)
VALUES
('hello')
,('world');
INSERT INTO bar
(data)
VALUES
('alpha')
,('beta');
INSERT INTO foo_bar_mapping
(foo_id, bar_id)
VALUES
((SELECT id FROM foo WHERE data = 'hello'), (SELECT id FROM bar WHERE data = 'alpha')),
((SELECT id FROM foo WHERE data = 'world'), (SELECT id FROM bar WHERE data = 'beta'));
SELECT
f.id as foo_id
, b.id as bar_id
, f.data as foo_data
, b.data as bar_data
FROM foo_bar_mapping fbm
JOIN foo f ON fbm.foo_id = f.id
JOIN bar b ON fbm.bar_id = b.id;
It will show error
my postgres verision is 14 |
I'm not super familiar with rust, but I added the above snippets to the man branches tests locally, and it looks like thanks to this commit (relevant merged PR), joins are working as expected, we'd just either need a new release, or to build the extension from the source ourselves |
Yup, I am waiting on adding tests to the code before releasing it. I also need to look into commutator. Os is it only an issue with postgis? |
I'll see if I can't create some sort of minimum reproduction for that too. I think it has to do with casting existing ulids that are from a text format to the |
Repoduce bycontinue from my last example.
Error
|
Looks like the same PR fixed that too. I can make a PR that adds my local tests if you'd like. I'm sure the formatting is off, but at the very least it could be a head start for you :) |
Adds test cases for simple foreign keys, many to many tables, and joins between tables. This tests the functionality of the commutator and hash functions for the `ulid` type in postgres. ref: [pksunkara#13][issue] [issue]: pksunkara#13
Adds test cases for simple foreign keys, many to many tables, and joins between tables. This tests the functionality of the commutator and hash functions for the `ulid` type in postgres. ref: [pksunkara#13][issue] [issue]: pksunkara#13 Signed-off-by: Jay McDoniel <jmcdo29@gmail.com>
Adds test cases for simple foreign keys, many to many tables, and joins between tables. This tests the functionality of the commutator and hash functions for the `ulid` type in postgres. ref: [pksunkara#13][issue] [issue]: pksunkara#13
Thanks, I will be able to clean it up and release it early next week since I am going to be a bit busy until then. |
I am also experiencing issues where joins don't work with mysterious errors I don't fully understand,
and
Is this going to be released soon? as it is blocking us from proceeding, might need to rip out |
Yup, as mentioned in #16 (comment), just waiting for a release in the underlying dependency. |
@pksunkara looks like the underlying dependency has been released! Looking forward to this being bumped too. https://github.com/pgcentralfoundation/pgrx/releases/tag/v0.10.0-beta.4 |
All problems should be resolved as-of #18 (which currently doesn't include regression tests, isn't officially accepted yet, doesn't have prebuilt releases, et cetera). The patched Dockerfile in my branch at https://github.com/workingjubilee/pgx_ulid/tree/use-pgrx-0.10.0-beta.4 should be good enough to build this extension if one cannot wait for the extension developer's official release. Or, if you have an available recent Rust compiler, using Regarding the errors:
These errors are essentially saying "this set of operators, which Postgres has assigned the object ID #16536, cannot support this query". I say "set" because it may be referencing an operator, an operator class(!), or an operator family(!!), and I can't automatically tell which is which because those errors have like 4 different locations in the Postgres source. |
Can confirm my migrations work as intended migrating existing data from a text ulid to this extension! Thank you all for the work on this! |
I tried updating the version of My Postgres ARG PG_MAJOR
FROM postgres:${PG_MAJOR}
ARG PG_MAJOR
ARG PGX_ULID_VERSION
WORKDIR /app
RUN apt-get update && apt-get install -y wget
# Download the pre-built binary from GitHub releases
RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
wget https://github.com/pksunkara/pgx_ulid/releases/download/v${PGX_ULID_VERSION}/pgx_ulid-v${PGX_ULID_VERSION}-pg${PG_MAJOR}-amd64-linux-gnu.deb; \
else \
wget https://github.com/pksunkara/pgx_ulid/releases/download/v${PGX_ULID_VERSION}/pgx_ulid-v${PGX_ULID_VERSION}-pg${PG_MAJOR}-arm64-linux-gnu.deb; \
fi
# Install the binary using dpkg
RUN dpkg -i pgx_ulid-v${PGX_ULID_VERSION}-pg${PG_MAJOR}-*-linux-gnu.deb
# Cleanup the .deb file
RUN rm pgx_ulid-v${PGX_ULID_VERSION}-pg${PG_MAJOR}-*-linux-gnu.deb
# Reset the Docker image's command back to the original entrypoint script
CMD ["postgres"] with Any help would be appreciated! |
@osdiab Are you doing this in a fresh database which has never had a prior version of pgx_ulid installed, or are you doing this in your existing database? My instincts say there should be a different OID this time for the operator. There is a possibility that the old operator definition is still being used, despite the new extension being installed, and that the extension version number is a red herring. What DDL commands did you run after replacing the binary? |
It’s the existing database (locally); I just replaced the version of pgx_ulid installed in the Docker image but kept the same volume. I didn’t run any SQL commands. |
...so this is a bit of a shot in the dark but try running ALTER EXTENSION ulid UPDATE TO '0.1.2'; |
Message ID: ***@***.***>I ended up
just not using ulid anymore hence the delay but I tried your suggestion on
the volume I kept - got this error:
ERROR: extension "ulid" has no update path from version "0.1.1" to version
"0.1.2"
Hope this helps!
|
Hey, would you be able to drop the extension completely and recreate it? |
@osdiab I am not surprised it failed, but unfortunately, that confirms what I thought. Your Postgres was never actually on 0.1.2. It is not enough to reinstall the binary. You must also run the SQL command to actually update the database, because extensions are not just binaries, they are also sequences of SQL commands that inform Postgres about how to use the binary code. Postico was providing you its idea of what it saw, not showing you what Postgres saw. |
I'm experiencing some difficulties related to queries, potentially tied to missing operations on the ULID type.
Here are the error messages I've been encountering:
More info on this error here
More info on this error here
If anyone has suggestions or insights into these errors, I'd greatly appreciate your help.
The text was updated successfully, but these errors were encountered: