Skip to content
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

Question on REPLACE with trigger #4435

Closed
joel-rieke opened this issue Sep 30, 2022 · 7 comments
Closed

Question on REPLACE with trigger #4435

joel-rieke opened this issue Sep 30, 2022 · 7 comments
Labels
question Further information is requested sql Issue with SQL

Comments

@joel-rieke
Copy link

I am wondering if the REPLACE INTO query works in dolthub to create the appropriate trigger behavior (before/after DELETE then before/after INSERT). Looking at some behavior I'm not seeing some of my triggers activate. Does anyone know if this has been implemented?

@timsehn
Copy link
Sponsor Contributor

timsehn commented Sep 30, 2022

REPLACE and SELECT INTO are supported. I'm not certain about REPLACE INTO. I think it is but I'll check to confirm.

Triggers are also supported.

@timsehn timsehn added question Further information is requested sql Issue with SQL labels Sep 30, 2022
@joel-rieke
Copy link
Author

I've seen triggers activate before for other cases, but just not for REPLACE INTO. The query itself works fine, I just don't see the triggers activated.

@timsehn
Copy link
Sponsor Contributor

timsehn commented Sep 30, 2022

Repro?

@bpf120
Copy link

bpf120 commented Sep 30, 2022

Hi @joel-rieke, We'd love to learn more about your use case too. Feel free to swing by our Discord or shoot me an email if you want to share.

@timsehn
Copy link
Sponsor Contributor

timsehn commented Oct 4, 2022

I can use replace into in triggers:

$ dolt init
Successfully initialized dolt data repository.
$ dolt sql -q "create table t1 (id int, c1 int)"
$ dolt sql -q "create table t2 (id int, c1 int)"
$ dolt sql -q "create trigger repl after insert on t1 for each row replace into t2 values (new.id, new.c1)"
$ dolt sql -q "insert into t1 values (0,0)"
Query OK, 1 row affected (0.00 sec)
$ dolt sql -q "select * from t2"
+----+----+
| id | c1 |
+----+----+
| 0  | 0  |
+----+----+

$ dolt sql -q "insert into t1 values (0,1)"
Query OK, 1 row affected (0.00 sec)
$ dolt sql -q "select * from t2"           
+----+----+
| id | c1 |
+----+----+
| 0  | 1  |
| 0  | 0  |
+----+----+

Please reopen with an exact repro so we can help debug further.

@timsehn timsehn closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2022
@joel-rieke
Copy link
Author

Really slick attempt to repro, @timsehn. I forget the really cool command line for setting up tests like this sometimes. I'll try to remember this for the future. With the latest code, I'm not able to repro this particular issue anymore either.

@timsehn
Copy link
Sponsor Contributor

timsehn commented Oct 4, 2022

Dolt is cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested sql Issue with SQL
Projects
None yet
Development

No branches or pull requests

3 participants