-
Notifications
You must be signed in to change notification settings - Fork 215
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
fix: remove foreign key, make trigger handle deletes #485
base: main
Are you sure you want to change the base?
Conversation
2f3cf22
to
b4ccdc1
Compare
3e3b196
to
1293d44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
update ai.vectorizer | ||
set config = jsonb_set(config, '{version}', format('"%s"', _new_version)::jsonb) | ||
where id = _vec.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make sure we don't have any other config upgrades in this release or this may cause the other(s) to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if they rely on the version being pre 0.8.1 right? Or is there another concern, I don't understand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just mean if we have a second upgrade like this in the same release that this one goes out in, then we may have an issue because the other upgrade would also be looking for vectorizers with version < 0.8.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
@@ -126,7 +126,6 @@ begin | |||
, chunk text not null | |||
, embedding @extschema:[email protected](%L) storage main not null | |||
, unique (%s, chunk_seq) | |||
, foreign key (%s) references %I.%I (%s) on delete cascade |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source_schema
and source_table
parameters are no longer required/used.
|
||
elsif (TG_LEVEL = 'STATEMENT') then | ||
if (TG_OP = 'TRUNCATE') then | ||
execute format('truncate table %I.%I', '$TARGET_SCHEMA$', '$TARGET_TABLE$'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
truncate the queue table too
|
||
return _func_def; | ||
end; | ||
$func$ language plpgsql stable security invoker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$func$ language plpgsql stable security invoker | |
$func$ language plpgsql immutable security invoker |
); | ||
|
||
execute format( | ||
'create trigger %I after insert or update or delete on %I.%I for each row execute function ai.%I()', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ai
-> queue_schema
execute format( | ||
'create trigger %I after truncate on %I.%I for each statement execute function ai.%I()', | ||
format('%s_truncate',_vec.trigger_name) , _vec.source_schema, _vec.source_table, _vec.trigger_name | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ai
-> queue_schema
execute format( | ||
'alter extension ai drop function ai.%I()', | ||
_vec.trigger_name | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ai
-> queue_schema
update ai.vectorizer | ||
set config = jsonb_set(config, '{version}', format('"%s"', _new_version)::jsonb) | ||
where id = _vec.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just mean if we have a second upgrade like this in the same release that this one goes out in, then we may have an issue because the other upgrade would also be looking for vectorizers with version < 0.8.1
FROM ai.vectorizer v | ||
LOOP | ||
-- Find the foreign key constraint for this vectorizer's store table | ||
SELECT conname INTO _constraint_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in theory there could be multiple foreign key constraints here, but this would only happen if the users did so manually, and that would be very weird. so, i'm okay with the assumption
No description provided.