Last insert id in pg

- last_insert_id is failed when using PostgreSQL and specify $table_name
- add testcode