There is another option to do it directly in db_postgres constraints "auto
detection"
https://www.postgresql.org/docs/9.1/static/catalog-pg-constraint.html
We would search the catalog :
```
select conntype from pg_constraint where conrelid = (select oid from pg_class where
relname like 'location_test') and contype = u;
select conntype from pg_constraint where conrelid = (select oid from pg_class where
relname like 'location_test') and contype = p;
```
wich would return : `location_ruid_idx_test` or `location_test_pkey`
Then we can save this in the module memory :
```struct constraint {
char *db_name;
char *db_table;
char *unique_contraint;
char *primary_key_constraint;
};
```
And use it automatically in the next queries ...
```insert into location_test (ruid, username, domain) values ('1234','jo',
'my dom') on conflict on constraint location_ruid_idx_test do update set
ruid='1234', username='jo', domain='my dom';
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1039#issuecomment-287967115