Révision 5587145e
Ajouté par Assos Assos il y a presque 7 ans
drupal7/includes/database/pgsql/database.inc | ||
---|---|---|
11 | 11 |
*/ |
12 | 12 |
|
13 | 13 |
/** |
14 |
* The name by which to obtain a lock for retrive the next insert id.
|
|
14 |
* The name by which to obtain a lock for retrieving the next insert id.
|
|
15 | 15 |
*/ |
16 | 16 |
define('POSTGRESQL_NEXTID_LOCK', 1000); |
17 | 17 |
|
... | ... | |
55 | 55 |
$connection_options['pdo'] += array( |
56 | 56 |
// Prepared statements are most effective for performance when queries |
57 | 57 |
// are recycled (used several times). However, if they are not re-used, |
58 |
// prepared statements become ineffecient. Since most of Drupal's
|
|
58 |
// prepared statements become inefficient. Since most of Drupal's
|
|
59 | 59 |
// prepared queries are not re-used, it should be faster to emulate |
60 | 60 |
// the preparation than to actually ready statements for re-use. If in |
61 | 61 |
// doubt, reset to FALSE and measure performance. |
... | ... | |
175 | 175 |
} |
176 | 176 |
|
177 | 177 |
/** |
178 |
* Retrive a the next id in a sequence.
|
|
178 |
* Retrieve the next id in a sequence.
|
|
179 | 179 |
* |
180 | 180 |
* PostgreSQL has built in sequences. We'll use these instead of inserting |
181 | 181 |
* and updating a sequences table. |
182 | 182 |
*/ |
183 | 183 |
public function nextId($existing = 0) { |
184 | 184 |
|
185 |
// Retrive the name of the sequence. This information cannot be cached |
|
185 |
// Retrieve the name of the sequence. This information cannot be cached
|
|
186 | 186 |
// because the prefix may change, for example, like it does in simpletests. |
187 | 187 |
$sequence_name = $this->makeSequenceName('sequences', 'value'); |
188 | 188 |
|
... | ... | |
194 | 194 |
} |
195 | 195 |
|
196 | 196 |
// PostgreSQL advisory locks are simply locks to be used by an |
197 |
// application such as Drupal. This will prevent other Drupal proccesses
|
|
197 |
// application such as Drupal. This will prevent other Drupal processes |
|
198 | 198 |
// from altering the sequence while we are. |
199 | 199 |
$this->query("SELECT pg_advisory_lock(" . POSTGRESQL_NEXTID_LOCK . ")"); |
200 | 200 |
|
... | ... | |
209 | 209 |
// Reset the sequence to a higher value than the existing id. |
210 | 210 |
$this->query("ALTER SEQUENCE " . $sequence_name . " RESTART WITH " . ($existing + 1)); |
211 | 211 |
|
212 |
// Retrive the next id. We know this will be as high as we want it. |
|
212 |
// Retrieve the next id. We know this will be as high as we want it.
|
|
213 | 213 |
$id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField(); |
214 | 214 |
|
215 | 215 |
$this->query("SELECT pg_advisory_unlock(" . POSTGRESQL_NEXTID_LOCK . ")"); |
Formats disponibles : Unified diff
Update to 7.56