microo8 / plgo

easily create postgresql extensions in golang; moved to gitlab.com/microo8/plgo
292 stars 23 forks source link

Can't make trigger #6

Closed remotejob closed 6 years ago

remotejob commented 6 years ago

I try use yours example on VERSION = PostgreSQL 9.6.2 All function work correctly a part of CreatedTimeTrigger()

`CREATE TRIGGER gettrigger BEFORE INSERT OR UPDATE OR DELETE ON urls FOR EACH ROW EXECUTE PROCEDURE CreatedTimeTrigger();

CREATE TRIGGER so looks OK `

` func CreatedTimeTrigger(td plgo.TriggerData) plgo.TriggerRow {

// td.NewRow.Set(4, time.Now()) //set the 4th column to now()

// td.NewRow.Set(1, "trig")

// log.Println("trigget start")

return td.NewRow //return the new modified row

} But after INSERT INTO urls VALUES ('333llssl');`

server closed the connection unexpectedly

microo8 commented 6 years ago

This will have nothing to do with your issue but, what go version are you using?

I've didn't make anything with plgo in a while, and now I cannot build the shared objects file with go 1.10, because it don't want to accept the -shared flag in LDFLAGS:

invalid flag in #cgo LDFLAGS: -shared

I'm guessing it is this issue.

remotejob commented 6 years ago

I am still --> on go version go1.9.2 linux/amd64 I try use as well use https://github.com/rapidloop/ptgo/issues/2 but I have isssue

microo8 commented 6 years ago

The trigger data (new and old row) wasn't acquired as it has to be, so I've fixed it. Try to update plgo and build your trigger again. Close the issue if it is OK.

Also fixed the LDFLAGS problem :)