-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathdbext.txt
More file actions
3233 lines (2842 loc) · 142 KB
/
dbext.txt
File metadata and controls
3233 lines (2842 loc) · 142 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
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
212
213
214
215
216
217
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*dbext.txt* For Vim version 7.0. Last change: 2010 Jul 15
VIM REFERENCE MANUAL
by
David Fishburn <dfishburn dot vim at gmail dot com>
Peter Bagyinszki <petike1 at dpg dot hu>
Database extension plugin (dbext.vim) manual
dbext.vim version 12.00
For instructions on installing this file, type
:help add-local-help
|add-local-help| inside Vim.
Homepage: http://vim.sourceforge.net/script.php?script_id=356
*dbext* *dbext.vim* *db_ext* *db_ext.vim* *database-extension* *pgsql* *mysql*
*asa* *ase* *ingres* *interbase* *sqlite* *sqlsrv* *ora* *oracle*
*db2* *DBI* *ODBC* *sqlanywhere* *firebird*
1. Getting Started |dbext-getting-started|
2. Whats New |dbext-new|
3. Overview |dbext-overview|
4. Installation |dbext-install|
5. Configuration |dbext-configure|
5.1 Displaying Results |dbext-configure-results|
5.2 Script Variables |dbext-configure-variables|
5.3 Database Specific Options |dbext-configure-options|
5.4 DB2 Modes |dbext-configure-db2|
5.5 DBI Installation |dbext-configure-dbi|
6. Mappings and commands |dbext-mappings|
7. Adding new database types |dbext-newdb|
8. Prompting for input parameters |dbext-prompting|
9. Setting up connection information |dbext-connect|
9.1 Connection Parameters |dbext-connect-parameters|
9.2 Prompting for Parameters |dbext-connect-prompting|
9.3 Connection profiles |dbext-connect-profiles|
9.4 Connection profile examples |dbext-connect-profiles-examples|
9.5 Connection information in modelines |dbext-connect-modelines|
9.6 Asking for connection parameters |dbext-connect-ask|
9.7 Using autocmds to setup parameters |dbext-connect-autocmd|
10. Creating mappings using dbext commands |dbext-in-mappings|
11. Object Completion |dbext-completion|
12. Listing Objects in the Database |dbext-list-objects|
13. Plugin integration |dbext-integration|
13.1 OMNI completion integration |dbext-omni-completion|
13.2 Intellisense integration |dbext-intellisense|
14. Filetype support |dbext-filetypes|
14.1 Using filetype support |dbext-filetypes-using|
14.2 Adding new filetypes |dbext-filetypes-adding|
15. Using SQL History |dbext-history|
16. Open Source |dbext-sourceforge|
17. Tutorial |dbext-tutorial|
17.1 Creating the connection |dbext-tutorial-connection|
17.2 The result buffer |dbext-tutorial-results|
17.3 Executing commands |dbext-tutorial-execute|
17.4 Selecting from tables |dbext-tutorial-select|
17.5 Describing objects |dbext-tutorial-describe|
17.6 Connection Profiles |dbext-tutorial-profile|
17.7 Login Script |dbext-tutorial-login|
17.8 Listing object |dbext-tutorial-objects|
17.9 Object Completion |dbext-tutorial-completion|
17.10 Host variable replacement |dbext-tutorial-variables|
17.11 Filetype support |dbext-tutorial-filetype|
17.12 History |dbext-tutorial-history|
17.13 DBI Tutorial |dbext-tutorial-dbi|
{Vi does not have any of this}
==============================================================================
1. Getting Started *dbext-getting-started*
If you are looking for a tutorial that will take you through the
features and the "best way" to use this plugin start here |dbext-tutorial|.
This tutorial is a must before beginning to use dbext.
If you have used dbext for a bit and want to start using some more of it's
advanced features you can read this entire document.
dbext is also integrated with the OMNI SQL Completion script which is
included in the Vim distribution. See :h |omni-sql-completion|
The sqlcomplete.vim plugin is occassionally updated before a new
release of Vim and newer versions of this file can be found here:
http://www.vim.org/scripts/script.php?script_id=1572
You can also post questions to the Vim mailing list. I routinely monitor
the list. Comments, feedback and suggestions are always welcome.
David Fishburn
==============================================================================
2. What's New *dbext-new*
Version 12.00
New Features
---------
- A number of changes around the Oracle formating instructions.
Support for packages when describing certain objects.
These changes were provided by Sergey Khorev.
- Improved the parsing of Perl strings when prompting for
variables.
- Made some additional changes to the variable_def_regex for how you
can specify it from Vim modelines and DBSetOption. This makes it
much more flexible.
Bug Fixes
---------
- If the word "profile" was used in a dbext profile name dbext would report
the error: "dbext: Profiles cannot be nested" (Chris Cierpisz).
- Corrected the regex used to find object owner names (Sergey Khorev).
Version 11.01
Bug Fixes
---------
- If a large result set is retrieved, there is a significant performance
delay which was introduced in 11.00. This was related to the new
g:dbext_rows_affected feature (Tocer).
- Error E15: Invalid expression: b:dbext_sqlvar_mv[var] is reported if
you are using saved variables and then modified the query with a new
variable. Now the saved variables are used for the known variables
and you are prompted for the unknown.
Version 11.00
New Features
------------
- When autoclose is enabled, a message is displayed indicating autoclose is
enabled. This message will now also include the number of rows affected
by the last statement (if applicable). This is available for all
database interfaces which can provide this information. Vim scripts or
mappings have access to this value by referencing the g:dbext_rows_affected
variable (Philippe Moravie).
- The Select, Update, Delete, Alter and Drop commands will now complete
table names.
- Revamped the saved variables (see |dbext-tutorial-variables|). dbext
checks your queries and will prompt for variables (see |dbext-prompting|).
dbext uses regular expressions to determine which variables should be
prompted. To see how you can easily extend the regular expressions follow
the tutorial. This replaces the previous method which was too limiting.
The new technique uses Vim's standard regular expressions. This introduces
the variable_def_regex dbext option and deprecates the variable_def dbext
option.
- With the introduction of saved variables, you are now prompted during
SQL execution to determine whether the previously saved variables
should be substituted.
Bug Fixes
---------
- If you re-sourced plugin/dbext.vim you would receive the following error:
E227: mapping already exists for <Leader>sas
- Errors were reported about undefined variable, dbext_sqlvar_temp_mv, if
executing a SQL statement directly from a filetype which was not SQL
(i.e. PHP).
- If saved variables were in use, it was possible for dbext to used the
replaced variables without the user knowing. For example stored
procedures could be created with the replaced strings instead of the
variables.
Version 10.00
New Features
------------
- Added new database support for SQL Anywhere UltraLite (11.x).
- Added new database support for Firebird (2.x).
- Added "@@variable" style to the list of bypassed variable names along
with IN, OUT, INOUT and DECLARE.
- When listing stored variables, you can now remove multiple lines
using visual mode.
- When closing the result window (using "q" or DBResultsClose) you are
intentionally returned to the buffer which opened the window
instead of allowing Vim to choose which window.
Bug Fixes
---------
- The version 9.00 release of dbext broke modeline support.
- When listing variables the following error could be reported:
E121: Undefined variable
- It was not possible to retrieve more than 500 characters from a character
or binary column in the database when using DBI or ODBC. Adding
driver_parms=LongReadLen=4096 now works correctly. You can also
change this after you are connected to the database using
DBSetOption LongReadLen=4096. Running DBListConnections will display
the current setting for each database connection currently open.
Version 9.00
New Features
------------
- Added the ability to set and store SQL variables for each buffer.
This will reduce prompting for statements which are often
re-used. Added support for listing and deleting SQL variables.
Initial prototype by Garrison Yu.
- Added option, g:dbext_default_variable_remember, to control whether
SQL variables should be stored when prompted.
- Improved the parsing of SQL statements to account for procedural
language. If a IN, OUT, INOUT or DECLARE statement is found prior
to the use of the variable, it is stored for later use. When the
variable is encountered, if the declaration was found we skip
prompting for it's value. This should reduce the number of prompts
you receive when executing SQL (i.e. Functions, Procedures, Events,
Packages and so on depending on the naming convention you use for
your variables.
- Updated the tutorial and added more links to different sections
see |dbext-tutorial-variable|
- Added VB filetype support (Garrison Yu).
- Added escaping to allow specifying an new Oracle URL syntax for
server connection parameters (Anton Sharonov).
- Renamed DBCloseResults, DBOpenResults, DBRefreshResult,
DBToggleResultsResize to DBResultsClose, DBResultsOpen,
DBResultsRefresh, DBResultsToggleResize to be more consistent.
Bug Fixes
---------
- DBextPostResult was passed in a string for the buf_nr which required
conversion if passed to Vim's builtin functions like getbuflines
(Ying Chen).
- If g:dbext_default_menu_mode was set to an invalid value an error
would occur when starting Vim.
- Renamed some of the <Plug> names so a delay of timeoutlen is avoided
when using the mappings (DBExecVisualTopXSQL, DBExecSQLUnderTopXCursor,
DBSelectFromTopXTable).
- The dbext menu item "List Connections (DBI)" did not work.
- You are often repeatedly prompted for connection information.
This change reduces the number and allows you to cancel out
of the prompt dialogs.
- Added an unconditional quit command to exit out of Oracle's
SQLPlus (Anton Sharonov).
Version 8.00
New Features
------------
- When defining a profile or running DBPromptForBufferParameters,
you can now optionally specify a file containing commands you want to
execute against the database when you first connect (James Horine).
- A new global variable, g:dbext_default_login_script_dir allows you
to override the 2 default directories which are searched for these
files.
- The dbext tutorial has been updated to demonstrate the login_script
see |dbext-tutorial-login|
- Doc update demonstrating the use of integrated logins (Daren Thomas).
- Added a new user defined autocommand dbextPreConnection which is
triggered prior to dbext connecting to the database. This allows you
to customize settings based on your buffer and environment (Tim Pope).
- Added escaping to allow specifying an new Oracle URL syntax for
server connection parameters (Anton Sharonov).
Bug Fixes
---------
- Setting LongReadLen for DBI and ODBC connections did not work.
- DBextPostResult was passed in a string for the buf_nr which required
conversion if passed to Vim's builtin functions like getbuflines
(Ying Chen).
- If g:dbext_default_menu_mode was set to an invalid value an error
would occur when starting Vim.
- Renamed some of the <Plug> names so a delay of timeoutlen is avoided
when using the mappings (DBExecVisualTopXSQL, DBExecSQLUnderTopXCursor,
DBSelectFromTopXTable).
- The dbext menu item "List Connections (DBI)" did not work.
Version 7.00
New Features
------------
- Large change between how the error handling between DBI and ODBC
connections were reported and displayed.
- Non-printable characters are now dealt with for DBI and ODBC
connections.
Bug Fixes
---------
- Using ODBC to connect to SQL Server, dbext did not handle informational
messages appropriately leading to "not connected" messages
(Albie Janse van Rensburg).
- When executing SQL if you were prompted for a variable replacement
and cancelled the query the dbext history window was displayed
instead of returning to the buffer you were editing.
Version 6.20
New Features
------------
- None
Bug Fixes
---------
- Changed the DB2 TOP X syntax (DBExecSQLTopX).
- Changed the query used to retrieve the current line for
DBExecSQLUnderCursor when no text is selected (Sergey Alekhin).
- When parsing a SQL statement for host variables it was possible
to miss excluding the INTO clause correctly (Sergey Alekhin).
Version 6.10
New Features
------------
- The result window inherits the connection parameters of the
buffer which last executed SQL (Antony Scriven). For example,
if you retrieve a list of tables, you may want to describe
a table or generate a list of columns for one of the tables.
Using the usual maps will generate the result you need without
prompting for connection parameters. This is especially useful
if you have more than 1 buffer and each buffer connects to
different databases.
- Added the ability to choose where to put the Result window.
When the window is split you can choose vertical or horizontal,
bottom or top, and choose the the width of the window for
horizontal switches (Clinton Jones).
- Modified DBExecSQLUnderCursor to select all text until end of
line if no valid command terminator is found rather than just
one letter (David Venus).
- DBGetOption displays the output from :ver for debugging.
Bug Fixes
---------
- Tutorial update (Nico Coetzee).
- Tutorial update (Clinton Jones).
- DBGetOption reported an exception E730: using List as a String.
Version 6.01
Bug Fixes
---------
- On dbext startup an error was reported indicating mapleader was not defined
(Matt).
Version 6.00
New Features
------------
- dbext now supports table and column names which can contain
spaces (Antony Scriven). There is a corresponding change
to sqlcomplete.vim to support this.
- Added an autoclose option. If you execute SQL which does not
return a result set you can choose to have the dbext results
window automatically close (unless of course there was an error).
See the autoclose option for more details.
- Added the map shortcuts to each of menu items under the dbext
menu so that users can learn them more easily (Alexander Langer).
- Using the menu_mode option you can control if and where the
dbext menu is created (Marty Grenfell). See the menu_mode option
for more details.
- For MySQL, added -t as part of the default command line parameters setting.
This will properly format the data into tabs or spaces to make it more
readable (Luke Cordingley).
- A message is displayed indicating the time a SQL command began
executing. The result window also contains the time the SQL
finished executing.
- DBI or ODBC can now fetch BLOB columns from the database. By
default these are truncated at 500 characters, but that can
be changed by issuing: DBSetOption driver_parms=LongReadLen=4096
Bug Fixes
---------
- If a database column had an emdedded double quote this would be
displayed as \" in the dbext result window (Jean-Christophe Clavier).
- When loading the plugin, it will now check to ensure the map
does not already exist before attempting to create it. This
will prevent errors when mappings clash (Antony Scriven).
- If you prompt for connection parameters using the DBI or
ODBC types we need to disconnect any existing connections
or the existing connection will continue to be used.
- In some cases when using DBI or ODBC an error was not reported
and only a blank result set was returned. Now the database
error is reported back to the user.
- Data retrieved via DBI or ODBC which contained a backslash
were not escaped properly and could disappear.
Version 5.20
New Features
------------
- When using DBI or DBI::ODBC null fields are now displayed as NULL
instead of empty spaces (now you can distinguish between them).
- When using DBI or DBI::ODBC you can specify the column separator let
g:dbext_default_dbi_column_delimiter="\t" (Jean-Christophe Clavier)
- When using DBI or DBI::ODBC and you use a vertical orientation for the
result set, if there are any embedded newline characters in your
data this will be displayed and shifted to align with the column
above. Prior to this all newlines were stripped from the output
when printing to preserve standard horizontal output (Jean-Christophe
Clavier).
Version 5.11
New Features
------------
- Added support for Oracle Rdb on an Open VMS Node.
For vim on Open VMS look at http://www.polarhome.com/vim/.
For Open VMS http://h71000.www7.hp.com/openvms/.
Development of support by Andi Stern.
Version 5.00
New Features
------------
- Added Perl's DBI and DBI::ODBC support. This opens additional database
support without having to adjust the scripts. You must have a Perl enabled
Vim (:echo has('perl')). Using the DBI layer offers some advantages over
using the native binary tools:
- Transaction support which allows you to maintain a transaction during
your editing session and either commit or rollback any changes.
This is not possible without using the DBI layer.
- Speed improvements, since the database connection is maintained, the
there is less overhead per command. You are also not shelling out
to execute commands but using an already loaded DLL, shared object.
- New commands are available to select only a few rows instead of an entire
result set. In most databases this is referred to as TOP X.
DBExecSQLTopX, DBExecVisualSQLTopX, DBExecSQLUnderCursorTopX have been
added plus associated mappings (Albie Janse van Rensburg).
- Made Cygwin detection a bit easier using the shellslash option (Steve
Gibson).
Bug Fixes
------------
- SQL Server support had issues with the queries when running DBCompleteTable,
DBCompleteProcedure, DBCompleteView which also affected the sqlcomplete.vim
plugin included with Vim7 (Albie Janse van Rensburg).
- Oracle reported "rows will be truncated", added "set linesize 10000" to the
Oracle headers (Stuart Brock)
- When prompting for connection parameters if you choose a profile of "0"
which is no profile, you had to re-run the wizard to prompt for the rest
of the parameters, now the wizard continues as expected.
Version 4.20
New Features
------------
- Improved support for Cygwin. If you are using a Cygwin compiled Vim (on
Windows) and are accessing Windows compiled binaries (i.e. sqlplus.exe)
the binary will complain since it does not understand Unix path names.
Added the option g:dbext_default_use_win32_filenames which allows you to
indicate the binaries must use translated Windows paths instead. (Richard)
- DBGetOption displays more information.
Bug Fixes
------------
- SQL Server support had issues with the queries when running DBCompleteTable,
DBCompleteProcedure, DBCompleteView which also affected the sqlcomplete.vim
plugin included with Vim7 (Albie Janse van Rensburg).
Version 4.10
New Features
------------
- Updated DBGetOption to additionally display a list of all database profiles
and their types. All dbext options that have been overriden via the
vimrc are also displayed.
Bug Fixes
------------
- db2 support had issues with the queries when running DBCompleteTable,
DBCompleteProcedure, DBCompleteView which also affected the sqlcomplete.vim
plugin included with Vim7 (Peter Princz).
- The documentation was still indicating there was a plugin dependency which
has been removed with Vim7.
Version 4.00
New Features
------------
- dbext.vim now requires Vim7.
- dbext.vim required 2 additional plugins multvals and genutil to operate.
These dependencies have been removed by taking advantage of the new Vim7
features (Lists and Dictionaries).
- When using the DBCompleteTable, DBCompleteProcedure, DBCompleteView
commands errors are displayed instead of silently ignored. This makes
them more useful with the sqlComplete plugin (see |sql.txt|).
- Added new option, dbext_default_MYSQL_version, for MySQL to indicate the
version you using.
- You can optionally define a function, DBextPostResult, in your .vimrc, this
function will be called each time the result window is updated. This
function can be used to do anything, for example, syntax highlighting the
result set in the result window.
Bug Fixes
------------
- Added version support with MySQL to control what SQL is sent for version
4 and 5 servers.
Version 3.50
New Features
------------
- g:dbext_default_inputdialog_cancel_support = 0 will prevent
inputdialog from providing a cancel option. This works around
a Vim7 bug. dbext will automatically detect this and set the
option the first time it is encountered.
- Changed the order of some of the text in the dialog boxes to
make them more readable when using the console version of Vim.
- dbext can parse SQL statements and prompt the user to replace
variables with values prior to sending the statement to the database
to be executed. This is useful for testing SQL which is embedded
in your code without having to manually replace variables and string
concatentation. A new identifier (the until flag) allows you to
specify the beginning of a string and what to prompt for until a
finishing string. This makes it more flexible for you to configure
what you would like prompting for when looking for variables.
Bug Fixes
------------
- DBPromptForBufferParameters can report "E180: Invalid complete value: -1"
if running the console version of Vim. dbext will detect this problem
and automatically set g:dbext_default_inputdialog_cancel_support = 0 to
work around this Vim7 bug.
Version 3.00
New Features
------------
- dbext supports a history of previous commands. The DBHistory
command will display a numbered list of previous SQL statements.
Pressing <enter> or double clicking on one of the items will
execute the statement. The number of items in the list is
configurable via your vimrc. The history items are stored in a
file, dbext_sql_history.txt. The location of the file can also
be controlled.
- The 'refresh' feature added in version 2.30 has been updated to take
advantage of the history feature.
- The PHP parser has improved and can handle single or double quoted
strings, string concatenation and host variables. It will correctly
strip the quotes, join the concatenated strings and prompt the user
for host variables before executing the SQL statement.
- Updated documentation for Vim 7 SQL code completion.
- Table, procedure and view dictionaries include the owner name of the
object. This is on by default, but can be controlled via a new global
option, dbext_default_dict_show_owner. This has not been enabled for all
databases it depends on whether the database supports this feature. The
autoload\sqlcomplete.vim plugin takes advantage of this feature.
- Added support for stored procedures / functions in MySQL 5.
Bug Fixes
------------
- Updated the PHP parser to work with a more varied string quotes and
string concatenation.
- The "extra" feature did not add a leading space for MySQL. Using the
tabbed output required updates to the parsing of the output generated
by MySQL.
- Miscellaneous documentation updates.
Version 2.30
New Features
------------
- The result window has a local buffer mapping 'R', which will 'refresh'
the window. This means it will re-run the previous statement which is
useful if you are repeatedly checking something in the database.
- SQL Anywhere (ASA) no longer relies on the jcatalogue tables to be
installed in the database. System views are used instead.
- Support for MySQL 5.0 has been added, which includes stored procedures
and views (as much as the beta allowed).
- For Postgress SQL you can now optionally enter an owner name to filter by
when showing list of objects (tables, procedures, views).
Bug Fixes
------------
- The |alternate-file| is no longer changed the first time the result buffer
is opened.
- Using DB2 with db2cmd incorrectly specified the command terminator with
td, instead of -t.
- On win32 platforms, if the bin_path has been specified for DB2, then
add this to the system path since db2cmd relies on other batch files to
operate correctly.
- The connection string is displayed by both the Result buffer (first line)
and the titlestring to the buffer (if enabled). This was not correctly
appending the user used to connect to the database.
- When parsing Vim scripts we did not correctly remove a leading line
continuation slash from the from of a query.
Version 2.20
New Features
------------
- Added new connection parameter called "extra", you can place any
additional command line parameters in this option.
- DBGetOption displays all options including the dbext version.
- Better support for command terminators that have newline or special
characters in them. For example ASE/SQLSRV use "\ngo\n", now the
command DBExecSQLUnderCursor will correctly find the statement.
- Use_tbl_alias defaults to "ask", instead of "default on".
- For most supported databases, when displaying the Table / Procedure / View
List, you can now enter a partial string "DBA.", and if a . is included
it will only display objects created / owned by that userid.
- DBExecSQLUnderCursor would sometimes stop in the middle of a query
if the command terminator was included (inside a quoted string), now
it ensures there is no text following the terminator.
- The result window also includes the error code returned by the binary
used to execute the command. This can be useful for debugging.
- The first line of the result window includes a line showing the connection
information, if you have many buffers open, it can be difficult to
determine which database you are executing commands against. A glance at
this line will tell you immediately.
- g:dbext_default_always_prompt_for_variables = 0 will prevent you from
being prompted for substitution parameters. Setting this value to 1
will always prompt the user.
- You can now abort the execution of a statement if you are prompted
for substitution parameters.
- If you are prompted for parameters, if you choose "Stop Prompting" the
command will be executed immediate. If "Never Prompt" is chosen, no
further prompting will occur for this buffer.
Bug Fixes
---------
- SQLSRV did not have a default command terminator, now it is "\ngo\n".
- Changed the Oracle command terminator to ";", and the routine that
executes the statements automatically adds the "\nquit;\n" so that
sqlplus will complete.
- Spaces were not correctly removed from column lists in all cases, this
showed up as an issue with the SQL Intellisense plugin.
- When executing SELECT statements the INTO clause (if present) is
removed so the results are displayed in the result window. Refined the
removal of the INTO clause to ensure it does not interfer with an
INSERT or MERGE statement.
Version 2.11
Bug Fixes
---------
- On some platforms the temporary file created to execute SQL statements must
end in ".sql". Corrected this for all databases
Version 2.10
New Features
------------
- Added support for the database SQLite (thanks to Ron Aaron).
- Added a tutorial in the documentation for first time users.
- New functionality for better integration with the Intellisense SQL plugin.
- Ability to change the title of the window/buffer.
- Integrated Login support for windows.
- Added new functionality to these commands: |dbext-mappings|
DBGetOption
DBSetOption
DBExecRangeSQL
- Added 4 new options: |dbext-configure-variables|
replace_title
custom_title
use_tbl_alias
delete_temp_file
Bug Fixes
---------
- dbname was not defaulting correctly.
- Overhauled the DB2 support.
- bin_path did not work correctly on windows platforms.
- Updated the connection text in the Result buffer.
Version 2.00
New Features
------------
- In version 2.00 the following new features have been added to dbext.
- Connection Profiles |dbext-connect-profiles|
- Modeline Support |dbext-connect-modelines|
- Object Completion |dbext-completion|
- Viewing Lists of Objects |dbext-list-objects|
Tables
Procedures
Views
Columns
- FileType Support Added |dbext-filetypes|
Supported PHP, Java, JSP, JavaScript, jProperties, Perl, SQL, Vim
- Intellisense Addin Support |dbext-intellisense|
==============================================================================
3. Overview *dbext-overview*
This plugin contains functions/mappings/commands to enable Vim to access
several databases. List of currently supported databases:
DB2
Firebird
Ingres
Interbase
Microsoft SQL Server
MySQL
PostgreSQL
Oracle
Oracle Rdb on an Open VMS Node
SQLite
Sybase Adaptive Server Anywhere
Sybase UltraLite
Sybase Adaptive Server Enterprise
When using a Perl enabled Vim ( :echo has('perl') ):
DBI
ODBC
It does this by shelling out to the operating system and calling the
command line tools that come with the client software for the database.
For example, if you are connecting to an Oracle database, dbext.vim will call
sqlplus to execute the SQL statements, for MySQL it uses the
mysql binary, for ASA it uses the DBISQL binary.
When a command is executed, a read only buffer (Result) is opened (see
options |dbext-configure-variables|): >
:DBGetOption use_result_buffer
:DBGetOption buffer_lines
<
The output from the command is displayed in this buffer. The buffer can be
moved or deleted. The next time a command is executed, it will be created,
or cleared out and the new results will be placed within.
If a select statement is executed, its results will be displayed in this
buffer. If a syntax error occurs during a command (for example running a
statement that has a syntax error in it) the output error messages from the
database will be displayed in the Result buffer.
In addition to the 10 currently supported relation databases (RDBMS), you can
easily add support for new database's. See |dbext-newdb| for details.
On the supported databases you can execute any SQL statements (insert,
update, delete, create, alter, drop ...), describe tables, describe stored
procedures, see table lists, create column lists and so on. >
TIP:
<You can create dbext modelines |dbext-connect-modelines| in your files to
automatically specify connection information. In your |.vimrc| you can
also create dbext connection profiles |dbext-connect-profiles| to specify
common connection information (for example by projects). The first time you
execute SQL, you will be prompted to choose these profiles (if not already
set via a modeline or default profile). This is the easiest and most
efficient use of specifying connection information. It also has the added
benefit of hiding userids, passwords and so on, in your |.vimrc| instead
of in the files themselves.
In the event of an error, the command line used to execute the command
against the database is displayed in the Result buffer. This is done to
help determine what is the cause of the problem might be.
==============================================================================
4. Installing the plugin *dbext-install*
You can use this script as a plugin by copying it to your plugin directory.
See |add-global-plugin| for instructions.
You can also |:source| it from your |.vimrc|.
To install this help file |add-local-help| inside Vim.
:help add-local-help
:helptags $VIM/vimfiles/doc (Windows)
:helptags $VIM/.vim/doc (Unix)
==============================================================================
5. Configuration *dbext-configure*
The behavior of dbext.vim are governed by several variables. These variables
are used as the default database connection information. These variables can
be assigned global defaults which can be set in your |.vimrc|. See the script
for details. Otherwise, each buffer maintains its own values. So each
buffer can be connected to different databases, even different relational
databases (one buffer connect to Oracle, another buffer to MySQL).
A menu has been added to gvim with available commands in all modes.
5.1 Displaying Results *dbext-configure-results*
When any command is run, by default a window is opened with a read-only
buffer. By default, the window is called Result. Each buffer will clear
out and re-populate this buffer with the results of the last command.
To control the size of the Result window, you can set the following: >
let g:dbext_default_buffer_lines = 5 (default)
<If you want each buffer to have its OWN Result buffer, you can define: >
let g:dbext_default_use_sep_result_buffer = 1 (default=0)
<
There are a few local buffer mapping created in the Results buffer:
R - Pressing 'R' calls the DBResultsRefresh command. This will
to re-run the statement which populated the result window.
q - Quick way to close the window if you have finished with
the results and essentially want to hide it until the
next time you need it.
a - Toggle the autoclose feature.
the results and essentially want to hide it until the
next time you need it.
O - Change the result orientation (only with DBI and ODBC).
<Space> - If using a vertical window will toggle the width to make
it easier to read.
If you define a function, DBextPostResult, in your .vimrc (or elsewhere)
it will be called automatically each time the Result buffer is updated.
This can be used to do anything you need, the initial request for the
feature was for the ability to use Vim's syntax highlighting to make
the results displayed from a MYSQL query more readable.
The function takes two parameters: >
db_type
< - The database type specified for the buffer which caused the
Result buffer to be updated. It will be one of the following:
ASA,ASE,DB2,INGRES,INTERBASE,MYSQL,ORA,PGSQL,SQLSRV,SQLITE >
buf_nr
< - The buffer number of the result window
Here is a very simple example which will:
- Do nothing if connected to a database other than MYSQL
- Highlight any numeric values at the beginning of a line >
function! DBextPostResult(db_type, buf_nr)
" If dealing with a MYSQL database
if a:db_type == 'MYSQL'
" Assuming the first column is an integer
" highlight it using the WarningMsg color
syn match logWarn '^\d\+'
hi def link logWarn WarningMsg
endif
endfunction
<
5.2 Script Variables *dbext-configure-variables*
Global variables: >
dbext_default_profile
< - Predefined favourite connection information >
dbext_default_type
< - Default relational database to connect to >
dbext_default_integratedlogin
< - On Windows, whether to use integrated login for ASA and SQLSRV >
dbext_default_user
< - Default user id >
dbext_default_passwd
< - Default password >
dbext_default_dbname
< - Default database to connect to >
dbext_default_host
< - Default host the server is running on >
dbext_default_port
< - Default port to connect to >
dbext_default_extra
< - Customization string if the above options are not enough >
dbext_default_use_result_buffer
< - Whether to use the result buffer, or echo the results of the command >
dbext_default_use_sep_result_buffer
< - Whether to use separate result buffers for each file >
dbext_default_buffer_lines
< - How many lines the Result window should be >
dbext_default_parse_statements
< - Which statements are parsed for input parameters (See |dbext-newdb|) >
dbext_default_prompt_for_variables
< - Allows you to specify if dbext should check for host variables >
dbext_default_always_prompt_for_variables
< - If host variables are found, you are asked if you want to be
prompted, setting this variable assumes you always want to be
prompted, so it saves you a dialog.
- This option can have 3 values:
1 - Always prompt for variables
0 - Ask if you want to (if variables are found)
-1 - Never prompt for variables >
dbext_default_stop_prompt_for_variables
< - This is used internally by dbext. Each time a query is executed
and the user is prompted for variables, if you press "Ok" without
entering anything, you are prompted asking whether you want to:
1. Skip the replacement for this string
2. Replace it with a blank
3. Stop prompting for just this query
4. Never prompt for variables (including subsequent queries)
5. Abort the query and do NOT execute it
- If option 3 is chosen, dbext sets this variable and resets it for
the next query. >
dbext_default_display_cmd_line
< - When the command is run, the results are displayed in the Result
buffer, setting display_cmd_line = 1, will also display the command
that was run to generate the output. Useful for debugging. >
dbext_default_variable_def
< - List of variables and rules on how to search and prompt for variable
names within a statement that starts with any of the words listed in
dbext_parse_statements. >
dbext_default_replace_title
< - Changes the title of the buffer to show connection information.
This is useful if you are using a scratch buffer to test statements,
it will show you which database you are connected to visually by
glancing at the buffer title. >
dbext_default_custom_title
< - If the default format of the replace title feature does not meet
your needs, you can set a custom title. To retrieve settings
from the dbext plugin you can use: >
:let new_title = 'Srvr: ' . DB_listOption('srvname')
:exec 'DBSetOption custom_title='.new_title
dbext_default_use_tbl_alias
< - DBListColumn (by default) will create a column list with an
alias attached to each column. This option has three
settings: >
n - do not use an alias
d - use the default (calculated) alias
a - ask to confirm the alias name
< - An alias is determined following a few rules:
1. If the table name has an '_', then use it as a separator: >
MY_TABLE_NAME --> MTN
my_table_name --> mtn
My_table_NAME --> MtN
< 2. If the table name does NOT an '_', but DOES use mixed case
then the case is used as a separator: >
MyTableName --> MTN
< 3. If the table name does NOT an '_', and does NOT use mixed case
then the first letter of the table is used: >
mytablename --> m
MYTABLENAME --> M
< - The option can be turned on and off via the DBSetOption command. >
:DBSetOption use_tbl_alias=n
dbext_default_delete_temp_file
< - If debugging, it can be useful to view the SQL file that
dbext generated to be executed by the database. Setting this
option to 0 (off) will leave the temporary file in the
$TEMP directory for viewing. >
:DBSetOption delete_temp_file=0
dbext_default_history_file
< - The SQL history is stored within a file. This was done for
a couple of reasons:
1. No upper bound on the size of the history.
2. If you have multiple instances of Vim running, each
will see the current history without overwriting
each other (thereby loosing history).
3. The history can easily be removed if necessary.
Each SQL statement has it's newline characters replaced with
@@@ so the statement fits on one line. The default history
file varies by the OS:
Unix: $HOME/dbext_sql_history.txt
Windows: $VIM/dbext_sql_history.txt
If you wish to override the file location you can via your
|vimrc|. To see the current setting run :DBGetOption. >
:let g:dbext_default_history_file = '/your/loc/file.txt'
:let g:dbext_default_history_file = 'c:\your\loc\file.txt'
dbext_default_history_size
< - Controls how many SQL statements should be stored within the
history. The default value is 50. This option must be
set within your |vimrc|. To see the current setting run
:DBGetOption. >
:let g:dbext_default_history_size = 50
dbext_default_history_max_entry
< - You can limit the size of the entries dbext records in the
history file. The current default is 4K. Statements longer
than 4K are not stored within the history file. Setting this
value to 0, removes any limits on the size of a single entry. >
:let g:dbext_default_history_max_entry = 4096
dbext_default_dict_show_owner
< - When creating a dictionary of tables, procedures and views
the owner name can also be included. The omni sql complete
plugin uses this setting. The default is enabled, to disable
add the following to your vimrc: >
:let g:dbext_default_dict_show_owner = 0
dbext_default_use_win32_filenames
< - If using Cygwin on Windows and the 3rd party binaries (sqlplus.exe,
mysql.exe, dbisql.exe, ...) are Windows compiled then they will not
understand Unix style filenames (with forward slashes). Setting
this option to 1, forces all filenames to be referenced with
double backslashes instead. It also uses the Cygwin utility,
cygpath, to identify the absolute filename from a Windows
perspective. The default is 0, to enable add the following to your
vimrc: >
:let g:dbext_default_use_win32_filenames = 1
dbext_default_DBI_dict_proc_<DBI Driver Name>
< - DBI has meta data for tables and views but not for procedures.
If you use stored procedure completion with DBI you can define
the SQL statement DBI will use to retrieve the list of stored
procedures from the database. For the current supported databases
these settings have already been defined (if this was supported
by version 4.20). >
:let g:dbext_default_DBI_dict_proc_SQLAnywhere =
\ 'SELECT u.user_name ||''.''|| p.proc_name '.
\ ' FROM SYS.SYSPROCEDURE as p, '.
\ ' SYS.SYSUSERPERM as u '.
\ ' WHERE p.creator = u.user_id '.
\ ' ORDER BY u.user_name, proc_name')
dbext_default_DBI_list_proc_<DBI Driver Name>
< - DBI has meta data for tables and views but not for procedures.
If you use stored procedure completion with DBI you can define
the SQL statement DBI will use to retrieve the list of stored
procedures from the database. For the current supported databases
these settings have already been defined (if this was supported
by version 4.20). dbext prompts for search criteria. The SQL
statement should support place holders to fill in both the
owner name and the beginning of the procedure name. In the
example below you can see if no owner or procedure name supplied
a match to '%' is used which retrieves all procedures. Simply
add similar support to your own SQL statement. >
:let g:dbext_default_DBI_list_proc_SQLAnywhere =