PostgreSQL: Limit rows in data manipulation without unique key

This commit is contained in:
Jakub Vrana
2018-02-01 16:56:50 +01:00
parent 763e66a148
commit 52d98e16fa
9 changed files with 15 additions and 13 deletions

View File

@@ -226,8 +226,8 @@ if (isset($_GET["pgsql"])) {
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
}
function limit1($query, $where) {
return " $query$where";
function limit1($table, $query, $where) {
return (preg_match('~^INTO~', $query) ? limit($query, $where, 1) : "$query WHERE ctid = (SELECT ctid FROM " . table($table) . "$where LIMIT 1)");
}
function db_collation($db, $collations) {