]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add SKIP LOCKED variations of sqlippool allocate_find queries as options.
authorNathan Ward <nward@braintrust.co.nz>
Fri, 11 Jan 2019 03:13:35 +0000 (16:13 +1300)
committerNathan Ward <nward@braintrust.co.nz>
Fri, 11 Jan 2019 03:13:35 +0000 (16:13 +1300)
raddb/mods-config/sql/ippool/mysql/queries.conf
raddb/mods-config/sql/ippool/oracle/queries.conf
raddb/mods-config/sql/ippool/postgresql/queries.conf

index 157ea96738ff5243d0cd1bcc8ef10ee6ddc8a7f5..804a05c29ec4aacbce02c9cfb0534b5c051cfae9 100644 (file)
@@ -49,6 +49,21 @@ allocate_find = "\
        LIMIT 1 \
        FOR UPDATE"
 
+#
+#  The above query again, but with SKIP LOCKED. This requires MySQL >= 8.0.1,
+#  and InnoDB.
+#
+#allocate_find = "\
+#      SELECT framedipaddress FROM ${ippool_table} \
+#      WHERE pool_name = '%{control:${pool_name}}' \
+#      AND (expiry_time < NOW() OR expiry_time IS NULL) \
+#      ORDER BY \
+#              (username <> '%{User-Name}'), \
+#              (callingstationid <> '%{Calling-Station-Id}'), \
+#              expiry_time \
+#      LIMIT 1 \
+#      FOR UPDATE SKIP LOCKED"
+
 #
 #  If you prefer to allocate a random IP address every time, use this query instead.
 #
@@ -61,6 +76,19 @@ allocate_find = "\
 #      LIMIT 1 \
 #      FOR UPDATE"
 
+#
+#  The above query again, but with SKIP LOCKED. This requires MySQL >= 8.0.1,
+#  and InnoDB.
+#
+#allocate_find = "\
+#      SELECT framedipaddress FROM ${ippool_table} \
+#      WHERE pool_name = '%{control:${pool_name}}' \
+#      AND expiry_time IS NULL \
+#      ORDER BY \
+#              RAND() \
+#      LIMIT 1 \
+#      FOR UPDATE SKIP LOCKED"
+
 #
 #  If an IP could not be allocated, check to see if the pool exists or not
 #  This allows the module to differentiate between a full pool and no pool
index 8a94e369c906f38adbdbc3e67e9d798bfee36337..6f08bfad2ee5aab455fc3f66a2b76f7cc58416d2 100644 (file)
@@ -28,6 +28,22 @@ allocate_find = "\
                expiry_time \
        FOR UPDATE"
 
+#
+#  The above query again, but with SKIP LOCKED. This requires Oracle > 11g.
+#  It may work in 9i and 10g, but is not documented, so YMMV.
+#
+#allocate_find = "\
+#      SELECT framedipaddress \
+#      FROM ${ippool_table} \
+#      WHERE pool_name = '%{control:${pool_name}}' \
+#      AND expiry_time < current_timestamp \
+#      AND rownum <= 1 \
+#      ORDER BY \
+#              (username <> '%{SQL-User-Name}'), \
+#              (callingstationid <> '%{Calling-Station-Id}'), \
+#              expiry_time \
+#      FOR UPDATE SKIP LOCKED"
+
 #
 #  This function is available if you want to use multiple pools
 #
@@ -47,6 +63,19 @@ allocate_find = "\
 #      ORDER BY RANDOM() \
 #      FOR UPDATE"
 
+#
+#  The above query again, but with SKIP LOCKED. This requires Oracle > 11g.
+#  It may work in 9i and 10g, but is not documented, so YMMV.
+#
+#allocate_find = "\
+#      SELECT framedipaddress \
+#      FROM ${ippool_table} \
+#      WHERE pool_name = '%{control:${pool_name}}' \
+#      AND expiry_time < current_timestamp \
+#      AND rownum <= 1 \
+#      ORDER BY RANDOM() \
+#      FOR UPDATE SKIP LOCKED"
+
 #
 #  If an IP could not be allocated, check to see whether the pool exists or not
 #  This allows the module to differentiate between a full pool and no pool
index 818562498895b54522b22dc66f53459ef4cea4d9..f7942072cb2033489b21186059f6df898076c47f 100644 (file)
@@ -21,6 +21,21 @@ allocate_find = "\
        LIMIT 1 \
        FOR UPDATE"
 
+#
+#  The above query again, but with SKIP LOCKED. This requires PostgreSQL >= 9.5.
+#
+#allocate_find = "\
+#      SELECT framedipaddress \
+#      FROM ${ippool_table} \
+#      WHERE pool_name = '%{control:${pool_name}}' \
+#      AND expiry_time < 'now'::timestamp(0) \
+#      ORDER BY \
+#              (username <> '%{SQL-User-Name}'), \
+#              (callingstationid <> '%{Calling-Station-Id}'), \
+#              expiry_time \
+#      LIMIT 1 \
+#      FOR UPDATE SKIP LOCKED"
+
 #
 #  If you prefer to allocate a random IP address every time, use this query instead
 #
@@ -31,6 +46,16 @@ allocate_find = "\
        LIMIT 1 \
        FOR UPDATE"
 
+#
+#  The above query again, but with SKIP LOCKED. This requires PostgreSQL >= 9.5.
+#
+#allocate_find = "\
+#      SELECT framedipaddress FROM ${ippool_table} \
+#      WHERE pool_name = '%{control:${pool_name}}' AND expiry_time < 'now'::timestamp(0) \
+#      ORDER BY RANDOM() \
+#      LIMIT 1 \
+#      FOR UPDATE SKIP LOCKED"
+
 #
 #  If an IP could not be allocated, check to see whether the pool exists or not
 #  This allows the module to differentiate between a full pool and no pool