Commit 2b759bf
Merge #156600
156600: sql: introduce a non-experimental version of SHOW FINGERPRINTS r=jeffswenson a=mw5h
In 2017, we implemented SHOW EXPERIMENTAL_FINGERPRINTS, which provides
FNV fingerprints of all the indexes in a table. The implementation of
this command involved casting all the columns in each index to either a
string or bytes value so that it could be consumed by fnv64(). This
meant that values that cast to the same string value were not
diffentiated by the hash function. For this reason, the feature was
deemed "experimental" and not for use by users.
SHOW EXPERIMENTAL_FINGERPRINTS was useful enough to find its way into
various DR and CDC tests to determine whether or not data was preserved
correctly.
This patch introduces SHOW FINGERPRINTS, which uses
crdb_internal.datums_to_bytes() to transform the input data into encoded
bytes for use by fnv64(). This version of fingerprinting should be more
sensitive to changes in data. Now, data that prints the same won't
necessarily produce the same hash. Additionally, adding NULL values will
impact the hash as well. FNV was originally chosen for SHOW
EXPERIMENTAL_FINGERPRINTS and not changed by this patch because it's
approximately four times as fast as SHA256/512 and cryptographic
security is not required by this particular use case.
This patch also changes the output to be a 0-padded hexidecimal
representation of the hash instead of an integer.
No changes to external references to SHOW EXPERIMENTAL_FINGERPRINTS are
made here so that other groups can migrate at their own pace.
Epic: [CRDB-49047](https://cockroachlabs.atlassian.net/browse/CRDB-49047)
Release note (sql change): We have introduced the "SHOW FINGERPRINTS FOR
TABLE" SQL command, which produces a FNV hash of each index a table. FNV
is used here for performance reasons.
Co-authored-by: Matt White <[email protected]>File tree
8 files changed
+375
-70
lines changed- docs/generated/sql/bnf
- pkg
- crosscluster/logical
- sql
- logictest/testdata/logic_test
- parser
- testdata
- sem/tree
8 files changed
+375
-70
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1232 | 1232 | | |
1233 | 1233 | | |
1234 | 1234 | | |
| 1235 | + | |
1235 | 1236 | | |
1236 | 1237 | | |
1237 | 1238 | | |
| |||
4174 | 4175 | | |
4175 | 4176 | | |
4176 | 4177 | | |
| 4178 | + | |
4177 | 4179 | | |
4178 | 4180 | | |
4179 | 4181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1652 | 1652 | | |
1653 | 1653 | | |
1654 | 1654 | | |
1655 | | - | |
| 1655 | + | |
1656 | 1656 | | |
1657 | | - | |
| 1657 | + | |
1658 | 1658 | | |
1659 | 1659 | | |
1660 | 1660 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| |||
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
21 | 40 | | |
22 | 41 | | |
23 | 42 | | |
24 | 43 | | |
25 | 44 | | |
26 | 45 | | |
27 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
28 | 53 | | |
29 | 54 | | |
30 | 55 | | |
31 | 56 | | |
32 | 57 | | |
33 | 58 | | |
34 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
35 | 66 | | |
36 | 67 | | |
37 | 68 | | |
38 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
39 | 73 | | |
40 | 74 | | |
41 | 75 | | |
42 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
43 | 80 | | |
44 | 81 | | |
45 | 82 | | |
| |||
52 | 89 | | |
53 | 90 | | |
54 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
55 | 98 | | |
56 | 99 | | |
57 | 100 | | |
| |||
66 | 109 | | |
67 | 110 | | |
68 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
69 | 118 | | |
70 | 119 | | |
71 | 120 | | |
| |||
76 | 125 | | |
77 | 126 | | |
78 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
79 | 134 | | |
80 | 135 | | |
81 | 136 | | |
| |||
86 | 141 | | |
87 | 142 | | |
88 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
89 | 150 | | |
90 | 151 | | |
91 | 152 | | |
| |||
97 | 158 | | |
98 | 159 | | |
99 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
100 | 168 | | |
101 | 169 | | |
102 | 170 | | |
| |||
107 | 175 | | |
108 | 176 | | |
109 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
110 | 184 | | |
111 | 185 | | |
112 | 186 | | |
| |||
116 | 190 | | |
117 | 191 | | |
118 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
119 | 198 | | |
120 | 199 | | |
121 | 200 | | |
122 | 201 | | |
123 | 202 | | |
124 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
125 | 209 | | |
126 | 210 | | |
127 | 211 | | |
| |||
136 | 220 | | |
137 | 221 | | |
138 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
139 | 229 | | |
140 | 230 | | |
141 | 231 | | |
| |||
149 | 239 | | |
150 | 240 | | |
151 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
152 | 247 | | |
153 | 248 | | |
154 | 249 | | |
| |||
158 | 253 | | |
159 | 254 | | |
160 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
161 | 261 | | |
162 | 262 | | |
163 | 263 | | |
| |||
173 | 273 | | |
174 | 274 | | |
175 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
0 commit comments