diff --git a/sql/Makefile b/sql/Makefile index ec2f045..7a72b99 100644 --- a/sql/Makefile +++ b/sql/Makefile @@ -2,7 +2,7 @@ # Desc: GNU makefile for FLAIM-SQL library and utilities # Tabs: 3 # -# Copyright (c) 2006 Novell, Inc. All Rights Reserved. +# Copyright (c) 2000-2006 Novell, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public @@ -19,7 +19,7 @@ # To contact Novell about this file by physical or electronic mail, # you may find current contact information at www.novell.com # -# $Id$ +# $Id: Makefile 3136 2006-01-25 12:19:01 -0700 (Wed, 25 Jan 2006) dsanders $ #------------------------------------------------------------------------- ############################################################################# @@ -37,143 +37,8 @@ # -- Project -- project_name = flaimsql -project_desc = An embeddable SQL database engine - -# -- Versions -- - -major_version = 6 -minor_version = 0 - -calc_svn_revision = - -ifneq (,$(findstring ignore-local-mods,$(MAKECMDGOALS))) - submake_targets += ignore-local-mods - ignore_local_mods = 1 -endif - -ifneq (,$(findstring ilm,$(MAKECMDGOALS))) - submake_targets += ilm - ignore_local_mods = 1 -endif - -ifdef ignore_local_mods - local_mods_ok = 1 -else - local_mods_ok = -endif - -ifneq (,$(findstring dist,$(MAKECMDGOALS))) - calc_svn_revision = 1 - ifndef ignore_local_mods - local_mods_ok = - endif -endif - -ifneq (,$(findstring rpm,$(MAKECMDGOALS))) - calc_svn_revision = 1 - ifndef ignore_local_mods - local_mods_ok = - endif -endif - -ifneq (,$(findstring pathinfo,$(MAKECMDGOALS))) - calc_svn_revision = 1 - ifndef ignore_local_mods - local_mods_ok = - endif -endif - -ifneq (,$(findstring changelog,$(MAKECMDGOALS))) - - calc_svn_revision = 1 - - # Get the info for this directory - - ifndef svn_user - $(error Must define svn_user= in environment or as a parameter) - endif - - ifndef svn_rev - $(error Must define svn_rev= in environment or as a parameter) - endif - - svnrevs = $(subst :, ,$(svn_rev)) - svn_low_rev = $(word 1,$(svnrevs)) - svn_high_rev = $(word 2,$(svnrevs)) - - svnurl0 := $(shell svn info) - svnurl1 = $(subst URL: ,URL:,$(svnurl0)) - svnurl2 = $(filter URL:%,$(svnurl1)) - svnurl3 = $(subst URL:,,$(svnurl2)) - svnurl = $(subst ://,://$(svn_user)@,$(svnurl3)) -endif - -ifdef calc_svn_revision - - # Get the info for all files. - - ifndef local_mods_ok - srevision := $(shell svnversion . -n) - - ifneq (,$(findstring M,$(srevision))) - $(error Local modifications found - please check in before making distro) - endif - - ifneq (,$(findstring :,$(srevision))) - $(error Mixed revisions in repository - please update before making distro) - endif - endif - - numdigits = $(words $(subst 9,9 ,$(subst 8,8 ,$(subst 7,7 ,\ - $(subst 6,6 ,$(subst 5,5 ,$(subst 4,4 ,$(subst 3,3 ,\ - $(subst 2,2 ,$(subst 1,1 ,$(subst 0,0 ,$(1)))))))))))) - revision0 := $(shell svn info -R) - revision1 = $(subst Last Changed Rev: ,LastChangedRev:,$(revision0)) - revision2 = $(filter LastChangedRev:%,$(revision1)) - revision3 = $(subst LastChangedRev:,,$(revision2)) - revision4 = $(sort $(revision3)) - revision5 = $(foreach num,$(revision4),$(call numdigits,$(num)):$(num)) - revision6 = $(sort $(revision5)) - revision7 = $(word $(words $(revision6)),$(revision6)) - svn_revision = $(word 2,$(subst :, ,$(revision7))) - -else - ifeq "$(wildcard SVNRevision.*)" "" - svn_revision = 0 - else - svn_revision = $(word 2,$(subst ., ,$(wildcard SVNRevision.*))) - endif -endif - -ifeq "$(svn_high_rev)" "" - svn_high_rev = $(svn_revision) -endif - -version = $(major_version).$(minor_version).$(svn_revision) - -so_current = 1 -so_revision = 0 -so_age = 0 -shared_lib_version = - -package_release_num = 1 - -# -- Paths initializations -- - -ifndef rpm_build_root - ifneq (,$(DESTDIR)) - rpm_build_root = $(DESTDIR)/ - else - rpm_build_root = - endif -endif - -install_prefix = /usr - -# -- RPM, SPEC file names - -package_proj_name = lib$(project_name) -package_proj_name_and_ver = $(package_proj_name)-$(version) +project_display_name = FLAIMSQL +project_desc = An extensible, flexible, adaptable, embeddable SQL database engine # -- Target variables -- @@ -187,6 +52,7 @@ win_target = unix_target = netware_target = submake_targets = +netware_ring_0_target = # -- Enable command echoing -- @@ -197,22 +63,6 @@ else ec = @ endif -# -- Determine if we are only cleaning -- - -util_targets = checkdb rebuild view sample sqlshell -test_targets = basictest -all_targets = rpms install libs all allutils test $(util_targets) $(test_targets) -found_targets = $(foreach target,$(MAKECMDGOALS),$(if $(findstring $(target),$(all_targets)),$(target),)) - -ifneq (,$(findstring clean,$(MAKECMDGOALS))) - do_clean = 1 - ifeq ($(if $(findstring 0,$(words $(found_targets))),1,0),0) - $(error Cannot specify other targets with clean target) - endif -else - do_clean = 0 -endif - # -- Determine the host operating system -- ifndef host_os_family @@ -227,9 +77,15 @@ ifndef host_os_family endif endif -ifeq (,$(OSTYPE)) - ifneq (,$(RPM_OS)) - HOSTTYPE = $(RPM_OS) +ifndef host_os_family + ifeq (,$(OSTYPE)) + ifneq (,$(RPM_OS)) + OSTYPE = $(RPM_OS) + endif + endif + + ifeq (,$(OSTYPE)) + OSTYPE := $(shell uname -s) endif endif @@ -251,12 +107,24 @@ ifndef host_os_family endif endif +ifndef host_os_family + ifneq (,$(findstring SunOS,$(OSTYPE))) + host_os_family = solaris + endif +endif + ifndef host_os_family ifneq (,$(findstring darwin,$(OSTYPE))) host_os_family = osx endif endif +ifndef host_os_family + ifneq (,$(findstring Darwin,$(OSTYPE))) + host_os_family = osx + endif +endif + ifndef host_os_family ifneq (,$(findstring aix,$(OSTYPE))) host_os_family = aix @@ -270,7 +138,7 @@ ifndef host_os_family endif ifndef host_os_family - $(error Host operating system could not be determined. You may need to export HOSTTYPE from the environment.) + $(error Host operating system could not be determined. You may need to export OSTYPE from the environment.) endif # -- Target build type -- @@ -354,6 +222,11 @@ ifneq (,$(findstring nlm,$(MAKECMDGOALS))) netware_target = yes target_os_family = netware host_os_family = win + + ifneq (,$(findstring ring0,$(MAKECMDGOALS))) + submake_targets += ring0 + netware_ring_0_target = yes + endif endif ifndef target_os_family @@ -381,7 +254,17 @@ ifeq (,$(HOSTTYPE)) ifneq (,$(RPM_ARCH)) HOSTTYPE = $(RPM_ARCH) endif - $(error HOSTTYPE environment variable has not been set) +endif + +ifeq (,$(HOSTTYPE)) + HOSTTYPE := $(shell uname -p) + ifneq (,$(findstring nvalid,$(HOSTTYPE))) + HOSTTYPE := $(shell uname -m) + endif +endif + +ifeq (,$(HOSTTYPE)) + HOSTYPE := $(shell uname -p) endif ifeq (,$(HOSTTYPE)) @@ -468,6 +351,14 @@ ifndef host_native_word_size endif endif +ifndef host_native_word_size + ifneq (,$(findstring Power,$(HOSTTYPE))) + host_processor_family = powerpc + host_native_word_size = 32 + host_supported_word_sizes = 32 64 + endif +endif + ifndef host_native_word_size ifneq (,$(findstring rs6000,$(HOSTTYPE))) host_processor_family = powerpc @@ -485,7 +376,15 @@ ifndef host_native_word_size endif ifndef host_native_word_size - $(error Unable to determine host word size) + ifneq (,$(findstring 9000,$(HOSTTYPE))) + host_processor_family = hppa + host_native_word_size = 64 + host_supported_word_sizes = 32 64 + endif +endif + +ifndef host_native_word_size + $(error Unable to determine host word size. $(HOSTTYPE)) endif # -- Target word size and processor -- @@ -587,18 +486,196 @@ endif # a sibling to the top directory - which is how it is set up in the # subversion repository. -ifeq "$(wildcard $(topdir)/tools)" "" +ifeq "$(wildcard $(topdir)/tools*)" "" tooldir := $(dir $(topdir))tools/$(host_os_family) else tooldir := $(topdir)/tools/$(host_os_family) endif +# -- Utility variables -- + +em := +sp := $(em) $(em) +percent := \045 +dollar := \044 +question := \077 +asterisk := \052 +dash := \055 +backslash := \134 + +# -- Tools -- + +ifdef unix_target + gprintf = printf +else + gprintf = $(call hostpath,$(tooldir)/printf.exe) +endif + # Determine the toolkit directory ifeq "$(wildcard $(topdir)/ftk)" "" - ftkdir := $(dir $(topdir))ftk + ftk_dir := $(dir $(topdir))ftk else - ftkdir := $(topdir)/ftk + ftk_dir := $(topdir)/ftk +endif + +ftk_src_dir = $(ftk_dir)/src + +# -- Subversion Revision -- + +calc_svn_revision = +ignore_local_mods = + +ifneq (,$(findstring ignore-local-mods,$(MAKECMDGOALS))) + submake_targets += ignore-local-mods + ignore_local_mods = 1 +endif + +ifneq (,$(findstring ilm,$(MAKECMDGOALS))) + submake_targets += ilm + ignore_local_mods = 1 +endif + +ifdef ignore_local_mods + local_mods_ok = 1 +else + local_mods_ok = +endif + +ifneq (,$(findstring dist,$(MAKECMDGOALS))) + calc_svn_revision = 1 + ifndef ignore_local_mods + local_mods_ok = + endif +endif + +ifneq (,$(findstring rpm,$(MAKECMDGOALS))) + calc_svn_revision = 1 + ifndef ignore_local_mods + local_mods_ok = + endif +endif + +ifneq (,$(findstring docs,$(MAKECMDGOALS))) + calc_svn_revision = 1 + ifndef ignore_local_mods + local_mods_ok = + endif +endif + +ifneq (,$(findstring changelog,$(MAKECMDGOALS))) + + calc_svn_revision = 1 + + # Get the info for this directory + + ifndef svn_user + $(error Must define svn_user= in environment or as a parameter) + endif + + ifndef svn_rev + $(error Must define svn_rev= in environment or as a parameter) + endif + + svnrevs = $(subst :, ,$(svn_rev)) + svn_low_rev = $(word 1,$(svnrevs)) + svn_high_rev = $(word 2,$(svnrevs)) + + svnurl0 := $(shell svn info) + svnurl1 = $(subst URL: ,URL:,$(svnurl0)) + svnurl2 = $(filter URL:%,$(svnurl1)) + svnurl3 = $(subst URL:,,$(svnurl2)) + svnurl = $(subst ://,://$(svn_user)@,$(svnurl3)) +endif + +ifdef calc_svn_revision + + # Get the info for all files. + + ifndef local_mods_ok + srevision := $(shell svnversion . -n) + + ifneq (,$(findstring M,$(srevision))) + $(error Local modifications found - please check in before making distro) + endif + + ifneq (,$(findstring :,$(srevision))) + $(error Mixed revisions in repository - please update before making distro) + endif + + srevision := $(shell svnversion $(ftk_dir) -n) + + ifneq (,$(findstring M,$(srevision))) + $(error Local modifications found - please check in before making distro) + endif + + ifneq (,$(findstring :,$(srevision))) + $(error Mixed revisions in repository - please update before making distro) + endif + endif + + numdigits = $(words $(subst 9,9 ,$(subst 8,8 ,$(subst 7,7 ,\ + $(subst 6,6 ,$(subst 5,5 ,$(subst 4,4 ,$(subst 3,3 ,\ + $(subst 2,2 ,$(subst 1,1 ,$(subst 0,0 ,$(1)))))))))))) + revision0 := $(shell svn info -R . $(ftk_dir)) + revision1 = $(subst Last Changed Rev: ,LastChangedRev:,$(revision0)) + revision2 = $(filter LastChangedRev:%,$(revision1)) + revision3 = $(subst LastChangedRev:,,$(revision2)) + revision4 = $(sort $(revision3)) + revision5 = $(foreach num,$(revision4),$(call numdigits,$(num)):$(num)) + revision6 = $(sort $(revision5)) + revision7 = $(word $(words $(revision6)),$(revision6)) + svn_revision = $(word 2,$(subst :, ,$(revision7))) + +else + ifeq "$(wildcard SVNRevision.*)" "" + svn_revision = 0 + else + svn_revision = $(word 2,$(subst ., ,$(wildcard SVNRevision.*))) + endif +endif + +ifeq "$(svn_high_rev)" "" + svn_high_rev = $(svn_revision) +endif + +# -- Versions -- + +major_version = 6 +minor_version = 0 + +version = $(major_version).$(minor_version).$(svn_revision) + +so_current = 1 +so_revision = 0 +so_age = 0 +shared_lib_version = + +package_release_num = 1 + +# -- Paths initializations -- + +install_prefix = /usr + +# -- RPM, SPEC file names + +package_proj_name = lib$(project_name) +package_proj_name_and_ver = $(package_proj_name)-$(version) + +# -- Determine if we are only cleaning -- + +util_targets = checkdb rebuild view sample sqlshell +test_targets = basictest +all_targets = rpms install libs all allutils test $(util_targets) $(test_targets) +found_targets = $(foreach target,$(MAKECMDGOALS),$(if $(findstring $(target),$(all_targets)),$(target),)) + +ifneq (,$(findstring clean,$(MAKECMDGOALS))) + do_clean = 1 + ifeq ($(if $(findstring 0,$(words $(found_targets))),1,0),0) + $(error Cannot specify other targets with clean target) + endif +else + do_clean = 0 endif # Files and Directories @@ -613,11 +690,19 @@ ifndef lib_dir_name lib_dir_name = lib endif +ifndef rpm_build_root + ifneq (,$(DESTDIR)) + rpm_build_root = $(DESTDIR)/ + else + rpm_build_root = + endif +endif + lib_install_dir = $(rpm_build_root)$(install_prefix)/$(lib_dir_name) include_install_dir = $(rpm_build_root)$(install_prefix)/include pkgconfig_install_dir = $(lib_install_dir)/pkgconfig build_output_dir = $(topdir)/build -docs_output_dir = $(build_output_dir)/docs +doxygen_output_dir = $(build_output_dir)/docs target_path = $(build_output_dir)/$(target_os_family)-$(target_processor_family)-$(target_word_size)/$(target_build_type) @@ -654,7 +739,7 @@ rpm_name = $(package_proj_name_and_ver)-$(package_release_num).$(HOSTTYPE).rpm srpm_name = $(package_proj_name_and_ver)-$(package_release_num).src.rpm develrpm_name = $(package_proj_name)-devel-$(version)-$(package_release_num).$(HOSTTYPE).rpm -inc_dirs = src util $(ftkdir)/src +inc_dirs = src util $(ftk_src_dir) util_dir = $(target_path)/util test_dir = $(target_path)/test @@ -669,15 +754,7 @@ sample_obj_dir = $(sample_dir)/obj lib_obj_dir = $(lib_dir)/obj -# -- Utility variables -- - -em := -sp := $(em) $(em) -percent := \045 -dollar := \044 -question := \077 -asterisk := \052 -dash := \055 +doxyfile = $(doxygen_output_dir)/Doxyfile # -- Tools -- @@ -686,12 +763,6 @@ exe_linker = shared_linker = compiler = -ifdef unix_target - gprintf = printf -else - gprintf = $(call hostpath,$(tooldir)/printf.exe) -endif - # Compiler definitions and flags ccflags = @@ -866,8 +937,9 @@ ifdef unix_target endif ifeq ($(target_os_family),solaris) + ifeq ($(usenativecc),yes) - ccflags += -KPIC -errwarn=%all -errtags -erroff=hidef,inllargeuse + ccflags += -KPIC -errwarn=%all -errtags -erroff=hidef,inllargeuse,doubunder ifeq ($(target_word_size),64) ccflags += -xarch=generic64 else @@ -943,7 +1015,7 @@ ifdef unix_target exe_link_libs = -lpthread ifeq ($(target_os_family),linux) - lib_link_libs += -lrt -lstdc++ -ldl + lib_link_libs += -lrt -lstdc++ -ldl -lncurses exe_link_libs += -lrt -lstdc++ -ldl -lncurses shared_link_flags += -shared -Wl,-Bsymbolic -fpic \ -Wl,-soname,$(@F).1 -o $@ @@ -961,23 +1033,23 @@ ifdef unix_target endif endif - lib_link_libs += -lm -lc -ldl -lsocket -lnsl -lrt + lib_link_libs += -lm -lc -ldl -lsocket -lnsl -lrt -lcurses exe_link_libs += -lm -lc -ldl -lsocket -lnsl -lrt -lcurses endif ifeq ($(target_os_family),aix) - lib_link_libs += -lm -lc + lib_link_libs += -lm -lc -lcurses exe_link_libs += -lm -lc -lcurses endif ifeq ($(target_os_family),hpux) - lib_link_libs += -lm -lc -lrt + lib_link_libs += -lm -lc -lrt -lcurses exe_link_libs += -lm -lc -lrt -lcurses endif ifeq ($(target_os_family),osx) shared_lib_suffix = -$(major_version).$(so_current).dylib - lib_link_libs += -lstdc++ -ldl + lib_link_libs += -lstdc++ -ldl -lncurses exe_link_libs += -lstdc++ -ldl -lncurses shared_link_flags += -dynamiclib shared_link_flags += -current_version $(major_version).$(so_current).$(so_revision) @@ -1012,11 +1084,13 @@ ifdef netware_target wc_dir := $(call normpath,$(wc_dir)) - ifndef ndk_dir - $(error Netware SDK could not be found. Please define ndk_dir.) + ifndef netware_ring_0_target + ifndef ndk_dir + $(error Netware SDK could not be found. Please define ndk_dir) + endif + + ndk_dir := $(call normpath,$(ndk_dir)) endif - - ndk_dir := $(call normpath,$(ndk_dir)) libr = "$(call normpath,$(strip $(wc_dir)))/binnt/wlib.exe" exe_linker = "$(call normpath,$(strip $(wc_dir)))/binnt/wlink.exe" @@ -1027,6 +1101,12 @@ ifdef netware_target ccdefs += FLM_DEBUG endif + ifdef netware_ring_0_target + ccdefs += FLM_RING_ZERO_NLM + else + ccdefs += FLM_LIBC_NLM + endif + ccflags += /ez /6s /w4 /za /zp1 /zq /zm /s /ei /of+ /we /bt=NETWARE ifeq ($(build),release) @@ -1046,10 +1126,45 @@ ifdef netware_target export wpp386 = /d$(subst $(sp), /d,$(strip $(ccdefs))) $(ccflags) export wcc386 = /d$(subst $(sp), /d,$(strip $(ccdefs))) $(ccflags) - define make_lis_file_cmd + define make_ring_0_lis_file_cmd + $(ec)$(gprintf) "option verbose\n" > $(4) + $(ec)$(gprintf) "option stack=32k\n" >> $(4) + $(ec)$(gprintf) "option nod\n" >> $(4) + $(ec)$(gprintf) "option map\n" >> $(4) + $(ec)$(gprintf) "option nodefaultlibs\n" >> $(4) + $(ec)$(gprintf) "option screenname 'NONE'\n" >> $(4) + $(ec)$(gprintf) "option threadname '$(2)'\n" >> $(4) + $(ec)$(gprintf) "option start = f_nlmEntryPoint\n" >> $(4) + $(ec)$(gprintf) "option exit = f_nlmExitPoint\n" >> $(4) + $(ec)$(gprintf) "option nodefaultlibs\n" >> $(4) + $(ec)$(gprintf) "option xdcdata=nlm.xdc\n" >> $(4) + $(ec)$(gprintf) "option pseudopreemption\n" >> $(4) + $(ec)$(gprintf) "debug all debug novell\n" >> $(4) + $(ec)$(gprintf) "form novell nlm '$(2)'\n" >> $(4) + $(ec)$(gprintf) "name $(call ppath,$(1)/$(2)$(exe_suffix))\n" >> $(4) + $(ec)$(gprintf) "file $(subst $(sp),\nfile ,$(call ppath,$(3)))\n" >> $(4) + $(ec)$(gprintf) "library $(call ppath,$(flaimsql_static_lib))\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(ctorarst)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(dtorarst)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(undefed)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(undefmbd)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(pure_err)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stablcl)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stabact)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stabactv)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stabmod)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(prwdata)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(moddtorr)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/plib3s.lib)(stabadt)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/netware/clib3s.lib)(i8d)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/netware/clib3s.lib)(i8m)\n" >> $(4) + $(ec)$(gprintf) "file $(call ppath,$(wc_dir)/lib386/netware/clib3s.lib)(i8s)\n" >> $(4) + $(ec)$(gprintf) "alias __wcpp_4_fatal_runtime_error_=f_fatalRuntimeError\n" >> $(4) + endef + + define make_libc_lis_file_cmd $(ec)$(gprintf) "option verbose\n" > $(4) $(ec)$(gprintf) "option stack=32k\n" >> $(4) - $(ec)$(gprintf) "option synchronize\n" >> $(4) $(ec)$(gprintf) "option nod\n" >> $(4) $(ec)$(gprintf) "option map\n" >> $(4) $(ec)$(gprintf) "option nodefaultlibs\n" >> $(4) @@ -1057,26 +1172,180 @@ ifdef netware_target $(ec)$(gprintf) "option threadname '$(2)'\n" >> $(4) $(ec)$(gprintf) "option start = _LibCPrelude\n" >> $(4) $(ec)$(gprintf) "option exit = _LibCPostlude\n" >> $(4) + $(ec)$(gprintf) "option nodefaultlibs\n" >> $(4) + $(ec)$(gprintf) "option xdcdata=nlm.xdc\n" >> $(4) $(ec)$(gprintf) "option pseudopreemption\n" >> $(4) $(ec)$(gprintf) "debug all debug novell\n" >> $(4) $(ec)$(gprintf) "form novell nlm '$(2)'\n" >> $(4) $(ec)$(gprintf) "name $(call ppath,$(1)/$(2)$(exe_suffix))\n" >> $(4) - $(ec)$(gprintf) "file $(subst $(sp),\nfile ,$(call ppath,$(3)))\n" >> $(4) $(ec)$(gprintf) "file $(call ppath,$(ndk_dir)/libc/imports/libcpre.obj)\n" >> $(4) $(ec)$(gprintf) "library $(call ppath,$(flaimsql_static_lib))\n" >> $(4) $(ec)$(gprintf) "library $(call ppath,$(wc_dir)/lib386/plib3s.lib)\n" >> $(4) $(ec)$(gprintf) "library $(call ppath,$(wc_dir)/lib386/netware/libc3s.lib)\n" >> $(4) - $(ec)$(gprintf) "import CurrentProcess\n" >> $(4) - $(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/libc.imp)\n" >> $(4) - $(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/netware.imp)\n" >> $(4) - $(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/ws2nlm.imp)\n" >> $(4) endef - + + define make_ring_0_imp_file_cmd + $(ec)$(gprintf) "import __WSAFDIsSet\n" > $(1) + $(ec)$(gprintf) "import ActivateScreen\n" >> $(1) + $(ec)$(gprintf) "import Alloc\n" >> $(1) + $(ec)$(gprintf) "import AllocateResourceTag\n" >> $(1) + $(ec)$(gprintf) "import atomic_dec\n" >> $(1) + $(ec)$(gprintf) "import atomic_inc\n" >> $(1) + $(ec)$(gprintf) "import atomic_xchg\n" >> $(1) + $(ec)$(gprintf) "import BitTest\n" >> $(1) + $(ec)$(gprintf) "import CEvaluateExpression\n" >> $(1) + $(ec)$(gprintf) "import CFindLoadModuleHandle\n" >> $(1) + $(ec)$(gprintf) "import CheckKeyStatus\n" >> $(1) + $(ec)$(gprintf) "import ClearScreen\n" >> $(1) + $(ec)$(gprintf) "import CloseFile\n" >> $(1) + $(ec)$(gprintf) "import CloseScreen\n" >> $(1) + $(ec)$(gprintf) "import CMovB\n" >> $(1) + $(ec)$(gprintf) "import CMoveFast\n" >> $(1) + $(ec)$(gprintf) "import ConvertPathString\n" >> $(1) + $(ec)$(gprintf) "import ConvertSecondsToTicks\n" >> $(1) + $(ec)$(gprintf) "import ConvertTicksToSeconds\n" >> $(1) + $(ec)$(gprintf) "import CpuCurrentProcessor\n" >> $(1) + $(ec)$(gprintf) "import CreateDirectory\n" >> $(1) + $(ec)$(gprintf) "import CreateFile\n" >> $(1) + $(ec)$(gprintf) "import CSetD\n" >> $(1) + $(ec)$(gprintf) "import DebuggerSymbolList\n" >> $(1) + $(ec)$(gprintf) "import DeleteDirectory\n" >> $(1) + $(ec)$(gprintf) "import DirectorySearch\n" >> $(1) + $(ec)$(gprintf) "import DirectReadFile\n" >> $(1) + $(ec)$(gprintf) "import DirectReadFile\n" >> $(1) + $(ec)$(gprintf) "import DirectWriteFile\n" >> $(1) + $(ec)$(gprintf) "import DirectWriteFile\n" >> $(1) + $(ec)$(gprintf) "import DirectWriteFileNoWait\n" >> $(1) + $(ec)$(gprintf) "import DirectWriteFileNoWait\n" >> $(1) + $(ec)$(gprintf) "import DisableInputCursor\n" >> $(1) + $(ec)$(gprintf) "import DisplayScreenTextWithAttribute\n" >> $(1) + $(ec)$(gprintf) "import DOSFirstByteBitMap\n" >> $(1) + $(ec)$(gprintf) "import EnableInputCursor\n" >> $(1) + $(ec)$(gprintf) "import EnterDebugger\n" >> $(1) + $(ec)$(gprintf) "import EraseFile\n" >> $(1) + $(ec)$(gprintf) "import ExpandFileInContiguousBlocks\n" >> $(1) + $(ec)$(gprintf) "import ExpandFileInContiguousBlocks\n" >> $(1) + $(ec)$(gprintf) "import ExportPublicSymbol\n" >> $(1) + $(ec)$(gprintf) "import FindAndLoadNLM\n" >> $(1) + $(ec)$(gprintf) "import Free\n" >> $(1) + $(ec)$(gprintf) "import FreeLimboVolumeSpace\n" >> $(1) + $(ec)$(gprintf) "import FreeLimboVolumeSpace\n" >> $(1) + $(ec)$(gprintf) "import GetCacheBufferSize\n" >> $(1) + $(ec)$(gprintf) "import GetClosestSymbol\n" >> $(1) + $(ec)$(gprintf) "import GetCurrentClock\n" >> $(1) + $(ec)$(gprintf) "import GetCurrentNumberOfCacheBuffers\n" >> $(1) + $(ec)$(gprintf) "import GetCurrentTime\n" >> $(1) + $(ec)$(gprintf) "import GetEntryFromPathStringBase\n" >> $(1) + $(ec)$(gprintf) "import GetEntryFromPathStringBase\n" >> $(1) + $(ec)$(gprintf) "import GetFileSize\n" >> $(1) + $(ec)$(gprintf) "import GetKey\n" >> $(1) + $(ec)$(gprintf) "import GetNLMAllocMemoryCounts\n" >> $(1) + $(ec)$(gprintf) "import GetOriginalNumberOfCacheBuffers\n" >> $(1) + $(ec)$(gprintf) "import GetProductMajorVersionNumber\n" >> $(1) + $(ec)$(gprintf) "import GetRunningProcess\n" >> $(1) + $(ec)$(gprintf) "import GetScreenSize\n" >> $(1) + $(ec)$(gprintf) "import GetSyncClockFields\n" >> $(1) + $(ec)$(gprintf) "import GetSystemConsoleScreen\n" >> $(1) + $(ec)$(gprintf) "import ImportPublicSymbol\n" >> $(1) + $(ec)$(gprintf) "import kCreateThread\n" >> $(1) + $(ec)$(gprintf) "import kCurrentThread\n" >> $(1) + $(ec)$(gprintf) "import kDelayThread\n" >> $(1) + $(ec)$(gprintf) "import kDestroyThread\n" >> $(1) + $(ec)$(gprintf) "import kExitThread\n" >> $(1) + $(ec)$(gprintf) "import kGetThreadName\n" >> $(1) + $(ec)$(gprintf) "import kGetThreadName\n" >> $(1) + $(ec)$(gprintf) "import KillMe\n" >> $(1) + $(ec)$(gprintf) "import kMutexAlloc\n" >> $(1) + $(ec)$(gprintf) "import kMutexFree\n" >> $(1) + $(ec)$(gprintf) "import kMutexLock\n" >> $(1) + $(ec)$(gprintf) "import kMutexUnlock\n" >> $(1) + $(ec)$(gprintf) "import kReturnCurrentProcessorID\n" >> $(1) + $(ec)$(gprintf) "import kScheduleThread\n" >> $(1) + $(ec)$(gprintf) "import kSemaphoreAlloc\n" >> $(1) + $(ec)$(gprintf) "import kSemaphoreExamineCount\n" >> $(1) + $(ec)$(gprintf) "import kSemaphoreFree\n" >> $(1) + $(ec)$(gprintf) "import kSemaphoreSignal\n" >> $(1) + $(ec)$(gprintf) "import kSemaphoreTimedWait\n" >> $(1) + $(ec)$(gprintf) "import kSemaphoreWait\n" >> $(1) + $(ec)$(gprintf) "import kSetThreadLoadHandle\n" >> $(1) + $(ec)$(gprintf) "import kSetThreadName\n" >> $(1) + $(ec)$(gprintf) "import kYieldIfTimeSliceUp\n" >> $(1) + $(ec)$(gprintf) "import kYieldThread\n" >> $(1) + $(ec)$(gprintf) "import LoadModule\n" >> $(1) + $(ec)$(gprintf) "import LoadRules\n" >> $(1) + $(ec)$(gprintf) "import MapFileHandleToFCB\n" >> $(1) + $(ec)$(gprintf) "import MapPathToDirectoryNumber\n" >> $(1) + $(ec)$(gprintf) "import MapPathToDirectoryNumber\n" >> $(1) + $(ec)$(gprintf) "import MapVolumeNameToNumber\n" >> $(1) + $(ec)$(gprintf) "import ModifyDirectoryEntry\n" >> $(1) + $(ec)$(gprintf) "import ModifyDirectoryEntry\n" >> $(1) + $(ec)$(gprintf) "import MountVolume\n" >> $(1) + $(ec)$(gprintf) "import NDSCreateStreamFile\n" >> $(1) + $(ec)$(gprintf) "import NDSDeleteStreamFile\n" >> $(1) + $(ec)$(gprintf) "import NDSOpenStreamFile\n" >> $(1) + $(ec)$(gprintf) "import NWLocalToUnicode\n" >> $(1) + $(ec)$(gprintf) "import NWUnicodeToLocal\n" >> $(1) + $(ec)$(gprintf) "import OpenFile\n" >> $(1) + $(ec)$(gprintf) "import OpenScreen\n" >> $(1) + $(ec)$(gprintf) "import OutputToScreen\n" >> $(1) + $(ec)$(gprintf) "import PositionInputCursor\n" >> $(1) + $(ec)$(gprintf) "import PositionOutputCursor\n" >> $(1) + $(ec)$(gprintf) "import ReadFile\n" >> $(1) + $(ec)$(gprintf) "import RenameEntry\n" >> $(1) + $(ec)$(gprintf) "import RestartServer\n" >> $(1) + $(ec)$(gprintf) "import ReturnResourceTag\n" >> $(1) + $(ec)$(gprintf) "import ReturnVolumeMappingInformation\n" >> $(1) + $(ec)$(gprintf) "import ReturnVolumeMappingInformation\n" >> $(1) + $(ec)$(gprintf) "import RevokeFileHandleRights\n" >> $(1) + $(ec)$(gprintf) "import SetCursorStyle\n" >> $(1) + $(ec)$(gprintf) "import SetFileSize\n" >> $(1) + $(ec)$(gprintf) "import SetFileSize\n" >> $(1) + $(ec)$(gprintf) "import SGUIDCreate\n" >> $(1) + $(ec)$(gprintf) "import SizeOfAllocBlock\n" >> $(1) + $(ec)$(gprintf) "import SwitchToDirectFileMode\n" >> $(1) + $(ec)$(gprintf) "import SwitchToDirectFileMode\n" >> $(1) + $(ec)$(gprintf) "import UngetKey\n" >> $(1) + $(ec)$(gprintf) "import UnImportPublicSymbol\n" >> $(1) + $(ec)$(gprintf) "import UnloadRules\n" >> $(1) + $(ec)$(gprintf) "import VMGetDirectoryEntry\n" >> $(1) + $(ec)$(gprintf) "import WriteFile\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_bind\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_closesocket\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_gethostbyaddr\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_gethostbyname\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_gethostname\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_htonl\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_htons\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_inet_addr\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_inet_ntoa\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_listen\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_recv\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_select\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_send\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_setsockopt\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_shutdown\n" >> $(1) + $(ec)$(gprintf) "import WS2_32_socket\n" >> $(1) + $(ec)$(gprintf) "import WSAAccept\n" >> $(1) + $(ec)$(gprintf) "import WSACleanup\n" >> $(1) + $(ec)$(gprintf) "import WSAConnect\n" >> $(1) + $(ec)$(gprintf) "import WSAGetLastError\n" >> $(1) + $(ec)$(gprintf) "import WSAStartup\n" >> $(1) + endef + + define make_libc_imp_file_cmd + $(ec)$(gprintf) "import CurrentProcess\n" > $(1) + $(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/libc.imp)\n" >> $(1) + $(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/netware.imp)\n" >> $(1) + $(ec)$(gprintf) "import @$(call ppath,$(ndk_dir)/libc/imports/ws2nlm.imp)\n" >> $(1) + endef + define flm_exe_link_cmd - $(call make_lis_file_cmd,$(1),$(2),$(3),$(call hostpath,$(1)/$(2).lis)) - $(ec)$(call hostpath,$(exe_linker)) @$(call hostpath,$(1)/$(2).lis) + $(call $(if $(netware_ring_0_target),make_ring_0_imp_file_cmd,make_libc_imp_file_cmd),$(call hostpath,$(1)/$(2).imp)) + $(call $(if $(netware_ring_0_target),make_ring_0_lis_file_cmd,make_libc_lis_file_cmd),$(1),$(2),$(3),$(call hostpath,$(1)/$(2).lis)) + $(ec)$(call hostpath,$(exe_linker)) @$(call hostpath,$(1)/$(2).lis) @$(call hostpath,$(1)/$(2).imp) $(ec)$(call rmcmd,$(target_path)/$(1).lis) + $(ec)$(call rmcmd,$(target_path)/$(1).imp) endef endif @@ -1087,12 +1356,11 @@ flaimsql_src = \ $(patsubst src/%.cpp,%.cpp,$(wildcard src/*.cpp)) ftk_src = \ - $(patsubst $(ftkdir)/src/%.cpp,%.cpp,$(wildcard $(ftkdir)/src/*.cpp)) + $(patsubst $(ftk_src_dir)/%.cpp,%.cpp,$(wildcard $(ftk_src_dir)/*.cpp)) util_common_src = \ flm_dlst.cpp \ flm_lutl.cpp \ - ftx.cpp \ sharutil.cpp checkdb_src = \ @@ -1118,9 +1386,9 @@ sample_src = \ sample.cpp \ $(util_common_src) -xshell_src = \ +sqlshell_src = \ fdomedt.cpp \ - xshell.cpp \ + sqlshell.cpp \ fshell.cpp \ $(util_common_src) @@ -1128,91 +1396,7 @@ ut_basictest_src = \ flmunittest.cpp \ basictestsrv.cpp -ut_binarytest_src = \ - flmunittest.cpp \ - binarytest.cpp - -ut_colldeftest_src = \ - flmunittest.cpp \ - colldeftestsrv.cpp - -ut_dictchangetest_src = \ - flmunittest.cpp \ - dictchangetest.cpp - -ut_dictdeftest_src = \ - flmunittest.cpp \ - dictdeftestsrv.cpp - -ut_dirtyexittest1_src = \ - flmunittest.cpp \ - dirtyexittest1srv.cpp - -ut_dirtyexittest2_src = \ - flmunittest.cpp \ - dirtyexittest2srv.cpp - -ut_domnodetest_src = \ - flmunittest.cpp \ - domnodetestsrv.cpp - -ut_enctest_src = \ - flmunittest.cpp \ - enctestsrv.cpp - -ut_importtest_src = \ - flmunittest.cpp \ - importtestsrv.cpp - -ut_indexdeftest_src = \ - flmunittest.cpp \ - indexdeftestsrv.cpp - -ut_indextest1_src = \ - flmunittest.cpp \ - indextest1srv.cpp - -ut_indextest2_src = \ - flmunittest.cpp \ - indextest2srv.cpp - -ut_indextest3_src = \ - flmunittest.cpp \ - indextest3.cpp - -ut_metaphonetest_src = \ - flmunittest.cpp \ - metaphonetestsrv.cpp - -ut_namespacetest_src = \ - flmunittest.cpp \ - namespacetestsrv.cpp - -ut_regressiontest_src = \ - flmunittest.cpp \ - regressiontest.cpp - -ut_rfltest_src = \ - flmunittest.cpp \ - rfltestsrv.cpp - -ut_sortkeytest_src = \ - flmunittest.cpp \ - sortkeytest.cpp - -ut_sortkeytest2_src = \ - flmunittest.cpp \ - sortkeytest2.cpp - -ut_xpathtest1_src = \ - flmunittest.cpp \ - xpathtest1srv.cpp - -ut_xpathtest2_src = \ - flmunittest.cpp \ - xpathtest2srv.cpp - -# -- XFLAIM library -- +# -- FLAIMSQL library -- ftk_obj = $(patsubst %.cpp,$(lib_obj_dir)/%$(obj_suffix),$(ftk_src)) flaimsql_obj = $(patsubst %.cpp,$(lib_obj_dir)/%$(obj_suffix),$(flaimsql_src)) @@ -1237,15 +1421,15 @@ rebuild_exe = $(util_dir)/rebuild$(exe_suffix) view_obj = $(patsubst %.cpp,$(util_obj_dir)/%$(obj_suffix),$(view_src)) view_exe = $(util_dir)/view$(exe_suffix) -xshell_obj = $(patsubst %.cpp,$(util_obj_dir)/%$(obj_suffix),$(xshell_src)) -xshell_exe = $(util_dir)/xshell$(exe_suffix) +sqlshell_obj = $(patsubst %.cpp,$(util_obj_dir)/%$(obj_suffix),$(sqlshell_src)) +sqlshell_exe = $(util_dir)/sqlshell$(exe_suffix) sample_obj = $(patsubst %.cpp,$(sample_obj_dir)/%$(obj_suffix),$(sample_src)) sample_exe = $(sample_dir)/sample$(exe_suffix) # -- Make system pattern search paths -- -vpath %.cpp src util sample ../ftk/src +vpath %.cpp src util sample $(ftk_src_dir) # -- Default target -- @@ -1279,7 +1463,7 @@ endif $(foreach tmpl,lib util sample test,$(eval $(call cpp_to_obj_template,$(tmpl)))) -# -- xflaim.lib and libxflaim.a -- +# -- flaimsql.lib and libflaimsql.a -- $(flaimsql_static_lib) : $(flaimsql_obj) $(ftk_obj) $(ec)$(gprintf) "Building $@ ...\n" @@ -1299,7 +1483,7 @@ ifdef netware_target $(ec)$(call hostpath,$(libr)) $(libflags) $(call hostpath,$(flaimsql_static_lib)) @$(call hostpath,$(static_lib_dir)/xflmlib.lis) endif -# -- xflaim.dll and libxflaim.so -- +# -- flaimsql.dll and libflaimsql.so -- $(flaimsql_shared_lib) : $(flaimsql_obj) $(ftk_obj) $(ec)$(gprintf) "Building $@ ...\n" @@ -1311,7 +1495,7 @@ ifdef unix_target $(ec)$(shared_linker) $+ $(shared_link_flags) $(lib_link_libs) endif -# -- xflaim.lib import library -- +# -- flaimsql.lib import library -- $(flaimsql_shared_imp_lib) : $(flaimsql_shared_lib) $(ec)$(gprintf) "Building $@ ...\n" @@ -1357,13 +1541,13 @@ $(sample_exe): $(sample_obj) $(flaimsql_static_lib) $(call flm_exe_link_cmd,$(sample_dir),sample,$(sample_obj)) $(ec)$(call copycmd,sample/xmlfiles/*.xml,$(sample_dir)) -# -- xshell -- +# -- sqlshell -- -.PHONY : xshell -xshell: status clean dircheck libs $(xshell_exe) -$(xshell_exe): $(xshell_obj) $(flaimsql_static_lib) +.PHONY : sqlshell +sqlshell: status clean dircheck libs $(sqlshell_exe) +$(sqlshell_exe): $(sqlshell_obj) $(flaimsql_static_lib) $(ec)$(gprintf) "Linking $@ ...\n" - $(call flm_exe_link_cmd,$(sample_dir),sample,$(sample_obj)) + $(call flm_exe_link_cmd,$(util_dir),sqlshell,$(sqlshell_obj)) # -- basictest -- @@ -1563,13 +1747,14 @@ srcdist: status clean dircheck docs spec $(ec)$(call make_version_files,$(package_stage_dir)) $(ec)$(call copycmd,Makefile,$(package_stage_dir)) $(ec)$(call copycmd,COPYING,$(package_stage_dir)) - $(ec)$(call copycmd,Doxyfile,$(package_stage_dir)) + $(ec)$(call dircopycmd,docs,$(package_stage_dir)/docs) $(ec)$(call dircopycmd,src,$(package_stage_dir)/src) $(ec)$(call dircopycmd,util,$(package_stage_dir)/util) $(ec)$(call dircopycmd,sample,$(package_stage_dir)/sample) - $(ec)$(call dircopycmd,$(docs_output_dir),$(package_stage_dir)/docs) + $(ec)$(call dircopycmd,$(doxygen_output_dir),$(package_stage_dir)/docs) $(ec)$(call dircopycmd,$(dir $(topdir))tools,$(package_stage_dir)/tools) - $(ec)$(call dircopycmd,$(dir $(topdir))ftk,$(package_stage_dir)/ftk) + $(ec)$(call mkdircmd,$(package_stage_dir)/ftk) + $(ec)$(call dircopycmd,$(dir $(topdir))ftk/src,$(package_stage_dir)/ftk/src) ifneq ($(host_os_family),win) -$(ec)rm -rf `find $(package_stage_dir) -name .svn` endif @@ -1579,7 +1764,6 @@ endif $(ec)$(call create_archive,$(package_stage_parent_dir), \ $(src_package_dir)/$(src_package_base_name), \ $(package_proj_name_and_ver)) - $(ec)$(call copycmd,$(package_proj_name).changes,$(package_stage_dir)) $(ec)$(call rmdircmd,$(package_stage_dir)) $(ec)$(gprintf) "Source package created.\n" @@ -1606,7 +1790,8 @@ binpackage: status $(ec)$(call mkdircmd,$(package_util_stage_dir)) $(ec)$(call make_version_files,$(package_stage_dir)) $(ec)$(call copycmd,COPYING,$(package_stage_dir)) - $(ec)$(call copycmd,src/xflaim.h,$(package_inc_stage_dir)) + $(ec)$(call copycmd,src/flaimsql.h,$(package_inc_stage_dir)) + $(ec)$(call copycmd,$(ftk_src_dir)/ftk.h,$(package_inc_stage_dir)/flaimsqltk.h) $(ec)$(call copycmd,$(flaimsql_static_lib),$(package_static_lib_stage_dir)) ifdef flaimsql_shared_lib $(ec)$(call copycmd,$(flaimsql_shared_lib),$(package_shared_lib_stage_dir)) @@ -1617,7 +1802,7 @@ endif $(ec)$(call copycmd,$(checkdb_exe),$(package_util_stage_dir)) $(ec)$(call copycmd,$(rebuild_exe),$(package_util_stage_dir)) $(ec)$(call copycmd,$(view_exe),$(package_util_stage_dir)) - $(ec)$(call copycmd,$(xshell_exe),$(package_util_stage_dir)) + $(ec)$(call copycmd,$(sqlshell_exe),$(package_util_stage_dir)) $(ec)$(call create_archive,$(package_stage_parent_dir), \ $(bin_package_dir)/$(bin_package_base_name), \ $(package_proj_name_and_ver)) @@ -1642,16 +1827,6 @@ dist: status clean dircheck srcdist $(ec)$(call rmcmd,$(package_dir)/$(src_package_name)) $(ec)$(gprintf) "Distribution created.\n" -# -- pathinfo -- - -.PHONY : pathinfo -pathinfo: - $(ec)$(gprintf) "srcpackage = $(call ppath,$(src_package_dir)/$(src_package_name))\n" - $(ec)$(gprintf) "binpackage = $(call ppath,$(bin_package_dir)/$(bin_package_name))\n" - $(ec)$(gprintf) "rpm = $(call ppath,$(package_rpms_dir)/$(HOSTTYPE)/$(rpm_name))\n" - $(ec)$(gprintf) "srcrpm = $(call ppath,$(package_srpms_dir)/$(srpm_name))\n" - $(ec)$(gprintf) "develrpm = $(call ppath,$(package_rpms_dir)/$(HOSTTYPE)/$(develrpm_name))\n" - # -- Change log -- .PHONY : changelog @@ -1673,7 +1848,8 @@ ifneq ($(host_os_family),win) install --mode=644 $(flaimsql_shared_lib) $(lib_install_dir) install --mode=644 $(flaimsql_static_lib) $(lib_install_dir) install --mode=644 $(pkgconfig_file) $(pkgconfig_install_dir) - install --mode=644 src/xflaim.h $(include_install_dir) + install --mode=644 src/flaimsql.h $(include_install_dir) + install --mode=644 src/flaimsqltk.h $(include_install_dir) -ldconfig $(lib_install_dir) -l -v $(lib_install_dir)/$(lib_prefix)$(project_name)$(shared_lib_suffix) $(ec)$(gprintf) "Installation complete.\n" endif @@ -1687,7 +1863,8 @@ ifneq ($(host_os_family),win) -rm -rf $(lib_install_dir)/$(lib_prefix)$(project_name)*$(shared_lib_suffix)* -rm -rf $(lib_install_dir)/$(lib_prefix)$(project_name)$(static_lib_suffix) -rm -rf $(pkgconfig_install_dir)/$(pkgconfig_file_name) - -rm -rf $(include_install_dir)/xflaim.h + -rm -rf $(include_install_dir)/flaimsql.h + -rm -rf $(include_install_dir)/flaimsqltk.h $(ec)$(gprintf) "Uninstalled.\n" endif @@ -1710,7 +1887,7 @@ spec: dircheck $(ec)$(gprintf) "BuildRoot: $(percent){_tmppath}/$(percent){name}-$(percent){version}-build\n" >> $(spec_file) $(ec)$(gprintf) "\n" >> $(spec_file) $(ec)$(gprintf) "$(percent)description\n" >> $(spec_file) - $(ec)$(gprintf) "XFLAIM is an embeddable cross-platform XML database engine that\n" >> $(spec_file) + $(ec)$(gprintf) "FLAIM-SQL is an embeddable cross-platform SQL database engine that\n" >> $(spec_file) $(ec)$(gprintf) "provides a rich, powerful, easy-to-use feature set. It has proven to be\n" >> $(spec_file) $(ec)$(gprintf) "highly scalable, reliable, and robust. It is available on a wide\n" >> $(spec_file) $(ec)$(gprintf) "variety of 32 bit and 64 bit platforms.\n" >> $(spec_file) @@ -1721,12 +1898,12 @@ spec: dircheck $(ec)$(gprintf) " Andrew Hodgkinson\n" >> $(spec_file) $(ec)$(gprintf) "\n" >> $(spec_file) $(ec)$(gprintf) "$(percent)package devel\n" >> $(spec_file) - $(ec)$(gprintf) "Summary: XFLAIM static library and header file\n" >> $(spec_file) + $(ec)$(gprintf) "Summary: FLAIMSQL static library and header file\n" >> $(spec_file) $(ec)$(gprintf) "Group: Development/Libraries/C and C++\n" >> $(spec_file) $(ec)$(gprintf) "Provides: $(package_proj_name)-devel\n" >> $(spec_file) $(ec)$(gprintf) "\n" >> $(spec_file) $(ec)$(gprintf) "$(percent)description devel\n" >> $(spec_file) - $(ec)$(gprintf) "XFLAIM is an embeddable cross-platform XML database engine that\n" >> $(spec_file) + $(ec)$(gprintf) "FLAIMSQL is an embeddable cross-platform SQL database engine that\n" >> $(spec_file) $(ec)$(gprintf) "provides a rich, powerful, easy-to-use feature set. It has proven to be\n" >> $(spec_file) $(ec)$(gprintf) "highly scalable, reliable, and robust. It is available on a wide\n" >> $(spec_file) $(ec)$(gprintf) "variety of 32 bit and 64 bit platforms.\n" >> $(spec_file) @@ -1757,7 +1934,8 @@ spec: dircheck $(ec)$(gprintf) "$(percent)files devel\n" >> $(spec_file) $(ec)$(gprintf) "$(percent){prefix}/$(percent){_lib}/$(lib_prefix)$(project_name)$(static_lib_suffix)\n" >> $(spec_file) $(ec)$(gprintf) "$(percent){prefix}/$(percent){_lib}/pkgconfig/$(pkgconfig_file_name)\n" >> $(spec_file) - $(ec)$(gprintf) "$(percent){prefix}/include/xflaim.h\n" >> $(spec_file) + $(ec)$(gprintf) "$(percent){prefix}/include/flaimsql.h\n" >> $(spec_file) + $(ec)$(gprintf) "$(percent){prefix}/include/flaimsqltk.h\n" >> $(spec_file) $(ec)$(gprintf) "Created spec file.\n" # -- PKG-CONFIG -- @@ -1771,7 +1949,7 @@ pkgconfig: dircheck $(ec)$(gprintf) "Name: $(package_proj_name)\n" >> $(pkgconfig_file) $(ec)$(gprintf) "Description: $(project_desc)\n" >> $(pkgconfig_file) $(ec)$(gprintf) "Version: $(version)\n" >> $(pkgconfig_file) - $(ec)$(gprintf) "Libs: $(lib_link_libs) -lxflaim -L$(dollar){libdir}\n" >> $(pkgconfig_file) + $(ec)$(gprintf) "Libs: $(lib_link_libs) -lflaimsql -L$(dollar){libdir}\n" >> $(pkgconfig_file) $(ec)$(gprintf) "Cflags: -I$(dollar){includedir}\n" >> $(pkgconfig_file) # -- SRCRPM -- @@ -1785,45 +1963,29 @@ srcrpm: srcdist spec # -- RPMS -- .PHONY : rpms -rpms: dist spec +rpms: spec srcdist $(ec)$(gprintf) "Creating source and binary RPMs ...\n" - $(ec)rpmbuild --define="_topdir $(package_dir)" --quiet -ba $(spec_file) + $(ec)rpmbuild --define="_topdir $(package_dir)" --quiet --nodeps -ba $(spec_file) $(ec)find $(package_dir) -name *.rpm | xargs chmod 775 $(ec)$(gprintf) "Source and binary RPMs created.\n" # -- Documentation -- .PHONY : docs -docs: status clean dircheck +docs: status clean dircheck doxyfile $(ec)$(gprintf) "Creating documentation ...\n" - $(ec)doxygen Doxyfile + $(ec)doxygen $(doxyfile) $(ec)$(gprintf) "Documentation created.\n" # -- misc. targets -- -.PHONY : status -status: - $(ec)$(gprintf) "===============================================================================\n" - $(ec)$(gprintf) "SVN Revision.................... $(svn_revision)\n" - $(ec)$(gprintf) "Host Operating System Family.... $(host_os_family)\n" - $(ec)$(gprintf) "Top Directory................... $(call ppath,$(topdir))\n" - $(ec)$(gprintf) "Toolkit Directory............... $(call ppath,$(ftkdir))\n" - $(ec)$(gprintf) "Target Operating System Family.. $(target_os_family)\n" - $(ec)$(gprintf) "Target Processor Family......... $(target_processor_family)\n" - $(ec)$(gprintf) "Target Word Size................ $(target_word_size)\n" - $(ec)$(gprintf) "Target Build Type............... $(target_build_type)\n" - $(ec)$(gprintf) "Target Path..................... $(call ppath,$(target_path))\n" - $(ec)$(gprintf) "Compiler........................ $(call ppath,$(compiler))\n" - $(ec)$(gprintf) "Librarian....................... $(call ppath,$(libr))\n" - $(ec)$(gprintf) "Defines......................... $(strip $(ccdefs))\n" - $(ec)$(gprintf) "===============================================================================\n" - .PHONY : dircheck dircheck: $(ec)$(call mkdircmd,$(util_obj_dir)) $(ec)$(call mkdircmd,$(test_obj_dir)) $(ec)$(call mkdircmd,$(sample_obj_dir)) $(ec)$(call mkdircmd,$(lib_obj_dir)) + $(ec)$(call mkdircmd,$(doxygen_output_dir)) $(ec)$(call mkdircmd,$(util_dir)) $(ec)$(call mkdircmd,$(test_dir)) $(ec)$(call mkdircmd,$(sample_dir)) @@ -1915,6 +2077,10 @@ osx: nlm: $(ec)$(gprintf) "" +.PHONY : ring0 +ring0: + $(ec)$(gprintf) "" + .PHONY : verbose verbose: $(ec)$(gprintf) "" @@ -1964,3 +2130,203 @@ mostlyclean : clean maintainer-clean: -$(ec)$(call rmdircmd,$(build_output_dir)) -$(ec)$(call rmcmd,*.pch) + +.PHONY : status +status: + $(ec)$(gprintf) "===============================================================================\n" + $(ec)$(gprintf) "SVN Revision.................... $(svn_revision)\n" + $(ec)$(gprintf) "Host Operating System Family.... $(host_os_family)\n" + $(ec)$(gprintf) "Top Directory................... $(call ppath,$(topdir))\n" + $(ec)$(gprintf) "Target Operating System Family.. $(target_os_family)\n" + $(ec)$(gprintf) "Target Processor Family......... $(target_processor_family)\n" + $(ec)$(gprintf) "Target Word Size................ $(target_word_size)\n" + $(ec)$(gprintf) "Target Build Type............... $(target_build_type)\n" + $(ec)$(gprintf) "Target Path..................... $(call ppath,$(target_path))\n" + $(ec)$(gprintf) "Compiler........................ $(call ppath,$(compiler))\n" + $(ec)$(gprintf) "Librarian....................... $(call ppath,$(libr))\n" + $(ec)$(gprintf) "Defines......................... $(strip $(ccdefs))\n" + $(ec)$(gprintf) "===============================================================================\n" + +.PHONY : doxyfile +doxyfile: dircheck + $(ec)$(gprintf) "PROJECT_NAME = \"$(project_display_name)\"\n" > $(doxyfile) + $(ec)$(gprintf) "PROJECT_NUMBER = \"$(version)\"\n" >> $(doxyfile) + $(ec)$(gprintf) "OUTPUT_DIRECTORY = $(doxygen_output_dir)\n" >> $(doxyfile) + $(ec)$(gprintf) "CREATE_SUBDIRS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "OUTPUT_LANGUAGE = English\n" >> $(doxyfile) + $(ec)$(gprintf) "USE_WINDOWS_ENCODING = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "BRIEF_MEMBER_DESC = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "REPEAT_BRIEF = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "ABBREVIATE_BRIEF = \"The $(dollar)name class\" $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " \"The $(dollar)name widget\" $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " \"The $(dollar)name file\" $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " is $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " provides $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " specifies $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " contains $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " represents $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " a $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " an $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " the\n" >> $(doxyfile) + $(ec)$(gprintf) "ALWAYS_DETAILED_SEC = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "INLINE_INHERITED_MEMB = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "FULL_PATH_NAMES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "STRIP_FROM_PATH = \"\"\n" >> $(doxyfile) + $(ec)$(gprintf) "STRIP_FROM_INC_PATH = \n" >> $(doxyfile) + $(ec)$(gprintf) "SHORT_NAMES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "JAVADOC_AUTOBRIEF = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "MULTILINE_CPP_IS_BRIEF = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "DETAILS_AT_TOP = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "INHERIT_DOCS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "SEPARATE_MEMBER_PAGES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "TAB_SIZE = 3\n" >> $(doxyfile) + $(ec)$(gprintf) "ALIASES = \n" >> $(doxyfile) + $(ec)$(gprintf) "OPTIMIZE_OUTPUT_FOR_C = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "OPTIMIZE_OUTPUT_JAVA = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "BUILTIN_STL_SUPPORT = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "DISTRIBUTE_GROUP_DOC = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "SUBGROUPING = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "EXTRACT_ALL = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "EXTRACT_PRIVATE = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "EXTRACT_STATIC = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "EXTRACT_LOCAL_CLASSES = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "EXTRACT_LOCAL_METHODS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "HIDE_UNDOC_MEMBERS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "HIDE_UNDOC_CLASSES = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "HIDE_FRIEND_COMPOUNDS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "HIDE_IN_BODY_DOCS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "INTERNAL_DOCS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "CASE_SENSE_NAMES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "HIDE_SCOPE_NAMES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "SHOW_INCLUDE_FILES = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "INLINE_INFO = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "SORT_MEMBER_DOCS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "SORT_BRIEF_DOCS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "SORT_BY_SCOPE_NAME = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_TODOLIST = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_TESTLIST = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_BUGLIST = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_DEPRECATEDLIST= YES\n" >> $(doxyfile) + $(ec)$(gprintf) "ENABLED_SECTIONS = \n" >> $(doxyfile) + $(ec)$(gprintf) "MAX_INITIALIZER_LINES = 30\n" >> $(doxyfile) + $(ec)$(gprintf) "SHOW_USED_FILES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "SHOW_DIRECTORIES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "FILE_VERSION_FILTER = \n" >> $(doxyfile) + $(ec)$(gprintf) "QUIET = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "WARNINGS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "WARN_IF_UNDOCUMENTED = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "WARN_IF_DOC_ERROR = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "WARN_NO_PARAMDOC = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "WARN_FORMAT = \"$(dollar)file:$(dollar)line: $(dollar)text\"\n" >> $(doxyfile) + $(ec)$(gprintf) "WARN_LOGFILE = \n" >> $(doxyfile) + $(ec)$(gprintf) "INPUT = src/flaimsql.h $(backslash)\n" >> $(doxyfile) + $(ec)$(gprintf) " $(ftk_src_dir)/ftk.h\n" >> $(doxyfile) + $(ec)$(gprintf) "FILE_PATTERNS = *.h\n" >> $(doxyfile) + $(ec)$(gprintf) "RECURSIVE = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "EXCLUDE = \n" >> $(doxyfile) + $(ec)$(gprintf) "EXCLUDE_SYMLINKS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "EXCLUDE_PATTERNS = \n" >> $(doxyfile) + $(ec)$(gprintf) "EXAMPLE_PATH = \n" >> $(doxyfile) + $(ec)$(gprintf) "EXAMPLE_PATTERNS = *\n" >> $(doxyfile) + $(ec)$(gprintf) "EXAMPLE_RECURSIVE = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "IMAGE_PATH = \n" >> $(doxyfile) + $(ec)$(gprintf) "INPUT_FILTER = \n" >> $(doxyfile) + $(ec)$(gprintf) "FILTER_PATTERNS = \n" >> $(doxyfile) + $(ec)$(gprintf) "FILTER_SOURCE_FILES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "SOURCE_BROWSER = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "INLINE_SOURCES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "STRIP_CODE_COMMENTS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "REFERENCED_BY_RELATION = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "REFERENCES_RELATION = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "USE_HTAGS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "VERBATIM_HEADERS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "ALPHABETICAL_INDEX = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "COLS_IN_ALPHA_INDEX = 5\n" >> $(doxyfile) + $(ec)$(gprintf) "IGNORE_PREFIX = \n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_HTML = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "HTML_OUTPUT = html\n" >> $(doxyfile) + $(ec)$(gprintf) "HTML_FILE_EXTENSION = .html\n" >> $(doxyfile) + $(ec)$(gprintf) "HTML_HEADER = \n" >> $(doxyfile) + $(ec)$(gprintf) "HTML_FOOTER = \n" >> $(doxyfile) + $(ec)$(gprintf) "HTML_STYLESHEET = \n" >> $(doxyfile) + $(ec)$(gprintf) "HTML_ALIGN_MEMBERS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_HTMLHELP = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "CHM_FILE = \n" >> $(doxyfile) + $(ec)$(gprintf) "HHC_LOCATION = \n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_CHI = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "BINARY_TOC = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "TOC_EXPAND = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "DISABLE_INDEX = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "ENUM_VALUES_PER_LINE = 4\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_TREEVIEW = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "TREEVIEW_WIDTH = 250\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_LATEX = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "LATEX_OUTPUT = latex\n" >> $(doxyfile) + $(ec)$(gprintf) "LATEX_CMD_NAME = latex\n" >> $(doxyfile) + $(ec)$(gprintf) "MAKEINDEX_CMD_NAME = makeindex\n" >> $(doxyfile) + $(ec)$(gprintf) "COMPACT_LATEX = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "PAPER_TYPE = a4wide\n" >> $(doxyfile) + $(ec)$(gprintf) "EXTRA_PACKAGES = \n" >> $(doxyfile) + $(ec)$(gprintf) "LATEX_HEADER = \n" >> $(doxyfile) + $(ec)$(gprintf) "PDF_HYPERLINKS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "USE_PDFLATEX = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "LATEX_BATCHMODE = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "LATEX_HIDE_INDICES = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_RTF = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "RTF_OUTPUT = rtf\n" >> $(doxyfile) + $(ec)$(gprintf) "COMPACT_RTF = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "RTF_HYPERLINKS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "RTF_STYLESHEET_FILE = \n" >> $(doxyfile) + $(ec)$(gprintf) "RTF_EXTENSIONS_FILE = \n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_MAN = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "MAN_OUTPUT = man\n" >> $(doxyfile) + $(ec)$(gprintf) "MAN_EXTENSION = .3\n" >> $(doxyfile) + $(ec)$(gprintf) "MAN_LINKS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_XML = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "XML_OUTPUT = xml\n" >> $(doxyfile) + $(ec)$(gprintf) "XML_SCHEMA = \n" >> $(doxyfile) + $(ec)$(gprintf) "XML_DTD = \n" >> $(doxyfile) + $(ec)$(gprintf) "XML_PROGRAMLISTING = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_AUTOGEN_DEF = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_PERLMOD = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "PERLMOD_LATEX = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "PERLMOD_PRETTY = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "PERLMOD_MAKEVAR_PREFIX = \n" >> $(doxyfile) + $(ec)$(gprintf) "ENABLE_PREPROCESSING = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "MACRO_EXPANSION = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "EXPAND_ONLY_PREDEF = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "SEARCH_INCLUDES = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "INCLUDE_PATH = \n" >> $(doxyfile) + $(ec)$(gprintf) "INCLUDE_FILE_PATTERNS = \n" >> $(doxyfile) + $(ec)$(gprintf) "PREDEFINED = \n" >> $(doxyfile) + $(ec)$(gprintf) "EXPAND_AS_DEFINED = \n" >> $(doxyfile) + $(ec)$(gprintf) "SKIP_FUNCTION_MACROS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "TAGFILES = \n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_TAGFILE = \n" >> $(doxyfile) + $(ec)$(gprintf) "ALLEXTERNALS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "EXTERNAL_GROUPS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "PERL_PATH = \n" >> $(doxyfile) + $(ec)$(gprintf) "CLASS_DIAGRAMS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "HIDE_UNDOC_RELATIONS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "HAVE_DOT = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "CLASS_GRAPH = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "COLLABORATION_GRAPH = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "GROUP_GRAPHS = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "UML_LOOK = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "TEMPLATE_RELATIONS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "INCLUDE_GRAPH = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "INCLUDED_BY_GRAPH = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "CALL_GRAPH = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "GRAPHICAL_HIERARCHY = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "DIRECTORY_GRAPH = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "DOT_IMAGE_FORMAT = png\n" >> $(doxyfile) + $(ec)$(gprintf) "DOT_PATH = \n" >> $(doxyfile) + $(ec)$(gprintf) "DOTFILE_DIRS = \n" >> $(doxyfile) + $(ec)$(gprintf) "MAX_DOT_GRAPH_WIDTH = 1024\n" >> $(doxyfile) + $(ec)$(gprintf) "MAX_DOT_GRAPH_HEIGHT = 1024\n" >> $(doxyfile) + $(ec)$(gprintf) "MAX_DOT_GRAPH_DEPTH = 1000\n" >> $(doxyfile) + $(ec)$(gprintf) "DOT_TRANSPARENT = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "DOT_MULTI_TARGETS = NO\n" >> $(doxyfile) + $(ec)$(gprintf) "GENERATE_LEGEND = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "DOT_CLEANUP = YES\n" >> $(doxyfile) + $(ec)$(gprintf) "SEARCHENGINE = NO\n" >> $(doxyfile) diff --git a/sql/src/fdbcnfig.cpp b/sql/src/fdbcnfig.cpp index e2be908..70409a3 100644 --- a/sql/src/fdbcnfig.cpp +++ b/sql/src/fdbcnfig.cpp @@ -1163,9 +1163,9 @@ RCODE F_Db::getDiskSpaceUsage( // Open the file and get its size. - if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->openBlockFile( + if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->openFile( szTmpName, FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, - 512, &pFileHdl))) + &pFileHdl))) { if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) diff --git a/sql/src/fdbcopy.cpp b/sql/src/fdbcopy.cpp index 82888ff..ac2ced0 100644 --- a/sql/src/fdbcopy.cpp +++ b/sql/src/fdbcopy.cpp @@ -20,7 +20,7 @@ // To contact Novell about this file by physical or electronic mail, // you may find current contact information at www.novell.com // -// $Id$ +// $Id: fdbcopy.cpp 3112 2006-01-19 13:12:40 -0700 (Thu, 19 Jan 2006) dsanders $ //------------------------------------------------------------------------------ #include "flaimsys.h" @@ -151,8 +151,10 @@ RCODE F_DbSystem::copyDb( { RCODE rc = NE_SFLM_OK; DB_COPY_INFO DbCopyInfo; - F_SuperFileHdl SrcSFileHdl; - F_SuperFileHdl DestSFileHdl; + F_SuperFileHdl * pSrcSFileHdl = NULL; + F_SuperFileHdl * pDestSFileHdl = NULL; + F_SuperFileClient * pSrcSFileClient = NULL; + F_SuperFileClient * pDestSFileClient = NULL; FLMUINT uiFileNumber; FLMUINT uiHighFileNumber; FLMUINT uiHighLogFileNumber; @@ -168,7 +170,7 @@ RCODE F_DbSystem::copyDb( IF_LockObject * pDatabaseLockObj = NULL; COPIED_NAME * pCopiedList = NULL; FLMBOOL bUsedDatabase = FALSE; - eLockType eCurrLockType; + eLockType currLockType; FLMUINT uiThreadId; FLMUINT uiNumExclQueued; FLMUINT uiNumSharedQueued; @@ -209,7 +211,24 @@ RCODE F_DbSystem::copyDb( // Set up the super file object for the source database. // Must at least open the control file. - if (RC_BAD( rc = SrcSFileHdl.setup( pszSrcDbName, pszSrcDataDir))) + if( (pSrcSFileClient = f_new F_SuperFileClient) == NULL) + { + rc = RC_SET( NE_SFLM_MEM); + goto Exit; + } + + if( RC_BAD( rc = pSrcSFileClient->setup( pszSrcDbName, pszSrcDataDir))) + { + goto Exit; + } + + if( (pSrcSFileHdl = f_new F_SuperFileHdl) == NULL) + { + rc = RC_SET( NE_SFLM_MEM); + goto Exit; + } + + if (RC_BAD( rc = pSrcSFileHdl->setup( pSrcSFileClient))) { goto Exit; } @@ -272,11 +291,11 @@ retry: // object, if not already locked. pDatabase->m_pDatabaseLockObj->getLockInfo( (FLMINT)0, - &eCurrLockType, + &currLockType, &uiThreadId, &uiNumExclQueued, &uiNumSharedQueued, &uiPriorityCount); - if (eCurrLockType != FLM_LOCK_EXCLUSIVE || + if (currLockType != FLM_LOCK_EXCLUSIVE || uiThreadId != f_threadId()) { pDatabaseLockObj = pDatabase->m_pDatabaseLockObj; @@ -293,11 +312,11 @@ retry: // Lock the write object, if not already locked pDatabase->m_pWriteLockObj->getLockInfo( (FLMINT)0, - &eCurrLockType, + &currLockType, &uiThreadId, &uiNumExclQueued, &uiNumSharedQueued, &uiPriorityCount); - if (eCurrLockType != FLM_LOCK_EXCLUSIVE || + if (currLockType != FLM_LOCK_EXCLUSIVE || uiThreadId != (FLMUINT)f_threadId()) { pWriteLockObj = pDatabase->m_pWriteLockObj; @@ -316,7 +335,24 @@ retry: // Set up the super file object for the destination database. - if (RC_BAD( rc = DestSFileHdl.setup( pszDestDbName, pszDestDataDir))) + if( (pDestSFileClient = f_new F_SuperFileClient) == NULL) + { + rc = RC_SET( NE_SFLM_MEM); + goto Exit; + } + + if( RC_BAD( rc = pDestSFileClient->setup( pszDestDbName, pszDestDataDir))) + { + goto Exit; + } + + if( (pDestSFileHdl = f_new F_SuperFileHdl) == NULL) + { + rc = RC_SET( NE_SFLM_MEM); + goto Exit; + } + + if (RC_BAD( rc = pDestSFileHdl->setup( pDestSFileClient))) { goto Exit; } @@ -326,7 +362,7 @@ retry: uiHighFileNumber = 0; for (;;) { - if ((RC_BAD( rc = SrcSFileHdl.getFileSize( + if ((RC_BAD( rc = pSrcSFileHdl->getFileSize( uiHighFileNumber, &ui64FileSize))) || !ui64FileSize ) { if (rc == NE_FLM_IO_PATH_NOT_FOUND || @@ -361,7 +397,7 @@ retry: uiHighLogFileNumber = FIRST_LOG_BLOCK_FILE_NUMBER; for (;;) { - if ((RC_BAD( rc = SrcSFileHdl.getFileSize( + if ((RC_BAD( rc = pSrcSFileHdl->getFileSize( uiHighLogFileNumber, &ui64FileSize))) || !ui64FileSize) { if (rc == NE_FLM_IO_PATH_NOT_FOUND || @@ -433,8 +469,8 @@ retry: // Close all file handles in the source and destination - SrcSFileHdl.releaseFiles( TRUE); - DestSFileHdl.releaseFiles( TRUE); + pSrcSFileHdl->releaseFiles( TRUE); + pDestSFileHdl->releaseFiles( TRUE); // Copy the database files. @@ -443,12 +479,12 @@ retry: // Get the source file path and destination file path. - if( RC_BAD( rc = SrcSFileHdl.getFilePath( + if( RC_BAD( rc = pSrcSFileHdl->getFilePath( uiFileNumber, DbCopyInfo.szSrcFileName))) { goto Exit; } - if( RC_BAD( rc = DestSFileHdl.getFilePath( + if( RC_BAD( rc = pDestSFileHdl->getFilePath( uiFileNumber, DbCopyInfo.szDestFileName))) { goto Exit; @@ -470,13 +506,13 @@ retry: // Get the source file path and destination file path. - if (RC_BAD( rc = SrcSFileHdl.getFilePath( uiFileNumber, + if (RC_BAD( rc = pSrcSFileHdl->getFilePath( uiFileNumber, DbCopyInfo.szSrcFileName))) { goto Exit; } - if (RC_BAD( rc = DestSFileHdl.getFilePath( uiFileNumber, + if (RC_BAD( rc = pDestSFileHdl->getFilePath( uiFileNumber, DbCopyInfo.szDestFileName))) { goto Exit; @@ -621,6 +657,7 @@ Exit: if (RC_OK( rc)) rc = rc3; } + bDatabaseLocked = FALSE; } @@ -687,6 +724,26 @@ Exit: f_semDestroy( &hWaitSem); } + if( pSrcSFileClient) + { + pSrcSFileClient->Release(); + } + + if( pSrcSFileHdl) + { + pSrcSFileHdl->Release(); + } + + if( pDestSFileClient) + { + pDestSFileClient->Release(); + } + + if( pDestSFileHdl) + { + pDestSFileHdl->Release(); + } + return( rc); } diff --git a/sql/src/fdbremov.cpp b/sql/src/fdbremov.cpp index 4398966..82ccc69 100644 --- a/sql/src/fdbremov.cpp +++ b/sql/src/fdbremov.cpp @@ -151,7 +151,7 @@ RCODE F_DbSystem::dbRemove( uiFileNumber = 1; for (;;) { - bldSuperFileExtension( uiFileNumber, pszDataExt); + F_SuperFileClient::bldSuperFileExtension( uiFileNumber, pszDataExt); if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->deleteFile( pszDataName))) { @@ -177,7 +177,7 @@ RCODE F_DbSystem::dbRemove( uiFileNumber = FIRST_LOG_BLOCK_FILE_NUMBER; for (;;) { - bldSuperFileExtension( uiFileNumber, pszExt); + F_SuperFileClient::bldSuperFileExtension( uiFileNumber, pszExt); if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->deleteFile( pszTmpName))) { diff --git a/sql/src/fdbrenam.cpp b/sql/src/fdbrenam.cpp index ce869e6..de5325e 100644 --- a/sql/src/fdbrenam.cpp +++ b/sql/src/fdbrenam.cpp @@ -230,8 +230,8 @@ RCODE F_DbSystem::dbRename( uiFileNumber = 1; for (;;) { - bldSuperFileExtension( uiFileNumber, pszDataExtOld); - bldSuperFileExtension( uiFileNumber, pszDataExtNew); + F_SuperFileClient::bldSuperFileExtension( uiFileNumber, pszDataExtOld); + F_SuperFileClient::bldSuperFileExtension( uiFileNumber, pszDataExtNew); if (RC_BAD( rc = flmRenameFile( pszOldDataName, pszNewDataName, bOverwriteDestOk, TRUE, @@ -256,8 +256,8 @@ RCODE F_DbSystem::dbRename( uiFileNumber = FIRST_LOG_BLOCK_FILE_NUMBER; for (;;) { - bldSuperFileExtension( uiFileNumber, pszExtOld); - bldSuperFileExtension( uiFileNumber, pszExtNew); + F_SuperFileClient::bldSuperFileExtension( uiFileNumber, pszExtOld); + F_SuperFileClient::bldSuperFileExtension( uiFileNumber, pszExtNew); if (RC_BAD( rc = flmRenameFile( pszOldName, pszNewName, bOverwriteDestOk, TRUE, diff --git a/sql/src/fdynbtre.cpp b/sql/src/fdynbtre.cpp deleted file mode 100644 index 46cfc17..0000000 --- a/sql/src/fdynbtre.cpp +++ /dev/null @@ -1,1198 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Contains the methods for the FFixedBlk, FBtreeRoot, FBtreeLeaf, -// FBtreeNonLeaf, and FBtreeBlk classes. -// -// Tabs: 3 -// -// Copyright (c) 1998-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id$ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" -#include "fdynsset.h" - -// Make sure that the extension is in lower case characters. - -#define FRSET_FILENAME_EXTENSION "frs" - -/**************************************************************************** - -Organization: - - These modules are orgianized by function and NOT by class. - For example, all of the searchEntry modules are together. - All of the split and getFirst/next/last... modules are together. - -****************************************************************************/ - - -/**************************************************************************** - Constructors and Setup Methods -****************************************************************************/ - -/**************************************************************************** -Desc: Set common variables -****************************************************************************/ -FFixedBlk::FFixedBlk() -{ - m_fnCompare = NULL; - m_pvUserData = NULL; - m_uiPosition = DYNSSET_POSITION_NOT_SET; - m_bDirty = FALSE; - m_pucBlkBuf = NULL; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FBtreeRoot::FBtreeRoot() -{ - int i; - - m_pFileHdl = NULL; - m_pszFileName = NULL; - m_eBlkType = ACCESS_BTREE_ROOT; - m_uiEntryOvhd = 4; - m_uiLRUCount = 1; - m_uiLevels = 1; - m_uiNewBlkAddr = 0; - m_uiHighestWrittenBlkAddr = 0; - m_uiTotalEntries = 0; - - // Initialize the cache blocks. - for( i = 0; i < FBTREE_CACHE_BLKS; i++) - { - m_CacheBlks[i].uiBlkAddr = 0xFFFFFFFF; - m_CacheBlks[i].uiLRUValue = 0; - m_CacheBlks[i].pBlk = NULL; - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FBtreeRoot::~FBtreeRoot() -{ - int i; - - closeFile(); - - for( i = 0; i < FBTREE_CACHE_BLKS; i++) - { - if( m_CacheBlks[i].pBlk) - { - m_CacheBlks[i].pBlk->Release(); - } - } -} - -/**************************************************************************** -Desc: Allocate structures and set entry size. -****************************************************************************/ -RCODE FBtreeLeaf::setup( - FLMUINT uiEntrySize) -{ - RCODE rc = NE_SFLM_OK; - - if (RC_BAD( rc = f_calloc( DYNSSET_BLOCK_SIZE, &m_pucBlkBuf))) - { - goto Exit; - } - - m_uiEntrySize = uiEntrySize; - m_pvUserData = (void *) uiEntrySize; - reset( ACCESS_BTREE_LEAF); - nextBlk( FBTREE_END); - prevBlk( FBTREE_END); - lemBlk( FBTREE_END); - reset( ACCESS_BTREE_LEAF); - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Allocate structures and set entry size. -****************************************************************************/ -RCODE FBtreeNonLeaf::setup( - FLMUINT uiEntrySize) -{ - RCODE rc = NE_SFLM_OK; - - if (RC_BAD( rc = f_calloc( DYNSSET_BLOCK_SIZE, &m_pucBlkBuf))) - { - goto Exit; - } - - m_uiEntrySize = uiEntrySize; - m_pvUserData = (void *) uiEntrySize; - reset( ACCESS_BTREE_NON_LEAF); - nextBlk( FBTREE_END); - prevBlk( FBTREE_END); - lemBlk( FBTREE_END); - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Allocate structures and set entry size. -****************************************************************************/ -RCODE FBtreeRoot::setup( - FLMUINT uiEntrySize, - char * pszFileName) -{ - RCODE rc; - - if (RC_BAD( rc = f_calloc( DYNSSET_BLOCK_SIZE, &m_pucBlkBuf))) - { - goto Exit; - } - - m_uiEntrySize = uiEntrySize; - m_pvUserData = (void *) uiEntrySize; - reset( ACCESS_BTREE_ROOT); - m_pszFileName = pszFileName; - nextBlk( FBTREE_END); - prevBlk( FBTREE_END); - lemBlk( FBTREE_END); - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Setup the block as a new block -****************************************************************************/ -void FBtreeBlk::reset( - FBlkTypes eBlkType) -{ - m_eBlkType = eBlkType; - - if (eBlkType == ACCESS_BTREE_ROOT || eBlkType == ACCESS_BTREE_NON_LEAF) - { - m_uiEntryOvhd = 4; - } - else - { - m_uiEntryOvhd = 0; - } - m_uiNumSlots = (DYNSSET_BLOCK_SIZE - sizeof( FixedBlkHdr)) / - ( m_uiEntrySize + m_uiEntryOvhd); - entryCount( 0); - m_uiPosition = DYNSSET_POSITION_NOT_SET; - m_bDirty = FALSE; -} - -/**************************************************************************** -Desc: Return the next entry in the result set. If the result set - is not positioned then the first entry will be returned. -****************************************************************************/ -RCODE FBtreeBlk::getNext( - void * pvEntryBuffer) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiPos = m_uiPosition; - - // Position to the next/first entry. - - if (uiPos == DYNSSET_POSITION_NOT_SET) - { - uiPos = 0; - } - else - { - if (++uiPos > entryCount()) - { - rc = RC_SET( NE_SFLM_EOF_HIT); - goto Exit; - } - } - f_memcpy( pvEntryBuffer, ENTRY_POS(uiPos), m_uiEntrySize); - m_uiPosition = uiPos; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Return the last entry in the result set. -****************************************************************************/ -RCODE FBtreeBlk::getLast( - void * pvEntryBuffer) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiPos = entryCount(); - - // Position to the next/first entry. - - if (uiPos == 0) - { - rc = RC_SET( NE_SFLM_EOF_HIT); - goto Exit; - } - - uiPos--; - f_memcpy( pvEntryBuffer, ENTRY_POS(uiPos), m_uiEntrySize); - m_uiPosition = uiPos; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Search a btree. Position for get* or for insert. -****************************************************************************/ -RCODE FBtreeRoot::search( - void * pvEntry, - void * pvFoundEntry) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiCurLevel = m_uiLevels - 1; // Min 2 levels - FLMUINT uiBlkAddr; - - // Reset the stack - only needed for debugging. - //f_memset( m_BTStack, 0, sizeof(FBtreeBlk *) * FBTREE_MAX_LEVELS); - - // Search this root block. - - m_BTStack[ uiCurLevel] = this; - (void) searchEntry( pvEntry, &uiBlkAddr); - - while( uiCurLevel--) - { - // Read the next block and place at uiCurLevel (backwards from FS). - - if( RC_BAD( rc = readBlk( uiBlkAddr, - uiCurLevel ? ACCESS_BTREE_NON_LEAF : ACCESS_BTREE_LEAF, - &m_BTStack[ uiCurLevel] ))) - { - goto Exit; - } - - // Set the rc - only for the leaf block, otherwise rc should be ignored. - - rc = m_BTStack[ uiCurLevel]->searchEntry( pvEntry, &uiBlkAddr, - uiCurLevel ? NULL : pvFoundEntry); - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Search a single block tree. Position for get* or for insert. - Do a binary search on all of the entries to find a match. - If no match then position to the entry where an insert - will take place. -****************************************************************************/ -RCODE FBtreeBlk::searchEntry( - void * pvEntry, - FLMUINT * puiChildAddr, - void * pvFoundEntry) -{ - RCODE rc = RC_SET( NE_SFLM_NOT_FOUND); - FLMUINT uiLow; - FLMUINT uiMid; - FLMUINT uiHigh; - FLMUINT uiTblSize; - FLMINT iCompare; - - // check for zero entries. - - if (!entryCount()) - { - uiMid = 0; - goto Exit; - } - uiHigh = uiTblSize = entryCount() - 1; - uiLow = 0; - for(;;) - { - uiMid = (uiLow + uiHigh) >> 1; // (uiLow + uiHigh) / 2 - - // Use compare routine - - if (m_fnCompare) - { - iCompare = m_fnCompare( pvEntry, ENTRY_POS( uiMid), m_pvUserData); - } - else - { - iCompare = f_memcmp( pvEntry, ENTRY_POS( uiMid), m_uiEntrySize); - } - - if (iCompare == 0) - { - if (pvFoundEntry) - { - f_memcpy( pvFoundEntry, ENTRY_POS( uiMid), m_uiEntrySize); - } - rc = NE_SFLM_OK; - goto Exit; - } - - // Check if we are done - where wLow equals uiHigh or mid is at end. - - if (iCompare < 0) - { - if (uiMid == uiLow || uiLow == uiHigh) - { - break; - } - uiHigh = uiMid - 1; // Too high - } - else - { - if (uiMid == uiHigh || uiLow == uiHigh) - { - - // Go up one for the correct position? - - uiMid++; - break; - } - uiLow = uiMid + 1; // Too low - } - } - -Exit: - - m_uiPosition = uiMid; - if (puiChildAddr && blkType() != ACCESS_BTREE_LEAF) - { - if (uiMid == entryCount()) - { - *puiChildAddr = lemBlk(); - } - else - { - FLMBYTE * pucChildAddr = ENTRY_POS(uiMid) + m_uiEntrySize; - *puiChildAddr = (FLMUINT)FB2UD( pucChildAddr); - } - } - return( rc); -} - -/**************************************************************************** -Desc: Insert the entry into the btree - should be positioned -****************************************************************************/ -RCODE FBtreeRoot::insert( - void * pvEntry) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiCurLevel; - FLMBYTE ucEntryBuf[FBTREE_MAX_LEVELS][DYNSSET_MAX_FIXED_ENTRY_SIZE]; - FLMUINT uiNewBlkAddr; - - if (RC_OK( rc = m_BTStack[0]->insert( pvEntry))) - { - goto Exit; - } - - // Failed to input at the left level. Do block split(s). - // This is an iterative and NOT a recursive split algorithm. - // The debugging, and cases to test should be lots easier this way. - - f_memcpy( ucEntryBuf[0], pvEntry, m_uiEntrySize); - uiCurLevel = 0; - uiNewBlkAddr = FBTREE_END; - for(;;) - { - - // Split while adding the element. - - if (RC_BAD( rc = (m_BTStack[uiCurLevel])->split( - this, - ucEntryBuf[ uiCurLevel], - uiNewBlkAddr, - ucEntryBuf[ uiCurLevel+1], - &uiNewBlkAddr))) - { - goto Exit; - } - - uiCurLevel++; - flmAssert( uiCurLevel < m_uiLevels); - - if (RC_OK( rc = m_BTStack[uiCurLevel]->insertEntry( - ucEntryBuf[uiCurLevel], uiNewBlkAddr))) - { - goto Exit; - } - - // Only returns NE_SFLM_OK or FAILURE. - - // Root split? - - if (uiCurLevel + 1 == m_uiLevels) - { - flmAssert( m_uiLevels + 1 <= FBTREE_MAX_LEVELS); - if (m_uiLevels + 1 > FBTREE_MAX_LEVELS) - { - rc = RC_SET( NE_SFLM_BTREE_FULL); - goto Exit; - } - - // Need to split the root block. - rc = ((FBtreeRoot *)m_BTStack[uiCurLevel])->split( - ucEntryBuf[uiCurLevel], uiNewBlkAddr ); - break; - } - } - -Exit: - - if (RC_OK(rc)) - { - m_uiTotalEntries++; - } - return( rc); -} - -/**************************************************************************** -Desc: Insert the entry into the buffer. -****************************************************************************/ -RCODE FBtreeBlk::insertEntry( - void * pvEntry, - FLMUINT uiChildAddr) -{ - RCODE rc = NE_SFLM_OK; - FLMBYTE * pucCurEntry; - FLMUINT uiShiftBytes; // Always shift down - - if( entryCount() >= m_uiNumSlots) - { - rc = RC_SET( NE_SFLM_FAILURE); - goto Exit; - } - flmAssert( m_uiPosition != DYNSSET_POSITION_NOT_SET); - pucCurEntry = ENTRY_POS( m_uiPosition); - if ((uiShiftBytes = (entryCount() - m_uiPosition) * - (m_uiEntrySize + m_uiEntryOvhd)) != 0) - { - - // Big hairy assert. Finds coding bugs and corruptions. - - flmAssert( m_uiPosition * (m_uiEntrySize + m_uiEntryOvhd) + - uiShiftBytes < DYNSSET_BLOCK_SIZE - sizeof( FixedBlkHdr)); - - f_memmove( pucCurEntry + m_uiEntrySize + m_uiEntryOvhd, - pucCurEntry, uiShiftBytes); - } - f_memcpy( pucCurEntry, pvEntry, m_uiEntrySize); - if( m_uiEntryOvhd) - { - UD2FBA( (FLMUINT32)uiChildAddr, &pucCurEntry[m_uiEntrySize]); - } - entryCount( entryCount() + 1); - m_uiPosition++; - m_bDirty = TRUE; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Move first half of entries into new block. Reset previous block - to point to new block. Add new last entry in new block to parent. - Fixup prev/next linkages. -****************************************************************************/ -RCODE FBtreeBlk::split( - FBtreeRoot * pRoot, - FLMBYTE * pucCurEntry, // (in) Contains entry to insert - FLMUINT uiCurBlkAddr, // (in) Blk addr if non-leaf - FLMBYTE * pucParentEntry, // (out) Entry to insert into parent. - FLMUINT * puiNewBlkAddr) // (out) New blk addr to insert into parent. -{ - RCODE rc = NE_SFLM_OK; - FBtreeBlk * pPrevBlk; - FBtreeBlk * pNewBlk = NULL; - FLMBYTE * pucEntry = NULL; - FLMBYTE * pucMidEntry; - FLMBYTE * pucChildAddr; - FLMUINT uiChildAddr; - FLMUINT uiPrevBlkAddr; - FLMUINT uiMid; - FLMUINT uiPos; - FLMUINT uiMoveBytes; - FLMBOOL bInserted = FALSE; - - // Allocate a new block for the split. - - if (RC_BAD( rc = pRoot->newBlk( &pNewBlk, blkType() ))) - { - goto Exit; - } - pNewBlk->AddRef(); // Pin the block - may get flushed out. - - - // the last half into the new block, but that would force the parent - // entry to be changed. This may take a little longer, but it is much - // more easier to code. - - // Call search entry once just to setup for insert. - - (void) pNewBlk->searchEntry( ENTRY_POS( 0)); - - // get the count and move more then half into the new block. - - uiMid = (entryCount() + 5) >> 1; - uiChildAddr = FBTREE_END; - - for (uiPos = 0; uiPos < uiMid; uiPos++) - { - pucEntry = ENTRY_POS( uiPos); - if (blkType() != ACCESS_BTREE_LEAF) - { - pucChildAddr = pucEntry + m_uiEntrySize; - uiChildAddr = (FLMUINT)FB2UD(pucChildAddr); - } - - // m_uiPosition automatically gets incremented. - - if (RC_BAD( rc = pNewBlk->insertEntry( pucEntry, uiChildAddr))) - { - RC_UNEXPECTED_ASSERT( rc); - goto Exit; - } - } - - if (m_uiPosition < uiMid) - { - - // Insert this entry now - - bInserted = TRUE; - (void) pNewBlk->searchEntry( pucCurEntry); - if (RC_BAD( rc = pNewBlk->insertEntry( pucCurEntry, uiCurBlkAddr))) - { - goto Exit; - } - } - - // Let caller insert into parent entry. This rids us of recursion. - - f_memcpy( pucParentEntry, pucEntry, m_uiEntrySize); - - // Move the rest down - - pucEntry = ENTRY_POS( 0); - pucMidEntry = ENTRY_POS( uiMid); - - entryCount( entryCount() - uiMid); - uiMoveBytes = entryCount() * (m_uiEntrySize + m_uiEntryOvhd); - flmAssert( uiMoveBytes < DYNSSET_BLOCK_SIZE - sizeof( FixedBlkHdr)); - f_memmove( pucEntry, pucMidEntry, uiMoveBytes); - - if( !bInserted) - { - - // m_uiPosition -= uiMid; - - (void) searchEntry( pucCurEntry); - if (RC_BAD( rc = insertEntry( pucCurEntry, uiCurBlkAddr))) - { - goto Exit; - } - } - - // VISIT: Could position stack to point to current element to insert. - - // Fixup the prev/next block linkages. - - if (prevBlk() != FBTREE_END) - { - if (RC_BAD( rc = pRoot->readBlk( prevBlk(), blkType(), &pPrevBlk ))) - { - goto Exit; - } - - pPrevBlk->nextBlk( pNewBlk->blkAddr()); - uiPrevBlkAddr = pPrevBlk->blkAddr(); - } - else - { - uiPrevBlkAddr = FBTREE_END; - } - pNewBlk->prevBlk( uiPrevBlkAddr); - pNewBlk->nextBlk( blkAddr()); - prevBlk( pNewBlk->blkAddr()); - - *puiNewBlkAddr = pNewBlk->blkAddr(); - -Exit: - - if (pNewBlk) - { - pNewBlk->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: Reinsert all entries given a new root block. - Caller will release 'this'. Used ONLY for building the first - ROOT and two leaves of the tree. -****************************************************************************/ -RCODE FBtreeLeaf::split( - FBtreeRoot * pNewRoot) // New Non-leaf root -{ - RCODE rc = NE_SFLM_OK; - FLMBYTE * pucEntry; - FLMUINT uiPos; - FLMUINT uiEntryCount = entryCount(); - FLMUINT uiMid = (uiEntryCount + 1) >> 1; - - if (RC_BAD( rc = pNewRoot->setupTree( ENTRY_POS(uiMid), - ACCESS_BTREE_LEAF, NULL, NULL))) - { - goto Exit; - } - - for (uiPos = 0; uiPos < uiEntryCount; uiPos++) - { - pucEntry = ENTRY_POS( uiPos); - if ((rc = pNewRoot->search( pucEntry)) != NE_SFLM_NOT_FOUND) - { - rc = RC_SET_AND_ASSERT( NE_SFLM_FAILURE); - goto Exit; - } - - if (RC_BAD( rc = pNewRoot->insert( pucEntry))) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Split the root block and make two new non-leaf blocks. - The secret here is that the root block never moves (cheers!). - This takes a little longer but is worth the work because the - root block never goes out to disk and is not in the cache. -****************************************************************************/ -RCODE FBtreeRoot::split( - void * pvCurEntry, - FLMUINT uiCurChildAddr) -{ - RCODE rc = NE_SFLM_OK; - FLMBYTE * pucEntry; - FLMBYTE * pucChildAddr; - FBtreeBlk * pLeftBlk; - FBtreeBlk * pRightBlk; - FBtreeBlk * pBlk; - FLMUINT uiChildAddr; - FLMUINT uiPos; - FLMUINT uiEntryCount = entryCount(); - FLMUINT uiMid = (uiEntryCount + 1) >> 1; - - if (RC_BAD( rc = setupTree( NULL, ACCESS_BTREE_NON_LEAF, - &pLeftBlk, &pRightBlk))) - { - goto Exit; - } - - // Call search entry once just to setup for insert. - - (void) pLeftBlk->searchEntry( ENTRY_POS( 0)); - - // Take the entries from the root block and move into leafs. - - for (uiPos = 0; uiPos <= uiMid; uiPos++) - { - pucEntry = ENTRY_POS( uiPos); - pucChildAddr = pucEntry + m_uiEntrySize; - uiChildAddr = (FLMUINT)FB2UD(pucChildAddr); - - if (RC_BAD( rc = pLeftBlk->insertEntry( pucEntry, uiChildAddr))) - { - goto Exit; - } - } - - // Call search entry once just to setup for insert. - - (void) pRightBlk->searchEntry( ENTRY_POS( 0)); - - for (uiPos = uiMid + 1; uiPos < uiEntryCount; uiPos++) - { - pucEntry = ENTRY_POS( uiPos); - pucChildAddr = pucEntry + m_uiEntrySize; - uiChildAddr = (FLMUINT)FB2UD(pucChildAddr); - - if ((rc = pRightBlk->searchEntry( pucEntry )) != NE_SFLM_NOT_FOUND) - { - rc = RC_SET_AND_ASSERT( NE_SFLM_FAILURE); - goto Exit; - } - - if (RC_BAD( rc = pRightBlk->insertEntry( pucEntry, uiChildAddr))) - { - goto Exit; - } - } - - // Reset the root block and insert new midpoint. - - entryCount( 0); - lemBlk( pRightBlk->blkAddr()); // Duplicated just in case. - pucEntry = ENTRY_POS( uiMid); - - if ((rc = searchEntry( pucEntry )) != NE_SFLM_NOT_FOUND) - { - rc = RC_SET_AND_ASSERT( NE_SFLM_FAILURE); - goto Exit; - } - - if (RC_BAD( rc = insertEntry( pucEntry, pLeftBlk->blkAddr() ))) - { - goto Exit; - } - - // Insert the current entry (parameters) into the left or right blk. - // This could be done a number of different ways. - (void) searchEntry( pvCurEntry, &uiChildAddr); - if (RC_BAD( rc = readBlk( uiChildAddr, ACCESS_BTREE_NON_LEAF, &pBlk))) - { - goto Exit; - } - (void) pBlk->searchEntry( pvCurEntry); - if (RC_BAD( rc = pBlk->insertEntry( pvCurEntry, uiCurChildAddr))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Setup two child blocks for a root block. -****************************************************************************/ -RCODE FBtreeRoot::setupTree( - FLMBYTE * pucMidEntry, // If !NULL entry to insert into root. - FBlkTypes eBlkType, // Leaf or non-leaf - FBtreeBlk ** ppLeftBlk, // (out) - FBtreeBlk ** ppRightBlk) // (out) -{ - RCODE rc = NE_SFLM_OK; - FBtreeBlk * pLeftBlk = NULL; - FBtreeBlk * pRightBlk = NULL; - - if (RC_BAD( rc = newBlk( &pLeftBlk, eBlkType))) - { - goto Exit; - } - - if (RC_BAD( rc = newBlk( &pRightBlk, eBlkType))) - { - goto Exit; - } - - if (eBlkType == ACCESS_BTREE_NON_LEAF) - { - ((FBtreeNonLeaf *)pRightBlk)->lemBlk( lemBlk()); - } - - // Fix up the linkages - - pLeftBlk->nextBlk( pRightBlk->blkAddr()); - pRightBlk->prevBlk( pLeftBlk->blkAddr()); - lemBlk( pRightBlk->blkAddr()); - - if (pucMidEntry) - { - - // Add the midentry to the root block. Search to position and insert. - - searchEntry( pucMidEntry); - insertEntry( pucMidEntry, pLeftBlk->blkAddr()); - } - m_uiLevels++; - - if (ppLeftBlk) - { - *ppLeftBlk = pLeftBlk; - } - if (ppRightBlk) - { - *ppRightBlk = pRightBlk; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Read in the block or get it from the cache. -****************************************************************************/ -RCODE FBtreeRoot::readBlk( - FLMUINT uiBlkAddr, // Blk address to read - FBlkTypes eBlkType, // Expected access type to read - FBtreeBlk ** ppBlk) // (out) Return block -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiPos; - FLMUINT uiLRUValue = (FLMUINT)~0; - FLMUINT uiLRUPos = 0; - FBtreeBlk * pNewBlk; - - for (uiPos = 0; uiPos < FBTREE_CACHE_BLKS; uiPos++) - { - if (m_CacheBlks[uiPos].uiBlkAddr == uiBlkAddr) - { - goto Exit; - } - - // The ref count is used for pinning the block. - - if (m_CacheBlks[uiPos].pBlk && - m_CacheBlks[uiPos].pBlk->getRefCount() == 1 && - uiLRUValue > m_CacheBlks[uiPos].uiLRUValue) - { - uiLRUValue = m_CacheBlks[uiPos].uiLRUValue; - uiLRUPos = uiPos; - } - - // There better not be a hole by this point. - - flmAssert( m_CacheBlks[uiPos].pBlk != NULL); - } - uiPos = uiLRUPos; - - // Read from disk? - - flmAssert( m_pFileHdl != NULL); - - if (RC_BAD( rc = newCacheBlk( uiPos, &pNewBlk, eBlkType))) - { - goto Exit; - } - - // Pick the LRU block and make that object do the reading - // so it can reset all internals and get used to being a different blk. - - pNewBlk->blkAddr( uiBlkAddr); - m_CacheBlks[uiPos].uiBlkAddr = uiBlkAddr; - m_CacheBlks[uiPos].uiLRUValue = m_uiLRUCount++; - - if (RC_BAD( rc = pNewBlk->readBlk( m_pFileHdl, uiBlkAddr))) - { - - // Release the block because the reset() changed the object type. - // May hit the assert above. - - m_CacheBlks[uiPos].pBlk->Release(); - m_CacheBlks[uiPos].pBlk = NULL; - goto Exit; - } - -Exit: - - if (RC_OK(rc)) - { - *ppBlk = m_CacheBlks[uiPos].pBlk; - m_CacheBlks[uiPos].uiLRUValue = m_uiLRUCount++; - } - return( rc); -} - -/**************************************************************************** -Desc: Get a new block using an exising or newly allocated block from - the cache. Initializes the block. May be leaf or non-leaf - but NOT the root block. -****************************************************************************/ -RCODE FBtreeRoot::newBlk( - FBtreeBlk ** ppBlk, - FBlkTypes eBlkType) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiLRUValue = (FLMUINT)~0; - FLMUINT uiPos; - FLMUINT uiLRUPos = 0; - FBtreeBlk * pNewBlk; - - for (uiPos = 0; uiPos < FBTREE_CACHE_BLKS; uiPos++) - { - - // The ref count is used for pinning the block. - - if (getRefCount() == 1 && - uiLRUValue > m_CacheBlks[uiPos].uiLRUValue) - { - uiLRUValue = m_CacheBlks[uiPos].uiLRUValue; - uiLRUPos = uiPos; - } - - // use the first hole. - - if (m_CacheBlks[uiPos].pBlk == NULL) - { - uiLRUPos = uiPos; - break; - } - } - uiPos = uiLRUPos; - if (RC_BAD( rc = newCacheBlk( uiPos, &pNewBlk, eBlkType))) - { - goto Exit; - } - - pNewBlk->blkAddr( newBlkAddr()); - m_CacheBlks[uiPos].uiBlkAddr = pNewBlk->blkAddr(); - m_CacheBlks[uiPos].uiLRUValue = m_uiLRUCount++; - - pNewBlk->entryCount(0); - pNewBlk->lemBlk( FBTREE_END); - pNewBlk->nextBlk( FBTREE_END); - pNewBlk->prevBlk( FBTREE_END); - *ppBlk = pNewBlk; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Release the existing cache block and setup and alloc new blk. -****************************************************************************/ -RCODE FBtreeRoot::newCacheBlk( - FLMUINT uiCachePos, - FBtreeBlk ** ppBlk, - FBlkTypes eBlkType) -{ - RCODE rc = NE_SFLM_OK; - FBtreeBlk * pNewBlk = NULL; - - if (m_CacheBlks[uiCachePos].pBlk) - { - if (m_CacheBlks[uiCachePos].pBlk->isDirty()) - { - if (RC_BAD( rc = writeBlk( uiCachePos))) - { - goto Exit; - } - } - } - - if (m_CacheBlks[uiCachePos].pBlk != NULL && - m_CacheBlks[uiCachePos].pBlk->blkType() == eBlkType) - { - - // If block is of the same type then reset it and use it. - - pNewBlk = m_CacheBlks[uiCachePos].pBlk; - pNewBlk->reset( eBlkType); - *ppBlk = pNewBlk; - goto Exit; - } - - if (m_CacheBlks[uiCachePos].pBlk) - { - m_CacheBlks[uiCachePos].pBlk->Release(); - } - if (eBlkType == ACCESS_BTREE_LEAF) - { - FBtreeLeaf * pLeafBlk; - if ((pLeafBlk = f_new FBtreeLeaf) == NULL) - { - rc = RC_SET( NE_SFLM_MEM); - goto Exit; - } - if (RC_BAD( rc = pLeafBlk->setup( m_uiEntrySize))) - { - pLeafBlk->Release(); - goto Exit; - } - pLeafBlk->setCompareFunc( m_fnCompare, m_pvUserData); - pNewBlk = (FBtreeBlk *) pLeafBlk; - } - else - { - FBtreeNonLeaf * pNonLeafBlk; - if ((pNonLeafBlk = f_new FBtreeNonLeaf) == NULL) - { - rc = RC_SET( NE_SFLM_MEM); - goto Exit; - } - if (RC_BAD( rc = pNonLeafBlk->setup( m_uiEntrySize))) - { - pNonLeafBlk->Release(); - goto Exit; - } - pNonLeafBlk->setCompareFunc( m_fnCompare, m_pvUserData); - pNewBlk = (FBtreeBlk *) pNonLeafBlk; - } - m_CacheBlks[uiCachePos].pBlk = pNewBlk; - *ppBlk = pNewBlk; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Read the block from disk. -****************************************************************************/ -RCODE FBtreeBlk::readBlk( - IF_FileHdl * pFileHdl, - FLMUINT uiBlkAddr) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiBytesRead; - - if (RC_BAD( rc = pFileHdl->read( - uiBlkAddr * DYNSSET_BLOCK_SIZE, DYNSSET_BLOCK_SIZE, - m_pucBlkBuf, &uiBytesRead))) - { - RC_UNEXPECTED_ASSERT( rc); - goto Exit; - } - - if (blkAddr() != uiBlkAddr) - { - - // Most likely a coding error rather than an I/O error. - - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Write the block to disk. -****************************************************************************/ -RCODE FBtreeBlk::writeBlk( - IF_FileHdl * pFileHdl) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiBytesWritten; - FLMUINT uiBlkAddr = blkAddr(); - - if (RC_BAD( rc = pFileHdl->write( - uiBlkAddr * DYNSSET_BLOCK_SIZE, - DYNSSET_BLOCK_SIZE, - m_pucBlkBuf, - &uiBytesWritten))) - { - goto Exit; - } - - m_bDirty = FALSE; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Write all blocks that are dirty and have an addrees lower - than the input block address and then write this block. - Write in order so that - we don't have to write zeros for any block. -****************************************************************************/ -RCODE FBtreeRoot::writeBlk( - FLMUINT uiWritePos) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiPos; - FLMUINT uiHighBlkAddr = m_CacheBlks[uiWritePos].uiBlkAddr; - - if (!m_pFileHdl) - { - if (RC_BAD( rc = openFile())) - { - goto Exit; - } - } - for (uiPos = 0; uiPos < FBTREE_CACHE_BLKS; uiPos++) - { - if( (uiWritePos != uiPos) && - (m_CacheBlks[uiPos].pBlk) && - (m_CacheBlks[uiPos].uiBlkAddr >= m_uiHighestWrittenBlkAddr) && - (m_CacheBlks[uiPos].uiBlkAddr < uiHighBlkAddr) && - (m_CacheBlks[uiPos].pBlk->isDirty()) ) - { - - // Recursive call to write out lower blocks if needed. - - if (RC_BAD( rc = writeBlk( uiPos))) - { - goto Exit; - } - } - } - m_CacheBlks[ uiWritePos].pBlk->writeBlk( m_pFileHdl); - if (m_CacheBlks[uiWritePos].uiBlkAddr > m_uiHighestWrittenBlkAddr) - { - m_uiHighestWrittenBlkAddr = m_CacheBlks[uiWritePos].uiBlkAddr; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Close the file if previously opened and creates the file. -****************************************************************************/ -RCODE FBtreeRoot::openFile( void) -{ - RCODE rc = NE_SFLM_OK; - - if (!m_pFileHdl) - { - rc = gv_SFlmSysData.pFileSystem->createUniqueFile( m_pszFileName, - FRSET_FILENAME_EXTENSION, - FLM_IO_RDWR | FLM_IO_CREATE_DIR, &m_pFileHdl); - } - return( rc); -} - -/**************************************************************************** -Desc: Closes and deletes the temporary file. -****************************************************************************/ -void FBtreeRoot::closeFile( void) -{ - if (m_pFileHdl) - { - m_pFileHdl->close(); - gv_SFlmSysData.pFileSystem->deleteFile( m_pszFileName); - m_pFileHdl->Release(); - m_pFileHdl = NULL; - } -} diff --git a/sql/src/fdynsset.cpp b/sql/src/fdynsset.cpp deleted file mode 100644 index 3e5d4da..0000000 --- a/sql/src/fdynsset.cpp +++ /dev/null @@ -1,328 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Contains the methods for FDynSearchSet class. -// -// Tabs: 3 -// -// Copyright (c) 1998-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id$ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" -#include "fdynsset.h" - -#define HASH_POS(vp) \ - (((FLMUINT)(FB2UD((FLMBYTE*)vp)) % m_uiNumSlots) * m_uiEntrySize) - -static const FLMBYTE ucZeros [ DYNSSET_MAX_FIXED_ENTRY_SIZE ] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/**************************************************************************** -Desc: Setup the result set with input values. This method must be - called and only called once. -****************************************************************************/ -RCODE FDynSearchSet::setup( - char * pszTmpDir, - FLMUINT uiEntrySize) -{ - RCODE rc = NE_SFLM_OK; - FHashBlk * pHashBlk; - - // Set the input variables. - - if( pszTmpDir ) - { - f_strcpy( m_szFileName, pszTmpDir); // Dest <- src - } - else - { - f_memset( m_szFileName, 0, F_PATH_MAX_SIZE); - } - m_uiEntrySize = uiEntrySize; - - if ((pHashBlk = f_new FHashBlk) == NULL) - { - rc = RC_SET( NE_SFLM_MEM); - goto Exit; - } - pHashBlk->setup( uiEntrySize); - m_pAccess = (FFixedBlk *) pHashBlk; - m_pvUserData = (void *) uiEntrySize; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Add a fixed length entry to the dynamic search result set. -****************************************************************************/ -RCODE FDynSearchSet::addEntry( - void * pvEntry) -{ - RCODE rc = NE_SFLM_OK; - -Add_Again: - - if (RC_OK( rc = m_pAccess->search( pvEntry))) - { - rc = RC_SET( NE_SFLM_EXISTS); - } - else if (rc == NE_SFLM_NOT_FOUND) - { - - // Insert the entry. - - if ((rc = m_pAccess->insert( pvEntry)) == NE_SFLM_FAILURE) - { - // Find the type of access method implemented - - if (m_pAccess->blkType() == ACCESS_HASH) - { - FBtreeLeaf * pBtreeBlk; - FLMBYTE ucEntryBuffer[ DYNSSET_MAX_FIXED_ENTRY_SIZE]; - - // Go from a hash to a b-tree object. Alloc and move stuff over. - - if ((pBtreeBlk = f_new FBtreeLeaf) == NULL) - { - rc = RC_SET( NE_SFLM_MEM); - goto Exit; - } - pBtreeBlk->setup( m_uiEntrySize); - pBtreeBlk->setCompareFunc( m_fnCompare, m_pvUserData); - for( rc = m_pAccess->getFirst( ucEntryBuffer ); - RC_OK(rc); - rc = m_pAccess->getNext( ucEntryBuffer) ) - { - // Call search to setup for insert. - (void) pBtreeBlk->search( ucEntryBuffer); - if (RC_BAD( rc = pBtreeBlk->insert( ucEntryBuffer))) - { - pBtreeBlk->Release(); - goto Exit; - } - } - rc = NE_SFLM_OK; - m_pAccess->Release(); - m_pAccess = pBtreeBlk; - goto Add_Again; - } - else if( m_pAccess->blkType() == ACCESS_BTREE_LEAF) - { - FBtreeRoot * pFullBtree; - - // Go from 1 block to 3 changing root blocks and free m_pAccess - // All new splits will be taken care of automatically. - - if ((pFullBtree = f_new FBtreeRoot) == NULL) - { - rc = RC_SET( NE_SFLM_MEM); - goto Exit; - } - if( RC_BAD( rc = pFullBtree->setup( m_uiEntrySize, m_szFileName))) - { - pFullBtree->Release(); - goto Exit; - } - pFullBtree->setCompareFunc( m_fnCompare, m_pvUserData); - if (RC_BAD( rc = ((FBtreeLeaf *)m_pAccess)->split( pFullBtree))) - { - goto Exit; - } - m_pAccess->Release(); - m_pAccess = pFullBtree; - goto Add_Again; - } - else - { - rc = RC_SET_AND_ASSERT( NE_SFLM_FAILURE); - goto Exit; - } - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Find matching entry. Position for Get* or for insert. -****************************************************************************/ -RCODE FHashBlk::search( - void * pvEntry, - void * pvFoundEntry) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiHashPos = HASH_POS( pvEntry); - FLMINT iCompare; - - for (;;) - { - - // If all zeros then setup to insert at this position. - - if (!f_memcmp( &m_pucBlkBuf[ uiHashPos], ucZeros, m_uiEntrySize)) - { - rc = RC_SET( NE_SFLM_NOT_FOUND); - goto Exit; - } - - if (m_fnCompare) - { - iCompare = m_fnCompare( pvEntry, &m_pucBlkBuf[ uiHashPos], - m_pvUserData); - } - else - { - iCompare = f_memcmp( pvEntry, &m_pucBlkBuf[ uiHashPos], - m_uiEntrySize); - } - - if (iCompare == 0) - { - - // Found match. - - if (pvFoundEntry) - { - f_memcpy( pvFoundEntry, &m_pucBlkBuf[ uiHashPos], m_uiEntrySize); - } - break; - } - - // Go to the next entry - - uiHashPos += m_uiEntrySize; - if (uiHashPos >= DYNSSET_HASH_BUFFER_SIZE) - { - uiHashPos = 0; - } - } - -Exit: - - m_uiPosition = uiHashPos; - return( rc); -} - -/**************************************************************************** -Desc: Insert the entry into the buffer. -****************************************************************************/ -RCODE FHashBlk::insert( - void * pvEntry) -{ - RCODE rc = NE_SFLM_OK; - - if( getTotalEntries() > ((m_uiNumSlots * 7) / 10)) - { - rc = RC_SET( NE_SFLM_FAILURE); - goto Exit; - } - - f_memcpy( &m_pucBlkBuf[ m_uiPosition], pvEntry, m_uiEntrySize); - m_uiTotalEntries++; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Return the next entry in the result set. If the result set - is not positioned then the first entry will be returned. -****************************************************************************/ -RCODE FHashBlk::getNext( - void * pvEntryBuffer) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiHashPos; - - // Position to the next/first entry. - - if (m_uiPosition == DYNSSET_POSITION_NOT_SET) - { - uiHashPos = 0; - } - else - { - uiHashPos = m_uiPosition + m_uiEntrySize; - } - - for ( ; ; uiHashPos += m_uiEntrySize) - { - if (uiHashPos >= DYNSSET_HASH_BUFFER_SIZE) - { - rc = RC_SET( NE_SFLM_EOF_HIT); - goto Exit; - } - - // If all zeros then setup to insert at this position. - - if (f_memcmp( &m_pucBlkBuf[ uiHashPos], ucZeros, m_uiEntrySize)) - { - f_memcpy( pvEntryBuffer, &m_pucBlkBuf[ uiHashPos], m_uiEntrySize); - m_uiPosition = uiHashPos; - goto Exit; - } - } - -Exit: - - return rc; -} - -/**************************************************************************** -Desc: Returns the last entry in the result set. -****************************************************************************/ -RCODE FHashBlk::getLast( - void * pvEntryBuffer) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiHashPos; - - // Position to the next/first entry. - - uiHashPos = DYNSSET_HASH_BUFFER_SIZE; - - for( ; ; ) - { - uiHashPos -= m_uiEntrySize; - - // If all zeros then setup to insert at this position. - - if (f_memcmp( &m_pucBlkBuf[ uiHashPos], ucZeros, m_uiEntrySize)) - { - f_memcpy( pvEntryBuffer, &m_pucBlkBuf[ uiHashPos], m_uiEntrySize); - m_uiPosition = uiHashPos; - goto Exit; - } - if (uiHashPos == 0) - { - rc = RC_SET( NE_SFLM_EOF_HIT); - goto Exit; - } - } - -Exit: - - return( rc); -} diff --git a/sql/src/fdynsset.h b/sql/src/fdynsset.h deleted file mode 100644 index c50f98f..0000000 --- a/sql/src/fdynsset.h +++ /dev/null @@ -1,672 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: FLAIM Dynamic search result set class. -// -// Tabs: 3 -// -// Copyright (c) 1998-2000, 2002-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id$ -//------------------------------------------------------------------------------ - -#ifndef FDYNSSET_H -#define FDYNSSET_H - -/***************************************************************************** -***** -** Definitions -***** -*****************************************************************************/ - -/* -A block size of 8K will perform well in minimizing the number of reads -to obtain a block. A 6K may perform better if the file is located -across the network. -*/ - -#define DYNSSET_BLOCK_SIZE 0x4000 -#define DYNSSET_HASH_BUFFER_SIZE 0x2000 -#define DYNSSET_MIN_FIXED_ENTRY_SIZE 4 -// Change ucZeros in fdynsset.cpp if this changes. -#define DYNSSET_MAX_FIXED_ENTRY_SIZE 32 -#define DYNSSET_POSITION_NOT_SET 0xFFFFFFFF - -#define FBTREE_CACHE_BLKS 32 -#define FBTREE_END 0xFFFFFFFF -#define FBTREE_MAX_LEVELS 4 - -typedef int (* FDYNSET_COMPARE_FUNC)( - void * pvData1, - void * pvData2, - void * pvUserData); - - -/***************************************************************************** -***** -** Forward References -***** -*****************************************************************************/ - -class FDynSearchSet; -class FHashBlk; -class FBtreeBlk; -class FBtreeRoot; -class FBtreeNonLeaf; -class FBtreeLeaf; - -enum eBlkTypes -{ - ACCESS_HASH, - ACCESS_BTREE_LEAF, - ACCESS_BTREE_ROOT, - ACCESS_BTREE_NON_LEAF -}; -typedef enum eBlkTypes FBlkTypes; - - -/*=========================================================================== - Virtual FFixedBlk -===========================================================================*/ -class FFixedBlk : public F_Object -{ -public: - - FFixedBlk(); - ~FFixedBlk() - { - } - - /* virtual methods that must be implemented */ - - FBlkTypes blkType() - { - return m_eBlkType; - } - - virtual RCODE getCurrent( - void * pvEntryBuffer) = 0; - - virtual RCODE getFirst( - void * pvEntryBuffer) = 0; - - virtual RCODE getLast( - void * pvEntryBuffer) = 0; - - virtual RCODE getNext( - void * pvEntryBuffer) = 0; - - virtual FLMUINT getTotalEntries() = 0; - - virtual RCODE insert( - void * pvEntry) = 0; - - FINLINE FLMBOOL isDirty( void) - { - return( m_bDirty); - } - - virtual RCODE search( - void * pvEntry, - void * pvFoundEntry = NULL) = 0; - - void setCompareFunc( - FDYNSET_COMPARE_FUNC fnCompare, - void * pvUserData) - { - m_fnCompare = fnCompare; - m_pvUserData = pvUserData; - } - -protected: - - // Variables - - FDYNSET_COMPARE_FUNC m_fnCompare; - void * m_pvUserData; - FBlkTypes m_eBlkType; - FLMUINT m_uiEntrySize; - FLMUINT m_uiNumSlots; - FLMUINT m_uiPosition; - FLMBOOL m_bDirty; - FLMBYTE * m_pucBlkBuf; -}; - - -/***************************************************************************** -***** -** Result Set Class Definitions -** Source: fdynsset.cpp -***** -*****************************************************************************/ -class FDynSearchSet : public F_Object -{ - -public: - - FDynSearchSet() - { - m_fnCompare = NULL; - m_pvUserData = NULL; - m_uiEntrySize = 0; - m_pAccess = NULL; - } - - ~FDynSearchSet() - { - if (m_pAccess) - { - m_pAccess->Release(); - } - } - - RCODE setup( - char * pszTmpDir, - FLMUINT uiEntrySize); - - FINLINE void setCompareFunc( - FDYNSET_COMPARE_FUNC fnCompare, - void * pvUserData - ) - { - m_fnCompare = fnCompare; - m_pvUserData = pvUserData; - m_pAccess->setCompareFunc( fnCompare, pvUserData); - } - - RCODE addEntry( - void * pvEntry); - - FINLINE RCODE findMatch( - void * pvMatchEntry, - void * pvFoundEntry - ) - { - return m_pAccess->search( pvMatchEntry, pvFoundEntry); - } - - FINLINE FLMUINT getEntrySize( void) - { - return m_uiEntrySize; - } - - FINLINE FLMUINT getTotalEntries( void) - { - return m_pAccess->getTotalEntries(); - } - -private: - - // Variables - - FDYNSET_COMPARE_FUNC m_fnCompare; - void * m_pvUserData; - FLMUINT m_uiEntrySize; - FFixedBlk * m_pAccess; - char m_szFileName [F_PATH_MAX_SIZE]; -}; - -/*=========================================================================== - Block Header Definition - -Desc: Actually stored as the first section of each block. - We can write this structure because the same process will - read the block header i.e. portability is not a problem. -===========================================================================*/ - -typedef struct -{ - FLMUINT uiBlkAddr; - FLMUINT uiPrevBlkAddr; - FLMUINT uiNextBlkAddr; - FLMUINT uiLEMAddr; - FLMUINT uiNumEntries; -} FixedBlkHdr; - -/*=========================================================================== - Fixed Length HASH Access Method -===========================================================================*/ -class FHashBlk : public FFixedBlk -{ -public: - - FHashBlk() - { - // Base class constructors are called before this constructor is. - - m_eBlkType = ACCESS_HASH; - m_pucBlkBuf = m_ucHashBlk; - f_memset( m_ucHashBlk, 0, sizeof( m_ucHashBlk)); - m_uiTotalEntries = 0; - } - - ~FHashBlk() - { - // Set to NULL so we don't free the block - m_pucBlkBuf = NULL; - } - - FINLINE RCODE setup( - FLMUINT uiEntrySize - ) - { - m_uiEntrySize = uiEntrySize; - m_uiNumSlots = DYNSSET_HASH_BUFFER_SIZE / uiEntrySize; - return( NE_SFLM_OK); - } - - FINLINE RCODE getCurrent( - void * pvEntryBuffer - ) - { - - // Position to the next/first entry. - - if (m_uiPosition == DYNSSET_POSITION_NOT_SET) - { - return RC_SET( NE_SFLM_NOT_FOUND); - } - - f_memcpy( pvEntryBuffer, &m_pucBlkBuf[ m_uiPosition], m_uiEntrySize); - return( NE_SFLM_OK); - } - - FINLINE RCODE getFirst( - void * pvEntryBuffer - ) - { - m_uiPosition = DYNSSET_POSITION_NOT_SET; - return( getNext( pvEntryBuffer)); - } - - RCODE getLast( - void * pvEntryBuffer); - - RCODE getNext( - void * pvEntryBuffer); - - FINLINE FLMUINT getTotalEntries( void) - { - return m_uiTotalEntries; - } - - RCODE insert( - void * pvEntry); - - RCODE search( - void * pvEntry, - void * pvFoundEntry = NULL); - -private: - - FLMUINT m_uiTotalEntries; - // Allocate the hash block to save 1 allocation. - // We need to make the hash as fast as possible. - FLMBYTE m_ucHashBlk[ DYNSSET_HASH_BUFFER_SIZE]; -}; - - -/*=========================================================================== - Virtual FBtreeBlk -===========================================================================*/ - -// Leaf and non-leaf entry position. Don't do any ++ or -- ! ! ! ! - -#define ENTRY_POS(uiPos) (m_pucBlkBuf + sizeof( FixedBlkHdr) + \ - (uiPos * (m_uiEntrySize+m_uiEntryOvhd))) - -class FBtreeBlk : public FFixedBlk -{ -public: - - FBtreeBlk() - { - } - - ~FBtreeBlk() - { - if (m_pucBlkBuf) - { - f_free( &m_pucBlkBuf); - } - } - - // virtual methods that must be implemented - - FINLINE RCODE getCurrent( - void * pvEntryBuffer - ) - { - // Position to the next/first entry. - - if (m_uiPosition == DYNSSET_POSITION_NOT_SET) - { - return RC_SET( NE_SFLM_NOT_FOUND); - } - - f_memcpy( pvEntryBuffer, ENTRY_POS( m_uiPosition), m_uiEntrySize); - return( NE_SFLM_OK); - } - - FINLINE RCODE getFirst( - void * pvEntryBuffer - ) - { - m_uiPosition = DYNSSET_POSITION_NOT_SET; - return( getNext( pvEntryBuffer)); - } - - RCODE getLast( - void * pvEntryBuffer); - - RCODE getNext( - void * pvEntryBuffer); - - RCODE readBlk( - IF_FileHdl * pFileHdl, - FLMUINT uiBlkAddr); - - void reset( - FBlkTypes eBlkType); - - RCODE split( - FBtreeRoot * pParent, - FLMBYTE * pucCurEntry, - FLMUINT uiCurBlkAddr, - FLMBYTE * pucParentEntry, - FLMUINT * puiNewBlkAddr); - - RCODE writeBlk( - IF_FileHdl * pFileHdl); - - // Virtual methods - - virtual FLMUINT getTotalEntries( void) = 0; - - virtual RCODE insert( - void * pvEntry) = 0; - - virtual RCODE search( - void * pvEntry, - void * pvFoundEntry = NULL) = 0; - - virtual RCODE searchEntry( - void * pvEntry, - FLMUINT * puiChildAddr = NULL, - void * pvFoundEntry = NULL); - - // Implemented as inline functions. - // Even though these are b-tree specific - keep them here to - // avoid having a b-tree block class. Most are not used for hash. - - FINLINE FLMUINT blkAddr( void) - { - return( ((FixedBlkHdr *)m_pucBlkBuf)->uiBlkAddr); - } - - FINLINE void blkAddr( - FLMUINT uiBlkAddr) - { - ((FixedBlkHdr *)m_pucBlkBuf)->uiBlkAddr = uiBlkAddr; - m_bDirty = TRUE; - } - - // Get and set the number of entries in the block - - FINLINE FLMUINT entryCount( void) - { - return( ((FixedBlkHdr *)m_pucBlkBuf)->uiNumEntries); - } - - FINLINE void entryCount( - FLMUINT uiNumEntries) - { - ((FixedBlkHdr *)m_pucBlkBuf)->uiNumEntries = uiNumEntries; - m_bDirty = TRUE; - } - - RCODE insertEntry( - void * pvEntry, - FLMUINT uiChildAddr = FBTREE_END); - - - // Get and set the last element marker in the block. - - FINLINE FLMUINT lemBlk( void) - { - return( ((FixedBlkHdr *)m_pucBlkBuf)->uiLEMAddr); - } - - FINLINE void lemBlk( - FLMUINT uiLEMAddr) - { - ((FixedBlkHdr *)m_pucBlkBuf)->uiLEMAddr = uiLEMAddr; - m_bDirty = TRUE; - } - - // Get and set the next block address element - - FINLINE FLMUINT nextBlk( void) - { - return( ((FixedBlkHdr *)m_pucBlkBuf)->uiNextBlkAddr); - } - - FINLINE void nextBlk( - FLMUINT uiBlkAddr) - { - ((FixedBlkHdr *)m_pucBlkBuf)->uiNextBlkAddr = uiBlkAddr; - m_bDirty = TRUE; - } - - // Get and set the previous block address element - - FINLINE FLMUINT prevBlk( void) - { - return( ((FixedBlkHdr *)m_pucBlkBuf)->uiPrevBlkAddr); - } - - FINLINE void prevBlk( - FLMUINT uiBlkAddr) - { - ((FixedBlkHdr *)m_pucBlkBuf)->uiPrevBlkAddr = uiBlkAddr; - m_bDirty = TRUE; - } - -protected: - - // Variables - - FLMUINT m_uiEntryOvhd; // Overhead in the entry. -}; - - -/*=========================================================================== - Fixed Length B-tree Leaf - may be a root -===========================================================================*/ - -class FBtreeLeaf : public FBtreeBlk -{ -public: - - FBtreeLeaf() - { - m_eBlkType = ACCESS_BTREE_LEAF; - m_uiEntryOvhd = 0; - } - - ~FBtreeLeaf() - { - } - - RCODE setup( - FLMUINT uiEntrySize); - - FINLINE FLMUINT getTotalEntries( void) - { - return( (FLMUINT)entryCount()); - } - - FINLINE RCODE insert( - void * pvEntry) - { - return( insertEntry( pvEntry, FBTREE_END)); - } - - FINLINE RCODE search( - void * pvEntry, - void * pvFoundEntry = NULL) - { - return( searchEntry( pvEntry, NULL, pvFoundEntry)); - } - - RCODE split( - FBtreeRoot * pNewRoot); - -}; - -typedef struct -{ - FLMUINT uiBlkAddr; - FLMUINT uiLRUValue; - FBtreeBlk * pBlk; // Points to leaf or non-leaf block -} FBTREE_CACHE; - -/*=========================================================================== - Fixed Length B-tree non-leaf block -===========================================================================*/ - -class FBtreeNonLeaf : public FBtreeBlk -{ -public: - - FBtreeNonLeaf() - { - m_eBlkType = ACCESS_BTREE_NON_LEAF; - m_uiEntryOvhd = sizeof( FLMUINT32); - } - - ~FBtreeNonLeaf() - { - } - - RCODE setup( - FLMUINT uiEntrySize); - - FINLINE FLMUINT getTotalEntries( void) - { - return( (FLMUINT) entryCount()); - } - - FINLINE RCODE insert( - void * // pvEntry - ) - { - return( NE_SFLM_OK); - } - - FINLINE RCODE search( - void *, // pvEntry, - void * pvFoundEntry = NULL - ) - { - F_UNREFERENCED_PARM( pvFoundEntry); - flmAssert( 0); - return( NE_SFLM_OK); - } -}; - -/*=========================================================================== - Fixed Length B-tree Non-Leaf Root -===========================================================================*/ -class FBtreeRoot : public FBtreeNonLeaf -{ -public: - FBtreeRoot(); - ~FBtreeRoot(); - - RCODE setup( - FLMUINT uiEntrySize, - char * pszFileName); - - - void closeFile( void); - - FINLINE FLMUINT getTotalEntries( void) - { - return( m_uiTotalEntries); - } - - RCODE insert( - void * pvEntry); - - RCODE newBlk( - FBtreeBlk ** ppBlk, - FBlkTypes eBlkType); - - FINLINE FLMUINT newBlkAddr( void) - { - return( m_uiNewBlkAddr++); - } - - RCODE newCacheBlk( - FLMUINT uiCachePos, - FBtreeBlk ** ppBlk, - FBlkTypes eBlkType); - - RCODE openFile( void); - - RCODE readBlk( - FLMUINT uiBlkAddr, - FBlkTypes eBlkType, - FBtreeBlk ** ppBlk); - - RCODE search( - void * pvEntry, - void * pvFoundEntry = NULL); - - RCODE setupTree( - FLMBYTE * pucMidEntry, // If !NULL entry to insert into root. - FBlkTypes eBlkType, // Leaf or non-leaf - FBtreeBlk ** ppLeftBlk, // (out) - FBtreeBlk ** ppRightBlk); // (out) - - RCODE split( - void * pvCurEntry, - FLMUINT uiCurChildAddr); - - RCODE writeBlk( - FLMUINT uiWritePos); - -private: - - FLMUINT m_uiLevels; // Number of levels in the b-tree - FLMUINT m_uiTotalEntries; // Count of total entries - FLMUINT m_uiNewBlkAddr; // Next new blk addr. - FLMUINT m_uiHighestWrittenBlkAddr; - - IF_FileHdl * m_pFileHdl; // File handle or NULL if not open. - char * m_pszFileName; // File created for result set or default. - - // Cache of 'n' blocks to apply LRU algorithm. - - FLMUINT m_uiLRUCount; // Count to find least rec. used. - FBTREE_CACHE m_CacheBlks[ FBTREE_CACHE_BLKS]; - - // B-tree stack. - FBtreeBlk * m_BTStack[ FBTREE_MAX_LEVELS]; -}; - -#endif // ifndef FRSET_H diff --git a/sql/src/flaimodbc.h b/sql/src/flaimodbc.h index 1349511..2dfdf62 100644 --- a/sql/src/flaimodbc.h +++ b/sql/src/flaimodbc.h @@ -26,8 +26,6 @@ #ifndef FLAIMODBC_H #define FLAIMODBC_H -#include "fdynsset.h" - // Forward declarations struct SQL_NODE; diff --git a/sql/src/flaimsql.h b/sql/src/flaimsql.h index 607f76f..cf622de 100644 --- a/sql/src/flaimsql.h +++ b/sql/src/flaimsql.h @@ -41,7 +41,7 @@ #include "config.h" #endif -#include "ftk.h" +#include "flaimsqltk.h" // Forward declarations diff --git a/sql/src/flaimsqltk.h b/sql/src/flaimsqltk.h new file mode 100644 index 0000000..484b066 --- /dev/null +++ b/sql/src/flaimsqltk.h @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// Desc: Placeholder for FLAIM's cross-platform toolkit public definitions +// and interfaces +// +// Tabs: 3 +// +// Copyright (c) 2006 Novell, Inc. All Rights Reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of version 2 of the GNU General Public +// License as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, contact Novell, Inc. +// +// To contact Novell about this file by physical or electronic mail, +// you may find current contact information at www.novell.com +// +// $Id$ +//------------------------------------------------------------------------------ + +#include "ftk.h" diff --git a/sql/src/flaimsys.h b/sql/src/flaimsys.h index 9a62fa0..207db82 100644 --- a/sql/src/flaimsys.h +++ b/sql/src/flaimsys.h @@ -481,7 +481,6 @@ FINLINE RCODE FlmStorage2UTF8( #include "f_btree.h" #include "f_btpool.h" #include "rfl.h" -#include "fsuperfl.h" #include "filesys.h" #include "flog.h" #include "f_nici.h" @@ -3228,11 +3227,6 @@ public: return( FALSE); } - static void getDbBasePath( - char * pszBaseDbName, - const char * pszDbName, - FLMUINT * puiBaseDbNameLen); - RCODE waitToClose( const char * pszDbPath); @@ -3255,10 +3249,6 @@ private: NULL, NULL, 0, TRUE, NULL, NULL, NULL, ppDb)); } - void lockSysData( void); - - void unlockSysData( void); - void initFastBlockCheckSum( void); RCODE allocDb( @@ -3327,6 +3317,11 @@ typedef enum SFLM_UTF8_TEXT } eSFlmTextType; +void flmGetDbBasePath( + char * pszBaseDbName, + const char * pszDbName, + FLMUINT * puiBaseDbNameLen); + /*------------------------------------------------------ FLAIM Processing Hooks (call-backs) -------------------------------------------------------*/ @@ -4351,6 +4346,43 @@ FINLINE RCODE F_RowCacheMgr::makeWriteCopy( return( NE_SFLM_OK); } +/**************************************************************************** +Desc: +*****************************************************************************/ +class FLMEXP F_SuperFileClient : public IF_SuperFileClient +{ +public: + + F_SuperFileClient(); + + virtual ~F_SuperFileClient(); + + RCODE setup( + const char * pszCFileName, + const char * pszDataDir); + + FLMUINT FLMAPI getFileNumber( + FLMUINT uiBlockAddr); + + FLMUINT FLMAPI getFileOffset( + FLMUINT uiBlockAddr); + + RCODE FLMAPI getFilePath( + FLMUINT uiFileNumber, + char * pszPath); + + static void bldSuperFileExtension( + FLMUINT uiFileNum, + char * pszFileExtension); + +private: + + char * m_pszCFileName; + char * m_pszDataFileBaseName; + FLMUINT m_uiExtOffset; + FLMUINT m_uiDataExtOffset; +}; + // More includes #include "flaimodbc.h" diff --git a/sql/src/flbackup.cpp b/sql/src/flbackup.cpp index c186125..46a0441 100644 --- a/sql/src/flbackup.cpp +++ b/sql/src/flbackup.cpp @@ -973,9 +973,11 @@ RCODE F_DbSystem::dbRestore( // [IN] Object for reporting the status of the restore // operation { + RCODE rc = NE_SFLM_OK; IF_FileHdl * pFileHdl = NULL; IF_FileHdl * pLockFileHdl = NULL; F_SuperFileHdl * pSFile = NULL; + F_SuperFileClient SFileClient; FLMBYTE szBasePath[ F_PATH_MAX_SIZE]; char szTmpPath[ F_PATH_MAX_SIZE]; FLMUINT uiDbVersion; @@ -987,7 +989,6 @@ RCODE F_DbSystem::dbRestore( F_Database * pDatabase = NULL; F_FSRestore * pFSRestoreObj = NULL; FLMBOOL bOKToRetry; - RCODE rc = NE_SFLM_OK; // Set up the callback @@ -1022,7 +1023,7 @@ RCODE F_DbSystem::dbRestore( // Get the base path - getDbBasePath( (char *)szBasePath, pszDbPath, NULL); + flmGetDbBasePath( (char *)szBasePath, pszDbPath, NULL); // Lock the global mutex @@ -1088,7 +1089,12 @@ RCODE F_DbSystem::dbRestore( goto Exit; } - if( RC_BAD( rc = pSFile->setup( pszDbPath, pszDataDir))) + if( RC_BAD( rc = SFileClient.setup( pszDbPath, pszDataDir))) + { + goto Exit; + } + + if( RC_BAD( rc = pSFile->setup( &SFileClient))) { goto Exit; } @@ -1384,19 +1390,6 @@ FSTATIC RCODE flmRestoreFile( *pbOKToRetry = TRUE; } -#ifdef FLM_WIN - - // Don't want to do extra file extensions or flush when file - // is extended. Setting the extend size to ~0 has the effect - // of not updating the directory entry (a time-consuming operation) - // on Windows platforms. On all other platforms, we will just - // go with the default behavior. - - pSFile->setExtendSize( (FLMUINT)(~0)); - -#endif - - // Set up the backer stream object if( (pBackerStream = f_new F_BackerStream) == NULL) @@ -1772,12 +1765,10 @@ FSTATIC RCODE flmRestoreFile( // write out the amount requested, not a full sector. if( RC_BAD( rc = pSFile->writeBlock( uiBlkAddr, - uiBlockSize, pucBlkBuf, uiBlockSize, - NULL, &uiBytesWritten))) + uiBlockSize, pucBlkBuf, NULL, &uiBytesWritten))) #else if( RC_BAD( rc = pSFile->writeBlock( uiBlkAddr, - uiBlockSize, pucBlkBuf, uiBlkBufSize, - NULL, &uiBytesWritten))) + uiBlockSize, pucBlkBuf, NULL, &uiBytesWritten))) #endif { if( rc == NE_FLM_IO_PATH_NOT_FOUND || @@ -1798,12 +1789,10 @@ FSTATIC RCODE flmRestoreFile( #ifdef FLM_UNIX if( RC_BAD( rc = pSFile->writeBlock( uiBlkAddr, - uiBlockSize, pucBlkBuf, uiBlockSize, - NULL, &uiBytesWritten))) + uiBlockSize, pucBlkBuf, NULL, &uiBytesWritten))) #else if( RC_BAD( rc = pSFile->writeBlock( uiBlkAddr, - uiBlockSize, pucBlkBuf, uiBlkBufSize, - NULL, &uiBytesWritten))) + uiBlockSize, pucBlkBuf, NULL, &uiBytesWritten))) #endif { goto Exit; diff --git a/sql/src/flcreate.cpp b/sql/src/flcreate.cpp index 8bec2ee..5664928 100644 --- a/sql/src/flcreate.cpp +++ b/sql/src/flcreate.cpp @@ -369,8 +369,7 @@ RCODE F_Db::initDbFiles( pBlkHdr->ui32BlkCRC = calcBlkCRC( pBlkHdr, SIZEOF_STD_BLK_HDR); if (RC_BAD( rc = m_pSFileHdl->writeBlock( (FLMUINT)pBlkHdr->ui32BlkAddr, - uiBlkSize, pucBuf, uiBlkSize, NULL, - &uiWriteBytes))) + uiBlkSize, pucBuf, NULL, &uiWriteBytes))) { goto Exit; } diff --git a/sql/src/flog.h b/sql/src/flog.h index dcffd67..ac7f3d4 100644 --- a/sql/src/flog.h +++ b/sql/src/flog.h @@ -27,49 +27,11 @@ #ifndef FLOG_H #define FLOG_H -// Special defines for use in the format string of flmLogPrintf - -#define F_BLACK "%0C" -#define F_BLUE "%1C" -#define F_GREEN "%2C" -#define F_CYAN "%3C" -#define F_RED "%4C" -#define F_PURPLE "%5C" -#define F_BROWN "%6C" -#define F_LIGHTGRAY "%7C" -#define F_DARKGRAY "%8C" -#define F_LIGHTBLUE "%9C" -#define F_LIGHTGREEN "%10C" -#define F_LIGHTCYAN "%11C" -#define F_LIGHTRED "%12C" -#define F_LIGHTPURPLE "%13C" -#define F_YELLOW "%14C" -#define F_WHITE "%15C" - -#define F_PUSHFORECOLOR "%+0C" -#define F_PUSHBACKCOLOR "%+1C" -#define F_POPFORECOLOR "%-0C" -#define F_POPBACKCOLOR "%-1C" - -#define F_PUSHCOLOR F_PUSHFORECOLOR F_PUSHBACKCOLOR -#define F_POPCOLOR F_POPFORECOLOR F_POPBACKCOLOR - -#define F_BLUE_ON_WHITE "%1.15C" - // Logging functions for use within FLAIM IF_LogMessageClient * flmBeginLogMessage( eLogMessageType eMsgType); -void flmLogPrintf( - IF_LogMessageClient * pLogMessage, - const char * pszFormatStr, ...); - -void flmLogVPrintf( - IF_LogMessageClient * pLogMessage, - const char * szFormatStr, - f_va_list * args); - void flmEndLogMessage( IF_LogMessageClient ** ppLogMessage); diff --git a/sql/src/flopen.cpp b/sql/src/flopen.cpp index 5e33a85..b1ba469 100644 --- a/sql/src/flopen.cpp +++ b/sql/src/flopen.cpp @@ -243,7 +243,7 @@ Desc: Returns the length of the base part of a database name. If the name ends with a '.' or ".db", this will not be included in the returned length. ****************************************************************************/ -void F_DbSystem::getDbBasePath( +void flmGetDbBasePath( char * pszBaseDbName, const char * pszDbName, FLMUINT * puiBaseDbNameLen) @@ -559,12 +559,14 @@ RCODE flmCreateLckFile( pLockFileHdl = NULL; Exit: + if (pLockFileHdl) { (void)pLockFileHdl->close(); pLockFileHdl->Release(); pLockFileHdl = NULL; } + return( rc); } @@ -1611,10 +1613,11 @@ Desc: This routine begins a thread that will do checkpoints for the *****************************************************************************/ RCODE F_Database::startCPThread( void) { - RCODE rc = NE_SFLM_OK; - CP_INFO * pCPInfo = NULL; - char szThreadName[ F_PATH_MAX_SIZE]; - char szBaseName[ 32]; + RCODE rc = NE_SFLM_OK; + CP_INFO * pCPInfo = NULL; + char szThreadName[ F_PATH_MAX_SIZE]; + char szBaseName[ 32]; + F_SuperFileClient * pSFileClient = NULL; // Allocate a CP_INFO structure that will be passed into the // thread when it is created. @@ -1634,15 +1637,26 @@ RCODE F_Database::startCPThread( void) // Allocate a super file handle. - if ((pCPInfo->pSFileHdl = f_new F_SuperFileHdl) == NULL) + if( (pCPInfo->pSFileHdl = f_new F_SuperFileHdl) == NULL) { rc = RC_SET( NE_SFLM_MEM); goto Exit; } + + if( (pSFileClient = f_new F_SuperFileClient) == NULL) + { + rc = RC_SET( NE_SFLM_MEM); + goto Exit; + } + + if( RC_BAD( rc = pSFileClient->setup( m_pszDbPath, m_pszDataDir))) + { + goto Exit; + } // Set up the super file - if (RC_BAD( rc = pCPInfo->pSFileHdl->setup( m_pszDbPath, m_pszDataDir))) + if (RC_BAD( rc = pCPInfo->pSFileHdl->setup( pSFileClient))) { goto Exit; } @@ -1684,6 +1698,11 @@ Exit: flmFreeCPInfo( &pCPInfo); } + if( pSFileClient) + { + pSFileClient->Release(); + } + return( rc); } diff --git a/sql/src/frestore.cpp b/sql/src/frestore.cpp index 41004b3..8b37aa4 100644 --- a/sql/src/frestore.cpp +++ b/sql/src/frestore.cpp @@ -161,8 +161,8 @@ RCODE F_FSRestore::openRflFile( // Open the file. - if( RC_BAD( rc = gv_SFlmSysData.pFileSystem->openBlockFile( szRflPath, - FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, 512, &m_pFileHdl))) + if( RC_BAD( rc = gv_SFlmSysData.pFileSystem->openFile( szRflPath, + FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, &m_pFileHdl))) { goto Exit; } diff --git a/sql/src/frow.cpp b/sql/src/frow.cpp index 7b6562c..0c59933 100644 --- a/sql/src/frow.cpp +++ b/sql/src/frow.cpp @@ -296,9 +296,9 @@ RCODE F_RowCacheMgr::initCache( void) // Set up the F_Row object allocator - if (RC_BAD( rc = m_pRowAllocator->setup( &m_rowRelocator, - gv_SFlmSysData.pGlobalCacheMgr->m_pSlabManager, - sizeof( F_Row), &m_Usage.slabUsage))) + if (RC_BAD( rc = m_pRowAllocator->setup( + gv_SFlmSysData.pGlobalCacheMgr->m_pSlabManager, + &m_rowRelocator, sizeof( F_Row), &m_Usage.slabUsage, NULL))) { goto Exit; } @@ -311,8 +311,8 @@ RCODE F_RowCacheMgr::initCache( void) // Set up the buffer allocator for F_Row objects if (RC_BAD( rc = m_pBufAllocator->setup( - gv_SFlmSysData.pGlobalCacheMgr->m_pSlabManager, - &m_Usage.slabUsage))) + gv_SFlmSysData.pGlobalCacheMgr->m_pSlabManager, NULL, + &m_Usage.slabUsage, NULL))) { goto Exit; } diff --git a/sql/src/fscursor.h b/sql/src/fscursor.h index 0b853e1..4f81bf3 100644 --- a/sql/src/fscursor.h +++ b/sql/src/fscursor.h @@ -26,8 +26,6 @@ #ifndef FSCURSOR_H #define FSCURSOR_H -#include "fdynsset.h" - typedef struct KeyPosition { FLMBYTE ucKey [SFLM_MAX_KEY_SIZE]; diff --git a/sql/src/fsuperfl.cpp b/sql/src/fsuperfl.cpp deleted file mode 100644 index a1bd1ef..0000000 --- a/sql/src/fsuperfl.cpp +++ /dev/null @@ -1,1003 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This include file contains the methods for FLAIM's -// super file class. -// -// Tabs: 3 -// -// Copyright (c) 1998-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id$ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -FSTATIC char base24ToDigit( - FLMUINT uiBaseValue); - -/**************************************************************************** -Desc: -****************************************************************************/ -F_SuperFileHdl::F_SuperFileHdl( void) -{ - m_pszDbFileName = NULL; - m_pszDataFileNameBase = NULL; - f_memset( &m_CheckedOutFileHdls[ 0], 0, sizeof( m_CheckedOutFileHdls)); - m_pCheckedOutFileHdls = &m_CheckedOutFileHdls [0]; - m_uiCkoArraySize = MAX_CHECKED_OUT_FILE_HDLS + 1; - m_uiBlockSize = 0; - m_uiExtendSize = SFLM_DEFAULT_FILE_EXTEND_SIZE; - m_uiMaxAutoExtendSize = gv_SFlmSysData.uiMaxFileSize; - m_uiLowestDirtySlot = 1; - m_uiHighestDirtySlot = 0; - m_uiHighestUsedSlot = 0; - m_uiHighestFileNumber = 0; - m_bMinimizeFlushes = FALSE; - m_bSetupCalled = FALSE; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_SuperFileHdl::~F_SuperFileHdl() -{ - if( m_bSetupCalled) - { - (void)releaseFiles( TRUE); - } - - if (m_pszDbFileName) - { - f_free( &m_pszDbFileName); - } -} - -/**************************************************************************** -Desc: Configures the super file object -****************************************************************************/ -RCODE F_SuperFileHdl::setup( - const char * pszDbFileName, - const char * pszDataDir) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiNameLen; - FLMUINT uiDataNameLen; - char szDir [F_PATH_MAX_SIZE]; - char szBaseName [F_FILENAME_SIZE]; - - flmAssert( !m_bSetupCalled); - - if( !pszDbFileName && *pszDbFileName == 0) - { - rc = RC_SET( NE_FLM_IO_INVALID_FILENAME); - goto Exit; - } - - uiNameLen = f_strlen( pszDbFileName); - if (pszDataDir && *pszDataDir) - { - if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->pathReduce( - pszDbFileName, szDir, szBaseName))) - { - goto Exit; - } - f_strcpy( szDir, pszDataDir); - if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->pathAppend( - szDir, szBaseName))) - { - goto Exit; - } - uiDataNameLen = f_strlen( szDir); - - if (RC_BAD( rc = f_alloc( (uiNameLen + 1) + (uiDataNameLen + 1), - &m_pszDbFileName))) - { - goto Exit; - } - - f_memcpy( m_pszDbFileName, pszDbFileName, uiNameLen + 1); - m_pszDataFileNameBase = m_pszDbFileName + uiNameLen + 1; - F_DbSystem::getDbBasePath( m_pszDataFileNameBase, szDir, &m_uiDataExtOffset); - m_uiExtOffset = uiNameLen - (uiDataNameLen - m_uiDataExtOffset); - } - else - { - if (RC_BAD( rc = f_alloc( (uiNameLen + 1) * 2, &m_pszDbFileName))) - { - goto Exit; - } - - f_memcpy( m_pszDbFileName, pszDbFileName, uiNameLen + 1); - m_pszDataFileNameBase = m_pszDbFileName + uiNameLen + 1; - F_DbSystem::getDbBasePath( m_pszDataFileNameBase, - m_pszDbFileName, &m_uiDataExtOffset); - m_uiExtOffset = m_uiDataExtOffset; - } - - m_bSetupCalled = TRUE; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Creates a file -****************************************************************************/ -RCODE F_SuperFileHdl::createFile( - FLMUINT uiFileNumber) -{ - RCODE rc = NE_SFLM_OK; - char szFilePath[ F_PATH_MAX_SIZE]; - IF_FileHdl * pFileHdl = NULL; -// FLMUINT uiFileId; - - // Sanity checks - - flmAssert( m_bSetupCalled && m_uiBlockSize); - flmAssert( uiFileNumber <= MAX_LOG_BLOCK_FILE_NUMBER); - - // See if we already have an open file handle (or if we can open the file). - // If so, truncate the file and use it. - - if( RC_OK( rc = getFileHdl( uiFileNumber, TRUE, &pFileHdl))) - { - rc = pFileHdl->truncate( 0); - pFileHdl = NULL; - goto Exit; - } - else if( rc != NE_FLM_IO_PATH_NOT_FOUND) - { - goto Exit; - } - - // Build the file path - - if( RC_BAD( rc = getFilePath( uiFileNumber, szFilePath))) - { - goto Exit; - } - - if( RC_BAD( rc = gv_SFlmSysData.pFileSystem->createFile( szFilePath, - FLM_IO_RDWR | FLM_IO_EXCL | FLM_IO_DIRECT | FLM_IO_SH_DENYNONE, - &pFileHdl))) - { - goto Exit; - } - - pFileHdl->setBlockSize( m_uiBlockSize); - -Exit: - - if( pFileHdl) - { - pFileHdl->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: Reads a database block into a buffer -****************************************************************************/ -RCODE F_SuperFileHdl::readBlock( - FLMUINT uiBlkAddress, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesRead) -{ - IF_FileHdl * pFileHdl = NULL; - RCODE rc = NE_SFLM_OK; - - flmAssert( m_bSetupCalled && m_uiBlockSize); - - if( RC_BAD( rc = getFileHdl( - FSGetFileNumber( uiBlkAddress), FALSE, &pFileHdl))) - { - goto Exit; - } - - if( RC_BAD( rc = pFileHdl->sectorRead( - FSGetFileOffset( uiBlkAddress), uiBytesToRead, - pvBuffer, puiBytesRead))) - { - if (rc != NE_FLM_IO_END_OF_FILE && rc != NE_SFLM_MEM) - { - releaseFile( FSGetFileNumber( uiBlkAddress), TRUE); - } - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Writes a block to the database -****************************************************************************/ -RCODE F_SuperFileHdl::writeBlock( - FLMUINT uiBlkAddress, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT uiBufferSize, - IF_IOBuffer * pIOBuffer, - FLMUINT * puiBytesWritten) -{ - IF_FileHdl * pFileHdl = NULL; - RCODE rc = NE_SFLM_OK; - - flmAssert( m_bSetupCalled && m_uiBlockSize); - -Get_Handle: - if( RC_BAD( rc = getFileHdl( - FSGetFileNumber( uiBlkAddress), TRUE, &pFileHdl))) - { - if (rc == NE_FLM_IO_PATH_NOT_FOUND) - { - if (RC_BAD( rc = createFile( FSGetFileNumber( uiBlkAddress)))) - { - goto Exit; - } - else - { - goto Get_Handle; - } - } - goto Exit; - } - - pFileHdl->setExtendSize( m_uiExtendSize); - pFileHdl->setMaxAutoExtendSize( m_uiMaxAutoExtendSize); - if( RC_BAD( rc = pFileHdl->sectorWrite( - FSGetFileOffset( uiBlkAddress), uiBytesToWrite, - pvBuffer, uiBufferSize, pIOBuffer, puiBytesWritten))) - { - if (rc != NE_FLM_IO_DISK_FULL && rc != NE_SFLM_MEM) - { - releaseFile( FSGetFileNumber( uiBlkAddress), TRUE); - } - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Reads data from the database header -****************************************************************************/ -RCODE F_SuperFileHdl::readHeader( - FLMUINT uiOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_SFLM_OK; - IF_FileHdl * pFileHdl; - -#ifdef FLM_DEBUG - if( m_uiBlockSize) - { - // Note: Block size may not be set because we are in the process of - // opening the file for the first time and we don't know the block - // size until after the header has been read. - - flmAssert( (FLMUINT)(uiOffset + uiBytesToRead) <= m_uiBlockSize); - } -#endif - - if( RC_BAD( rc = getFileHdl( 0, TRUE, &pFileHdl))) - { - goto Exit; - } - - if( RC_BAD( rc = pFileHdl->read( uiOffset, - uiBytesToRead, pvBuffer, puiBytesRead))) - { - if (rc != NE_FLM_IO_END_OF_FILE && rc != NE_SFLM_MEM) - { - releaseFile( (FLMUINT)0, TRUE); - } - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Writes data to the database header -****************************************************************************/ -RCODE F_SuperFileHdl::writeHeader( - FLMUINT uiOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT * puiBytesWritten) -{ - RCODE rc = NE_SFLM_OK; - IF_FileHdl * pFileHdl; - -#ifdef FLM_DEBUG - if( m_uiBlockSize) - { - flmAssert( (FLMUINT)(uiOffset + uiBytesToWrite) <= m_uiBlockSize); - } -#endif - - if( RC_BAD( rc = getFileHdl( 0, TRUE, &pFileHdl))) - { - goto Exit; - } - - if( RC_BAD( rc = pFileHdl->write( uiOffset, - uiBytesToWrite, pvBuffer, puiBytesWritten))) - { - if (rc != NE_FLM_IO_DISK_FULL && rc != NE_SFLM_MEM) - { - releaseFile( (FLMUINT)0, TRUE); - } - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Releases all file handle objects and optionally closes the files -****************************************************************************/ -RCODE F_SuperFileHdl::releaseFile( - FLMUINT uiFileNum, - FLMBOOL bCloseFile) -{ - RCODE rc = NE_SFLM_OK; - CHECKED_OUT_FILE_HDL * pCkoFileHdl; - FLMUINT uiSlot; - - pCkoFileHdl = getCkoFileHdlPtr( uiFileNum, &uiSlot); - if( pCkoFileHdl->uiFileNumber == uiFileNum) - { - if( RC_BAD( rc = releaseFile( pCkoFileHdl, bCloseFile))) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Releases all file handle objects and optionally closes the files -****************************************************************************/ -RCODE F_SuperFileHdl::releaseFiles( - FLMBOOL bCloseFiles) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiLoop; - - flmAssert( m_bSetupCalled); - - for( uiLoop = 0; uiLoop <= m_uiHighestUsedSlot; uiLoop++) - { - if( RC_BAD( rc = releaseFile( - &m_CheckedOutFileHdls[ uiLoop], bCloseFiles))) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Releases a file handle object -****************************************************************************/ -RCODE F_SuperFileHdl::releaseFile( - CHECKED_OUT_FILE_HDL * pCkoFileHdl, - FLMBOOL bCloseFile) -{ - RCODE rc = NE_SFLM_OK; - IF_FileHdl * pFileHdl = pCkoFileHdl->pFileHdl; - - if( pFileHdl) - { -// flmAssert( pFileHdl->getFileId()); - - if( pCkoFileHdl->bDirty) - { - (void)pFileHdl->flush(); - } - - if( bCloseFile) - { - FLMUINT uiRefCnt; - - uiRefCnt = pFileHdl->Release(); - flmAssert( uiRefCnt == 0); - } - - clearCkoFileHdl( pCkoFileHdl); - } - - return( rc); -} - -/**************************************************************************** -Desc: Copy one CKO array into another. -****************************************************************************/ -void F_SuperFileHdl::copyCkoFileHdls( - CHECKED_OUT_FILE_HDL * pSrcCkoArray, - FLMUINT uiSrcHighestUsedSlot - ) -{ - FLMUINT uiNewSlot; - FLMUINT uiSrcSlot; - - // Zeroeth element is always copied. - - f_memcpy( m_pCheckedOutFileHdls, pSrcCkoArray, - sizeof( CHECKED_OUT_FILE_HDL)); - - // Memset the rest of the destination array to zero. - - f_memset( &m_pCheckedOutFileHdls[1], 0, sizeof( CHECKED_OUT_FILE_HDL) * - (m_uiCkoArraySize - 1)); - - m_uiHighestUsedSlot = 0; - m_uiLowestDirtySlot = 1; - m_uiHighestDirtySlot = 0; - for (uiSrcSlot = 1, pSrcCkoArray++; - uiSrcSlot <= uiSrcHighestUsedSlot; - uiSrcSlot++, pSrcCkoArray++) - { - if (pSrcCkoArray->pFileHdl && pSrcCkoArray->uiFileNumber) - { - uiNewSlot = pSrcCkoArray->uiFileNumber % (m_uiCkoArraySize - 1) + 1; - - // Only overwrite the destination one if the file number is - // lower than the one already there - - if (pSrcCkoArray->uiFileNumber < - m_pCheckedOutFileHdls [uiNewSlot].uiFileNumber || - !m_pCheckedOutFileHdls [uiNewSlot].uiFileNumber) - { - if (m_pCheckedOutFileHdls [uiNewSlot].uiFileNumber) - { - releaseFile( &m_pCheckedOutFileHdls [uiNewSlot], FALSE); - } - f_memcpy( &m_pCheckedOutFileHdls [uiNewSlot], pSrcCkoArray, - sizeof( CHECKED_OUT_FILE_HDL)); - if (uiNewSlot > m_uiHighestUsedSlot) - { - m_uiHighestUsedSlot = uiNewSlot; - } - if (m_uiHighestFileNumber < pSrcCkoArray->uiFileNumber) - { - m_uiHighestFileNumber = pSrcCkoArray->uiFileNumber; - } - if (pSrcCkoArray->bDirty) - { - if (m_uiLowestDirtySlot > m_uiHighestDirtySlot) - - { - m_uiLowestDirtySlot = - m_uiHighestDirtySlot = uiNewSlot; - } - else if( m_uiHighestDirtySlot < uiNewSlot) - { - m_uiHighestDirtySlot = uiNewSlot; - } - else if (m_uiLowestDirtySlot < uiNewSlot) - { - m_uiLowestDirtySlot = uiNewSlot; - } - } - } - else - { - releaseFile( pSrcCkoArray, FALSE); - } - } - } -} - -/**************************************************************************** -Desc: Disable flush minimizing. -****************************************************************************/ -void F_SuperFileHdl::disableFlushMinimize( void) -{ - - // Copy the allocated array back into the fixed array. - // This doesn't necessarily copy all of the file handles. - - if (m_pCheckedOutFileHdls != &m_CheckedOutFileHdls [0]) - { - CHECKED_OUT_FILE_HDL * pOldCkoArray = m_pCheckedOutFileHdls; - FLMUINT uiOldHighestUsedSlot = m_uiHighestUsedSlot; - - m_pCheckedOutFileHdls = &m_CheckedOutFileHdls [0]; - m_uiCkoArraySize = MAX_CHECKED_OUT_FILE_HDLS + 1; - copyCkoFileHdls( pOldCkoArray, uiOldHighestUsedSlot); - - f_free( &pOldCkoArray); - } - m_bMinimizeFlushes = FALSE; -} - -/**************************************************************************** -Desc: Flush dirty files to disk. -****************************************************************************/ -RCODE F_SuperFileHdl::flush( void) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiLoop; - - // Flush all dirty files - - for (uiLoop = m_uiLowestDirtySlot; - uiLoop <= m_uiHighestDirtySlot; - uiLoop++) - { - if( m_pCheckedOutFileHdls[ uiLoop].bDirty) - { - RCODE tmpRc; - - if (RC_BAD( tmpRc = - m_pCheckedOutFileHdls[ uiLoop].pFileHdl->flush())) - { - rc = tmpRc; - releaseFile( &m_pCheckedOutFileHdls [uiLoop], TRUE); - } - m_pCheckedOutFileHdls[ uiLoop].bDirty = FALSE; - } - } - m_uiLowestDirtySlot = 1; - m_uiHighestDirtySlot = 0; - return( rc); -} - -/**************************************************************************** -Desc: Truncates back to an end of file block address. - This may only be called from reduce() because there cannot - be any other cases to reduce a 3x block file. -****************************************************************************/ -RCODE F_SuperFileHdl::truncateFile( - FLMUINT uiEOFBlkAddress) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiFileNumber = (FLMUINT)FSGetFileNumber( uiEOFBlkAddress); - FLMUINT uiBlockOffset = (FLMUINT)FSGetFileOffset( uiEOFBlkAddress); - IF_FileHdl * pFileHdl; - - // Truncate the current block file. - - if( RC_BAD( rc = getFileHdl( uiFileNumber, TRUE, &pFileHdl))) - { - goto Exit; - } - - if( RC_BAD( rc = pFileHdl->truncate( uiBlockOffset))) - { - releaseFile( uiFileNumber, TRUE); - goto Exit; - } - - // Visit the rest of the high block files until a NULL file hdl is hit. - - for( ;;) - { - if( RC_BAD( getFileHdl( ++uiFileNumber, TRUE, &pFileHdl))) - { - break; - } - - if( RC_BAD( rc = pFileHdl->truncate( (FLMUINT)0 ))) - { - releaseFile( uiFileNumber, TRUE); - goto Exit; - } - - if( RC_BAD( rc = releaseFile( uiFileNumber, TRUE))) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Truncate to zero length any files between the specified start - and end files. -****************************************************************************/ -void F_SuperFileHdl::truncateFiles( - FLMUINT uiStartFileNum, - FLMUINT uiEndFileNum) -{ - FLMUINT uiFileNumber; - IF_FileHdl * pFileHdl; - - for( uiFileNumber = uiStartFileNum; - uiFileNumber <= uiEndFileNum; - uiFileNumber++ ) - { - if( RC_OK( getFileHdl( uiFileNumber, TRUE, &pFileHdl ))) - { - (void)pFileHdl->truncate( (FLMUINT)0 ); - (void)releaseFile( uiFileNumber, TRUE); - } - } -} - -/**************************************************************************** -Desc: Returns the physical size of a file -****************************************************************************/ -RCODE F_SuperFileHdl::getFileSize( - FLMUINT uiFileNumber, - FLMUINT64 * pui64FileSize) -{ - IF_FileHdl * pFileHdl = NULL; - RCODE rc = NE_SFLM_OK; - - flmAssert( m_bSetupCalled); - flmAssert( pui64FileSize); - - *pui64FileSize = 0; - - // Get the file handle. - - if( RC_BAD( rc = getFileHdl( uiFileNumber, FALSE, &pFileHdl))) - { - goto Exit; - } - - if( RC_BAD( rc = pFileHdl->size( pui64FileSize))) - { - releaseFile( uiFileNumber, TRUE); - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Returns the path of a file given its file number -****************************************************************************/ -RCODE F_SuperFileHdl::getFilePath( - FLMUINT uiFileNumber, - char * pszIoPath) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiExtOffset; - - // Sanity checks - - flmAssert( m_bSetupCalled); - - if (!uiFileNumber) - { - f_strcpy( pszIoPath, m_pszDbFileName); - goto Exit; - } - - if( uiFileNumber <= MAX_DATA_BLOCK_FILE_NUMBER) - { - f_memcpy( pszIoPath, m_pszDataFileNameBase, m_uiDataExtOffset); - uiExtOffset = m_uiDataExtOffset; - } - else - { - f_memcpy( pszIoPath, m_pszDbFileName, m_uiExtOffset); - uiExtOffset = m_uiExtOffset; - } - - // Modify the file's extension. - - bldSuperFileExtension( uiFileNumber, &pszIoPath[ uiExtOffset]); - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Reallocates the checked out file handle array. -****************************************************************************/ -RCODE F_SuperFileHdl::reallocCkoArray( - FLMUINT uiFileNum - ) -{ - RCODE rc = NE_SFLM_OK; - FLMUINT uiNewSize; - CHECKED_OUT_FILE_HDL * pNewCkoArray; - CHECKED_OUT_FILE_HDL * pOldCkoArray; - FLMUINT uiOldHighestUsedSlot; - - if (uiFileNum < m_uiHighestFileNumber) - { - uiFileNum = m_uiHighestFileNumber; - } - uiNewSize = uiFileNum + 128; - - // Reallocate so we can guarantee that all of the current file - // numbers will copy and there is room for this new one as well. - - if (uiNewSize > MAX_LOG_BLOCK_FILE_NUMBER + 1) - { - flmAssert( uiFileNum <= MAX_LOG_BLOCK_FILE_NUMBER); - uiNewSize = MAX_LOG_BLOCK_FILE_NUMBER + 1; - } - - // No need to call f_calloc, because copyCkoFileHdls will initialize - // it below. - - if (RC_BAD( rc = f_alloc( sizeof( CHECKED_OUT_FILE_HDL) * uiNewSize, - &pNewCkoArray))) - { - goto Exit; - } - - pOldCkoArray = m_pCheckedOutFileHdls; - uiOldHighestUsedSlot = m_uiHighestUsedSlot; - - m_pCheckedOutFileHdls = pNewCkoArray; - m_uiCkoArraySize = uiNewSize; - - copyCkoFileHdls( pOldCkoArray, uiOldHighestUsedSlot); - - // Can't free the old one until after the copy! - - if (pOldCkoArray != &m_CheckedOutFileHdls [0]) - { - f_free( &pOldCkoArray); - } - -Exit: - - return( rc); - -} - -/**************************************************************************** -Desc: Returns a file handle given the file's number -****************************************************************************/ -RCODE F_SuperFileHdl::getFileHdl( - FLMUINT uiFileNum, - FLMBOOL bGetForUpdate, - IF_FileHdl ** ppFileHdl) -{ - RCODE rc = NE_SFLM_OK; - IF_FileHdl * pFileHdl = NULL; - CHECKED_OUT_FILE_HDL * pCkoFileHdl; - char szFilePath[ F_PATH_MAX_SIZE]; - FLMUINT uiSlot; - - pCkoFileHdl = getCkoFileHdlPtr( uiFileNum, &uiSlot); - if( pCkoFileHdl->uiFileNumber != uiFileNum && - pCkoFileHdl->pFileHdl) - { - if (pCkoFileHdl->bDirty && m_bMinimizeFlushes) - { - flmAssert( pCkoFileHdl->uiFileNumber); - if (RC_BAD( reallocCkoArray( uiFileNum))) - { - goto Exit; - } - pCkoFileHdl = getCkoFileHdlPtr( uiFileNum, &uiSlot); - - // Better have reallocated so that the new slot for - // the file number has nothing in it. - - flmAssert( !pCkoFileHdl->uiFileNumber && - !pCkoFileHdl->pFileHdl); - } - else - { - if( RC_BAD( rc = releaseFile( pCkoFileHdl, FALSE))) - { - goto Exit; - } - } - } - - if( !pCkoFileHdl->pFileHdl) - { - if (!pFileHdl) - { - // Build the file path - - if( RC_BAD( rc = getFilePath( uiFileNum, szFilePath))) - { - goto Exit; - } - - // Open the file - - if( RC_BAD( rc = gv_SFlmSysData.pFileSystem->openFile( szFilePath, - FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, - &pFileHdl))) - { - goto Exit; - } - - pFileHdl->setBlockSize( m_uiBlockSize); - } - - pCkoFileHdl->pFileHdl = pFileHdl; - pFileHdl = NULL; - pCkoFileHdl->uiFileNumber = uiFileNum; - pCkoFileHdl->bDirty = FALSE; - - if( m_uiHighestUsedSlot < uiSlot) - { - m_uiHighestUsedSlot = uiSlot; - } - if (m_uiHighestFileNumber < uiFileNum) - { - m_uiHighestFileNumber = uiFileNum; - } - } - - *ppFileHdl = pCkoFileHdl->pFileHdl; - if( bGetForUpdate) - { - pCkoFileHdl->bDirty = TRUE; - if (m_uiLowestDirtySlot > m_uiHighestDirtySlot) - - { - m_uiLowestDirtySlot = - m_uiHighestDirtySlot = uiSlot; - } - else if( m_uiHighestDirtySlot < uiSlot) - { - m_uiHighestDirtySlot = uiSlot; - } - else if (m_uiLowestDirtySlot < uiSlot) - { - m_uiLowestDirtySlot = uiSlot; - } - } - -Exit: - - if( pFileHdl) - { - pFileHdl->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: Generates a file name given a super file number. - Adds ".xx" to pFileExtension. Use lower case characters. -Notes: This is a base 24 alphanumeric value where - { a, b, c, d, e, f, i, l, o, r, u, v } values are removed. -****************************************************************************/ -void bldSuperFileExtension( - FLMUINT uiFileNum, - char * pszFileExtension) -{ - char ucLetter; - - if (uiFileNum <= MAX_DATA_BLOCK_FILE_NUMBER - 1536) - { - // No additional letter - File numbers 1 to 511 - // This is just like pre-4.3 numbering. - ucLetter = 0; - } - else if (uiFileNum <= MAX_DATA_BLOCK_FILE_NUMBER - 1024) - { - // File numbers 512 to 1023 - ucLetter = 'r'; - } - else if (uiFileNum <= MAX_DATA_BLOCK_FILE_NUMBER - 512) - { - // File numbers 1024 to 1535 - ucLetter = 's'; - } - else if (uiFileNum <= MAX_DATA_BLOCK_FILE_NUMBER) - { - // File numbers 1536 to 2047 - ucLetter = 't'; - } - else if (uiFileNum <= MAX_LOG_BLOCK_FILE_NUMBER - 1536) - { - // File numbers 2048 to 2559 - ucLetter = 'v'; - } - else if (uiFileNum <= MAX_LOG_BLOCK_FILE_NUMBER - 1024) - { - // File numbers 2560 to 3071 - ucLetter = 'w'; - } - else if (uiFileNum <= MAX_LOG_BLOCK_FILE_NUMBER - 512) - { - // File numbers 3072 to 3583 - ucLetter = 'x'; - } - else - { - flmAssert( uiFileNum <= MAX_LOG_BLOCK_FILE_NUMBER); - - // File numbers 3584 to 4095 - ucLetter = 'z'; - } - - *pszFileExtension++ = '.'; - *pszFileExtension++ = (char)(base24ToDigit( (uiFileNum & 511) / 24)); - *pszFileExtension++ = (char)(base24ToDigit( (uiFileNum & 511) % 24)); - *pszFileExtension++ = ucLetter; - *pszFileExtension = 0; -} - -/**************************************************************************** -Desc: Turn a base 24 value into a native alphanumeric value. -Notes: This is a base 24 alphanumeric value where - {a, b, c, d, e, f, i, l, o, r, u, v } values are removed. -****************************************************************************/ -FSTATIC char base24ToDigit( - FLMUINT uiValue) -{ - flmAssert( uiValue <= 23); - - if( uiValue <= 9) - { - uiValue += (FLMUINT) NATIVE_ZERO; - } - else - { - uiValue = f_toascii(uiValue) - 10 + (FLMUINT)f_toascii('g'); - if( uiValue >= (FLMUINT)'i') - { - uiValue++; - if( uiValue >= (FLMUINT)'l') - { - uiValue++; - if( uiValue >= (FLMUINT)'o') - { - uiValue++; - if( uiValue >= (FLMUINT)'r') - { - uiValue++; - if( uiValue >= (FLMUINT)'u') - { - uiValue++; - if( uiValue >= (FLMUINT)'v') - { - uiValue++; - } - } - } - } - } - } - } - return (char)uiValue; -} diff --git a/sql/src/fsuperfl.h b/sql/src/fsuperfl.h deleted file mode 100644 index 3007811..0000000 --- a/sql/src/fsuperfl.h +++ /dev/null @@ -1,213 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This include file contains the class definitions for FLAIM's -// super file class. -// -// Tabs: 3 -// -// Copyright (c) 1998-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id$ -//------------------------------------------------------------------------------ - -#ifndef FSUPERFL_H -#define FSUPERFL_H - -#define MAX_CHECKED_OUT_FILE_HDLS 8 - -void bldSuperFileExtension( - FLMUINT uiFileNum, - char * pszFileExtension); - -typedef struct -{ - IF_FileHdl * pFileHdl; - FLMUINT uiFileNumber; - FLMBOOL bDirty; -} CHECKED_OUT_FILE_HDL; - -/**************************************************************************** -Desc: The F_SuperFileHdl object manages the control and block files - associated with a FLAIM Super File. This class also provides - backward compatibility with prior file formats. -Note: -****************************************************************************/ -class F_SuperFileHdl : public F_Object -{ -public: - F_SuperFileHdl(); - - ~F_SuperFileHdl(); - - RCODE setup( - const char * pszDbFileName, - const char * pszDataDir); - - RCODE createFile( - FLMUINT uiFileNumber); - - RCODE readBlock( - FLMUINT uiBlkAddress, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesRead); - - RCODE writeBlock( - FLMUINT uiBlkAddress, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT uiBufferSize, - IF_IOBuffer * pIOBuffer, - FLMUINT * puiBytesWritten); - - RCODE readHeader( - FLMUINT uiOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesRead); - - RCODE writeHeader( - FLMUINT uiOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT * puiBytesWritten); - - RCODE getFilePath( - FLMUINT uiFileNumber, - char * pszPath); - - RCODE getFileHdl( - FLMUINT uiFileNumber, - FLMBOOL bGetForUpdate, - IF_FileHdl ** ppFileHdlRV); - - RCODE getFileSize( - FLMUINT uiFileNumber, - FLMUINT64 * pui64FileSize); - - RCODE releaseFile( - FLMUINT uiFileNum, - FLMBOOL bCloseFile); - - RCODE releaseFiles( - FLMBOOL bCloseFiles); - - RCODE truncateFile( - FLMUINT uiEOFBlkAddress); - - void truncateFiles( - FLMUINT uiStartFileNum, - FLMUINT uiEndFileNum); - - RCODE releaseFile( - CHECKED_OUT_FILE_HDL * pChkFileHdl, - FLMBOOL bCloseFile); - - FINLINE void enableFlushMinimize( void) - { - m_bMinimizeFlushes = TRUE; - } - - void disableFlushMinimize( void); - - RCODE flush( void); - - FINLINE void setBlockSize( - FLMUINT uiBlockSize) - { - m_uiBlockSize = uiBlockSize; - } - - FINLINE void setExtendSize( - FLMUINT uiExtendSize) - { - m_uiExtendSize = uiExtendSize; - } - - FINLINE void setMaxAutoExtendSize( - FLMUINT uiMaxAutoExtendSize) - { - m_uiMaxAutoExtendSize = uiMaxAutoExtendSize; - } - - FINLINE FLMBOOL canDoAsync( void) - { - if (m_pCheckedOutFileHdls[ 0].pFileHdl) - { - return( m_pCheckedOutFileHdls[ 0].pFileHdl->canDoAsync()); - } - else - { - IF_FileHdl * pFileHdl; - - if( RC_OK( getFileHdl( 0, FALSE, &pFileHdl))) - { - return( pFileHdl->canDoAsync()); - } - } - - return( FALSE); - } - -private: - - FINLINE CHECKED_OUT_FILE_HDL * getCkoFileHdlPtr( - FLMUINT uiFileNum, - FLMUINT * puiSlot) - { - *puiSlot = (uiFileNum - ? (uiFileNum % (m_uiCkoArraySize - 1)) + 1 - : 0); - - return( &m_pCheckedOutFileHdls[ *puiSlot]); - } - - FINLINE void clearCkoFileHdl( - CHECKED_OUT_FILE_HDL * pCkoFileHdl) - { - pCkoFileHdl->pFileHdl = NULL; - pCkoFileHdl->uiFileNumber = 0; - pCkoFileHdl->bDirty = FALSE; - } - - void copyCkoFileHdls( - CHECKED_OUT_FILE_HDL * pSrcCkoArray, - FLMUINT uiSrcHighestUsedSlot); - - RCODE reallocCkoArray( - FLMUINT uiFileNum); - - char * m_pszDbFileName; - char * m_pszDataFileNameBase; - FLMUINT m_uiExtOffset; - FLMUINT m_uiDataExtOffset; - CHECKED_OUT_FILE_HDL m_CheckedOutFileHdls[ - MAX_CHECKED_OUT_FILE_HDLS + 1]; - CHECKED_OUT_FILE_HDL * m_pCheckedOutFileHdls; - FLMUINT m_uiCkoArraySize; - FLMUINT m_uiBlockSize; - FLMUINT m_uiExtendSize; - FLMUINT m_uiMaxAutoExtendSize; - FLMUINT m_uiLowestDirtySlot; - FLMUINT m_uiHighestDirtySlot; - FLMUINT m_uiHighestUsedSlot; - FLMUINT m_uiHighestFileNumber; - FLMBOOL m_bMinimizeFlushes; - FLMBOOL m_bSetupCalled; -}; - -#endif // FSUPERFL_H diff --git a/sql/src/fsysdata.cpp b/sql/src/fsysdata.cpp index d4307d8..6ba7bb6 100644 --- a/sql/src/fsysdata.cpp +++ b/sql/src/fsysdata.cpp @@ -29,7 +29,6 @@ #include "flaimsys.h" -#define HIGH_FLMUINT (~((FLMUINT)0)) #define FLM_MIN_FREE_BYTES (2 * 1024 * 1024) #ifdef FLM_32BIT @@ -48,8 +47,8 @@ #define FLM_MAX_CACHE_SIZE (~((FLMUINT)0)) #endif -FLMATOMIC F_DbSystem::m_flmSysSpinLock = 0; -FLMUINT F_DbSystem::m_uiFlmSysStartupCount = 0; +static FLMATOMIC gv_flmSysSpinLock = 0; +static FLMBOOL gv_bToolkitStarted = FALSE; FSTATIC RCODE flmGetCacheBytes( FLMUINT uiPercent, @@ -82,6 +81,10 @@ FSTATIC void flmGetUintParam( FLMUINT * puiUint, IF_IniFile * pIniFile); +FSTATIC void lockSysData( void); + +FSTATIC void unlockSysData( void); + void flmGetBoolParam( const char * pszParamName, FLMBOOL uiDefaultValue, @@ -92,8 +95,6 @@ FSTATIC RCODE flmGetIniFileName( FLMBYTE * pszIniFileName, FLMUINT uiBufferSz); -FLMBOOL gv_bToolkitStarted = FALSE; - /**************************************************************************** Desc: This routine allocates and initializes a hash table. ****************************************************************************/ @@ -185,9 +186,9 @@ FSTATIC RCODE flmGetCacheBytes( goto Exit; } - if( ui64TotalPhysMem > HIGH_FLMUINT) + if( ui64TotalPhysMem > FLM_MAX_UINT) { - ui64TotalPhysMem = HIGH_FLMUINT; + ui64TotalPhysMem = FLM_MAX_UINT; } if( ui64AvailPhysMem > ui64TotalPhysMem) @@ -204,9 +205,9 @@ FSTATIC RCODE flmGetCacheBytes( if (bCalcOnAvailMem) { - if (uiMem > HIGH_FLMUINT - uiBytesCurrentlyInUse) + if (uiMem > FLM_MAX_UINT - uiBytesCurrentlyInUse) { - uiMem = HIGH_FLMUINT; + uiMem = FLM_MAX_UINT; } else { @@ -234,7 +235,7 @@ FSTATIC RCODE flmGetCacheBytes( // Calculate memory as a percentage of memory. - uiMem = (FLMUINT)((uiMem > HIGH_FLMUINT / 100) + uiMem = (FLMUINT)((uiMem > FLM_MAX_UINT / 100) ? (FLMUINT)(uiMem / 100) * uiPercent : (FLMUINT)(uiMem * uiPercent) / 100); @@ -705,10 +706,10 @@ Desc: This routine links an FDB structure to an F_Database structure. locked. ****************************************************************************/ RCODE F_Db::linkToDatabase( - F_Database * pDatabase - ) + F_Database * pDatabase) { - RCODE rc = NE_SFLM_OK; + RCODE rc = NE_SFLM_OK; + F_SuperFileClient * pSFileClient = NULL; // If the use count on the file used to be zero, unlink it from the // unused list. @@ -730,22 +731,31 @@ RCODE F_Db::linkToDatabase( // Allocate the super file object - if (!m_pSFileHdl) + if( !m_pSFileHdl) { - if ((m_pSFileHdl = f_new F_SuperFileHdl) == NULL) + if( (m_pSFileHdl = f_new F_SuperFileHdl) == NULL) { rc = RC_SET( NE_SFLM_MEM); goto Exit; } - // Set up the super file + if( (pSFileClient = f_new F_SuperFileClient) == NULL) + { + rc = RC_SET( NE_SFLM_MEM); + goto Exit; + } - if( RC_BAD( rc = m_pSFileHdl->setup( + if( RC_BAD( rc = pSFileClient->setup( pDatabase->m_pszDbPath, pDatabase->m_pszDataDir))) { goto Exit; } + if( RC_BAD( rc = m_pSFileHdl->setup( pSFileClient))) + { + goto Exit; + } + if( pDatabase->m_lastCommittedDbHdr.ui32DbVersion) { m_pSFileHdl->setBlockSize( pDatabase->m_uiBlockSize); @@ -754,6 +764,11 @@ RCODE F_Db::linkToDatabase( Exit: + if( pSFileClient) + { + pSFileClient->Release(); + } + return( rc); } @@ -1047,11 +1062,9 @@ Desc: Lock the system data structure for access - called only by startup and shutdown. NOTE: On platforms that do not support atomic exchange this is less than perfect - won't handle tight race conditions. ***************************************************************************/ -void F_DbSystem::lockSysData( void) +void lockSysData( void) { - // Obtain the spin lock - - while( f_atomicExchange( &m_flmSysSpinLock, 1) == 1) + while( f_atomicExchange( &gv_flmSysSpinLock, 1) == 1) { f_sleep( 10); } @@ -1061,9 +1074,9 @@ void F_DbSystem::lockSysData( void) Desc: Unlock the system data structure for access - called only by startup and shutdown. ***************************************************************************/ -void F_DbSystem::unlockSysData( void) +void unlockSysData( void) { - (void)f_atomicExchange( &m_flmSysSpinLock, 0); + (void)f_atomicExchange( &gv_flmSysSpinLock, 0); } /**************************************************************************** @@ -3193,3 +3206,207 @@ Exit: return( rc); } +/**************************************************************************** +Desc: +****************************************************************************/ +F_SuperFileClient::F_SuperFileClient() +{ + m_pszCFileName = NULL; + m_pszDataFileBaseName = NULL; + m_uiExtOffset = 0; + m_uiDataExtOffset = 0; +} + +/**************************************************************************** +Desc: +****************************************************************************/ +F_SuperFileClient::~F_SuperFileClient() +{ + if( m_pszCFileName) + { + f_free( &m_pszCFileName); + } +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE F_SuperFileClient::setup( + const char * pszCFileName, + const char * pszDataDir) +{ + RCODE rc = NE_SFLM_OK; + FLMUINT uiNameLen; + FLMUINT uiDataNameLen; + char szDir[ F_PATH_MAX_SIZE]; + char szBaseName[ F_FILENAME_SIZE]; + + if( !pszCFileName && *pszCFileName == 0) + { + rc = RC_SET( NE_FLM_IO_INVALID_FILENAME); + goto Exit; + } + + uiNameLen = f_strlen( pszCFileName); + if (pszDataDir && *pszDataDir) + { + if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->pathReduce( + pszCFileName, szDir, szBaseName))) + { + goto Exit; + } + f_strcpy( szDir, pszDataDir); + if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->pathAppend( + szDir, szBaseName))) + { + goto Exit; + } + uiDataNameLen = f_strlen( szDir); + + if (RC_BAD( rc = f_alloc( (uiNameLen + 1) + (uiDataNameLen + 1), + &m_pszCFileName))) + { + goto Exit; + } + + f_memcpy( m_pszCFileName, pszCFileName, uiNameLen + 1); + m_pszDataFileBaseName = m_pszCFileName + uiNameLen + 1; + flmGetDbBasePath( m_pszDataFileBaseName, szDir, &m_uiDataExtOffset); + m_uiExtOffset = uiNameLen - (uiDataNameLen - m_uiDataExtOffset); + } + else + { + if (RC_BAD( rc = f_alloc( (uiNameLen + 1) * 2, &m_pszCFileName))) + { + goto Exit; + } + + f_memcpy( m_pszCFileName, pszCFileName, uiNameLen + 1); + m_pszDataFileBaseName = m_pszCFileName + uiNameLen + 1; + flmGetDbBasePath( m_pszDataFileBaseName, + m_pszCFileName, &m_uiDataExtOffset); + m_uiExtOffset = m_uiDataExtOffset; + } + +Exit: + + return( rc); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMUINT FLMAPI F_SuperFileClient::getFileNumber( + FLMUINT uiBlockAddr) +{ + return( FSGetFileNumber( uiBlockAddr)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMUINT FLMAPI F_SuperFileClient::getFileOffset( + FLMUINT uiBlockAddr) +{ + return( FSGetFileOffset( uiBlockAddr)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_SuperFileClient::getFilePath( + FLMUINT uiFileNumber, + char * pszPath) +{ + RCODE rc = NE_SFLM_OK; + FLMUINT uiExtOffset; + + if( !uiFileNumber) + { + f_strcpy( pszPath, m_pszCFileName); + goto Exit; + } + + if( uiFileNumber <= MAX_DATA_BLOCK_FILE_NUMBER) + { + f_memcpy( pszPath, m_pszDataFileBaseName, m_uiDataExtOffset); + uiExtOffset = m_uiDataExtOffset; + } + else + { + f_memcpy( pszPath, m_pszCFileName, m_uiExtOffset); + uiExtOffset = m_uiExtOffset; + } + + // Modify the file's extension. + + bldSuperFileExtension( uiFileNumber, &pszPath[ uiExtOffset]); + +Exit: + + return( rc); +} + +/**************************************************************************** +Desc: Generates a file name given a super file number. + Adds ".xx" to pFileExtension. Use lower case characters. +Notes: This is a base 24 alphanumeric value where + { a, b, c, d, e, f, i, l, o, r, u, v } values are removed. +****************************************************************************/ +void F_SuperFileClient::bldSuperFileExtension( + FLMUINT uiFileNum, + char * pszFileExtension) +{ + char ucLetter; + + if (uiFileNum <= MAX_DATA_BLOCK_FILE_NUMBER - 1536) + { + // No additional letter - File numbers 1 to 511 + // This is just like pre-4.3 numbering. + ucLetter = 0; + } + else if (uiFileNum <= MAX_DATA_BLOCK_FILE_NUMBER - 1024) + { + // File numbers 512 to 1023 + ucLetter = 'r'; + } + else if (uiFileNum <= MAX_DATA_BLOCK_FILE_NUMBER - 512) + { + // File numbers 1024 to 1535 + ucLetter = 's'; + } + else if (uiFileNum <= MAX_DATA_BLOCK_FILE_NUMBER) + { + // File numbers 1536 to 2047 + ucLetter = 't'; + } + else if (uiFileNum <= MAX_LOG_BLOCK_FILE_NUMBER - 1536) + { + // File numbers 2048 to 2559 + ucLetter = 'v'; + } + else if (uiFileNum <= MAX_LOG_BLOCK_FILE_NUMBER - 1024) + { + // File numbers 2560 to 3071 + ucLetter = 'w'; + } + else if (uiFileNum <= MAX_LOG_BLOCK_FILE_NUMBER - 512) + { + // File numbers 3072 to 3583 + ucLetter = 'x'; + } + else + { + flmAssert( uiFileNum <= MAX_LOG_BLOCK_FILE_NUMBER); + + // File numbers 3584 to 4095 + ucLetter = 'z'; + } + + *pszFileExtension++ = '.'; + *pszFileExtension++ = (char)(f_getBase24DigitChar( (FLMBYTE)((uiFileNum & 511) / 24))); + *pszFileExtension++ = (char)(f_getBase24DigitChar( (FLMBYTE)((uiFileNum & 511) % 24))); + *pszFileExtension++ = ucLetter; + *pszFileExtension = 0; +} + diff --git a/sql/src/recover.cpp b/sql/src/recover.cpp index bd3ca2c..0619d2f 100644 --- a/sql/src/recover.cpp +++ b/sql/src/recover.cpp @@ -249,7 +249,7 @@ RCODE F_Db::processBeforeImage( m_pSFileHdl->setMaxAutoExtendSize( m_pDatabase->m_uiMaxFileSize); m_pSFileHdl->setExtendSize( m_pDatabase->m_uiFileExtendSize); rc = m_pSFileHdl->writeBlock( uiBlkAddress, uiBlkLength, pBlkHdr, - m_pDatabase->m_uiBlockSize, NULL, &uiBytesWritten); + NULL, &uiBytesWritten); #ifdef FLM_DBG_LOG flmDbgLogWrite( m_pDatabase, uiBlkAddress, 0, ui64TransID, "ROLLBACK"); @@ -360,9 +360,7 @@ RCODE F_Database::writeDbHdr( } if( RC_BAD( rc = pCFileHdl->sectorWrite( 0, - uiBytesWritten, pTmpDbHdr, - pCFileHdl->getSectorSize(), - NULL, &uiBytesWritten, FALSE))) + uiBytesWritten, pTmpDbHdr, NULL, &uiBytesWritten))) { if (pDbStats) { diff --git a/sql/src/rfl.cpp b/sql/src/rfl.cpp index effb095..0a30347 100644 --- a/sql/src/rfl.cpp +++ b/sql/src/rfl.cpp @@ -405,7 +405,7 @@ RCODE rflGetDirAndPrefix( // Get the base path - F_DbSystem::getDbBasePath( szPrefix, szBaseName, NULL); + flmGetDbBasePath( szPrefix, szBaseName, NULL); // Determine the RFL directory. If one was // specified, it is whatever was specified. @@ -792,8 +792,7 @@ RCODE F_Rfl::writeHeader( // Write out the header if (RC_BAD( rc = m_pFileHdl->sectorWrite( 0L, 512, - ucBuf, sizeof( ucBuf), - NULL, &uiBytesWritten))) + ucBuf, NULL, &uiBytesWritten))) { // Remap disk full error @@ -951,9 +950,9 @@ RCODE F_Rfl::openFile( // Open the file. - if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->openBlockFile( szRflFileName, + if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->openFile( szRflFileName, FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, - 512, &m_pFileHdl))) + &m_pFileHdl))) { goto Exit; } @@ -1077,9 +1076,9 @@ RCODE F_Rfl::createFile( // Create the file - if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->createBlockFile( szRflFileName, + if (RC_BAD( rc = gv_SFlmSysData.pFileSystem->createFile( szRflFileName, FLM_IO_RDWR | FLM_IO_EXCL | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, - 512, &m_pFileHdl))) + &m_pFileHdl))) { goto Exit; } @@ -1255,9 +1254,8 @@ RCODE F_Rfl::flush( } rc = m_pFileHdl->sectorWrite( uiFileOffset, uiBufBytes, - pucOldBuffer, - m_uiBufferSize, pAsyncBuf, - &uiBytesWritten, FALSE); + pucOldBuffer, pAsyncBuf, + &uiBytesWritten); if( m_uiRflWriteBufs == 1) { diff --git a/sql/src/scache.cpp b/sql/src/scache.cpp index 7f0db66..877262b 100644 --- a/sql/src/scache.cpp +++ b/sql/src/scache.cpp @@ -3802,8 +3802,7 @@ RCODE F_Database::writeContiguousBlocks( // non-asynchronous write. rc = pSFileHdl->writeBlock( uiBlkAddress, uiWriteLen, - pucWriteBuffer, pIOBuffer->getBufferSize(), - pAsyncBuffer, &uiBytesWritten); + pucWriteBuffer, pAsyncBuffer, &uiBytesWritten); if (!pAsyncBuffer) { pIOBuffer->notifyComplete( rc); @@ -6074,8 +6073,8 @@ RCODE F_BlockCacheMgr::initCache( void) } if (RC_BAD( rc = m_pBlockAllocator->setup( - gv_SFlmSysData.pGlobalCacheMgr->m_pSlabManager, uiBlockSizes, - &m_Usage.slabUsage))) + gv_SFlmSysData.pGlobalCacheMgr->m_pSlabManager, NULL, uiBlockSizes, + &m_Usage.slabUsage, NULL))) { goto Exit; } diff --git a/sql/src/translog.cpp b/sql/src/translog.cpp index d959ac1..0220b67 100644 --- a/sql/src/translog.cpp +++ b/sql/src/translog.cpp @@ -142,7 +142,6 @@ RCODE F_Database::lgFlushLogBuffer( rc = pSFileHdl->writeBlock( m_uiCurrLogBlkAddr, m_uiCurrLogWriteOffset, m_pCurrLogBuffer->getBuffer(), - m_pCurrLogBuffer->getBufferSize(), pAsyncBuffer, &uiBytesWritten); if (!pAsyncBuffer) {