8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:43:03 +01:00

First steps towards a C++ conversion.

This commit is contained in:
tamlin 2001-05-23 13:26:42 +00:00
parent 3ebbe26d17
commit 9a776a604e
1093 changed files with 1007905 additions and 0 deletions

27
generated/alice/makefile Normal file
View File

@ -0,0 +1,27 @@
!IF "$(OS)" == "Windows_NT"
# NOTE - If you enter an absolute path to gpre.exe, it MUST use
# MS-DOS style backslash!
GPRE_PGM=..\..\bin\gpre
DELETE_COMMAND=del /q
!ELSE
!ERROR Running on unknown operating system.
!ENDIF
REL_SRC_DIR=../../src/alice
C_FILES=alice_meta.c
all: $(C_FILES)
clean :
-$(DELETE_COMMAND) *.c
alice_meta.c : $(REL_SRC_DIR)/alice_meta.e
$(GPRE_PGM) -r -m -n $? -o >$@

View File

44
generated/burp/makefile Normal file
View File

@ -0,0 +1,44 @@
!IF "$(OS)" == "Windows_NT"
# NOTE - If you enter an absolute path to gpre.exe, it MUST use
# MS-DOS style backslash!
GPRE_PGM=..\..\bin\gpre
SED_PGM=sed
COMPILER_CFLAGS=-c -DNOMSG -DWIN32_LEAN_AND_MEAN -nologo
OBJEXT=obj
DELETE_COMMAND=del /q
!ELSE
!ERROR Running on unknown operating system.
!ENDIF
REL_SRC_DIR=../../src/burp
COMMON_CFLAGS=-I../../src -I../../src/include
CFLAGS=$(COMMON_CFLAGS) $(COMPILER_CFLAGS)
#
# C_FILES could be useful as build target in case we are only
# generate the C files into this dir
#
C_FILES=backup.c restore.c
OBJ_FILES=backup.$(OBJEXT) restore.$(OBJEXT)
all: $(OBJ_FILES)
c_files : $(C_FILES)
clean :
-$(DELETE_COMMAND) *.$(OBJEXT)
-$(DELETE_COMMAND) *.c
backup.c : $(REL_SRC_DIR)/backup.e
$(GPRE_PGM) -r -m -n $? -o >$@
restore.c : $(REL_SRC_DIR)/restore.e
$(GPRE_PGM) -r -m -n $? -o >$@

View File

33
generated/dsql/makefile Normal file
View File

@ -0,0 +1,33 @@
!IF "$(OS)" == "Windows_NT"
# NOTE - If you enter an absolute path to gpre.exe, it MUST use
# MS-DOS style backslash!
GPRE_PGM=..\..\bin\gpre
DELETE_COMMAND=del /q
!ELSE
!ERROR Running on unknown operating system.
!ENDIF
REL_SRC_DIR=../../src/dsql
C_FILES=array.c blob.c metd.c
all: $(C_FILES)
clean :
-$(DELETE_COMMAND) *.c
array.c : $(REL_SRC_DIR)/array.e
$(GPRE_PGM) -r -m -n $? -o >$@
blob.c : $(REL_SRC_DIR)/blob.e
$(GPRE_PGM) -r -m -n $? -o >$@
metd.c : $(REL_SRC_DIR)/metd.e
$(GPRE_PGM) -r -m -n $? -o >$@

View File

30
generated/dudley/makefile Normal file
View File

@ -0,0 +1,30 @@
!IF "$(OS)" == "Windows_NT"
# NOTE - If you enter an absolute path to gpre.exe, it MUST use
# MS-DOS style backslash!
GPRE_PGM=..\..\bin\gpre
DELETE_COMMAND=del /q
!ELSE
!ERROR Running on unknown operating system.
!ENDIF
REL_SRC_DIR=../../src/dudley
C_FILES=exe.c extract.c
all: $(C_FILES)
clean :
-$(DELETE_COMMAND) *.c
exe.c : $(REL_SRC_DIR)/exe.e
$(GPRE_PGM) -r -m -n $? -o >$@
extract.c : $(REL_SRC_DIR)/extract.e
$(GPRE_PGM) -r -m -n $? -o >$@

View File

27
generated/gpre/makefile Normal file
View File

@ -0,0 +1,27 @@
!IF "$(OS)" == "Windows_NT"
# NOTE - If you enter an absolute path to gpre.exe, it MUST use
# MS-DOS style backslash!
GPRE_PGM=..\..\bin\gpre
DELETE_COMMAND=del /q
!ELSE
!ERROR Running on unknown operating system.
!ENDIF
REL_SRC_DIR=../../src/gpre
C_FILES=gpre_meta.c
all: $(C_FILES)
clean :
-$(DELETE_COMMAND) *.c
gpre_meta.c : $(REL_SRC_DIR)/gpre_meta.e
$(GPRE_PGM) -r -m -n $? -o >$@

View File

33
generated/isql/makefile Normal file
View File

@ -0,0 +1,33 @@
!IF "$(OS)" == "Windows_NT"
# NOTE - If you enter an absolute path to gpre.exe, it MUST use
# MS-DOS style backslash!
GPRE_PGM=..\..\bin\gpre
DELETE_COMMAND=del /q
!ELSE
!ERROR Running on unknown operating system.
!ENDIF
REL_SRC_DIR=../../src/isql
C_FILES=extract.c isql.c show.c
all: $(C_FILES)
clean :
-$(DELETE_COMMAND) *.c
extract.c : $(REL_SRC_DIR)/extract.e
$(GPRE_PGM) -r -m -n $? -o >$@
isql.c : $(REL_SRC_DIR)/isql.e
$(GPRE_PGM) -r -m -n $? -o >$@
show.c : $(REL_SRC_DIR)/show.e
$(GPRE_PGM) -r -m -n $? -o >$@

View File

View File

48
generated/jrd/makefile Normal file
View File

@ -0,0 +1,48 @@
REL_SRC_DIR=../../src/jrd
.SUFFIXES : .e
!IF "$(OS)" == "Windows_NT"
# NOTE - This should probably also be the path taken for other
# Win32 operating systems, like Win9x/Me.
# NOTE - If you enter an absolute path to gpre.exe, it MUST use
# MS-DOS style backslash!
GPRE_PGM=..\..\bin\gpre
SED_PGM=sed
DELETE_COMMAND=del /q
#
# MS NMAKE specific directory-relative inference rule
#
{$(REL_SRC_DIR)}.e{}.c:
$(GPRE_PGM) -n -gds -raw -ids $? -o >$@
!ELSE
!ERROR Running on unknown operating system.
!ENDIF
#
# NOTE: "stats" is temporarily removed since it isn't even used.
#
# stats.c
#
C_FILES=blob_filter.c dfw.c dpm.c dyn.c dyn_def.c dyn_del.c dyn_mod.c \
dyn_util.c fun.c grant.c ini.c met.c pcmet.c scl.c stats.c
all: $(C_FILES)
clean :
-$(DELETE_COMMAND) *.c
blob_filter.c :
$(GPRE_PGM) -n -manual -raw $? -o >$@
dyn_def.c :
$(GPRE_PGM) -n -gds -raw -ids $? -o > dyn_def.c.tmp
$(SED_PGM) -f $(REL_SRC_DIR)/dyn_def.sed dyn_def.c.tmp > dyn_def.c

View File

39
generated/msgs/makefile Normal file
View File

@ -0,0 +1,39 @@
REL_SRC_DIR=../../src/msgs
.SUFFIXES : .e
!IF "$(OS)" == "Windows_NT"
# NOTE - This should probably also be the path taken for other
# Win32 operating systems, like Win9x/Me.
# NOTE - If you enter an absolute path to gpre.exe, it MUST use
# MS-DOS style backslash!
GPRE_PGM=..\..\bin\gpre
SED_PGM=sed
DELETE_COMMAND=del /q
#
# MS NMAKE specific directory-relative inference rule
#
{$(REL_SRC_DIR)}.e{}.c:
$(GPRE_PGM) -r -m -n $? -o >$@
!ELSE
!ERROR Running on unknown operating system.
!ENDIF
#
# load.c - disabled
#
C_FILES=build_file.c check_msgs.c enter_msgs.c modify_msgs.c \
change_msgs.c
all: $(C_FILES)
clean :
-$(DELETE_COMMAND) *.c

View File

View File

View File

View File

@ -0,0 +1,39 @@
!IF "$(OS)" == "Windows_NT"
# NOTE - If you enter an absolute path to gpre.exe, it MUST use
# MS-DOS style backslash!
GPRE_PGM=..\..\bin\gpre
DELETE_COMMAND=del /q
!ELSE
!ERROR Running on unknown operating system.
!ENDIF
REL_SRC_DIR=../../src/utilities
#
# rstore.c - disabled
#
C_FILES=dba.c security.c rmet.c
all: $(C_FILES)
clean :
-$(DELETE_COMMAND) *.c
dba.c : $(REL_SRC_DIR)/dba.e
$(GPRE_PGM) -r -m -n $? -o >$@
security.c : $(REL_SRC_DIR)/security.e
$(GPRE_PGM) -r -m -n $? -o >$@
rmet.c : $(REL_SRC_DIR)/rmet.e
$(GPRE_PGM) -r -m -n $? -o >$@
# Disabled - unused
#rstore.c : $(REL_SRC_DIR)/rstore.e
# $(GPRE_PGM) -r -m -n $? -o >$@

View File

743
src/alice/alice.cpp Normal file
View File

@ -0,0 +1,743 @@
//____________________________________________________________
//
// PROGRAM: Alice (All Else) Utility
// MODULE: alice.cpp
// DESCRIPTION: Neo-Debe (does everything but eat)
//
// The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html
//
// Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing
// rights and limitations under the License.
//
// The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation.
//
// All Rights Reserved.
// Contributor(s): ______________________________________.
//
//
//____________________________________________________________
//
// $Id: alice.cpp,v 1.1.1.1 2001-05-23 13:25:33 tamlin Exp $
//
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#define FB_FROM_ALICE_CPP
#include "../jrd/ib_stdio.h"
#include "../include/jrd/gds.h"
#include "../jrd/common.h"
#include "../jrd/license.h"
#include "../jrd/ibsetjmp.h"
#include "../jrd/msg_encode.h"
#include "../alice/alice.h"
#include "../alice/aliceswi.h"
#include "../alice/all.h"
#include "../alice/alice_proto.h"
#include "../alice/all_proto.h"
#include "../alice/exe_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/svc.h"
#include "../jrd/svc_proto.h"
#include "../jrd/thd_proto.h"
#ifdef SUPERSERVER
#include "../utilities/cmd_util_proto.h"
#endif
#ifdef WIN_NT
#include <windows.h>
#endif
#if (defined WIN_NT || defined PC_PLATFORM)
#include <io.h>
#endif
extern "C" {
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
static USHORT val_err_table[] = {
0,
55, /* msg 55: \n\tNumber of record level errors\t: %ld */
56, /* msg 56: \tNumber of Blob page errors\t: %ld */
57, /* msg 57: \tNumber of data page errors\t: %ld */
58, /* msg 58: \tNumber of index page errors\t: %ld */
59, /* msg 59: \tNumber of pointer page errors\t: %ld */
60, /* msg 60: \tNumber of transaction page errors\t: %ld */
61 /* msg 61: \tNumber of database page errors\t: %ld */
};
#ifndef NETWARE_386
struct tgbl *gdgbl;
#endif
#define ALICE_MSG_FAC 3
#if defined (WIN95) && !defined (GUI_TOOLS)
static BOOL fAnsiCP = FALSE;
#define TRANSLATE_CP(a) if (!fAnsiCP) AnsiToOem(a, a)
#else
#define TRANSLATE_CP(a)
#endif
static void expand_filename(TEXT *, TEXT *);
static int output_thread(SLONG, UCHAR *);
static int output_main(SLONG, UCHAR *);
static int output_svc(SLONG, UCHAR *);
static void alice_output(CONST SCHAR *, ...);
#ifdef SUPERSERVER
//____________________________________________________________
//
// Entry point for GFIX in case of service manager.
//
int main_gfix(SVC service)
{
int exit_code;
exit_code = ALICE_gfix(service->svc_argc, service->svc_argv,
output_thread, (SLONG) service);
service->svc_handle = 0;
if (service->svc_service->in_use != NULL)
*(service->svc_service->in_use) = FALSE;
// Mark service thread as finished.
// If service is detached, cleanup memory being used by service.
SVC_finish(service, SVC_finished);
return exit_code;
}
//____________________________________________________________
//
// Routine which is passed to GFIX for calling back when there is output.
//
static int output_thread(SLONG output_data, UCHAR * output_buf)
{
SVC_fprintf((SVC) output_data, "%s", output_buf);
return 0;
}
#else
#ifndef GUI_TOOLS
//____________________________________________________________
//
// Call the 'real' main.
//
int CLIB_ROUTINE main(int argc, char *argv[])
{
int exit_code;
exit_code = ALICE_gfix(argc, argv, output_main, (SLONG) NULL);
return exit_code;
}
//____________________________________________________________
//
// Routine which is passed to GFIX for calling back when there is output.
//
static int output_main(SLONG output_data, UCHAR * output_buf)
{
ib_fprintf(ib_stderr, "%s", output_buf);
return 0;
}
#endif
#endif
//____________________________________________________________
//
// Routine which is passed to GFIX for calling back when there is output
// if gfix is run as a service
//
static int output_svc(SLONG output_data, UCHAR * output_buf)
{
ib_fprintf(ib_stdout, "%s", output_buf);
return 0;
}
//____________________________________________________________
//
// Routine called by command line utility, and server manager
// Parse switches and do work
//
int DLL_EXPORT ALICE_gfix(
int argc,
char *argv[],
OUTPUTPROC output_proc, SLONG output_data)
{
USHORT error, i;
IN_SW_TAB table = alice_in_sw_table;
TEXT *database, string[512], *p, *q;
ULONG switches;
SLONG redir_in, redir_out, redir_err;
JMP_BUF env;
USHORT ret;
#if defined (WIN95) && !defined (GUI_TOOLS)
BOOL fAnsiCP fAnsiCP = (GetConsoleCP() == GetACP());
#endif
VOLATILE tgbl *tdgbl = (struct tgbl *) gds__alloc(sizeof(*tdgbl));
// NOMEM: return error, FREE: during function exit in the SETJMP
if (tdgbl == NULL)
return FINI_ERROR;
// TMN
#if 0
SET_THREAD_DATA;
#else
tdgbl->tgbl_thd_data.thdd_type = THDD_TYPE_TALICE;
#endif
SVC_PUTSPECIFIC_DATA;
memset((void *) tdgbl, 0, sizeof(*tdgbl));
// TMN: I can't for my life understand why the jmp_buf is defined
// as a UCHAR* in ' struct tgbl', but it forces this cast.
tdgbl->alice_env = (UCHAR * volatile) env;
tdgbl->output_proc = output_proc;
tdgbl->output_data = output_data;
tdgbl->ALICE_permanent_pool = NULL;
tdgbl->ALICE_default_pool = NULL;
tdgbl->pools = NULL;
if (SETJMP(env)) {
int exit_code;
/* All calls to EXIT(), normal and error exits, wind up here */
SVC_STARTED(tdgbl->service_blk);
tdgbl->alice_env = NULL;
exit_code = tdgbl->exit_code;
/* Close the status output file */
if (tdgbl->sw_redirect == TRUE && tdgbl->output_file != NULL) {
ib_fclose(tdgbl->output_file);
tdgbl->output_file = NULL;
}
/* Free all unfreed memory used by Gfix itself */
ALLA_fini();
RESTORE_THREAD_DATA;
if (tdgbl != NULL) {
gds__free((SLONG *) tdgbl);
}
#if defined(DEBUG_GDS_ALLOC) && !defined(SUPERSERVER)
gds_alloc_report(0, __FILE__, __LINE__);
#endif
/* All returns occur from this point - even normal returns */
return exit_code;
}
#ifdef VMS
argc = VMS_parse(&argv, argc);
#endif
// Perform some special handling when run as an Interbase service. The
// first switch can be "-svc" (lower case!) or it can be "-svc_re" followed
// by 3 file descriptors to use in re-directing ib_stdin, ib_stdout, and ib_stderr.
tdgbl->sw_service = FALSE;
tdgbl->sw_service_thd = FALSE;
tdgbl->service_blk = NULL;
tdgbl->status =
/* TMN: cast away volatile */
(long *) tdgbl->status_vector;
if (argc > 1 && !strcmp(argv[1], "-svc")) {
tdgbl->sw_service = TRUE;
argv++;
argc--;
}
else if (argc > 1 && !strcmp(argv[1], "-svc_thd")) {
tdgbl->sw_service = TRUE;
tdgbl->sw_service_thd = TRUE;
tdgbl->service_blk = (SVC) output_data;
tdgbl->status = tdgbl->service_blk->svc_status;
argv++;
argc--;
}
#ifndef NETWARE_386
else if (argc > 4 && !strcmp(argv[1], "-svc_re")) {
tdgbl->sw_service = TRUE;
tdgbl->output_proc = output_svc;
redir_in = atol(argv[2]);
redir_out = atol(argv[3]);
redir_err = atol(argv[4]);
#ifdef WIN_NT
#if defined (WIN95) && !defined (GUI_TOOLS)
fAnsiCP = TRUE;
#endif
redir_in = _open_osfhandle(redir_in, 0);
redir_out = _open_osfhandle(redir_out, 0);
redir_err = _open_osfhandle(redir_err, 0);
#endif
if (redir_in != 0)
if (dup2((int) redir_in, 0))
close((int) redir_in);
if (redir_out != 1)
if (dup2((int) redir_out, 1))
close((int) redir_out);
if (redir_err != 2)
if (dup2((int) redir_err, 2))
close((int) redir_err);
argv += 4;
argc -= 4;
}
#endif
tdgbl->ALICE_data.ua_user = NULL;
tdgbl->ALICE_data.ua_password = NULL;
// Start by parsing switches
error = 0;
switches = 0;
tdgbl->ALICE_data.ua_shutdown_delay = 0;
database = NULL;
argv++;
while (--argc > 0) {
if ((*argv)[0] != '-') {
if (database)
ALICE_error(1, database, 0, 0, 0, 0); /* msg 1: "data base file name (%s) already given", */
database = *argv++;
#if defined (WIN95) && !defined (GUI_TOOLS)
// There is a small problem with SuperServer on NT, since it is a
// Windows app, it uses the ANSI character set. All the console
// apps use the OEN character set. We need to pass the database
// name in the correct character set.
// if (GetConsoleCP != GetACP())
// OemToAnsi(database, database);
//
#else
#endif
continue;
}
ALICE_down_case(*argv++, string);
if (!string[1])
continue;
for (table = alice_in_sw_table; TRUE; table++) {
if (!(p = (TEXT *) table->in_sw_name)) {
ALICE_print(2, *--argv, 0, 0, 0, 0); /* msg 2: invalid switch %s */
error = TRUE;
break;
}
q = &string[1];
while (*q && *p++ == *q)
q++;
if (!*q)
break;
}
if (error)
break;
if (*table->in_sw_name == 'x')
tdgbl->ALICE_data.ua_debug++;
if (table->in_sw_value == sw_z)
ALICE_print(3, GDS_VERSION, 0, 0, 0, 0); /* msg 3: gfix version %s */
if ((table->in_sw_incompatibilities & switches) ||
(table->in_sw_requires && !(table->in_sw_requires & switches))) {
ALICE_print(4, 0, 0, 0, 0, 0); /* msg 4: incompatible switch combination */
error = TRUE;
break;
}
switches |= table->in_sw_value;
if (table->in_sw_value & sw_begin_log) {
if (--argc <= 0)
ALICE_error(5, 0, 0, 0, 0, 0); /* msg 5: replay log pathname required */
expand_filename(*argv++, /* TMN: cast away volatile */
(TEXT *) tdgbl->ALICE_data.ua_log_file);
}
if (table->in_sw_value & (sw_buffers)) {
if (--argc <= 0)
ALICE_error(6, 0, 0, 0, 0, 0); /* msg 6: number of page buffers for cache required */
ALICE_down_case(*argv++, string);
if ((!(tdgbl->ALICE_data.ua_page_buffers = atoi(string)))
&& (strcmp(string, "0")))
ALICE_error(7, 0, 0, 0, 0, 0); /* msg 7: numeric value required */
if (tdgbl->ALICE_data.ua_page_buffers < 0)
ALICE_error(8, 0, 0, 0, 0, 0); /* msg 8: positive numeric value required */
}
if (table->in_sw_value & (sw_housekeeping)) {
if (--argc <= 0)
ALICE_error(9, 0, 0, 0, 0, 0); /* msg 9: number of transactions per sweep required */
ALICE_down_case(*argv++, string);
if ((!(tdgbl->ALICE_data.ua_sweep_interval = atoi(string)))
&& (strcmp(string, "0")))
ALICE_error(7, 0, 0, 0, 0, 0); /* msg 7: numeric value required */
if (tdgbl->ALICE_data.ua_sweep_interval < 0)
ALICE_error(8, 0, 0, 0, 0, 0); /* msg 8: positive numeric value required */
}
if (table->in_sw_value & (sw_set_db_dialect)) {
if (--argc <= 0)
ALICE_error(9, 0, 0, 0, 0, 0); /* msg 9: dialect info is required XXX */
ALICE_down_case(*argv++, string);
if ((!(tdgbl->ALICE_data.ua_db_SQL_dialect = atoi(string))) &&
(strcmp(string, "0")))
ALICE_error(7, 0, 0, 0, 0, 0); /* msg 7: numeric value required */
if (tdgbl->ALICE_data.ua_db_SQL_dialect < 0)
ALICE_error(8, 0, 0, 0, 0, 0); /* msg 8: positive numeric value
required */
}
if (table->in_sw_value & (sw_commit | sw_rollback | sw_two_phase)) {
if (--argc <= 0)
ALICE_error(10, 0, 0, 0, 0, 0); /* msg 10: transaction number or "all" required */
ALICE_down_case(*argv++, string);
if (!(tdgbl->ALICE_data.ua_transaction = atoi(string)))
if (strcmp(string, "all"))
ALICE_error(10, 0, 0, 0, 0, 0); /* msg 10: transaction number or "all" required */
else
switches |= sw_list;
}
if (table->in_sw_value & sw_write) {
if (--argc <= 0)
ALICE_error(11, 0, 0, 0, 0, 0); /* msg 11: "sync" or "async" required */
ALICE_down_case(*argv++, string);
if (!strcmp(string, ALICE_SW_SYNC))
tdgbl->ALICE_data.ua_force = TRUE;
else if (!strcmp(string, ALICE_SW_ASYNC))
tdgbl->ALICE_data.ua_force = FALSE;
else
ALICE_error(11, 0, 0, 0, 0, 0); /* msg 11: "sync" or "async" required */
}
if (table->in_sw_value & sw_use) {
if (--argc <= 0)
ALICE_error(12, 0, 0, 0, 0, 0); /* msg 12: "full" or "reserve" required */
ALICE_down_case(*argv++, string);
if (!strcmp(string, "full"))
tdgbl->ALICE_data.ua_use = TRUE;
else if (!strcmp(string, "reserve"))
tdgbl->ALICE_data.ua_use = FALSE;
else
ALICE_error(12, 0, 0, 0, 0, 0); /* msg 12: "full" or "reserve" required */
}
if (table->in_sw_value & sw_user) {
if (--argc <= 0)
ALICE_error(13, 0, 0, 0, 0, 0); /* msg 13: user name required */
tdgbl->ALICE_data.ua_user =
const_cast < UCHAR * volatile >(reinterpret_cast <
UCHAR * >(*argv++));
}
if (table->in_sw_value & sw_password) {
if (--argc <= 0)
ALICE_error(14, 0, 0, 0, 0, 0); /* msg 14: password required */
tdgbl->ALICE_data.ua_password =
const_cast < UCHAR * volatile >(reinterpret_cast <
UCHAR * >(*argv++));
}
if (table->in_sw_value & sw_disable) {
if (--argc <= 0)
ALICE_error(15, 0, 0, 0, 0, 0); /* msg 15: subsystem name */
ALICE_down_case(*argv++, string);
if (strcmp(string, "wal"))
ALICE_error(16, 0, 0, 0, 0, 0); /* msg 16: "wal" required */
}
if (table->in_sw_value & (sw_attach | sw_force | sw_tran | sw_cache)) {
if (--argc <= 0)
ALICE_error(17, 0, 0, 0, 0, 0); /* msg 17: number of seconds required */
ALICE_down_case(*argv++, string);
if ((!(tdgbl->ALICE_data.ua_shutdown_delay = atoi(string)))
&& (strcmp(string, "0")))
ALICE_error(7, 0, 0, 0, 0, 0); /* msg 7: numeric value required */
if (tdgbl->ALICE_data.ua_shutdown_delay < 0
|| tdgbl->ALICE_data.ua_shutdown_delay > 32767)
ALICE_error(18, 0, 0, 0, 0, 0); /* msg 18: numeric value between 0 and 32767 inclusive required */
}
#ifdef READONLY_DATABASE
if (table->in_sw_value & sw_mode) {
if (--argc <= 0)
ALICE_error(110, 0, 0, 0, 0, 0); /* msg 110: "read_only" or "read_write" required */
ALICE_down_case(*argv++, string);
if (!strcmp(string, ALICE_SW_MODE_RO))
tdgbl->ALICE_data.ua_read_only = TRUE;
else if (!strcmp(string, ALICE_SW_MODE_RW))
tdgbl->ALICE_data.ua_read_only = FALSE;
else
ALICE_error(110, 0, 0, 0, 0, 0); /* msg 110: "read_only" or "read_write" required */
}
#endif
}
// put this here since to put it above overly complicates the parsing
// can't use tbl_requires since it only looks backwards on command line
if ((switches & sw_shut)
&& !(switches & ((sw_attach | sw_force | sw_tran | sw_cache))))
ALICE_error(19, 0, 0, 0, 0, 0); /* msg 19: must specify type of shutdown */
// catch the case where -z is only command line option
// switches is unset since sw_z == 0
if (!switches && !error && table->in_sw_value == sw_z)
EXIT(FINI_OK);
if (!switches || !(switches & ~(sw_user | sw_password))) {
#ifndef SUPERSERVER
ALICE_print(20, 0, 0, 0, 0, 0); /* msg 20: please retry, specifying an option */
#endif
error = TRUE;
}
if (error) {
#ifdef SUPERSERVER
CMD_UTIL_put_svc_status(tdgbl->service_blk->svc_status, ALICE_MSG_FAC,
20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
SVC_STARTED(tdgbl->service_blk);
#else
ALICE_print(21, 0, 0, 0, 0, 0); /* msg 21: plausible options are:\n */
for (table = alice_in_sw_table; table->in_sw_msg; table++)
ALICE_print(table->in_sw_msg, 0, 0, 0, 0, 0);
ALICE_print(22, 0, 0, 0, 0, 0); /* msg 22: \n qualifiers show the major option in parenthesis */
#endif
EXIT(FINI_ERROR);
}
if (!database)
ALICE_error(23, 0, 0, 0, 0, 0); /* msg 23: please retry, giving a database name */
// generate the database parameter block for the attach,
// based on the various switches
if (switches & (sw_list | sw_commit | sw_rollback | sw_two_phase))
ret = EXE_two_phase(database, switches);
else {
ret = EXE_action(database, switches);
USHORT count = 0;
for (i = 0; i < MAX_VAL_ERRORS; i++)
if (tdgbl->ALICE_data.ua_val_errors[i])
count++;
if ((count)
&& !(tdgbl->ALICE_data.ua_val_errors[VAL_INVALID_DB_VERSION])) {
ALICE_print(24, 0, 0, 0, 0, 0); /* msg 24: Summary of validation errors\n */
for (i = 0; i < MAX_VAL_ERRORS; i++)
if (tdgbl->ALICE_data.ua_val_errors[i])
ALICE_print(val_err_table[i],
reinterpret_cast <
char *>(tdgbl->ALICE_data.ua_val_errors[i]),
0, 0, 0, 0);
}
}
if (ret == FINI_ERROR)
ALICE_print_status(tdgbl->status);
EXIT(FINI_OK);
return 0; // compiler silencer
}
//____________________________________________________________
//
// Copy a string, down casing as we go.
//
void ALICE_down_case(TEXT * in, TEXT * out)
{
TEXT c;
while (c = *in++)
*out++ = (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c;
*out = 0;
}
//____________________________________________________________
//
// Display a formatted error message
//
void ALICE_print(USHORT number,
TEXT * arg1,
TEXT * arg2, TEXT * arg3, TEXT * arg4, TEXT * arg5)
{
TEXT buffer[256];
gds__msg_format(0, ALICE_MSG_FAC, number, sizeof(buffer), buffer, arg1,
arg2, arg3, arg4, arg5);
TRANSLATE_CP(buffer);
alice_output("%s\n", buffer);
}
//____________________________________________________________
//
// Print error message. Use isc_interprete
// to allow redirecting output.
//
void ALICE_print_status(STATUS * status_vector)
{
#ifdef SUPERSERVER
TGBL tdgbl;
STATUS *status;
int i = 0, j;
#endif
STATUS *vector;
SCHAR s[1024];
if (status_vector) {
vector = status_vector;
#ifdef SUPERSERVER
tdgbl = GET_THREAD_DATA;
status = tdgbl->service_blk->svc_status;
if (status != status_vector) {
while (*status && (++i < ISC_STATUS_LENGTH))
status++;
for (j = 0; status_vector[j] && (i < ISC_STATUS_LENGTH); j++, i++)
*status++ = status_vector[j];
}
#endif
isc_interprete(s, &vector);
TRANSLATE_CP(s);
alice_output("%s\n", s);
/* Continuation of error */
s[0] = '-';
while (isc_interprete(s + 1, &vector)) {
TRANSLATE_CP(s);
alice_output("%s\n", s);
}
}
}
//____________________________________________________________
//
// Format and print an error message, then punt.
//
void ALICE_error(USHORT number,
TEXT * arg1,
TEXT * arg2, TEXT * arg3, TEXT * arg4, TEXT * arg5)
{
TGBL tdgbl;
TEXT buffer[256];
#ifdef SUPERSERVER
STATUS *status;
#endif
tdgbl = GET_THREAD_DATA;
#ifdef SUPERSERVER
status = tdgbl->service_blk->svc_status;
CMD_UTIL_put_svc_status(status, ALICE_MSG_FAC, number,
isc_arg_string, arg1,
isc_arg_string, arg2,
isc_arg_string, arg3,
isc_arg_string, arg4, isc_arg_string, arg5);
#endif
gds__msg_format(0, ALICE_MSG_FAC, number, sizeof(buffer), buffer, arg1,
arg2, arg3, arg4, arg5);
TRANSLATE_CP(buffer);
alice_output("%s\n", buffer);
EXIT(FINI_ERROR);
}
//____________________________________________________________
//
// Platform independent output routine.
//
static void alice_output(CONST SCHAR * format, ...)
{
va_list arglist;
UCHAR buf[1000];
int exit_code;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (tdgbl->sw_redirect == NOOUTPUT || format[0] == '\0') {
exit_code =
tdgbl->output_proc(tdgbl->output_data,
reinterpret_cast < UCHAR * >(""));
}
else if (tdgbl->sw_redirect == TRUE && tdgbl->output_file != NULL) {
VA_START(arglist, format);
ib_vfprintf(tdgbl->output_file, format, arglist);
va_end(arglist);
exit_code =
tdgbl->output_proc(tdgbl->output_data,
reinterpret_cast < UCHAR * >(""));
}
else {
VA_START(arglist, format);
vsprintf((char *) buf, format, arglist);
va_end(arglist);
exit_code = tdgbl->output_proc(tdgbl->output_data, buf);
}
if (exit_code != 0)
EXIT(exit_code);
}
//____________________________________________________________
//
// Fully expand a file name. If the file doesn't exist, do something
// intelligent.
//
static void expand_filename(TEXT * filename, TEXT * expanded_name)
{
strcpy(expanded_name, filename);
}
} // extern "C"

228
src/alice/alice.h Normal file
View File

@ -0,0 +1,228 @@
/*
* PROGRAM: Alice
* MODULE: alice.h
* DESCRIPTION: Block definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _ALICE_ALICE_H_
#define _ALICE_ALICE_H_
#include "../jrd/ib_stdio.h"
#include "../jrd/ibase.h"
#include "../jrd/ibsetjmp.h"
#include "../jrd/thd.h"
#include "../alice/all.h"
#include "../alice/alice_proto.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
#define BLKDEF(type, root, tail) type,
enum blk_t {
type_MIN = 0,
#include "../alice/blk.h"
type_MAX
};
#undef BLKDEF
#define VAL_INVALID_DB_VERSION 0
#define VAL_RECORD_ERRORS 1
#define VAL_BLOB_PAGE_ERRORS 2
#define VAL_DATA_PAGE_ERRORS 3
#define VAL_INDEX_PAGE_ERRORS 4
#define VAL_POINTER_PAGE_ERRORS 5
#define VAL_TIP_PAGE_ERRORS 6
#define VAL_PAGE_ERRORS 7
#define MAX_VAL_ERRORS 8
typedef struct user_action
{
ULONG ua_switches;
UCHAR *ua_user;
UCHAR *ua_password;
UCHAR ua_use;
UCHAR ua_force;
BOOLEAN ua_read_only;
SLONG ua_shutdown_delay;
SLONG ua_sweep_interval;
SLONG ua_transaction;
SLONG ua_page_buffers;
USHORT ua_debug;
SLONG ua_val_errors[MAX_VAL_ERRORS];
TEXT ua_log_file[MAXPATHLEN];
USHORT ua_db_SQL_dialect;
} *USER_ACTION;
/* String block: used to store a string of constant length. */
typedef struct str {
struct blk str_header;
USHORT str_length;
UCHAR str_data[2];
} *STR;
/* Transaction block: used to store info about a multidatabase transaction. */
typedef struct tdr
{
struct blk tdr_header;
struct tdr *tdr_next; /* next subtransaction */
SLONG tdr_id; /* database-specific transaction id */
struct str *tdr_fullpath; /* full (possibly) remote pathname */
TEXT *tdr_filename; /* filename within full pathname */
struct str *tdr_host_site; /* host for transaction */
struct str *tdr_remote_site; /* site for remote transaction */
SLONG *tdr_handle; /* reconnected transaction handle */
SLONG *tdr_db_handle; /* reattached database handle */
USHORT tdr_db_caps; /* capabilities of database */
USHORT tdr_state; /* see flags below */
} *TDR;
/* Transaction Description Record */
#define TDR_VERSION 1
#define TDR_HOST_SITE 1
#define TDR_DATABASE_PATH 2
#define TDR_TRANSACTION_ID 3
#define TDR_REMOTE_SITE 4
/* flags for tdr_db_caps */
#define CAP_none 0
#define CAP_transactions 1 /* db has a RDB$TRANSACTIONS relation */
/* flags for tdr_state */
#define TRA_none 0 /* transaction description record is missing */
#define TRA_limbo 1 /* has been prepared */
#define TRA_commit 2 /* has committed */
#define TRA_rollback 3 /* has rolled back */
#define TRA_unknown 4 /* database couldn't be reattached, state is unknown */
/* a couple of obscure blocks used only in data allocator routines */
typedef struct vec
{
struct blk vec_header;
ULONG vec_count;
struct blk *vec_object[1];
} *VEC;
typedef struct vcl
{
struct blk vcl_header;
ULONG vcl_count;
SLONG vcl_long[1];
} *VCL;
/* Global switches and data */
#include "../jrd/svc.h"
typedef struct tgbl
{
struct thdd tgbl_thd_data;
struct user_action ALICE_data;
PLB ALICE_permanent_pool;
PLB ALICE_default_pool;
STATUS status_vector[ISC_STATUS_LENGTH];
VEC pools;
UCHAR* alice_env;
int exit_code;
OUTPUTPROC output_proc;
SLONG output_data;
IB_FILE* output_file;
SVC service_blk;
isc_db_handle db_handle;
isc_tr_handle tr_handle;
STATUS* status;
USHORT sw_redirect;
USHORT sw_service;
USHORT sw_service_thd;
} *TGBL;
#ifdef GET_THREAD_DATA
#undef GET_THREAD_DATA
#endif
#ifdef SUPERSERVER
#define GET_THREAD_DATA ((TGBL) THD_get_specific())
#ifdef __cplusplus
#ifdef FB_FROM_ALICE_CPP
#define SET_THREAD_DATA THD_put_specific ((THDD) tdgbl); \
tdgbl->tgbl_thd_data.thdd_type = \
reinterpret_cast<volatile ULONG>(THDD_TYPE_TALICE)
#else /* FB_FROM_ALICE_CPP */
#define SET_THREAD_DATA THD_put_specific ((THDD) tdgbl); \
tdgbl->tgbl_thd_data.thdd_type = \
reinterpret_cast<tgbl*>(THDD_TYPE_TALICE)
#endif /* FB_FROM_ALICE_CPP */
#else
#define SET_THREAD_DATA THD_put_specific ((THDD) tdgbl); \
tdgbl->tgbl_thd_data.thdd_type=THDD_TYPE_TALICE
#endif
#define RESTORE_THREAD_DATA THD_restore_specific();
#else
extern struct tgbl *gdgbl;
#define GET_THREAD_DATA (gdgbl)
#ifdef __cplusplus
#define SET_THREAD_DATA gdgbl = tdgbl; \
tdgbl->tgbl_thd_data.thdd_type = const_cast<tgbl*>(THDD_TYPE_TGBL)
#else
#define SET_THREAD_DATA gdgbl = tdgbl; \
tdgbl->tgbl_thd_data.thdd_type = THDD_TYPE_TGBL
#endif
#define RESTORE_THREAD_DATA
#endif
#if defined(__cplusplus)
#define EXIT(code) { tdgbl->exit_code = (code); \
if (tdgbl->alice_env != NULL) \
LONGJMP(reinterpret_cast<jmp_buf&>(const_cast<UCHAR*>(tdgbl->alice_env)), 1); }
#else
#define EXIT(code) { tdgbl->exit_code = (code); \
if (tdgbl->alice_env != NULL) \
LONGJMP(tdgbl->alice_env, 1); }
#endif /* __cplusplus */
#define NOOUTPUT 2
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _ALICE_ALICE_H_ */

510
src/alice/alice_meta.e Normal file
View File

@ -0,0 +1,510 @@
/*
* tab=4
*
*____________________________________________________________
*
* PROGRAM: Alice (All Else) Utility
* MODULE: met.e
* DESCRIPTION: Metadata lookup routines
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
*
*____________________________________________________________
*
* $Id: alice_meta.e,v 1.1.1.1 2001-05-23 13:25:33 tamlin Exp $
*/
#include <stdio.h>
#include "../jrd/common.h"
#include "../jrd/ibsetjmp.h"
#include "../include/jrd/gds.h"
#include "../jrd/license.h"
#include "../alice/alice.h"
#include "../alice/all.h"
#include "../alice/alloc.h"
#include "../alice/all_proto.h"
#include "../alice/alice_meta.h"
#include "../jrd/gds_proto.h"
#include "../jrd/thd_proto.h"
/* Transaction Description Record */
#define TDR_VERSION 1
#define TDR_HOST_SITE 1
#define TDR_DATABASE_PATH 2
#define TDR_TRANSACTION_ID 3
#define TDR_REMOTE_SITE 4
#define TDR_PROTOCOL 5
/* For service APIs the follow DB handle is #defined to be a value stored
* in thread data. This is also done for other statics generated by
* GPRE. This is to avoid multiple threading problems with module
* level statics.
*/
DATABASE DB = STATIC FILENAME "yachts.lnk";
#define DB tdgbl->db_handle
#define gds__trans tdgbl->tr_handle
static STR alloc_string(TEXT **);
static USHORT get_capabilities(STATUS *);
static TDR get_description(SLONG[2]);
static void parse_fullpath(TDR);
static USHORT snarf_blob(SLONG[2], USHORT, TEXT *);
/*
table used to determine capabilities, checking for specific
fields in system relations
*/
typedef struct rfr_tab_t {
TEXT *relation;
TEXT *field;
int bit_mask;
} *RFR_TAB;
static struct rfr_tab_t rfr_table[] = {
"RDB$TRANSACTIONS", "RDB$TRANSACTION_DESCRIPTION", CAP_transactions,
0, 0, 0
};
#ifdef GUI_TOOLS
#define RETURN_ERROR(user_status) \
{ memcpy (user_status, gds__status, sizeof (gds__status)); \
LONGJMP (tdgbl->alice_env, 1); }
#else
#define RETURN_ERROR(user_status) \
{ ALICE_print_status (gds__status); \
LONGJMP (tdgbl->alice_env, 1); }
#endif
/*____________________________________________________________
*
* Disable WAL for the database forcibly.
* Drop all the entries from RDB$LOG_FILES
*/
void MET_disable_wal(STATUS * user_status, isc_db_handle handle)
{
SLONG *request = NULL;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (!(DB = handle))
return;
START_TRANSACTION ON_ERROR RETURN_ERROR(user_status) END_ERROR;
FOR(REQUEST_HANDLE request)
X IN RDB$LOG_FILES ERASE X;
END_FOR COMMIT ON_ERROR RETURN_ERROR(user_status) END_ERROR;
}
/*____________________________________________________________
*
* Get the state of a transaction,
* assuming that the database has
* already been attached.
*/
void MET_get_state(STATUS * user_status, TDR trans)
{
SLONG *request = NULL;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (!(DB = trans->tdr_db_handle) ||
!(trans->tdr_db_caps & CAP_transactions)) {
trans->tdr_state = TRA_unknown;
return;
}
START_TRANSACTION ON_ERROR RETURN_ERROR(user_status) END_ERROR;
FOR(REQUEST_HANDLE request)
TRA IN RDB$TRANSACTIONS WITH
TRA.RDB$TRANSACTION_ID = trans->tdr_id
trans->tdr_state = TRA.RDB$TRANSACTION_STATE;
END_FOR ON_ERROR RETURN_ERROR(user_status) END_ERROR;
gds__release_request(gds__status, GDS_REF(request));
if (gds__status[1]) {
RETURN_ERROR(user_status)
}
ROLLBACK ON_ERROR RETURN_ERROR(user_status) END_ERROR;
}
/*____________________________________________________________
*
* Get the description of a transaction in
* limbo, including all associated transactions
* in other databases.
*/
TDR MET_get_transaction(STATUS * user_status, isc_db_handle handle, SLONG id)
{
SLONG *request = NULL;
TDR trans = NULL;
USHORT capabilities;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (!(DB = handle))
return 0;
START_TRANSACTION ON_ERROR RETURN_ERROR(user_status) END_ERROR;
capabilities = get_capabilities(user_status);
if (capabilities & CAP_transactions) {
FOR(REQUEST_HANDLE request)
TRA IN RDB$TRANSACTIONS WITH
TRA.RDB$TRANSACTION_ID = id AND
TRA.RDB$TRANSACTION_DESCRIPTION NOT MISSING
trans = get_description(&TRA.RDB$TRANSACTION_DESCRIPTION);
END_FOR ON_ERROR RETURN_ERROR(user_status) END_ERROR;
gds__release_request(gds__status, GDS_REF(request));
if (gds__status[1]) {
RETURN_ERROR(user_status)
}
}
ROLLBACK ON_ERROR RETURN_ERROR(user_status) END_ERROR;
if (trans)
trans->tdr_db_caps = capabilities;
return trans;
}
/*____________________________________________________________
*
* Get the capabilities associated with
* the database for a particular transaction.
*/
void MET_set_capabilities(STATUS * user_status, TDR trans)
{
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (!(DB = trans->tdr_db_handle))
return;
START_TRANSACTION ON_ERROR RETURN_ERROR(user_status) END_ERROR;
trans->tdr_db_caps = get_capabilities(user_status);
ROLLBACK ON_ERROR RETURN_ERROR(user_status) END_ERROR;
}
/*____________________________________________________________
*
* Eat a string with a byte-encoded length.
*/
static STR alloc_string(TEXT ** ptr)
{
TEXT *p, *q;
USHORT length;
STR string;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
p = *ptr;
length = (USHORT) * p++;
string = (STR) ALLOCDV(type_str, length + 1);
q = (TEXT *) string->str_data;
while (length--)
*q++ = *p++;
*q = 0;
*ptr = p;
return string;
}
/*____________________________________________________________
*
* Get the capabilities associated with
* the database for a particular transaction.
*/
static USHORT get_capabilities(STATUS * user_status)
{
ULONG *req;
RFR_TAB rel_field_table;
USHORT capabilities = CAP_none;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
req = NULL;
/* Look for desired fields in system relations */
for (rel_field_table = rfr_table; rel_field_table->relation;
rel_field_table++) {
FOR(REQUEST_HANDLE req) x IN DB.
RDB$RELATION_FIELDS WITH x.RDB$RELATION_NAME =
rel_field_table->relation AND x.RDB$FIELD_NAME =
rel_field_table->field capabilities |= rel_field_table->bit_mask;
END_FOR ON_ERROR RETURN_ERROR(user_status) END_ERROR;
}
gds__release_request(gds__status, GDS_REF(req));
if (gds__status[1]) {
RETURN_ERROR(user_status)
}
return capabilities;
}
/*____________________________________________________________
*
* Get the description of a transaction in
* limbo, including all associated transactions
* in other databases.
*/
static TDR get_description(SLONG blob_id[2])
{
SLONG id_length, id;
USHORT length;
TEXT buffer[1024], *bigger_buffer, *p;
TDR trans, ptr;
STR host_site, database_path;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
p = buffer;
if (length = snarf_blob(blob_id, (USHORT) sizeof(buffer), buffer)) {
p = bigger_buffer = (TEXT *) gds__alloc((SLONG) length);
snarf_blob(blob_id, length, bigger_buffer);
}
trans = NULL;
host_site = database_path = NULL;
/* skip version number */
p++;
while (*p)
switch (*p++) {
case TDR_HOST_SITE:
host_site = alloc_string(&p);
break;
case TDR_DATABASE_PATH:
database_path = alloc_string(&p);
break;
case TDR_TRANSACTION_ID:
id_length = *p++;
id = gds__vax_integer(p, id_length);
p += id_length;
if (!trans)
trans = ptr = (TDR) ALLOCD(type_tdr);
else {
ptr->tdr_next = (TDR) ALLOCD(type_tdr);
ptr = ptr->tdr_next;
}
ptr->tdr_host_site = host_site;
ptr->tdr_fullpath = database_path;
parse_fullpath(ptr);
ptr->tdr_id = id;
database_path = NULL;
break;
default:
ALICE_print(108, 0, 0, 0, 0, 0); /* msg 108: Transaction description item unknown. */
if (length)
gds__free(bigger_buffer);
return NULL;
}
if (length)
gds__free(bigger_buffer);
return trans;
}
/*____________________________________________________________
*
* Take apart a full remote path specification,
* finding the filename and the remote site.
*/
static void parse_fullpath(TDR trans)
{
TEXT *start, *p, *q, *end;
USHORT length;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
/* start at the end of the full pathname */
start = p = trans->tdr_fullpath->str_data;
while (*p)
p++;
end = p;
/* Check for a named pipes name - \\node\path\db or //node/path/db */
while (p > start &&
!(*p == '/' && *(p - 1) == '/') &&
!(*p == '\\' && *(p - 1) == '\\')) p--;
if (p > start) {
/* Increment p past slash, & search forward for end of node name */
p = p + 1;
q = p;
while (*q && *q != '/' && *q != '\\')
q++;
if (*q) {
trans->tdr_filename = q + 1;
trans->tdr_remote_site = (STR) ALLOCDV(type_str, q - p + 1);
strncpy(trans->tdr_remote_site->str_data, p, q - p);
trans->tdr_remote_site->str_data[q - p] = '\0';
}
}
else {
p = end;
/* If not named pipes, check the other protocols
* work backwards until we find a remote protocol specifier
*/
while (p >= start && (*p != '^' && *p != ':' && *p != '@'))
p--;
trans->tdr_filename = p + 1;
/* now find the last remote node in the chain */
while (p > start && (*p == ':' || *p == '^' || *p == '@'))
p--;
for (length = 0; p >= start && (*p != '^' && *p != ':' && *p != '@');
length++)
p--;
p++;
if (length) {
trans->tdr_remote_site = (STR) ALLOCDV(type_str, length + 1);
q = (TEXT *) trans->tdr_remote_site->str_data;
while (length--)
*q++ = *p++;
*q = 0;
}
}
}
/*____________________________________________________________
*
* Get a blob into a buffer, returning the
* size of the blob if the passed buffer
* is not big enough.
*/
static USHORT snarf_blob(SLONG blob_id[2],
USHORT buffer_length, TEXT * buffer)
{
USHORT returned_length;
TEXT *ptr, *end;
STATUS status;
int *blob;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (buffer_length)
buffer[0] = 0;
if (buffer_length > 1)
buffer[1] = 0;
blob = NULL;
if (gds__open_blob(gds__status,
GDS_REF(DB),
GDS_REF(gds__trans), GDS_REF(blob), GDS_VAL(blob_id))) {
ALICE_print_status(gds__status);
return 0;
}
/* get the blob into the buffer, if it fits */
ptr = buffer;
end = buffer + buffer_length;
for (;;) {
if (ptr >= end)
break;
if (!(buffer_length = end - ptr))
break;
status = gds__get_segment(gds__status,
GDS_REF(blob),
GDS_REF(returned_length),
buffer_length, GDS_VAL(ptr));
if (status && status != gds__segment)
break;
ptr += returned_length;
}
/* snarf failed, get length of blob for retry */
if (!buffer_length)
for (;;) {
status = gds__get_segment(gds__status,
GDS_REF(blob),
GDS_REF(returned_length),
buffer_length, buffer);
if (status && status != gds__segment)
break;
buffer_length += returned_length;
}
else
buffer_length = 0;
gds__close_blob(gds__status, GDS_REF(blob));
*ptr = 0;
return buffer_length;
}

39
src/alice/alice_meta.h Normal file
View File

@ -0,0 +1,39 @@
/*
* PROGRAM: Alice (All Else) Utility
* MODULE: alice_meta.h
* DESCRIPTION: Prototype header file for alice_meta.e
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef ALICE_ALICE_META_H
#define ALICE_ALICE_META_H
#ifdef __cplusplus
extern "C" {
#endif
void MET_disable_wal(STATUS*, isc_db_handle);
void MET_get_state(STATUS*, TDR);
TDR MET_get_transaction(STATUS*, isc_db_handle, SLONG);
void MET_set_capabilities(STATUS*, TDR);
#ifdef __cplusplus
}
#endif
#endif /* ALICE_ALICE_META_H */

43
src/alice/alice_proto.h Normal file
View File

@ -0,0 +1,43 @@
/*
* PROGRAM: Alice (All Else) Utility
* MODULE: alice_proto.h
* DESCRIPTION: Prototype header file for alice.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _ALICE_ALICE_PROTO_H_
#define _ALICE_ALICE_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef int (DLL_EXPORT * OUTPUTPROC) (SLONG, UCHAR *);
void ALICE_down_case(TEXT*, TEXT*);
int ALICE_gfix(int, char**, OUTPUTPROC, SLONG);
void ALICE_print(USHORT, TEXT*, TEXT*, TEXT*, TEXT*, TEXT*);
void ALICE_error(USHORT, TEXT*, TEXT*, TEXT*, TEXT*, TEXT*);
void ALICE_print_status(STATUS*);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _ALICE_ALICE_PROTO_H_ */

264
src/alice/aliceswi.h Normal file
View File

@ -0,0 +1,264 @@
/*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef ALICE_ALICESWI_H
#define ALICE_ALICESWI_H
#include "../jrd/common.h"
#include "../jrd/ibase.h"
/* switch definitions */
#define sw_list 0x00000001L /* Byte 0, Bit 0 */
#define sw_prompt 0x00000002L
#define sw_commit 0x00000004L
#define sw_rollback 0x00000008L
#define sw_sweep 0x00000010L
#define sw_validate 0x00000020L
#define sw_no_update 0x00000040L
#define sw_full 0x00000080L
#define sw_mend 0x00000100L /* Byte 1, Bit 0 */
#define sw_all 0x00000200L
#define sw_enable 0x00000400L
#define sw_disable 0x00000800L
#define sw_ignore 0x00001000L
#define sw_activate 0x00002000L
#define sw_two_phase 0x00004000L
#define sw_housekeeping 0x00008000L
#define sw_kill 0x00010000L /* Byte 2, Bit 0 */
#define sw_begin_log 0x00020000L
#define sw_quit_log 0x00040000L
#define sw_write 0x00080000L
#define sw_use 0x00100000L
#define sw_user 0x00200000L
#define sw_password 0x00400000L
#define sw_shut 0x00800000L
#define sw_online 0x01000000L /* Byte 3, Bit 0 */
#define sw_cache 0x02000000L
#define sw_attach 0x04000000L
#define sw_force 0x08000000L
#define sw_tran 0x10000000L
#define sw_buffers 0x20000000L
#define sw_mode 0x40000000L
#define sw_set_db_dialect 0x80000000L
#define sw_z 0x0L
#define SW_MEND sw_mend | sw_validate | sw_full
#define IN_SW_ALICE_0 0 /* not a known switch */
#define IN_SW_ALICE_LIST 1
#define IN_SW_ALICE_PROMPT 2
#define IN_SW_ALICE_COMMIT 3
#define IN_SW_ALICE_ROLLBACK 4
#define IN_SW_ALICE_SWEEP 5
#define IN_SW_ALICE_VALIDATE 6
#define IN_SW_ALICE_NO_UPDATE 7
#define IN_SW_ALICE_FULL 8
#define IN_SW_ALICE_MEND 9
#define IN_SW_ALICE_ALL 10
#define IN_SW_ALICE_ENABLE 11
#define IN_SW_ALICE_DISABLE 12
#define IN_SW_ALICE_IGNORE 13
#define IN_SW_ALICE_ACTIVATE 14
#define IN_SW_ALICE_TWO_PHASE 15
#define IN_SW_ALICE_HOUSEKEEPING 16
#define IN_SW_ALICE_KILL 17
#define IN_SW_ALICE_BEGIN_LOG 18
#define IN_SW_ALICE_QUIT_LOG 19
#define IN_SW_ALICE_WRITE 20
#define IN_SW_ALICE_USE 21
#define IN_SW_ALICE_USER 22
#define IN_SW_ALICE_PASSWORD 23
#define IN_SW_ALICE_SHUT 24
#define IN_SW_ALICE_ONLINE 25
#define IN_SW_ALICE_CACHE 26
#define IN_SW_ALICE_ATTACH 27
#define IN_SW_ALICE_FORCE 28
#define IN_SW_ALICE_TRAN 29
#define IN_SW_ALICE_BUFFERS 30
#define IN_SW_ALICE_Z 31
#define IN_SW_ALICE_X 32 /* set debug mode on */
#define IN_SW_ALICE_HIDDEN_ASYNC 33
#define IN_SW_ALICE_HIDDEN_SYNC 34
#define IN_SW_ALICE_HIDDEN_USEALL 35
#define IN_SW_ALICE_HIDDEN_RESERVE 36
#define IN_SW_ALICE_HIDDEN_RDONLY 37
#define IN_SW_ALICE_HIDDEN_RDWRITE 38
#define IN_SW_ALICE_MODE 39
#define IN_SW_ALICE_HIDDEN_FORCE 40
#define IN_SW_ALICE_HIDDEN_TRAN 41
#define IN_SW_ALICE_HIDDEN_ATTACH 42
#define IN_SW_ALICE_SET_DB_SQL_DIALECT 43
#define ALICE_SW_ASYNC "async"
#define ALICE_SW_SYNC "sync"
#define ALICE_SW_MODE_RO "read_only"
#define ALICE_SW_MODE_RW "read_write"
/* Switch table */
static struct in_sw_tab_t alice_in_sw_table[] =
{
IN_SW_ALICE_ACTIVATE, isc_spb_prp_activate, "activate", sw_activate,
0, ~sw_activate, FALSE, 25, 0, NULL,
/* msg 25: \t-activate shadow file for database usage */
IN_SW_ALICE_ATTACH, 0, "attach", sw_attach,
sw_shut, 0, FALSE, 26, 0, NULL,
/* msg 26: \t-attach\tshutdown new database attachments */
#ifdef DEV_BUILD
IN_SW_ALICE_BEGIN_LOG, 0, "begin_log", sw_begin_log,
0, ~sw_begin_log, FALSE, 27, 0, NULL,
/* msg 27: \t-begin_log\tbegin logging for replay utility */
#endif
IN_SW_ALICE_BUFFERS, isc_spb_prp_page_buffers, "buffers", sw_buffers,
0, 0, FALSE, 28, 0, NULL,
/* msg 28: \t-buffers\tset page buffers <n> */
IN_SW_ALICE_COMMIT, isc_spb_rpr_commit_trans, "commit", sw_commit,
0, ~sw_commit, FALSE, 29, 0, NULL,
/* msg 29: \t-commit\t\tcommit transaction <tr / all> */
IN_SW_ALICE_CACHE, 0, "cache", sw_cache,
sw_shut, 0, FALSE, 30, 0, NULL,
/* msg 30: \t-cache\t\tshutdown cache manager */
#ifdef DEV_BUILD
IN_SW_ALICE_DISABLE, 0, "disable", sw_disable,
0, 0, FALSE, 31, 0, NULL,
/* msg 31: \t-disable\tdisable WAL */
#endif
IN_SW_ALICE_FULL, isc_spb_rpr_full, "full", sw_full,
sw_validate, 0, FALSE, 32, 0, NULL,
/* msg 32: \t-full\t\tvalidate record fragments (-v) */
IN_SW_ALICE_FORCE, 0, "force", sw_force,
sw_shut, 0, FALSE, 33, 0, NULL,
/* msg 33: \t-force\t\tforce database shutdown */
IN_SW_ALICE_HOUSEKEEPING, isc_spb_prp_sweep_interval, "housekeeping",
sw_housekeeping,
0, 0, FALSE, 34, 0, NULL,
/* msg 34: \t-housekeeping\tset sweep interval <n> */
IN_SW_ALICE_IGNORE, isc_spb_rpr_ignore_checksum, "ignore", sw_ignore,
0, 0, FALSE, 35, 0, NULL,
/* msg 35: \t-ignore\t\tignore checksum errors */
IN_SW_ALICE_KILL, isc_spb_rpr_kill_shadows, "kill", sw_kill,
0, 0, FALSE, 36, 0, NULL,
/* msg 36: \t-kill\t\tkill all unavailable shadow files */
IN_SW_ALICE_LIST, isc_spb_rpr_list_limbo_trans, "list", sw_list,
0, ~sw_list, FALSE, 37, 0, NULL,
/* msg 37: \t-list\t\tshow limbo transactions */
IN_SW_ALICE_MEND, isc_spb_rpr_mend_db, "mend", SW_MEND,
0, ~sw_no_update, FALSE, 38, 0, NULL,
/* msg 38: \t-mend\t\tprepare corrupt database for backup */
#ifdef READONLY_DATABASE
IN_SW_ALICE_MODE, 0, "mode", sw_mode,
0, ~sw_mode, FALSE, 109, 0, NULL,
/* msg 109: \t-mode\t\tread_only or read_write */
#endif /* READONLY_DATABASE */
IN_SW_ALICE_NO_UPDATE, isc_spb_rpr_check_db, "no_update", sw_no_update,
sw_validate, 0, FALSE, 39, 0, NULL,
/* msg 39: \t-no_update\tread-only validation (-v) */
IN_SW_ALICE_ONLINE, isc_spb_prp_db_online, "online", sw_online,
0, 0, FALSE, 40, 0, NULL,
/* msg 40: \t-online\t\tdatabase online */
IN_SW_ALICE_PROMPT, 0, "prompt", sw_prompt,
sw_list, 0, FALSE, 41, 0, NULL,
/* msg 41: \t-prompt\t\tprompt for commit/rollback (-l) */
IN_SW_ALICE_PASSWORD, 0, "password", sw_password,
0, 0, FALSE, 42, 0, NULL,
/* msg 42: \t-password\tdefault password */
#ifdef DEV_BUILD
IN_SW_ALICE_QUIT_LOG, 0, "quit_log", sw_quit_log,
0, ~sw_quit_log, FALSE, 43, 0, NULL,
/* msg 43: \t-quit_log\tquit logging for replay utility */
#endif
IN_SW_ALICE_ROLLBACK, isc_spb_rpr_rollback_trans, "rollback", sw_rollback,
0, ~sw_rollback, FALSE, 44, 0, NULL,
/* msg 44: \t-rollback\trollback transaction <tr / all> */
IN_SW_ALICE_SET_DB_SQL_DIALECT,
isc_spb_prp_set_sql_dialect,
"sql_dialect",
sw_set_db_dialect,
0,
0,
FALSE,
111,
0,
NULL,
/* msg 111: \t-SQL_dialect\t\set dataabse dialect n */
IN_SW_ALICE_SWEEP, isc_spb_rpr_sweep_db, "sweep", sw_sweep,
0, ~sw_sweep, FALSE, 45, 0, NULL,
/* msg 45: \t-sweep\t\tforce garbage collection */
IN_SW_ALICE_SHUT, 0, "shut", sw_shut,
0, ~(sw_shut |
sw_attach | sw_cache | sw_force | sw_tran), FALSE, 46, 0, NULL,
/* msg 46: \t-shut\t\tshutdown */
IN_SW_ALICE_TWO_PHASE, isc_spb_rpr_recover_two_phase, "two_phase",
sw_two_phase,
0, ~sw_two_phase, FALSE, 47, 0, NULL,
/* msg 47: \t-two_phase\tperform automated two-phase recovery */
IN_SW_ALICE_TRAN, 0, "tran", sw_tran,
sw_shut, 0, FALSE, 48, 0, NULL,
/* msg 48: \t-tran\t\tshutdown transaction startup */
IN_SW_ALICE_USE, 0, "use", sw_use,
0, ~sw_use, FALSE, 49, 0, NULL,
/* msg 49: \t-use\t\tuse full or reserve space for versions */
IN_SW_ALICE_USER, 0, "user", sw_user,
0, 0, FALSE, 50, 0, NULL,
/* msg 50: \t-user\t\tdefault user name */
IN_SW_ALICE_VALIDATE, isc_spb_rpr_validate_db, "validate", sw_validate,
0, ~sw_validate, FALSE, 51, 0, NULL,
/* msg 51: \t-validate\tvalidate database structure */
IN_SW_ALICE_WRITE, 0, "write", sw_write,
0, ~sw_write, FALSE, 52, 0, NULL,
/* msg 52: \t-write\t\twrite synchronously or asynchronously */
#ifdef DEV_BUILD
IN_SW_ALICE_X, 0, "x", 0,
0, 0, FALSE, 53, 0, NULL,
/* msg 53: \t-x\t\tset debug on */
#endif
IN_SW_ALICE_Z, 0, "z", sw_z,
0, 0, FALSE, 54, 0, NULL,
/* msg 54: \t-z\t\tprint software version number */
/************************************************************************/
/* WARNING: All new switches should be added right before this comments */
/************************************************************************/
/* The next nine 'virtual' switches are hidden from user and are needed
for services API
************************************************************************/
IN_SW_ALICE_HIDDEN_ASYNC, isc_spb_prp_wm_async, "write async", 0, 0, 0,
FALSE, 0, 0, NULL,
IN_SW_ALICE_HIDDEN_SYNC, isc_spb_prp_wm_sync, "write sync", 0, 0, 0,
FALSE, 0, 0, NULL,
IN_SW_ALICE_HIDDEN_USEALL, isc_spb_prp_res_use_full, "use full", 0, 0, 0,
FALSE, 0, 0, NULL,
IN_SW_ALICE_HIDDEN_RESERVE, isc_spb_prp_res, "use reserve", 0, 0, 0,
FALSE, 0, 0, NULL,
IN_SW_ALICE_HIDDEN_FORCE, isc_spb_prp_shutdown_db, "shut -force", 0, 0, 0,
FALSE, 0, 0, NULL,
IN_SW_ALICE_HIDDEN_TRAN, isc_spb_prp_deny_new_transactions, "shut -tran",
0, 0, 0, FALSE, 0, 0, NULL,
IN_SW_ALICE_HIDDEN_ATTACH, isc_spb_prp_deny_new_attachments,
"shut -attach", 0, 0, 0, FALSE, 0, 0, NULL,
#ifdef READONLY_DATABASE
IN_SW_ALICE_HIDDEN_RDONLY, isc_spb_prp_am_readonly, "mode read_only", 0,
0, 0, FALSE, 0, 0, NULL,
IN_SW_ALICE_HIDDEN_RDWRITE, isc_spb_prp_am_readwrite, "mode read_write",
0, 0, 0, FALSE, 0, 0, NULL,
#endif /* READONLY_DATABASE */
/************************************************************************/
IN_SW_ALICE_0, 0, NULL, 0,
0, 0, FALSE, 0, 0, NULL
};
#endif /* ALICE_ALICESWI_H */

548
src/alice/all.cpp Normal file
View File

@ -0,0 +1,548 @@
//____________________________________________________________
//
// PROGRAM: Alice (All Else) Utility
// MODULE: all.cpp
// DESCRIPTION: Block allocator
//
// The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html
//
// Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing
// rights and limitations under the License.
//
// The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation.
//
// All Rights Reserved.
// Contributor(s): ______________________________________.
//
//
//____________________________________________________________
//
// $Id: all.cpp,v 1.1.1.1 2001-05-23 13:25:33 tamlin Exp $
//
#include "../jrd/ib_stdio.h"
#include "../jrd/common.h"
#include "../jrd/ibsetjmp.h"
#include "../alice/alice.h"
#include "../alice/all.h"
#include "../alice/alloc.h"
#include "../alice/lls.h"
#include "../alice/all_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/thd_proto.h"
#define BLKDEF(type, root, tail) sizeof (struct root), tail,
static struct {
SSHORT typ_root_length;
SSHORT typ_tail_length;
} block_sizes[] = {
0, 0,
#include "../alice/blk.h"
0};
#undef BLKDEF
static void extend_pool(PLB, SLONG);
static PLB find_pool(BLK);
static void release(FRB, PLB);
//____________________________________________________________
//
// Allocate a block from a given pool and initialize the block.
// This is the primary block allocation routine.
//
BLK ALLA_alloc(PLB pool, UCHAR type, int count)
{
register BLK block;
FRB free, *best, *ptr;
SLONG best_tail, tail;
USHORT units;
register SLONG size;
register USHORT *p;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (type <= (UCHAR) type_MIN || type >= (SCHAR) type_MAX)
ALICE_error(62, 0, 0, 0, 0, 0); /* msg 62: bad block type */
// Compute block length
size = block_sizes[type].typ_root_length;
if ((tail = block_sizes[type].typ_tail_length) && count >= FUDGE)
size += (count - FUDGE) * tail;
size = (size + MIN_ALLOC - 1) & ~((ULONG) MIN_ALLOC - 1);
// TMN: Here we should probably have the following assert
// assert((size >> SHIFT) <= MAX_USHORT);
units = (USHORT) (size >> SHIFT);
if (size >= MAX_BLOCK)
ALICE_error(63, 0, 0, 0, 0, 0); /* msg 63:internal block exceeds maximum size */
// Find best fit. Best fit is defined to be the free block of shortest
// tail. If there isn't a fit, extend the pool and try, try again.
while (TRUE) {
best = NULL;
best_tail = MAX_BLOCK;
for (ptr = &pool->plb_free; (free = *ptr); ptr = &free->frb_next) {
if (free == free->frb_next)
ALICE_error(64, 0, 0, 0, 0, 0); /* msg 64: corrupt pool */
if ((tail = (int) free->frb_header.blk_length - (int) units) >= 0
&& tail < best_tail) {
best = ptr;
best_tail = tail;
if (tail == 0)
break;
}
}
if (best)
break;
extend_pool(pool, size);
}
// We've got our free block. If there's enough left of the free block
// after taking out our block, chop out out block. If not, allocate
// the entire free block as our block (a little extra won't hurt).
best_tail <<= SHIFT;
free = *best;
if (best_tail > sizeof(struct frb)) {
block =
(BLK) ((SCHAR *) free + (free->frb_header.blk_length << SHIFT));
block = (BLK) ((SCHAR *) block - size);
free->frb_header.blk_length -= units;
}
else {
*best = free->frb_next;
units = free->frb_header.blk_length;
size = units << SHIFT;
block = (BLK) free;
}
// zero out the allocated memory
size >>= 1;
p = (USHORT *) block;
do
*p++ = 0;
while (--size);
block->blk_type = type;
// TMN: Here we should probably have the following assert
// assert(pool->plb_pool_id <= MAX_UCHAR);
block->blk_pool_id = (UCHAR) pool->plb_pool_id;
block->blk_length = units;
return block;
}
//____________________________________________________________
//
// Extend a repeating block, copying the constant part.
//
BLK ALLA_extend(BLK * pointer, int size)
{
BLK block;
PLB pool;
SLONG old_length, new_length;
register SCHAR *from, *to;
register SSHORT length;
block = *pointer;
pool = find_pool(block);
BLK new_ = ALLA_alloc(pool, block->blk_type, size);
old_length = block->blk_length << SHIFT;
new_length = new_->blk_length << SHIFT;
from = (SCHAR *) block + sizeof(struct blk);
to = (SCHAR *) new_ + sizeof(struct blk);
length = MIN(old_length, new_length) - sizeof(struct blk);
if (length)
do
*to++ = *from++;
while (--length);
release(reinterpret_cast < frb * >(block), pool);
if (new_->blk_type == (UCHAR) type_vec)
((VEC) new_)->vec_count = size;
else if (new_->blk_type == (UCHAR) type_vcl)
((VCL) new_)->vcl_count = size;
*pointer = new_;
return new_;
}
//____________________________________________________________
//
// Get rid of everything.
//
void ALLA_fini(void)
{
register PLB pool, *vector, *until;
register HNK hunks, hunk;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (tdgbl->pools) {
for (vector =
(PLB *) tdgbl->pools->vec_object + tdgbl->pools->vec_count,
until = (PLB *) tdgbl->pools->vec_object; --vector >= until;)
if (pool = *vector)
for (hunks = pool->plb_hunks; hunk = hunks;) {
hunks = hunk->hnk_next;
ALLA_free(hunk->hnk_address);
}
}
tdgbl->pools = NULL;
}
//____________________________________________________________
//
// Give space back to system.
//
void ALLA_free(SCHAR * memory)
{
gds__free(memory);
}
//____________________________________________________________
//
// Initialize the pool system.
//
void ALLA_init(void)
{
SLONG temp_vector[20];
VEC vector;
PLB pool;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
tdgbl->pools = vector = (VEC) temp_vector;
vector->vec_count = 1;
vector->vec_object[0] = NULL;
tdgbl->ALICE_default_pool = tdgbl->ALICE_permanent_pool = pool =
ALLA_pool();
tdgbl->pools = vector = (VEC) ALLA_alloc(pool, type_vec, 10);
vector->vec_count = 10;
vector->vec_object[0] = (BLK) pool;
}
//____________________________________________________________
//
// Get memory from system.
//
SCHAR *ALLA_malloc(SLONG size)
{
register SCHAR *memory;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (memory = (SCHAR *) gds__alloc(size))
return memory;
ALICE_error(65, 0, 0, 0, 0, 0); /* msg 65: virtual memory exhausted */
return (SCHAR *) 0; /* Keep compilers happy. ALICE_error() never returns. */
}
//____________________________________________________________
//
// Allocate a new pool. This is done by creating a tempory
// pool block on the stack, then allocating a real pool block.
// In USHORT, by mirrors.
//
PLB ALLA_pool(void)
{
struct plb temp_pool;
register VEC vector;
register PLB pool;
register int pool_id;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
// Start by assigning a pool id
vector = tdgbl->pools;
for (pool_id = 0; pool_id < (int) vector->vec_count; pool_id++)
if (!(vector->vec_object[pool_id]))
break;
if (pool_id >= (int) vector->vec_count)
vector =
(VEC) ALLA_extend(reinterpret_cast < blk ** >(&(tdgbl->pools)),
pool_id + 10);
vector->vec_object[pool_id] = (BLK) & temp_pool;
temp_pool.plb_free = NULL;
temp_pool.plb_hunks = NULL;
temp_pool.plb_pool_id = pool_id;
if (pool_id == 0)
tdgbl->ALICE_permanent_pool = &temp_pool;
pool = (PLB) ALLA_alloc(&temp_pool, type_plb, 0);
pool->plb_pool_id = pool_id;
pool->plb_free = temp_pool.plb_free;
pool->plb_hunks = temp_pool.plb_hunks;
vector->vec_object[pool_id] = (BLK) pool;
if (pool_id == 0)
tdgbl->ALICE_permanent_pool = pool;
return pool;
}
//____________________________________________________________
//
// Push an object on an LLS stack.
//
void ALLA_push(BLK object, register LLS * stack)
{
register LLS node;
PLB pool;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
pool = tdgbl->ALICE_default_pool;
if (node = pool->plb_lls)
pool->plb_lls = node->lls_next;
else
node = (LLS) ALLA_alloc(pool, type_lls, 0);
node->lls_object = object;
node->lls_next = *stack;
*stack = node;
}
//____________________________________________________________
//
// Pop an object off a linked list stack. Save the node for
// further use.
//
BLK ALLA_pop(register LLS * stack)
{
register LLS node;
register PLB pool;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
node = *stack;
pool = (PLB) tdgbl->pools->vec_object[node->lls_header.blk_pool_id];
*stack = node->lls_next;
node->lls_next = pool->plb_lls;
pool->plb_lls = node;
return node->lls_object;
}
//____________________________________________________________
//
// Release a block to its pool. If it is contiguous to
// another free block, combine them. Otherwise link it
// into the free block linked list (kept in ascending order
// of addresses).
//
void ALLA_release(register FRB block)
{
release(block, find_pool(block ? &block->frb_header : (BLK) 0));
}
//____________________________________________________________
//
// Release a storage pool. This involves nothing more than returning
// hunks to the free hunk list.
//
void ALLA_rlpool(PLB pool)
{
register HNK hunk, hunks;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
tdgbl->pools->vec_object[pool->plb_pool_id] = NULL;
for (hunks = pool->plb_hunks; hunk = hunks;) {
hunks = hunk->hnk_next;
ALLA_free(hunk->hnk_address);
}
}
//____________________________________________________________
//
// Allocate, extend, or no-op a vector making sure it is "long enough".
//
VEC ALLA_vector(PLB pool, VEC * ptr, USHORT count)
{
VEC vector;
++count;
if (!(vector = *ptr)) {
vector = *ptr = (VEC) ALLA_alloc(pool, type_vec, count);
vector->vec_count = count;
return vector;
}
if (vector->vec_count >= count)
return vector;
return (VEC) ALLA_extend(reinterpret_cast < blk ** >(ptr), count);
}
//____________________________________________________________
//
// Extend a pool by at least enough to accomodate a block
// of given size.
//
static void extend_pool(PLB pool, SLONG size)
{
register HNK hunk;
register BLK block;
size =
(size + sizeof(struct hnk) + MIN_ALLOCATION -
1) & ~((ULONG) MIN_ALLOCATION - 1);
block = (BLK) ALLA_malloc((SLONG) size);
// TMN: Here we should probably have the following assert
// assert((size >> SHIFT) <= MAX_USHORT);
block->blk_length = (USHORT) size >> SHIFT;
block->blk_type = (UCHAR) type_frb;
// TMN: Here we should probably have the following assert
// assert(pool->plb_pool_id <= MAX_UCHAR);
block->blk_pool_id = (UCHAR) pool->plb_pool_id;
release(reinterpret_cast < frb * >(block), pool);
hunk = (HNK) ALLA_alloc(pool, type_hnk, 0);
hunk->hnk_address = (SCHAR *) block;
hunk->hnk_length = size;
hunk->hnk_next = pool->plb_hunks;
pool->plb_hunks = hunk;
}
//____________________________________________________________
//
// Find pool associate with block.
//
static PLB find_pool(BLK block)
{
PLB pool;
HNK hunk;
USHORT pool_id;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
for (pool_id = block->blk_pool_id;
pool_id < tdgbl->pools->vec_count
&& (pool = (PLB) tdgbl->pools->vec_object[pool_id]); pool_id += 256)
for (hunk = pool->plb_hunks; hunk; hunk = hunk->hnk_next)
if ((SCHAR *) block >= hunk->hnk_address
&& (SCHAR *) block < hunk->hnk_address + hunk->hnk_length)
return pool;
ALICE_error(66, 0, 0, 0, 0, 0); /* msg 66: bad pool id */
return (PLB) 0; /* Keep compilers happy. ALICE_error() never returns. */
}
//____________________________________________________________
//
// Release a block to its pool. If it is contiguous to
// another free block, combine them. Otherwise link it
// into the free block linked list (kept in ascending order
// of addresses).
//
static void release(FRB block, PLB pool)
{
register FRB prior, free;
FRB *ptr;
SLONG length;
block->frb_header.blk_type = (UCHAR) type_frb;
prior = NULL;
for (ptr = &pool->plb_free; free = *ptr;
prior = free, ptr = &free->frb_next) if (block < free)
break;
// Merge block into list first, then try to combine blocks
block->frb_next = free;
*ptr = block;
// Try to merge the free block with the next one down.
length = block->frb_header.blk_length << SHIFT;
if (free && (SCHAR *) block + length == (SCHAR *) free) {
block->frb_header.blk_length += free->frb_header.blk_length;
block->frb_next = free->frb_next;
}
// Try and merge the block with the prior free block
if (prior &&
(length = prior->frb_header.blk_length << SHIFT) &&
(SCHAR *) prior + length == (SCHAR *) block) {
prior->frb_header.blk_length += block->frb_header.blk_length;
prior->frb_next = block->frb_next;
}
}

76
src/alice/all.h Normal file
View File

@ -0,0 +1,76 @@
/*
* PROGRAM: Alice
* MODULE: all.h
* DESCRIPTION: Data allocation declarations
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _ALICE_ALL_H_
#define _ALICE_ALL_H_
#if ALIGNMENT == 8
#define MIN_ALLOC 8
#else
#define MIN_ALLOC 4
#endif
#define MAX_BLOCK 256000
#define FUDGE 1
#define SHIFT 2
#define MIN_ALLOCATION 1024 /* Minimin allocation from operating system */
/* This is the header to be used by all blocks to
specify the type of block, the pool in which it has
been allocated, and the length of its tail. */
#ifndef INCLUDE_FB_BLK
#include "../include/fb_blk.h"
#endif
/* Free block */
typedef struct frb
{
struct blk frb_header;
struct frb *frb_next; /* Next free block in pool */
} *FRB;
/* Pool block */
typedef struct plb
{
struct blk plb_header;
USHORT plb_pool_id; /* pool id */
struct frb *plb_free; /* first free block */
struct hnk *plb_hunks; /* first hunk block */
struct lls *plb_lls; /* avaiable linked list stack nodes */
} *PLB;
/* Hunk blocks */
typedef struct hnk
{
struct blk hnk_header;
SCHAR *hnk_address; /* start of memory hunk */
SLONG hnk_length; /* length of memory hunk */
struct hnk *hnk_next; /* next memory hunk in structure */
} *HNK;
#endif /* _ALICE_ALL_H_ */

50
src/alice/all_proto.h Normal file
View File

@ -0,0 +1,50 @@
/*
* PROGRAM: Alice (All Else) Utility
* MODULE: all_proto.h
* DESCRIPTION: Prototype header file for all.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _ALICE_ALL_PROTO_H_
#define _ALICE_ALL_PROTO_H_
#include "../alice/lls.h"
#ifdef __cplusplus
extern "C" {
#endif
BLK ALLA_alloc(PLB, UCHAR, int);
BLK ALLA_extend(BLK *, int);
void ALLA_fini(void);
void ALLA_free(SCHAR *);
void ALLA_init(void);
SCHAR* ALLA_malloc(SLONG);
PLB ALLA_pool(void);
void ALLA_push(BLK, register LLS *);
BLK ALLA_pop(register LLS *);
void ALLA_release(register FRB);
void ALLA_rlpool(PLB);
VEC ALLA_vector(PLB, VEC *, USHORT);
#ifdef __cplusplus
};
#endif
#endif /* _ALICE_ALL_PROTO_H_ */

35
src/alice/alloc.h Normal file
View File

@ -0,0 +1,35 @@
/*
* PROGRAM: Alice
* MODULE: alloc.h
* DESCRIPTION: Data allocation macros
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _ALICE_ALLOC_H_
#define _ALICE_ALLOC_H_
#define ALL_release(blk) ALLA_release (blk)
#define ALLOCD(type) ALLA_alloc (tdgbl->ALICE_default_pool, type, 0)
#define ALLOCDV(type,repeat) ALLA_alloc (tdgbl->ALICE_default_pool, type, repeat)
#define ALLOCP(type) ALLA_alloc (tdgbl->ALICE_permanent_pool, type, 0)
#define ALLOCPV(type,repeat) ALLA_alloc (tdgbl->ALICE_permanent_pool, type, repeat)
#define ALLOC(type,pool) ALLA_alloc (pool, type, 0)
#define ALLOCV(type,pool,repeat) ALLA_alloc (pool, type, repeat)
#endif /* _ALICE_ALLOC_H_ */

31
src/alice/blk.h Normal file
View File

@ -0,0 +1,31 @@
/*
* PROGRAM: Alice
* MODULE: blk.h
* DESCRIPTION: Block type definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
BLKDEF(type_frb, frb, 0)
BLKDEF(type_hnk, hnk, 0)
BLKDEF(type_plb, plb, 0)
BLKDEF(type_vec, vec, sizeof(((VEC) 0)->vec_object[0]))
BLKDEF(type_vcl, vcl, sizeof(((VCL) 0)->vcl_long[0]))
BLKDEF(type_tdr, tdr, 0) /* transaction description */
BLKDEF(type_str, str, 1) /* general string block */
BLKDEF(type_lls, lls, 0)

447
src/alice/exe.cpp Normal file
View File

@ -0,0 +1,447 @@
//____________________________________________________________
//
// PROGRAM: Alice (All Else) Utility
// MODULE: exe.cpp
// DESCRIPTION: Does the database calls
//
// The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html
//
// Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing
// rights and limitations under the License.
//
// The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation.
//
// All Rights Reserved.
// Contributor(s): ______________________________________.
//
//
//____________________________________________________________
//
// $Id: exe.cpp,v 1.1.1.1 2001-05-23 13:25:33 tamlin Exp $
//
#include "../jrd/ib_stdio.h"
#include <stdlib.h>
#include <string.h>
#include "../include/jrd/gds.h"
#include "../jrd/common.h"
#include "../jrd/ibsetjmp.h"
#include "../alice/alice.h"
#include "../alice/aliceswi.h"
#include "../alice/all.h"
#include "../alice/all_proto.h"
#include "../alice/alice_meta.h"
#include "../alice/tdr_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/thd_proto.h"
#if (defined WIN_NT || defined PC_PLATFORM)
#include <io.h>
#endif
extern "C" {
static USHORT build_dpb(UCHAR *, ULONG);
static void extract_db_info(UCHAR *);
static TEXT val_errors[] =
{
isc_info_page_errors, isc_info_record_errors, isc_info_bpage_errors,
isc_info_dpage_errors, isc_info_ipage_errors, isc_info_ppage_errors,
isc_info_tpage_errors, gds_info_end
};
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
#define STUFF_DPB(blr) {*d++ = (UCHAR)(blr);}
#define STUFF_DPB_INT(blr) \
{ \
STUFF_DPB(blr); \
STUFF_DPB((blr) >> 8); \
STUFF_DPB((blr) >> 16); \
STUFF_DPB((blr) >> 24); \
}
//____________________________________________________________
//
//
int EXE_action(TEXT * database, ULONG switches)
{
UCHAR dpb[128];
USHORT dpb_length, error;
SLONG *handle;
UCHAR error_string[128];
USHORT i;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
ALLA_init();
for (i = 0; i < MAX_VAL_ERRORS; i++)
tdgbl->ALICE_data.ua_val_errors[i] = 0;
// generate the database parameter block for the attach,
// based on the various switches
dpb_length = build_dpb(dpb, switches);
error = FALSE;
handle = NULL;
gds__attach_database(tdgbl->status,
0,
GDS_VAL(database),
reinterpret_cast < void **>(GDS_REF(handle)),
dpb_length,
reinterpret_cast < char *>(GDS_VAL(dpb)));
SVC_STARTED(tdgbl->service_blk);
if (tdgbl->status[1])
error = TRUE;
if (tdgbl->status[2] == isc_arg_warning)
ALICE_print_status(tdgbl->status);
if (handle != NULL) {
if ((switches & sw_validate) && (tdgbl->status[1] != isc_bug_check)) {
gds__database_info(tdgbl->status,
reinterpret_cast < void **>(GDS_REF(handle)),
sizeof(val_errors),
val_errors,
sizeof(error_string),
reinterpret_cast < char *>(error_string));
extract_db_info(error_string);
}
if (switches & sw_disable)
MET_disable_wal(tdgbl->status, handle);
gds__detach_database(tdgbl->status,
reinterpret_cast < void **>(GDS_REF(handle)));
}
ALLA_fini();
return ((error) ? FINI_ERROR : FINI_OK);
}
#ifndef GUI_TOOLS
//____________________________________________________________
//
//
int EXE_two_phase(TEXT * database, ULONG switches)
{
UCHAR dpb[128];
USHORT dpb_length, error;
SLONG *handle;
USHORT i;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
ALLA_init();
for (i = 0; i < MAX_VAL_ERRORS; i++)
tdgbl->ALICE_data.ua_val_errors[i] = 0;
// generate the database parameter block for the attach,
// based on the various switches
dpb_length = build_dpb(dpb, switches);
error = FALSE;
handle = NULL;
gds__attach_database(tdgbl->status,
0,
GDS_VAL(database),
reinterpret_cast < void **>(GDS_REF(handle)),
dpb_length,
reinterpret_cast < char *>(GDS_VAL(dpb)));
SVC_STARTED(tdgbl->service_blk);
if (tdgbl->status[1])
error = TRUE;
else if (switches & sw_list)
TDR_list_limbo(reinterpret_cast < int *>(handle), database, switches);
else if (switches & (sw_commit | sw_rollback | sw_two_phase))
error =
TDR_reconnect_multiple(reinterpret_cast < int *>(handle),
tdgbl->ALICE_data.ua_transaction, database,
switches);
if (handle)
gds__detach_database(tdgbl->status,
reinterpret_cast < void **>(GDS_REF(handle)));
ALLA_fini();
return ((error) ? FINI_ERROR : FINI_OK);
}
#endif /* GUI_TOOLS */
//____________________________________________________________
//
//
// generate the database parameter block for the attach,
// based on the various switches
//
static USHORT build_dpb(UCHAR * dpb, ULONG switches)
{
UCHAR *d;
USHORT dpb_length;
SSHORT i;
TEXT *q;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
d = dpb;
*d++ = gds_dpb_version1;
*d++ = isc_dpb_gfix_attach;
*d++ = 0;
if (switches & sw_sweep) {
*d++ = gds_dpb_sweep;
*d++ = 1;
*d++ = gds_dpb_records;
}
else if (switches & sw_activate) {
*d++ = gds_dpb_activate_shadow;
*d++ = 0;
}
else if (switches & sw_validate) {
*d++ = gds_dpb_verify;
*d++ = 1;
*d = gds_dpb_pages;
if (switches & sw_full)
*d |= gds_dpb_records;
if (switches & sw_no_update)
*d |= gds_dpb_no_update;
if (switches & sw_mend)
*d |= gds_dpb_repair;
if (switches & sw_ignore)
*d |= gds_dpb_ignore;
d++;
}
else if (switches & sw_housekeeping) {
*d++ = gds_dpb_sweep_interval;
*d++ = 4;
for (i = 0; i < 4;
i++, tdgbl->ALICE_data.ua_sweep_interval =
tdgbl->ALICE_data.ua_sweep_interval >> 8)
/* TMN: Here we should really have the following assert */
/* assert(tdgbl->ALICE_data.ua_sweep_interval <= MAX_UCHAR); */
*d++ = (UCHAR) tdgbl->ALICE_data.ua_sweep_interval;
}
else if (switches & sw_begin_log) {
*d++ = gds_dpb_begin_log;
*d++ = strlen(tdgbl->ALICE_data.ua_log_file);
for (q = tdgbl->ALICE_data.ua_log_file; *q;)
*d++ = *q++;
}
else if (switches & sw_buffers) {
*d++ = isc_dpb_set_page_buffers;
*d++ = 4;
for (i = 0; i < 4;
i++, tdgbl->ALICE_data.ua_page_buffers =
tdgbl->ALICE_data.ua_page_buffers >> 8)
/* TMN: Here we should really have the following assert */
/* assert(tdgbl->ALICE_data.ua_page_buffers <= MAX_UCHAR); */
*d++ = (UCHAR) tdgbl->ALICE_data.ua_page_buffers;
}
else if (switches & sw_quit_log) {
*d++ = gds_dpb_quit_log;
*d++ = 0;
}
else if (switches & sw_kill) {
*d++ = gds_dpb_delete_shadow;
*d++ = 0;
}
else if (switches & sw_write) {
*d++ = gds_dpb_force_write;
*d++ = 1;
*d++ = tdgbl->ALICE_data.ua_force;
}
else if (switches & sw_use) {
*d++ = gds_dpb_no_reserve;
*d++ = 1;
*d++ = tdgbl->ALICE_data.ua_use;
}
#ifdef READONLY_DATABASE
else if (switches & sw_mode) {
*d++ = isc_dpb_set_db_readonly;
*d++ = 1;
*d++ = tdgbl->ALICE_data.ua_read_only;
}
#endif /* READONLY_DATABASE */
else if (switches & sw_shut) {
*d++ = gds_dpb_shutdown;
*d++ = 1;
*d = 0;
if (switches & sw_attach)
*d |= gds_dpb_shut_attachment;
else if (switches & sw_cache)
*d |= gds_dpb_shut_cache;
else if (switches & sw_force)
*d |= gds_dpb_shut_force;
else if (switches & sw_tran)
*d |= gds_dpb_shut_transaction;
d++;
*d++ = gds_dpb_shutdown_delay;
*d++ = 2; /* Build room for shutdown delay */
/* TMN: Here we should really have the following assert */
/* assert(tdgbl->ALICE_data.ua_page_buffers <= MAX_USHORT); */
/* or maybe even compare with MAX_SSHORT */
*d++ = (UCHAR) tdgbl->ALICE_data.ua_shutdown_delay;
*d++ = (UCHAR) (tdgbl->ALICE_data.ua_shutdown_delay >> 8);
}
else if (switches & sw_online) {
*d++ = gds_dpb_online;
*d++ = 0;
}
else if (switches & sw_disable) {
*d++ = isc_dpb_disable_wal;
*d++ = 0;
}
else if (switches & (sw_list | sw_commit | sw_rollback | sw_two_phase)) {
*d++ = gds_dpb_no_garbage_collect;
*d++ = 0;
}
else if (switches & sw_set_db_dialect) {
STUFF_DPB(isc_dpb_set_db_sql_dialect);
STUFF_DPB(4);
STUFF_DPB_INT(tdgbl->ALICE_data.ua_db_SQL_dialect);
}
if (tdgbl->ALICE_data.ua_user) {
*d++ = gds_dpb_user_name;
*d++ =
strlen(reinterpret_cast <
const char *>(tdgbl->ALICE_data.ua_user));
for (q = reinterpret_cast < TEXT * >(tdgbl->ALICE_data.ua_user); *q;)
*d++ = *q++;
}
if (tdgbl->ALICE_data.ua_password) {
if (!tdgbl->sw_service_thd)
*d++ = gds_dpb_password;
else
*d++ = gds_dpb_password_enc;
*d++ =
strlen(reinterpret_cast <
const char *>(tdgbl->ALICE_data.ua_password));
for (q = reinterpret_cast < TEXT * >(tdgbl->ALICE_data.ua_password);
*q;)
*d++ = *q++;
}
dpb_length = d - dpb;
if (dpb_length == 1)
dpb_length = 0;
return dpb_length;
}
//____________________________________________________________
//
// Extract database info from string
//
static void extract_db_info(UCHAR * db_info_buffer)
{
UCHAR item;
UCHAR *p;
SLONG length;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
p = db_info_buffer;
while ((item = *p++) != gds_info_end) {
length = gds__vax_integer(p, 2);
p += 2;
/* TMN: Here we should really have the following assert */
/* assert(length <= MAX_SSHORT); */
/* for all cases that use 'length' as input to 'gds__vax_integer' */
switch (item) {
case isc_info_page_errors:
tdgbl->ALICE_data.ua_val_errors[VAL_PAGE_ERRORS] =
gds__vax_integer(p, (SSHORT) length);
p += length;
break;
case isc_info_record_errors:
tdgbl->ALICE_data.ua_val_errors[VAL_RECORD_ERRORS] =
gds__vax_integer(p, (SSHORT) length);
p += length;
break;
case isc_info_bpage_errors:
tdgbl->ALICE_data.ua_val_errors[VAL_BLOB_PAGE_ERRORS] =
gds__vax_integer(p, (SSHORT) length);
p += length;
break;
case isc_info_dpage_errors:
tdgbl->ALICE_data.ua_val_errors[VAL_DATA_PAGE_ERRORS] =
gds__vax_integer(p, (SSHORT) length);
p += length;
break;
case isc_info_ipage_errors:
tdgbl->ALICE_data.ua_val_errors[VAL_INDEX_PAGE_ERRORS] =
gds__vax_integer(p, (SSHORT) length);
p += length;
break;
case isc_info_ppage_errors:
tdgbl->ALICE_data.ua_val_errors[VAL_POINTER_PAGE_ERRORS] =
gds__vax_integer(p, (SSHORT) length);
p += length;
break;
case isc_info_tpage_errors:
tdgbl->ALICE_data.ua_val_errors[VAL_TIP_PAGE_ERRORS] =
gds__vax_integer(p, (SSHORT) length);
p += length;
break;
case isc_info_error:
/* has to be a < V4 database. */
tdgbl->ALICE_data.ua_val_errors[VAL_INVALID_DB_VERSION] = 1;
return;
default:
;
}
}
}
} // extern "C"

38
src/alice/exe_proto.h Normal file
View File

@ -0,0 +1,38 @@
/*
* PROGRAM: Alice (All Else) Utility
* MODULE: exe_proto.h
* DESCRIPTION: Prototype header file for exe.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _ALICE_EXE_PROTO_H_
#define _ALICE_EXE_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
extern int EXE_action(TEXT *, ULONG);
extern int EXE_two_phase(TEXT *, ULONG);
#ifdef __cplusplus
};
#endif
#endif /* _ALICE_ALICE_PROTO_H_ */

107
src/alice/info.h Normal file
View File

@ -0,0 +1,107 @@
/*
* PROGRAM: Alice
* MODULE: info.h
* DESCRIPTION: gds__version definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef ALICE_INFO_H
#define ALICE_INFO_H
static UCHAR info[] =
{
gds_info_version,
gds_info_implementation,
gds_info_end
};
/* this table describes the implementations that
require a node_name,protocol combination be
generated */
static BOOLEAN generate_protocol[] =
{
0, /* NULL, 0 */
0, /* access method */
0, /* Y-valve */
0, /* remote interface */
1, /* remote server */
0,
0,
0, /* pipe interface */
1, /* pipe server */
0, /* central interface */
1, /* central server */
1, /* gateway */
};
/* this table describes the protocols that can be
used for getting from a node of a given type */
#define DECNET_PROTOCOL 1 /* :: */
#define TCP_PROTOCOL 2 /* : */
#define VMS_TCP_PROTOCOL 4 /* ^ */
#define APOLLO_PROTOCOL 8 /* // */
#define MSLAN_PROTOCOL 16 /* \\ */
static USHORT protocols_supported[] =
{
0,
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "Rdb/VMS" */
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "Rdb/ELN target" */
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "Rdb/ELN development" */
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "Rdb/VMS Y" */
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "Rdb/ELN Y" */
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "JRI" */
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "JSV" */
0,
0,
TCP_PROTOCOL | APOLLO_PROTOCOL, /* "InterBase/apollo" */
DECNET_PROTOCOL | TCP_PROTOCOL, /* "InterBase/ultrix" */
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "InterBase/vms" */
TCP_PROTOCOL, /* "InterBase/sun" */
TCP_PROTOCOL, /* "InterBase/OS2" */
0, /* 15 */
0, /* 16 */
0, /* 17 */
0, /* 18 */
0, /* 19 */
0, /* 20 */
0, /* 21 */
0, /* 22 */
0, /* 23 */
0, /* 24 */
TCP_PROTOCOL | APOLLO_PROTOCOL, /* "InterBase/apollo" */
DECNET_PROTOCOL | TCP_PROTOCOL, /* "InterBase/ultrix" */
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "InterBase/vms" */
TCP_PROTOCOL, /* "InterBase/sun" */
TCP_PROTOCOL, /* "InterBase/OS2" */
TCP_PROTOCOL, /* "InterBase/sun4" */
TCP_PROTOCOL, /* "InterBase/hpux" */
TCP_PROTOCOL, /* "InterBase/sun386" */
DECNET_PROTOCOL | VMS_TCP_PROTOCOL, /* "InterBase:ORACLE/vms" */
TCP_PROTOCOL, /* "InterBase/mac/aux" */
TCP_PROTOCOL, /* "InterBase/ibm/rt" */
DECNET_PROTOCOL | TCP_PROTOCOL, /* "InterBase/mips/ultrix" */
};
#endif /* ALICE_INFO_H */

36
src/alice/lls.h Normal file
View File

@ -0,0 +1,36 @@
/*
* PROGRAM: Alice
* MODULE: lls.h
* DESCRIPTION: Linked list stack definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _ALICE_LLS_H_
#define _ALICE_LLS_H_
#define LLS_PUSH(object, stack) ALL_push (object, stack)
#define LLS_POP(stack) ALL_pop (stack)
typedef struct lls {
struct blk lls_header;
struct blk *lls_object;
struct lls *lls_next;
} *LLS;
#endif /* _ALICE_LLS_H_ */

995
src/alice/tdr.cpp Normal file
View File

@ -0,0 +1,995 @@
//____________________________________________________________
//
// PROGRAM: Alice (All Else) Utility
// MODULE: tdr.cpp
// DESCRIPTION: Routines for automated transaction recovery
//
// The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html
//
// Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing
// rights and limitations under the License.
//
// The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation.
//
// All Rights Reserved.
// Contributor(s): ______________________________________.
//
//
//____________________________________________________________
//
// $Id: tdr.cpp,v 1.1.1.1 2001-05-23 13:25:33 tamlin Exp $
//
#include "../jrd/ib_stdio.h"
#include <string.h>
#include "../include/jrd/gds.h"
#include "../jrd/common.h"
#include "../alice/alice.h"
#include "../alice/aliceswi.h"
#include "../alice/all.h"
#include "../alice/alloc.h"
#include "../alice/info.h"
#include "../alice/alice_proto.h"
#include "../alice/all_proto.h"
#include "../alice/alice_meta.h"
#include "../alice/tdr_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/isc_proto.h"
#include "../jrd/svc_proto.h"
#include "../jrd/thd_proto.h"
static ULONG ask(void);
static void print_description(TDR);
static void reattach_database(TDR);
static void reattach_databases(TDR);
static BOOLEAN reconnect(int *, SLONG, TEXT *, ULONG);
#ifdef GUI_TOOLS
#define NEWLINE "\r\n"
#else
#define NEWLINE "\n"
#endif
static UCHAR limbo_info[] = { gds_info_limbo, gds_info_end };
//
// The following routines are shared by the command line gfix and
// the windows server manager. These routines should not contain
// any direct screen I/O (i.e. ib_printf/ib_getc statements).
//
//____________________________________________________________
//
// Determine the proper action to take
// based on the state of the various
// transactions.
//
USHORT TDR_analyze(TDR trans)
{
USHORT state, advice = TRA_none;
if (trans == NULL)
return TRA_none;
// if the tdr for the first transaction is missing,
// we can assume it was committed
state = trans->tdr_state;
if (state == TRA_none)
state = TRA_commit;
else if (state == TRA_unknown)
advice = TRA_unknown;
for (trans = trans->tdr_next; trans; trans = trans->tdr_next) {
switch (trans->tdr_state) {
/* an explicitly committed transaction necessitates a check for the
perverse case of a rollback, otherwise a commit if at all possible */
case TRA_commit:
if (state == TRA_rollback) {
ALICE_print(105, 0, 0, 0, 0, 0); /* msg 105: Warning: Multidatabase transaction is in inconsistent state for recovery. */
ALICE_print(106, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 106: Transaction %ld was committed, but prior ones were rolled back. */
return 0;
}
else
advice = TRA_commit;
break;
// a prepared transaction requires a commit if there are missing
// records up to now, otherwise only do something if somebody else
// already has
case TRA_limbo:
if (state == TRA_none)
advice = TRA_commit;
else if (state == TRA_commit)
advice = TRA_commit;
else if (state == TRA_rollback)
advice = TRA_rollback;
break;
// an explicitly rolled back transaction requires a rollback unless a
// transaction has committed or is assumed committed
case TRA_rollback:
if ((state == TRA_commit) || (state == TRA_none)) {
ALICE_print(105, 0, 0, 0, 0, 0); /* msg 105: Warning: Multidatabase transaction is in inconsistent state for recovery. */
ALICE_print(107, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 107: Transaction %ld was rolled back, but prior ones were committed. */
return 0;
}
else
advice = TRA_rollback;
break;
// a missing TDR indicates a committed transaction if a limbo one hasn't
// been found yet, otherwise it implies that the transaction wasn't
// prepared
case TRA_none:
if (state == TRA_commit)
advice = TRA_commit;
else if (state == TRA_limbo)
advice = TRA_rollback;
break;
// specifically advise TRA_unknown to prevent assumption that all are
// in limbo
case TRA_unknown:
if (!advice)
advice = TRA_unknown;
break;
default:
ALICE_print(67, reinterpret_cast < char *>(trans->tdr_state), 0,
0, 0, 0); /* msg 67: Transaction state %d not in valid range. */
return 0;
}
}
return advice;
}
//____________________________________________________________
//
// Attempt to attach a database with a given pathname.
//
BOOLEAN TDR_attach_database(STATUS * status_vector,
TDR trans, TEXT * pathname)
{
UCHAR dpb[128], *d, *q;
USHORT dpb_length;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
#ifndef GUI_TOOLS
if (tdgbl->ALICE_data.ua_debug)
ALICE_print(68, pathname, 0, 0, 0, 0); /* msg 68: ATTACH_DATABASE: attempted attach of %s */
#endif
d = dpb;
*d++ = gds_dpb_version1;
*d++ = gds_dpb_no_garbage_collect;
*d++ = 0;
*d++ = isc_dpb_gfix_attach;
*d++ = 0;
if (tdgbl->ALICE_data.ua_user) {
*d++ = gds_dpb_user_name;
*d++ =
strlen(reinterpret_cast <
const char *>(tdgbl->ALICE_data.ua_user));
for (q = tdgbl->ALICE_data.ua_user; *q;)
*d++ = *q++;
}
if (tdgbl->ALICE_data.ua_password) {
if (!tdgbl->sw_service_thd)
*d++ = gds_dpb_password;
else
*d++ = gds_dpb_password_enc;
*d++ =
strlen(reinterpret_cast <
const char *>(tdgbl->ALICE_data.ua_password));
for (q = tdgbl->ALICE_data.ua_password; *q;)
*d++ = *q++;
}
dpb_length = d - dpb;
if (dpb_length == 1)
dpb_length = 0;
trans->tdr_db_handle = NULL;
gds__attach_database(status_vector,
0,
GDS_VAL(pathname),
reinterpret_cast <
void **>(GDS_REF(trans->tdr_db_handle)), dpb_length,
reinterpret_cast < char *>(GDS_VAL(dpb)));
if (status_vector[1]) {
#ifndef GUI_TOOLS
if (tdgbl->ALICE_data.ua_debug) {
ALICE_print(69, 0, 0, 0, 0, 0); /* msg 69: failed */
ALICE_print_status(status_vector);
}
#endif
return FALSE;
}
MET_set_capabilities(status_vector, trans);
#ifndef GUI_TOOLS
if (tdgbl->ALICE_data.ua_debug)
ALICE_print(70, 0, 0, 0, 0, 0); /* msg 70: succeeded */
#endif
return TRUE;
}
//____________________________________________________________
//
// Get the state of the various transactions
// in a multidatabase transaction.
//
void TDR_get_states(TDR trans)
{
STATUS status_vector[20];
TDR ptr;
for (ptr = trans; ptr; ptr = ptr->tdr_next)
MET_get_state(status_vector, ptr);
}
//____________________________________________________________
//
// Detach all databases associated with
// a multidatabase transaction.
//
void TDR_shutdown_databases(TDR trans)
{
TDR ptr;
STATUS status_vector[20];
for (ptr = trans; ptr; ptr = ptr->tdr_next)
gds__detach_database(status_vector,
reinterpret_cast <
void **>(GDS_REF(ptr->tdr_db_handle)));
}
#ifndef GUI_TOOLS
//
// The following routines are only for the command line utility.
// This should really be split into two files...
//
//____________________________________________________________
//
// List transaction stuck in limbo. If the prompt switch is set,
// prompt for commit, rollback, or leave well enough alone.
//
void TDR_list_limbo(int *handle, TEXT * name, ULONG switches)
{
UCHAR buffer[1024], *ptr;
STATUS status_vector[20];
SLONG id;
USHORT item, flag, length;
TDR trans;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
if (gds__database_info(status_vector,
reinterpret_cast < void **>(GDS_REF(handle)),
sizeof(limbo_info),
reinterpret_cast < char *>(limbo_info),
sizeof(buffer),
reinterpret_cast < char *>(buffer))) {
ALICE_print_status(status_vector);
return;
}
ptr = buffer;
flag = TRUE;
while (flag) {
item = *ptr++;
length = (USHORT) gds__vax_integer(ptr, 2);
ptr += 2;
switch (item) {
case gds_info_limbo:
id = gds__vax_integer(ptr, length);
if (switches &
(sw_commit | sw_rollback | sw_two_phase | sw_prompt)) {
TDR_reconnect_multiple(handle, id, name, switches);
ptr += length;
break;
}
if (!tdgbl->sw_service_thd)
ALICE_print(71, reinterpret_cast < char *>(id), 0, 0, 0, 0); /* msg 71: Transaction %d is in limbo. */
if (trans = MET_get_transaction(status_vector, handle, id)) {
#ifdef SUPERSERVER
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_multi_tra_id);
SVC_putc(tdgbl->service_blk, (UCHAR) id);
SVC_putc(tdgbl->service_blk, (UCHAR) (id >> 8));
SVC_putc(tdgbl->service_blk, (UCHAR) (id >> 16));
SVC_putc(tdgbl->service_blk, (UCHAR) (id >> 24));
#endif
reattach_databases(trans);
TDR_get_states(trans);
TDR_shutdown_databases(trans);
print_description(trans);
}
#ifdef SUPERSERVER
else {
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_single_tra_id);
SVC_putc(tdgbl->service_blk, (UCHAR) id);
SVC_putc(tdgbl->service_blk, (UCHAR) (id >> 8));
SVC_putc(tdgbl->service_blk, (UCHAR) (id >> 16));
SVC_putc(tdgbl->service_blk, (UCHAR) (id >> 24));
}
#endif
ptr += length;
break;
case gds_info_truncated:
if (!tdgbl->sw_service_thd)
ALICE_print(72, 0, 0, 0, 0, 0); /* msg 72: More limbo transactions than fit. Try again */
case gds_info_end:
flag = FALSE;
break;
default:
if (!tdgbl->sw_service_thd)
ALICE_print(73, reinterpret_cast < char *>(item), 0, 0, 0, 0); /* msg 73: Unrecognized info item %d */
}
}
}
//____________________________________________________________
//
// Check a transaction's TDR to see if it is
// a multi-database transaction. If so, commit
// or rollback according to the user's wishes.
// Object strongly if the transaction is in a
// state that would seem to preclude committing
// or rolling back, but essentially do what the
// user wants. Intelligence is assumed for the
// gfix user.
//
BOOLEAN TDR_reconnect_multiple(int *handle,
SLONG id, TEXT * name, ULONG switches)
{
TDR trans, ptr;
STATUS status_vector[20];
USHORT advice;
BOOLEAN error = FALSE;
// get the state of all the associated transactions
if (!(trans = MET_get_transaction(status_vector, handle, id)))
return reconnect(handle, id, name, switches);
reattach_databases(trans);
TDR_get_states(trans);
// analyze what to do with them; if the advice contradicts the user's
// desire, make them confirm it; otherwise go with the flow.
advice = TDR_analyze(trans);
if (!advice) {
print_description(trans);
switches = ask();
}
else {
switch (advice) {
case TRA_rollback:
if (switches & sw_commit) {
ALICE_print(74, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 74: "A commit of transaction %ld will violate two-phase commit. */
print_description(trans);
switches = ask();
}
else if (switches & sw_rollback)
switches |= sw_rollback;
else if (switches & sw_two_phase)
switches |= sw_rollback;
else if (switches & sw_prompt) {
ALICE_print(75, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 75: A rollback of transaction %ld is needed to preserve two-phase commit. */
print_description(trans);
switches = ask();
}
break;
case TRA_commit:
if (switches & sw_rollback) {
ALICE_print(76, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 76: Transaction %ld has already been partially committed. */
ALICE_print(77, 0, 0, 0, 0, 0); /* msg 77: A rollback of this transaction will violate two-phase commit. */
print_description(trans);
switches = ask();
}
else if (switches & sw_commit)
switches |= sw_commit;
else if (switches & sw_two_phase)
switches |= sw_commit;
else if (switches & sw_prompt) {
ALICE_print(78, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 78: Transaction %ld has been partially committed. */
ALICE_print(79, 0, 0, 0, 0, 0); /* msg 79: A commit is necessary to preserve the two-phase commit. */
print_description(trans);
switches = ask();
}
break;
case TRA_unknown:
ALICE_print(80, 0, 0, 0, 0, 0); /* msg 80: Insufficient information is available to determine */
ALICE_print(81, reinterpret_cast < char *>(trans->tdr_id), 0, 0,
0, 0); /* msg 81: a proper action for transaction %ld. */
print_description(trans);
switches = ask();
break;
default:
if (!(switches & (sw_commit | sw_rollback))) {
ALICE_print(82, reinterpret_cast < char *>(trans->tdr_id), 0,
0, 0, 0); /* msg 82: Transaction %ld: All subtransactions have been prepared. */
ALICE_print(83, 0, 0, 0, 0, 0); /* msg 83: Either commit or rollback is possible. */
print_description(trans);
switches = ask();
}
}
}
if (switches != (ULONG) - 1) {
/* now do the required operation with all the subtransactions */
if (switches & (sw_commit | sw_rollback))
for (ptr = trans; ptr; ptr = ptr->tdr_next)
if (ptr->tdr_state == TRA_limbo)
reconnect(reinterpret_cast < int *>(ptr->tdr_db_handle),
ptr->tdr_id, ptr->tdr_filename, switches);
}
else {
ALICE_print(84, 0, 0, 0, 0, 0); /* msg 84: unexpected end of input */
error = TRUE;
}
// shutdown all the databases for cleanliness' sake
TDR_shutdown_databases(trans);
return error;
}
//____________________________________________________________
//
// format and print description of a transaction in
// limbo, including all associated transactions
// in other databases.
//
static void print_description(TDR trans)
{
TDR ptr;
BOOLEAN prepared_seen;
TGBL tdgbl;
int i;
tdgbl = GET_THREAD_DATA;
if (!trans)
return;
if (!tdgbl->sw_service_thd)
ALICE_print(92, 0, 0, 0, 0, 0); /* msg 92: Multidatabase transaction: */
prepared_seen = FALSE;
for (ptr = trans; ptr; ptr = ptr->tdr_next) {
if (ptr->tdr_host_site) {
#ifndef SUPERSERVER
ALICE_print(93,
reinterpret_cast <
char *>(ptr->tdr_host_site->str_data), 0, 0, 0, 0); /* msg 93: Host Site: %s */
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_host_site);
SVC_putc(tdgbl->service_blk,
(UCHAR) strlen(reinterpret_cast <
const char *>(ptr->
tdr_host_site->str_data)));
SVC_putc(tdgbl->service_blk,
(UCHAR) (strlen
(reinterpret_cast <
const char *>(ptr->
tdr_host_site->str_data)) >> 8));
for (i = 0;
i < (int) strlen(reinterpret_cast <
const char *>(ptr->
tdr_host_site->str_data));
i++);
SVC_putc(tdgbl->service_blk,
(UCHAR) ptr->tdr_host_site->str_data[i]);
#endif
}
if (ptr->tdr_id)
#ifndef SUPERSERVER
ALICE_print(94, reinterpret_cast < char *>(ptr->tdr_id), 0, 0, 0, 0); /* msg 94: Transaction %ld */
#else
{
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_id);
SVC_putc(tdgbl->service_blk, (UCHAR) ptr->tdr_id);
SVC_putc(tdgbl->service_blk, (UCHAR) (ptr->tdr_id >> 8));
SVC_putc(tdgbl->service_blk, (UCHAR) (ptr->tdr_id >> 16));
SVC_putc(tdgbl->service_blk, (UCHAR) (ptr->tdr_id >> 24));
}
#endif
switch (ptr->tdr_state) {
case TRA_limbo:
#ifndef SUPERSERVER
ALICE_print(95, 0, 0, 0, 0, 0); /* msg 95: has been prepared. */
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state_limbo);
#endif
prepared_seen = TRUE;
break;
case TRA_commit:
#ifndef SUPERSERVER
ALICE_print(96, 0, 0, 0, 0, 0); /* msg 96: has been committed. */
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state_commit);
#endif
break;
case TRA_rollback:
#ifndef SUPERSERVER
ALICE_print(97, 0, 0, 0, 0, 0); /* msg 97: has been rolled back. */
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state_rollback);
#endif
break;
case TRA_unknown:
#ifndef SUPERSERVER
ALICE_print(98, 0, 0, 0, 0, 0); /* msg 98: is not available. */
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_state_unknown);
#endif
break;
default:
#ifndef SUPERSERVER
if (prepared_seen)
ALICE_print(99, 0, 0, 0, 0, 0); /* msg 99: is not found, assumed not prepared. */
else
ALICE_print(100, 0, 0, 0, 0, 0); /* msg 100: is not found, assumed to be committed. */
#endif
break;
}
if (ptr->tdr_remote_site) {
#ifndef SUPERSERVER
ALICE_print(101,
reinterpret_cast <
char *>(ptr->tdr_remote_site->str_data), 0, 0, 0, 0); /*msg 101: Remote Site: %s */
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_remote_site);
SVC_putc(tdgbl->service_blk,
(UCHAR) strlen(reinterpret_cast <
const char *>(ptr->
tdr_remote_site->str_data)));
SVC_putc(tdgbl->service_blk,
(UCHAR) (strlen
(reinterpret_cast <
const char *>(ptr->
tdr_remote_site->str_data)) >>
8));
for (i = 0;
i < (int) strlen(reinterpret_cast <
const char *>(ptr->
tdr_remote_site->str_data));
i++) SVC_putc(tdgbl->service_blk,
(UCHAR) ptr->tdr_remote_site->str_data[i]);
#endif
}
if (ptr->tdr_fullpath) {
#ifndef SUPERSERVER
ALICE_print(102,
reinterpret_cast <
char *>(ptr->tdr_fullpath->str_data), 0, 0, 0, 0); /* msg 102: Database Path: %s */
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_db_path);
SVC_putc(tdgbl->service_blk,
(UCHAR) strlen(reinterpret_cast <
const char *>(ptr->
tdr_fullpath->str_data)));
SVC_putc(tdgbl->service_blk,
(UCHAR) (strlen
(reinterpret_cast <
const char *>(ptr->
tdr_fullpath->str_data)) >> 8));
for (i = 0;
i < (int) strlen(reinterpret_cast <
const char *>(ptr->tdr_fullpath->str_data));
i++) SVC_putc(tdgbl->service_blk,
(UCHAR) ptr->tdr_fullpath->str_data[i]);
#endif
}
}
// let the user know what the suggested action is
switch (TDR_analyze(trans)) {
case TRA_commit:
#ifndef SUPERSERVER
ALICE_print(103, 0, 0, 0, 0, 0); /* msg 103: Automated recovery would commit this transaction. */
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise_commit);
#endif
break;
case TRA_rollback:
#ifndef SUPERSERVER
ALICE_print(104, 0, 0, 0, 0, 0); /* msg 104: Automated recovery would rollback this transaction. */
#else
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise_rollback);
#endif
break;
default:
#ifdef SUPERSERVER
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise);
SVC_putc(tdgbl->service_blk, (UCHAR) isc_spb_tra_advise_unknown);
#endif
break;
}
}
//____________________________________________________________
//
// Ask the user whether to commit or rollback.
//
static ULONG ask(void)
{
UCHAR response[32], *p;
int c;
ULONG switches;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
switches = 0;
while (TRUE) {
ALICE_print(85, 0, 0, 0, 0, 0); /* msg 85: Commit, rollback, or neither (c, r, or n)? */
if (tdgbl->sw_service)
ib_putc('\001', ib_stdout);
ib_fflush(ib_stdout);
for (p = response; (c = ib_getchar()) != '\n' && c != EOF;)
*p++ = c;
if (c == EOF && p == response)
return (ULONG) - 1;
*p = 0;
ALICE_down_case(reinterpret_cast < char *>(response),
reinterpret_cast < char *>(response));
if (!strcmp(reinterpret_cast < const char *>(response), "n")
|| !strcmp(reinterpret_cast < const char *>(response), "c")
|| !strcmp(reinterpret_cast < const char *>(response), "r"))
break;
}
if (response[0] == 'c')
switches |= sw_commit;
else if (response[0] == 'r')
switches |= sw_rollback;
return switches;
}
//____________________________________________________________
//
// Generate pathnames for a given database
// until the database is successfully attached.
//
static void reattach_database(TDR trans)
{
STATUS status_vector[20];
UCHAR buffer[1024], *p, *q, *start;
USHORT protocols = 0;
STR string;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
// determine what protocols are allowable for this OS
#ifdef VMS
protocols |= DECNET_PROTOCOL | VMS_TCP_PROTOCOL;
#else
protocols |= TCP_PROTOCOL;
#endif
#ifdef ultrix
protocols |= DECNET_PROTOCOL;
#endif
ISC_get_host(reinterpret_cast < char *>(buffer), sizeof(buffer));
// if this is being run from the same host,
// (or if this is apollo land), just
// try to reconnect using the same pathname
if ((protocols & APOLLO_PROTOCOL) ||
!strcmp(reinterpret_cast < const char *>(buffer),
reinterpret_cast <
const char *>(trans->tdr_host_site->str_data)))
{
if (TDR_attach_database(status_vector,
trans,
reinterpret_cast<char*>(trans->tdr_fullpath->str_data)))
{
return;
}
}
// try going through the previous host with all available
// protocols, using chaining to try the same method of
// attachment originally used from that host
else if (trans->tdr_host_site) {
for (p = buffer, q = trans->tdr_host_site->str_data; *q;)
*p++ = *q++;
start = p;
if (protocols & DECNET_PROTOCOL) {
p = start;
*p++ = ':';
*p++ = ':';
for (q = trans->tdr_fullpath->str_data; *q;)
*p++ = *q++;
*q = 0;
if (TDR_attach_database
(status_vector, trans,
reinterpret_cast < char *>(buffer))) return;
}
if (protocols & VMS_TCP_PROTOCOL) {
p = start;
*p++ = '^';
for (q = trans->tdr_fullpath->str_data; *q;)
*p++ = *q++;
*q = 0;
if (TDR_attach_database
(status_vector, trans,
reinterpret_cast < char *>(buffer))) return;
}
if (protocols & TCP_PROTOCOL) {
p = start;
*p++ = ':';
for (q = trans->tdr_fullpath->str_data; *q;)
*p++ = *q++;
*q = 0;
if (TDR_attach_database
(status_vector, trans,
reinterpret_cast < char *>(buffer))) return;
}
}
// attaching using the old method didn't work;
// try attaching to the remote node directly
if (trans->tdr_remote_site) {
for (p = buffer, q = trans->tdr_remote_site->str_data; *q;)
*p++ = *q++;
start = p;
if (protocols & DECNET_PROTOCOL) {
p = start;
*p++ = ':';
*p++ = ':';
for (q = (UCHAR *) trans->tdr_filename; *q;)
*p++ = *q++;
*q = 0;
if (TDR_attach_database
(status_vector, trans,
reinterpret_cast < char *>(buffer))) return;
}
if (protocols & VMS_TCP_PROTOCOL) {
p = start;
*p++ = '^';
for (q = (UCHAR *) trans->tdr_filename; *q;)
*p++ = *q++;
*q = 0;
if (TDR_attach_database
(status_vector, trans,
reinterpret_cast < char *>(buffer))) return;
}
if (protocols & TCP_PROTOCOL) {
p = start;
*p++ = ':';
for (q = (UCHAR *) trans->tdr_filename; *q;)
*p++ = *q++;
*q = 0;
if (TDR_attach_database
(status_vector, trans,
reinterpret_cast < char *>(buffer))) return;
}
if (protocols & MSLAN_PROTOCOL) {
p = buffer;
*p++ = '\\';
*p++ = '\\';
for (q = trans->tdr_remote_site->str_data; *q;)
*p++ = *q++;
for (q = (UCHAR *) trans->tdr_filename; *q;)
*p++ = *q++;
*q = 0;
if (TDR_attach_database
(status_vector, trans,
reinterpret_cast < char *>(buffer))) return;
}
}
// we have failed to reattach; notify the user
// and let them try to succeed where we have failed
ALICE_print(86, reinterpret_cast < char *>(trans->tdr_id), 0, 0, 0, 0); /* msg 86: Could not reattach to database for transaction %ld. */
ALICE_print(87, reinterpret_cast < char *>(trans->tdr_fullpath->str_data),
0, 0, 0, 0); /* msg 87: Original path: %s */
for (;;) {
ALICE_print(88, 0, 0, 0, 0, 0); /* msg 88: Enter a valid path: */
for (p = buffer; (*p = ib_getchar()) != '\n'; p++);
*p = 0;
if (!buffer[0])
break;
p = buffer;
while (*p == ' ')
*p++;
if (TDR_attach_database
(status_vector, trans, reinterpret_cast < char *>(p))) {
string =
(STR) ALLOCDV(type_str,
strlen(reinterpret_cast <
const char *>(p)) + 1);
strcpy(reinterpret_cast < char *>(string->str_data),
reinterpret_cast < const char *>(p));
string->str_length = strlen(reinterpret_cast < const char *>(p));
trans->tdr_fullpath = string;
trans->tdr_filename = (TEXT *) string->str_data;
return;
}
ALICE_print(89, 0, 0, 0, 0, 0); /* msg 89: Attach unsuccessful. */
}
}
//____________________________________________________________
//
// Attempt to locate all databases used in
// a multidatabase transaction.
//
static void reattach_databases(TDR trans)
{
TDR ptr;
for (ptr = trans; ptr; ptr = ptr->tdr_next)
reattach_database(ptr);
}
//____________________________________________________________
//
// Commit or rollback a named transaction.
//
static BOOLEAN reconnect(int *handle,
SLONG number, TEXT * name, ULONG switches)
{
int *transaction;
SLONG id;
STATUS status_vector[20];
id = gds__vax_integer((UCHAR *) & number, 4);
transaction = NULL;
if (gds__reconnect_transaction(status_vector,
reinterpret_cast <
void **>(GDS_REF(handle)),
reinterpret_cast <void **>(GDS_REF(transaction)),
sizeof(id),
reinterpret_cast <char *>(GDS_REF(id)))) {
ALICE_print(90, name, 0, 0, 0, 0); /* msg 90: failed to reconnect to a transaction in database %s */
ALICE_print_status(status_vector);
return TRUE;
}
if (!(switches & (sw_commit | sw_rollback))) {
ALICE_print(91, reinterpret_cast < char *>(number), 0, 0, 0, 0); /* msg 91: Transaction %ld: */
switches = ask();
if (switches == (ULONG) - 1) {
ALICE_print(84, 0, 0, 0, 0, 0); /* msg 84: unexpected end of input */
return TRUE;
}
}
if (switches & sw_commit)
gds__commit_transaction(status_vector,
reinterpret_cast <void **>(GDS_REF(transaction)));
else if (switches & sw_rollback)
gds__rollback_transaction(status_vector,
reinterpret_cast <void **>(GDS_REF(transaction)));
else
return FALSE;
if (status_vector[1]) {
ALICE_print_status(status_vector);
return TRUE;
}
return FALSE;
}
#endif /* GUI_TOOLS */

42
src/alice/tdr_proto.h Normal file
View File

@ -0,0 +1,42 @@
/*
* PROGRAM: Alice (All Else) Utility
* MODULE: tdr_proto.h
* DESCRIPTION: Prototype header file for tdr.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef ALICE_TDR_PROTO_H
#define ALICE_TDR_PROTO_H
#ifdef __cplusplus
extern "C" {
#endif
void TDR_list_limbo(int*, TEXT*, ULONG);
BOOLEAN TDR_reconnect_multiple(int*, SLONG, TEXT*, ULONG);
void TDR_shutdown_databases(TDR);
USHORT TDR_analyze(TDR);
BOOLEAN TDR_attach_database(STATUS*, TDR, TEXT*);
void TDR_get_states(TDR);
#ifdef __cplusplus
};
#endif
#endif /* ALICE_TDR_PROTO_H */

37
src/burp/backu_proto.h Normal file
View File

@ -0,0 +1,37 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: backu_proto.h
* DESCRIPTION: Prototype Header file for backup.e
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _BURP_BACKU_PROTO_H_
#define _BURP_BACKU_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
extern int BACKUP_backup (TEXT *, TEXT *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _BURP_BACKU_PROTO_H_ */

4099
src/burp/backup.e Normal file

File diff suppressed because it is too large Load Diff

2258
src/burp/burp.cpp Normal file

File diff suppressed because it is too large Load Diff

45
src/burp/burp.def Normal file
View File

@ -0,0 +1,45 @@
; The contents of this file are subject to the Interbase Public
; License Version 1.0 (the "License"); you may not use this file
; except in compliance with the License. You may obtain a copy
; of the License at http://www.Inprise.com/IPL.html
;
; Software distributed under the License is distributed on an
; "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
; or implied. See the License for the specific language governing
; rights and limitations under the License.
;
; The Original Code was created by Inprise Corporation
; and its predecessors. Portions created by Inprise Corporation are
; Copyright (C) Inprise Corporation.
;
; All Rights Reserved.
; Contributor(s): ______________________________________.
;------------------------------------------------------------
; GBAK DLL MODULE DEFINITION FILE
;------------------------------------------------------------
LIBRARY GBAK.DLL
DESCRIPTION 'INTERBASE BACKUP/RESTORE DLL'
CODE MOVEABLE
DATA MOVEABLE
SEGMENTS
_TEXT DISCARDABLE
BURP_TEXT DISCARDABLE
CANONICA_TEXT DISCARDABLE
MISC_TEXT DISCARDABLE
MVOL_TEXT DISCARDABLE
BACKUP_TEXT DISCARDABLE
RESTORE_TEXT DISCARDABLE
BURPWEP_TEXT PRELOAD
XDR_TEXT DISCARDABLE
NTOH_TEXT DISCARDABLE
DLLSHELL_TEXT PRELOAD
EXPORTS
_BURP_gbak @2
; WEP @1 RESIDENTNAME
IMPORTS
_gds__start_transaction=gds32.gds__start_transaction

945
src/burp/burp.h Normal file
View File

@ -0,0 +1,945 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: burp.h
* DESCRIPTION: Burp file format
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _BURP_BURP_H_
#define _BURP_BURP_H_
#include "../jrd/ib_stdio.h"
#include "../jrd/common.h"
#include "../include/jrd/gds.h"
#include "../jrd/dsc.h"
#include "../burp/burp_proto.h"
#include "../burp/misc_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/thd.h"
#ifdef __cplusplus
extern "C" {
#endif
#define BURP_ALLOC(size) MISC_alloc_burp((ULONG) size)
#define BURP_ALLOC_ZERO(size) MISC_alloc_burp((ULONG) size)
#define BURP_FREE(block) MISC_free_burp(block)
#define GDS_NAME_LEN 32
typedef TEXT GDS_NAME [GDS_NAME_LEN];
#define NOOUTPUT 2
/* Record types in backup file */
typedef enum rec_type {
rec_burp, /* Restore program attributes */
rec_database, /* Logical database parameters */
rec_global_field, /* Global field description */
rec_relation, /* Relation description */
rec_field, /* Local field description */
rec_index, /* Index description */
rec_data, /* Data for relation */
rec_blob, /* Blob */
rec_relation_data, /* Standalone data header */
rec_relation_end, /* End of data for relation */
rec_end, /* End of file */
rec_view, /* View attributes */
rec_security_class, /* Security class acl */
rec_trigger, /* Trigger definition */
rec_physical_db, /* Physical database parameters */
rec_function, /* Function description */
rec_function_arg, /* Function arguement description */
rec_function_end, /* End of function and its args */
rec_gen_id, /* From blr_gen_id */
rec_type, /* Type of field */
rec_filter, /* Filter */
rec_trigger_message, /* Trigger message texts */
rec_user_privilege, /* User privilege */
rec_array, /* 23*/ /* Array blob */
rec_field_dimensions, /* Array field dimensions */
rec_files, /* files for shadowing */
rec_generator, /* another format for gen-ids */
rec_procedure, /* Stored procedure */
rec_procedure_prm, /* Stored procedure parameters */
rec_procedure_end, /* End of procedure and its args */
rec_exception, /* Exception */
rec_rel_constraint, /* Relation constraints */
rec_ref_constraint, /* Referential constraints */
rec_chk_constraint, /* Check constraints */
rec_charset, /* Character sets */
rec_collation, /* Collations */
rec_sql_roles /* SQL roles */
} REC_TYPE;
/* The order of battle for major records is:
[<rec_physical_database>] <rec_database> <global fields> <field dimensions> <relation> <function>
<types> <filters> <relation data> <trigger-new> <trigger messages> <user privileges> <security> rec_end
where each relation is:
<rec_relation> <rel name> <att_end> <local fields> <view> <rec_relation_end>
where local fields is:
<rec_field> <att_field_... att_field_dimensions, att_field_range_low, att_field_range_high...> <att_end>
where each relation data is:
<rec_relation_data> <rel attributes> <gen id> <indices> <data> <trigger-old> <rec_relation_end>
where data is:
<rec_data> <rec length> [<xdr_length>] <data attr> [ <blob>, <array>...]
and <blob> is
<rec_blob> <blob_field_number> <max_sigment> <blob_type> <number_segments> <blob_data>
and <array> is
<rec_array> <blob_field_number> <att_array_dimensions> <att_array_range_low>
<att_array_range_high> <blob_data> [<att_xdr_array>]
where each function is:
<rec_function> <function attributes> <att_end> [<function_arguments>] <rec_function_end>
and <function_arguments> is
<rec_function_arg> <function argument attributes> <att_end>
where trigger-old is:
<rec_trigger> <trig_type> <trig_blr> <trig_source> <att_end>
and trigger-new is:
<rec_trigger> <trig_type> <trig_blr> <trig_source> <trigger name> <relation name> <trig_seqence>
<description> <system flag> <att_end>
*/
/* Attributes within major record */
/* CAREFUL not to pull the lastest version into maint version without
modifying the att_backup_format to be one version back */
/* ATT_BACKUP_FORMAT has been increased to 5. It allows us to distinguish
backup format between IB3.3/IB4.0 and IB4.5 in case of migration
problem */
/* Version 6: Supports SQL Time & Date columns.
RDB$FIELD_PRECISION
SQL Dialect from database header
SQL_INT64 columns and generator values
*/
#define ATT_BACKUP_FORMAT 6
/* format version number for ranges for arrays */
#define GDS_NDA_VERSION 1
/* max array dimension */
#define MAX_DIMENSION 16
#define SERIES 1
enum att_type {
att_end = 0, /* end of major record */
/* Backup program attributes */
att_backup_date = SERIES, /* date of backup */
att_backup_format, /* backup format version */
att_backup_os, /* backup operating system */
att_backup_compress,
att_backup_transportable, /* XDR datatypes for user data */
att_backup_blksize, /* backup block size */
att_backup_file, /* database file name */
att_backup_volume, /* backup volume number */
/* Database attributes */
att_file_name = SERIES, /* database file name (physical) */
att_file_size, /* size of original database (physical) */
att_jrd_version, /* jrd version (physical) */
att_creation_date, /* database creation date (physical) */
att_page_size, /* page size of original database (physical) */
att_database_description, /* description from RDB$DATABASE (logical) */
att_database_security_class, /* database level security (logical) */
att_sweep_interval, /* sweep interval */
att_no_reserve, /* don't reserve space for versions */
att_database_description2,
att_database_dfl_charset, /* default character set from RDB$DATABASE */
att_forced_writes, /* syncronous writes flag */
att_page_buffers, /* page buffers for buffer cache */
att_SQL_dialect, /* SQL dialect that it speaks */
att_db_read_only, /* Is the database ReadOnly? */
/* Relation attributes */
att_relation_name = SERIES,
att_relation_view_blr,
att_relation_description,
att_relation_record_length, /* Record length in file */
att_relation_view_relation,
att_relation_view_context,
att_relation_system_flag,
att_relation_security_class,
att_relation_view_source,
att_relation_dummy, /* this space available */
att_relation_ext_description,
att_relation_owner_name,
att_relation_description2,
att_relation_view_source2,
att_relation_ext_description2,
att_relation_flags,
att_relation_ext_file_name, /* name of file for external tables */
/* Field attributes (used for both global and local fields) */
att_field_name = SERIES, /* name of field */
att_field_source, /* Global field name for local field */
att_base_field, /* Source field for view */
att_view_context, /* Context variable for view definition */
att_field_query_name, /* Query attributes */
att_field_query_header,
att_field_edit_string,
att_field_type, /* Physical attributes */
att_field_sub_type,
att_field_length, /* 10 */
att_field_scale,
att_field_segment_length,
att_field_position, /* Field position in relation (not in file) */
att_field_offset, /* Offset in data record (local fields only) */
att_field_default_value, /* Fluff */
att_field_description,
att_field_missing_value,
att_field_computed_blr,
att_field_computed_source,
att_field_validation_blr, /* 20 */
att_field_validation_source,
att_field_number, /* Field number to match up blobs */
att_field_computed_flag, /* Field is computed, not real */
att_field_system_flag, /* Interesting system flag */
att_field_security_class,
att_field_external_length,
att_field_external_type,
att_field_external_scale,
att_field_dimensions, /* 29 */
att_field_ranges, /* this space for rent */
att_field_complex_name, /* relation field attribute */
att_field_range_low, /* low range for array */
att_field_range_high, /* high range for array */
att_field_update_flag,
att_field_description2,
att_field_validation_source2,
att_field_computed_source2,
att_field_null_flag, /* If field can be null */
att_field_default_source, /* default source for field (new fmt only) */
att_field_missing_source, /* missing source for field (new fmt only) */
att_field_character_length, /* length of field in characters */
att_field_character_set, /* Charset id of field */
att_field_collation_id, /* Collation id of field */
att_field_precision, /* numeric field precision of RDB$FIELDS */
/* Index attributes */
att_index_name = SERIES,
att_segment_count,
att_index_inactive,
att_index_unique_flag,
att_index_field_name,
att_index_description,
att_index_type,
att_index_foreign_key,
att_index_description2,
att_index_expression_source,
att_index_expression_blr,
/* Data record */
att_data_length = SERIES,
att_data_data,
/* Blob record */
att_blob_field_number = SERIES + 2, /* Field number of blob field */
att_blob_type, /* Segmented = 0, stream = 1 */
att_blob_number_segments, /* Number of segments */
att_blob_max_segment, /* Longest segment */
att_blob_data,
/* View attributes */
att_view_relation_name = SERIES + 7,
att_view_context_id,
att_view_context_name,
/* Security class attributes */
att_class_security_class = SERIES + 10,
att_class_acl,
att_class_description,
/* Array attributes */
att_array_dimensions = SERIES + 13,
att_array_range_low,
att_array_range_high,
/* XDR encoded data attributes */
att_xdr_length = SERIES + 16,
att_xdr_array,
att_class_description2,
/* Trigger attributes */
att_trig_type = SERIES,
att_trig_blr,
att_trig_source,
att_trig_name,
att_trig_relation_name,
att_trig_sequence,
att_trig_description,
att_trig_system_flag,
att_trig_inactive,
att_trig_source2,
att_trig_description2,
att_trig_flags,
/* Function attributes */
att_function_name = SERIES,
att_function_description,
att_function_class,
att_function_module_name,
att_function_entrypoint,
att_function_return_arg,
att_function_query_name,
att_function_type,
att_function_description2,
/* Function argument attributes */
att_functionarg_name = SERIES,
att_functionarg_position,
att_functionarg_mechanism,
att_functionarg_field_type,
att_functionarg_field_scale,
att_functionarg_field_length,
att_functionarg_field_sub_type,
att_functionarg_character_set,
att_functionarg_field_precision,
/* TYPE relation attributes */
att_type_name = SERIES,
att_type_type,
att_type_field_name,
att_type_description,
att_type_system_flag,
/* Also see att_type_description2 below! */
/* Filter attributes */
att_filter_name,
att_filter_description,
att_filter_module_name,
att_filter_entrypoint,
att_filter_input_sub_type,
att_filter_output_sub_type,
att_filter_description2,
att_type_description2,
/* Trigger message attributes */
att_trigmsg_name = SERIES,
att_trigmsg_number,
att_trigmsg_text,
/* User privilege attributes */
att_priv_user = SERIES,
att_priv_grantor,
att_priv_privilege,
att_priv_grant_option,
att_priv_object_name,
att_priv_field_name,
att_priv_user_type,
att_priv_obj_type,
/* files for shadowing purposes */
att_file_filename = SERIES,
att_file_sequence,
att_file_start,
att_file_length,
att_file_flags,
att_shadow_number,
/* Attributes for gen_id */
att_gen_generator = SERIES,
att_gen_value,
att_gen_value_int64,
/* Stored procedure attributes */
att_procedure_name = SERIES,
att_procedure_inputs,
att_procedure_outputs,
att_procedure_description,
att_procedure_description2,
att_procedure_source,
att_procedure_source2,
att_procedure_blr,
att_procedure_security_class,
att_procedure_owner_name,
/* Stored procedure parameter attributes */
att_procedureprm_name = SERIES,
att_procedureprm_number,
att_procedureprm_type,
att_procedureprm_field_source,
att_procedureprm_description,
att_procedureprm_description2,
/* Exception attributes */
att_exception_name = SERIES,
att_exception_msg,
att_exception_description,
att_exception_description2,
/* Relation constraints attributes */
att_rel_constraint_name = SERIES,
att_rel_constraint_type,
att_rel_constraint_rel_name,
att_rel_constraint_defer,
att_rel_constraint_init,
att_rel_constraint_index,
/* Referential constraints attributes */
att_ref_constraint_name = SERIES,
att_ref_unique_const_name,
att_ref_match_option,
att_ref_update_rule,
att_ref_delete_rule,
/* SQL roles attributes */
att_role_name = SERIES,
att_role_owner_name,
/* Check constraints attributes */
att_chk_constraint_name = SERIES,
att_chk_trigger_name,
/* Character Set attributes */
att_charset_name = SERIES,
att_charset_form,
att_charset_numchar,
att_charset_coll,
att_charset_id,
att_charset_sysflag,
att_charset_description,
att_charset_funct,
att_charset_bytes_char,
att_coll_name = SERIES,
att_coll_id,
att_coll_cs_id,
att_coll_attr,
att_coll_subtype, /* Unused: 93-11-12 Daves */
att_coll_sysflag,
att_coll_description,
att_coll_funct
};
#define ATT_TYPE enum att_type
// TMN: Why was this even added in the first place???
//typedef SCHAR att_type;
/* Trigger types */
enum trig_t {
trig_pre_store = 1, /* default */
trig_pre_modify, /* default */
trig_post_erase /* default */
};
/* these types to go away when recognized by gpre as
<relation>.<field>.<type> some time in the future */
#define TRIG_TYPE_PRE_STORE 1
#define TRIG_TYPE_PRE_MODIFY 3
#define TRIG_TYPE_POST_ERASE 6
/* default trigger name templates */
#define TRIGGER_SEQUENCE_DEFAULT 0
/* common structure definitions */
/* field block, used to hold local field definitions */
typedef struct fld {
struct fld *fld_next;
SSHORT fld_type;
SSHORT fld_sub_type;
FLD_LENGTH fld_length;
SSHORT fld_scale;
SSHORT fld_position;
SSHORT fld_parameter;
SSHORT fld_missing_parameter;
SSHORT fld_id;
RCRD_OFFSET fld_offset;
RCRD_OFFSET fld_old_offset;
SSHORT fld_number;
SSHORT fld_system_flag;
SSHORT fld_name_length;
TEXT fld_name [32];
TEXT fld_source [32];
TEXT fld_base [32];
TEXT fld_query_name [32];
TEXT fld_security_class [32];
SSHORT fld_edit_length;
SSHORT fld_view_context;
SSHORT fld_update_flag;
SSHORT fld_flags;
TEXT fld_edit_string [256];
GDS__QUAD fld_description;
GDS__QUAD fld_query_header;
TEXT fld_complex_name [32];
SSHORT fld_dimensions;
SLONG fld_ranges [2 * MAX_DIMENSION];
SSHORT fld_null_flag;
GDS__QUAD fld_default_value;
GDS__QUAD fld_default_source;
SSHORT fld_character_length;
SSHORT fld_character_set_id;
SSHORT fld_collation_id;
} *FLD;
#define FLD_computed 1
#define FLD_position_missing 2
#define FLD_array 4
#define FLD_update_missing 8
#define FLD_null_flag 16
#define FLD_charset_flag 32 /* column has global charset */
#define FLD_collate_flag 64 /* local column has specific collation */
/* relation definition - holds useful relation type stuff */
typedef struct rel {
struct rel *rel_next;
struct fld *rel_fields;
SSHORT rel_flags;
SSHORT rel_id;
SSHORT rel_name_length;
GDS_NAME rel_name;
GDS_NAME rel_owner; /* relation owner, if not us */
GDS__QUAD rel_store_blr; /* trigger blr blob id */
GDS__QUAD rel_store_source; /* trigger source blob id */
GDS__QUAD rel_modify_blr; /* trigger blr blob id */
GDS__QUAD rel_modify_source; /* trigger source blob id */
GDS__QUAD rel_erase_blr; /* trigger blr blob id */
GDS__QUAD rel_erase_source; /* trigger source blob id */
} *REL;
#define REL_view 1
#define REL_external 2
/* procedure definition - holds useful procedure type stuff */
typedef struct prc {
struct prc *prc_next;
SSHORT prc_name_length;
GDS_NAME prc_name;
GDS_NAME prc_owner; /* relation owner, if not us */
} *PRC;
typedef struct gfld {
TEXT gfld_name [32];
ISC_QUAD gfld_vb;
ISC_QUAD gfld_vs;
ISC_QUAD gfld_vs2;
struct gfld *gfld_next;
USHORT gfld_flags;
} *GFLD;
#define GFLD_validation_blr 1
#define GFLD_validation_source 2
#define GFLD_validation_source2 4
#define MAX_FILE_NAME_LENGTH 256
/* Note that this typedef is also defined in JRD.H and REMOTE.H */
/* but for some reason we are avoiding including JRD.H */
/* and this typedef is needed to include SVC.H */
#if !(defined REMOTE_REMOTE_H || defined JRD_JRD_H)
#ifndef INCLUDE_FB_BLK
#include "../include/fb_blk.h"
#endif
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "../jrd/svc.h"
#include "../jrd/svc_proto.h"
#ifdef __cplusplus
extern "C" {
#endif
/* typedef the file descriptor type to make things cleaner */
#ifdef WIN_NT
typedef void *DESC;
#define CLOSE CloseHandle
#define UNLINK DeleteFile
#define FLUSH(x) FlushFileBuffers(x)
#else
typedef int DESC;
#define CLOSE close
#define UNLINK unlink
#define FLUSH(x) /* nothing */
#define INVALID_HANDLE_VALUE -1
#endif /* WIN_NT */
/* File block -- for multi-file databases */
typedef enum {
size_n = 0, /* none */
size_k, /* k = 1024 */
size_m, /* m = k x 1024 */
size_g, /* g = m x 1024 */
size_e /* error */
} SIZE_CODE;
typedef struct fil {
struct fil *fil_next;
TEXT *fil_name;
ULONG fil_length;
DESC fil_fd;
USHORT fil_seq;
SIZE_CODE fil_size_code;
} *FIL;
#define FIL_LEN sizeof (struct fil)
/* Split & Join stuff */
typedef enum act_t {
ACT_unknown, /* action is unknown */
ACT_backup,
ACT_backup_split,
ACT_restore,
ACT_restore_join
} ACT_T;
typedef struct act {
USHORT act_total;
FIL act_file;
ACT_T act_action;
} *ACT;
#define ACT_LEN sizeof (struct act)
#define MAX_LENGTH -1
/* This structure has been cloned from spit.c */
typedef struct hdr_split {
TEXT hdr_split_tag[18];
TEXT hdr_split_timestamp[30];
TEXT hdr_split_text1[11];
TEXT hdr_split_sequence[4]; /* File sequence number */
TEXT hdr_split_text2[4];
TEXT hdr_split_total[4]; /* Total number of files */
TEXT hdr_split_text3[2];
TEXT hdr_split_name[27]; /* File name */
} *HDR_SPLIT;
/* NOTE: size of the hdr_split_tag and HDR_SPLIT_TAG must be the same and equal
to 18. Otherwise we will not be able to join the gbk files v5.x */
#define HDR_SPLIT_SIZE sizeof (struct hdr_split)
#define HDR_SPLIT_TAG5 "InterBase/gsplit, "
#define HDR_SPLIT_TAG6 "InterBase/gbak, "
#define HDR_SPLIT_TAG HDR_SPLIT_TAG6
#define MIN_SPLIT_SIZE 2048 /* bytes */
/* Global switches and data */
typedef struct tgbl {
struct thdd tgbl_thd_data;
TEXT *gbl_database_file_name;
TEXT gbl_backup_start_time [30];
USHORT gbl_sw_verbose;
USHORT gbl_sw_ignore_limbo;
USHORT gbl_sw_meta;
USHORT gbl_sw_novalidity;
USHORT gbl_sw_page_size;
USHORT gbl_sw_compress;
USHORT gbl_sw_version;
USHORT gbl_sw_transportable;
USHORT gbl_sw_incremental;
USHORT gbl_sw_deactivate_indexes;
USHORT gbl_sw_kill;
USHORT gbl_sw_blk_factor;
USHORT gbl_sw_no_reserve;
USHORT gbl_sw_old_descriptions;
USHORT gbl_sw_service_gbak;
USHORT gbl_sw_service_thd;
USHORT gbl_sw_bug8183;
USHORT gbl_sw_convert_ext_tables;
BOOLEAN gbl_sw_mode;
BOOLEAN gbl_sw_mode_val;
SCHAR *gbl_sw_sql_role;
SCHAR *gbl_sw_user;
SCHAR *gbl_sw_password;
SLONG gbl_sw_skip_count;
SLONG gbl_sw_page_buffers;
FIL gbl_sw_files;
FIL gbl_sw_backup_files;
GFLD gbl_global_fields;
ACT action;
ULONG io_buffer_size;
USHORT sw_redirect;
UCHAR dpb_string [100];
SSHORT dpb_length;
UCHAR *burp_env;
UCHAR *io_ptr;
int io_cnt;
REL relations;
PRC procedures;
SLONG BCK_capabilities;
USHORT RESTORE_format;
ULONG mvol_io_buffer_size;
ULONG mvol_actual_buffer_size;
ULONG mvol_cumul_count_kb;
UCHAR *mvol_io_ptr;
int mvol_io_cnt;
UCHAR *mvol_io_buffer;
UCHAR *mvol_io_volume;
UCHAR *mvol_io_header;
UCHAR *mvol_io_data;
TEXT mvol_db_name_buffer [MAX_FILE_NAME_LENGTH];
SCHAR mvol_old_file [MAX_FILE_NAME_LENGTH];
int mvol_volume_count;
USHORT mvol_empty_file;
isc_db_handle db_handle;
isc_tr_handle tr_handle;
isc_tr_handle global_trans;
DESC file_desc;
long *status; /* points to either the tdgbl status or service status */
long status_vector [ISC_STATUS_LENGTH];
int exit_code;
UCHAR *head_of_mem_list;
OUTPUTPROC output_proc;
SLONG output_data;
IB_FILE *output_file;
SVC service_blk;
/*
* Link list of global fields that were converted from V3 sub_type
* to V4 char_set_id/collate_id. Needed for local fields conversion.
*/
FLD v3_cvt_fld_list;
isc_req_handle handles_get_character_sets_req_handle1;
isc_req_handle handles_get_chk_constraint_req_handle1;
isc_req_handle handles_get_collation_req_handle1;
isc_req_handle handles_get_exception_req_handle1;
isc_req_handle handles_get_field_dimensions_req_handle1;
isc_req_handle handles_get_field_req_handle1;
isc_req_handle handles_get_fields_req_handle1;
isc_req_handle handles_get_fields_req_handle2;
isc_req_handle handles_get_fields_req_handle3;
isc_req_handle handles_get_fields_req_handle4;
isc_req_handle handles_get_fields_req_handle5;
isc_req_handle handles_get_fields_req_handle6;
isc_req_handle handles_get_files_req_handle1;
isc_req_handle handles_get_filter_req_handle1;
isc_req_handle handles_get_function_arg_req_handle1;
isc_req_handle handles_get_function_req_handle1;
isc_req_handle handles_get_global_field_req_handle1;
isc_req_handle handles_get_index_req_handle1;
isc_req_handle handles_get_index_req_handle2;
isc_req_handle handles_get_index_req_handle3;
isc_req_handle handles_get_index_req_handle4;
isc_req_handle handles_get_procedure_prm_req_handle1;
isc_req_handle handles_get_procedure_req_handle1;
isc_req_handle handles_get_ranges_req_handle1;
isc_req_handle handles_get_ref_constraint_req_handle1;
isc_req_handle handles_get_rel_constraint_req_handle1;
isc_req_handle handles_get_relation_req_handle1;
isc_req_handle handles_get_security_class_req_handle1;
isc_req_handle handles_get_sql_roles_req_handle1;
isc_req_handle handles_get_trigger_message_req_handle1;
isc_req_handle handles_get_trigger_message_req_handle2;
isc_req_handle handles_get_trigger_old_req_handle1;
isc_req_handle handles_get_trigger_req_handle1;
isc_req_handle handles_get_type_req_handle1;
isc_req_handle handles_get_user_privilege_req_handle1;
isc_req_handle handles_get_view_req_handle1;
isc_req_handle handles_put_index_req_handle1;
isc_req_handle handles_put_index_req_handle2;
isc_req_handle handles_put_index_req_handle3;
isc_req_handle handles_put_index_req_handle4;
isc_req_handle handles_put_index_req_handle5;
isc_req_handle handles_put_index_req_handle6;
isc_req_handle handles_put_index_req_handle7;
isc_req_handle handles_put_relation_req_handle1;
isc_req_handle handles_put_relation_req_handle2;
isc_req_handle handles_store_blr_gen_id_req_handle1;
isc_req_handle handles_write_function_args_req_handle1;
isc_req_handle handles_write_function_args_req_handle2;
isc_req_handle handles_write_procedure_prms_req_handle1;
USHORT hdr_forced_writes;
TEXT database_security_class[32]; /* To save database security class for deferred update */
} *TGBL;
#ifdef GET_THREAD_DATA
#undef GET_THREAD_DATA
#endif
#ifdef SUPERSERVER
#define GET_THREAD_DATA ((TGBL) THD_get_specific())
#define SET_THREAD_DATA THD_put_specific ((THDD) tdgbl); \
tdgbl->tgbl_thd_data.thdd_type = THDD_TYPE_TGBL
#define RESTORE_THREAD_DATA THD_restore_specific();
#else
extern struct tgbl *gdgbl;
#define GET_THREAD_DATA (gdgbl)
#ifdef __cplusplus
#define SET_THREAD_DATA gdgbl = const_cast<tgbl*>(tdgbl); \
tdgbl->tgbl_thd_data.thdd_type = THDD_TYPE_TGBL
#else /* __cplusplus */
#define SET_THREAD_DATA gdgbl = (struct tgbl *)tdgbl; \
tdgbl->tgbl_thd_data.thdd_type = (volatile)THDD_TYPE_TGBL
#endif /* __cplusplus */
#define RESTORE_THREAD_DATA
#endif
#if defined(__cplusplus)
#define EXIT(code) { tdgbl->exit_code = ((volatile int)code); \
if (tdgbl->burp_env != NULL) \
LONGJMP(reinterpret_cast<jmp_buf&>(const_cast<UCHAR*>(tdgbl->burp_env)), 1); }
#else
#define EXIT(code) { tdgbl->exit_code = ((volatile int)code); \
if (tdgbl->burp_env != NULL) \
LONGJMP(tdgbl->burp_env, 1); }
#endif /* __cplusplus */
#define FINI_DB_NOT_ONLINE 2 /* database is not on-line due to
failure to activate one or more
indices */
/* I/O definitions */
#ifndef IO_BUFFER_SIZE
#ifdef BUFSIZ
#define IO_BUFFER_SIZE BUFSIZ
#else
#define IO_BUFFER_SIZE 1024
#endif
#endif
#define GBAK_IO_BUFFER_SIZE (16 * (IO_BUFFER_SIZE))
/* Burp will always write a backup in multiples of the following number
* of bytes. The initial value is the smallest which ensures that writes
* to fixed-block SCSI tapes such as QIC-150 will work. The value should
* always be a multiple of 512 for that reason.
* If you change to a value which is NOT a power of 2, then change the
* BURP_UP_TO_BLOCK macro to use division and multiplication instead of
* bit masking.
*/
#define BURP_BLOCK 512
#define BURP_UP_TO_BLOCK(n) (((n) + BURP_BLOCK - 1) & ~(BURP_BLOCK - 1))
/* Move the read and write mode declarations in here from burp.c
so that other files can see them for multivolume opens */
#ifdef NETWARE_386
#define MODE_WRITE O_RDWR | O_CREAT | O_TRUNC
#endif
#ifdef PC_PLATFORM
#ifndef NETWARE_386
#define MODE_READ O_RDONLY | O_BINARY
#define MODE_WRITE O_WRONLY | O_BINARY | O_CREAT
#endif
#endif
#ifdef WIN_NT
#define MODE_READ GENERIC_READ
#define MODE_WRITE GENERIC_WRITE
#endif
#ifdef VMS
#define MODE_WRITE O_WRONLY | O_CREAT | O_TRUNC
#endif
#ifndef MODE_READ
#define MODE_READ O_RDONLY
#endif
#ifndef MODE_WRITE
#define MODE_WRITE O_WRONLY | O_CREAT
#endif
/* Burp Messages */
#define msgVerbose_write_charsets 211
#define msgVerbose_write_collations 212
#define msgErr_restore_charset 213
#define msgVerbose_restore_charset 214
#define msgErr_restore_collation 215
#define msgVerbose_restore_collation 216
#ifdef __cplusplus
} /* extern "C" */
#endif
#define GDS_VERSION "Firebird-W32-V1.0"
#endif /* _BURP_BURP_H_ */

45
src/burp/burp32.def Normal file
View File

@ -0,0 +1,45 @@
; The contents of this file are subject to the Interbase Public
; License Version 1.0 (the "License"); you may not use this file
; except in compliance with the License. You may obtain a copy
; of the License at http://www.Inprise.com/IPL.html
;
; Software distributed under the License is distributed on an
; "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
; or implied. See the License for the specific language governing
; rights and limitations under the License.
;
; The Original Code was created by Inprise Corporation
; and its predecessors. Portions created by Inprise Corporation are
; Copyright (C) Inprise Corporation.
;
; All Rights Reserved.
; Contributor(s): ______________________________________.
;------------------------------------------------------------
; GBAK DLL MODULE DEFINITION FILE
;------------------------------------------------------------
LIBRARY GBAK32.DLL
DESCRIPTION 'INTERBASE BACKUP/RESTORE DLL'
CODE MOVEABLE
DATA MOVEABLE
SEGMENTS
_TEXT DISCARDABLE
BURP_TEXT DISCARDABLE
CANONICA_TEXT DISCARDABLE
MISC_TEXT DISCARDABLE
MVOL_TEXT DISCARDABLE
BACKUP_TEXT DISCARDABLE
RESTORE_TEXT DISCARDABLE
BURPWEP_TEXT PRELOAD
XDR_TEXT DISCARDABLE
NTOH_TEXT DISCARDABLE
DLLSHELL_TEXT PRELOAD
EXPORTS
_BURP_gbak @2
; WEP @1 RESIDENTNAME
IMPORTS
_gds__start_transaction=gds32.gds__start_transaction

52
src/burp/burp_proto.h Normal file
View File

@ -0,0 +1,52 @@
/*
* PROGRAM: JRD Backup and Restore program
* MODULE: burp_proto.h
* DESCRIPTION: Prototype header file for burp.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _BURP_BURP_PROTO_H_
#define _BURP_BURP_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef int (DLL_EXPORT* OUTPUTPROC) (SLONG, UCHAR *);
extern int BURP_gbak (int, char **, OUTPUTPROC, SLONG);
extern void BURP_abort (void);
extern void BURP_svc_error (USHORT, USHORT, void *, USHORT, void *, USHORT, void *, USHORT, void *, USHORT, void *);
extern void BURP_error (USHORT, void*, void*, void*, void*, void*);
extern void BURP_print_status (STATUS *);
extern void BURP_error_redirect (STATUS *, USHORT, void*, void*);
extern void BURP_msg_partial (USHORT, void*, void*, void*, void*, void*);
extern void BURP_msg_put (USHORT, void*, void*, void*, void*, void*);
extern void BURP_msg_get (USHORT, void*, void*, void*, void*, void*, void*);
extern void BURP_output_version (TEXT *, TEXT *);
extern void BURP_print (USHORT, void*, void*, void*, void*, void*);
extern void BURP_print_warning (STATUS*);
extern void BURP_verbose (USHORT, void*, void*, void*, void*, void*);
#ifdef __cplusplus
}
#endif
#endif /* _BURP_BURP_PROTO_H_ */

185
src/burp/burpswi.h Normal file
View File

@ -0,0 +1,185 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: burpswi.h
* DESCRIPTION: Burp switches
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _BURP_BURPSWI_H_
#define _BURP_BURPSWI_H_
#include "../jrd/common.h"
#include "../jrd/ibase.h"
/* Local copies of global variables. They wil be copied into
a data structure. */
/* Local variables */
#define IN_SW_BURP_0 0 /* the unknowable switch */
#define IN_SW_BURP_B 1 /* backup */
#define IN_SW_BURP_C 2 /* create_database */
#define IN_SW_BURP_F 3 /* file names and starting page */
#define IN_SW_BURP_M 4 /* backup only metadata */
#define IN_SW_BURP_N 5 /* do not restore validity conditions */
#define IN_SW_BURP_P 6 /* specify output page size */
#define IN_SW_BURP_R 7 /* replace existing database */
#define IN_SW_BURP_U 9 /* don't back up security information */
#define IN_SW_BURP_V 10 /* verify actions */
#define IN_SW_BURP_Z 11 /* print version number */
#define IN_SW_BURP_D 12 /* backup file on tape - APOLLO only */
#define IN_SW_BURP_E 13 /* expand (no compress) */
#define IN_SW_BURP_Y 14 /* redirect/suppress status and error output */
#define IN_SW_BURP_L 15 /* ignore limbo transactions */
#define IN_SW_BURP_T 16 /* build a 'transportable' backup (V4 default) */
#define IN_SW_BURP_O 17 /* commit after each relation */
#define IN_SW_BURP_I 18 /* deactivate indexes */
#define IN_SW_BURP_K 19 /* kill any shadows defined on database*/
#define IN_SW_BURP_G 20 /* inhibit garbage collection */
#define IN_SW_BURP_IG 21 /* database is largely trash try anyway */
#define IN_SW_BURP_FA 22 /* blocking factor */
#define IN_SW_BURP_US 23 /* use all space on data page */
#define IN_SW_BURP_OL 24 /* write RDB$DESCRIPTIONS & SOURCE in old manner */
#define IN_SW_BURP_7 25 /* force creation of an ODS 7 database */
#define IN_SW_BURP_USER 26 /* default user name to use on attach */
#define IN_SW_BURP_PASS 27 /* default password to use on attach */
#define IN_SW_BURP_S 28 /* skip some number of bytes if find a bad attribute */
#define IN_SW_BURP_NT 29 /* build a "non-transportable" backup (V3 default) */
#define IN_SW_BURP_BUG8183 30 /* use workaround to allow restore database
v3.3 with comment field inside of index
definition */
#define IN_SW_BURP_ROLE 31 /* default SQL role to use on attach */
#define IN_SW_BURP_CO 32 /* convert external tables to internal tables during backup */
#define IN_SW_BURP_BU 33 /* specify page buffers for cache */
#define IN_SW_BURP_SE 34 /* use services manager */
#define IN_SW_BURP_MODE 35 /* database could be restored ReadOnly */
/**************************************************************************/
/* The next two 'virtual' switches are hidden from user and are needed */
/* for services API */
/**************************************************************************/
#define IN_SW_BURP_HIDDEN_RDONLY 36
#define IN_SW_BURP_HIDDEN_RDWRITE 37
/**************************************************************************/
/* used 0BCDEFGILMNOPRSTUVYZ available AHJQWX */
#define BURP_SW_MODE_RO "read_only"
#define BURP_SW_MODE_RW "read_write"
static struct in_sw_tab_t burp_in_sw_table [] =
{
IN_SW_BURP_B, 0, "BACKUP_DATABASE", 0, 0, 0, FALSE, 60, 0, NULL,
/* msg 60: %sBACKUP_DATABASE backup database to file */
IN_SW_BURP_BU, isc_spb_res_buffers, "BUFFERS", 0, 0, 0, FALSE, 257, 0, NULL,
/* msg 257: %sBU(FFERS) override default page buffers */
IN_SW_BURP_C, isc_spb_res_create, "CREATE_DATABASE", 0, 0, 0, FALSE, 73, 0, NULL,
/* msg 73: %sCREATE_DATABASE create database from backup file */
IN_SW_BURP_CO, isc_spb_bkp_convert, "CONVERT", 0, 0, 0, FALSE, 254, 0, NULL,
/* msg 254: %sCO(NVERT) backup external files as tables */
IN_SW_BURP_E, isc_spb_bkp_expand, "EXPAND", 0, 0, 0, FALSE, 97, 0, NULL,
/* msg 97: %sEXPAND no data compression */
IN_SW_BURP_F, 0, "FILE_NAMES", 0, 0, 0, FALSE, 0, 0, NULL,
IN_SW_BURP_FA, isc_spb_bkp_factor, "FACTOR", 0, 0, 0, FALSE, 181, 0, NULL,
/* msg 181; %sFACTOR blocking factor */
IN_SW_BURP_G, isc_spb_bkp_no_garbage_collect, "GARBAGE_COLLECT", 0, 0, 0, FALSE, 177, 0, NULL,
/* msg 177:%sGARBAGE_COLLECT inhibit garbage collection */
IN_SW_BURP_I, isc_spb_res_deactivate_idx, "INACTIVE", 0, 0, 0, FALSE, 78, 0, NULL,
/* msg 78:%sINACTIVE deactivate indexes during restore */
IN_SW_BURP_IG, isc_spb_bkp_ignore_checksums, "IGNORE", 0, 0, 0, FALSE, 178, 0, NULL,
/* msg 178:%sIGNORE ignore bad checksums */
IN_SW_BURP_K, isc_spb_res_no_shadow, "KILL", 0, 0, 0, FALSE, 172, 0, NULL,
/* msg 172:%sKILL restore without creating shadows */
IN_SW_BURP_L, isc_spb_bkp_ignore_limbo, "LIMBO", 0, 0, 0, FALSE, 98, 0, NULL,
/* msg 98 ignore transactions in limbo */
IN_SW_BURP_M, isc_spb_bkp_metadata_only, "METADATA", 0, 0, 0, FALSE, 0, 0, NULL,
IN_SW_BURP_M, 0, "META_DATA", 0, 0, 0, FALSE, 63, 0, NULL,
/* msg 63: %sMETA_DATA backup metadata only */
#ifdef READONLY_DATABASE
IN_SW_BURP_MODE, 0, "MODE", 0, 0, 0, FALSE, 278, 0, NULL,
/* msg 278: %sMODE read_only or read_write access */
#endif /* READONLY_DATABASE */
IN_SW_BURP_N, isc_spb_res_no_validity, "NO_VALIDITY", 0, 0, 0, FALSE, 187, 0, NULL,
/* msg 187: %sN(O_VALIDITY) do not restore database validity conditions */
IN_SW_BURP_NT, isc_spb_bkp_non_transportable, "NT", 0, 0, 0, FALSE, 239, 0, NULL,
/* msg 239: %sNT Non-Transportable backup file format */
IN_SW_BURP_O, isc_spb_res_one_at_a_time, "ONE_AT_A_TIME", 0, 0, 0, FALSE, 99, 0, NULL,
/* msg 99: %sONE_AT_A_TIME restore one relation at a time */
IN_SW_BURP_OL, isc_spb_bkp_old_descriptions, "OLD_DESCRIPTIONS", 0, 0, 0, FALSE, 186, 0, NULL,
/* msg 186: %sOLD_DESCRIPTIONS save old style metadata descriptions */
IN_SW_BURP_P, isc_spb_res_page_size, "PAGE_SIZE", 0, 0, 0, FALSE, 101, 0, NULL,
/* msg 101: %sPAGE_SIZE override default page size */
IN_SW_BURP_PASS, 0, "PASSWORD", 0, 0, 0, FALSE, 190, 0, NULL,
/* msg 190: %sPA(SSWORD) InterBase password */
IN_SW_BURP_R, isc_spb_res_replace, "REPLACE_DATABASE", 0, 0, 0, FALSE, 112, 0, NULL,
/* msg 112: %sREPLACE_DATABASE replace database from backup file */
/**************************************************************
** msg 252: %sRO(LE) InterBase SQL role
***************************************************************/
IN_SW_BURP_ROLE, isc_spb_sql_role_name, "ROLE", 0, 0, 0, FALSE, 252, 0, NULL,
IN_SW_BURP_S, 0, "SKIP_BAD_DATA", 0, 0, 0, FALSE, 0, 0, NULL,
IN_SW_BURP_SE, 0, "SERVICE", 0, 0, 0, FALSE, 277, 0, NULL,
/* msg 277: %sSE(RVICE) use services manager */
IN_SW_BURP_T, 0, "TRANSPORTABLE", 0, 0, 0, FALSE, 175, 0, NULL,
/* msg 175: %sTRANSPORTABLE transportable backup -- data in XDR format */
/*
IN_SW_BURP_U, 0, "UNPROTECTED", 0, 0, 0, FALSE, 0, 0, NULL,
*/
IN_SW_BURP_US, isc_spb_res_use_all_space, "USE_ALL_SPACE", 0, 0, 0, FALSE, 276, 0, NULL,
/* msg 276: %sUSE_(ALL_SPACE) do not reserve space for record versions */
IN_SW_BURP_USER, 0, "USER", 0, 0, 0, FALSE, 191, 0, NULL,
/* msg 191: %sUSER InterBase user name */
IN_SW_BURP_V, isc_spb_verbose, "VERBOSE", 0, 0, 0, FALSE, 0, 0, NULL,
IN_SW_BURP_V, 0, "VERIFY", 0, 0, 0, FALSE, 113, 0, NULL,
/* msg 113: %sVERIFY report each action taken */
IN_SW_BURP_Y, 0, "Y", 0, 0, 0, FALSE, 109, 0, NULL,
/* msg 109: %sY redirect/suppress output (file path or OUTPUT_SUPPRESS) */
IN_SW_BURP_Z, 0, "Z", 0, 0, 0, FALSE, 104, 0, NULL,
/* msg 104: %sZ print version number */
#ifdef DEV_BUILD
IN_SW_BURP_7, 0, "7", 0, 0, 0, FALSE, 0, 0, NULL,
#endif
/* next switch is a hidden option in case of bug_no 8183 */
IN_SW_BURP_BUG8183, 0, "BUG_8183", 0, 0, 0, FALSE, 0, 0, NULL,
#ifdef READONLY_DATABASE
/**************************************************************************/
/* The next two 'virtual' switches are hidden from user and are needed */
/* for services API */
/**************************************************************************/
IN_SW_BURP_HIDDEN_RDONLY, isc_spb_res_am_readonly, "mode read_only", 0, 0, 0, FALSE, 0, 0, NULL,
IN_SW_BURP_HIDDEN_RDWRITE, isc_spb_res_am_readwrite, "mode read_write", 0, 0, 0, FALSE, 0, 0, NULL,
/**************************************************************************/
#endif
IN_SW_BURP_0, 0, NULL, 0, 0, 0, FALSE, 0, 0, NULL
};
/* Definitions for GSPLIT */
#define IN_SW_SPIT_0 0 /* the unknowable switch */
#define IN_SW_SPIT_SP 30 /* splits back up files */
#define IN_SW_SPIT_JT 31 /* joins back up files */
static struct in_sw_tab_t spit_in_sw_table [] =
{
IN_SW_SPIT_SP, 0, "SPLIT_BK_FILE", 0, 0, 0, FALSE, 0, 0, NULL,
IN_SW_SPIT_JT, 0, "JOIN_BK_FILE", 0, 0, 0, FALSE, 0, 0, NULL,
IN_SW_SPIT_0, 0, NULL, 0, 0, 0, FALSE, 0, 0, NULL
};
#endif /* _BURP_BURP_H_ */

38
src/burp/canon_proto.h Normal file
View File

@ -0,0 +1,38 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: canon_proto.h
* DESCRIPTION: Prototype Header file for canonical.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _BURP_CANON_PROTO_H_
#define _BURP_CANON_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
extern ULONG CAN_encode_decode (struct rel *, struct lstring *, UCHAR *, int);
extern ULONG CAN_slice (struct lstring *, struct lstring *, int, USHORT, UCHAR *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _BURP_CANON_PROTO_H_ */

1005
src/burp/canonical.cpp Normal file

File diff suppressed because it is too large Load Diff

203
src/burp/depends.mak Normal file
View File

@ -0,0 +1,203 @@
# The contents of this file are subject to the Interbase Public
# License Version 1.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy
# of the License at http://www.Inprise.com/IPL.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
# or implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code was created by Inprise Corporation
# and its predecessors. Portions created by Inprise Corporation are
# Copyright (C) Inprise Corporation.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
# depends.mak - burp
# Created by 'make depends.mak'
# Created on 1998-11-17
backup.c.o: backu_proto.h
backup.c.o: backup.c.c
backup.c.o: burp.h
backup.c.o: burp_proto.h
backup.c.o: canon_proto.h
backup.c.o: misc_proto.h
backup.c.o: mvol_proto.h
backup.c.o: source/interbase/include/iberror.h
backup.c.o: source/jrd/align.h
backup.c.o: source/jrd/common.h
backup.c.o: source/jrd/dsc.h
backup.c.o: source/jrd/fil.h
backup.c.o: source/jrd/gds.h
backup.c.o: source/jrd/gds_proto.h
backup.c.o: source/jrd/isc.h
backup.c.o: source/jrd/isc_s_proto.h
backup.c.o: source/jrd/pwd.h
backup.c.o: source/jrd/svc.h
backup.c.o: source/jrd/svc_proto.h
backup.c.o: source/jrd/svc_undoc.h
backup.c.o: source/jrd/thd.h
backup.c.o: source/remote/protocol.h
backup.o: backu_proto.h
backup.o: backup.c
backup.o: burp.h
backup.o: burp_proto.h
backup.o: canon_proto.h
backup.o: misc_proto.h
backup.o: mvol_proto.h
backup.o: source/interbase/include/iberror.h
backup.o: source/jrd/align.h
backup.o: source/jrd/common.h
backup.o: source/jrd/dsc.h
backup.o: source/jrd/fil.h
backup.o: source/jrd/gds.h
backup.o: source/jrd/gds_proto.h
backup.o: source/jrd/gdsassert.h
backup.o: source/jrd/isc.h
backup.o: source/jrd/isc_s_proto.h
backup.o: source/jrd/ods.h
backup.o: source/jrd/pwd.h
backup.o: source/jrd/svc.h
backup.o: source/jrd/svc_proto.h
backup.o: source/jrd/svc_undoc.h
backup.o: source/jrd/thd.h
backup.o: source/remote/protocol.h
burp.o: backu_proto.h
burp.o: burp.c
burp.o: burp.h
burp.o: burp_proto.h
burp.o: burpswi.h
burp.o: misc_proto.h
burp.o: mvol_proto.h
burp.o: resto_proto.h
burp.o: source/interbase/include/iberror.h
burp.o: source/jrd/build_no.h
burp.o: source/jrd/common.h
burp.o: source/jrd/dsc.h
burp.o: source/jrd/fil.h
burp.o: source/jrd/gds.h
burp.o: source/jrd/gds_proto.h
burp.o: source/jrd/gdsassert.h
burp.o: source/jrd/ibase.h
burp.o: source/jrd/ibsetjmp.h
burp.o: source/jrd/isc.h
burp.o: source/jrd/isc_s_proto.h
burp.o: source/jrd/license.h
burp.o: source/jrd/msg_encode.h
burp.o: source/jrd/pwd.h
burp.o: source/jrd/svc.h
burp.o: source/jrd/svc_proto.h
burp.o: source/jrd/svc_undoc.h
burp.o: source/jrd/thd.h
burp.o: source/jrd/time.h
burp.o: source/jrd/why_proto.h
burpwep.o: burpwep.c
burpwep.o: source/jrd/common.h
canonical.o: burp.h
canonical.o: burp_proto.h
canonical.o: canon_proto.h
canonical.o: canonical.c
canonical.o: misc_proto.h
canonical.o: source/interbase/include/iberror.h
canonical.o: source/jrd/align.h
canonical.o: source/jrd/common.h
canonical.o: source/jrd/dsc.h
canonical.o: source/jrd/fil.h
canonical.o: source/jrd/gds.h
canonical.o: source/jrd/gds_proto.h
canonical.o: source/jrd/ibsetjmp.h
canonical.o: source/jrd/isc.h
canonical.o: source/jrd/isc_s_proto.h
canonical.o: source/jrd/pwd.h
canonical.o: source/jrd/sdl.h
canonical.o: source/jrd/sdl_proto.h
canonical.o: source/jrd/svc.h
canonical.o: source/jrd/svc_proto.h
canonical.o: source/jrd/svc_undoc.h
canonical.o: source/jrd/thd.h
canonical.o: source/remote/allr_proto.h
canonical.o: source/remote/blk.h
canonical.o: source/remote/protocol.h
canonical.o: source/remote/remote.h
canonical.o: source/remote/remote_def.h
canonical.o: source/remote/xdr.h
gsplit.o: gsplit.c
gsplit.o: gsplit.h
gsplit.o: source/jrd/common.h
misc.o: burp.h
misc.o: burp_proto.h
misc.o: misc.c
misc.o: misc_proto.h
misc.o: source/interbase/include/iberror.h
misc.o: source/jrd/common.h
misc.o: source/jrd/dsc.h
misc.o: source/jrd/fil.h
misc.o: source/jrd/gds.h
misc.o: source/jrd/gds_proto.h
misc.o: source/jrd/isc.h
misc.o: source/jrd/isc_s_proto.h
misc.o: source/jrd/pwd.h
misc.o: source/jrd/svc.h
misc.o: source/jrd/svc_proto.h
misc.o: source/jrd/svc_undoc.h
misc.o: source/jrd/thd.h
mvol.o: burp.h
mvol.o: burp_proto.h
mvol.o: misc_proto.h
mvol.o: mvol.c
mvol.o: mvol_proto.h
mvol.o: source/interbase/include/iberror.h
mvol.o: source/jrd/common.h
mvol.o: source/jrd/dsc.h
mvol.o: source/jrd/fil.h
mvol.o: source/jrd/gds.h
mvol.o: source/jrd/gds_proto.h
mvol.o: source/jrd/gdsassert.h
mvol.o: source/jrd/isc.h
mvol.o: source/jrd/isc_s_proto.h
mvol.o: source/jrd/pwd.h
mvol.o: source/jrd/svc.h
mvol.o: source/jrd/svc_proto.h
mvol.o: source/jrd/svc_undoc.h
mvol.o: source/jrd/thd.h
restore.o: burp.h
restore.o: burp_proto.h
restore.o: canon_proto.h
restore.o: misc_proto.h
restore.o: mvol_proto.h
restore.o: resto_proto.h
restore.o: restore.c
restore.o: source/interbase/include/iberror.h
restore.o: source/intl/charsets.h
restore.o: source/jrd/align.h
restore.o: source/jrd/build_no.h
restore.o: source/jrd/common.h
restore.o: source/jrd/dsc.h
restore.o: source/jrd/fil.h
restore.o: source/jrd/flags.h
restore.o: source/jrd/gds.h
restore.o: source/jrd/gds_proto.h
restore.o: source/jrd/gdsassert.h
restore.o: source/jrd/isc.h
restore.o: source/jrd/isc_s_proto.h
restore.o: source/jrd/license.h
restore.o: source/jrd/obj.h
restore.o: source/jrd/pwd.h
restore.o: source/jrd/svc.h
restore.o: source/jrd/svc_proto.h
restore.o: source/jrd/svc_undoc.h
restore.o: source/jrd/thd.h
restore.o: source/remote/protocol.h
spit.o: burpswi.h
spit.o: source/interbase/include/iberror.h
spit.o: source/jrd/blk.h
spit.o: source/jrd/common.h
spit.o: source/jrd/dsc.h
spit.o: source/jrd/gdsassert.h
spit.o: source/jrd/ibase.h
spit.o: source/jrd/isc.h
spit.o: source/jrd/jrd.h
spit.o: source/jrd/thd.h
spit.o: spit.c
spit.o: spit.h

173
src/burp/makefile.mak Normal file
View File

@ -0,0 +1,173 @@
# The contents of this file are subject to the Interbase Public
# License Version 1.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy
# of the License at http://www.Inprise.com/IPL.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
# or implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code was created by Inprise Corporation
# and its predecessors. Portions created by Inprise Corporation are
# Copyright (C) Inprise Corporation.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
# The contents of this file are subject to the Interbase Public
# License Version 1.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy
# of the License at http://www.Inprise.com/IPL.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
# or implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code was created by Inprise Corporation
# and its predecessors. Portions created by Inprise Corporation are
# Copyright (C) Inprise Corporation.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
#use $(Cx) to have command line options appear in DLL_CFLAGS
#NOTE: USE -DCx=-DWINBETA for BETA version string (see code in burp.c)
#--------------------------- PC BURP MAKEFILE ---------------------------
ROOT=..
.path.c=$(ROOT)\burp
# Path to devkit and clisdk
!if !$d(TPATH)
TPATH=..
!endif
# CRM - temporarily disabled until warnings are cleaned up!!!
LCFLAGS=-N-
# These are C flags if you want to enable useful warnings.
#LCFLAGS=$(LCFLAGS) -w -w-ucp -w-sus -w-par -w-stu -w-aus -w-pia
!include $(ROOT)\std.mk
#--------------------------- SOURCE COMPONENTS -----------------------------
WINSRCS = dllshell.c
S1 = burp.c canonical.c misc.c mvol.c backup.c restore.c
S2 = burpwep.c
SRCS = $(S1) $(S2)
# sources from the remote component used to build gbak.dll
REMSRCS = xdr.c ntoh.c
# NOTE: Object list - c0dx must be the first obj in the list!
!if $d(WIN32)
OBJS=$(TOOLPATH)\lib\c0d32.obj $(SRCS:.c=.obj) \
$(REMSRCS:.c=.obj) $(WINSRCS:.c=.obj)
!else
OBJS=$(TOOLPATH)\lib\c0d$(MODEL).obj $(SRCS:.c=.obj) \
$(REMSRCS:.c=.obj) $(WINSRCS:.c=.obj)
!endif
# import libraries
# NOTE: Client libs should now be taken from generic directories - Jeevan
#BURPLIBS = $(ROOT)\jrd\$(.path.obj)\gds.lib $(ROOT)\jrd\$(.path.obj)\iutls.lib
!if $d(WIN32)
BURPLIBS = $(SHRLIB_PATH)\gds32.lib
LIBS = import32 cw32
!else
BURPLIBS = $(INSTALLLIB)\gds.lib $(INSTALLLIB)\iutls.lib
LIBS = mathw$(MODEL) import cw$(MODEL)
!endif
# Extra files which are used to build the product
XFILES = burp.def makefile.mak backup.e restore.e
#---------------------------- TARGET LIST --------------------------------
!if $d(WIN32)
ALLBIN = gbak32.dll
ALLLIBS = gbak32.lib
!else
ALLBIN = gbak.dll
ALLLIBS = gbak.lib
!endif
gbk_dll: makefile.tmp $(ALLBIN) $(ALLLIB)
all: makefile.tmp extern_libs $(ALLLIBS) $(ALLBIN)
allbin: makefile.tmp extern_libs $(ALLBIN)
alllibs: makefile.tmp $(ALLLIBS)
#------------------------------ RULES -------------------------------------
!if $d(WIN32)
gbak32.dll: $(OBJS) $(BURPLIBS) $(ROOT)\jrd\version_95.rc burp.rsp burp32.def
$(TLINK) $(LFLAGS) @$(.path.obj)\burp.rsp, @&&|
$<
$*.map
$(LIBS) $(BURPLIBS)
burp32.def
|
$(RC) -i $(TOOLPATH)\include $(ROOT)\jrd\version_95.rc $<
!else
gbak.dll: $(OBJS) $(BURPLIBS) $(ROOT)\jrd\version.rc burp.rsp burp.def
$(TLINK) $(LFLAGS) @$(.path.obj)\burp.rsp, @&&|
$<
$*.map
$(LIBS) $(BURPLIBS)
burp.def
|
$(RC) -i $(TOOLPATH)\include $(ROOT)\jrd\version.rc $<
!endif
#----------- Response files -----------
burp.rsp: $(OBJS)
copy &&|
$**
| $<
#----------- Import Libraries -----------
!if $d(WIN32)
gbak32.lib: burp32.def
$(IMPLIB) $< $**
!else
gbak.lib: burp.def
$(IMPLIB) -o $< $**
!endif
# Because of the circular "architecture" here, we need to build
# required libraries within each of the makefiles.
extern_libs:
cd $(ROOT)\jrd
make $(MAKEFLAGS) alllibs
cd $(ROOT)\burp
# ---- Rules for source files which require special handling ----
xdr.obj: $(ROOT)\remote\xdr.c
$(CC) -c -DBURP @&&<
$(CFLAGS)
< $**
ntoh.obj: $(ROOT)\remote\ntoh.c
$(CC) -c @&&<
$(CFLAGS)
< $**
dllshell.obj: $(ROOT)\jrd\dllshell.c
$(CC) -c @&&<
$(CFLAGS)
< $**
#---------------------------- UTILITIES ---------------------------------
# Copy targets to a known installation directory
install: extern_libs $(ALLBIN) $(ALLLIBS)
for %i in ($(ALLBIN)) do copy $(.path.dll)\%i $(INSTALLBIN)
for %i in ($(ALLLIBS)) do copy $(.path.dll)\%i $(INSTALLLIB)
# Refresh all the source & header files from the DEVSRC directory
srcs::
copy $(DEVSRC)\burp\*.h
for %i in ($(S1)) do copy $(DEVSRC)\burp\%i
for %i in ($(S2)) do copy $(DEVSRC)\burp\%i
for %i in ($(XFILES)) do copy $(DEVSRC)\burp\%i

154
src/burp/misc.cpp Normal file
View File

@ -0,0 +1,154 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: misc.c
* DESCRIPTION: Miscellaneous useful routines
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include "../jrd/ib_stdio.h"
#include <string.h>
#ifdef UNIXWARE
#include <sys/fcntl.h>
#endif
#include "../burp/burp.h"
#include "../burp/burp_proto.h"
#include "../burp/misc_proto.h"
#ifdef SUPERSERVER
#include "../jrd/thd_proto.h"
#endif
extern "C" {
UCHAR *MISC_alloc_burp(ULONG size)
{
/**************************************
*
* M I S C _ a l l o c _ b u r p
*
**************************************
*
* Functional description
* Allocate block of memory. Note that it always zeros out memory.
* This could be optimized.
*
**************************************/
UCHAR *block;
TGBL tdgbl;
tdgbl = GET_THREAD_DATA;
/* Add some header space to store a list of blocks allocated for this gbak */
size += ROUNDUP(sizeof(UCHAR *), ALIGNMENT);
if (!(block = gds__alloc(size)))
/* NOMEM: message & abort FREE: all items freed at gbak exit */
{
BURP_error(238, NULL, NULL, NULL, NULL, NULL); /* msg 238: System memory exhaused */
return NULL;
}
memset(block, 0, size);
/* FREE: We keep a linked list of all gbak memory allocations, which
* are then freed when gbak exits. This is important for
* NETWARE in particular.
*/
*((UCHAR **) block) = tdgbl->head_of_mem_list;
tdgbl->head_of_mem_list = block;
return (block + ROUNDUP(sizeof(UCHAR *), ALIGNMENT));
}
void MISC_free_burp( void *free)
{
/**************************************
*
* M I S C _ f r e e _ b u r p
*
**************************************
*
* Functional description
* Release an unwanted block.
*
**************************************/
UCHAR **block;
TGBL tdgbl;
UCHAR **ptr;
tdgbl = GET_THREAD_DATA;
if (free != NULL) {
/* Point at the head of the allocated block */
block =
(UCHAR **) ((UCHAR *) free - ROUNDUP(sizeof(UCHAR *), ALIGNMENT));
/* Scan for this block in the list of blocks */
for (ptr = &tdgbl->head_of_mem_list; *ptr; ptr = (UCHAR **) * ptr) {
if (*ptr == (UCHAR *) block) {
/* Found it - remove it from the list */
*ptr = *block;
/* and free it */
gds__free((SLONG *) block);
return;
}
}
/* We should always find the block in the list */
BURP_error(238, NULL, NULL, NULL, NULL, NULL); /* msg 238: System memory exhausted */
/* (too lazy to add a better message) */
}
}
void MISC_terminate(UCHAR* from, UCHAR* to, ULONG length, ULONG max_length)
{
/**************************************
*
* M I S C _ t e r m i n a t e
*
**************************************
*
* Functional description
* Null-terminate a possibly non-
* null-terminated string with max
* buffer room.
*
**************************************/
if (length) {
length = MIN(length, max_length - 1);
do
*to++ = *from++;
while (--length);
*to++ = '\0';
}
else {
while (max_length-- && (*to++ = *from++));
*--to = '\0';
}
}
} // extern "C"

39
src/burp/misc_proto.h Normal file
View File

@ -0,0 +1,39 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: misc_proto.h
* DESCRIPTION: Prototype Header file for misc.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _BURP_MISC_PROTO_H_
#define _BURP_MISC_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
extern UCHAR *MISC_alloc_burp (ULONG);
extern void MISC_free_burp (void *);
extern void MISC_terminate (UCHAR *, UCHAR *, ULONG, ULONG);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _BURP_MISC_PROTO_H_ */

1453
src/burp/mvol.cpp Normal file

File diff suppressed because it is too large Load Diff

54
src/burp/mvol_proto.h Normal file
View File

@ -0,0 +1,54 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: mvol_proto.h
* DESCRIPTION: Prototype Header file for mvol.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _BURP_MVOL_PROTO_H_
#define _BURP_MVOL_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
extern void MVOL_fini_read (int *);
extern void MVOL_fini_write (int *, UCHAR * *, int *);
extern void MVOL_init (ULONG);
extern void MVOL_init_read (UCHAR *, UCHAR *, USHORT *, int *, UCHAR * *);
extern void MVOL_init_write (UCHAR *, UCHAR *, int *, UCHAR * *);
extern BOOLEAN MVOL_split_hdr_write (void);
extern BOOLEAN MVOL_split_hdr_read (void);
extern int MVOL_read (int *, UCHAR * *);
extern UCHAR * MVOL_read_block (TGBL, UCHAR *, ULONG);
extern void MVOL_skip_block (TGBL, ULONG);
extern UCHAR MVOL_write (UCHAR, int *, UCHAR * *);
extern UCHAR * MVOL_write_block (TGBL, UCHAR *, ULONG);
#if defined WIN_NT && defined _WINNT_
/* the _WINNT_ symbol is defined if winnt.h has been included */
/* it contains the definition of a HANDLE */
/* those files that don't include winnt.h don't need MVOL_open either */
extern HANDLE MVOL_open (TEXT*,DWORD,DWORD);
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _BURP_MVOL_PROTO_H_ */

37
src/burp/resto_proto.h Normal file
View File

@ -0,0 +1,37 @@
/*
* PROGRAM: JRD Backup and Restore Program
* MODULE: resto_proto.h
* DESCRIPTION: Prototype Header file for restore.e
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _BURP_RESTO_PROTO_H_
#define _BURP_RESTO_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
extern int RESTORE_restore (TEXT *, TEXT *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _BURP_RESTO_PROTO_H_ */

7164
src/burp/restore.e Normal file

File diff suppressed because it is too large Load Diff

1431
src/burp/spit.cpp Normal file

File diff suppressed because it is too large Load Diff

50
src/burp/spit.h Normal file
View File

@ -0,0 +1,50 @@
/*
**************************************************************************
*
* PROGRAM: JRD file split utility program
* MODULE: spit.h
* DESCRIPTION: file split utility program main header file
*
*
**************************************************************************
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include "../jrd/common.h"
#define BLANK ' '
#define BURP_ALLOC_ZERO(size) MISC_alloc_burp((ULONG) size)
#define FILE_IS_FULL -9
#define FILE_NM_ARR_LEN 20
#define GBAK_STDIN_DESC (int)0 /* standart input file descriptor */
#define GBAK_STDOUT_DESC (int)1 /* standart output file descriptor */
#define GSPLIT_HDR_REC_NM "InterBase/Gsplit"
#define IO_BUFFER_SIZE (16 * K_BYTES)
#define K_BYTES 1024
#define M_BYTES (K_BYTES * K_BYTES)
#define G_BYTES (K_BYTES * M_BYTES)
#define MAX_FILE_NM_LEN 27 /* size of header_rec.fl_name */
#define MAX_NUM_OF_FILES 9999
#define MIN_FILE_SIZE M_BYTES
#define NEW_LINE '\n'
#define NULL_B_FIL ((B_FIL) NULL)
#define TERMINAL '\0'
typedef int FILE_DESC;

3774
src/csv/csi.cpp Normal file

File diff suppressed because it is too large Load Diff

590
src/csv/csi.h Normal file
View File

@ -0,0 +1,590 @@
/*
* PROGRAM: JRD Access Method
* MODULE: csi.h
* DESCRIPTION: Central Server Interface definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _CSV_CSI_H_
#define _CSV_CSI_H_
#include "../jrd/common.h"
#include "../jrd/thd.h"
#include "../jrd/isc.h"
#ifdef VMS
#define CSI_FILE "[000000]isc_csv_gbl.%s"
#if !(defined MULTI_THREAD) || defined (__ALPHA)
#ifndef PIPE_SERVER
#define CSV_SIGNAL 33
#define EVENT_SIGNAL 3
#else
#define CSV_SIGNAL 34
#define EVENT_SIGNAL 4
#endif
#endif
#endif
#ifdef UNIX
#include <signal.h>
#define EVENT_SIGNAL SIGUSR2
#define CSI_FILE "/usr/interbase/isc_csv.%s"
#endif
#ifdef WIN_NT
#define CSI_FILE "/interbas/%s.csv"
#endif
#ifdef PC_PLATFORM
#define CSI_DEFAULT_SIZE 65535
#endif
#ifdef GATEWAY
#ifdef PIPE_SERVER
#define CSI_DEFAULT_SIZE 69632
#endif
#endif
#ifndef CSI_DEFAULT_SIZE
#define CSI_DEFAULT_SIZE 262144
#endif
#define CSI_EXTEND_SIZE 32768
#ifndef MAX_ARRAY_MESSAGE
#define MAX_ARRAY_MESSAGE 64000
#endif
#ifndef BLOB_LENGTH
#define BLOB_LENGTH 4096
#endif
#define PTR SLONG
#define BASE ((UCHAR*) CSS_header)
#define REL_PTR(item) ((UCHAR*) item - BASE)
#define ABS_PTR(item) (BASE + item)
#define ACQUIRE CSS_acquire()
#define RELEASE CSS_release()
#define QUE_INIT(que) {que.srq_forward = que.srq_backward = REL_PTR (&que);}
#define QUE_EMPTY(que) (que.srq_forward == REL_PTR (&que))
#define QUE_NEXT(que) ABS_PTR (que.srq_forward)
#define QUE_LOOP(header,que) for (que = (SRQ*) QUE_NEXT (header);\
que != &header; que = (SRQ*) QUE_NEXT ((*que)))
#define SIZE_SHIFT 2
#define FAST_ALLOC 16
/* Self-relative que block. Offsets are from the block itself. */
typedef struct srq {
PTR srq_forward; /* Forward offset */
PTR srq_backward; /* Backward offset */
} SRQ;
/* Global section header */
#define CSI_VERSION 3
#define CSI_PROTOCOL_VERSION 1
typedef struct csh {
SLONG csh_length; /* Current length of global section */
UCHAR csh_version; /* Version number of global section */
SRQ csh_processes; /* Known processes */
PTR csh_free; /* Free blocks */
PTR csh_current_process; /* Process "acquiring" section */
SLONG csh_mutex[2]; /* Mutex controlling access */
SLONG csh_semid; /* Semaphore id for UNIX */
SLONG csh_process_number; /* Assigned sequentially */
UCHAR csh_semaphores[16]; /* Free semaphores */
PTR csh_free_vector[FAST_ALLOC];
} *CSH;
/* Common block header */
typedef struct hdr {
SLONG hdr_length; /* Length of block */
UCHAR hdr_type; /* Type of block */
} HDR;
#define type_hdr 1
#define type_frb 2
#define type_prb 3
#define type_cnct 4
#define type_msg 5
/* Free blocks */
typedef struct frb {
HDR frb_header;
SLONG frb_next; /* Next block */
} *FRB;
/* Process blocks */
typedef struct prb {
HDR prb_header;
USHORT prb_flags; /* Misc */
USHORT prb_protocol_version; /* Protocol version */
ULONG prb_group_id; /* Group id for VMS */
USHORT prb_semaphore; /* Semaphore used for event on UNIX */
SRQ prb_processes; /* Process que ownerd by header */
SRQ prb_connections; /* Connections to server process */
SRQ prb_messages; /* Messages to be processed */
SLONG prb_process_id; /* Process id */
SLONG prb_process_number; /* Relative process number */
EVENT_T prb_event[1]; /* Event on which to wait */
} *PRB;
#define PRB_client 0 /* Process is client */
#define PRB_server 1 /* Process is server (otherwise client) */
#define PRB_disconnect 2 /* Some connection was broken */
#define PRB_client_t1 4 /* Process is client type 1 */
#define PRB_server_t1 8 /* Process is server type 1 */
#define PRB_timeout 32 /* Process has waited too long for a message */
#define PRB_wait 64 /* Process is awaiting acquisition */
#define PRB_signal_me 128 /* Process is waiting for a signal */
/* Connection block */
typedef struct cnct {
HDR cnct_header;
PTR cnct_parent; /* Client process block */
PTR cnct_partner; /* Server process lock */
PTR cnct_mirror; /* Mirror of connection */
SRQ cnct_connections; /* Que of parents connections */
} *CNCT;
/* Message block */
typedef enum {
MSG_attach_database,
MSG_blob_info,
MSG_cancel_blob,
MSG_close_blob,
MSG_commit,
MSG_commit_retaining,
MSG_compile,
MSG_create_blob,
MSG_create_database,
MSG_database_info,
MSG_detach,
MSG_get_segment,
MSG_open_blob,
MSG_prepare,
MSG_put_segment,
MSG_reconnect,
MSG_receive,
MSG_release,
MSG_request_info,
MSG_rollback,
MSG_send,
MSG_start_and_send,
MSG_start_request,
MSG_start_transaction,
MSG_transaction_info,
MSG_unwind,
MSG_disconnect,
MSG_response,
MSG_que_events,
MSG_cancel_events,
MSG_event,
MSG_alt_connection,
MSG_util_cmd,
MSG_query_connect,
MSG_mdi_attach_db,
MSG_ping,
MSG_get_slice,
MSG_put_slice,
MSG_ddl,
MSG_seek_blob,
MSG_get_segment_buf,
MSG_put_segment_buf,
MSG_allocate_stmt,
MSG_execute,
MSG_execute_immediate,
MSG_fetch,
MSG_free_stmt,
MSG_prepare_stmt,
MSG_set_cursor,
MSG_sql_info,
MSG_insert,
MSG_execute2,
MSG_execute_immediate2,
MSG_transact_request,
MSG_drop_database
} MSG_T;
typedef struct msg {
HDR msg_header;
SRQ msg_que;
MSG_T msg_type; /* Specific message type */
PTR msg_connection; /* Process sending message */
} *MSG;
/* Miscellaneous message formats */
typedef struct msg_att {
struct msg msg_att_header; /* Common message header */
USHORT msg_att_file_length; /* Length of file name */
USHORT msg_att_dpb_length; /* Length of database parameter block */
USHORT msg_att_expanded_length; /* Length of expanded file name */
USHORT msg_att_type; /* Create type */
UCHAR msg_att_data[1]; /* File name and dpb */
} *MSG_ATT;
typedef struct msg_info {
struct msg msg_info_header;
SLONG msg_info_handle;
USHORT msg_info_level;
USHORT msg_info_length; /* Item length */
USHORT msg_info_buffer_length; /* Length of return buffer */
UCHAR msg_info_data[1];
} *MSG_INFO;
typedef struct msg_op {
struct msg msg_op_header;
SLONG msg_op_handle;
SLONG msg_op_level;
USHORT msg_op_length;
USHORT msg_op_data[1];
} *MSG_OP;
typedef struct msg_blob {
struct msg msg_blob_header;
SLONG msg_blob_database;
SLONG msg_blob_transaction;
USHORT msg_blob_bpb_length;
SLONG msg_blob_id[2];
UCHAR msg_blob_bpb[1];
} *MSG_BLOB;
typedef struct msg_seg {
struct msg msg_seg_header;
SLONG msg_seg_handle;
USHORT msg_seg_length;
USHORT msg_seg_buffer_length;
UCHAR msg_seg_data[1];
} *MSG_SEG;
typedef struct msg_msg {
struct msg msg_msg_header;
SLONG msg_msg_request;
SLONG msg_msg_transaction;
USHORT msg_msg_level;
USHORT msg_msg_type;
USHORT msg_msg_length;
UCHAR msg_msg_data[1];
} *MSG_MSG;
typedef struct tdb {
SLONG tdb_database;
USHORT tdb_tpb_length;
PTR tdb_tpb;
} TDB;
typedef struct msg_trans {
struct msg msg_trans_header;
USHORT msg_trans_count;
TDB msg_trans_tdb[1];
} *MSG_TRANS;
typedef struct msg_resp {
struct msg msg_resp_header;
SLONG msg_resp_handle;
STATUS msg_resp_status[20];
USHORT msg_resp_length;
UCHAR msg_resp_data[1];
} *MSG_RESP;
typedef struct msg_event {
struct msg msg_event_header;
SLONG msg_event_database;
void (*msg_event_ast) ();
void *msg_event_arg;
USHORT msg_event_length;
UCHAR msg_event_data[1];
} *MSG_EVENT;
typedef struct msg_slice {
struct msg msg_slice_header;
SLONG msg_slice_database;
SLONG msg_slice_transaction;
USHORT msg_slice_sdl_length;
USHORT msg_slice_param_length;
SLONG msg_slice_slice_length;
SLONG msg_slice_id[2];
SLONG msg_slice_handle;
UCHAR msg_slice_data[1]; /* sdl, param, and slice */
} *MSG_SLICE;
typedef struct msg_ddl {
struct msg msg_ddl_header;
SLONG msg_ddl_database;
SLONG msg_ddl_transaction;
USHORT msg_ddl_length;
USHORT msg_ddl_data[1];
} *MSG_DDL;
typedef struct msg_util {
struct msg msg_util_header;
USHORT msg_util_cmd;
USHORT msg_util_csn_len;
USHORT msg_util_dbn_len;
TEXT msg_util_data[2];
} *MSG_UTIL;
typedef struct msg_seek {
struct msg msg_seek_header;
SLONG msg_seek_handle;
SSHORT msg_seek_mode;
SLONG msg_seek_offset;
} *MSG_SEEK;
typedef struct msg_exnow {
struct msg msg_exnow_header;
SLONG msg_exnow_database;
SLONG msg_exnow_transaction;
USHORT msg_exnow_SQL_length;
USHORT msg_exnow_SQL_dialect;
USHORT msg_exnow_in_blr_length;
USHORT msg_exnow_in_msg_type;
USHORT msg_exnow_in_msg_length;
USHORT msg_exnow_out_blr_length;
USHORT msg_exnow_out_msg_type;
USHORT msg_exnow_out_msg_length;
UCHAR msg_exnow_data[1];
} *MSG_EXNOW;
typedef struct msg_pstmt {
struct msg msg_pstmt_header;
SLONG msg_pstmt_transaction;
SLONG msg_pstmt_statement;
USHORT msg_pstmt_SQL_length;
USHORT msg_pstmt_SQL_dialect;
USHORT msg_pstmt_item_length;
USHORT msg_pstmt_buffer_length;
UCHAR msg_pstmt_data[1];
} *MSG_PSTMT;
typedef struct msg_setcur {
struct msg msg_setcur_header;
SLONG msg_setcur_statement;
USHORT msg_setcur_type;
TEXT msg_setcur_cursor[1];
} *MSG_SETCUR;
typedef struct msg_sqlmsg {
struct msg msg_sqlmsg_header;
SLONG msg_sqlmsg_transaction;
SLONG msg_sqlmsg_statement;
USHORT msg_sqlmsg_in_blr_length;
USHORT msg_sqlmsg_in_msg_type;
USHORT msg_sqlmsg_in_msg_length;
USHORT msg_sqlmsg_out_blr_length;
USHORT msg_sqlmsg_out_msg_type;
USHORT msg_sqlmsg_out_msg_length;
UCHAR msg_sqlmsg_data[1];
} *MSG_SQLMSG;
typedef struct msg_trrq {
struct msg msg_trrq_header;
SLONG msg_trrq_database;
SLONG msg_trrq_transaction;
USHORT msg_trrq_blr_length;
USHORT msg_trrq_in_msg_length;
USHORT msg_trrq_out_msg_length;
UCHAR msg_trrq_data[1];
} *MSG_TRRQ;
#define UTIL_noop 0
#define UTIL_list 1
#define UTIL_disable 2
#define UTIL_kill 3
#define UTIL_reenable 4
#define UTIL_enable 5
/* Local blocks */
typedef struct bid {
ULONG bid_relation_id; /* Relation id (or null) */
ULONG bid_number; /* Record number */
} *BID;
typedef SLONG HANDLE;
/* Block types */
#ifndef INCLUDE_FB_BLK
#include "../include/fb_blk.h"
#endif
#define type_rdb 10
#define type_rbl 11
#define type_rrq 12
#define type_rtr 13
#define type_evnt 14
#define type_dbn 15
#define type_csn 16
#define type_array 17
#define type_rsr 18
/* Block types */
typedef struct rdb {
struct blk rdb_header;
PTR rdb_connection; /* Connection to partner */
PTR rdb_connection2; /* Connection to partner for async events */
PTR rdb_server; /* Server process */
HANDLE rdb_handle; /* database handle */
struct rtr *rdb_transactions; /* linked list of transactions */
struct rrq *rdb_requests; /* compiled requests */
struct rsr *rdb_sql_requests; /* SQL requests */
struct rdb *rdb_next; /* next database in system */
struct evnt *rdb_events; /* list of allocated event blocks */
struct dbn *rdb_dbn; /* database name */
int *rdb_status_vector;
SCHAR *rdb_setjmp;
} *RDB;
typedef struct rtr {
struct blk rtr_header;
struct rdb *rtr_rdb;
struct rtr *rtr_next;
struct rbl *rtr_blobs;
struct array *rtr_arrays;
HANDLE rtr_handle;
USHORT rtr_flags;
} *RTR;
#define RTR_limbo 1
typedef struct rbl {
struct blk rbl_header;
struct rdb *rbl_rdb;
struct rtr *rbl_rtr;
struct rbl *rbl_next;
HANDLE rbl_handle;
USHORT rbl_flags;
UCHAR *rbl_ptr;
USHORT rbl_length;
USHORT rbl_fragment_length;
USHORT rbl_buffer_length;
UCHAR rbl_buffer[1];
} *RBL;
#define RBL_eof 1
#define RBL_segment 2
#define RBL_eof_pending 4
#define RBL_create 8
typedef struct rrq {
struct blk rrq_header;
struct rdb *rrq_rdb;
struct rrq *rrq_next;
struct rrq **rrq_user_handle;
HANDLE rrq_handle;
} *RRQ;
typedef struct evnt {
struct blk evnt_header;
struct evnt *evnt_next;
struct rdb *evnt_rdb;
SLONG evnt_id;
void (*evnt_ast) ();
void *evnt_arg;
} *EVNT;
typedef struct array {
struct blk array_header;
struct rdb *array_rdb;
struct rtr *array_rtr;
struct array *array_next;
SLONG array_length;
UCHAR *array_slice;
UCHAR array_data[1];
} *ARRAY;
typedef struct rsr {
struct blk rsr_header;
struct rdb *rsr_rdb;
struct rsr *rsr_next;
HANDLE rsr_handle;
} *RSR;
typedef struct dbn {
struct blk dbn_header;
USHORT dbn_attaches; /* number of attachments */
USHORT dbn_max_attaches; /* maximum number of allowable attachments */
USHORT dbn_flags;
struct rdb *dbn_server; /* central server attachment */
struct dbn *dbn_next;
USHORT dbn_length; /* length of name string */
TEXT dbn_name[1]; /* name string */
} *DBN;
#define DBN_disable 1 /* disable new attachments */
#define DBN_kill 2 /* kill all attachments */
#define DBN_server_att 4 /* server has its own attachment to database */
#define DBN_cmd_process 8 /* used by central server utility */
#define DBN_reenable 16 /* re-enable new attachments */
#define DBN_enable 32 /* enable a new database */
typedef struct csn {
struct blk csn_header;
USHORT csn_flags;
struct csn *csn_next;
USHORT csn_cs_len; /* length of server name string */
USHORT csn_db_len; /* length of database name string */
TEXT *csn_cs_name; /* server name string */
TEXT *csn_db_name; /* database name string */
TEXT csn_data[2];
} *CSN;
/* Central server utility list command data */
typedef struct csu_list {
USHORT csu_list_attaches;
USHORT csu_list_flags;
USHORT csu_list_length;
TEXT csu_list_name[1];
} *CSU_LIST;
#ifdef PIPE_SERVER
#define CSS_acquire PSS_acquire
#define CSS_alloc_message PSS_alloc_message
#define CSS_alloc_local PSS_alloc_local
#define CSS_check_partner PSS_check_partner
#define CSS_connect PSS_connect
#define CSS_create_process PSS_create_process
#define CSS_disconnect PSS_disconnect
#define CSS_free_global PSS_free_global
#define CSS_free_local PSS_free_local
#define CSS_find_process PSS_find_process
#define CSS_get_message PSS_get_message
#define CSS_init PSS_init
#define CSS_probe_processes PSS_probe_processes
#define CSS_put_message PSS_put_message
#define CSS_release PSS_release
#define CSS_validate PSS_validate
#endif
#endif /* _CSV_CSI_H_ */

108
src/csv/csi_proto.h Normal file
View File

@ -0,0 +1,108 @@
/*
* PROGRAM: Central Server
* MODULE: csi_proto.h
* DESCRIPTION: Prototype Header file for csi.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _CSV_CSI_PROTO_H_
#define _CSV_CSI_PROTO_H_
extern STATUS CSI_attach_database(STATUS *, SSHORT, SCHAR *, struct rdb **,
SSHORT, SCHAR *, TEXT *);
extern STATUS CSI_blob_info(STATUS *, struct rbl **, SSHORT, UCHAR *, SSHORT,
UCHAR *);
extern STATUS CSI_cancel_blob(STATUS *, struct rbl **);
extern STATUS CSI_cancel_events(STATUS *, struct rdb **, SLONG *);
extern STATUS CSI_close_blob(STATUS *, struct rbl **);
extern STATUS CSI_commit_transaction(STATUS *, struct rtr **);
extern STATUS CSI_commit_retaining(STATUS *, struct rtr **);
extern STATUS CSI_compile_request(STATUS *, struct rdb **, struct rrq **,
USHORT, UCHAR *);
extern STATUS CSI_create_blob2(STATUS *, struct rdb **, struct rtr **,
struct rbl **, BID, USHORT, UCHAR *);
extern STATUS CSI_create_database(STATUS *, SSHORT, SCHAR *, struct rdb **,
SSHORT, SCHAR *, SSHORT, TEXT *);
extern STATUS CSI_database_info(STATUS *, struct rdb **, SSHORT, UCHAR *,
SSHORT, UCHAR *);
extern STATUS CSI_ddl(STATUS *, struct rdb **, struct rtr **, USHORT,
UCHAR *);
extern STATUS CSI_detach_database(STATUS *, struct rdb **);
extern STATUS CSI_drop_database(STATUS *, struct rdb **);
extern STATUS CSI_allocate_statement(STATUS *, struct rdb **, struct rsr **);
extern STATUS CSI_execute(STATUS *, struct rtr **, struct rsr **, USHORT,
UCHAR *, USHORT, USHORT, UCHAR *);
extern STATUS CSI_execute2(STATUS *, struct rtr **, struct rsr **, USHORT,
UCHAR *, USHORT, USHORT, UCHAR *, USHORT, UCHAR *,
USHORT, USHORT, UCHAR *);
extern STATUS CSI_execute_immediate(STATUS *, struct rdb **, struct rtr **,
USHORT, TEXT *, USHORT, USHORT, UCHAR *,
USHORT, USHORT, UCHAR *);
extern STATUS CSI_execute_immediate2(STATUS *, struct rdb **, struct rtr **,
USHORT, TEXT *, USHORT, USHORT, UCHAR *,
USHORT, USHORT, UCHAR *, USHORT, UCHAR *,
USHORT, USHORT, UCHAR *);
extern STATUS CSI_fetch(STATUS *, struct rsr **, USHORT, UCHAR *, USHORT,
USHORT, UCHAR *);
extern STATUS CSI_free_statement(STATUS *, struct rsr **, USHORT);
extern STATUS CSI_insert(STATUS *, struct rsr **, USHORT, UCHAR *, USHORT,
USHORT, UCHAR *);
extern STATUS CSI_prepare(STATUS *, struct rtr **, struct rsr **, USHORT,
TEXT *, USHORT, USHORT, SCHAR *, USHORT, SCHAR *);
extern STATUS CSI_set_cursor_name(STATUS *, struct rsr **, TEXT *, USHORT);
extern STATUS CSI_sql_info(STATUS *, struct rsr **, SSHORT, SCHAR *, SSHORT,
SCHAR *);
extern STATUS CSI_get_segment(STATUS *, struct rbl **, USHORT *, USHORT,
UCHAR *);
extern STATUS CSI_get_slice(STATUS *, struct rdb **, struct rtr **, BID,
USHORT, UCHAR *, USHORT, UCHAR *, SLONG, UCHAR *,
SLONG *);
extern STATUS CSI_open_blob2(STATUS *, struct rdb **, struct rtr **,
struct rbl **, BID, USHORT, UCHAR *);
extern STATUS CSI_prepare_transaction(STATUS *, struct rtr **, USHORT,
UCHAR *);
extern STATUS CSI_put_segment(STATUS *, struct rbl **, USHORT, UCHAR *);
extern STATUS CSI_put_slice(STATUS *, struct rdb **, struct rtr **, BID,
USHORT, UCHAR *, USHORT, UCHAR *, SLONG, UCHAR *);
extern STATUS CSI_que_events(STATUS *, struct rdb **, SLONG *, SSHORT,
UCHAR *, FPTR_VOID, void *);
extern STATUS CSI_receive(STATUS *, struct rrq **, USHORT, USHORT, UCHAR *,
SSHORT);
extern STATUS CSI_reconnect_transaction(STATUS *, struct rdb **,
struct rtr **, SSHORT, UCHAR *);
extern STATUS CSI_release_request(STATUS *, struct rrq **);
extern STATUS CSI_request_info(STATUS *, struct rrq **, USHORT, SSHORT,
UCHAR *, SSHORT, UCHAR *);
extern STATUS CSI_rollback_transaction(STATUS *, struct rtr **);
extern STATUS CSI_seek_blob(STATUS *, struct rbl **, SSHORT, SLONG, SLONG *);
extern STATUS CSI_send(STATUS *, struct rrq **, USHORT, USHORT, UCHAR *,
SSHORT);
extern STATUS CSI_start_and_send(STATUS *, struct rrq **, struct rtr **,
USHORT, USHORT, UCHAR *, SSHORT);
extern STATUS CSI_start_request(STATUS *, register struct rrq **,
register struct rtr **, SSHORT);
extern STATUS CSI_start_transaction(STATUS *, struct rtr **, SSHORT, ...);
extern STATUS CSI_transact_request(STATUS *, struct rdb **, struct rtr **,
USHORT, UCHAR *, USHORT, UCHAR *, USHORT,
UCHAR *);
extern STATUS CSI_transaction_info(STATUS *, struct rtr **, SSHORT, UCHAR *,
SSHORT, UCHAR *);
extern STATUS CSI_unwind_request(STATUS *, struct rrq **, SSHORT);
#endif /* _CSV_CSI_PROTO_H_ */

1691
src/csv/css.cpp Normal file

File diff suppressed because it is too large Load Diff

52
src/csv/css_proto.h Normal file
View File

@ -0,0 +1,52 @@
/*
* PROGRAM: Central Server Interface
* MODULE: css_proto.h
* DESCRIPTION: Prototype header file for css.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _CSV_CSS_PROTO_H_
#define _CSV_CSS_PROTO_H_
extern CSH CSS_acquire(void);
extern FRB CSS_alloc_message(USHORT, int);
extern BLK CSS_alloc_local(USHORT, USHORT);
extern int CSS_check_partner(PTR, USHORT);
extern PTR CSS_connect(SLONG);
extern PTR CSS_create_process(USHORT);
extern void CSS_disconnect(SLONG);
extern void CSS_free_global(FRB);
extern void CSS_free_local(BLK);
extern PTR CSS_find_process(SLONG);
extern MSG CSS_get_message(PTR, MSG, SSHORT);
#ifndef PIPE_SERVER
extern CSH CSS_init(STATUS *, USHORT);
#else
#ifdef GATEWAY
extern CSH CSS_init(STATUS *, USHORT, TEXT *);
#else
extern CSH CSS_init(STATUS *, USHORT, SSHORT);
#endif
#endif
extern void CSS_probe_processes(void);
extern int CSS_put_message(PTR, MSG, MSG);
extern void CSS_release(void);
extern void CSS_validate(void);
#endif /* _CSV_CSS_PROTO_H_ */

570
src/csv/csu.cpp Normal file
View File

@ -0,0 +1,570 @@
/*
* PROGRAM: Central Server
* MODULE: csu.c
* DESCRIPTION: Central Server Utility
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
/*
$Id: csu.cpp,v 1.1.1.1 2001-05-23 13:25:33 tamlin Exp $
*/
#include "../csv/csi.h"
#include "../jrd/license.h"
#include "../jrd/codes.h"
#include "../jrd/thd.h"
#include "../csv/css_proto.h"
#include "../jrd/gds_proto.h"
#define ALLOC(type, length) CSS_alloc_local (type, length)
#define FREE(block) CSS_free_local (block)
static void move(UCHAR *, UCHAR *, USHORT);
static void parse_command_line(int, TEXT **, USHORT *, CSN *, CSN *);
static void process_list_cmd(PTR, USHORT *);
static void process_nonlist_cmd(PTR, CSN);
static STATUS process_response(MSG_RESP, STATUS *, USHORT *);
static TEXT error_buffer[1024];
static USHORT return_buffer_length;
static UCHAR *return_buffer;
int CLIB_ROUTINE main( int argc, char **argv)
{
/**************************************
*
* m a i n
*
**************************************
*
* Functional description
* Run the central server utility.
*
**************************************/
USHORT sw_list, listed_flag, flags;
CSN csv_enable_names, csv_other_names, cs_name;
STATUS status_vector[20];
SRQ *que;
PRB process;
PTR connection, server, client;
CSH CSS_header;
SLONG process_number, process_numbers[256], *ptr, *end;
#ifdef VMS
argc = VMS_parse(&argv, argc);
#endif
csv_enable_names = csv_other_names = NULL;
sw_list = FALSE;
THREAD_ENTER;
parse_command_line(argc, argv, &sw_list, &csv_enable_names,
&csv_other_names);
if (!CSS_init(status_vector, FALSE)) {
printf("It's likely that no central servers are operating.\n");
gds__print_status(status_vector);
exit(FINI_ERROR);
}
client = CSS_create_process(PRB_client);
/* Start by finding all server processes */
CSS_header = ACQUIRE;
CSS_probe_processes();
end = process_numbers;
QUE_LOOP(CSS_header->csh_processes, que) {
process = (PRB) ((UCHAR *) que - OFFSET(PRB, prb_processes));
server = REL_PTR(process);
if (client != server &&
(process->prb_flags & PRB_server) &&
process->prb_protocol_version == CSI_PROTOCOL_VERSION)
*end++ = process->prb_process_number;
}
RELEASE;
/* Go back and talk to servers */
/* Initialize a flag that indicates if anything has been listed */
listed_flag = FALSE;
for (ptr = process_numbers; ptr < end; ptr++) {
process_number = *ptr;
if (server = CSS_find_process(process_number)) {
connection = CSS_connect(server);
/* For each server name specified by the user, ask this
server to process it. */
for (cs_name = csv_enable_names;
cs_name && CSS_find_process(process_number);
cs_name =
cs_name->csn_next) process_nonlist_cmd(connection, cs_name);
/* For each database name specified by the user, ask this
server to process it. */
for (cs_name = csv_other_names;
cs_name && CSS_find_process(process_number);
cs_name = cs_name->csn_next) if (cs_name->csn_flags)
process_nonlist_cmd(connection, cs_name);
/* We may also need to do a list of this server's databases */
if (sw_list && CSS_find_process(process_number))
process_list_cmd(connection, &listed_flag);
CSS_disconnect(connection);
}
}
if (sw_list && !listed_flag)
printf("\nNo central servers are operating.\n\n");
for (cs_name = csv_other_names; cs_name; cs_name = cs_name->csn_next)
if ((flags = cs_name->csn_flags) && !(flags & DBN_cmd_process)) {
printf("Database \"%s\" ", cs_name->csn_db_name);
if (cs_name->csn_cs_len)
printf("running on server\n \"%s\" could not be ",
cs_name->csn_cs_name);
else
printf("could not be\n ");
printf("found and so it was not %sed.\n",
(flags & DBN_reenable) ? "re-enabl" : (flags & DBN_kill) ?
"kill" : "disabl");
}
for (cs_name = csv_enable_names; cs_name; cs_name = cs_name->csn_next)
if (!(cs_name->csn_flags & DBN_cmd_process))
printf
("Server \"%s\" could not be found and so database\n \"%s\" was not enabled.\n",
cs_name->csn_cs_name, cs_name->csn_db_name);
exit(FINI_OK);
}
static void move( UCHAR * from_ptr, UCHAR * to_ptr, USHORT length)
{
/**************************************
*
* m o v e
*
**************************************
*
* Functional description
* Move some bytes.
*
**************************************/
USHORT l;
UCHAR *from, *to;
from = from_ptr;
to = to_ptr;
if (length)
do
*to++ = *from++;
while (--length);
}
static void parse_command_line(
int argc,
TEXT ** argv,
USHORT * sw_list,
CSN * csv_enable_names, CSN * csv_other_names)
{
/**************************************
*
* p a r s e _ c o m m a n d _ l i n e
*
**************************************
*
* Functional description
* Parse a Unix style command line.
*
**************************************/
USHORT sw_enable, sw_name, sw_all, dbn_flag, all_flag;
USHORT length, listed_flag, csv_name_len;
TEXT **end, *p, c, expanded_name[256], *q, csv_name[256];
CSN other_names, enable_names, name, *head;
other_names = enable_names = NULL;
dbn_flag = all_flag = sw_enable = 0;
sw_name = FALSE;
for (end = argv++ + argc; argv < end;) {
p = *argv++;
if (*p++ == '-') {
/* Clear -a, -e, and -n indicators for each new switch. Clear -d,
-k, and -r indicators except when the switch is "-a" or "-n". */
sw_name = sw_all = FALSE;
if (((c = UPPER(*p)) != 'A' && c != 'N') || *(p + 1) || sw_enable)
dbn_flag = 0;
sw_enable = csv_name_len = 0;
while (c = *p++)
switch (UPPER(c)) {
case 'L':
*sw_list = TRUE;
break;
case 'D':
dbn_flag |= DBN_disable;
break;
case 'K':
dbn_flag |= DBN_kill;
break;
case 'R':
dbn_flag |= DBN_reenable;
break;
case 'E':
sw_enable = 1;
break;
case 'A':
sw_all = TRUE;
break;
case 'N':
sw_name = TRUE;
break;
case 'Z':
printf("csu version %s\n", GDS_VERSION);
break;
}
if (sw_enable && (dbn_flag || sw_all || sw_name)) {
printf
("The -e switch may only be used in conjunction with\nthe -l and -z switches.\n");
exit(FINI_ERROR);
}
else if (sw_all)
if (!dbn_flag)
printf
("No command indicated with the -a switch. It will be ignored.\n");
else {
all_flag |= dbn_flag;
dbn_flag = 0;
}
}
else if (!dbn_flag && !sw_enable && !sw_name)
printf
("No command indicated for database \"%s\".\nThe name will be ignored.\n",
p - 1);
else {
if (sw_enable == 1 || sw_name) {
if ((length = strlen(--p)) >= sizeof(csv_name))
length = sizeof(csv_name) - 1;
csv_name_len = length;
for (q = csv_name; length--;) {
c = *p++;
*q++ = UPPER(c);
}
if (sw_name)
sw_name = FALSE;
else
sw_enable++;
continue;
}
length = ISC_expand_filename(p - 1, 0, expanded_name);
#ifdef VMS
/* The next expansion is Gateway specific but we'll do it
for everyone. Since '@' isn't valid in a VMS filename,
this is ok. */
/* Look for an '@' after the first SCHARacter in expanded_name.
If one is found, try to expand the remainder of the string. */
if (*(p = expanded_name) != '@')
while (*p)
if (*p++ == '@' && *p) {
length =
ISC_expand_logical(p,
length - (p - expanded_name),
p) + (p - expanded_name);
break;
}
#endif
csv_name[csv_name_len] = 0;
head = (sw_enable) ? &enable_names : &other_names;
for (name = *head; name; name = name->csn_next)
if (!strcmp(name->csn_db_name, expanded_name) &&
!strcmp(name->csn_cs_name, csv_name))
break;
if (!name) {
name =
(CSN) ALLOC(type_csn,
sizeof(struct csn) + length + csv_name_len);
name->csn_next = *head;
*head = name;
name->csn_cs_name = name->csn_data;
name->csn_db_name = name->csn_data + csv_name_len + 1;
move(csv_name, name->csn_cs_name, csv_name_len + 1);
move(expanded_name, name->csn_db_name, length + 1);
name->csn_cs_len = csv_name_len;
name->csn_db_len = length;
}
name->csn_flags |= (sw_enable) ? DBN_enable : dbn_flag;
}
}
if (all_flag) {
/* We're to do something to all central server databases.
But first, make sure we won't try to do the same thing
or something similar to a specific database. Reenable
takes precedence over kill and disable. Kill takes
precedence over disable. */
if (all_flag & DBN_reenable)
all_flag |= DBN_kill | DBN_disable;
else if (all_flag & DBN_kill)
all_flag |= DBN_disable;
for (name = other_names; name; name = name->csn_next)
name->csn_flags &= ~all_flag;
/* The -a switch gets saved as a name with a zero length */
name = (CSN) ALLOC(type_csn, sizeof(struct csn));
name->csn_next = other_names;
other_names = name;
name->csn_cs_name = name->csn_db_name = name->csn_data;
name->csn_cs_len = name->csn_db_len = 0;
name->csn_flags = all_flag;
}
*csv_other_names = other_names;
*csv_enable_names = enable_names;
}
static void process_list_cmd( PTR connection, USHORT * listed_flag)
{
/**************************************
*
* p r o c e s s _ l i s t _ c m d
*
**************************************
*
* Functional description
* Process a list command for a server.
*
**************************************/
MSG_UTIL message;
MSG_RESP response;
STATUS status_vector[20];
USHORT l;
CSU_LIST list_msg;
message = (MSG_UTIL) CSS_alloc_message(type_msg, sizeof(struct msg_util));
message->msg_util_header.msg_type = MSG_util_cmd;
message->msg_util_cmd = UTIL_list;
message->msg_util_csn_len = message->msg_util_dbn_len = 0;
if (!CSS_put_message(connection, message, 0) ||
!(response = CSS_get_message(connection, 0, 0)))
return;
if (!process_response(response, status_vector, 0)) {
list_msg = (CSU_LIST) return_buffer;
/* Print a header before the first name listed */
if (!*listed_flag) {
printf("\nServer\n\tAttaches Flags Database Name\n\n");
*listed_flag = TRUE;
}
/* Print the server name */
printf("%s\n", list_msg->csu_list_name);
list_msg =
(CSU_LIST) (list_msg->csu_list_name +
FB_ALIGN(list_msg->csu_list_length + 1, 2));
/* Loop over returned database name info */
while (l = list_msg->csu_list_length) {
printf("\t%7d%s %c %c %s\n", list_msg->csu_list_attaches,
(list_msg->csu_list_flags & DBN_server_att) ? "+s" : " ",
(list_msg->csu_list_flags & DBN_disable) ? 'D' : ' ',
(list_msg->csu_list_flags & DBN_kill) ? 'K' : ' ',
list_msg->csu_list_name);
list_msg =
(CSU_LIST) (list_msg->csu_list_name + FB_ALIGN(l + 1, 2));
}
}
else if (status_vector[1] != gds__unavailable) {
/**** DO SOMETHING MORE INTELLIGENT ****/
}
}
static void process_nonlist_cmd( PTR connection, CSN cs_name)
{
/**************************************
*
* p r o c e s s _ n o n l i s t _ c m d
*
**************************************
*
* Functional description
* Process a disable, enable, kill, or re-enable command
* for a server.
*
**************************************/
SLONG length;
MSG_UTIL message;
MSG_RESP response;
USHORT l, cmd;
STATUS status_vector[20];
l = cs_name->csn_cs_len + cs_name->csn_db_len;
length = sizeof(struct msg_util) + l;
message = (MSG_UTIL) CSS_alloc_message(type_msg, (int) length);
message->msg_util_header.msg_type = MSG_util_cmd;
if (cs_name->csn_flags & DBN_enable)
cmd = UTIL_enable;
else if (cs_name->csn_flags & DBN_reenable)
cmd = UTIL_reenable;
else if (cs_name->csn_flags & DBN_kill)
cmd = UTIL_kill;
else
cmd = UTIL_disable;
message->msg_util_cmd = cmd;
message->msg_util_csn_len = cs_name->csn_cs_len;
message->msg_util_dbn_len = cs_name->csn_db_len;
move(cs_name->csn_data, message->msg_util_data, l + 2);
if (!CSS_put_message(connection, message, 0) ||
!(response = CSS_get_message(connection, 0, 0)))
return;
if (!process_response(response, status_vector, 0)) {
/* Set a flag to indicate that a central server has processed
the command relating to this server and database name */
cs_name->csn_flags |= DBN_cmd_process;
}
else if (status_vector[1] != gds__unavailable)
if (cs_name->csn_flags & DBN_enable) {
printf
("Server \"%s\" could not enable database \"%s\" because:\n",
cs_name->csn_cs_name, cs_name->csn_db_name);
gds__print_status(status_vector);
cs_name->csn_flags |= DBN_cmd_process;
}
else {
/**** DO SOMETHING MORE INTELLIGENT ****/
}
}
static STATUS process_response(
MSG_RESP message,
STATUS * user_status, USHORT * return_length)
{
/**************************************
*
* p r o c e s s _ r e s p o n s e
*
**************************************
*
* Functional description
* Process a response packet from server.
*
**************************************/
TEXT *p, *q;
STATUS *status, *stuff, *end;
USHORT l;
/* If there isn't a message, the server has disappeared */
if (!message || message->msg_resp_header.msg_type != MSG_response) {
status = user_status;
*status++ = gds_arg_gds;
*status++ = gds__random;
*status++ = gds_arg_string;
*status++ = (STATUS) "connection lost to central server";
*status = gds_arg_end;
return user_status[1];
}
/* Well, at least we got something -- eat it up */
p = error_buffer;
for (status = user_status, end = status + 20, stuff =
message->msg_resp_status; (*status = *stuff++) && status < end;)
switch (*status++) {
case gds_arg_interpreted:
case gds_arg_string:
q = (TEXT *) message + *stuff++;
*status++ = (STATUS) p;
while (*p++ = *q++);
break;
case gds_arg_cstring:
l = *status++ = *stuff++;
q = (TEXT *) message + *stuff++;
*status++ = (STATUS) p;
if (l)
do
*p++ = *q++;
while (--l);
break;
default:
*status++ = *stuff++;
}
if (!user_status[1] || user_status[1] == gds__segment) {
if (return_buffer_length < (l = message->msg_resp_length)) {
if (return_buffer)
FREE(return_buffer);
return_buffer = (UCHAR *) ALLOC(0, l);
return_buffer_length = l;
}
if (l)
move(message->msg_resp_data, return_buffer, l);
if (return_length)
*return_length = l;
}
CSS_free_global(message);
return user_status[1];
}

3612
src/csv/csv.cpp Normal file

File diff suppressed because it is too large Load Diff

75
src/csv/depends.mak Normal file
View File

@ -0,0 +1,75 @@
# The contents of this file are subject to the Interbase Public
# License Version 1.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy
# of the License at http://www.Inprise.com/IPL.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
# or implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code was created by Inprise Corporation
# and its predecessors. Portions created by Inprise Corporation are
# Copyright (C) Inprise Corporation.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
# depends.mak - csv
# Created by 'make depends.mak'
# Created on 1998-11-17
csi.o: csi.c
csi.o: csi.h
csi.o: csi_proto.h
csi.o: css_proto.h
csi.o: source/jrd/build_no.h
csi.o: source/jrd/codes.h
csi.o: source/jrd/common.h
csi.o: source/jrd/fil.h
csi.o: source/jrd/gds_proto.h
csi.o: source/jrd/inf.h
csi.o: source/jrd/isc.h
csi.o: source/jrd/license.h
csi.o: source/jrd/thd.h
csi.o: source/remote/merge_proto.h
css.o: csi.h
css.o: css.c
css.o: css_proto.h
css.o: source/jrd/codes.h
css.o: source/jrd/common.h
css.o: source/jrd/fil.h
css.o: source/jrd/gds_proto.h
css.o: source/jrd/isc.h
css.o: source/jrd/isc_proto.h
css.o: source/jrd/thd.h
csu.o: csi.h
csu.o: css_proto.h
csu.o: csu.c
csu.o: source/jrd/build_no.h
csu.o: source/jrd/codes.h
csu.o: source/jrd/common.h
csu.o: source/jrd/fil.h
csu.o: source/jrd/gds_proto.h
csu.o: source/jrd/isc.h
csu.o: source/jrd/license.h
csu.o: source/jrd/thd.h
csv.o: csi.h
csv.o: css_proto.h
csv.o: csv.c
csv.o: source/interbase/include/iberror.h
csv.o: source/jrd/build_no.h
csv.o: source/jrd/common.h
csv.o: source/jrd/fil.h
csv.o: source/jrd/gds.h
csv.o: source/jrd/gds_proto.h
csv.o: source/jrd/isc.h
csv.o: source/jrd/license.h
csv.o: source/jrd/thd.h
csv.o: source/remote/merge_proto.h
print.o: csi.h
print.o: css_proto.h
print.o: print.c
print.o: source/jrd/common.h
print.o: source/jrd/fil.h
print.o: source/jrd/gds_proto.h
print.o: source/jrd/isc.h
print.o: source/jrd/thd.h

141
src/csv/print.cpp Normal file
View File

@ -0,0 +1,141 @@
/*
* PROGRAM: Central Server
* MODULE: print.c
* DESCRIPTION: Global region print utility
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include "../csv/csi.h"
#include "../csv/css_proto.h"
#include "../jrd/gds_proto.h"
static void prt_que(UCHAR *, SRQ *);
static CSH CSS_header;
void main( int argc, char **argv)
{
/**************************************
*
* m a i n
*
**************************************
*
* Functional description
*
**************************************/
SRQ *que;
HDR *block;
PRB process;
MSG message;
FRB free;
CNCT connection;
SLONG offset;
STATUS status_vector[20];
if (!(CSS_header = CSS_init(status_vector, TRUE))) {
printf("Can't access global region\n");
gds__print_status(status_vector);
exit(FINI_ERROR);
}
printf("%.5d GLOBAL REGION HEADER\n", 0);
printf("\tLength: %ld, version: %d, free: %ld\n", CSS_header->csh_length,
CSS_header->csh_version, CSS_header->csh_free);
printf("\tSemid: %ld, current process: %ld\n",
CSS_header->csh_semid, CSS_header->csh_current_process);
prt_que("\tProcesses", &CSS_header->csh_processes);
for (offset = sizeof(struct csh); offset < CSS_header->csh_length;
offset += block->hdr_length) {
printf("\n%.5ld ", offset);
block = (HDR *) ABS_PTR(offset);
switch (block->hdr_type) {
case type_prb:
printf("PROCESS_BLOCK (%ld)\n", block->hdr_length);
process = (PRB) block;
printf("\tProcess_id: %ld, flags: %d, protocol: %d\n",
process->prb_process_id, process->prb_flags,
process->prb_protocol_version);
printf("\tSemaphore: %d, group_id: %ld, number: %ld\n",
process->prb_semaphore, process->prb_group_id,
process->prb_process_number);
prt_que("\tProcesses", &process->prb_processes);
prt_que("\tConnections", &process->prb_connections);
prt_que("\tMessages", &process->prb_messages);
break;
case type_frb:
printf("FREE BLOCK (%ld)\n", block->hdr_length);
free = (FRB) block;
printf("\tNext: %ld\n", free->frb_next);
break;
case type_msg:
printf("MSG (%ld)\n", block->hdr_length);
message = (MSG) block;
printf("\tType: %d, connection: %ld\n", message->msg_type,
message->msg_connection);
prt_que("\tMsg que", &message->msg_que);
break;
case type_cnct:
printf("CONNECTION (%ld)\n", block->hdr_length);
connection = (CNCT) block;
printf("\tParent: %ld, partner: %ld, mirror: %ld\n",
connection->cnct_parent, connection->cnct_partner,
connection->cnct_mirror);
prt_que("\tConnections", &connection->cnct_connections);
break;
default:
printf("*** UNKNOWN *** (%ld)\n", block->hdr_length);
break;
}
if (!block->hdr_length)
break;
}
exit(FINI_OK);
}
static void prt_que( UCHAR * string, SRQ * que)
{
/**************************************
*
* p r t _ q u e
*
**************************************
*
* Functional description
* Print the contents of a self-relative que.
*
**************************************/
SLONG offset;
offset = REL_PTR(que);
if (offset == que->srq_forward && offset == que->srq_backward)
printf("%s: *empty*\n", string);
else
printf("%s: forward: %d, backward: %d\n",
string, que->srq_forward, que->srq_backward);
}

40
src/dsql/all.h Normal file
View File

@ -0,0 +1,40 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: all.h
* DESCRIPTION: Allocator prototypes
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include "../dsql/dsql.h"
BLK ALLD_alloc( /* alloc and init a block from a pool */
PLB pool, UCHAR type, int count);
BLK ALLD_extend( /* extend a block by given size */
BLK * pointer, int size);
int ALLD_fini(); /* get rid of everything */
int ALLD_free(SCHAR * memory); /* give space back to system */
int ALLD_init(); /* initialize pool system */
UCHAR *ALLD_malloc(int size); /* get memory from system */
PLB ALLD_pool(); /* allocate a new pool */
int ALLD_push(BLK object, LLS * stack); /* push object on LLS stack */
BLK ALLD_pop(LLS * stack); /* pop object off LLS stack */
int ALLD_release(FRB block); /* release a block to its pool */
int ALLD_rlpool(PLB pool); /* release a pool */

919
src/dsql/alld.cpp Normal file
View File

@ -0,0 +1,919 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: all.c
* DESCRIPTION: Internal block allocator
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
/***************************************************
THIS MODULE HAS SEVERAL KISSING COUSINS; IF YOU
SHOULD CHANGE ONE OF THE MODULES IN THE FOLLOWING
LIST, PLEASE BE SURE TO CHECK THE OTHERS FOR
SIMILAR CHANGES:
/gds/maint/pyxis/all.c
/dsql/all.c
/jrd/all.c
/pipe/allp.c
/qli/all.c
/remote/allr.c
/gpre/msc.c
- THANK YOU
***************************************************/
/**************************************************************
V4 Multi-threading changes.
-- direct calls to gds__ () & isc_ () entry points
THREAD_EXIT;
gds__ () or isc_ () call.
THREAD_ENTER;
-- calls through embedded GDML.
the following protocol will be used. Care should be taken if
nested FOR loops are added.
THREAD_EXIT; // last statment before FOR loop
FOR ...............
THREAD_ENTER; // First statment in FOR loop
.....some C code....
.....some C code....
THREAD_EXIT; // last statment in FOR loop
END_FOR;
THREAD_ENTER; // First statment after FOR loop
***************************************************************/
#include <string.h>
#include "../jrd/ib_stdio.h"
#include "../dsql/dsql.h"
#include "../dsql/node.h"
#include "../dsql/sym.h"
#include "../jrd/codes.h"
#include "../dsql/alld_proto.h"
#include "../dsql/errd_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/thd_proto.h"
#include "../jrd/gdsassert.h"
ASSERT_FILENAME /* Define things dsql/assert needed */
extern "C" {
#define MIN_ALLOCATION 1024
#if (defined PC_PLATFORM && !defined NETWARE_386)
#define MAX_BLOCK 65520
#else
#define MAX_BLOCK (262144 - MIN_ALLOCATION - sizeof (struct hnk) - 8)
#endif
#define SHIFT SHIFTLONG
#define BLOCK_FACTOR (1 << SHIFT)
#define BLOCKS_TO_SIZE(blocks) ((blocks) << SHIFT)
#define SIZE_TO_BLOCKS(size) ((size) >> SHIFT)
#define BLOCK_ROUNDUP(size) ROUNDUP (size, MAX(BLOCK_FACTOR,ALIGNMENT))
#define EXPAND_BLOCKSIZE(b) (BLOCKS_TO_SIZE ((b)->blk_length))
#define BLKDEF(type, root, tail) sizeof (struct root), tail,
static CONST struct {
USHORT typ_root_length;
USHORT typ_tail_length;
} block_sizes[] = {
0, 0,
#include "../dsql/blk.h"
0};
#undef BLKDEF
#ifdef SUPERSERVER
extern SLONG trace_pools;
SLONG alld_delta_alloc = 0;
#define BLKDEF(type, root, tail) 0,
SLONG alld_block_type_count[] = {
#include "../dsql/blk.h"
0
};
#undef BLKDEF
#define BLKDEF(type, root, tail) #type,
char ALLD_types[][24] = {
"type_MIN",
#include "../dsql/blk.h"
"type_MAX"
};
#undef BLKDEF
int alld_type_MAX = type_MAX;
#endif
static void extend_pool(PLB, ULONG);
static PLB find_pool(BLK);
static void release(FRB, PLB);
static USHORT init_flag = FALSE;
static VEC pools = NULL;
BLK ALLD_alloc( PLB pool, UCHAR type, ULONG count)
{
/**************************************
*
* A L L D _ a l l o c
*
**************************************
*
* Functional description
* Allocate a block from a given pool and initialize the block.
* This is the primary block allocation routine.
*
**************************************/
register BLK block;
FRB free, *best, *ptr;
register ULONG size;
ULONG l;
SLONG best_tail, tail;
ULONG needed_blocks;
assert(pool != NULL);
DEV_BLKCHK(pool, type_plb);
if (type <= (SCHAR) type_MIN || type >= (SCHAR) type_MAX)
BUGCHECK("bad block type");
/* Compute block length */
size = block_sizes[type].typ_root_length;
if ((tail = block_sizes[type].typ_tail_length) && count >= 1)
size += (count - 1) * tail;
#ifdef DEV_BUILD
if (size <= sizeof(struct blk) || size >= MAX_BLOCK)
BUGCHECK("bad block size");
#endif
needed_blocks = SIZE_TO_BLOCKS(BLOCK_ROUNDUP(size));
assert(BLOCKS_TO_SIZE(needed_blocks) >= size);
/* Find best fit. Best fit is defined to be the free block of shortest
tail. If there isn't a fit, extend the pool and try, try again. */
while (TRUE) {
best = NULL;
best_tail = MAX_BLOCK;
for (ptr = &pool->plb_free; ((free = *ptr) != NULL);
ptr =
&free->frb_next) if ((SCHAR HUGE_PTR *) free ==
(SCHAR HUGE_PTR *) free->frb_next) {
BUGCHECK("corrupt pool");
}
/* Is this block big enough?
* And have less leftover than the best one found? */
else
if (
((tail
=
((ULONG) free->frb_header.blk_length -
needed_blocks)) >= 0) && (tail < best_tail)) {
best = ptr;
best_tail = tail;
if (tail == 0)
break;
}
if (best)
break;
extend_pool(pool, size);
}
/* We've got our free block. If there's enough left of the free block
after taking out our block, chop out out block. If not, allocate
the entire free block as our block (a little extra won't hurt). */
free = *best;
if (best_tail > SIZE_TO_BLOCKS(BLOCK_ROUNDUP(sizeof(struct frb)))) {
/* Carve off the needed size from the bottom of the free block */
l = free->frb_header.blk_length - needed_blocks;
block = (BLK) ((UCHAR *) free + BLOCKS_TO_SIZE(l));
/* Reset the length of the free block */
assert(l <= MAX_USHORT);
free->frb_header.blk_length = (USHORT) l;
}
else {
/* There isn't left over in the free block to save in the free list */
/* So give the client the whole free block */
/* Unhook the free block from the free chain */
*best = free->frb_next;
/* Client gets the whole block */
needed_blocks = free->frb_header.blk_length;
block = (BLK) free;
}
/* Zero the whole allocated structure */
memset(block, 0, BLOCKS_TO_SIZE(needed_blocks));
/* Now set the block header (yeah, we just zero'ed it, sue me) */
block->blk_type = type;
assert(pool->plb_pool_id <= MAX_UCHAR);
block->blk_pool_id = (UCHAR) pool->plb_pool_id;
assert(needed_blocks <= MAX_USHORT);
block->blk_length = (USHORT) needed_blocks;
#ifdef SUPERSERVER
if (trace_pools) {
++alld_block_type_count[type];
++pool->plb_blk_type_count[type];
}
#endif
return block;
}
BLK ALLD_extend(BLK * pointer, ULONG size)
{
/**************************************
*
* A L L D _ e x t e n d
*
**************************************
*
* Functional description
* Extend a repeating block, copying the constant part.
*
**************************************/
BLK block, new_;
PLB pool;
register ULONG length, l;
register SLONG *p1, *p2;
register SCHAR *c1, *c2;
assert(pointer != NULL);
assert(*pointer != NULL);
block = *pointer;
pool = find_pool(block);
new_ = ALLD_alloc(pool, block->blk_type, size);
length = MIN(EXPAND_BLOCKSIZE(block), EXPAND_BLOCKSIZE(new_))
- sizeof(struct blk);
p1 = (SLONG *) ((UCHAR *) new_ + sizeof(struct blk));
p2 = (SLONG *) ((UCHAR *) block + sizeof(struct blk));
/* Copy the bytes a longword at a time */
if ((l = length >> SHIFTLONG) != 0)
do
*p1++ = *p2++;
while (--l);
/* Copy any remaining bytes */
if (length &= 3) {
c1 = (SCHAR *) p1;
c2 = (SCHAR *) p2;
do
*c1++ = *c2++;
while (--length);
}
release(reinterpret_cast<FRB>(block), pool);
if (new_->blk_type == (SCHAR) type_vec)
((VEC) new_)->vec_count = size;
else if (new_->blk_type == (SCHAR) type_vcl)
((VCL) new_)->vcl_count = size;
*pointer = new_;
return new_;
}
void ALLD_fini(void)
{
/**************************************
*
* A L L D _ f i n i
*
**************************************
*
* Functional description
* Get rid of everything.
*
**************************************/
BLK *vector, *until;
PLB pool;
assert(init_flag); /* Must _init before _fini */
/* if there are no pools, we've already finished. */
if (!pools)
return;
/* vec_object [0] is the memory pool which contains pools, so release
* objects in reverse order, and be careful not to refer to pools
* during the process.
*/
for (vector = pools->vec_object + pools->vec_count, until =
pools->vec_object; --vector >= until;)
if ((pool = (PLB) * vector) != NULL)
ALLD_rlpool(pool);
pools = NULL;
init_flag = FALSE;
}
void ALLD_free( SCHAR * memory)
{
/**************************************
*
* A L L D _ f r e e
*
**************************************
*
* Functional description
* Give space back to system.
*
**************************************/
#ifdef SUPERSERVER
alld_delta_alloc -= gds__free(memory);
#else
gds__free(memory);
#endif
}
USHORT ALLD_init(void)
{
/**************************************
*
* A L L D _ i n i t
*
**************************************
*
* Functional description
* Initialize the pool system. Return
* TRUE if initialization took place, FALSE if
* we had been previous initialized.
*
**************************************/
SLONG temp_vector[20];
PLB pool;
USHORT init;
TSQL tdsql;
tdsql = GET_THREAD_DATA;
init = (init_flag == FALSE);
if (!init_flag) {
init_flag = TRUE;
pools = (VEC) temp_vector;
pools->vec_count = 1;
pools->vec_object[0] = NULL;
tdsql->tsql_default = DSQL_permanent_pool = pool = ALLD_pool();
pools = (VEC) ALLD_alloc(pool, type_vec, 10);
pools->vec_count = 10;
/* Note: ALLD_fini() assumes the this master pool is in vec_object [0] */
pools->vec_object[0] = (BLK) pool;
}
return init;
}
UCHAR *ALLD_malloc(ULONG size)
{
/**************************************
*
* A L L D _ m a l l o c
*
**************************************
*
* Functional description
* Get memory from system.
*
**************************************/
register UCHAR *memory;
TSQL tdsql;
tdsql = GET_THREAD_DATA;
if ((memory = gds__alloc((SLONG) size)) != NULL)
#ifdef SUPERSERVER
{
alld_delta_alloc += size;
return memory;
}
#else
return memory;
#endif
/* FREE: by ALLD_free, called during DSQL cleanup */
/* NOMEM: post a user level error - if we can */
if (tdsql && tdsql->tsql_setjmp)
ERRD_post(gds__sys_request, gds_arg_string, "gds__alloc", gds_arg_gds,
gds__virmemexh, gds_arg_end);
/* Commentary: This expands out to a call to ERRD_error - which
* promply depends on tdsql being non-NULL. Knock, knock, anyone home?
*/
IBERROR(-1, "out of memory");
return ((UCHAR *) NULL); /* Added to remove warnings */
}
PLB ALLD_pool(void)
{
/**************************************
*
* A L L D _ p o o l
*
**************************************
*
* Functional description
* Allocate a new pool. This is done by creating a tempory
* pool block on the stack, then allocating a real pool block.
* In short, by mirrors.
*
**************************************/
struct plb temp_pool;
register PLB pool;
register USHORT pool_id;
/* Start by assigning a pool id */
for (pool_id = 0; pool_id < pools->vec_count; pool_id++)
if (!(pools->vec_object[pool_id]))
break;
if (pool_id >= pools->vec_count)
ALLD_extend((BLK *) & pools, (ULONG) (pool_id + 10));
memset((UCHAR *) & temp_pool, 0, sizeof(temp_pool));
temp_pool.plb_header.blk_type = type_plb;
pools->vec_object[pool_id] = (BLK) & temp_pool;
temp_pool.plb_free = NULL;
temp_pool.plb_hunks = NULL;
temp_pool.plb_pool_id = pool_id;
temp_pool.plb_blk_type_count = NULL;
#ifdef SUPERSERVER
if (trace_pools)
{
temp_pool.plb_blk_type_count =
reinterpret_cast <long*>(gds__alloc(sizeof(alld_block_type_count)));
if (!temp_pool.plb_blk_type_count) {
trace_pools = 0; /* No memory!! stop tracing pool info */
} else {
memset(temp_pool.plb_blk_type_count, 0, sizeof(alld_block_type_count));
}
}
#endif
if (pool_id == 0)
DSQL_permanent_pool = &temp_pool;
pool = (PLB) ALLD_alloc(&temp_pool, type_plb, 0);
pool->plb_pool_id = pool_id;
pool->plb_free = temp_pool.plb_free;
pool->plb_hunks = temp_pool.plb_hunks;
#ifdef SUPERSERVER
pool->plb_blk_type_count = temp_pool.plb_blk_type_count;
#endif
pools->vec_object[pool_id] = (BLK) pool;
if (pool_id == 0)
DSQL_permanent_pool = pool;
return pool;
}
#ifdef SUPERSERVER
void ALLD_print_memory_pool_info( IB_FILE * fptr)
{
/*************************************************************
*
* A L L D _ p r i n t _ m e m o r y _ p o o l _ i n f o
*
*************************************************************
*
* Functional description
* Print the various block types allocated with in the pools
*
*************************************************************/
VEC vector;
PLB myPool;
HNK hnk;
int i, j, col;
if (!trace_pools)
return;
ib_fprintf(fptr, "\n\tALLD_xx block types\n");
ib_fprintf(fptr, "\t--------------------");
for (i = 0, col = 0; i < type_MAX; i++)
if (alld_block_type_count[i]) {
if (col % 5 == 0)
ib_fprintf(fptr, "\n\t");
ib_fprintf(fptr, "%s = %d ", ALLD_types[i],
alld_block_type_count[i]);
++col;
}
ib_fprintf(fptr, "\n");
if (!pools) {
ib_fprintf(fptr, "\t No pools allocated");
return;
}
vector = pools;
for (j = 0, i = 0; i < (int) vector->vec_count; i++) {
myPool = (PLB) vector->vec_object[i];
if (myPool)
++j;
}
ib_fprintf(fptr, "\t There are %d pools", j);
for (i = 0; i < (int) vector->vec_count; i++) {
myPool = (PLB) vector->vec_object[i];
if (!myPool)
continue;
ib_fprintf(fptr, "\n\t Pool %d", myPool->plb_pool_id);
for (j = 0, hnk = myPool->plb_hunks; hnk; hnk = hnk->hnk_next)
j++;
if (j)
ib_fprintf(fptr, " has %d hunks", j);
for (j = 0, col = 0; j < type_MAX; j++)
if (myPool->plb_blk_type_count[j]) {
if (col % 5 == 0)
ib_fprintf(fptr, "\n\t ");
ib_fprintf(fptr, "%s = %d ", ALLD_types[j],
myPool->plb_blk_type_count[j]);
++col;
}
}
}
#endif
void ALLD_push( BLK object, register LLS * stack)
{
/**************************************
*
* A L L D _ p u s h
*
**************************************
*
* Functional description
* Push an object on an LLS stack.
*
**************************************/
register LLS node;
PLB pool;
TSQL tdsql;
tdsql = GET_THREAD_DATA;
pool = tdsql->tsql_default;
if ((node = pool->plb_lls) != NULL) {
/* Pull a stack block off the list of free stack blocks */
pool->plb_lls = node->lls_next;
}
else {
/* No free stack blocks - allocate a new one */
node = (LLS) ALLD_alloc(pool, type_lls, 0);
}
DEV_BLKCHK(node, type_lls);
DEV_BLKCHK(*stack, type_lls);
node->lls_object = object;
node->lls_next = *stack;
*stack = node;
}
BLK ALLD_pop(register LLS * stack)
{
/**************************************
*
* A L L D _ p o p
*
**************************************
*
* Functional description
* Pop an object off a linked list stack. Save the node for
* further use.
*
**************************************/
register LLS node;
register PLB pool;
BLK block;
DEV_BLKCHK(*stack, type_lls);
node = *stack;
DEV_BLKCHK(node, type_lls);
/* what we are doing below is .... block = &(node->lls_header) */
block = (BLK) node;
pool = find_pool(block);
/* Pop item off the stack */
*stack = node->lls_next;
/* Add the popped stack lls block to the list of free stack blocks */
node->lls_next = pool->plb_lls;
pool->plb_lls = node;
return node->lls_object;
}
void ALLD_release( register FRB block)
{
/**************************************
*
* A L L D _ r e l e a s e
*
**************************************
*
* Functional description
* Release a block to its pool. If it is contiguous to
* another free block, combine them. Otherwise link it
* into the free block linked list (kept in ascending order
* of addresses).
*
**************************************/
release(block, find_pool(&block->frb_header));
}
void ALLD_rlpool( PLB pool)
{
/**************************************
*
* A L L D _ r l p o o l
*
**************************************
*
* Functional description
* Release a storage pool. This involves nothing more than returning
* hunks to the free hunk list.
*
**************************************/
register HNK hunk, hunks;
/* if there are no pools, there's no point in releasing anything... */
if (!pools)
return;
DEV_BLKCHK(pool, type_plb);
pools->vec_object[pool->plb_pool_id] = NULL;
/* Have to release hunks carefully, as one of the hunks being released
* contains pool itself
*/
#ifdef SUPERSERVER
if (trace_pools && pool->plb_blk_type_count) {
int i;
for (i = 0; i < type_MAX; i++)
alld_block_type_count[i] -= pool->plb_blk_type_count[i];
gds__free(pool->plb_blk_type_count);
}
#endif
for (hunks = pool->plb_hunks; hunk = hunks;) {
hunks = hunk->hnk_next;
ALLD_free(reinterpret_cast < char *>(hunk->hnk_address));
}
}
static void extend_pool( PLB pool, ULONG size)
{
/**************************************
*
* e x t e n d _ p o o l
*
**************************************
*
* Functional description
* Extend a pool by at least enough to accomodate a block
* of given size.
*
**************************************/
register HNK hunk;
register BLK block;
DEV_BLKCHK(pool, type_plb);
size =
(size + sizeof(struct hnk) + MIN_ALLOCATION -
1) & ~((ULONG) MIN_ALLOCATION - 1);
block = (BLK) ALLD_malloc(size);
assert(SIZE_TO_BLOCKS(size) <= MAX_USHORT);
block->blk_length = (USHORT) SIZE_TO_BLOCKS(size);
block->blk_type = (SCHAR) type_frb;
assert(pool->plb_pool_id <= MAX_UCHAR);
block->blk_pool_id = (UCHAR) pool->plb_pool_id;
#ifdef SUPERSERVER
if (trace_pools) {
++alld_block_type_count[block->blk_type];
++pool->plb_blk_type_count[block->blk_type];
}
#endif
release(reinterpret_cast<FRB>(block), pool);
hunk = (HNK) ALLD_alloc(pool, type_hnk, 0);
hunk->hnk_address = (UCHAR *) block;
hunk->hnk_length = size;
hunk->hnk_next = pool->plb_hunks;
pool->plb_hunks = hunk;
}
static PLB find_pool( BLK block)
{
/**************************************
*
* f i n d _ p o o l
*
**************************************
*
* Functional description
* Find pool associate with block.
*
**************************************/
PLB pool;
HNK hunk;
USHORT pool_id;
if (pools->vec_count < 256)
if ((pool_id = block->blk_pool_id) < pools->vec_count &&
(pool = (PLB) pools->vec_object[pool_id]))
return pool;
else
BUGCHECK("bad pool id");
for (pool_id = block->blk_pool_id; pool_id < pools->vec_count;
pool_id += 256) if (pool = (PLB) pools->vec_object[pool_id]) {
hunk = pool->plb_hunks;
for (; hunk; hunk = hunk->hnk_next)
if ((SCHAR HUGE_PTR *) block >=
(SCHAR HUGE_PTR *) hunk->hnk_address
&& (SCHAR HUGE_PTR *) block <
(SCHAR HUGE_PTR *) hunk->hnk_address + hunk->hnk_length)
return pool;
}
BUGCHECK("bad pool id");
return (PLB) NULL; /* Added to remove warnings */
}
static void release( FRB block, PLB pool)
{
/**************************************
*
* r e l e a s e
*
**************************************
*
* Functional description
* Release a block to its pool. If it is contiguous to
* another free block, combine them. Otherwise link it
* into the free block linked list (kept in ascending order
* of addresses).
*
**************************************/
register FRB prior, free;
FRB *ptr;
#ifdef SUPERSERVER
UCHAR blk_header_type;
#endif
DEV_BLKCHK(pool, type_plb);
#ifdef SUPERSERVER
blk_header_type = block->frb_header.blk_type;
#endif
block->frb_header.blk_type = (SCHAR) type_frb;
prior = NULL;
for (ptr = &pool->plb_free; (free = *ptr) != NULL;
prior = free, ptr =
&free->frb_next) if ((SCHAR HUGE_PTR *) block <=
(SCHAR HUGE_PTR *) free) break;
#ifdef DEBUG_GDS_ALLOC
/* Debugging code to erase memory locations after a release -
* this will assist in catching dangling memory references to
* freed locations.
* Note that the header parts of the freed block may still be used,
* for the free chain, so we don't zap those locations.
*/
#define ALLD_RELEASED_PATTERN 0xEE
{
ULONG size;
size = BLOCKS_TO_SIZE(block->frb_header.blk_length);
assert(size >= sizeof(struct blk));
size -= sizeof(struct blk);
if (size)
memset((SCHAR *) block + sizeof(struct blk),
ALLD_RELEASED_PATTERN, size);
};
#endif /* DEBUG_GDS_ALLOC */
if ((SCHAR HUGE_PTR *) block == (SCHAR HUGE_PTR *) free) {
BUGCHECK("block released twice");
}
/* Merge block into list first, then try to combine blocks */
block->frb_next = free;
*ptr = block;
/* Try to merge the free block with the next one down. */
if (free) {
if ((SCHAR HUGE_PTR *) block + EXPAND_BLOCKSIZE(&block->frb_header) ==
(SCHAR HUGE_PTR *) free) {
block->frb_header.blk_length += free->frb_header.blk_length;
block->frb_next = free->frb_next;
#ifdef DEBUG_GDS_ALLOC
/* Paint the freed header of the merged-away block */
memset((UCHAR *) free, ALLD_RELEASED_PATTERN, sizeof(*free));
#endif /* DEBUG_GDS_ALLOC */
}
else if ((SCHAR HUGE_PTR *) block +
EXPAND_BLOCKSIZE(&block->frb_header) >
(SCHAR HUGE_PTR *) free) {
BUGCHECK("released block overlaps following free block");
}
}
/* Try and merge the block with the prior free block */
if (prior) {
if ((SCHAR HUGE_PTR *) prior + EXPAND_BLOCKSIZE(&prior->frb_header) ==
(SCHAR HUGE_PTR *) block) {
prior->frb_header.blk_length += block->frb_header.blk_length;
prior->frb_next = block->frb_next;
#ifdef DEBUG_GDS_ALLOC
/* Paint the freed header of the merged-away block */
memset((UCHAR *) block, ALLD_RELEASED_PATTERN, sizeof(*block));
#endif /* DEBUG_GDS_ALLOC */
}
else if ((SCHAR HUGE_PTR *) prior +
EXPAND_BLOCKSIZE(&prior->frb_header) >
(SCHAR HUGE_PTR *) block) {
BUGCHECK("released block overlaps prior free block");
}
}
#ifdef SUPERSERVER
if (trace_pools) {
--alld_block_type_count[blk_header_type];
--pool->plb_blk_type_count[blk_header_type];
}
#endif
}
} // extern "C"

47
src/dsql/alld_proto.h Normal file
View File

@ -0,0 +1,47 @@
/*
* PROGRAM: Dynamic SQL RUNTIME SUPPORT
* MODULE: alld_proto.h
* DESCRIPTION: Prototype Header file for alld.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_ALLD_PROTO_H_
#define _DSQL_ALLD_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
extern BLK ALLD_alloc(struct plb *, UCHAR, ULONG);
extern BLK ALLD_extend(struct blk **, ULONG);
extern void ALLD_fini(void);
extern void ALLD_free(SCHAR *);
extern USHORT ALLD_init(void);
extern UCHAR *ALLD_malloc(ULONG);
extern PLB ALLD_pool(void);
extern BLK ALLD_pop(register struct lls **);
extern void ALLD_push(struct blk *, register struct lls **);
extern void ALLD_release(register struct frb *);
extern void ALLD_rlpool(struct plb *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _DSQL_ALLD_PROTO_H_ */

631
src/dsql/array.e Normal file
View File

@ -0,0 +1,631 @@
/*
* PROGRAM: Interbase layered support library
* MODULE: array.e
* DESCRIPTION: Dynamic array support
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include <string.h>
#include "../jrd/common.h"
#include <stdarg.h>
#include "../include/jrd/gds.h"
#include "../dsql/array_proto.h"
#include "../jrd/gds_proto.h"
#ifdef WINDOWS_ONLY
#include "../jrd/seg_proto.h"
#endif
DATABASE DB = STATIC "yachts.lnk";
#define ARRAY_DESC_COLUMN_MAJOR 1 /* Set for FORTRAN */
typedef struct gen {
SCHAR *gen_sdl;
SCHAR **gen_sdl_ptr;
SCHAR *gen_end;
STATUS *gen_status;
SSHORT gen_internal;
} *GEN;
static void adjust_length(ISC_ARRAY_DESC *);
static STATUS copy_status(STATUS *, STATUS *);
static STATUS error(STATUS *, SSHORT, ...);
static STATUS gen_sdl(STATUS *, ISC_ARRAY_DESC *, SSHORT *, SCHAR **,
SSHORT *, BOOLEAN);
static void get_name(SCHAR *, SCHAR *);
static STATUS lookup_desc(STATUS *, void **, void **, SCHAR *, SCHAR *,
ISC_ARRAY_DESC *, SCHAR *);
static STATUS stuff(GEN, SSHORT, ...);
static STATUS stuff_literal(GEN, SLONG);
static STATUS stuff_string(GEN, SCHAR, SCHAR *);
/* STUFF_SDL used in place of STUFF to avoid confusion with BLR STUFF
macro defined in dsql.h */
#define STUFF_SDL(byte) if (stuff (gen, 1, byte)) return status [1]
#define STUFF_SDL_WORD(word) if (stuff (gen, 2, word, word >> 8)) return status [1]
#define STUFF_SDL_LONG(word) if (stuff (gen, 4, word, word >> 8, word >> 16, word >> 24)) return status [1]
STATUS API_ROUTINE isc_array_gen_sdl(STATUS * status,
ISC_ARRAY_DESC * desc,
SSHORT * sdl_buffer_length,
SCHAR * sdl_buffer, SSHORT * sdl_length)
{
/**************************************
*
* i s c _ a r r a y _ g e n _ s d l
*
**************************************
*
* Functional description
*
**************************************/
return gen_sdl(status, desc, sdl_buffer_length, &sdl_buffer, sdl_length,
FALSE);
}
STATUS API_ROUTINE isc_array_get_slice(STATUS * status,
void **db_handle,
void **trans_handle,
GDS_QUAD * array_id,
ISC_ARRAY_DESC * desc,
void *array, SLONG * slice_length)
{
/**************************************
*
* i s c _ a r r a y _ g e t _ s l i c e
*
**************************************
*
* Functional description
*
**************************************/
SCHAR *sdl, sdl_buffer[512];
SSHORT sdl_length;
sdl_length = sizeof(sdl_buffer);
sdl = sdl_buffer;
if (gen_sdl(status, desc, &sdl_length, &sdl, &sdl_length, TRUE))
return status[1];
isc_get_slice(status, db_handle, trans_handle, array_id,
sdl_length, sdl, 0, NULL_PTR,
*slice_length, array, slice_length);
if (sdl != sdl_buffer)
gds__free((SLONG *) sdl);
return status[1];
}
STATUS API_ROUTINE isc_array_lookup_bounds(STATUS * status,
void **db_handle,
void **trans_handle,
SCHAR * relation_name,
SCHAR * field_name,
ISC_ARRAY_DESC * desc)
{
/**************************************
*
* i s c _ a r r a y _ l o o k u p _ b o u n d s
*
**************************************
*
* Functional description
*
**************************************/
ISC_ARRAY_BOUND *tail;
SCHAR global[32];
if (lookup_desc(status, db_handle, trans_handle,
field_name, relation_name, desc, global))
return status[1];
tail = desc->array_desc_bounds;
FOR X IN RDB$FIELD_DIMENSIONS WITH X.RDB$FIELD_NAME EQ global SORTED BY X.RDB$DIMENSION
tail->array_bound_lower = (SSHORT)X.RDB$LOWER_BOUND;
tail->array_bound_upper = (SSHORT)X.RDB$UPPER_BOUND;
++tail;
END_FOR
ON_ERROR
return copy_status(gds__status, status);
END_ERROR;
return status[1];
}
STATUS API_ROUTINE isc_array_lookup_desc(STATUS * status,
void **db_handle,
void **trans_handle,
SCHAR * relation_name,
SCHAR * field_name,
ISC_ARRAY_DESC * desc)
{
/**************************************
*
* i s c _ a r r a y _ l o o k u p _ d e s c
*
**************************************
*
* Functional description
*
**************************************/
return lookup_desc(status, db_handle, trans_handle,
field_name, relation_name, desc, NULL_PTR);
}
STATUS API_ROUTINE isc_array_put_slice(STATUS * status,
void **db_handle,
void **trans_handle,
GDS_QUAD * array_id,
ISC_ARRAY_DESC * desc,
void *array, SLONG * slice_length)
{
/**************************************
*
* i s c _ a r r a y _ p u t _ s l i c e
*
**************************************
*
* Functional description
*
**************************************/
SCHAR *sdl, sdl_buffer[512];
SSHORT sdl_length;
sdl_length = sizeof(sdl_buffer);
sdl = sdl_buffer;
if (gen_sdl(status, desc, &sdl_length, &sdl, &sdl_length, TRUE))
return status[1];
isc_put_slice(status, db_handle, trans_handle, array_id,
sdl_length, sdl, 0, NULL_PTR, *slice_length, array);
if (sdl != sdl_buffer)
gds__free((SLONG *) sdl);
return status[1];
}
STATUS API_ROUTINE isc_array_set_desc(STATUS * status,
SCHAR * relation_name,
SCHAR * field_name,
SSHORT * sql_dtype,
SSHORT * sql_length,
SSHORT * dimensions,
ISC_ARRAY_DESC * desc)
{
/**************************************
*
* i s c _ a r r a y _ s e t _ d e s c
*
**************************************
*
* Functional description
*
**************************************/
SSHORT dtype;
get_name(field_name, desc->array_desc_field_name);
get_name(relation_name, desc->array_desc_relation_name);
desc->array_desc_flags = 0;
desc->array_desc_dimensions = *dimensions;
desc->array_desc_length = *sql_length;
desc->array_desc_scale = 0;
dtype = *sql_dtype & ~1;
if (dtype == SQL_VARYING)
desc->array_desc_dtype = blr_varying;
else if (dtype == SQL_TEXT)
desc->array_desc_dtype = blr_text;
else if (dtype == SQL_DOUBLE)
desc->array_desc_dtype = blr_double;
else if (dtype == SQL_FLOAT)
desc->array_desc_dtype = blr_float;
else if (dtype == SQL_D_FLOAT)
desc->array_desc_dtype = blr_d_float;
else if (dtype == SQL_TIMESTAMP)
desc->array_desc_dtype = blr_timestamp;
else if (dtype == SQL_TYPE_DATE)
desc->array_desc_dtype = blr_sql_date;
else if (dtype == SQL_TYPE_TIME)
desc->array_desc_dtype = blr_sql_time;
else if (dtype == SQL_LONG)
desc->array_desc_dtype = blr_long;
else if (dtype == SQL_SHORT)
desc->array_desc_dtype = blr_short;
else if (dtype == SQL_INT64)
desc->array_desc_dtype = blr_int64;
else if (dtype == SQL_QUAD)
desc->array_desc_dtype = blr_quad;
else
return error(status, 7, (STATUS) gds__sqlerr,
(STATUS) gds_arg_number, (STATUS) - 804,
(STATUS) gds_arg_gds, (STATUS) gds__random,
(STATUS) gds_arg_string,
(STATUS) "data type not understood");
return error(status, 1, (STATUS) SUCCESS);
}
static void adjust_length( ISC_ARRAY_DESC * desc)
{
/**************************************
*
* a d j u s t _ l e n g t h
*
**************************************
*
* Functional description
* Make architectural adjustment to fixed datatypes.
*
**************************************/
}
static STATUS copy_status( STATUS * from, STATUS * to)
{
/**************************************
*
* c o p y _ s t a t u s
*
**************************************
*
* Functional description
* Copy a status vector.
*
**************************************/
STATUS status, *end;
status = from[1];
for (end = from + ISC_STATUS_LENGTH; from < end;)
*to++ = *from++;
return status;
}
static STATUS error( STATUS * status, SSHORT count, ...)
{
/**************************************
*
* e r r o r
*
**************************************
*
* Functional description
* Stuff a status vector.
*
**************************************/
STATUS *stat;
va_list ptr;
VA_START(ptr, count);
stat = status;
*stat++ = gds_arg_gds;
for (; count; --count)
*stat++ = (STATUS) va_arg(ptr, STATUS);
*stat = gds_arg_end;
return status[1];
}
static STATUS gen_sdl(STATUS * status,
ISC_ARRAY_DESC * desc,
SSHORT * sdl_buffer_length,
SCHAR ** sdl_buffer,
SSHORT * sdl_length, BOOLEAN internal_flag)
{
/**************************************
*
* g e n _ s d l
*
**************************************
*
* Functional description
*
**************************************/
SSHORT n, from, to, increment, dimensions;
ISC_ARRAY_BOUND *tail;
struct gen *gen, gen_block;
dimensions = desc->array_desc_dimensions;
if (dimensions > 16)
return error(status, 5, (STATUS) gds__invalid_dimension,
(STATUS) gds_arg_number, (STATUS) dimensions,
(STATUS) gds_arg_number, (STATUS) 16);
gen = &gen_block;
gen->gen_sdl = *sdl_buffer;
gen->gen_sdl_ptr = sdl_buffer;
gen->gen_end = *sdl_buffer + *sdl_buffer_length;
gen->gen_status = status;
gen->gen_internal = internal_flag ? 0 : -1;
if (stuff
(gen, 4, gds__sdl_version1, gds__sdl_struct, 1,
desc->array_desc_dtype)) return status[1];
switch (desc->array_desc_dtype) {
case blr_short:
case blr_long:
case blr_int64:
case blr_quad:
STUFF_SDL(desc->array_desc_scale);
break;
case blr_text:
case blr_cstring:
case blr_varying:
STUFF_SDL_WORD(desc->array_desc_length);
break;
default:
break;
}
if (stuff_string(gen, gds__sdl_relation, desc->array_desc_relation_name))
return status[1];
if (stuff_string(gen, gds__sdl_field, desc->array_desc_field_name))
return status[1];
if (desc->array_desc_flags & ARRAY_DESC_COLUMN_MAJOR) {
from = dimensions - 1;
to = -1;
increment = -1;
}
else {
from = 0;
to = dimensions;
increment = 1;
}
for (n = from; n != to; n += increment) {
tail = desc->array_desc_bounds + n;
if (tail->array_bound_lower == 1) {
if (stuff(gen, 2, gds__sdl_do1, n))
return status[1];
}
else {
if (stuff(gen, 2, gds__sdl_do2, n))
return status[1];
if (stuff_literal(gen, (SLONG) tail->array_bound_lower))
return status[1];
}
if (stuff_literal(gen, (SLONG) tail->array_bound_upper))
return status[1];
}
if (stuff(gen, 5, gds__sdl_element, 1, gds__sdl_scalar, 0, dimensions))
return status[1];
for (n = 0; n < dimensions; n++)
if (stuff(gen, 2, gds__sdl_variable, n))
return status[1];
STUFF_SDL(gds__sdl_eoc);
*sdl_length = gen->gen_sdl - *gen->gen_sdl_ptr;
return error(status, 1, (STATUS) SUCCESS);
}
static void get_name( SCHAR * from, SCHAR * to)
{
/**************************************
*
* g e t _ n a m e
*
**************************************
*
* Functional description
* Copy null or blank terminated name.
*
**************************************/
while (*from && *from != ' ') {
*to++ = UPPER7(*from);
from++;
}
*to = 0;
}
static STATUS lookup_desc(STATUS * status,
void **db_handle,
void **trans_handle,
SCHAR * field_name,
SCHAR * relation_name, ISC_ARRAY_DESC * desc, SCHAR * global)
{
/**************************************
*
* l o o k u p _ d e s c
*
**************************************
*
* Functional description
*
**************************************/
SSHORT flag;
if (DB && DB != *db_handle)
RELEASE_REQUESTS;
DB = *db_handle;
gds__trans = *trans_handle;
get_name(field_name, desc->array_desc_field_name);
get_name(relation_name, desc->array_desc_relation_name);
desc->array_desc_flags = 0;
flag = FALSE;
FOR X IN RDB$RELATION_FIELDS CROSS Y IN RDB$FIELDS
WITH X.RDB$FIELD_SOURCE EQ Y.RDB$FIELD_NAME AND
X.RDB$RELATION_NAME EQ desc->array_desc_relation_name AND
X.RDB$FIELD_NAME EQ desc->array_desc_field_name
flag = TRUE;
desc->array_desc_dtype = (UCHAR)Y.RDB$FIELD_TYPE;
desc->array_desc_scale = (SCHAR)Y.RDB$FIELD_SCALE;
desc->array_desc_length = Y.RDB$FIELD_LENGTH;
adjust_length(desc);
desc->array_desc_dimensions = Y.RDB$DIMENSIONS;
if (global)
get_name(Y.RDB$FIELD_NAME, global);
END_FOR
ON_ERROR
return copy_status(gds__status, status);
END_ERROR;
if (!flag)
return error(status, 5, (STATUS) gds__fldnotdef,
(STATUS) gds_arg_string,
(STATUS) desc->array_desc_field_name,
(STATUS) gds_arg_string,
(STATUS) desc->array_desc_relation_name);
return error(status, 1, (STATUS) SUCCESS);
}
static STATUS stuff( GEN gen, SSHORT count, ...)
{
/**************************************
*
* s t u f f
*
**************************************
*
* Functional description
* Stuff a SDL byte.
*
**************************************/
SCHAR c, *new_sdl;
va_list ptr;
SSHORT new_len, current_len;
if (gen->gen_sdl + count >= gen->gen_end) {
if (gen->gen_internal < 0)
return error(gen->gen_status, 3, (STATUS) gds__misc_interpreted,
(STATUS) gds_arg_string,
(STATUS) "SDL buffer overflow");
/* The sdl buffer is too small. Allocate a larger one. */
new_len = gen->gen_end - *gen->gen_sdl_ptr + 512 + count;
new_sdl = (SCHAR *) gds__alloc((SLONG) new_len);
if (!new_sdl)
return error(gen->gen_status, 5, (STATUS) gds__misc_interpreted,
(STATUS) gds_arg_string,
(STATUS) "SDL buffer overflow", (STATUS) gds_arg_gds,
(STATUS) gds__virmemexh);
current_len = gen->gen_sdl - *gen->gen_sdl_ptr;
memcpy(new_sdl, *gen->gen_sdl_ptr, current_len);
if (gen->gen_internal++)
gds__free(*gen->gen_sdl_ptr);
gen->gen_sdl = new_sdl + current_len;
*gen->gen_sdl_ptr = new_sdl;
gen->gen_end = new_sdl + new_len;
}
VA_START(ptr, count);
for (; count; --count) {
c = va_arg(ptr, int);
*(gen->gen_sdl)++ = c;
}
return 0;
}
static STATUS stuff_literal( GEN gen, SLONG literal)
{
/**************************************
*
* s t u f f _ l i t e r a l
*
**************************************
*
* Functional description
* Stuff an SDL literal.
*
**************************************/
STATUS *status;
status = gen->gen_status;
if (literal >= -128 && literal <= 127)
return stuff(gen, 2, gds__sdl_tiny_integer, literal);
if (literal >= -32768 && literal <= 32767)
return stuff(gen, 3, gds__sdl_short_integer, literal, literal >> 8);
STUFF_SDL(gds__sdl_long_integer);
STUFF_SDL_LONG(literal);
return SUCCESS;
}
static STATUS stuff_string( GEN gen, SCHAR sdl, SCHAR * string)
{
/**************************************
*
* s t u f f _ s t r i n g
*
**************************************
*
* Functional description
* Stuff a "thing" then a counted string.
*
**************************************/
STATUS *status;
status = gen->gen_status;
STUFF_SDL(sdl);
STUFF_SDL(strlen(string));
while (*string)
STUFF_SDL(*string++);
return SUCCESS;
}

45
src/dsql/array_proto.h Normal file
View File

@ -0,0 +1,45 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: array_proto.h
* DESCRIPTION: Prototype Header file for array.e
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_ARRAY_PROTO_H_
#define _DSQL_ARRAY_PROTO_H_
extern STATUS API_ROUTINE isc_array_gen_sdl(STATUS *, ISC_ARRAY_DESC *,
SSHORT *, SCHAR *, SSHORT *);
extern STATUS API_ROUTINE isc_array_get_slice(STATUS *, void **, void **,
GDS_QUAD *, ISC_ARRAY_DESC *,
void *, SLONG *);
extern STATUS API_ROUTINE isc_array_lookup_bounds(STATUS *, void **, void **,
SCHAR *, SCHAR *,
ISC_ARRAY_DESC *);
extern STATUS API_ROUTINE isc_array_lookup_desc(STATUS *, void **, void **,
SCHAR *, SCHAR *,
ISC_ARRAY_DESC *);
extern STATUS API_ROUTINE isc_array_put_slice(STATUS *, void **, void **,
GDS_QUAD *, ISC_ARRAY_DESC *,
void *, SLONG *);
extern STATUS API_ROUTINE isc_array_set_desc(STATUS *, SCHAR *, SCHAR *,
SSHORT *, SSHORT *, SSHORT *,
ISC_ARRAY_DESC *);
#endif /*_DSQL_ARRAY_PROTO_H_ */

49
src/dsql/blk.h Normal file
View File

@ -0,0 +1,49 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: blk.h
* DESCRIPTION: Block type definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
BLKDEF(type_ctx, ctx, 0)
BLKDEF(type_par, par, 0)
BLKDEF(type_map, map, 0)
BLKDEF(type_req, req, 0)
BLKDEF(type_dbb, dbb, 0)
BLKDEF(type_dsql_rel, dsql_rel, 1)
BLKDEF(type_fld, fld, 1)
BLKDEF(type_fil, fil, 0)
BLKDEF(type_nod, nod, sizeof(((NOD) 0)->nod_arg[0]))
BLKDEF(type_msg, msg, 0)
BLKDEF(type_frb, frb, 0)
BLKDEF(type_hnk, hnk, 0)
BLKDEF(type_plb, plb, 0)
BLKDEF(type_vec, vec, sizeof(((VEC) 0)->vec_object[0]))
BLKDEF(type_vcl, vcl, sizeof(((VCL) 0)->vcl_long[0]))
BLKDEF(type_lls, lls, 0) /* linked list stack */
BLKDEF(type_str, str, 1) /* random string block */
BLKDEF(type_sym, sym, 1) /* symbol block */
BLKDEF(type_err, err, 0)
BLKDEF(type_opn, opn, 0)
BLKDEF(type_tra, tra, 0)
BLKDEF(type_udf, udf, 1)
BLKDEF(type_var, var, 1)
BLKDEF(type_blb, blb, 0)
BLKDEF(type_prc, prc, 1)
BLKDEF(type_intlsym, intlsym, 1)

277
src/dsql/blob.e Normal file
View File

@ -0,0 +1,277 @@
/*
* PROGRAM: InterBase layered support library
* MODULE: blob.e
* DESCRIPTION: Dynamic blob support
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include "../jrd/common.h"
#include <stdarg.h>
#include "../include/jrd/gds.h"
#include "../jrd/intl.h"
#include "../jrd/constants.h"
#include "../dsql/blob_proto.h"
DATABASE DB = STATIC "yachts.lnk";
static STATUS copy_status(STATUS *, STATUS *);
static STATUS error(STATUS *, SSHORT, ...);
static void get_name(UCHAR *, UCHAR *);
void API_ROUTINE isc_blob_default_desc(
ISC_BLOB_DESC * desc,
UCHAR * relation_name,
UCHAR * field_name)
{
/**************************************
*
* i s c _ b l o b _ d e f a u l t _ d e s c
*
**************************************
*
* Functional description
*
* This function will set the default
* values in the blob_descriptor.
*
**************************************/
desc->blob_desc_subtype = BLOB_text;
desc->blob_desc_charset = CS_dynamic;
desc->blob_desc_segment_size = 80;
get_name(field_name, desc->blob_desc_field_name);
get_name(relation_name, desc->blob_desc_relation_name);
}
STATUS API_ROUTINE isc_blob_gen_bpb(
STATUS * status,
ISC_BLOB_DESC * to_desc,
ISC_BLOB_DESC * from_desc,
USHORT bpb_buffer_length, UCHAR * bpb_buffer, USHORT * bpb_length)
{
/**************************************
*
* i s c _ b l o b _ g e n _ b p b
*
**************************************
*
* Functional description
*
* This function will generate a bpb
* given a to_desc and a from_desc
* which contain the subtype and
* character set information.
*
**************************************/
UCHAR *p;
if (bpb_buffer_length < 17)
return error(status, 3, (STATUS) gds__random,
(STATUS) gds_arg_string,
(STATUS) "BPB buffer too small");
p = bpb_buffer;
*p++ = isc_bpb_version1;
*p++ = isc_bpb_target_type;
*p++ = 2;
*p++ = (UCHAR)to_desc->blob_desc_subtype;
*p++ = (UCHAR)(to_desc->blob_desc_subtype >> 8);
*p++ = isc_bpb_source_type;
*p++ = 2;
*p++ = (UCHAR)from_desc->blob_desc_subtype;
*p++ = (UCHAR)(from_desc->blob_desc_subtype >> 8);
*p++ = isc_bpb_target_interp;
*p++ = 2;
*p++ = (UCHAR)to_desc->blob_desc_charset;
*p++ = (UCHAR)(to_desc->blob_desc_charset >> 8);
*p++ = isc_bpb_source_interp;
*p++ = 2;
*p++ = (UCHAR)from_desc->blob_desc_charset;
*p++ = (UCHAR)(from_desc->blob_desc_charset >> 8);
*bpb_length = p - bpb_buffer;
return error(status, 1, (STATUS) SUCCESS);
}
STATUS API_ROUTINE isc_blob_lookup_desc(STATUS * status,
void **db_handle,
void **trans_handle,
UCHAR * relation_name,
UCHAR * field_name,
ISC_BLOB_DESC * desc, UCHAR * global)
{
/***********************************************
*
* i s c _ b l o b _ l o o k u p _ d e s c
*
***********************************************
*
* Functional description
*
* This routine will lookup the subtype,
* character set and segment size information
* from the metadata, given a relation name
* and column name. it will fill in the information
* in the BLOB_DESC.
*
***********************************************/
SSHORT flag;
if (DB && DB != *db_handle)
RELEASE_REQUESTS;
DB = *db_handle;
gds__trans = *trans_handle;
get_name(field_name, desc->blob_desc_field_name);
get_name(relation_name, desc->blob_desc_relation_name);
flag = FALSE;
FOR X IN RDB$RELATION_FIELDS CROSS Y IN RDB$FIELDS
WITH X.RDB$FIELD_SOURCE EQ Y.RDB$FIELD_NAME AND
X.RDB$RELATION_NAME EQ desc->blob_desc_relation_name AND
X.RDB$FIELD_NAME EQ desc->blob_desc_field_name flag = TRUE;
desc->blob_desc_subtype = Y.RDB$FIELD_SUB_TYPE;
desc->blob_desc_charset = Y.RDB$CHARACTER_SET_ID;
desc->blob_desc_segment_size = Y.RDB$SEGMENT_LENGTH;
if (global)
get_name((UCHAR *) Y.RDB$FIELD_NAME, global);
END_FOR ON_ERROR return copy_status(gds__status, status);
END_ERROR;
if (!flag)
return error(status, 5, (STATUS) gds__fldnotdef,
(STATUS) gds_arg_string,
(STATUS) desc->blob_desc_field_name,
(STATUS) gds_arg_string,
(STATUS) desc->blob_desc_relation_name);
return error(status, 1, (STATUS) SUCCESS);
}
STATUS API_ROUTINE isc_blob_set_desc(STATUS * status,
UCHAR * relation_name,
UCHAR * field_name,
SSHORT subtype,
SSHORT charset,
SSHORT segment_size,
ISC_BLOB_DESC * desc)
{
/**************************************
*
* i s c _ b l o b _ s e t _ d e s c
*
**************************************
*
* Functional description
*
* This routine will set the subtype
* and character set information in the
* BLOB_DESC based on the information
* specifically passed in by the user.
*
**************************************/
get_name(field_name, desc->blob_desc_field_name);
get_name(relation_name, desc->blob_desc_relation_name);
desc->blob_desc_subtype = subtype;
desc->blob_desc_charset = charset;
desc->blob_desc_segment_size = segment_size;
return error(status, 1, (STATUS) SUCCESS);
}
static STATUS copy_status( STATUS * from, STATUS * to)
{
/**************************************
*
* c o p y _ s t a t u s
*
**************************************
*
* Functional description
* Copy a status vector.
*
**************************************/
STATUS status, *end;
status = from[1];
for (end = from + 20; from < end;)
*to++ = *from++;
return status;
}
static STATUS error( STATUS * status, SSHORT count, ...)
{
/**************************************
*
* e r r o r
*
**************************************
*
* Functional description
* Stuff a status vector.
*
**************************************/
STATUS *stat;
va_list ptr;
VA_START(ptr, count);
stat = status;
*stat++ = gds_arg_gds;
for (; count; --count)
*stat++ = (STATUS) va_arg(ptr, STATUS);
*stat = gds_arg_end;
return status[1];
}
static void get_name( UCHAR * from, UCHAR * to)
{
/**************************************
*
* g e t _ n a m e
*
**************************************
*
* Functional description
* Copy null or blank terminated name.
*
**************************************/
while (*from && *from != ' ')
*to++ = *from++;
*to = 0;
}

37
src/dsql/blob_proto.h Normal file
View File

@ -0,0 +1,37 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: blob_proto.h
* DESCRIPTION: Prototype Header file for blob.e
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_BLOB_PROTO_H_
#define _DSQL_BLOB_PROTO_H_
extern STATUS API_ROUTINE isc_blob_gen_bpb(STATUS *, ISC_BLOB_DESC *,
ISC_BLOB_DESC *, USHORT, UCHAR *,
USHORT *);
extern STATUS API_ROUTINE isc_blob_lookup_desc(STATUS *, void **, void **,
UCHAR *, UCHAR *,
ISC_BLOB_DESC *, UCHAR *);
extern STATUS API_ROUTINE isc_blob_set_desc(STATUS *, UCHAR *, UCHAR *,
SSHORT, SSHORT, SSHORT,
ISC_BLOB_DESC *);
#endif /*_DSQL_BLOB_PROTO_H_ */

289
src/dsql/chars.h Normal file
View File

@ -0,0 +1,289 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: chars.h
* DESCRIPTION: character classification
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#define CHR_LETTER 1
#define CHR_DIGIT 2
#define CHR_IDENT 4
#define CHR_QUOTE 8
#define CHR_WHITE 16
#define CHR_HEX 32
#define CHR_INTRODUCER 64
static CONST SCHAR classes[] = {
/* 000 */ 0,
/* 001 */ 0,
/* 002 */ 0,
/* 003 */ 0,
/* 004 */ 0,
/* 005 */ 0,
/* 006 */ 0,
/* 007 */ 0,
/* 008 */ 0,
/* 009 */ 0 | CHR_WHITE,
/* 010 */ 0 | CHR_WHITE,
/* 011 */ 0,
/* 012 */ 0,
/* 013 */ 0 | CHR_WHITE,
/* 014 */ 0,
/* 015 */ 0,
/* 016 */ 0,
/* 017 */ 0,
/* 018 */ 0,
/* 019 */ 0,
/* 020 */ 0,
/* 021 */ 0,
/* 022 */ 0,
/* 023 */ 0,
/* 024 */ 0,
/* 025 */ 0,
/* 026 */ 0,
/* 027 */ 0,
/* 028 */ 0,
/* 029 */ 0,
/* 030 */ 0,
/* 031 */ 0,
/* 032 */ 0 | CHR_WHITE,
/* 033 ! */ 0,
/* 034 " */ 0 | CHR_QUOTE,
/* 035 # */ 0,
/* 036 $ */ 0 | CHR_IDENT,
/* 037 % */ 0,
/* 038 & */ 0,
/* 039 ' */ 0 | CHR_QUOTE,
/* 040 ( */ 0,
/* 041 ) */ 0,
/* 042 * */ 0,
/* 043 + */ 0,
/* 044 , */ 0,
/* 045 - */ 0,
/* 046 . */ 0,
/* 047 / */ 0,
/* 048 0 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 049 1 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 050 2 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 051 3 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 052 4 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 053 5 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 054 6 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 055 7 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 056 8 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 057 9 */ 0 | CHR_DIGIT | CHR_IDENT | CHR_HEX,
/* 058 : */ 0,
/* 059 ; */ 0,
/* 060 < */ 0,
/* 061 = */ 0,
/* 062 > */ 0,
/* 063 ? */ 0,
/* 064 @ */ 0,
/* 065 A */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 066 B */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 067 C */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 068 D */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 069 E */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 070 F */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 071 G */ 0 | CHR_LETTER | CHR_IDENT,
/* 072 H */ 0 | CHR_LETTER | CHR_IDENT,
/* 073 I */ 0 | CHR_LETTER | CHR_IDENT,
/* 074 J */ 0 | CHR_LETTER | CHR_IDENT,
/* 075 K */ 0 | CHR_LETTER | CHR_IDENT,
/* 076 L */ 0 | CHR_LETTER | CHR_IDENT,
/* 077 M */ 0 | CHR_LETTER | CHR_IDENT,
/* 078 N */ 0 | CHR_LETTER | CHR_IDENT,
/* 079 O */ 0 | CHR_LETTER | CHR_IDENT,
/* 080 P */ 0 | CHR_LETTER | CHR_IDENT,
/* 081 Q */ 0 | CHR_LETTER | CHR_IDENT,
/* 082 R */ 0 | CHR_LETTER | CHR_IDENT,
/* 083 S */ 0 | CHR_LETTER | CHR_IDENT,
/* 084 T */ 0 | CHR_LETTER | CHR_IDENT,
/* 085 U */ 0 | CHR_LETTER | CHR_IDENT,
/* 086 V */ 0 | CHR_LETTER | CHR_IDENT,
/* 087 W */ 0 | CHR_LETTER | CHR_IDENT,
/* 088 X */ 0 | CHR_LETTER | CHR_IDENT,
/* 089 Y */ 0 | CHR_LETTER | CHR_IDENT,
/* 090 Z */ 0 | CHR_LETTER | CHR_IDENT,
/* 091 [ */ 0,
/* 092 \ */ 0,
/* 093 ] */ 0,
/* 094 ^ */ 0,
/* 095 _ */ 0 | CHR_IDENT | CHR_INTRODUCER,
/* 096 ` */ 0,
/* 097 a */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 098 b */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 099 c */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 100 d */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 101 e */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 102 f */ 0 | CHR_LETTER | CHR_IDENT | CHR_HEX,
/* 103 g */ 0 | CHR_LETTER | CHR_IDENT,
/* 104 h */ 0 | CHR_LETTER | CHR_IDENT,
/* 105 i */ 0 | CHR_LETTER | CHR_IDENT,
/* 106 j */ 0 | CHR_LETTER | CHR_IDENT,
/* 107 k */ 0 | CHR_LETTER | CHR_IDENT,
/* 108 l */ 0 | CHR_LETTER | CHR_IDENT,
/* 109 m */ 0 | CHR_LETTER | CHR_IDENT,
/* 110 n */ 0 | CHR_LETTER | CHR_IDENT,
/* 111 o */ 0 | CHR_LETTER | CHR_IDENT,
/* 112 p */ 0 | CHR_LETTER | CHR_IDENT,
/* 113 q */ 0 | CHR_LETTER | CHR_IDENT,
/* 114 r */ 0 | CHR_LETTER | CHR_IDENT,
/* 115 s */ 0 | CHR_LETTER | CHR_IDENT,
/* 116 t */ 0 | CHR_LETTER | CHR_IDENT,
/* 117 u */ 0 | CHR_LETTER | CHR_IDENT,
/* 118 v */ 0 | CHR_LETTER | CHR_IDENT,
/* 119 w */ 0 | CHR_LETTER | CHR_IDENT,
/* 120 x */ 0 | CHR_LETTER | CHR_IDENT,
/* 121 y */ 0 | CHR_LETTER | CHR_IDENT,
/* 122 z */ 0 | CHR_LETTER | CHR_IDENT,
/* 123 { */ 0 | CHR_LETTER | CHR_IDENT,
/* 124 | */ 0,
/* 125 } */ 0 | CHR_LETTER | CHR_IDENT,
/* 126 ~ */ 0,
/* 127 */ 0,
/* 128 */ 0,
/* 129 */ 0,
/* 130 */ 0,
/* 131 */ 0,
/* 132 */ 0,
/* 133 */ 0,
/* 134 */ 0,
/* 135 */ 0,
/* 136 */ 0,
/* 137 */ 0,
/* 138 */ 0,
/* 139 */ 0,
/* 140 */ 0,
/* 141 */ 0,
/* 142 */ 0,
/* 143 */ 0,
/* 144 */ 0,
/* 145 */ 0,
/* 146 */ 0,
/* 147 */ 0,
/* 148 */ 0,
/* 149 */ 0,
/* 150 */ 0,
/* 151 */ 0,
/* 152 */ 0,
/* 153 */ 0,
/* 154 */ 0,
/* 155 */ 0,
/* 156 */ 0,
/* 157 */ 0,
/* 158 */ 0,
/* 159 */ 0,
/* 160 */ 0,
/* 161 */ 0,
/* 162 */ 0,
/* 163 */ 0,
/* 164 */ 0,
/* 165 */ 0,
/* 166 */ 0,
/* 167 */ 0,
/* 168 */ 0,
/* 169 */ 0,
/* 170 */ 0,
/* 171 */ 0,
/* 172 */ 0,
/* 173 */ 0,
/* 174 */ 0,
/* 175 */ 0,
/* 176 */ 0,
/* 177 */ 0,
/* 178 */ 0,
/* 179 */ 0,
/* 180 */ 0,
/* 181 */ 0,
/* 182 */ 0,
/* 183 */ 0,
/* 184 */ 0,
/* 185 */ 0,
/* 186 */ 0,
/* 187 */ 0,
/* 188 */ 0,
/* 189 */ 0,
/* 190 */ 0,
/* 191 */ 0,
/* 192 */ 0,
/* 193 */ 0,
/* 194 */ 0,
/* 195 */ 0,
/* 196 */ 0,
/* 197 */ 0,
/* 198 */ 0,
/* 199 */ 0,
/* 200 */ 0,
/* 201 */ 0,
/* 202 */ 0,
/* 203 */ 0,
/* 204 */ 0,
/* 205 */ 0,
/* 206 */ 0,
/* 207 */ 0,
/* 208 */ 0,
/* 209 */ 0,
/* 210 */ 0,
/* 211 */ 0,
/* 212 */ 0,
/* 213 */ 0,
/* 214 */ 0,
/* 215 */ 0,
/* 216 */ 0,
/* 217 */ 0,
/* 218 */ 0,
/* 219 */ 0,
/* 220 */ 0,
/* 221 */ 0,
/* 222 */ 0,
/* 223 */ 0,
/* 224 */ 0,
/* 225 */ 0,
/* 226 */ 0,
/* 227 */ 0,
/* 228 */ 0,
/* 229 */ 0,
/* 230 */ 0,
/* 231 */ 0,
/* 232 */ 0,
/* 233 */ 0,
/* 234 */ 0,
/* 235 */ 0,
/* 236 */ 0,
/* 237 */ 0,
/* 238 */ 0,
/* 239 */ 0,
/* 240 */ 0,
/* 241 */ 0,
/* 242 */ 0,
/* 243 */ 0,
/* 244 */ 0,
/* 245 */ 0,
/* 246 */ 0,
/* 247 */ 0,
/* 248 */ 0,
/* 249 */ 0,
/* 250 */ 0,
/* 251 */ 0,
/* 252 */ 0,
/* 253 */ 0,
/* 254 */ 0,
/* 255 */ 0
};

5526
src/dsql/ddl.cpp Normal file

File diff suppressed because it is too large Load Diff

41
src/dsql/ddl_proto.h Normal file
View File

@ -0,0 +1,41 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: ddl_proto.h
* DESCRIPTION: Prototype Header file for ddl_proto.h
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_DDL_PROTO_H_
#define _DSQL_DDL_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
void DDL_execute(struct req *);
void DDL_generate(struct req *, struct nod *);
int DDL_ids(struct req *);
void DDL_put_field_dtype(struct req *, struct fld *, USHORT);
void DDL_resolve_intl_type(struct req *, struct fld *, struct str *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _DSQL_DDL_PROTO_H_ */

613
src/dsql/depends.mak Normal file
View File

@ -0,0 +1,613 @@
# The contents of this file are subject to the Interbase Public
# License Version 1.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy
# of the License at http://www.Inprise.com/IPL.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
# or implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code was created by Inprise Corporation
# and its predecessors. Portions created by Inprise Corporation are
# Copyright (C) Inprise Corporation.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
# depends.mak - dsql
# Created by 'make depends.mak'
# Created on 1998-11-17
alld.o: alld.c
alld.o: alld_proto.h
alld.o: blk.h
alld.o: dsql.h
alld.o: errd_proto.h
alld.o: node.h
alld.o: source/jrd/codes.h
alld.o: source/jrd/common.h
alld.o: source/jrd/dsc.h
alld.o: source/jrd/fil.h
alld.o: source/jrd/gds_proto.h
alld.o: source/jrd/gdsassert.h
alld.o: source/jrd/ibsetjmp.h
alld.o: source/jrd/isc.h
alld.o: source/jrd/thd.h
alld.o: source/jrd/thd_proto.h
alld.o: sym.h
array.o: array.c
array.o: array_proto.h
array.o: source/interbase/include/iberror.h
array.o: source/jrd/common.h
array.o: source/jrd/fil.h
array.o: source/jrd/gds.h
array.o: source/jrd/gds_proto.h
array.o: source/jrd/thd.h
blob.o: blob.c
blob.o: blob_proto.h
blob.o: source/interbase/include/iberror.h
blob.o: source/intl/charsets.h
blob.o: source/jrd/common.h
blob.o: source/jrd/constants.h
blob.o: source/jrd/gds.h
blob.o: source/jrd/intl.h
ddl.o: alld_proto.h
ddl.o: blk.h
ddl.o: ddl.c
ddl.o: ddl_proto.h
ddl.o: dsql.h
ddl.o: errd_proto.h
ddl.o: gen_proto.h
ddl.o: make_proto.h
ddl.o: metd_proto.h
ddl.o: node.h
ddl.o: pass1_proto.h
ddl.o: source/interbase/include/iberror.h
ddl.o: source/intl/charsets.h
ddl.o: source/jrd/codes.h
ddl.o: source/jrd/common.h
ddl.o: source/jrd/constants.h
ddl.o: source/jrd/dsc.h
ddl.o: source/jrd/flags.h
ddl.o: source/jrd/gds.h
ddl.o: source/jrd/ibsetjmp.h
ddl.o: source/jrd/intl.h
ddl.o: source/jrd/isc.h
ddl.o: source/jrd/sch_proto.h
ddl.o: source/jrd/thd.h
ddl.o: source/jrd/thd_proto.h
ddl.o: sym.h
dsql.o: alld_proto.h
dsql.o: blk.h
dsql.o: ddl_proto.h
dsql.o: dsql.c
dsql.o: dsql.h
dsql.o: dsql_proto.h
dsql.o: errd_proto.h
dsql.o: gen_proto.h
dsql.o: hsh_proto.h
dsql.o: make_proto.h
dsql.o: movd_proto.h
dsql.o: node.h
dsql.o: parse_proto.h
dsql.o: pass1_proto.h
dsql.o: source/interbase/include/iberror.h
dsql.o: source/intl/charsets.h
dsql.o: source/jrd/align.h
dsql.o: source/jrd/common.h
dsql.o: source/jrd/dsc.h
dsql.o: source/jrd/fil.h
dsql.o: source/jrd/gds.h
dsql.o: source/jrd/gds_proto.h
dsql.o: source/jrd/ibsetjmp.h
dsql.o: source/jrd/intl.h
dsql.o: source/jrd/isc.h
dsql.o: source/jrd/sch_proto.h
dsql.o: source/jrd/thd.h
dsql.o: source/jrd/thd_proto.h
dsql.o: source/jrd/why_proto.h
dsql.o: sqlda.h
dsql.o: sym.h
dsqlwep.o: dsqlwep.c
dsqlwep.o: source/jrd/common.h
errd.o: blk.h
errd.o: dsql.h
errd.o: errd.c
errd.o: errd_proto.h
errd.o: source/jrd/codes.h
errd.o: source/jrd/common.h
errd.o: source/jrd/dsc.h
errd.o: source/jrd/fil.h
errd.o: source/jrd/gds_proto.h
errd.o: source/jrd/iberr.h
errd.o: source/jrd/ibsetjmp.h
errd.o: source/jrd/isc.h
errd.o: source/jrd/thd.h
errd.o: source/jrd/thd_proto.h
errd.o: sqlda.h
errd.o: utld_proto.h
gen.o: alld_proto.h
gen.o: blk.h
gen.o: ddl_proto.h
gen.o: dsql.h
gen.o: errd_proto.h
gen.o: gen.c
gen.o: gen_proto.h
gen.o: make_proto.h
gen.o: metd_proto.h
gen.o: node.h
gen.o: source/interbase/include/iberror.h
gen.o: source/intl/charsets.h
gen.o: source/jrd/align.h
gen.o: source/jrd/common.h
gen.o: source/jrd/dsc.h
gen.o: source/jrd/gds.h
gen.o: source/jrd/ibsetjmp.h
gen.o: source/jrd/intl.h
gen.o: source/jrd/isc.h
gen.o: source/jrd/thd.h
gen.o: source/jrd/thd_proto.h
gen.o: sym.h
hsh.o: alld_proto.h
hsh.o: blk.h
hsh.o: dsql.h
hsh.o: errd_proto.h
hsh.o: hsh.c
hsh.o: hsh_proto.h
hsh.o: source/interbase/include/iberror.h
hsh.o: source/jrd/common.h
hsh.o: source/jrd/dsc.h
hsh.o: source/jrd/gds.h
hsh.o: source/jrd/ibsetjmp.h
hsh.o: source/jrd/isc.h
hsh.o: source/jrd/sch_proto.h
hsh.o: source/jrd/thd.h
hsh.o: source/jrd/thd_proto.h
hsh.o: sym.h
make.o: alld_proto.h
make.o: blk.h
make.o: dsql.h
make.o: errd_proto.h
make.o: hsh_proto.h
make.o: make.c
make.o: make_proto.h
make.o: node.h
make.o: source/interbase/include/iberror.h
make.o: source/intl/charsets.h
make.o: source/jrd/align.h
make.o: source/jrd/common.h
make.o: source/jrd/constants.h
make.o: source/jrd/dsc.h
make.o: source/jrd/dsc_proto.h
make.o: source/jrd/gds.h
make.o: source/jrd/ibsetjmp.h
make.o: source/jrd/intl.h
make.o: source/jrd/isc.h
make.o: source/jrd/thd.h
make.o: source/jrd/thd_proto.h
make.o: sym.h
metd.o: alld_proto.h
metd.o: blk.h
metd.o: ddl_proto.h
metd.o: dsql.h
metd.o: hsh_proto.h
metd.o: make_proto.h
metd.o: metd.c
metd.o: metd_proto.h
metd.o: node.h
metd.o: source/interbase/include/iberror.h
metd.o: source/intl/charsets.h
metd.o: source/jrd/align.h
metd.o: source/jrd/common.h
metd.o: source/jrd/constants.h
metd.o: source/jrd/dsc.h
metd.o: source/jrd/fil.h
metd.o: source/jrd/gds.h
metd.o: source/jrd/gds_proto.h
metd.o: source/jrd/ibsetjmp.h
metd.o: source/jrd/intl.h
metd.o: source/jrd/isc.h
metd.o: source/jrd/sch_proto.h
metd.o: source/jrd/thd.h
metd.o: source/jrd/thd_proto.h
metd.o: sym.h
movd.o: blk.h
movd.o: dsql.h
movd.o: errd_proto.h
movd.o: movd.c
movd.o: movd_proto.h
movd.o: source/jrd/codes.h
movd.o: source/jrd/common.h
movd.o: source/jrd/cvt_proto.h
movd.o: source/jrd/dsc.h
movd.o: source/jrd/iberr.h
movd.o: source/jrd/ibsetjmp.h
movd.o: source/jrd/isc.h
movd.o: source/jrd/thd.h
movd.o: source/jrd/thd_proto.h
parse.o: alld_proto.h
parse.o: blk.h
parse.o: chars.h
parse.o: dsql.h
parse.o: errd_proto.h
parse.o: hsh_proto.h
parse.o: keywords.h
parse.o: make_proto.h
parse.o: node.h
parse.o: parse.c
parse.o: parse_proto.h
parse.o: source/interbase/include/iberror.h
parse.o: source/jrd/common.h
parse.o: source/jrd/dsc.h
parse.o: source/jrd/fil.h
parse.o: source/jrd/flags.h
parse.o: source/jrd/gds.h
parse.o: source/jrd/gds_proto.h
parse.o: source/jrd/ibsetjmp.h
parse.o: source/jrd/isc.h
parse.o: source/jrd/misc.h
parse.o: source/jrd/thd.h
parse.o: source/jrd/thd_proto.h
parse.o: source/wal/wal.h
parse.o: sym.h
pass1.o: alld_proto.h
pass1.o: blk.h
pass1.o: ddl_proto.h
pass1.o: dsql.h
pass1.o: errd_proto.h
pass1.o: hsh_proto.h
pass1.o: make_proto.h
pass1.o: metd_proto.h
pass1.o: node.h
pass1.o: pass1.c
pass1.o: pass1_proto.h
pass1.o: source/intl/charsets.h
pass1.o: source/jrd/blr.h
pass1.o: source/jrd/codes.h
pass1.o: source/jrd/common.h
pass1.o: source/jrd/dsc.h
pass1.o: source/jrd/dsc_proto.h
pass1.o: source/jrd/ibsetjmp.h
pass1.o: source/jrd/intl.h
pass1.o: source/jrd/isc.h
pass1.o: source/jrd/thd.h
pass1.o: source/jrd/thd_proto.h
pass1.o: sym.h
preparse.o: chars.h
preparse.o: prepa_proto.h
preparse.o: preparse.c
preparse.o: source/interbase/include/iberror.h
preparse.o: source/jrd/common.h
preparse.o: source/jrd/fil.h
preparse.o: source/jrd/gds.h
preparse.o: source/jrd/gds_proto.h
preparse.o: source/jrd/thd.h
preparse.o: utld_proto.h
user_dsql.o: blk.h
user_dsql.o: chars.h
user_dsql.o: dsql.h
user_dsql.o: source/jrd/align.h
user_dsql.o: source/jrd/blr.h
user_dsql.o: source/jrd/codes.h
user_dsql.o: source/jrd/common.h
user_dsql.o: source/jrd/dsc.h
user_dsql.o: source/jrd/fil.h
user_dsql.o: source/jrd/gds_proto.h
user_dsql.o: source/jrd/ibsetjmp.h
user_dsql.o: source/jrd/inf.h
user_dsql.o: source/jrd/thd.h
user_dsql.o: source/jrd/why_proto.h
user_dsql.o: sqlda.h
user_dsql.o: user__proto.h
user_dsql.o: user_dsql.c
utld.o: blk.h
utld.o: dsql.h
utld.o: source/jrd/align.h
utld.o: source/jrd/blr.h
utld.o: source/jrd/codes.h
utld.o: source/jrd/common.h
utld.o: source/jrd/dsc.h
utld.o: source/jrd/fil.h
utld.o: source/jrd/gds_proto.h
utld.o: source/jrd/ibsetjmp.h
utld.o: source/jrd/inf.h
utld.o: source/jrd/thd.h
utld.o: sqlda.h
utld.o: utld.c
utld.o: utld_proto.h
alld.bin: alld.c
alld.bin: alld_proto.h
alld.bin: blk.h
alld.bin: dsql.h
alld.bin: errd_proto.h
alld.bin: node.h
alld.bin: source/jrd/codes.h
alld.bin: source/jrd/common.h
alld.bin: source/jrd/dsc.h
alld.bin: source/jrd/fil.h
alld.bin: source/jrd/gds_proto.h
alld.bin: source/jrd/gdsassert.h
alld.bin: source/jrd/ibsetjmp.h
alld.bin: source/jrd/isc.h
alld.bin: source/jrd/thd.h
alld.bin: source/jrd/thd_proto.h
alld.bin: sym.h
array.bin: array.c
array.bin: array_proto.h
array.bin: source/interbase/include/iberror.h
array.bin: source/jrd/common.h
array.bin: source/jrd/fil.h
array.bin: source/jrd/gds.h
array.bin: source/jrd/gds_proto.h
array.bin: source/jrd/thd.h
blob.bin: blob.c
blob.bin: blob_proto.h
blob.bin: source/interbase/include/iberror.h
blob.bin: source/intl/charsets.h
blob.bin: source/jrd/common.h
blob.bin: source/jrd/constants.h
blob.bin: source/jrd/gds.h
blob.bin: source/jrd/intl.h
ddl.bin: alld_proto.h
ddl.bin: blk.h
ddl.bin: ddl.c
ddl.bin: ddl_proto.h
ddl.bin: dsql.h
ddl.bin: errd_proto.h
ddl.bin: gen_proto.h
ddl.bin: make_proto.h
ddl.bin: metd_proto.h
ddl.bin: node.h
ddl.bin: pass1_proto.h
ddl.bin: source/interbase/include/iberror.h
ddl.bin: source/intl/charsets.h
ddl.bin: source/jrd/codes.h
ddl.bin: source/jrd/common.h
ddl.bin: source/jrd/constants.h
ddl.bin: source/jrd/dsc.h
ddl.bin: source/jrd/flags.h
ddl.bin: source/jrd/gds.h
ddl.bin: source/jrd/ibsetjmp.h
ddl.bin: source/jrd/intl.h
ddl.bin: source/jrd/isc.h
ddl.bin: source/jrd/sch_proto.h
ddl.bin: source/jrd/thd.h
ddl.bin: source/jrd/thd_proto.h
ddl.bin: sym.h
dsql.bin: alld_proto.h
dsql.bin: blk.h
dsql.bin: ddl_proto.h
dsql.bin: dsql.c
dsql.bin: dsql.h
dsql.bin: dsql_proto.h
dsql.bin: errd_proto.h
dsql.bin: gen_proto.h
dsql.bin: hsh_proto.h
dsql.bin: make_proto.h
dsql.bin: movd_proto.h
dsql.bin: node.h
dsql.bin: parse_proto.h
dsql.bin: pass1_proto.h
dsql.bin: source/interbase/include/iberror.h
dsql.bin: source/intl/charsets.h
dsql.bin: source/jrd/align.h
dsql.bin: source/jrd/common.h
dsql.bin: source/jrd/dsc.h
dsql.bin: source/jrd/fil.h
dsql.bin: source/jrd/gds.h
dsql.bin: source/jrd/gds_proto.h
dsql.bin: source/jrd/ibsetjmp.h
dsql.bin: source/jrd/intl.h
dsql.bin: source/jrd/isc.h
dsql.bin: source/jrd/sch_proto.h
dsql.bin: source/jrd/thd.h
dsql.bin: source/jrd/thd_proto.h
dsql.bin: source/jrd/why_proto.h
dsql.bin: sqlda.h
dsql.bin: sym.h
dsqlwep.bin: dsqlwep.c
dsqlwep.bin: source/jrd/common.h
errd.bin: blk.h
errd.bin: dsql.h
errd.bin: errd.c
errd.bin: errd_proto.h
errd.bin: source/jrd/codes.h
errd.bin: source/jrd/common.h
errd.bin: source/jrd/dsc.h
errd.bin: source/jrd/fil.h
errd.bin: source/jrd/gds_proto.h
errd.bin: source/jrd/iberr.h
errd.bin: source/jrd/ibsetjmp.h
errd.bin: source/jrd/isc.h
errd.bin: source/jrd/thd.h
errd.bin: source/jrd/thd_proto.h
errd.bin: sqlda.h
errd.bin: utld_proto.h
gen.bin: alld_proto.h
gen.bin: blk.h
gen.bin: ddl_proto.h
gen.bin: dsql.h
gen.bin: errd_proto.h
gen.bin: gen.c
gen.bin: gen_proto.h
gen.bin: make_proto.h
gen.bin: metd_proto.h
gen.bin: node.h
gen.bin: source/interbase/include/iberror.h
gen.bin: source/intl/charsets.h
gen.bin: source/jrd/align.h
gen.bin: source/jrd/common.h
gen.bin: source/jrd/dsc.h
gen.bin: source/jrd/gds.h
gen.bin: source/jrd/ibsetjmp.h
gen.bin: source/jrd/intl.h
gen.bin: source/jrd/isc.h
gen.bin: source/jrd/thd.h
gen.bin: source/jrd/thd_proto.h
gen.bin: sym.h
hsh.bin: alld_proto.h
hsh.bin: blk.h
hsh.bin: dsql.h
hsh.bin: errd_proto.h
hsh.bin: hsh.c
hsh.bin: hsh_proto.h
hsh.bin: source/interbase/include/iberror.h
hsh.bin: source/jrd/common.h
hsh.bin: source/jrd/dsc.h
hsh.bin: source/jrd/gds.h
hsh.bin: source/jrd/ibsetjmp.h
hsh.bin: source/jrd/isc.h
hsh.bin: source/jrd/sch_proto.h
hsh.bin: source/jrd/thd.h
hsh.bin: source/jrd/thd_proto.h
hsh.bin: sym.h
make.bin: alld_proto.h
make.bin: blk.h
make.bin: dsql.h
make.bin: errd_proto.h
make.bin: hsh_proto.h
make.bin: make.c
make.bin: make_proto.h
make.bin: node.h
make.bin: source/interbase/include/iberror.h
make.bin: source/intl/charsets.h
make.bin: source/jrd/align.h
make.bin: source/jrd/common.h
make.bin: source/jrd/constants.h
make.bin: source/jrd/dsc.h
make.bin: source/jrd/dsc_proto.h
make.bin: source/jrd/gds.h
make.bin: source/jrd/ibsetjmp.h
make.bin: source/jrd/intl.h
make.bin: source/jrd/isc.h
make.bin: source/jrd/thd.h
make.bin: source/jrd/thd_proto.h
make.bin: sym.h
metd.bin: alld_proto.h
metd.bin: blk.h
metd.bin: ddl_proto.h
metd.bin: dsql.h
metd.bin: hsh_proto.h
metd.bin: make_proto.h
metd.bin: metd.c
metd.bin: metd_proto.h
metd.bin: node.h
metd.bin: source/interbase/include/iberror.h
metd.bin: source/intl/charsets.h
metd.bin: source/jrd/align.h
metd.bin: source/jrd/common.h
metd.bin: source/jrd/constants.h
metd.bin: source/jrd/dsc.h
metd.bin: source/jrd/fil.h
metd.bin: source/jrd/gds.h
metd.bin: source/jrd/gds_proto.h
metd.bin: source/jrd/ibsetjmp.h
metd.bin: source/jrd/intl.h
metd.bin: source/jrd/isc.h
metd.bin: source/jrd/sch_proto.h
metd.bin: source/jrd/thd.h
metd.bin: source/jrd/thd_proto.h
metd.bin: sym.h
movd.bin: blk.h
movd.bin: dsql.h
movd.bin: errd_proto.h
movd.bin: movd.c
movd.bin: movd_proto.h
movd.bin: source/jrd/codes.h
movd.bin: source/jrd/common.h
movd.bin: source/jrd/cvt_proto.h
movd.bin: source/jrd/dsc.h
movd.bin: source/jrd/iberr.h
movd.bin: source/jrd/ibsetjmp.h
movd.bin: source/jrd/isc.h
movd.bin: source/jrd/thd.h
movd.bin: source/jrd/thd_proto.h
parse.bin: alld_proto.h
parse.bin: blk.h
parse.bin: chars.h
parse.bin: dsql.h
parse.bin: errd_proto.h
parse.bin: hsh_proto.h
parse.bin: keywords.h
parse.bin: make_proto.h
parse.bin: node.h
parse.bin: parse.c
parse.bin: parse_proto.h
parse.bin: source/interbase/include/iberror.h
parse.bin: source/jrd/common.h
parse.bin: source/jrd/dsc.h
parse.bin: source/jrd/fil.h
parse.bin: source/jrd/flags.h
parse.bin: source/jrd/gds.h
parse.bin: source/jrd/gds_proto.h
parse.bin: source/jrd/ibsetjmp.h
parse.bin: source/jrd/isc.h
parse.bin: source/jrd/misc.h
parse.bin: source/jrd/thd.h
parse.bin: source/jrd/thd_proto.h
parse.bin: source/wal/wal.h
parse.bin: sym.h
pass1.bin: alld_proto.h
pass1.bin: blk.h
pass1.bin: ddl_proto.h
pass1.bin: dsql.h
pass1.bin: errd_proto.h
pass1.bin: hsh_proto.h
pass1.bin: make_proto.h
pass1.bin: metd_proto.h
pass1.bin: node.h
pass1.bin: pass1.c
pass1.bin: pass1_proto.h
pass1.bin: source/intl/charsets.h
pass1.bin: source/jrd/blr.h
pass1.bin: source/jrd/codes.h
pass1.bin: source/jrd/common.h
pass1.bin: source/jrd/dsc.h
pass1.bin: source/jrd/dsc_proto.h
pass1.bin: source/jrd/ibsetjmp.h
pass1.bin: source/jrd/intl.h
pass1.bin: source/jrd/isc.h
pass1.bin: source/jrd/thd.h
pass1.bin: source/jrd/thd_proto.h
pass1.bin: sym.h
preparse.bin: chars.h
preparse.bin: prepa_proto.h
preparse.bin: preparse.c
preparse.bin: source/interbase/include/iberror.h
preparse.bin: source/jrd/common.h
preparse.bin: source/jrd/fil.h
preparse.bin: source/jrd/gds.h
preparse.bin: source/jrd/gds_proto.h
preparse.bin: source/jrd/thd.h
preparse.bin: utld_proto.h
user_dsql.bin: blk.h
user_dsql.bin: chars.h
user_dsql.bin: dsql.h
user_dsql.bin: source/jrd/align.h
user_dsql.bin: source/jrd/blr.h
user_dsql.bin: source/jrd/codes.h
user_dsql.bin: source/jrd/common.h
user_dsql.bin: source/jrd/dsc.h
user_dsql.bin: source/jrd/fil.h
user_dsql.bin: source/jrd/gds_proto.h
user_dsql.bin: source/jrd/ibsetjmp.h
user_dsql.bin: source/jrd/inf.h
user_dsql.bin: source/jrd/thd.h
user_dsql.bin: source/jrd/why_proto.h
user_dsql.bin: sqlda.h
user_dsql.bin: user__proto.h
user_dsql.bin: user_dsql.c
utld.bin: blk.h
utld.bin: dsql.h
utld.bin: source/jrd/align.h
utld.bin: source/jrd/blr.h
utld.bin: source/jrd/codes.h
utld.bin: source/jrd/common.h
utld.bin: source/jrd/dsc.h
utld.bin: source/jrd/fil.h
utld.bin: source/jrd/gds_proto.h
utld.bin: source/jrd/ibsetjmp.h
utld.bin: source/jrd/inf.h
utld.bin: source/jrd/thd.h
utld.bin: sqlda.h
utld.bin: utld.c
utld.bin: utld_proto.h

3936
src/dsql/dsql.cpp Normal file

File diff suppressed because it is too large Load Diff

57
src/dsql/dsql.def Normal file
View File

@ -0,0 +1,57 @@
; The contents of this file are subject to the Interbase Public
; License Version 1.0 (the "License"); you may not use this file
; except in compliance with the License. You may obtain a copy
; of the License at http://www.Inprise.com/IPL.html
;
; Software distributed under the License is distributed on an
; "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
; or implied. See the License for the specific language governing
; rights and limitations under the License.
;
; The Original Code was created by Inprise Corporation
; and its predecessors. Portions created by Inprise Corporation are
; Copyright (C) Inprise Corporation.
;
; All Rights Reserved.
; Contributor(s): ______________________________________.
;------------------------------------------------------------
; DSQL DLL MODULE DEFINITION FILE
;------------------------------------------------------------
LIBRARY DSQL
DESCRIPTION 'DSQL INTERBASE MODULE'
CODE MOVEABLE
DATA MOVEABLE
SEGMENTS
_TEXT DISCARDABLE
ALLD_TEXT DISCARDABLE
DDL_TEXT DISCARDABLE
DSQL_TEXT DISCARDABLE
DSQLWEP_TEXT PRELOAD
ERRD_TEXT DISCARDABLE
GEN_TEXT DISCARDABLE
HSH_TEXT DISCARDABLE
MAKE_TEXT DISCARDABLE
METD_TEXT DISCARDABLE
MOVD_TEXT DISCARDABLE
PARSE_TEXT DISCARDABLE
PASS1_TEXT DISCARDABLE
CVT_TEXT DISCARDABLE
DLLSHELL_TEXT PRELOAD
EXPORTS
; ../DSQL/DSQL.C
_dsql8_sql_info @2
_dsql8_set_cursor @3
_dsql8_prepare @4
_dsql8_free_statement @5
_dsql8_fetch @6
_dsql8_execute_immediate @7
_dsql8_execute @8
_dsql8_allocate_statement @9
_dsql8_insert @10
;-----------------------------------------------
WEP @1 RESIDENTNAME

634
src/dsql/dsql.h Normal file
View File

@ -0,0 +1,634 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: dsql.h
* DESCRIPTION: General Definitions for V4 DSQL module
*
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_DSQL_H_
#define _DSQL_DSQL_H_
#include "../jrd/ibsetjmp.h"
#include "../jrd/common.h"
/* Dynamic SQL Error Status Block */
typedef struct err {
STATUS *dsql_status;
STATUS *dsql_user_status;
JMP_BUF dsql_env; /* Error return environment */
} *ERR;
/* macros for block allocation */
#define ALL_release(blk) ALLD_release (blk)
#define ALLOCD(type) ALLD_alloc (tdsql->tsql_default, type, 0)
#define ALLOCDV(type,repeat) ALLD_alloc (tdsql->tsql_default, type, repeat)
#define ALLOCP(type) ALLD_alloc (DSQL_permanent_pool, type, 0)
#define ALLOCPV(type,repeat) ALLD_alloc (DSQL_permanent_pool, type, repeat)
#define ALLOC(type,pool) ALLD_alloc (pool, type, 0)
#define ALLOCV(type,pool,repeat) ALLD_alloc (pool, type, repeat)
/* this table is used in data allocation to determine
whether a block has a variable length tail */
#define BLKDEF(type, root, tail) type,
ENUM blk_t {
type_MIN = 0,
#include "../dsql/blk.h"
type_MAX};
#undef BLKDEF
/* generic block used as header to all allocated structures */
#ifndef INCLUDE_FB_BLK
#include "../include/fb_blk.h"
#endif
/* aggregate blocks to store vectors of objects */
typedef struct vec {
struct blk vec_header;
ULONG vec_count;
struct blk *vec_object[1];
} *VEC;
typedef struct vcl {
struct blk vcl_header;
ULONG vcl_count;
SLONG vcl_long[1];
} *VCL;
/* generic structure used to store strings */
typedef struct str
{
struct blk str_header;
TEXT* str_charset; /* ASCIIZ Character set identifier for string */
USHORT str_flags;
USHORT str_length; /* length of string in BYTES */
UCHAR str_data[2]; /* one for ALLOC and one for the NULL */
} *STR;
/* values used in str_flags */
#define STR_delimited_id 0x1L
/* macros and block used to implement a generic stack mechanism */
#define LLS_PUSH(object,stack) ALLD_push ((BLK) object, stack)
#define LLS_POP(stack) ALLD_pop (stack)
typedef struct lls {
struct blk lls_header;
struct blk *lls_object;
struct lls *lls_next;
} *LLS;
/* blocks used internally to the data allocator */
/* free block used to point to an unused block */
typedef struct frb {
struct blk frb_header;
struct frb *frb_next; /* Next free block in pool */
} *FRB;
/* Pool block used to store a set of blocks to be treated as an aggregate */
typedef struct plb {
struct blk plb_header;
USHORT plb_pool_id; /* pool id */
struct frb *plb_free; /* first free block */
struct hnk *plb_hunks; /* first hunk block */
struct lls *plb_lls; /* available linked list stack nodes */
SLONG *plb_blk_type_count; /* array to keep track of block types */
} *PLB;
/* Hunk blocks, used to allow dynamic expansion of an allocated pool */
typedef struct hnk {
struct blk hnk_header;
UCHAR *hnk_address; /* start of memory hunk */
int hnk_length; /* length of memory hunk */
struct hnk *hnk_next; /* next memory hunk in structure */
} *HNK;
/*======================================================================
remaining node definitions for local processing
*/
/* Include definition of descriptor */
#include "../jrd/dsc.h"
/* internal DSQL requests */
#if 0
#define irq_relation 0 /* lookup a relation */
#define irq_fields 1 /* lookup a relation's fields */
#define irq_dimensions 2 /* lookup a field's dimensions */
#define irq_primary_key 3 /* lookup a primary key */
#define irq_view 4 /* lookup a view's base relations */
#define irq_function 5 /* lookup a user defined function */
#define irq_func_return 6 /* lookup a function's return argument */
#define irq_procedure 7 /* lookup a stored procedure */
#define irq_parameters 8 /* lookup a procedure's parameters */
#define irq_collation 9 /* lookup a collation name */
#define irq_charset 10 /* lookup a character set name */
#define irq_trigger 11 /* lookup a trigger */
#define irq_domain 12 /* lookup a domain */
#define irq_type 13 /* lookup a symbolic name in RDB$TYPES */
#define irq_col_default 14 /* lookup default for a column */
#define irq_domain_2 15 /* lookup a domain */
#define irq_MAX 16
#else
enum irq_type_t {
irq_relation = 0,
irq_fields = 1,
irq_dimensions = 2,
irq_primary_key = 3,
irq_view = 4,
irq_function = 5,
irq_func_return = 6,
irq_procedure = 7,
irq_parameters = 8,
irq_collation = 9,
irq_charset = 10,
irq_trigger = 11,
irq_domain = 12,
irq_type = 13,
irq_col_default = 14,
irq_domain_2 = 15,
irq_MAX = 16
};
#endif
/* blocks used to cache metadata */
typedef struct dbb { /* Database Block */
struct blk dbb_header;
struct dbb *dbb_next;
struct dsql_rel *dbb_relations; /* known relations in database */
struct prc *dbb_procedures; /* known procedures in database */
struct udf *dbb_functions; /* known functions in database */
struct plb *dbb_pool;
SLONG *dbb_database_handle;
SLONG *dbb_requests[irq_MAX];
struct str *dbb_dfl_charset;
USHORT dbb_base_level; /* indicates the version of the engine code itself */
USHORT dbb_flags;
USHORT dbb_db_SQL_dialect;
SSHORT dbb_att_charset; /* characterset at time of attachment */
} *DBB;
/* values used in dbb_flags */
#define DBB_no_arrays 0x1
#define DBB_v3 0x2
#define DBB_no_charset 0x4
#define DBB_read_only 0x8
typedef struct dsql_rel /* Relation block */
{
struct blk rel_header;
struct dsql_rel* rel_next; /* Next relation in database */
struct sym* rel_symbol; /* Hash symbol for relation */
struct fld* rel_fields; /* Field block */
struct dsql_rel* rel_base_relation; /* base relation for an updatable view */
TEXT* rel_name; /* Name of relation */
TEXT* rel_owner; /* Owner of relation */
USHORT rel_id; /* Relation id */
USHORT rel_dbkey_length;
USHORT rel_flags;
TEXT rel_data[3];
} *DSQL_REL;
/* rel_flags bits */
#define REL_new_relation 1 /* relation is newly defined, not committed yet */
#define REL_dropped 2 /* relation has been dropped */
typedef struct fld /* Field block */
{
struct blk fld_header;
struct fld* fld_next; /* Next field in relation */
struct dsql_rel* fld_relation; /* Parent relation */
struct prc* fld_procedure; /* Parent procedure */
struct nod* fld_ranges; /* ranges for multi dimension array */
struct nod* fld_character_set; /* null means not specified */
struct nod* fld_sub_type_name; /* Subtype name for later resolution */
USHORT fld_flags;
USHORT fld_id; /* Field in in database */
USHORT fld_dtype; /* Data type of field */
FLD_LENGTH fld_length; /* Length of field */
USHORT fld_element_dtype; /* Data type of array element */
USHORT fld_element_length; /* Length of array element */
SSHORT fld_scale; /* Scale factor of field */
SSHORT fld_sub_type; /* Subtype for text & blob fields */
USHORT fld_precision; /* Precision for exact numeric types */
USHORT fld_character_length; /* length of field in characters */
USHORT fld_seg_length; /* Segment length for blobs */
SSHORT fld_dimensions; /* Non-zero means array */
SSHORT fld_character_set_id; /* ID of field's character set */
SSHORT fld_collation_id; /* ID of field's collation */
SSHORT fld_ttype; /* ID of field's language_driver */
TEXT fld_name[2];
} *FLD;
/* values used in fld_flags */
#define FLD_computed 1
#define FLD_drop 2
#define FLD_dbkey 4
#define FLD_national 8 /* field uses NATIONAL character set */
#define FLD_nullable 16
#define MAX_ARRAY_DIMENSIONS 16 /* max array dimensions */
/* database/log/cache file block */
typedef struct fil {
struct blk fil_header;
SLONG fil_length; /* File length in pages */
SLONG fil_start; /* Starting page */
struct str *fil_name; /* File name */
struct fil *fil_next; /* next file */
SSHORT fil_shadow_number; /* shadow number if part of shadow */
SSHORT fil_manual; /* flag to indicate manual shadow */
SSHORT fil_partitions; /* number of log file partitions */
USHORT fil_flags;
} *FIL;
/* Stored Procedure block */
typedef struct prc { /* Relation block */
struct blk prc_header;
struct prc *prc_next; /* Next relation in database */
struct sym *prc_symbol; /* Hash symbol for procedure */
struct fld *prc_inputs; /* Input parameters */
struct fld *prc_outputs; /* Output parameters */
TEXT *prc_name; /* Name of procedure */
TEXT *prc_owner; /* Owner of procedure */
SSHORT prc_in_count;
SSHORT prc_out_count;
USHORT prc_id; /* Procedure id */
USHORT prc_flags;
TEXT prc_data[3];
} *PRC;
/* prc_flags bits */
#define PRC_new_procedure 1 /* procedure is newly defined, not committed yet */
#define PRC_dropped 2 /* procedure has been dropped */
/* User defined function block */
typedef struct udf {
struct blk udf_header;
struct udf *udf_next;
struct sym *udf_symbol; /* Hash symbol for udf */
USHORT udf_dtype;
SSHORT udf_scale;
SSHORT udf_sub_type;
USHORT udf_length;
SSHORT udf_character_set_id;
USHORT udf_character_length;
TEXT udf_name[2];
} *UDF;
/* these values are multiplied by -1 to indicate that server frees them
on return from the udf */
typedef ENUM {
FUN_value,
FUN_reference,
FUN_descriptor, FUN_blob_struct, FUN_scalar_array} FUN_T;
/* Variables - input, output & local */
typedef struct var { /* Variable block */
struct blk var_header;
struct fld *var_field; /* Field on which variable is based */
USHORT var_flags;
USHORT var_msg_number; /* Message number containing variable */
USHORT var_msg_item; /* Item number in message */
USHORT var_variable_number; /* Local variable number */
TEXT var_name[2];
} *VAR;
/* values used in var_flags */
#define VAR_input 1
#define VAR_output 2
#define VAR_local 4
/* Symbolic names for international text types */
/* (either collation or character set name) */
typedef struct intlsym { /* International symbol */
struct blk intlsym_header;
struct sym *intlsym_symbol; /* Hash symbol for intlsym */
USHORT intlsym_type; /* what type of name */
USHORT intlsym_flags;
SSHORT intlsym_ttype; /* id of implementation */
SSHORT intlsym_charset_id;
SSHORT intlsym_collate_id;
USHORT intlsym_bytes_per_char;
TEXT intlsym_name[2];
} *INTLSYM;
/* values used in intlsym_type */
#define INTLSYM_collation 1
#define INTLSYM_charset 2
/* values used in intlsym_flags */
/* Request information */
typedef enum {
REQ_SELECT, REQ_SELECT_UPD, REQ_INSERT, REQ_DELETE, REQ_UPDATE,
REQ_UPDATE_CURSOR, REQ_DELETE_CURSOR,
REQ_COMMIT, REQ_ROLLBACK, REQ_DDL, REQ_EMBED_SELECT,
REQ_START_TRANS, REQ_GET_SEGMENT, REQ_PUT_SEGMENT, REQ_EXEC_PROCEDURE,
REQ_COMMIT_RETAIN, REQ_SET_GENERATOR
} REQ_TYPE;
typedef struct req {
struct blk req_header;
struct req *req_parent; /* Source request, if cursor update */
struct req *req_sibling; /* Next sibling request, if cursor update */
struct req *req_offspring; /* Cursor update requests */
struct plb *req_pool;
struct lls *req_context;
struct sym *req_name; /* Name of request */
struct sym *req_cursor; /* Cursor symbol. if any */
struct dbb *req_dbb; /* Database handle */
int *req_trans; /* Database transaction handle */
struct opn *req_open_cursor;
struct nod *req_ddl_node; /* Store metadata request */
struct blb *req_blob; /* Blob info for blob requests */
int *req_handle; /* OSRI request handle */
struct str *req_blr_string; /* String block during BLR generation */
struct msg *req_send; /* Message to be sent to start request */
struct msg *req_receive; /* Per record message to be received */
struct msg *req_async; /* Message for sending scrolling information */
struct par *req_eof; /* End of file parameter */
struct par *req_dbkey; /* Database key for current of */
struct par *req_rec_version; /* Record Version for current of */
struct par *req_parent_rec_version; /* parent record version */
struct par *req_parent_dbkey; /* Parent database key for current of */
struct dsql_rel *req_relation; /* relation created by this request (for DDL) */
struct prc *req_procedure; /* procedure created by this request (for DDL) */
struct ctx *req_outer_agg_context; /* agg context for outer ref */
BLOB_PTR *req_blr; /* Running blr address */
BLOB_PTR *req_blr_yellow; /* Threshold for upping blr buffer size */
ULONG req_inserts; /* records processed in request */
ULONG req_deletes;
ULONG req_updates;
ULONG req_selects;
REQ_TYPE req_type; /* Type of request */
USHORT req_base_offset; /* place to go back and stuff in blr length */
USHORT req_context_number; /* Next available context number */
USHORT req_scope_level; /* Scope level for parsing aliases in subqueries */
USHORT req_message_number; /* Next available message number */
USHORT req_loop_number; /* Next available loop number */
SSHORT req_inhibit_map; /* Map inhibit count */
USHORT req_in_select_list; /* now processing "select list" */
USHORT req_in_where_clause; /* processing "where clause" */
USHORT req_in_having_clause; /* processing "having clause" */
USHORT req_in_order_by_clause; /* processing "order by clause" */
USHORT req_error_handlers; /* count of active error handlers */
USHORT req_flags; /* generic flag */
USHORT req_client_dialect; /* dialect passed into the API call */
} *REQ;
/* values used in req_flags */
#define REQ_cursor_open 1
#define REQ_save_metadata 2
#define REQ_prepared 4
#define REQ_embedded_sql_cursor 8
#define REQ_procedure 16
#define REQ_trigger 32
#define REQ_orphan 64
#define REQ_enforce_scope 128
#define REQ_no_batch 256
#define REQ_backwards 512
#define REQ_blr_version4 1024
#define REQ_blr_version5 2048
/* Blob */
typedef struct blb {
struct blk blb_header;
struct nod *blb_field; /* Related blob field */
struct par *blb_blob_id; /* Parameter to hold blob id */
struct par *blb_segment; /* Parameter for segments */
struct nod *blb_from;
struct nod *blb_to;
struct msg *blb_open_in_msg; /* Input message to open cursor */
struct msg *blb_open_out_msg; /* Output message from open cursor */
struct msg *blb_segment_msg; /* Segment message */
} *BLB;
/* List of open cursors */
typedef struct opn {
struct blk opn_header;
struct opn *opn_next; /* Next open cursor */
struct req *opn_request; /* Request owning the cursor */
SLONG *opn_transaction; /* Transaction executing request */
} *OPN;
/* Transaction block */
typedef struct tra {
struct blk tra_header;
struct tra *tra_next; /* Next open transaction */
} *TRA;
/* Context block used to create an instance of a relation reference */
typedef struct ctx {
struct blk ctx_header;
struct req *ctx_request; /* Parent request */
struct dsql_rel *ctx_relation; /* Relation for context */
struct prc *ctx_procedure; /* Procedure for context */
struct nod *ctx_proc_inputs; /* Procedure input parameters */
struct map *ctx_map; /* Map for aggregates */
struct nod *ctx_rse; /* Sub-rse for aggregates */
struct ctx *ctx_parent; /* Parent context for aggregates */
TEXT *ctx_alias; /* Context alias */
USHORT ctx_context; /* Context id */
USHORT ctx_scope_level; /* Subquery level within this request */
USHORT ctx_flags; /* Various flag values */
} *CTX;
/* Flag values for ctx_flags */
#define CTX_outer_join (1<<0) /* reference is part of an outer join */
/* Aggregate/union map block to map virtual fields to their base */
typedef struct map {
struct blk map_header;
struct map *map_next; /* Next map in item */
struct nod *map_node; /* Value for map item */
USHORT map_position; /* Position in map */
} *MAP;
/* Message block used in communicating with a running request */
#ifndef GUI_TOOLS
typedef struct msg {
struct blk msg_header;
struct par *msg_parameters; /* Parameter list */
struct par *msg_par_ordered; /* Ordered parameter list */
UCHAR *msg_buffer; /* Message buffer */
USHORT msg_number; /* Message number */
USHORT msg_length; /* Message length */
USHORT msg_parameter; /* Next parameter number */
USHORT msg_index; /* Next index into SQLDA */
} *MSG;
#endif
/* Parameter block used to describe a parameter of a message */
typedef struct par {
struct blk par_header;
struct msg *par_message; /* Parent message */
struct par *par_next; /* Next parameter in linked list */
struct par *par_ordered; /* Next parameter in order of index */
struct par *par_null; /* Null parameter, if used */
struct nod *par_node; /* Associated value node, if any */
struct ctx *par_dbkey_ctx; /* Context of internally requested dbkey */
struct ctx *par_rec_version_ctx; /* Context of internally requested record version */
TEXT *par_name; /* Parameter name, if any */
TEXT *par_rel_name; /* Relation name, if any */
TEXT *par_owner_name; /* Owner name, if any */
TEXT *par_alias; /* Alias, if any */
DSC par_desc; /* Field data type */
DSC par_user_desc; /* SQLDA data type */
USHORT par_parameter; /* BLR parameter number */
USHORT par_index; /* Index into SQLDA, if appropriate */
} *PAR;
#include "../jrd/thd.h"
/* DSQL threading declarations */
typedef struct tsql
{
struct thdd tsql_thd_data;
struct plb* tsql_default;
STATUS* tsql_status;
STATUS* tsql_user_status;
jmp_buf* tsql_setjmp;
} *TSQL;
#ifdef GET_THREAD_DATA
#undef GET_THREAD_DATA
#endif
#define GET_THREAD_DATA ((TSQL) THD_get_specific())
#ifndef SHLIB_DEFS
#ifdef DSQL_MAIN
PLB DSQL_permanent_pool;
int DSQL_debug;
#else
extern PLB DSQL_permanent_pool;
extern int DSQL_debug;
#endif
#else
extern PLB DSQL_permanent_pool;
extern int DSQL_debug;
#endif
/* macros for error generation */
#define BUGCHECK(string) ERRD_bugcheck(string)
#define IBERROR(code, string) ERRD_error(code, string)
#define BLKCHK(blk, type) if (blk->blk_type != (SCHAR) type) BUGCHECK ("expected type")
/* macro to stuff blr */
/* this is used in both ddl.cpp and gen.cpp, and is put here for commonality */
#define STUFF(byte) ((BLOB_PTR*)request->req_blr < (BLOB_PTR*)request->req_blr_yellow) ?\
(*request->req_blr++ = (UCHAR)(byte)) : GEN_expand_buffer (request, (UCHAR)(byte))
/* Macros for DEV_BUILD internal consistancy checking */
#ifdef DEV_BUILD
/* Verifies that a pointed to block matches the expected type.
* Useful to find coding errors & memory globbers.
*/
#define DEV_BLKCHK(blk, typ) \
{ \
if ((blk) && (((BLK) (blk))->blk_type != (typ))) \
ERRD_assert_msg (assert_blkchk_msg, assert_filename, (ULONG) __LINE__); \
}
#define _assert(ex) {if (!(ex)){(void) ERRD_assert_msg (NULL, assert_filename, __LINE__);}}
#define assert(ex) _assert(ex)
#define ASSERT_FAIL ERRD_assert_msg (NULL, assert_filename, __LINE__)
/* Define the assert_filename as a static variable to save on codespace */
#define ASSERT_FILENAME \
static UCHAR assert_filename[] = __FILE__; \
static UCHAR assert_blkchk_msg[] = "Unexpected memory block type"; /* NTX: dev */
#else /* PROD_BUILD */
#define DEV_BLKCHK(blk, typ)
#define _assert(ex)
#define assert(ex)
#define ASSERT_FAIL
#define ASSERT_FILENAME
#endif /* DEV_BUILD */
#endif /* _DSQL_DSQL_H_ */

68
src/dsql/dsql_proto.h Normal file
View File

@ -0,0 +1,68 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: dsql_proto.h
* DESCRIPTION: Prototype Header file for dsql.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_DSQL_PROTO_H_
#define _DSQL_DSQL_PROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
extern STATUS DLL_EXPORT dsql8_allocate_statement( STATUS*,
int**,
struct req**);
extern STATUS DLL_EXPORT dsql8_execute(STATUS *, void **, struct req**,
USHORT, UCHAR *, USHORT, USHORT,
UCHAR *, USHORT, UCHAR *, USHORT,
USHORT, UCHAR *);
extern STATUS DLL_EXPORT dsql8_execute_immediate(STATUS *, int **, int **,
USHORT, TEXT *, USHORT,
USHORT, UCHAR *, USHORT,
USHORT, UCHAR *, USHORT,
UCHAR *, USHORT, USHORT,
UCHAR *);
#ifdef SCROLLABLE_CURSORS
extern STATUS DLL_EXPORT dsql8_fetch(STATUS *, struct req **, USHORT, UCHAR *,
USHORT, USHORT, UCHAR *, USHORT, SLONG);
#else
extern STATUS DLL_EXPORT dsql8_fetch(STATUS *, struct req **, USHORT, UCHAR *,
USHORT, USHORT, UCHAR *);
#endif /* SCROLLABLE_CURSORS */
extern STATUS DLL_EXPORT dsql8_free_statement(STATUS *, struct req **,
USHORT);
extern STATUS DLL_EXPORT dsql8_insert(STATUS *, struct req **, USHORT,
UCHAR *, USHORT, USHORT, UCHAR *);
extern STATUS DLL_EXPORT dsql8_prepare(STATUS *, void **, struct req **,
USHORT, TEXT *, USHORT, USHORT,
UCHAR *, USHORT, UCHAR *);
extern STATUS DLL_EXPORT dsql8_set_cursor(STATUS *, struct req **, TEXT *,
USHORT);
extern STATUS DLL_EXPORT dsql8_sql_info(STATUS *, struct req **, USHORT,
SCHAR *, USHORT, SCHAR *);
extern void DSQL_pretty(struct nod *, int);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _DSQL_DSQL_PROTO_H_ */

327
src/dsql/errd.cpp Normal file
View File

@ -0,0 +1,327 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: err.c
* DESCRIPTION: Error handlers
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include "../jrd/ib_stdio.h"
#include <string.h>
#include "../jrd/common.h"
#include <stdarg.h>
#include "../dsql/dsql.h"
#include "../dsql/sqlda.h"
#include "../jrd/codes.h"
#include "../jrd/iberr.h"
#include "../dsql/errd_proto.h"
#include "../dsql/utld_proto.h"
#include "../jrd/gds_proto.h"
#include "../jrd/thd_proto.h"
extern "C" {
ASSERT_FILENAME /* Define things assert() needs */
#ifdef DEV_BUILD
void ERRD_assert_msg( CONST UCHAR * msg, CONST UCHAR * file, ULONG lineno)
{
/**************************************
*
* E R R D _ a s s e r t _ m s g
*
**************************************
*
* Functional description
* Generate an assertion failure with a message
*
**************************************/
char buffer[100];
sprintf(buffer, "Assertion failure: %s File: %s Line: %ld\n", /* NTX: dev build */
(msg ? msg : (UCHAR *) ""), (file ? file : (UCHAR *) ""), lineno);
ERRD_bugcheck(buffer);
}
#endif /* DEV_BUILD */
void ERRD_bugcheck( CONST TEXT * text)
{
/**************************************
*
* E R R D _ b u g c h e c k
*
**************************************
*
* Functional description
* Somebody has screwed up. Bugcheck.
*
**************************************/
TEXT s[128];
sprintf(s, "INTERNAL: %s", text); /* TXNN */
ERRD_error(-1, s);
}
void ERRD_error( int code, CONST TEXT * text)
{
/**************************************
*
* E R R D _ e r r o r
*
**************************************
*
* Functional description
* This routine should only be used by fatal
* error messages, those that cannot use the
* normal error routines because something
* is very badly wrong. ERRD_post() should
* be used by most error messages, especially
* so that strings will be handled.
*
**************************************/
TEXT s[256];
TSQL tdsql;
tdsql = GET_THREAD_DATA;
sprintf(s, "** DSQL error: %s **\n", text);
TRACE(s);
LONGJMP(*tdsql->tsql_setjmp, code);
}
BOOLEAN ERRD_post_warning(STATUS status, ...)
{
/**************************************
*
* E R R D _ p o s t _ w a r n i n g
*
**************************************
*
* Functional description
* Post a warning to the current status vector.
*
**************************************/
va_list args;
int type, len;
#pragma FB_COMPILER_MESSAGE("Warning, using STATUS array to hold pointers to STATUSes!")
STATUS *status_vector;
int indx = 0, warning_indx = 0;
VA_START(args, status);
status_vector = ((TSQL) GET_THREAD_DATA)->tsql_status;
if (status_vector[0] != gds_arg_gds ||
(status_vector[0] == gds_arg_gds && status_vector[1] == 0 &&
status_vector[2] != gds_arg_warning)) {
/* this is a blank status vector */
status_vector[0] = gds_arg_gds;
status_vector[1] = 0;
status_vector[2] = gds_arg_end;
indx = 2;
}
else
{
/* find end of a status vector */
PARSE_STATUS(status_vector, indx, warning_indx);
if (indx)
--indx;
}
/* stuff the warning */
if (indx + 3 < ISC_STATUS_LENGTH) {
status_vector[indx++] = gds_arg_warning;
status_vector[indx++] = status;
while ((type = va_arg(args, int)) && (indx + 3 < ISC_STATUS_LENGTH))
switch (status_vector[indx++] = type) {
case gds_arg_warning:
status_vector[indx++] = (STATUS) va_arg(args, STATUS);
break;
case gds_arg_string:
{
const char* pszTmp = va_arg(args, char*);
if (strlen(pszTmp) >= MAX_ERRSTR_LEN) {
status_vector[(indx - 1)] = gds_arg_cstring;
status_vector[indx++] = MAX_ERRSTR_LEN;
}
status_vector[indx++] = reinterpret_cast<STATUS>(pszTmp);
}
break;
case gds_arg_interpreted:
status_vector[indx++] = (STATUS) va_arg(args, TEXT *);
break;
case gds_arg_cstring:
len = va_arg(args, int);
status_vector[indx++] =
(STATUS) (len >= MAX_ERRSTR_LEN) ? MAX_ERRSTR_LEN : len;
status_vector[indx++] = (STATUS) va_arg(args, TEXT *);
break;
case gds_arg_number:
status_vector[indx++] = (STATUS) va_arg(args, SLONG);
break;
case gds_arg_vms:
case gds_arg_unix:
case gds_arg_domain:
case gds_arg_dos:
case gds_arg_mpexl:
case gds_arg_next_mach:
case gds_arg_netware:
case gds_arg_win32:
default:
status_vector[indx++] = (STATUS) va_arg(args, int);
break;
}
status_vector[indx] = gds_arg_end;
return TRUE;
}
else {
/* not enough free space */
return FALSE;
}
}
void ERRD_post( STATUS status, ...)
{
/**************************************
*
* E R R D _ p o s t
*
**************************************
*
* Functional description
* Post an error, copying any potentially
* transient data before we do the longjmp.
*
**************************************/
STATUS *status_vector;
STATUS tmp_status[ISC_STATUS_LENGTH], warning_status[ISC_STATUS_LENGTH];
int i, tmp_status_len = 0, status_len = 0, err_status_len = 0;
int warning_count = 0, warning_indx = 0;
status_vector = ((TSQL) GET_THREAD_DATA)->tsql_status;
/* stuff the status into temp buffer */
MOVE_CLEAR(tmp_status, sizeof(tmp_status));
STUFF_STATUS(tmp_status, status);
/* calculate length of the status */
PARSE_STATUS(tmp_status, tmp_status_len, warning_indx);
assert(warning_indx == 0);
if (status_vector[0] != gds_arg_gds ||
(status_vector[0] == gds_arg_gds && status_vector[1] == 0 &&
status_vector[2] != gds_arg_warning)) {
/* this is a blank status vector */
status_vector[0] = gds_arg_gds;
status_vector[1] = gds__dsql_error;
status_vector[2] = gds_arg_end;
}
PARSE_STATUS(status_vector, status_len, warning_indx);
if (status_len)
--status_len;
/* check for duplicated error code */
for (i = 0; i < ISC_STATUS_LENGTH; i++) {
if (status_vector[i] == gds_arg_end && i == status_len)
break; /* end of argument list */
if (i && i == warning_indx)
break; /* vector has no more errors */
if (status_vector[i] == tmp_status[1] && i &&
status_vector[i - 1] != gds_arg_warning &&
i + tmp_status_len - 2 < ISC_STATUS_LENGTH &&
(memcmp(&status_vector[i], &tmp_status[1],
sizeof(STATUS) * (tmp_status_len - 2)) == 0)) {
/* duplicate found */
ERRD_punt();
}
}
/* if the status_vector has only warnings then adjust err_status_len */
if ((err_status_len = i) == 2 && warning_indx)
err_status_len = 0;
if (warning_indx) {
/* copy current warning(s) to a temp buffer */
MOVE_CLEAR(warning_status, sizeof(warning_status));
MOVE_FASTER(&status_vector[warning_indx], warning_status,
sizeof(STATUS) * (ISC_STATUS_LENGTH - warning_indx));
PARSE_STATUS(warning_status, warning_count, warning_indx);
}
/* add the status into a real buffer right in between last error
and first warning */
if ((i = err_status_len + tmp_status_len) < ISC_STATUS_LENGTH) {
MOVE_FASTER(tmp_status, &status_vector[err_status_len],
sizeof(STATUS) * tmp_status_len);
/* copy current warning(s) to the status_vector */
if (warning_count && i + warning_count - 1 < ISC_STATUS_LENGTH) {
MOVE_FASTER(warning_status, &status_vector[i - 1],
sizeof(STATUS) * warning_count);
}
}
ERRD_punt();
}
void ERRD_punt(void)
{
/**************************************
*
* E R R D _ p u n t
*
**************************************
*
* Functional description
* Error stuff has been copied to
* status vector. Now punt.
*
**************************************/
TSQL tdsql;
tdsql = GET_THREAD_DATA;
/* Save any strings in a permanent location */
UTLD_save_status_strings(tdsql->tsql_status);
/* Give up whatever we were doing and return to the user. */
LONGJMP(*tdsql->tsql_setjmp, (int) tdsql->tsql_status[1]);
}
} // extern "C"

45
src/dsql/errd_proto.h Normal file
View File

@ -0,0 +1,45 @@
/*
* PROGRAM: Dynamic SQL RUNTIME SUPPORT
* MODULE: errd_proto.h
* DESCRIPTION: Prototype Header file for errd_proto.h
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef DSQL_ERRD_PROTO_H
#define DSQL_ERRD_PROTO_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef DEV_BUILD
void ERRD_assert_msg(CONST UCHAR *, CONST UCHAR *, ULONG);
#endif
void ERRD_bugcheck(CONST TEXT *);
void ERRD_error(int, CONST TEXT *);
void ERRD_post(STATUS, ...);
BOOLEAN ERRD_post_warning(STATUS, ...);
void ERRD_punt(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* DSQL_ERRD_PROTO_H */

2398
src/dsql/gen.cpp Normal file

File diff suppressed because it is too large Load Diff

35
src/dsql/gen_proto.h Normal file
View File

@ -0,0 +1,35 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: gen_proto.h
* DESCRIPTION: Prototype Header file for gen.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_GEN_PROTO_H_
#define _DSQL_GEN_PROTO_H_
extern UCHAR GEN_expand_buffer(struct req *, UCHAR);
extern void GEN_expr(struct req *, struct nod *);
extern void GEN_port(struct req *, struct msg *);
extern void GEN_request(struct req *, struct nod *);
extern void GEN_return(REQ, NOD, BOOLEAN);
extern void GEN_start_transaction(struct req *, struct nod *);
extern void GEN_statement(struct req *, struct nod *);
#endif /* _DSQL_GEN_PROTO_H_ */

505
src/dsql/hsh.cpp Normal file
View File

@ -0,0 +1,505 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: hsh.c
* DESCRIPTION: Hash table and symbol manager
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include <string.h>
#include "../dsql/dsql.h"
#include "../dsql/sym.h"
#include "../include/jrd/gds.h"
#include "../dsql/alld_proto.h"
#include "../dsql/errd_proto.h"
#include "../dsql/hsh_proto.h"
#include "../jrd/sch_proto.h"
#include "../jrd/thd_proto.h"
extern "C" {
ASSERT_FILENAME
#define HASH_SIZE 211
static SSHORT hash(register SCHAR *, register USHORT);
static BOOLEAN remove_symbol(struct sym **, struct sym *);
static BOOLEAN scompare(register TEXT *, register USHORT, register TEXT *,
USHORT);
static SYM *hash_table;
/*
SUPERSERVER can end up with many hands in the pie, so some
protection is provided via a mutex. This ensures the integrity
of lookups, inserts and removals, and also allows teh traversing
of symbol chains for marking of relations and procedures.
Otherwise, one DSQL user won't know what the other is doing
to the same object.
*/
#ifdef SUPERSERVER
static MUTX_T hash_mutex;
static USHORT hash_mutex_inited = 0;
#define LOCK_HASH THD_mutex_lock (&hash_mutex)
#define UNLOCK_HASH THD_mutex_unlock (&hash_mutex);
#else
#define LOCK_HASH
#define UNLOCK_HASH
#endif
void HSHD_init(void)
{
/*************************************
*
* H S H D _ i n i t
*
*************************************
*
* functional description
* create a new hash table
*
************************************/
UCHAR *p;
#ifdef SUPERSERVER
if (!hash_mutex_inited) {
hash_mutex_inited = 1;
THD_mutex_init(&hash_mutex);
}
#endif
p = (UCHAR *) ALLD_malloc(sizeof(SYM) * HASH_SIZE);
memset(p, 0, sizeof(SYM) * HASH_SIZE);
hash_table = (SYM *) p;
}
#ifdef DEV_BUILD
#include "../jrd/ib_stdio.h"
void HSHD_debug(void)
{
/**************************************
*
* H S H D _ d e b u g
*
**************************************
*
* Functional description
* Print out the hash table for debugging.
*
**************************************/
SYM collision;
SYM homptr;
SSHORT h;
/* dump each hash table entry */
LOCK_HASH;
for (h = 0; h < HASH_SIZE; h++) {
for (collision = hash_table[h]; collision;
collision = collision->sym_collision) {
/* check any homonyms first */
ib_fprintf(ib_stderr, "Symbol type %d: %s %x\n",
collision->sym_type, collision->sym_string,
collision->sym_dbb);
for (homptr = collision->sym_homonym; homptr;
homptr = homptr->sym_homonym) {
ib_fprintf(ib_stderr, "Homonym Symbol type %d: %s %x\n",
homptr->sym_type, homptr->sym_string,
homptr->sym_dbb);
}
}
}
UNLOCK_HASH;
}
#endif
void HSHD_fini(void)
{
/**************************************
*
* H S H D _ f i n i
*
**************************************
*
* Functional description
* Clear out the symbol table. All the
* symbols are deallocated with their pools.
*
**************************************/
SSHORT i;
for (i = 0; i < HASH_SIZE; i++)
hash_table[i] = NULL;
ALLD_free(reinterpret_cast < SCHAR * >(hash_table));
hash_table = NULL;
}
void HSHD_finish( void *database)
{
/**************************************
*
* H S H D _ f i n i s h
*
**************************************
*
* Functional description
* Remove symbols used by a particular database.
* Don't bother to release them since their pools
* will be released.
*
**************************************/
SYM *collision;
SYM *homptr;
SYM symbol;
SYM chain;
SSHORT h;
/* check each hash table entry */
LOCK_HASH;
for (h = 0; h < HASH_SIZE; h++) {
for (collision = &hash_table[h]; *collision;) {
/* check any homonyms first */
chain = *collision;
for (homptr = &chain->sym_homonym; *homptr;) {
symbol = *homptr;
if (symbol->sym_dbb == database) {
*homptr = symbol->sym_homonym;
symbol = symbol->sym_homonym;
}
else
homptr = &symbol->sym_homonym;
}
/* now, see if the root entry has to go */
if (chain->sym_dbb == database) {
if (chain->sym_homonym) {
chain->sym_homonym->sym_collision = chain->sym_collision;
*collision = chain->sym_homonym;
}
else
*collision = chain->sym_collision;
chain = *collision;
}
else
collision = &chain->sym_collision;
}
}
UNLOCK_HASH;
}
void HSHD_insert( register SYM symbol)
{
/**************************************
*
* H S H D _ i n s e r t
*
**************************************
*
* Functional description
* Insert a symbol into the hash table.
*
**************************************/
register SSHORT h;
register void *database;
register SYM old;
LOCK_HASH;
h = hash(symbol->sym_string, symbol->sym_length);
database = symbol->sym_dbb;
assert(symbol->sym_type >= SYM_statement && symbol->sym_type <= SYM_eof);
for (old = hash_table[h]; old; old = old->sym_collision)
if ((!database || (database == old->sym_dbb)) &&
scompare(symbol->sym_string, symbol->sym_length, old->sym_string,
old->sym_length)) {
symbol->sym_homonym = old->sym_homonym;
old->sym_homonym = symbol;
UNLOCK_HASH;
return;
}
symbol->sym_collision = hash_table[h];
hash_table[h] = symbol;
UNLOCK_HASH;
}
SYM HSHD_lookup(void *database,
TEXT * string,
SSHORT length, SYM_TYPE type, USHORT parser_version)
{
/**************************************
*
* H S H D _ l o o k u p
*
**************************************
*
* Functional description
* Perform a string lookup against hash table.
* Make sure to only return a symbol of the desired type.
*
**************************************/
register SYM symbol;
SSHORT h;
LOCK_HASH;
h = hash(string, length);
for (symbol = hash_table[h]; symbol; symbol = symbol->sym_collision)
if ((database == symbol->sym_dbb) &&
scompare(string, length, symbol->sym_string, symbol->sym_length)) {
/* Search for a symbol of the proper type */
while (symbol && symbol->sym_type != type)
symbol = symbol->sym_homonym;
UNLOCK_HASH;
/* If the symbol found was not part of the list of keywords for the
* client connecting, then assume nothing was found
*/
if (symbol) {
if (parser_version < symbol->sym_version
&& type == SYM_keyword) return NULL;
}
return symbol;
}
UNLOCK_HASH;
return NULL;
}
void HSHD_remove( SYM symbol)
{
/**************************************
*
* H S H D _ r e m o v e
*
**************************************
*
* Functional description
* Remove a symbol from the hash table.
*
**************************************/
SYM *collision;
SSHORT h;
LOCK_HASH;
h = hash(symbol->sym_string, symbol->sym_length);
for (collision = &hash_table[h]; *collision;
collision =
&(*collision)->sym_collision) if (remove_symbol(collision, symbol)) {
UNLOCK_HASH;
return;
}
UNLOCK_HASH;
IBERROR(-1, "HSHD_remove failed");
}
void HSHD_set_flag(
void *database,
TEXT * string, SSHORT length, SYM_TYPE type, SSHORT flag)
{
/**************************************
*
* H S H D _ s e t _ f l a g
*
**************************************
*
* Functional description
* Set a flag in all similar objects in a chain. This
* is used primarily to mark relations and procedures
* as deleted. The object must have the same name and
* type, but not the same database, and must belong to
* some database. Later access to such an object by
* another user or thread should result in that object's
* being refreshed. Note that even if the relation name
* and ID, or the procedure name and ID both match, it
* may still not represent an exact match. This is because
* there's no way at present for DSQL to tell if two databases
* as represented in DSQL are attachments to the same physical
* database.
*
**************************************/
SYM symbol, homonym;
SSHORT h;
DSQL_REL sym_rel;
PRC sym_prc;
/* as of now, there's no work to do if there is no database or if
the type is not a relation or procedure */
if (!database)
return;
switch (type) {
case SYM_relation:
case SYM_procedure:
break;
default:
return;
}
LOCK_HASH;
h = hash(string, length);
for (symbol = hash_table[h]; symbol; symbol = symbol->sym_collision) {
if (symbol->sym_dbb && (database != symbol->sym_dbb) &&
scompare(string, length, symbol->sym_string, symbol->sym_length)) {
/* the symbol name matches and it's from a different database */
for (homonym = symbol; homonym; homonym = homonym->sym_homonym) {
if (homonym->sym_type == type) {
/* the homonym is of the correct type */
/* the next check is for the same relation or procedure ID,
which indicates that it MAY be the same relation or
procedure */
switch (type) {
case SYM_relation:
sym_rel = (DSQL_REL) homonym->sym_object;
sym_rel->rel_flags |= flag;
break;
case SYM_procedure:
sym_prc = (PRC) homonym->sym_object;
sym_prc->prc_flags |= flag;
break;
}
}
}
}
}
UNLOCK_HASH;
}
static SSHORT hash( register SCHAR * string, register USHORT length)
{
/**************************************
*
* h a s h
*
**************************************
*
* Functional description
* Returns the hash function of a string.
*
**************************************/
register SLONG value;
SCHAR c;
value = 0;
while (length--) {
c = *string++;
value = (value << 1) + (c);
}
return ((value >= 0) ? value : -value) % HASH_SIZE;
}
static BOOLEAN remove_symbol( SYM * collision, SYM symbol)
{
/**************************************
*
* r e m o v e _ s y m b o l
*
**************************************
*
* Functional description
* Given the address of a collision,
* remove a symbol from the collision
* and homonym linked lists.
*
**************************************/
register SYM *ptr, homonym;
if (symbol == *collision) {
if ((homonym = symbol->sym_homonym) != NULL) {
homonym->sym_collision = symbol->sym_collision;
*collision = homonym;
}
else
*collision = symbol->sym_collision;
return TRUE;
}
for (ptr = &(*collision)->sym_homonym; *ptr; ptr = &(*ptr)->sym_homonym)
if (symbol == *ptr) {
*ptr = symbol->sym_homonym;
return TRUE;
}
return FALSE;
}
static BOOLEAN scompare(
register TEXT * string1,
register USHORT length1,
register TEXT * string2, USHORT length2)
{
/**************************************
*
* s c o m p a r e
*
**************************************
*
* Functional description
* Compare two symbolic strings
* The character set for these strings is either ASCII or
* Unicode in UTF format.
* Symbols are case-significant - so no uppercase operation
* is performed.
*
**************************************/
if (length1 != length2)
return FALSE;
while (length1--) {
if ((*string1++) != (*string2++))
return FALSE;
}
return TRUE;
}
} // extern "C"

43
src/dsql/hsh_proto.h Normal file
View File

@ -0,0 +1,43 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: hsh_proto.h
* DESCRIPTION: Prototype Header file for hsh.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef DSQL_HSH_PROTO_H
#define DSQL_HSH_PROTO_H
#ifdef __cplusplus
extern "C" {
#endif
void HSHD_fini(void);
void HSHD_finish(void *);
void HSHD_init(void);
void HSHD_insert(struct sym *);
SYM HSHD_lookup(void *, TEXT *, SSHORT, SYM_TYPE, USHORT);
void HSHD_remove(struct sym *);
void HSHD_set_flag(void *, TEXT *, SSHORT, SYM_TYPE, SSHORT);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*DSQL_HSH_PROTO_H*/

235
src/dsql/keywords.h Normal file
View File

@ -0,0 +1,235 @@
/* This list is maintained in alphabetical sorted order by 2nd column.
The following command will resort the list -- except for this comment
sort -t , -k 2b,2b keywords.h
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
See dsql/parse.y for a chronological list. */
NOT_LSS, "!<", 1,
NEQ, "!=", 1,
NOT_GTR, "!>", 1,
LPAREN, "(", 1,
RPAREN, ")", 1, COMMA, ",", 1, LSS, "<", 1, LEQ, "<=", 1, NEQ, "<>", 1, /* Alias of != */
EQL, "=", 1,
GTR, ">", 1,
GEQ, ">=", 1,
ACTION, "ACTION", 1,
ACTIVE, "ACTIVE", 1,
ADD, "ADD", 1,
ADMIN, "ADMIN", 1,
AFTER, "AFTER", 1,
ALL, "ALL", 1,
ALTER, "ALTER", 1, AND, "AND", 1, ANY, "ANY", 1, AS, "AS", 1, ASC, "ASC", 1, /* Alias of ASCENDING */
ASC, "ASCENDING", 1,
AT, "AT", 1,
AUTO, "AUTO", 1,
AVG, "AVG", 1,
BASENAME, "BASE_NAME", 1,
BEFORE, "BEFORE", 1,
BEGIN, "BEGIN", 1,
BETWEEN, "BETWEEN", 1,
BLOB, "BLOB", 1,
BY, "BY", 1,
CACHE, "CACHE", 1,
CASCADE, "CASCADE", 1,
CAST, "CAST", 1,
KW_CHAR, "CHAR", 1,
CHARACTER, "CHARACTER", 1,
CHECK, "CHECK", 1,
CHECK_POINT_LEN, "CHECK_POINT_LENGTH", 1,
COLLATE, "COLLATE", 1,
COLUMN, "COLUMN", 2,
COMMIT, "COMMIT", 1,
COMMITTED, "COMMITTED", 1,
COMPUTED, "COMPUTED", 1,
CONDITIONAL, "CONDITIONAL", 1,
CONSTRAINT, "CONSTRAINT", 1,
CONTAINING, "CONTAINING", 1,
COUNT, "COUNT", 1,
CREATE, "CREATE", 1,
CSTRING, "CSTRING", 1,
CURRENT, "CURRENT", 1,
CURRENT_DATE, "CURRENT_DATE", 2,
CURRENT_TIME, "CURRENT_TIME", 2,
CURRENT_TIMESTAMP, "CURRENT_TIMESTAMP", 2,
CURSOR, "CURSOR", 1,
DATABASE, "DATABASE", 1,
DATE, "DATE", 1,
DAY, "DAY", 2,
DEBUG, "DEBUG", 1,
KW_DEC, "DEC", 1,
DECIMAL, "DECIMAL", 1,
DECLARE, "DECLARE", 1,
DEFAULT, "DEFAULT", 1, DELETE, "DELETE", 1, DESC, "DESC", 1, /* Alias of DESCENDING */
DESC, "DESCENDING", 1,
DISTINCT, "DISTINCT", 1,
DO, "DO", 1,
DOMAIN, "DOMAIN", 1,
KW_DOUBLE, "DOUBLE", 1,
DROP, "DROP", 1,
ELSE, "ELSE", 1,
END, "END", 1,
ENTRY_POINT, "ENTRY_POINT", 1,
ESCAPE, "ESCAPE", 1,
EXCEPTION, "EXCEPTION", 1,
EXECUTE, "EXECUTE", 1,
EXISTS, "EXISTS", 1,
EXIT, "EXIT", 1,
EXTERNAL, "EXTERNAL", 1,
EXTRACT, "EXTRACT", 2,
KW_FILE, "FILE", 1,
FILTER, "FILTER", 1,
KW_FLOAT, "FLOAT", 1,
FOR, "FOR", 1,
FOREIGN, "FOREIGN", 1,
FREE_IT, "FREE_IT", 1,
FROM, "FROM", 1,
FULL, "FULL", 1,
FUNCTION, "FUNCTION", 1,
GDSCODE, "GDSCODE", 1,
GENERATOR, "GENERATOR", 1,
GEN_ID, "GEN_ID", 1,
GRANT, "GRANT", 1,
GROUP, "GROUP", 1,
GROUP_COMMIT_WAIT, "GROUP_COMMIT_WAIT_TIME", 1,
HAVING, "HAVING", 1,
HOUR, "HOUR", 2,
IF, "IF", 1,
IN, "IN", 1,
INACTIVE, "INACTIVE", 1,
INDEX, "INDEX", 1,
INNER, "INNER", 1,
INPUT_TYPE, "INPUT_TYPE", 1,
INSERT, "INSERT", 1,
KW_INT, "INT", 1,
INTEGER, "INTEGER", 1,
INTO, "INTO", 1,
IS, "IS", 1,
ISOLATION, "ISOLATION", 1,
JOIN, "JOIN", 1,
KEY, "KEY", 1,
LEFT, "LEFT", 1,
LENGTH, "LENGTH", 1,
LEVEL, "LEVEL", 1,
LIKE, "LIKE", 1,
LOGFILE, "LOGFILE", 1,
LOG_BUF_SIZE, "LOG_BUFFER_SIZE", 1,
KW_LONG, "LONG", 1,
MANUAL, "MANUAL", 1,
MAXIMUM, "MAX", 1,
MAX_SEGMENT, "MAXIMUM_SEGMENT", 1,
MERGE, "MERGE", 1,
MESSAGE, "MESSAGE", 1,
MINIMUM, "MIN", 1,
MINUTE, "MINUTE", 2,
MODULE_NAME, "MODULE_NAME", 1,
MONTH, "MONTH", 2,
NAMES, "NAMES", 1,
NATIONAL, "NATIONAL", 1,
NATURAL, "NATURAL", 1,
NCHAR, "NCHAR", 1,
NO, "NO", 1,
NOT, "NOT", 1,
KW_NULL, "NULL", 1,
KW_NUMERIC, "NUMERIC", 1,
NUM_LOG_BUFS, "NUM_LOG_BUFFERS", 1,
OF, "OF", 1,
ON, "ON", 1,
ONLY, "ONLY", 1,
OPTION, "OPTION", 1,
OR, "OR", 1,
ORDER, "ORDER", 1,
OUTER, "OUTER", 1,
OUTPUT_TYPE, "OUTPUT_TYPE", 1,
OVERFLOW, "OVERFLOW", 1,
PAGE, "PAGE", 1,
PAGES, "PAGES", 1,
PAGE_SIZE, "PAGE_SIZE", 1,
PARAMETER, "PARAMETER", 1,
PASSWORD, "PASSWORD", 1,
PLAN, "PLAN", 1,
POSITION, "POSITION", 1,
POST_EVENT, "POST_EVENT", 1,
PRECISION, "PRECISION", 1,
PRIMARY, "PRIMARY", 1,
PRIVILEGES, "PRIVILEGES", 1,
PROCEDURE, "PROCEDURE", 1,
PROTECTED, "PROTECTED", 1,
RAW_PARTITIONS, "RAW_PARTITIONS", 1,
DB_KEY, "RDB$DB_KEY", 1,
READ, "READ", 1,
REAL, "REAL", 1,
VERSION, "RECORD_VERSION", 1,
REFERENCES, "REFERENCES", 1, RESERVING, "RESERV", 1, /* Alias of RESERVING */
RESERVING, "RESERVING", 1,
RESTRICT, "RESTRICT", 1,
RETAIN, "RETAIN", 1,
RETURNING_VALUES, "RETURNING_VALUES", 1,
RETURNS, "RETURNS", 1,
REVOKE, "REVOKE", 1,
RIGHT, "RIGHT", 1,
ROLE, "ROLE", 1, ROLLBACK, "ROLLBACK", 1, DATABASE, "SCHEMA", 1, /* Alias of DATABASE */
SECOND, "SECOND", 2,
SEGMENT, "SEGMENT", 1,
SELECT, "SELECT", 1,
SET, "SET", 1,
SHADOW, "SHADOW", 1,
SHARED, "SHARED", 1,
SINGULAR, "SINGULAR", 1,
SIZE, "SIZE", 1,
SMALLINT, "SMALLINT", 1,
SNAPSHOT, "SNAPSHOT", 1,
SOME, "SOME", 1,
SORT, "SORT", 1,
SQLCODE, "SQLCODE", 1,
STABILITY, "STABILITY", 1, STARTING, "STARTING", 1, STARTING, "STARTS", 1, /* Alias of STARTING */
STATISTICS, "STATISTICS", 1,
SUB_TYPE, "SUB_TYPE", 1,
SUM, "SUM", 1,
SUSPEND, "SUSPEND", 1,
TABLE, "TABLE", 1,
THEN, "THEN", 1,
TIME, "TIME", 2,
TIMESTAMP, "TIMESTAMP", 2,
TO, "TO", 1,
TRANSACTION, "TRANSACTION", 1,
TRIGGER, "TRIGGER", 1,
TYPE, "TYPE", 2,
UNCOMMITTED, "UNCOMMITTED", 1,
UNION, "UNION", 1,
UNIQUE, "UNIQUE", 1,
UPDATE, "UPDATE", 1,
KW_UPPER, "UPPER", 1,
USER, "USER", 1,
KW_VALUE, "VALUE", 1,
VALUES, "VALUES", 1,
VARCHAR, "VARCHAR", 1,
VARIABLE, "VARIABLE", 1,
VARYING, "VARYING", 1,
VIEW, "VIEW", 1,
WAIT, "WAIT", 1,
WEEKDAY, "WEEKDAY", 2,
WHEN, "WHEN", 1,
WHERE, "WHERE", 1,
WHILE, "WHILE", 1,
WITH, "WITH", 1,
WORK, "WORK", 1,
WRITE, "WRITE", 1, YEAR, "YEAR", 2, YEARDAY, "YEARDAY", 2, NOT_LSS, "^<", 1, /* Alias of !< */
NEQ, "^=", 1, /* Alias of != */
NOT_GTR, "^>", 1, /* Alias of !> */
CONCATENATE, "||", 1, NOT_LSS, "~<", 1, /* Alias of !< */
NEQ, "~=", 1, /* Alias of != */
NOT_GTR, "~>", 1, /* Alias of !> */

1266
src/dsql/make.cpp Normal file

File diff suppressed because it is too large Load Diff

53
src/dsql/make_proto.h Normal file
View File

@ -0,0 +1,53 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: make_proto.h
* DESCRIPTION: Prototype Header file for make.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_MAKE_PROTO_H_
#define _DSQL_MAKE_PROTO_H_
#include "../dsql/sym.h"
#ifdef __cplusplus
extern "C" {
#endif
struct nod *MAKE_constant(struct str *, int);
struct nod *MAKE_str_constant(struct str *, SSHORT);
struct str *MAKE_cstring(CONST SCHAR *);
void MAKE_desc(struct dsc *, struct nod *);
void MAKE_desc_from_field(struct dsc *, struct fld *);
struct nod *MAKE_field(struct ctx *, struct fld *, struct nod *);
struct nod *MAKE_list(struct lls *);
struct nod *MAKE_node(ENUM nod_t, int);
struct par *MAKE_parameter(struct msg *, USHORT, USHORT);
struct str *MAKE_string(CONST UCHAR *, int);
struct sym *MAKE_symbol(struct dbb *, CONST TEXT *, USHORT,
ENUM sym_type, struct req *);
struct str *MAKE_tagged_string(CONST UCHAR *, int, CONST TEXT *);
struct nod *MAKE_variable(struct fld *, CONST TEXT *, USHORT, USHORT,
USHORT, USHORT);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _DSQL_MAKE_PROTO_H_ */

148
src/dsql/makefile.mak Normal file
View File

@ -0,0 +1,148 @@
# The contents of this file are subject to the Interbase Public
# License Version 1.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy
# of the License at http://www.Inprise.com/IPL.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
# or implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code was created by Inprise Corporation
# and its predecessors. Portions created by Inprise Corporation are
# Copyright (C) Inprise Corporation.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
# The contents of this file are subject to the Interbase Public
# License Version 1.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy
# of the License at http://www.Inprise.com/IPL.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
# or implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code was created by Inprise Corporation
# and its predecessors. Portions created by Inprise Corporation are
# Copyright (C) Inprise Corporation.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
#--------------------------- PC DSQL MAKEFILE ---------------------------
ROOT=..
.path.c=$(ROOT)\dsql
# -wpro : warns undefined function calls
# -N- : turn stack checking off
LCFLAGS=-DREQUESTER -N-
# Path to devkit and clisdk
!if !$d(TPATH)
TPATH=..
!endif
!include $(ROOT)\std.mk
#--------------------------- SOURCE COMPONENTS -----------------------------
WINSRCS = dllshell.c
# DSQL source files
S1 = alld.c ddl.c dsql.c dsqlwep.c errd.c gen.c hsh.c
S2 = make.c metd.c movd.c parse.c pass1.c
SRCS = $(S1) $(S2)
# sources from the jrd component used to build dsql.dll
JRDSRCS = cvt.c
# DSQL source files used by the jrd component for client side requests
CLIENTSRCS = array.c blob.c preparse.c user_dsq.c utld.c
# DSQL import definition files
DSQLLIBS = $(ROOT)\jrd\$(.path.obj)\gds.lib $(ROOT)\jrd\$(.path.obj)\iutls.lib
# Extra files which are used to build the product
XFILES = dsql.def makefile.mak
#---------------------------- TARGET LIST --------------------------------
# NOTE: c0dx must be the first obj in the list!
OBJS= $(TOOLPATH)\lib\c0d$(MODEL).obj $(SRCS:.c=.obj) \
$(JRDSRCS:.c=.obj) $(WINSRCS:.c=.obj)
ALLBIN = dsql.dll
ALLLIBS = dsql.lib
all: makefile.tmp extern_libs $(ALLBIN) $(ALLLIBS)
alllibs : makefile.tmp $(ALLLIBS)
allbin : makefile.tmp extern_libs $(ALLBIN)
LIBS=mathw$(MODEL) import cw$(MODEL)
#------------------------------ RULES -------------------------------------
#----- Windows DSQL DLL -----
dsql.dll: $(OBJS) $(DSQLLIBS) dsql.rsp dsql.def $(ROOT)\jrd\version.rc
$(TLINK) $(LFLAGS) @$*.rsp, @&&|
$<
$*.map
$(LIBS) $(DSQLLIBS)
$&.def
|
$(RC) -i $(TOOLPATH)\include $(ROOT)\jrd\version.rc $<
#----------- Response file -----------
dsql.rsp: $(OBJS)
copy &&|
$**
| $<
#----------- Import Library -----------
# Because of the circular "architecture" here, we need to build
# required libraries within each of the makefiles.
extern_libs:
cd $(ROOT)\jrd
make $(MAKEFLAGS) alllibs
cd $(ROOT)\dsql
dsql.lib: dsql.def
implib -o $< $**
# ---- Rules for source files which require special handling ----
cvt.obj: $(ROOT)\jrd\cvt.c
$(CC) -c @&&<
$(CFLAGS)
< $**
dllshell.obj: $(ROOT)\jrd\dllshell.c
$(CC) -c @&&<
$(CFLAGS)
< $**
#---------------------------- UTILITIES ---------------------------------
# Copy targets to a known installation directory
install: extern_libs $(ALLBIN) $(ALLLIBS)
for %i in ($(ALLBIN)) do copy $(.path.dll)\%i $(INSTALLBIN)
for %i in ($(ALLLIBS)) do copy $(.path.dll)\%i $(INSTALLLIB)
# Refresh all the source & header files from the DEVSRC directory
srcs::
copy $(DEVSRC)\dsql\*.h
for %i in ($(S1)) do copy $(DEVSRC)\dsql\%i
for %i in ($(S2)) do copy $(DEVSRC)\dsql\%i
for %i in ($(CLIENTSRCS)) do copy $(DEVSRC)\dsql\%i
for %i in ($(WINSRCS)) do copy $(DEVSRC)\dsql\%i
for %i in ($(XFILES)) do copy $(DEVSRC)\dsql\%i
copy $(DEVSRC)\wal\*.h $(ROOT)\wal

1717
src/dsql/metd.e Normal file

File diff suppressed because it is too large Load Diff

51
src/dsql/metd_proto.h Normal file
View File

@ -0,0 +1,51 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: metd_proto.h
* DESCRIPTION: Prototype Header file for metd.e
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_METD_PROTO_H
#define _DSQL_METD_PROTO_H
#ifdef __cplusplus
extern "C" {
#endif
void METD_drop_procedure(struct req*, struct str *);
void METD_drop_relation(struct req*, struct str *);
INTLSYM METD_get_charset(struct req*, USHORT, UCHAR *);
INTLSYM METD_get_collation(struct req*, struct str *);
void METD_get_col_default(REQ, TEXT*, TEXT*, BOOLEAN*, TEXT*, USHORT);
STR METD_get_default_charset(struct req*);
USHORT METD_get_domain(struct req*, struct fld*, UCHAR*);
void METD_get_domain_default(REQ, TEXT*, BOOLEAN*, TEXT*, USHORT);
UDF METD_get_function(struct req*, struct str*);
NOD METD_get_primary_key(struct req*, struct str*);
PRC METD_get_procedure(struct req*, struct str*);
DSQL_REL METD_get_relation(struct req*, struct str*);
STR METD_get_trigger_relation(struct req*, struct str*, USHORT*);
USHORT METD_get_type(struct req*, struct str*, UCHAR*, SSHORT*);
DSQL_REL METD_get_view_relation(struct req*, UCHAR*, UCHAR*, USHORT);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*_DSQL_METD_PROTO_H */

103
src/dsql/movd.cpp Normal file
View File

@ -0,0 +1,103 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: movd.c
* DESCRIPTION: Data mover and converter and comparator, etc.
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#include "../jrd/common.h"
#include "../jrd/ib_stdio.h"
#include <stdarg.h>
#include <string.h>
#include "../dsql/dsql.h"
#include "../jrd/codes.h"
#include "../jrd/iberr.h"
#include "../dsql/errd_proto.h"
#include "../dsql/movd_proto.h"
#include "../jrd/cvt_proto.h"
#include "../jrd/thd_proto.h"
static void post_error(STATUS, ...);
void MOVD_move( DSC * from, DSC * to)
{
/**************************************
*
* M O V D _ m o v e
*
**************************************
*
* Functional description
* Move (and possible convert) something to something else.
*
**************************************/
CVT_move(from, to, (FPTR_VOID) post_error);
}
static void post_error( STATUS status, ...)
{
/**************************************
*
* p o s t _ e r r o r
*
**************************************
*
* Functional description
* A conversion error occurred. Complain.
*
**************************************/
TSQL tdsql;
STATUS *v, *v_end, *temp, temp_status[20];
tdsql = GET_THREAD_DATA;
/* copy into a temporary array any other arguments which may
* have been handed to us, then post the error.
* N.B., the last supplied error should be a 0.
*/
STUFF_STATUS(temp_status, status);
v = tdsql->tsql_status;
v_end = v + 20;
*v++ = gds_arg_gds;
*v++ = gds__dsql_error;
*v++ = gds_arg_gds;
*v++ = gds__sqlerr;
*v++ = gds_arg_number;
*v++ = -303;
for (temp = temp_status; v < v_end && (*v = *temp) != gds_arg_end;
v++, temp++)
switch (*v) {
case gds_arg_cstring:
*++v = *++temp;
*++v = *++temp;
break;
default:
*++v = *++temp;
break;
};
ERRD_punt();
}

29
src/dsql/movd_proto.h Normal file
View File

@ -0,0 +1,29 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: movd_proto.h
* DESCRIPTION: Prototype Header file for movd.c
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_MOVD_PROTO_H_
#define _DSQL_MOVD_PROTO_H_
extern void MOVD_move(struct dsc *, struct dsc *);
#endif /* _DSQL_MOVD_PROTO_H_ */

749
src/dsql/node.h Normal file
View File

@ -0,0 +1,749 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: node.h
* DESCRIPTION: Definitions needed for accessing a parse tree
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef _DSQL_NODE_H_
#define _DSQL_NODE_H_
/* an enumeration of the possible node types in a syntax tree */
typedef ENUM nod_t
{
nod_commit = 1, /* Commands, not executed. */
nod_rollback,
nod_trans,
nod_prepare,
nod_create,
nod_define,
nod_def_default,
nod_del_default,
nod_def_database,
nod_def_domain, /* 10 */
nod_mod_domain,
nod_del_domain,
nod_mod_database,
nod_def_relation,
nod_mod_relation,
nod_del_relation,
nod_def_field,
nod_mod_field,
nod_del_field,
nod_def_index, /* 20 */
nod_del_index,
nod_def_view,
nod_def_constraint,
nod_def_trigger,
nod_mod_trigger,
nod_del_trigger,
nod_def_trigger_msg,
nod_mod_trigger_msg,
nod_del_trigger_msg,
nod_def_procedure, /* 30 */
nod_mod_procedure,
nod_del_procedure,
nod_def_exception,
nod_mod_exception,
nod_del_exception,
nod_def_generator,
nod_del_generator,
nod_def_filter,
nod_del_filter,
nod_def_shadow, /* 40 */
nod_del_shadow,
nod_def_udf,
nod_del_udf,
nod_grant,
nod_revoke,
nod_rel_constraint,
nod_delete_rel_constraint,
nod_primary,
nod_foreign,
nod_abort, /* 50 */
nod_references,
nod_proc_obj,
nod_trig_obj,
nod_view_obj,
nod_list, /* SQL statements, mapped into GDML statements */
nod_retrieve,
nod_select,
nod_insert,
nod_delete,
nod_update, /* 60 */
nod_fetch,
nod_close,
nod_open,
nod_all, /* ALL privileges */
nod_execute, /* EXECUTE privilege */
nod_for, /* created in context recognition phase to map to blr */
nod_store,
nod_modify,
nod_erase,
nod_assign, /* 70 */
nod_exec_procedure,
nod_return, /* Procedure statements */
nod_exit,
nod_while,
nod_if,
nod_for_select,
nod_erase_current,
nod_modify_current,
nod_post,
nod_block, /* 80 */
nod_on_error,
nod_sqlcode,
nod_gdscode,
nod_exception,
nod_exception_stmt,
nod_default,
nod_start_savepoint,
nod_end_savepoint,
nod_cursor, /* used to create record streams */
nod_relation, /* 90 */
nod_relation_name,
nod_procedure_name,
nod_rel_proc_name,
nod_name,
nod_rse,
nod_select_expr,
nod_union,
nod_aggregate,
nod_order,
nod_flag, /* 100 */
nod_join,
nod_top,
/* NOTE: when adding an expression node, be sure to
test various combinations; in particular, think
about parameterization using a '?' - there is code
in PASS1_node which must be updated to find the
data type of the parameter based on the arguments
to an expression node */
nod_eql,
nod_neq,
nod_gtr,
nod_geq,
nod_leq,
nod_lss,
nod_between,
nod_like,
nod_missing,
nod_and,
nod_or,
nod_any,
nod_not,
nod_unique,
nod_containing,
nod_starting,
nod_via,
nod_field, /* values */
nod_dom_value,
nod_field_name,
nod_agg_item,
nod_parameter,
nod_constant,
nod_position,
nod_values,
nod_map,
nod_alias,
nod_user_name,
nod_user_group,
nod_variable,
nod_var_name,
nod_array,
nod_add, /* functions */
nod_subtract,
nod_multiply,
nod_divide,
nod_negate,
nod_concatenate,
nod_substr,
nod_null,
nod_dbkey,
nod_udf,
nod_cast,
nod_upcase,
nod_collate,
nod_gen_id,
nod_add2, /* functions different for dialect >= V6_TRANSITION */
nod_subtract2,
nod_multiply2,
nod_divide2,
nod_gen_id2,
nod_average, /* aggregates */
nod_from,
nod_max,
nod_min,
nod_total,
nod_count,
nod_exists,
nod_singular,
nod_agg_average,
nod_agg_max,
nod_agg_min,
nod_agg_total,
nod_agg_count,
nod_average2, /* aggregates different for dialect >= V6_TRANSITION */
nod_agg_average2,
nod_agg_total2,
nod_get_segment, /* blobs */
nod_put_segment,
nod_join_inner, /* join types */
nod_join_left,
nod_join_right,
nod_join_full,
/* sql transaction support */
nod_access,
nod_wait,
nod_isolation,
nod_version,
nod_table_lock,
nod_lock_mode,
nod_reserve,
nod_commit_retain,
/* sql database stmts support */
nod_page_size,
nod_file_length,
nod_file_desc,
nod_log_file_desc,
nod_cache_file_desc,
nod_group_commit_wait,
nod_check_point_len,
nod_num_log_buffers,
nod_log_buffer_size,
nod_drop_log,
nod_drop_cache,
nod_dfl_charset,
/* sql connect options support (used for create database) */
nod_password,
nod_lc_ctype, /* SET NAMES */
/* Misc nodes */
nod_udf_return_value,
/* computed field */
nod_def_computed,
/* access plan stuff */
nod_plan_expr,
nod_plan_item,
nod_merge,
nod_natural,
nod_index,
nod_index_order,
nod_set_generator,
nod_set_generator2, /* SINT64 value for dialect > V6_TRANSITION */
/* alter index */
nod_mod_index,
nod_idx_active,
nod_idx_inactive,
/* drop behaviour */
nod_restrict,
nod_cascade,
/* set statistics */
nod_set_statistics,
/* record version */
nod_rec_version,
/* ANY keyword used */
nod_ansi_any,
nod_eql_any,
nod_neq_any,
nod_gtr_any,
nod_geq_any,
nod_leq_any,
nod_lss_any,
/* ALL keyword used */
nod_ansi_all,
nod_eql_all,
nod_neq_all,
nod_gtr_all,
nod_geq_all,
nod_leq_all,
nod_lss_all,
/*referential integrity actions */
nod_ref_upd_del,
nod_ref_trig_action,
/* SQL role support */
nod_def_role,
nod_role_name,
nod_grant_admin,
nod_del_role,
/* SQL time & date support */
nod_current_time,
nod_current_date,
nod_current_timestamp,
nod_extract,
/* ALTER column/domain support */
nod_mod_domain_type,
nod_mod_field_name,
nod_mod_field_type,
nod_mod_field_pos
} NOD_TYPE;
/* definition of a syntax node created both
in parsing and in context recognition */
typedef struct nod {
struct blk nod_header;
NOD_TYPE nod_type; /* Type of node */
DSC nod_desc; /* Descriptor */
USHORT nod_count; /* Number of arguments */
USHORT nod_flags;
struct nod *nod_arg[1];
} *NOD;
/* values of flags */
#define NOD_AGG_DISTINCT 1
#define NOD_UNION_ALL 1
#define NOD_SINGLETON_SELECT 1
#define NOD_READ_ONLY 1
#define NOD_READ_WRITE 2
#define NOD_WAIT 1
#define NOD_NO_WAIT 2
#define NOD_VERSION 1
#define NOD_NO_VERSION 2
#define NOD_CONCURRENCY 1
#define NOD_CONSISTENCY 2
#define NOD_READ_COMMITTED 4
#define NOD_SHARED 1
#define NOD_PROTECTED 2
#define NOD_READ 4
#define NOD_WRITE 8
#define REF_ACTION_CASCADE 1
#define REF_ACTION_SET_DEFAULT 2
#define REF_ACTION_SET_NULL 4
#define REF_ACTION_NONE 8
/* Node flag indicates that this node has a different type or result
depending on the SQL dialect. */
#define NOD_COMP_DIALECT 16
/* Parameters to MAKE_constant */
#define CONSTANT_STRING 0 /* stored as a string */
#define CONSTANT_SLONG 1 /* stored as a SLONG */
#define CONSTANT_DOUBLE 2 /* stored as a string */
#define CONSTANT_DATE 3 /* stored as a SLONG */
#define CONSTANT_TIME 4 /* stored as a ULONG */
#define CONSTANT_TIMESTAMP 5 /* stored as a QUAD */
#define CONSTANT_SINT64 6 /* stored as a SINT64 */
/* enumerations of the arguments to a node, offsets
within the variable tail nod_arg */
/* Note Bene:
* e_<nodename>_count == count of arguments in nod_arg
* This is often used as the count of sub-nodes, but there
* are cases when non-NOD arguments are stuffed into nod_arg
* entries. These include nod_udf, nod_gen_id, nod_cast,
* & nod_collate.
*/
#define e_fld_context 0 /* nod_field */
#define e_fld_field 1
#define e_fld_indices 2
#define e_fld_count 3
#define e_ary_array 0 /* nod_array */
#define e_ary_indices 1
#define e_ary_count 2
#define e_xcp_name 0 /* nod_exception */
#define e_xcp_text 1
#define e_xcp_count 2
#define e_blk_action 0 /* nod_block */
#define e_blk_errs 1
#define e_blk_count 2
#define e_err_errs 0 /* nod_on_error */
#define e_err_action 1
#define e_err_count 2
#define e_var_variable 0 /* nod_variable */
#define e_var_count 1
#define e_pst_event 0 /* nod_procedure */
#define e_pst_count 1
#define e_rtn_procedure 0 /* nod_procedure */
#define e_rtn_count 1
#define e_vrn_name 0 /* nod_variable_name */
#define e_vrn_count 1
#define e_fln_context 0 /* od_field_name */
#define e_fln_name 1
#define e_fln_count 2
#define e_rel_context 0 /* nod_relation */
#define e_rel_count 1
#define e_agg_context 0 /* nod_aggregate */
#define e_agg_group 1
#define e_agg_rse 2
#define e_agg_count 3
#define e_rse_streams 0 /* nod_rse */
#define e_rse_boolean 1
#define e_rse_sort 2
#define e_rse_reduced 3
#define e_rse_items 4
#define e_rse_first 5
#define e_rse_singleton 6
#define e_rse_plan 7
#define e_rse_count 8
#define e_par_parameter 0 /* nod_parameter */
#define e_par_count 1
#define e_flp_select 0 /* nod_for_select */
#define e_flp_into 1
#define e_flp_cursor 2
#define e_flp_action 3
#define e_flp_count 4
#define e_cur_name 0 /* nod_cursor */
#define e_cur_context 1
#define e_cur_next 2
#define e_cur_count 3
#define e_prc_name 0 /* nod_procedure */
#define e_prc_inputs 1
#define e_prc_outputs 2
#define e_prc_dcls 3
#define e_prc_body 4
#define e_prc_source 5
#define e_prc_cursors 6
#define e_prc_count 7
#define e_exe_procedure 0 /* nod_exec_procedure */
#define e_exe_inputs 1
#define e_exe_outputs 2
#define e_exe_count 3
#define e_msg_number 0 /* nod_message */
#define e_msg_text 1
#define e_msg_count 2
#define e_sel_distinct 0 /* nod_select_expr */
#define e_sel_list 1
#define e_sel_from 2
#define e_sel_where 3
#define e_sel_group 4
#define e_sel_having 5
#define e_sel_plan 6
#define e_sel_singleton 7
#define e_sel_count 8
#define e_ins_relation 0 /* nod_insert */
#define e_ins_fields 1
#define e_ins_values 2
#define e_ins_select 3
#define e_ins_count 4
#define e_sto_relation 0 /* nod_store */
#define e_sto_statement 1
#define e_sto_rse 2
#define e_sto_count 3
#define e_del_relation 0 /* nod_delete */
#define e_del_boolean 1
#define e_del_cursor 2
#define e_del_count 3
#define e_era_relation 0 /* nod_erase */
#define e_era_rse 1
#define e_era_count 2
#define e_erc_context 0 /* nod_erase_current */
#define e_erc_count 1
#define e_mdc_context 0 /* nod_modify_current */
#define e_mdc_update 1
#define e_mdc_statement 2
#define e_mdc_count 3
#define e_upd_relation 0 /* nod_update */
#define e_upd_statement 1
#define e_upd_boolean 2
#define e_upd_cursor 3
#define e_upd_count 4
#define e_mod_source 0 /* nod_modify */
#define e_mod_update 1
#define e_mod_statement 2
#define e_mod_rse 3
#define e_mod_count 4
#define e_map_context 0 /* nod_map */
#define e_map_map 1
#define e_map_count 2
#define e_blb_field 0 /* nod_get_segment & nod_put_segment */
#define e_blb_relation 1
#define e_blb_filter 2
#define e_blb_max_seg 3
#define e_blb_count 4
#define e_idx_unique 0 /* nod_def_index */
#define e_idx_asc_dsc 1
#define e_idx_name 2
#define e_idx_table 3
#define e_idx_fields 4
#define e_idx_count 5
#define e_rln_name 0 /* nod_relation_name */
#define e_rln_alias 1
#define e_rln_count 2
#define e_rpn_name 0 /* nod_rel_proc_name */
#define e_rpn_alias 1
#define e_rpn_inputs 2
#define e_rpn_count 3
#define e_join_left_rel 0 /* nod_join */
#define e_join_type 1
#define e_join_rght_rel 2
#define e_join_boolean 3
#define e_join_count 4
#define e_via_rse 0
#define e_via_value_1 1
#define e_via_value_2 2
#define e_via_count 3
#define e_if_condition 0
#define e_if_true 1
#define e_if_false 2
#define e_if_count 3
#define e_while_cond 0
#define e_while_action 1
#define e_while_number 2
#define e_while_count 3
#define e_drl_name 0 /* nod_def_relation */
#define e_drl_elements 1
#define e_drl_ext_file 2 /* external file */
#define e_drl_count 3
#define e_dft_default 0 /* nod_def_default */
#define e_dft_default_source 1
#define e_dft_count 2
#define e_dom_name 0 /* nod_def_domain */
#define e_dom_default 1
#define e_dom_default_source 2
#define e_dom_constraint 3
#define e_dom_collate 4
#define e_dom_count 5
#define e_dfl_field 0 /* nod_def_field */
#define e_dfl_default 1
#define e_dfl_default_source 2
#define e_dfl_constraint 3
#define e_dfl_collate 4
#define e_dfl_domain 5
#define e_dfl_computed 6
#define e_dfl_count 7
#define e_view_name 0 /* nod_def_view */
#define e_view_fields 1
#define e_view_select 2
#define e_view_check 3
#define e_view_source 4
#define e_view_count 5
#define e_alt_name 0 /* nod_mod_relation */
#define e_alt_ops 1
#define e_alt_count 2
#define e_grant_privs 0 /* nod_grant */
#define e_grant_table 1
#define e_grant_users 2
#define e_grant_grant 3
#define e_grant_count 4
#define e_alias_value 0 /* nod_alias */
#define e_alias_alias 1
#define e_alias_count 2
#define e_rct_name 0 /* nod_rel_constraint */
#define e_rct_type 1
#define e_pri_columns 0 /* nod_primary */
#define e_pri_count 1
#define e_for_columns 0 /* nod_foreign */
#define e_for_reftable 1
#define e_for_refcolumns 2
#define e_for_action 3
#define e_for_count 4
#define e_ref_upd 0 /* nod_ref_upd_del_action */
#define e_ref_del 1
#define e_ref_upd_del_count 2
#define e_ref_trig_action_count 0
#define e_cnstr_name 0 /* nod_def_constraint */
#define e_cnstr_table 1 /* NOTE: IF ADDING AN ARG IT MUST BE */
#define e_cnstr_type 2 /* NULLED OUT WHEN THE NODE IS */
#define e_cnstr_position 3 /* DEFINED IN parse.y */
#define e_cnstr_condition 4
#define e_cnstr_actions 5
#define e_cnstr_source 6
#define e_cnstr_message 7
#define e_cnstr_else 8
#define e_cnstr_count 9
#define e_trg_name 0 /* nod_mod_trigger and nod_def trigger */
#define e_trg_table 1
#define e_trg_active 2
#define e_trg_type 3
#define e_trg_position 4
#define e_trg_actions 5
#define e_trg_source 6
#define e_trg_messages 7
#define e_trg_count 8
#define e_abrt_number 0 /* nod_abort */
#define e_abrt_count 1
#define e_cast_target 0 /* Not a NOD */ /* nod_cast */
#define e_cast_source 1
#define e_cast_count 2
#define e_coll_target 0 /* Not a NOD */ /* nod_collate */
#define e_coll_source 1
#define e_coll_count 2
#define e_order_field 0 /* nod_order */
#define e_order_flag 1
#define e_order_collate 2
#define e_order_count 3
#define e_lock_tables 0
#define e_lock_mode 1
#define e_database_name 0
#define e_database_initial_desc 1
#define e_database_rem_desc 2
#define e_cdb_count 3
#define e_commit_retain 0
#define e_adb_all 0
#define e_adb_count 1
#define e_gen_name 0
#define e_gen_count 1
#define e_filter_name 0
#define e_filter_in_type 1
#define e_filter_out_type 2
#define e_filter_entry_pt 3
#define e_filter_module 4
#define e_filter_count 5
#define e_gen_id_name 0 /* Not a NOD */ /* nod_gen_id */
#define e_gen_id_value 1
#define e_gen_id_count 2
#define e_udf_name 0
#define e_udf_entry_pt 1
#define e_udf_module 2
#define e_udf_args 3
#define e_udf_return_value 4
#define e_udf_count 5
/* computed field */
#define e_cmp_expr 0
#define e_cmp_text 1
/* create shadow */
#define e_shadow_number 0
#define e_shadow_man_auto 1
#define e_shadow_conditional 2
#define e_shadow_name 3
#define e_shadow_length 4
#define e_shadow_sec_files 5
#define e_shadow_count 6
/* alter index */
#define e_alt_index 0
#define e_mod_idx_count 1
#define e_alt_idx_name 0
#define e_alt_idx_name_count 1
/* set statistics */
#define e_stat_name 0
#define e_stat_count 1
/* SQL extract() function */
#define e_extract_count 2
#define e_extract_part 0 /* constant representing part to extract */
#define e_extract_value 1 /* Must be a time or date value */
/* SQL CURRENT_TIME, CURRENT_DATE, CURRENT_TIMESTAMP */
#define e_current_time_count 0
#define e_current_date_count 0
#define e_current_timestamp_count 0
#define e_alt_dom_name 0 /* nod_modify_domain */
#define e_alt_dom_ops 1
#define e_alt_dom_count 2
#define e_mod_dom_new_dom_type 0 /* nod_mod_domain_type */
#define e_mod_dom_count 1
#define e_mod_fld_name_orig_name 0 /* nod_mod_field_name */
#define e_mod_fld_name_new_name 1
#define e_mod_fld_name_count 2
#define e_mod_fld_type 0 /* nod_mod_field_type */
#define e_mod_fld_type_dom_name 2
#define e_mod_fld_type_count 2
#define e_mod_fld_pos_orig_name 0 /* nod_mod_field_position */
#define e_mod_fld_pos_new_position 1
#define e_mod_fld_pos_count 2
#endif /* _DSQL_NODE_H_ */

7
src/dsql/parse.awk Normal file
View File

@ -0,0 +1,7 @@
BEGIN {Output = 1}
/NOT_FLINTSTONE/ {if(FLINTSTONE) Output = 0 ; next}
/END_FLINTSTONE/ {if(FLINTSTONE) Output = 1 ; next}
/FLINT_CACHE/ {if(CACHE && FLINTSTONE) Output = 1 ; next}
/END_CACHE/ {if(CACHE && FLINTSTONE) Output = 0 ; next}
/FLINT_WAL/ {if(WAL && FLINTSTONE) Output = 1 ; next}
/END_WAL/ {if(WAL && FLINTSTONE) Output = 0 ; next}

6796
src/dsql/parse.cpp Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More