From: Jakub Jirutka Date: Thu, 20 Feb 2020 11:12:09 +0000 (+0100) Subject: specify name for pkey constraint and use it in query for cui postgresql X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b0ca6366da2bf27e609ce3dc7627c7bc658c261;p=thirdparty%2Ffreeradius-server.git specify name for pkey constraint and use it in query for cui postgresql --- diff --git a/raddb/mods-config/sql/cui/postgresql/queries.conf b/raddb/mods-config/sql/cui/postgresql/queries.conf index 15e5f2dc4cc..cffd99e3e7c 100644 --- a/raddb/mods-config/sql/cui/postgresql/queries.conf +++ b/raddb/mods-config/sql/cui/postgresql/queries.conf @@ -14,7 +14,7 @@ post-auth { VALUES \ ('%{%{Packet-Src-IPv6-Address}:-%{Packet-Src-IP-Address}}', '%{Calling-Station-Id}', \ '%{User-Name}', '%{reply:Chargeable-User-Identity}') \ - ON CONFLICT (clientipaddress, callingstationid, username) \ + ON CONFLICT ON CONSTRAINT ${..cui_table}_pkey \ DO UPDATE SET cui = EXCLUDED.cui, lastaccounting = '-infinity'::timestamp" } diff --git a/raddb/mods-config/sql/cui/postgresql/schema.sql b/raddb/mods-config/sql/cui/postgresql/schema.sql index f223d0cc981..bc4129770e8 100644 --- a/raddb/mods-config/sql/cui/postgresql/schema.sql +++ b/raddb/mods-config/sql/cui/postgresql/schema.sql @@ -1,3 +1,5 @@ +-- Table for Chargeable-User-Identity. +-- Note: If you change name of the table, change name of cui_pkey as well. CREATE TABLE cui ( clientipaddress inet NOT NULL DEFAULT '0.0.0.0', callingstationid text NOT NULL DEFAULT '', @@ -5,7 +7,7 @@ CREATE TABLE cui ( cui text NOT NULL DEFAULT '', creationdate timestamp with time zone NOT NULL DEFAULT now(), lastaccounting timestamp with time zone NOT NULL DEFAULT '-infinity'::timestamp, - PRIMARY KEY (username, clientipaddress, callingstationid) + CONSTRAINT cui_pkey PRIMARY KEY (username, clientipaddress, callingstationid) ); /* This is an old workaround for upsert which was needed prior PostgreSQL 9.5.