node-firebird 1.1.6 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,772 @@
1
+ /***************************************
2
+ *
3
+ * Constantes
4
+ *
5
+ ***************************************/
6
+
7
+ const defaultOptions = {
8
+ DEFAULT_HOST : '127.0.0.1',
9
+ DEFAULT_PORT : 3050,
10
+ DEFAULT_USER : 'SYSDBA',
11
+ DEFAULT_PASSWORD : 'masterkey',
12
+ DEFAULT_LOWERCASE_KEYS : false,
13
+ DEFAULT_PAGE_SIZE : 4096,
14
+ DEFAULT_SVC_NAME : 'service_mgr',
15
+ DEFAULT_ENCODING : 'UTF8',
16
+ DEFAULT_FETCHSIZE : 200,
17
+ };
18
+
19
+ const buffer= {
20
+ MAX_BUFFER_SIZE : 8192,
21
+ };
22
+
23
+ const int = {
24
+ MAX_INT : Math.pow(2, 31) - 1,
25
+ MIN_INT : -Math.pow(2, 31),
26
+ };
27
+
28
+ const op = {
29
+ op_void : 0, // Packet has been voided
30
+ op_connect : 1, // Connect to remote server
31
+ op_exit : 2, // Remote end has exitted
32
+ op_accept : 3, // Server accepts connection
33
+ op_reject : 4, // Server rejects connection
34
+ op_disconnect : 6, // Connect is going away
35
+ op_response : 9, // Generic response block
36
+
37
+ // Full context server operations
38
+
39
+ op_attach : 19, // Attach database
40
+ op_create : 20, // Create database
41
+ op_detach : 21, // Detach database
42
+ op_compile : 22, // Request based operations
43
+ op_start : 23,
44
+ op_start_and_send : 24,
45
+ op_send : 25,
46
+ op_receive : 26,
47
+ op_unwind : 27, // apparently unused, see protocol.cpp's case op_unwind
48
+ op_release : 28,
49
+
50
+ op_transaction : 29, // Transaction operations
51
+ op_commit : 30,
52
+ op_rollback : 31,
53
+ op_prepare : 32,
54
+ op_reconnect : 33,
55
+
56
+ op_create_blob : 34, // Blob operations
57
+ op_open_blob : 35,
58
+ op_get_segment : 36,
59
+ op_put_segment : 37,
60
+ op_cancel_blob : 38,
61
+ op_close_blob : 39,
62
+
63
+ op_info_database : 40, // Information services
64
+ op_info_request : 41,
65
+ op_info_transaction : 42,
66
+ op_info_blob : 43,
67
+
68
+ op_batch_segments : 44, // Put a bunch of blob segments
69
+
70
+ op_que_events : 48, // Que event notification request
71
+ op_cancel_events : 49, // Cancel event notification request
72
+ op_commit_retaining : 50, // Commit retaining (what else)
73
+ op_prepare2 : 51, // Message form of prepare
74
+ op_event : 52, // Completed event request (asynchronous)
75
+ op_connect_request : 53, // Request to establish connection
76
+ op_aux_connect : 54, // Establish auxiliary connection
77
+ op_ddl : 55, // DDL call
78
+ op_open_blob2 : 56,
79
+ op_create_blob2 : 57,
80
+ op_get_slice : 58,
81
+ op_put_slice : 59,
82
+ op_slice : 60, // Successful response to op_get_slice
83
+ op_seek_blob : 61, // Blob seek operation
84
+
85
+ // DSQL operations
86
+
87
+ op_allocate_statement : 62, // allocate a statment handle
88
+ op_execute : 63, // execute a prepared statement
89
+ op_exec_immediate : 64, // execute a statement
90
+ op_fetch : 65, // fetch a record
91
+ op_fetch_response : 66, // response for record fetch
92
+ op_free_statement : 67, // free a statement
93
+ op_prepare_statement : 68, // prepare a statement
94
+ op_set_cursor : 69, // set a cursor name
95
+ op_info_sql : 70,
96
+
97
+ op_dummy : 71, // dummy packet to detect loss of client
98
+ op_response_piggyback : 72, // response block for piggybacked messages
99
+ op_start_and_receive : 73,
100
+ op_start_send_and_receive : 74,
101
+ op_exec_immediate2 : 75, // execute an immediate statement with msgs
102
+ op_execute2 : 76, // execute a statement with msgs
103
+ op_insert : 77,
104
+ op_sql_response : 78, // response from execute, exec immed, insert
105
+ op_transact : 79,
106
+ op_transact_response : 80,
107
+ op_drop_database : 81,
108
+ op_service_attach : 82,
109
+ op_service_detach : 83,
110
+ op_service_info : 84,
111
+ op_service_start : 85,
112
+ op_rollback_retaining : 86,
113
+ op_partial : 89, // packet is not complete - delay processing
114
+ op_trusted_auth : 90,
115
+ op_cancel : 91,
116
+ op_cont_auth : 92,
117
+ op_ping : 93,
118
+ op_accept_data : 94, // Server accepts connection and returns some data to client
119
+ op_abort_aux_connection : 95, // Async operation - stop waiting for async connection to arrive
120
+ op_crypt : 96,
121
+ op_crypt_key_callback : 97,
122
+ op_cond_accept : 98, // Server accepts connection, returns some data to client
123
+ // and asks client to continue authentication before attach call
124
+ };
125
+
126
+ const dsql = {
127
+ DSQL_close : 1,
128
+ DSQL_drop : 2,
129
+ DSQL_unprepare : 4, // >: 2.5
130
+ };
131
+
132
+ /***********************/
133
+ /* ISC Error Codes */
134
+ /***********************/
135
+ const iscError = {
136
+ isc_sqlerr: 335544436,
137
+ isc_arg_end : 0, // end of argument list
138
+ isc_arg_gds : 1, // generic DSRI status value
139
+ isc_arg_string : 2, // string argument
140
+ isc_arg_cstring : 3, // count & string argument
141
+ isc_arg_number : 4, // numeric argument (long)
142
+ isc_arg_interpreted : 5, // interpreted status code (string)
143
+ isc_arg_unix : 7, // UNIX error code
144
+ isc_arg_next_mach : 15, // NeXT/Mach error code
145
+ isc_arg_win32 : 17, // Win32 error code
146
+ isc_arg_warning : 18, // warning argument
147
+ isc_arg_sql_state : 19, // SQLSTATE
148
+ };
149
+
150
+ const connect = {
151
+ CONNECT_VERSION2 : 2,
152
+ CONNECT_VERSION3 : 3,
153
+ ARCHITECTURE_GENERIC : 1,
154
+ };
155
+
156
+ /*******************/
157
+ /* Protocols */
158
+ /*******************/
159
+ const FB_PROTOCOL_FLAG = 0x8000;
160
+ const protocol = {
161
+ // Protocol 10 includes support for warnings and removes the requirement for
162
+ // encoding and decoding status codes
163
+ PROTOCOL_VERSION10 : 10,
164
+
165
+ // Since protocol 11 we must be separated from Borland Interbase.
166
+ // Therefore always set highmost bit in protocol version to 1.
167
+ // For unsigned protocol version this does not break version's compare.
168
+ FB_PROTOCOL_FLAG : FB_PROTOCOL_FLAG,
169
+ FB_PROTOCOL_MASK : ~FB_PROTOCOL_FLAG & 0xFFFF,
170
+
171
+ // Protocol 11 has support for user authentication related
172
+ // operations (op_update_account_info, op_authenticate_user and
173
+ // op_trusted_auth). When specific operation is not supported,
174
+ // we say "sorry".
175
+ PROTOCOL_VERSION11 : (FB_PROTOCOL_FLAG | 11),
176
+
177
+ // Protocol 12 has support for asynchronous call op_cancel.
178
+ // Currently implemented asynchronously only for TCP/IP.
179
+ PROTOCOL_VERSION12 : (FB_PROTOCOL_FLAG | 12),
180
+
181
+ // Protocol 13 has support for authentication plugins (op_cont_auth).
182
+ PROTOCOL_VERSION13 : (FB_PROTOCOL_FLAG | 13),
183
+ };
184
+
185
+ // Protocols types (accept_type)
186
+ const acceptType = {
187
+ ptype_rpc : 2, // Simple remote procedure call
188
+ ptype_batch_send : 3, // Batch sends, no asynchrony
189
+ ptype_out_of_band : 4, // Batch sends w/ out of band notification
190
+ ptype_lazy_send : 5, // Deferred packets delivery;
191
+ ptype_mask : 0xFF, // Mask - up to 255 types of protocol
192
+ pflag_compress : 0x100 // Turn on compression if possible
193
+ };
194
+
195
+ const SUPPORTED_PROTOCOL = [
196
+ [protocol.PROTOCOL_VERSION10, connect.ARCHITECTURE_GENERIC, acceptType.ptype_rpc, acceptType.ptype_batch_send, 1],
197
+ [protocol.PROTOCOL_VERSION11, connect.ARCHITECTURE_GENERIC, acceptType.ptype_lazy_send, acceptType.ptype_lazy_send, 2],
198
+ [protocol.PROTOCOL_VERSION12, connect.ARCHITECTURE_GENERIC, acceptType.ptype_lazy_send, acceptType.ptype_lazy_send, 3],
199
+ [protocol.PROTOCOL_VERSION13, connect.ARCHITECTURE_GENERIC, acceptType.ptype_lazy_send, acceptType.ptype_lazy_send, 4],
200
+ ];
201
+
202
+ const authPlugin = {
203
+ AUTH_PLUGIN_LEGACY : 'Legacy_Auth',
204
+ AUTH_PLUGIN_SRP : 'Srp',
205
+ // AUTH_PLUGIN_SRP256 : 'Srp256',
206
+ };
207
+
208
+ const authOptions = {
209
+ // AUTH_PLUGIN_LIST : [authPlugin.AUTH_PLUGIN_SRP256, authPlugin.AUTH_PLUGIN_SRP, authPlugin.AUTH_PLUGIN_LEGACY],
210
+ AUTH_PLUGIN_LIST : [authPlugin.AUTH_PLUGIN_SRP, authPlugin.AUTH_PLUGIN_LEGACY],
211
+ // AUTH_PLUGIN_SRP_LIST : [authPlugin.AUTH_PLUGIN_SRP256, authPlugin.AUTH_PLUGIN_SRP],
212
+ AUTH_PLUGIN_SRP_LIST : [authPlugin.AUTH_PLUGIN_SRP],
213
+ LEGACY_AUTH_SALT : '9z',
214
+ WIRE_CRYPT_DISABLE : 0,
215
+ WIRE_CRYPT_ENABLE : 1,
216
+ };
217
+
218
+ /*******************/
219
+ /* SQL Type */
220
+ /*******************/
221
+ const sqlType = {
222
+ SQL_TEXT : 452, // Array of char
223
+ SQL_VARYING : 448,
224
+ SQL_SHORT : 500,
225
+ SQL_LONG : 496,
226
+ SQL_FLOAT : 482,
227
+ SQL_DOUBLE : 480,
228
+ SQL_D_FLOAT : 530,
229
+ SQL_TIMESTAMP : 510,
230
+ SQL_BLOB : 520,
231
+ SQL_ARRAY : 540,
232
+ SQL_QUAD : 550,
233
+ SQL_TYPE_TIME : 560,
234
+ SQL_TYPE_DATE : 570,
235
+ SQL_INT64 : 580,
236
+ SQL_INT128: 32752, // >= 4.0
237
+ SQL_BOOLEAN : 32764, // >: 3.0
238
+ SQL_NULL : 32766, // >= 2.5
239
+ };
240
+
241
+ const blobType = {
242
+ isc_blob_text : 1,
243
+ };
244
+
245
+ /*******************/
246
+ /* Blr definitions */
247
+ /*******************/
248
+ const blr = {
249
+ blr_text : 14,
250
+ blr_text2 : 15,
251
+ blr_short : 7,
252
+ blr_long : 8,
253
+ blr_quad : 9,
254
+ blr_float : 10,
255
+ blr_double : 27,
256
+ blr_d_float : 11,
257
+ blr_timestamp : 35,
258
+ blr_varying : 37,
259
+ blr_varying2 : 38,
260
+ blr_blob : 261,
261
+ blr_cstring : 40,
262
+ blr_cstring2 : 41,
263
+ blr_blob_id : 45,
264
+ blr_sql_date : 12,
265
+ blr_sql_time : 13,
266
+ blr_int64 : 16,
267
+ blr_int128 : 26, // >: 4.0
268
+ blr_blob2 : 17, // >: 2.0
269
+ blr_domain_name : 18, // >: 2.1
270
+ blr_domain_name2 : 19, // >: 2.1
271
+ blr_not_nullable : 20, // >: 2.1
272
+ blr_column_name : 21, // >: 2.5
273
+ blr_column_name2 : 22, // >: 2.5
274
+ blr_bool : 23, // >: 3.0
275
+
276
+ blr_version4 : 4,
277
+ blr_version5 : 5, // dialect 3
278
+ blr_eoc : 76,
279
+ blr_end : 255,
280
+
281
+ blr_assignment : 1,
282
+ blr_begin : 2,
283
+ blr_dcl_variable : 3,
284
+ blr_message : 4,
285
+ };
286
+
287
+ /**********************************/
288
+ /* Database parameter block stuff */
289
+ /**********************************/
290
+ const dpb = {
291
+ isc_dpb_version1 : 1,
292
+ isc_dpb_version2 : 2, // >: FB30
293
+ isc_dpb_cdd_pathname : 1,
294
+ isc_dpb_allocation : 2,
295
+ isc_dpb_journal : 3,
296
+ isc_dpb_page_size : 4,
297
+ isc_dpb_num_buffers : 5,
298
+ isc_dpb_buffer_length : 6,
299
+ isc_dpb_debug : 7,
300
+ isc_dpb_garbage_collect : 8,
301
+ isc_dpb_verify : 9,
302
+ isc_dpb_sweep : 10,
303
+ isc_dpb_enable_journal : 11,
304
+ isc_dpb_disable_journal : 12,
305
+ isc_dpb_dbkey_scope : 13,
306
+ isc_dpb_number_of_users : 14,
307
+ isc_dpb_trace : 15,
308
+ isc_dpb_no_garbage_collect : 16,
309
+ isc_dpb_damaged : 17,
310
+ isc_dpb_license : 18,
311
+ isc_dpb_sys_user_name : 19,
312
+ isc_dpb_encrypt_key : 20,
313
+ isc_dpb_activate_shadow : 21,
314
+ isc_dpb_sweep_interval : 22,
315
+ isc_dpb_delete_shadow : 23,
316
+ isc_dpb_force_write : 24,
317
+ isc_dpb_begin_log : 25,
318
+ isc_dpb_quit_log : 26,
319
+ isc_dpb_no_reserve : 27,
320
+ isc_dpb_user_name : 28,
321
+ isc_dpb_password : 29,
322
+ isc_dpb_password_enc : 30,
323
+ isc_dpb_sys_user_name_enc : 31,
324
+ isc_dpb_interp : 32,
325
+ isc_dpb_online_dump : 33,
326
+ isc_dpb_old_file_size : 34,
327
+ isc_dpb_old_num_files : 35,
328
+ isc_dpb_old_file : 36,
329
+ isc_dpb_old_start_page : 37,
330
+ isc_dpb_old_start_seqno : 38,
331
+ isc_dpb_old_start_file : 39,
332
+ isc_dpb_old_dump_id : 41,
333
+ isc_dpb_lc_messages : 47,
334
+ isc_dpb_lc_ctype : 48,
335
+ isc_dpb_cache_manager : 49,
336
+ isc_dpb_shutdown : 50,
337
+ isc_dpb_online : 51,
338
+ isc_dpb_shutdown_delay : 52,
339
+ isc_dpb_reserved : 53,
340
+ isc_dpb_overwrite : 54,
341
+ isc_dpb_sec_attach : 55,
342
+ isc_dpb_connect_timeout : 57,
343
+ isc_dpb_dummy_packet_interval : 58,
344
+ isc_dpb_gbak_attach : 59,
345
+ isc_dpb_sql_role_name : 60,
346
+ isc_dpb_set_page_buffers : 61,
347
+ isc_dpb_working_directory : 62,
348
+ isc_dpb_sql_dialect : 63,
349
+ isc_dpb_set_db_readonly : 64,
350
+ isc_dpb_set_db_sql_dialect : 65,
351
+ isc_dpb_gfix_attach : 66,
352
+ isc_dpb_gstat_attach : 67,
353
+ isc_dpb_set_db_charset : 68,
354
+ isc_dpb_gsec_attach : 69,
355
+ isc_dpb_address_path : 70,
356
+ isc_dpb_process_id : 71,
357
+ isc_dpb_no_db_triggers : 72,
358
+ isc_dpb_trusted_auth : 73,
359
+ isc_dpb_process_name : 74,
360
+ isc_dpb_trusted_role : 75,
361
+ isc_dpb_org_filename : 76,
362
+ isc_dpb_utf8_filename : 77,
363
+ isc_dpb_ext_call_depth : 78,
364
+ isc_dpb_auth_block : 79,
365
+ isc_dpb_client_version : 80,
366
+ isc_dpb_remote_protocol : 81,
367
+ isc_dpb_host_name : 82,
368
+ isc_dpb_os_user : 83,
369
+ isc_dpb_specific_auth_data : 84,
370
+ isc_dpb_auth_plugin_list : 85,
371
+ isc_dpb_auth_plugin_name : 86,
372
+ isc_dpb_config : 87,
373
+ isc_dpb_nolinger : 88,
374
+ isc_dpb_reset_icu : 89,
375
+ isc_dpb_map_attach : 90,
376
+ isc_dpb_session_time_zone : 91,
377
+ };
378
+
379
+ const cnct = {
380
+ CNCT_user : 1, // User name
381
+ CNCT_passwd : 2,
382
+ // CNCT_ppo : 3, // Apollo person, project, organization. OBSOLETE.
383
+ CNCT_host : 4,
384
+ CNCT_group : 5, // Effective Unix group id
385
+ CNCT_user_verification : 6, // Attach/create using this connection will use user verification
386
+ CNCT_specific_data : 7, // Some data, needed for user verification on server
387
+ CNCT_plugin_name : 8, // Name of plugin, which generated that data
388
+ CNCT_login : 9, // Same data as isc_dpb_user_name
389
+ CNCT_plugin_list : 10, // List of plugins, available on client
390
+ CNCT_client_crypt : 11, // Client encyption level (DISABLED/ENABLED/REQUIRED)
391
+ WIRE_CRYPT_DISABLED : 0,
392
+ WIRE_CRYPT_ENABLED : 1,
393
+ WIRE_CRYPT_REQUIRED : 2,
394
+ };
395
+
396
+ /****************************/
397
+ /* Common, structural codes */
398
+ /****************************/
399
+ const common = {
400
+ isc_info_end : 1,
401
+ isc_info_truncated : 2,
402
+ isc_info_error : 3,
403
+ isc_info_data_not_ready : 4,
404
+ isc_info_length : 126,
405
+ isc_info_flag_end : 127,
406
+ };
407
+
408
+ /*************************************/
409
+ /* Transaction parameter block stuff */
410
+ /*************************************/
411
+ const tpb = {
412
+ isc_tpb_version1 : 1,
413
+ isc_tpb_version3 : 3,
414
+ isc_tpb_consistency : 1,
415
+ isc_tpb_concurrency : 2,
416
+ isc_tpb_shared : 3, // < FB21
417
+ isc_tpb_protected : 4, // < FB21
418
+ isc_tpb_exclusive : 5, // < FB21
419
+ isc_tpb_wait : 6,
420
+ isc_tpb_nowait : 7,
421
+ isc_tpb_read : 8,
422
+ isc_tpb_write : 9,
423
+ isc_tpb_lock_read : 10,
424
+ isc_tpb_lock_write : 11,
425
+ isc_tpb_verb_time : 12,
426
+ isc_tpb_commit_time : 13,
427
+ isc_tpb_ignore_limbo : 14,
428
+ isc_tpb_read_committed : 15,
429
+ isc_tpb_autocommit : 16,
430
+ isc_tpb_rec_version : 17,
431
+ isc_tpb_no_rec_version : 18,
432
+ isc_tpb_restart_requests : 19,
433
+ isc_tpb_no_auto_undo : 20,
434
+ isc_tpb_lock_timeout : 21, // >= FB20
435
+ };
436
+
437
+ const transactionIsolation = {
438
+ ISOLATION_READ_UNCOMMITTED : [tpb.isc_tpb_version3, tpb.isc_tpb_write, tpb.isc_tpb_wait, tpb.isc_tpb_read_committed, tpb.isc_tpb_rec_version],
439
+ ISOLATION_READ_COMMITTED : [tpb.isc_tpb_version3, tpb.isc_tpb_write, tpb.isc_tpb_wait, tpb.isc_tpb_read_committed, tpb.isc_tpb_no_rec_version],
440
+ ISOLATION_REPEATABLE_READ : [tpb.isc_tpb_version3, tpb.isc_tpb_write, tpb.isc_tpb_wait, tpb.isc_tpb_concurrency],
441
+ ISOLATION_SERIALIZABLE : [tpb.isc_tpb_version3, tpb.isc_tpb_write, tpb.isc_tpb_wait, tpb.isc_tpb_consistency],
442
+ ISOLATION_READ_COMMITTED_READ_ONLY : [tpb.isc_tpb_version3, tpb.isc_tpb_read, tpb.isc_tpb_wait, tpb.isc_tpb_read_committed, tpb.isc_tpb_no_rec_version],
443
+ };
444
+
445
+ /*************************/
446
+ /* SQL information items */
447
+ /*************************/
448
+ const sqlInfo = {
449
+ isc_info_sql_select : 4,
450
+ isc_info_sql_bind : 5,
451
+ isc_info_sql_num_variables : 6,
452
+ isc_info_sql_describe_vars : 7,
453
+ isc_info_sql_describe_end : 8,
454
+ isc_info_sql_sqlda_seq : 9,
455
+ isc_info_sql_message_seq : 10,
456
+ isc_info_sql_type : 11,
457
+ isc_info_sql_sub_type : 12,
458
+ isc_info_sql_scale : 13,
459
+ isc_info_sql_length : 14,
460
+ isc_info_sql_null_ind : 15,
461
+ isc_info_sql_field : 16,
462
+ isc_info_sql_relation : 17,
463
+ isc_info_sql_owner : 18,
464
+ isc_info_sql_alias : 19,
465
+ isc_info_sql_sqlda_start : 20,
466
+ isc_info_sql_stmt_type : 21,
467
+ isc_info_sql_get_plan : 22,
468
+ isc_info_sql_records : 23,
469
+ isc_info_sql_batch_fetch : 24,
470
+ isc_info_sql_relation_alias : 25, // >: 2.0
471
+ isc_info_sql_explain_plan : 26, // >= 3.0
472
+ };
473
+
474
+ const statementInfo = {
475
+ isc_info_sql_stmt_select : 1,
476
+ isc_info_sql_stmt_insert : 2,
477
+ isc_info_sql_stmt_update : 3,
478
+ isc_info_sql_stmt_delete : 4,
479
+ isc_info_sql_stmt_ddl : 5,
480
+ isc_info_sql_stmt_get_segment : 6,
481
+ isc_info_sql_stmt_put_segment : 7,
482
+ isc_info_sql_stmt_exec_procedure : 8,
483
+ isc_info_sql_stmt_start_trans : 9,
484
+ isc_info_sql_stmt_commit : 10,
485
+ isc_info_sql_stmt_rollback : 11,
486
+ isc_info_sql_stmt_select_for_upd : 12,
487
+ isc_info_sql_stmt_set_generator : 13,
488
+ isc_info_sql_stmt_savepoint : 14,
489
+ };
490
+
491
+ const DESCRIBE = [
492
+ sqlInfo.isc_info_sql_stmt_type,
493
+ sqlInfo.isc_info_sql_select,
494
+ sqlInfo.isc_info_sql_describe_vars,
495
+ sqlInfo.isc_info_sql_sqlda_seq,
496
+ sqlInfo.isc_info_sql_type,
497
+ sqlInfo.isc_info_sql_sub_type,
498
+ sqlInfo.isc_info_sql_scale,
499
+ sqlInfo.isc_info_sql_length,
500
+ sqlInfo.isc_info_sql_field,
501
+ sqlInfo.isc_info_sql_relation,
502
+ //isc_info_sql_owner,
503
+ sqlInfo.isc_info_sql_alias,
504
+ sqlInfo.isc_info_sql_describe_end,
505
+ sqlInfo.isc_info_sql_bind,
506
+ sqlInfo.isc_info_sql_describe_vars,
507
+ sqlInfo.isc_info_sql_sqlda_seq,
508
+ sqlInfo.isc_info_sql_type,
509
+ sqlInfo.isc_info_sql_sub_type,
510
+ sqlInfo.isc_info_sql_scale,
511
+ sqlInfo.isc_info_sql_length,
512
+ sqlInfo.isc_info_sql_describe_end
513
+ ];
514
+
515
+ /***********************/
516
+ /* ISC Services */
517
+ /***********************/
518
+ const iscAction = {
519
+ isc_action_svc_backup : 1, /* Starts database backup process on the server */
520
+ isc_action_svc_restore : 2, /* Starts database restore process on the server */
521
+ isc_action_svc_repair : 3, /* Starts database repair process on the server */
522
+ isc_action_svc_add_user : 4, /* Adds a new user to the security database */
523
+ isc_action_svc_delete_user : 5, /* Deletes a user record from the security database */
524
+ isc_action_svc_modify_user : 6, /* Modifies a user record in the security database */
525
+ isc_action_svc_display_user : 7, /* Displays a user record from the security database */
526
+ isc_action_svc_properties : 8, /* Sets database properties */
527
+ isc_action_svc_add_license : 9, /* Adds a license to the license file */
528
+ isc_action_svc_remove_license : 10, /* Removes a license from the license file */
529
+ isc_action_svc_db_stats : 11, /* Retrieves database statistics */
530
+ isc_action_svc_get_ib_log : 12, /* Retrieves the InterBase log file from the server */
531
+ isc_action_svc_get_fb_log : 12, // isc_action_svc_get_ib_log, /* Retrieves the Firebird log file from the server */
532
+ isc_action_svc_nbak : 20, /* start nbackup */
533
+ isc_action_svc_nrest : 21, /* start nrestore */
534
+ isc_action_svc_trace_start : 22,
535
+ isc_action_svc_trace_stop : 23,
536
+ isc_action_svc_trace_suspend : 24,
537
+ isc_action_svc_trace_resume : 25,
538
+ isc_action_svc_trace_list : 26,
539
+ };
540
+
541
+ /* Services Properties */
542
+ const service = {
543
+ isc_spb_prp_page_buffers : 5,
544
+ isc_spb_prp_sweep_interval : 6,
545
+ isc_spb_prp_shutdown_db : 7,
546
+ isc_spb_prp_deny_new_attachments : 9,
547
+ isc_spb_prp_deny_new_transactions : 10,
548
+ isc_spb_prp_reserve_space : 11,
549
+ isc_spb_prp_write_mode : 12,
550
+ isc_spb_prp_access_mode : 13,
551
+ isc_spb_prp_set_sql_dialect : 14,
552
+ isc_spb_num_att : 5,
553
+ isc_spb_num_db : 6,
554
+ // SHUTDOWN OPTION FOR 2.0
555
+ isc_spb_prp_force_shutdown : 41,
556
+ isc_spb_prp_attachments_shutdown : 42,
557
+ isc_spb_prp_transactions_shutdown : 43,
558
+ isc_spb_prp_shutdown_mode : 44,
559
+ isc_spb_prp_online_mode : 45,
560
+
561
+ isc_spb_prp_sm_normal : 0,
562
+ isc_spb_prp_sm_multi : 1,
563
+ isc_spb_prp_sm_single : 2,
564
+ isc_spb_prp_sm_full : 3,
565
+
566
+ // WRITE_MODE_PARAMETERS
567
+ isc_spb_prp_wm_async : 37,
568
+ isc_spb_prp_wm_sync : 38,
569
+
570
+ // ACCESS_MODE_PARAMETERS
571
+ isc_spb_prp_am_readonly : 39,
572
+ isc_spb_prp_am_readwrite : 40,
573
+
574
+ // RESERVE_SPACE_PARAMETERS
575
+ isc_spb_prp_res_use_full : 35,
576
+ isc_spb_prp_res : 36,
577
+
578
+ // Option Flags
579
+ isc_spb_prp_activate : 0x0100,
580
+ isc_spb_prp_db_online : 0x0200,
581
+ };
582
+
583
+ /****************************/
584
+ /* Service info */
585
+ /****************************/
586
+ const serviceInfo = {
587
+ isc_info_svc_svr_db_info: 50, /* Retrieves the number of attachments and databases */
588
+ isc_info_svc_get_license: 51, /* Retrieves all license keys and IDs from the license file */
589
+ isc_info_svc_get_license_mask: 52, /* Retrieves a bitmask representing licensed options on the server */
590
+ isc_info_svc_get_config: 53, /* Retrieves the parameters and values for IB_CONFIG */
591
+ isc_info_svc_version: 54, /* Retrieves the version of the services manager */
592
+ isc_info_svc_server_version: 55, /* Retrieves the version of the InterBase server */
593
+ isc_info_svc_implementation: 56, /* Retrieves the implementation of the InterBase server */
594
+ isc_info_svc_capabilities: 57, /* Retrieves a bitmask representing the server's capabilities */
595
+ isc_info_svc_user_dbpath: 58, /* Retrieves the path to the security database in use by the server */
596
+ isc_info_svc_get_env: 59, /* Retrieves the setting of $INTERBASE */
597
+ isc_info_svc_get_env_lock: 60, /* Retrieves the setting of $INTERBASE_LCK */
598
+ isc_info_svc_get_env_msg: 61, /* Retrieves the setting of $INTERBASE_MSG */
599
+ isc_info_svc_line: 62, /* Retrieves 1 line of service output per call */
600
+ isc_info_svc_to_eof: 63, /* Retrieves as much of the server output as will fit in the supplied buffer */
601
+ isc_info_svc_timeout: 64, /* Sets / signifies a timeout value for reading service information */
602
+ isc_info_svc_get_licensed_users: 65, /* Retrieves the number of users licensed for accessing the server */
603
+ isc_info_svc_limbo_trans: 66, /* Retrieve the limbo transactions */
604
+ isc_info_svc_running: 67, /* Checks to see if a service is running on an attachment */
605
+ isc_info_svc_get_users: 68, /* Returns the user information from isc_action_svc_display_users */
606
+ isc_info_svc_stdin: 78,
607
+ };
608
+
609
+ /*************************************/
610
+ /* Services parameter block stuff */
611
+ /*************************************/
612
+ const spb = {
613
+ isc_spb_version1 : 1,
614
+ isc_spb_current_version : 2,
615
+ isc_spb_version : 2, // isc_spb_current_version,
616
+ isc_spb_user_name : dpb.isc_dpb_user_name,
617
+ isc_spb_sys_user_name : dpb.isc_dpb_sys_user_name,
618
+ isc_spb_sys_user_name_enc : dpb.isc_dpb_sys_user_name_enc,
619
+ isc_spb_password : dpb.isc_dpb_password,
620
+ isc_spb_password_enc : dpb.isc_dpb_password_enc,
621
+ isc_spb_command_line : 105,
622
+ isc_spb_dbname : 106,
623
+ isc_spb_verbose : 107,
624
+ isc_spb_options : 108,
625
+ };
626
+
627
+ /* · Backup Service ·*/
628
+ const serviceBackup = {
629
+ isc_spb_bkp_file : 5,
630
+ isc_spb_bkp_factor : 6,
631
+ isc_spb_bkp_length : 7,
632
+ isc_spb_bkp_ignore_checksums : 0x01,
633
+ isc_spb_bkp_ignore_limbo : 0x02,
634
+ isc_spb_bkp_metadata_only : 0x04,
635
+ isc_spb_bkp_no_garbage_collect : 0x08,
636
+ isc_spb_bkp_old_descriptions : 0x10,
637
+ isc_spb_bkp_non_transportable : 0x20,
638
+ isc_spb_bkp_convert : 0x40,
639
+ isc_spb_bkp_expand : 0x80,
640
+ isc_spb_bkp_no_triggers : 0x8000,
641
+ // nbackup
642
+ isc_spb_nbk_level : 5,
643
+ isc_spb_nbk_file : 6,
644
+ isc_spb_nbk_direct : 7,
645
+ isc_spb_nbk_no_triggers : 0x01,
646
+ };
647
+
648
+ /* Restore Service ·*/
649
+ const serviceRestore = {
650
+ isc_spb_res_buffers : 9,
651
+ isc_spb_res_page_size : 10,
652
+ isc_spb_res_length : 11,
653
+ isc_spb_res_access_mode : 12,
654
+ isc_spb_res_fix_fss_data : 13,
655
+ isc_spb_res_fix_fss_metadata : 14,
656
+ isc_spb_res_am_readonly : service.isc_spb_prp_am_readonly,
657
+ isc_spb_res_am_readwrite : service.isc_spb_prp_am_readwrite,
658
+ isc_spb_res_deactivate_idx : 0x0100,
659
+ isc_spb_res_no_shadow : 0x0200,
660
+ isc_spb_res_no_validity : 0x0400,
661
+ isc_spb_res_one_at_a_time : 0x0800,
662
+ isc_spb_res_replace : 0x1000,
663
+ isc_spb_res_create : 0x2000,
664
+ isc_spb_res_use_all_space : 0x4000,
665
+ };
666
+
667
+ /* · Repair Service ·*/
668
+ const serviceRepair = {
669
+ isc_spb_rpr_commit_trans : 15,
670
+ isc_spb_rpr_rollback_trans : 34,
671
+ isc_spb_rpr_recover_two_phase : 17,
672
+ isc_spb_tra_id : 18,
673
+ isc_spb_single_tra_id : 19,
674
+ isc_spb_multi_tra_id : 20,
675
+ isc_spb_tra_state : 21,
676
+ isc_spb_tra_state_limbo : 22,
677
+ isc_spb_tra_state_commit : 23,
678
+ isc_spb_tra_state_rollback : 24,
679
+ isc_spb_tra_state_unknown : 25,
680
+ isc_spb_tra_host_site : 26,
681
+ isc_spb_tra_remote_site : 27,
682
+ isc_spb_tra_db_path : 28,
683
+ isc_spb_tra_advise : 29,
684
+ isc_spb_tra_advise_commit : 30,
685
+ isc_spb_tra_advise_rollback : 31,
686
+ isc_spb_tra_advise_unknown : 33,
687
+ isc_spb_rpr_validate_db : 0x01,
688
+ isc_spb_rpr_sweep_db : 0x02,
689
+ isc_spb_rpr_mend_db : 0x04,
690
+ isc_spb_rpr_list_limbo_trans : 0x08,
691
+ isc_spb_rpr_check_db : 0x10,
692
+ isc_spb_rpr_ignore_checksum : 0x20,
693
+ isc_spb_rpr_kill_shadows : 0x40,
694
+ isc_spb_rpr_full : 0x80,
695
+ isc_spb_rpr_icu : 0x0800,
696
+ };
697
+
698
+ /* · Security Service ·*/
699
+ const serviceSecurity = {
700
+ isc_spb_sec_userid : 5,
701
+ isc_spb_sec_groupid : 6,
702
+ isc_spb_sec_username : 7,
703
+ isc_spb_sec_password : 8,
704
+ isc_spb_sec_groupname : 9,
705
+ isc_spb_sec_firstname : 10,
706
+ isc_spb_sec_middlename : 11,
707
+ isc_spb_sec_lastname : 12,
708
+ isc_spb_sec_admin : 13,
709
+ };
710
+
711
+ /* License Service */
712
+ const serviceLicence = {
713
+ isc_spb_lic_key : 5,
714
+ isc_spb_lic_id : 6,
715
+ isc_spb_lic_desc : 7,
716
+ };
717
+
718
+ /* Statistics Service */
719
+ const serviceStatistics = {
720
+ isc_spb_sts_data_pages : 0x01,
721
+ isc_spb_sts_db_log : 0x02,
722
+ isc_spb_sts_hdr_pages : 0x04,
723
+ isc_spb_sts_idx_pages : 0x08,
724
+ isc_spb_sts_sys_relations : 0x10,
725
+ isc_spb_sts_record_versions : 0x20,
726
+ isc_spb_sts_table : 0x40,
727
+ isc_spb_sts_nocreation : 0x80,
728
+ };
729
+
730
+ /* Trace Service */
731
+ const serviceTrace = {
732
+ isc_spb_trc_id : 1,
733
+ isc_spb_trc_name : 2,
734
+ isc_spb_trc_cfg : 3,
735
+ };
736
+
737
+ module.exports = Object.freeze({
738
+ ...acceptType,
739
+ ...authPlugin,
740
+ ...authOptions,
741
+ ...blr,
742
+ ...blobType,
743
+ ...buffer,
744
+ ...cnct,
745
+ ...common,
746
+ ...connect,
747
+ ...defaultOptions,
748
+ DESCRIBE,
749
+ ...dpb,
750
+ ...dsql,
751
+ ...int,
752
+ ...iscAction,
753
+ ...iscError,
754
+ ...op,
755
+ ...protocol,
756
+ ...service,
757
+ ...serviceBackup,
758
+ ...serviceInfo,
759
+ ...serviceLicence,
760
+ ...serviceRestore,
761
+ ...serviceRepair,
762
+ ...serviceSecurity,
763
+ ...serviceStatistics,
764
+ ...serviceTrace,
765
+ ...sqlInfo,
766
+ ...sqlType,
767
+ ...spb,
768
+ ...statementInfo,
769
+ SUPPORTED_PROTOCOL,
770
+ ...tpb,
771
+ ...transactionIsolation,
772
+ });