diff --git a/binreloc.m4 b/binreloc.m4 index 071e49e176..e1e2e2b960 100644 --- a/binreloc.m4 +++ b/binreloc.m4 @@ -48,30 +48,8 @@ AC_DEFUN([AM_BINRELOC], if test "x$br_cv_binreloc" = "xyes"; then BINRELOC_CFLAGS="-DENABLE_BINRELOC" AC_DEFINE(ENABLE_BINRELOC,,[Use binary relocation?]) - if test "x$enable_binreloc_threads" = "xyes"; then - AC_CHECK_LIB([pthread], [pthread_getspecific]) - fi - - AC_CACHE_CHECK([whether binary relocation should use threads], - [br_cv_binreloc_threads], - [if test "x$enable_binreloc_threads" = "xyes"; then - if test "x$ac_cv_lib_pthread_pthread_getspecific" = "xyes"; then - br_cv_binreloc_threads=yes - else - br_cv_binreloc_threads=no - fi - else - br_cv_binreloc_threads=no - fi]) - - if test "x$br_cv_binreloc_threads" = "xyes"; then - BINRELOC_LIBS="-lpthread" - AC_DEFINE(BR_PTHREAD,1,[Include pthread support for binary relocation?]) - else - BINRELOC_CFLAGS="$BINRELOC_CFLAGS -DBR_PTHREADS=0" - AC_DEFINE(BR_PTHREAD,0,[Include pthread support for binary relocation?]) - fi fi + AC_SUBST(BINRELOC_CFLAGS) AC_SUBST(BINRELOC_LIBS) ]) diff --git a/builds/posix/Makefile.in b/builds/posix/Makefile.in new file mode 100644 index 0000000000..c2cb94c057 --- /dev/null +++ b/builds/posix/Makefile.in @@ -0,0 +1,516 @@ +# +# PROGRAM: Firebird single makefile +# MODULE: Makefile.in +# DESCRIPTION: Posix build main file +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# You may obtain a copy of the Licence at +# http://www.gnu.org/licences/lgpl.html +# +# As a special exception this file can also be included in modules +# with other source code as long as that source code has been +# released under an Open Source Initiative certificed licence. +# More information about OSI certification can be found at: +# http://www.opensource.org +# +# This module 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 Lesser General Public Licence for more details. +# +# This module was created by members of the firebird development +# team. All individual contributions remain the Copyright (C) of +# those individuals and all rights are reserved. Contributors to +# this file are either listed below or can be obtained from a CVS +# history command. +# +# Created by: Mark O'Donohue +# +# Contributor(s): +# Alex Peshkoff - created single makefile based on Mark's files +# + +ROOT=.. + +include make.defaults +include make.platform +include make.rules +include make.shared.variables + +@SET_MAKE@ + +ifeq ($(IsDeveloper), Y) + DefaultTarget := Debug +else + DefaultTarget := Release +endif + +.PHONY: master_process firebird Debug Release extern + +all: firebird + +firebird: + $(MAKE) TARGET=$(DefaultTarget) master_process + +Release: + $(MAKE) TARGET=Release master_process + +Debug: + $(MAKE) TARGET=Debug master_process + + +#---------------------------------------------------------------------------- +# jrd/build_no.h contains the version and build# fields used throughout the +# program and quoted in the tools. This routine will update the build_no.h +# file with the auto update build# script file, writeBuildNum.sh. The +# writeBuildNum.sh script is autoupdated by CVS checkins. +# + +.PHONY: updateBuildNum + +updateBuildNum : $(SRC_ROOT)/jrd/build_no.h $(GEN_ROOT)/Make.Version + +$(SRC_ROOT)/jrd/build_no.h : $(SRC_ROOT)/misc/writeBuildNum.sh + (cd ..; ./src/misc/writeBuildNum.sh rebuildHeader) + +$(GEN_ROOT)/Make.Version : $(SRC_ROOT)/misc/writeBuildNum.sh + $(SRC_ROOT)/misc/writeBuildNum.sh createMakeVersion $@ + + +#___________________________________________________________________________ +# build external software +# + +extern: + $(MAKE) -C $(ROOT)/extern/btyacc + + +#___________________________________________________________________________ +# create platform-specific export lists (version scripts) in gen +# + +%.vers: ../builds/posix/%.vers + sh vers.sh $(firstword $@) + +export_lists: $(ALLVERS) + + +#___________________________________________________________________________ +# main build target for both debug abd release builds +# + +.PHONY: boot yvalve engine fbintl gpre utilities plugins rest codes + +master_process: + $(MAKE) updateBuildNum + $(MAKE) export_lists + $(MAKE) extern + $(MAKE) boot + $(MAKE) yvalve + $(MAKE) engine + $(MAKE) fbintl + $(MAKE) utilities +# Now having ready such useful tool as gbak, we may restore required databases +# and switch to full-featured gpre + $(MAKE) gpre +# Pay attention - after build force gpre_current to point to gpre +# even if gpre itself was not rebuilt + -$(RM) $(GPRE_CURRENT) + (cd $(BIN); $(LN) $(notdir $(GPRE)) $(notdir $(GPRE_CURRENT))) +ifeq ($(IsDeveloper), Y) +# In developer mode we must regenerate verious files in include/gen + $(MAKE) codes +endif + $(MAKE) plugins + $(MAKE) rest + +#___________________________________________________________________________ +# static library - various common code, used in different FB projects +# + +$(COMMON_LIB): $(Common_Objects) + -$(RM) $@ + $(STATICLIB_LINK) $@ $^ + + +#___________________________________________________________________________ +# gpre_boot +# + +boot: $(GPRE_BOOT) + +$(GPRE_BOOT): $(GPRE_Boot_Objects) $(COMMON_LIB) + $(STATICEXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) + -$(RM) $(GPRE_CURRENT) + (cd $(@D); $(LN) $(@F) $(notdir $(GPRE_CURRENT))) + + +#___________________________________________________________________________ +# yValve +# + +yvalve: $(LIBFIREBIRD_BASENAME) + +ifneq ($(LibraryBaseName),$(LibrarySoName)) +$(LIBFIREBIRD_BASENAME): $(LIBFIREBIRD_SONAME) + (cd $(LIB) && $(LN) -f $(LibrarySoName) $(LibraryBaseName) ) +endif + +ifneq ($(LibrarySoName),$(LibraryFullName)) +$(LIBFIREBIRD_SONAME): $(LIBFIREBIRD_FULLNAME) + (cd $(LIB) && $(LN) -f $(LibraryFullName) $(LibrarySoName) ) +endif + +# remote redirector is statically linked in main FB library +$(LIBFIREBIRD_FULLNAME): $(YValve_Objects) $(Remote_Client_Objects) $(COMMON_LIB) + $(LINK_FIREBIRD) -o $@ $^ $(LINK_FIREBIRD_LIBS) + + +#___________________________________________________________________________ +# core part - jrd's engine +# + +engine: $(ENGINE_SONAME) + +$(ENGINE_SONAME): $(Engine_Objects) $(SVC_Objects) $(COMMON_LIB) + $(LINK_ENGINE) -o $@ $^ $(LINK_ENGINE_LIBS) + + +#___________________________________________________________________________ +# intl support +# + +fbintl: $(LIBFBINTL_SO) + +$(LIBFBINTL_SO): $(INTL_Objects) $(COMMON_LIB) + $(LINK_INTL) -o $@ $^ $(LINK_INTL_LIBS) + + +#___________________________________________________________________________ +# full gpre +# when switching to it we also build databases needed later +# and libib_util needed to start engine smart +# + +.PHONY: databases udfsupport + +gpre: $(GPRE) databases udfsupport + +$(GPRE): $(GPRE_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + + +databases: yachts.lnk help.fdb security.fdb msg.timestamp + +yachts.lnk: metadata.fdb + -$(RM) $@ + $(LN) $^ $@ + +metadata.fdb: $(BLD_ROOT)/misc/metadata.gbak + $(GBAK) -MODE read_only -R $< $@ + $(TOUCH) $@ + $(CHMOD) 0444 $@ + +help.fdb: $(FIREBIRD)/help/help.fdb + -$(RM) $@ + $(LN) $^ $@ + +$(FIREBIRD)/help/help.fdb: $(BLD_ROOT)/misc/help.gbak + $(GBAK) -MODE read_only -R $< $@ + $(TOUCH) $@ + $(CHMOD) 0444 $@ + +security.fdb: $(SECURITY_FDB) + -$(RM) $@ + $(LN) $(SECDB) $@ + +SECDB = security.tmp +$(SECURITY_FDB): $(SRC_ROOT)/dbs/security.sql + -$(RM) $@ + -$(RM) $(SECDB) + echo create database \'$(SECDB)\'\; | $(ISQL) + $(ISQL) -i $^ $(SECDB) + $(CHMOD) a=rw $(SECDB) + $(CP) $(SECDB) $@ + +msg.timestamp: $(MSG_FILES) + -$(RM) msg.fdb + echo create database \'msg.fdb\'\; | $(ISQL) + for sql in $(MSG_FILES); do (echo $$sql; $(ISQL) -i $$sql msg.fdb) || exit; done + $(TOUCH) $@ + + +.PHONY: udfs ibutil ibudf fbudf + +udfsupport: + $(MAKE) ibutil + $(MAKE) udfs + +udfs: ibudf fbudf + +UDF = $(FIREBIRD)/UDF +IBUDF_SO = $(UDF)/ib_udf.$(SHRLIB_EXT) +FBUDF_SO = $(UDF)/fbudf.$(SHRLIB_EXT) + +ibudf: $(IBUDF_SO) + +$(IBUDF_SO): $(IBUDF_Objects) + $(call LINK_UDF,ib_udf) -o $@ $^ $(LINK_UDF_LIBS) + +fbudf: $(FBUDF_SO) + +$(FBUDF_SO): $(FBUDF_Objects) $(COMMON_LIB) + $(call LINK_UDF,fbudf) -o $@ $^ $(LINK_UDF_LIBS) $(FIREBIRD_LIBRARY_LINK) + +ibutil: $(LIBIBUTIL_SO) + +$(LIBIBUTIL_SO): $(UTIL_Objects) + $(LINK_IB_UTIL) -o $@ $^ $(LINK_IB_UTIL_LIBS) + + +#___________________________________________________________________________ +# most of utilities, including network server +# qli is not here cause it needs special database (help.fdb), therefore needs gbak +# + +.PHONY: firebird_server fb_lock_print fbguard fbsvcmgr fbtracemgr gbak gfix gsec gsplit gstat isql nbackup + +utilities: firebird_server fb_lock_print fbguard fbsvcmgr fbtracemgr gbak gfix gsec gsplit gstat isql nbackup + +firebird_server: $(FB_DAEMON) + +$(FB_DAEMON): $(Remote_Server_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +fb_lock_print: $(LOCKPRINT) + +$(LOCKPRINT): $(LOCKPRINT_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +fbguard: $(FBGUARD) + +$(FBGUARD): $(FBGUARD_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +fbsvcmgr: $(FBSVCMGR) + +$(FBSVCMGR): $(FBSVCMGR_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +fbtracemgr: $(FBTRACEMGR) + +$(FBTRACEMGR): $(FBTRACEMGR_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +gbak: $(GBAK) + +$(GBAK): $(GBAK_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +gsplit: $(GSPLIT) + +$(GSPLIT): $(GSPLIT_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +gfix: $(GFIX) + +$(GFIX): $(GFIX_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +gsec: $(GSEC) + +$(GSEC): $(GSEC_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +gstat: $(GSTAT) + +$(GSTAT): $(GSTAT_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +isql: $(ISQL) + +$(ISQL): $(ISQL_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(LIBEDITLINE) + +nbackup: $(NBACKUP) + +$(NBACKUP): $(NBACKUP_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + + +#___________________________________________________________________________ +# plugins - some of them are required to build examples, use separate entry for them +# + +.PHONY: udr legacy_user_management trace +UDR_PLUGIN = $(PLUGINS)/$(LIB_PREFIX)udr_engine.$(SHRLIB_EXT) +LEGACY_USER_MANAGER = $(PLUGINS)/$(LIB_PREFIX)user_management.$(SHRLIB_EXT) + +plugins: udr legacy_user_management trace + +udr: $(UDR_PLUGIN) $(PLUGINS)/udr_engine.conf + +$(PLUGINS)/udr_engine.conf: $(ROOT)/src/plugins/udr_engine/udr_engine.conf + cp $^ $@ + +$(UDR_PLUGIN): $(UDRENG_Objects) $(COMMON_LIB) + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK) + +legacy_user_management: $(LEGACY_USER_MANAGER) + +$(LEGACY_USER_MANAGER): $(LEGACY_USERS_MANAGE_Objects) $(COMMON_LIB) + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK) + +trace: $(FBTRACE) + +$(FBTRACE): $(FBTRACE_UTIL_Objects) $(COMMON_LIB) + $(LINK_TRACE) -o $@ $^ $(FIREBIRD_LIBRARY_LINK) $(LINK_TRACE_LIBS) + + +#___________________________________________________________________________ +# codes - developers change them sometimes +# + +.PHONY: gen_codes +CODES = $(BIN)/codes$(EXEC_EXT) +IDS = $(SRC_ROOT)/include/gen/ids.h + +codes: gen_codes $(IDS) + +gen_codes: $(CODES) msg.timestamp + $(CODES) $(SRC_ROOT)/include/gen $(LNG_ROOT) + +$(CODES): $(CODES_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +$(IDS): $(SRC_ROOT)/misc/ids.m $(SRC_ROOT)/jrd/relations.h + m4 $< > $@ + + +#___________________________________________________________________________ +# all the rest we need to build +# + +.PHONY: qli examples message_file + +rest: qli examples message_file + +qli: $(QLI) + +$(QLI): $(QLI_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +examples: + $(MAKE) -f Makefile.examples -C $(GEN_ROOT)/examples/ + $(MAKE) -f Makefile.plugins_examples -C $(GEN_ROOT)/examples/ + +message_file: $(FIREBIRD_MSG) + +$(FIREBIRD_MSG): $(BUILD_FILE) msg.timestamp + $(BUILD_FILE) -d msg.fdb -f $@ + $(CHMOD_6) $@ + +$(BUILD_FILE): $(BUILD_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + + +#___________________________________________________________________________ +# track dependencies +# + +include $(ROOT)/gen/make.shared.targets + +Dependencies = $(AllObjects:.o=.d) +-include $(Dependencies) + +#___________________________________________________________________________ +# various cleaning +# +.PHONY: clean clean_objects clean_dependancies clean_extern_objects clean_build \ + clean_gpre_gen clean_icu clean_dbs clean_examples clean_makefiles \ + clean_editline clean_all + + +clean: clean_objects clean_dependancies clean_extern_objects clean_build \ + clean_yacc_gen clean_gpre_gen clean_dbs clean_examples + +ifeq ($(EDITLINE_FLG),Y) +ifeq ($(STD_EDITLINE),false) +clean: clean_editline +endif +endif + +clean_config clean_all: clean clean_makefiles + $(RM) $(ROOT)/configure + $(RM) $(ROOT)/aclocal.m4 + $(RM) $(ROOT)/config.log + $(RM) $(ROOT)/config.status + $(RM) $(ROOT)/libtool + $(RM_R) $(ROOT)/autom4te.cache + -$(MAKE) -C $(ROOT)/extern/editline distclean +# -$(MAKE) -C $(ROOT)/extern/icu/source distclean + -$(MAKE) -C $(ROOT)/extern/btyacc distclean + +clean_dbs: + $(RM) *.fdb *.FDB msg.timestamp + $(RM) yachts.lnk + + +# The examples are a bit different, since the makefile is included in the directory +# and not in the gen directory, deleting it means, make clean; make doesnt work correctly +# so the code below deletes all the other stuff but not the Makefile.examples MOD Nov-2007 + +clean_examples: + $(RM) `find $(GEN_ROOT)/examples/ -type f ! -name 'Make*'` + +clean_editline: + -$(MAKE) -C $(ROOT)/extern/editline clean + +#clean_icu: +# -$(MAKE) -C $(ROOT)/extern/icu/source clean + +clean_objects: + $(RM) `find $(ROOT)/extern/ -type f -name '*.lo' -print` + $(RM) `find $(TMP_ROOT)/ -type f -name '*.o' -print` + +clean_extern_objects: + $(RM) `find $(ROOT)/extern/ -type f -name '*.o' -print` + +# Clear out dependancies files created by the gcc compiler +# since when .o and other files are deleted the dependant +# targets need to be recalculated +# MOD 10-July-2002 + +clean_dependancies: + $(RM) -f `find $(TMP_ROOT)/ -type f -name '*.d' -print` + +# delete only all of the files of type regular file in $FIREBIRD +# leave the directories to make dependacies work still +# MOD 11-July-2002 + +clean_build: + $(RM) `find $(GEN_ROOT)/*/firebird \( -type f -o -type l \) -print` +# $(RM) $(GDSLIB_OBJECTS) $(GDSLIB_PHASE3_OBJECTS) + +# +clean_makefiles: + $(RM) $(GEN_ROOT)/Make* + $(RM) $(GEN_ROOT)/make* + $(RM) `find $(GEN_ROOT)/install \( -type f -o -type l \) -print` + -$(RM) $(GEN_ROOT)/examples/Make* + $(RM) $(ROOT)/Makefile + $(RM) $(SRC_ROOT)/include/gen/autoconfig.h + $(RM) $(SRC_ROOT)/include/gen/blrtable.h + +clean_gpre_gen: + -$(RM) -f `find $(TMP_ROOT)/ -type f -name '*.cpp' -print` + +clean_yacc_gen: + $(RM) $(ROOT)/src/dsql/parse.cpp $(ROOT)/src/dsql/dsql.tab.h + +#___________________________________________________________________________ +# Extra platform specific targets +@POSTFIX_INCLUDE@ diff --git a/builds/posix/Makefile.in.boot.gpre b/builds/posix/Makefile.in.boot.gpre deleted file mode 100644 index f96bdfea04..0000000000 --- a/builds/posix/Makefile.in.boot.gpre +++ /dev/null @@ -1,88 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -JRDBOOT_Files = dsc.cpp gds.cpp isc.cpp $(JRDBOOT_Extra_Files) -JRDBOOT_Sources = $(addprefix jrd/, $(JRDBOOT_Files)) -JRDBOOT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(JRDBOOT_Sources)))) - - -COMMONBOOT_Files = cvt.cpp dllinst.cpp -COMMONBOOT_Sources = $(addprefix common/, $(COMMONBOOT_Files)) -COMMONBOOT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(COMMONBOOT_Sources)))) - - -GPRECOMMON_Files += cmd.cpp cme.cpp cmp.cpp c_cxx.cpp exp.cpp \ - gpre.cpp hsh.cpp int_cxx.cpp jrdmet.cpp movg.cpp \ - msc.cpp par.cpp pat.cpp sqe.cpp sql.cpp \ - @GPRE_LANGUAGE_MODULES@ - -GPRE_Files = $(GPRECOMMON_Files) pretty.cpp gpre_meta_boot.cpp -GPRE_Sources = $(addprefix gpre/, $(GPRE_Files)) -GPRE_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GPRE_Sources)))) - - - -GPREBOOT_Objects = $(JRDBOOT_Objects) $(GPRE_Objects) $(OS_SPECIFIC_Objects) \ - $(FBCOMMON_Objects) $(FBCONFIG_Objects) $(FBCLASSES_ClientObjects) \ - $(FBCLASSES_MsgObjects) $(COMMONBOOT_Objects) - -AllObjects = $(GPREBOOT_Objects) - -Dependencies = $(AllObjects:.o=.d) - - - -.PHONY: gpre_boot - - -gpre_boot : $(GPRE_BOOT) - -$(GPRE_BOOT): $(GPREBOOT_Objects) - $(STATICEXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) - -$(RM) $(GPRE_CURRENT) - (cd $(@D); $(LN) $(@F) $(notdir $(GPRE_CURRENT))) - - - -include $(ROOT)/gen/make.shared.targets - - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.client.fbudf b/builds/posix/Makefile.in.client.fbudf deleted file mode 100644 index 3e8d2660f2..0000000000 --- a/builds/posix/Makefile.in.client.fbudf +++ /dev/null @@ -1,87 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Blas Rodriguez Somoza -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=superclient -CXXFLAGS+= -DSUPERCLIENT - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -UDF= $(FIREBIRD)/UDF - -FBUDF_Other_Sources = common/classes/timestamp.cpp -FBUDF_Files = fbudf.cpp -FBUDF_Sources = $(addprefix extlib/fbudf/, $(FBUDF_Files)) $(FBUDF_Other_Sources) -FBUDF_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBUDF_Sources)))) - -UTIL_Files = ib_util.cpp -UTIL_Sources = $(addprefix extlib/, $(UTIL_Files)) -UTIL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(UTIL_Sources)))) - -CLASSES_Files = timestamp.cpp -CLASSES_Sources = $(addprefix common/classes/, $(CLASSES_Files)) -CLASSES_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(CLASSES_Sources)))) - -AllObjects = $(FBUDF_Objects) $(FBUTILSVC_Objects) $(CLASSES_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all lib_fbudf - -all: lib_fbudf - - -# The libraries in this directory could do with a bit more work, since they -# the previous code (presumably by John) that does the ar crv stuff, might -# work still, even if the .o files have directory prefixes on them. -# And the udf stuff doesn't want to do .$(SHRLIB_EXT).X.X.X extensions in UDF directory -# or the loader gets confused with loading the links. -# MOD 29-July-2002 - - - -# -# User defined functions. (I've put the .$(SHRLIB_EXT) extension back onto the library) -# - -lib_fbudf: $(LIBIBUTIL_SO) $(UDF)/fbudf.$(SHRLIB_EXT) - -$(UDF)/fbudf.$(SHRLIB_EXT): $(AllObjects) - $(call LINK_UDF,fbudf) -o $@ $^ $(LINK_UDF_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.client.gbak b/builds/posix/Makefile.in.client.gbak deleted file mode 100644 index 25e26d985b..0000000000 --- a/builds/posix/Makefile.in.client.gbak +++ /dev/null @@ -1,81 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# - -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -GBAK_Other_Sources = remote/xdr.cpp jrd/sdl.cpp \ - common/classes/MetaName.cpp jrd/path_utils.cpp jrd/ThreadData.cpp -GBAK_Files = backup.epp restore.epp OdsDetection.epp burpMain.cpp \ - burp.cpp canonical.cpp misc.cpp mvol.cpp -GBAK_Sources = $(addprefix burp/, $(GBAK_Files)) $(GBAK_Other_Sources) -GBAK_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GBAK_Sources)))) \ - $(FBUTILSVC_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) - -GSPLIT_Other_Sources = jrd/path_utils.cpp -GSPLIT_Files= spit.cpp -GSPLIT_Sources = $(addprefix burp/, $(GSPLIT_Files)) $(GSPLIT_Other_Sources) -GSPLIT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSPLIT_Sources)))) \ - $(FBUTIL_Objects) $(FBCLASSES_Objects) $(FBCOMMON_Objects) - - -AllObjects = $(GBAK_Objects) $(GSPLIT_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all gbak gsplit - -all: gbak gsplit - -gbak : $(LIBFBCLIENT_SO) $(GBAK) - -$(GBAK): $(GBAK_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - - -gsplit : $(LIBFBCLIENT_SO) $(GSPLIT) - -$(GSPLIT): $(GSPLIT_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.client.gfix b/builds/posix/Makefile.in.client.gfix deleted file mode 100644 index 38daf49bec..0000000000 --- a/builds/posix/Makefile.in.client.gfix +++ /dev/null @@ -1,65 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -GFIX_Other_Sources = jrd/isc.cpp jrd/ThreadData.cpp jrd/path_utils.cpp - -GFIX_Files = alice_meta.epp alice.cpp exe.cpp tdr.cpp aliceMain.cpp -GFIX_Sources = $(addprefix alice/, $(GFIX_Files)) $(GFIX_Other_Sources) -GFIX_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GFIX_Sources)))) - -AllObjects = $(GFIX_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) \ - $(FBCLASSES_ClientObjects) $(FBCLASSES_MsgObjects) $(FBUTILSVC_Objects) - -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: gfix - - -gfix : $(LIBFBCLIENT_SO) $(GFIX) - -$(GFIX): $(AllObjects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.client.gpre b/builds/posix/Makefile.in.client.gpre deleted file mode 100644 index 1f614c2810..0000000000 --- a/builds/posix/Makefile.in.client.gpre +++ /dev/null @@ -1,67 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -GPRE_Other_Sources = jrd/dsc.cpp jrd/path_utils.cpp common/cvt.cpp -GPRE_Files = gpre_meta.epp \ - cmd.cpp cme.cpp cmp.cpp c_cxx.cpp exp.cpp gpre.cpp \ - hsh.cpp int_cxx.cpp jrdmet.cpp movg.cpp msc.cpp par.cpp \ - pat.cpp pretty.cpp sqe.cpp sql.cpp \ - @GPRE_LANGUAGE_MODULES@ - -GPRE_Sources = $(addprefix gpre/, $(GPRE_Files)) $(GPRE_Other_Sources) -GPRE_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GPRE_Sources)))) - -AllObjects = $(GPRE_Objects) $(CLUMPLETS_Objects) - -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: gpre - - -gpre : $(LIBFBCLIENT_SO) $(GPRE) - -$(GPRE): $(GPRE_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.client.gsec b/builds/posix/Makefile.in.client.gsec deleted file mode 100644 index 33c957e5ed..0000000000 --- a/builds/posix/Makefile.in.client.gsec +++ /dev/null @@ -1,54 +0,0 @@ -# The contents of this file are subject to the Initial -# Developer's Public License Version 1.0 (the "License"); -# you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. -# -# Software distributed under the License is distributed AS IS, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. -# See the License for the specific language governing rights -# and limitations under the License. -# -# The Original Code was created by Alexander Peshkoff -# for the Firebird Open Source RDBMS project. -# -# Copyright (c) 2004 Alexander Peshkoff -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -GSEC_Other_Sources = jrd/isc_file.cpp jrd/ThreadData.cpp -GSEC_Files = gsec.cpp call_service.cpp gsecMain.cpp security.cpp -GSEC_Sources = $(addprefix utilities/gsec/, $(GSEC_Files)) $(GSEC_Other_Sources) -GSEC_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSEC_Sources)))) - -AllObjects = $(GSEC_Objects) $(FBCONFIG_Objects) $(COMMON_Objects) \ - $(CLUMPLETS_Objects) $(OS_SPECIFIC_Objects) $(FBUTILSVC_Objects) - -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all gsec - -all: gsec - -gsec: $(LIBFBCLIENT_SO) $(GSEC) - -$(GSEC): $(AllObjects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.client.isql b/builds/posix/Makefile.in.client.isql deleted file mode 100644 index bfe343ca42..0000000000 --- a/builds/posix/Makefile.in.client.isql +++ /dev/null @@ -1,67 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -unexport ISC_USER -unexport ISC_PASSWORD - -ISQL_Other_Sources = jrd/path_utils.cpp dsql/keywords.cpp -ISQL_Files = extract.epp isql.epp show.epp Extender.cpp InputDevices.cpp \ - ColList.cpp OptionsBase.cpp iutils.cpp -ISQL_Sources = $(addprefix isql/, $(ISQL_Files)) $(ISQL_Other_Sources) -ISQL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(ISQL_Sources)))) - -AllObjects = $(ISQL_Objects) $(FBCOMMON_Objects) $(FBUTIL_Objects) $(CLUMPLETS_Objects) $(FBCLASSES_Objects) - -Dependencies = $(AllObjects:.o=.d) - - - -.PHONY: isql - - -isql : $(LIBFBCLIENT_SO) $(ISQL) - -$(ISQL): $(AllObjects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) $(LIBEDITLINE) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.client.qli b/builds/posix/Makefile.in.client.qli deleted file mode 100644 index 683e34dfc0..0000000000 --- a/builds/posix/Makefile.in.client.qli +++ /dev/null @@ -1,76 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -QLI_Other_Sources = jrd/dsc.cpp gpre/pretty.cpp jrd/path_utils.cpp - -QLI_Files= all.cpp command.cpp compile.cpp dtr.cpp err.cpp eval.cpp \ - expand.cpp exe.cpp format.cpp gener.cpp help.cpp \ - hsh.cpp lex.cpp meta.cpp mov.cpp parse.cpp picstr.cpp proc.cpp \ - report.cpp show.cpp -QLI_Sources = $(addprefix qli/, $(QLI_Files)) $(QLI_Other_Sources) -QLI_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(QLI_Sources)))) - -AllObjects = $(QLI_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) $(FBUTIL_Objects) -Dependencies = $(AllObjects:.o=.d) - - - -.PHONY: all qli - -all: qli - - -qli : create_yachts $(LIBFBCLIENT_SO) $(QLI) - -$(QLI): $(AllObjects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - -# EKU: At this point yachts.lnk is a link to empty.fdb, but gpre will fail -# with it. metadata.fdb is what is needed here. -create_yachts: - -$(RM) yachts.lnk - -$(LN) -f metadata.fdb yachts.lnk - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) - diff --git a/builds/posix/Makefile.in.client.util b/builds/posix/Makefile.in.client.util deleted file mode 100644 index ebbad975b6..0000000000 --- a/builds/posix/Makefile.in.client.util +++ /dev/null @@ -1,234 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -LOCKPRINT_Other_Sources = jrd/isc_sync.cpp jrd/isc.cpp jrd/db_alias.cpp \ -common/config/config.cpp common/config/config_file.cpp common/config/ConfigCache.cpp \ -$(OS_SPECIFIC_Sources) -LOCKPRINT_Files= print.cpp -LOCKPRINT_Sources = $(addprefix lock/, $(LOCKPRINT_Files)) $(LOCKPRINT_Other_Sources) -LOCKPRINT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(LOCKPRINT_Sources)))) \ -$(FBCONFIG_Objects) - -NBACKUP_Other_Sources = jrd/db_alias.cpp jrd/ods.cpp $(OS_SPECIFIC_Sources) -NBACKUP_Files= nbackup.cpp nbackup/nbkMain.cpp -NBACKUP_Sources = $(addprefix utilities/, $(NBACKUP_Files)) $(NBACKUP_Other_Sources) -NBACKUP_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(NBACKUP_Sources)))) \ -$(CLUMPLETS_Objects) $(FBCONFIG_Objects) $(FBUTILSVC_Objects) - - -CREATEDB_Files= create_db.cpp -CREATEDB_Sources = $(addprefix utilities/, $(CREATEDB_Files)) -CREATEDB_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(CREATEDB_Sources)))) - - -DROP_Other_Sources = common/utils.cpp lock/lock.cpp jrd/isc_sync.cpp jrd/isc.cpp \ -common/config/config.cpp common/config/config_file.cpp common/config/ConfigCache.cpp \ -$(OS_SPECIFIC_Sources) - -DROP_Files= drop.cpp -DROP_Sources = $(addprefix utilities/, $(DROP_Files)) $(DROP_Other_Sources) -DROP_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(DROP_Sources)))) \ -$(FBCOMMON_ClientObjects) $(FBCLASSES_ClientObjects) - - -GSTAT_Other_Sources = jrd/btn.cpp jrd/db_alias.cpp jrd/ods.cpp common/utils.cpp \ -$(OS_SPECIFIC_Sources) jrd/isc_file.cpp jrd/isc.cpp jrd/ThreadData.cpp \ -common/classes/DbImplementation.cpp - -GSTAT_Files = dba.epp ppg.cpp gstatMain.cpp -GSTAT_Sources = $(addprefix utilities/gstat/, $(GSTAT_Files)) $(GSTAT_Other_Sources) -GSTAT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSTAT_Sources)))) \ -$(CLUMPLETS_Objects) $(FBUTILSVC_Objects) - - -FBSVCMGR_Files= fbsvcmgr.cpp -FBSVCMGR_Other_Sources = common/classes/fb_string.cpp common/classes/alloc.cpp \ -common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp jrd/path_utils.cpp - -FBSVCMGR_Sources = $(addprefix utilities/, $(FBSVCMGR_Files)) $(FBSVCMGR_Other_Sources) -FBSVCMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBSVCMGR_Sources)))) \ -$(FBCLASSES_MsgObjects) $(CLUMPLETS_Objects) $(FBCOMMON_ClientObjects) - - -FBTRACEMGR_Files= fbtracemgr/traceMgrMain.cpp -FBTRACEMGR_Other_Sources = common/classes/fb_string.cpp common/classes/alloc.cpp \ - common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp \ - jrd/trace/TraceCmdLine.cpp jrd/path_utils.cpp - -FBTRACEMGR_Sources = $(addprefix utilities/, $(FBTRACEMGR_Files)) $(FBTRACEMGR_Other_Sources) -FBTRACEMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBTRACEMGR_Sources)))) \ - $(FBCLASSES_MsgObjects) $(CLUMPLETS_Objects) $(FBCOMMON_ClientObjects) $(FBUTILSVC_Objects) - - -FBGUARD_Other_Sources = jrd/isc.cpp jrd/divorce.cpp jrd/path_utils.cpp -FBGUARD_Files = guard.cpp util.cpp -FBGUARD_Sources = $(addprefix utilities/guard/, $(FBGUARD_Files)) $(FBGUARD_Other_Sources) -FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources)))) $(FBCLASSES_ClientObjects) - - -IBGUARD_A_Files = cntl_guard.cpp iscguard.cpp -IBGUARD_A_Sources = $(addprefix iscguard/, $(IBGUARD_A_Files)) -IBGUARD_A_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(IBGUARD_A_Sources)))) -IBGUARD_B_Files = os/win32/chop.cpp -IBGUARD_B_Sources = $(addprefix remote/, $(IBGUARD_B_Files)) -IBGUARD_B_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(IBGUARD_B_Sources)))) - -FBMGR_Other_Sources = jrd/path_utils.cpp -FBMGR_Files = ibmgr.cpp srvrmgr.cpp -FBMGR_Sources = $(addprefix utilities/ibmgr/, $(FBMGR_Files)) $(FBMGR_Other_Sources) -FBMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBMGR_Sources)))) - - -INSTREG_Files = install_reg.cpp registry.cpp -INSTREG_Sources = $(addprefix utilities/install/, $(INSTREG_Files)) -INSTREG_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(INSTREG_Sources)))) - - -INSTSVC_Files = install_svc.cpp services.cpp -INSTSVC_Other_Sources = common/classes/alloc.cpp common/classes/fb_string.cpp -INSTSVC_Sources = $(addprefix utilities/install/, $(INSTSVC_Files)) $(INSTSVC_Other_Sources) -INSTSVC_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(INSTSVC_Sources)))) $(FBCOMMON_ClientObjects) - - -REBUILD_Files = rebuild.cpp rstore.epp rmet.epp -REBUILD_Sources = $(addprefix utilities/rebuild/, $(REBUILD_Files)) -REBUILD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(REBUILD_Sources)))) - - -RELAY_Files = relay.cpp -RELAY_Sources = $(addprefix utilities/, $(RELAY_Files)) -RELAY_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(RELAY_Sources)))) - -AllObjects = $(CREATEDB_Object) $(DROP_Object) $(GSTAT_Object) $(FBGUARD_Objects) \ - $(FBMGR_Objects) $(REBUILD_Objects) $(RELAY_Objects) $(FBSVCMGR_Objects) \ - $(FBTRACEMGR_Objects) - - -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all gstat gsec fbguard fbmgr_bin nbackup gds_drop gds_relay create_db fb_lock_print \ - fbsvcmgr fbtracemgr - -all: $(CLIENT_UTIL_TARGETS) - -create_db: $(CREATE_DB) - -$(CREATE_DB): $(CREATEDB_Objects) - $(STATICEXE_LINK) $(LINK_OPTS) $(CREATEDB_Objects) -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - - -nbackup: $(LIBFBCLIENT_SO) $(NBACKUP) - -$(NBACKUP): $(NBACKUP_Objects) $(CLUMPLETS_Objects) $(COMMON_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - -fb_lock_print: $(LIBFBCLIENT_SO) $(LOCKPRINT) - -$(LOCKPRINT): $(LOCKPRINT_Objects) $(COMMON_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - - -gstat : $(LIBFBCLIENT_SO) $(GSTAT) - -$(GSTAT): $(GSTAT_Objects) $(CLUMPLETS_Objects) $(COMMON_Objects) $(FBCONFIG_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - - -gds_drop: $(GDS_DROP) - -$(GDS_DROP): $(DROP_Objects) $(LIBFBCLIENT_SO) - $(EXE_LINK) $(LINK_OPTS) $(DROP_Objects) -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - - -fbsvcmgr: $(FBSVCMGR) - -$(FBSVCMGR): $(FBSVCMGR_Objects) $(LIBFBCLIENT_SO) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) - - -fbtracemgr: $(FBTRACEMGR) - -$(FBTRACEMGR): $(FBTRACEMGR_Objects) $(LIBFBCLIENT_SO) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) - - -fbguard: $(LIBFBCLIENT_SO) $(FBGUARD) - -$(FBGUARD): $(FBGUARD_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LIB_GUI) $(LINK_LIBS) - - -ibguard: $(LIBFBCLIENT_SO) $(IBGUARD) - -$(IBGUARD): $(IBGUARD_A_Objects) $(IBGUARD_B_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(FBCLASSES_Objects) $(FBCOMMON_Objects) -lfbclient \ -$(LIB_GUI) $(LINK_LIBS) - - -fbmgr_bin: $(FBMGR_BIN) - -$(FBMGR_BIN): $(FBMGR_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(FBCLASSES_Objects) $(FBCOMMON_Objects) -lfbclient \ -$(LINK_LIBS) - - -instreg: $(INSTREG) - -$(INSTREG): $(INSTREG_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) - - -instsvc: $(INSTSVC) - -$(INSTSVC): $(INSTSVC_Objects) - $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) - -# This one needs a bit of work. - -rebuild: $(GDS_REBUILD) - -$(GDS_REBUILD): $(REBUILD_Objects) $(LIBFBCLIENT_SO) - $(EXE_LINK) $(LINK_OPTS) $(REBUILD_Objects) -o $@ -L$(LIB) -lfbclient $(LINK_LIBS) - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.codes b/builds/posix/Makefile.in.codes deleted file mode 100644 index c4160d5070..0000000000 --- a/builds/posix/Makefile.in.codes +++ /dev/null @@ -1,73 +0,0 @@ - - -# The contents of this file are subject to the Initial -# Developer's Public License Version 1.0 (the "License"); -# you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. -# -# Software distributed under the License is distributed AS IS, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. -# See the License for the specific language governing rights -# and limitations under the License. -# -# The Original Code was created by Nickolay Samofatov -# for the Firebird Open Source RDBMS project. -# -# Copyright (c) 2004 Nickolay Samofatov -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -#____________________________________________________________________________ -# -# Rebuild the codes generates in the src/include/gen directory -# this target updates the values stored in the source path if they are -# different to the newly generated entries. -# -# There are also blrtable.h and ids.h which are generated as well. - -.PHONY: generated_headers - -#CODES_OutFiles= gds_codes.pas gds_codes.ftn iberror.h codetext.h \ -# msgs.h rdb_codes.h sql_code.h msg_facs.h -#CODES_Results=$(addprefix include/gen/, $(CODES_OutFiles)) -CODES_Sources = misc/codes.epp -CODES_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(CODES_Sources)))) - -AllObjects = $(CODES_Objects) -Dependencies = $(AllObjects:.o=.d) - -generated_headers: build_codes $(SRC_ROOT)/include/gen/ids.h - -# Rebuild error codes - -build_codes: $(BIN)/codes$(EXEC_EXT) msg.fdb - $(BIN)/codes$(EXEC_EXT) $(SRC_ROOT)/include/gen $(LNG_ROOT) - -$(SRC_ROOT)/misc/codes.cpp: $(SRC_ROOT)/misc/codes.epp - $(GPRE_CURRENT) $(GPRE_FLAGS) $< $@ - -$(BIN)/codes$(EXEC_EXT): $(CODES_Objects) $(COMMON_Objects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) $(ICU_LIBS) - - -# Rebuild ids.h -$(SRC_ROOT)/include/gen/ids.h: $(SRC_ROOT)/misc/ids.m $(SRC_ROOT)/jrd/relations.h - m4 $< > $(SRC_ROOT)/include/gen/ids.h - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.embed.fbudf b/builds/posix/Makefile.in.embed.fbudf deleted file mode 100644 index 4e8c66b3a2..0000000000 --- a/builds/posix/Makefile.in.embed.fbudf +++ /dev/null @@ -1,73 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Blas Rodriguez Somoza -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=superclient -CXXFLAGS+= -DSUPERCLIENT - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -UDF= $(FIREBIRD)/UDF - -FBUDF_Other_Sources = common/classes/timestamp.cpp -FBUDF_Files = fbudf.cpp -FBUDF_Sources = $(addprefix extlib/fbudf/, $(FBUDF_Files)) $(FBUDF_Other_Sources) -FBUDF_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBUDF_Sources)))) - -UTIL_Files = ib_util.cpp -UTIL_Sources = $(addprefix extlib/, $(UTIL_Files)) -UTIL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(UTIL_Sources)))) - -AllObjects = $(FBUDF_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all lib_fbudf - -all: lib_fbudf - - -# -# User defined functions. (I've put the .$(SHRLIB_EXT) extension back onto the library) -# - -lib_fbudf: $(LIBIBUTIL_SO) $(UDF)/fbudf.$(SHRLIB_EXT) - -$(UDF)/fbudf.$(SHRLIB_EXT): $(FBUDF_Objects) - $(call LINK_UDF,fbudf) -o $@ $^ $(LINK_UDF_LIBS) - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.embed.gbak b/builds/posix/Makefile.in.embed.gbak deleted file mode 100644 index f49c4e18e0..0000000000 --- a/builds/posix/Makefile.in.embed.gbak +++ /dev/null @@ -1,78 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -GBAK_Other_Sources = remote/xdr.cpp jrd/sdl.cpp jrd/path_utils.cpp \ - jrd/ThreadData.cpp -GBAK_Files = backup.epp restore.epp OdsDetection.epp \ - burp.cpp canonical.cpp misc.cpp mvol.cpp burpMain.cpp -GBAK_Sources = $(addprefix burp/, $(GBAK_Files)) $(GBAK_Other_Sources) -GBAK_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GBAK_Sources)))) \ - $(FBUTILSVC_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) - -GSPLIT_Other_Sources = jrd/path_utils.cpp -GSPLIT_Files= spit.cpp -GSPLIT_Sources = $(addprefix burp/, $(GSPLIT_Files)) $(GSPLIT_Other_Sources) -GSPLIT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSPLIT_Sources)))) \ - $(FBUTIL_Objects) $(FBCLASSES_Objects) $(FBCOMMON_Objects) - -AllObjects = $(GBAK_Objects) $(GSPLIT_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all gbak gsplit - -all: gbak gsplit - -gbak : $(LIBFBEMBED_SO) $(GBAK) - -$(GBAK): $(GBAK_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - - -gsplit : $(LIBFBEMBED_SO) $(GSPLIT) - -$(GSPLIT): $(GSPLIT_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.embed.gfix b/builds/posix/Makefile.in.embed.gfix deleted file mode 100644 index 0e0a145de7..0000000000 --- a/builds/posix/Makefile.in.embed.gfix +++ /dev/null @@ -1,67 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -GFIX_Files = alice_meta.epp \ - alice.cpp exe.cpp tdr.cpp aliceMain.cpp - -GFIX_Other_Sources += jrd/isc.cpp jrd/ThreadData.cpp jrd/path_utils.cpp - -GFIX_Sources = $(addprefix alice/, $(GFIX_Files)) $(GFIX_Other_Sources) -GFIX_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GFIX_Sources)))) - -AllObjects = $(GFIX_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) \ - $(FBUTILSVC_Objects) - -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: gfix - - -gfix : $(LIBFBEMBED_SO) $(GFIX) - -$(GFIX): $(AllObjects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.embed.gpre b/builds/posix/Makefile.in.embed.gpre deleted file mode 100644 index af396b9105..0000000000 --- a/builds/posix/Makefile.in.embed.gpre +++ /dev/null @@ -1,66 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -GPRE_Other_Sources = jrd/dsc.cpp jrd/path_utils.cpp common/cvt.cpp -GPRE_Files = gpre_meta.epp \ - cmd.cpp cme.cpp cmp.cpp c_cxx.cpp exp.cpp gpre.cpp \ - hsh.cpp int_cxx.cpp jrdmet.cpp movg.cpp msc.cpp par.cpp \ - pat.cpp pretty.cpp sqe.cpp sql.cpp \ - @GPRE_LANGUAGE_MODULES@ - -GPRE_Sources = $(addprefix gpre/, $(GPRE_Files)) $(GPRE_Other_Sources) -GPRE_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GPRE_Sources)))) - -AllObjects = $(GPRE_Objects) $(CLUMPLETS_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: gpre - - -gpre : $(LIBFBEMBED_SO) $(GPRE) - -$(GPRE): $(GPRE_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.embed.isql b/builds/posix/Makefile.in.embed.isql deleted file mode 100644 index 24eafb1b93..0000000000 --- a/builds/posix/Makefile.in.embed.isql +++ /dev/null @@ -1,67 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -unexport ISC_USER -unexport ISC_PASSWORD - -ISQL_Other_Sources = jrd/path_utils.cpp -ISQL_Files = extract.epp isql.epp show.epp Extender.cpp InputDevices.cpp \ - ColList.cpp OptionsBase.cpp iutils.cpp -ISQL_Sources = $(addprefix isql/, $(ISQL_Files)) $(ISQL_Other_Sources) -ISQL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(ISQL_Sources)))) - -AllObjects = $(ISQL_Objects) $(FBCOMMON_Objects) $(FBUTIL_Objects) $(CLUMPLETS_Objects) $(FBCLASSES_Objects) - -Dependencies = $(AllObjects:.o=.d) - - - -.PHONY: isql - - -isql : $(LIBFBEMBED_SO) $(ISQL) - -$(ISQL): $(AllObjects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LIBEDITLINE) $(LINK_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.embed.qli b/builds/posix/Makefile.in.embed.qli deleted file mode 100644 index 2fd8eda6d6..0000000000 --- a/builds/posix/Makefile.in.embed.qli +++ /dev/null @@ -1,75 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -QLI_Other_Sources = jrd/dsc.cpp gpre/pretty.cpp jrd/path_utils.cpp - -QLI_Files= all.cpp command.cpp compile.cpp dtr.cpp err.cpp eval.cpp \ - expand.cpp exe.cpp format.cpp gener.cpp help.epp \ - hsh.cpp lex.cpp meta.epp mov.cpp parse.cpp picstr.cpp proc.epp \ - report.cpp show.epp -QLI_Sources = $(addprefix qli/, $(QLI_Files)) $(QLI_Other_Sources) -QLI_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(QLI_Sources)))) - -AllObjects = $(QLI_Objects) $(CLUMPLETS_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) $(FBUTIL_Objects) -Dependencies = $(AllObjects:.o=.d) - - - -.PHONY: all qli - -all: qli - - -qli : create_yachts $(LIBFBEMBED_SO) $(QLI) - -$(QLI): $(AllObjects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - -# EKU: At this point yachts.lnk is a link to empty.fdb, but gpre will fail -# with it. metadata.fdb is what is needed here. -create_yachts: - -$(RM) yachts.lnk - -$(LN) -f metadata.fdb yachts.lnk - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.embed.util b/builds/posix/Makefile.in.embed.util deleted file mode 100644 index 6d164f592b..0000000000 --- a/builds/posix/Makefile.in.embed.util +++ /dev/null @@ -1,225 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - - -@SET_MAKE@ - - -LOCKPRINT_Other_Sources += jrd/isc_sync.cpp jrd/isc.cpp jrd/db_alias.cpp \ -$(OS_SPECIFIC_Sources) - -LOCKPRINT_Files= print.cpp -LOCKPRINT_Sources = $(addprefix lock/, $(LOCKPRINT_Files)) $(LOCKPRINT_Other_Sources) -LOCKPRINT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(LOCKPRINT_Sources)))) \ -$(FBCONFIG_Objects) - -NBACKUP_Other_Sources = jrd/db_alias.cpp jrd/ods.cpp $(OS_SPECIFIC_Sources) - -NBACKUP_Files= nbackup.cpp nbackup/nbkMain.cpp -NBACKUP_Sources = $(addprefix utilities/, $(NBACKUP_Files)) $(NBACKUP_Other_Sources) -NBACKUP_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(NBACKUP_Sources)))) \ -$(FBCONFIG_Objects) $(FBUTILSVC_Objects) - - -CREATEDB_Files= create_db.cpp -CREATEDB_Sources = $(addprefix utilities/, $(CREATEDB_Files)) -CREATEDB_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(CREATEDB_Sources)))) - - -DROP_Other_Sources += common/utils.cpp jrd/isc_sync.cpp jrd/isc.cpp \ -common/config/config.cpp common/config/config_file.cpp common/config/ConfigCache.cpp \ -$(OS_SPECIFIC_Sources) - -DROP_Files= drop.cpp -DROP_Sources = $(addprefix utilities/, $(DROP_Files)) $(DROP_Other_Sources) -DROP_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(DROP_Sources)))) $(FBCOMMON_ClientObjects) - - -GSEC_Other_Sources = \ -jrd/isc_file.cpp common/config/config.cpp common/config/config_file.cpp \ -common/config/ConfigCache.cpp common/config/dir_list.cpp \ -jrd/ThreadData.cpp $(OS_SPECIFIC_Sources) - -GSEC_Files = gsec.cpp security.cpp call_service.cpp gsecMain.cpp -GSEC_Sources = $(addprefix utilities/gsec/, $(GSEC_Files)) $(GSEC_Other_Sources) -GSEC_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSEC_Sources)))) \ -$(FBUTILSVC_Objects) - - -GSTAT_Other_Sources = jrd/btn.cpp jrd/db_alias.cpp common/utils.cpp jrd/ods.cpp \ -jrd/ThreadData.cpp jrd/isc_file.cpp $(OS_SPECIFIC_Sources) common/classes/DbImplementation.cpp - -GSTAT_Files = dba.epp ppg.cpp gstatMain.cpp -GSTAT_Sources = $(addprefix utilities/gstat/, $(GSTAT_Files)) $(GSTAT_Other_Sources) -GSTAT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSTAT_Sources)))) \ -$(FBUTILSVC_Objects) - - -FBSVCMGR_Files= fbsvcmgr.cpp -FBSVCMGR_Other_Sources = common/classes/fb_string.cpp common/classes/alloc.cpp \ -common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp jrd/path_utils.cpp \ -common/classes/semaphore.cpp - -FBSVCMGR_Sources = $(addprefix utilities/, $(FBSVCMGR_Files)) $(FBSVCMGR_Other_Sources) -FBSVCMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBSVCMGR_Sources)))) \ -$(FBCLASSES_MsgObjects) $(CLUMPLETS_Objects) $(FBCOMMON_ClientObjects) - - -FBTRACEMGR_Files= fbtracemgr/traceMgrMain.cpp -FBTRACEMGR_Other_Sources = common/classes/fb_string.cpp common/classes/alloc.cpp \ - common/fb_exception.cpp common/utils.cpp common/classes/locks.cpp \ - jrd/trace/TraceCmdLine.cpp jrd/path_utils.cpp common/classes/semaphore.cpp - -FBTRACEMGR_Sources = $(addprefix utilities/, $(FBTRACEMGR_Files)) $(FBTRACEMGR_Other_Sources) -FBTRACEMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBTRACEMGR_Sources)))) \ - $(FBCLASSES_MsgObjects) $(CLUMPLETS_Objects) $(FBCOMMON_ClientObjects) $(FBUTILSVC_Objects) - - -FBGUARD_Other_Sources = jrd/isc.cpp jrd/divorce.cpp jrd/path_utils.cpp -FBGUARD_Files = guard.cpp util.cpp -FBGUARD_Sources = $(addprefix utilities/guard/, $(FBGUARD_Files)) $(FBGUARD_Other_Sources) -FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources)))) $(FBCLASSES_ClientObjects) - - -IBMGR_Files = ibmgr.cpp srvrmgr.cpp -IBMGR_Sources = $(addprefix utilities/ibmgr/, $(IBMGR_Files)) -IBMGR_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(IBMGR_Sources)))) - - -REBUILD_Files = rebuild.cpp rstore.epp rmet.epp -REBUILD_Sources = $(addprefix utilities/rebuild/, $(REBUILD_Files)) -REBUILD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(REBUILD_Sources)))) - - -RELAY_Files = relay.cpp -RELAY_Sources = $(addprefix utilities/, $(RELAY_Files)) -RELAY_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(RELAY_Sources)))) - -AllObjects = $(CREATEDB_Object) $(DROP_Object) $(FBSVCMGR_Objects) \ - $(GSEC_Objects) $(GSTAT_Object) $(FBGUARD_Objects) \ - $(IBMGR_Objects) $(REBUILD_Objects) $(RELAY_Objects) $(CLUMPLETS_Objects) - -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: create_db gstat gds_drop gds_relay gsec fbguard ibmgr_bin nbackup fb_lock_print \ - fbsvcmgr fbtracemgr - -all: $(EMBED_UTIL_TARGETS) - - -# it's important to note here that create_db is linked against the static -# 'boot' libraries rather than the later embedded shared library. The -# other utilities are released but create_db is used in construction. -# MOD 29-July-2002 - -create_db: $(CREATE_DB) - -$(CREATE_DB): $(CREATEDB_Objects) $(COMMON_Objects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) $(ICU_LIBS) - - -nbackup: $(LIBFBEMBED_SO) $(NBACKUP) - -$(NBACKUP): $(NBACKUP_Objects) $(CLUMPLETS_Objects) $(COMMON_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -fb_lock_print: $(LIBFBEMBED_SO) $(LOCKPRINT) - -$(LOCKPRINT): $(LOCKPRINT_Objects) $(COMMON_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -gstat : $(LIBFBEMBED_SO) $(GSTAT) - -$(GSTAT): $(GSTAT_Objects) $(CLUMPLETS_Objects) $(COMMON_Objects) $(FBCONFIG_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -gds_drop: $(GDS_DROP) - -$(GDS_DROP): $(DROP_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -fbsvcmgr: $(FBSVCMGR) - -$(FBSVCMGR): $(FBSVCMGR_Objects) $(LIBFBEMBED_SO) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -fbtracemgr: $(FBTRACEMGR) - -$(FBTRACEMGR): $(FBTRACEMGR_Objects) $(LIBFBEMBED_SO) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -gds_relay: $(GDS_RELAY) - -$(GDS_RELAY): $(RELAY_Objects) $(LIBFBEMBED_SO) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $(RELAY_Objects) -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -gsec: $(GSEC) - -$(GSEC): $(GSEC_Objects) $(CLUMPLETS_Objects) $(COMMON_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - - -fbguard: $(LIBFBCLIENT_SO) $(FBGUARD) - -$(FBGUARD): $(FBGUARD_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ -L$(LIB) -lfbclient $(LIB_GUI) $(LINK_LIBS) - - -ibmgr_bin: $(IBMGR_BIN) - -$(IBMGR_BIN): $(IBMGR_Objects) $(LIBFBEMBED_SO) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $(IBMGR_Objects) -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - -# This one needs a bit of work. - -rebuild: $(GDS_REBUILD) - -$(GDS_REBUILD): $(REBUILD_Objects) $(LIBFBEMBED_SO) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $(REBUILD_Objects) -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.examples b/builds/posix/Makefile.in.examples index 2ae36cfd37..5897102c15 100644 --- a/builds/posix/Makefile.in.examples +++ b/builds/posix/Makefile.in.examples @@ -29,7 +29,6 @@ # # ROOT=../.. -ObjModuleType=std # Add the install include directory to the search path since the # examples need to build using those headers values. @@ -51,15 +50,17 @@ include $(ROOT)/gen/make.shared.variables PATH := ./:$(BIN):$(PATH) export PATH -ifeq ($(PLATFORM),DARWIN) -DYLD_LIBRARY_PATH := $(GEN_ROOT)/firebird/lib -export DYLD_LIBRARY_PATH -else -LD_LIBRARY_PATH := $(GEN_ROOT)/firebird/lib -export LD_LIBRARY_PATH -endif +#ifeq ($(PLATFORM),DARWIN) +#DYLD_LIBRARY_PATH := $(GEN_ROOT)/firebird/lib +#export DYLD_LIBRARY_PATH +#else +#LD_LIBRARY_PATH := $(GEN_ROOT)/firebird/lib +#export LD_LIBRARY_PATH +#endif GPRE_FLAGS= -r -m -z -n +LIB_LINK_RPATH = $(call LIB_PLATFORM_RPATH,$(if $(subst intl,,$(1)),$(LIB),$(LIB)/../intl)) + EXAMPLES_DEST= $(GEN_ROOT)/examples EXAMPLES_SRC= $(ROOT)/examples @@ -79,12 +80,13 @@ INTL_Sources = $(addprefix $(EXAMPLES_DEST)/, $(INTL_Files)) EMPLOYEE_DB= $(EXAMPLES_DEST)/employee.fdb INTLEMP_DB= $(EXAMPLES_DEST)/intlemp.fdb -.PHONY: all examples plugins_examples +.PHONY: all examples -all: examples plugins_examples +all: examples # examples: $(EMPLOYEE_DB) $(INTLEMP_DB) $(FIREBIRD)/examples/README -examples: $(EMPLOYEE_DB) $(FIREBIRD)/examples/README plugins_examples +examples: $(EMPLOYEE_DB) + $(MAKE) -f Makefile.examples $(FIREBIRD)/examples/README $(FIREBIRD)/examples/README: $(CP) $(ROOT)/examples/readme $(FIREBIRD)/examples/README @@ -120,14 +122,13 @@ $(EMPLOYEE_DB): $(EXAMPLES_DEST)/empbuild$(EXEC_EXT) $(INPUT_Sources) $(EXAMPLES ./empbuild $(EMPLOYEE_DB) -$(CHMOD_6) $(EMPLOYEE_DB) -# To get past the fact isql is called from the programs, we create a local link -# to the static one in this directory +# To get past the fact isql is called from the programs, we create a local link in this directory $(EXAMPLES_DEST)/isql$(EXEC_EXT): - -$(LN) $(ISQL_STATIC) $(EXAMPLES_DEST)/isql$(EXEC_EXT) + -$(LN) $(ISQL) $(EXAMPLES_DEST)/isql$(EXEC_EXT) -$(EXAMPLES_DEST)/empbuild$(EXEC_EXT): $(EMPBLD_Objects) $(COMMON_Objects) $(LIBFBSTATIC_A) - $(EXE_LINK) $(LINK_OPTS) $(EMPBLD_Objects) $(COMMON_Objects) -o $@ -L$(LIB) -lfbstatic $(LINK_LIBS) $(ICU_LIBS) +$(EXAMPLES_DEST)/empbuild$(EXEC_EXT): $(EMPBLD_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(EXAMPLES_DEST)/empbuild.c: $(EXAMPLES_DEST)/empbuild.fdb $(EXAMPLES_DEST)/empbuild.e @@ -144,8 +145,8 @@ $(EXAMPLES_DEST)/intlemp.fdb: $(EXAMPLES_DEST)/intlbld$(EXEC_EXT) $(INTL_Sources ./intlbld intlemp.fdb -$(CHMOD_6) intlemp.fdb -$(EXAMPLES_DEST)/intlbld$(EXEC_EXT): $(INTLBLD_Objects) $(COMMON_Objects) $(LIBFBSTATIC_A) - $(EXE_LINK) $(LINK_OPTS) $(INTLBLD_Objects) $(COMMON_Objects) -o $@ -L$(LIB) -lfbstatic $(LINK_LIBS) $(ICU_LIBS) +$(EXAMPLES_DEST)/intlbld$(EXEC_EXT): $(INTLBLD_Objects) $(COMMON_LIB) + $(EXE_LINK) $(LINK_OPTS) @^ -o $@ -L$(LIB) $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(EXAMPLES_DEST)/intlbld.c: $(EXAMPLES_DEST)/intlbuild.fdb $(EXAMPLES_DEST)/intlbld.e @@ -165,6 +166,3 @@ $(EXAMPLES_DEST)/%.e: $(EXAMPLES_SRC)/empbuild/%.e $(EXAMPLES_DEST)/%.h: $(EXAMPLES_SRC)/common/%.h $(CP) $^ $@ - -plugins_examples: # plugins examples - $(MAKE) -f $(GEN_ROOT)/examples/Makefile.plugins_examples diff --git a/builds/posix/Makefile.in.extern.icu b/builds/posix/Makefile.in.extern.icu deleted file mode 100644 index 073b13eeb2..0000000000 --- a/builds/posix/Makefile.in.extern.icu +++ /dev/null @@ -1,42 +0,0 @@ -# The contents of this file are subject to the Initial -# Developer's Public License Version 1.0 (the "License"); -# you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. -# -# Software distributed under the License is distributed AS IS, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. -# See the License for the specific language governing rights -# and limitations under the License. -# -# The Original Code was created by Adriano dos Santos Fernandes -# for the Firebird Open Source RDBMS project. -# -# Copyright (c) 2005 Adriano dos Santos Fernandes -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# -# -ROOT=.. - - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -ALL_ICU_SO = $(addsuffix *, $(notdir $(LIBICU_SO))) - -.PHONY: libicu - -# SD: Let it be so until I find the way to build only required things - -libicu: - $(MAKE) -C $(ROOT)/extern/icu/source - (cd $(ROOT)/extern/icu/source/lib/; tar cf - $(ALL_ICU_SO)) | (cd $(LIB); tar xf -) - -include $(ROOT)/gen/make.shared.targets diff --git a/builds/posix/Makefile.in.extlib b/builds/posix/Makefile.in.extlib deleted file mode 100644 index cc2a4f09c4..0000000000 --- a/builds/posix/Makefile.in.extlib +++ /dev/null @@ -1,90 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -UDF= $(FIREBIRD)/UDF - - -UDF_Files = ib_udf.cpp -UDF_Sources = $(addprefix extlib/, $(UDF_Files)) -UDF_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(UDF_Sources)))) - -UTIL_Files = ib_util.cpp -UTIL_Sources = $(addprefix extlib/, $(UTIL_Files)) -UTIL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(UTIL_Sources)))) - - -AllObjects = $(UDF_Objects) $(UTIL_Objects) $(FBUDF_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all lib_ib_udf lib_ib_util - -all: lib_ib_util lib_ib_udf - - -# The libraries in this directory could do with a bit more work, since they -# the previous code (presumably by John) that does the ar crv stuff, might -# work still, even if the .o files have directory prefixes on them. -# And the udf stuff doesn't want to do .$(SHRLIB_EXT).X.X.X extensions in UDF directory -# or the loader gets confused with loading the links. -# MOD 29-July-2002 - - - -# ib_udf.$(SHRLIB_EXT) -# -# User defined functions. (I've put the .$(SHRLIB_EXT) extension back onto the library) -# - -lib_ib_udf: $(LIBIBUTIL_SO) $(UDF)/ib_udf.$(SHRLIB_EXT) - -$(UDF)/ib_udf.$(SHRLIB_EXT): $(UDF_Objects) - $(call LINK_UDF,ib_udf) -o $@ $^ $(LINK_UDF_LIBS) - -# ib_util - -lib_ib_util: $(LIBIBUTIL_SO) - -$(LIBIBUTIL_SO): $(UTIL_Objects) - $(LINK_IB_UTIL) -o $@ $^ $(LINK_IB_UTIL_LIBS) - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.fbserver b/builds/posix/Makefile.in.fbserver deleted file mode 100644 index 71a85b42de..0000000000 --- a/builds/posix/Makefile.in.fbserver +++ /dev/null @@ -1,65 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -ROOT=.. -ObjModuleType=superserver -CXXFLAGS+= -DSUPERSERVER -ArchType=super - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -SERVER_Other_sources = jrd/pwd.cpp jrd/sha.cpp -SERVER_Other_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(SERVER_Other_sources)))) - -SERVER_Files = $(OS_ServerFiles) server.cpp -SERVER_Sources = $(addprefix remote/, $(SERVER_Files)) -SERVER_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(SERVER_Sources)))) \ - $(LIBFBSERVER_Objects) $(COMMON_Objects) $(SERVER_Other_Objects) - - -.PHONY: fbserver - - -fbserver : $(FB_SUPER_SERVER) - -$(FB_SUPER_SERVER): $(SERVER_Objects) - $(EXE_LINK) $(LINK_EXEC_EXPORT) $(LINK_FIREBIRD_SYMBOLS) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LIB_GUI) $(LINK_LIBS) $(ICU_LIBS) - -AllObjects = $(SERVER_Objects) - -Dependencies = $(AllObjects:.o=.d) - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.fbtrace b/builds/posix/Makefile.in.fbtrace deleted file mode 100644 index 003e7e1834..0000000000 --- a/builds/posix/Makefile.in.fbtrace +++ /dev/null @@ -1,80 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=superclient -CXXFLAGS+= -DSUPERCLIENT - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -FBTRACE_UTIL_Files= TraceConfiguration.cpp traceplugin.cpp TracePluginImpl.cpp \ - TraceUnicodeUtils.cpp PluginLogWriter.cpp platform.cpp - -FBTRACE_UTIL_Sources = $(addprefix utilities/ntrace/, $(FBTRACE_UTIL_Files)) - -FBTRACE_UTIL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBTRACE_UTIL_Sources)))) - - -FBTRACE_OTHER_Sources = $(OS_SPECIFIC_Sources) $(TRACE_OS_Sources) \ - jrd/isc.cpp jrd/isc_file.cpp jrd/isc_sync.cpp jrd/CharSet.cpp jrd/TextType.cpp \ - jrd/IntlUtil.cpp jrd/unicode_util.cpp common/classes/ClumpletReader.cpp common/utils.cpp - -FBTRACE_OTHER_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBTRACE_OTHER_Sources)))) - - -FBTRACE_Objects = $(FBTRACE_UTIL_Objects) $(FBTRACE_OTHER_Objects) $(CONFIG_Objects) \ - $(FBCOMMON_ClientObjects) $(FBCLASSES_MsgObjects) \ - $(FBCLASSES_ClientObjects) $(FBCONFIG_Objects) - - -AllObjects = $(FBTRACE_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all fbtrace - - -all : fbtrace - -fbtrace: $(FBTRACE) - -$(FBTRACE): $(FBTRACE_Objects) - $(LINK_TRACE) -o $@ $^ $(LINK_TRACE_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.firebird b/builds/posix/Makefile.in.firebird deleted file mode 100644 index db66a7e477..0000000000 --- a/builds/posix/Makefile.in.firebird +++ /dev/null @@ -1,590 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# - -ROOT=.. - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -ISC_USER= sysdba -ISC_PASSWORD= masterkey -#LD_LIBRARY_PATH=/home/odonohue/src/firebird2/gen/firebird/lib:/usr/lib -TEST_PATH = @FIREBIRD_BUILD_DIR@ -# Firebird libs path set at link time (-R) so do not override local requirements - nmcc 28/12/2002 -#LD_LIBRARY_PATH=$(RealFirebirdPath)/lib -LD_LIBRARY_PATH=$(LIB) -FIREBIRD_BOOT_BUILD=1 - -#export ISC_USER -#export ISC_PASSWORD -#export INTERBASE -export FIREBIRD -export DYLD_FRAMEWORK_PATH -export LD_LIBRARY_PATH -export FIREBIRD_BOOT_BUILD - -CPU = 1 -CPU_OPTION = -j$(CPU) - -###################################################################### -########### Build process overview ################################# -# -# Firebird2 has brought with it a new build process. This extended -# comment should help explain that process. Keep in mind there are -# a number of artifacts left in the makefiles from the previous build -# processes. -# -# The build process starts by building a bootstrap version of gpre. -# This is possible because of a special version of gpre_meta.cpp, -# gpre_meta_boot.cpp. It is a copy of the gpre_meta.epp file with all -# the embeded commands removed. There are pregenerated copy of the -# iberror.h and related files in the source tree. These are used for the -# entire build process. In the future we should check for the ability -# to regenerate iberror.h and friends (ie, a working FB install) and only -# use the static files as a last resort. -# -# The bootstrap version of gpre (gpre_boot) is used to build all the -# engine file. -# During this phase of the build process the limited version of alt.bin -# is used. The full version of alt.bin is compiled later in the build -# process after the security database is available. After the -# (hopefully pending) redesign of FB security the security database -# dependancies should go away. -# -# The engine objects are placed in the jrd_static.a archive. This archive -# contains all the objects needed to create statically linked programs. -# A fully functional version of gpre, gpre_static, is then generated -# using jrd_static.a. I choose to statically link the few utilities -# required to build FB to avoid possible shared library symbol conflicts. -# -# All of the aforementioned work is done in the -# first phase of the compilation. I called it the first phase because -# none of the work (except iberror.h and friends) requires database access. -# Phase 2 builds all the tools necessary to compile the rest of FB. Those -# tools are gbak and the gds.$(SHRLIB_EXT) shared library. -# -# The .epp files in gbak require the yachts.lnk database. But the only -# thing the database is used for is the metadata, so an empty database -# will do the job. The create_db program is a small c API utility that -# creates an empty database. This utility is statically linked. -# Once there is an empty database gbak_static is built. gbak_static is -# used later on in the compilation process to restore build databases. -# -# After gbak_static is built the gds.$(SHRLIB_EXT) library is built. This library is -# still missing the security functionality. -# -# Now we are on phase 3, building the actual DB tools. This is as expected. -# We build all tools and link them against the shared library, including -# gpre, gbak, and the fully functional gds.$(SHRLIB_EXT). -# -# John Belardo ~ July 2001 -# -# In the tradition of makefiles, they have evolved even further. But most of -# the above is still applies. There now tends to be a Makefile for each -# target rather than the more traditional Makefile per directory model. -# This was needed to enable super to build corrently. But it also allowed -# some of the boot build process to be done simpler as well. -# MOD 28-July-2002 -# -########### And now on with the show............ -################################################################# - - -#__________________________________________________________________________ -# -# This is the main target for the make. The targets are -# firebird_embedded and firebird_server. Or as they used to be known -# firebird_classic and firebird_super. - -# (The .PHONY: stuff just means it's a fake target, and make wont go searching -# for a real file or directory - but there are a lot of them here -# MOD 28-July-2002) -.PHONY: all firebird firebird_boot firebird_basic -.PHONY: firebird_embedded firebird_server classic_programs super_programs -.PHONY: firebird_super firebird_classic btyacc_binary -.PHONY: plugins2 - - -# The main targets are firebird_embedded or firebird_server -# or their older names _classic or _super. -# The following target is expanded by autoconf process to -# either _classic or _super. - - -firebird : firebird_@FIREBIRD_ARCH_TYPE@ $(PLATFORM_POSTBUILD_TARGET) - -firebird_classic firebird_embedded: firebird_basic classic_targets plugins2 -firebird_super firebird_server: firebird_basic super_targets plugins2 - - - - -# In building embedded/server version some targets are common, mainly the -# boot kit, security2.fdb database and messages files. Boot builds a number of -# static programs gpre_static gbak_static isql_static though an involved -# process. These are used to compile the rest of the source, as it saves -# some complications particularly for super in needing to start the server -# that you are currently building. MOD 28-July-2002 - -firebird_basic: btyacc_binary external_libraries export_lists firebird_boot basic_targets - -firebird_boot: updateBuildNum boot_phase1 boot_phase2 - - - -#---------------------------------------------------------------------------- -# jrd/build_no.h contains the version and build# fields used throughout the -# program and quoted in the tools. This routine will update the build_no.h -# file with the auto update build# script file, writeBuildNum.sh. The -# writeBuildNum.sh script is autoupdated by CVS checkins. -# - -.PHONY: updateBuildNum external_libraries export_lists - -updateBuildNum : jrd/build_no.h $(GEN_ROOT)/Make.Version - -jrd/build_no.h : $(SRC_ROOT)/misc/writeBuildNum.sh - (cd ..; ./src/misc/writeBuildNum.sh rebuildHeader) - -$(GEN_ROOT)/Make.Version : $(SRC_ROOT)/misc/writeBuildNum.sh - $(SRC_ROOT)/misc/writeBuildNum.sh createMakeVersion $@ - - -# -# Libraries that come from outside the project but are built -# as part of the project are included here. Currently IBM ICU and -# editline are the only externals libraries we have included. -# - -external_libraries: -ifeq ($(STD_ICU),false) - $(MAKE) CFLAGS="@CFLAGS@" -f $(GEN_ROOT)/Makefile.extern.icu -endif -ifeq ($(STD_EDITLINE),false) -ifeq ($(EDITLINE_FLG),Y) - $(MAKE) CFLAGS="@CFLAGS@" $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.extern.editline -endif -endif - -btyacc_binary: $(BTYACC) - -$(BTYACC): - $(MAKE) -C $(ROOT)/extern/btyacc - -#--------------------------------------------------------------------------- -# Phase1: make a gpre_static from scratch so we can parse .e and .epp files -# to build the rest of the system. It goes in two bits make a real simple -# gpre_boot one and use that to build a gpre_static one. -# -# gpre_static has a fair bit more in it and we have now actually built most -# of the libraries. With gpre_static we now have enough to build gbak and -# start restoring databases. -# -# if $(BIN)/gpre_static exists then phase1 is complete. phase1 does not then -# rebuild automatically gpre_static if some of it's dependancies change. We -# only need on gpre_static to boot after we have one we don't care. -# (If you really want to rebuild it you need to remove the executable file -# $(BIN)/gpre_static). -# -.PHONY: boot_phase1 boot_phase1_build -.PHONY: libfbstatic gpre_boot gpre_static - -boot_phase1: $(GPRE_STATIC) - -$(GPRE_STATIC): - $(MAKE) boot_phase1_build - -boot_phase1_build: gpre_boot libfbstatic gpre_static - - -gpre_boot: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.boot.gpre $@ - -libfbstatic: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.libfbstatic $@ - -gpre_static: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.static.gpre $@ - - - - -#-------------------------------------------------------------------------- -#Phase2: We can now start build some of the static utilities needed to build -# an empty database (lock manager and create_db). Then we rebuild all the -# items we have built in the static library into a dynamic library. -# (It's probably possible to directly build the dynamic library - but thats -# for another day). We still don't have the security database stuff. -# -# Phase2 is complete with the building of an security2.fdb user store database -# in order to do that isql tool needs to be built without security -# to do that a special alt_boot.o is inserted into the shared library. -# Again once security2.fdb is built then were not too worried about the -# components (in fact some of them have to be rebuilt again to incorperate -# the security module) -# - -.PHONY: create_db empty_db gbak_static isql_static ref_databases - -boot_phase2 : libfbstatic $(ISC_GDB) - -$(ISC_GDB): create_db empty_db gbak_static isql_static ref_databases - -create_db: - $(MAKE) -f $(GEN_ROOT)/Makefile.embed.util $(CREATE_DB) - -gbak_static: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.static.gbak - -isql_static: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.static.isql - -empty_db : - $(MAKE) -f $(GEN_ROOT)/Makefile.refDatabases $@ - -ref_databases : $(GBAK_STATIC) - $(MAKE) -f $(GEN_ROOT)/Makefile.refDatabases $@ - - -security2.fdb: isql # build the security database - $(MAKE) -C utilities $@ - - - - -#-------------------------------------------------------------------------- -#Phase3: Now we start building the tools we are actually going to use -# against the shared library. -# an empty database (lock manager and create_db). Then we rebuild all the -# items we have built in the static library into a dynamic library. -# (It's probably possible to directly build the dynamic library - but thats -# for another day). We still don't have the security database stuff. -# -# Notes: -# mainly we need isql to be able to build security2.fdb. I wonder -# if we could reduce the tricky dependancy by restoring the security2.fdb -# database earlier, then perhaps we could build the jrdlib in one step and -# include the security bits and pieces. - -.PHONY: ref_databases msgs msgs_intl generated_headers intl extlib plugins includes - -basic_targets: ref_databases msgs msgs_intl generated_headers \ - intl extlib plugins includes examples_cp - -# hack to make code regeneration work -generated_headers : - $(MAKE) -f $(GEN_ROOT)/Makefile.codes $@ - -msgs: # messages file for user $(FIREBIRD)/firebird.msg - $(MAKE) -f $(GEN_ROOT)/Makefile.msgs $@ - -msgs_intl: # international version of msgs file - $(MAKE) -f $(GEN_ROOT)/Makefile.msgs $@ - -intl: # international lang components $(FIREBIRD)/intl/ - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.intl - -extlib: # external programs than can be called - $(MAKE) -f $(GEN_ROOT)/Makefile.extlib - -plugins: # plugins - $(MAKE) -f $(GEN_ROOT)/Makefile.plugins - - # distribution header include files -includes: include_generic - - # examples still need a good makefile to ship with them -examples_cp: - $(MAKE) -f Makefile.examples -C $(GEN_ROOT)/examples/ - - -#_ Embedded Firebird Targets (Classic)_______________________________________ - -.PHONY: libfbembed fb_smp_server embed_gfix embed_gbak embed_isql -.PHONY: embed_gpre embed_util - -classic_targets: $(PLAT_CLASSIC_PRE_TARGET) libfbembed fb_smp_server embed_gfix embed_gbak embed_isql \ - embed_gpre libfbclient embed_util embed_qli embed_fbudf $(PLAT_CLASSIC_POST_TARGET) - -libfbembed: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.libfbembed $@ - -fb_smp_server: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.smp_server - -embed_gfix: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.embed.gfix - -embed_gbak: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.embed.gbak - -embed_isql: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.embed.isql - -embed_gpre: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.embed.gpre - -embed_util: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.embed.util - -embed_qli: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.embed.qli - -embed_fbudf: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.embed.fbudf - -#_ Firebird Server Targets (super and super client)__________________________ - -.PHONY: fbserver -.PHONY: libfbclient client_gfix client_gbak client_isql client_gpre client_util client_fbudf - -super_targets: $(PLAT_SUPER_PRE_TARGET) fbserver libfbclient client_gfix client_gbak client_gsec\ - client_isql client_gpre client_util client_fbudf client_qli $(PLAT_SUPER_POST_TRAGET) - -fbserver: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.fbserver $@ - -libfbclient: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.libfbclient $@ - -client_gfix: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.client.gfix - -client_gbak: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.client.gbak - -client_gsec: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.client.gsec - -client_gpre: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.client.gpre - -client_isql: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.client.isql - -client_util: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.client.util - -client_fbudf: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.client.fbudf - -# Not sure we need this target in super -# MOD 04-Oct-2002 - -client_qli: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.client.qli - - -#sysdba_user gstat: # add sysdba user and build gstat program -# $(MAKE) -C utilities $@ - - - -#--------------------------------------------------------------------------- - -plugins2: - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.fbtrace - $(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.user.management - - -#--------------------------------------------------------------------------- - -# This target builds the include files for disttribution with the release -# Some of the files differ from the ones used internally to compile the -# software - mainly they are just flattened out to make the view simpler -# from an external point of view. - -INCLUDE_DEST= $(FIREBIRD)/include - -include_generic: $(INCLUDE_DEST)/ib_util.h \ - $(INCLUDE_DEST)/ibase.h - -# ib_util.h actually is a marker for a number of headers - -# All these files are #includes in ibase.h here we cat them all together -# and remove the embedded #includes to make it simpler for external usage. - -IBASE_ExtraFiles = include/types_pub.h include/consts_pub.h dsql/sqlda_pub.h jrd/dsc_pub.h jrd/ibase.h jrd/inf_pub.h jrd/blr.h include/gen/iberror.h -SRC_IBASE_ExtraFiles = $(addprefix $(SRC_ROOT)/, $(IBASE_ExtraFiles)) -MAKE_HEADER_Src = $(addprefix $(SRC_ROOT)/, misc/makeHeader.cpp) -MAKE_HEADER_Bin = ./makeHeader - -$(INCLUDE_DEST)/ibase.h: $(SRC_IBASE_ExtraFiles) - $(STATICEXE_LINK) -o $(MAKE_HEADER_Bin) $(MAKE_HEADER_Src) - $(CP) $^ . - $(MAKE_HEADER_Bin) $@ - $(RM) -f ibase.h - -# Copy all the other headers to the distribution directory. we use -# ib_util.h as the marker for all the files. - -OtherDistribHeaders = extlib/ib_util.h \ - jrd/perf.h \ - include/gen/iberror.h - -SRC_OtherDistribHeaders = $(addprefix $(SRC_ROOT)/, $(OtherDistribHeaders)) - -$(INCLUDE_DEST)/ib_util.h : $(SRC_OtherDistribHeaders) - $(CP) $^ $(INCLUDE_DEST)/ - - -# There are also gds*f and gds*ada header files around if someone -# wants them. You might need to hunt around in the old cvs tree for them. - - -#___________________________________________________________________________ - -# create platform-specific export lists (version scripts) in gen - -%.vers: ../builds/posix/%.vers - sh vers.sh $(firstword $@) - -export_lists: $(ALLVERS) - -#___________________________________________________________________________ - -# When the msgs.fdb dataabse has changed with new messages a number of header -# files need to be regenerated. This is the target to do it. These new -# header files (placed in include/gen) then need to be committed since they -# are not generally rebuilt from scratch - -rebuild_codes : - $(MAKE) -C jrd $@ - - - -#___________________________________________________________________________ -# - -.PHONY: install install-embedded package packages dist srctarfile - -install install-embedded package packages dist: - $(MAKE) -f $(GEN_ROOT)/Makefile.install $@ - -SrcTarFile=Firebird$(ArchPrefix)-$(Version).tar.bz2 - -srctarfile: $(SrcTarFile) - -$(SrcTarFile) : - $(SRC_ROOT)/misc/src_bundle.sh - - -#___________________________________________________________________________ -# -.PHONY: clean clean_objects clean_dependancies clean_extern_objects clean_build \ - clean_gpre_gen clean_icu clean_dbs clean_examples clean_makefiles \ - clean_editline clean_all - - -clean: clean_objects clean_dependancies clean_extern_objects clean_build \ - clean_yacc_gen clean_gpre_gen clean_icu clean_dbs clean_examples - -ifeq ($(EDITLINE_FLG),Y) -ifeq ($(STD_EDITLINE),false) -clean: clean_editline -endif -endif - -clean_config clean_all: clean clean_makefiles - $(RM) $(ROOT)/configure - $(RM) $(ROOT)/aclocal.m4 - $(RM) $(ROOT)/config.log - $(RM) $(ROOT)/config.status - $(RM) $(ROOT)/libtool - $(RM_R) $(ROOT)/autom4te.cache - -$(MAKE) -C $(ROOT)/extern/editline distclean - -$(MAKE) -C $(ROOT)/extern/icu/source distclean - -$(MAKE) -C $(ROOT)/extern/btyacc distclean - -clean_dbs: - $(RM) *.fdb *.FDB msg.timestamp - $(RM) yachts.lnk - - -# The examples are a bit different, since the makefile is included in the directory -# and not in the gen directory, deleting it means, make clean; make doesnt work correctly -# so the code below deletes all the other stuff but not the Makefile.examples MOD Nov-2007 - -clean_examples: - $(RM) `find $(GEN_ROOT)/examples/ -type f ! -name 'Make*'` - -clean_editline: - -$(MAKE) -C $(ROOT)/extern/editline clean - -clean_icu: - -$(MAKE) -C $(ROOT)/extern/icu/source clean - -clean_objects: - $(RM) `find $(ROOT)/extern/ -type f -name '*.lo' -print` - $(RM) `find $(TMP_ROOT)/ -type f -name '*.o' -print` - -clean_extern_objects: - $(RM) `find $(ROOT)/extern/ -type f -name '*.o' -print` - -# Clear out dependancies files created by the gcc compiler -# since when .o and other files are deleted the dependant -# targets need to be recalculated -# MOD 10-July-2002 - -clean_dependancies: - $(RM) -f `find $(TMP_ROOT)/ -type f -name '*.d' -print` - -# delete only all of the files of type regular file in $FIREBIRD -# leave the directories to make dependacies work still -# MOD 11-July-2002 - -clean_build: - $(RM) `find $(GEN_ROOT)/firebird \( -type f -o -type l \) -print` -# $(RM) $(GDSLIB_OBJECTS) $(GDSLIB_PHASE3_OBJECTS) - -# -clean_makefiles: - $(RM) $(GEN_ROOT)/Make* - $(RM) $(GEN_ROOT)/make* - $(RM) `find $(GEN_ROOT)/install \( -type f -o -type l \) -print` - -$(RM) $(GEN_ROOT)/examples/Make* - $(RM) $(ROOT)/Makefile - $(RM) $(SRC_ROOT)/include/gen/autoconfig.h - $(RM) $(SRC_ROOT)/include/gen/blrtable.h - -clean_gpre_gen: - -$(RM) -f `find $(TMP_ROOT)/ -type f -name '*.cpp' -print` - -clean_yacc_gen: - $(RM) $(ROOT)/src/dsql/parse.cpp $(ROOT)/src/dsql/dsql.tab.h - -#___________________________________________________________________________ -# Extra platform specific targets -@POSTFIX_INCLUDE@ diff --git a/builds/posix/Makefile.in.intl b/builds/posix/Makefile.in.intl deleted file mode 100644 index 7ff3796614..0000000000 --- a/builds/posix/Makefile.in.intl +++ /dev/null @@ -1,89 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=superclient -CXXFLAGS+= -DSUPERCLIENT - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - - -INTL_Files1= ld.cpp cv_narrow.cpp \ - cs_narrow.cpp lc_ascii.cpp lc_narrow.cpp lc_iso8859_1.cpp \ - lc_iso8859_2.cpp lc_iso8859_13.cpp lc_dos.cpp \ - cs_unicode_ucs2.cpp lc_unicode_ucs2.cpp \ - cs_unicode_fss.cpp cv_unicode_fss.cpp \ - cs_big5.cpp cv_big5.cpp lc_big5.cpp \ - cs_gb2312.cpp cv_gb2312.cpp lc_gb2312.cpp \ - cs_jis.cpp cv_jis.cpp lc_jis.cpp \ - cs_ksc.cpp cv_ksc.cpp lc_ksc.cpp \ - cs_icu.cpp cv_icu.cpp lc_icu.cpp - -# use INTL_Files2 in prefix file for host-specific additional files -INTL_Sources= $(addprefix intl/, $(INTL_Files1)) $(INTL_Files2) \ - jrd/IntlUtil.cpp jrd/unicode_util.cpp jrd/CharSet.cpp jrd/mod_loader.cpp - -INTL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(INTL_Sources)))) - -# SD: Shared variables are overriden to exclude extra files and -# this way fix 'unresolved symbol' errors when some unused routines call -# other routines from not included modules -FBCLASSES_ClientFiles=alloc.cpp locks.cpp fb_string.cpp timestamp.cpp - - -AllObjects = $(INTL_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all libfbintl - - -all : libfbintl - -# In the following the rpath variable probably wants to be different -# if it's going to be installed in fb specific path. -# Also the dynamic link process used in fb, will fall over if it finds -# links etc in the intl directory MOD 28-July-2002 - -libfbintl : $(LIBFBINTL_SO) - -$(LIBFBINTL_SO): $(INTL_Objects) $(FBCOMMON_ClientObjects) $(FBCLASSES_ClientObjects) - $(LINK_INTL) -o $@ $^ $(LINK_INTL_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.libfbclient b/builds/posix/Makefile.in.libfbclient deleted file mode 100644 index 4af10b23a1..0000000000 --- a/builds/posix/Makefile.in.libfbclient +++ /dev/null @@ -1,114 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=superclient -CXXFLAGS+= -DSUPERCLIENT - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -# These are deliberatly unexported otherwise gbak and others will try and check -# the userid against the security2.fdb database, which doesn't exist at this stage -# in the build. MOD 11-July-2002 - -unexport ISC_USER -unexport ISC_PASSWORD - - -# jrd has it's own rule for using gpre to use gpre boot. -# I would eventually like to set these based on a determination -# if the file GPRE_STATIC exists or not. - -JRD_ClientObjects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(JRD_ClientSources)))) - -DSQL_ClientSources = $(addprefix dsql/, $(DSQL_ClientFiles)) -DSQL_ClientObjects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(DSQL_ClientSources)))) - - -REMOTE_ClientObjects = $(INTERFACE_Objects) - - -GPRELIB_ClientSources = $(addprefix gpre/, $(GPRELIB_ClientFiles)) -GPRELIB_ClientObjects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GPRELIB_ClientSources)))) - - -SECURITY_ClientSources_gsec = $(addprefix utilities/gsec/, $(SECURITY_ClientFiles_gsec)) -SECURITY_ClientObjects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(SECURITY_ClientSources_gsec)))) - - -FBUTIL_ClientSources = $(addprefix fbutil/, $(FBUTIL_ClientFiles)) -FBUTIL_ClientObjects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBUTIL_ClientSources)))) - - -FBCLIENT_Objects = $(JRD_ClientObjects) \ - $(DSQL_ClientObjects) \ - $(REMOTE_ClientObjects) \ - $(GPRELIB_ClientObjects) \ - $(SECURITY_ClientObjects) \ - $(FBUTIL_ClientObjects) \ - $(FBCOMMON_Objects)\ - $(FBCLASSES_ClientObjects)\ - $(FBCLASSES_MsgObjects)\ - $(OS_SPECIFIC_Objects)\ - $(FBCONFIG_Objects) \ - $(CLUMPLETS_Objects) - - -.PHONY: libfbclient - - -libfbclient : $(LIBFBCLIENT_SONAME) - -ifneq ($(ClientLibraryNameFull),$(ClientLibrarySoName)) -$(LIBFBCLIENT_SOBASENAME): $(LIBFBCLIENT_SO) - (cd $(LIB) && $(LN) -f $(ClientLibraryNameFull) $(ClientLibrarySoName) ) -endif - -ifneq ($(ClientLibrarySoName),$(ClientLibraryName)) -$(LIBFBCLIENT_SONAME): $(LIBFBCLIENT_SOBASENAME) - (cd $(LIB) && $(LN) -f $(ClientLibrarySoName) $(ClientLibraryName) ) -endif - -$(LIBFBCLIENT_SO): $(FBCLIENT_Objects) - $(LINK_CLIENT) -o $@ $^ $(LINK_CLIENT_LIBS) - -AllObjects = $(FBCLIENT_Objects) -Dependencies = $(AllObjects:.o=.d) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.libfbembed b/builds/posix/Makefile.in.libfbembed deleted file mode 100644 index cdb65cef74..0000000000 --- a/builds/posix/Makefile.in.libfbembed +++ /dev/null @@ -1,69 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -ROOT=.. -ObjModuleType=std -ArchType=classic - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -# These are deliberatly unexported otherwise gbak and others will try and check -# the userid against the security2.fdb database, which doesn't exist at this stage -# in the build. MOD 11-July-2002 - -unexport ISC_USER -unexport ISC_PASSWORD - - -AllObjects = $(LIBFBEMBED_Objects) $(COMMON_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: libfbembed - -libfbembed : $(LIBIBUTIL_SO) $(LIBFBEMBED_SONAME) - -$(LIBFBEMBED_SO): $(AllObjects) - $(LINK_EMBED) -o $@ $^ $(LINK_EMBED_LIBS) - -$(LIBFBEMBED_SOBASENAME): $(LIBFBEMBED_SO) - (cd $(LIB) && $(LN) -f $(SharedLibraryName) $(SharedLibrarySoName) ) - -$(LIBFBEMBED_SONAME): $(LIBFBEMBED_SOBASENAME) - (cd $(LIB) && $(LN) -f $(SharedLibrarySoName) $(SharedLibraryBaseName) ) - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.libfbstatic b/builds/posix/Makefile.in.libfbstatic deleted file mode 100644 index ecdf9a0237..0000000000 --- a/builds/posix/Makefile.in.libfbstatic +++ /dev/null @@ -1,70 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -DSQL_GPRE_FLAGS += -lang_internal - -AllObjects= $(LIBFBSTATIC_Objects) -Dependancies=$(AllObjects:.o=.d) - -# added here to force creation of dsql.tab.h -PARSE = parse.cpp -PARSE_Sources = $(addprefix $(SRC_ROOT)/dsql/, $(PARSE)) - - -.PHONY: libfbstatic - - -# Added to support super build, but have stong suspicion that -# will not be different from the above fbmem_boot.a library -# compile time macros being the main (if there) difference - -libfbstatic: $(PARSE_Sources) $(LIB)/libfbstatic.a - -$(LIB)/libfbstatic.a: $(LIBFBSTATIC_Objects) - -$(RM) $@ - $(AR) $@ $^ - -$(RANLIB) $@ - $(CHMOD_6) $@ - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependancies) diff --git a/builds/posix/Makefile.in.msgs b/builds/posix/Makefile.in.msgs deleted file mode 100644 index e80f4551e0..0000000000 --- a/builds/posix/Makefile.in.msgs +++ /dev/null @@ -1,180 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -unexport ISC_USER -unexport ISC_PASSWORD - - -.PHONY: msgs - - - -CHECK_Files = check_msgs.epp -CHECK_Sources = $(addprefix msgs/, $(CHECK_Files)) -CHECK_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(CHECK_Sources)))) - - -BUILD_Files = build_file.epp -BUILD_Sources = $(addprefix msgs/, $(BUILD_Files)) -BUILD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(BUILD_Sources)))) - -ENTER_Files = enter_msgs.epp -ENTER_Sources = $(addprefix msgs/, $(ENTER_Files)) -ENTER_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(ENTER_Sources)))) - -MODIFY_Files = modify_msgs.epp -MODIFY_Sources = $(addprefix msgs/, $(MODIFY_Files)) -MODIFY_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(MODIFY_Sources)))) - -CHANGE_Files = change_msgs.epp -CHANGE_Sources = $(addprefix msgs/, $(CHANGE_Files)) -CHANGE_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(CHANGE_Sources)))) - - -AllObjects = $(CHECK_Objects) $(BUILD_Objects) $(ENTER_Objects) \ - $(MODIFY_Objects) $(CHANGE_Objects) - -Dependencies = $(AllObjects:.o=.d) - -.PHONY: all msgs build_file check_messages enter_messages modify_messages change_messages - - -Programs = $(BUILD_FILE) #$(CHECK_MESSAGES) $(ENTER_MESSAGES) \ -# $(CHECK_MESSAGES) $(MODIFY_MESSAGES) $(CHANGE_MESSAGES) - -all: build_file check_messages enter_messages modify_messages change_messages - -msgs: $(Programs) message_file - - -do_check: $(CHECK_MESSAGES) $(BUILD_FILE) - $(CHECK_MESSAGES) -d $(MSGSDIR)master_msg_db.lnk -l - - - -# it's important to note here that these programs are linked against the static -# 'boot' libraries rather than the later embedded shared library. -# They could be linked against the embedded one, or client one, if required. -# MOD 29-July-2002 - - -check_messages : $(CHECK_MESSAGES) - -$(CHECK_MESSAGES): $(CHECK_Objects) $(COMMON_Objects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $(CHECK_Objects) $(COMMON_Objects) -o $@ -L$(LIB) -lfbstatic $(LINK_LIBS) $(ICU_LIBS) - $(CHMOD_7) $@ - - -build_file : $(BUILD_FILE) - -$(BUILD_FILE): $(BUILD_Objects) $(COMMON_Objects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $(BUILD_Objects) $(COMMON_Objects) -o $@ -L$(LIB) -lfbstatic $(LINK_LIBS) $(ICU_LIBS) - $(CHMOD_7) $@ - - -enter_messages : $(ENTER_MESSAGES) - -$(ENTER_MESSAGES): $(ENTER_Objects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $(ENTER_Objects) $(COMMON_Objects) -o $@ -L$(LIB) -lfbstatic $(LINK_LIBS) $(ICU_LIBS) - $(CHMOD_7) $@ - - -modify_messages: $(MODIFY_MESSAGES) - -$(MODIFY_MESSAGES): $(MODIFY_Objects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $(MODIFY_Objects) $(COMMON_Objects) -o $@ -L$(LIB) -lfbstatic $(LINK_LIBS) $(ICU_LIBS) - $(CHMOD_7) $@ - - -change_messages: $(CHANGE_MESSAGES) - -$(CHANGE_MESSAGES): $(CHANGE_Objects) $(COMMON_Objects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $(CHANGE_Objects) $(COMMON_Objects) -o $@ -L$(LIB) -lfbstatic $(LINK_LIBS) $(ICU_LIBS) - $(CHMOD_7) $@ - - - -message_file : $(FIREBIRD_MSG) - -$(FIREBIRD_MSG) : $(BUILD_FILE) msg.timestamp - $(BUILD_FILE) -d $(MSGSDIR)msg.fdb -f $@ - $(CHMOD_6) $@ - - -indicator.msg indicator.incl: - $(CHECK_MESSAGES) -d $(MSGSDIR)master_msg_db.lnk - -indicator.loc: - $(CHECK_MESSAGES) -d $(MSGSDIR)master_msg_db.lnk -l - - -master_msg_db.lnk: - $(LN) -f msg.fdb master_msg_db.lnk - - - - -# I know nother about these other than the default being set to none. I -# assume that as we get into it someone will want to use them and fix the -# following. - -# potential locals are $(fr_FR_MSG) $(de_DE_MSG) $(ja_JP_MSG) - -LOCALES= $(fr_FR_MSG) $(de_DE_MSG) -#LOCALES= - -msgs_intl locales.msg: $(LOCALES) - - -$(fr_FR_MSG) : $(BUILD_FILE) msg.timestamp - $(BUILD_FILE) -d $(MSGSDIR)msg.fdb -l fr_FR -f $@ - $(CHMOD_6) $@ - -$(de_DE_MSG) : $(BUILD_FILE) msg.timestamp - $(BUILD_FILE) -d $(MSGSDIR)msg.fdb -l de_DE -f $@ - $(CHMOD_6) $@ - - -$(ja_JP_MSG) : $(BUILD_FILE) msg.timestamp - $(BUILD_FILE) -d $(MSGSDIR)msg.fdb -l ja_JP.EUC -f $@ - $(CHMOD_6) $@ - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.plugins b/builds/posix/Makefile.in.plugins deleted file mode 100644 index b1d4937701..0000000000 --- a/builds/posix/Makefile.in.plugins +++ /dev/null @@ -1,72 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# Adriano dos Santos Fernandes -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -PLUGINS= $(FIREBIRD)/plugins - - -UDRENG_Files = UdrEngine.cpp -UDRENG_Sources = $(addprefix plugins/udr_engine/, $(UDRENG_Files)) jrd/mod_loader.cpp -UDRENG_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(UDRENG_Sources)))) - - -AllObjects = $(UDRENG_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all udr_engine - -all: udr_engine $(PLUGINS)/udr_engine.conf - - -udr_engine: $(PLUGINS)/$(LIB_PREFIX)udr_engine.$(SHRLIB_EXT) - -$(PLUGINS)/$(LIB_PREFIX)udr_engine.$(SHRLIB_EXT): $(UDRENG_Objects) $(FBCOMMON_Objects) $(FBCLASSES_Objects) $(OS_SPECIFIC_Objects) -ifeq ($(PLATFORM),DARWIN) - $(LIB_LINK) $(LIB_BUNDLE_OPTIONS) -o $@ $^ @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ -else - $(LIB_LINK) $(LINK_UDRENG_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_LINK_SONAME)udr_engine.$(SHRLIB_EXT) \ -$(LIB_PATH_OPTS) -o $@ $^ $(THR_LIBS) $(SO_LINK_LIBS) -endif - -$(PLUGINS)/udr_engine.conf: $(ROOT)/src/plugins/udr_engine/udr_engine.conf - cp $^ $@ - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.plugins_examples b/builds/posix/Makefile.in.plugins_examples index 0e7d458049..a19cf9f864 100644 --- a/builds/posix/Makefile.in.plugins_examples +++ b/builds/posix/Makefile.in.plugins_examples @@ -28,7 +28,6 @@ # Adriano dos Santos Fernandes # ROOT=../.. -ObjModuleType=std CXXFLAGS+= -I$(ROOT)/gen/firebird/include diff --git a/builds/posix/Makefile.in.refDatabases b/builds/posix/Makefile.in.refDatabases deleted file mode 100644 index fdc87ad761..0000000000 --- a/builds/posix/Makefile.in.refDatabases +++ /dev/null @@ -1,129 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -# If we export the username/password we get an error because we can't connect -# to security2.fdb! So we won't export them while we make the databases... -# -unexport ISC_USER -unexport ISC_PASSWORD -export DYLD_FRAMEWORK_PATH -DYLD_FRAMEWORK_PATH= $(OBJS)/firebird -export INTERBASE - -MSG_SCRIPTS = msg.sql facilities2.sql locales.sql sqlstates.sql history2.sql messages2.sql \ - symbols2.sql system_errors2.sql transmsgs.fr_FR2.sql transmsgs.de_DE2.sql -MSG_FILES = $(addprefix $(SRC_ROOT)/msgs/, $(MSG_SCRIPTS)) - -.PHONY: empty_db refDatabases - -# This is where you are going to have trouble if there is one, at creating -# the first empty database. Things to watch out for, $INTERBASE variable -# pointing in the wrong place, shared library path LD_LIBRARY_PATH -# not pointing to new stuff (mind you this point it should be creating -# using create_db statically linked). - -empty_db : empty.fdb yachts.lnk - -empty.fdb : $(CREATE_DB) - $(MAKE) -f $(GEN_ROOT)/Makefile.embed.util $(BIN)/create_db - -$(RM) $@ - $(BIN)/create_db $@ - $(TOUCH) $@ - $(CHMOD) 444 $@ - -# Ok so Jim had/has a sailing theme, and the sample database that a lot -# of .epp files require to compile is yachts.lnk. MOD 05-Aug-2002 - -yachts.lnk: empty.fdb - $(RM) -f yachts.lnk - $(LN) -f empty.fdb yachts.lnk - - - -# These are the rest of the databases used to build the system. We also build -# the help database from here. - -.PHONY: ref_databases - -# Use msg.timestamp as a target to help dependency tracking work. - -ref_databases : msg.timestamp help.fdb metadata.fdb $(FIREBIRD)/security2.fdb - -msg.timestamp: $(MSG_FILES) - $(RM) -f msg.fdb - echo create database \'msg.fdb\'\; | $(ISQL_STATIC) - for sn in $(MSG_FILES); do (echo $$sn; $(ISQL_STATIC) -i $$sn msg.fdb) || exit; done -# $(CHMOD) 444 msg.fdb - $(TOUCH) $@ - -help.fdb: $(FIREBIRD)/help/help.fdb - $(RM) -f $@ - $(LN) -f $^ $@ - -$(FIREBIRD)/help/help.fdb: $(BLD_ROOT)/misc/help.gbak - $(BIN)/gbak_static -MODE read_only -R $< $@ - $(TOUCH) $@ - $(CHMOD) 444 $@ - -$(FIREBIRD)/security2.fdb: security2.fdb - $(RM) -f $@ - $(CP) -f $^ $@ - -security2.fdb: $(SRC_ROOT)/dbs/security.sql - $(RM) -f $@ - echo create database \'$@\'\; | $(ISQL_STATIC) - $(ISQL_STATIC) -i $^ $@ - $(CHMOD) a=rw $@ - -metadata.fdb: $(BLD_ROOT)/misc/metadata.gbak - $(BIN)/gbak_static -MODE read_only -R $< $@ - $(TOUCH) $@ - $(CHMOD) 444 $@ - -# An alternative metadata creation method, this one is actually preferred -# since it ensures the data is valid. - -metadata.fdb.x: $(SRC_ROOT)/misc/metadata.sql - $(BIN)/isql -i $< - $(TOUCH) $@ - $(CHMOD) 444 $@ - - -FORCE: diff --git a/builds/posix/Makefile.in.smp_server b/builds/posix/Makefile.in.smp_server deleted file mode 100644 index 98a096798a..0000000000 --- a/builds/posix/Makefile.in.smp_server +++ /dev/null @@ -1,72 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -ROOT=.. -ObjModuleType=superserver -CXXFLAGS+= -DSUPERSERVER -ArchType=super - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -SERVER_JrdFiles = ThreadData.cpp divorce.cpp dsc.cpp enc.cpp isc_file.cpp isc.cpp \ -sdl.cpp status.cpp -SERVER_Files = $(OS_ServerFiles) server.cpp -SERVER_Other_sources = common/cvt.cpp common/classes/DbImplementation.cpp auth/Auth.cpp \ -jrd/pwd.cpp jrd/sha.cpp jrd/guid.cpp -SERVER_Sources = $(addprefix remote/, $(SERVER_Files)) $(addprefix jrd/, $(SERVER_JrdFiles)) $(SERVER_Other_sources) - -REMOTE_CommonSources = $(addprefix remote/, $(REMOTE_CommonFiles)) -REMOTE_CommonObjects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(REMOTE_CommonSources)))) - - -SERVER_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(SERVER_Sources)))) \ -$(REMOTE_CommonObjects) $(COMMON_Objects) $(CLUMPLETS_Objects) \ -$(CONFIG_Objects) $(FBCONFIG_Objects) \ -$(OS_SPECIFIC_Objects) - -.PHONY: fb_smp_server - - -fb_smp_server: $(FB_DAEMON) - -$(FB_DAEMON): $(SERVER_Objects) - $(EXE_LINK) $(LINK_EMPTY_SYMBOLS) $(LINK_OPTS) $^ -o $@ $(FBEMBED_LINK) $(LINK_LIBS) - -AllObjects = $(SERVER_Objects) - -Dependencies = $(AllObjects:.o=.d) - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.static.gbak b/builds/posix/Makefile.in.static.gbak deleted file mode 100644 index 8108b8fd78..0000000000 --- a/builds/posix/Makefile.in.static.gbak +++ /dev/null @@ -1,67 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -GBAKSTATIC_Files = backup.epp restore.epp OdsDetection.epp \ - burp.cpp canonical.cpp misc.cpp mvol.cpp burpMain.cpp - -GBAK_Other_Sources = -GBAK_Other_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GBAK_Other_Sources)))) - -GBAKSTATIC_Sources = $(addprefix burp/, $(GBAKSTATIC_Files)) -GBAKSTATIC_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GBAKSTATIC_Sources)))) - -AllObjects = $(GBAKSTATIC_Objects) $(GBAK_Other_Objects) $(COMMON_Objects) $(FBUTILSVC_Objects) -Dependencies = $(AllObjects:.o=.d) - - - -.PHONY: gbak_static - - -gbak_static : $(GBAK_STATIC) - -$(GBAK_STATIC) : $(AllObjects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) $(ICU_LIBS) - - -include $(ROOT)/gen/make.shared.targets - - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.static.gpre b/builds/posix/Makefile.in.static.gpre deleted file mode 100644 index 36d7637f79..0000000000 --- a/builds/posix/Makefile.in.static.gpre +++ /dev/null @@ -1,70 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -GPRECOMMON_Files += cmd.cpp cme.cpp cmp.cpp c_cxx.cpp exp.cpp \ - gpre.cpp hsh.cpp int_cxx.cpp jrdmet.cpp movg.cpp \ - msc.cpp par.cpp pat.cpp sqe.cpp sql.cpp\ - @GPRE_LANGUAGE_MODULES@ - -GPRESTATIC_Files = $(GPRECOMMON_Files) gpre_meta.epp -GPRESTATIC_Sources = $(addprefix gpre/, $(GPRESTATIC_Files)) -GPRESTATIC_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GPRESTATIC_Sources)))) - - -AllObjects = $(GPRESTATIC_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: gpre_static - -all : gpre_static - -gpre_static : $(GPRE_STATIC) - -$(GPRE_STATIC): $(GPRESTATIC_Objects) $(COMMON_Objects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS) $(ICU_LIBS) - -$(RM) $(GPRE_CURRENT) - (cd $(@D); $(LN) $(@F) $(notdir $(GPRE_CURRENT))) - - -include $(ROOT)/gen/make.shared.targets - - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.static.isql b/builds/posix/Makefile.in.static.isql deleted file mode 100644 index 201af9ab3a..0000000000 --- a/builds/posix/Makefile.in.static.isql +++ /dev/null @@ -1,66 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - -unexport ISC_USER -unexport ISC_PASSWORD - - -ISQL_Files = extract.epp isql.epp show.epp Extender.cpp InputDevices.cpp \ - ColList.cpp OptionsBase.cpp iutils.cpp -ISQL_Sources = $(addprefix isql/, $(ISQL_Files)) -ISQL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(ISQL_Sources)))) - -AllObjects = $(ISQL_Objects) $(COMMON_Objects) $(FBUTIL_Objects) -Dependencies = $(AllObjects:.o=.d) - - - -.PHONY: isql_static - - -isql_static : $(ISQL_STATIC) - -$(ISQL_STATIC): $(AllObjects) $(LIBFBSTATIC_A) - $(STATICEXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LIBEDITLINE) $(LINK_LIBS) $(ICU_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/Makefile.in.user.management b/builds/posix/Makefile.in.user.management deleted file mode 100644 index 8282e04b11..0000000000 --- a/builds/posix/Makefile.in.user.management +++ /dev/null @@ -1,81 +0,0 @@ -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# You may obtain a copy of the Licence at -# http://www.gnu.org/licences/lgpl.html -# -# As a special exception this file can also be included in modules -# with other source code as long as that source code has been -# released under an Open Source Initiative certificed licence. -# More information about OSI certification can be found at: -# http://www.opensource.org -# -# This module 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 Lesser General Public Licence for more details. -# -# This module was created by members of the firebird development -# team. All individual contributions remain the Copyright (C) of -# those individuals and all rights are reserved. Contributors to -# this file are either listed below or can be obtained from a CVS -# history command. -# -# Created by: Mark O'Donohue -# -# Contributor(s): -# -# -# -ROOT=.. -ObjModuleType=std - -include $(ROOT)/gen/make.defaults -include $(ROOT)/gen/make.platform -include $(ROOT)/gen/make.rules -include $(ROOT)/gen/make.shared.variables - -@SET_MAKE@ - - -USER_MANAGEMENT_Files = LegacyManagement.epp - -USER_MANAGEMENT_Sources = $(addprefix auth/SecurityDatabase/, $(USER_MANAGEMENT_Files)) - -USER_MANAGEMENT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(USER_MANAGEMENT_Sources)))) - - -MANAGEMENT_OTHER_Sources = jrd/enc.cpp jrd/sha.cpp jrd/guid.cpp common/classes/alloc.cpp \ -common/classes/locks.cpp common/classes/UserBlob.cpp common/classes/init.cpp common/classes/fb_string.cpp \ -common/fb_exception.cpp common/thd.cpp common/StatusArg.cpp - - -MANAGEMENT_OTHER_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(MANAGEMENT_OTHER_Sources)))) - - -MANAGEMENT_Objects = $(USER_MANAGEMENT_Objects) $(MANAGEMENT_OTHER_Objects) -#$(FBCLASSES_ClientObjects) $(FBCOMMON_ClientObjects) -# $(CONFIG_Objects) \ -# $(FBCLASSES_MsgObjects) \ -# $(FBCONFIG_Objects) - - -AllObjects = $(MANAGEMENT_Objects) -Dependencies = $(AllObjects:.o=.d) - - -.PHONY: all user_management - - -all : user_management - -user_management: $(MANAGEMENT) - -$(MANAGEMENT): $(MANAGEMENT_Objects) - $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(MANAGEMENT).0) -o $@ $^ $(LINK_PLUG_LIBS) - - -include $(ROOT)/gen/make.shared.targets - --include $(Dependencies) diff --git a/builds/posix/firebird.vers b/builds/posix/firebird.vers index decd45932c..89bac39cd8 100644 --- a/builds/posix/firebird.vers +++ b/builds/posix/firebird.vers @@ -80,6 +80,7 @@ gds__open gds__open_blob gds__open_blob2 gds__parse_bpb +gds__parse_bpb2 gds__prefix gds__prefix_lock gds__prefix_msg @@ -123,6 +124,9 @@ gds__version gds__vtof gds__vtov gds__default_printer +gds__trace +gds__trace_raw +gds__trace_printer gds__alloc_debug @@ -332,12 +336,17 @@ Bopen fb_shutdown fb_shutdown_callback +fb_ping # Plugins support fb_register_plugin fb_query_plugin +# COM emulation + +fb_get_status_instance + # Other misc functions isc_ftof @@ -355,7 +364,5 @@ isc_vtov # OTHER FUNCTIONS #----------------- -CVT_move - KEYWORD_stringIsAToken KEYWORD_getTokens diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults index 8e2eb98637..1a499e0367 100755 --- a/builds/posix/make.defaults +++ b/builds/posix/make.defaults @@ -40,14 +40,14 @@ #_____________________________________________________________________________ -TMP_ROOT=$(ROOT)/temp +TMP_ROOT=$(ROOT)/temp/$(TARGET) GEN_ROOT=$(ROOT)/gen SRC_ROOT=$(ROOT)/src BLD_ROOT=$(ROOT)/builds LNG_ROOT=$(ROOT)/lang_helpers EXA_ROOT=$(ROOT)/examples -FIREBIRD=$(GEN_ROOT)/firebird +FIREBIRD=$(GEN_ROOT)/$(TARGET)/firebird INTERBASE=$(FIREBIRD) export INTERBASE @@ -65,10 +65,13 @@ RealSrcRootPath = $(shell cd $(SRC_ROOT); pwd) #ModuleName:=$(notdir $(CURDIR)) ModuleName:=$(subst $(RealSrcRootPath)/,,$(CURDIR)) -OBJ=$(TMP_ROOT)/$(ObjModuleType) +OBJ=$(TMP_ROOT) GEN_SRC=$(OBJ) +# avoid generated cpp files deletion +.SECONDARY: $(OBJ)/%.cpp + # This one is not so widely used at the momement. # but I would like it to become so. @@ -88,9 +91,9 @@ CXXFLAGS:= $(CXXFLAGS) $(GLOB_OPTIONS) #____________________________________________________________________________ -IsProdTypeBuild = @PROD_BUILD_FLG@ - # If this is defined then we are building a production - # release with debug and optimization +IsDeveloper = @DEVEL_FLG@ + # If this is defined then we use special rules + # useful for developers only CpuType=@CPU_TYPE@ @@ -173,7 +176,15 @@ SHRLIB_FOREIGN_EXT= $(SHRLIB_EXT) # Include file with version variable definitions --include $(ROOT)/gen/Make.Version +include $(ROOT)/gen/Make.Version +#MajorVer = 2 +#MinorVer = 5 +#RevNo = 0 +#BuildNum = 28678 +#BuildType = T +#BuildSuffix = Firebird 3.0 Unstable +#PackageVersion = Unstable +#FirebirdVersion = 2.5.0 # Add windows dll to library patterns @@ -193,30 +204,26 @@ vpath %.dll $(LIB) BLRTABLE = $(BIN)/blrtable$(EXEC_EXT) -# The shared library name for the embedded (or classic) library +# The firebird shared library name # SD: This name is also hard-coded in builds/install/.../linux/classic scripts. # Scold me, but I don't want library names to be in configure.in # -SharedLibraryName=libfbembed.${SHRLIB_EXT}.${FirebirdVersion} -SharedLibrarySoName=libfbembed.${SHRLIB_EXT}.${MajorVer}.${MinorVer} -SharedLibraryBaseName=libfbembed.${SHRLIB_EXT} +#LibraryFileName=libfbclient +LibraryFileName=libfirebird +LibraryFullName=$(LibraryFileName).${SHRLIB_EXT}.${FirebirdVersion} +LibrarySoName=$(LibraryFileName).${SHRLIB_EXT}.${MajorVer} +LibraryBaseName=$(LibraryFileName).${SHRLIB_EXT} -LIBFBEMBED_SO = $(LIB)/$(SharedLibraryName) -LIBFBEMBED_SOBASENAME = $(LIB)/$(SharedLibrarySoName) -LIBFBEMBED_SONAME = $(LIB)/$(SharedLibraryBaseName) +LIBFIREBIRD_FULLNAME = $(LIB)/$(LibraryFullName) +LIBFIREBIRD_SONAME = $(LIB)/$(LibraryBaseName) +LIBFIREBIRD_BASENAME = $(LIB)/$(LibrarySoName) -# Shared library names for client side of fbserver (or super) version -# used to link all the utilities to enable them to connect over the wire -# to the fbserver. MOD 28-July-2002 +# The firebird engine library name -ClientLibraryName = $(LIB_PREFIX)fbclient.$(SHRLIB_EXT) -ClientLibrarySoName = $(ClientLibraryName).2 -ClientLibraryNameFull = $(ClientLibraryName).${FirebirdVersion} - -LIBFBCLIENT_SO = $(LIB)/$(ClientLibraryNameFull) -LIBFBCLIENT_SOBASENAME=$(LIB)/$(ClientLibrarySoName) -LIBFBCLIENT_SONAME=$(LIB)/$(ClientLibraryName) +EngineFileName=libengine +EngineSoName=$(EngineFileName).${SHRLIB_EXT}.${OdsVersion} +ENGINE_SONAME = $(LIB)/$(EngineSoName) # intl will load dynamically, and having the whole soname set with version # confuses the dynamic load process. So we only have the .$(SHRLIB_EXT) file @@ -224,8 +231,6 @@ LIBFBCLIENT_SONAME=$(LIB)/$(ClientLibraryName) LIBFBINTL_SO = $(FIREBIRD)/intl/$(LIB_PREFIX)fbintl.$(SHRLIB_EXT) -LIBFBSTATIC_A = $(LIB)/libfbstatic.a - ifeq ($(EDITLINE_FLG),Y) ifeq ($(STD_EDITLINE), true) LIBEDITLINE := -l$(READLINE) @@ -234,10 +239,6 @@ ifeq ($(EDITLINE_FLG),Y) endif endif -LIBICU_SO = $(LIB)/$(LIB_PREFIX)icuuc*.$(SHRLIB_FOREIGN_EXT) \ - $(LIB)/$(LIB_PREFIX)icudata*.$(SHRLIB_FOREIGN_EXT) \ - $(LIB)/$(LIB_PREFIX)icui18n*.$(SHRLIB_FOREIGN_EXT) - # Shared library name for usage inside of the UDF IbUtilLibraryName = $(LIB_PREFIX)ib_util.$(SHRLIB_EXT) LIBIBUTIL_SO = $(LIB)/$(IbUtilLibraryName) @@ -246,12 +247,11 @@ LIBIBUTIL_SO = $(LIB)/$(IbUtilLibraryName) # UNDEF_PLATFORM = -Wl,--no-undefined -ifneq ($(IsProdTypeBuild),Y) +ifeq ($(TARGET),Debug) UNDEF_FLAGS = $(UNDEF_PLATFORM) endif FIREBIRD_VERS = firebird.vers -FIREBIRD_CLIENT_VERS = firebird.vers FBTRACE_VERS = fbtrace.vers FBINTL_VERS = fbintl.vers IB_UTIL_VERS = ib_util.vers @@ -262,13 +262,12 @@ ALLVERS = $(FIREBIRD_VERS) $(FBTRACE_VERS) $(FBINTL_VERS) $(IB_UTIL_VERS) ALLVERS += $(UDR_ENGINE_VERS) $(EMPTY_VERS) LINK_FIREBIRD_SYMBOLS = $(LIB_LINK_MAPFILE)$(FIREBIRD_VERS) -LINK_FIREBIRD_EMBED_SYMBOLS=$(LIB_LINK_MAPFILE)$(FIREBIRD_VERS) -LINK_FIREBIRD_CLIENT_SYMBOLS=$(LIB_LINK_MAPFILE)$(FIREBIRD_CLIENT_VERS) LINK_TRACE_SYMBOLS = $(LIB_LINK_MAPFILE)$(FBTRACE_VERS) LINK_FBINTL_SYMBOLS = $(LIB_LINK_MAPFILE)$(FBINTL_VERS) LINK_IBUTIL_SYMBOLS = $(LIB_LINK_MAPFILE)$(IB_UTIL_VERS) LINK_UDRENG_SYMBOLS = $(LIB_LINK_MAPFILE)$(UDR_ENGINE_VERS) LINK_EMPTY_SYMBOLS = $(LIB_LINK_MAPFILE)$(EMPTY_VERS) +LINK_PLUGIN_SYMBOLS = $(LINK_EMPTY_SYMBOLS) LINK_EXEC_EXPORT=-rdynamic LIB_PLATFORM_RPATH = -Wl,-rpath,$(1) @@ -280,46 +279,45 @@ endif LIB_PATH_OPTS = $(call LIB_LINK_RPATH,lib) $(call LIB_LINK_RPATH,intl) LIB_LINK_SONAME= -Wl,-soname,$(1) LIB_LINK_MAPFILE= -Wl,--version-script, -FBEMBED_LINK= -L$(LIB) -lfbembed +FIREBIRD_LIBRARY_LINK= -L$(LIB) -lfirebird LINK_OPTS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) LIB_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) -shared -FB_SUPER_SERVER = $(BIN)/fbserver$(EXEC_EXT) -FB_DAEMON = $(BIN)/fb_smp_server$(EXEC_EXT) - -STATIC_CXXSUPPORT_LIB=@STATIC_CXXSUPPORT_LIB@ -LIB_LINK_IMPLIB = -LIB_GUI = +FB_DAEMON = $(BIN)/firebird$(EXEC_EXT) # Per-library link rules -LINK_UDF = $(LIB_LINK) $(LIB_LINK_OPTIONS) $(call LIB_LINK_SONAME,$(1).$(SHRLIB_EXT))\ +LINK_UDF = $(LIB_LINK) $(LIB_LINK_OPTIONS) $(call LIB_LINK_SONAME,$(1).$(SHRLIB_EXT)) $(UNDEF_FLAGS)\ $(call LIB_LINK_RPATH,lib) -lm LINK_UDF_LIBS = $(THR_LIBS) -L$(LIB) -lib_util -LINK_IB_UTIL = $(LIB_LINK) $(LINK_IBUTIL_SYMBOLS) $(LIB_LINK_OPTIONS)\ +LINK_IB_UTIL = $(LIB_LINK) $(LINK_IBUTIL_SYMBOLS) $(LIB_LINK_OPTIONS) $(UNDEF_FLAGS)\ $(call LIB_LINK_SONAME,$(IbUtilLibraryName)) $(call LIB_LINK_RPATH,lib) LINK_IB_UTIL_LIBS = $(THR_LIBS) -LINK_INTL = $(LIB_LINK) $(LINK_FBINTL_SYMBOLS) $(LIB_LINK_OPTIONS)\ +LINK_INTL = $(LIB_LINK) $(LINK_FBINTL_SYMBOLS) $(LIB_LINK_OPTIONS) $(UNDEF_FLAGS)\ $(call LIB_LINK_SONAME,libintl.$(SHRLIB_EXT).1) $(call LIB_LINK_RPATH,lib) -LINK_INTL_LIBS = -L$(LIB) $(ICU_LIBS) $(SO_LINK_LIBS) +LINK_INTL_LIBS = -L$(LIB) $(ICU_LIBS) $(SO_LINK_LIBS) $(FIREBIRD_LIBRARY_LINK) -LINK_TRACE = $(LIB_LINK) $(LINK_TRACE_SYMBOLS) $(LIB_LINK_OPTIONS)\ +LINK_TRACE = $(LIB_LINK) $(LINK_TRACE_SYMBOLS) $(LIB_LINK_OPTIONS) $(UNDEF_FLAGS)\ $(call LIB_LINK_SONAME,$(LIB_PREFIX)fbtrace.$(SHRLIB_EXT).0) $(call LIB_LINK_RPATH,lib) -LINK_TRACE_LIBS = -L$(LIB) $(SO_LINK_LIBS) +LINK_TRACE_LIBS = -L$(LIB) $(SO_LINK_LIBS) -licuuc -LINK_CLIENT = $(CLIENTLIB_LINK) $(LINK_FIREBIRD_CLIENT_SYMBOLS) $(LIB_LINK_OPTIONS)\ - $(LIB_LINK_IMPLIB) $(call LIB_LINK_SONAME,$(ClientLibrarySoName)) $(call LIB_LINK_RPATH,lib) -LINK_CLIENT_LIBS = $(SO_LINK_LIBS) $(STATIC_CXXSUPPORT_LIB) +LINK_FIREBIRD = $(LIB_LINK) $(LINK_FIREBIRD_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_FIREBIRD_OPTIONS) $(UNDEF_FLAGS)\ + $(call LIB_LINK_SONAME,$(LibrarySoName)) $(call LIB_LINK_RPATH,lib) +LINK_FIREBIRD_LIBS = -L$(LIB) $(LIB_GUI) $(SO_LINK_LIBS) -LINK_EMBED = $(LIB_LINK) $(LINK_FIREBIRD_EMBED_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_EMBED_LINK_OPTIONS)\ - $(call LIB_LINK_SONAME,$(SharedLibrarySoName)) $(call LIB_LINK_RPATH,lib) -LINK_EMBED_LIBS = -L$(LIB) $(LIB_GUI) $(SO_LINK_LIBS) $(ICU_LIBS) +LINK_ENGINE = $(LIB_LINK) $(LINK_PLUGIN_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_FIREBIRD_OPTIONS) $(UNDEF_FLAGS)\ + $(call LIB_LINK_SONAME,$(EngineSoName)) $(call LIB_LINK_RPATH,lib) +LINK_ENGINE_LIBS = $(LINK_FIREBIRD_LIBS) $(FIREBIRD_LIBRARY_LINK) -licuuc -LINK_PLUGIN = $(LIB_LINK) $(LINK_EMPTY_SYMBOLS) $(LIB_LINK_OPTIONS) $(call LIB_LINK_RPATH,lib) +LINK_PLUGIN = $(LIB_LINK) $(LINK_PLUGIN_SYMBOLS) $(LIB_LINK_OPTIONS) $(call LIB_LINK_RPATH,lib) $(UNDEF_FLAGS) LINK_PLUG_LIBS = -L$(LIB) $(SO_LINK_LIBS) +# Pay attention - we place common library into obj, not lib dir +# It's just a set of object files, prepared to be used by ld, not an output library +COMMON_LIB = $(OBJ)/common.a + # From utilities CREATE_DB = $(BIN)/create_db$(EXEC_EXT) GDS_DROP = $(BIN)/gds_drop$(EXEC_EXT) @@ -340,9 +338,8 @@ IBGUARD = $(BIN)/ibguard$(EXEC_EXT) FBMGR_BIN = $(BIN)/fbmgr.bin$(EXEC_EXT) INSTREG = $(BIN)/instreg$(EXEC_EXT) INSTSVC = $(BIN)/instsvc$(EXEC_EXT) -ISC_GDB = $(FIREBIRD)/security2.fdb -ISC_GBAK = $(BIN)/security.gbak -MANAGEMENT = $(PLUGINS)/$(LIB_PREFIX)user_management.$(SHRLIB_EXT) + +SECURITY_FDB = $(FIREBIRD)/security3.fdb # From qli QLI = $(BIN)/qli$(EXEC_EXT) diff --git a/builds/posix/make.rules b/builds/posix/make.rules index 1af3c456a0..e5d530e437 100644 --- a/builds/posix/make.rules +++ b/builds/posix/make.rules @@ -38,7 +38,7 @@ ifeq ($(STD_ICU),false) WFLAGS:= $(WFLAGS) -I$(ROOT)/extern/icu/source/common -I$(ROOT)/extern/icu/source/i18n endif -ifeq ($(IsProdTypeBuild),Y) +ifeq ($(TARGET),Release) WFLAGS:= $(WFLAGS) $(PROD_FLAGS) else WFLAGS:= $(WFLAGS) $(DEV_FLAGS) -DDEV_BUILD @@ -75,65 +75,35 @@ DSQL_GPRE_FLAGS = -m -z -n $(GPRE_CURRENT) $(GPRE_FLAGS) $< $@ -$(OBJ)/jrd/%.cpp: $(SRC_ROOT)/jrd/%.epp +$(OBJ)/jrd/%.cpp: $(SRC_ROOT)/jrd/%.epp $(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $(firstword $<) $@ $(OBJ)/dsql/%.cpp: $(SRC_ROOT)/dsql/%.epp $(GPRE_CURRENT) $(DSQL_GPRE_FLAGS) $< $@ -$(OBJ)/%.cpp: $(SRC_ROOT)/%.epp +$(OBJ)/yvalve/%.cpp: $(SRC_ROOT)/yvalve/%.epp + $(GPRE_CURRENT) $(DSQL_GPRE_FLAGS) $< $@ + +$(OBJ)/%.cpp: $(SRC_ROOT)/%.epp $(GPRE_CURRENT) $(GPRE_FLAGS) $(firstword $<) $@ .SUFFIXES: .lo .o .cpp .c -$(OBJ)/jrd/%.o: $(SRC_ROOT)/jrd/$(PLATFORM_PATH)/%.cpp - $(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@ - @sed -i -e "1s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@) - -$(OBJ)/utilities/ntrace/%.o: $(SRC_ROOT)/utilities/ntrace/$(PLATFORM_PATH)/%.cpp - $(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@ - @sed -i -e "1s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@) - -ifneq ($(strip $(PLATFORM_FALLBACK)),) -$(OBJ)/jrd/%.o: $(SRC_ROOT)/jrd/$(PLATFORM_FALLBACK)/%.cpp - $(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@ - @sed -i -e "1s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@) - -$(OBJ)/utilities/ntrace/%.o: $(SRC_ROOT)/utilities/ntrace/$(PLATFORM_FALLBACK)/%.cpp - $(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@ - @sed -i -e "1s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@) -endif - -$(OBJ)/%.o: $(SRC_ROOT)/%.c +$(OBJ)/%.o: $(SRC_ROOT)/%.c $(CC) $(WCFLAGS) -c $(firstword $<) -o $@ @sed -i -e "1s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@) -$(OBJ)/%.o: $(OBJ)/%.cpp +$(OBJ)/%.o: $(OBJ)/%.cpp $(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@ @sed -i -e "1s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@) -$(OBJ)/%.o: $(SRC_ROOT)/%.cpp +$(OBJ)/%.o: $(SRC_ROOT)/%.cpp $(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@ @sed -i -e "1s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@) .SUFFIXES: .epp .e -.SECONDARY: \ - $(OBJ)/msgs/modify_msgs.epp $(OBJ)/msgs/check_msgs.epp $(OBJ)/msgs/include.epp \ - $(OBJ)/msgs/load.epp $(OBJ)/msgs/build_file.epp $(OBJ)/msgs/change_msgs.epp \ - $(OBJ)/msgs/enter_msgs.epp $(OBJ)/jrd/ini.epp $(OBJ)/jrd/dyn_def.epp $(OBJ)/jrd/scl.epp \ - $(OBJ)/jrd/dyn_del.epp $(OBJ)/jrd/dyn_mod.epp $(OBJ)/jrd/Function.epp $(OBJ)/jrd/grant.epp \ - $(OBJ)/jrd/fun.epp $(OBJ)/jrd/dyn.epp $(OBJ)/jrd/dfw.epp $(OBJ)/jrd/dyn_util.epp \ - $(OBJ)/jrd/pcmet.epp $(OBJ)/jrd/met.epp $(OBJ)/jrd/dpm.epp $(OBJ)/utilities/rebuild/rstore.epp \ - $(OBJ)/utilities/rebuild/rmet.epp $(OBJ)/utilities/gstat/dba.epp $(OBJ)/utilities/stats.epp \ - $(OBJ)/auth/SecurityDatabase/LegacyManagement.epp $(OBJ)/alice/alice_meta.epp $(OBJ)/qli/meta.epp \ - $(OBJ)/qli/proc.epp $(OBJ)/qli/show.epp $(OBJ)/qli/help.epp $(OBJ)/misc/codes.epp \ - $(OBJ)/gpre/gpre_meta.epp $(OBJ)/dsql/blob.epp $(OBJ)/dsql/array.epp \ - $(OBJ)/dsql/PackageNodes.epp $(OBJ)/dsql/metd.epp $(OBJ)/dsql/DdlNodes.epp $(OBJ)/isql/show.epp \ - $(OBJ)/isql/extract.epp $(OBJ)/isql/isql.epp $(OBJ)/burp/restore.epp $(OBJ)/burp/backup.epp \ - $(OBJ)/burp/OdsDetection.epp - # Rules for making resource files $(GEN_ROOT)/%.res: $(SRC_ROOT)/%.rc diff --git a/builds/posix/make.shared.targets b/builds/posix/make.shared.targets index 00f9eafcf5..8629ea2707 100644 --- a/builds/posix/make.shared.targets +++ b/builds/posix/make.shared.targets @@ -41,10 +41,10 @@ # This rule creates parse.cpp from parse.y -$(SRC_ROOT)/dsql/parse.cpp $(SRC_ROOT)/dsql/dsql.tab.h: $(SRC_ROOT)/dsql/parse.y $(SRC_ROOT)/dsql/btyacc_fb.ske +$(OBJ)/dsql/parse.cpp $(SRC_ROOT)/include/gen/parse.h: $(SRC_ROOT)/dsql/parse.y $(SRC_ROOT)/dsql/btyacc_fb.ske $(BTYACC) -l -d -S $(SRC_ROOT)/dsql/btyacc_fb.ske $< - $(MV) $(GEN_ROOT)/y_tab.c $(SRC_ROOT)/dsql/parse.cpp - $(MV) $(GEN_ROOT)/y_tab.h $(SRC_ROOT)/dsql/dsql.tab.h + $(MV) $(GEN_ROOT)/y_tab.c $(OBJ)/dsql/parse.cpp + $(MV) $(GEN_ROOT)/y_tab.h $(SRC_ROOT)/include/gen/parse.h # gpre_meta needs a special boot build since there is no database. @@ -53,19 +53,6 @@ $(SRC_ROOT)/gpre/gpre_meta.cpp: $(SRC_ROOT)/gpre/gpre_meta.epp $(GPRE_BOOT) -lang_internal $(GPRE_FLAGS) $< $@ -buildb: security2.fdb yachts.lnk help.fdb - -security2.fdb : $(ISC_GDB) - -$(LN) -f $(ISC_GDB) $@ - -yachts.lnk: - -$(LN) -f $(SRC_ROOT)/refDatabases/empty.fdb yachts.lnk - -help.fdb: - -$(LN) -f $(SRC_ROOT)/refDatabases/help.fdb help.fdb - - - # These need to change to $(GEN_SRC) at some stage #$(SRC_ROOT)/qli/meta.cpp $(SRC_ROOT)/qli/proc.cpp $(SRC_ROOT)/qli/show.cpp: yachts.lnk #$(SRC_ROOT)/qli/help.cpp: help.fdb @@ -74,8 +61,7 @@ help.fdb: $(OBJ)/jrd/par.o: $(SRC_ROOT)/include/gen/blrtable.h # Explicit dependence on generated header (parser) -$(SRC_ROOT)/dsql/keywords.cpp: $(SRC_ROOT)/dsql/dsql.tab.h -$(OBJ)/dsql/Parser.h: $(SRC_ROOT)/dsql/dsql.tab.h +$(OBJ)/dsql/Parser.o $(OBJ)/dsql/keywords.o $(OBJ)/dsql/dsql.o: $(SRC_ROOT)/include/gen/parse.h $(OBJ)/dsql/AggNodes.o: $(SRC_ROOT)/include/gen/blrtable.h $(OBJ)/dsql/ExprNodes.o: $(SRC_ROOT)/include/gen/blrtable.h diff --git a/builds/posix/make.shared.variables b/builds/posix/make.shared.variables index 44808c1c69..e932cb3fbc 100644 --- a/builds/posix/make.shared.variables +++ b/builds/posix/make.shared.variables @@ -1,388 +1,200 @@ -# -# jrd +# Helper functions +makeObjects= $(addprefix $(OBJ)/$(1)/,$(patsubst %.y,%.o,$(patsubst %.epp,%.o,$(patsubst %.c,%.o,$(2:.cpp=.o))))) +dirFiles= $(notdir $(wildcard ../src/$(1)/*.cpp)) $(notdir $(wildcard ../src/$(1)/*.c)) \ + $(notdir $(wildcard ../src/$(1)/*.epp)) $(notdir $(wildcard ../src/$(1)/*.y)) +dirInPath= $(call makeObjects,$(1),$(call dirFiles,$(1))) -# to get at the database. why.cpp is the normal one whybk.cpp is the one -# compiled with a BACKEND flag, it seems to be (from a quick look at -# the code) to allow the use of another library to talk to data from -# and earlier version data file. (Good way to achieve back portability) -# In the current builds only why.cpp is used, to build using whybk.cpp you -# will need to look at what is contained in the original makefiles. - -WHY_Sources = why.cpp - -# why.cpp does the switch to determine the actual implementation to use - - -JRD_ClientFiles = alt.cpp db_alias.cpp dsc.cpp \ - gds.cpp isc.cpp isc_file.cpp isc_ipc.cpp \ - perf.cpp sdl.cpp status.cpp \ - ThreadData.cpp ThreadStart.cpp utl.cpp \ - $(WHY_Sources) - -JRD_ClientSources = $(addprefix jrd/, $(JRD_ClientFiles)) \ - common/cvt.cpp common/classes/DbImplementation.cpp - - -JRD_ServerFiles= blob_filter.cpp cvt.cpp dpm.epp dyn.epp dyn_def.epp \ - dyn_del.epp dyn_mod.epp dyn_util.epp fun.epp Function.epp \ - grant.epp ini.epp met.epp pcmet.epp scl.epp \ - CharSet.cpp Collation.cpp DatabaseSnapshot.cpp VirtualTable.cpp RecordBuffer.cpp \ - blb.cpp btn.cpp btr.cpp builtin.cpp \ - GlobalRWLock.cpp cch.cpp cmp.cpp cvt2.cpp \ - DataTypeUtil.cpp dfw.cpp UserManagement.cpp divorce.cpp \ - err.cpp event.cpp ErrorImpl.cpp evl.cpp exe.cpp ext.cpp \ - execute_statement.cpp ExtEngineManager.cpp filters.cpp flu.cpp \ - idx.cpp inf.cpp intl.cpp intl_builtin.cpp IntlManager.cpp \ - IntlUtil.cpp isc_sync.cpp \ - jrd.cpp JrdStatement.cpp Attachment.cpp Database.cpp lck.cpp \ - mov.cpp opt.cpp Optimizer.cpp pag.cpp par.cpp \ - ods.cpp PluginManager.cpp PreparedStatement.cpp RandomGenerator.cpp \ - Relation.cpp ResultSet.cpp rlck.cpp rpb_chain.cpp \ - sdw.cpp shut.cpp sort.cpp sqz.cpp \ - svc.cpp SysFunction.cpp TempSpace.cpp tpc.cpp tra.cpp validation.cpp \ - ValueImpl.cpp ValuesImpl.cpp vio.cpp \ - nodebug.cpp nbak.cpp $(Physical_IO_Module) TextType.cpp \ - unicode_util.cpp RecordSourceNodes.cpp RuntimeStatistics.cpp DebugInterface.cpp \ - extds/ExtDS.cpp extds/InternalDS.cpp extds/IscDS.cpp \ - trace/TraceConfigStorage.cpp trace/TraceLog.cpp \ - trace/TraceManager.cpp trace/TraceObjects.cpp \ - recsrc/AggregatedStream.cpp recsrc/BitmapTableScan.cpp \ - recsrc/BufferedStream.cpp recsrc/Cursor.cpp recsrc/ExternalTableScan.cpp \ - recsrc/FilteredStream.cpp recsrc/FirstRowsStream.cpp recsrc/FullOuterJoin.cpp \ - recsrc/FullTableScan.cpp recsrc/HashJoin.cpp recsrc/IndexTableScan.cpp recsrc/LockedStream.cpp \ - recsrc/MergeJoin.cpp recsrc/NestedLoopJoin.cpp \ - recsrc/ProcedureScan.cpp recsrc/RecordSource.cpp recsrc/RecursiveStream.cpp \ - recsrc/SingularStream.cpp recsrc/SkipRowsStream.cpp recsrc/SortedStream.cpp recsrc/Union.cpp \ - recsrc/VirtualTableScan.cpp recsrc/WindowedStream.cpp - -JRD_ServerSources = $(addprefix jrd/, $(JRD_ServerFiles)) -JRD_ServerSources += gpre/pretty.cpp - -JRD_Sources = $(JRD_ClientSources) $(JRD_ServerSources) - -# expands list to ..//jrd/xx.o entries -JRD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(JRD_Sources)))) - - - -# If your platform needs these then you may need -# to include something like. -# JRD_P_Sources := $(subst, flu.lo, , $(JRD_P_Sources)) - - - -#________________________________________________________________________ -# -# dsql - -DSQL_ClientFiles = array.epp blob.epp \ - preparse.cpp user_dsql.cpp utld.cpp keywords.cpp - -DSQL_ServerFiles= metd.epp DSqlDataTypeUtil.cpp \ - ddl.cpp dsql.cpp errd.cpp gen.cpp hsh.cpp make.cpp \ - movd.cpp parse.cpp Parser.cpp pass1.cpp \ - DdlNodes.epp PackageNodes.epp AggNodes.cpp BlrWriter.cpp BoolNodes.cpp \ - DsqlCompilerScratch.cpp ExprNodes.cpp StmtNodes.cpp WinNodes.cpp - - -DSQL_Files = $(DSQL_ClientFiles) $(DSQL_ServerFiles) - -DSQL_Sources = $(addprefix dsql/, $(DSQL_Files)) -DSQL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(DSQL_Sources)))) - - -#________________________________________________________________________ -# -# lock - - -LOCK_Files = lock.cpp - -LOCK_Sources = $(addprefix lock/, $(LOCK_Files)) -LOCK_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(LOCK_Sources)))) - - -#________________________________________________________________________ -# -# remote - -REMOTE_CommonFiles = inet.cpp merge.cpp \ - parser.cpp protocol.cpp remote.cpp xdr.cpp - -REMOTE_ClientFiles = interface.cpp - -INTERFACE_Files= $(REMOTE_ClientFiles) $(REMOTE_CommonFiles) - - -INTERFACE_Sources = $(addprefix remote/, $(INTERFACE_Files)) \ - auth/Auth.cpp auth/AuthDbg.cpp auth/SecurityDatabase/LegacyClient.cpp jrd/enc.cpp -INTERFACE_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(INTERFACE_Sources)))) - -ifeq ($(PLATFORM),win32) -REMOTE_CommonFiles += os/win32/wnet.cpp xnet.cpp -INTERFACE_Objects += $(OBJ)/auth/trusted/AuthSspi.o +dirMaster= $(call dirInPath,$(1)) +dirOs= $(call dirInPath,$(1)/$(PLATFORM_PATH)) +ifneq ($(strip $(PLATFORM_FALLBACK)),) +dirBackList= $(filter-out $(call dirFiles,$(1)/$(PLATFORM_PATH)),$(call dirFiles,$(1)/$(PLATFORM_FALLBACK))) +dirFallBack= $(call makeObjects,$(1)/$(PLATFORM_FALLBACK),$(call dirBackList,$(1))) +else +dirFallBack= endif -#________________________________________________________________________ -# -# intl - -# none currently. +dirObjects= $(call dirMaster,$(1)) $(call dirOs,$(1)) $(call dirOs2,$(1)) + + +# Collect all object files here +AllObjects= + + +# Common files +CO1:= $(call dirObjects,common) +CO2:= $(call dirObjects,common/classes) +CO3:= $(call dirObjects,common/config) +#CO4:= $(call dirObjects,common/exceptions) +#CO5:= $(call dirObjects,common/sync) +Common_Objects:= $(CO1) $(CO2) $(CO3) +# $(CO4) $(CO5) + +AllObjects += $(Common_Objects) -#________________________________________________________________________ -# # gpre +GPRE_Common_Objects:= $(call dirObjects,gpre) $(call makeObjects,gpre/languages,@GPRE_LANGUAGE_MODULES@) +GPRE_std:= $(call dirObjects,gpre/std) +GPRE_Objects:= $(GPRE_Common_Objects) $(GPRE_std) +GPRE_boot:= $(call dirObjects,gpre/boot) $(call makeObjects,yvalve,gds.cpp) +GPRE_Boot_Objects:= $(GPRE_Common_Objects) $(GPRE_boot) -GPRELIB_ClientFiles = pretty.cpp - -GPRELIB_Files = $(GPRELIB_ClientFiles) $(GPRELIB_ServerFiles) - -GPRELIB_Sources = $(addprefix gpre/, $(GPRELIB_Files)) -GPRELIB_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GPRELIB_Sources)))) +AllObjects += $(GPRE_Common_Objects) $(GPRE_std) $(GPRE_boot) +# Y-Valve +YValve_Objects:= $(call dirObjects,yvalve) -#________________________________________________________________________ -# -# alice +AllObjects += $(YValve_Objects) -ALICE_Files=alice.cpp exe.cpp alice_meta.epp tdr.cpp -ALICE_Sources = $(addprefix alice/, $(ALICE_Files)) -ALICE_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(ALICE_Sources)))) -#________________________________________________________________________ -# -# burp +# Remote +Remote_Common:= $(call dirObjects,remote) +Remote_Server:= $(call dirObjects,remote/server) $(call makeObjects,auth/SecurityDatabase,pwd.cpp) + # legacy security database pwd.cpp should become SA plugin +Remote_Client:= $(call dirObjects,remote/client) $(call makeObjects,auth/SecurityDatabase,LegacyClient.cpp) +Remote_Server_Objects:= $(Remote_Common) $(Remote_Server) +Remote_Client_Objects:= $(Remote_Common) $(Remote_Client) -BURP_Files=burp.cpp backup.epp restore.epp OdsDetection.epp mvol.cpp misc.cpp canonical.cpp -BURP_Sources = $(addprefix burp/, $(BURP_Files)) -BURP_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(BURP_Sources)))) +AllObjects += $(Remote_Common) $(Remote_Server) $(Remote_Client) + + +# Engine +Engine_Objects:= $(call dirObjects,jrd) $(call dirObjects,dsql) $(call dirObjects,jrd/extds) \ + $(call dirObjects,jrd/recsrc) $(call dirObjects,jrd/trace) \ + $(call makeObjects,lock,lock.cpp) + +AllObjects += $(Engine_Objects) + + +# services + +# gfix +Svc_GFIX_Objects:= $(call dirObjects,alice) +GFIX_Objects:= $(Svc_GFIX_Objects) $(call dirObjects,alice/main) + +AllObjects += $(GFIX_Objects) + +# gbak +Svc_GBAK_Objects:= $(call dirObjects,burp) +GBAK_Objects:= $(Svc_GBAK_Objects) $(call dirObjects,burp/main) + +AllObjects += $(GBAK_Objects) + +# gsec +Svc_GSEC_Objects:= $(call dirObjects,utilities/gsec) +GSEC_Objects:= $(Svc_GSEC_Objects) $(call dirObjects,utilities/gsec/main) + +AllObjects += $(GSEC_Objects) + +# gstat +Svc_GSTAT_Objects:= $(call dirObjects,utilities/gstat) +GSTAT_Own_Objects:= $(Svc_GSTAT_Objects) $(call dirObjects,utilities/gstat/main) +GSTAT_Objects:= $(GSTAT_Own_Objects) $(call makeObjects,jrd,btn.cpp ods.cpp) + +AllObjects += $(GSTAT_Own_Objects) -#________________________________________________________________________ -# # nbackup +Svc_NBACKUP_Objects:= $(call dirObjects,utilities/nbackup) +NBACKUP_Own_Objects:= $(Svc_NBACKUP_Objects) $(call dirObjects,utilities/nbackup/main) +NBACKUP_Objects:= $(NBACKUP_Own_Objects) $(call makeObjects,jrd,ods.cpp) -NBACKUP_SERVER_Files= nbackup.cpp -NBACKUP_SERVER_Sources = $(addprefix utilities/, $(NBACKUP_SERVER_Files)) -NBACKUP_SERVER_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(NBACKUP_SERVER_Sources)))) +AllObjects += $(NBACKUP_Own_Objects) -#________________________________________________________________________ -# -# ntrace +SVC_Objects:= $(Svc_GFIX_Objects) $(Svc_GBAK_Objects) $(Svc_GSEC_Objects) $(Svc_GSTAT_Objects) \ + $(Svc_NBACKUP_Objects) -NTRACE_SERVER_Files= TraceCmdLine.cpp TraceService.cpp -NTRACE_SERVER_Sources = $(addprefix jrd/trace/, $(NTRACE_SERVER_Files)) -NTRACE_SERVER_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(NTRACE_SERVER_Sources)))) -#________________________________________________________________________ -# -# utilities +# International support +INTL_Objects:= $(call dirObjects,intl) -SECURITY_ClientFiles_gsec = call_service.cpp +AllObjects += $(INTL_Objects) -SECURITY_ServerFiles_gsec:= security.cpp gsec.cpp -SECURITY_ServerFiles_gstat:= dba.epp ppg.cpp -SECURITY_ServerFiles_common:= -SECURITY_Files_gsec = $(SECURITY_ClientFiles_gsec) $(SECURITY_ServerFiles_gsec) -SECURITY_Files_gstat = $(SECURITY_ServerFiles_gstat) -SECURITY_Files_common = $(SECURITY_ServerFiles_common) -SECURITY_Sources_gsec = $(addprefix utilities/gsec/, $(SECURITY_Files_gsec)) -SECURITY_Sources_gstat = $(addprefix utilities/gstat/, $(SECURITY_Files_gstat)) -SECURITY_Sources_common = $(addprefix utilities/common/, $(SECURITY_Files_common)) +# Lockprint +LOCKPRINT_Objects:= $(call makeObjects,lock,print.cpp) -SECURITY_Sources = $(SECURITY_Sources_gsec) $(SECURITY_Sources_gstat) $(SECURITY_Sources_common) -SECURITY_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(SECURITY_Sources)))) +AllObjects += $(LOCKPRINT_Objects) -SECURITY_ClientSources_gsec = $(addprefix utilities/gsec/, $(SECURITY_ClientFiles_gsec)) -SECURITY_ClientObjects_gsec = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(SECURITY_ClientSources_gsec)))) -#________________________________________________________________________ -# -# common/classes +# Guardian +FBGUARD_Objects:= $(call dirObjects,utilities/guard) -FBCLASSES_ClientFiles=alloc.cpp locks.cpp semaphore.cpp fb_string.cpp timestamp.cpp \ - PublicHandle.cpp TempFile.cpp -FBCLASSES_MsgFiles=SafeArg.cpp MsgPrint.cpp BaseStream.cpp -FBCLASSES_ServerFiles=UserBlob.cpp +AllObjects += $(FBGUARD_Objects) -FBCLASSES_ClientSources = $(addprefix common/classes/, $(FBCLASSES_ClientFiles)) -FBCLASSES_MsgSources = $(addprefix common/classes/, $(FBCLASSES_MsgFiles)) -FBCLASSES_ServerSources = $(addprefix common/classes/, $(FBCLASSES_ServerFiles)) -FBCLASSES_ClientObjects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBCLASSES_ClientSources)))) -FBCLASSES_MsgObjects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBCLASSES_MsgSources)))) -FBCLASSES_ServerObjects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBCLASSES_ServerSources)))) +# Services manager +FBSVCMGR_Objects:= $(call dirObjects,utilities/fbsvcmgr) -FBCLASSES_Objects = $(FBCLASSES_ClientObjects) $(FBCLASSES_ServerObjects) $(FBCLASSES_MsgObjects) +AllObjects += $(FBSVCMGR_Objects) -#________________________________________________________________________ -# -# common/config -FBCONFIG_ClientFiles=config.cpp config_file.cpp dir_list.cpp ConfigCache.cpp -FBCONFIG_ServerFiles= +# Trace manager +FBTRACEMGR_Objects:= $(call dirObjects,utilities/fbtracemgr) $(call makeObjects,jrd/trace,TraceCmdLine.cpp) -FBCONFIG_Files= $(FBCONFIG_ClientFiles) $(FBCONFIG_ServerFiles) +AllObjects += $(FBTRACEMGR_Objects) -FBCONFIG_Sources = $(addprefix common/config/, $(FBCONFIG_Files)) -FBCONFIG_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBCONFIG_Sources)))) -#________________________________________________________________________ -# -# config +# Trace plugin +FBTRACE_UTIL_Objects:= $(call dirObjects,utilities/ntrace) -CONFIG_ClientFiles=ScanDir.cpp -CONFIG_ServerFiles= +AllObjects += $(FBTRACE_UTIL_Objects) -CONFIG_Files= $(CONFIG_ClientFiles) $(CONFIG_ServerFiles) -CONFIG_Sources = $(addprefix config/, $(CONFIG_Files)) -CONFIG_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(CONFIG_Sources)))) +# Split/merge backup files +GSPLIT_Objects:= $(call dirObjects,burp/split) -#________________________________________________________________________ -# -# common +AllObjects += $(GSPLIT_Objects) -FBCOMMON_ClientFiles = fb_exception.cpp thd.cpp classes/MetaName.cpp StatusHolder.cpp classes/init.cpp StatusArg.cpp -FBCOMMON_ServerFiles = utils.cpp -FBCOMMON_ClientObjects = $(addprefix $(OBJ)/common/, $(addsuffix .o, $(basename $(FBCOMMON_ClientFiles)))) -FBCOMMON_ServerObjects = $(addprefix $(OBJ)/common/, $(addsuffix .o, $(basename $(FBCOMMON_ServerFiles)))) +# Interactive sql +ISQL_Objects:= $(call dirObjects,isql) -FBCOMMON_Objects = $(FBCOMMON_ClientObjects) $(FBCOMMON_ServerObjects) +AllObjects += $(ISQL_Objects) -#________________________________________________________________________ -# -# clumplets -CLUMPLETS_ClientFiles = ClumpletReader.cpp ClumpletWriter.cpp -CLUMPLETS_ServerFiles = +# QLI +QLI_Objects:= $(call dirObjects,qli) -CLUMPLETS_Files = $(CLUMPLETS_ClientFiles) $(CLUMPLETS_ServerFiles) +AllObjects += $(QLI_Objects) -CLUMPLETS_Sources = $(addprefix common/classes/, $(CLUMPLETS_Files)) -CLUMPLETS_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(CLUMPLETS_Sources)))) +# Legacy users management in security database +LEGACY_USERS_MANAGE_Objects:= $(call makeObjects,auth/SecurityDatabase,LegacyManagement.epp) -#________________________________________________________________________ -# -# Platform Manager +AllObjects += $(LEGACY_USERS_MANAGE_Objects) -# just in case if make.platform defined some files -OS_SPECIFIC_Files += config_root.cpp path_utils.cpp mod_loader.cpp fbsyslog.cpp guid.cpp os_utils.cpp -OS_SPECIFIC_Sources = $(addprefix jrd/, $(OS_SPECIFIC_Files)) common/dllinst.cpp -ifneq ($(strip @BINRELOC_CFLAGS@),) -OS_SPECIFIC_Sources += $(ROOT)/extern/binreloc/binreloc.c -endif -OS_SPECIFIC_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(OS_SPECIFIC_Sources)))) +# UDR engine +UDRENG_Objects:= $(call dirObjects,plugins/udr_engine) +AllObjects += $(UDRENG_Objects) -#________________________________________________________________________ -# -# These objects are needed in any target +# UDF support +IBUDF_Objects:= $(call makeObjects,extlib,ib_udf.cpp) +FBUDF_Objects:= $(call makeObjects,extlib/fbudf,fbudf.cpp) +UTIL_Objects:= $(call makeObjects,extlib,ib_util.cpp) -COMMON_Objects = $(FBCLASSES_Objects) \ - $(FBCOMMON_Objects) \ - $(CONFIG_Objects) +AllObjects += $(IBUDF_Objects) $(FBUDF_Objects) $(UTIL_Objects) -#________________________________________________________________________ -# +# Regenerate error codes +CODES_Objects:= $(call makeObjects,misc,codes.epp) +MSG_SCRIPTS = msg.sql facilities2.sql locales.sql sqlstates.sql history2.sql messages2.sql \ + symbols2.sql system_errors2.sql transmsgs.fr_FR2.sql transmsgs.de_DE2.sql +MSG_FILES = $(addprefix $(SRC_ROOT)/msgs/, $(MSG_SCRIPTS)) -# These objects are needed for all utilities +AllObjects += $(CODES_Objects) -FBUTIL_Files = classes/Switches.cpp -FBUTIL_Sources = $(addprefix common/, $(FBUTIL_Files)) -FBUTIL_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBUTIL_Sources)))) +# Create messages file +BUILD_Objects:= $(call makeObjects,msgs,build_file.epp) +AllObjects += $(BUILD_Objects) -#________________________________________________________________________ -# -# These objects are needed for all services +# BLR +BLRTABLE_Objects = $(call makeObjects,misc,blrtable.cpp) -FBSVC_Files = UtilSvc.cpp - -FBSVC_Sources = $(addprefix common/, $(FBSVC_Files)) -FBSVC_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBSVC_Sources)))) - - -#________________________________________________________________________ -# - -# These objects are needed for utilities, that can be used as services - -FBUTILSVC_Objects = $(FBUTIL_Objects) $(FBSVC_Objects) - - -#________________________________________________________________________ -# - -SVCTAB_Sources = jrd/svc_tab.cpp -SVCTAB_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(SVCTAB_Sources)))) - -# These are the lists of object/shared object files that will go into libgds.$(SHRLIB_EXT). - -LIBFBEMBED_Objects =$(OS_SPECIFIC_Objects) \ - $(JRD_Objects) \ - $(DSQL_Objects) \ - $(LOCK_Objects) \ - $(INTERFACE_Objects) \ - $(GPRELIB_Objects) \ - $(SECURITY_Objects) \ - $(CLUMPLETS_Objects) \ - $(FBCONFIG_Objects) \ - $(BURP_Objects) \ - $(ALICE_Objects) \ - $(NBACKUP_SERVER_Objects) \ - $(NTRACE_SERVER_Objects) \ - $(FBUTIL_Objects) \ - $(SVCTAB_Objects) - -# Objects differences for server (super) and embedded (classic) libraries -# have been worked out above in this file, based on macros, so here they -# both refer to the same thing. (better way always possible) -# MOD 29-July-2002 - -LIBFBSERVER_Objects =$(LIBFBEMBED_Objects) - - -# The following library is a 'reduced' set (although not that reduced) -# to enable easy compilation of a boot kit containing a simple gpre and -# gbak modules. These are then used to compile the rest of the system. -# MOD 29-July-2002 - -# Stub for services entrypoints missing in static library -STUB_Sources = jrd/svc_stub.cpp utilities/gsec/security.cpp -STUB_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(STUB_Sources)))) - - -# Notice that $(SECURITY_Objects) are missing, because that file can't be -# compiled until later in the build process. - -LIBFBSTATIC_Objects = $(OS_SPECIFIC_Objects) \ - $(JRD_Objects) \ - $(DSQL_Objects) \ - $(LOCK_Objects) \ - $(INTERFACE_Objects) \ - $(GPRELIB_Objects) \ - $(FBCONFIG_Objects) \ - $(CLUMPLETS_Objects) \ - $(SECURITY_ClientObjects_gsec) \ - $(STUB_Objects) - - -# Not needed since loaded into libfbmemory.a already -# $(FBMEMORY_Objects) - -#________________________________________________________________________ -# -# blrtable builder - -BLRTABLE_Sources = misc/blrtable.cpp -BLRTABLE_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(BLRTABLE_Sources)))) +AllObjects += $(BLRTABLE_Objects) diff --git a/configure.in b/configure.in index 709f743015..1bb7ba9611 100644 --- a/configure.in +++ b/configure.in @@ -450,14 +450,14 @@ case $FIREBIRD_ARCH_TYPE in esac PROD_BUILD_FLG=Y -AC_ARG_ENABLE(debug, - [ --enable-debug build debug version (default=no)], +AC_ARG_ENABLE(developer, + [ --enable-developer use developer mopde rules (default=no)], [case "$enableval" in - yes) PROD_BUILD_FLG=N;; - no) PROD_BUILD_FLG=Y;; - *) AC_MSG_ERROR(bad value '${enableval}' for --enable-debug);; + yes) DEVEL_FLG=Y;; + no) DEVEL_FLG=N;; + *) AC_MSG_ERROR(bad value '${enableval}' for --enable-developer);; esac]) -AC_SUBST(PROD_BUILD_FLG) +AC_SUBST(DEVEL_FLG) dnl Avoid dumb '-g -O2' autoconf's default dnl Debugging information and optimization flags should be set in prefix.$platform file @@ -1021,190 +1021,47 @@ AC_SUBST(EXPORT_SYMBOLS_STYLE) AC_DEFINE_UNQUOTED(FB_PREFIX, $(if test "x$prefix" = "xNONE" ; then echo \"$ac_default_prefix\"; else echo \"$prefix\"; fi), [Installation path prefix]) AC_CONFIG_COMMANDS(,,[ -dnl ### GEN ### directories for preprocessed cpp, databases and output -mkdir -p gen/alice -mkdir -p gen/burp -mkdir -p gen/dsql -mkdir -p gen/dudley -mkdir -p gen/gpre -mkdir -p gen/iscguard -mkdir -p gen/isql -mkdir -p gen/jrd -mkdir -p gen/jrd/extds -mkdir -p gen/jrd/recsrc -mkdir -p gen/jrd/trace -mkdir -p gen/msgs -mkdir -p gen/plugins/udr_engine -mkdir -p gen/qli -mkdir -p gen/utilities -mkdir -p gen/examples +for fb_tgt in Debug Release; do +dnl ### GEN ### directories for databases and misc + mkdir -p gen/\$fb_tgt/examples + mkdir -p gen/\$fb_tgt/refDatabases -dnl # some .o and .d in this directory (to be removed) -mkdir -p gen/remote/os/win32 -mkdir -p gen/remote/os/sun +dnl # output + mkdir -p gen/\$fb_tgt/include + mkdir -p gen/\$fb_tgt/intl + mkdir -p gen/\$fb_tgt/firebird/UDF + mkdir -p gen/\$fb_tgt/firebird/bin + mkdir -p gen/\$fb_tgt/firebird/plugins + mkdir -p gen/\$fb_tgt/firebird/examples/api + mkdir -p gen/\$fb_tgt/firebird/examples/dyn + dnl # mkdir -p gen/\$fb_tgt/firebird/examples/build_unix + dnl # mkdir -p gen/\$fb_tgt/firebird/examples/build_win32 + mkdir -p gen/\$fb_tgt/firebird/examples/empbuild + mkdir -p gen/\$fb_tgt/firebird/examples/include + mkdir -p gen/\$fb_tgt/firebird/examples/udr + mkdir -p gen/\$fb_tgt/firebird/examples/stat + mkdir -p gen/\$fb_tgt/firebird/examples/udf + mkdir -p gen/\$fb_tgt/firebird/lib + mkdir -p gen/\$fb_tgt/firebird/misc + mkdir -p gen/\$fb_tgt/firebird/help + mkdir -p gen/\$fb_tgt/firebird/plugins/udr -dnl # databases and output -mkdir -p gen/refDatabases -mkdir -p gen/firebird/include -mkdir -p gen/firebird/intl -mkdir -p gen/firebird/UDF -mkdir -p gen/firebird/bin -mkdir -p gen/firebird/plugins -mkdir -p gen/firebird/examples/api -mkdir -p gen/firebird/examples/dyn -dnl # mkdir -p gen/firebird/examples/build_unix -dnl # mkdir -p gen/firebird/examples/build_win32 -mkdir -p gen/firebird/examples/empbuild -mkdir -p gen/firebird/examples/include -mkdir -p gen/firebird/examples/udr -mkdir -p gen/firebird/examples/stat -mkdir -p gen/firebird/examples/udf -mkdir -p gen/firebird/lib -mkdir -p gen/firebird/misc -mkdir -p gen/firebird/help -mkdir -p gen/firebird/plugins/udr +dnl #### TEMP ######### directories for generated .cpp, .o and .d +dnl # by module name + for src_dir in `cd src; ls -R -1 * | grep : | tr -d : | tr "\n" " "; cd ..`; do + mkdir -p temp/\$fb_tgt/\$src_dir + done + + src/misc/writeBuildNum.sh createMakeVersion gen/Make.Version +done + +for src_dir in `ls -R -1 examples | grep : | tr -d : | tr "\n" " "`; do + mkdir -p temp/\$src_dir +done dnl # rebuild version header if needed ./src/misc/writeBuildNum.sh rebuildHeader -dnl #### TEMP ######### directories for .o and .d -dnl # by module name - -mkdir -p temp/extern/binreloc -mkdir -p temp/std/alice -mkdir -p temp/std/auth/trusted -mkdir -p temp/std/auth/SecurityDatabase -mkdir -p temp/std/burp -mkdir -p temp/std/common/classes -mkdir -p temp/std/common/config -mkdir -p temp/std/config -mkdir -p temp/std/dsql -mkdir -p temp/std/dudley -mkdir -p temp/std/extlib -mkdir -p temp/std/extlib/fbudf -mkdir -p temp/std/gpre -mkdir -p temp/std/intl -mkdir -p temp/std/ipserver -mkdir -p temp/std/iscguard -mkdir -p temp/std/isql -mkdir -p temp/std/jrd -mkdir -p temp/std/jrd/extds -mkdir -p temp/std/jrd/recsrc -mkdir -p temp/std/jrd/trace -mkdir -p temp/std/jrd/os/posix -mkdir -p temp/std/jrd/os/win32 -mkdir -p temp/std/jrd/os/darwin -mkdir -p temp/std/lock -mkdir -p temp/std/misc -mkdir -p temp/std/msgs -mkdir -p temp/std/plugins/udr_engine -mkdir -p temp/std/qli -mkdir -p temp/std/remote -mkdir -p temp/std/remote/os/win32 -mkdir -p temp/std/remote/os/sun -mkdir -p temp/std/remote/os/darwin -mkdir -p temp/std/utilities/common -mkdir -p temp/std/utilities/fbtracemgr -mkdir -p temp/std/utilities/gsec -mkdir -p temp/std/utilities/gstat -mkdir -p temp/std/utilities/guard -mkdir -p temp/std/utilities/ibmgr -mkdir -p temp/std/utilities/install -mkdir -p temp/std/utilities/nbackup -mkdir -p temp/std/utilities/rebuild -mkdir -p temp/std/utilities/ntrace -mkdir -p temp/std/vulcan - -mkdir -p temp/superclient/alice -mkdir -p temp/superclient/auth/trusted -mkdir -p temp/superclient/auth/SecurityDatabase -mkdir -p temp/superclient/burp -mkdir -p temp/superclient/common/classes -mkdir -p temp/superclient/common/config -mkdir -p temp/superclient/config -mkdir -p temp/superclient/dsql -mkdir -p temp/superclient/dudley -mkdir -p temp/superclient/extlib -mkdir -p temp/superclient/extlib/fbudf -mkdir -p temp/superclient/gpre -mkdir -p temp/superclient/intl -mkdir -p temp/superclient/ipserver -mkdir -p temp/superclient/iscguard -mkdir -p temp/superclient/isql -mkdir -p temp/superclient/jrd -mkdir -p temp/superclient/jrd/extds -mkdir -p temp/superclient/jrd/recsrc -mkdir -p temp/superclient/jrd/trace -mkdir -p temp/superclient/jrd/os/posix -mkdir -p temp/superclient/jrd/os/win32 -mkdir -p temp/superclient/jrd/os/darwin -mkdir -p temp/superclient/lock -mkdir -p temp/superclient/misc -mkdir -p temp/superclient/msgs -mkdir -p temp/superclient/plugins/udr_engine -mkdir -p temp/superclient/qli -mkdir -p temp/superclient/remote -mkdir -p temp/superclient/remote/os/win32 -mkdir -p temp/superclient/remote/os/sun -mkdir -p temp/superclient/remote/os/darwin -mkdir -p temp/superclient/utilities/common -mkdir -p temp/superclient/utilities/fbtracemgr -mkdir -p temp/superclient/utilities/gsec -mkdir -p temp/superclient/utilities/gstat -mkdir -p temp/superclient/utilities/guard -mkdir -p temp/superclient/utilities/ibmgr -mkdir -p temp/superclient/utilities/install -mkdir -p temp/superclient/utilities/nbackup -mkdir -p temp/superclient/utilities/rebuild -mkdir -p temp/superclient/utilities/ntrace -mkdir -p temp/superclient/vulcan - -mkdir -p temp/superserver/alice -mkdir -p temp/superserver/auth/trusted -mkdir -p temp/superserver/auth/SecurityDatabase -mkdir -p temp/superserver/burp -mkdir -p temp/superserver/common/classes -mkdir -p temp/superserver/common/config -mkdir -p temp/superserver/config -mkdir -p temp/superserver/dsql -mkdir -p temp/superserver/dudley -mkdir -p temp/superserver/extlib -mkdir -p temp/superserver/extlib/fbudf -mkdir -p temp/superserver/gpre -mkdir -p temp/superserver/intl -mkdir -p temp/superserver/ipserver -mkdir -p temp/superserver/iscguard -mkdir -p temp/superserver/isql -mkdir -p temp/superserver/jrd -mkdir -p temp/superserver/jrd/extds -mkdir -p temp/superserver/jrd/recsrc -mkdir -p temp/superserver/jrd/trace -mkdir -p temp/superserver/jrd/os/posix -mkdir -p temp/superserver/jrd/os/win32 -mkdir -p temp/superserver/jrd/os/darwin -mkdir -p temp/superserver/lock -mkdir -p temp/superserver/misc -mkdir -p temp/superserver/msgs -mkdir -p temp/superserver/plugins/udr_engine -mkdir -p temp/superserver/qli -mkdir -p temp/superserver/remote -mkdir -p temp/superserver/remote/os/win32 -mkdir -p temp/superserver/remote/os/sun -mkdir -p temp/superserver/remote/os/darwin -mkdir -p temp/superserver/utilities/common -mkdir -p temp/superserver/utilities/fbtracemgr -mkdir -p temp/superserver/utilities/gsec -mkdir -p temp/superserver/utilities/gstat -mkdir -p temp/superserver/utilities/guard -mkdir -p temp/superserver/utilities/ibmgr -mkdir -p temp/superserver/utilities/install -mkdir -p temp/superserver/utilities/nbackup -mkdir -p temp/superserver/utilities/rebuild -mkdir -p temp/superserver/utilities/ntrace -mkdir -p temp/superserver/vulcan - -mkdir -p temp/examples/udr - ]) @@ -1212,29 +1069,35 @@ MAKE_SRC_DIR=builds/posix dnl common files for all posix hosts dnl TODO: fix "arch-specific/linux/" paths for common posix scripts with SVN -AC_CONFIG_FILES([gen/firebird/firebird.conf:builds/install/misc/firebird.conf.in -gen/firebird/aliases.conf:builds/install/misc/aliases.conf.in -gen/firebird/fbtrace.conf:src/utilities/ntrace/fbtrace.conf -gen/firebird/intl/fbintl.conf:builds/install/misc/fbintl.conf -gen/firebird/bin/fb_config:builds/install/misc/fb_config.in -gen/firebird/bin/posixLibrary.sh:builds/install/misc/posixLibrary.sh.in -gen/firebird/bin/classicLibrary.sh:builds/install/misc/classicLibrary.sh.in -gen/firebird/bin/superLibrary.sh:builds/install/misc/superLibrary.sh.in -gen/firebird/bin/changeRunUser.sh:builds/install/misc/changeRunUser.sh.in -gen/firebird/bin/restoreRootRunUser.sh:builds/install/misc/restoreRootRunUser.sh.in -gen/firebird/bin/tarMainInstall.sh:builds/install/arch-specific/linux/misc/tarMainInstall.sh.in -gen/firebird/bin/tarinstall.sh:builds/install/arch-specific/linux/misc/tarinstall.sh.in -gen/firebird/bin/preinstall.sh:builds/install/arch-specific/linux/misc/preinstall.sh.in -gen/firebird/bin/postinstall.sh:builds/install/arch-specific/linux/misc/postinstall.sh.in -gen/firebird/bin/preuninstall.sh:builds/install/arch-specific/linux/misc/preuninstall.sh.in -gen/firebird/bin/postuninstall.sh:builds/install/arch-specific/linux/misc/postuninstall.sh.in -gen/firebird/bin/taruninstall.sh:builds/install/arch-specific/linux/misc/taruninstall.sh.in -gen/firebird/bin/tarMainUninstall.sh:builds/install/arch-specific/linux/misc/tarMainUninstall.sh.in +AC_CONFIG_FILES([ +gen/Debug/firebird/firebird.conf:builds/install/misc/firebird.conf.in +gen/Release/firebird/firebird.conf:builds/install/misc/firebird.conf.in +gen/Debug/firebird/aliases.conf:builds/install/misc/aliases.conf.in +gen/Release/firebird/aliases.conf:builds/install/misc/aliases.conf.in +gen/Debug/firebird/fbtrace.conf:src/utilities/ntrace/fbtrace.conf +gen/Release/firebird/fbtrace.conf:src/utilities/ntrace/fbtrace.conf +gen/Debug/firebird/intl/fbintl.conf:builds/install/misc/fbintl.conf +gen/Release/firebird/intl/fbintl.conf:builds/install/misc/fbintl.conf +gen/Release/firebird/bin/fb_config:builds/install/misc/fb_config.in +gen/Release/firebird/bin/posixLibrary.sh:builds/install/misc/posixLibrary.sh.in +gen/Release/firebird/bin/classicLibrary.sh:builds/install/misc/classicLibrary.sh.in +gen/Release/firebird/bin/superLibrary.sh:builds/install/misc/superLibrary.sh.in +gen/Release/firebird/bin/changeRunUser.sh:builds/install/misc/changeRunUser.sh.in +gen/Release/firebird/bin/restoreRootRunUser.sh:builds/install/misc/restoreRootRunUser.sh.in +gen/Release/firebird/bin/tarMainInstall.sh:builds/install/arch-specific/linux/misc/tarMainInstall.sh.in +gen/Release/firebird/bin/tarinstall.sh:builds/install/arch-specific/linux/misc/tarinstall.sh.in +gen/Release/firebird/bin/preinstall.sh:builds/install/arch-specific/linux/misc/preinstall.sh.in +gen/Release/firebird/bin/postinstall.sh:builds/install/arch-specific/linux/misc/postinstall.sh.in +gen/Release/firebird/bin/preuninstall.sh:builds/install/arch-specific/linux/misc/preuninstall.sh.in +gen/Release/firebird/bin/postuninstall.sh:builds/install/arch-specific/linux/misc/postuninstall.sh.in +gen/Release/firebird/bin/taruninstall.sh:builds/install/arch-specific/linux/misc/taruninstall.sh.in +gen/Release/firebird/bin/tarMainUninstall.sh:builds/install/arch-specific/linux/misc/tarMainUninstall.sh.in gen/vers.sh:builds/posix/vers.sh.in -gen/firebird/bin/changeDBAPassword.sh:builds/install/misc/changeDBAPassword.sh.in -gen/firebird/bin/changeMultiConnectMode.sh:builds/install/misc/changeMultiConnectMode.sh.in -gen/firebird/bin/changeGdsLibraryCompatibleLink.sh:builds/install/misc/changeGdsLibraryCompatibleLink.sh.in -gen/firebird/bin/createAliasDB.sh:builds/install/misc/createAliasDB.sh.in], +gen/Release/firebird/bin/changeDBAPassword.sh:builds/install/misc/changeDBAPassword.sh.in +gen/Release/firebird/bin/changeMultiConnectMode.sh:builds/install/misc/changeMultiConnectMode.sh.in +gen/Release/firebird/bin/changeGdsLibraryCompatibleLink.sh:builds/install/misc/changeGdsLibraryCompatibleLink.sh.in +gen/Release/firebird/bin/createAliasDB.sh:builds/install/misc/createAliasDB.sh.in +], [chmod a+x gen/install/scripts/*.sh gen/install/*sh 2>/dev/null]) dnl: Platform Specific Files @@ -1248,19 +1111,21 @@ case "$PLATFORM" in mkdir -p gen/RPM/BUILD]) INSTALL_SRC_DIR=builds/install/arch-specific/linux/${FIREBIRD_ARCH_TYPE} - AC_CONFIG_FILES([gen/install/makeInstallImage.sh:builds/install/arch-specific/linux/misc/makeInstallImage.sh.in - gen/install/scripts/rpmheader.txt:${INSTALL_SRC_DIR}/rpmheader.txt.in - gen/install/scripts/rpmfiles.txt:${INSTALL_SRC_DIR}/rpmfiles.txt.in - gen/install/misc/firebird.xinetd:builds/install/arch-specific/linux/misc/firebird.xinetd.in - gen/install/misc/firebird.init.d.generic:builds/install/arch-specific/linux/misc/firebird.init.d.generic.in - gen/install/misc/firebird.init.d.mandrake:builds/install/arch-specific/linux/misc/firebird.init.d.mandrake.in - gen/install/misc/firebird.init.d.suse:builds/install/arch-specific/linux/misc/firebird.init.d.suse.in - gen/install/misc/firebird.init.d.debian:builds/install/arch-specific/linux/misc/firebird.init.d.debian.in - gen/install/misc/firebird.init.d.gentoo:builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in - gen/install/misc/firebird.init.d.slackware:builds/install/arch-specific/linux/misc/firebird.init.d.slackware.in - gen/install/misc/rc.config.firebird:builds/install/arch-specific/linux/misc/rc.config.firebird.in - gen/firebird/bin/linuxLibrary.sh:builds/install/arch-specific/linux/misc/linuxLibrary.sh.in] - ,[chmod a+x gen/install/scripts/*.sh gen/install/*sh 2>/dev/null]) + AC_CONFIG_FILES([ + gen/install/makeInstallImage.sh:builds/install/arch-specific/linux/misc/makeInstallImage.sh.in + gen/install/scripts/rpmheader.txt:${INSTALL_SRC_DIR}/rpmheader.txt.in + gen/install/scripts/rpmfiles.txt:${INSTALL_SRC_DIR}/rpmfiles.txt.in + gen/install/misc/firebird.xinetd:builds/install/arch-specific/linux/misc/firebird.xinetd.in + gen/install/misc/firebird.init.d.generic:builds/install/arch-specific/linux/misc/firebird.init.d.generic.in + gen/install/misc/firebird.init.d.mandrake:builds/install/arch-specific/linux/misc/firebird.init.d.mandrake.in + gen/install/misc/firebird.init.d.suse:builds/install/arch-specific/linux/misc/firebird.init.d.suse.in + gen/install/misc/firebird.init.d.debian:builds/install/arch-specific/linux/misc/firebird.init.d.debian.in + gen/install/misc/firebird.init.d.gentoo:builds/install/arch-specific/linux/misc/firebird.init.d.gentoo.in + gen/install/misc/firebird.init.d.slackware:builds/install/arch-specific/linux/misc/firebird.init.d.slackware.in + gen/install/misc/rc.config.firebird:builds/install/arch-specific/linux/misc/rc.config.firebird.in + gen/Release/firebird/bin/linuxLibrary.sh:builds/install/arch-specific/linux/misc/linuxLibrary.sh.in + ], + [chmod a+x gen/install/scripts/*.sh gen/install/*sh 2>/dev/null]) ;; HPUX) @@ -1277,10 +1142,7 @@ case "$PLATFORM" in gen/firebird/bin/postUninstall.sh:${HP_INSTALL_SRC_DIR}/postUninstall.sh.in gen/install/misc/firebird.init.d.hpux:builds/install/arch-specific/hpux/misc/firebird.init.d.hpux.in gen/install/misc/rc.config.firebird.hpux:builds/install/arch-specific/hpux/misc/rc.config.firebird.hpux.in - gen/firebird/bin/changedbaPassword.sh:builds/install/arch-specific/hpux/misc/changedbaPassword.sh.in - gen/firebird/bin/changegdslibrarycompatibleLink.sh:builds/install/arch-specific/hpux/misc/changegdslibrarycompatibleLink.sh.in - gen/firebird/bin/hpuxLibrary.sh:builds/install/arch-specific/hpux/misc/hpuxLibrary.sh.in - gen/firebird/bin/createaliasDB.sh:builds/install/arch-specific/hpux/misc/createaliasDB.sh.in], + gen/Release/firebird/bin/hpuxLibrary.sh:builds/install/arch-specific/hpux/misc/hpuxLibrary.sh.in], [chmod a+x gen/install/scripts/*.sh gen/install/*.sh 2>/dev/null]) ;; @@ -1359,41 +1221,9 @@ gen/darwin.defaults:${MAKE_SRC_DIR}/darwin.defaults ${POSTFIX_FILE} gen/make.shared.variables:${MAKE_SRC_DIR}/make.shared.variables gen/make.shared.targets:${MAKE_SRC_DIR}/make.shared.targets -gen/Makefile:${MAKE_SRC_DIR}/Makefile.in.firebird -gen/Makefile.codes:${MAKE_SRC_DIR}/Makefile.in.codes -gen/Makefile.boot.gpre:${MAKE_SRC_DIR}/Makefile.in.boot.gpre -gen/Makefile.libfbstatic:${MAKE_SRC_DIR}/Makefile.in.libfbstatic -gen/Makefile.static.gpre:${MAKE_SRC_DIR}/Makefile.in.static.gpre -gen/Makefile.static.gbak:${MAKE_SRC_DIR}/Makefile.in.static.gbak -gen/Makefile.static.isql:${MAKE_SRC_DIR}/Makefile.in.static.isql -gen/Makefile.refDatabases:${MAKE_SRC_DIR}/Makefile.in.refDatabases -gen/Makefile.fbserver:${MAKE_SRC_DIR}/Makefile.in.fbserver -gen/Makefile.smp_server:${MAKE_SRC_DIR}/Makefile.in.smp_server -gen/Makefile.libfbclient:${MAKE_SRC_DIR}/Makefile.in.libfbclient -gen/Makefile.client.fbudf:${MAKE_SRC_DIR}/Makefile.in.client.fbudf -gen/Makefile.client.gbak:${MAKE_SRC_DIR}/Makefile.in.client.gbak -gen/Makefile.client.gfix:${MAKE_SRC_DIR}/Makefile.in.client.gfix -gen/Makefile.client.qli:${MAKE_SRC_DIR}/Makefile.in.client.qli -gen/Makefile.client.isql:${MAKE_SRC_DIR}/Makefile.in.client.isql -gen/Makefile.client.gpre:${MAKE_SRC_DIR}/Makefile.in.client.gpre -gen/Makefile.client.util:${MAKE_SRC_DIR}/Makefile.in.client.util -gen/Makefile.client.gsec:${MAKE_SRC_DIR}/Makefile.in.client.gsec -gen/Makefile.intl:${MAKE_SRC_DIR}/Makefile.in.intl -gen/Makefile.msgs:${MAKE_SRC_DIR}/Makefile.in.msgs -gen/Makefile.extlib:${MAKE_SRC_DIR}/Makefile.in.extlib -gen/Makefile.plugins:${MAKE_SRC_DIR}/Makefile.in.plugins +gen/Makefile:${MAKE_SRC_DIR}/Makefile.in gen/examples/Makefile.examples:${MAKE_SRC_DIR}/Makefile.in.examples gen/examples/Makefile.plugins_examples:${MAKE_SRC_DIR}/Makefile.in.plugins_examples -gen/Makefile.libfbembed:${MAKE_SRC_DIR}/Makefile.in.libfbembed -gen/Makefile.embed.util:${MAKE_SRC_DIR}/Makefile.in.embed.util -gen/Makefile.embed.fbudf:${MAKE_SRC_DIR}/Makefile.in.embed.fbudf -gen/Makefile.embed.gfix:${MAKE_SRC_DIR}/Makefile.in.embed.gfix -gen/Makefile.embed.gbak:${MAKE_SRC_DIR}/Makefile.in.embed.gbak -gen/Makefile.embed.isql:${MAKE_SRC_DIR}/Makefile.in.embed.isql -gen/Makefile.embed.qli:${MAKE_SRC_DIR}/Makefile.in.embed.qli -gen/Makefile.embed.gpre:${MAKE_SRC_DIR}/Makefile.in.embed.gpre -gen/Makefile.fbtrace:${MAKE_SRC_DIR}/Makefile.in.fbtrace -gen/Makefile.user.management:${MAKE_SRC_DIR}/Makefile.in.user.management gen/Makefile.install:builds/install/arch-specific/${INSTALL_PREFIX}/Makefile.in Makefile:Makefile.in ) diff --git a/lang_helpers/gds_codes.ftn b/lang_helpers/gds_codes.ftn index 1768e8016e..ffa98d038c 100644 --- a/lang_helpers/gds_codes.ftn +++ b/lang_helpers/gds_codes.ftn @@ -1450,6 +1450,8 @@ C -- PARAMETER (GDS__private_function = 335545018) INTEGER*4 GDS__private_procedure PARAMETER (GDS__private_procedure = 335545019) + INTEGER*4 GDS__bad_events_handle + PARAMETER (GDS__bad_events_handle = 335545020) INTEGER*4 GDS__gfix_db_name PARAMETER (GDS__gfix_db_name = 335740929) INTEGER*4 GDS__gfix_invalid_sw diff --git a/lang_helpers/gds_codes.pas b/lang_helpers/gds_codes.pas index 1f6926a32f..3c32624826 100644 --- a/lang_helpers/gds_codes.pas +++ b/lang_helpers/gds_codes.pas @@ -732,6 +732,7 @@ const gds_async_active = 335545017; gds_private_function = 335545018; gds_private_procedure = 335545019; + gds_bad_events_handle = 335545020; gds_gfix_db_name = 335740929; gds_gfix_invalid_sw = 335740930; gds_gfix_incmp_sw = 335740932; diff --git a/src/alice/alice.cpp b/src/alice/alice.cpp index 8cb51e35cf..f876a696fb 100644 --- a/src/alice/alice.cpp +++ b/src/alice/alice.cpp @@ -46,7 +46,7 @@ #include "../alice/alice.h" #include "../alice/exe_proto.h" #include "../jrd/msg_encode.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/svc.h" #include "../alice/alice_proto.h" #include "../common/utils_proto.h" diff --git a/src/alice/alice.h b/src/alice/alice.h index 53fc9d9078..b486d96750 100644 --- a/src/alice/alice.h +++ b/src/alice/alice.h @@ -27,7 +27,7 @@ #include #include "../jrd/ibase.h" -#include "../jrd/ThreadData.h" +#include "../common/ThreadData.h" #include "../include/fb_blk.h" #include "../common/classes/alloc.h" #include "../common/classes/array.h" diff --git a/src/alice/alice_meta.epp b/src/alice/alice_meta.epp index c248333035..8fa2272252 100644 --- a/src/alice/alice_meta.epp +++ b/src/alice/alice_meta.epp @@ -34,7 +34,7 @@ //#include "../jrd/license.h" #include "../alice/alice.h" #include "../alice/alice_meta.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../include/fb_exception.h" #include "../common/classes/alloc.h" #include "../alice/alice_proto.h" diff --git a/src/alice/alice_proto.h b/src/alice/alice_proto.h index 75fe21e2e3..f83693e7e0 100644 --- a/src/alice/alice_proto.h +++ b/src/alice/alice_proto.h @@ -24,7 +24,7 @@ #ifndef ALICE_ALICE_PROTO_H #define ALICE_ALICE_PROTO_H -#include "../jrd/ThreadData.h" +#include "../common/ThreadData.h" #include "../common/classes/MsgPrint.h" #include "../common/UtilSvc.h" diff --git a/src/alice/exe.cpp b/src/alice/exe.cpp index f4f2a6e664..195810eb9b 100644 --- a/src/alice/exe.cpp +++ b/src/alice/exe.cpp @@ -44,7 +44,7 @@ #include "../alice/aliceswi.h" #include "../alice/alice_meta.h" #include "../alice/tdr_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/constants.h" #include "../common/classes/ClumpletWriter.h" diff --git a/src/alice/aliceMain.cpp b/src/alice/main/aliceMain.cpp similarity index 100% rename from src/alice/aliceMain.cpp rename to src/alice/main/aliceMain.cpp diff --git a/src/alice/tdr.cpp b/src/alice/tdr.cpp index d8a94e10f2..ba7217581b 100644 --- a/src/alice/tdr.cpp +++ b/src/alice/tdr.cpp @@ -42,8 +42,8 @@ #include "../alice/alice_proto.h" #include "../alice/alice_meta.h" #include "../alice/tdr_proto.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_proto.h" #include "../jrd/constants.h" #include "../common/classes/ClumpletWriter.h" diff --git a/src/jrd/jrd_pwd.h b/src/auth/SecurityDatabase/jrd_pwd.h similarity index 97% rename from src/jrd/jrd_pwd.h rename to src/auth/SecurityDatabase/jrd_pwd.h index 91d92de399..3d0f7e0f5e 100644 --- a/src/jrd/jrd_pwd.h +++ b/src/auth/SecurityDatabase/jrd_pwd.h @@ -29,7 +29,7 @@ #include "../jrd/ibase.h" #include "../common/utils_proto.h" -#include "../jrd/sha.h" +#include "../common/sha.h" #include "gen/iberror.h" #include "../common/classes/ClumpletWriter.h" @@ -52,7 +52,7 @@ class SecurityDatabase public: static void getPath(char* path_buffer) { - static const char* USER_INFO_NAME = "security2.fdb"; + static const char* USER_INFO_NAME = "security3.fdb"; Firebird::PathName name = fb_utils::getPrefix(fb_utils::FB_DIR_SECDB, USER_INFO_NAME); name.copyTo(path_buffer, MAXPATHLEN); } diff --git a/src/jrd/pwd.cpp b/src/auth/SecurityDatabase/pwd.cpp similarity index 98% rename from src/jrd/pwd.cpp rename to src/auth/SecurityDatabase/pwd.cpp index b07d40cc84..f956b8987b 100644 --- a/src/jrd/pwd.cpp +++ b/src/auth/SecurityDatabase/pwd.cpp @@ -30,11 +30,11 @@ #include "../jrd/common.h" #include "../jrd/ibase.h" #include "../jrd/jrd.h" -#include "../jrd/jrd_pwd.h" -#include "../jrd/enc_proto.h" +#include "../auth/SecurityDatabase/jrd_pwd.h" +#include "../common/enc_proto.h" #include "../jrd/err_proto.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_proto.h" #include "../jrd/thread_proto.h" #include "../jrd/jrd_proto.h" #include "../jrd/scl.h" @@ -50,7 +50,7 @@ namespace { // register plugin #ifndef WIN_NT char name[] = "LEGACY_AUTH"; -PluginHelper server; +PluginHelper server; #endif // temporal implementation of timer @@ -110,7 +110,7 @@ int fb_alloc_timer() if (! active) { active = 1; - gds__thread_start(threadTimer, 0, 0, 0, 0); + Thread::start(threadTimer, 0, 0); fb_shutdown_callback(0, stopTimer, fb_shut_preproviders | fb_shut_finish, 0); } return 1; diff --git a/src/burp/backup.epp b/src/burp/backup.epp index edf09b9aec..5da2615ade 100644 --- a/src/burp/backup.epp +++ b/src/burp/backup.epp @@ -54,7 +54,7 @@ #include "../burp/mvol_proto.h" #include "../remote/protocol.h" #ifdef DEBUG -#include "../gpre/prett_proto.h" +#include "../common/prett_proto.h" #endif #include "../common/classes/UserBlob.h" diff --git a/src/burp/burp.cpp b/src/burp/burp.cpp index 1ba36ce99e..1073e253bd 100644 --- a/src/burp/burp.cpp +++ b/src/burp/burp.cpp @@ -53,7 +53,7 @@ #include "../burp/backu_proto.h" #include "../burp/mvol_proto.h" #include "../burp/resto_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/gdsassert.h" #include "../common/classes/ClumpletWriter.h" #include "../common/classes/Switches.h" diff --git a/src/burp/burp.h b/src/burp/burp.h index 900363f143..e43c4e842d 100644 --- a/src/burp/burp.h +++ b/src/burp/burp.h @@ -32,10 +32,10 @@ #include #include "../jrd/common.h" #include "../jrd/ibase.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../burp/misc_proto.h" -#include "../jrd/gds_proto.h" -#include "../jrd/ThreadData.h" +#include "../yvalve/gds_proto.h" +#include "../common/ThreadData.h" #include "../common/UtilSvc.h" #include "../common/classes/array.h" #include "../common/classes/fb_pair.h" diff --git a/src/burp/burp_proto.h b/src/burp/burp_proto.h index 2d6a40faa2..913fd4531b 100644 --- a/src/burp/burp_proto.h +++ b/src/burp/burp_proto.h @@ -24,7 +24,7 @@ #ifndef BURP_BURP_PROTO_H #define BURP_BURP_PROTO_H -#include "../jrd/ThreadData.h" +#include "../common/ThreadData.h" #include "../common/classes/MsgPrint.h" #include "../common/UtilSvc.h" diff --git a/src/burp/canonical.cpp b/src/burp/canonical.cpp index 218ba8d6f2..b325c135d4 100644 --- a/src/burp/canonical.cpp +++ b/src/burp/canonical.cpp @@ -36,10 +36,10 @@ #endif #include "../burp/burp.h" #include "../jrd/align.h" -#include "../jrd/sdl.h" +#include "../common/sdl.h" #include "../burp/canon_proto.h" -#include "../jrd/sdl_proto.h" -#include "../remote/xdr_proto.h" +#include "../common/sdl_proto.h" +#include "../common/xdr_proto.h" #include "../jrd/gdsassert.h" #include "../include/fb_types.h" diff --git a/src/burp/burpMain.cpp b/src/burp/main/burpMain.cpp similarity index 100% rename from src/burp/burpMain.cpp rename to src/burp/main/burpMain.cpp diff --git a/src/burp/mvol.cpp b/src/burp/mvol.cpp index fea2c1652b..837cd7a0e0 100644 --- a/src/burp/mvol.cpp +++ b/src/burp/mvol.cpp @@ -42,7 +42,7 @@ #include "../burp/burp.h" #include "../burp/burp_proto.h" #include "../burp/mvol_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/gdsassert.h" #include #include diff --git a/src/burp/restore.epp b/src/burp/restore.epp index a9670c61d9..cbe6c08a2a 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -47,7 +47,7 @@ #include "../jrd/constants.h" #include "../remote/protocol.h" #ifdef DEBUG -#include "../gpre/prett_proto.h" +#include "../common/prett_proto.h" #endif #include "../common/classes/ClumpletWriter.h" #include "../common/classes/UserBlob.h" diff --git a/src/burp/spit.cpp b/src/burp/split/spit.cpp similarity index 99% rename from src/burp/spit.cpp rename to src/burp/split/spit.cpp index b9dd066cb7..7c7bd54c93 100644 --- a/src/burp/spit.cpp +++ b/src/burp/split/spit.cpp @@ -46,7 +46,7 @@ # include # endif #endif -#include "../burp/spit.h" +#include "../burp/split/spit.h" #include "../common/classes/Switches.h" #include "../burp/burpswi.h" diff --git a/src/burp/spit.h b/src/burp/split/spit.h similarity index 100% rename from src/burp/spit.h rename to src/burp/split/spit.h diff --git a/src/auth/Auth.cpp b/src/common/Auth.cpp similarity index 98% rename from src/auth/Auth.cpp rename to src/common/Auth.cpp index 8b804ef1a8..b570ef244d 100644 --- a/src/auth/Auth.cpp +++ b/src/common/Auth.cpp @@ -26,7 +26,7 @@ */ #include "firebird.h" -#include "../auth/Auth.h" +#include "../common/Auth.h" #include "../jrd/ibase.h" #include "../common/classes/ImplementHelper.h" diff --git a/src/auth/Auth.h b/src/common/Auth.h similarity index 100% rename from src/auth/Auth.h rename to src/common/Auth.h diff --git a/src/jrd/CharSet.cpp b/src/common/CharSet.cpp similarity index 100% rename from src/jrd/CharSet.cpp rename to src/common/CharSet.cpp diff --git a/src/jrd/CharSet.h b/src/common/CharSet.h similarity index 100% rename from src/jrd/CharSet.h rename to src/common/CharSet.h diff --git a/src/jrd/CsConvert.h b/src/common/CsConvert.h similarity index 100% rename from src/jrd/CsConvert.h rename to src/common/CsConvert.h diff --git a/src/jrd/IntlUtil.cpp b/src/common/IntlUtil.cpp similarity index 99% rename from src/jrd/IntlUtil.cpp rename to src/common/IntlUtil.cpp index 84ddaf9555..a0411dcc77 100644 --- a/src/jrd/IntlUtil.cpp +++ b/src/common/IntlUtil.cpp @@ -25,8 +25,8 @@ */ #include "firebird.h" -#include "../jrd/IntlUtil.h" -#include "../jrd/unicode_util.h" +#include "../common/IntlUtil.h" +#include "../common/unicode_util.h" #include "../jrd/intl_classes.h" #include "../intl/country_codes.h" #include "../common/classes/auto.h" diff --git a/src/jrd/IntlUtil.h b/src/common/IntlUtil.h similarity index 99% rename from src/jrd/IntlUtil.h rename to src/common/IntlUtil.h index 113e1c251d..9e7dd4c3e0 100644 --- a/src/jrd/IntlUtil.h +++ b/src/common/IntlUtil.h @@ -30,7 +30,7 @@ #include "../common/classes/array.h" #include "../common/classes/GenericMap.h" #include "../common/classes/fb_string.h" -#include "../jrd/intlobj_new.h" +#include "../common/intlobj_new.h" namespace Jrd { diff --git a/src/config/ScanDir.cpp b/src/common/ScanDir.cpp similarity index 100% rename from src/config/ScanDir.cpp rename to src/common/ScanDir.cpp diff --git a/src/config/ScanDir.h b/src/common/ScanDir.h similarity index 100% rename from src/config/ScanDir.h rename to src/common/ScanDir.h diff --git a/src/common/StatusArg.cpp b/src/common/StatusArg.cpp index 9c74ab9113..f0a513f721 100644 --- a/src/common/StatusArg.cpp +++ b/src/common/StatusArg.cpp @@ -28,6 +28,7 @@ #include "firebird.h" #include "../common/StatusArg.h" +#include "../common/utils_proto.h" #include "../common/classes/fb_string.h" #include "../common/classes/MetaName.h" @@ -126,25 +127,9 @@ bool StatusVector::ImplStatusVector::append(const ISC_STATUS* const from, const if (!count) return true; // not sure it's the best option here - unsigned int copied = 0; - - for (unsigned int i = 0; i < count; ) - { - if (from[i] == isc_arg_end) - { - break; - } - i += (from[i] == isc_arg_cstring ? 3 : 2); - if (m_length + i > FB_NELEM(m_status_vector) - 1) - { - break; - } - copied = i; - } - - memcpy(&m_status_vector[m_length], from, copied * sizeof(m_status_vector[0])); + unsigned int copied = + fb_utils::copyStatus(&m_status_vector[m_length], FB_NELEM(m_status_vector) - m_length, from, count); m_length += copied; - m_status_vector[m_length] = isc_arg_end; return copied == count; } diff --git a/src/common/StatusHolder.cpp b/src/common/StatusHolder.cpp index 9d7e4a789d..2974fe3f97 100644 --- a/src/common/StatusHolder.cpp +++ b/src/common/StatusHolder.cpp @@ -109,7 +109,7 @@ void StatusHolder::clear() break; } } - memset(m_status_vector, 0, sizeof(m_status_vector)); + fb_utils::init_status(m_status_vector); m_raised = false; } diff --git a/src/common/StatusHolder.h b/src/common/StatusHolder.h index 977253a2cc..38c870a3ef 100644 --- a/src/common/StatusHolder.h +++ b/src/common/StatusHolder.h @@ -29,15 +29,65 @@ #ifndef FB_STATUS_HOLDER #define FB_STATUS_HOLDER +#include "ProviderInterface.h" +#include "../common/utils_proto.h" namespace Firebird { +class BaseStatus : public FbApi::Status +{ +public: + virtual void set(const ISC_STATUS* value) + { + set(fb_utils::statusLength(value), value); + } + + virtual void set(size_t length, const ISC_STATUS* value) + { + fb_utils::copyStatus(vector, FB_NELEM(vector), value, length); + } + + virtual void init() + { + fb_utils::init_status(vector); + } + + virtual const ISC_STATUS* get() const + { + return vector; + } + + virtual int isSuccess() const + { + return vector[1] == 0; + } + +public: + BaseStatus() + { + init(); + } + +private: + ISC_STATUS vector[40]; // FixMe - may be a kind of dynamic storage will be better? +}; + +class LocalStatus : public Firebird::BaseStatus +{ +public: + virtual void release() + { + // do nothing - we are supposed to be on stack or a part of other object + fb_assert(false); + } +}; + class StatusHolder { public: explicit StatusHolder(const ISC_STATUS* status = NULL) { - memset(m_status_vector, 0, sizeof(m_status_vector)); + fb_utils::init_status(m_status_vector); m_raised = false; if (status) @@ -53,10 +103,7 @@ public: ISC_STATUS getError() { - if (m_raised) { - clear(); - } - return m_status_vector[1]; + return value()[1]; } const ISC_STATUS* value() @@ -67,6 +114,11 @@ public: return m_status_vector; } + bool isSuccess() + { + return getError() == 0; + } + private: ISC_STATUS_ARRAY m_status_vector; bool m_raised; diff --git a/src/jrd/TextType.cpp b/src/common/TextType.cpp similarity index 99% rename from src/jrd/TextType.cpp rename to src/common/TextType.cpp index 0e918152c3..b18ed8aaed 100644 --- a/src/jrd/TextType.cpp +++ b/src/common/TextType.cpp @@ -95,7 +95,7 @@ #include "gen/iberror.h" #include "../jrd/jrd.h" #include "../jrd/intl_classes.h" -#include "../jrd/IntlUtil.h" +#include "../common/IntlUtil.h" #include "../common/classes/Aligner.h" diff --git a/src/jrd/TextType.h b/src/common/TextType.h similarity index 100% rename from src/jrd/TextType.h rename to src/common/TextType.h diff --git a/src/jrd/ThreadData.cpp b/src/common/ThreadData.cpp similarity index 96% rename from src/jrd/ThreadData.cpp rename to src/common/ThreadData.cpp index 0ee2c08e06..e1bd571ae3 100644 --- a/src/jrd/ThreadData.cpp +++ b/src/common/ThreadData.cpp @@ -31,9 +31,7 @@ #include #include #include "../jrd/common.h" -#include "../jrd/ThreadData.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_s_proto.h" +#include "../common/ThreadData.h" #include "../jrd/gdsassert.h" #include "../common/classes/fb_tls.h" diff --git a/src/jrd/ThreadData.h b/src/common/ThreadData.h similarity index 100% rename from src/jrd/ThreadData.h rename to src/common/ThreadData.h diff --git a/src/jrd/ThreadStart.cpp b/src/common/ThreadStart.cpp similarity index 84% rename from src/jrd/ThreadStart.cpp rename to src/common/ThreadStart.cpp index bd9466430a..905a2338a7 100644 --- a/src/jrd/ThreadStart.cpp +++ b/src/common/ThreadStart.cpp @@ -31,10 +31,10 @@ #include #include #include "../jrd/common.h" -#include "../jrd/ThreadStart.h" +#include "../common/ThreadStart.h" #include "../jrd/os/thd_priority.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_s_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_s_proto.h" #include "../jrd/gdsassert.h" @@ -51,34 +51,6 @@ #include "../common/classes/rwlock.h" -int API_ROUTINE gds__thread_start(ThreadEntryPoint* entrypoint, - void* arg, - int priority, - int /*flags*/, - void* thd_id) -{ -/************************************** - * - * g d s _ _ t h r e a d _ s t a r t - * - ************************************** - * - * Functional description - * Start a thread. - * - **************************************/ - - int rc = 0; - try { - ThreadStart::start(entrypoint, arg, priority, thd_id); - } - catch (const Firebird::status_exception& status) { - rc = status.value()[1]; - } - return rc; -} - - namespace { @@ -86,7 +58,7 @@ namespace THREAD_ENTRY_DECLARE threadStart(THREAD_ENTRY_PARAM arg) { fb_assert(arg); - Firebird::MemoryPool::setContextPool(getDefaultMemoryPool()); + MemoryPool::setContextPool(getDefaultMemoryPool()); { ThreadPriorityScheduler* tps = static_cast(arg); try { @@ -136,7 +108,7 @@ extern "C" THREAD_ENTRY_DECLARE threadStart(THREAD_ENTRY_PARAM arg) { fb_assert(arg); - Firebird::ContextPoolHolder mainThreadContext(getDefaultMemoryPool()); + MemoryPool::setContextPool(getDefaultMemoryPool()); ThreadArgs localArgs(*static_cast(arg)); delete static_cast(arg); localArgs.run(); @@ -150,7 +122,7 @@ THREAD_ENTRY_DECLARE threadStart(THREAD_ENTRY_PARAM arg) #ifdef USE_POSIX_THREADS #define START_THREAD -void ThreadStart::start(ThreadEntryPoint* routine, void* arg, int priority_arg, void* thd_id) +void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Handle* thd_id) { /************************************** * @@ -222,11 +194,11 @@ void ThreadStart::start(ThreadEntryPoint* routine, void* arg, int priority_arg, if (thd_id) { - *static_cast(thd_id) = thread; + *thd_id = thread; } } -void THD_wait_for_completion(ThreadHandle& thread) +void Thread::waitForCompletion(Handle& thread) { int state = pthread_join(thread, NULL); if (state) @@ -237,7 +209,7 @@ void THD_wait_for_completion(ThreadHandle& thread) #ifdef WIN_NT #define START_THREAD -void ThreadStart::start(ThreadEntryPoint* routine, void* arg, int priority_arg, void* thd_id) +void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Handle* thd_id) { /************************************** * @@ -302,7 +274,7 @@ void ThreadStart::start(ThreadEntryPoint* routine, void* arg, int priority_arg, if (thd_id) { - *static_cast(thd_id) = handle; + *thd_id = handle; } else { @@ -310,7 +282,7 @@ void ThreadStart::start(ThreadEntryPoint* routine, void* arg, int priority_arg, } } -void THD_wait_for_completion(ThreadHandle& handle) +void Thread::waitForCompletion(Handle&) { WaitForSingleObject(handle, INFINITE); } @@ -318,7 +290,7 @@ void THD_wait_for_completion(ThreadHandle& handle) #ifndef START_THREAD -void ThreadStart::start(ThreadEntryPoint* routine, void* arg, int priority_arg, void* thd_id) +void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Handle* thd_id) { /************************************** * @@ -333,7 +305,7 @@ void ThreadStart::start(ThreadEntryPoint* routine, void* arg, int priority_arg, } -void THD_wait_for_completion(ThreadHandle&) +void Thread::waitForCompletion(Handle&) { } #endif // START_THREAD diff --git a/src/jrd/ThreadStart.h b/src/common/ThreadStart.h similarity index 81% rename from src/jrd/ThreadStart.h rename to src/common/ThreadStart.h index 573309b53b..b420cc5cbd 100644 --- a/src/jrd/ThreadStart.h +++ b/src/common/ThreadStart.h @@ -31,7 +31,7 @@ #define JRD_THREADSTART_H #include "firebird.h" -#include "../jrd/ThreadData.h" +#include "../common/ThreadData.h" // Thread priorities (may be ignored) @@ -50,25 +50,20 @@ const int THREAD_critical = 6; // The definition inside the thdd class should be replaced with the following one. typedef THREAD_ENTRY_DECLARE ThreadEntryPoint(THREAD_ENTRY_PARAM); -class ThreadStart : public ThreadData +class Thread : public ThreadData { public: - explicit ThreadStart(ThreadData::ThreadDataType t) : ThreadData(t) { } - - static void start(ThreadEntryPoint* routine, void* arg, int priority_arg, void* thd_id); -}; - -extern "C" { - int API_ROUTINE gds__thread_start(ThreadEntryPoint*, void*, int, int, void*); -} + explicit Thread(ThreadData::ThreadDataType t) : ThreadData(t) { } #ifdef WIN_NT -typedef HANDLE ThreadHandle; + typedef HANDLE Handle; #endif #ifdef USE_POSIX_THREADS -typedef pthread_t ThreadHandle; + typedef pthread_t Handle; #endif -void THD_wait_for_completion(ThreadHandle& handle); + static void start(ThreadEntryPoint* routine, void* arg, int priority_arg, Handle* thd_id = NULL); + static void waitForCompletion(Handle& handle); +}; #endif // JRD_THREADSTART_H diff --git a/src/utilities/gsec/call_service.cpp b/src/common/call_service.cpp similarity index 99% rename from src/utilities/gsec/call_service.cpp rename to src/common/call_service.cpp index 2096efcc4f..c1db4324ee 100644 --- a/src/utilities/gsec/call_service.cpp +++ b/src/common/call_service.cpp @@ -23,7 +23,7 @@ #include "firebird.h" #include "../jrd/common.h" -#include "../utilities/gsec/call_service.h" +#include "../common/call_service.h" #include "../common/classes/ClumpletWriter.h" #include #include @@ -419,7 +419,7 @@ void callRemoteServiceManager(ISC_STATUS* status, ISC_STATUS_ARRAY temp_status; ISC_STATUS* local_status = status[1] ? temp_status : status; - memset(local_status, 0, sizeof(ISC_STATUS_ARRAY)); + fb_utils::init_status(local_status); if (userInfo.operation == DIS_OPER || userInfo.operation == OLD_DIS_OPER) { diff --git a/src/utilities/gsec/call_service.h b/src/common/call_service.h similarity index 100% rename from src/utilities/gsec/call_service.h rename to src/common/call_service.h diff --git a/src/gpre/cdbtable.h b/src/common/cdbtable.h similarity index 100% rename from src/gpre/cdbtable.h rename to src/common/cdbtable.h diff --git a/src/common/classes/ClumpletReader.cpp b/src/common/classes/ClumpletReader.cpp index f193d886a9..19bb81626c 100644 --- a/src/common/classes/ClumpletReader.cpp +++ b/src/common/classes/ClumpletReader.cpp @@ -34,7 +34,7 @@ #include "../jrd/ibase.h" #ifdef DEBUG_CLUMPLETS -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include namespace Firebird { diff --git a/src/common/classes/ImplementHelper.h b/src/common/classes/ImplementHelper.h index 33b1be106a..d010763f37 100644 --- a/src/common/classes/ImplementHelper.h +++ b/src/common/classes/ImplementHelper.h @@ -31,7 +31,7 @@ #include "../common/classes/Interface.h" -//#include "../jrd/gds_proto.h" +//#include "../yvalve/gds_proto.h" #include "../common/classes/alloc.h" namespace Firebird { @@ -71,7 +71,7 @@ void interfaceFree(T* ptr) } // Template to create static instance of plugin -template +template class PluginHelper : public C { public: @@ -90,18 +90,23 @@ public: return T; } + virtual unsigned int priority() const + { + return P; + } + virtual void link(Plugin* chain) { - pp = chain; + plug = chain; } virtual Plugin* next() const { - return pp; + return plug; } private: - Plugin* pp; + Plugin* plug; }; } // namespace Firebird diff --git a/src/common/classes/Interface.h b/src/common/classes/Interface.h index e673d9289c..132416435a 100644 --- a/src/common/classes/Interface.h +++ b/src/common/classes/Interface.h @@ -49,16 +49,17 @@ class Plugin public: virtual const char* name() const = 0; virtual unsigned int type() const = 0; + virtual unsigned int priority() const = 0; virtual void link(Plugin* chain) = 0; virtual Plugin* next() const = 0; -// static const unsigned int YValve = 1; -// static const unsigned int Engine = 2; -// static const unsigned int Redirector = 3; - static const unsigned int AuthServer = 4; - static const unsigned int AuthClient = 5; - static const unsigned int UserManagement = 6; + static const unsigned int YValve = 1; + static const unsigned int Provider = 2; + // leave space for may be some more super-std plugins + static const unsigned int AuthServer = 11; + static const unsigned int AuthClient = 12; + static const unsigned int UserManagement = 13; }; } // namespace Firebird diff --git a/src/common/classes/MsgPrint.cpp b/src/common/classes/MsgPrint.cpp index ccb81a8a44..16437a0deb 100644 --- a/src/common/classes/MsgPrint.cpp +++ b/src/common/classes/MsgPrint.cpp @@ -29,7 +29,7 @@ #include "BaseStream.h" #include "MsgPrint.h" #include -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../common/utils_proto.h" #include "../jrd/file_params.h" diff --git a/src/common/classes/TempFile.cpp b/src/common/classes/TempFile.cpp index cda57a2f62..0b145f00a4 100644 --- a/src/common/classes/TempFile.cpp +++ b/src/common/classes/TempFile.cpp @@ -45,7 +45,7 @@ #endif #include "../jrd/gdsassert.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #include "../common/classes/init.h" #include "../common/classes/TempFile.h" diff --git a/src/common/classes/UserBlob.cpp b/src/common/classes/UserBlob.cpp index fbe234f162..167f40abf7 100644 --- a/src/common/classes/UserBlob.cpp +++ b/src/common/classes/UserBlob.cpp @@ -24,7 +24,7 @@ #include "UserBlob.h" #include "../jrd/ibase.h" #include "../jrd/common.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" static const USHORT SEGMENT_LIMIT = 65535; //static SLONG fb_vax_integer(const UCHAR* ptr, int length); diff --git a/src/common/classes/alloc.cpp b/src/common/classes/alloc.cpp index 762b658f25..0bf3712331 100644 --- a/src/common/classes/alloc.cpp +++ b/src/common/classes/alloc.cpp @@ -144,12 +144,21 @@ void MemoryPool::cleanup() VALGRIND_MAKE_MEM_DEFINED(defaultMemoryManager, sizeof(MemoryPool))); #endif - defaultMemoryManager->~MemoryPool(); - defaultMemoryManager = NULL; - default_stats_group->~MemoryStats(); - default_stats_group = NULL; - cache_mutex->~Mutex(); - cache_mutex = NULL; + if (defaultMemoryManager) + { + defaultMemoryManager->~MemoryPool(); + defaultMemoryManager = NULL; + } + if (default_stats_group) + { + default_stats_group->~MemoryStats(); + default_stats_group = NULL; + } + if (cache_mutex) + { + cache_mutex->~Mutex(); + cache_mutex = NULL; + } } MemoryPool::MemoryPool(MemoryStats& s, bool shared, int rounding, int cutoff, int minAlloc) diff --git a/src/common/classes/class_perf.cpp b/src/common/classes/misc/class_perf.cpp similarity index 100% rename from src/common/classes/class_perf.cpp rename to src/common/classes/misc/class_perf.cpp diff --git a/src/common/classes/class_test.cpp b/src/common/classes/misc/class_test.cpp similarity index 100% rename from src/common/classes/class_test.cpp rename to src/common/classes/misc/class_test.cpp diff --git a/src/common/classes/string_test.cmd b/src/common/classes/misc/string_test.cmd similarity index 100% rename from src/common/classes/string_test.cmd rename to src/common/classes/misc/string_test.cmd diff --git a/src/common/classes/string_test.cpp b/src/common/classes/misc/string_test.cpp similarity index 100% rename from src/common/classes/string_test.cpp rename to src/common/classes/misc/string_test.cpp diff --git a/src/common/classes/test.sh b/src/common/classes/misc/test.sh similarity index 100% rename from src/common/classes/test.sh rename to src/common/classes/misc/test.sh diff --git a/src/common/classes/timestamp.h b/src/common/classes/timestamp.h index 15d12f3df4..014940255d 100644 --- a/src/common/classes/timestamp.h +++ b/src/common/classes/timestamp.h @@ -27,7 +27,7 @@ #ifndef CLASSES_TIMESTAMP_H #define CLASSES_TIMESTAMP_H -#include "../jrd/dsc.h" +#include "../common/dsc.h" // struct tm declaration #if defined(TIME_WITH_SYS_TIME) diff --git a/src/common/config/config.cpp b/src/common/config/config.cpp index 8b4eacc699..5bef36d46e 100644 --- a/src/common/config/config.cpp +++ b/src/common/config/config.cpp @@ -24,10 +24,10 @@ #include "../common/config/config.h" #include "../common/config/config_file.h" -#include "../jrd/os/config_root.h" +#include "../common/config/os/config_root.h" #include "../common/classes/init.h" #include "../common/dllinst.h" -#include "../jrd/os/fbsyslog.h" +#include "../common/os/fbsyslog.h" #ifdef HAVE_STDLIB_H #include diff --git a/src/common/config/config_file.cpp b/src/common/config/config_file.cpp index df6bdcc8e5..ca04952322 100644 --- a/src/common/config/config_file.cpp +++ b/src/common/config/config_file.cpp @@ -26,7 +26,7 @@ #include "../common/classes/auto.h" #include "../common/config/config_file.h" #include "../common/config/config.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #include #ifdef HAVE_STDLIB_H diff --git a/src/common/config/config_file.h b/src/common/config/config_file.h index 3e1cf62a7c..4244cda00e 100644 --- a/src/common/config/config_file.h +++ b/src/common/config/config_file.h @@ -43,7 +43,7 @@ hash-mark) are ignored as well. Now this implementation is used by generic configuration manager - (common/config/config.cpp) and server-side alias manager (jrd/db_alias.cpp). + (common/config/config.cpp) and server-side alias manager (common/db_alias.cpp). **/ class ConfigFile : public Firebird::AutoStorage, public Firebird::RefCounted diff --git a/src/common/config/dir_list.cpp b/src/common/config/dir_list.cpp index 358bb94448..2504069b12 100644 --- a/src/common/config/dir_list.cpp +++ b/src/common/config/dir_list.cpp @@ -22,8 +22,8 @@ #include "firebird.h" #include "../common/config/config.h" #include "../common/config/dir_list.h" -#include "../jrd/os/path_utils.h" -#include "../jrd/gds_proto.h" +#include "../common/os/path_utils.h" +#include "../yvalve/gds_proto.h" #include "../jrd/TempSpace.h" #include "../common/utils_proto.h" diff --git a/src/jrd/os/config_root.h b/src/common/config/os/config_root.h similarity index 98% rename from src/jrd/os/config_root.h rename to src/common/config/os/config_root.h index b561803ec5..e7092da9b0 100644 --- a/src/jrd/os/config_root.h +++ b/src/common/config/os/config_root.h @@ -31,7 +31,7 @@ #include "../common/classes/fb_string.h" #include "../common/config/config.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #include "../common/utils_proto.h" /** diff --git a/src/jrd/os/darwin/config_root.cpp b/src/common/config/os/darwin/config_root.cpp similarity index 97% rename from src/jrd/os/darwin/config_root.cpp rename to src/common/config/os/darwin/config_root.cpp index 7b677c83e3..413fca30a7 100644 --- a/src/jrd/os/darwin/config_root.cpp +++ b/src/common/config/os/darwin/config_root.cpp @@ -34,8 +34,8 @@ #include "fb_types.h" #include "../common/classes/fb_string.h" -#include "../jrd/os/config_root.h" -#include "../jrd/os/path_utils.h" +#include "../common/config/os/config_root.h" +#include "../common/os/path_utils.h" #include "../jrd/file_params.h" #include diff --git a/extern/binreloc/binreloc.c b/src/common/config/os/posix/binreloc.c similarity index 100% rename from extern/binreloc/binreloc.c rename to src/common/config/os/posix/binreloc.c diff --git a/extern/binreloc/binreloc.h b/src/common/config/os/posix/binreloc.h similarity index 100% rename from extern/binreloc/binreloc.h rename to src/common/config/os/posix/binreloc.h diff --git a/src/jrd/os/posix/config_root.cpp b/src/common/config/os/posix/config_root.cpp similarity index 94% rename from src/jrd/os/posix/config_root.cpp rename to src/common/config/os/posix/config_root.cpp index 259760fcc1..e4ad18a07b 100644 --- a/src/jrd/os/posix/config_root.cpp +++ b/src/common/config/os/posix/config_root.cpp @@ -31,9 +31,9 @@ #include "fb_types.h" #include "../common/classes/fb_string.h" -#include "../jrd/os/config_root.h" -#include "../jrd/os/path_utils.h" -#include "../../extern/binreloc/binreloc.h" +#include "../common/config/os/config_root.h" +#include "../common/os/path_utils.h" +#include "binreloc.h" typedef Firebird::PathName string; diff --git a/src/jrd/os/win32/config_root.cpp b/src/common/config/os/win32/config_root.cpp similarity index 98% rename from src/jrd/os/win32/config_root.cpp rename to src/common/config/os/win32/config_root.cpp index 3e523e6a02..237f60a716 100644 --- a/src/jrd/os/win32/config_root.cpp +++ b/src/common/config/os/win32/config_root.cpp @@ -29,7 +29,7 @@ #include "../../../common/classes/fb_string.h" #include "../../../common/dllinst.h" -#include "../jrd/os/config_root.h" +#include "../common/config/os/config_root.h" using Firebird::PathName; diff --git a/src/common/cvt.cpp b/src/common/cvt.cpp index 5f71b6e435..54f6c68953 100644 --- a/src/common/cvt.cpp +++ b/src/common/cvt.cpp @@ -46,11 +46,11 @@ #include "../common/classes/timestamp.h" #include "../common/cvt.h" #include "../jrd/intl.h" -#include "../jrd/quad.h" +#include "../common/quad.h" #include "../jrd/val.h" #include "../common/classes/VaryStr.h" #include "../common/classes/FpeControl.h" -#include "../jrd/dsc_proto.h" +#include "../common/dsc_proto.h" #include "../common/utils_proto.h" @@ -154,10 +154,6 @@ static const SQUAD quad_max_int = { SLONG_MAX, -1 }; #endif -#if !defined (NATIVE_QUAD) -#include "../jrd/quad.cpp" -#endif - static const double eps_double = 1e-14; static const double eps_float = 1e-5; diff --git a/src/jrd/db_alias.cpp b/src/common/db_alias.cpp similarity index 98% rename from src/jrd/db_alias.cpp rename to src/common/db_alias.cpp index 91c96163fa..f5fb6fd187 100644 --- a/src/jrd/db_alias.cpp +++ b/src/common/db_alias.cpp @@ -26,10 +26,9 @@ #include "../common/config/config_file.h" #include "../common/config/ConfigCache.h" #include "../common/config/dir_list.h" -#include "../jrd/os/path_utils.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_proto.h" -#include "../jrd/Database.h" +#include "../common/os/path_utils.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_proto.h" #include "../common/utils_proto.h" #include "../common/classes/Hash.h" #include diff --git a/src/jrd/db_alias.h b/src/common/db_alias.h similarity index 100% rename from src/jrd/db_alias.h rename to src/common/db_alias.h diff --git a/src/jrd/dsc.cpp b/src/common/dsc.cpp similarity index 99% rename from src/jrd/dsc.cpp rename to src/common/dsc.cpp index 7338c66acf..9e78e313d8 100644 --- a/src/jrd/dsc.cpp +++ b/src/common/dsc.cpp @@ -27,12 +27,12 @@ #include #include #include "../jrd/common.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../jrd/ibase.h" #include "../jrd/intl.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/gdsassert.h" -#include "../jrd/dsc_proto.h" +#include "../common/dsc_proto.h" // When converting non-text values to text, how many bytes to allocate diff --git a/src/jrd/dsc.h b/src/common/dsc.h similarity index 99% rename from src/jrd/dsc.h rename to src/common/dsc.h index 2368f1a014..b504d0f270 100644 --- a/src/jrd/dsc.h +++ b/src/common/dsc.h @@ -27,7 +27,7 @@ #ifndef JRD_DSC_H #define JRD_DSC_H -#include "../jrd/dsc_pub.h" +#include "../common/dsc_pub.h" #include "consts_pub.h" #include "../jrd/ods.h" #include "../intl/charsets.h" diff --git a/src/jrd/dsc_proto.h b/src/common/dsc_proto.h similarity index 98% rename from src/jrd/dsc_proto.h rename to src/common/dsc_proto.h index 2cd2106d6c..1664edabed 100644 --- a/src/jrd/dsc_proto.h +++ b/src/common/dsc_proto.h @@ -24,7 +24,7 @@ #ifndef JRD_DSC_PROTO_H #define JRD_DSC_PROTO_H -#include "../jrd/dsc.h" +#include "../common/dsc.h" int DSC_string_length(const struct dsc*); const TEXT* DSC_dtype_tostring(UCHAR); diff --git a/src/jrd/dsc_pub.h b/src/common/dsc_pub.h similarity index 100% rename from src/jrd/dsc_pub.h rename to src/common/dsc_pub.h diff --git a/src/gpre/dyntable.h b/src/common/dyntable.h similarity index 100% rename from src/gpre/dyntable.h rename to src/common/dyntable.h diff --git a/src/jrd/enc.cpp b/src/common/enc.cpp similarity index 99% rename from src/jrd/enc.cpp rename to src/common/enc.cpp index 011ac23bff..38c831b64c 100644 --- a/src/jrd/enc.cpp +++ b/src/common/enc.cpp @@ -7,7 +7,7 @@ #include "firebird.h" #include "../jrd/common.h" -#include "../jrd/enc_proto.h" +#include "../common/enc_proto.h" #include "../jrd/gdsassert.h" #include "../common/classes/locks.h" #include "../common/classes/alloc.h" diff --git a/src/jrd/enc_proto.h b/src/common/enc_proto.h similarity index 100% rename from src/jrd/enc_proto.h rename to src/common/enc_proto.h diff --git a/src/common/fb_exception.cpp b/src/common/fb_exception.cpp index 367e933154..77ee4fdd18 100644 --- a/src/common/fb_exception.cpp +++ b/src/common/fb_exception.cpp @@ -1,6 +1,6 @@ #include "firebird.h" -//#include "fb_exception.h" +#include "ProviderInterface.h" #include #include @@ -10,6 +10,7 @@ #include "../common/classes/init.h" #include "../common/classes/array.h" #include "../common/thd.h" +#include "../common/utils_proto.h" #ifdef WIN_NT #include @@ -204,7 +205,9 @@ void makePermanentVector(ISC_STATUS* perm, const ISC_STATUS* trans, FB_THREAD_ID } catch (const BadAlloc& ex) { - ex.stuff_exception(perm); + *perm++ = isc_arg_gds; + *perm++ = isc_virmemexh; + *perm++ = isc_arg_end; } catch (...) { @@ -225,6 +228,17 @@ void makePermanentVector(ISC_STATUS* v, FB_THREAD_ID thr) throw() Exception::~Exception() throw() { } +ISC_STATUS Exception::stuff_exception(ISC_STATUS* const status_vector) const throw() +{ + FbApi::Status* status = FbApi::fb_get_status_instance(); + stuffException(status); + const ISC_STATUS* s = status->get(); + fb_utils::copyStatus(status_vector, ISC_STATUS_LENGTH, s, fb_utils::statusLength(s)); + status->release(); + + return status_vector[1]; +} + // ********************************* status_exception ******************************* status_exception::status_exception() throw() @@ -268,23 +282,14 @@ void status_exception::raise(const Arg::StatusVector& statusVector) throw status_exception(statusVector.value()); } -ISC_STATUS status_exception::stuff_exception(ISC_STATUS* const status_vector) const throw() +ISC_STATUS status_exception::stuffException(FbApi::Status* status) const throw() { - const ISC_STATUS *ptr = value(); - ISC_STATUS *sv = status_vector; - - // Copy status vector - while (true) + if (status) { - const ISC_STATUS type = *sv++ = *ptr++; - if (type == isc_arg_end) - break; - if (type == isc_arg_cstring) - *sv++ = *ptr++; - *sv++ = *ptr++; + status->set(value()); } - return status_vector[1]; + return value()[1]; } // ********************************* BadAlloc **************************** @@ -294,15 +299,16 @@ void BadAlloc::raise() throw BadAlloc(); } -ISC_STATUS BadAlloc::stuff_exception(ISC_STATUS* const status_vector) const throw() +ISC_STATUS BadAlloc::stuffException(FbApi::Status* status) const throw() { - ISC_STATUS *sv = status_vector; + const ISC_STATUS sv[] = {isc_arg_gds, isc_virmemexh}; - *sv++ = isc_arg_gds; - *sv++ = isc_virmemexh; - *sv++ = isc_arg_end; + if (status) + { + status->set(FB_NELEM(sv), sv); + } - return status_vector[1]; + return sv[1]; } const char* BadAlloc::what() const throw() @@ -317,24 +323,16 @@ void LongJump::raise() throw LongJump(); } -ISC_STATUS LongJump::stuff_exception(ISC_STATUS* const status_vector) const throw() +ISC_STATUS LongJump::stuffException(FbApi::Status* status) const throw() { - /* - * Do nothing for a while - not all utilities are ready, - * status_vector is passed in them by other means. - * Ideally status_exception should be always used for it, - * and we should activate the following code: + ISC_STATUS sv[] = {isc_arg_gds, isc_random, isc_arg_string, (ISC_STATUS)(IPTR)"Unexpected Firebird::LongJump"}; - ISC_STATUS *sv = status_vector; + if (status) + { + status->set(FB_NELEM(sv), sv); + } - *sv++ = isc_arg_gds; - *sv++ = isc_random; - *sv++ = isc_arg_string; - *sv++ = (ISC_STATUS)(IPTR) "Unexpected Firebird::LongJump"; - *sv++ = isc_arg_end; - */ - - return status_vector[1]; + return sv[1]; } const char* LongJump::what() const throw() @@ -445,4 +443,9 @@ ISC_STATUS stuff_exception(ISC_STATUS *status_vector, const Firebird::Exception& return ex.stuff_exception(status_vector); } +ISC_STATUS stuff_exception(FbApi::Status *status, const Firebird::Exception& ex) throw() +{ + return ex.stuffException(status); +} + } // namespace Firebird diff --git a/src/jrd/intlobj_new.h b/src/common/intlobj_new.h similarity index 100% rename from src/jrd/intlobj_new.h rename to src/common/intlobj_new.h diff --git a/src/jrd/isc.cpp b/src/common/isc.cpp similarity index 99% rename from src/jrd/isc.cpp rename to src/common/isc.cpp index 073ef41b9c..1077900d64 100644 --- a/src/jrd/isc.cpp +++ b/src/common/isc.cpp @@ -45,8 +45,8 @@ #include "../jrd/ibase.h" #include "../jrd/jrd.h" #include "../jrd/scl.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_proto.h" #include "../jrd/jrd_proto.h" #include "../common/classes/init.h" diff --git a/src/jrd/isc_f_proto.h b/src/common/isc_f_proto.h similarity index 100% rename from src/jrd/isc_f_proto.h rename to src/common/isc_f_proto.h diff --git a/src/jrd/isc_file.cpp b/src/common/isc_file.cpp similarity index 99% rename from src/jrd/isc_file.cpp rename to src/common/isc_file.cpp index 4c3c5aee2f..07c8fd40d4 100644 --- a/src/jrd/isc_file.cpp +++ b/src/common/isc_file.cpp @@ -49,15 +49,15 @@ #include "../jrd/common.h" #include "gen/iberror.h" #include "../jrd/jrd.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_proto.h" -#include "../jrd/isc_f_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_proto.h" +#include "../common/isc_f_proto.h" #include "../jrd/jrd_proto.h" #include "../common/config/config.h" #include "../common/config/dir_list.h" #include "../common/classes/init.h" #include "../common/utils_proto.h" -#include "../jrd/os/os_utils.h" +#include "../common/os/os_utils.h" #include #ifdef HAVE_SYS_IPC_H diff --git a/src/jrd/isc_proto.h b/src/common/isc_proto.h similarity index 100% rename from src/jrd/isc_proto.h rename to src/common/isc_proto.h diff --git a/src/jrd/isc_s_proto.h b/src/common/isc_s_proto.h similarity index 100% rename from src/jrd/isc_s_proto.h rename to src/common/isc_s_proto.h diff --git a/src/jrd/isc_sync.cpp b/src/common/isc_sync.cpp similarity index 99% rename from src/jrd/isc_sync.cpp rename to src/common/isc_sync.cpp index a36a44767d..e6e1e94014 100644 --- a/src/jrd/isc_sync.cpp +++ b/src/common/isc_sync.cpp @@ -50,24 +50,20 @@ #include #endif -//#include "../common/classes/timestamp.h" #include "../jrd/common.h" #include "gen/iberror.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_proto.h" -#include "../jrd/os/isc_i_proto.h" -#include "../jrd/os/os_utils.h" -#include "../jrd/isc_s_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_proto.h" +#include "../common/os/isc_i_proto.h" +#include "../common/os/os_utils.h" +#include "../common/isc_s_proto.h" #include "../jrd/file_params.h" #include "../jrd/gdsassert.h" -#include "../jrd/jrd.h" -#include "../jrd/err_proto.h" -#include "../jrd/thread_proto.h" #include "../common/classes/fb_tls.h" #include "../common/config/config.h" #include "../common/utils_proto.h" #include "../common/StatusArg.h" -#include "../jrd/jrd_pwd.h" +#include "../auth/SecurityDatabase/jrd_pwd.h" #ifdef UNIX #include diff --git a/src/jrd/os/darwin/mod_loader.cpp b/src/common/os/darwin/mod_loader.cpp similarity index 99% rename from src/jrd/os/darwin/mod_loader.cpp rename to src/common/os/darwin/mod_loader.cpp index d9f7d4c89d..e3f0545f29 100644 --- a/src/jrd/os/darwin/mod_loader.cpp +++ b/src/common/os/darwin/mod_loader.cpp @@ -27,7 +27,7 @@ #include "firebird.h" -#include "../jrd/os/mod_loader.h" +#include "../common/os/mod_loader.h" #include "../../common.h" #include #include diff --git a/src/jrd/divorce.h b/src/common/os/divorce.h similarity index 100% rename from src/jrd/divorce.h rename to src/common/os/divorce.h diff --git a/src/jrd/os/fbsyslog.h b/src/common/os/fbsyslog.h similarity index 100% rename from src/jrd/os/fbsyslog.h rename to src/common/os/fbsyslog.h diff --git a/src/jrd/os/guid.h b/src/common/os/guid.h similarity index 100% rename from src/jrd/os/guid.h rename to src/common/os/guid.h diff --git a/src/jrd/os/isc_i_proto.h b/src/common/os/isc_i_proto.h similarity index 100% rename from src/jrd/os/isc_i_proto.h rename to src/common/os/isc_i_proto.h diff --git a/src/jrd/os/mod_loader.h b/src/common/os/mod_loader.h similarity index 100% rename from src/jrd/os/mod_loader.h rename to src/common/os/mod_loader.h diff --git a/src/jrd/os/os_utils.h b/src/common/os/os_utils.h similarity index 100% rename from src/jrd/os/os_utils.h rename to src/common/os/os_utils.h diff --git a/src/jrd/os/path_utils.h b/src/common/os/path_utils.h similarity index 100% rename from src/jrd/os/path_utils.h rename to src/common/os/path_utils.h diff --git a/src/jrd/divorce.cpp b/src/common/os/posix/divorce.cpp similarity index 98% rename from src/jrd/divorce.cpp rename to src/common/os/posix/divorce.cpp index 6300f5e3fc..8e23f2b6df 100644 --- a/src/jrd/divorce.cpp +++ b/src/common/os/posix/divorce.cpp @@ -51,7 +51,7 @@ #include "firebird.h" #include "../jrd/common.h" -#include "../jrd/divorce.h" +#include "../common/os/divorce.h" #include "../common/classes/semaphore.h" #ifdef HAVE_IO_H diff --git a/src/jrd/os/posix/fbsyslog.cpp b/src/common/os/posix/fbsyslog.cpp similarity index 97% rename from src/jrd/os/posix/fbsyslog.cpp rename to src/common/os/posix/fbsyslog.cpp index 1aa252df1a..fd33219b91 100644 --- a/src/jrd/os/posix/fbsyslog.cpp +++ b/src/common/os/posix/fbsyslog.cpp @@ -20,7 +20,7 @@ */ #include "firebird.h" -#include "../jrd/os/fbsyslog.h" +#include "../common/os/fbsyslog.h" #include #include diff --git a/src/jrd/os/posix/guid.cpp b/src/common/os/posix/guid.cpp similarity index 98% rename from src/jrd/os/posix/guid.cpp rename to src/common/os/posix/guid.cpp index dd95bd9c20..7c96e5d6e5 100644 --- a/src/jrd/os/posix/guid.cpp +++ b/src/common/os/posix/guid.cpp @@ -27,7 +27,7 @@ */ #include "firebird.h" -#include "../jrd/os/guid.h" +#include "../common/os/guid.h" #include "fb_exception.h" #include diff --git a/src/jrd/os/posix/isc_ipc.cpp b/src/common/os/posix/isc_ipc.cpp similarity index 85% rename from src/jrd/os/posix/isc_ipc.cpp rename to src/common/os/posix/isc_ipc.cpp index 8b3e7f9406..446db846c9 100644 --- a/src/jrd/os/posix/isc_ipc.cpp +++ b/src/common/os/posix/isc_ipc.cpp @@ -42,10 +42,10 @@ #include "../jrd/gdsassert.h" #include "../jrd/common.h" #include "gen/iberror.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_proto.h" -#include "../jrd/os/isc_i_proto.h" -#include "../jrd/isc_s_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_proto.h" +#include "../common/os/isc_i_proto.h" +#include "../common/isc_s_proto.h" #include "../common/classes/locks.h" #include "../common/classes/init.h" @@ -110,17 +110,37 @@ const USHORT SIG_informs = 2; // routine tells us whether to chain const SLONG SIG_informs_continue = 0; // continue on signal processing const SLONG SIG_informs_stop = 1; // stop signal processing -static SIG volatile signals = NULL; -static SLONG volatile overflow_count = 0; +namespace { + SIG volatile signals = NULL; + volatile bool sigActive = false; -static Firebird::GlobalPtr sig_mutex; + class SignalMutex + { + public: + Firebird::Mutex mutex; -const char* GDS_RELAY = "/bin/gds_relay"; + explicit SignalMutex(Firebird::MemoryPool&) + { + sigActive = true; + } + ~SignalMutex() + { + Firebird::MutexLockGuard guard(mutex); + sigActive = false; -static int volatile relay_pipe = 0; + for (SIG sig = signals; sig;) + { + SIG sig2 = sig; + sig = sig->sig_next; + gds__free(sig2); + } + signals = NULL; + } + }; + Firebird::GlobalPtr sigMutex; +} -static void signal_cleanup(void* arg); static bool isc_signal2(int signal, FPTR_VOID handler, void* arg, ULONG); static SIG que_signal(int signal, FPTR_VOID handler, void* arg, int flags, bool w_siginfo); @@ -148,12 +168,13 @@ bool ISC_signal(int signal_number, FPTR_VOID_PTR handler, void* arg) * Multiplex multiple handers into single signal. * **************************************/ - ISC_signal_init(); - return isc_signal2(signal_number, reinterpret_cast(handler), arg, SIG_user); } +void ISC_signal_init() { } + + static bool isc_signal2(int signal_number, FPTR_VOID handler, void* arg, ULONG flags) { /************************************** @@ -167,9 +188,12 @@ static bool isc_signal2(int signal_number, FPTR_VOID handler, void* arg, ULONG f * **************************************/ + if (!sigActive) + return false; + SIG sig; - Firebird::MutexLockGuard guard(sig_mutex); + Firebird::MutexLockGuard guard(sigMutex->mutex); // See if this signal has ever been cared about before @@ -229,12 +253,14 @@ void ISC_signal_cancel(int signal_number, FPTR_VOID_PTR handler, void* arg) * If handler == NULL, cancel all handlers for a given signal. * **************************************/ - ISC_signal_init(); + + if (!sigActive) + return; SIG sig; volatile SIG* ptr; - Firebird::MutexLockGuard guard(sig_mutex); + Firebird::MutexLockGuard guard(sigMutex->mutex); for (ptr = &signals; sig = *ptr;) { if (sig->sig_signal == signal_number && @@ -250,61 +276,6 @@ void ISC_signal_cancel(int signal_number, FPTR_VOID_PTR handler, void* arg) } -namespace -{ - class SignalInit - { - public: - static void init() - { - GDS_init_prefix(); - - overflow_count = 0; - gds__register_cleanup(signal_cleanup, 0); - } - - static void cleanup() - { - signals = NULL; - } - }; - - Firebird::InitMutex signalInit; -} // anonymous namespace - -void ISC_signal_init() -{ -/************************************** - * - * I S C _ s i g n a l _ i n i t - * - ************************************** - * - * Functional description - * Initialize any system signal handlers. - * - **************************************/ - - signalInit.init(); -} - - -static void signal_cleanup(void*) -{ -/************************************** - * - * s i g n a l _ c l e a n u p - * - ************************************** - * - * Functional description - * Module level cleanup handler. - * - **************************************/ - signalInit.cleanup(); -} - - static SIG que_signal(int signal_number, FPTR_VOID handler, void* arg, diff --git a/src/jrd/os/posix/mod_loader.cpp b/src/common/os/posix/mod_loader.cpp similarity index 94% rename from src/jrd/os/posix/mod_loader.cpp rename to src/common/os/posix/mod_loader.cpp index 3a8996167a..ec1faa79b5 100644 --- a/src/jrd/os/posix/mod_loader.cpp +++ b/src/common/os/posix/mod_loader.cpp @@ -26,8 +26,8 @@ */ #include "firebird.h" -#include "../jrd/os/mod_loader.h" -#include "../../common.h" +#include "../common/os/mod_loader.h" +#include "../jrd/common.h" #ifdef HAVE_UNISTD_H #include #endif @@ -87,7 +87,7 @@ ModuleLoader::Module* ModuleLoader::loadModule(const Firebird::PathName& modPath if (module == NULL) { #ifdef DEV_BUILD - gds__log("loadModule failed loading %s: %s", modPath.c_str(), dlerror()); +// gds__log("loadModule failed loading %s: %s", modPath.c_str(), dlerror()); #endif return 0; } diff --git a/src/jrd/os/posix/os_utils.cpp b/src/common/os/posix/os_utils.cpp similarity index 99% rename from src/jrd/os/posix/os_utils.cpp rename to src/common/os/posix/os_utils.cpp index 9f1b9f2a4f..649f69ee62 100644 --- a/src/jrd/os/posix/os_utils.cpp +++ b/src/common/os/posix/os_utils.cpp @@ -31,7 +31,7 @@ #include "../common/classes/init.h" #include "../jrd/gdsassert.h" -#include "../jrd/os/os_utils.h" +#include "../common/os/os_utils.h" #include "../jrd/constants.h" #ifdef HAVE_UNISTD_H diff --git a/src/jrd/os/posix/path_utils.cpp b/src/common/os/posix/path_utils.cpp similarity index 99% rename from src/jrd/os/posix/path_utils.cpp rename to src/common/os/posix/path_utils.cpp index 0086e17895..9c1e9d910d 100644 --- a/src/jrd/os/posix/path_utils.cpp +++ b/src/common/os/posix/path_utils.cpp @@ -26,7 +26,7 @@ */ #include "firebird.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #include #include #include diff --git a/src/jrd/os/win32/fbsyslog.cpp b/src/common/os/win32/fbsyslog.cpp similarity index 98% rename from src/jrd/os/win32/fbsyslog.cpp rename to src/common/os/win32/fbsyslog.cpp index ba05209837..1255bd7d2b 100644 --- a/src/jrd/os/win32/fbsyslog.cpp +++ b/src/common/os/win32/fbsyslog.cpp @@ -20,7 +20,7 @@ */ #include "firebird.h" -#include "../jrd/os/fbsyslog.h" +#include "../common/os/fbsyslog.h" #include "../common/classes/init.h" #include diff --git a/src/jrd/os/win32/guid.cpp b/src/common/os/win32/guid.cpp similarity index 98% rename from src/jrd/os/win32/guid.cpp rename to src/common/os/win32/guid.cpp index e355eaa0cc..e07981522e 100644 --- a/src/jrd/os/win32/guid.cpp +++ b/src/common/os/win32/guid.cpp @@ -35,7 +35,7 @@ #include #include "firebird.h" -#include "../jrd/os/guid.h" +#include "../common/os/guid.h" #include "fb_exception.h" diff --git a/src/jrd/os/win32/isc_ipc.cpp b/src/common/os/win32/isc_ipc.cpp similarity index 97% rename from src/jrd/os/win32/isc_ipc.cpp rename to src/common/os/win32/isc_ipc.cpp index 025d5294b6..1ef8cc2f11 100644 --- a/src/jrd/os/win32/isc_ipc.cpp +++ b/src/common/os/win32/isc_ipc.cpp @@ -42,10 +42,10 @@ #include "../../../common/utils_proto.h" #include "../jrd/common.h" #include "gen/iberror.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_proto.h" -#include "../jrd/os/isc_i_proto.h" -#include "../jrd/isc_s_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_proto.h" +#include "../common/os/isc_i_proto.h" +#include "../common/isc_s_proto.h" #include #include diff --git a/src/jrd/os/win32/mod_loader.cpp b/src/common/os/win32/mod_loader.cpp similarity index 99% rename from src/jrd/os/win32/mod_loader.cpp rename to src/common/os/win32/mod_loader.cpp index 6a29b0423b..697701a11f 100644 --- a/src/jrd/os/win32/mod_loader.cpp +++ b/src/common/os/win32/mod_loader.cpp @@ -8,7 +8,7 @@ #include "firebird.h" #include "../../../common/dllinst.h" -#include "../jrd/os/mod_loader.h" +#include "../common/os/mod_loader.h" #include typedef Firebird::string string; diff --git a/src/jrd/os/win32/os_utils.cpp b/src/common/os/win32/os_utils.cpp similarity index 98% rename from src/jrd/os/win32/os_utils.cpp rename to src/common/os/win32/os_utils.cpp index eb1be79735..9bc1e75b3c 100644 --- a/src/jrd/os/win32/os_utils.cpp +++ b/src/common/os/win32/os_utils.cpp @@ -30,10 +30,10 @@ #include "../common/classes/init.h" #include "../jrd/gdsassert.h" -#include "../jrd/os/os_utils.h" +#include "../common/os/os_utils.h" #include "../jrd/constants.h" -#include "../jrd/os/path_utils.h" -#include "../jrd/isc_proto.h" +#include "../common/os/path_utils.h" +#include "../common/isc_proto.h" #include #include // isatty() diff --git a/src/jrd/os/win32/path_utils.cpp b/src/common/os/win32/path_utils.cpp similarity index 99% rename from src/jrd/os/win32/path_utils.cpp rename to src/common/os/win32/path_utils.cpp index 42ddb0136e..8b45242414 100644 --- a/src/jrd/os/win32/path_utils.cpp +++ b/src/common/os/win32/path_utils.cpp @@ -1,6 +1,6 @@ #include "firebird.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #include // _access /// The Win32 implementation of the path_utils abstraction. diff --git a/src/gpre/prett_proto.h b/src/common/prett_proto.h similarity index 100% rename from src/gpre/prett_proto.h rename to src/common/prett_proto.h diff --git a/src/gpre/pretty.cpp b/src/common/pretty.cpp similarity index 99% rename from src/gpre/pretty.cpp rename to src/common/pretty.cpp index 50b98b9321..91a854fab8 100644 --- a/src/gpre/pretty.cpp +++ b/src/common/pretty.cpp @@ -34,8 +34,8 @@ #include #include "../jrd/ibase.h" #include "../jrd/constants.h" -#include "../gpre/prett_proto.h" -#include "../jrd/gds_proto.h" +#include "../common/prett_proto.h" +#include "../yvalve/gds_proto.h" static inline void ADVANCE_PTR(TEXT*& ptr) { @@ -88,19 +88,19 @@ static inline void CHECK_BUFFER(ctl* control, SSHORT offset) const char *dyn_table[] = { -#include "../gpre/dyntable.h" +#include "../common/dyntable.h" NULL }; const char *cdb_table[] = { -#include "../gpre/cdbtable.h" +#include "../common/cdbtable.h" NULL }; const char *sdl_table[] = { -#include "../gpre/sdltable.h" +#include "../common/sdltable.h" NULL }; diff --git a/src/jrd/quad.cpp b/src/common/quad.cpp similarity index 98% rename from src/jrd/quad.cpp rename to src/common/quad.cpp index ba385ab18c..a8bc234069 100644 --- a/src/jrd/quad.cpp +++ b/src/common/quad.cpp @@ -22,6 +22,8 @@ */ #include "firebird.h" +#include "gen/iberror.h" +#include "../common/quad.h" using namespace Firebird; diff --git a/src/jrd/quad.h b/src/common/quad.h similarity index 98% rename from src/jrd/quad.h rename to src/common/quad.h index 70cb13110e..65e0a9fe12 100644 --- a/src/jrd/quad.h +++ b/src/common/quad.h @@ -61,7 +61,7 @@ const int HIGH_WORD = 0; #define QUAD_NEGATE(a, e) QUAD_negate (&(a), e) #define QUAD_SUBTRACT(a, b, e) QUAD_subtract (&(a), &(b), e) -#include "../jrd/quad_proto.h" +#include "../common/quad_proto.h" #endif #endif /* JRD_QUAD_H */ diff --git a/src/jrd/quad_proto.h b/src/common/quad_proto.h similarity index 100% rename from src/jrd/quad_proto.h rename to src/common/quad_proto.h diff --git a/src/jrd/sdl.cpp b/src/common/sdl.cpp similarity index 96% rename from src/jrd/sdl.cpp rename to src/common/sdl.cpp index ce826b010f..3347e517a1 100644 --- a/src/jrd/sdl.cpp +++ b/src/common/sdl.cpp @@ -27,10 +27,10 @@ #include "../jrd/jrd.h" #include "../jrd/ibase.h" #include "../jrd/val.h" -#include "../jrd/sdl.h" +#include "../common/sdl.h" #include "../jrd/intl.h" -#include "../jrd/gds_proto.h" -#include "../jrd/sdl_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/sdl_proto.h" #include "../jrd/err_proto.h" const int COMPILE_SIZE = 256; @@ -116,29 +116,6 @@ const int op_scalar = 12; */ -// CVC: This is a routine that merely copies binary slice description buffer -// to new place and if the new place's size it's not enough, allocates a buffer. -// Typically, "target" is a static buffer with limited size for the small cases. -// Was made for "remote/interface.cpp" to ensure input buffers aren't overwritten. -UCHAR* SDL_clone_sdl(const UCHAR* origin, size_t origin_size, UCHAR* target, size_t target_size) -{ - UCHAR* temp_sdl = target; - if (origin_size > target_size) - { - temp_sdl = (UCHAR*)gds__alloc((SLONG) origin_size); - // FREE: apparently never freed, the caller is responsible. - if (!temp_sdl) - { - // NOMEM: ignore operation - fb_assert_continue(FALSE); // no real error handling - return 0; - } - } - memcpy(temp_sdl, origin, origin_size); - return temp_sdl; -} - - SLONG SDL_compute_subscript(ISC_STATUS* status_vector, const Ods::InternalArrayDesc* desc, USHORT dimensions, diff --git a/src/jrd/sdl.h b/src/common/sdl.h similarity index 100% rename from src/jrd/sdl.h rename to src/common/sdl.h diff --git a/src/jrd/sdl_proto.h b/src/common/sdl_proto.h similarity index 95% rename from src/jrd/sdl_proto.h rename to src/common/sdl_proto.h index 4ceec438b2..1bed1e8218 100644 --- a/src/jrd/sdl_proto.h +++ b/src/common/sdl_proto.h @@ -31,7 +31,6 @@ namespace Ods { struct sdl_info; struct array_alice; -UCHAR* SDL_clone_sdl(const UCHAR*, size_t, UCHAR*, size_t); SLONG SDL_compute_subscript(ISC_STATUS*, const Ods::InternalArrayDesc*, USHORT, const SLONG*); ISC_STATUS SDL_info(ISC_STATUS*, const UCHAR*, sdl_info*, SLONG*); const UCHAR* SDL_prepare_slice(const UCHAR*, USHORT); diff --git a/src/gpre/sdltable.h b/src/common/sdltable.h similarity index 100% rename from src/gpre/sdltable.h rename to src/common/sdltable.h diff --git a/src/jrd/sha.cpp b/src/common/sha.cpp similarity index 99% rename from src/jrd/sha.cpp rename to src/common/sha.cpp index b6456ddedc..c49fae1d55 100644 --- a/src/jrd/sha.cpp +++ b/src/common/sha.cpp @@ -11,9 +11,9 @@ #include #include -#include "../jrd/sha.h" +#include "../common/sha.h" #include "../common/classes/array.h" -#include "../jrd/os/guid.h" +#include "../common/os/guid.h" namespace { diff --git a/src/jrd/sha.h b/src/common/sha.h similarity index 100% rename from src/jrd/sha.h rename to src/common/sha.h diff --git a/src/jrd/unicode_util.cpp b/src/common/unicode_util.cpp similarity index 99% rename from src/jrd/unicode_util.cpp rename to src/common/unicode_util.cpp index 053dbd9aaf..ae350024e5 100644 --- a/src/jrd/unicode_util.cpp +++ b/src/common/unicode_util.cpp @@ -27,9 +27,9 @@ #include "firebird.h" #include "../common/classes/alloc.h" #include "../jrd/constants.h" -#include "../jrd/unicode_util.h" -#include "../jrd/CharSet.h" -#include "../jrd/IntlUtil.h" +#include "../common/unicode_util.h" +#include "../common/CharSet.h" +#include "../common/IntlUtil.h" #include "../jrd/gdsassert.h" #include "../common/classes/auto.h" #include "../common/classes/GenericMap.h" diff --git a/src/jrd/unicode_util.h b/src/common/unicode_util.h similarity index 98% rename from src/jrd/unicode_util.h rename to src/common/unicode_util.h index 77e8c8ece0..db9a722c01 100644 --- a/src/jrd/unicode_util.h +++ b/src/common/unicode_util.h @@ -28,8 +28,8 @@ #define JRD_UNICODE_UTIL_H #include "intlobj_new.h" -#include "../jrd/IntlUtil.h" -#include "../jrd/os/mod_loader.h" +#include "../common/IntlUtil.h" +#include "../common/os/mod_loader.h" struct UCollator; struct USet; diff --git a/src/common/utils.cpp b/src/common/utils.cpp index c96d1bcced..8157c90710 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -44,7 +44,7 @@ #include "../common/classes/locks.h" #include "../common/classes/init.h" #include "../jrd/constants.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #ifdef WIN_NT #include @@ -1033,4 +1033,46 @@ Firebird::PathName getPrefix(FB_DIR prefType, const char* name) return tmp; } +unsigned int copyStatus(ISC_STATUS* const to, const unsigned int space, + const ISC_STATUS* const from, const unsigned int count) throw() +{ + unsigned int copied = 0; + + for (unsigned int i = 0; i < count; ) + { + if (from[i] == isc_arg_end) + { + break; + } + i += (from[i] == isc_arg_cstring ? 3 : 2); + if (i > space - 1) + { + break; + } + copied = i; + } + + memcpy(to, from, copied * sizeof(to[0])); + to[copied] = isc_arg_end; + + return copied; +} + +unsigned int statusLength(const ISC_STATUS* const status) throw() +{ + unsigned int l = 0; + for(;;) + { + if (status[l] == isc_arg_end) + { +/* if (l == 1 && status[2] == isc_arg_warning) + { + l += 2; + } */ + return l; + } + l += (status[l] == isc_arg_cstring ? 3 : 2); + } +} + } // namespace fb_utils diff --git a/src/common/utils_proto.h b/src/common/utils_proto.h index e1c9e8e63a..be5530f0e4 100644 --- a/src/common/utils_proto.h +++ b/src/common/utils_proto.h @@ -32,6 +32,7 @@ #include #include "../common/classes/fb_string.h" #include "gen/iberror.h" +#include "ProviderInterface.h" #ifdef SFIO #include @@ -112,6 +113,16 @@ namespace fb_utils status[2] = isc_arg_end; } + void inline init_status(FbApi::Status* status) + { + status->init(); + } + + unsigned int copyStatus(ISC_STATUS* const to, const unsigned int space, + const ISC_STATUS* const from, const unsigned int count) throw(); + + unsigned int statusLength(const ISC_STATUS* const status) throw(); + enum FetchPassResult { FETCH_PASS_OK, FETCH_PASS_FILE_OPEN_ERROR, diff --git a/src/remote/xdr.cpp b/src/common/xdr.cpp similarity index 98% rename from src/remote/xdr.cpp rename to src/common/xdr.cpp index c0480c04df..d3e9199a4e 100644 --- a/src/remote/xdr.cpp +++ b/src/common/xdr.cpp @@ -26,24 +26,14 @@ #include "firebird.h" #include -#include "../remote/remote.h" -#include "../remote/xdr.h" +//#include "../remote/remote.h" +#include "../common/xdr.h" #include "../jrd/common.h" -#include "../remote/proto_proto.h" -#include "../remote/xdr_proto.h" -#include "../jrd/gds_proto.h" +//#include "../remote/proto_proto.h" +#include "../common/xdr_proto.h" +#include "../yvalve/gds_proto.h" +#include "../jrd/gdsassert.h" -#ifdef BURP -#include "../burp/misc_proto.h" -inline UCHAR* XDR_ALLOC(ULONG size) -{ - return MISC_alloc_burp(size); -} -inline void XDR_FREEA(void* block) -{ - MISC_free_burp(block); -} -#else // BURP inline UCHAR* XDR_ALLOC(ULONG size) { return (UCHAR*) gds__alloc((SLONG) size); @@ -52,7 +42,6 @@ inline void XDR_FREEA(void* block) { gds__free(block); } -#endif // BURP #ifdef DEBUG_XDR_MEMORY inline void DEBUG_XDR_ALLOC(XDR* xdrs, const void* xdrvar, const void* addr, ULONG len) @@ -870,7 +859,7 @@ SLONG getOperation(const void* data, size_t size) **************************************/ if (size < sizeof(SLONG)) { - return op_void; + return 0; } const SLONG* p = (SLONG*) data; diff --git a/src/remote/xdr.h b/src/common/xdr.h similarity index 100% rename from src/remote/xdr.h rename to src/common/xdr.h diff --git a/src/remote/xdr_proto.h b/src/common/xdr_proto.h similarity index 98% rename from src/remote/xdr_proto.h rename to src/common/xdr_proto.h index 16008e6926..62e9634152 100644 --- a/src/remote/xdr_proto.h +++ b/src/common/xdr_proto.h @@ -24,7 +24,7 @@ #ifndef REMOTE_XDR_PROTO_H #define REMOTE_XDR_PROTO_H -#include "../remote/xdr.h" +#include "../common/xdr.h" // 15 Jan 2003. Nickolay Samofatov // Functions below need to have C++ linkage to avoid name clash with diff --git a/src/dsql/BoolNodes.cpp b/src/dsql/BoolNodes.cpp index 57593f3a2c..7e4425b55e 100644 --- a/src/dsql/BoolNodes.cpp +++ b/src/dsql/BoolNodes.cpp @@ -25,7 +25,7 @@ #include "../dsql/node.h" #include "../jrd/align.h" #include "../jrd/blr.h" -#include "../jrd/quad.h" +#include "../common/quad.h" #include "../jrd/tra.h" #include "../jrd/recsrc/RecordSource.h" #include "../jrd/Optimizer.h" diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index fa1de29052..347632c676 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -34,17 +34,17 @@ #include "../jrd/msg_encode.h" #include "../jrd/obj.h" #include "../jrd/tra.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #include "../jrd/IntlManager.h" #include "../jrd/PreparedStatement.h" #include "../jrd/blb_proto.h" #include "../jrd/cmp_proto.h" -#include "../jrd/dsc_proto.h" +#include "../common/dsc_proto.h" #include "../jrd/dyn_dl_proto.h" #include "../jrd/dyn_ut_proto.h" #include "../jrd/exe_proto.h" #include "../jrd/intl_proto.h" -#include "../jrd/isc_f_proto.h" +#include "../common/isc_f_proto.h" #include "../jrd/met_proto.h" #include "../jrd/scl_proto.h" #include "../jrd/vio_proto.h" diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp index be787742f8..54b70b6d93 100644 --- a/src/dsql/ExprNodes.cpp +++ b/src/dsql/ExprNodes.cpp @@ -27,7 +27,7 @@ #include "../dsql/node.h" #include "../jrd/align.h" #include "../jrd/blr.h" -#include "../jrd/quad.h" +#include "../common/quad.h" #include "../jrd/tra.h" #include "../jrd/Function.h" #include "../jrd/SysFunction.h" @@ -37,7 +37,7 @@ #include "../jrd/cmp_proto.h" #include "../jrd/cvt_proto.h" #include "../jrd/dpm_proto.h" -#include "../jrd/dsc_proto.h" +#include "../common/dsc_proto.h" #include "../jrd/evl_proto.h" #include "../jrd/intl_proto.h" #include "../jrd/met_proto.h" diff --git a/src/dsql/Parser.h b/src/dsql/Parser.h index 8543b9bbd3..7cd33bedbe 100644 --- a/src/dsql/Parser.h +++ b/src/dsql/Parser.h @@ -37,7 +37,7 @@ #include "../common/classes/stack.h" #define _yacc_defines_keywords -#include "../dsql/dsql.tab.h" +#include "gen/parse.h" namespace Jrd { diff --git a/src/dsql/btyacc_fb.ske b/src/dsql/btyacc_fb.ske index 8a9b1c52a7..8f532a6dec 100644 --- a/src/dsql/btyacc_fb.ske +++ b/src/dsql/btyacc_fb.ske @@ -24,8 +24,8 @@ #include "../dsql/StmtNodes.h" #include "../dsql/WinNodes.h" #include "../common/classes/Nullable.h" -#include "dsql.tab.h" -#include "Parser.h" +#include "gen/parse.h" +#include "../dsql/Parser.h" #define YYERROR_DETAILED diff --git a/src/dsql/ddl.cpp b/src/dsql/ddl.cpp index cd831717ab..a438c2ee8e 100644 --- a/src/dsql/ddl.cpp +++ b/src/dsql/ddl.cpp @@ -94,17 +94,17 @@ #include "../jrd/dyn_proto.h" #include "../jrd/met_proto.h" #include "../jrd/thread_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/jrd_proto.h" #include "../jrd/vio_proto.h" -#include "../jrd/why_proto.h" +#include "../yvalve/why_proto.h" #include "../common/utils_proto.h" #include "../dsql/DdlNodes.h" #include "../dsql/DSqlDataTypeUtil.h" #include "../common/StatusArg.h" #ifdef DSQL_DEBUG -#include "../gpre/prett_proto.h" +#include "../common/prett_proto.h" #endif using namespace Jrd; diff --git a/src/dsql/dsql.cpp b/src/dsql/dsql.cpp index 6bbd19417d..1eb91b5047 100644 --- a/src/dsql/dsql.cpp +++ b/src/dsql/dsql.cpp @@ -41,9 +41,9 @@ #include "../jrd/ibase.h" #include "../jrd/align.h" #include "../jrd/intl.h" -#include "../jrd/intlobj_new.h" +#include "../common/intlobj_new.h" #include "../jrd/jrd.h" -#include "../jrd/CharSet.h" +#include "../common/CharSet.h" #include "../dsql/Parser.h" #include "../dsql/ddl_proto.h" #include "../dsql/dsql_proto.h" @@ -56,7 +56,7 @@ #include "../dsql/pass1_proto.h" #include "../jrd/blb_proto.h" #include "../jrd/cmp_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/inf_proto.h" #include "../jrd/ini_proto.h" #include "../jrd/intl_proto.h" @@ -79,13 +79,13 @@ using namespace Firebird; static void close_cursor(thread_db*, dsql_req*); static void execute_blob(thread_db*, dsql_req*, USHORT, const UCHAR*, USHORT, const UCHAR*, - USHORT, UCHAR*, USHORT, UCHAR*); + USHORT, const UCHAR*, USHORT, UCHAR*); static void execute_immediate(thread_db*, Jrd::Attachment*, jrd_tra**, USHORT, const TEXT*, USHORT, USHORT, const UCHAR*, /*USHORT,*/ USHORT, const UCHAR*, - USHORT, UCHAR*, /*USHORT,*/ USHORT, UCHAR*, bool); + USHORT, const UCHAR*, /*USHORT,*/ USHORT, UCHAR*, bool); static void execute_request(thread_db*, dsql_req*, jrd_tra**, USHORT, const UCHAR*, - USHORT, const UCHAR*, USHORT, UCHAR*, USHORT, UCHAR*, bool); + USHORT, const UCHAR*, USHORT, const UCHAR*, USHORT, UCHAR*, bool); static SSHORT filter_sub_type(dsql_req*, const dsql_nod*); static bool get_indices(SLONG*, const UCHAR**, SLONG*, SCHAR**); static USHORT get_request_info(thread_db*, dsql_req*, SLONG, UCHAR*); @@ -217,7 +217,7 @@ void DSQL_execute(thread_db* tdbb, dsql_req* request, USHORT in_blr_length, const UCHAR* in_blr, USHORT in_msg_type, USHORT in_msg_length, const UCHAR* in_msg, - USHORT out_blr_length, UCHAR* out_blr, + USHORT out_blr_length, const UCHAR* const out_blr, USHORT out_msg_length, UCHAR* out_msg) { SET_TDBB(tdbb); @@ -315,7 +315,7 @@ void DSQL_execute_immediate(thread_db* tdbb, USHORT length, const TEXT* string, USHORT dialect, USHORT in_blr_length, const UCHAR* in_blr, USHORT in_msg_length, const UCHAR* in_msg, - USHORT out_blr_length, UCHAR* out_blr, + USHORT out_blr_length, const UCHAR* out_blr, USHORT out_msg_length, UCHAR* out_msg, bool isInternalRequest) { @@ -872,7 +872,7 @@ static void execute_blob(thread_db* tdbb, USHORT in_msg_length, const UCHAR* in_msg, USHORT out_blr_length, - UCHAR* out_blr, + const UCHAR* out_blr, USHORT out_msg_length, UCHAR* out_msg) { @@ -970,7 +970,7 @@ static void execute_immediate(thread_db* tdbb, USHORT length, const TEXT* string, USHORT dialect, USHORT in_blr_length, const UCHAR* in_blr, USHORT in_msg_length, const UCHAR* in_msg, - USHORT out_blr_length, UCHAR* out_blr, + USHORT out_blr_length, const UCHAR* out_blr, USHORT out_msg_length, UCHAR* out_msg, bool isInternalRequest) { @@ -1075,7 +1075,7 @@ static void execute_request(thread_db* tdbb, jrd_tra** tra_handle, USHORT in_blr_length, const UCHAR* in_blr, USHORT in_msg_length, const UCHAR* in_msg, - USHORT out_blr_length, UCHAR* out_blr, + USHORT out_blr_length, const UCHAR* out_blr, USHORT out_msg_length, UCHAR* out_msg, bool singleton) { @@ -1091,21 +1091,21 @@ static void execute_request(thread_db* tdbb, return; case DsqlCompiledStatement::TYPE_COMMIT: - JRD_commit_transaction(tdbb, &request->req_transaction); + JRD_commit_transaction(tdbb, request->req_transaction); *tra_handle = NULL; return; case DsqlCompiledStatement::TYPE_COMMIT_RETAIN: - JRD_commit_retaining(tdbb, &request->req_transaction); + JRD_commit_retaining(tdbb, request->req_transaction); return; case DsqlCompiledStatement::TYPE_ROLLBACK: - JRD_rollback_transaction(tdbb, &request->req_transaction); + JRD_rollback_transaction(tdbb, request->req_transaction); *tra_handle = NULL; return; case DsqlCompiledStatement::TYPE_ROLLBACK_RETAIN: - JRD_rollback_retaining(tdbb, &request->req_transaction); + JRD_rollback_retaining(tdbb, request->req_transaction); return; case DsqlCompiledStatement::TYPE_CREATE_DB: diff --git a/src/dsql/dsql.h b/src/dsql/dsql.h index 9cd30b3684..b3445ff558 100644 --- a/src/dsql/dsql.h +++ b/src/dsql/dsql.h @@ -99,7 +99,7 @@ namespace Firebird /// Include definition of descriptor -#include "../jrd/dsc.h" +#include "../common/dsc.h" namespace Jrd { @@ -507,7 +507,7 @@ private: }; -class dsql_req : public pool_alloc +class dsql_req : public pool_alloc, public FbApi::Statement { public: static const unsigned FLAG_OPENED_CURSOR = 0x01; @@ -575,6 +575,38 @@ protected: // To avoid posix warning about missing public destructor declare // MemoryPool as friend class. In fact IT releases request memory! friend class Firebird::MemoryPool; + +public: + virtual void release(); + //virtual Sqlda* describeInput(Status* status); + //virtual Sqlda* describeOutput(Status* status); + virtual FbApi::Statement* prepare(Status* status, FbApi::Transaction* tra, + unsigned int stmtLength, const char* sqlStmt, unsigned int dialect, + unsigned int item_length, const unsigned char* items, + unsigned int buffer_length, unsigned char* buffer); + virtual void getInfo(Status* status, + unsigned int itemsLength, const unsigned char* items, + unsigned int bufferLength, unsigned char* buffer); + virtual void setCursor(Status* status, const char* name, unsigned int type); +// virtual FbApi::Transaction* execute(Status* status, FbApi::Transaction* tra, Sqlda* in, Sqlda* out); + virtual FbApi::Transaction* executeMessage(Status* status, FbApi::Transaction* tra, + unsigned int in_blr_length, const unsigned char* in_blr, + unsigned int in_msg_type, + unsigned int in_msg_length, const unsigned char* in_message, + unsigned int out_blr_length, const unsigned char* out_blr, + unsigned int out_msg_type, + unsigned int out_msg_length, unsigned char* out_message); +// virtual int fetch(Status* status, Sqlda* out); // returns 100 if EOF, 101 if fragmented + virtual int fetchMessage(Status* status, + unsigned int blr_length, const unsigned char* blr, + unsigned int msg_type, + unsigned int msg_length, unsigned char* message); // returns 100 if EOF, 101 if fragmented +// virtual void insert(Status* status, Sqlda* in); + virtual void insertMessage(Status* status, + unsigned int blr_length, const unsigned char* blr, + unsigned int msg_type, + unsigned int msg_length, const unsigned char* message); + virtual void free(Status* status, unsigned int option); }; // Blob diff --git a/src/dsql/dsql_proto.h b/src/dsql/dsql_proto.h index 4953ead726..6790745d19 100644 --- a/src/dsql/dsql_proto.h +++ b/src/dsql/dsql_proto.h @@ -37,13 +37,13 @@ Jrd::dsql_req* DSQL_allocate_statement(Jrd::thread_db*, Jrd::Attachment*); void DSQL_execute(Jrd::thread_db*, Jrd::jrd_tra**, Jrd::dsql_req*, USHORT, const UCHAR*, USHORT, USHORT, const UCHAR*, - USHORT, UCHAR*, + USHORT, const UCHAR*, USHORT, UCHAR*); void DSQL_execute_immediate(Jrd::thread_db*, Jrd::Attachment*, Jrd::jrd_tra**, USHORT, const TEXT*, USHORT, USHORT, const UCHAR*, USHORT, const UCHAR*, - USHORT, UCHAR*, + USHORT, const UCHAR*, USHORT, UCHAR*, bool); ISC_STATUS DSQL_fetch(Jrd::thread_db*, Jrd::dsql_req*, USHORT, const UCHAR*, USHORT, UCHAR*); diff --git a/src/dsql/errd.cpp b/src/dsql/errd.cpp index 45ded43592..ddd066412d 100644 --- a/src/dsql/errd.cpp +++ b/src/dsql/errd.cpp @@ -39,7 +39,6 @@ #include "gen/iberror.h" #include "../jrd/jrd.h" #include "../dsql/errd_proto.h" -#include "../dsql/utld_proto.h" // This is the only one place in dsql code, where we need both // dsql.h and err_proto.h. @@ -54,7 +53,7 @@ //#undef BUGCHECK //#undef IBERROR -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../common/utils_proto.h" using namespace Jrd; @@ -310,16 +309,12 @@ void ERRD_punt(const ISC_STATUS* local) { thread_db* tdbb = JRD_get_thread_data(); - // copy local status into user status - if (local) { - UTLD_copy_status(local, tdbb->tdbb_status_vector); + // Save any strings in a permanent location + if (local) + { + Firebird::makePermanentVector(tdbb->tdbb_status_vector, local); } - // Save any strings in a permanent location - - UTLD_save_status_strings(tdbb->tdbb_status_vector); - // Give up whatever we were doing and return to the user. - status_exception::raise(tdbb->tdbb_status_vector); } diff --git a/src/dsql/gen.cpp b/src/dsql/gen.cpp index 7234728202..b287ddc211 100644 --- a/src/dsql/gen.cpp +++ b/src/dsql/gen.cpp @@ -53,8 +53,8 @@ #include "../dsql/metd_proto.h" #include "../dsql/utld_proto.h" #include "../jrd/thread_proto.h" -#include "../jrd/dsc_proto.h" -#include "../jrd/why_proto.h" +#include "../common/dsc_proto.h" +#include "../yvalve/why_proto.h" #include "gen/iberror.h" #include "../common/StatusArg.h" diff --git a/src/dsql/hsh.cpp b/src/dsql/hsh.cpp index 72e75266b2..6537b35ac4 100644 --- a/src/dsql/hsh.cpp +++ b/src/dsql/hsh.cpp @@ -25,7 +25,7 @@ #include #include "../dsql/dsql.h" #include "../jrd/ibase.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../dsql/errd_proto.h" #include "../dsql/hsh_proto.h" #include "../dsql/parse_proto.h" diff --git a/src/dsql/make.cpp b/src/dsql/make.cpp index 8d2858676f..a381fdb2ce 100644 --- a/src/dsql/make.cpp +++ b/src/dsql/make.cpp @@ -54,10 +54,10 @@ #include "../jrd/jrd.h" #include "../jrd/ods.h" #include "../jrd/ini.h" -#include "../jrd/dsc_proto.h" +#include "../common/dsc_proto.h" #include "../common/cvt.h" #include "../jrd/thread_proto.h" -#include "../jrd/why_proto.h" +#include "../yvalve/why_proto.h" #include "../common/config/config.h" #include "../common/StatusArg.h" diff --git a/src/dsql/metd.epp b/src/dsql/metd.epp index cbe5b8da7d..271a427895 100644 --- a/src/dsql/metd.epp +++ b/src/dsql/metd.epp @@ -48,10 +48,10 @@ #include "../jrd/blb_proto.h" #include "../jrd/cmp_proto.h" #include "../jrd/exe_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/met_proto.h" #include "../jrd/thread_proto.h" -#include "../jrd/why_proto.h" +#include "../yvalve/why_proto.h" #include "../common/utils_proto.h" #include "../common/classes/init.h" diff --git a/src/dsql/parse.y b/src/dsql/parse.y index 18be2b1b0a..e57b13fca8 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -91,10 +91,10 @@ #include "../dsql/errd_proto.h" #include "../dsql/hsh_proto.h" #include "../dsql/make_proto.h" -#include "../dsql/keywords.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/keywords.h" +#include "../yvalve/gds_proto.h" #include "../jrd/err_proto.h" -#include "../jrd/intlobj_new.h" +#include "../common/intlobj_new.h" #include "../jrd/Attachment.h" #include "../common/StatusArg.h" @@ -165,7 +165,7 @@ inline void check_copy_incr(char*& to, const char ch, const char* const string) // token declarations // Tokens are organized chronologically by date added. -// See dsql/keywords.cpp for a list organized alphabetically +// See yvalve/keywords.cpp for a list organized alphabetically // Tokens in v4.0 -- not separated into v3 and v4 tokens diff --git a/src/dsql/pass1.cpp b/src/dsql/pass1.cpp index df9c6f6652..19a30fd6d7 100644 --- a/src/dsql/pass1.cpp +++ b/src/dsql/pass1.cpp @@ -163,11 +163,11 @@ #include "../dsql/pass1_proto.h" #include "../dsql/utld_proto.h" #include "../dsql/DSqlDataTypeUtil.h" -#include "../jrd/dsc_proto.h" +#include "../common/dsc_proto.h" #include "../jrd/intl_proto.h" #include "../jrd/jrd_proto.h" #include "../jrd/thread_proto.h" -#include "../jrd/why_proto.h" +#include "../yvalve/why_proto.h" #include "../jrd/SysFunction.h" #include "../common/classes/array.h" #include "../common/classes/auto.h" diff --git a/src/dsql/utld.cpp b/src/dsql/utld.cpp index 7a713d9cc4..3a9084f032 100644 --- a/src/dsql/utld.cpp +++ b/src/dsql/utld.cpp @@ -39,112 +39,11 @@ #include "../jrd/align.h" #include "../jrd/constants.h" #include "../dsql/utld_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../common/classes/init.h" using namespace Jrd; -static void cleanup(void *); -static ISC_STATUS error_dsql_804(ISC_STATUS *, ISC_STATUS); -static SLONG get_numeric_info(const SCHAR**); -static SSHORT get_string_info(const SCHAR**, SCHAR*, int); -#ifdef NOT_USED_OR_REPLACED -#ifdef DEV_BUILD -static void print_xsqlda(XSQLDA *); -#endif -#endif -static void sqlvar_to_xsqlvar(const SQLVAR*, XSQLVAR*); -static void xsqlvar_to_sqlvar(const XSQLVAR*, SQLVAR*); - -static inline void ch_stuff(BLOB_PTR*& p, const UCHAR value, bool& same_flag) -{ - if (*p == value) - p++; - else { - *p++ = value; - same_flag = false; - } -} - -static inline void ch_stuff_word(BLOB_PTR*& p, const USHORT value, bool& same_flag) -{ - ch_stuff(p, value & 255, same_flag); - ch_stuff(p, value >> 8, same_flag); -} - -// these statics define a round-robin data area for storing -// textual error messages returned to the user - -static Firebird::GlobalPtr failuresMutex; -static TEXT *DSQL_failures, *DSQL_failures_ptr; - -const int DSQL_FAILURE_SPACE = 2048; - -/** - Parse response on isc_info_sql_select or isc_info_sql_bind - request. Return pointer to the next byte after successfully - parsed info or NULL if error is encountered or info is truncated -**/ -SCHAR* UTLD_skip_sql_info(SCHAR* info) -{ - if (*info != isc_info_sql_select && - *info != isc_info_sql_bind) - { - return 0; - } - - info++; - - if (*info++ != isc_info_sql_describe_vars) - return 0; - - get_numeric_info((const SCHAR**) &info); // skip message->msg_index - - // Loop over the variables being described - while (true) - { - SCHAR str[256]; // must be big enough to hold metadata name - const UCHAR item = *info++; - - switch (item) - { - case isc_info_end: - return info; - - case isc_info_truncated: - return 0; - - case isc_info_sql_select: - case isc_info_sql_bind: - return --info; - - case isc_info_sql_describe_end: - break; - - case isc_info_sql_sqlda_seq: - case isc_info_sql_type: - case isc_info_sql_sub_type: - case isc_info_sql_scale: - case isc_info_sql_length: - get_numeric_info((const SCHAR**) &info); - break; - - case isc_info_sql_field: - case isc_info_sql_relation: - case isc_info_sql_owner: - case isc_info_sql_alias: - get_string_info((const SCHAR**) &info, str, sizeof(str)); - break; - - default: - return 0; - } - } - - return 0; -} - - /** UTLD_char_length_to_byte_length @@ -182,888 +81,3 @@ ISC_STATUS UTLD_copy_status(const ISC_STATUS* from, ISC_STATUS* to) return status; } - - -/** - - UTLD_parse_sql_info - - @brief Fill in an SQLDA using data returned - by a call to isc_dsql_sql_info. - - - @param status - @param dialect - @param info - @param xsqlda - @param return_index - - **/ -ISC_STATUS UTLD_parse_sql_info(ISC_STATUS* status, - USHORT dialect, - const SCHAR* info, - XSQLDA* xsqlda, - USHORT* return_index) -{ - XSQLVAR *xvar, xsqlvar; - SQLDA* sqlda; - - if (return_index) - *return_index = 0; - - if (!xsqlda) - return 0; - - // The first byte of the returned buffer is assumed to be either a - // isc_info_sql_select or isc_info_sql_bind item. The second byte - // is assumed to be isc_info_sql_describe_vars. - - info += 2; - - const SSHORT n = static_cast(get_numeric_info(&info)); - if (dialect >= DIALECT_xsqlda) - { - if (xsqlda->version != SQLDA_VERSION1) - return error_dsql_804(status, isc_dsql_sqlda_err); - xsqlda->sqld = n; - - // If necessary, inform the application that more sqlda items are needed - if (xsqlda->sqld > xsqlda->sqln) - return 0; - } - else - { - sqlda = (SQLDA *) xsqlda; - sqlda->sqld = n; - - // If necessary, inform the application that more sqlda items are needed - if (sqlda->sqld > sqlda->sqln) - return 0; - - xsqlda = NULL; - xvar = &xsqlvar; - } - - // Loop over the variables being described. - - SQLVAR* qvar = NULL; - USHORT last_index = 0; - USHORT index = 0; - - while (*info != isc_info_end) - { - SCHAR item; - while ((item = *info++) != isc_info_sql_describe_end) - switch (item) - { - case isc_info_sql_sqlda_seq: - index = static_cast(get_numeric_info(&info)); - if (xsqlda) - xvar = xsqlda->sqlvar + index - 1; - else - { - qvar = sqlda->sqlvar + index - 1; - memset(xvar, 0, sizeof(XSQLVAR)); - } - break; - - case isc_info_sql_type: - xvar->sqltype = static_cast(get_numeric_info(&info)); - break; - - case isc_info_sql_sub_type: - xvar->sqlsubtype = static_cast(get_numeric_info(&info)); - break; - - case isc_info_sql_scale: - xvar->sqlscale = static_cast(get_numeric_info(&info)); - break; - - case isc_info_sql_length: - xvar->sqllen = static_cast(get_numeric_info(&info)); - break; - - case isc_info_sql_field: - xvar->sqlname_length = get_string_info(&info, xvar->sqlname, sizeof(xvar->sqlname)); - break; - - case isc_info_sql_relation: - xvar->relname_length = get_string_info(&info, xvar->relname, sizeof(xvar->relname)); - break; - - case isc_info_sql_owner: - xvar->ownname_length = get_string_info(&info, xvar->ownname, sizeof(xvar->ownname)); - break; - - case isc_info_sql_alias: - xvar->aliasname_length = - get_string_info(&info, xvar->aliasname, sizeof(xvar->aliasname)); - break; - - case isc_info_truncated: - if (return_index) - *return_index = last_index; - - default: - return error_dsql_804(status, isc_dsql_sqlda_err); - } - - if (!xsqlda) - xsqlvar_to_sqlvar(xvar, qvar); - - if (index > last_index) - last_index = index; - } - - if (*info != isc_info_end) - return error_dsql_804(status, isc_dsql_sqlda_err); - - return FB_SUCCESS; -} - - -/** - - UTLD_parse_sqlda - - @brief This routine creates a blr message that describes - a SQLDA as well as moving data from the SQLDA - into a message buffer or from the message buffer - into the SQLDA. - - - @param status - @param dasup - @param blr_length - @param msg_type - @param msg_length - @param dialect - @param xsqlda - @param clause - - **/ -ISC_STATUS UTLD_parse_sqlda(ISC_STATUS* status, - sqlda_sup* const dasup, - USHORT* blr_length, - USHORT* msg_type, - USHORT* msg_length, - USHORT dialect, - const XSQLDA* xsqlda, - const USHORT clause) -{ - USHORT n; - XSQLVAR xsqlvar; - const XSQLVAR* xvar = &xsqlvar; - const SQLVAR* qvar; - const SQLDA* sqlda = NULL; - - if (!xsqlda) - n = 0; - else - if (dialect >= DIALECT_xsqlda) - { - if (xsqlda->version != SQLDA_VERSION1) - return error_dsql_804(status, isc_dsql_sqlda_err); - n = xsqlda->sqld; - } - else - { - sqlda = reinterpret_cast(xsqlda); - n = sqlda->sqld; - xsqlda = NULL; - } - - - sqlda_sup::dasup_clause* const pClause = &dasup->dasup_clauses[clause]; - - if (!n) - { - // If there isn't an SQLDA, don't bother with anything else. - - if (blr_length) - *blr_length = pClause->dasup_blr_length = 0; - if (msg_length) - *msg_length = 0; - if (msg_type) - *msg_type = 0; - return 0; - } - - if (msg_length) - { - // This is a call from execute or open, or the first call from fetch. - // Determine the size of the blr, allocate a blr buffer, create the - // blr, and finally allocate a message buffer. - - // The message buffer we are describing could be for a message to - // either IB 4.0 or IB 3.3 - thus we need to describe the buffer - // with the right set of blr. - // As the BLR is only used to describe space allocation and alignment, - // we can safely use blr_text for both 4.0 and 3.3. - - // Make a quick pass through the SQLDA to determine the amount of - // blr that will be generated. - - USHORT blr_len = 8; - USHORT par_count = 0; - if (xsqlda) - xvar = xsqlda->sqlvar - 1; - else - qvar = sqlda->sqlvar - 1; - - for (USHORT i = 0; i < n; i++) - { - if (xsqlda) - ++xvar; - else - sqlvar_to_xsqlvar(++qvar, &xsqlvar); - - const USHORT dtype = xvar->sqltype & ~1; - switch (dtype) - { - case SQL_VARYING: - case SQL_TEXT: - case SQL_NULL: - blr_len += 3; - break; - case SQL_SHORT: - case SQL_LONG: - case SQL_INT64: - case SQL_QUAD: - case SQL_BLOB: - case SQL_ARRAY: - blr_len += 2; - break; - default: - ++blr_len; - } - - blr_len += 2; - par_count += 2; - } - - // Make sure the blr buffer is large enough. If it isn't, allocate - // a new one. - - if (blr_len > pClause->dasup_blr_buf_len) - { - if (pClause->dasup_blr) { - gds__free(pClause->dasup_blr); - } - pClause->dasup_blr = static_cast(gds__alloc((SLONG) blr_len)); - // FREE: unknown - if (!pClause->dasup_blr) // NOMEM: - return error_dsql_804(status, isc_virmemexh); - pClause->dasup_blr_buf_len = blr_len; - pClause->dasup_blr_length = 0; - } - memset(pClause->dasup_blr, 0, blr_len); - - bool same_flag = (blr_len == pClause->dasup_blr_length); - - // turn off same_flag because it breaks execute & execute2 when - // more than one statement is prepared - - same_flag = false; - - pClause->dasup_blr_length = blr_len; - - // Generate the blr for the message and at the same time, determine - // the size of the message buffer. Allow for a null indicator with - // each variable in the SQLDA. - - // one huge pointer per line for LIBS - BLOB_PTR* p = reinterpret_cast(pClause->dasup_blr); - - // The define SQL_DIALECT_V5 is not available here, Hence using - // constant 1. - - if (dialect > 1) { - ch_stuff(p, blr_version5, same_flag); - } - else { - ch_stuff(p, blr_version4, same_flag); - } - //else if ((SCHAR) *(p) == (SCHAR) (blr_version4)) { - // (p)++; - //} - //else { - // *(p)++ = (blr_version4); - // same_flag = false; - //} - - ch_stuff(p, blr_begin, same_flag); - ch_stuff(p, blr_message, same_flag); - ch_stuff(p, 0, same_flag); - ch_stuff_word(p, par_count, same_flag); - USHORT msg_len = 0; - if (xsqlda) - xvar = xsqlda->sqlvar - 1; - else - qvar = sqlda->sqlvar - 1; - for (USHORT i = 0; i < n; i++) - { - if (xsqlda) - ++xvar; - else - sqlvar_to_xsqlvar(++qvar, &xsqlvar); - - USHORT dtype = xvar->sqltype & ~1; - USHORT len = xvar->sqllen; - switch (dtype) - { - case SQL_VARYING: - ch_stuff(p, blr_varying, same_flag); - ch_stuff_word(p, len, same_flag); - dtype = dtype_varying; - len += sizeof(USHORT); - break; - case SQL_TEXT: - ch_stuff(p, blr_text, same_flag); - ch_stuff_word(p, len, same_flag); - dtype = dtype_text; - break; - case SQL_DOUBLE: - ch_stuff(p, blr_double, same_flag); - dtype = dtype_double; - break; - case SQL_FLOAT: - ch_stuff(p, blr_float, same_flag); - dtype = dtype_real; - break; - case SQL_D_FLOAT: - ch_stuff(p, blr_d_float, same_flag); - dtype = dtype_d_float; - break; - case SQL_TYPE_DATE: - ch_stuff(p, blr_sql_date, same_flag); - dtype = dtype_sql_date; - break; - case SQL_TYPE_TIME: - ch_stuff(p, blr_sql_time, same_flag); - dtype = dtype_sql_time; - break; - case SQL_TIMESTAMP: - ch_stuff(p, blr_timestamp, same_flag); - dtype = dtype_timestamp; - break; - case SQL_BLOB: - ch_stuff(p, blr_quad, same_flag); - ch_stuff(p, 0, same_flag); - dtype = dtype_blob; - break; - case SQL_ARRAY: - ch_stuff(p, blr_quad, same_flag); - ch_stuff(p, 0, same_flag); - dtype = dtype_array; - break; - case SQL_LONG: - ch_stuff(p, blr_long, same_flag); - ch_stuff(p, xvar->sqlscale, same_flag); - dtype = dtype_long; - break; - case SQL_SHORT: - ch_stuff(p, blr_short, same_flag); - ch_stuff(p, xvar->sqlscale, same_flag); - dtype = dtype_short; - break; - case SQL_INT64: - ch_stuff(p, blr_int64, same_flag); - ch_stuff(p, xvar->sqlscale, same_flag); - dtype = dtype_int64; - break; - case SQL_QUAD: - ch_stuff(p, blr_quad, same_flag); - ch_stuff(p, xvar->sqlscale, same_flag); - dtype = dtype_quad; - break; - case SQL_NULL: - ch_stuff(p, blr_text, same_flag); - ch_stuff_word(p, len, same_flag); - dtype = dtype_text; - break; - default: - return error_dsql_804(status, isc_dsql_sqlda_value_err); - } - - ch_stuff(p, blr_short, same_flag); - ch_stuff(p, 0, same_flag); - - USHORT align = type_alignments[dtype]; - if (align) - msg_len = FB_ALIGN(msg_len, align); - msg_len += len; - align = type_alignments[dtype_short]; - if (align) - msg_len = FB_ALIGN(msg_len, align); - msg_len += sizeof(SSHORT); - } - - ch_stuff(p, blr_end, same_flag); - ch_stuff(p, blr_eoc, same_flag); - - // Make sure the message buffer is large enough. If it isn't, allocate - // a new one. - - if (msg_len > pClause->dasup_msg_buf_len) - { - if (pClause->dasup_msg) - gds__free(pClause->dasup_msg); - pClause->dasup_msg = static_cast(gds__alloc((SLONG) msg_len)); - // FREE: unknown - if (!pClause->dasup_msg) // NOMEM: - return error_dsql_804(status, isc_virmemexh); - pClause->dasup_msg_buf_len = msg_len; - } - memset(pClause->dasup_msg, 0, msg_len); - - // Fill in the return values to the caller. - - *blr_length = same_flag ? 0 : blr_len; - *msg_length = msg_len; - *msg_type = 0; - - // If this is the first call from fetch, we're done. - - if (clause == DASUP_CLAUSE_select) - return 0; - } - - // Move the data between the SQLDA and the message buffer. - - USHORT offset = 0; - // one huge pointer per line for LIBS - BLOB_PTR* msg_buf = reinterpret_cast(pClause->dasup_msg); - if (xsqlda) - xvar = xsqlda->sqlvar - 1; - else - qvar = sqlda->sqlvar - 1; - for (USHORT i = 0; i < n; i++) - { - if (xsqlda) - ++xvar; - else - sqlvar_to_xsqlvar(++qvar, &xsqlvar); - - USHORT dtype = xvar->sqltype & ~1; - USHORT len = xvar->sqllen; - switch (dtype) - { - case SQL_VARYING: - dtype = dtype_varying; - len += sizeof(USHORT); - break; - case SQL_TEXT: - dtype = dtype_text; - break; - case SQL_DOUBLE: - dtype = dtype_double; - break; - case SQL_FLOAT: - dtype = dtype_real; - break; - case SQL_D_FLOAT: - dtype = dtype_d_float; - break; - case SQL_TYPE_DATE: - dtype = dtype_sql_date; - break; - case SQL_TYPE_TIME: - dtype = dtype_sql_time; - break; - case SQL_TIMESTAMP: - dtype = dtype_timestamp; - break; - case SQL_BLOB: - dtype = dtype_blob; - break; - case SQL_ARRAY: - dtype = dtype_array; - break; - case SQL_LONG: - dtype = dtype_long; - break; - case SQL_SHORT: - dtype = dtype_short; - break; - case SQL_INT64: - dtype = dtype_int64; - break; - case SQL_QUAD: - dtype = dtype_quad; - break; - case SQL_NULL: - dtype = dtype_text; - break; - } - - USHORT align = type_alignments[dtype]; - if (align) - offset = FB_ALIGN(offset, align); - USHORT null_offset = offset + len; - - align = type_alignments[dtype_short]; - if (align) - null_offset = FB_ALIGN(null_offset, align); - - SSHORT *null_ind = (SSHORT *) (msg_buf + null_offset); - if (clause == DASUP_CLAUSE_select) - { - // Move data from the message into the SQLDA. - - if ((xvar->sqltype & ~1) != SQL_NULL) - { - // Make sure user has specified a data location - if (!xvar->sqldata) - return error_dsql_804(status, isc_dsql_sqlda_value_err); - - memcpy(xvar->sqldata, msg_buf + offset, len); - } - - if (xvar->sqltype & 1) - { - // Make sure user has specified a location for null indicator - if (!xvar->sqlind) - return error_dsql_804(status, isc_dsql_sqlda_value_err); - *xvar->sqlind = *null_ind; - } - } - else - { - // Move data from the SQLDA into the message. If the - // indicator variable identifies a null value, permit - // the data value to be missing. - - if (xvar->sqltype & 1) - { - // Make sure user has specified a location for null indicator - if (!xvar->sqlind) - return error_dsql_804(status, isc_dsql_sqlda_value_err); - *null_ind = *xvar->sqlind; - } - else - *null_ind = 0; - - // Make sure user has specified a data location (unless NULL) - if (!xvar->sqldata && !*null_ind && (xvar->sqltype & ~1) != SQL_NULL) - return error_dsql_804(status, isc_dsql_sqlda_value_err); - - // Copy data - unless known to be NULL - if ((offset + len) > pClause->dasup_msg_buf_len) - return error_dsql_804(status, isc_dsql_sqlda_value_err); - - if (!*null_ind) - memcpy(msg_buf + offset, xvar->sqldata, len); - } - - offset = null_offset + sizeof(SSHORT); - } - - return 0; -} - - -/** - - UTLD_save_status_strings - - @brief Strings in status vectors may be stored in stack variables - or memory pools that are transient. To perserve the information, - copy any included strings to a special buffer. - - - @param vector - - **/ -void UTLD_save_status_strings(ISC_STATUS* vector) -{ - Firebird::MutexLockGuard guard(failuresMutex); - - // allocate space for failure strings if it hasn't already been allocated - - if (!DSQL_failures) - { - DSQL_failures = (TEXT*) gds__alloc((SLONG) DSQL_FAILURE_SPACE); - // FREE: by exit handler cleanup() - if (!DSQL_failures) // NOMEM: don't try to copy the strings - return; - DSQL_failures_ptr = DSQL_failures; - gds__register_cleanup(cleanup, 0); - -#ifdef DEBUG_GDS_ALLOC - gds_alloc_flag_unfreed((void*) DSQL_failures); -#endif - } - - while (*vector) - { - const TEXT* p; - USHORT l; - const ISC_STATUS status = *vector++; - switch (status) - { - case isc_arg_cstring: - l = static_cast(*vector++); - - case isc_arg_string: - case isc_arg_interpreted: - case isc_arg_sql_state: - p = (TEXT*) *vector; - - if (status != isc_arg_cstring) - l = strlen(p) + 1; - - // If there isn't any more room in the buffer, - // start at the beginning again - - if (DSQL_failures_ptr + l > DSQL_failures + DSQL_FAILURE_SPACE) - DSQL_failures_ptr = DSQL_failures; - - *vector++ = (ISC_STATUS) DSQL_failures_ptr; - - if (l) - { - do - { - *DSQL_failures_ptr++ = *p++; - } while (--l && (DSQL_failures_ptr < DSQL_failures + DSQL_FAILURE_SPACE)); - } - - if (l) - *(DSQL_failures_ptr - 1) = '\0'; - - break; - - default: - ++vector; - break; - } - } -} - - -/** - - cleanup - - @brief Exit handler to cleanup dynamically allocated memory. - - - @param arg - - **/ -static void cleanup(void*) -{ - Firebird::MutexLockGuard guard(failuresMutex); - - if (DSQL_failures) - gds__free(DSQL_failures); - - gds__unregister_cleanup(cleanup, 0); - DSQL_failures = NULL; -} - - -/** - - error_dsql_804 - - @brief Move a DSQL -804 error message into a status vector. - - - @param status - @param err - - **/ -static ISC_STATUS error_dsql_804( ISC_STATUS * status, ISC_STATUS err) -{ - ISC_STATUS *p = status; - - *p++ = isc_arg_gds; - *p++ = isc_dsql_error; - *p++ = isc_arg_gds; - *p++ = isc_sqlerr; - *p++ = isc_arg_number; - *p++ = -804; - *p++ = isc_arg_gds; - *p++ = err; - *p = isc_arg_end; - - return status[1]; -} - - -/** - - get_numeric_info - - @brief Pick up a VAX format numeric info item - with a 2 byte length. - - - @param ptr - - **/ -static SLONG get_numeric_info(const SCHAR** ptr) -{ - const SSHORT l = static_cast(gds__vax_integer(reinterpret_cast(*ptr), 2)); - *ptr += 2; - int item = gds__vax_integer(reinterpret_cast(*ptr), l); - *ptr += l; - - return item; -} - - -/** - - get_string_info - - @brief Pick up a string valued info item and return - its length. The buffer_len argument is assumed - to include space for the terminating null. - - - @param ptr - @param buffer - @param buffer_len - - **/ -static SSHORT get_string_info(const SCHAR** ptr, SCHAR* buffer, int buffer_len) -{ - const SCHAR* p = *ptr; - SSHORT len = static_cast(gds__vax_integer(reinterpret_cast(p), 2)); - // CVC: What else can we do here? - if (len < 0) - len = 0; - - *ptr += len + 2; - p += 2; - - if (len >= buffer_len) - len = buffer_len - 1; - - if (len) - memcpy(buffer, p, len); - buffer[len] = 0; - - return len; -} - -#ifdef NOT_USED_OR_REPLACED -#ifdef DEV_BUILD -static void print_xsqlda( XSQLDA * xsqlda) -{ -/***************************************** - * - * p r i n t _ x s q l d a - * - ***************************************** - * - * print an sqlda - * - *****************************************/ - XSQLVAR *xvar, *end_var; - - if (!xsqlda) - return; - - printf("SQLDA Version %d\n", xsqlda->version); - printf(" sqldaid %.8s\n", xsqlda->sqldaid); - printf(" sqldabc %d\n", xsqlda->sqldabc); - printf(" sqln %d\n", xsqlda->sqln); - printf(" sqld %d\n", xsqlda->sqld); - - xvar = xsqlda->sqlvar; - for (end_var = xvar + xsqlda->sqld; xvar < end_var; xvar++) - printf(" %.31s %.31s type: %d, scale %d, len %d subtype %d\n", - xvar->sqlname, xvar->relname, xvar->sqltype, - xvar->sqlscale, xvar->sqllen, xvar->sqlsubtype); -} -#endif -#endif - -/** - - sqlvar_to_xsqlvar - - - @param sqlvar - @param xsqlvar - - - @param sqlvar - @param xsqlvar - - **/ -static void sqlvar_to_xsqlvar(const SQLVAR* sqlvar, XSQLVAR* xsqlvar) -{ - - xsqlvar->sqltype = sqlvar->sqltype; - xsqlvar->sqldata = sqlvar->sqldata; - xsqlvar->sqlind = sqlvar->sqlind; - - xsqlvar->sqlsubtype = 0; - xsqlvar->sqlscale = 0; - xsqlvar->sqllen = sqlvar->sqllen; - switch (xsqlvar->sqltype & ~1) - { - case SQL_LONG: - xsqlvar->sqlscale = xsqlvar->sqllen >> 8; - xsqlvar->sqllen = sizeof(SLONG); - break; - case SQL_SHORT: - xsqlvar->sqlscale = xsqlvar->sqllen >> 8; - xsqlvar->sqllen = sizeof(SSHORT); - break; - case SQL_INT64: - xsqlvar->sqlscale = xsqlvar->sqllen >> 8; - xsqlvar->sqllen = sizeof(SINT64); - break; - case SQL_QUAD: - xsqlvar->sqlscale = xsqlvar->sqllen >> 8; - xsqlvar->sqllen = sizeof(ISC_QUAD); - break; - } -} - - -/** - - xsqlvar_to_sqlvar - - @brief Move an XSQLVAR to an SQLVAR. - - - @param xsqlvar - @param sqlvar - - **/ -static void xsqlvar_to_sqlvar(const XSQLVAR* xsqlvar, SQLVAR* sqlvar) -{ - - sqlvar->sqltype = xsqlvar->sqltype; - sqlvar->sqlname_length = xsqlvar->aliasname_length; - - // N.B., this may not NULL-terminate the name... - - memcpy(sqlvar->sqlname, xsqlvar->aliasname, sizeof(sqlvar->sqlname)); - - sqlvar->sqllen = xsqlvar->sqllen; - const USHORT scale = xsqlvar->sqlscale << 8; - switch (sqlvar->sqltype & ~1) - { - case SQL_LONG: - sqlvar->sqllen = sizeof(SLONG) | scale; - break; - case SQL_SHORT: - sqlvar->sqllen = sizeof(SSHORT) | scale; - break; - case SQL_INT64: - sqlvar->sqllen = sizeof(SINT64) | scale; - break; - case SQL_QUAD: - sqlvar->sqllen = sizeof(ISC_QUAD) | scale; - break; - } -} diff --git a/src/dsql/utld_proto.h b/src/dsql/utld_proto.h index 391b7ec054..65d2f25498 100644 --- a/src/dsql/utld_proto.h +++ b/src/dsql/utld_proto.h @@ -27,15 +27,8 @@ #ifndef DSQL_UTLD_PROTO_H #define DSQL_UTLD_PROTO_H -struct sqlda_sup; - USHORT UTLD_char_length_to_byte_length(USHORT lengthInChars, USHORT maxBytesPerChar); ISC_STATUS UTLD_copy_status(const ISC_STATUS*, ISC_STATUS*); -ISC_STATUS UTLD_parse_sql_info(ISC_STATUS*, USHORT, const SCHAR*, XSQLDA*, USHORT*); -ISC_STATUS UTLD_parse_sqlda(ISC_STATUS*, sqlda_sup* const, USHORT*, USHORT*, - USHORT*, USHORT, const XSQLDA*, const USHORT); -void UTLD_save_status_strings(ISC_STATUS*); -SCHAR* UTLD_skip_sql_info(SCHAR*); #endif // DSQL_UTLD_PROTO_H diff --git a/src/gpre/gpre_meta_boot.cpp b/src/gpre/boot/gpre_meta_boot.cpp similarity index 99% rename from src/gpre/gpre_meta_boot.cpp rename to src/gpre/boot/gpre_meta_boot.cpp index c5db01e04d..21c2ecd742 100644 --- a/src/gpre/gpre_meta_boot.cpp +++ b/src/gpre/boot/gpre_meta_boot.cpp @@ -40,7 +40,7 @@ #include "../gpre/gpre_meta.h" #include "../gpre/msc_proto.h" #include "../gpre/par_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" static const UCHAR blr_bpb[] = { diff --git a/src/gpre/c_cxx.cpp b/src/gpre/c_cxx.cpp index da1ec97f80..d2fbfeccc9 100644 --- a/src/gpre/c_cxx.cpp +++ b/src/gpre/c_cxx.cpp @@ -42,8 +42,8 @@ #include "../gpre/gpre_proto.h" #include "../gpre/lang_proto.h" #include "../gpre/pat_proto.h" -#include "../gpre/prett_proto.h" -#include "../jrd/gds_proto.h" +#include "../common/prett_proto.h" +#include "../yvalve/gds_proto.h" #include "../common/utils_proto.h" diff --git a/src/gpre/cme.cpp b/src/gpre/cme.cpp index cb1c15130c..6eff04901a 100644 --- a/src/gpre/cme.cpp +++ b/src/gpre/cme.cpp @@ -39,8 +39,8 @@ #include "../gpre/gpre_meta.h" #include "../gpre/movg_proto.h" #include "../gpre/par_proto.h" -#include "../gpre/prett_proto.h" -#include "../jrd/dsc_proto.h" +#include "../common/prett_proto.h" +#include "../common/dsc_proto.h" #include "../gpre/msc_proto.h" #include "../jrd/align.h" diff --git a/src/gpre/dyntable.cpp b/src/gpre/dyntable.cpp deleted file mode 100644 index 018ffc1eea..0000000000 --- a/src/gpre/dyntable.cpp +++ /dev/null @@ -1,154 +0,0 @@ -//____________________________________________________________ -// -// PROGRAM: BLR Pretty Printer -// MODULE: dyntable.cpp -// DESCRIPTION: Dynamic DDL to internal conversion table generator -// -// The contents of this file are subject to the Interbase Public -// License Version 1.0 (the "License"); you may not use this file -// except in compliance with the License. You may obtain a copy -// of the License at http://www.Inprise.com/IPL.html -// -// Software distributed under the License is distributed on an -// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express -// or implied. See the License for the specific language governing -// rights and limitations under the License. -// -// The Original Code was created by Inprise Corporation -// and its predecessors. Portions created by Inprise Corporation are -// Copyright (C) Inprise Corporation. -// -// All Rights Reserved. -// Contributor(s): ______________________________________. -// -// -//____________________________________________________________ -// -// -// CVC: Strange, this file is only referenced in a MacOsX project and gpre -// works directly with dyntable.h. - -#include "firebird.h" -#include -#include "../jrd/ibase.h" - -#define NODE(dyn) {dyn, "dyn"}, - -struct dyn -{ - SSHORT dyn_value; - const char* dyn_string; -}; - -const dyn dyn_table[] = -{ - NODE(gds__dyn_begin) - NODE(gds__dyn_end) - NODE(gds__dyn_if) - NODE(gds__dyn_def_database) - NODE(gds__dyn_def_global_fld) - NODE(gds__dyn_def_local_fld) - NODE(gds__dyn_def_idx) - NODE(gds__dyn_def_rel) - NODE(gds__dyn_def_view) - NODE(gds__dyn_def_sql_fld) - NODE(gds__dyn_def_trigger) - NODE(gds__dyn_mod_rel) - NODE(gds__dyn_mod_global_fld) - NODE(gds__dyn_mod_local_fld) - NODE(gds__dyn_mod_view) - NODE(gds__dyn_delete_database) - NODE(gds__dyn_delete_rel) - NODE(gds__dyn_delete_global_fld) - NODE(gds__dyn_delete_local_fld) - NODE(gds__dyn_delete_idx) - NODE(gds__dyn_rel_defined) - NODE(gds__dyn_global_fld_defined) - NODE(gds__dyn_local_fld_defined) - NODE(gds__dyn_index_defined) - NODE(gds__dyn_not) - NODE(gds__dyn_and) - NODE(gds__dyn_or) - NODE(gds__dyn_rel_name) - NODE(gds__dyn_fld_name) - NODE(gds__dyn_idx_name) - NODE(gds__dyn_description) - NODE(gds__dyn_security_class) - NODE(gds__dyn_system_flag) - NODE(gds__dyn_update_flag) - - NODE(gds__dyn_view_blr) - NODE(gds__dyn_view_source) - NODE(gds__dyn_view_relation) - NODE(gds__dyn_view_context) - NODE(gds__dyn_view_context_name) - - NODE(gds__dyn_rel_dbkey_length) - NODE(gds__dyn_rel_store_trig) - NODE(gds__dyn_rel_modify_trig) - NODE(gds__dyn_rel_erase_trig) - NODE(gds__dyn_rel_store_trig_source) - NODE(gds__dyn_rel_modify_trig_source) - NODE(gds__dyn_rel_erase_trig_source) - NODE(gds__dyn_rel_sql_protection) - NODE(gds__dyn_fld_type) - NODE(gds__dyn_fld_length) - NODE(gds__dyn_fld_scale) - NODE(gds__dyn_fld_sub_type) - NODE(gds__dyn_fld_segment_length) - NODE(gds__dyn_fld_query_header) - NODE(gds__dyn_fld_edit_string) - NODE(gds__dyn_fld_validation_blr) - NODE(gds__dyn_fld_validate_source) - NODE(gds__dyn_fld_computed_blr) - NODE(gds__dyn_fld_computed_source) - NODE(gds__dyn_fld_missing_value) - NODE(gds__dyn_fld_default_value) - NODE(gds__dyn_fld_query_name) - NODE(gds__dyn_fld_source) - NODE(gds__dyn_fld_base_fld) - NODE(gds__dyn_fld_position) - NODE(gds__dyn_fld_update_flag) - NODE(gds__dyn_idx_unique) - NODE(gds__dyn_idx_active) - NODE(gds__dyn_trg_type) - NODE(gds__dyn_trg_blr) - NODE(gds__dyn_trg_source) - {0, 0} -}; -//int *table[256]; - - -//____________________________________________________________ -// -// Spit out a conversion table. -// - -int main() -{ - int max; - const char* table[256]; - - for (max = 0; max < 256; max++) - table[max] = NULL; - - max = 0; - for (const dyn* item = dyn_table; item->dyn_string; item++) { - if (table[item->dyn_value]) - fprintf(stderr, "%s (%d) is duplicate\n", item->dyn_string, item->dyn_value); - table[item->dyn_value] = item->dyn_string; - if (item->dyn_value > max) - max = item->dyn_value; - } - - for (int dyn_iter = 0; dyn_iter <= max; dyn_iter++) - { - if (table[dyn_iter]) - printf(" \"%s\",\n", table[dyn_iter]); - else - printf(" NULL,\n"); - } - - return 0; -} - diff --git a/src/gpre/gpre.h b/src/gpre/gpre.h index a940d1c1ad..f4e2b52f1e 100644 --- a/src/gpre/gpre.h +++ b/src/gpre/gpre.h @@ -1515,7 +1515,7 @@ struct upd { const size_t UPD_LEN = sizeof(upd); -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "parse.h" // GPRE wide globals diff --git a/src/gpre/int_cxx.cpp b/src/gpre/int_cxx.cpp index 6858a23740..f23446d2e4 100644 --- a/src/gpre/int_cxx.cpp +++ b/src/gpre/int_cxx.cpp @@ -35,7 +35,7 @@ #include "../gpre/gpre.h" #include "../gpre/gpre_proto.h" #include "../gpre/lang_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../common/utils_proto.h" static void align(const int); diff --git a/src/gpre/ada.cpp b/src/gpre/languages/ada.cpp similarity index 99% rename from src/gpre/ada.cpp rename to src/gpre/languages/ada.cpp index 40912a4bb4..811c9ef406 100644 --- a/src/gpre/ada.cpp +++ b/src/gpre/languages/ada.cpp @@ -42,8 +42,8 @@ #include "../gpre/gpre_proto.h" #include "../gpre/lang_proto.h" #include "../gpre/pat_proto.h" -#include "../gpre/prett_proto.h" -#include "../jrd/gds_proto.h" +#include "../common/prett_proto.h" +#include "../yvalve/gds_proto.h" #include "../common/utils_proto.h" static void align (int); diff --git a/src/gpre/cob.cpp b/src/gpre/languages/cob.cpp similarity index 99% rename from src/gpre/cob.cpp rename to src/gpre/languages/cob.cpp index fb16bdb978..2be8251877 100644 --- a/src/gpre/cob.cpp +++ b/src/gpre/languages/cob.cpp @@ -44,13 +44,13 @@ #include "../jrd/common.h" #include #include "../jrd/ibase.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../gpre/gpre.h" #include "../gpre/pat.h" #include "../gpre/cmp_proto.h" #include "../gpre/lang_proto.h" #include "../gpre/pat_proto.h" -#include "../gpre/prett_proto.h" +#include "../common/prett_proto.h" #include "../gpre/gpre_proto.h" #include "../common/utils_proto.h" diff --git a/src/gpre/fbrmclib.cpp b/src/gpre/languages/fbrmclib.cpp similarity index 100% rename from src/gpre/fbrmclib.cpp rename to src/gpre/languages/fbrmclib.cpp diff --git a/src/gpre/ftn.cpp b/src/gpre/languages/ftn.cpp similarity index 99% rename from src/gpre/ftn.cpp rename to src/gpre/languages/ftn.cpp index 2dc1943d1e..de90e125f4 100644 --- a/src/gpre/ftn.cpp +++ b/src/gpre/languages/ftn.cpp @@ -35,14 +35,14 @@ #include "../jrd/common.h" #include #include "../jrd/ibase.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../gpre/gpre.h" #include "../gpre/pat.h" #include "../gpre/cmp_proto.h" #include "../gpre/gpre_proto.h" #include "../gpre/lang_proto.h" #include "../gpre/pat_proto.h" -#include "../gpre/prett_proto.h" +#include "../common/prett_proto.h" #include "../gpre/msc_proto.h" #include "../common/utils_proto.h" diff --git a/src/gpre/pas.cpp b/src/gpre/languages/pas.cpp similarity index 99% rename from src/gpre/pas.cpp rename to src/gpre/languages/pas.cpp index 56bd9c10ca..86def210b8 100644 --- a/src/gpre/pas.cpp +++ b/src/gpre/languages/pas.cpp @@ -38,8 +38,8 @@ #include "../gpre/lang_proto.h" #include "../gpre/pat_proto.h" #include "../gpre/gpre_proto.h" -#include "../gpre/prett_proto.h" -#include "../jrd/gds_proto.h" +#include "../common/prett_proto.h" +#include "../yvalve/gds_proto.h" #include "../common/utils_proto.h" #pragma FB_COMPILER_MESSAGE("This file is not fit for public consumption") diff --git a/src/gpre/rmc.cpp b/src/gpre/languages/rmc.cpp similarity index 99% rename from src/gpre/rmc.cpp rename to src/gpre/languages/rmc.cpp index e9ce2daf9d..d1a716f235 100644 --- a/src/gpre/rmc.cpp +++ b/src/gpre/languages/rmc.cpp @@ -30,13 +30,13 @@ #include "../jrd/common.h" #include #include "../jrd/ibase.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../gpre/gpre.h" #include "../gpre/pat.h" #include "../gpre/cmp_proto.h" #include "../gpre/lang_proto.h" #include "../gpre/pat_proto.h" -#include "../gpre/prett_proto.h" +#include "../common/prett_proto.h" #include "../gpre/gpre_proto.h" #include "../common/utils_proto.h" diff --git a/src/gpre/movg.cpp b/src/gpre/movg.cpp index 7526157fa8..a1d88232af 100644 --- a/src/gpre/movg.cpp +++ b/src/gpre/movg.cpp @@ -29,7 +29,7 @@ #include "../jrd/common.h" #include -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../gpre/movg_proto.h" // TMN: Unfortunately we need to include gpre.h before gpre_proto.h since // the latter references a macro from the former, and doesn't include that diff --git a/src/gpre/msc.cpp b/src/gpre/msc.cpp index 4029568577..5507b778fb 100644 --- a/src/gpre/msc.cpp +++ b/src/gpre/msc.cpp @@ -47,7 +47,7 @@ #include "../gpre/gpre.h" #include "../gpre/gpre_proto.h" #include "../gpre/msc_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" struct gpre_space diff --git a/src/gpre/gpre_meta.epp b/src/gpre/std/gpre_meta.epp similarity index 100% rename from src/gpre/gpre_meta.epp rename to src/gpre/std/gpre_meta.epp diff --git a/src/include/ProviderInterface.h b/src/include/ProviderInterface.h new file mode 100644 index 0000000000..36dfa31d87 --- /dev/null +++ b/src/include/ProviderInterface.h @@ -0,0 +1,244 @@ +/* + * PROGRAM: Firebird basic API + * MODULE: YValveInterface.h + * DESCRIPTION: Interfaces, used by yValve + * + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. + * + * Software distributed under the License is distributed AS IS, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. + * See the License for the specific language governing rights + * and limitations under the License. + * + * The Original Code was created by Alex Peshkov + * for the Firebird Open Source RDBMS project. + * + * Copyright (c) 2010 Alex Peshkov + * and all contributors signed below. + * + * All Rights Reserved. + * Contributor(s): ______________________________________. + * + * + */ + +#ifndef FB_PROVIDER_INTERFACE +#define FB_PROVIDER_INTERFACE + +#include "firebird.h" +#include "../common/classes/Interface.h" + +namespace FbApi { // Do not mix it with namespace Why + +class Attachment; // Forward + +class EventCallback +{ +public: + virtual void eventCallbackFunction(unsigned int length, const UCHAR* events) = 0; +}; + +/* +class ShutdownCallback +{ +public: + virtual void shutdownCallbackFunction(int reason, int mask) = 0; +}; + +class MultipleTransaction +{ +public: + virtual unsigned int count() = 0; + virtual Attachment* attachment(unsigned int n) = 0; + virtual unsigned char* tpb(unsigned int n) = 0; + virtual unsigned int tpbLength(unsigned int n) = 0; +}; +*/ + +class Status : public Firebird::Interface +{ +public: + virtual void set(size_t length, const ISC_STATUS* value) = 0; + virtual void set(const ISC_STATUS* value) = 0; + virtual void init() = 0; + + virtual const ISC_STATUS* get() const = 0; + virtual int isSuccess() const = 0; +}; + +//class Sqlda; // from Vulcan mainly + +class Blob : public Firebird::Interface +{ +public: + virtual void getInfo(Status* status, + unsigned int itemsLength, const unsigned char* items, + unsigned int bufferLength, unsigned char* buffer) = 0; + virtual unsigned int getSegment(Status* status, unsigned int length, unsigned char* buffer) = 0; // returns real length + virtual void putSegment(Status* status, unsigned int length, const unsigned char* buffer) = 0; + virtual void cancel(Status* status) = 0; + virtual void close(Status* status) = 0; + virtual int seek(Status* status, int mode, int offset) = 0; // returns position +}; + +class Transaction : public Firebird::Interface +{ +public: + virtual void getInfo(Status* status, + unsigned int itemsLength, const unsigned char* items, + unsigned int bufferLength, unsigned char* buffer) = 0; + virtual Blob* createBlob(Status* status, ISC_QUAD* id, + unsigned int bpbLength = 0, const unsigned char* bpb = 0, + Attachment* att = 0) = 0; + virtual Blob* openBlob(Status* status, ISC_QUAD* id, + unsigned int bpbLength = 0, const unsigned char* bpb = 0, + Attachment* att = 0) = 0; + virtual int getSlice(Status* status, ISC_QUAD* id, + unsigned int sdl_length, const unsigned char* sdl, + unsigned int param_length, const unsigned char* param, + int sliceLength, unsigned char* slice, + Attachment* att = 0) = 0; + virtual void putSlice(Status* status, ISC_QUAD* id, + unsigned int sdl_length, const unsigned char* sdl, + unsigned int param_length, const unsigned char* param, + int sliceLength, unsigned char* slice, + Attachment* att = 0) = 0; + virtual void transactRequest(Status* status, + unsigned int blr_length, const unsigned char* blr, + unsigned int in_msg_length, const unsigned char* in_msg, + unsigned int out_msg_length, unsigned char* out_msg, + Attachment* att = 0) = 0; + virtual void prepare(Status* status, + unsigned int msg_length = 0, const unsigned char* message = 0) = 0; + virtual void ddl(Status* status, unsigned int length, const unsigned char* ddlCommand) = 0; + virtual void commit(Status* status) = 0; + virtual void commitRetaining(Status* status) = 0; + virtual void rollback(Status* status) = 0; + virtual void rollbackRetaining(Status* status) = 0; + // virtual void disconnect(Status* status) = 0; // Y-valve only object +}; + +class Statement : public Firebird::Interface +{ +public: + //virtual Sqlda* describeInput(Status* status) = 0; + //virtual Sqlda* describeOutput(Status* status) = 0; + + // FixMe - prepare must return void, not new statement handle + virtual Statement* prepare(Status* status, Transaction* tra, + unsigned int stmtLength, const char* sqlStmt, unsigned int dialect, + unsigned int item_length, const unsigned char* items, + unsigned int buffer_length, unsigned char* buffer) = 0; + + virtual void getInfo(Status* status, + unsigned int itemsLength, const unsigned char* items, + unsigned int bufferLength, unsigned char* buffer) = 0; + virtual void setCursor(Status* status, const char* name, unsigned int type) = 0; +// virtual Transaction* execute(Status* status, Transaction* tra, Sqlda* in, Sqlda* out) = 0; + virtual Transaction* executeMessage(Status* status, Transaction* tra, + unsigned int in_blr_length, const unsigned char* in_blr, + unsigned int in_msg_type, + unsigned int in_msg_length, const unsigned char* in_message, + unsigned int out_blr_length, const unsigned char* out_blr, + unsigned int out_msg_type, + unsigned int out_msg_length, unsigned char* out_message) = 0; +// virtual int fetch(Status* status, Sqlda* out) = 0; // returns 100 if EOF, 101 if fragmented + virtual int fetchMessage(Status* status, + unsigned int blr_length, const unsigned char* blr, + unsigned int msg_type, + unsigned int msg_length, unsigned char* message) = 0; // returns 100 if EOF, 101 if fragmented +// virtual void insert(Status* status, Sqlda* in) = 0; + virtual void insertMessage(Status* status, + unsigned int blr_length, const unsigned char* blr, + unsigned int msg_type, + unsigned int msg_length, const unsigned char* message) = 0; + virtual void free(Status* status, unsigned int option) = 0; +}; + +class Request : public Firebird::Interface +{ +public: + virtual void receive(Status* status, int level, unsigned int msg_type, + unsigned int length, unsigned char* message) = 0; + virtual void send(Status* status, int level, unsigned int msg_type, + unsigned int length, const unsigned char* message) = 0; + virtual void getInfo(Status* status, int level, + unsigned int itemsLength, const unsigned char* items, + unsigned int bufferLength, unsigned char* buffer) = 0; + virtual void start(Status* status, Transaction* tra, int level) = 0; + virtual void startAndSend(Status* status, Transaction* tra, int level, unsigned int msg_type, + unsigned int length, const unsigned char* message) = 0; + virtual void unwind(Status* status, int level) = 0; + virtual void detach(Status* status) = 0; +}; + +class Events : public Firebird::Interface +{ +public: + virtual void cancel(Status* status) = 0; +}; + +class Attachment : public Firebird::Interface +{ +public: + virtual void getInfo(Status* status, + unsigned int itemsLength, const unsigned char* items, + unsigned int bufferLength, unsigned char* buffer) = 0; +// virtual Transaction* startTransaction(Status* status, unsigned int tpbLength, const unsigned char* tpb) = 0; +// second form is tmp - not to rewrite external engines right now + virtual Transaction* startTransaction(Status* status, unsigned int tpbLength, const unsigned char* tpb, + FB_API_HANDLE api) = 0; + virtual Transaction* reconnectTransaction(Status* status, unsigned int length, const unsigned char* id) = 0; + virtual Statement* allocateStatement(Status* status) = 0; + virtual Request* compileRequest(Status* status, unsigned int blr_length, const unsigned char* blr) = 0; + virtual Transaction* execute(Status* status, Transaction* transaction, + unsigned int length, const char* string, unsigned int dialect, + unsigned int in_blr_length, const unsigned char* in_blr, + unsigned int in_msg_type, unsigned int in_msg_length, const unsigned char* in_msg, + unsigned int out_blr_length, unsigned char* out_blr, + unsigned int out_msg_type, unsigned int out_msg_length, unsigned char* out_msg) = 0; + virtual Events* queEvents(Status* status, EventCallback* callback, + unsigned int length, const unsigned char* events) = 0; + virtual void cancelOperation(Status* status, int option) = 0; + virtual void ping(Status* status) = 0; + virtual void detach(Status* status) = 0; + virtual void drop(Status* status) = 0; +}; + +class Service : public Firebird::Interface +{ +public: + virtual void detach(Status* status) = 0; + virtual void query(Status* status, + unsigned int sendLength, const unsigned char* sendItems, + unsigned int receiveLength, const unsigned char* receiveItems, + unsigned int bufferLength, unsigned char* buffer) = 0; + virtual void start(Status* status, + unsigned int spbLength, const unsigned char* spb) = 0; +}; + +class Provider : public Firebird::Plugin +{ +public: + virtual void attachDatabase(Attachment** ptr, Status* status, FB_API_HANDLE api, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb) = 0; + virtual void createDatabase(Attachment** ptr, Status* status, FB_API_HANDLE api, const char* fileName, + unsigned int dpbLength, const unsigned char* dpb) = 0; + virtual Service* attachServiceManager(Status* status, const char* service, + unsigned int spbLength, const unsigned char* spb) = 0; + //virtual Transaction* startTransaction(Status* status, unsigned int count, ...) = 0; + //virtual Transaction* startMultiple(Status* status, MultipleTransaction* multi) = 0; + virtual int shutdown(unsigned int timeout, const int reason) = 0; + //virtual void fb_shutdown_callback(Status* status, const int mask, ShutdownCallback* callback) = 0; +}; + +extern "C" Status* ISC_EXPORT fb_get_status_instance(); + +} // namespace FbApi + + +#endif // FB_PROVIDER_INTERFACE diff --git a/src/include/fb_api_proto.h b/src/include/fb_api_proto.h index 6f825c1bc0..eecb3a99bf 100644 --- a/src/include/fb_api_proto.h +++ b/src/include/fb_api_proto.h @@ -301,7 +301,7 @@ typedef ISC_STATUS ISC_EXPORT prototype_isc_get_slice(ISC_STATUS *, ISC_LONG *); typedef ISC_STATUS ISC_EXPORT prototype_isc_interprete(char *, - ISC_STATUS * *); + const ISC_STATUS * *); typedef ISC_STATUS ISC_EXPORT prototype_isc_open_blob(ISC_STATUS *, isc_db_handle *, diff --git a/src/include/fb_blk.h b/src/include/fb_blk.h index 53cb6ebfec..9d0b8d8155 100644 --- a/src/include/fb_blk.h +++ b/src/include/fb_blk.h @@ -51,6 +51,7 @@ enum BlockType type_opt, type_prf, type_ctl, + type_Events, type_PageSpace, type_PageManager, @@ -80,7 +81,8 @@ enum BlockType rem_type_rrq, rem_type_rtr, rem_type_rbl, - rem_type_rsr + rem_type_rsr, + rem_type_rev }; diff --git a/src/include/fb_exception.h b/src/include/fb_exception.h index f30df9b7ee..11eb4cb0ee 100644 --- a/src/include/fb_exception.h +++ b/src/include/fb_exception.h @@ -37,6 +37,11 @@ #include "../common/StatusArg.h" #include "../common/thd.h" +namespace FbApi +{ + class Status; +}; + namespace Firebird { class MemoryPool; @@ -46,8 +51,9 @@ class Exception protected: Exception() throw() { } public: + ISC_STATUS stuff_exception(ISC_STATUS* const status_vector) const throw(); virtual ~Exception() throw(); - virtual ISC_STATUS stuff_exception(ISC_STATUS* const status_vector) const throw() = 0; + virtual ISC_STATUS stuffException(FbApi::Status* status_vector) const throw() = 0; virtual const char* what() const throw() = 0; }; @@ -55,7 +61,7 @@ public: class LongJump : public Exception { public: - virtual ISC_STATUS stuff_exception(ISC_STATUS* const status_vector) const throw(); + virtual ISC_STATUS stuffException(FbApi::Status* status_vector) const throw(); virtual const char* what() const throw(); static void raise(); LongJump() throw() : Exception() { } @@ -65,7 +71,7 @@ public: class BadAlloc : public std::bad_alloc, public Exception { public: - virtual ISC_STATUS stuff_exception(ISC_STATUS* const status_vector) const throw(); + virtual ISC_STATUS stuffException(FbApi::Status* status_vector) const throw(); virtual const char* what() const throw(); static void raise(); BadAlloc() throw() : std::bad_alloc(), Exception() { } @@ -78,7 +84,7 @@ public: status_exception(const ISC_STATUS *status_vector) throw(); virtual ~status_exception() throw(); - virtual ISC_STATUS stuff_exception(ISC_STATUS* const status_vector) const throw(); + virtual ISC_STATUS stuffException(FbApi::Status* status_vector) const throw(); virtual const char* what() const throw(); const ISC_STATUS* value() const throw() { return m_status_vector; } @@ -143,6 +149,7 @@ public: // Serialize exception into status_vector ISC_STATUS stuff_exception(ISC_STATUS *status_vector, const Firebird::Exception& ex) throw(); +ISC_STATUS stuff_exception(FbApi::Status *status, const Firebird::Exception& ex) throw(); // Put status vector strings into strings buffer void makePermanentVector(ISC_STATUS* perm, const ISC_STATUS* trans, FB_THREAD_ID thr = getThreadId()) throw(); diff --git a/src/include/gen/codetext.h b/src/include/gen/codetext.h index a2a13cc203..a7d4332111 100644 --- a/src/include/gen/codetext.h +++ b/src/include/gen/codetext.h @@ -721,6 +721,7 @@ static const struct { {"async_active", 335545017}, {"private_function", 335545018}, {"private_procedure", 335545019}, + {"bad_events_handle", 335545020}, {"gfix_db_name", 335740929}, {"gfix_invalid_sw", 335740930}, {"gfix_incmp_sw", 335740932}, diff --git a/src/include/gen/iberror.h b/src/include/gen/iberror.h index 2c889042b7..d2c1c7eda2 100644 --- a/src/include/gen/iberror.h +++ b/src/include/gen/iberror.h @@ -755,6 +755,7 @@ const ISC_STATUS isc_formatted_exception = 335545016L; const ISC_STATUS isc_async_active = 335545017L; const ISC_STATUS isc_private_function = 335545018L; const ISC_STATUS isc_private_procedure = 335545019L; +const ISC_STATUS isc_bad_events_handle = 335545020L; const ISC_STATUS isc_gfix_db_name = 335740929L; const ISC_STATUS isc_gfix_invalid_sw = 335740930L; const ISC_STATUS isc_gfix_incmp_sw = 335740932L; @@ -1173,7 +1174,7 @@ const ISC_STATUS isc_trace_switch_user_only = 337182757L; const ISC_STATUS isc_trace_switch_param_miss = 337182758L; const ISC_STATUS isc_trace_param_act_notcompat = 337182759L; const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L; -const ISC_STATUS isc_err_max = 1117; +const ISC_STATUS isc_err_max = 1118; #else /* c definitions */ @@ -1898,6 +1899,7 @@ const ISC_STATUS isc_err_max = 1117; #define isc_async_active 335545017L #define isc_private_function 335545018L #define isc_private_procedure 335545019L +#define isc_bad_events_handle 335545020L #define isc_gfix_db_name 335740929L #define isc_gfix_invalid_sw 335740930L #define isc_gfix_incmp_sw 335740932L @@ -2316,7 +2318,7 @@ const ISC_STATUS isc_err_max = 1117; #define isc_trace_switch_param_miss 337182758L #define isc_trace_param_act_notcompat 337182759L #define isc_trace_mandatory_switch_miss 337182760L -#define isc_err_max 1117 +#define isc_err_max 1118 #endif diff --git a/src/include/gen/msgs.h b/src/include/gen/msgs.h index 1267b46411..51d4c268b7 100644 --- a/src/include/gen/msgs.h +++ b/src/include/gen/msgs.h @@ -724,6 +724,7 @@ Data source : @4"}, /* eds_statement */ {335545017, "Asynchronous call is already running for this attachment"}, /* async_active */ {335545018, "Function @1 is private to package @2"}, /* private_function */ {335545019, "Procedure @1 is private to package @2"}, /* private_procedure */ + {335545020, "invalid events id (handle)"}, /* bad_events_handle */ {335740929, "data base file name (@1) already given"}, /* gfix_db_name */ {335740930, "invalid switch @1"}, /* gfix_invalid_sw */ {335740932, "incompatible switch combination"}, /* gfix_incmp_sw */ diff --git a/src/include/gen/sql_code.h b/src/include/gen/sql_code.h index 9b62c4f663..2dc26e1d85 100644 --- a/src/include/gen/sql_code.h +++ b/src/include/gen/sql_code.h @@ -720,6 +720,7 @@ static const struct { {335545017, -532}, /* 697 async_active */ {335545018, -901}, /* 698 private_function */ {335545019, -901}, /* 699 private_procedure */ + {335545020, -901}, /* 700 bad_events_handle */ {335740929, -901}, /* 1 gfix_db_name */ {335740930, -901}, /* 2 gfix_invalid_sw */ {335740932, -901}, /* 4 gfix_incmp_sw */ diff --git a/src/include/gen/sql_state.h b/src/include/gen/sql_state.h index b47b763b96..a387607508 100644 --- a/src/include/gen/sql_state.h +++ b/src/include/gen/sql_state.h @@ -720,6 +720,7 @@ static const struct { {335545017, "HY018"}, // 697 async_active {335545018, "42000"}, // 698 private_function {335545019, "42000"}, // 699 private_procedure + {335545020, "08003"}, // 700 bad_events_handle {335740929, "00000"}, // 1 gfix_db_name {335740930, "00000"}, // 2 gfix_invalid_sw {335740932, "00000"}, // 4 gfix_incmp_sw diff --git a/src/intl/lc_ascii.cpp b/src/intl/lc_ascii.cpp index d23626386b..16650670a1 100644 --- a/src/intl/lc_ascii.cpp +++ b/src/intl/lc_ascii.cpp @@ -24,8 +24,8 @@ #include "firebird.h" #include "../common/classes/alloc.h" #include "../intl/ldcommon.h" -#include "../jrd/CharSet.h" -#include "../jrd/IntlUtil.h" +#include "../common/CharSet.h" +#include "../common/IntlUtil.h" #include "ld_proto.h" #include "lc_ascii.h" diff --git a/src/intl/lc_icu.cpp b/src/intl/lc_icu.cpp index 55ddb72b10..aed4f4fe75 100644 --- a/src/intl/lc_icu.cpp +++ b/src/intl/lc_icu.cpp @@ -30,8 +30,8 @@ #include "ld_proto.h" #include "lc_icu.h" #include "cs_icu.h" -#include "../jrd/CharSet.h" -#include "../jrd/IntlUtil.h" +#include "../common/CharSet.h" +#include "../common/IntlUtil.h" #include "../common/classes/auto.h" using namespace Firebird; diff --git a/src/intl/lc_iso8859_1.cpp b/src/intl/lc_iso8859_1.cpp index a1acef8322..070df29091 100644 --- a/src/intl/lc_iso8859_1.cpp +++ b/src/intl/lc_iso8859_1.cpp @@ -25,7 +25,7 @@ #include "firebird.h" #include "../intl/ldcommon.h" #include "../intl/ld_proto.h" -#include "../jrd/CharSet.h" +#include "../common/CharSet.h" #include "lc_narrow.h" #include "lc_dos.h" diff --git a/src/intl/lc_narrow.cpp b/src/intl/lc_narrow.cpp index 66887b34cc..a91cd7d5af 100644 --- a/src/intl/lc_narrow.cpp +++ b/src/intl/lc_narrow.cpp @@ -25,8 +25,8 @@ #include "firebird.h" #include "../common/classes/alloc.h" #include "../intl/ldcommon.h" -#include "../jrd/CharSet.h" -#include "../jrd/IntlUtil.h" +#include "../common/CharSet.h" +#include "../common/IntlUtil.h" #include "lc_narrow.h" #include "ld_proto.h" #include diff --git a/src/intl/ld.cpp b/src/intl/ld.cpp index 4ae81d293f..db54211d7e 100644 --- a/src/intl/ld.cpp +++ b/src/intl/ld.cpp @@ -23,7 +23,7 @@ */ #include "firebird.h" -#include "../jrd/IntlUtil.h" +#include "../common/IntlUtil.h" #include "../intl/ldcommon.h" #include "../intl/ld_proto.h" #include "../intl/cs_icu.h" diff --git a/src/intl/ldcommon.h b/src/intl/ldcommon.h index edc36c0c96..7e2c1055fa 100644 --- a/src/intl/ldcommon.h +++ b/src/intl/ldcommon.h @@ -25,7 +25,7 @@ #define INTL_LDCOMMON_H #include "../common/classes/alloc.h" -#include "../jrd/intlobj_new.h" +#include "../common/intlobj_new.h" #include "../jrd/constants.h" #include "../jrd/gdsassert.h" #include "../intl/charsets.h" diff --git a/src/iscguard/cntl_guard.cpp b/src/iscguard/cntl_guard.cpp index 65f5cadd5e..9fd63271fb 100644 --- a/src/iscguard/cntl_guard.cpp +++ b/src/iscguard/cntl_guard.cpp @@ -27,8 +27,8 @@ #include "../iscguard/cntlg_proto.h" #include "../remote/remote.h" #include "../utilities/install/install_nt.h" -#include "../jrd/isc_proto.h" -#include "../jrd/gds_proto.h" +#include "../common/isc_proto.h" +#include "../yvalve/gds_proto.h" #include "../common/classes/fb_string.h" #include "../common/classes/init.h" diff --git a/src/iscguard/cntlg_proto.h b/src/iscguard/cntlg_proto.h index d1e9e23b9c..3a0b3d8ffc 100644 --- a/src/iscguard/cntlg_proto.h +++ b/src/iscguard/cntlg_proto.h @@ -24,7 +24,7 @@ #ifndef REMOTE_CNTL_PROTO_H #define REMOTE_CNTL_PROTO_H -#include "../jrd/ThreadStart.h" +#include "../common/ThreadStart.h" void CNTL_init(ThreadEntryPoint*, const TEXT*); void* CNTL_insert_thread(); diff --git a/src/iscguard/iscguard.cpp b/src/iscguard/iscguard.cpp index 22a90adf43..afeeb9d024 100644 --- a/src/iscguard/iscguard.cpp +++ b/src/iscguard/iscguard.cpp @@ -19,7 +19,7 @@ #include "firebird.h" #include "../jrd/common.h" #include -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include #include #include @@ -43,7 +43,7 @@ #include "../remote/os/win32/chop_proto.h" #include "../common/config/config.h" #include "../common/classes/init.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #ifdef WIN_NT #include // _beginthread diff --git a/src/isql/InputDevices.h b/src/isql/InputDevices.h index 6acd24fba3..90b3714781 100644 --- a/src/isql/InputDevices.h +++ b/src/isql/InputDevices.h @@ -26,7 +26,7 @@ #define FB_INPUT_DEVICES_H #include "../common/classes/fb_string.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #include // This is basically a stack of input files caused by the INPUT command, diff --git a/src/isql/extract.epp b/src/isql/extract.epp index b5d8a50c3c..e4f8ae2c7b 100644 --- a/src/isql/extract.epp +++ b/src/isql/extract.epp @@ -48,8 +48,8 @@ #include "../jrd/common.h" #include "../jrd/constants.h" #include "../jrd/ibase.h" -#include "../jrd/gds_proto.h" -#include "../jrd/intlobj_new.h" +#include "../yvalve/gds_proto.h" +#include "../common/intlobj_new.h" #include "../isql/isql.h" #include "../isql/extra_proto.h" #include "../isql/isql_proto.h" diff --git a/src/isql/isql.epp b/src/isql/isql.epp index 7163f41ed6..11ccb38e9f 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -45,8 +45,8 @@ #include "firebird.h" #include -#include "../dsql/keywords.h" -//#include "../jrd/gds_proto.h" +#include "../yvalve/keywords.h" +//#include "../yvalve/gds_proto.h" #include #include #include @@ -60,7 +60,7 @@ #include "../common/classes/ClumpletWriter.h" #include "../common/classes/TempFile.h" #include "../common/classes/FpeControl.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #ifdef HAVE_UNISTD_H #include @@ -99,7 +99,7 @@ enum literal_string_type #endif #include "../jrd/ibase.h" #include "../isql/isql.h" -#include "../jrd/perf.h" +#include "../yvalve/perf.h" #include "../jrd/license.h" #include "../jrd/constants.h" #include "../jrd/ods.h" @@ -109,9 +109,9 @@ enum literal_string_type #include "../isql/isql_proto.h" #include "../isql/show_proto.h" #include "../isql/iutils_proto.h" -#include "../jrd/perf_proto.h" -#include "../jrd/utl_proto.h" -#include "../jrd/why_proto.h" +#include "../yvalve/perf_proto.h" +#include "../yvalve/utl_proto.h" +#include "../yvalve/why_proto.h" #include "../jrd/gdsassert.h" #include "../isql/Extender.h" diff --git a/src/isql/isql_win.cpp b/src/isql/isql_win.cpp deleted file mode 100644 index 888484d272..0000000000 --- a/src/isql/isql_win.cpp +++ /dev/null @@ -1,2370 +0,0 @@ -/* - * PROGRAM: Windows Interactive SQL utility - * MODULE: isql_win.cpp - * DESCRIPTION: Windows shell for ISQL - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#include "firebird.h" -#include -#pragma hdrstop -#include -#include -#include -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#include -#include -#include -#include -#include -#include - -#include "../jrd/common.h" -#include "../isql/isql.h" -#include "../isql/isql_win.h" -#include "../isql/isql.rh" -#include "../jrd/ibase.h" -#include "../isql/isqlw_proto.h" -#include "../isql/isql_proto.h" -#include "../jrd/constants.h" - -struct scrollkeys -{ - WORD wVirtkey; - int iMessage; - WORD wRequest; -}; - -scrollkeys key2scroll[] = -{ - {VK_HOME, WM_COMMAND, IDM_HOME}, - {VK_END, WM_VSCROLL, SB_BOTTOM}, - {VK_PRIOR, WM_VSCROLL, SB_PAGEUP}, - {VK_NEXT, WM_VSCROLL, SB_PAGEDOWN}, - {VK_UP, WM_VSCROLL, SB_LINEUP}, - {VK_DOWN, WM_VSCROLL, SB_LINEDOWN}, - {VK_LEFT, WM_HSCROLL, SB_PAGEUP}, - {VK_RIGHT, WM_HSCROLL, SB_PAGEDOWN} -}; - -// data initialized by first instance - -struct tagSETUPDATA -{ - SCHAR appName[20]; - SCHAR menuName[20]; - SCHAR iconName[20]; - SCHAR errorString[20]; -}; -typedef tagSETUPDATA SETUPDATA; - -// various temp file names - -static SCHAR defInputFile[MAXPATHLEN]; // default input file name -static SCHAR defOutputFile[MAXPATHLEN]; // default output file name -static SCHAR defHistFile[MAXPATHLEN]; // command history file name -static SCHAR defSessionFile[MAXPATHLEN]; // SQL session file -static FILE *ipf; // input file -static FILE *opf; // output file -static FILE *chf; // command history -static FILE *sss; // SQL session - -// global flags - -static SSHORT gflags; - -const SSHORT DBINITED = 1; // database initilized flag -const SSHORT DEFINPUT = 2; // default input file exists flag -const SSHORT DEFOUTPUT = 4; // default output file exists flag -const SSHORT COMHIST = 8; // command history file exists flag -const SSHORT OVERWRITE = 16; // overwrite/append to window -const SSHORT SESSFILE = 32; // SQL session file exists flag - -SETUPDATA SetUpData; - -/* - Data that can be referenced throughout the - program but not passed to other instances -*/ - -HINSTANCE hInst; // hInstance of application -HWND hWndMain; // hWnd of main window - -int xChar, yChar, yCharnl; // character size -int xClient, yClient; // client window size - -LOGFONT cursfont; // font structure -HFONT holdsfont; // handle of original font -HFONT hnewsfont; // handle of new fixed font -SCHAR tmpDialogParam[1024]; // used by dialog boxes - -// window scroll/paint stuff - -int nVscrollMax, nHscrollMax; // scroll ranges -int nVscrollPos, nHscrollPos; // current scroll positions -int numlines; // number of lines in file -int maxwidth; // width of display format -int nVscrollInc, nHscrollInc; // scroll increments -int nPageMaxLines; // max lines on screen - -// arguments passed to ISQL - -int ISQL_argc; // argument count -char *ISQL_argv[20]; // argument vector -char ISQL_args[1024]; // space for arguments -char *ISQL_cursor; // cursor into arguments - -// database startup parameters - -static SCHAR newDataBase[256]; -static SCHAR newUserName[MAX_SQL_IDENTIFIER_SIZE]; -static SCHAR newPassword[16]; - -// script parameters -static SCHAR scriptName[256]; -static SCHAR scriptOutput[256]; - -// extract parameters -static SCHAR extractDbName[256]; -static SCHAR extractOutput[256]; -static SCHAR extractTarget[256]; - -static SSHORT allblobsflag; -static SSHORT allobjectsflag; - - -int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int cmdShow) -{ -/************************************************** - * - * W i n M a i n - * - ************************************************** - * - * Functional description: - * WinMain shell for the Windows ISQL function. - * - * - * paramaters: - * hInstance - The instance of this instance of this - * application. - * hPrevInstance - The instance of the previous instance - * of this application. This will be 0 - * if this is the first instance. - * pCmdLine - A long pointer to the command line that - * started this application. - * cmdShow - Indicates how the window is to be shown - * initially. ie. SW_SHOWNORMAL, SW_HIDE, - * SW_MIMIMIZE. - * - * returns: - * wParam from last message. - * - ********************************************************************/ - - if (pCmdLine && *pCmdLine) - return cmdline_isql(hInstance, pCmdLine); - - return windows_isql(hInstance, hPrevInstance, cmdShow); -} - - -LRESULT CALLBACK _export ISQLWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * I S Q L W n d P r o c - * - ******************************************************************** - * - * Functional description: - * This handles all messages for the application's main window, - * including scrolling and menu picks. - * - * paramaters: - * hWnd - The window handle for this message - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * - ********************************************************************/ - DLGPROC lpproc; // pointer to thunk for dialog box - SCHAR buf[1024]; // temp buffer - SCHAR pwbuf[50]; - SCHAR unbuf[50]; - int ret; - - switch (message) - { - case WM_CREATE: - nVscrollPos = 0; - nHscrollPos = 0; - return (DefWindowProc(hWnd, message, wParam, lParam)); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDM_QUIT: - // User selected Quit on menu - PostMessage(hWnd, WM_CLOSE, 0, 0L); - break; - - case IDM_HOME: - // Used to implement home to topleft from keyboard. - SendMessage(hWnd, WM_HSCROLL, GET_WM_HSCROLL_MPS(SB_TOP, 0, 0)); - SendMessage(hWnd, WM_VSCROLL, GET_WM_VSCROLL_MPS(SB_TOP, 0, 0)); - break; - - case IDM_ABOUT: - // Display about box. - lpproc = (DLGPROC) MakeProcInstance((FARPROC) aboutDlgProc, hInst); - DialogBox(hInst, MAKEINTRESOURCE(ABOUT), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - break; - - case IDM_EXEC_SQL: - tmpDialogParam[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) execDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(EXEC_SQL), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) - { - fprintf(sss, "%s\n\r", tmpDialogParam); - fflush(sss); - test_overwrite(); - ISQL_sql_statement(tmpDialogParam, ipf, opf, chf); - fprintf(opf, "\n\r\n\r"); - display_page(hWnd); - } - break; - - case IDM_CONNECT_DB: - newDataBase[0] = '\0'; - newUserName[0] = '\0'; - newPassword[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) dbNameDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(CONNECT_DB), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) { - ISQL_exit_db(); - if (ISQL_init - (newDataBase, newUserName, newPassword, ipf, - opf)) gflags |= DBINITED; - } - break; - - case IDM_CREATE_DB: - newDataBase[0] = '\0'; - newUserName[0] = '\0'; - newPassword[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) createDbDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(CREATE_DB), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) - { - ISQL_exit_db(); - if (newUserName[0]) - sprintf(unbuf, " USER \"%s\" ", newUserName); - else - unbuf[0] = '\0'; - if (newPassword[0]) - sprintf(pwbuf, " PASSWORD \"%s\" ", newPassword); - else - pwbuf[0] = '\0'; - sprintf(buf, "CREATE DATABASE \"%s\" %s %s", - newDataBase, unbuf, pwbuf); - ISQL_frontend_command(buf, ipf, opf, chf); - gflags |= DBINITED; - } - break; - - case IDM_DROP_DB: - lpproc = (DLGPROC) MakeProcInstance((FARPROC) dropDbDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(DROP_DB), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) { - ISQL_frontend_command("DROP DATABASE", ipf, opf, chf); - gflags &= ~DBINITED; - } - break; - - case IDM_SAVE_SESSION: - tmpDialogParam[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) sessionDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(SAVE_SESSION), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) { - fflush(chf); - fclose(chf); - xfer_file(defHistFile, tmpDialogParam, false); - chf = fopen(defHistFile, "a"); - } - break; - - case IDM_SAVE_OUTPUT: - tmpDialogParam[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) outputDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(SAVE_OUTPUT), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) { - fflush(opf); - fclose(opf); - xfer_file(defOutputFile, tmpDialogParam, false); - opf = fopen(defOutputFile, "a"); - } - break; - - case IDM_EXEC_SCRIPT: - scriptName[0] = '\0'; - scriptOutput[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) scriptDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(EXEC_SCRIPT), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) - { - // generate an argc/argv - - ISQL_cursor = ISQL_args; - ISQL_argc = 0; - pusharg("isql"); - pusharg("-input"); - pusharg(scriptName); - pusharg("-output"); - - // use specified output file, or default - - if (scriptOutput[0]) - pusharg(scriptOutput); - else - pusharg(defOutputFile); - fclose(opf); - fclose(ipf); - - /* if database already open, exit and add database - name to arguments */ - - if (gflags & DBINITED) { - ISQL_exit_db(); - pusharg(newDataBase); - } - - /* if overwrite flag is set, make sure ISQL appends to - an empty file */ - - if (gflags & OVERWRITE) { - opf = fopen(defOutputFile, "w"); - fclose(opf); - } - ISQL_main(ISQL_argc, ISQL_argv); - - // reopen default files and database - - ipf = fopen(defInputFile, "r"); - opf = fopen(defOutputFile, "a"); - if (gflags & DBINITED) - ISQL_init(newDataBase, newUserName, newPassword, ipf, opf); - fprintf(opf, "\n\r\n\r"); - display_page(hWnd); - } - break; - - case IDM_EXTRACT_DB: - extractOutput[0] = '\0'; - extractDbName[0] = '\0'; - extractTarget[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) extractDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(EXTRACT_DB), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) - { - // create an argument vector for ISQL - - ISQL_cursor = ISQL_args; - ISQL_argc = 0; - pusharg("isql"); - pusharg("-extract"); - pusharg("-o"); - if (extractOutput[0]) - pusharg(extractOutput); - else - pusharg(defOutputFile); - pusharg(extractDbName); - if (extractTarget[0]) { - pusharg("-database"); - pusharg(extractTarget); - } - fclose(opf); - fclose(ipf); - ISQL_exit_db(); - ISQL_main(ISQL_argc, ISQL_argv); - ISQL_exit_db(); - - // reopen default files and database - - ipf = fopen(defInputFile, "r"); - opf = fopen(defOutputFile, "a"); - if (gflags & DBINITED) - ISQL_init(newDataBase, newUserName, newPassword, ipf, - opf); - fprintf(opf, "\n\r\n\r"); - display_page(hWnd); - } - break; - - case IDM_HELP: - ISQL_win_err("not implemented yet"); - break; - - case IDM_APPEND: - if (gflags & OVERWRITE) - gflags &= ~OVERWRITE; - else - gflags |= OVERWRITE; - break; - - // Send the proper frontend commands for these: - - case IDM_BLOB_TYPE: - tmpDialogParam[0] = '\0'; - allblobsflag = FALSE; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) blobDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(BLOB_TYPE), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) { - sprintf(buf, "SET BLOBDISPLAY %s", tmpDialogParam); - ISQL_frontend_command(buf, ipf, opf, chf); - } - break; - - case IDM_STATISTICS: - ISQL_frontend_command("SET STATS", ipf, opf, chf); - break; - - case IDM_COUNT: - ISQL_frontend_command("SET COUNT", ipf, opf, chf); - break; - - case IDM_AUTOCOMMIT: - ISQL_frontend_command("SET AUTOCOMMIT", ipf, opf, chf); - break; - - case IDM_LIST: - ISQL_frontend_command("SET LIST", ipf, opf, chf); - break; - - case IDM_PLAN: - ISQL_frontend_command("SET PLAN", ipf, opf, chf); - break; - - case IDM_TRANSACTION: - tmpDialogParam[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) transDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(TRANS_STRING), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) { - sprintf(buf, "SET TRANSACTION %s", tmpDialogParam); - ISQL_frontend_command(buf, ipf, opf, chf); - } - break; - - case IDM_AUTODDL: - ISQL_frontend_command("SET AUTO", ipf, opf, chf); - break; - - case IDM_TERMINATOR: - tmpDialogParam[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) termDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(TERMINATOR), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) { - sprintf(buf, "SET TERM %s", tmpDialogParam); - ISQL_frontend_command(buf, ipf, opf, chf); - } - break; - - case IDM_CHAR_SET: - tmpDialogParam[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) charSetDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(CHAR_SET), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) { - sprintf(buf, "SET NAMES %s", tmpDialogParam); - ISQL_frontend_command(buf, ipf, opf, chf); - } - break; - - // Send the proper show commands for these: - - case IDM_SHOW_VERSION: - test_overwrite(); - ISQL_frontend_command("SHOW VERSION", ipf, opf, chf); - fprintf(opf, "\n\r\n\r"); - display_page(hWnd); - break; - - case IDM_SHOW_SYSTEM: - test_overwrite(); - ISQL_frontend_command("SHOW SYSTEM", ipf, opf, chf); - fprintf(opf, "\n\r\n\r"); - display_page(hWnd); - break; - - case IDM_SHOW_SETTINGS: - test_overwrite(); - ISQL_frontend_command("SET", ipf, opf, chf); - fprintf(opf, "\n\r\n\r"); - display_page(hWnd); - break; - - case IDM_SHOW_DATABASE: - test_overwrite(); - ISQL_frontend_command("SHOW DATABASE", ipf, opf, chf); - fprintf(opf, "\n\r\n\r"); - display_page(hWnd); - break; - - case IDM_SHOW_CHECK: - case IDM_SHOW_TRIGGER: - case IDM_SHOW_PROCEDURE: - case IDM_SHOW_GENERATOR: - case IDM_SHOW_GRANT: - case IDM_SHOW_FUNCTION: - case IDM_SHOW_FILTER: - case IDM_SHOW_EXCEPTS: - case IDM_SHOW_DOMAIN: - case IDM_SHOW_INDEX: - case IDM_SHOW_VIEW: - case IDM_SHOW_TABLE: - tmpDialogParam[0] = '\0'; - lpproc = (DLGPROC) MakeProcInstance((FARPROC) objectDlgProc, hInst); - ret = DialogBox(hInst, MAKEINTRESOURCE(DB_OBJECT), hWnd, lpproc); - FreeProcInstance((FARPROC) lpproc); - if (ret) - { - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDM_SHOW_CHECK: - sprintf(buf, "SHOW CHECK %s", tmpDialogParam); - break; - - case IDM_SHOW_TRIGGER: - sprintf(buf, "SHOW TRIGGER %s", tmpDialogParam); - break; - - case IDM_SHOW_PROCEDURE: - sprintf(buf, "SHOW PROCEDURE %s", tmpDialogParam); - break; - - case IDM_SHOW_GENERATOR: - sprintf(buf, "SHOW GENERATOR %s", tmpDialogParam); - break; - - case IDM_SHOW_GRANT: - sprintf(buf, "SHOW GRANT %s", tmpDialogParam); - break; - - case IDM_SHOW_FUNCTION: - sprintf(buf, "SHOW FUNCTION %s", tmpDialogParam); - break; - - case IDM_SHOW_FILTER: - sprintf(buf, "SHOW FILTER %s", tmpDialogParam); - break; - - case IDM_SHOW_EXCEPTS: - sprintf(buf, "SHOW EXCEPTION %s", tmpDialogParam); - break; - - case IDM_SHOW_DOMAIN: - sprintf(buf, "SHOW DOMAIN %s", tmpDialogParam); - break; - - case IDM_SHOW_INDEX: - sprintf(buf, "SHOW INDEX %s", tmpDialogParam); - break; - - case IDM_SHOW_VIEW: - if (allobjectsflag) - strcpy(buf, "SHOW VIEWS"); - else - sprintf(buf, "SHOW VIEW %s", tmpDialogParam); - break; - - case IDM_SHOW_TABLE: - if (allobjectsflag) - strcpy(buf, "SHOW TABLES"); - else - sprintf(buf, "SHOW TABLE %s", tmpDialogParam); - break; - - } - test_overwrite(); - ISQL_frontend_command(buf, ipf, opf, chf); - fprintf(opf, "\n\r\n\r"); - display_page(hWnd); - } - break; - - default: - break; - } - break; - - case WM_SIZE: - // Save size of window client area. - if (lParam) - { - yClient = HIWORD(lParam); - xClient = LOWORD(lParam); - yClient = (yClient / yCharnl + 1) * yCharnl; - lParam = MAKELONG(xClient, yClient); - - // Go setup scroll ranges and file display area based upon - // client area size. - - setup_scroll(hWnd); - return DefWindowProc(hWnd, message, wParam, lParam); - } - break; - - case WM_VSCROLL: - // React to the various vertical scroll related actions. - - switch (GET_WM_VSCROLL_CODE(wParam, lParam)) - { - case SB_TOP: - nVscrollInc = -nVscrollPos; - break; - case SB_BOTTOM: - nVscrollInc = nVscrollMax - nVscrollPos; - break; - case SB_LINEUP: - nVscrollInc = -1; - break; - case SB_LINEDOWN: - nVscrollInc = 1; - break; - case SB_PAGEUP: - nVscrollInc = -max(1, yClient / yChar); - break; - case SB_PAGEDOWN: - nVscrollInc = max(1, yClient / yChar); - break; - case SB_THUMBPOSITION: - nVscrollInc = GET_WM_VSCROLL_POS(wParam, lParam) - nVscrollPos; - break; - case SB_THUMBTRACK: - nVscrollInc = GET_WM_VSCROLL_POS(wParam, lParam) - nVscrollPos; - break; - default: - nVscrollInc = 0; - } - nVscrollInc = max(-nVscrollPos, min(nVscrollInc, nVscrollMax - nVscrollPos)); - if (nVscrollInc) { - nVscrollPos += nVscrollInc; - ScrollWindow(hWnd, 0, -yChar * nVscrollInc, NULL, NULL); - SetScrollPos(hWnd, SB_VERT, nVscrollPos, TRUE); - UpdateWindow(hWnd); - } - break; - - case WM_HSCROLL: - // React to the various horizontal scroll related actions. - - switch (GET_WM_HSCROLL_CODE(wParam, lParam)) - { - case SB_LINEUP: - nHscrollInc = -1; - break; - case SB_LINEDOWN: - nHscrollInc = 1; - break; - case SB_PAGEUP: - nHscrollInc = -8; - break; - case SB_PAGEDOWN: - nHscrollInc = 8; - break; - case SB_THUMBPOSITION: - nHscrollInc = GET_WM_HSCROLL_POS(wParam, lParam) - nHscrollPos; - break; - case SB_THUMBTRACK: - nHscrollInc = GET_WM_HSCROLL_POS(wParam, lParam) - nHscrollPos; - break; - default: - nHscrollInc = 0; - } - nHscrollInc = max(-nHscrollPos, min(nHscrollInc, nHscrollMax - nHscrollPos)); - if (nHscrollInc) { - nHscrollPos += nHscrollInc; - ScrollWindow(hWnd, -xChar * nHscrollInc, 0, NULL, NULL); - SetScrollPos(hWnd, SB_HORZ, nHscrollPos, TRUE); - UpdateWindow(hWnd); - } - break; - - case WM_KEYDOWN: - // Translate various keydown messages to appropriate horizontal - // and vertical scroll actions. - - for (SSHORT i = 0; i < FB_NELEM(key2scroll); i++) - { - if (wParam == key2scroll[i].wVirtkey) { - SendMessage(hWnd, key2scroll[i].iMessage, key2scroll[i].wRequest, 0L); - break; - } - } - break; - - case WM_PAINT: - // Go paint the client area of the window with the appropriate - // part of the selected file. - - paint_isql(hWnd); - break; - - case WM_DESTROY: - // This is the end if we were closed by a DestroyWindow call. - close_isql(); // take any necessary wrapup action. - PostQuitMessage(0); // this is the end... - break; - - case WM_QUERYENDSESSION: - // If we return TRUE we are saying it's ok with us to end the - // windows session. - close_isql(); // take any necessary wrapup action. - return (long) TRUE; // we agree to end session. - - case WM_CLOSE: - // Tell windows to destroy our window. - DestroyWindow(hWnd); - break; - - default: - // Let windows handle all messages we choose to ignore. - return DefWindowProc(hWnd, message, wParam, lParam); - } - - return 0L; -} - - -void ISQL_win_err(const char* string) -{ -/*************************************************************** - * - * I S Q L _ w i n _ e r r - * - *************************************************************** - * - * Functional description: - * Output a Windows ISQL error in a message box. - * - ***************************************************************/ - - if (Merge_stderr) - fprintf(Out, "%s\n", string); - else - MessageBox(NULL, string, SetUpData.errorString, MB_ICONEXCLAMATION | MB_OK); -} - - -static void close_isql() -{ -/******************************************************************** - * - * c l o s e _ i s q l - * - ******************************************************************** - * - * Functional description: - * Shut down the database prior to exit. - * - ********************************************************************/ - - ISQL_exit_db(); - if (gflags & COMHIST) - fclose(chf); - unlink(defHistFile); - if (gflags & DEFINPUT) - fclose(ipf); - unlink(defInputFile); - if (gflags & DEFOUTPUT) - fclose(opf); - unlink(defOutputFile); - if (gflags & SESSFILE) - fclose(sss); - unlink(defSessionFile); - DeleteObject(hnewsfont); -} - - -static int cmdline_isql( HINSTANCE hInstance, LPSTR pCmdLine) -{ -/******************************************************************** - * - * c m d l i n e _ i s q l - * - ******************************************************************** - * - * Functional Description: - * Take the command line and turn it into an argc/argv to feed - * to ISQL. - * - * paramaters: - * hInstance - Instance used for error messsages - * pCmdLine - A long pointer to the command line that - * started this application. - * - * returns: - * return from ISQL - * - ********************************************************************/ - FILE *inputfile; // input file - FILE *outputfile; // output file - SCHAR inputfilename[MAXPATHLEN]; // input file name - SCHAR outputfilename[MAXPATHLEN]; // output file name - SCHAR arg[MAXPATHLEN]; // current argument - const SCHAR *cp; // command line cursor - SCHAR *ap; // current argument cursor - -// create default input and output files - - if (!open_temp_file(hInstance, &inputfile, inputfilename, IDS_TEMP_IN_FILE)) - return 0; - if (!open_temp_file(hInstance, &outputfile, outputfilename, IDS_TEMP_OUT_FILE)) - return 0; - -// create failsafe input file - - fprintf(inputfile, "QUIT;\n"); - fclose(inputfile); - fclose(outputfile); - -// create an argument vector, including the default files and command line args - - ISQL_cursor = ISQL_args; - ISQL_argc = 0; - pusharg("isql"); - pusharg("-input"); - pusharg(inputfilename); - pusharg("-output"); - pusharg(outputfilename); - ap = arg; - for (cp = (SCHAR *) pCmdLine; *cp; cp++) - { - *ap = *cp++; - if (*ap == ' ') { - *ap = '\0'; - pusharg(arg); - ap = arg; - } - else - ap++; - if (ISQL_argc == 20) - break; - } - ISQL_main(ISQL_argc, ISQL_argv); - unlink(inputfilename); - unlink(outputfilename); - - return 0; -} - - -static void display_page( HWND hWnd) -{ -/*************************************************************** - * - * d i s p l a y _ p a g e - * - *************************************************************** - * - * Functional description: - * Throw the result up on the window. - * - ***************************************************************/ - FILE *fh; - -// Determine file size and some display paramaters. - nVscrollPos = numlines; - numlines = 0; - maxwidth = 0; - fflush(opf); - fclose(opf); - fh = fopen(defOutputFile, "r+b"); - if (fh) - { - while (fgets(tmpDialogParam, sizeof(tmpDialogParam), fh)) { - numlines++; - if (strlen(tmpDialogParam) > maxwidth) - maxwidth = strlen(tmpDialogParam); - } - fclose(fh); - } - opf = fopen(defOutputFile, "a"); - -// Go setup scroll ranges for this file. - - setup_scroll(hWnd); - -// Show first part of file. - - InvalidateRect(hWnd, NULL, TRUE); - UpdateWindow(hWnd); -} - - -static SSHORT init_isql(HINSTANCE hInstance, HINSTANCE hPrevInstance, int cmdShow) -{ -/******************************************************************** - * - * i n i t _ i s q l - * - ******************************************************************** - * - * Functional description: - * Startup code for Windows. This builds the window and also - * presents the user with a dialog box to specify the database - * connection parameters. - * - * paramaters: - * hInstance - The instance of this instance of this - * application. - * hPrevInstance - The instance of the previous instance - * of this application. This will be 0 - * if this is the first instance. - * cmdShow - Indicates how the window is to be shown - * initially. ie. SW_SHOWNORMAL, SW_HIDE, - * SW_MIMIMIZE. - * - *********************************************************************/ -#pragma argsused - DLGPROC dlgProc; - int iReturn; - -// perform instance dependant Windows initialization - - if (!hPrevInstance) - init_isql_first(hInstance); -#if !defined(__WIN32__) - else - init_isql_added(hPrevInstance); -#endif - -// perform common instance Windows initialization - - init_isql_every(hInstance, cmdShow); - -// open all the files - - if (!open_temp_file(hInstance, &ipf, defInputFile, IDS_DEF_IN_FILE)) - return FALSE; - fprintf(ipf, "QUIT;\n"); - fclose(ipf); - ipf = fopen(defInputFile, "r"); - gflags |= DEFINPUT; - if (!open_temp_file(hInstance, &opf, defOutputFile, IDS_DEF_OUT_FILE)) - return FALSE; - gflags |= DEFOUTPUT; - if (!open_temp_file(hInstance, &chf, defHistFile, IDS_DEF_HIST_FILE)) - return FALSE; - gflags |= COMHIST; - if (!open_temp_file(hInstance, &sss, defSessionFile, IDS_DEF_SESS_FILE)) - return FALSE; - gflags |= SESSFILE; - newDataBase[0] = '\0'; - newUserName[0] = '\0'; - newPassword[0] = '\0'; - dlgProc = (DLGPROC) MakeProcInstance((FARPROC) dbNameDlgProc, hInst); - iReturn = DialogBox(hInst, MAKEINTRESOURCE(CONNECT_DB), hWndMain, dlgProc); - FreeProcInstance((FARPROC) dlgProc); - if (iReturn) - if (ISQL_init(newDataBase, newUserName, newPassword, ipf, opf)) - gflags |= DBINITED; - return TRUE; -} - - -#if !defined(__WIN32__) -static void init_isql_added( HINSTANCE hPrevInstance) -{ -/******************************************************************** - * - * i n i t _ i s q l _ a d d e d - * - ******************************************************************** - * - * Functional description: - * This gets called for each added instance of the application. - * - * paramaters: - * hPrevInstance - The instance of the previous instance - * of this application. - * - *********************************************************************/ - -// get the results of the initialization of first instance - - GetInstanceData(hPrevInstance, (BYTE *) & SetUpData, sizeof(SETUPDATA)); -} -#endif - - -static void init_isql_every( HINSTANCE hInstance, int cmdShow) -{ -/******************************************************************** - * - * i n i t _ i s q l _ e v e r y - * - ******************************************************************** - * - * Functional description: - * Perform initialization done for all instances. - * - * paramaters: - * hInstance - The instance of this instance of this - * application. - * cmdShow - Indicates how the window is to be shown - * initially. ie. SW_SHOWNORMAL, SW_HIDE, - * SW_MIMIMIZE. - * - ********************************************************************/ - TEXTMETRIC tm; - HDC hDC; - - hInst = hInstance; // save for use by window procs - -// Create applications main window. - - hWndMain = CreateWindow(SetUpData.appName, // window class name - SetUpData.appName, // window title - WS_OVERLAPPEDWINDOW | // type of window - WS_HSCROLL | WS_VSCROLL, CW_USEDEFAULT, // x window location - CW_USEDEFAULT, // y - CW_USEDEFAULT, // cx and size - CW_USEDEFAULT, // cy - NULL, // no parent for this window - NULL, // use the class menu - hInstance, // who created this window - NULL // no parms to pass on - ); - -// Get the display context. - - hDC = GetDC(hWndMain); - -// Build fixed screen font. - - cursfont.lfHeight = 14; - cursfont.lfWidth = 9; - cursfont.lfEscapement = 0; - cursfont.lfOrientation = 0; - cursfont.lfWeight = FW_NORMAL; - cursfont.lfItalic = FALSE; - cursfont.lfUnderline = FALSE; - cursfont.lfStrikeOut = FALSE; - cursfont.lfCharSet = ANSI_CHARSET; - cursfont.lfOutPrecision = OUT_DEFAULT_PRECIS; - cursfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; - cursfont.lfQuality = DEFAULT_QUALITY; - cursfont.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE; - strcpy((char *) cursfont.lfFaceName, "System"); - - hnewsfont = CreateFontIndirect((LPLOGFONT) & cursfont); - -// Install the font in the current display context. - - holdsfont = SelectObject(hDC, hnewsfont); - -// get text metrics for paint - - GetTextMetrics(hDC, &tm); - xChar = tm.tmAveCharWidth; - yChar = tm.tmHeight + tm.tmExternalLeading; - yCharnl = tm.tmHeight; - numlines = 0; - -// Release the display context. - - ReleaseDC(hWndMain, hDC); - -// Update display of main window. - - ShowWindow(hWndMain, cmdShow); - UpdateWindow(hWndMain); -} - - -static void init_isql_first( HINSTANCE hInstance) -{ -/******************************************************************** - * - * i n i t _ i s q l _ f i r s t - * - ******************************************************************** - * - * Functions description: - * Initialization for first instance of application. - * - * paramaters: - * hInstance - The instance of this instance of this - * application. - * - ********************************************************************/ - WNDCLASS wcISQLClass; - -// Get string from resource with application name. - - LoadString(hInstance, IDS_NAME, (LPSTR) SetUpData.appName, 20); - LoadString(hInstance, IDS_MENUNAME, (LPSTR) SetUpData.menuName, 20); - LoadString(hInstance, IDS_ICONNAME, (LPSTR) SetUpData.iconName, 20); - LoadString(hInstance, IDS_ERROR, (LPSTR) SetUpData.errorString, 20); - -// Define the window class for this application. - - wcISQLClass.lpszClassName = SetUpData.appName; - wcISQLClass.hInstance = hInstance; - wcISQLClass.lpfnWndProc = isqlWndProc; - wcISQLClass.hCursor = LoadCursor(hInstance, MAKEINTRESOURCE(ISQLCURSOR)); - wcISQLClass.hIcon = LoadIcon(hInstance, SetUpData.iconName); - wcISQLClass.lpszMenuName = (LPSTR) SetUpData.menuName; - wcISQLClass.hbrBackground = GetStockObject(WHITE_BRUSH); - wcISQLClass.style = CS_HREDRAW | CS_VREDRAW; - wcISQLClass.cbClsExtra = 0; - wcISQLClass.cbWndExtra = 0; - -// Register the class - - RegisterClass(&wcISQLClass); -} - - -static SSHORT open_temp_file(HINSTANCE hInstance, - FILE** file, - SCHAR* fileName, SSHORT errStrNum) -{ -/******************************************************************** - * - * o p e n _ t e m p _ f i l e - * - ******************************************************************** - * - * Functions description: - * Create a temp file, get its name, and print the proper - * error on failure. - * - ********************************************************************/ - SCHAR errorString[100]; - SCHAR message[100]; - - *file = (FILE *) gds__temp_file(TRUE, "isql_", fileName); - if (*file == (FILE *) - 1) { - LoadString(hInstance, errStrNum, errorString, 100); - sprintf(message, errorString, fileName); - ISQL_win_err(message); - return 0; - } - - return 1; -} - - -static int windows_isql(HINSTANCE hInstance, HINSTANCE hPrevInstance, int cmdShow) -{ -/******************************************************************** - * - * w i n d o w s _ i s q l - * - ******************************************************************** - * - * Functional description: - * Process ISQL for Windows (no command line was passed). - * - * paramaters: - * hInstance - The instance of this instance of this - * application. - * hPrevInstance - The instance of the previous instance - * of this application. This will be 0 - * if this is the first instance. - * cmdShow - Indicates how the window is to be shown - * initially. ie. SW_SHOWNORMAL, SW_HIDE, - * SW_MIMIMIZE. - * - * returns: - * wParam from last message. - * - ********************************************************************/ \ - MSG msg; - -// Go init this application. - - if (!init_isql(hInstance, hPrevInstance, cmdShow)) - return 0; - -// Get and dispatch messages for this applicaton. - - while (GetMessage(&msg, NULL, NULL, NULL)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - return msg.wParam; -} - - -static void paint_isql( HWND hWnd) -{ -/******************************************************************** - * - * p a i n t _ i s q l - * - ******************************************************************** - * Functional description: - * If a file has been selected, as indicated by numlines being - * greater than 0, this module will read and display a portion - * of the file as determined by the current size and scroll - * position of the window. - * - * paramaters: - * hWnd - The callers window handle - * - ********************************************************************/ - PAINTSTRUCT ps; - HDC hDC; - SSHORT e; - SCHAR buf[1024]; - FILE *hfile; - - BeginPaint(hWnd, (LPPAINTSTRUCT) & ps); - hDC = ps.hdc; - -// Establish fixed font in display context. - - SelectObject(hDC, hnewsfont); - - if (numlines) - { - // Open the file to display - // (files should not stay open over multiple windows messages) - - hfile = fopen(defOutputFile, "r"); - if (hfile) - { - // Skip lines outside window limits - - for (SSHORT i = 0; i < nVscrollPos; i++) - fgets(buf, sizeof(buf), hfile); - - // Read visible lines - - for (SSHORT i = 0; i < nPageMaxLines; i++) { - if (!fgets(buf, sizeof(buf), hfile)) - break; - - // figure out shortest text to put - - for (e = strlen(buf); e >= 0; e--) - if (buf[e] > ' ' && buf[e] <= '~') - break; - if (e == -1) - buf[++e] = ' '; - buf[++e] = '\0'; - TextOut(hDC, xChar * (-nHscrollPos + 0), yChar * i, buf, e); - } - fclose(hfile); - } - } - - EndPaint(hWnd, (LPPAINTSTRUCT) & ps); -} - - -static void pusharg(const char* argument) -{ -/******************************************************************** - * - * p u s h a r g - * - ******************************************************************** - * - * Functional description: - * Used to push arguments onto an argv to be sent to ISQL. - * - ********************************************************************/ - - ISQL_argv[ISQL_argc++] = ISQL_cursor; - strcpy(ISQL_cursor, argument); - ISQL_cursor += strlen(argument); - *ISQL_cursor++ = '\0'; -} - - -static void setup_scroll( HWND hWnd) -{ -/******************************************************************** - * - * s e t u p _ s c r o l l - * - ******************************************************************** - * - * Functional description: - * Set up the vertical and horizontal scroll ranges and positions - * of the applicatons main window based on: - * - * numlines - The maximum number of lines to display. - * maxwidth - The width of each line to display. - * - * The resulting variables, nVscrollPos and nPageMaxLines, are used - * by the function paint_isql to determine what to display in the window. - * - * paramaters: - * hWnd - The callers window handle - * - *********************************************************************/ - -// numlines established during open - - nVscrollMax = max(0, numlines - yClient / yChar); - nVscrollPos = min(nVscrollPos, nVscrollMax); - - nHscrollMax = max(0, maxwidth - xClient / xChar); - nHscrollPos = min(nHscrollPos, nHscrollMax); - - SetScrollRange(hWnd, SB_VERT, 0, nVscrollMax, FALSE); - SetScrollPos(hWnd, SB_VERT, nVscrollPos, TRUE); - - SetScrollRange(hWnd, SB_HORZ, 0, nHscrollMax, FALSE); - SetScrollPos(hWnd, SB_HORZ, nHscrollPos, TRUE); - - nPageMaxLines = min(numlines, yClient / yChar); -} - - -static void test_overwrite() -{ -/*************************************************************** - * - * t e s t _ o v e r w r i t e - * - *************************************************************** - * - * Functional description: - * If the overwrite flag is set, clear the file and reset - * the scroll positions. - * - ***************************************************************/ - - if (gflags & OVERWRITE) - { - fclose(opf); - opf = fopen(defOutputFile, "w"); - nVscrollPos = 0; - nHscrollPos = 0; - } -} - - -static void xfer_file(const char* inFileName, - const char* outFileName, bool appendFlag) -{ -/*************************************************************** - * - * x f e r _ f i l e - * - *************************************************************** - * - * Functional description: - * Copy current file to a save file. - * - ***************************************************************/ - SCHAR xferbuff[1024]; - - FILE* xferin = fopen(inFileName, "r"); - if (xferin) - { - FILE* xferout; - if (appendFlag) - xferout = fopen(outFileName, "a"); - else - xferout = fopen(outFileName, "w"); - if (xferout) { - while (fgets(xferbuff, sizeof(xferbuff), xferin)) { - fprintf(xferout, "%s", xferbuff); - } - fclose(xferout); - } - fclose(xferin); - } -} - - -BOOL CALLBACK _export aboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * a b o u t D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Put up a little dislog box saying what this is. - * - * paramaters: - * hDlg - The window handle for this message - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - ********************************************************************/ -#pragma argsused - - if (message == WM_INITDIALOG) - return TRUE; - - if (message == WM_COMMAND) - { - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDOK: - EndDialog(hDlg, TRUE); - return TRUE; - default: - return TRUE; - } - } - - return FALSE; -} - - -BOOL CALLBACK _export blobDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * b l o b D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get blob display type, or "ALL" by managing the BLOB_TYPE - * dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_BLOB_TYPE, EM_LIMITTEXT, 10, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_ALL_BLOBS: - allblobsflag = TRUE; - tmpDialogParam[0] = '\0'; - EndDialog(hDlg, TRUE); - break; - - case IDD_BLOB_TYPE: - allblobsflag = FALSE; - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_BLOB_TYPE, tmpDialogParam, 10); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - strcpy(tmpDialogParam, "0"); - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export charSetDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * c h a r S e t D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get characetr set name by managing the NAMES dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_CHAR_SET, EM_LIMITTEXT, 100, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_CHAR_SET: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_CHAR_SET, tmpDialogParam, 100); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - tmpDialogParam[0] = '\0'; - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export createDbDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * c r e a t e D b D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get database name, user name and password for a newly created - * database by managing the CREATE_DB dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_DB_DBNAME, EM_LIMITTEXT, 256, 0L); - SendDlgItemMessage(hDlg, IDD_DB_USERNAME, EM_LIMITTEXT, MAX_SQL_IDENTIFIER_SIZE, 0L); - SendDlgItemMessage(hDlg, IDD_DB_PASSWORD, EM_LIMITTEXT, 16, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_CREATE_DBNAME: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDD_CREATE_USERNAME: - case IDD_CREATE_PASSWORD: - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_DB_DBNAME, newDataBase, 256); - GetDlgItemText(hDlg, IDD_DB_USERNAME, newUserName, MAX_SQL_IDENTIFIER_SIZE); - GetDlgItemText(hDlg, IDD_DB_PASSWORD, newPassword, 16); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - // Terminate this dialog box. - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export dbNameDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * d b N a m e D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get database name, user name and password by managing the - * DB_NAME dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_DB_DBNAME, EM_LIMITTEXT, 256, 0L); - SendDlgItemMessage(hDlg, IDD_DB_USERNAME, EM_LIMITTEXT, MAX_SQL_IDENTIFIER_SIZE, 0L); - SendDlgItemMessage(hDlg, IDD_DB_PASSWORD, EM_LIMITTEXT, 16, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_DB_DBNAME: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDD_DB_USERNAME: - case IDD_DB_PASSWORD: - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_DB_DBNAME, newDataBase, 256); - GetDlgItemText(hDlg, IDD_DB_USERNAME, newUserName, MAX_SQL_IDENTIFIER_SIZE); - GetDlgItemText(hDlg, IDD_DB_PASSWORD, newPassword, 16); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - // Terminate this dialog box. - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export dropDbDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * d r o p D b D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Drop the database by managing the DROP_DB dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDOK: - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - // Terminate this dialog box. - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export execDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * e x e c D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get a SQL command by managing the EXEC dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - FILE *fh; - SCHAR buf[256]; - SSHORT i; - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_SQL_COMMAND, EM_LIMITTEXT, 1024, 0L); - fflush(sss); - fclose(sss); - fh = fopen(defSessionFile, "r"); - if (fh) - { - while (fgets(buf, sizeof(buf), fh)) { - for (i = strlen(buf); i; i--) - if (buf[i] >= ' ' && buf[i] <= '~') - break; - if (!i) - break; - buf[i + 1] = '\0'; - SendMessage(GetDlgItem(hDlg, IDD_SQL_HISTORY), LB_ADDSTRING, 0, (SLONG) buf); - } - fclose(fh); - } - sss = fopen(defSessionFile, "a"); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_SQL_COMMAND: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) { - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - } - break; - - case IDD_SQL_HISTORY: - if (GET_WM_COMMAND_CMD(wParam, lParam) == LBN_DBLCLK) { - i = (SSHORT) SendMessage(GetDlgItem(hDlg, IDD_SQL_HISTORY), LB_GETCURSEL, 0, 0); - SendMessage(GetDlgItem(hDlg, IDD_SQL_HISTORY), LB_GETTEXT, i, (SLONG) buf); - SetDlgItemText(hDlg, IDD_SQL_COMMAND, buf); - } - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_SQL_COMMAND, tmpDialogParam, 1024); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export extractDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * e x t r a c t D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get extract database name plus optional target database and - * output file by managing the EXTRACT_DB dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_EXTRACT_DBNAME, EM_LIMITTEXT, 256, 0L); - SendDlgItemMessage(hDlg, IDD_EXTRACT_OUTPUT, EM_LIMITTEXT, 256, 0L); - SendDlgItemMessage(hDlg, IDD_EXTRACT_TARGET, EM_LIMITTEXT, 256, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_EXTRACT_DBNAME: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDD_EXTRACT_TARGET: - case IDD_EXTRACT_OUTPUT: - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_EXTRACT_DBNAME, extractDbName, 256); - GetDlgItemText(hDlg, IDD_EXTRACT_TARGET, extractTarget, 256); - GetDlgItemText(hDlg, IDD_EXTRACT_OUTPUT, extractOutput, 256); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - // Terminate this dialog box. - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export objectDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * o b j e c t D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get database object name or "ALL" by managing the - * DB_OBJECT dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_OBJECT, EM_LIMITTEXT, 256, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_ALL_OBJECTS: - allobjectsflag = TRUE; - tmpDialogParam[0] = '\0'; - EndDialog(hDlg, TRUE); - break; - - case IDD_OBJECT: - allobjectsflag = FALSE; - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_OBJECT, tmpDialogParam, 256); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - tmpDialogParam[0] = '\0'; - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export outputDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * o u t p u t D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get name of file to dump current window to, using - * SAVE_OUTPUT dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_SAVE_OUTPUT_FILE, EM_LIMITTEXT, 256, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_SAVE_OUTPUT_FILE: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_SAVE_OUTPUT_FILE, tmpDialogParam, 256); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - tmpDialogParam[0] = '\0'; - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export scriptDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * s c r i p t D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get script name and optional output file name by managing the - * SCRIPT dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_SCRIPT_INPUT, EM_LIMITTEXT, 256, 0L); - SendDlgItemMessage(hDlg, IDD_SCRIPT_OUTPUT, EM_LIMITTEXT, 256, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_SCRIPT_INPUT: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDD_SCRIPT_OUTPUT: - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_SCRIPT_INPUT, scriptName, 256); - GetDlgItemText(hDlg, IDD_SCRIPT_OUTPUT, scriptOutput, 256); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - // Terminate this dialog box. - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export sessionDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * s e s s i o n D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get name of file to dump current session's commands to, using - * SAVE_SESSION dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_SAVE_SESSION_FILE, EM_LIMITTEXT, 256, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_SAVE_SESSION_FILE: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_SAVE_SESSION_FILE, tmpDialogParam, 256); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - tmpDialogParam[0] = '\0'; - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export termDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * t e r m D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get SQL statement terminator by managing the TERMINATOR dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_TERMINATOR, EM_LIMITTEXT, 10, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_TERMINATOR: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_TERMINATOR, tmpDialogParam, 10); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - strcpy(tmpDialogParam, ";"); - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - - -BOOL CALLBACK _export transDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) -{ -/******************************************************************** - * - * t r a n s D l g P r o c - * - ******************************************************************** - * - * Functional description: - * Get transaction definition string by managing the TRANS dialog box. - * - * paramaters: - * hDlg - The window handle of this dialog box - * message - The message number - * wParam - The WPARAM parameter for this message - * lParam - The LPARAM parameter for this message - * - * returns: - * depends on message. - * -/********************************************************************/ - - switch (iMessage) - { - case WM_INITDIALOG: - SendDlgItemMessage(hDlg, IDD_TRANS_STRING, EM_LIMITTEXT, 256, 0L); - return (TRUE); - - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDD_TRANS_STRING: - if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hDlg, IDOK), - (BOOL) SendMessage((HWND) lParam, WM_GETTEXTLENGTH, 0, 0L)); - break; - - case IDOK: - GetDlgItemText(hDlg, IDD_TRANS_STRING, tmpDialogParam, 256); - EndDialog(hDlg, TRUE); - break; - - case IDCANCEL: - tmpDialogParam[0] = '\0'; - EndDialog(hDlg, FALSE); - break; - - case IDD_HELP_BUTTON: - ISQL_win_err("Not implemented yet"); - break; - - default: - return FALSE; - } - break; - - default: - return FALSE; - } - - return TRUE; -} - diff --git a/src/isql/isql_win.h b/src/isql/isql_win.h deleted file mode 100644 index bf5c1fceee..0000000000 --- a/src/isql/isql_win.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * PROGRAM: Interactive SQL utility - * MODULE: isql_win.h - * DESCRIPTION: Windows ISQL include file - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#ifndef ISQL_WIN_H -#define ISQL_WIN_H - -// prototypes - -static void close_isql(); -static int cmdline_isql(HINSTANCE, LPSTR); -static void display_page(HWND); -static SSHORT init_isql(HINSTANCE, HINSTANCE, int); -static void init_isql_added(HINSTANCE); -static void init_isql_every(HINSTANCE, int); -static void init_isql_first(HINSTANCE); -static SSHORT open_temp_file(HINSTANCE, FILE**, SCHAR*, SSHORT); -static void paint_isql(HWND); -static void pusharg(const char*); -static void setup_scroll(HWND); -static void test_overwrite(); -static int windows_isql(HINSTANCE, HINSTANCE, int); -static void xfer_file(const char*, const char*, bool); - -#endif // ISQL_WIN_H - diff --git a/src/isql/isqlw_proto.h b/src/isql/isqlw_proto.h deleted file mode 100644 index 43c28bf448..0000000000 --- a/src/isql/isqlw_proto.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * PROGRAM: Interactive SQL utility - * MODULE: isqlw_proto.h - * DESCRIPTION: Prototype header file for isql_win.c - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#ifndef ISQL_WIN_PROTO_H -#define ISQL_WIN_PROTO_H - -BOOL CALLBACK _export aboutDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export blobDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export charSetDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export createDbDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export dbNameDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export dropDbDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export execDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export extractDlgProc(HWND, UINT, WPARAM, LPARAM); -LRESULT CALLBACK _export isqlWndProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export objectDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export outputDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export scriptDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export sessionDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export termDlgProc(HWND, UINT, WPARAM, LPARAM); -BOOL CALLBACK _export transDlgProc(HWND, UINT, WPARAM, LPARAM); -int PASCAL WinMain(HINSTANCE, HINSTANCE, LPSTR, int); - -#endif // ISQL_WIN_PROTO_H - diff --git a/src/isql/iutils.cpp b/src/isql/iutils.cpp index b609dfc564..943e0f196f 100644 --- a/src/isql/iutils.cpp +++ b/src/isql/iutils.cpp @@ -25,8 +25,8 @@ #include "firebird.h" #include "iutils_proto.h" -#include "../dsql/keywords.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/keywords.h" +#include "../yvalve/gds_proto.h" #include "../jrd/common.h" //#if defined(WIN_NT) //#include diff --git a/src/isql/show.epp b/src/isql/show.epp index db5061fa61..3eb79aed1d 100644 --- a/src/isql/show.epp +++ b/src/isql/show.epp @@ -40,12 +40,12 @@ #include "../jrd/license.h" #include -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/common.h" #include "../jrd/ibase.h" #include "../isql/isql.h" #include "../jrd/intl.h" -#include "../jrd/intlobj_new.h" +#include "../common/intlobj_new.h" #include "../isql/isql_proto.h" #include "../isql/show_proto.h" #include "../isql/iutils_proto.h" diff --git a/src/jrd/Attachment.h b/src/jrd/Attachment.h index 787247ad08..bbef484549 100644 --- a/src/jrd/Attachment.h +++ b/src/jrd/Attachment.h @@ -41,6 +41,11 @@ #include "../common/classes/stack.h" #include "../common/classes/timestamp.h" +#include "ProviderInterface.h" +namespace Jrd +{ + typedef FbApi::Status Status; +} namespace EDS { class Connection; @@ -65,6 +70,7 @@ namespace Jrd class IndexLock; class ArrayField; struct sort_context; + class RecordSelExpr; class vcl; class TextType; class Parameter; @@ -74,7 +80,6 @@ namespace Jrd class TraceManager; template class vec; - struct DSqlCacheItem { Lock* lock; @@ -118,7 +123,7 @@ const int DBB_max_count = 8; // // the attachment block; one is created for each attachment to a database // -class Attachment : public pool_alloc, public Firebird::PublicHandle +class Attachment : public pool_alloc, public Firebird::PublicHandle, public FbApi::Attachment { public: static Attachment* create(Database* dbb, FB_API_HANDLE publicHandle); @@ -215,6 +220,31 @@ public: bool checkHandle() const; +public: + virtual void release(); + virtual void getInfo(Status* status, + unsigned int itemsLength, const unsigned char* items, + unsigned int bufferLength, unsigned char* buffer); +// virtual FbApi::Transaction* startTransaction(Status* status, unsigned int tpbLength, const unsigned char* tpb); +// second form is tmp - not to rewrite external engines right now + virtual FbApi::Transaction* startTransaction(Status* status, unsigned int tpbLength, const unsigned char* tpb, + FB_API_HANDLE api); + virtual FbApi::Transaction* reconnectTransaction(Status* status, unsigned int length, const unsigned char* id); + virtual FbApi::Statement* allocateStatement(Status* status); + virtual FbApi::Request* compileRequest(Status* status, unsigned int blr_length, const unsigned char* blr); + virtual FbApi::Transaction* execute(Status* status, FbApi::Transaction* transaction, + unsigned int length, const char* string, unsigned int dialect, + unsigned int in_blr_length, const unsigned char* in_blr, + unsigned int in_msg_type, unsigned int in_msg_length, const unsigned char* in_msg, + unsigned int out_blr_length, unsigned char* out_blr, + unsigned int out_msg_type, unsigned int out_msg_length, unsigned char* out_msg); + virtual FbApi::Events* queEvents(Status* status, FbApi::EventCallback* callback, + unsigned int length, const unsigned char* events); + virtual void cancelOperation(Status* status, int option); + virtual void ping(Status* status); + virtual void detach(Status* status); + virtual void drop(Status* status); + private: Attachment(MemoryPool* pool, Database* dbb, FB_API_HANDLE publicHandle); ~Attachment(); diff --git a/src/jrd/Collation.cpp b/src/jrd/Collation.cpp index e5294aa066..baca73b31f 100644 --- a/src/jrd/Collation.cpp +++ b/src/jrd/Collation.cpp @@ -99,7 +99,7 @@ #include "../jrd/intl_classes.h" #include "../jrd/lck_proto.h" #include "../jrd/intl_classes.h" -#include "../jrd/TextType.h" +#include "../common/TextType.h" #include "../jrd/SimilarToMatcher.h" @@ -725,7 +725,6 @@ template < typename pContainsMatcher, typename pLikeMatcher, typename pSimilarToMatcher, - typename pSubstringSimilarMatcher, typename pMatchesMatcher, typename pSleuthMatcher > @@ -781,21 +780,16 @@ public: } virtual bool similarTo(MemoryPool& pool, const UCHAR* s, SLONG sl, - const UCHAR* p, SLONG pl, const UCHAR* escape, SLONG escapeLen) + const UCHAR* p, SLONG pl, const UCHAR* escape, SLONG escapeLen, bool forSubstring) { - return pSimilarToMatcher::evaluate(pool, this, s, sl, p, pl, escape, escapeLen); + return pSimilarToMatcher::evaluate(pool, this, s, sl, p, pl, escape, + escapeLen, forSubstring); } - virtual PatternMatcher* createSimilarToMatcher(MemoryPool& pool, const UCHAR* p, SLONG pl, - const UCHAR* escape, SLONG escapeLen) + virtual BaseSimilarToMatcher* createSimilarToMatcher(MemoryPool& pool, const UCHAR* p, SLONG pl, + const UCHAR* escape, SLONG escapeLen, bool forSubstring) { - return pSimilarToMatcher::create(pool, this, p, pl, escape, escapeLen); - } - - virtual BaseSubstringSimilarMatcher* createSubstringSimilarMatcher(MemoryPool& pool, - const UCHAR* p, SLONG pl, const UCHAR* escape, SLONG escapeLen) - { - return pSubstringSimilarMatcher::create(pool, this, p, pl, escape, escapeLen); + return pSimilarToMatcher::create(pool, this, p, pl, escape, escapeLen, forSubstring); } virtual bool contains(MemoryPool& pool, const UCHAR* s, SLONG sl, const UCHAR* p, SLONG pl) @@ -823,7 +817,6 @@ Collation* newCollation(MemoryPool& pool, TTYPE_ID id, texttype* tt, CharSet* cs ContainsMatcherUCharDirect, LikeMatcher, SimilarToMatcher, - SubstringSimilarMatcher, MatchesMatcher, SleuthMatcher > DirectImpl; @@ -833,7 +826,6 @@ Collation* newCollation(MemoryPool& pool, TTYPE_ID id, texttype* tt, CharSet* cs ContainsMatcher, LikeMatcher, SimilarToMatcher, - SubstringSimilarMatcher, MatchesMatcher, SleuthMatcher > NonDirectImpl; diff --git a/src/jrd/Collation.h b/src/jrd/Collation.h index 3f29917dfe..a4b569c5e3 100644 --- a/src/jrd/Collation.h +++ b/src/jrd/Collation.h @@ -30,7 +30,7 @@ #ifndef JRD_COLLATION_H #define JRD_COLLATION_H -#include "TextType.h" +#include "../common/TextType.h" namespace Jrd { @@ -66,12 +66,9 @@ public: const UCHAR* escape, SLONG escapeLen) = 0; virtual bool similarTo(MemoryPool& pool, const UCHAR* s, SLONG sl, const UCHAR* p, SLONG pl, - const UCHAR* escape, SLONG escapeLen) = 0; - virtual PatternMatcher* createSimilarToMatcher(MemoryPool& pool, const UCHAR* p, SLONG pl, - const UCHAR* escape, SLONG escapeLen) = 0; - - virtual BaseSubstringSimilarMatcher* createSubstringSimilarMatcher(MemoryPool& pool, - const UCHAR* p, SLONG pl, const UCHAR* escape, SLONG escapeLen) = 0; + const UCHAR* escape, SLONG escapeLen, bool forSubstring) = 0; + virtual BaseSimilarToMatcher* createSimilarToMatcher(MemoryPool& pool, const UCHAR* p, SLONG pl, + const UCHAR* escape, SLONG escapeLen, bool forSubstring) = 0; virtual bool contains(MemoryPool& pool, const UCHAR* s, SLONG sl, const UCHAR* p, SLONG pl) = 0; virtual PatternMatcher* createContainsMatcher(MemoryPool& pool, const UCHAR* p, SLONG pl) = 0; diff --git a/src/jrd/DataTypeUtil.cpp b/src/jrd/DataTypeUtil.cpp index 776bd4cdeb..0a02941878 100644 --- a/src/jrd/DataTypeUtil.cpp +++ b/src/jrd/DataTypeUtil.cpp @@ -29,10 +29,10 @@ #include "../jrd/DataTypeUtil.h" #include "../jrd/SysFunction.h" #include "../jrd/align.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../jrd/ibase.h" #include "../jrd/intl.h" -#include "../jrd/dsc_proto.h" +#include "../common/dsc_proto.h" #include "../jrd/intl_proto.h" #include "../jrd/gdsassert.h" diff --git a/src/jrd/Database.cpp b/src/jrd/Database.cpp index 64dddb7977..7faf184b51 100644 --- a/src/jrd/Database.cpp +++ b/src/jrd/Database.cpp @@ -39,7 +39,7 @@ #include "../jrd/os/pio_proto.h" // Thread data block -#include "../jrd/ThreadData.h" +#include "../common/ThreadData.h" // recursive mutexes #include "../common/thd.h" diff --git a/src/jrd/Database.h b/src/jrd/Database.h index da12be5737..f8407e6acf 100644 --- a/src/jrd/Database.h +++ b/src/jrd/Database.h @@ -34,7 +34,7 @@ #include "../jrd/cch.h" #include "../jrd/gdsassert.h" #include "../jrd/common.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../jrd/btn.h" #include "../jrd/jrd_proto.h" #include "../jrd/val.h" @@ -55,7 +55,7 @@ #include "../common/classes/semaphore.h" #include "../common/utils_proto.h" #include "../jrd/RandomGenerator.h" -#include "../jrd/os/guid.h" +#include "../common/os/guid.h" #include "../jrd/sbm.h" #include "../jrd/flu.h" #include "../jrd/RuntimeStatistics.h" diff --git a/src/jrd/DatabaseSnapshot.cpp b/src/jrd/DatabaseSnapshot.cpp index d573f820af..999f8aa605 100644 --- a/src/jrd/DatabaseSnapshot.cpp +++ b/src/jrd/DatabaseSnapshot.cpp @@ -31,14 +31,14 @@ #include "../jrd/cch.h" #include "../jrd/ini.h" #include "../jrd/nbak.h" -#include "../jrd/os/guid.h" +#include "../common/os/guid.h" #include "../jrd/os/pio.h" #include "../jrd/req.h" #include "../jrd/tra.h" #include "../jrd/blb_proto.h" -#include "../jrd/isc_proto.h" -#include "../jrd/isc_f_proto.h" -#include "../jrd/isc_s_proto.h" +#include "../common/isc_proto.h" +#include "../common/isc_f_proto.h" +#include "../common/isc_s_proto.h" #include "../jrd/lck_proto.h" #include "../jrd/met_proto.h" #include "../jrd/mov_proto.h" @@ -918,7 +918,7 @@ void DatabaseSnapshot::putDatabase(const Database* database, Writer& writer, int } -bool DatabaseSnapshot::putAttachment(thread_db* /*tdbb*/, const Jrd::Attachment* attachment, +bool DatabaseSnapshot::putAttachment(thread_db* tdbb, const Jrd::Attachment* attachment, Writer& writer, int stat_id) { fb_assert(attachment); diff --git a/src/jrd/DatabaseSnapshot.h b/src/jrd/DatabaseSnapshot.h index f7dad1f059..3b23df4079 100644 --- a/src/jrd/DatabaseSnapshot.h +++ b/src/jrd/DatabaseSnapshot.h @@ -26,7 +26,7 @@ #include "../common/classes/array.h" #include "../common/classes/init.h" -#include "../jrd/isc_s_proto.h" +#include "../common/isc_s_proto.h" #include "../common/classes/timestamp.h" #include "../jrd/val.h" #include "../jrd/recsrc/RecordSource.h" diff --git a/src/jrd/ExtEngineManager.cpp b/src/jrd/ExtEngineManager.cpp index 1b9748f3b7..d8eaa553cb 100644 --- a/src/jrd/ExtEngineManager.cpp +++ b/src/jrd/ExtEngineManager.cpp @@ -29,7 +29,7 @@ #include "../jrd/ValueImpl.h" #include "../jrd/ValuesImpl.h" #include "../dsql/sqlda_pub.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../jrd/jrd.h" #include "../jrd/exe.h" #include "../jrd/req.h" @@ -37,7 +37,7 @@ #include "../jrd/tra.h" #include "../jrd/PluginManager.h" #include "../jrd/ibase.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #include "../jrd/cvt_proto.h" #include "../jrd/evl_proto.h" #include "../jrd/intl_proto.h" @@ -45,13 +45,13 @@ #include "../jrd/mov_proto.h" #include "../jrd/thread_proto.h" #include "../jrd/Function.h" -#include "../jrd/isc_proto.h" +#include "../common/isc_proto.h" #include "../common/classes/auto.h" #include "../common/classes/fb_string.h" #include "../common/classes/init.h" #include "../common/classes/objects_array.h" #include "../common/config/config.h" -#include "../config/ScanDir.h" +#include "../common/ScanDir.h" using namespace Firebird; @@ -388,7 +388,7 @@ ExtEngineManager::Function::~Function() } -void ExtEngineManager::Function::execute(thread_db* tdbb, const jrd_nod* args, impure_value* impure) const +void ExtEngineManager::Function::execute(thread_db* tdbb, const jrd_nod* args, impure_value* impure) { EngineAttachmentInfo* attInfo = extManager->getEngineAttachment(tdbb, engine); ContextManager ctxManager(tdbb, attInfo, function, @@ -564,7 +564,7 @@ ExtEngineManager::Trigger::~Trigger() void ExtEngineManager::Trigger::execute(thread_db* tdbb, ExternalTrigger::Action action, - record_param* oldRpb, record_param* newRpb) const + record_param* oldRpb, record_param* newRpb) { EngineAttachmentInfo* attInfo = extManager->getEngineAttachment(tdbb, engine); ContextManager ctxManager(tdbb, attInfo, trigger, @@ -612,9 +612,9 @@ void ExtEngineManager::Trigger::execute(thread_db* tdbb, ExternalTrigger::Action } -int ExtEngineManager::Trigger::setValues(thread_db* /*tdbb*/, MemoryPool& pool, +int ExtEngineManager::Trigger::setValues(thread_db* tdbb, MemoryPool& pool, AutoPtr& values, Array& descs, - record_param* rpb) const + record_param* rpb) { if (!rpb || !rpb->rpb_record) return 0; diff --git a/src/jrd/ExtEngineManager.h b/src/jrd/ExtEngineManager.h index 4be3fb6191..0c8a2246ca 100644 --- a/src/jrd/ExtEngineManager.h +++ b/src/jrd/ExtEngineManager.h @@ -130,7 +130,7 @@ public: const Jrd::Function* aUdf); ~Function(); - void execute(thread_db* tdbb, const jrd_nod* args, impure_value* impure) const; + void execute(thread_db* tdbb, const jrd_nod* args, impure_value* impure); private: ExtEngineManager* extManager; @@ -191,12 +191,12 @@ public: ~Trigger(); void execute(thread_db* tdbb, Firebird::ExternalTrigger::Action action, - record_param* oldRpb, record_param* newRpb) const; + record_param* oldRpb, record_param* newRpb); private: int setValues(thread_db* tdbb, Firebird::MemoryPool& pool, Firebird::AutoPtr& values, Firebird::Array& descs, - record_param* rpb) const; + record_param* rpb); ExtEngineManager* extManager; Firebird::ExternalEngine* engine; diff --git a/src/jrd/Function.epp b/src/jrd/Function.epp index 0bbd3499b5..86f9ae9037 100644 --- a/src/jrd/Function.epp +++ b/src/jrd/Function.epp @@ -34,7 +34,7 @@ #include "../jrd/align.h" #include "../jrd/blb_proto.h" #include "../jrd/cmp_proto.h" -#include "../jrd/dsc_proto.h" +#include "../common/dsc_proto.h" #include "../jrd/evl_proto.h" #include "../jrd/exe_proto.h" #include "../jrd/flu_proto.h" @@ -228,7 +228,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT AutoCacheRequest request_fun(tdbb, irq_l_functions, IRQ_REQUESTS); - Argument temp[MAX_UDF_ARGUMENTS + 1]; + fun_repeat temp[MAX_UDF_ARGUMENTS + 1]; FOR(REQUEST_HANDLE request_fun) X IN RDB$FUNCTIONS @@ -261,6 +261,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT memset(temp, 0, sizeof(temp)); ULONG length = 0; + function->setUndefined(false); function->fun_inputs = 0; function->fun_defaults = 0; @@ -275,7 +276,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT if (Y.RDB$ARGUMENT_POSITION != X.RDB$RETURN_ARGUMENT) function->fun_inputs++; - Argument* const tail = temp + Y.RDB$ARGUMENT_POSITION; + fun_repeat* const tail = temp + Y.RDB$ARGUMENT_POSITION; tail->fun_mechanism = (FUN_T) Y.RDB$MECHANISM; Parameter* const parameter = FB_NEW(*dbb->dbb_permanent) Parameter(*dbb->dbb_permanent); @@ -333,7 +334,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT try { parameter->prm_default_value = - MET_parse_blob(tdbb, NULL, &default_value, NULL, NULL, false, false); + MET_parse_blob(tdbb, NULL, &default_value, NULL, NULL, false); } catch (const Exception&) { @@ -355,7 +356,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT function->fun_return_arg = X.RDB$RETURN_ARGUMENT; function->fun_temp_length = length; function->fun_args.resize(count + 1); - memcpy(function->fun_args.begin(), temp, function->fun_args.getCount() * sizeof(Argument)); + memcpy(function->fun_args.begin(), temp, function->fun_args.getCount() * sizeof(fun_repeat)); // Prepare the exception message to be used in case this function ever // causes an exception. This is done at this time to save us from preparing @@ -363,20 +364,23 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT function->fun_exception_message.printf(EXCEPTION_MESSAGE, function->getName().toString().c_str(), X.RDB$ENTRYPOINT, X.RDB$MODULE_NAME); + if (!X.RDB$LEGACY_FLAG.NULL) + { + function->fun_legacy = (X.RDB$LEGACY_FLAG != 0); + } + if (!X.RDB$INVARIANT_FLAG.NULL) { function->fun_invariant = (X.RDB$INVARIANT_FLAG != 0); } - function->setUndefined(false); - function->setImplemented(true); - - function->fun_entrypoint = NULL; - function->fun_external = NULL; - function->setStatement(NULL); - if (!X.RDB$ENGINE_NAME.NULL) { + fb_assert(!function->fun_legacy); + + function->fun_entrypoint = NULL; + function->setStatement(NULL); + HalfStaticArray body; if (!X.RDB$FUNCTION_SOURCE.NULL) @@ -391,17 +395,17 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT body.getBuffer(1)[0] = 0; } - function->fun_external = - dbb->dbb_extManager.makeFunction(tdbb, function, X.RDB$ENGINE_NAME, + function->fun_external = dbb->dbb_extManager.makeFunction( + tdbb, function, X.RDB$ENGINE_NAME, (X.RDB$ENTRYPOINT.NULL ? "" : X.RDB$ENTRYPOINT), (char*) body.begin()); - - if (!function->fun_external) - { - function->setImplemented(false); - } } else if (!X.RDB$FUNCTION_BLR.NULL) { + fb_assert(!function->fun_legacy); + + function->fun_external = NULL; + function->fun_entrypoint = NULL; + MemoryPool* const csb_pool = dbb->createPool(); Jrd::ContextPoolHolder context(tdbb, csb_pool); @@ -432,27 +436,31 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT function->makeFormat(); } - else if (!X.RDB$MODULE_NAME.NULL && !X.RDB$ENTRYPOINT.NULL) - { - function->fun_entrypoint = - Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb->dbb_modules); - - // Could not find a function with given MODULE, ENTRYPOINT. - // Try the list of internally implemented functions. - if (!function->fun_entrypoint) - { - function->fun_entrypoint = - BUILTIN_entrypoint(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT); - } - - if (!function->fun_entrypoint) - { - function->setImplemented(false); - } - } else { - function->setUndefined(true); + function->fun_external = NULL; + function->setStatement(NULL); + + if (!X.RDB$MODULE_NAME.NULL && !X.RDB$ENTRYPOINT.NULL) + { + fb_assert(function->fun_legacy); + + function->fun_entrypoint = + Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb->dbb_modules); + + // Could not find a function with given MODULE, ENTRYPOINT. + // Try the list of internally implemented functions. + if (!function->fun_entrypoint) + { + function->fun_entrypoint = + BUILTIN_entrypoint(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT); + } + } + else + { + function->fun_entrypoint = NULL; + function->setUndefined(true); + } } if (X.RDB$VALID_BLR.NULL || X.RDB$VALID_BLR == FALSE) @@ -553,7 +561,7 @@ void Function::remove(thread_db* tdbb) } } -ULONG Function::allocateImpure(CompilerScratch* csb) const +ULONG Function::allocateImpure(CompilerScratch* csb) { const ULONG impure = CMP_impure(csb, sizeof(impure_value)); @@ -586,7 +594,7 @@ void Function::parseBlr(thread_db* tdbb, bid* blob_id, CompilerScratch* csb) statement = NULL; } - MET_parse_blob(tdbb, NULL, blob_id, &csb, &statement, false, false); + MET_parse_blob(tdbb, NULL, blob_id, &csb, &statement, false); statement->function = this; setStatement(statement); } @@ -660,7 +668,7 @@ dsc* Function::execute(thread_db* tdbb, const jrd_nod* args, impure_value* value jrd_req* const request = tdbb->getRequest(); - const Argument* const return_ptr = &fun_args[fun_return_arg]; + const fun_repeat* const return_ptr = &fun_args[fun_return_arg]; value->vlu_desc = return_ptr->fun_parameter->prm_desc; // If the return data type is any of the string types, @@ -696,8 +704,9 @@ dsc* Function::execute(thread_db* tdbb, const jrd_nod* args, impure_value* value { fun_external->execute(tdbb, args, value); } - else if (getStatement()) + else { + fb_assert(getStatement()); fb_assert(!fun_return_arg); fb_assert(args->nod_count == fun_inputs); @@ -796,10 +805,6 @@ dsc* Function::execute(thread_db* tdbb, const jrd_nod* args, impure_value* value MOV_move(tdbb, &arg_desc, &value->vlu_desc); } } - else - { - fb_assert(false); - } return (request->req_flags & req_null) ? NULL : &value->vlu_desc; } diff --git a/src/jrd/Function.h b/src/jrd/Function.h index 994fd23574..16eb7fa3f7 100644 --- a/src/jrd/Function.h +++ b/src/jrd/Function.h @@ -22,24 +22,23 @@ #include "../jrd/Routine.h" #include "../common/classes/array.h" -#include "../common/classes/NestConst.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../jrd/val.h" namespace Jrd { + struct fun_repeat + { + Parameter* fun_parameter; // parameter info + FUN_T fun_mechanism; // passing mechanism + }; + class Function : public Routine { static const USHORT MAX_ALTER_COUNT = 64; // Number of times an in-cache function can be altered static const char* const EXCEPTION_MESSAGE; public: - struct Argument - { - NestConst fun_parameter; // parameter info - FUN_T fun_mechanism; // passing mechanism - }; - static Function* lookup(thread_db* tdbb, USHORT id, bool return_deleted, bool noscan, USHORT flags); static Function* lookup(thread_db* tdbb, const Firebird::QualifiedName& name, bool noscan); @@ -56,7 +55,7 @@ namespace Jrd dsc* execute(thread_db* tdbb, const jrd_nod* args, impure_value* value) const; void releaseLocks(thread_db* tdbb); void remove(thread_db* tdbb); - ULONG allocateImpure(CompilerScratch* csb) const; + ULONG allocateImpure(CompilerScratch* csb); void parseBlr(thread_db* tdbb, bid* blob_id, CompilerScratch* csb); jrd_nod* parseArgs(thread_db* tdbb, CompilerScratch* csb); @@ -76,6 +75,7 @@ namespace Jrd fun_existence_lock(NULL), fun_alter_count(0), fun_exception_message(p), + fun_legacy(true), fun_invariant(false), fun_external(NULL) { @@ -107,7 +107,7 @@ namespace Jrd Format fun_in_msg_format; Format fun_out_msg_format; - Firebird::Array fun_args; + Firebird::Array fun_args; USHORT fun_flags; // flags USHORT fun_use_count; // requests compiled with function @@ -116,8 +116,9 @@ namespace Jrd Firebird::string fun_exception_message; // message containing the exception error message + bool fun_legacy; bool fun_invariant; - const ExtEngineManager::Function* fun_external; + ExtEngineManager::Function* fun_external; }; const USHORT FUN_scanned = 1; // Field expressions scanned diff --git a/src/jrd/GlobalRWLock.cpp b/src/jrd/GlobalRWLock.cpp index e1a44744a5..0e48f96502 100644 --- a/src/jrd/GlobalRWLock.cpp +++ b/src/jrd/GlobalRWLock.cpp @@ -31,7 +31,7 @@ #include "firebird.h" #include "GlobalRWLock.h" #include "../lock/lock_proto.h" -#include "isc_proto.h" +#include "../common/isc_proto.h" #include "jrd.h" #include "lck_proto.h" #include "err_proto.h" diff --git a/src/jrd/IntlManager.cpp b/src/jrd/IntlManager.cpp index 9a172a84e4..28a94ff4a1 100644 --- a/src/jrd/IntlManager.cpp +++ b/src/jrd/IntlManager.cpp @@ -26,17 +26,17 @@ #include "firebird.h" #include "../jrd/IntlManager.h" -#include "../jrd/os/mod_loader.h" -#include "../jrd/intlobj_new.h" +#include "../common/os/mod_loader.h" +#include "../common/intlobj_new.h" #include "../jrd/intl_proto.h" -#include "../jrd/isc_proto.h" +#include "../common/isc_proto.h" #include "../common/config/config.h" #include "../common/classes/GenericMap.h" #include "../common/classes/objects_array.h" #include "../common/classes/fb_string.h" #include "../common/classes/init.h" -#include "../config/ScanDir.h" +#include "../common/ScanDir.h" #include "../common/config/config_file.h" using namespace Firebird; diff --git a/src/jrd/JrdStatement.cpp b/src/jrd/JrdStatement.cpp index ab01230e1a..2d9583c0a6 100644 --- a/src/jrd/JrdStatement.cpp +++ b/src/jrd/JrdStatement.cpp @@ -138,7 +138,8 @@ JrdStatement::JrdStatement(thread_db* tdbb, MemoryPool* p, CompilerScratch* csb) // make a vector of all invariant-type nodes, so that we will // be able to easily reinitialize them when we restart the request - invariants.join(csb->csb_invariants); + for (Array::iterator i = csb->csb_invariants.begin(); i != csb->csb_invariants.end(); ++i) + invariants.add(*i); rpbsSetup.grow(csb->csb_n_stream); diff --git a/src/jrd/JrdStatement.h b/src/jrd/JrdStatement.h index 6c4b23d2ac..b9ed55af0b 100644 --- a/src/jrd/JrdStatement.h +++ b/src/jrd/JrdStatement.h @@ -28,7 +28,7 @@ namespace Jrd { // Compiled statement. -class JrdStatement : public pool_alloc +class JrdStatement : public pool_alloc, public FbApi::Request { public: static const unsigned FLAG_SYS_TRIGGER = 0x01; @@ -77,11 +77,26 @@ public: const jrd_nod* topNode; // top of execution tree Firebird::Array fors; // record sources Firebird::Array execStmts; // exec_into nodes - Firebird::Array invariants; // pointer to nodes invariant offsets + Firebird::Array invariants; // invariant nodes Firebird::RefStrPtr sqlText; // SQL text (encoded in the metadata charset) Firebird::Array blr; // BLR for non-SQL query MapFieldInfo mapFieldInfo; // Map field name to field info MapItemInfo mapItemInfo; // Map item to item info + +public: + virtual void release(); + virtual void receive(Status* status, int level, unsigned int msg_type, + unsigned int length, unsigned char* message); + virtual void send(Status* status, int level, unsigned int msg_type, + unsigned int length, const unsigned char* message); + virtual void getInfo(Status* status, int level, + unsigned int itemsLength, const unsigned char* items, + unsigned int bufferLength, unsigned char* buffer); + virtual void start(Status* status, FbApi::Transaction* tra, int level); + virtual void startAndSend(Status* status, FbApi::Transaction* tra, int level, unsigned int msg_type, + unsigned int length, const unsigned char* message); + virtual void unwind(Status* status, int level); + virtual void detach(Status* status); }; diff --git a/src/jrd/Optimizer.cpp b/src/jrd/Optimizer.cpp index b5dd24f0a6..527f4bdfcd 100644 --- a/src/jrd/Optimizer.cpp +++ b/src/jrd/Optimizer.cpp @@ -36,9 +36,7 @@ #include "../jrd/rse.h" #include "../jrd/ods.h" #include "../jrd/Optimizer.h" -#include "../jrd/RecordSourceNodes.h" #include "../jrd/recsrc/RecordSource.h" -#include "../dsql/BoolNodes.h" #include "../dsql/ExprNodes.h" #include "../dsql/StmtNodes.h" @@ -91,18 +89,56 @@ bool OPT_computable(CompilerScratch* csb, jrd_nod* node, SSHORT stream, DEV_BLKCHK(csb, type_csb); DEV_BLKCHK(node, type_nod); + if (node->nod_flags & nod_deoptimize) { + return false; + } + // Recurse thru interesting sub-nodes switch (node->nod_type) { - case nod_class_recsrcnode_jrd: - return reinterpret_cast(node->nod_arg[0])->computable( - csb, stream, idx_use, allowOnlyCurrentStream, NULL); + case nod_procedure: + { + jrd_nod* inputs = node->nod_arg[e_prc_inputs]; + if (inputs) + { + fb_assert(inputs->nod_type == nod_asn_list); + jrd_nod* const* ptr = inputs->nod_arg; + for (const jrd_nod* const* const end = ptr + inputs->nod_count; ptr < end; ptr++) + { + if (!OPT_computable(csb, *ptr, stream, idx_use, allowOnlyCurrentStream)) { + return false; + } + } + } + break; + } + + case nod_union: + { + jrd_nod* clauses = node->nod_arg[e_uni_clauses]; + jrd_nod* const* ptr = clauses->nod_arg; + for (const jrd_nod* const* const end = ptr + clauses->nod_count; ptr < end; ptr += 2) + { + if (!OPT_computable(csb, *ptr, stream, idx_use, allowOnlyCurrentStream)) { + return false; + } + } + break; + } case nod_class_exprnode_jrd: { ExprNode* exprNode = reinterpret_cast(node->nod_arg[0]); - return exprNode->computable(csb, stream, idx_use, allowOnlyCurrentStream); + + for (NestConst >* i = exprNode->jrdChildNodes.begin(); + i != exprNode->jrdChildNodes.end(); ++i) + { + if (!OPT_computable(csb, **i, stream, idx_use, allowOnlyCurrentStream)) + return false; + } + + break; } default: @@ -110,13 +146,17 @@ bool OPT_computable(CompilerScratch* csb, jrd_nod* node, SSHORT stream, jrd_nod* const* ptr = node->nod_arg; for (const jrd_nod* const* const end = ptr + node->nod_count; ptr < end; ptr++) { - if (!OPT_computable(csb, *ptr, stream, idx_use, allowOnlyCurrentStream)) + if (!OPT_computable(csb, *ptr, stream, idx_use, allowOnlyCurrentStream)) { return false; + } } break; } } + RecordSelExpr* rse; + jrd_nod* sub; + jrd_nod* value; USHORT n; switch (node->nod_type) @@ -126,12 +166,15 @@ bool OPT_computable(CompilerScratch* csb, jrd_nod* node, SSHORT stream, if (allowOnlyCurrentStream) { if (n != stream && !(csb->csb_rpt[n].csb_flags & csb_sub_stream)) + { return false; + } } else { - if (n == stream) + if (n == stream) { return false; + } } return csb->csb_rpt[n].csb_flags & csb_active; @@ -182,24 +225,115 @@ bool OPT_computable(CompilerScratch* csb, jrd_nod* node, SSHORT stream, case nod_total: case nod_count: case nod_from: + if ((sub = node->nod_arg[e_stat_default]) && + !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) { - jrd_nod* sub; + return false; + } + rse = (RecordSelExpr*) node->nod_arg[e_stat_rse]; + value = node->nod_arg[e_stat_value]; + break; - if ((sub = node->nod_arg[e_stat_default]) && - !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) + case nod_rse: + rse = (RecordSelExpr*) node; + value = NULL; + break; + + case nod_aggregate: + rse = (RecordSelExpr*) node->nod_arg[e_agg_rse]; + rse->rse_sorted = node->nod_arg[e_agg_group]; + value = NULL; + break; + + case nod_window: + rse = (RecordSelExpr*) node->nod_arg[e_win_rse]; + value = NULL; + break; + + default: + return true; + } + + // Node is a record selection expression. + bool result = true; + + if ((sub = rse->rse_first) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) { + return false; + } + + if ((sub = rse->rse_skip) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) { + return false; + } + + // Set sub-streams of rse active + jrd_nod* const* ptr; + const jrd_nod* const* end; + + for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end; ptr++) + { + const jrd_nod* const node = *ptr; + + if (node->nod_type == nod_window) + { + const jrd_nod* windows = node->nod_arg[e_win_windows]; + + for (unsigned i = 0; i < windows->nod_count; ++i) { - return false; + n = (USHORT)(IPTR) windows->nod_arg[i]->nod_arg[e_part_stream]; + csb->csb_rpt[n].csb_flags |= (csb_active | csb_sub_stream); } - - fb_assert(node->nod_arg[e_stat_rse]->nod_type == nod_class_recsrcnode_jrd); - RseNode* rse = reinterpret_cast(node->nod_arg[e_stat_rse]->nod_arg[0]); - - return rse->computable(csb, stream, idx_use, allowOnlyCurrentStream, - node->nod_arg[e_stat_value]); + } + else if (node->nod_type != nod_rse) + { + n = (USHORT)(IPTR) node->nod_arg[STREAM_INDEX(node)]; + csb->csb_rpt[n].csb_flags |= (csb_active | csb_sub_stream); } } - return true; + // Check sub-stream + if (((sub = rse->rse_boolean) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) || + ((sub = rse->rse_sorted) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) || + ((sub = rse->rse_projection) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream))) + { + result = false; + } + + for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end && result; ptr++) + { + if (!OPT_computable(csb, (*ptr), stream, idx_use, allowOnlyCurrentStream)) + { + result = false; + } + } + + // Check value expression, if any + if (result && value && !OPT_computable(csb, value, stream, idx_use, allowOnlyCurrentStream)) { + result = false; + } + + // Reset streams inactive + for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end; ptr++) + { + const jrd_nod* const node = *ptr; + + if (node->nod_type == nod_window) + { + const jrd_nod* windows = node->nod_arg[e_win_windows]; + + for (unsigned i = 0; i < windows->nod_count; ++i) + { + n = (USHORT)(IPTR) windows->nod_arg[i]->nod_arg[e_part_stream]; + csb->csb_rpt[n].csb_flags &= ~(csb_active | csb_sub_stream); + } + } + else if (node->nod_type != nod_rse) + { + n = (USHORT)(IPTR) (*ptr)->nod_arg[STREAM_INDEX((*ptr))]; + csb->csb_rpt[n].csb_flags &= ~(csb_active | csb_sub_stream); + } + } + + return result; } @@ -255,7 +389,9 @@ bool OPT_expression_equal2(thread_db* tdbb, CompilerScratch* csb, SET_TDBB(tdbb); if (!node1 || !node2) + { BUGCHECK(303); // msg 303 Invalid expression for evaluation. + } if (node1->nod_type != node2->nod_type) { @@ -294,10 +430,86 @@ bool OPT_expression_equal2(thread_db* tdbb, CompilerScratch* csb, { ExprNode* exprNode1 = reinterpret_cast(node1->nod_arg[0]); ExprNode* exprNode2 = reinterpret_cast(node2->nod_arg[0]); + Array > >& children1 = exprNode1->jrdChildNodes; + Array > >& children2 = exprNode2->jrdChildNodes; - return exprNode1->expressionEqual(tdbb, csb, exprNode2, stream); + if (exprNode1->type != exprNode2->type || children1.getCount() != children2.getCount()) + return false; + + switch (exprNode1->type) + { + case ExprNode::TYPE_SYSFUNC_CALL: + case ExprNode::TYPE_UDF_CALL: + switch (exprNode1->type) + { + case ExprNode::TYPE_SYSFUNC_CALL: + if (!exprNode1->as()->function || + exprNode1->as()->function != exprNode2->as()->function) + { + return false; + } + break; + + case ExprNode::TYPE_UDF_CALL: + if (!exprNode1->as()->function || + exprNode1->as()->function != exprNode2->as()->function) + { + return false; + } + break; + } + // fall into + + case ExprNode::TYPE_CONCATENATE: + case ExprNode::TYPE_SUBSTRING_SIMILAR: + for (NestConst >* i = children1.begin(), *j = children2.begin(); + i != children1.end(); ++i, ++j) + { + if (!OPT_expression_equal2(tdbb, csb, **i, **j, stream)) + return false; + } + + return true; + } + + break; } + case nod_add: + case nod_multiply: + case nod_add2: + case nod_multiply2: + case nod_equiv: + case nod_eql: + case nod_neq: + case nod_and: + case nod_or: + // A+B is equivalent to B+A, ditto A*B==B*A + // Note: If one expression is A+B+C, but the other is B+C+A we won't + // necessarily match them. + if (OPT_expression_equal2(tdbb, csb, node1->nod_arg[0], node2->nod_arg[1], stream) && + OPT_expression_equal2(tdbb, csb, node1->nod_arg[1], node2->nod_arg[0], stream)) + { + return true; + } + // Fall into ... + case nod_subtract: + case nod_divide: + case nod_subtract2: + case nod_divide2: + + // TODO match A > B to B <= A, etc + case nod_gtr: + case nod_geq: + case nod_leq: + case nod_lss: + if (OPT_expression_equal2(tdbb, csb, node1->nod_arg[0], node2->nod_arg[0], stream) && + OPT_expression_equal2(tdbb, csb, node1->nod_arg[1], node2->nod_arg[1], stream)) + { + return true; + } + break; + case nod_rec_version: case nod_dbkey: if (node1->nod_arg[0] == node2->nod_arg[0]) @@ -307,77 +519,147 @@ bool OPT_expression_equal2(thread_db* tdbb, CompilerScratch* csb, break; case nod_field: - { - const USHORT fld_stream = (USHORT)(IPTR) node2->nod_arg[e_fld_stream]; - return (node1->nod_arg[e_fld_id] == node2->nod_arg[e_fld_id]) && fld_stream == stream; - } + { + const USHORT fld_stream = (USHORT)(IPTR) node2->nod_arg[e_fld_stream]; + if ((node1->nod_arg[e_fld_id] == node2->nod_arg[e_fld_id]) && fld_stream == stream) + { + return true; + } + } + break; case nod_literal: - { - dsc desc1, desc2; + { + dsc desc1, desc2; - CMP_get_desc(tdbb, csb, node1, &desc1); - CMP_get_desc(tdbb, csb, node2, &desc2); + CMP_get_desc(tdbb, csb, node1, &desc1); + CMP_get_desc(tdbb, csb, node2, &desc2); - return DSC_EQUIV(&desc1, &desc2, true) && - !memcmp(desc1.dsc_address, desc2.dsc_address, desc1.dsc_length); - } + if (DSC_EQUIV(&desc1, &desc2, true) && + !memcmp(desc1.dsc_address, desc2.dsc_address, desc1.dsc_length)) + { + return true; + } + } + break; case nod_null: + case nod_user_name: + case nod_current_role: + case nod_current_time: + case nod_current_date: + case nod_current_timestamp: return true; + case nod_between: + case nod_like: + case nod_similar: + case nod_missing: + case nod_any: + case nod_ansi_any: + case nod_ansi_all: + case nod_not: + case nod_unique: + + case nod_value_if: case nod_substr: - if (node1->nod_count != node2->nod_count) - return false; - - for (int i = 0; i < node1->nod_count; ++i) + case nod_trim: { - if (!OPT_expression_equal2(tdbb, csb, node1->nod_arg[i], node2->nod_arg[i], stream)) + if (node1->nod_count != node2->nod_count) + { return false; + } + for (int i = 0; i < node1->nod_count; ++i) + { + if (!OPT_expression_equal2(tdbb, csb, node1->nod_arg[i], node2->nod_arg[i], stream)) + { + return false; + } + } + return true; } + break; - return true; + case nod_gen_id: + case nod_gen_id2: + if (node1->nod_arg[e_gen_id] == node2->nod_arg[e_gen_id]) + { + return true; + } + break; + + case nod_negate: + case nod_internal_info: + if (OPT_expression_equal2(tdbb, csb, node1->nod_arg[0], node2->nod_arg[0], stream)) + { + return true; + } + break; + + case nod_upcase: + case nod_lowcase: + if (OPT_expression_equal2(tdbb, csb, node1->nod_arg[0], node2->nod_arg[0], stream)) + { + return true; + } + break; case nod_cast: - { - dsc desc1, desc2; + { + dsc desc1, desc2; - CMP_get_desc(tdbb, csb, node1, &desc1); - CMP_get_desc(tdbb, csb, node2, &desc2); + CMP_get_desc(tdbb, csb, node1, &desc1); + CMP_get_desc(tdbb, csb, node2, &desc2); - return DSC_EQUIV(&desc1, &desc2, true) && - OPT_expression_equal2(tdbb, csb, node1->nod_arg[e_cast_source], - node2->nod_arg[e_cast_source], stream); - } + if (DSC_EQUIV(&desc1, &desc2, true) && + OPT_expression_equal2(tdbb, csb, node1->nod_arg[e_cast_source], + node2->nod_arg[e_cast_source], stream)) + { + return true; + } + } + break; case nod_extract: - return node1->nod_arg[e_extract_part] == node2->nod_arg[e_extract_part] && + if (node1->nod_arg[e_extract_part] == node2->nod_arg[e_extract_part] && OPT_expression_equal2(tdbb, csb, node1->nod_arg[e_extract_value], - node2->nod_arg[e_extract_value], stream); + node2->nod_arg[e_extract_value], stream)) + { + return true; + } + break; case nod_strlen: - return node1->nod_arg[e_strlen_type] == node2->nod_arg[e_strlen_type] && + if (node1->nod_arg[e_strlen_type] == node2->nod_arg[e_strlen_type] && OPT_expression_equal2(tdbb, csb, node1->nod_arg[e_strlen_value], - node2->nod_arg[e_strlen_value], stream); + node2->nod_arg[e_strlen_value], stream)) + { + return true; + } + break; case nod_list: - { - jrd_nod* const* ptr1 = node1->nod_arg; - jrd_nod* const* ptr2 = node2->nod_arg; - - if (node1->nod_count != node2->nod_count) - return false; - - ULONG count = node1->nod_count; - - while (count--) { - if (!OPT_expression_equal2(tdbb, csb, *ptr1++, *ptr2++, stream)) - return false; - } + jrd_nod* const* ptr1 = node1->nod_arg; + jrd_nod* const* ptr2 = node2->nod_arg; - return true; - } + if (node1->nod_count != node2->nod_count) + { + return false; + } + + ULONG count = node1->nod_count; + + while (count--) + { + if (!OPT_expression_equal2(tdbb, csb, *ptr1++, *ptr2++, stream)) + { + return false; + } + } + + return true; + } // AB: New nodes has to be added @@ -422,6 +704,32 @@ double OPT_getRelationCardinality(thread_db* tdbb, jrd_rel* relation, const Form } +jrd_nod* OPT_make_binary_node(nod_t type, jrd_nod* arg1, jrd_nod* arg2, bool flag) +{ +/************************************** + * + * m a k e _ b i n a r y _ n o d e + * + ************************************** + * + * Functional description + * Make a binary node. + * + **************************************/ + thread_db* tdbb = JRD_get_thread_data(); + DEV_BLKCHK(arg1, type_nod); + DEV_BLKCHK(arg2, type_nod); + jrd_nod* node = PAR_make_node(tdbb, 2); + node->nod_type = type; + node->nod_arg[0] = arg1; + node->nod_arg[1] = arg2; + if (flag) { + node->nod_flags |= nod_comparison; + } + return node; +} + + string OPT_make_alias(thread_db* tdbb, const CompilerScratch* csb, const CompilerScratch::csb_repeat* base_tail) { @@ -661,8 +969,8 @@ InversionCandidate::InversionCandidate(MemoryPool& p) : OptimizerRetrieval::OptimizerRetrieval(MemoryPool& p, OptimizerBlk* opt, SSHORT streamNumber, bool outer, - bool inner, SortNode** sortNode) - : pool(p), alias(p), indexScratches(p), inversionCandidates(p) + bool inner, jrd_nod** sortNode) : + pool(p), alias(p), indexScratches(p), inversionCandidates(p) { /************************************** * @@ -715,8 +1023,8 @@ OptimizerRetrieval::~OptimizerRetrieval() } } -InversionNode* OptimizerRetrieval::composeInversion(InversionNode* node1, InversionNode* node2, - InversionNode::Type node_type) const +jrd_nod* OptimizerRetrieval::composeInversion(jrd_nod* node1, jrd_nod* node2, + nod_t node_type) const { /************************************** * @@ -730,32 +1038,35 @@ InversionNode* OptimizerRetrieval::composeInversion(InversionNode* node1, Invers * **************************************/ - if (!node2) + if (!node2) { return node1; + } - if (!node1) + if (!node1) { return node2; + } - if (node_type == InversionNode::TYPE_OR) + if (node_type == nod_bit_or) { - if (node1->type == InversionNode::TYPE_INDEX && - node2->type == InversionNode::TYPE_INDEX && - node1->retrieval->irb_index == node2->retrieval->irb_index) + if ((node1->nod_type == nod_index) && + (node2->nod_type == nod_index) && + (reinterpret_cast(node1->nod_arg[e_idx_retrieval])->irb_index == + reinterpret_cast(node2->nod_arg[e_idx_retrieval])->irb_index)) { - node_type = InversionNode::TYPE_IN; + node_type = nod_bit_in; } - else if (node1->type == InversionNode::TYPE_IN && - node2->type == InversionNode::TYPE_INDEX && - node1->node2->retrieval->irb_index == node2->retrieval->irb_index) + else if ((node1->nod_type == nod_bit_in) && + (node2->nod_type == nod_index) && + (reinterpret_cast(node1->nod_arg[1]->nod_arg[e_idx_retrieval])->irb_index == + reinterpret_cast(node2->nod_arg[e_idx_retrieval])->irb_index)) { - node_type = InversionNode::TYPE_IN; + node_type = nod_bit_in; } } - return FB_NEW(pool) InversionNode(node_type, node1, node2); + return OPT_make_binary_node(node_type, node1, node2, false); } - void OptimizerRetrieval::findDependentFromStreams(jrd_nod* node, SortedStreamList* streamList) const { /************************************** @@ -770,24 +1081,51 @@ void OptimizerRetrieval::findDependentFromStreams(jrd_nod* node, SortedStreamLis // Recurse thru interesting sub-nodes - if (node->nod_type == nod_class_exprnode_jrd) + if (node->nod_type == nod_procedure) + { + jrd_nod* const inputs = node->nod_arg[e_prc_inputs]; + if (inputs) + { + fb_assert(inputs->nod_type == nod_asn_list); + jrd_nod* const* ptr = inputs->nod_arg; + for (const jrd_nod* const* const end = ptr + inputs->nod_count; ptr < end; ptr++) + { + findDependentFromStreams(*ptr, streamList); + } + } + } + else if (node->nod_type == nod_union) + { + jrd_nod* const clauses = node->nod_arg[e_uni_clauses]; + jrd_nod* const* ptr = clauses->nod_arg; + for (const jrd_nod* const* const end = ptr + clauses->nod_count; ptr < end; ptr += 2) + { + findDependentFromStreams(*ptr, streamList); + } + } + else if (node->nod_type == nod_class_exprnode_jrd) { ExprNode* exprNode = reinterpret_cast(node->nod_arg[0]); - exprNode->findDependentFromStreams(this, streamList); - } - else if (node->nod_type == nod_class_recsrcnode_jrd) - { - reinterpret_cast(node->nod_arg[0])->findDependentFromStreams( - this, streamList); + + for (NestConst >* i = exprNode->jrdChildNodes.begin(); + i != exprNode->jrdChildNodes.end(); ++i) + { + findDependentFromStreams(**i, streamList); + } } else { jrd_nod* const* ptr = node->nod_arg; - for (const jrd_nod* const* const end = ptr + node->nod_count; ptr < end; ptr++) + { findDependentFromStreams(*ptr, streamList); + } } + RecordSelExpr* rse; + jrd_nod* sub; + jrd_nod* value; + switch (node->nod_type) { case nod_field: @@ -798,8 +1136,9 @@ void OptimizerRetrieval::findDependentFromStreams(jrd_nod* node, SortedStreamLis (csb->csb_rpt[fieldStream].csb_flags & csb_active) && !(csb->csb_rpt[fieldStream].csb_flags & csb_trigger)) { - if (!streamList->exist(fieldStream)) + if (!streamList->exist(fieldStream)) { streamList->add(fieldStream); + } } return; } @@ -841,26 +1180,67 @@ void OptimizerRetrieval::findDependentFromStreams(jrd_nod* node, SortedStreamLis case nod_total: case nod_count: case nod_from: - { - jrd_nod* sub; - - if (sub = node->nod_arg[e_stat_default]) + if (sub = node->nod_arg[e_stat_default]) { findDependentFromStreams(sub, streamList); - - fb_assert(node->nod_arg[e_stat_rse]->nod_type == nod_class_recsrcnode_jrd); - RseNode* rse = reinterpret_cast(node->nod_arg[e_stat_rse]->nod_arg[0]); - - rse->findDependentFromStreams(this, streamList); - - jrd_nod* value = node->nod_arg[e_stat_value]; - - // Check value expression, if any - if (value) - findDependentFromStreams(value, streamList); - + } + rse = (RecordSelExpr*) node->nod_arg[e_stat_rse]; + value = node->nod_arg[e_stat_value]; break; - } + + case nod_rse: + rse = (RecordSelExpr*) node; + value = NULL; + break; + + case nod_aggregate: + rse = (RecordSelExpr*) node->nod_arg[e_agg_rse]; + rse->rse_sorted = node->nod_arg[e_agg_group]; + value = NULL; + break; + + case nod_window: + rse = (RecordSelExpr*) node->nod_arg[e_win_rse]; + value = NULL; + break; + + default: + return; } + + // Node is a record selection expression. + if (sub = rse->rse_first) { + findDependentFromStreams(sub, streamList); + } + + if (sub = rse->rse_skip) { + findDependentFromStreams(sub, streamList); + } + + if (sub = rse->rse_boolean) { + findDependentFromStreams(sub, streamList); + } + + if (sub = rse->rse_sorted) { + findDependentFromStreams(sub, streamList); + } + + if (sub = rse->rse_projection) { + findDependentFromStreams(sub, streamList); + } + + jrd_nod* const* ptr; + const jrd_nod* const* end; + for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end; ptr++) + { + findDependentFromStreams(*ptr, streamList); + } + + // Check value expression, if any + if (value) { + findDependentFromStreams(value, streamList); + } + + return; } const string& OptimizerRetrieval::getAlias() @@ -909,15 +1289,13 @@ InversionCandidate* OptimizerRetrieval::generateInversion(IndexTableScan** rsb) // Check for any DB_KEY comparisons for (OptimizerBlk::opt_conjunct* tail = opt_begin; tail < opt_end; tail++) { - if (tail->opt_conjunct_flags & opt_conjunct_matched) + if (tail->opt_conjunct_flags & opt_conjunct_matched) { continue; - - BoolExprNode* const node = tail->opt_conjunct_node; - + } + jrd_nod* const node = tail->opt_conjunct_node; if (!(tail->opt_conjunct_flags & opt_conjunct_used) && node) { invCandidate = matchDbKey(node); - if (invCandidate) { invCandidate->boolean = node; @@ -926,17 +1304,14 @@ InversionCandidate* OptimizerRetrieval::generateInversion(IndexTableScan** rsb) } } - // First, handle "AND" comparisons (all nodes except OR) + // First, handle "AND" comparisons (all nodes except nod_or) for (OptimizerBlk::opt_conjunct* tail = opt_begin; tail < opt_end; tail++) { - if (tail->opt_conjunct_flags & opt_conjunct_matched) + if (tail->opt_conjunct_flags & opt_conjunct_matched) { continue; - - BoolExprNode* const node = tail->opt_conjunct_node; - BinaryBoolNode* booleanNode = node->as(); - - if (!(tail->opt_conjunct_flags & opt_conjunct_used) && node && - (!booleanNode || booleanNode->blrOp != blr_or)) + } + jrd_nod* const node = tail->opt_conjunct_node; + if (!(tail->opt_conjunct_flags & opt_conjunct_used) && node && (node->nod_type != nod_or)) { matchOnIndexes(&indexScratches, node, 1); } @@ -944,23 +1319,20 @@ InversionCandidate* OptimizerRetrieval::generateInversion(IndexTableScan** rsb) getInversionCandidates(&inversions, &indexScratches, 1); - if (sort && rsb) + if (sort && rsb) { *rsb = generateNavigation(); + } // Second, handle "OR" comparisons for (OptimizerBlk::opt_conjunct* tail = opt_begin; tail < opt_end; tail++) { - if (tail->opt_conjunct_flags & opt_conjunct_matched) + if (tail->opt_conjunct_flags & opt_conjunct_matched) { continue; - - BoolExprNode* const node = tail->opt_conjunct_node; - BinaryBoolNode* booleanNode = node->as(); - - if (!(tail->opt_conjunct_flags & opt_conjunct_used) && node && - (booleanNode && booleanNode->blrOp == blr_or)) + } + jrd_nod* const node = tail->opt_conjunct_node; + if (!(tail->opt_conjunct_flags & opt_conjunct_used) && node && (node->nod_type == nod_or)) { invCandidate = matchOnIndexes(&indexScratches, node, 1); - if (invCandidate) { invCandidate->boolean = node; @@ -979,7 +1351,9 @@ InversionCandidate* OptimizerRetrieval::generateInversion(IndexTableScan** rsb) // Clean up inversion list InversionCandidate** inversion = inversions.begin(); for (size_t i = 0; i < inversions.getCount(); i++) + { delete inversion[i]; + } } if (!invCandidate) @@ -1006,15 +1380,13 @@ InversionCandidate* OptimizerRetrieval::generateInversion(IndexTableScan** rsb) for (const OptimizerBlk::opt_conjunct* tail = optimizer->opt_conjuncts.begin(); tail < optimizer->opt_conjuncts.end(); tail++) { - BoolExprNode* const node = tail->opt_conjunct_node; + jrd_nod* const node = tail->opt_conjunct_node; if (!(tail->opt_conjunct_flags & opt_conjunct_used) && - node->computable(csb, stream, false, true) && + OPT_computable(csb, node, stream, false, true) && !invCandidate->matches.exist(node)) { - const ComparativeBoolNode* cmpNode = node->as(); - - const double factor = (cmpNode && cmpNode->blrOp == blr_eql) ? + const double factor = (node->nod_type == nod_eql) ? REDUCE_SELECTIVITY_FACTOR_EQUALITY : REDUCE_SELECTIVITY_FACTOR_INEQUALITY; invCandidate->selectivity *= factor; } @@ -1022,24 +1394,25 @@ InversionCandidate* OptimizerRetrieval::generateInversion(IndexTableScan** rsb) // Add the streams where this stream is depending on. for (size_t i = 0; i < invCandidate->matches.getCount(); i++) - invCandidate->matches[i]->findDependentFromStreams(this, &invCandidate->dependentFromStreams); + { + findDependentFromStreams(invCandidate->matches[i], &invCandidate->dependentFromStreams); + } if (setConjunctionsMatched) { - SortedArray matches; - + SortedArray matches; // AB: Putting a unsorted array in a sorted array directly by join isn't // very safe at the moment, but in our case Array holds a sorted list. // However SortedArray class should be updated to handle join right! - matches.join(invCandidate->matches); - for (OptimizerBlk::opt_conjunct* tail = opt_begin; tail < opt_end; tail++) { if (!(tail->opt_conjunct_flags & opt_conjunct_used)) { if (matches.exist(tail->opt_conjunct_node)) + { tail->opt_conjunct_flags |= opt_conjunct_matched; + } } } } @@ -1065,9 +1438,10 @@ IndexTableScan* OptimizerRetrieval::generateNavigation() **************************************/ fb_assert(sort); - SortNode* sortPtr = *sort; - if (!sortPtr) + jrd_nod* sortPtr = *sort; + if (!sortPtr) { return NULL; + } size_t i = 0; for (; i < indexScratches.getCount(); ++i) @@ -1080,8 +1454,9 @@ IndexTableScan* OptimizerRetrieval::generateNavigation() // sort--note that in the case where the first field is unique, this // could be optimized, since the sort will be performed correctly by // navigating on a unique index on the first field--deej - if (sortPtr->expressions.getCount() > idx->idx_count) + if (sortPtr->nod_count > idx->idx_count) { continue; + } // if the user-specified access plan for this request didn't // mention this index, forget it @@ -1095,7 +1470,7 @@ IndexTableScan* OptimizerRetrieval::generateNavigation() // an expression index if (idx->idx_flags & idx_expressn) { - if (sortPtr->expressions.getCount() != 1) + if (sortPtr->nod_count != 1) continue; } @@ -1104,17 +1479,10 @@ IndexTableScan* OptimizerRetrieval::generateNavigation() bool usableIndex = true; index_desc::idx_repeat* idx_tail = idx->idx_rpt; - NestConst* ptr = sortPtr->expressions.begin(); - const bool* descending = sortPtr->descending.begin(); - const int* nullOrder = sortPtr->nullOrder.begin(); - - for (const NestConst* const end = sortPtr->expressions.end(); - ptr != end; - ++ptr, ++descending, ++nullOrder, ++idx_tail) + jrd_nod* const* ptr = sortPtr->nod_arg; + for (const jrd_nod* const* const end = ptr + sortPtr->nod_count; ptr < end; ptr++, idx_tail++) { - jrd_nod* node = *ptr; - if (idx->idx_flags & idx_expressn) { if (!OPT_expression_equal(tdbb, csb, idx, node, stream)) @@ -1131,10 +1499,12 @@ IndexTableScan* OptimizerRetrieval::generateNavigation() break; } - if ((*descending && !(idx->idx_flags & idx_descending)) || - (!*descending && (idx->idx_flags & idx_descending)) || - ((*nullOrder == rse_nulls_first && *descending) || - (*nullOrder == rse_nulls_last && !*descending))) + if ((ptr[sortPtr->nod_count] && !(idx->idx_flags & idx_descending)) || + (!ptr[sortPtr->nod_count] && (idx->idx_flags & idx_descending)) || + ((reinterpret_cast(ptr[2 * sortPtr->nod_count]) == rse_nulls_first && + ptr[sortPtr->nod_count]) || + (reinterpret_cast(ptr[2 * sortPtr->nod_count]) == rse_nulls_last && + !ptr[sortPtr->nod_count]))) { usableIndex = false; break; @@ -1163,7 +1533,8 @@ IndexTableScan* OptimizerRetrieval::generateNavigation() // ASF: We currently can't use non-unique index for GROUP BY and DISTINCT with // multi-level and insensitive collation. In NAV, keys are verified with memcmp // but there we don't know length of each level. - if (sortPtr->unique && (tt->getFlags() & TEXTTYPE_SEPARATE_UNIQUE)) + if ((sortPtr->nod_flags & nod_unique_sort) && + (tt->getFlags() & TEXTTYPE_SEPARATE_UNIQUE)) { usableIndex = false; break; @@ -1185,7 +1556,7 @@ IndexTableScan* OptimizerRetrieval::generateNavigation() idx->idx_runtime_flags |= idx_navigate; indexScratches[i].utilized = true; - InversionNode* const index_node = makeIndexScanNode(&indexScratches[i]); + jrd_nod* const index_node = makeIndexScanNode(&indexScratches[i]); const USHORT key_length = ROUNDUP(BTR_key_length(tdbb, relation, idx), sizeof(SLONG)); return FB_NEW(*tdbb->getDefaultPool()) IndexTableScan(csb, getAlias(), stream, index_node, key_length); @@ -1245,9 +1616,8 @@ void OptimizerRetrieval::getInversionCandidates(InversionCandidateList* inversio const double cardinality = csb->csb_rpt[stream].csb_cardinality; // Walk through indexes to calculate selectivity / candidate - Array matches; + Array matches; size_t i = 0; - for (i = 0; i < fromIndexScratches->getCount(); i++) { IndexScratch& scratch = (*fromIndexScratches)[i]; @@ -1256,21 +1626,17 @@ void OptimizerRetrieval::getInversionCandidates(InversionCandidateList* inversio scratch.lowerCount = 0; scratch.upperCount = 0; scratch.nonFullMatchedSegments = MAX_INDEX_SEGMENTS + 1; - if (scratch.candidate) { matches.clear(); scratch.selectivity = MAXIMUM_SELECTIVITY; - bool unique = false; - for (int j = 0; j < scratch.idx->idx_count; j++) { IndexScratchSegment* segment = scratch.segments[j]; - - if (segment->scope == scope) + if (segment->scope == scope) { scratch.scopeCandidate = true; - + } // Check if this is the last usable segment if (((segment->scanType == segmentScanEqual) || (segment->scanType == segmentScanEquivalent) || @@ -1318,7 +1684,6 @@ void OptimizerRetrieval::getInversionCandidates(InversionCandidateList* inversio // estimate the selectivity double selectivity = scratch.selectivity; double factor = 1; - switch (segment->scanType) { case segmentScanBetween: @@ -1376,7 +1741,6 @@ void OptimizerRetrieval::getInversionCandidates(InversionCandidateList* inversio // For a non-unique one, assume 1/10 of the maximum selectivity, so that // at least some indexes could be chosen by the optimizer. double selectivity = scratch.selectivity; - if (selectivity <= 0) { if (unique && cardinality) @@ -1401,13 +1765,11 @@ void OptimizerRetrieval::getInversionCandidates(InversionCandidateList* inversio invCandidate->indexes = 1; invCandidate->scratch = &scratch; invCandidate->matches.join(matches); - for (size_t k = 0; k < invCandidate->matches.getCount(); k++) { - invCandidate->matches[k]->findDependentFromStreams(this, - &invCandidate->dependentFromStreams); + findDependentFromStreams(invCandidate->matches[k], + &invCandidate->dependentFromStreams); } - invCandidate->dependencies = (int) invCandidate->dependentFromStreams.getCount(); inversions->add(invCandidate); } @@ -1432,7 +1794,9 @@ jrd_nod* OptimizerRetrieval::findDbKey(jrd_nod* dbkey, USHORT stream, SLONG* pos if (dbkey->nod_type == nod_dbkey) { if ((USHORT)(IPTR) dbkey->nod_arg[0] == stream) + { return dbkey; + } *position = *position + 1; return NULL; @@ -1443,21 +1807,23 @@ jrd_nod* OptimizerRetrieval::findDbKey(jrd_nod* dbkey, USHORT stream, SLONG* pos if (concatNode) { jrd_nod* dbkey_temp = findDbKey(concatNode->arg1, stream, position); - if (dbkey_temp) + { return dbkey_temp; + } dbkey_temp = findDbKey(concatNode->arg2, stream, position); - if (dbkey_temp) + { return dbkey_temp; + } } return NULL; } -InversionNode* OptimizerRetrieval::makeIndexNode(const index_desc* idx) const +jrd_nod* OptimizerRetrieval::makeIndexNode(const index_desc* idx) const { /************************************** * @@ -1480,19 +1846,21 @@ InversionNode* OptimizerRetrieval::makeIndexNode(const index_desc* idx) const Resource::rsc_index, idx->idx_id); } + jrd_nod* node = PAR_make_node(tdbb, e_idx_length); + node->nod_type = nod_index; + node->nod_count = 0; + IndexRetrieval* retrieval = FB_NEW_RPT(pool, idx->idx_count * 2) IndexRetrieval(); + node->nod_arg[e_idx_retrieval] = (jrd_nod*) retrieval; retrieval->irb_index = idx->idx_id; memcpy(&retrieval->irb_desc, idx, sizeof(retrieval->irb_desc)); - - InversionNode* node = FB_NEW(pool) InversionNode(retrieval); - - if (csb) - node->impure = CMP_impure(csb, sizeof(impure_inversion)); - + if (csb) { + node->nod_impure = CMP_impure(csb, sizeof(impure_inversion)); + } return node; } -InversionNode* OptimizerRetrieval::makeIndexScanNode(IndexScratch* indexScratch) const +jrd_nod* OptimizerRetrieval::makeIndexScanNode(IndexScratch* indexScratch) const { /************************************** * @@ -1505,13 +1873,14 @@ InversionNode* OptimizerRetrieval::makeIndexScanNode(IndexScratch* indexScratch) * **************************************/ - if (!createIndexScanNodes) + if (!createIndexScanNodes) { return NULL; + } // Allocate both a index retrieval node and block. index_desc* idx = indexScratch->idx; - InversionNode* node = makeIndexNode(idx); - IndexRetrieval* retrieval = node->retrieval; + jrd_nod* node = makeIndexNode(idx); + IndexRetrieval* retrieval = (IndexRetrieval*) node->nod_arg[e_idx_retrieval]; retrieval->irb_relation = relation; // Pick up lower bound segment values @@ -1533,7 +1902,6 @@ InversionNode* OptimizerRetrieval::makeIndexScanNode(IndexScratch* indexScratch) int i = 0; bool ignoreNullsOnScan = true; IndexScratchSegment** segment = indexScratch->segments.begin(); - for (i = 0; i < MAX(indexScratch->lowerCount, indexScratch->upperCount); i++) { if (segment[i]->scanType == segmentScanMissing) @@ -1545,19 +1913,19 @@ InversionNode* OptimizerRetrieval::makeIndexScanNode(IndexScratch* indexScratch) } else { - if (i < indexScratch->lowerCount) + if (i < indexScratch->lowerCount) { *lower++ = segment[i]->lowerValue; - - if (i < indexScratch->upperCount) + } + if (i < indexScratch->upperCount) { *upper++ = segment[i]->upperValue; - - if (segment[i]->scanType == segmentScanEquivalent) + } + if (segment[i]->scanType == segmentScanEquivalent) { ignoreNullsOnScan = false; + } } } i = MAX(indexScratch->lowerCount, indexScratch->upperCount) - 1; - if (i >= 0) { if (segment[i]->scanType == segmentScanStarting) @@ -1573,11 +1941,8 @@ InversionNode* OptimizerRetrieval::makeIndexScanNode(IndexScratch* indexScratch) for (IndexScratchSegment** tail = indexScratch->segments.begin(); tail != indexScratch->segments.end() && ((*tail)->lowerValue || (*tail)->upperValue); ++tail) { - ComparativeBoolNode* cmpNode = (*tail)->matches[0]->as(); - fb_assert(cmpNode); - dsc dsc0; - CMP_get_desc(tdbb, csb, cmpNode->arg1.getObject(), &dsc0); + CMP_get_desc(tdbb, csb, (*tail)->matches[0]->nod_arg[0], &dsc0); // ASF: "dsc0.dsc_ttype() > ttype_last_internal" is to avoid recursion // when looking for charsets/collations @@ -1616,14 +1981,15 @@ InversionNode* OptimizerRetrieval::makeIndexScanNode(IndexScratch* indexScratch) // which requires NULLs to be found in the index. // A second exception is when this index is used for navigation. if (ignoreNullsOnScan && !(idx->idx_runtime_flags & idx_navigate)) + { retrieval->irb_generic |= irb_ignore_null_value_key; + } // Check to see if this is really an equality retrieval if (retrieval->irb_lower_count == retrieval->irb_upper_count) { retrieval->irb_generic |= irb_equality; segment = indexScratch->segments.begin(); - for (i = 0; i < retrieval->irb_lower_count; i++) { if (segment[i]->lowerValue != segment[i]->upperValue) @@ -1637,13 +2003,15 @@ InversionNode* OptimizerRetrieval::makeIndexScanNode(IndexScratch* indexScratch) // If we are matching less than the full index, this is a partial match if (idx->idx_flags & idx_descending) { - if (retrieval->irb_lower_count < idx->idx_count) + if (retrieval->irb_lower_count < idx->idx_count) { retrieval->irb_generic |= irb_partial; + } } else { - if (retrieval->irb_upper_count < idx->idx_count) + if (retrieval->irb_upper_count < idx->idx_count) { retrieval->irb_generic |= irb_partial; + } } // mark the index as utilized for the purposes of this compile @@ -1715,10 +2083,11 @@ InversionCandidate* OptimizerRetrieval::makeInversion(InversionCandidateList* in } // The matches returned in this inversion are always sorted. - SortedArray matches; + SortedArray matches; for (i = 0; i < inversions->getCount(); i++) { + // Initialize vars before walking through candidates InversionCandidate* bestCandidate = NULL; bool restartLoop = false; @@ -1732,14 +2101,15 @@ InversionCandidate* OptimizerRetrieval::makeInversion(InversionCandidateList* in // we can make the inversion and return it. if (currentInv->unique && currentInv->dependencies) { - if (!invCandidate) + if (!invCandidate) { invCandidate = FB_NEW(pool) InversionCandidate(pool); - - if (!currentInv->inversion && currentInv->scratch) + } + if (!currentInv->inversion && currentInv->scratch) { invCandidate->inversion = makeIndexScanNode(currentInv->scratch); - else + } + else { invCandidate->inversion = currentInv->inversion; - + } invCandidate->unique = currentInv->unique; invCandidate->selectivity = currentInv->selectivity; invCandidate->cost = currentInv->cost; @@ -1748,16 +2118,16 @@ InversionCandidate* OptimizerRetrieval::makeInversion(InversionCandidateList* in invCandidate->matchedSegments = currentInv->matchedSegments; invCandidate->dependencies = currentInv->dependencies; matches.clear(); - for (size_t j = 0; j < currentInv->matches.getCount(); j++) { - if (!matches.exist(currentInv->matches[j])) + if (!matches.exist(currentInv->matches[j])) { matches.add(currentInv->matches[j]); + } } - invCandidate->matches.join(matches); - if (acceptAll) + if (acceptAll) { continue; + } return invCandidate; } @@ -1971,14 +2341,13 @@ InversionCandidate* OptimizerRetrieval::makeInversion(InversionCandidateList* in if (!bestCandidate->inversion && bestCandidate->scratch) { invCandidate->inversion = composeInversion(invCandidate->inversion, - makeIndexScanNode(bestCandidate->scratch), InversionNode::TYPE_AND); + makeIndexScanNode(bestCandidate->scratch), nod_bit_and); } else { invCandidate->inversion = composeInversion(invCandidate->inversion, - bestCandidate->inversion, InversionNode::TYPE_AND); + bestCandidate->inversion, nod_bit_and); } - invCandidate->unique = (invCandidate->unique || bestCandidate->unique); invCandidate->selectivity = totalSelectivity; invCandidate->cost += bestCandidate->cost; @@ -1987,20 +2356,19 @@ InversionCandidate* OptimizerRetrieval::makeInversion(InversionCandidateList* in invCandidate->matchedSegments = MAX(bestCandidate->matchedSegments, invCandidate->matchedSegments); invCandidate->dependencies += bestCandidate->dependencies; - for (size_t j = 0; j < bestCandidate->matches.getCount(); j++) { - if (!matches.exist(bestCandidate->matches[j])) + if (!matches.exist(bestCandidate->matches[j])) { matches.add(bestCandidate->matches[j]); + } } - if (bestCandidate->boolean) { - if (!matches.exist(bestCandidate->boolean)) + if (!matches.exist(bestCandidate->boolean)) { matches.add(bestCandidate->boolean); + } } } - if (invCandidate->unique) { // Single unique full equal match is enough @@ -2026,8 +2394,7 @@ InversionCandidate* OptimizerRetrieval::makeInversion(InversionCandidateList* in return invCandidate; } -bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode* boolean, - USHORT scope) const +bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, jrd_nod* boolean, USHORT scope) const { /************************************** * @@ -2038,31 +2405,11 @@ bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode* * Functional description * **************************************/ - ComparativeBoolNode* cmpNode = boolean->as(); - MissingBoolNode* missingNode = boolean->as(); - NotBoolNode* notNode = boolean->as(); - RseBoolNode* rseNode = boolean->as(); bool forward = true; - jrd_nod* value = NULL; - jrd_nod* match = NULL; - if (cmpNode) - { - match = cmpNode->arg1; - value = cmpNode->arg2; - } - else if (missingNode) - match = missingNode->arg; - else if (notNode) - return false; - else if (rseNode) - match = rseNode->rse; - else - { - fb_assert(false); - } - - jrd_nod* value2 = (cmpNode && cmpNode->blrOp == blr_between) ? cmpNode->arg3 : NULL; + jrd_nod* match = boolean->nod_arg[0]; + jrd_nod* value = (boolean->nod_count < 2) ? NULL : boolean->nod_arg[1]; + jrd_nod* value2 = (boolean->nod_type == nod_between) ? boolean->nod_arg[2] : NULL; if (indexScratch->idx->idx_flags & idx_expressn) { @@ -2073,13 +2420,12 @@ bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode* if (!OPT_expression_equal(tdbb, csb, indexScratch->idx, match, stream) || (value && !OPT_computable(csb, value, stream, true, false))) { - if ((!cmpNode || cmpNode->blrOp != blr_starting) && value && + if (boolean->nod_type != nod_starts && value && OPT_expression_equal(tdbb, csb, indexScratch->idx, value, stream) && OPT_computable(csb, match, stream, true, false)) { - jrd_nod* temp = match; - match = value; - value = temp; + match = boolean->nod_arg[1]; + value = boolean->nod_arg[0]; forward = false; } else @@ -2095,17 +2441,14 @@ bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode* (USHORT)(IPTR) match->nod_arg[e_fld_stream] != stream || (value && !OPT_computable(csb, value, stream, true, false))) { - jrd_nod* temp = match; match = value; - value = temp; - + value = boolean->nod_arg[0]; if (!match || match->nod_type != nod_field || (USHORT)(IPTR) match->nod_arg[e_fld_stream] != stream || !OPT_computable(csb, value, stream, true, false)) { return false; } - forward = false; } } @@ -2158,153 +2501,156 @@ bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode* const bool isDesc = (indexScratch->idx->idx_flags & idx_descending); int count = 0; IndexScratchSegment** segment = indexScratch->segments.begin(); - for (int i = 0; i < indexScratch->idx->idx_count; i++) { + if ((indexScratch->idx->idx_flags & idx_expressn) || (USHORT)(IPTR) match->nod_arg[e_fld_id] == indexScratch->idx->idx_rpt[i].idx_field) { - if (cmpNode) + + switch (boolean->nod_type) { - switch (cmpNode->blrOp) - { - case blr_between: - if (!forward || !OPT_computable(csb, value2, stream, true, false)) - return false; - segment[i]->matches.add(boolean); - // AB: If we have already an exact match don't - // override it with worser matches. - if (!((segment[i]->scanType == segmentScanEqual) || - (segment[i]->scanType == segmentScanEquivalent))) - { - segment[i]->lowerValue = value; - segment[i]->upperValue = value2; - segment[i]->scanType = segmentScanBetween; - segment[i]->excludeLower = false; - segment[i]->excludeUpper = false; - } - break; - case blr_equiv: - segment[i]->matches.add(boolean); - // AB: If we have already an exact match don't - // override it with worser matches. - if (!(segment[i]->scanType == segmentScanEqual)) - { - segment[i]->lowerValue = segment[i]->upperValue = value; - segment[i]->scanType = segmentScanEquivalent; - segment[i]->excludeLower = false; - segment[i]->excludeUpper = false; - } - break; - - case blr_eql: - segment[i]->matches.add(boolean); - segment[i]->lowerValue = segment[i]->upperValue = value; - segment[i]->scanType = segmentScanEqual; + case nod_between: + if (!forward || !OPT_computable(csb, value2, stream, true, false)) + { + return false; + } + segment[i]->matches.add(boolean); + // AB: If we have already an exact match don't + // override it with worser matches. + if (!((segment[i]->scanType == segmentScanEqual) || + (segment[i]->scanType == segmentScanEquivalent))) + { + segment[i]->lowerValue = value; + segment[i]->upperValue = value2; + segment[i]->scanType = segmentScanBetween; segment[i]->excludeLower = false; segment[i]->excludeUpper = false; - break; + } + break; - case blr_gtr: - case blr_geq: - segment[i]->matches.add(boolean); - if (!((segment[i]->scanType == segmentScanEqual) || - (segment[i]->scanType == segmentScanEquivalent) || - (segment[i]->scanType == segmentScanBetween))) - { - if (forward != isDesc) // (forward && !isDesc || !forward && isDesc) - segment[i]->excludeLower = (cmpNode->blrOp == blr_gtr); - else - segment[i]->excludeUpper = (cmpNode->blrOp == blr_gtr); + case nod_equiv: + segment[i]->matches.add(boolean); + // AB: If we have already an exact match don't + // override it with worser matches. + if (!(segment[i]->scanType == segmentScanEqual)) + { + segment[i]->lowerValue = segment[i]->upperValue = value; + segment[i]->scanType = segmentScanEquivalent; + segment[i]->excludeLower = false; + segment[i]->excludeUpper = false; + } + break; - if (forward) - { - segment[i]->lowerValue = value; - if (segment[i]->scanType == segmentScanLess) - segment[i]->scanType = segmentScanBetween; - else - segment[i]->scanType = segmentScanGreater; - } - else - { - segment[i]->upperValue = value; - if (segment[i]->scanType == segmentScanGreater) - segment[i]->scanType = segmentScanBetween; - else - segment[i]->scanType = segmentScanLess; - } - } - break; - - case blr_lss: - case blr_leq: - segment[i]->matches.add(boolean); - if (!((segment[i]->scanType == segmentScanEqual) || - (segment[i]->scanType == segmentScanEquivalent) || - (segment[i]->scanType == segmentScanBetween))) - { - if (forward != isDesc) - segment[i]->excludeUpper = (cmpNode->blrOp == blr_lss); - else - segment[i]->excludeLower = (cmpNode->blrOp == blr_lss); - - if (forward) - { - segment[i]->upperValue = value; - if (segment[i]->scanType == segmentScanGreater) - segment[i]->scanType = segmentScanBetween; - else - segment[i]->scanType = segmentScanLess; - } - else - { - segment[i]->lowerValue = value; - if (segment[i]->scanType == segmentScanLess) - segment[i]->scanType = segmentScanBetween; - else - segment[i]->scanType = segmentScanGreater; - } - } - break; - - case blr_starting: - // Check if validate for using index - if (!forward || !validateStarts(indexScratch, cmpNode, i)) - return false; - segment[i]->matches.add(boolean); - if (!((segment[i]->scanType == segmentScanEqual) || - (segment[i]->scanType == segmentScanEquivalent))) - { - segment[i]->lowerValue = segment[i]->upperValue = value; - segment[i]->scanType = segmentScanStarting; - segment[i]->excludeLower = false; - segment[i]->excludeUpper = false; - } - break; - - default: - return false; - } - } - else if (missingNode) - { - segment[i]->matches.add(boolean); - if (!((segment[i]->scanType == segmentScanEqual) || - (segment[i]->scanType == segmentScanEquivalent))) - { + case nod_eql: + segment[i]->matches.add(boolean); segment[i]->lowerValue = segment[i]->upperValue = value; - segment[i]->scanType = segmentScanMissing; + segment[i]->scanType = segmentScanEqual; segment[i]->excludeLower = false; segment[i]->excludeUpper = false; - } + break; + + case nod_gtr: + case nod_geq: + segment[i]->matches.add(boolean); + if (!((segment[i]->scanType == segmentScanEqual) || + (segment[i]->scanType == segmentScanEquivalent) || + (segment[i]->scanType == segmentScanBetween))) + { + if (forward != isDesc) // (forward && !isDesc || !forward && isDesc) + segment[i]->excludeLower = (boolean->nod_type == nod_gtr); + else + segment[i]->excludeUpper = (boolean->nod_type == nod_gtr); + + if (forward) + { + segment[i]->lowerValue = value; + if (segment[i]->scanType == segmentScanLess) + segment[i]->scanType = segmentScanBetween; + else + segment[i]->scanType = segmentScanGreater; + } + else + { + segment[i]->upperValue = value; + if (segment[i]->scanType == segmentScanGreater) + segment[i]->scanType = segmentScanBetween; + else + segment[i]->scanType = segmentScanLess; + } + } + break; + + case nod_lss: + case nod_leq: + segment[i]->matches.add(boolean); + if (!((segment[i]->scanType == segmentScanEqual) || + (segment[i]->scanType == segmentScanEquivalent) || + (segment[i]->scanType == segmentScanBetween))) + { + if (forward != isDesc) + segment[i]->excludeUpper = (boolean->nod_type == nod_lss); + else + segment[i]->excludeLower = (boolean->nod_type == nod_lss); + + if (forward) + { + segment[i]->upperValue = value; + if (segment[i]->scanType == segmentScanGreater) + segment[i]->scanType = segmentScanBetween; + else + segment[i]->scanType = segmentScanLess; + } + else + { + segment[i]->lowerValue = value; + if (segment[i]->scanType == segmentScanLess) + segment[i]->scanType = segmentScanBetween; + else + segment[i]->scanType = segmentScanGreater; + } + } + break; + + + case nod_starts: + // Check if validate for using index + if (!forward || !validateStarts(indexScratch, boolean, i)) { + return false; + } + segment[i]->matches.add(boolean); + if (!((segment[i]->scanType == segmentScanEqual) || + (segment[i]->scanType == segmentScanEquivalent))) + { + segment[i]->lowerValue = segment[i]->upperValue = value; + segment[i]->scanType = segmentScanStarting; + segment[i]->excludeLower = false; + segment[i]->excludeUpper = false; + } + break; + + case nod_missing: + segment[i]->matches.add(boolean); + if (!((segment[i]->scanType == segmentScanEqual) || + (segment[i]->scanType == segmentScanEquivalent))) + { + segment[i]->lowerValue = segment[i]->upperValue = value; + segment[i]->scanType = segmentScanMissing; + segment[i]->excludeLower = false; + segment[i]->excludeUpper = false; + } + break; + + + default: // If no known boolean type is found return 0 + return false; } - else - return false; // A match could be made - if (segment[i]->scope < scope) + if (segment[i]->scope < scope) { segment[i]->scope = scope; + } ++count; @@ -2317,10 +2663,10 @@ bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode* } } - return count >= 1; + return (count >= 1); } -InversionCandidate* OptimizerRetrieval::matchDbKey(BoolExprNode* boolean) const +InversionCandidate* OptimizerRetrieval::matchDbKey(jrd_nod* boolean) const { /************************************** * @@ -2334,30 +2680,34 @@ InversionCandidate* OptimizerRetrieval::matchDbKey(BoolExprNode* boolean) const **************************************/ // If this isn't an equality, it isn't even interesting - ComparativeBoolNode* cmpNode = boolean->as(); - - if (!cmpNode || cmpNode->blrOp != blr_eql) + if (boolean->nod_type != nod_eql) + { return NULL; + } // Find the side of the equality that is potentially a dbkey. If // neither, make the obvious deduction - jrd_nod* dbkey = cmpNode->arg1; - jrd_nod* value = cmpNode->arg2; + jrd_nod* dbkey = boolean->nod_arg[0]; + jrd_nod* value = boolean->nod_arg[1]; if (dbkey->nod_type != nod_dbkey && !ExprNode::is(dbkey)) { if (value->nod_type != nod_dbkey && !ExprNode::is(value)) + { return NULL; + } dbkey = value; - value = cmpNode->arg1; + value = boolean->nod_arg[0]; } // If the value isn't computable, this has been a waste of time if (!OPT_computable(csb, value, stream, false, false)) + { return NULL; + } // If this is a concatenation, find an appropriate dbkey @@ -2366,13 +2716,17 @@ InversionCandidate* OptimizerRetrieval::matchDbKey(BoolExprNode* boolean) const { dbkey = findDbKey(dbkey, stream, &n); if (!dbkey) + { return NULL; + } } // Make sure we have the correct stream if ((USHORT)(IPTR) dbkey->nod_arg[0] != stream) + { return NULL; + } // If this is a dbkey for the appropriate stream, it's invertable @@ -2385,8 +2739,12 @@ InversionCandidate* OptimizerRetrieval::matchDbKey(BoolExprNode* boolean) const if (createIndexScanNodes) { - InversionNode* const inversion = FB_NEW(pool) InversionNode(value, n); - inversion->impure = CMP_impure(csb, sizeof(impure_inversion)); + jrd_nod* const inversion = PAR_make_node(tdbb, 2); + inversion->nod_count = 1; + inversion->nod_type = nod_bit_dbkey; + inversion->nod_arg[0] = value; + inversion->nod_arg[1] = (jrd_nod*)(IPTR) n; + inversion->nod_impure = CMP_impure(csb, sizeof(impure_inversion)); invCandidate->inversion = inversion; } @@ -2394,7 +2752,7 @@ InversionCandidate* OptimizerRetrieval::matchDbKey(BoolExprNode* boolean) const } InversionCandidate* OptimizerRetrieval::matchOnIndexes( - IndexScratchList* inputIndexScratches, BoolExprNode* boolean, USHORT scope) const + IndexScratchList* inputIndexScratches, jrd_nod* boolean, USHORT scope) const { /************************************** * @@ -2408,10 +2766,11 @@ InversionCandidate* OptimizerRetrieval::matchOnIndexes( * inversion candidate could be returned. * **************************************/ - BinaryBoolNode* binaryNode = boolean->as(); + DEV_BLKCHK(boolean, type_nod); + // Handle the "OR" case up front - if (binaryNode && binaryNode->blrOp == blr_or) + if (boolean->nod_type == nod_or) { InversionCandidateList inversions; inversions.shrink(0); @@ -2420,70 +2779,59 @@ InversionCandidate* OptimizerRetrieval::matchOnIndexes( IndexScratchList indexOrScratches; // Copy information from caller - size_t i = 0; - for (; i < inputIndexScratches->getCount(); i++) { IndexScratch& scratch = (*inputIndexScratches)[i]; indexOrScratches.add(scratch); } - // We use a scope variable to see on how // deep we are in a nested or conjunction. scope++; InversionCandidate* invCandidate1 = - matchOnIndexes(&indexOrScratches, binaryNode->arg1, scope); - - if (invCandidate1) + matchOnIndexes(&indexOrScratches, boolean->nod_arg[0], scope); + if (invCandidate1) { inversions.add(invCandidate1); - - BinaryBoolNode* childBoolNode = binaryNode->arg1->as(); - + } // Get usable inversions based on indexOrScratches and scope - if (!childBoolNode || childBoolNode->blrOp != blr_or) + if (boolean->nod_arg[0]->nod_type != nod_or) { getInversionCandidates(&inversions, &indexOrScratches, scope); + } invCandidate1 = makeInversion(&inversions); - if (!invCandidate1) + if (!invCandidate1) { return NULL; + } // Clear list to remove previously matched conjunctions indexOrScratches.clear(); - // Copy information from caller - i = 0; - for (; i < inputIndexScratches->getCount(); i++) { IndexScratch& scratch = (*inputIndexScratches)[i]; indexOrScratches.add(scratch); } - // Clear inversion list inversions.clear(); - InversionCandidate* invCandidate2 = matchOnIndexes( - &indexOrScratches, binaryNode->arg2, scope); - - if (invCandidate2) + InversionCandidate* invCandidate2 = + matchOnIndexes(&indexOrScratches, boolean->nod_arg[1], scope); + if (invCandidate2) { inversions.add(invCandidate2); - - childBoolNode = binaryNode->arg2->as(); - + } // Make inversion based on indexOrScratches and scope - if (!childBoolNode || childBoolNode->blrOp != blr_or) + if (boolean->nod_arg[1]->nod_type != nod_or) { getInversionCandidates(&inversions, &indexOrScratches, scope); - + } invCandidate2 = makeInversion(&inversions); if (invCandidate2) { InversionCandidate* invCandidate = FB_NEW(pool) InversionCandidate(pool); - invCandidate->inversion = composeInversion(invCandidate1->inversion, - invCandidate2->inversion, InversionNode::TYPE_OR); + invCandidate->inversion = + composeInversion(invCandidate1->inversion, invCandidate2->inversion, nod_bit_or); invCandidate->unique = (invCandidate1->unique && invCandidate2->unique); invCandidate->selectivity = invCandidate1->selectivity + invCandidate2->selectivity; invCandidate->cost = invCandidate1->cost + invCandidate2->cost; @@ -2496,43 +2844,39 @@ InversionCandidate* OptimizerRetrieval::matchOnIndexes( // Add matches conjunctions that exists in both left and right inversion if ((invCandidate1->matches.getCount()) && (invCandidate2->matches.getCount())) { - SortedArray matches; - - for (size_t j = 0; j < invCandidate1->matches.getCount(); j++) + SortedArray matches; + for (size_t j = 0; j < invCandidate1->matches.getCount(); j++) { matches.add(invCandidate1->matches[j]); - + } for (size_t j = 0; j < invCandidate2->matches.getCount(); j++) { - if (matches.exist(invCandidate2->matches[j])) + if (matches.exist(invCandidate2->matches[j])) { invCandidate->matches.add(invCandidate2->matches[j]); + } } } - return invCandidate; } - return NULL; } - if (binaryNode && binaryNode->blrOp == blr_and) + if (boolean->nod_type == nod_and) { // Recursivly call this procedure for every boolean // and finally get candidate inversions. - // Normally we come here from within a OR conjunction. + // Normally we come here from within a nod_or conjunction. InversionCandidateList inversions; inversions.shrink(0); - InversionCandidate* invCandidate = matchOnIndexes( - inputIndexScratches, binaryNode->arg1, scope); - - if (invCandidate) + InversionCandidate* invCandidate = + matchOnIndexes(inputIndexScratches, boolean->nod_arg[0], scope); + if (invCandidate) { inversions.add(invCandidate); - - invCandidate = matchOnIndexes(inputIndexScratches, binaryNode->arg2, scope); - - if (invCandidate) + } + invCandidate = matchOnIndexes(inputIndexScratches, boolean->nod_arg[1], scope); + if (invCandidate) { inversions.add(invCandidate); - + } return makeInversion(&inversions); } @@ -2540,7 +2884,6 @@ InversionCandidate* OptimizerRetrieval::matchOnIndexes( for (size_t i = 0; i < inputIndexScratches->getCount(); i++) { IndexScratch& indexScratch = (*inputIndexScratches)[i]; - // Try to match the boolean against a index. if (!(indexScratch.idx->idx_runtime_flags & idx_plan_dont_use) || (indexScratch.idx->idx_runtime_flags & idx_plan_navigate)) @@ -2548,7 +2891,6 @@ InversionCandidate* OptimizerRetrieval::matchOnIndexes( matchBoolean(&indexScratch, boolean, scope); } } - return NULL; } @@ -2637,8 +2979,8 @@ void OptimizerRetrieval::printFinalCandidate(const InversionCandidate* candidate #endif -bool OptimizerRetrieval::validateStarts(IndexScratch* indexScratch, ComparativeBoolNode* cmpNode, - USHORT segment) const +bool OptimizerRetrieval::validateStarts(IndexScratch* indexScratch, + jrd_nod* boolean, USHORT segment) const { /************************************** * @@ -2651,20 +2993,18 @@ bool OptimizerRetrieval::validateStarts(IndexScratch* indexScratch, ComparativeB * using it against the given index segment. * **************************************/ - - fb_assert(cmpNode && cmpNode->blrOp == blr_starting); - if (!cmpNode || cmpNode->blrOp != blr_starting) + if (boolean->nod_type != nod_starts) { return false; + } - jrd_nod* field = cmpNode->arg1; - jrd_nod* value = cmpNode->arg2; + jrd_nod* field = boolean->nod_arg[0]; + jrd_nod* value = boolean->nod_arg[1]; if (indexScratch->idx->idx_flags & idx_expressn) { // AB: What if the expression contains a number/float etc.. and // we use starting with against it? Is that allowed? fb_assert(indexScratch->idx->idx_expression != NULL); - if (!(OPT_expression_equal(tdbb, csb, indexScratch->idx, field, stream) || (value && !OPT_computable(csb, value, stream, true, false)))) { @@ -2675,10 +3015,11 @@ bool OptimizerRetrieval::validateStarts(IndexScratch* indexScratch, ComparativeB OPT_computable(csb, field, stream, true, false)) { field = value; - value = cmpNode->arg1; + value = boolean->nod_arg[0]; } - else + else { return false; + } } } else @@ -2694,7 +3035,7 @@ bool OptimizerRetrieval::validateStarts(IndexScratch* indexScratch, ComparativeB if (value->nod_type != nod_field) return NULL; field = value; - value = cmpNode->arg1; + value = boolean->nod_arg[0]; */ } @@ -2785,8 +3126,8 @@ bool InnerJoinStreamInfo::independent() const OptimizerInnerJoin::OptimizerInnerJoin(MemoryPool& p, OptimizerBlk* opt, const UCHAR* streams, - SortNode** sort_clause, PlanNode* plan_clause) - : pool(p), innerStreams(p) + jrd_nod** sort_clause, jrd_nod* plan_clause) : + pool(p), innerStreams(p) { /************************************** * diff --git a/src/jrd/Optimizer.h b/src/jrd/Optimizer.h index 5a71432cd9..236ecc0f8f 100644 --- a/src/jrd/Optimizer.h +++ b/src/jrd/Optimizer.h @@ -36,9 +36,10 @@ #define OPTIMIZER_DEBUG_FILE "opt_debug.out" //#endif + #include "../common/classes/alloc.h" #include "../common/classes/array.h" -#include "../jrd/RecordSourceNodes.h" + #include "../jrd/rse.h" #include "../jrd/exe.h" @@ -70,17 +71,32 @@ struct index_desc; class OptimizerBlk; class jrd_rel; class IndexTableScan; -class ComparativeBoolNode; -class InversionNode; -class PlanNode; class River; -class SortNode; bool OPT_computable(CompilerScratch*, jrd_nod*, SSHORT, const bool, const bool); bool OPT_expression_equal(thread_db*, CompilerScratch*, const index_desc*, jrd_nod*, USHORT); bool OPT_expression_equal2(thread_db*, CompilerScratch*, jrd_nod*, jrd_nod*, USHORT); double OPT_getRelationCardinality(thread_db*, jrd_rel*, const Format*); Firebird::string OPT_make_alias(thread_db*, const CompilerScratch*, const CompilerScratch::csb_repeat*); +jrd_nod* OPT_make_binary_node(nod_t, jrd_nod*, jrd_nod*, bool); + +inline int STREAM_INDEX(const jrd_nod* node) +{ + switch (node->nod_type) + { + case nod_relation: + return e_rel_stream; + case nod_procedure: + return e_prc_stream; + case nod_union: + return e_uni_stream; + case nod_aggregate: + return e_agg_stream; + default: + fb_assert(false); + return 0; // silence compiler warning. + } +} enum segmentScanType { segmentScanNone, @@ -107,7 +123,7 @@ public: int scope; // highest scope level segmentScanType scanType; // scan type - Firebird::Array matches; + Firebird::Array matches; }; class IndexScratch @@ -130,6 +146,8 @@ public: Firebird::Array segments; }; +typedef Firebird::SortedArray SortedStreamList; + class InversionCandidate { public: @@ -141,13 +159,13 @@ public: USHORT matchedSegments; int indexes; int dependencies; - BoolExprNode* boolean; - InversionNode* inversion; + jrd_nod* boolean; + jrd_nod* inversion; IndexScratch* scratch; bool used; bool unique; - Firebird::Array matches; + Firebird::Array matches; SortedStreamList dependentFromStreams; }; @@ -158,29 +176,27 @@ class OptimizerRetrieval { public: OptimizerRetrieval(MemoryPool& p, OptimizerBlk* opt, SSHORT streamNumber, - bool outer, bool inner, SortNode** sortNode); + bool outer, bool inner, jrd_nod** sortNode); ~OptimizerRetrieval(); InversionCandidate* getCost(); InversionCandidate* getInversion(IndexTableScan** rsb); - void findDependentFromStreams(jrd_nod* node, SortedStreamList* streamList) const; - protected: - InversionNode* composeInversion(InversionNode* node1, InversionNode* node2, - InversionNode::Type node_type) const; + jrd_nod* composeInversion(jrd_nod* node1, jrd_nod* node2, nod_t node_type) const; + void findDependentFromStreams(jrd_nod* node, SortedStreamList* streamList) const; const Firebird::string& getAlias(); InversionCandidate* generateInversion(IndexTableScan** rsb); IndexTableScan* generateNavigation(); void getInversionCandidates(InversionCandidateList* inversions, IndexScratchList* indexScratches, USHORT scope) const; - InversionNode* makeIndexNode(const index_desc* idx) const; - InversionNode* makeIndexScanNode(IndexScratch* indexScratch) const; + jrd_nod* makeIndexNode(const index_desc* idx) const; + jrd_nod* makeIndexScanNode(IndexScratch* indexScratch) const; InversionCandidate* makeInversion(InversionCandidateList* inversions) const; - bool matchBoolean(IndexScratch* indexScratch, BoolExprNode* boolean, USHORT scope) const; - InversionCandidate* matchDbKey(BoolExprNode* boolean) const; + bool matchBoolean(IndexScratch* indexScratch, jrd_nod* boolean, USHORT scope) const; + InversionCandidate* matchDbKey(jrd_nod* boolean) const; InversionCandidate* matchOnIndexes(IndexScratchList* indexScratches, - BoolExprNode* boolean, USHORT scope) const; + jrd_nod* boolean, USHORT scope) const; jrd_nod* findDbKey(jrd_nod*, USHORT, SLONG*) const; #ifdef OPT_DEBUG_RETRIEVAL @@ -189,14 +205,13 @@ protected: void printFinalCandidate(const InversionCandidate* candidate) const; #endif - bool validateStarts(IndexScratch* indexScratch, ComparativeBoolNode* cmpNode, - USHORT segment) const; + bool validateStarts(IndexScratch* indexScratch, jrd_nod* boolean, USHORT segment) const; private: MemoryPool& pool; thread_db* tdbb; SSHORT stream; Firebird::string alias; - SortNode** sort; + jrd_nod** sort; jrd_rel* relation; CompilerScratch* csb; Database* database; @@ -245,7 +260,7 @@ class OptimizerInnerJoin { public: OptimizerInnerJoin(MemoryPool& p, OptimizerBlk* opt, const UCHAR* streams, - SortNode** sort_clause, PlanNode* plan_clause); + jrd_nod** sort_clause, jrd_nod* plan_clause); ~OptimizerInnerJoin(); int findJoinOrder(); @@ -271,8 +286,8 @@ protected: private: MemoryPool& pool; thread_db* tdbb; - SortNode** sort; - PlanNode* plan; + jrd_nod** sort; + jrd_nod* plan; CompilerScratch* csb; Database* database; OptimizerBlk* optimizer; diff --git a/src/jrd/PluginManager.cpp b/src/jrd/PluginManager.cpp index f835d785df..d1c7b36ebb 100644 --- a/src/jrd/PluginManager.cpp +++ b/src/jrd/PluginManager.cpp @@ -26,15 +26,15 @@ #include "inf_pub.h" #include "../jrd/PluginManager.h" #include "../jrd/ErrorImpl.h" -#include "../jrd/os/path_utils.h" +#include "../common/os/path_utils.h" #include "../jrd/err_proto.h" -#include "../jrd/isc_proto.h" +#include "../common/isc_proto.h" #include "../common/classes/fb_string.h" #include "../common/classes/init.h" #include "../common/config/config.h" #include "../common/config/config_file.h" #include "../common/utils_proto.h" -#include "../config/ScanDir.h" +#include "../common/ScanDir.h" using namespace Firebird; using Firebird::uint; diff --git a/src/jrd/PluginManager.h b/src/jrd/PluginManager.h index 89f2175519..d1c472be4d 100644 --- a/src/jrd/PluginManager.h +++ b/src/jrd/PluginManager.h @@ -25,7 +25,7 @@ #include "FirebirdPluginApi.h" #include "../jrd/common.h" -#include "../jrd/os/mod_loader.h" +#include "../common/os/mod_loader.h" #include "../common/classes/array.h" #include "../common/classes/auto.h" #include "../common/classes/fb_string.h" diff --git a/src/jrd/PreparedStatement.h b/src/jrd/PreparedStatement.h index 689e9473e8..8e5b45116f 100644 --- a/src/jrd/PreparedStatement.h +++ b/src/jrd/PreparedStatement.h @@ -25,7 +25,7 @@ #include "firebird.h" #include "../jrd/common.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../jrd/intl.h" #include "../common/classes/alloc.h" #include "../common/classes/array.h" diff --git a/src/jrd/RandomGenerator.cpp b/src/jrd/RandomGenerator.cpp index 3fc54efd55..d89bc8b4bd 100644 --- a/src/jrd/RandomGenerator.cpp +++ b/src/jrd/RandomGenerator.cpp @@ -23,7 +23,7 @@ #include "firebird.h" #include "common.h" #include "../jrd/RandomGenerator.h" -#include "../jrd/os/guid.h" +#include "../common/os/guid.h" namespace Jrd { diff --git a/src/jrd/RecordSourceNodes.cpp b/src/jrd/RecordSourceNodes.cpp deleted file mode 100644 index 8db13d0bbc..0000000000 --- a/src/jrd/RecordSourceNodes.cpp +++ /dev/null @@ -1,2486 +0,0 @@ -/* - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - * Adriano dos Santos Fernandes - */ - -#include "firebird.h" -#include "../jrd/common.h" -#include "../jrd/align.h" -#include "../jrd/RecordSourceNodes.h" -#include "../jrd/DataTypeUtil.h" -#include "../jrd/Optimizer.h" -#include "../jrd/recsrc/RecordSource.h" -#include "../dsql/BoolNodes.h" -#include "../dsql/ExprNodes.h" -#include "../jrd/btr_proto.h" -#include "../jrd/cmp_proto.h" -#include "../jrd/dbg_proto.h" -#include "../jrd/dsc_proto.h" -#include "../jrd/met_proto.h" -#include "../jrd/opt_proto.h" -#include "../jrd/par_proto.h" - -using namespace Firebird; -using namespace Jrd; - - -static MapNode* parseMap(thread_db* tdbb, CompilerScratch* csb, USHORT stream); -static SSHORT strcmpSpace(const char* p, const char* q); -static void processSource(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - RecordSourceNode* source, BoolExprNode** boolean, RecordSourceNodeStack& stack); -static void processMap(thread_db* tdbb, CompilerScratch* csb, MapNode* map, Format** inputFormat); -static void genDeliverUnmapped(thread_db* tdbb, BoolExprNodeStack* deliverStack, MapNode* map, - BoolExprNodeStack* parentStack, UCHAR shellStream); -static void markIndices(CompilerScratch::csb_repeat* csbTail, SSHORT relationId); -static void sortIndicesBySelectivity(CompilerScratch::csb_repeat* csbTail); - - -//-------------------- - - -SortNode* SortNode::copy(thread_db* tdbb, NodeCopier& copier) -{ - SortNode* newSort = FB_NEW(*tdbb->getDefaultPool()) SortNode(*tdbb->getDefaultPool()); - newSort->unique = unique; - - for (NestConst* i = expressions.begin(); i != expressions.end(); ++i) - newSort->expressions.add(copier.copy(tdbb, *i)); - - newSort->descending = descending; - newSort->nullOrder = nullOrder; - - return newSort; -} - -void SortNode::pass1(thread_db* tdbb, CompilerScratch* csb) -{ - for (NestConst* i = expressions.begin(); i != expressions.end(); ++i) - *i = CMP_pass1(tdbb, csb, *i); -} - -void SortNode::pass2(thread_db* tdbb, CompilerScratch* csb) -{ - for (NestConst* i = expressions.begin(); i != expressions.end(); ++i) - (*i)->nod_flags |= nod_value; - - for (NestConst* i = expressions.begin(); i != expressions.end(); ++i) - CMP_pass2(tdbb, csb, *i, NULL); -} - -bool SortNode::computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream) -{ - for (NestConst* i = expressions.begin(); i != expressions.end(); ++i) - { - if (!OPT_computable(csb, *i, stream, idx_use, allowOnlyCurrentStream)) - return false; - } - - return true; -} - -void SortNode::findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList) -{ - for (NestConst* i = expressions.begin(); i != expressions.end(); ++i) - optRet->findDependentFromStreams(*i, streamList); -} - - -//-------------------- - - -MapNode* MapNode::copy(thread_db* tdbb, NodeCopier& copier) -{ - MapNode* newMap = FB_NEW(*tdbb->getDefaultPool()) MapNode(*tdbb->getDefaultPool()); - - for (NestConst* i = items.begin(); i != items.end(); ++i) - newMap->items.add(copier.copy(tdbb, *i)); - - return newMap; -} - -void MapNode::pass1(thread_db* tdbb, CompilerScratch* csb) -{ - for (NestConst* i = items.begin(); i != items.end(); ++i) - *i = CMP_pass1(tdbb, csb, *i); -} - -void MapNode::pass2(thread_db* tdbb, CompilerScratch* csb) -{ - for (NestConst* i = items.begin(); i != items.end(); ++i) - CMP_pass2(tdbb, csb, *i, NULL); -} - - -//-------------------- - - -// Parse a relation reference. -RelationSourceNode* RelationSourceNode::parse(thread_db* tdbb, CompilerScratch* csb, - SSHORT blrOp, bool parseContext) -{ - SET_TDBB(tdbb); - - // Make a relation reference node - - RelationSourceNode* node = FB_NEW(*tdbb->getDefaultPool()) RelationSourceNode( - *tdbb->getDefaultPool()); - - // Find relation either by id or by name - string* aliasString = NULL; - MetaName name; - - switch (blrOp) - { - case blr_rid: - case blr_rid2: - { - const SSHORT id = csb->csb_blr_reader.getWord(); - - if (blrOp == blr_rid2) - { - aliasString = FB_NEW(csb->csb_pool) string(csb->csb_pool); - PAR_name(csb, *aliasString); - } - - if (!(node->relation = MET_lookup_relation_id(tdbb, id, false))) - name.printf("id %d", id); - - break; - } - - case blr_relation: - case blr_relation2: - { - PAR_name(csb, name); - - if (blrOp == blr_relation2) - { - aliasString = FB_NEW(csb->csb_pool) string(csb->csb_pool); - PAR_name(csb, *aliasString); - } - - node->relation = MET_lookup_relation(tdbb, name); - break; - } - - default: - fb_assert(false); - } - - if (!node->relation) - PAR_error(csb, Arg::Gds(isc_relnotdef) << Arg::Str(name), false); - - // if an alias was passed, store with the relation - - if (aliasString) - node->alias = stringDup(*tdbb->getDefaultPool(), *aliasString); - - // Scan the relation if it hasn't already been scanned for meta data - - if ((!(node->relation->rel_flags & REL_scanned) || (node->relation->rel_flags & REL_being_scanned)) && - ((node->relation->rel_flags & REL_force_scan) || !(csb->csb_g_flags & csb_internal))) - { - node->relation->rel_flags &= ~REL_force_scan; - MET_scan_relation(tdbb, node->relation); - } - else if (node->relation->rel_flags & REL_sys_triggers) - MET_parse_sys_trigger(tdbb, node->relation); - - // generate a stream for the relation reference, assuming it is a real reference - - if (parseContext) - { - node->stream = PAR_context(csb, &node->context); - fb_assert(node->stream <= MAX_STREAMS); - - csb->csb_rpt[node->stream].csb_relation = node->relation; - csb->csb_rpt[node->stream].csb_alias = aliasString; - - if (csb->csb_g_flags & csb_get_dependencies) - PAR_dependency(tdbb, csb, node->stream, (SSHORT) -1, ""); - } - else - delete aliasString; - - return node; -} - -RelationSourceNode* RelationSourceNode::copy(thread_db* tdbb, NodeCopier& copier) -{ - if (!copier.remap) - BUGCHECK(221); // msg 221 (CMP) copy: cannot remap - - RelationSourceNode* newSource = FB_NEW(*tdbb->getDefaultPool()) RelationSourceNode( - *tdbb->getDefaultPool()); - - // Last entry in the remap contains the the original stream number. - // Get that stream number so that the flags can be copied - // into the newly created child stream. - - const int relativeStream = stream ? copier.remap[stream - 1] : stream; - newSource->stream = copier.csb->nextStream(); - copier.remap[stream] = (UCHAR) newSource->stream; - - newSource->context = context; - newSource->relation = relation; - newSource->view = view; - - CompilerScratch::csb_repeat* element = CMP_csb_element(copier.csb, newSource->stream); - element->csb_relation = (jrd_rel*) newSource->relation; - element->csb_view = newSource->view; - element->csb_view_stream = copier.remap[0]; - - /** If there was a parent stream no., then copy the flags - from that stream to its children streams. (Bug 10164/10166) - For e.g. - consider a view V1 with 2 streams - stream #1 from table T1 - stream #2 from table T2 - consider a procedure P1 with 2 streams - stream #1 from table X - stream #2 from view V1 - - During pass1 of procedure request, the engine tries to expand - all the views into their base tables. It creates a compiler - scratch block which initially looks like this - stream 1 -------- X - stream 2 -------- V1 - while expanding V1 the engine calls copy() with nod_relation. - A new stream 3 is created. Now the CompilerScratch looks like - stream 1 -------- X - stream 2 -------- V1 map [2,3] - stream 3 -------- T1 - After T1 stream has been created the flags are copied from - stream #1 because V1's definition said the original stream - number for T1 was 1. However since its being merged with - the procedure request, stream #1 belongs to a different table. - The flags should be copied from stream 2 i.e. V1. We can get - this info from variable remap. - - Since we didn't do this properly before, V1's children got - tagged with whatever flags X possesed leading to various - errors. - - We now store the proper stream no in relativeStream and - later use it to copy the flags. -Sudesh (03/05/99) - **/ - - copier.csb->csb_rpt[newSource->stream].csb_flags |= - copier.csb->csb_rpt[relativeStream].csb_flags & csb_no_dbkey; - - return newSource; -} - -void RelationSourceNode::ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const -{ - csb->csb_rpt[stream].csb_flags |= csb_no_dbkey; - const CompilerScratch::csb_repeat* tail = &csb->csb_rpt[stream]; - const jrd_rel* relation = tail->csb_relation; - - if (relation) - { - CMP_post_access(tdbb, csb, relation->rel_security_name, - (tail->csb_view) ? tail->csb_view->rel_id : (view ? view->rel_id : 0), - SCL_read, SCL_object_table, relation->rel_name); - } -} - -void RelationSourceNode::pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - BoolExprNode** boolean, RecordSourceNodeStack& stack) -{ - stack.push(this); // Assume that the source will be used. Push it on the final stream stack. - - // We have a view or a base table; - // prepare to check protection of relation when a field in the stream of the - // relation is accessed. - - jrd_rel* const parentView = csb->csb_view; - const USHORT viewStream = csb->csb_view_stream; - - jrd_rel* relationView = relation; - CMP_post_resource(&csb->csb_resources, relationView, Resource::rsc_relation, relationView->rel_id); - view = parentView; - - CompilerScratch::csb_repeat* const element = CMP_csb_element(csb, stream); - element->csb_view = parentView; - fb_assert(viewStream <= MAX_STREAMS); - element->csb_view_stream = (UCHAR) viewStream; - - // in the case where there is a parent view, find the context name - - if (parentView) - { - const ViewContexts& ctx = parentView->rel_view_contexts; - const USHORT key = context; - size_t pos; - - if (ctx.find(key, pos)) - { - element->csb_alias = FB_NEW(csb->csb_pool) - string(csb->csb_pool, ctx[pos]->vcx_context_name); - } - } - - // check for a view - if not, nothing more to do - - RseNode* viewRse = relationView->rel_view_rse; - if (!viewRse) - return; - - // we've got a view, expand it - - DEBUG; - stack.pop(); - UCHAR* map = CMP_alloc_map(tdbb, csb, stream); - - AutoSetRestore autoRemapVariable(&csb->csb_remap_variable, - (csb->csb_variables ? csb->csb_variables->count() : 0) + 1); - AutoSetRestore autoView(&csb->csb_view, relationView); - AutoSetRestore autoViewStream(&csb->csb_view_stream, stream); - - // We don't expand the view in two cases: - // 1) If the view has a projection, sort, first/skip or explicit plan. - // 2) If it's part of an outer join. - - if (rse->rse_jointype || // viewRse->rse_jointype || ??? - viewRse->rse_sorted || viewRse->rse_projection || viewRse->rse_first || - viewRse->rse_skip || viewRse->rse_plan) - { - NodeCopier copier(csb, map); - RseNode* copy = viewRse->copy(tdbb, copier); - DEBUG; - copy->pass1(tdbb, csb, csb->csb_view); - stack.push(copy); - DEBUG; - return; - } - - // ASF: Below we start to do things when viewRse->rse_projection is not NULL. - // But we should never come here, as the code above returns in this case. - - // if we have a projection which we can bubble up to the parent rse, set the - // parent rse to our projection temporarily to flag the fact that we have already - // seen one so that lower-level views will not try to map their projection; the - // projection will be copied and correctly mapped later, but we don't have all - // the base streams yet - - if (viewRse->rse_projection) - rse->rse_projection = viewRse->rse_projection; - - // disect view into component relations - - NestConst* arg = viewRse->rse_relations.begin(); - for (const NestConst* const end = viewRse->rse_relations.end(); arg != end; ++arg) - { - // this call not only copies the node, it adds any streams it finds to the map - NodeCopier copier(csb, map); - RecordSourceNode* node = (*arg)->copy(tdbb, copier); - - // Now go out and process the base table itself. This table might also be a view, - // in which case we will continue the process by recursion. - processSource(tdbb, csb, rse, node, boolean, stack); - } - - // When there is a projection in the view, copy the projection up to the query RseNode. - // In order to make this work properly, we must remap the stream numbers of the fields - // in the view to the stream number of the base table. Note that the map at this point - // contains the stream numbers of the referenced relations, since it was added during the call - // to copy() above. After the copy() below, the fields in the projection will reference the - // base table(s) instead of the view's context (see bug #8822), so we are ready to context- - // recognize them in CMP_pass1() - that is, replace the field nodes with actual field blocks. - - if (viewRse->rse_projection) - { - NodeCopier copier(csb, map); - rse->rse_projection = viewRse->rse_projection->copy(tdbb, copier); - rse->rse_projection->pass1(tdbb, csb); - } - - // if we encounter a boolean, copy it and retain it by ANDing it in with the - // boolean on the parent view, if any - - if (viewRse->rse_boolean) - { - NodeCopier copier(csb, map); - BoolExprNode* node = viewRse->rse_boolean->copy(tdbb, copier); - - node = node->pass1(tdbb, csb); - - if (*boolean) - { - // The order of the nodes here is important! The - // boolean from the view must appear first so that - // it gets expanded first in pass1. - - BinaryBoolNode* andNode = FB_NEW(csb->csb_pool) BinaryBoolNode(csb->csb_pool, blr_and); - andNode->arg1 = node; - andNode->arg2 = *boolean; - - *boolean = andNode; - } - else - *boolean = node; - } -} - -void RelationSourceNode::pass2Rse(thread_db* tdbb, CompilerScratch* csb) -{ - fb_assert(stream <= MAX_STREAMS); - csb->csb_rpt[stream].csb_flags |= csb_active; - - pass2(tdbb, csb); -} - -RecordSource* RelationSourceNode::compile(thread_db* tdbb, OptimizerBlk* opt, bool /*innerSubStream*/) -{ - fb_assert(stream <= MAX_UCHAR); - fb_assert(opt->beds[0] < MAX_STREAMS && opt->beds[0] < MAX_UCHAR); // debug check - //if (opt->beds[0] >= MAX_STREAMS) // all builds check - // ERR_post(Arg::Gds(isc_too_many_contexts)); - - opt->beds[++opt->beds[0]] = (UCHAR) stream; - - // we have found a base relation; record its stream - // number in the streams array as a candidate for - // merging into a river - - // TMN: Is the intention really to allow streams[0] to overflow? - // I must assume that is indeed not the intention (not to mention - // it would make code later on fail), so I added the following fb_assert. - fb_assert(opt->compileStreams[0] < MAX_STREAMS && opt->compileStreams[0] < MAX_UCHAR); - - opt->compileStreams[++opt->compileStreams[0]] = (UCHAR) stream; - - if (opt->rse->rse_jointype == blr_left) - opt->outerStreams.add(stream); - - // if we have seen any booleans or sort fields, we may be able to - // use an index to optimize them; retrieve the current format of - // all indices at this time so we can determine if it's possible - // AB: if a parentStack was available and conjunctCount was 0 - // then no indices where retrieved. Added also OR check on - // parentStack below. SF BUG # [ 508594 ] - - if (opt->conjunctCount || opt->rse->rse_sorted || opt->rse->rse_aggregate || opt->parentStack) - { - if (relation && !relation->rel_file && !relation->isVirtual()) - { - opt->opt_csb->csb_rpt[stream].csb_indices = - BTR_all(tdbb, relation, &opt->opt_csb->csb_rpt[stream].csb_idx, relation->getPages(tdbb)); - sortIndicesBySelectivity(&opt->opt_csb->csb_rpt[stream]); - markIndices(&opt->opt_csb->csb_rpt[stream], relation->rel_id); - } - else - opt->opt_csb->csb_rpt[stream].csb_indices = 0; - - const Format* format = CMP_format(tdbb, opt->opt_csb, stream); - opt->opt_csb->csb_rpt[stream].csb_cardinality = - OPT_getRelationCardinality(tdbb, relation, format); - } - - return NULL; -} - - -//-------------------- - - -// Parse an procedural view reference. -ProcedureSourceNode* ProcedureSourceNode::parse(thread_db* tdbb, CompilerScratch* csb, - SSHORT blrOp) -{ - SET_TDBB(tdbb); - - jrd_prc* procedure = NULL; - string* aliasString = NULL; - QualifiedName name; - - switch (blrOp) - { - case blr_pid: - case blr_pid2: - { - const SSHORT pid = csb->csb_blr_reader.getWord(); - - if (blrOp == blr_pid2) - { - aliasString = FB_NEW(csb->csb_pool) string(csb->csb_pool); - PAR_name(csb, *aliasString); - } - - if (!(procedure = MET_lookup_procedure_id(tdbb, pid, false, false, 0))) - name.identifier.printf("id %d", pid); - - break; - } - - case blr_procedure: - case blr_procedure2: - case blr_procedure3: - case blr_procedure4: - { - if (blrOp == blr_procedure3 || blrOp == blr_procedure4) - PAR_name(csb, name.package); - - PAR_name(csb, name.identifier); - - if (blrOp == blr_procedure2 || blrOp == blr_procedure4) - { - aliasString = FB_NEW(csb->csb_pool) string(csb->csb_pool); - PAR_name(csb, *aliasString); - } - - procedure = MET_lookup_procedure(tdbb, name, false); - - break; - } - - default: - fb_assert(false); - } - - if (!procedure) - PAR_error(csb, Arg::Gds(isc_prcnotdef) << Arg::Str(name.toString())); - - if (procedure->prc_type == prc_executable) - { - const string name = procedure->getName().toString(); - - if (tdbb->getAttachment()->att_flags & ATT_gbak_attachment) - PAR_warning(Arg::Warning(isc_illegal_prc_type) << Arg::Str(name)); - else - PAR_error(csb, Arg::Gds(isc_illegal_prc_type) << Arg::Str(name)); - } - - ProcedureSourceNode* node = FB_NEW(*tdbb->getDefaultPool()) ProcedureSourceNode( - *tdbb->getDefaultPool()); - - node->procedure = procedure->getId(); - node->stream = PAR_context(csb, &node->context); - - csb->csb_rpt[node->stream].csb_procedure = procedure; - csb->csb_rpt[node->stream].csb_alias = aliasString; - - PAR_procedure_parms(tdbb, csb, procedure, node->in_msg.getAddress(), - node->inputs.getAddress(), true); - - if (csb->csb_g_flags & csb_get_dependencies) - PAR_dependency(tdbb, csb, node->stream, (SSHORT) -1, ""); - - return node; -} - -ProcedureSourceNode* ProcedureSourceNode::copy(thread_db* tdbb, NodeCopier& copier) -{ - if (!copier.remap) - BUGCHECK(221); // msg 221 (CMP) copy: cannot remap - - ProcedureSourceNode* newSource = FB_NEW(*tdbb->getDefaultPool()) ProcedureSourceNode( - *tdbb->getDefaultPool()); - - // dimitr: See the appropriate code and comment in NodeCopier (in nod_argument). - // We must copy the message first and only then use the new pointer to - // copy the inputs properly. - newSource->in_msg = copier.copy(tdbb, in_msg); - - { // scope - AutoSetRestore autoMessage(&copier.message, newSource->in_msg); - newSource->inputs = copier.copy(tdbb, inputs); - } - - newSource->stream = copier.csb->nextStream(); - copier.remap[stream] = (UCHAR) newSource->stream; - newSource->context = context; - newSource->procedure = procedure; - newSource->view = view; - CompilerScratch::csb_repeat* element = CMP_csb_element(copier.csb, newSource->stream); - // SKIDDER: Maybe we need to check if we really found a procedure? - element->csb_procedure = MET_lookup_procedure_id(tdbb, newSource->procedure, false, false, 0); - element->csb_view = newSource->view; - element->csb_view_stream = copier.remap[0]; - - copier.csb->csb_rpt[newSource->stream].csb_flags |= copier.csb->csb_rpt[stream].csb_flags & csb_no_dbkey; - - return newSource; -} - -void ProcedureSourceNode::pass1(thread_db* tdbb, CompilerScratch* csb, jrd_rel* /*view*/) -{ - inputs = CMP_pass1(tdbb, csb, inputs); - in_msg = CMP_pass1(tdbb, csb, in_msg); -} - -void ProcedureSourceNode::pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* /*rse*/, - BoolExprNode** /*boolean*/, RecordSourceNodeStack& stack) -{ - stack.push(this); // Assume that the source will be used. Push it on the final stream stack. - - pass1(tdbb, csb, csb->csb_view); - - jrd_prc* const proc = MET_lookup_procedure_id(tdbb, procedure, false, false, 0); - CMP_post_procedure_access(tdbb, csb, proc); - CMP_post_resource(&csb->csb_resources, proc, Resource::rsc_procedure, proc->getId()); - - jrd_rel* const parentView = csb->csb_view; - const USHORT viewStream = csb->csb_view_stream; - view = parentView; - - CompilerScratch::csb_repeat* const element = CMP_csb_element(csb, stream); - element->csb_view = parentView; - fb_assert(viewStream <= MAX_STREAMS); - element->csb_view_stream = (UCHAR) viewStream; - - // in the case where there is a parent view, find the context name - - if (parentView) - { - const ViewContexts& ctx = parentView->rel_view_contexts; - const USHORT key = context; - size_t pos; - - if (ctx.find(key, pos)) - { - element->csb_alias = FB_NEW(csb->csb_pool) string( - csb->csb_pool, ctx[pos]->vcx_context_name); - } - } -} - -void ProcedureSourceNode::pass2(thread_db* tdbb, CompilerScratch* csb) -{ - CMP_pass2(tdbb, csb, inputs, NULL); - CMP_pass2(tdbb, csb, in_msg, NULL); -} - -void ProcedureSourceNode::pass2Rse(thread_db* tdbb, CompilerScratch* csb) -{ - fb_assert(stream <= MAX_STREAMS); - csb->csb_rpt[stream].csb_flags |= csb_active; - - pass2(tdbb, csb); -} - -RecordSource* ProcedureSourceNode::compile(thread_db* tdbb, OptimizerBlk* opt, bool /*innerSubStream*/) -{ - fb_assert(stream <= MAX_UCHAR); - fb_assert(opt->beds[0] < MAX_STREAMS && opt->beds[0] < MAX_UCHAR); // debug check - //if (opt->beds[0] >= MAX_STREAMS) // all builds check - // ERR_post(Arg::Gds(isc_too_many_contexts)); - - opt->beds[++opt->beds[0]] = (UCHAR) stream; - - RecordSource* rsb = generate(tdbb, opt); - fb_assert(opt->localStreams[0] < MAX_STREAMS && opt->localStreams[0] < MAX_UCHAR); - opt->localStreams[++opt->localStreams[0]] = stream; - - return rsb; -} - -// Compile and optimize a record selection expression into a set of record source blocks (rsb's). -ProcedureScan* ProcedureSourceNode::generate(thread_db* tdbb, OptimizerBlk* opt) -{ - SET_TDBB(tdbb); - - jrd_prc* const proc = MET_lookup_procedure_id(tdbb, procedure, false, false, 0); - - CompilerScratch* const csb = opt->opt_csb; - CompilerScratch::csb_repeat* const csbTail = &csb->csb_rpt[stream]; - const string alias = OPT_make_alias(tdbb, csb, csbTail); - - return FB_NEW(*tdbb->getDefaultPool()) ProcedureScan(csb, alias, stream, proc, inputs, in_msg); -} - -bool ProcedureSourceNode::computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* /*value*/) -{ - if (inputs) - { - fb_assert(inputs->nod_type == nod_asn_list); - jrd_nod* const* ptr = inputs->nod_arg; - - for (const jrd_nod* const* const end = ptr + inputs->nod_count; ptr < end; ptr++) - { - if (!OPT_computable(csb, *ptr, stream, idx_use, allowOnlyCurrentStream)) - return false; - } - } - - return true; -} - -void ProcedureSourceNode::findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList) -{ - if (inputs) - { - fb_assert(inputs->nod_type == nod_asn_list); - jrd_nod* const* ptr = inputs->nod_arg; - - for (const jrd_nod* const* const end = ptr + inputs->nod_count; ptr < end; ptr++) - optRet->findDependentFromStreams(*ptr, streamList); - } -} - - -//-------------------- - - -// Parse an aggregate reference. -AggregateSourceNode* AggregateSourceNode::parse(thread_db* tdbb, CompilerScratch* csb) -{ - SET_TDBB(tdbb); - - AggregateSourceNode* node = FB_NEW(*tdbb->getDefaultPool()) AggregateSourceNode( - *tdbb->getDefaultPool()); - - node->stream = PAR_context(csb, NULL); - fb_assert(node->stream <= MAX_STREAMS); - node->rse = RseNode::getFrom(PAR_parse_node(tdbb, csb, TYPE_RSE)); - node->group = PAR_sort(tdbb, csb, blr_group_by, true); - node->map = parseMap(tdbb, csb, node->stream); - - return node; -} - -AggregateSourceNode* AggregateSourceNode::copy(thread_db* tdbb, NodeCopier& copier) -{ - if (!copier.remap) - BUGCHECK(221); // msg 221 (CMP) copy: cannot remap - - AggregateSourceNode* newSource = FB_NEW(*tdbb->getDefaultPool()) AggregateSourceNode( - *tdbb->getDefaultPool()); - - fb_assert(stream <= MAX_STREAMS); - newSource->stream = copier.csb->nextStream(); - // fb_assert(newSource->stream <= MAX_UCHAR); - copier.remap[stream] = (UCHAR) newSource->stream; - CMP_csb_element(copier.csb, newSource->stream); - - copier.csb->csb_rpt[newSource->stream].csb_flags |= - copier.csb->csb_rpt[stream].csb_flags & csb_no_dbkey; - - newSource->rse = rse->copy(tdbb, copier); - if (group) - newSource->group = group->copy(tdbb, copier); - newSource->map = map->copy(tdbb, copier); - - return newSource; -} - -void AggregateSourceNode::ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const -{ - rse->ignoreDbKey(tdbb, csb, view); -} - -void AggregateSourceNode::pass1(thread_db* tdbb, CompilerScratch* csb, jrd_rel* view) -{ - fb_assert(stream <= MAX_STREAMS); - csb->csb_rpt[stream].csb_flags |= csb_no_dbkey; - rse->ignoreDbKey(tdbb, csb, view); - rse->pass1(tdbb, csb, csb->csb_view); - map->pass1(tdbb, csb); - if (group) - group->pass1(tdbb, csb); -} - -void AggregateSourceNode::pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* /*rse*/, - BoolExprNode** /*boolean*/, RecordSourceNodeStack& stack) -{ - stack.push(this); // Assume that the source will be used. Push it on the final stream stack. - - fb_assert(stream <= MAX_STREAMS); - pass1(tdbb, csb, csb->csb_view); -} - -void AggregateSourceNode::pass2(thread_db* tdbb, CompilerScratch* csb) -{ - rse->pass2Rse(tdbb, csb); - map->pass2(tdbb, csb); - if (group) - group->pass2(tdbb, csb); - - fb_assert(stream <= MAX_STREAMS); - - processMap(tdbb, csb, map, &csb->csb_rpt[stream].csb_internal_format); - csb->csb_rpt[stream].csb_format = csb->csb_rpt[stream].csb_internal_format; -} - -void AggregateSourceNode::pass2Rse(thread_db* tdbb, CompilerScratch* csb) -{ - fb_assert(stream <= MAX_STREAMS); - csb->csb_rpt[stream].csb_flags |= csb_active; - - pass2(tdbb, csb); -} - -bool AggregateSourceNode::containsStream(USHORT checkStream) const -{ - // for aggregates, check current RseNode, if not found then check - // the sub-rse - - if (checkStream == stream) - return true; // do not mark as variant - - if (rse->containsStream(checkStream)) - return true; // do not mark as variant - - return false; -} - -RecordSource* AggregateSourceNode::compile(thread_db* tdbb, OptimizerBlk* opt, bool /*innerSubStream*/) -{ - fb_assert(stream <= MAX_UCHAR); - fb_assert(opt->beds[0] < MAX_STREAMS && opt->beds[0] < MAX_UCHAR); // debug check - //if (opt->beds[0] >= MAX_STREAMS) // all builds check - // ERR_post(Arg::Gds(isc_too_many_contexts)); - - opt->beds[++opt->beds[0]] = (UCHAR) stream; - - BoolExprNodeStack::const_iterator stackEnd; - if (opt->parentStack) - stackEnd = opt->conjunctStack.merge(*opt->parentStack); - - RecordSource* rsb = generate(tdbb, opt, &opt->conjunctStack, stream); - - if (opt->parentStack) - opt->conjunctStack.split(stackEnd, *opt->parentStack); - - fb_assert(opt->localStreams[0] < MAX_STREAMS && opt->localStreams[0] < MAX_UCHAR); - opt->localStreams[++opt->localStreams[0]] = stream; - - return rsb; -} - -// Generate a RecordSource (Record Source Block) for each aggregate operation. -// Generate an AggregateSort (Aggregate SortedStream Block) for each DISTINCT aggregate. -RecordSource* AggregateSourceNode::generate(thread_db* tdbb, OptimizerBlk* opt, - BoolExprNodeStack* parentStack, UCHAR shellStream) -{ - SET_TDBB(tdbb); - - CompilerScratch* const csb = opt->opt_csb; - rse->rse_sorted = group; - - // AB: Try to distribute items from the HAVING CLAUSE to the WHERE CLAUSE. - // Zip thru stack of booleans looking for fields that belong to shellStream. - // Those fields are mappings. Mappings that hold a plain field may be used - // to distribute. Handle the simple cases only. - BoolExprNodeStack deliverStack; - genDeliverUnmapped(tdbb, &deliverStack, map, parentStack, shellStream); - - // try to optimize MAX and MIN to use an index; for now, optimize - // only the simplest case, although it is probably possible - // to use an index in more complex situations - NestConst* ptr; - AggNode* aggNode = NULL; - - if (map->items.getCount() == 1 && (ptr = map->items.begin()) && - (aggNode = ExprNode::as((*ptr)->nod_arg[e_asgn_from])) && - (aggNode->aggInfo.blr == blr_agg_min || aggNode->aggInfo.blr == blr_agg_max)) - { - // generate a sort block which the optimizer will try to map to an index - - SortNode* aggregate = rse->rse_aggregate = - FB_NEW(*tdbb->getDefaultPool()) SortNode(*tdbb->getDefaultPool()); - - aggregate->expressions.add(aggNode->arg); - // in the max case, flag the sort as descending - aggregate->descending.add(aggNode->aggInfo.blr == blr_agg_max); - // 10-Aug-2004. Nickolay Samofatov - Unneeded nulls seem to be skipped somehow. - aggregate->nullOrder.add(rse_nulls_default); - } - - RecordSource* const nextRsb = OPT_compile(tdbb, csb, rse, &deliverStack); - - fb_assert(stream <= MAX_STREAMS); - fb_assert(stream <= MAX_UCHAR); - - // allocate and optimize the record source block - - AggregatedStream* const rsb = FB_NEW(*tdbb->getDefaultPool()) AggregatedStream(csb, stream, - (group ? &group->expressions : NULL), map, nextRsb); - - if (rse->rse_aggregate) - { - // The rse_aggregate is still set. That means the optimizer - // was able to match the field to an index, so flag that fact - // so that it can be handled in EVL_group - aggNode->indexed = true; - } - - OPT_gen_aggregate_distincts(tdbb, csb, map); - - return rsb; -} - -bool AggregateSourceNode::computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* /*value*/) -{ - rse->rse_sorted = group; - return rse->computable(csb, stream, idx_use, allowOnlyCurrentStream, NULL); -} - -void AggregateSourceNode::findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList) -{ - rse->rse_sorted = group; - rse->findDependentFromStreams(optRet, streamList); -} - - -//-------------------- - - -// Parse a union reference. -UnionSourceNode* UnionSourceNode::parse(thread_db* tdbb, CompilerScratch* csb, SSHORT blrOp) -{ - SET_TDBB(tdbb); - - // Make the node, parse the context number, get a stream assigned, - // and get the number of sub-RseNode's. - - UnionSourceNode* node = FB_NEW(*tdbb->getDefaultPool()) UnionSourceNode( - *tdbb->getDefaultPool()); - - node->recursive = blrOp == blr_recurse; - - node->stream = PAR_context(csb, NULL); - fb_assert(node->stream <= MAX_STREAMS); - - // assign separate context for mapped record if union is recursive - USHORT stream2 = node->stream; - - if (node->recursive) - { - stream2 = PAR_context(csb, 0); - node->mapStream = stream2; - } - - int count = (unsigned int) csb->csb_blr_reader.getByte(); - - // Pick up the sub-RseNode's and maps. - - while (--count >= 0) - { - node->clauses.push(RseNode::getFrom(PAR_parse_node(tdbb, csb, TYPE_RSE))); - node->maps.push(parseMap(tdbb, csb, stream2)); - } - - return node; -} - -UnionSourceNode* UnionSourceNode::copy(thread_db* tdbb, NodeCopier& copier) -{ - if (!copier.remap) - BUGCHECK(221); // msg 221 (CMP) copy: cannot remap - - UnionSourceNode* newSource = FB_NEW(*tdbb->getDefaultPool()) UnionSourceNode( - *tdbb->getDefaultPool()); - newSource->recursive = recursive; - - fb_assert(stream <= MAX_STREAMS); - newSource->stream = copier.csb->nextStream(); - copier.remap[stream] = (UCHAR) newSource->stream; - CMP_csb_element(copier.csb, newSource->stream); - - USHORT oldStream = stream; - USHORT newStream = newSource->stream; - - if (newSource->recursive) - { - oldStream = mapStream; - fb_assert(oldStream <= MAX_STREAMS); - newStream = copier.csb->nextStream(); - newSource->mapStream = newStream; - copier.remap[oldStream] = (UCHAR) newStream; - CMP_csb_element(copier.csb, newStream); - } - - copier.csb->csb_rpt[newStream].csb_flags |= - copier.csb->csb_rpt[oldStream].csb_flags & csb_no_dbkey; - - NestConst* ptr = clauses.begin(); - NestConst* ptr2 = maps.begin(); - - for (NestConst* const end = clauses.end(); ptr != end; ++ptr, ++ptr2) - { - newSource->clauses.add((*ptr)->copy(tdbb, copier)); - newSource->maps.add((*ptr2)->copy(tdbb, copier)); - } - - return newSource; -} - -void UnionSourceNode::ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const -{ - const NestConst* ptr = clauses.begin(); - - for (const NestConst* const end = clauses.end(); ptr != end; ++ptr) - (*ptr)->ignoreDbKey(tdbb, csb, view); -} - -void UnionSourceNode::pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* /*rse*/, - BoolExprNode** /*boolean*/, RecordSourceNodeStack& stack) -{ - stack.push(this); // Assume that the source will be used. Push it on the final stream stack. - - NestConst* ptr = clauses.begin(); - NestConst* ptr2 = maps.begin(); - - for (NestConst* const end = clauses.end(); ptr != end; ++ptr, ++ptr2) - { - (*ptr)->pass1(tdbb, csb, csb->csb_view); - (*ptr2)->pass1(tdbb, csb); - } -} - -// Process a union clause of a RseNode. -void UnionSourceNode::pass2(thread_db* tdbb, CompilerScratch* csb) -{ - SET_TDBB(tdbb); - - // make up a format block sufficiently large to hold instantiated record - - const USHORT id = getStream(); - Format** format = &csb->csb_rpt[id].csb_internal_format; - - // Process RseNodes and map blocks. - - NestConst* ptr = clauses.begin(); - NestConst* ptr2 = maps.begin(); - - for (NestConst* const end = clauses.end(); ptr != end; ++ptr, ++ptr2) - { - (*ptr)->pass2Rse(tdbb, csb); - (*ptr2)->pass2(tdbb, csb); - processMap(tdbb, csb, *ptr2, format); - csb->csb_rpt[id].csb_format = *format; - } - - if (recursive) - csb->csb_rpt[mapStream].csb_format = *format; -} - -void UnionSourceNode::pass2Rse(thread_db* tdbb, CompilerScratch* csb) -{ - fb_assert(stream <= MAX_STREAMS); - csb->csb_rpt[stream].csb_flags |= csb_active; - - pass2(tdbb, csb); -} - -bool UnionSourceNode::containsStream(USHORT checkStream) const -{ - // for unions, check current RseNode, if not found then check - // all sub-rse's - - if (checkStream == stream) - return true; // do not mark as variant - - const NestConst* ptr = clauses.begin(); - - for (const NestConst* const end = clauses.end(); ptr != end; ++ptr) - { - if ((*ptr)->containsStream(checkStream)) - return true; - } - - return false; -} - -RecordSource* UnionSourceNode::compile(thread_db* tdbb, OptimizerBlk* opt, bool /*innerSubStream*/) -{ - const SSHORT i = (SSHORT) opt->keyStreams[0]; - computeDbKeyStreams(opt->keyStreams); - - BoolExprNodeStack::const_iterator stackEnd; - if (opt->parentStack) - stackEnd = opt->conjunctStack.merge(*opt->parentStack); - - RecordSource* rsb = generate(tdbb, opt, opt->keyStreams + i + 1, - (USHORT) (opt->keyStreams[0] - i), &opt->conjunctStack, stream); - - if (opt->parentStack) - opt->conjunctStack.split(stackEnd, *opt->parentStack); - - fb_assert(opt->localStreams[0] < MAX_STREAMS && opt->localStreams[0] < MAX_UCHAR); - opt->localStreams[++opt->localStreams[0]] = stream; - - return rsb; -} - -// Generate an union complex. -RecordSource* UnionSourceNode::generate(thread_db* tdbb, OptimizerBlk* opt, UCHAR* streams, - USHORT nstreams, BoolExprNodeStack* parentStack, UCHAR shellStream) -{ - SET_TDBB(tdbb); - - CompilerScratch* csb = opt->opt_csb; - HalfStaticArray rsbs; - - const SLONG baseImpure = CMP_impure(csb, 0); - - NestConst* ptr = clauses.begin(); - NestConst* ptr2 = maps.begin(); - - for (NestConst* const end = clauses.end(); ptr != end; ++ptr, ++ptr2) - { - RseNode* rse = *ptr; - MapNode* map = *ptr2; - - // AB: Try to distribute booleans from the top rse for an UNION to - // the WHERE clause of every single rse. - // hvlad: don't do it for recursive unions else they will work wrong ! - BoolExprNodeStack deliverStack; - if (!recursive) - genDeliverUnmapped(tdbb, &deliverStack, map, parentStack, shellStream); - - rsbs.add(OPT_compile(tdbb, csb, rse, &deliverStack)); - - // hvlad: activate recursive union itself after processing first (non-recursive) - // member to allow recursive members be optimized - if (recursive) - csb->csb_rpt[stream].csb_flags |= csb_active; - } - - if (recursive) - { - fb_assert(rsbs.getCount() == 2 && maps.getCount() == 2); - // hvlad: save size of inner impure area and context of mapped record - // for recursive processing later - return FB_NEW(*tdbb->getDefaultPool()) RecursiveStream(csb, stream, mapStream, - rsbs[0], rsbs[1], maps[0], maps[1], nstreams, streams, baseImpure); - } - - return FB_NEW(*tdbb->getDefaultPool()) Union(csb, stream, clauses.getCount(), rsbs.begin(), - maps.begin(), nstreams, streams); -} - -// Identify all of the streams for which a dbkey may need to be carried through a sort. -void UnionSourceNode::computeDbKeyStreams(UCHAR* streams) const -{ - const NestConst* ptr = clauses.begin(); - - for (const NestConst* const end = clauses.end(); ptr != end; ++ptr) - (*ptr)->computeDbKeyStreams(streams); -} - -bool UnionSourceNode::computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* /*value*/) -{ - NestConst* ptr = clauses.begin(); - - for (NestConst* const end = clauses.end(); ptr != end; ++ptr) - { - if (!(*ptr)->computable(csb, stream, idx_use, allowOnlyCurrentStream, NULL)) - return false; - } - - return true; -} - -void UnionSourceNode::findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList) -{ - NestConst* ptr = clauses.begin(); - - for (NestConst* const end = clauses.end(); ptr != end; ++ptr) - (*ptr)->findDependentFromStreams(optRet, streamList); -} - - -//-------------------- - - -// Parse a window reference. -WindowSourceNode* WindowSourceNode::parse(thread_db* tdbb, CompilerScratch* csb) -{ - SET_TDBB(tdbb); - - WindowSourceNode* node = FB_NEW(*tdbb->getDefaultPool()) WindowSourceNode( - *tdbb->getDefaultPool()); - - node->rse = RseNode::getFrom(PAR_parse_node(tdbb, csb, TYPE_RSE)); - - unsigned partitionCount = csb->csb_blr_reader.getByte(); - - for (unsigned i = 0; i < partitionCount; ++i) - node->parsePartitionBy(tdbb, csb); - - return node; -} - -// Parse PARTITION BY subclauses of window functions. -void WindowSourceNode::parsePartitionBy(thread_db* tdbb, CompilerScratch* csb) -{ - SET_TDBB(tdbb); - - if (csb->csb_blr_reader.getByte() != blr_partition_by) - PAR_syntax_error(csb, "blr_partition_by"); - - SSHORT context; - Partition& partition = partitions.add(); - partition.stream = PAR_context(csb, &context); - - const UCHAR count = csb->csb_blr_reader.getByte(); - - if (count != 0) - { - partition.group = PAR_sort_internal(tdbb, csb, blr_partition_by, count); - partition.regroup = PAR_sort_internal(tdbb, csb, blr_partition_by, count); - } - - partition.order = PAR_sort(tdbb, csb, blr_sort, true); - partition.map = parseMap(tdbb, csb, partition.stream); -} - -WindowSourceNode* WindowSourceNode::copy(thread_db* tdbb, NodeCopier& copier) -{ - if (!copier.remap) - BUGCHECK(221); // msg 221 (CMP) copy: cannot remap - - WindowSourceNode* newSource = FB_NEW(*tdbb->getDefaultPool()) WindowSourceNode( - *tdbb->getDefaultPool()); - - newSource->rse = rse->copy(tdbb, copier); - - for (ObjectsArray::iterator inputPartition = partitions.begin(); - inputPartition != partitions.end(); - ++inputPartition) - { - fb_assert(inputPartition->stream <= MAX_STREAMS); - - Partition& copyPartition = newSource->partitions.add(); - - copyPartition.stream = copier.csb->nextStream(); - // fb_assert(copyPartition.stream <= MAX_UCHAR); - - copier.remap[inputPartition->stream] = (UCHAR) copyPartition.stream; - CMP_csb_element(copier.csb, copyPartition.stream); - - if (inputPartition->group) - copyPartition.group = inputPartition->group->copy(tdbb, copier); - if (inputPartition->regroup) - copyPartition.regroup = inputPartition->regroup->copy(tdbb, copier); - if (inputPartition->order) - copyPartition.order = inputPartition->order->copy(tdbb, copier); - copyPartition.map = inputPartition->map->copy(tdbb, copier); - } - - return newSource; -} - -void WindowSourceNode::ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const -{ - rse->ignoreDbKey(tdbb, csb, view); -} - -void WindowSourceNode::pass1(thread_db* tdbb, CompilerScratch* csb, jrd_rel* view) -{ - for (ObjectsArray::iterator partition = partitions.begin(); - partition != partitions.end(); - ++partition) - { - fb_assert(partition->stream <= MAX_STREAMS); - csb->csb_rpt[partition->stream].csb_flags |= csb_no_dbkey; - } - - rse->ignoreDbKey(tdbb, csb, view); - rse->pass1(tdbb, csb, csb->csb_view); - - for (ObjectsArray::iterator partition = partitions.begin(); - partition != partitions.end(); - ++partition) - { - if (partition->group) - partition->group->pass1(tdbb, csb); - if (partition->regroup) - partition->regroup->pass1(tdbb, csb); - if (partition->order) - partition->order->pass1(tdbb, csb); - partition->map->pass1(tdbb, csb); - } -} - -void WindowSourceNode::pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* /*rse*/, - BoolExprNode** /*boolean*/, RecordSourceNodeStack& stack) -{ - stack.push(this); // Assume that the source will be used. Push it on the final stream stack. - - pass1(tdbb, csb, csb->csb_view); -} - -void WindowSourceNode::pass2(thread_db* tdbb, CompilerScratch* csb) -{ - rse->pass2Rse(tdbb, csb); - - for (ObjectsArray::iterator partition = partitions.begin(); - partition != partitions.end(); - ++partition) - { - partition->map->pass2(tdbb, csb); - if (partition->group) - partition->group->pass2(tdbb, csb); - if (partition->order) - partition->order->pass2(tdbb, csb); - - fb_assert(partition->stream <= MAX_STREAMS); - - processMap(tdbb, csb, partition->map, &csb->csb_rpt[partition->stream].csb_internal_format); - csb->csb_rpt[partition->stream].csb_format = - csb->csb_rpt[partition->stream].csb_internal_format; - } - - for (ObjectsArray::iterator partition = partitions.begin(); - partition != partitions.end(); - ++partition) - { - if (partition->regroup) - partition->regroup->pass2(tdbb, csb); - } -} - -void WindowSourceNode::pass2Rse(thread_db* tdbb, CompilerScratch* csb) -{ - pass2(tdbb, csb); - - for (ObjectsArray::iterator partition = partitions.begin(); - partition != partitions.end(); - ++partition) - { - csb->csb_rpt[partition->stream].csb_flags |= csb_active; - } -} - -bool WindowSourceNode::containsStream(USHORT checkStream) const -{ - for (ObjectsArray::const_iterator partition = partitions.begin(); - partition != partitions.end(); - ++partition) - { - if (checkStream == partition->stream) - return true; // do not mark as variant - } - - if (rse->containsStream(checkStream)) - return true; // do not mark as variant - - return false; -} - -RecordSource* WindowSourceNode::compile(thread_db* tdbb, OptimizerBlk* opt, bool /*innerSubStream*/) -{ - for (ObjectsArray::iterator partition = partitions.begin(); - partition != partitions.end(); - ++partition) - { - fb_assert(partition->stream <= MAX_UCHAR); - fb_assert(opt->beds[0] < MAX_STREAMS && opt->beds[0] < MAX_UCHAR); // debug check - //if (opt->beds[0] >= MAX_STREAMS) // all builds check - // ERR_post(Arg::Gds(isc_too_many_contexts)); - - opt->beds[++opt->beds[0]] = (UCHAR) partition->stream; - } - - BoolExprNodeStack deliverStack; - - RecordSource* rsb = FB_NEW(*tdbb->getDefaultPool()) WindowedStream(opt->opt_csb, partitions, - OPT_compile(tdbb, opt->opt_csb, rse, &deliverStack)); - - StreamsArray rsbStreams; - rsb->findUsedStreams(rsbStreams); - - for (StreamsArray::iterator i = rsbStreams.begin(); i != rsbStreams.end(); ++i) - { - fb_assert(opt->localStreams[0] < MAX_STREAMS && opt->localStreams[0] < MAX_UCHAR); - opt->localStreams[++opt->localStreams[0]] = *i; - } - - return rsb; -} - -bool WindowSourceNode::computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* /*value*/) -{ - return rse->computable(csb, stream, idx_use, allowOnlyCurrentStream, NULL); -} - -void WindowSourceNode::getStreams(StreamsArray& list) const -{ - for (ObjectsArray::const_iterator partition = partitions.begin(); - partition != partitions.end(); - ++partition) - { - list.add(partition->stream); - } -} - -void WindowSourceNode::findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList) -{ - rse->findDependentFromStreams(optRet, streamList); -} - - -//-------------------- - - -RseNode* RseNode::copy(thread_db* tdbb, NodeCopier& copier) -{ - RseNode* newSource = FB_NEW(*tdbb->getDefaultPool()) RseNode(*tdbb->getDefaultPool()); - - NestConst* ptr = rse_relations.begin(); - - for (NestConst* const end = rse_relations.end(); ptr != end; ++ptr) - newSource->rse_relations.add((*ptr)->copy(tdbb, copier)); - - newSource->flags = flags; - newSource->rse_jointype = rse_jointype; - newSource->rse_first = copier.copy(tdbb, rse_first); - newSource->rse_skip = copier.copy(tdbb, rse_skip); - - if (rse_boolean) - newSource->rse_boolean = rse_boolean->copy(tdbb, copier); - - if (rse_sorted) - newSource->rse_sorted = rse_sorted->copy(tdbb, copier); - - if (rse_projection) - newSource->rse_projection = rse_projection->copy(tdbb, copier); - - return newSource; -} - -// For each relation or aggregate in the RseNode, mark it as not having a dbkey. -void RseNode::ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const -{ - const NestConst* ptr = rse_relations.begin(); - - for (const NestConst* const end = rse_relations.end(); ptr != end; ++ptr) - (*ptr)->ignoreDbKey(tdbb, csb, view); -} - -// Process a record select expression during pass 1 of compilation. -// Mostly this involves expanding views. -void RseNode::pass1(thread_db* tdbb, CompilerScratch* csb, jrd_rel* /*view*/) -{ - SET_TDBB(tdbb); - - // for scoping purposes, maintain a stack of RseNode's which are - // currently being parsed; if there are none on the stack as - // yet, mark the RseNode as variant to make sure that statement- - // level aggregates are not treated as invariants -- bug #6535 - - bool topLevelRse = true; - - for (LegacyNodeOrRseNode* node = csb->csb_current_nodes.begin(); - node != csb->csb_current_nodes.end(); ++node) - { - if (node->rseNode) - { - topLevelRse = false; - break; - } - } - - if (topLevelRse) - flags |= FLAG_VARIANT; - - csb->csb_current_nodes.push(this); - - RecordSourceNodeStack stack; - BoolExprNode* boolean = NULL; - SortNode* sort = rse_sorted; - SortNode* project = rse_projection; - jrd_nod* first = rse_first; - jrd_nod* skip = rse_skip; - PlanNode* plan = rse_plan; - - // zip thru RseNode expanding views and inner joins - NestConst* arg = rse_relations.begin(); - for (const NestConst* const end = rse_relations.end(); arg != end; ++arg) - processSource(tdbb, csb, this, *arg, &boolean, stack); - - // Now, rebuild the RseNode block. - - rse_relations.resize(stack.getCount()); - arg = rse_relations.end(); - - while (stack.hasData()) - *--arg = stack.pop(); - - AutoSetRestore autoValidateExpr(&csb->csb_validate_expr, false); - - // finish of by processing other clauses - - if (first) - rse_first = CMP_pass1(tdbb, csb, first); - - if (skip) - rse_skip = CMP_pass1(tdbb, csb, skip); - - if (boolean) - { - if (rse_boolean) - { - BinaryBoolNode* andNode = FB_NEW(csb->csb_pool) BinaryBoolNode(csb->csb_pool, blr_and); - andNode->arg1 = boolean; - andNode->arg2 = rse_boolean->pass1(tdbb, csb); - - rse_boolean = andNode; - } - else - rse_boolean = boolean; - } - else if (rse_boolean) - rse_boolean = rse_boolean->pass1(tdbb, csb); - - if (sort) - { - sort->pass1(tdbb, csb); - rse_sorted = sort; - } - - if (project) - { - project->pass1(tdbb, csb); - rse_projection = project; - } - - if (plan) - rse_plan = plan; - - // we are no longer in the scope of this RseNode - csb->csb_current_nodes.pop(); -} - -void RseNode::pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - BoolExprNode** boolean, RecordSourceNodeStack& stack) -{ - // in the case of an RseNode, it is possible that a new RseNode will be generated, - // so wait to process the source before we push it on the stack (bug 8039) - - // The addition of the JOIN syntax for specifying inner joins causes an - // RseNode tree to be generated, which is undesirable in the simplest case - // where we are just trying to inner join more than 2 streams. If possible, - // try to flatten the tree out before we go any further. - - if (!rse->rse_jointype && !rse_jointype && !rse_sorted && !rse_projection && - !rse_first && !rse_skip && !rse_plan) - { - NestConst* arg = rse_relations.begin(); - for (const NestConst* const end = rse_relations.end(); arg != end; ++arg) - processSource(tdbb, csb, rse, *arg, boolean, stack); - - // fold in the boolean for this inner join with the one for the parent - - if (rse_boolean) - { - BoolExprNode* node = rse_boolean->pass1(tdbb, csb); - - if (*boolean) - { - BinaryBoolNode* andNode = FB_NEW(csb->csb_pool) BinaryBoolNode( - csb->csb_pool, blr_and); - andNode->arg1 = node; - andNode->arg2 = *boolean; - - *boolean = andNode; - } - else - *boolean = node; - } - - return; - } - - pass1(tdbb, csb, csb->csb_view); - stack.push(this); -} - -// Perform the first half of record selection expression compilation. -// The actual optimization is done in "post_rse". -void RseNode::pass2Rse(thread_db* tdbb, CompilerScratch* csb) -{ - SET_TDBB(tdbb); - - // Maintain stack of RSEe for scoping purposes - csb->csb_current_nodes.push(this); - - if (rse_first) - CMP_pass2(tdbb, csb, rse_first, NULL); - - if (rse_skip) - CMP_pass2(tdbb, csb, rse_skip, NULL); - - NestConst* ptr = rse_relations.begin(); - - for (const NestConst* const end = rse_relations.end(); ptr != end; ++ptr) - (*ptr)->pass2Rse(tdbb, csb); - - if (rse_boolean) - rse_boolean->pass2(tdbb, csb); - - if (rse_sorted) - rse_sorted->pass2(tdbb, csb); - - if (rse_projection) - rse_projection->pass2(tdbb, csb); - - // If the user has submitted a plan for this RseNode, check it for correctness. - - if (rse_plan) - { - planSet(csb, rse_plan); - planCheck(csb); - } - - csb->csb_current_nodes.pop(); -} - -// Return true if stream is contained in the specified RseNode. -bool RseNode::containsStream(USHORT checkStream) const -{ - // Look through all relation nodes in this RseNode to see - // if the field references this instance of the relation. - - const NestConst* ptr = rse_relations.begin(); - - for (const NestConst* const end = rse_relations.end(); ptr != end; ++ptr) - { - const RecordSourceNode* sub = *ptr; - - if (sub->containsStream(checkStream)) - return true; // do not mark as variant - } - - return false; -} - -RecordSource* RseNode::compile(thread_db* tdbb, OptimizerBlk* opt, bool innerSubStream) -{ - // for nodes which are not relations, generate an rsb to - // represent that work has to be done to retrieve them; - // find all the substreams involved and compile them as well - - computeRseStreams(opt->opt_csb, opt->beds); - computeRseStreams(opt->opt_csb, opt->localStreams); - computeDbKeyStreams(opt->keyStreams); - - RecordSource* rsb; - - // pass RseNode boolean only to inner substreams because join condition - // should never exclude records from outer substreams - if (opt->rse->rse_jointype == blr_inner || (opt->rse->rse_jointype == blr_left && innerSubStream)) - { - // AB: For an (X LEFT JOIN Y) mark the outer-streams (X) as - // active because the inner-streams (Y) are always "dependent" - // on the outer-streams. So that index retrieval nodes could be made. - // For an INNER JOIN mark previous generated RecordSource's as active. - if (opt->rse->rse_jointype == blr_left) - { - for (StreamsArray::iterator i = opt->outerStreams.begin(); i != opt->outerStreams.end(); ++i) - opt->opt_csb->csb_rpt[*i].csb_flags |= csb_active; - } - - //const BoolExprNodeStack::iterator stackSavepoint(opt->conjunctStack); - BoolExprNodeStack::const_iterator stackEnd; - BoolExprNodeStack deliverStack; - - if (opt->rse->rse_jointype != blr_inner) - { - // Make list of nodes that can be delivered to an outer-stream. - // In fact these are all nodes except when a IS NULL comparison is done. - // Note! Don't forget that this can be burried inside a expression - // such as "CASE WHEN (FieldX IS NULL) THEN 0 ELSE 1 END = 0" - BoolExprNodeStack::iterator stackItem; - if (opt->parentStack) - stackItem = *opt->parentStack; - - for (; stackItem.hasData(); ++stackItem) - { - BoolExprNode* deliverNode = stackItem.object(); - PossibleUnknownFinder finder; - - if (!deliverNode->jrdPossibleUnknownFinder(finder)) - deliverStack.push(deliverNode); - } - - stackEnd = opt->conjunctStack.merge(deliverStack); - } - else - { - if (opt->parentStack) - stackEnd = opt->conjunctStack.merge(*opt->parentStack); - } - - rsb = OPT_compile(tdbb, opt->opt_csb, this, &opt->conjunctStack); - - if (opt->rse->rse_jointype != blr_inner) - { - // Remove previously added parent conjuctions from the stack. - opt->conjunctStack.split(stackEnd, deliverStack); - } - else - { - if (opt->parentStack) - opt->conjunctStack.split(stackEnd, *opt->parentStack); - } - - if (opt->rse->rse_jointype == blr_left) - { - for (StreamsArray::iterator i = opt->outerStreams.begin(); i != opt->outerStreams.end(); ++i) - opt->opt_csb->csb_rpt[*i].csb_flags &= ~csb_active; - } - } - else - rsb = OPT_compile(tdbb, opt->opt_csb, this, opt->parentStack); - - return rsb; -} - -// Identify the streams that make up a RseNode. -void RseNode::computeRseStreams(const CompilerScratch* csb, UCHAR* streams) const -{ - const NestConst* ptr = rse_relations.begin(); - - for (const NestConst* const end = rse_relations.end(); ptr != end; ++ptr) - { - const RecordSourceNode* node = *ptr; - - if (node->type == RseNode::TYPE) - static_cast(node)->computeRseStreams(csb, streams); - else - { - StreamsArray sourceStreams; - node->getStreams(sourceStreams); - - for (StreamsArray::iterator i = sourceStreams.begin(); i != sourceStreams.end(); ++i) - { - fb_assert(streams[0] < MAX_STREAMS && streams[0] < MAX_UCHAR); - streams[++streams[0]] = (UCHAR) *i; - } - } - } -} - -// Check that all streams in the RseNode have a plan specified for them. -// If they are not, there are streams in the RseNode which were not mentioned in the plan. -void RseNode::planCheck(const CompilerScratch* csb) const -{ - // if any streams are not marked with a plan, give an error - - const NestConst* ptr = rse_relations.begin(); - for (const NestConst* const end = rse_relations.end(); ptr != end; ++ptr) - { - const RecordSourceNode* node = *ptr; - - if (node->type == RelationSourceNode::TYPE) - { - const USHORT stream = node->getStream(); - - if (!(csb->csb_rpt[stream].csb_plan)) - { - ERR_post(Arg::Gds(isc_no_stream_plan) << - Arg::Str(csb->csb_rpt[stream].csb_relation->rel_name)); - } - } - else if (node->type == RseNode::TYPE) - static_cast(node)->planCheck(csb); - } -} - -// Go through the streams in the plan, find the corresponding streams in the RseNode and store the -// plan for that stream. Do it once and only once to make sure there is a one-to-one correspondence -// between streams in the query and streams in the plan. -void RseNode::planSet(CompilerScratch* csb, PlanNode* plan) -{ - if (plan->type == PlanNode::TYPE_JOIN) - { - for (NestConst* ptr = plan->subNodes.begin(), *end = plan->subNodes.end(); - ptr != end; - ++ptr) - { - planSet(csb, *ptr); - } - } - - if (plan->type != PlanNode::TYPE_RETRIEVE) - return; - - const jrd_rel* viewRelation = NULL; - const jrd_rel* planRelation = plan->relationNode->relation; - const char* planAlias = plan->relationNode->alias; - - // find the tail for the relation specified in the RseNode - - const USHORT stream = plan->relationNode->getStream(); - CompilerScratch::csb_repeat* tail = &csb->csb_rpt[stream]; - - // if the plan references a view, find the real base relation - // we are interested in by searching the view map - UCHAR* map = NULL; - - if (tail->csb_map) - { - const TEXT* p = planAlias; - - // if the user has specified an alias, skip past it to find the alias - // for the base table (if multiple aliases are specified) - if (p && *p && - ((tail->csb_relation && !strcmpSpace(tail->csb_relation->rel_name.c_str(), p)) || - (tail->csb_alias && !strcmpSpace(tail->csb_alias->c_str(), p)))) - { - while (*p && *p != ' ') - p++; - - if (*p == ' ') - p++; - } - - // loop through potentially a stack of views to find the appropriate base table - UCHAR* mapBase; - - while ( (mapBase = tail->csb_map) ) - { - map = mapBase; - tail = &csb->csb_rpt[*map]; - viewRelation = tail->csb_relation; - - // if the plan references the view itself, make sure that - // the view is on a single table; if it is, fix up the plan - // to point to the base relation - - if (viewRelation->rel_id == planRelation->rel_id) - { - if (!mapBase[2]) - { - map++; - tail = &csb->csb_rpt[*map]; - } - else - { - // view %s has more than one base relation; use aliases to distinguish - ERR_post(Arg::Gds(isc_view_alias) << Arg::Str(planRelation->rel_name)); - } - - break; - } - - viewRelation = NULL; - - // if the user didn't specify an alias (or didn't specify one - // for this level), check to make sure there is one and only one - // base relation in the table which matches the plan relation - - if (!*p) - { - const jrd_rel* duplicateRelation = NULL; - UCHAR* duplicateMap = mapBase; - - map = NULL; - - for (duplicateMap++; *duplicateMap; ++duplicateMap) - { - CompilerScratch::csb_repeat* duplicateTail = &csb->csb_rpt[*duplicateMap]; - const jrd_rel* relation = duplicateTail->csb_relation; - - if (relation && relation->rel_id == planRelation->rel_id) - { - if (duplicateRelation) - { - // table %s is referenced twice in view; use an alias to distinguish - ERR_post(Arg::Gds(isc_duplicate_base_table) << - Arg::Str(duplicateRelation->rel_name)); - } - else - { - duplicateRelation = relation; - map = duplicateMap; - tail = duplicateTail; - } - } - } - - break; - } - - // look through all the base relations for a match - - map = mapBase; - for (map++; *map; map++) - { - tail = &csb->csb_rpt[*map]; - const jrd_rel* relation = tail->csb_relation; - - // match the user-supplied alias with the alias supplied - // with the view definition; failing that, try the base - // table name itself - - // CVC: I found that "relation" can be NULL, too. This may be an - // indication of a logic flaw while parsing the user supplied SQL plan - // and not an oversight here. It's hard to imagine a csb->csb_rpt with - // a NULL relation. See exe.h for CompilerScratch struct and its inner csb_repeat struct. - - if ((tail->csb_alias && !strcmpSpace(tail->csb_alias->c_str(), p)) || - (relation && !strcmpSpace(relation->rel_name.c_str(), p))) - { - break; - } - } - - // skip past the alias - - while (*p && *p != ' ') - p++; - - if (*p == ' ') - p++; - - if (!*map) - { - // table %s is referenced in the plan but not the from list - ERR_post(Arg::Gds(isc_stream_not_found) << Arg::Str(planRelation->rel_name)); - } - } - - // fix up the relation node to point to the base relation's stream - - if (!map || !*map) - { - // table %s is referenced in the plan but not the from list - ERR_post(Arg::Gds(isc_stream_not_found) << Arg::Str(planRelation->rel_name)); - } - - plan->relationNode->setStream(*map); - } - - // make some validity checks - - if (!tail->csb_relation) - { - // table %s is referenced in the plan but not the from list - ERR_post(Arg::Gds(isc_stream_not_found) << Arg::Str(planRelation->rel_name)); - } - - if ((tail->csb_relation->rel_id != planRelation->rel_id) && !viewRelation) - { - // table %s is referenced in the plan but not the from list - ERR_post(Arg::Gds(isc_stream_not_found) << Arg::Str(planRelation->rel_name)); - } - - // check if we already have a plan for this stream - - if (tail->csb_plan) - { - // table %s is referenced more than once in plan; use aliases to distinguish - ERR_post(Arg::Gds(isc_stream_twice) << Arg::Str(tail->csb_relation->rel_name)); - } - - tail->csb_plan = plan; -} - -// Identify all of the streams for which a dbkey may need to be carried through a sort. -void RseNode::computeDbKeyStreams(UCHAR* streams) const -{ - const NestConst* ptr = rse_relations.begin(); - - for (const NestConst* const end = rse_relations.end(); ptr != end; ++ptr) - (*ptr)->computeDbKeyStreams(streams); -} - -bool RseNode::computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* value) -{ - if (rse_first && !OPT_computable(csb, rse_first, stream, idx_use, allowOnlyCurrentStream)) - return false; - - if (rse_skip && !OPT_computable(csb, rse_skip, stream, idx_use, allowOnlyCurrentStream)) - return false; - - const NestConst* const end = rse_relations.end(); - NestConst* ptr; - - // Set sub-streams of rse active - - for (ptr = rse_relations.begin(); ptr != end; ++ptr) - { - const RecordSourceNode* const node = *ptr; - - StreamsArray streams; - node->getStreams(streams); - - for (StreamsArray::iterator i = streams.begin(); i != streams.end(); ++i) - csb->csb_rpt[*i].csb_flags |= (csb_active | csb_sub_stream); - } - - bool result = true; - - // Check sub-stream - if ((rse_boolean && !rse_boolean->computable(csb, stream, idx_use, allowOnlyCurrentStream)) || - (rse_sorted && !rse_sorted->computable(csb, stream, idx_use, allowOnlyCurrentStream)) || - (rse_projection && !rse_projection->computable(csb, stream, idx_use, allowOnlyCurrentStream))) - { - result = false; - } - - for (ptr = rse_relations.begin(); ptr != end && result; ++ptr) - { - if (!(*ptr)->computable(csb, stream, idx_use, allowOnlyCurrentStream, NULL)) - result = false; - } - - // Check value expression, if any - if (result && value && !OPT_computable(csb, value, stream, idx_use, allowOnlyCurrentStream)) - result = false; - - // Reset streams inactive - - for (ptr = rse_relations.begin(); ptr != end; ++ptr) - { - const RecordSourceNode* const node = *ptr; - - StreamsArray streams; - node->getStreams(streams); - - for (StreamsArray::iterator i = streams.begin(); i != streams.end(); ++i) - csb->csb_rpt[*i].csb_flags &= ~(csb_active | csb_sub_stream); - } - - return result; -} - -void RseNode::findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList) -{ - if (rse_first) - optRet->findDependentFromStreams(rse_first, streamList); - - if (rse_skip) - optRet->findDependentFromStreams(rse_skip, streamList); - - if (rse_boolean) - rse_boolean->findDependentFromStreams(optRet, streamList); - - if (rse_sorted) - rse_sorted->findDependentFromStreams(optRet, streamList); - - if (rse_projection) - rse_projection->findDependentFromStreams(optRet, streamList); - - NestConst* ptr; - const NestConst* end; - - for (ptr = rse_relations.begin(), end = rse_relations.end(); ptr != end; ++ptr) - (*ptr)->findDependentFromStreams(optRet, streamList); -} - - -//-------------------- - - -// Parse a MAP clause for a union or global aggregate expression. -static MapNode* parseMap(thread_db* tdbb, CompilerScratch* csb, USHORT stream) -{ - SET_TDBB(tdbb); - - if (csb->csb_blr_reader.getByte() != blr_map) - PAR_syntax_error(csb, "blr_map"); - - int count = csb->csb_blr_reader.getWord(); - MapNode* node = FB_NEW(csb->csb_pool) MapNode(csb->csb_pool); - - while (count-- > 0) - { - jrd_nod* assignment = PAR_make_node(tdbb, e_asgn_length); - assignment->nod_type = nod_assignment; - assignment->nod_count = e_asgn_length; - assignment->nod_arg[e_asgn_to] = PAR_gen_field(tdbb, stream, csb->csb_blr_reader.getWord()); - assignment->nod_arg[e_asgn_from] = PAR_parse_node(tdbb, csb, VALUE); - node->items.add(assignment); - } - - return node; -} - -// Compare two strings, which could be either space-terminated or null-terminated. -static SSHORT strcmpSpace(const char* p, const char* q) -{ - for (; *p && *p != ' ' && *q && *q != ' '; p++, q++) - { - if (*p != *q) - break; - } - - if ((!*p || *p == ' ') && (!*q || *q == ' ')) - return 0; - - return (*p > *q) ? 1 : -1; -} - -// Process a single record source stream from an RseNode. -// Obviously, if the source is a view, there is more work to do. -static void processSource(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - RecordSourceNode* source, BoolExprNode** boolean, RecordSourceNodeStack& stack) -{ - SET_TDBB(tdbb); - - Database* dbb = tdbb->getDatabase(); - CHECK_DBB(dbb); - - AutoSetRestore autoValidateExpr(&csb->csb_validate_expr, false); - - source->pass1Source(tdbb, csb, rse, boolean, stack); -} - -// Translate a map block into a format. If the format is missing or incomplete, extend it. -static void processMap(thread_db* tdbb, CompilerScratch* csb, MapNode* map, Format** inputFormat) -{ - SET_TDBB(tdbb); - - Format* format = *inputFormat; - if (!format) - format = *inputFormat = Format::newFormat(*tdbb->getDefaultPool(), map->items.getCount()); - - // process alternating rse and map blocks - dsc desc2; - NestConst* ptr = map->items.begin(); - - for (const NestConst* const end = map->items.end(); ptr != end; ++ptr) - { - jrd_nod* assignment = *ptr; - jrd_nod* field = assignment->nod_arg[e_asgn_to]; - const USHORT id = (USHORT)(IPTR) field->nod_arg[e_fld_id]; - - if (id >= format->fmt_count) - format->fmt_desc.resize(id + 1); - - dsc* desc = &format->fmt_desc[id]; - CMP_get_desc(tdbb, csb, assignment->nod_arg[e_asgn_from], &desc2); - const USHORT min = MIN(desc->dsc_dtype, desc2.dsc_dtype); - const USHORT max = MAX(desc->dsc_dtype, desc2.dsc_dtype); - - if (!min) - { - // eg: dtype_unknown - *desc = desc2; - } - else if (max == dtype_blob) - { - desc->dsc_dtype = dtype_blob; - desc->dsc_length = sizeof(ISC_QUAD); - desc->dsc_scale = 0; - desc->dsc_sub_type = DataTypeUtil::getResultBlobSubType(desc, &desc2); - desc->dsc_flags = 0; - } - else if (min <= dtype_any_text) - { - // either field a text field? - const USHORT len1 = DSC_string_length(desc); - const USHORT len2 = DSC_string_length(&desc2); - desc->dsc_dtype = dtype_varying; - desc->dsc_length = MAX(len1, len2) + sizeof(USHORT); - - // pick the max text type, so any transparent casts from ints are - // not left in ASCII format, but converted to the richer text format - - desc->setTextType(MAX(INTL_TEXT_TYPE(*desc), INTL_TEXT_TYPE(desc2))); - desc->dsc_scale = 0; - desc->dsc_flags = 0; - } - else if (DTYPE_IS_DATE(max) && !DTYPE_IS_DATE(min)) - { - desc->dsc_dtype = dtype_varying; - desc->dsc_length = DSC_convert_to_text_length(max) + sizeof(USHORT); - desc->dsc_ttype() = ttype_ascii; - desc->dsc_scale = 0; - desc->dsc_flags = 0; - } - else if (max != min) - { - // different numeric types: if one is inexact use double, - // if both are exact use int64 - if ((!DTYPE_IS_EXACT(max)) || (!DTYPE_IS_EXACT(min))) - { - desc->dsc_dtype = DEFAULT_DOUBLE; - desc->dsc_length = sizeof(double); - desc->dsc_scale = 0; - desc->dsc_sub_type = 0; - desc->dsc_flags = 0; - } - else - { - desc->dsc_dtype = dtype_int64; - desc->dsc_length = sizeof(SINT64); - desc->dsc_scale = MIN(desc->dsc_scale, desc2.dsc_scale); - desc->dsc_sub_type = MAX(desc->dsc_sub_type, desc2.dsc_sub_type); - desc->dsc_flags = 0; - } - } - } - - // flesh out the format of the record - - ULONG offset = FLAG_BYTES(format->fmt_count); - - Format::fmt_desc_iterator desc3 = format->fmt_desc.begin(); - for (const Format::fmt_desc_const_iterator end_desc = format->fmt_desc.end(); - desc3 < end_desc; ++desc3) - { - const USHORT align = type_alignments[desc3->dsc_dtype]; - - if (align) - offset = FB_ALIGN(offset, align); - - desc3->dsc_address = (UCHAR *) (IPTR) offset; - offset += desc3->dsc_length; - } - - if (offset > MAX_FORMAT_SIZE) - ERR_post(Arg::Gds(isc_imp_exc) << Arg::Gds(isc_blktoobig)); - - format->fmt_length = (USHORT) offset; - format->fmt_count = format->fmt_desc.getCount(); -} - -// Make new boolean nodes from nodes that contain a field from the given shellStream. -// Those fields are references (mappings) to other nodes and are used by aggregates and union rse's. -static void genDeliverUnmapped(thread_db* tdbb, BoolExprNodeStack* deliverStack, MapNode* map, - BoolExprNodeStack* parentStack, UCHAR shellStream) -{ - SET_TDBB(tdbb); - - for (BoolExprNodeStack::iterator stack1(*parentStack); stack1.hasData(); ++stack1) - { - BoolExprNode* boolean = stack1.object(); - - // Reduce to simple comparisons - - ComparativeBoolNode* cmpNode = boolean->as(); - MissingBoolNode* missingNode = boolean->as(); - HalfStaticArray children; - - if (cmpNode && - (cmpNode->blrOp == blr_eql || cmpNode->blrOp == blr_gtr || cmpNode->blrOp == blr_geq || - cmpNode->blrOp == blr_leq || cmpNode->blrOp == blr_lss || cmpNode->blrOp == blr_starting)) - { - children.add(cmpNode->arg1); - children.add(cmpNode->arg2); - } - else if (missingNode) - children.add(missingNode->arg); - else - continue; - - // At least 1 mapping should be used in the arguments - size_t indexArg; - bool mappingFound = false; - - for (indexArg = 0; (indexArg < children.getCount()) && !mappingFound; ++indexArg) - { - jrd_nod* node = children[indexArg]; - - if (node->nod_type == nod_field && - (USHORT)(IPTR) node->nod_arg[e_fld_stream] == shellStream) - { - mappingFound = true; - } - } - - if (!mappingFound) - continue; - - // Create new node and assign the correct existing arguments - - BoolExprNode* deliverNode = NULL; - HalfStaticArray newChildren; - - if (cmpNode) - { - ComparativeBoolNode* newCmpNode = FB_NEW(*tdbb->getDefaultPool()) ComparativeBoolNode( - *tdbb->getDefaultPool(), cmpNode->blrOp); - - newChildren.add(newCmpNode->arg1.getAddress()); - newChildren.add(newCmpNode->arg2.getAddress()); - - deliverNode = newCmpNode; - } - else if (missingNode) - { - MissingBoolNode* newMissingNode = FB_NEW(*tdbb->getDefaultPool()) MissingBoolNode( - *tdbb->getDefaultPool()); - - newChildren.add(newMissingNode->arg.getAddress()); - - deliverNode = newMissingNode; - } - - deliverNode->flags = boolean->flags; - deliverNode->impureOffset = boolean->impureOffset; - - bool wrongNode = false; - - for (indexArg = 0; (indexArg < children.getCount()) && !wrongNode; ++indexArg) - { - JrdNode node = UnmappedNodeGetter::get(map, shellStream, children[indexArg]); - - wrongNode = (!node.jrdNode || !*node.jrdNode); - - if (!wrongNode) - *newChildren[indexArg] = *node.jrdNode; - } - - if (wrongNode) - delete deliverNode; - else - deliverStack->push(deliverNode); - } -} - -// Mark indices that were not included in the user-specified access plan. -static void markIndices(CompilerScratch::csb_repeat* csbTail, SSHORT relationId) -{ - const PlanNode* plan = csbTail->csb_plan; - - if (!plan || plan->type != PlanNode::TYPE_RETRIEVE) - return; - - // Go through each of the indices and mark it unusable - // for indexed retrieval unless it was specifically mentioned - // in the plan; also mark indices for navigational access. - - // If there were none indices, this is a sequential retrieval. - - index_desc* idx = csbTail->csb_idx->items; - - for (USHORT i = 0; i < csbTail->csb_indices; i++) - { - if (plan->accessType) - { - ObjectsArray::iterator arg = plan->accessType->items.begin(); - const ObjectsArray::iterator end = plan->accessType->items.end(); - - for (; arg != end; ++arg) - { - if (relationId != arg->relationId) - { - // index %s cannot be used in the specified plan - ERR_post(Arg::Gds(isc_index_unused) << arg->indexName); - } - - if (idx->idx_id == arg->indexId) - { - if (plan->accessType->type == PlanNode::AccessType::TYPE_NAVIGATIONAL && - arg == plan->accessType->items.begin()) - { - // dimitr: navigational access can use only one index, - // hence the extra check added (see the line above) - idx->idx_runtime_flags |= idx_plan_navigate; - } - else - { - // nod_indices - break; - } - } - } - - if (arg == end) - idx->idx_runtime_flags |= idx_plan_dont_use; - } - else - idx->idx_runtime_flags |= idx_plan_dont_use; - - ++idx; - } -} - -// Sort SortedStream indices based on there selectivity. Lowest selectivy as first, highest as last. -static void sortIndicesBySelectivity(CompilerScratch::csb_repeat* csbTail) -{ - if (csbTail->csb_plan) - return; - - index_desc* selectedIdx = NULL; - Array idxSort(csbTail->csb_indices); - bool sameSelectivity = false; - - // Walk through the indices and sort them into into idxSort - // where idxSort[0] contains the lowest selectivity (best) and - // idxSort[csbTail->csb_indices - 1] the highest (worst) - - if (csbTail->csb_idx && (csbTail->csb_indices > 1)) - { - for (USHORT j = 0; j < csbTail->csb_indices; j++) - { - float selectivity = 1; // Maximum selectivity is 1 (when all keys are the same) - index_desc* idx = csbTail->csb_idx->items; - - for (USHORT i = 0; i < csbTail->csb_indices; i++) - { - // Prefer ASC indices in the case of almost the same selectivities - if (selectivity > idx->idx_selectivity) - sameSelectivity = ((selectivity - idx->idx_selectivity) <= 0.00001); - else - sameSelectivity = ((idx->idx_selectivity - selectivity) <= 0.00001); - - if (!(idx->idx_runtime_flags & idx_marker) && - (idx->idx_selectivity <= selectivity) && - !((idx->idx_flags & idx_descending) && sameSelectivity)) - { - selectivity = idx->idx_selectivity; - selectedIdx = idx; - } - - ++idx; - } - - // If no index was found than pick the first one available out of the list - if ((!selectedIdx) || (selectedIdx->idx_runtime_flags & idx_marker)) - { - idx = csbTail->csb_idx->items; - - for (USHORT i = 0; i < csbTail->csb_indices; i++) - { - if (!(idx->idx_runtime_flags & idx_marker)) - { - selectedIdx = idx; - break; - } - - ++idx; - } - } - - selectedIdx->idx_runtime_flags |= idx_marker; - idxSort.add(*selectedIdx); - } - - // Finally store the right order in cbs_tail->csb_idx - index_desc* idx = csbTail->csb_idx->items; - - for (USHORT j = 0; j < csbTail->csb_indices; j++) - { - idx->idx_runtime_flags &= ~idx_marker; - memcpy(idx, &idxSort[j], sizeof(index_desc)); - ++idx; - } - } -} diff --git a/src/jrd/RecordSourceNodes.h b/src/jrd/RecordSourceNodes.h deleted file mode 100644 index d3e6423b97..0000000000 --- a/src/jrd/RecordSourceNodes.h +++ /dev/null @@ -1,613 +0,0 @@ -/* - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - * Adriano dos Santos Fernandes - */ - -#ifndef JRD_RECORD_SOURCE_NODES_H -#define JRD_RECORD_SOURCE_NODES_H - -#include "../jrd/common.h" -#include "../common/classes/alloc.h" -#include "../common/classes/array.h" -#include "../common/classes/objects_array.h" -#include "../common/classes/NestConst.h" -#include "../jrd/jrd.h" -#include "../jrd/exe.h" -#include "../dsql/Visitors.h" - -namespace Jrd { - -class IndexRetrieval; -class OptimizerRetrieval; -class ProcedureScan; -class BoolExprNode; -class RelationSourceNode; -class RseNode; - - -typedef Firebird::Array > LegacyNodeArray; - -class SortNode : public Firebird::PermanentStorage -{ -public: - explicit SortNode(MemoryPool& pool) - : PermanentStorage(pool), - unique(false), - expressions(pool), - descending(pool), - nullOrder(pool) - { - } - - SortNode* copy(thread_db* tdbb, NodeCopier& copier); - void pass1(thread_db* tdbb, CompilerScratch* csb); - void pass2(thread_db* tdbb, CompilerScratch* csb); - bool computable(CompilerScratch* csb, SSHORT stream, bool idx_use, bool allowOnlyCurrentStream); - void findDependentFromStreams(const OptimizerRetrieval* optRet, SortedStreamList* streamList); - - bool unique; // sorts using unique key - for distinct and group by - LegacyNodeArray expressions; // sort expressions - Firebird::Array descending; // true = descending / false = ascending - Firebird::Array nullOrder; // rse_nulls_* -}; - -class MapNode : public Firebird::PermanentStorage -{ -public: - explicit MapNode(MemoryPool& pool) - : PermanentStorage(pool), - items(pool) - { - } - - MapNode* copy(thread_db* tdbb, NodeCopier& copier); - void pass1(thread_db* tdbb, CompilerScratch* csb); - void pass2(thread_db* tdbb, CompilerScratch* csb); - - LegacyNodeArray items; // map items -}; - -class PlanNode : public Firebird::PermanentStorage -{ -public: - enum Type - { - TYPE_JOIN, - TYPE_RETRIEVE - }; - - struct AccessItem - { - explicit AccessItem(MemoryPool& pool) - : relationId(0), - indexId(0), - indexName(pool) - { - } - - SLONG relationId; - SLONG indexId; - Firebird::MetaName indexName; - }; - - struct AccessType - { - enum Type - { - TYPE_SEQUENTIAL, - TYPE_NAVIGATIONAL, - TYPE_INDICES - }; - - AccessType(MemoryPool& pool, Type aType) - : type(aType), - items(pool) - { - } - - Type const type; - Firebird::ObjectsArray items; - }; - - PlanNode(MemoryPool& pool, Type aType) - : PermanentStorage(pool), - type(aType), - accessType(NULL), - relationNode(NULL), - subNodes(pool) - { - } - - Type const type; - AccessType* accessType; - RelationSourceNode* relationNode; - Firebird::Array > subNodes; -}; - -class InversionNode -{ -public: - enum Type - { - TYPE_AND, - TYPE_OR, - TYPE_IN, - TYPE_DBKEY, - TYPE_INDEX - }; - - InversionNode(Type aType, InversionNode* aNode1, InversionNode* aNode2) - : type(aType), - impure(0), - retrieval(NULL), - node1(aNode1), - node2(aNode2), - value(NULL), - id(0) - { - } - - explicit InversionNode(IndexRetrieval* aRetrieval) - : type(TYPE_INDEX), - impure(0), - retrieval(aRetrieval), - node1(NULL), - node2(NULL), - value(NULL), - id(0) - { - } - - InversionNode(jrd_nod* aValue, USHORT aId) - : type(TYPE_DBKEY), - impure(0), - retrieval(NULL), - node1(NULL), - node2(NULL), - value(aValue), - id(aId) - { - } - - Type type; - ULONG impure; - NestConst retrieval; - NestConst node1; - NestConst node2; - NestConst value; - USHORT id; -}; - - -class RecordSourceNode : public Firebird::PermanentStorage -{ -public: - enum Type - { - TYPE_RELATION, - TYPE_PROCEDURE, - TYPE_AGGREGATE, - TYPE_UNION, - TYPE_WINDOW, - TYPE_RSE - }; - - RecordSourceNode(Type aType, MemoryPool& pool) - : PermanentStorage(pool), - type(aType), - stream(MAX_USHORT) - { - } - - virtual USHORT getStream() const - { - return stream; - } - - void setStream(USHORT value) - { - stream = value; - } - - // Identify the streams that make up an RseNode. - virtual void getStreams(StreamsArray& list) const - { - list.add(getStream()); - } - - virtual RecordSourceNode* copy(thread_db* tdbb, NodeCopier& copier) = 0; - virtual void ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const = 0; - virtual void pass1(thread_db* tdbb, CompilerScratch* csb, jrd_rel* view) = 0; - virtual void pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - BoolExprNode** boolean, RecordSourceNodeStack& stack) = 0; - virtual void pass2(thread_db* tdbb, CompilerScratch* csb) = 0; - virtual void pass2Rse(thread_db* tdbb, CompilerScratch* csb) = 0; - virtual bool containsStream(USHORT checkStream) const = 0; - - // Identify all of the streams for which a dbkey may need to be carried through a sort. - virtual void computeDbKeyStreams(UCHAR* streams) const = 0; - - virtual bool computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* value) = 0; - virtual void findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList) = 0; - virtual RecordSource* compile(thread_db* tdbb, OptimizerBlk* opt, bool innerSubStream) = 0; - -public: - const Type type; - -protected: - USHORT stream; -}; - -class RelationSourceNode : public TypedNode -{ -public: - explicit RelationSourceNode(MemoryPool& pool) - : TypedNode(pool), - relation(NULL), - context(NULL), - alias(NULL), - view(NULL) - { - } - - static RelationSourceNode* parse(thread_db* tdbb, CompilerScratch* csb, SSHORT blrOp, - bool parseContext); - - virtual RelationSourceNode* copy(thread_db* tdbb, NodeCopier& copier); - virtual void ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const; - - virtual void pass1(thread_db* /*tdbb*/, CompilerScratch* /*csb*/, jrd_rel* /*view*/) - { - } - - virtual void pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - BoolExprNode** boolean, RecordSourceNodeStack& stack); - - virtual void pass2(thread_db* /*tdbb*/, CompilerScratch* /*csb*/) - { - } - - virtual void pass2Rse(thread_db* tdbb, CompilerScratch* csb); - - virtual bool containsStream(USHORT checkStream) const - { - return checkStream == stream; - } - - virtual void computeDbKeyStreams(UCHAR* streams) const - { - fb_assert(streams[0] < MAX_STREAMS && streams[0] < MAX_UCHAR); - streams[++streams[0]] = getStream(); - } - - virtual bool computable(CompilerScratch* /*csb*/, SSHORT /*stream*/, bool /*idx_use*/, - bool /*allowOnlyCurrentStream*/, jrd_nod* /*value*/) - { - return true; - } - - virtual void findDependentFromStreams(const OptimizerRetrieval* /*optRet*/, - SortedStreamList* /*streamList*/) - { - } - - virtual RecordSource* compile(thread_db* tdbb, OptimizerBlk* opt, bool innerSubStream); - -public: - jrd_rel* relation; - SSHORT context; // user-specified context number for the relation reference - const char* alias; // SQL alias for the relation - -private: - jrd_rel* view; // parent view for posting access -}; - -class ProcedureSourceNode : public TypedNode -{ -public: - explicit ProcedureSourceNode(MemoryPool& pool) - : TypedNode(pool), - inputs(NULL), - in_msg(NULL), - procedure(NULL), - view(NULL), - context(NULL) - { - } - - static ProcedureSourceNode* parse(thread_db* tdbb, CompilerScratch* csb, SSHORT blrOp); - - virtual ProcedureSourceNode* copy(thread_db* tdbb, NodeCopier& copier); - - virtual void ignoreDbKey(thread_db* /*tdbb*/, CompilerScratch* /*csb*/, const jrd_rel* /*view*/) const - { - } - - virtual void pass1(thread_db* tdbb, CompilerScratch* csb, jrd_rel* view); - virtual void pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - BoolExprNode** boolean, RecordSourceNodeStack& stack); - virtual void pass2(thread_db* tdbb, CompilerScratch* csb); - virtual void pass2Rse(thread_db* tdbb, CompilerScratch* csb); - - virtual bool containsStream(USHORT /*checkStream*/) const - { - return false; - } - - virtual void computeDbKeyStreams(UCHAR* /*streams*/) const - { - } - - virtual bool computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* value); - virtual void findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList); - virtual RecordSource* compile(thread_db* tdbb, OptimizerBlk* opt, bool innerSubStream); - -private: - ProcedureScan* generate(thread_db* tdbb, OptimizerBlk* opt); - -public: - NestConst inputs; - -private: - NestConst in_msg; - USHORT procedure; - jrd_rel* view; - SSHORT context; -}; - -class AggregateSourceNode : public TypedNode -{ -public: - explicit AggregateSourceNode(MemoryPool& pool) - : TypedNode(pool), - group(NULL), - map(NULL), - rse(NULL) - { - } - - static AggregateSourceNode* parse(thread_db* tdbb, CompilerScratch* csb); - - virtual AggregateSourceNode* copy(thread_db* tdbb, NodeCopier& copier); - virtual void ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const; - virtual void pass1(thread_db* tdbb, CompilerScratch* csb, jrd_rel* view); - virtual void pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - BoolExprNode** boolean, RecordSourceNodeStack& stack); - virtual void pass2(thread_db* tdbb, CompilerScratch* csb); - virtual void pass2Rse(thread_db* tdbb, CompilerScratch* csb); - virtual bool containsStream(USHORT checkStream) const; - - virtual void computeDbKeyStreams(UCHAR* /*streams*/) const - { - } - - virtual bool computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* value); - virtual void findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList); - virtual RecordSource* compile(thread_db* tdbb, OptimizerBlk* opt, bool innerSubStream); - -private: - RecordSource* generate(thread_db* tdbb, OptimizerBlk* opt, BoolExprNodeStack* parentStack, - UCHAR shellStream); - -public: - NestConst group; - NestConst map; - -private: - NestConst rse; -}; - -class UnionSourceNode : public TypedNode -{ -public: - explicit UnionSourceNode(MemoryPool& pool) - : TypedNode(pool), - clauses(pool), - maps(pool), - mapStream(NULL), - recursive(false) - { - } - - static UnionSourceNode* parse(thread_db* tdbb, CompilerScratch* csb, SSHORT blrOp); - - virtual UnionSourceNode* copy(thread_db* tdbb, NodeCopier& copier); - virtual void ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const; - - virtual void pass1(thread_db* /*tdbb*/, CompilerScratch* /*csb*/, jrd_rel* /*view*/) - { - } - - virtual void pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - BoolExprNode** boolean, RecordSourceNodeStack& stack); - virtual void pass2(thread_db* tdbb, CompilerScratch* csb); - virtual void pass2Rse(thread_db* tdbb, CompilerScratch* csb); - virtual bool containsStream(USHORT checkStream) const; - virtual void computeDbKeyStreams(UCHAR* streams) const; - virtual bool computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* value); - virtual void findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList); - virtual RecordSource* compile(thread_db* tdbb, OptimizerBlk* opt, bool innerSubStream); - -private: - RecordSource* generate(thread_db* tdbb, OptimizerBlk* opt, UCHAR* streams, USHORT nstreams, - BoolExprNodeStack* parentStack, UCHAR shellStream); - -private: - Firebird::Array > clauses; // RseNode's for union - Firebird::Array > maps; // RseNode's maps - USHORT mapStream; // stream for next level record of recursive union - bool recursive; // union node is a recursive union -}; - -class WindowSourceNode : public TypedNode -{ -public: - struct Partition - { - explicit Partition(MemoryPool&) - : stream(MAX_USHORT) - { - } - - USHORT stream; - NestConst group; - NestConst regroup; - NestConst order; - NestConst map; - }; - - explicit WindowSourceNode(MemoryPool& pool) - : TypedNode(pool), - rse(NULL), - partitions(pool) - { - } - - static WindowSourceNode* parse(thread_db* tdbb, CompilerScratch* csb); - -private: - void parsePartitionBy(thread_db* tdbb, CompilerScratch* csb); - -public: - virtual USHORT getStream() const - { - fb_assert(false); - return 0; - } - - virtual void getStreams(StreamsArray& list) const; - virtual WindowSourceNode* copy(thread_db* tdbb, NodeCopier& copier); - virtual void ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const; - virtual void pass1(thread_db* tdbb, CompilerScratch* csb, jrd_rel* view); - virtual void pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - BoolExprNode** boolean, RecordSourceNodeStack& stack); - virtual void pass2(thread_db* tdbb, CompilerScratch* csb); - virtual void pass2Rse(thread_db* tdbb, CompilerScratch* csb); - virtual bool containsStream(USHORT checkStream) const; - - virtual void computeDbKeyStreams(UCHAR* /*streams*/) const - { - } - - virtual bool computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* value); - virtual void findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList); - virtual RecordSource* compile(thread_db* tdbb, OptimizerBlk* opt, bool innerSubStream); - -private: - NestConst rse; - Firebird::ObjectsArray partitions; -}; - -class RseNode : public TypedNode -{ -public: - static const unsigned FLAG_VARIANT = 0x1; // variant (not invariant?) - static const unsigned FLAG_SINGULAR = 0x2; // singleton select - static const unsigned FLAG_WRITELOCK = 0x4; // locked for write - static const unsigned FLAG_SCROLLABLE = 0x8; // scrollable cursor - - explicit RseNode(MemoryPool& pool) - : TypedNode(pool), - rse_jointype(0), - rse_invariants(NULL), - rse_relations(pool), - flags(0) - { - } - - static RseNode* getFrom(jrd_nod* node) - { - fb_assert(node->nod_type == nod_class_recsrcnode_jrd); - return reinterpret_cast(node->nod_arg[0]); - } - - RseNode* clone() - { - RseNode* obj = FB_NEW(getPool()) RseNode(getPool()); - - obj->rse_jointype = rse_jointype; - obj->rse_first = rse_first; - obj->rse_skip = rse_skip; - obj->rse_boolean = rse_boolean; - obj->rse_sorted = rse_sorted; - obj->rse_projection = rse_projection; - obj->rse_aggregate = rse_aggregate; - obj->rse_plan = rse_plan; - obj->rse_invariants = rse_invariants; - obj->flags = flags; - obj->rse_relations = rse_relations; - - return obj; - } - - virtual void getStreams(StreamsArray& /*list*/) const - { - } - - virtual RseNode* copy(thread_db* tdbb, NodeCopier& copier); - virtual void ignoreDbKey(thread_db* tdbb, CompilerScratch* csb, const jrd_rel* view) const; - virtual void pass1(thread_db* tdbb, CompilerScratch* csb, jrd_rel* view); - virtual void pass1Source(thread_db* tdbb, CompilerScratch* csb, RseNode* rse, - BoolExprNode** boolean, RecordSourceNodeStack& stack); - - virtual void pass2(thread_db* /*tdbb*/, CompilerScratch* /*csb*/) - { - } - - virtual void pass2Rse(thread_db* tdbb, CompilerScratch* csb); - virtual bool containsStream(USHORT checkStream) const; - virtual void computeDbKeyStreams(UCHAR* streams) const; - virtual bool computable(CompilerScratch* csb, SSHORT stream, bool idx_use, - bool allowOnlyCurrentStream, jrd_nod* value); - virtual void findDependentFromStreams(const OptimizerRetrieval* optRet, - SortedStreamList* streamList); - virtual RecordSource* compile(thread_db* tdbb, OptimizerBlk* opt, bool innerSubStream); - -private: - void computeRseStreams(const CompilerScratch* csb, UCHAR* streams) const; - void planCheck(const CompilerScratch* csb) const; - static void planSet(CompilerScratch* csb, PlanNode* plan); - -public: - USHORT rse_jointype; // inner, left, full - NestConst rse_first; - NestConst rse_skip; - NestConst rse_boolean; - NestConst rse_sorted; - NestConst rse_projection; - NestConst rse_aggregate; // singleton aggregate for optimizing to index - NestConst rse_plan; // user-specified access plan - NestConst rse_invariants; // Invariant nodes bound to top-level RSE - Firebird::Array > rse_relations; - unsigned flags; -}; - - -} //namespace Jrd - -#endif // JRD_RECORD_SOURCE_NODES_H diff --git a/src/jrd/Relation.h b/src/jrd/Relation.h index 1aaef6d534..f0ece07cd9 100644 --- a/src/jrd/Relation.h +++ b/src/jrd/Relation.h @@ -29,9 +29,6 @@ namespace Jrd { -class BoolExprNode; -class RseNode; - // view context block to cache view aliases class ViewContext @@ -187,7 +184,7 @@ public: Firebird::MetaName rel_owner_name; // ascii owner vec* rel_fields; // vector of field blocks - RseNode* rel_view_rse; // view record select expression + RecordSelExpr* rel_view_rse; // view record select expression ViewContexts rel_view_contexts; // sorted array of view contexts Firebird::MetaName rel_security_name; // security class name for relation @@ -331,10 +328,8 @@ inline RelationPages* jrd_rel::getPages(thread_db* tdbb, SLONG tran, bool allocP class jrd_fld : public pool_alloc { public: - BoolExprNode* fld_validation; // validation clause, if any - jrd_nod* fld_validation_stmt; // validation clause, if any - nod_stmt_expr fragment - BoolExprNode* fld_not_null; // if field cannot be NULL - jrd_nod* fld_not_null_stmt; // if field cannot be NULL - nod_stmt_expr fragment + jrd_nod* fld_validation; // validation clause, if any + jrd_nod* fld_not_null; // if field cannot be NULL jrd_nod* fld_missing_value; // missing value, if any jrd_nod* fld_computation; // computation for virtual field jrd_nod* fld_source; // source for view fields diff --git a/src/jrd/ResultSet.h b/src/jrd/ResultSet.h index ba381d8ba6..ccd4d2e608 100644 --- a/src/jrd/ResultSet.h +++ b/src/jrd/ResultSet.h @@ -26,7 +26,7 @@ #include "firebird.h" #include "../jrd/common.h" #include "../jrd/gdsassert.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../common/classes/auto.h" #include "../common/classes/fb_string.h" #include "../common/classes/MetaName.h" diff --git a/src/jrd/Routine.h b/src/jrd/Routine.h index f4d2b94cec..317b4c79fa 100644 --- a/src/jrd/Routine.h +++ b/src/jrd/Routine.h @@ -38,8 +38,7 @@ namespace Jrd name(p), securityName(p), statement(NULL), - undefined(false), - implemented(true) + undefined(false) { } @@ -64,9 +63,6 @@ namespace Jrd bool isUndefined() const { return undefined; } void setUndefined(bool value) { undefined = value; } - bool isImplemented() const { return implemented; } - void setImplemented(bool value) { implemented = value; } - public: virtual int getObjectType() const = 0; virtual SLONG getSclType() const = 0; @@ -77,7 +73,6 @@ namespace Jrd Firebird::MetaName securityName; // security class name JrdStatement* statement; // compiled routine statement bool undefined; // Is the packaged routine missing the body/entrypoint? - bool implemented; // routine has its implementation available }; } diff --git a/src/jrd/SimilarToMatcher.h b/src/jrd/SimilarToMatcher.h index 2bf6411e63..36f083ddc8 100644 --- a/src/jrd/SimilarToMatcher.h +++ b/src/jrd/SimilarToMatcher.h @@ -35,11 +35,12 @@ // #define RECURSIVE_SIMILAR // useless in production due to stack overflow #endif + namespace Firebird { template > -class SimilarToMatcher : public Jrd::PatternMatcher +class SimilarToMatcher : public Jrd::BaseSimilarToMatcher { private: typedef Jrd::CharSet CharSet; @@ -73,9 +74,9 @@ private: class Evaluator : private StaticAllocator { public: - Evaluator(MemoryPool& pool, TextType* aTextType, + Evaluator(MemoryPool& pool, TextType* textType, const UCHAR* patternStr, SLONG patternLen, - CharType aEscapeChar, bool aUseEscape); + CharType escapeChar, bool useEscape, bool forSubstring); ~Evaluator() { @@ -162,65 +163,6 @@ private: { } -#ifdef DEBUG_SIMILAR - void dump(string& text, int i) const - { - string temp; - - switch (op) - { - case opRepeat: - temp.printf("opRepeat(%d, %d, %d)", len, len2, ref); - break; - - case opBranch: - if (branchNum == -1) - temp.printf("opBranch(%d)", i + ref); - else - temp.printf("opBranch(%d, %d)", i + ref, branchNum); - break; - - case opStart: - temp = "opStart"; - break; - - case opEnd: - temp = "opEnd"; - break; - - case opRef: - if (branchNum == -1) - temp.printf("opRef(%d)", i + ref); - else - temp.printf("opRef(%d, %d)", i + ref, branchNum); - break; - - case opNothing: - temp = "opNothing"; - break; - - case opAny: - temp = "opAny"; - break; - - case opAnyOf: - temp.printf("opAnyOf(%.*s, %d, %.*s, %d, %.*s, %d, %.*s, %d)", - len, str, len, len2, str2, len2, len3, str3, len3, len4, str4, len4); - break; - - case opExactly: - temp.printf("opExactly(%.*s, %d)", len, str, len); - break; - - default: - temp = "unknown"; - break; - } - - text.printf("%d: %s", i, temp.c_str()); - } -#endif // DEBUG_SIMILAR - Op op; const CharType* str; SLONG len; @@ -292,14 +234,10 @@ private: unsigned length; }; -#ifdef DEBUG_SIMILAR - Array debugLog; - int debugLevel; -#endif - TextType* textType; CharType escapeChar; bool useEscape; + bool forSubstring; HalfStaticArray buffer; const UCHAR* originalPatternStr; SLONG originalPatternLen; @@ -322,9 +260,9 @@ private: public: SimilarToMatcher(MemoryPool& pool, TextType* ttype, const UCHAR* str, - SLONG strLen, CharType escape, bool useEscape) - : PatternMatcher(pool, ttype), - evaluator(pool, ttype, str, strLen, escape, useEscape) + SLONG strLen, CharType escape, bool useEscape, bool forSubstring) + : BaseSimilarToMatcher(pool, ttype), + evaluator(pool, ttype, str, strLen, escape, useEscape, forSubstring) { } @@ -356,21 +294,23 @@ public: } static SimilarToMatcher* create(MemoryPool& pool, TextType* ttype, - const UCHAR* str, SLONG length, const UCHAR* escape, SLONG escapeLen) + const UCHAR* str, SLONG length, const UCHAR* escape, SLONG escapeLen, bool forSubstring) { StrConverter cvt_escape(pool, ttype, escape, escapeLen); return FB_NEW(pool) SimilarToMatcher(pool, ttype, str, length, - (escape ? *reinterpret_cast(escape) : 0), escapeLen != 0); + (escape ? *reinterpret_cast(escape) : 0), escapeLen != 0, + forSubstring); } static bool evaluate(MemoryPool& pool, TextType* ttype, const UCHAR* s, SLONG sl, - const UCHAR* p, SLONG pl, const UCHAR* escape, SLONG escapeLen) + const UCHAR* p, SLONG pl, const UCHAR* escape, SLONG escapeLen, bool forSubstring) { StrConverter cvt_escape(pool, ttype, escape, escapeLen); Evaluator evaluator(pool, ttype, p, pl, - (escape ? *reinterpret_cast(escape) : 0), escapeLen != 0); + (escape ? *reinterpret_cast(escape) : 0), escapeLen != 0, + forSubstring); evaluator.processNextChunk(s, sl); return evaluator.getResult(); } @@ -382,17 +322,14 @@ private: template SimilarToMatcher::Evaluator::Evaluator( - MemoryPool& pool, TextType* aTextType, + MemoryPool& pool, TextType* textType, const UCHAR* patternStr, SLONG patternLen, - CharType aEscapeChar, bool aUseEscape) + CharType escapeChar, bool useEscape, bool forSubstring) : StaticAllocator(pool), -#ifdef DEBUG_SIMILAR - debugLog(pool), - debugLevel(-1), -#endif - textType(aTextType), - escapeChar(aEscapeChar), - useEscape(aUseEscape), + textType(textType), + escapeChar(escapeChar), + useEscape(useEscape), + forSubstring(forSubstring), buffer(pool), originalPatternStr(patternStr), originalPatternLen(patternLen), @@ -434,6 +371,9 @@ SimilarToMatcher::Evaluator::Evaluator( int flags; parseExpr(&flags); + if (forSubstring && branchNum != 2) + status_exception::raise(Arg::Gds(isc_invalid_similar_pattern)); + nodes.push(Node(opEnd)); #ifdef DEBUG_SIMILAR @@ -463,11 +403,6 @@ bool SimilarToMatcher::Evaluator::getResult() bufferStart = bufferPos = (const CharType*) str; bufferEnd = bufferStart + len / sizeof(CharType); -#ifdef DEBUG_SIMILAR - debugLog.clear(); - debugLevel = -1; -#endif - const bool matched = #ifdef RECURSIVE_SIMILAR match(nodes.getCount(), 0); @@ -478,16 +413,15 @@ bool SimilarToMatcher::Evaluator::getResult() #ifdef DEBUG_SIMILAR if (matched) { + string s; for (unsigned i = 0; i <= branchNum; ++i) { string x; - x.printf("%d: %d, %d\n", i, branches[i].start, branches[i].length); - debugLog.add(x.c_str(), x.length()); + x.printf("%d: %d, %d\n\t", i, branches[i].start, branches[i].length); + s += x; } - debugLog.add('\0'); - - gds__log("\n%s", debugLog.begin()); + gds__log("%s", s.c_str()); } #endif // DEBUG_SIMILAR @@ -567,6 +501,14 @@ void SimilarToMatcher::Evaluator::parseTerm(int* flagp) (c = *patternPos) != canonicalChar(TextType::CHAR_VERTICAL_BAR) && c != canonicalChar(TextType::CHAR_CLOSE_PAREN)) { + if (forSubstring && branchNum != 0 && patternPos + 1 < patternEnd && + *patternPos == escapeChar && + patternPos[1] == canonicalChar(TextType::CHAR_DOUBLE_QUOTE)) + { + ++branchNum; + break; + } + parseFactor(&flags); *flagp |= flags & FLAG_NOT_EMPTY; @@ -972,7 +914,8 @@ void SimilarToMatcher::Evaluator::parsePrimary(int* flag int flags; parseExpr(&flags); - ++branchNum; // This is used for the trace stuff. + if (!forSubstring) // This is used for the trace stuff. + ++branchNum; if (patternPos >= patternEnd || *patternPos++ != canonicalChar(TextType::CHAR_CLOSE_PAREN)) status_exception::raise(Arg::Gds(isc_invalid_similar_pattern)); @@ -984,14 +927,40 @@ void SimilarToMatcher::Evaluator::parsePrimary(int* flag if (patternPos >= patternEnd) status_exception::raise(Arg::Gds(isc_escape_invalid)); - if (*patternPos != escapeChar && - notInSet(patternPos, 1, metaCharacters, FB_NELEM(metaCharacters)) != 0) + if (forSubstring && *patternPos == canonicalChar(TextType::CHAR_DOUBLE_QUOTE)) { - status_exception::raise(Arg::Gds(isc_escape_invalid)); - } + if (branchNum != 0) + { + --patternPos; + return; + } - nodes.push(Node(opExactly, patternPos++, 1)); - *flagp |= FLAG_NOT_EMPTY; + ++branchNum; + ++patternPos; + + int flags; + parseExpr(&flags); + + if (patternPos + 1 >= patternEnd || *patternPos != escapeChar || + patternPos[1] != canonicalChar(TextType::CHAR_DOUBLE_QUOTE)) + { + status_exception::raise(Arg::Gds(isc_invalid_similar_pattern)); + } + + patternPos += 2; + *flagp |= flags & FLAG_NOT_EMPTY; + } + else + { + if (*patternPos != escapeChar && + notInSet(patternPos, 1, metaCharacters, FB_NELEM(metaCharacters)) != 0) + { + status_exception::raise(Arg::Gds(isc_escape_invalid)); + } + + nodes.push(Node(opExactly, patternPos++, 1)); + *flagp |= FLAG_NOT_EMPTY; + } } else { @@ -1030,10 +999,62 @@ void SimilarToMatcher::Evaluator::dump() const for (unsigned i = 0; i < nodes.getCount(); ++i) { string type; - nodes[i].dump(type, i); + + switch (nodes[i].op) + { + case opRepeat: + type.printf("opRepeat(%d, %d, %d)", nodes[i].len, nodes[i].len2, nodes[i].ref); + break; + + case opBranch: + if (nodes[i].branchNum == -1) + type.printf("opBranch(%d)", i + nodes[i].ref); + else + type.printf("opBranch(%d, %d)", i + nodes[i].ref, nodes[i].branchNum); + break; + + case opStart: + type = "opStart"; + break; + + case opEnd: + type = "opEnd"; + break; + + case opRef: + if (nodes[i].branchNum == -1) + type.printf("opRef(%d)", i + nodes[i].ref); + else + type.printf("opRef(%d, %d)", i + nodes[i].ref, nodes[i].branchNum); + break; + + case opNothing: + type = "opNothing"; + break; + + case opAny: + type = "opAny"; + break; + + case opAnyOf: + type.printf("opAnyOf(%.*s, %d, %.*s, %d, %.*s, %d, %.*s, %d)", + nodes[i].len, nodes[i].str, nodes[i].len, + nodes[i].len2, nodes[i].str2, nodes[i].len2, + nodes[i].len3, nodes[i].str3, nodes[i].len3, + nodes[i].len4, nodes[i].str4, nodes[i].len4); + break; + + case opExactly: + type.printf("opExactly(%.*s, %d)", nodes[i].len, nodes[i].str, nodes[i].len); + break; + + default: + type = "unknown"; + break; + } string s; - s.printf("%s%s", (i > 0 ? ", " : ""), type.c_str()); + s.printf("%s%d:%s", (i > 0 ? ", " : ""), i, type.c_str()); text += s; } @@ -1047,25 +1068,10 @@ template #ifdef RECURSIVE_SIMILAR bool SimilarToMatcher::Evaluator::match(int limit, int start) { -#ifdef DEBUG_SIMILAR - AutoSetRestore autoDebugLevel(&debugLevel, debugLevel + 1); -#endif - for (int i = start; i < limit; ++i) { const Node* node = &nodes[i]; -#ifdef DEBUG_SIMILAR - string s; - node->dump(s, i); - - for (int debugLevelI = 0; debugLevelI < debugLevel; ++debugLevelI) - s = " " + s; - - s = "\n" + s; - debugLog.add(s.c_str(), s.length()); -#endif - switch (node->op) { case opRepeat: @@ -1113,16 +1119,6 @@ bool SimilarToMatcher::Evaluator::match(int limit, int s if (node->ref == 0) break; - -#ifdef DEBUG_SIMILAR - node->dump(s, i); - - for (int debugLevelI = 0; debugLevelI < debugLevel; ++debugLevelI) - s = " " + s; - - s = "\n" + s; - debugLog.add(s.c_str(), s.length()); -#endif } break; @@ -1154,28 +1150,12 @@ bool SimilarToMatcher::Evaluator::match(int limit, int s break; case opAny: -#ifdef DEBUG_SIMILAR - if (bufferPos >= bufferEnd) - s = " -> "; - else - s.printf(" -> %d", *bufferPos); - debugLog.add(s.c_str(), s.length()); -#endif - if (bufferPos >= bufferEnd) return false; ++bufferPos; break; case opAnyOf: -#ifdef DEBUG_SIMILAR - if (bufferPos >= bufferEnd) - s = " -> "; - else - s.printf(" -> %d", *bufferPos); - debugLog.add(s.c_str(), s.length()); -#endif - if (bufferPos >= bufferEnd) return false; @@ -1563,219 +1543,7 @@ SLONG SimilarToMatcher::Evaluator::notInSet( return strLen; } - -// Given a regular expression R1#R2#R3 and the string S: -// - Find the shortest substring of S that matches R1 while the remainder (S23) matches R2R3; -// - Find the longest (S2) substring of S23 that matches R2 while the remainder matches R3; -// - Return S2. -template > -class SubstringSimilarMatcher : public Jrd::BaseSubstringSimilarMatcher -{ -private: - typedef Jrd::CharSet CharSet; - typedef Jrd::TextType TextType; - -public: - SubstringSimilarMatcher(MemoryPool& pool, TextType* ttype, - const UCHAR* patternStr, SLONG patternLen, CharType aEscapeChar) - : BaseSubstringSimilarMatcher(pool, ttype), - escapeChar(aEscapeChar), - originalPatternStr(patternStr), - originalPatternLen(patternLen), - patternCvt(pool, textType, patternStr, patternLen), - buffer(pool) - { - CharSet* charSet = textType->getCharSet(); - - // Make a new string without the . While doing it, get the byte - // length of each segment. - - UCharBuffer newExpr(originalPatternLen); - UCHAR* newExprPos = newExpr.begin(); - - const UCHAR* originalPatternEnd = originalPatternStr + originalPatternLen; - const UCHAR* originalPatternPos = originalPatternStr; - - const CharType* lastStart = reinterpret_cast(patternStr); - const CharType* end = lastStart + patternLen; - unsigned lengths[3]; - unsigned lengthsNum = 0; - UCHAR dummy[sizeof(ULONG) * 2]; - - for (const CharType* p = lastStart; p < end; ++p) - { - if (*p != escapeChar) - continue; - - if (++p >= end) - status_exception::raise(Arg::Gds(isc_invalid_similar_pattern)); - - if (*p == canonicalChar(TextType::CHAR_DOUBLE_QUOTE)) - { - if (lengthsNum >= 2) - status_exception::raise(Arg::Gds(isc_invalid_similar_pattern)); - - // Get the byte length since the last segment. - ULONG len = charSet->substring(originalPatternEnd - originalPatternPos, - originalPatternPos, newExpr.begin() + originalPatternLen - newExprPos, - newExprPos, 0, p - lastStart - 1); - - lengths[lengthsNum++] = len; - newExprPos += len; - originalPatternPos += len; - - // Advance two () characters. - originalPatternPos += charSet->substring(originalPatternEnd - originalPatternPos, - originalPatternPos, sizeof(dummy), dummy, 0, 2); - - lastStart = p + 1; // Register the start of the next segment. - } - } - - if (lengthsNum != 2) - status_exception::raise(Arg::Gds(isc_invalid_similar_pattern)); - - // Get the byte length of the last segment. - lengths[2] = charSet->substring(originalPatternEnd - originalPatternPos, - originalPatternPos, newExpr.begin() + originalPatternLen - newExprPos, - newExprPos, 0, end - lastStart); - - // Construct the needed regular expressions. - - r1 = FB_NEW(pool) SimilarToMatcher(pool, ttype, - newExpr.begin(), lengths[0], escapeChar, true); - - r2 = FB_NEW(pool) SimilarToMatcher(pool, ttype, - newExpr.begin() + lengths[0], lengths[1], escapeChar, true); - - r3 = FB_NEW(pool) SimilarToMatcher(pool, ttype, - newExpr.begin() + lengths[0] + lengths[1], lengths[2], escapeChar, true); - - r23 = FB_NEW(pool) SimilarToMatcher(pool, ttype, - newExpr.begin() + lengths[0], lengths[1] + lengths[2], escapeChar, true); - } - - static SubstringSimilarMatcher* create(MemoryPool& pool, TextType* ttype, - const UCHAR* str, SLONG length, const UCHAR* escape, SLONG escapeLen) - { - StrConverter cvt_escape(pool, ttype, escape, escapeLen); - - return FB_NEW(pool) SubstringSimilarMatcher(pool, ttype, str, length, - *reinterpret_cast(escape)); - } - - void reset() - { - buffer.shrink(0); - - r1->reset(); - r2->reset(); - r3->reset(); - r23->reset(); - } - - bool result() - { - CharSet* charSet = textType->getCharSet(); - const UCHAR* p = buffer.begin(); - UCharBuffer temp(buffer.getCount()); - UCHAR dummy[sizeof(ULONG)]; - - // Find the shortest substring that matches R1 while the full expression matches R1R2R3. - do - { - r1->reset(); - r1->process(buffer.begin(), p - buffer.begin()); - - if (r1->result()) - { - // We have a initial substring matching R1. Let's see if the remainder matches R2R3. - - r23->reset(); - r23->process(p, buffer.end() - p); - - if (r23->result()) - { - // Now we start to find the longest substring that matches R2 while the - // remainder matches R3. Once we found it, it's the result string. - - // We already know its start, based on the substring that matched R1. - matchedStart = p - buffer.begin(); - - const UCHAR* p3 = buffer.end(); - SLONG charLen23 = -1; - memcpy(temp.begin(), p, p3 - p); - - while (true) - { - r2->reset(); - r2->process(temp.begin(), p3 - p); - - if (r2->result()) - { - r3->reset(); - r3->process(p3, buffer.end() - p3); - - if (r3->result()) - { - matchedLength = p3 - buffer.begin() - matchedStart; - return true; - } - } - - if (charLen23 == -1) - charLen23 = charSet->length(p3 - p, p, true); - - if (charLen23-- == 0) - break; - - // Shrink in one character the string to match R2. - // Move back one character to match R3. - p3 = p + charSet->substring(buffer.end() - p, p, temp.getCapacity(), - temp.begin(), 0, charLen23); - } - } - } - - // Advance a character. - p += charSet->substring(buffer.end() - p, p, sizeof(dummy), dummy, 0, 1); - } while (p < buffer.end()); - - return false; - } - - bool process(const UCHAR* str, SLONG length) - { - const size_t pos = buffer.getCount(); - memcpy(buffer.getBuffer(pos + length) + pos, str, length); - return true; - } - - // We return byte-base start and length. - void getResultInfo(unsigned* start, unsigned* length) - { - *start = matchedStart; - *length = matchedLength; - } - -private: - CharType canonicalChar(int ch) const - { - return *reinterpret_cast(textType->getCanonicalChar(ch)); - } - -private: - CharType escapeChar; - const UCHAR* originalPatternStr; - SLONG originalPatternLen; - StrConverter patternCvt; - HalfStaticArray buffer; - AutoPtr r1, r2, r3, r23; - unsigned matchedStart; - unsigned matchedLength; -}; - - } // namespace Firebird + #endif // JRD_SIMILAR_TO_EVALUATOR_H diff --git a/src/jrd/SysFunction.cpp b/src/jrd/SysFunction.cpp index 18c045381c..4179f96740 100644 --- a/src/jrd/SysFunction.cpp +++ b/src/jrd/SysFunction.cpp @@ -44,7 +44,7 @@ #include "../jrd/mov_proto.h" #include "../jrd/pag_proto.h" #include "../jrd/tra_proto.h" -#include "../jrd/os/guid.h" +#include "../common/os/guid.h" #include "../jrd/license.h" #include "../jrd/trace/TraceManager.h" #include "../jrd/trace/TraceObjects.h" @@ -2208,7 +2208,7 @@ dsc* evlSetContext(thread_db* tdbb, const SysFunction*, const jrd_nod* args, impure->vlu_desc.makeLong(0, &impure->vlu_misc.vlu_long); - StringMap* contextVars = NULL; + Firebird::StringMap* contextVars = NULL; if (nameSpaceStr == USER_SESSION_NAMESPACE) { @@ -2600,7 +2600,7 @@ dsc* evlOverlay(thread_db* tdbb, const SysFunction* function, const jrd_nod* arg if (value->isBlob()) { - UCharBuffer bpb; + Firebird::UCharBuffer bpb; BLB_gen_bpb_from_descs(value, &impure->vlu_desc, bpb); blb* blob = BLB_open2(tdbb, tdbb->getRequest()->req_transaction, @@ -2621,7 +2621,7 @@ dsc* evlOverlay(thread_db* tdbb, const SysFunction* function, const jrd_nod* arg if (placing->isBlob()) { - UCharBuffer bpb; + Firebird::UCharBuffer bpb; BLB_gen_bpb_from_descs(placing, &impure->vlu_desc, bpb); blb* blob = BLB_open2(tdbb, tdbb->getRequest()->req_transaction, @@ -2887,7 +2887,7 @@ dsc* evlPad(thread_db* tdbb, const SysFunction* function, const jrd_nod* args, } -dsc* evlPi(thread_db* /*tdbb*/, const SysFunction*, const jrd_nod* args, +dsc* evlPi(thread_db* tdbb, const SysFunction*, const jrd_nod* args, impure_value* impure) { fb_assert(args->nod_count == 0); @@ -2957,7 +2957,7 @@ dsc* evlPosition(thread_db* tdbb, const SysFunction* function, const jrd_nod* ar else value1Length = MOV_make_string2(tdbb, value1, ttype, &value1Address, value1Buffer); - HalfStaticArray value1Canonical; + Firebird::HalfStaticArray value1Canonical; value1Canonical.getBuffer(value1Length / cs->minBytesPerChar() * canonicalWidth); const SLONG value1CanonicalLen = tt->canonical(value1Length, value1Address, value1Canonical.getCount(), value1Canonical.begin()) * canonicalWidth; @@ -2985,7 +2985,7 @@ dsc* evlPosition(thread_db* tdbb, const SysFunction* function, const jrd_nod* ar else value2Length = MOV_make_string2(tdbb, value2, ttype, &value2Address, value2Buffer); - HalfStaticArray value2Canonical; + Firebird::HalfStaticArray value2Canonical; value2Canonical.getBuffer(value2Length / cs->minBytesPerChar() * canonicalWidth); const SLONG value2CanonicalLen = tt->canonical(value2Length, value2Address, value2Canonical.getCount(), value2Canonical.begin()) * canonicalWidth; @@ -3126,7 +3126,7 @@ dsc* evlReplace(thread_db* tdbb, const SysFunction*, const jrd_nod* args, if (lengths[1] == 0) return values[0]; - HalfStaticArray canonicals[2]; // searched, find + Firebird::HalfStaticArray canonicals[2]; // searched, find for (int i = 0; i < 2; ++i) { canonicals[i].getBuffer(lengths[i] / cs->minBytesPerChar() * canonicalWidth); @@ -3247,8 +3247,8 @@ dsc* evlReverse(thread_db* tdbb, const SysFunction*, const jrd_nod* args, blb* blob = BLB_open(tdbb, tdbb->getRequest()->req_transaction, reinterpret_cast(value->dsc_address)); - HalfStaticArray buffer; - HalfStaticArray buffer2; + Firebird::HalfStaticArray buffer; + Firebird::HalfStaticArray buffer2; UCHAR* p = buffer.getBuffer(blob->blb_length); const SLONG len = BLB_get_data(tdbb, blob, p, blob->blb_length, true); @@ -3357,7 +3357,7 @@ dsc* evlRight(thread_db* tdbb, const SysFunction*, const jrd_nod* args, if (charSet->isMultiByte()) { - HalfStaticArray buffer; + Firebird::HalfStaticArray buffer; start = charSet->length( BLB_get_data(tdbb, blob, buffer.getBuffer(blob->blb_length), blob->blb_length, false), @@ -3667,7 +3667,7 @@ const SysFunction SysFunction::functions[] = }; -const SysFunction* SysFunction::lookup(const MetaName& name) +const SysFunction* SysFunction::lookup(const Firebird::MetaName& name) { for (const SysFunction* f = functions; f->name.length() > 0; ++f) { @@ -3726,7 +3726,7 @@ dsc* SysFunction::substring(thread_db* tdbb, impure_value* impure, blb* blob = BLB_open(tdbb, tdbb->getRequest()->req_transaction, reinterpret_cast(value->dsc_address)); - HalfStaticArray buffer; + Firebird::HalfStaticArray buffer; CharSet* charSet = INTL_charset_lookup(tdbb, value->getCharSet()); //const ULONG totLen = length * charSet->maxBytesPerChar(); @@ -3735,7 +3735,7 @@ dsc* SysFunction::substring(thread_db* tdbb, impure_value* impure, buffer.getBuffer(MIN(blob->blb_length, (offset + length) * charSet->maxBytesPerChar())); dataLen = BLB_get_data(tdbb, blob, buffer.begin(), buffer.getCount(), false); - HalfStaticArray buffer2; + Firebird::HalfStaticArray buffer2; buffer2.getBuffer(dataLen); dataLen = charSet->substring(dataLen, buffer.begin(), diff --git a/src/jrd/SysFunction.h b/src/jrd/SysFunction.h index 0b20c611ac..331099b168 100644 --- a/src/jrd/SysFunction.h +++ b/src/jrd/SysFunction.h @@ -33,7 +33,7 @@ #include "../common/classes/MetaName.h" #include "../jrd/DataTypeUtil.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" namespace Jrd { diff --git a/src/jrd/TempSpace.cpp b/src/jrd/TempSpace.cpp index e4a1c2f67d..ce49d09b2a 100644 --- a/src/jrd/TempSpace.cpp +++ b/src/jrd/TempSpace.cpp @@ -26,10 +26,10 @@ #include "../common/config/config.h" #include "../common/config/dir_list.h" #include "../jrd/gdsassert.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/err_proto.h" -#include "../jrd/isc_proto.h" -#include "../jrd/os/path_utils.h" +#include "../common/isc_proto.h" +#include "../common/os/path_utils.h" #include "../jrd/TempSpace.h" diff --git a/src/jrd/UserManagement.cpp b/src/jrd/UserManagement.cpp index 5be110e55d..26581f7516 100644 --- a/src/jrd/UserManagement.cpp +++ b/src/jrd/UserManagement.cpp @@ -25,7 +25,7 @@ #include "../jrd/UserManagement.h" #include "../jrd/common.h" #include "../jrd/jrd.h" -#include "../jrd/jrd_pwd.h" +#include "../auth/SecurityDatabase/jrd_pwd.h" #include "../jrd/tra.h" #include "../jrd/msg_encode.h" #include "../utilities/gsec/gsec.h" diff --git a/src/jrd/ValueImpl.h b/src/jrd/ValueImpl.h index 94a20cd9c3..757bc8484a 100644 --- a/src/jrd/ValueImpl.h +++ b/src/jrd/ValueImpl.h @@ -26,7 +26,7 @@ #include "FirebirdApi.h" #include "FirebirdExternalApi.h" #include "../jrd/common.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../jrd/jrd.h" #include "../jrd/ErrorImpl.h" diff --git a/src/jrd/ValuesImpl.cpp b/src/jrd/ValuesImpl.cpp index 79856d54c5..3c2905629a 100644 --- a/src/jrd/ValuesImpl.cpp +++ b/src/jrd/ValuesImpl.cpp @@ -67,7 +67,8 @@ ValuesImpl::IndividualQueue::~IndividualQueue() void FB_CALL ValuesImpl::IndividualQueue::enqueue(Error* /*error*/) { - const size_t recordCount = records.getCount(); + thread_db* tdbb = JRD_get_thread_data(); + size_t recordCount = records.getCount(); UCHAR* const buffer = (enqueuePos < recordCount ? records[enqueuePos] : FB_NEW(getPool()) UCHAR[recordSize]); UCHAR* nullsBuffer = buffer + nullsStart; @@ -160,7 +161,8 @@ ValuesImpl::MsgQueue::~MsgQueue() void FB_CALL ValuesImpl::MsgQueue::enqueue(Error* /*error*/) { - const size_t recordCount = records.getCount(); + thread_db* tdbb = JRD_get_thread_data(); + size_t recordCount = records.getCount(); UCHAR* buffer = (enqueuePos < recordCount ? records[enqueuePos] : FB_NEW(getPool()) UCHAR[msgLength]); diff --git a/src/jrd/ValuesImpl.h b/src/jrd/ValuesImpl.h index 3371a4c4b1..831996bc3c 100644 --- a/src/jrd/ValuesImpl.h +++ b/src/jrd/ValuesImpl.h @@ -99,7 +99,7 @@ public: } ValuesImpl(Firebird::MemoryPool& p, const Format* format, UCHAR* aMsg, - const Firebird::Array >& parameters) + const Firebird::Array& parameters) : PermanentStorage(p), msg(aMsg), msgLength(format->fmt_length), diff --git a/src/jrd/VirtualTable.cpp b/src/jrd/VirtualTable.cpp index 5d72107eb1..a1535a9075 100644 --- a/src/jrd/VirtualTable.cpp +++ b/src/jrd/VirtualTable.cpp @@ -26,7 +26,7 @@ #include "../jrd/constants.h" #include "../jrd/gdsassert.h" #include "../jrd/jrd.h" -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../jrd/exe.h" #include "../jrd/ini.h" #include "../jrd/req.h" diff --git a/src/jrd/align.h b/src/jrd/align.h index d6c339a349..e66b5b66fd 100644 --- a/src/jrd/align.h +++ b/src/jrd/align.h @@ -49,7 +49,7 @@ No need to worry about blr_blob or ?blr_blob_id */ -#include "../jrd/dsc.h" +#include "../common/dsc.h" #include "../jrd/RecordNumber.h" static const USHORT gds_cvt_blr_dtype[DTYPE_BLR_MAX + 1] = diff --git a/src/jrd/blb.cpp b/src/jrd/blb.cpp index 62942e5c38..b2b0b180d4 100644 --- a/src/jrd/blb.cpp +++ b/src/jrd/blb.cpp @@ -51,10 +51,9 @@ #include "../jrd/lls.h" #include "gen/iberror.h" #include "../jrd/blob_filter.h" -#include "../jrd/sdl.h" +#include "../common/sdl.h" #include "../jrd/intl.h" #include "../jrd/cch.h" -#include "../dsql/ExprNodes.h" #include "../jrd/gdsassert.h" #include "../jrd/blb_proto.h" #include "../jrd/blf_proto.h" @@ -63,19 +62,20 @@ #include "../jrd/err_proto.h" #include "../jrd/evl_proto.h" #include "../jrd/filte_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/intl_proto.h" #include "../jrd/jrd_proto.h" #include "../jrd/met_proto.h" #include "../jrd/mov_proto.h" #include "../jrd/pag_proto.h" -#include "../jrd/sdl_proto.h" -#include "../jrd/dsc_proto.h" +#include "../common/sdl_proto.h" +#include "../common/dsc_proto.h" #include "../common/classes/array.h" #include "../common/classes/VaryStr.h" using namespace Jrd; using namespace Firebird; +using Firebird::UCharBuffer; typedef Ods::blob_page blob_page; @@ -987,15 +987,9 @@ void BLB_move(thread_db* tdbb, dsc* from_desc, dsc* to_desc, const jrd_nod* fiel simpleMove = tdbb->getRequest()->req_rpb[(IPTR)field->nod_arg[e_fld_stream]].rpb_relation == NULL; break; - + case nod_argument: case nod_variable: break; - - case nod_class_exprnode_jrd: - if (ExprNode::is(field)) - break; - // fall into - default: BUGCHECK(199); // msg 199 expected field node } diff --git a/src/jrd/blb.h b/src/jrd/blb.h index aa16ea1983..707acad227 100644 --- a/src/jrd/blb.h +++ b/src/jrd/blb.h @@ -31,6 +31,12 @@ #include "../common/classes/array.h" #include "../common/classes/File.h" +#include "ProviderInterface.h" +namespace Jrd +{ + typedef FbApi::Status Status; +} + namespace Jrd { /* Blob id. A blob has two states -- temporary and permanent. In each @@ -139,7 +145,7 @@ struct bid // Your basic blob block. -class blb : public pool_alloc +class blb : public pool_alloc, public FbApi::Blob { public: blb(MemoryPool& pool, USHORT page_size) @@ -198,6 +204,17 @@ public: blb_buffer.free(); blb_has_buffer = false; } + +public: + virtual void release(); + virtual void getInfo(Status* status, + unsigned int itemsLength, const unsigned char* items, + unsigned int bufferLength, unsigned char* buffer); + virtual unsigned int getSegment(Status* status, unsigned int length, unsigned char* buffer); // returns real length + virtual void putSegment(Status* status, unsigned int length, const unsigned char* buffer); + virtual void cancel(Status* status); + virtual void close(Status* status); + virtual int seek(Status* status, int mode, int offset); // returns position }; const int BLB_temporary = 1; // Newly created blob diff --git a/src/jrd/blob_filter.cpp b/src/jrd/blob_filter.cpp index b3a1f45b32..ef064b459c 100644 --- a/src/jrd/blob_filter.cpp +++ b/src/jrd/blob_filter.cpp @@ -35,13 +35,13 @@ #include "../jrd/gdsassert.h" #include "../jrd/blf_proto.h" #include "../jrd/filte_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/inf_proto.h" #include "../jrd/intl_proto.h" #include "../jrd/err_proto.h" #include "../jrd/common.h" #include "../jrd/ibsetjmp.h" -#include "../jrd/isc_s_proto.h" +#include "../common/isc_s_proto.h" #include "gen/iberror.h" using namespace Jrd; @@ -71,7 +71,7 @@ static void open_blob(thread_db*, jrd_tra*, BlobControl**, bid*, USHORT, BlobFilter*); -void BLF_close_blob(thread_db* /*tdbb*/, BlobControl** filter_handle) +void BLF_close_blob(thread_db* tdbb, BlobControl** filter_handle) { /************************************** * @@ -147,7 +147,7 @@ void BLF_create_blob(thread_db* tdbb, } -ISC_STATUS BLF_get_segment(thread_db* /*tdbb*/, +ISC_STATUS BLF_get_segment(thread_db* tdbb, BlobControl** filter_handle, USHORT* length, USHORT buffer_length, @@ -258,7 +258,7 @@ void BLF_open_blob(thread_db* tdbb, } -void BLF_put_segment(thread_db* /*tdbb*/, +void BLF_put_segment(thread_db* tdbb, BlobControl** filter_handle, USHORT length, const UCHAR* buffer) @@ -305,7 +305,7 @@ void BLF_put_segment(thread_db* /*tdbb*/, // SEH moved to separate function to avoid conflicts // with destructor of BlobControl -inline void initializeFilter(thread_db* /*tdbb*/, +inline void initializeFilter(thread_db *tdbb, ISC_STATUS &status, BlobControl* control, BlobFilter* filter, diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index d1b1b4017a..4cb67de3b9 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -52,13 +52,12 @@ #include "../jrd/err_proto.h" #include "../jrd/evl_proto.h" #include "../jrd/exe_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/intl_proto.h" #include "../jrd/jrd_proto.h" #include "../jrd/lck_proto.h" #include "../jrd/met_proto.h" #include "../jrd/mov_proto.h" -#include "../jrd/dbg_proto.h" #include "../jrd/pag_proto.h" #include "../jrd/pcmet_proto.h" #include "../jrd/tra_proto.h" diff --git a/src/jrd/build_no.h b/src/jrd/build_no.h index a863a754d3..b5579394cd 100644 --- a/src/jrd/build_no.h +++ b/src/jrd/build_no.h @@ -3,16 +3,16 @@ *** DO NOT EDIT *** TO CHANGE ANY INFORMATION IN HERE PLEASE EDIT src/misc/writeBuildNum.sh - FORMAL BUILD NUMBER:28758 + FORMAL BUILD NUMBER:28715 */ -#define PRODUCT_VER_STRING "3.0.0.28758" -#define FILE_VER_STRING "WI-T3.0.0.28758" -#define LICENSE_VER_STRING "WI-T3.0.0.28758" -#define FILE_VER_NUMBER 3, 0, 0, 28758 +#define PRODUCT_VER_STRING "3.0.0.28715" +#define FILE_VER_STRING "WI-T3.0.0.28715" +#define LICENSE_VER_STRING "WI-T3.0.0.28715" +#define FILE_VER_NUMBER 3, 0, 0, 28715 #define FB_MAJOR_VER "3" #define FB_MINOR_VER "0" #define FB_REV_NO "0" -#define FB_BUILD_NO "28758" +#define FB_BUILD_NO "28715" #define FB_BUILD_TYPE "T" #define FB_BUILD_SUFFIX "Firebird 3.0 Unstable" diff --git a/src/jrd/builtin.cpp b/src/jrd/builtin.cpp index 625d9e528d..face6ce754 100644 --- a/src/jrd/builtin.cpp +++ b/src/jrd/builtin.cpp @@ -28,7 +28,7 @@ #include "../jrd/flu.h" #include "../jrd/common.h" #include "../jrd/flu_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" struct FN { diff --git a/src/jrd/cch.cpp b/src/jrd/cch.cpp index 1e2822a644..6393e0403c 100644 --- a/src/jrd/cch.cpp +++ b/src/jrd/cch.cpp @@ -47,9 +47,9 @@ #include "../jrd/gdsassert.h" #include "../jrd/cch_proto.h" #include "../jrd/err_proto.h" -#include "../jrd/gds_proto.h" -#include "../jrd/isc_proto.h" -#include "../jrd/isc_s_proto.h" +#include "../yvalve/gds_proto.h" +#include "../common/isc_proto.h" +#include "../common/isc_s_proto.h" #include "../jrd/jrd_proto.h" #include "../jrd/lck_proto.h" #include "../jrd/mov_proto.h" @@ -57,7 +57,7 @@ #include "../jrd/os/pio_proto.h" #include "../jrd/sdw_proto.h" #include "../jrd/shut_proto.h" -#include "../jrd/ThreadStart.h" +#include "../common/ThreadStart.h" #include "../jrd/thread_proto.h" #include "../jrd/tra_proto.h" #include "../common/config/config.h" @@ -206,7 +206,7 @@ static inline SharedLatch* allocSharedLatch(thread_db* tdbb, BufferDesc* bdb) } -static inline void freeSharedLatch(thread_db* /*tdbb*/, BufferControl* bcb, SharedLatch* latch) +static inline void freeSharedLatch(thread_db* tdbb, BufferControl* bcb, SharedLatch* latch) { latch->slt_bdb = NULL; QUE_DELETE(latch->slt_bdb_que); diff --git a/src/jrd/cmp.cpp b/src/jrd/cmp.cpp index acf4d6e0f7..9b670ded01 100644 --- a/src/jrd/cmp.cpp +++ b/src/jrd/cmp.cpp @@ -61,11 +61,11 @@ #include "../jrd/sort.h" #include "../jrd/gdsassert.h" #include "../jrd/cmp_proto.h" -#include "../jrd/dsc_proto.h" +#include "../common/dsc_proto.h" #include "../jrd/err_proto.h" #include "../jrd/exe_proto.h" #include "../jrd/fun_proto.h" -#include "../jrd/gds_proto.h" +#include "../yvalve/gds_proto.h" #include "../jrd/idx_proto.h" #include "../jrd/intl_proto.h" #include "../jrd/jrd_proto.h" @@ -75,8 +75,7 @@ #include "../jrd/par_proto.h" #include "../jrd/met_proto.h" #include "../jrd/mov_proto.h" -#include "../jrd/dsc_proto.h" -#include "../jrd/dbg_proto.h" // DBG_supervisor +#include "../common/dsc_proto.h" #include "../jrd/execute_statement.h" #include "../jrd/Optimizer.h" @@ -89,12 +88,11 @@ #include "../common/classes/auto.h" #include "../common/utils_proto.h" #include "../dsql/Nodes.h" -#include "../jrd/RecordSourceNodes.h" #include "../jrd/ValuesImpl.h" #include "../jrd/recsrc/RecordSource.h" #include "../jrd/recsrc/Cursor.h" #include "../jrd/Function.h" -#include "../dsql/BoolNodes.h" +#include "../jrd/misc_func_ids.h" #include "../dsql/ExprNodes.h" #include "../dsql/StmtNodes.h" @@ -102,6 +100,23 @@ using namespace Jrd; using namespace Firebird; +// Firebird provides transparent conversion from string to date in +// contexts where it makes sense. This macro checks a descriptor to +// see if it is something that *could* represent a date value + +inline bool COULD_BE_DATE(const dsc desc) +{ + return ((DTYPE_IS_DATE(desc.dsc_dtype)) || (desc.dsc_dtype <= dtype_any_text)); +} + +// One of d1,d2 is time, the other is date +inline bool IS_DATE_AND_TIME(const dsc d1, const dsc d2) +{ + return (((d1.dsc_dtype == dtype_sql_time) && (d2.dsc_dtype == dtype_sql_date)) || + ((d2.dsc_dtype == dtype_sql_time) && (d1.dsc_dtype == dtype_sql_date))); +} + + namespace { // Node copier for views. @@ -156,20 +171,58 @@ namespace private: USHORT fldId; }; + + // Copy sub expressions (including subqueries). + class SubExprNodeCopier : public NodeCopier + { + public: + explicit SubExprNodeCopier(CompilerScratch* aCsb) + : NodeCopier(aCsb, localMap) + { + // Initialize the map so all streams initially resolve to the original number. As soon + // copy creates new streams, the map are being overwritten. + for (unsigned i = 0; i < JrdStatement::MAP_LENGTH; ++i) + localMap[i] = i; + } + + static jrd_nod* copy(thread_db* tdbb, CompilerScratch* csb, jrd_nod* input) + { + SubExprNodeCopier obj(csb); + return static_cast(obj).copy(tdbb, input); + } + + private: + UCHAR localMap[JrdStatement::MAP_LENGTH]; + }; } // namespace +static UCHAR* alloc_map(thread_db*, CompilerScratch*, USHORT); static jrd_nod* catenate_nodes(thread_db*, NodeStack&); +static jrd_nod* convertNeqAllToNotAny(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node); static void expand_view_nodes(thread_db*, CompilerScratch*, USHORT, NodeStack&, nod_t, bool); +static void ignore_dbkey(thread_db*, CompilerScratch*, RecordSelExpr*, const jrd_rel*); static jrd_nod* make_defaults(thread_db*, CompilerScratch*, USHORT, jrd_nod*); static jrd_nod* make_validation(thread_db*, CompilerScratch*, USHORT); static void mark_variant(CompilerScratch* csb, USHORT stream); static void pass1_erase(thread_db*, CompilerScratch*, jrd_nod*); static jrd_nod* pass1_expand_view(thread_db*, CompilerScratch*, USHORT, USHORT, bool); static void pass1_modify(thread_db*, CompilerScratch*, jrd_nod*); +static RecordSelExpr* pass1_rse(thread_db*, CompilerScratch*, RecordSelExpr*); +static void pass1_source(thread_db*, CompilerScratch*, RecordSelExpr*, jrd_nod*, jrd_nod**, NodeStack&); static bool pass1_store(thread_db*, CompilerScratch*, jrd_nod*); -static RelationSourceNode* pass1_update(thread_db*, CompilerScratch*, jrd_rel*, const trig_vec*, USHORT, USHORT, +static jrd_nod* pass1_update(thread_db*, CompilerScratch*, jrd_rel*, const trig_vec*, USHORT, USHORT, SecurityClass::flags_t, jrd_rel*, USHORT); +static void pass2_rse(thread_db*, CompilerScratch*, RecordSelExpr*); +static jrd_nod* pass2_union(thread_db*, CompilerScratch*, jrd_nod*); +static jrd_nod* pass2_validation(thread_db*, CompilerScratch*, const Item&); +static void plan_check(const CompilerScratch*, const RecordSelExpr*); +static void plan_set(CompilerScratch*, RecordSelExpr*, jrd_nod*); +static void post_procedure_access(thread_db*, CompilerScratch*, jrd_prc*); +static RecordSource* post_rse(thread_db*, CompilerScratch*, RecordSelExpr*); static void post_trigger_access(CompilerScratch*, jrd_rel*, ExternalAccess::exa_act, jrd_rel*); +static void process_map(thread_db*, CompilerScratch*, jrd_nod*, Format**); +static SSHORT strcmp_space(const char*, const char*); +static bool stream_in_rse(const USHORT, const RecordSelExpr*); #ifdef CMP_DEBUG #include @@ -198,18 +251,27 @@ jrd_nod* CMP_clone_node(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node) } -// Clone a value node for the optimizer. -// Make a copy of the node (if necessary) and assign impure space. - jrd_nod* CMP_clone_node_opt(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node) { +/************************************** + * + * C M P _ c l o n e _ n o d e _ o p t + * + ************************************** + * + * Functional description + * Clone a value node for the optimizer. Make a copy of the node + * (if necessary) and assign impure space. + * + **************************************/ SET_TDBB(tdbb); DEV_BLKCHK(csb, type_csb); DEV_BLKCHK(node, type_nod); - if (ExprNode::is(node)) + if (node->nod_type == nod_argument) { return node; + } jrd_nod* clone = NodeCopier::copy(tdbb, csb, node, NULL); CMP_pass2(tdbb, csb, clone, 0); @@ -217,20 +279,6 @@ jrd_nod* CMP_clone_node_opt(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node return clone; } -BoolExprNode* CMP_clone_node_opt(thread_db* tdbb, CompilerScratch* csb, BoolExprNode* node) -{ - SET_TDBB(tdbb); - - DEV_BLKCHK(csb, type_csb); - - NodeCopier copier(csb, NULL); - BoolExprNode* clone = node->copy(tdbb, copier); - - clone->pass2(tdbb, csb); - - return clone; -} - jrd_req* CMP_compile2(thread_db* tdbb, const UCHAR* blr, ULONG blr_length, bool internal_flag, USHORT dbginfo_length, const UCHAR* dbginfo) @@ -357,7 +405,7 @@ void CMP_fini(thread_db* tdbb) } -const Format* CMP_format(thread_db* tdbb, CompilerScratch* csb, USHORT stream) +Format* CMP_format(thread_db* tdbb, CompilerScratch* csb, USHORT stream) { /************************************** * @@ -485,6 +533,7 @@ void CMP_get_desc(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node, DSC* des case nod_prot_mask: case nod_null: case nod_count: + case nod_gen_id: case nod_lock_state: desc->dsc_dtype = dtype_long; desc->dsc_length = sizeof(SLONG); @@ -548,15 +597,26 @@ void CMP_get_desc(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node, DSC* des return; } - case nod_average: - CMP_get_desc(tdbb, csb, node->nod_arg[e_stat_value], desc); - - if (!(DTYPE_IS_NUMERIC(desc->dsc_dtype) || DTYPE_IS_TEXT(desc->dsc_dtype))) + case nod_divide: { - if (desc->dsc_dtype != dtype_unknown) - break; + DSC desc1, desc2; + CMP_get_desc(tdbb, csb, node->nod_arg[0], &desc1); + CMP_get_desc(tdbb, csb, node->nod_arg[1], &desc2); + // for compatibility with older versions of the product, we accept + // text types for division in blr_version4 (dialect <= 1) only + if (!(DTYPE_IS_NUMERIC(desc1.dsc_dtype) || DTYPE_IS_TEXT(desc1.dsc_dtype))) + { + if (desc1.dsc_dtype != dtype_unknown) { + break; // error, dtype not supported by arithmetic + } + } + if (!(DTYPE_IS_NUMERIC(desc2.dsc_dtype) || DTYPE_IS_TEXT(desc2.dsc_dtype))) + { + if (desc2.dsc_dtype != dtype_unknown) { + break; // error, dtype not supported by arithmetic + } + } } - desc->dsc_dtype = DEFAULT_DOUBLE; desc->dsc_length = sizeof(double); desc->dsc_scale = 0; @@ -564,13 +624,569 @@ void CMP_get_desc(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node, DSC* des desc->dsc_flags = 0; return; + case nod_average: + if (node->nod_type == nod_average) { + CMP_get_desc(tdbb, csb, node->nod_arg[e_stat_value], desc); + } + if (!(DTYPE_IS_NUMERIC(desc->dsc_dtype) || DTYPE_IS_TEXT(desc->dsc_dtype))) + { + if (desc->dsc_dtype != dtype_unknown) { + break; + } + } + desc->dsc_dtype = DEFAULT_DOUBLE; + desc->dsc_length = sizeof(double); + desc->dsc_scale = 0; + desc->dsc_sub_type = 0; + desc->dsc_flags = 0; + return; + + case nod_add: + case nod_subtract: + { + DSC desc1, desc2; + + CMP_get_desc(tdbb, csb, node->nod_arg[0], &desc1); + CMP_get_desc(tdbb, csb, node->nod_arg[1], &desc2); + + /* 92/05/29 DAVES - don't understand why this is done for ONLY + dtype_text (eg: not dtype_cstring or dtype_varying) Doesn't + appear to hurt. + + 94/04/04 DAVES - NOW I understand it! QLI will pass floating + point values to the engine as text. All other numeric constants + it turns into either integers or longs (with scale). */ + + USHORT dtype1 = desc1.dsc_dtype; + if (dtype_int64 == dtype1) { + dtype1 = dtype_double; + } + USHORT dtype2 = desc2.dsc_dtype; + if (dtype_int64 == dtype2) { + dtype2 = dtype_double; + } + + if (dtype1 == dtype_text || dtype2 == dtype_text) { + dtype = MAX(MAX(dtype1, dtype2), (UCHAR) DEFAULT_DOUBLE); + } + else { + dtype = MAX(dtype1, dtype2); + } + + switch (dtype) + { + case dtype_short: + desc->dsc_dtype = dtype_long; + desc->dsc_length = sizeof(SLONG); + if (DTYPE_IS_TEXT(desc1.dsc_dtype) || DTYPE_IS_TEXT(desc2.dsc_dtype)) + { + desc->dsc_scale = 0; + } + else { + desc->dsc_scale = MIN(desc1.dsc_scale, desc2.dsc_scale); + } + node->nod_scale = desc->dsc_scale; + desc->dsc_sub_type = 0; + desc->dsc_flags = 0; + return; + + case dtype_sql_date: + case dtype_sql_time: + if (DTYPE_IS_TEXT(desc1.dsc_dtype) || DTYPE_IS_TEXT(desc2.dsc_dtype)) + { + ERR_post(Arg::Gds(isc_expression_eval_err)); + } + // FALL INTO + + case dtype_timestamp: + node->nod_flags |= nod_date; + + fb_assert(DTYPE_IS_DATE(desc1.dsc_dtype) || DTYPE_IS_DATE(desc2.dsc_dtype)); + + if (COULD_BE_DATE(desc1) && COULD_BE_DATE(desc2)) + { + if (node->nod_type == nod_subtract) + { + // - + + /* Legal permutations are: + - + - + - + - +