forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit02b8048
committed
psql: improve tab-complete's handling of variant SQL names.
This patch improves tab completion's ability to deal withvalid variant spellings of SQL identifiers. Notably:* Unquoted upper-case identifiers are now downcased as the backendwould do, allowing them to be completed correctly.* Tab completion can now match identifiers that are quoted eventhough they don't need to be; for example "f<TAB> now completesto "foo" if that's the only available name. Previously, onlynames that require quotes would be offered.* Schema-qualified identifiers are now supported where SQL syntaxallows it; many lesser-used completion rules neglected this.* Completion operations that refer back to some previously-typedname (for example, to complete names of columns belonging to apreviously-mentioned table) now allow variant spellings of theprevious name too.In addition, performance of tab completion queries has beenimproved for databases containing many objects, althoughyou'd only be likely to notice with a heavily-loaded server.Authors of future tab-completion patches should note that thiscommit changes many details about how tab completion queriesmust be written:* Tab completion queries now deal in raw object names; do notuse quote_ident().* The name-matching restriction in a query must now be writtenas "outputcol LIKE '%s'", not "substring(outputcol,1,%d)='%s'".* The SchemaQuery mechanism has been extended so that it canhandle queries that refer back to a previous name. Most completionqueries that do that should be converted to SchemaQuery form.Only consider using a literal query if the previous name cannever be schema-qualified. Don't use a literal query if thename-to-be-completed can validly be schema-qualified, either.* Use set_completion_reference() to specify which word is the previousname to consider, for either a SchemaQuery or a literal query.* If you want to offer some keywords in addition to a query result(for example, offer COLUMN in addition to column names after"ALTER TABLE t RENAME"), do not use the old hack of tacking thekeywords on with UNION. Instead use the new QUERY_PLUS macrosto write such keywords separately from the query proper. The"addon" macro arguments that used to be used for this purposeare gone.* If your query returns something that's not a SQL identifier(such as an attribute number or enum label), use the newQUERY_VERBATIM macros to prevent the result from incorrectlygetting double-quoted. You may still need to use quote_literalin such a query, too.Tom Lane and Haiying TangDiscussion:https://postgr.es/m/a63cbd45e3884cf9b3961c2a6a95dcb7@G08CNEXMBPEKD05.g08.fujitsu.local1 parentb3d7d6e commit02b8048
File tree
3 files changed
+1613
-949
lines changed- doc/src/sgml/ref
- src/bin/psql
- t
3 files changed
+1613
-949
lines changedLines changed: 51 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
318 | 318 |
| |
319 | 319 |
| |
320 | 320 |
| |
321 |
| - | |
322 |
| - | |
323 |
| - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
324 | 324 |
| |
325 | 325 |
| |
326 | 326 |
| |
| |||
4562 | 4562 |
| |
4563 | 4563 |
| |
4564 | 4564 |
| |
4565 |
| - | |
| 4565 | + | |
4566 | 4566 |
| |
4567 | 4567 |
| |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
| 4575 | + | |
| 4576 | + | |
| 4577 | + | |
| 4578 | + | |
| 4579 | + | |
| 4580 | + | |
| 4581 | + | |
| 4582 | + | |
| 4583 | + | |
| 4584 | + | |
| 4585 | + | |
| 4586 | + | |
| 4587 | + | |
| 4588 | + | |
| 4589 | + | |
| 4590 | + | |
| 4591 | + | |
| 4592 | + | |
| 4593 | + | |
| 4594 | + | |
| 4595 | + | |
| 4596 | + | |
| 4597 | + | |
4568 | 4598 |
| |
4569 |
| - | |
4570 |
| - | |
4571 |
| - | |
4572 |
| - | |
4573 |
| - | |
4574 |
| - | |
4575 |
| - | |
4576 |
| - | |
4577 |
| - | |
4578 |
| - | |
4579 |
| - | |
| 4599 | + | |
| 4600 | + | |
| 4601 | + | |
| 4602 | + | |
| 4603 | + | |
| 4604 | + | |
| 4605 | + | |
4580 | 4606 |
| |
4581 | 4607 |
| |
4582 | 4608 |
| |
| |||
4587 | 4613 |
| |
4588 | 4614 |
| |
4589 | 4615 |
| |
| 4616 | + | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
| 4624 | + | |
| 4625 | + | |
4590 | 4626 |
| |
4591 | 4627 |
| |
4592 | 4628 |
| |
|
Lines changed: 94 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
40 | 40 |
| |
41 | 41 |
| |
42 | 42 |
| |
43 |
| - | |
| 43 | + | |
44 | 44 |
| |
45 | 45 |
| |
46 |
| - | |
| 46 | + | |
| 47 | + | |
47 | 48 |
| |
48 | 49 |
| |
49 | 50 |
| |
| |||
176 | 177 |
| |
177 | 178 |
| |
178 | 179 |
| |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
179 | 212 |
| |
180 | 213 |
| |
181 | 214 |
| |
182 | 215 |
| |
183 | 216 |
| |
184 | 217 |
| |
185 | 218 |
| |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
186 | 261 |
| |
187 | 262 |
| |
188 | 263 |
| |
| |||
234 | 309 |
| |
235 | 310 |
| |
236 | 311 |
| |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
237 | 329 |
| |
238 | 330 |
| |
239 | 331 |
| |
|
0 commit comments
Comments
(0)