- Notifications
You must be signed in to change notification settings - Fork5
Commit3350b37

Neil Conway
This patch optimizes the md5_text() function (which is used to
implement the md5() SQL-level function). The old code did thefollowing:1. de-toast the datum2. convert it to a cstring via textout()3. get the length of the cstring via strlen()Since we are treating the datum context as a blob of binary data,the latter two steps are unnecessary. Once the data has beendetoasted, we can just use it as-is, and derive its length fromthe varlena metadata.This patch improves some run-of-the-mill md5() computations byjust under 10% in my limited tests, and passes the regression tests.I also noticed that md5_text() wasn't checking the return valueof md5_hash(); encountering OOM at precisely the right momentcould result in returning a random md5 hash. This patch correctsthat. A better fix would be to make md5_hash() only return onsuccess (and/or allocate via palloc()), but since it's used inthe frontend as well I don't see an easy way to do that.1 parentb9a87e5 commit3350b37
2 files changed
+13
-7
lines changedLines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
17 |
| - | |
| 17 | + | |
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| |||
289 | 289 |
| |
290 | 290 |
| |
291 | 291 |
| |
292 |
| - | |
293 |
| - | |
| 292 | + | |
| 293 | + | |
294 | 294 |
| |
295 | 295 |
| |
296 | 296 |
| |
|
Lines changed: 10 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
2310 | 2310 |
| |
2311 | 2311 |
| |
2312 | 2312 |
| |
2313 |
| - | |
2314 |
| - | |
| 2313 | + | |
| 2314 | + | |
2315 | 2315 |
| |
2316 | 2316 |
| |
2317 | 2317 |
| |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
2318 | 2321 |
| |
2319 | 2322 |
| |
2320 | 2323 |
| |
2321 | 2324 |
| |
2322 |
| - | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
2323 | 2329 |
| |
2324 | 2330 |
| |
2325 | 2331 |
| |
|
0 commit comments
Comments
(0)