Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii framework and PostgreSQL partitioned table - 0 rows affected

  • PostgreSQL 9.1
  • Partitioned tables
    • tbl_master
    • tbl_slave1 (iherits master)
    • tbl_slave2 (iherits master)
  • Yii framework 1.1.10

Maybe someone can chare his expierience about Yii + PostgreSQL partitioned table. PostgreSQL part with partitioned tables, checks and triggers works great but i can't get Yii to love these tables..

Problem is that on insert into partitioned table PostgreSQL gives 0 rows affected and i can't figure out how to workaround this. Yii model thinks new record is not saved (but it is) and $Model->save(); return false and so afterSave() is not working and so on.

All other methods as ->find() or ->findAll() are working well. Even if i update just now saved record throw yii all is ok and i get executed afterSave as well. Problem is only with ->save() part. Update working because i have trigger only on inserting new rows.

I'm using trigger to split new data by tables. Maybe i need to modify trigger so postgres know what i'm forwarding new data to slave table not master?

One more thing. I added primary key to master table so Yii Model (CActiveRecord) don't throw errors about table without pk. I know documentation does not suggest this, but i got it working this way. Just trying to give big picture of my situation.

Thanks!

like image 367
briiC Avatar asked May 10 '12 12:05

briiC


1 Answers

You could try using rules as an alternative. As it rewrites the query I would expect it to return the correct number of affected rows. While triggers are in most cases better I think rules are better then inserting data in the master table and having to delete it again.

This is covered in paragraph 5.9.5 on this manual page.

like image 161
Eelke Avatar answered Nov 15 '22 06:11

Eelke