Using CRDTs v5.6
Using CRDTs in tables
Permissions required
PGD CRDTs requires usage access to CRDT types. Therefore, any user needing to access CRDT types must have at least the bdr_application role assigned to them.
To use CRDTs, you need to use a particular data type in CREATE/ALTER TABLE rather than standard built-in data types such as integer
. For example, consider the following table with one regular integer counter and a single row:
Non-CRDT example
CREATE TABLE non_crdt_example ( id integer PRIMARY KEY, counter integer NOT NULL DEFAULT 0 ); INSERT INTO non_crdt_example (id) VALUES (1);
Suppose you issue the following SQL on two different nodes at same time:
UPDATE non_crdt_example SET counter = counter + 1 -- "reflexive" update WHERE id = 1;
After both updates are applied, you can see the resulting values using this query: