summaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc
diff options
context:
space:
mode:
authorCVS to git conversion script <webmaster@postgresql.org>2002-06-20 20:29:55 +0000
committerCVS to git conversion script <webmaster@postgresql.org>2002-06-20 20:29:55 +0000
commit05dedace84ef8c93fea5309c3ac55f889011429b (patch)
tree4c7f513afbbc03060039a165d1770e11be711773 /src/interfaces/jdbc
parentd84fe82230c593f3dc5d7f427849b99d1efa8a0a (diff)
This commit was manufactured by cvs2git to create branch 'ecpg_big_bison'.
Sprout from master 2002-06-20 20:29:54 UTC Bruce Momjian <bruce@momjian.us> 'Update copyright to 2002.' Delete: COPYRIGHT GNUmakefile.in HISTORY INSTALL Makefile README aclocal.m4 config/ac_func_accept_argtypes.m4 config/c-compiler.m4 config/c-library.m4 config/config.guess config/config.sub config/cxx.m4 config/docbook.m4 config/general.m4 config/install-sh config/java.m4 config/libtool.m4 config/missing config/mkinstalldirs config/perl.m4 config/prep_buildtree config/programs.m4 config/python.m4 config/tcl.m4 configure configure.in contrib/Makefile contrib/README contrib/array/Makefile contrib/array/README.array_iterator contrib/array/array_iterator.c contrib/array/array_iterator.h contrib/array/array_iterator.sql.in contrib/btree_gist/Makefile contrib/btree_gist/README.btree_gist contrib/btree_gist/btree_gist.c contrib/btree_gist/btree_gist.sql.in contrib/btree_gist/data/test_btree.data contrib/btree_gist/data/test_btree_ts.data contrib/btree_gist/expected/btree_gist.out contrib/btree_gist/sql/btree_gist.sql contrib/chkpass/Makefile contrib/chkpass/README.chkpass contrib/chkpass/chkpass.c contrib/chkpass/chkpass.sql.in contrib/contrib-global.mk contrib/cube/Makefile contrib/cube/README.cube contrib/cube/buffer.c contrib/cube/buffer.h contrib/cube/cube.c contrib/cube/cube.sql.in contrib/cube/cubedata.h contrib/cube/cubeparse.y contrib/cube/cubescan.l contrib/cube/data/test_cube.data contrib/cube/expected/cube.out contrib/cube/sql/cube.sql contrib/dbase/Makefile contrib/dbase/README.dbf2pg contrib/dbase/dbf.c contrib/dbase/dbf.h contrib/dbase/dbf2pg.1 contrib/dbase/dbf2pg.c contrib/dbase/endian.c contrib/dblink/Makefile contrib/dblink/README.dblink contrib/dblink/dblink.c contrib/dblink/dblink.h contrib/dblink/dblink.sql.in contrib/dbsize/Makefile contrib/dbsize/README.dbsize contrib/dbsize/dbsize.c contrib/dbsize/dbsize.sql.in contrib/earthdistance/Makefile contrib/earthdistance/README.earthdistance contrib/earthdistance/earthdistance.c contrib/earthdistance/earthdistance.sql.in contrib/findoidjoins/Makefile contrib/findoidjoins/README.findoidjoins contrib/findoidjoins/findoidjoins.c contrib/findoidjoins/make_oidjoins_check contrib/fulltextindex/Makefile contrib/fulltextindex/README.fti contrib/fulltextindex/TODO contrib/fulltextindex/fti.c contrib/fulltextindex/fti.pl contrib/fulltextindex/fti.sql.in contrib/fulltextindex/timings.sh contrib/fuzzystrmatch/Makefile contrib/fuzzystrmatch/README.fuzzystrmatch contrib/fuzzystrmatch/README.soundex contrib/fuzzystrmatch/fuzzystrmatch.c contrib/fuzzystrmatch/fuzzystrmatch.h contrib/fuzzystrmatch/fuzzystrmatch.sql.in contrib/intagg/Makefile contrib/intagg/README.int_aggregate contrib/intagg/int_aggregate.c contrib/intagg/int_aggregate.sql.in contrib/intarray/Makefile contrib/intarray/README.intarray contrib/intarray/_int.c contrib/intarray/_int.sql.in contrib/intarray/bench/bench.pl contrib/intarray/bench/create_test.pl contrib/intarray/data/test__int.data contrib/intarray/expected/_int.out contrib/intarray/sql/_int.sql contrib/ipc_check/README contrib/ipc_check/ipc_check.pl contrib/isbn_issn/Makefile contrib/isbn_issn/README.isbn_issn contrib/isbn_issn/isbn_issn.c contrib/isbn_issn/isbn_issn.sql.in contrib/lo/Makefile contrib/lo/README.lo contrib/lo/lo.c contrib/lo/lo.sql.in contrib/lo/lo_drop.sql contrib/lo/lo_test.sql contrib/mSQL-interface/Makefile contrib/mSQL-interface/README.mpgsql contrib/mSQL-interface/mpgsql.c contrib/mac/README.mac contrib/mac/createoui contrib/mac/dropoui contrib/mac/ouiparse.awk contrib/mac/updateoui contrib/miscutil/Makefile contrib/miscutil/README.misc_utils contrib/miscutil/misc_utils.c contrib/miscutil/misc_utils.h contrib/miscutil/misc_utils.sql.in contrib/mysql/README contrib/mysql/my2pg.pl contrib/mysql/mysql2pgsql contrib/noupdate/Makefile contrib/noupdate/README.noup contrib/noupdate/noup.c contrib/noupdate/noup.sql.in contrib/oid2name/Makefile contrib/oid2name/README.oid2name contrib/oid2name/oid2name.c contrib/oracle/CHANGES contrib/oracle/Ora2Pg.pm contrib/oracle/README.ora2pg contrib/oracle/TODO contrib/oracle/ora2pg.html contrib/oracle/ora2pg.pl contrib/pg_controldata/Makefile contrib/pg_controldata/README.pg_controldata contrib/pg_controldata/pg_controldata.c contrib/pg_dumplo/Makefile contrib/pg_dumplo/README.pg_dumplo contrib/pg_dumplo/lo_export.c contrib/pg_dumplo/lo_import.c contrib/pg_dumplo/main.c contrib/pg_dumplo/pg_dumplo.h contrib/pg_dumplo/utils.c contrib/pg_logger/Makefile contrib/pg_logger/README.pg_logger contrib/pg_logger/pg_logger.c contrib/pg_resetxlog/Makefile contrib/pg_resetxlog/README.pg_resetxlog contrib/pg_resetxlog/pg_resetxlog.c contrib/pg_upgrade/README contrib/pg_upgrade/pg_upgrade contrib/pg_upgrade/pg_upgrade.1 contrib/pgbench/Makefile contrib/pgbench/README.pgbench contrib/pgbench/README.pgbench_jis contrib/pgbench/pgbench.c contrib/pgcrypto/API contrib/pgcrypto/Makefile contrib/pgcrypto/README.pgcrypto contrib/pgcrypto/blf.c contrib/pgcrypto/blf.h contrib/pgcrypto/crypt-blowfish.c contrib/pgcrypto/crypt-des.c contrib/pgcrypto/crypt-gensalt.c contrib/pgcrypto/crypt-md5.c contrib/pgcrypto/expected/blowfish.out contrib/pgcrypto/expected/crypt-blowfish.out contrib/pgcrypto/expected/crypt-des.out contrib/pgcrypto/expected/crypt-md5.out contrib/pgcrypto/expected/crypt-xdes.out contrib/pgcrypto/expected/hmac-md5.out contrib/pgcrypto/expected/hmac-sha1.out contrib/pgcrypto/expected/init.out contrib/pgcrypto/expected/md5.out contrib/pgcrypto/expected/rijndael.out contrib/pgcrypto/expected/sha1.out contrib/pgcrypto/internal.c contrib/pgcrypto/md5.c contrib/pgcrypto/md5.h contrib/pgcrypto/mhash.c contrib/pgcrypto/misc.c contrib/pgcrypto/openssl.c contrib/pgcrypto/pgcrypto.c contrib/pgcrypto/pgcrypto.h contrib/pgcrypto/pgcrypto.sql.in contrib/pgcrypto/px-crypt.c contrib/pgcrypto/px-crypt.h contrib/pgcrypto/px-hmac.c contrib/pgcrypto/px.c contrib/pgcrypto/px.h contrib/pgcrypto/random.c contrib/pgcrypto/rijndael.c contrib/pgcrypto/rijndael.h contrib/pgcrypto/rijndael.tbl contrib/pgcrypto/sha1.c contrib/pgcrypto/sha1.h contrib/pgcrypto/sql/blowfish.sql contrib/pgcrypto/sql/crypt-blowfish.sql contrib/pgcrypto/sql/crypt-des.sql contrib/pgcrypto/sql/crypt-md5.sql contrib/pgcrypto/sql/crypt-xdes.sql contrib/pgcrypto/sql/hmac-md5.sql contrib/pgcrypto/sql/hmac-sha1.sql contrib/pgcrypto/sql/init.sql contrib/pgcrypto/sql/md5.sql contrib/pgcrypto/sql/rijndael.sql contrib/pgcrypto/sql/sha1.sql contrib/pgstattuple/Makefile contrib/pgstattuple/README.pgstattuple contrib/pgstattuple/README.pgstattuple.euc_jp contrib/pgstattuple/pgstattuple.c contrib/pgstattuple/pgstattuple.sql.in contrib/retep/CHANGELOG contrib/retep/Implementation contrib/retep/Makefile contrib/retep/README contrib/retep/build.xml contrib/retep/data/cds.dtd contrib/retep/data/cds.xml contrib/retep/retep.jpx contrib/retep/uk/org/retep/dtu/DCollection.java contrib/retep/uk/org/retep/dtu/DConstants.java contrib/retep/uk/org/retep/dtu/DElement.java contrib/retep/uk/org/retep/dtu/DEnvironment.java contrib/retep/uk/org/retep/dtu/DModule.java contrib/retep/uk/org/retep/dtu/DModuleXML.java contrib/retep/uk/org/retep/dtu/DNode.java contrib/retep/uk/org/retep/dtu/DProcessor.java contrib/retep/uk/org/retep/dtu/DTransform.java contrib/retep/uk/org/retep/tools/Tool.java contrib/retep/uk/org/retep/tools.properties contrib/retep/uk/org/retep/util/ExceptionDialog.java contrib/retep/uk/org/retep/util/Globals.java contrib/retep/uk/org/retep/util/Logger.java contrib/retep/uk/org/retep/util/Main.java contrib/retep/uk/org/retep/util/StandaloneApp.java contrib/retep/uk/org/retep/util/hba/Editor.java contrib/retep/uk/org/retep/util/hba/Main.java contrib/retep/uk/org/retep/util/hba/Record.java contrib/retep/uk/org/retep/util/misc/IPAddress.java contrib/retep/uk/org/retep/util/misc/PropertiesIO.java contrib/retep/uk/org/retep/util/misc/WStringTokenizer.java contrib/retep/uk/org/retep/util/models/HBATableModel.java contrib/retep/uk/org/retep/util/models/PropertiesTableModel.java contrib/retep/uk/org/retep/util/proped/Main.java contrib/retep/uk/org/retep/util/proped/PropertyEditor.java contrib/retep/uk/org/retep/xml/core/XMLFactory.java contrib/retep/uk/org/retep/xml/core/XMLFactoryException.java contrib/retep/uk/org/retep/xml/jdbc/XMLDatabase.java contrib/retep/uk/org/retep/xml/jdbc/XMLResultSet.java contrib/retep/uk/org/retep/xml/parser/TagHandler.java contrib/retep/uk/org/retep/xml/parser/TagListener.java contrib/retep/uk/org/retep/xml/test/XMLExport.java contrib/rserv/ApplySnapshot.in contrib/rserv/CleanLog.in contrib/rserv/GetSyncID.in contrib/rserv/InitRservTest.in contrib/rserv/Makefile contrib/rserv/MasterAddTable.in contrib/rserv/MasterInit.in contrib/rserv/MasterSync.in contrib/rserv/PrepareSnapshot.in contrib/rserv/README.rserv contrib/rserv/RServ.pm contrib/rserv/Replicate.in contrib/rserv/RservTest.in contrib/rserv/SlaveAddTable.in contrib/rserv/SlaveInit.in contrib/rserv/master.sql.in contrib/rserv/regress.sh contrib/rserv/rserv.c contrib/rserv/slave.sql.in contrib/rtree_gist/Makefile contrib/rtree_gist/README.rtree_gist contrib/rtree_gist/bench/bench.pl contrib/rtree_gist/bench/create_test.pl contrib/rtree_gist/data/test_box.data contrib/rtree_gist/expected/rtree_gist.out contrib/rtree_gist/rtree_gist.c contrib/rtree_gist/rtree_gist.sql.in contrib/rtree_gist/sql/rtree_gist.sql contrib/seg/Makefile contrib/seg/README.seg contrib/seg/buffer.c contrib/seg/buffer.h contrib/seg/data/test_seg.data contrib/seg/expected/seg.out contrib/seg/seg-validate.pl contrib/seg/seg.c contrib/seg/seg.sql.in contrib/seg/segdata.h contrib/seg/segparse.y contrib/seg/segscan.l contrib/seg/sort-segments.pl contrib/seg/sql/seg.sql contrib/spi/Makefile contrib/spi/README.spi contrib/spi/autoinc.c contrib/spi/autoinc.example contrib/spi/autoinc.sql.in contrib/spi/insert_username.c contrib/spi/insert_username.example contrib/spi/insert_username.sql.in contrib/spi/moddatetime.c contrib/spi/moddatetime.example contrib/spi/moddatetime.sql.in contrib/spi/preprocessor/README.MAX contrib/spi/preprocessor/example.sql contrib/spi/preprocessor/step1.c contrib/spi/preprocessor/step1.e contrib/spi/preprocessor/step2.pl contrib/spi/refint.c contrib/spi/refint.example contrib/spi/refint.sql.in contrib/spi/timetravel.c contrib/spi/timetravel.example contrib/spi/timetravel.sql.in contrib/start-scripts/freebsd contrib/start-scripts/linux contrib/string/Makefile contrib/string/README.string_io contrib/string/string_io.c contrib/string/string_io.h contrib/string/string_io.sql.in contrib/tips/Makefile contrib/tips/README.apachelog contrib/tools/add-emacs-variables contrib/tools/find-sources contrib/tools/make-tags contrib/tsearch/Makefile contrib/tsearch/README.tsearch contrib/tsearch/crc32.c contrib/tsearch/crc32.h contrib/tsearch/data/test_tsearch.data contrib/tsearch/deflex.h contrib/tsearch/dict/porter_english.dct contrib/tsearch/dict/russian_stemming.dct contrib/tsearch/dict.h contrib/tsearch/expected/tsearch.out contrib/tsearch/gistidx.c contrib/tsearch/gistidx.h contrib/tsearch/makedict/makedict.pl contrib/tsearch/morph.c contrib/tsearch/morph.h contrib/tsearch/parser.h contrib/tsearch/parser.l contrib/tsearch/query.c contrib/tsearch/query.h contrib/tsearch/rewrite.c contrib/tsearch/rewrite.h contrib/tsearch/sql/tsearch.sql contrib/tsearch/tsearch.sql.in contrib/tsearch/txtidx.c contrib/tsearch/txtidx.h contrib/userlock/Makefile contrib/userlock/README.user_locks contrib/userlock/user_locks.c contrib/userlock/user_locks.h contrib/userlock/user_locks.sql.in contrib/vacuumlo/Makefile contrib/vacuumlo/README.vacuumlo contrib/vacuumlo/vacuumlo.c contrib/xml/Makefile contrib/xml/README contrib/xml/TODO contrib/xml/pgxml.c contrib/xml/pgxml.h contrib/xml/pgxml.source contrib/xml/pgxml_dom.c contrib/xml/pgxml_dom.source doc/FAQ doc/FAQ_AIX doc/FAQ_DEV doc/FAQ_HPUX doc/FAQ_IRIX doc/FAQ_MSWIN doc/FAQ_QNX4 doc/FAQ_SCO doc/FAQ_Solaris doc/FAQ_german doc/FAQ_japanese doc/FAQ_polish doc/FAQ_russian doc/KNOWN_BUGS doc/MISSING_FEATURES doc/Makefile doc/README.mb.big5 doc/README.mb.jp doc/TODO doc/TODO.detail/README doc/TODO.detail/atttypmod doc/TODO.detail/crossdb doc/TODO.detail/cursor doc/TODO.detail/drop doc/TODO.detail/exists doc/TODO.detail/foreign doc/TODO.detail/fsync doc/TODO.detail/inheritance doc/TODO.detail/java doc/TODO.detail/mmap doc/TODO.detail/namedatalen doc/TODO.detail/optimizer doc/TODO.detail/performance doc/TODO.detail/persistent doc/TODO.detail/pool doc/TODO.detail/prepare doc/TODO.detail/privileges doc/TODO.detail/replication doc/TODO.detail/schema doc/TODO.detail/tablespaces doc/TODO.detail/thread doc/TODO.detail/transactions doc/TODO.detail/typeconv doc/TODO.detail/update doc/TODO.detail/vacuum doc/TODO.detail/view doc/TODO.detail/win32 doc/TODO.detail/yacc doc/bug.template doc/src/FAQ/FAQ.html doc/src/FAQ/FAQ_DEV.html doc/src/FAQ/FAQ_german.html doc/src/FAQ/FAQ_japanese.html doc/src/FAQ/FAQ_polish.html doc/src/FAQ/FAQ_russian.html doc/src/Makefile doc/src/graphics/catalogs.ag doc/src/graphics/catalogs.cgm doc/src/graphics/catalogs.gif doc/src/graphics/catalogs.ps doc/src/graphics/clientserver.ag doc/src/graphics/clientserver.gif doc/src/graphics/connections.ag doc/src/graphics/connections.gif doc/src/sgml/Makefile doc/src/sgml/admin.sgml doc/src/sgml/advanced.sgml doc/src/sgml/arch-dev.sgml doc/src/sgml/arch-pg.sgml doc/src/sgml/array.sgml doc/src/sgml/backup.sgml doc/src/sgml/biblio.sgml doc/src/sgml/bki.sgml doc/src/sgml/book-decl.sgml doc/src/sgml/catalogs.sgml doc/src/sgml/charset.sgml doc/src/sgml/client-auth.sgml doc/src/sgml/compiler.sgml doc/src/sgml/contacts.sgml doc/src/sgml/cvs.sgml doc/src/sgml/datatype.sgml doc/src/sgml/datetime.sgml doc/src/sgml/developer.sgml doc/src/sgml/dfunc.sgml doc/src/sgml/diskusage.sgml doc/src/sgml/docguide.sgml doc/src/sgml/ecpg.sgml doc/src/sgml/extend.sgml doc/src/sgml/features.sgml doc/src/sgml/filelist.sgml doc/src/sgml/fixrtf doc/src/sgml/func-ref.sgml doc/src/sgml/func.sgml doc/src/sgml/geqo.sgml doc/src/sgml/gist.sgml doc/src/sgml/history.sgml doc/src/sgml/indexcost.sgml doc/src/sgml/indices.sgml doc/src/sgml/info.sgml doc/src/sgml/inherit.sgml doc/src/sgml/install-win32.sgml doc/src/sgml/installation.sgml doc/src/sgml/intro.sgml doc/src/sgml/jdbc.sgml doc/src/sgml/keywords.sgml doc/src/sgml/legal.sgml doc/src/sgml/libpgeasy.sgml doc/src/sgml/libpgtcl.sgml doc/src/sgml/libpq++.sgml doc/src/sgml/libpq.sgml doc/src/sgml/lobj.sgml doc/src/sgml/maintenance.sgml doc/src/sgml/manage-ag.sgml doc/src/sgml/manage.sgml doc/src/sgml/monitoring.sgml doc/src/sgml/mvcc.sgml doc/src/sgml/nls.sgml doc/src/sgml/notation.sgml doc/src/sgml/odbc.sgml doc/src/sgml/page.sgml doc/src/sgml/perform.sgml doc/src/sgml/plperl.sgml doc/src/sgml/plpython.sgml doc/src/sgml/plsql.sgml doc/src/sgml/pltcl.sgml doc/src/sgml/postgres.sgml doc/src/sgml/problems.sgml doc/src/sgml/programmer.sgml doc/src/sgml/protocol.sgml doc/src/sgml/pygresql.sgml doc/src/sgml/queries.sgml doc/src/sgml/query.sgml doc/src/sgml/recovery.sgml doc/src/sgml/ref/abort.sgml doc/src/sgml/ref/allfiles.sgml doc/src/sgml/ref/alter_database.sgml doc/src/sgml/ref/alter_group.sgml doc/src/sgml/ref/alter_table.sgml doc/src/sgml/ref/alter_trigger.sgml doc/src/sgml/ref/alter_user.sgml doc/src/sgml/ref/analyze.sgml doc/src/sgml/ref/begin.sgml doc/src/sgml/ref/checkpoint.sgml doc/src/sgml/ref/close.sgml doc/src/sgml/ref/cluster.sgml doc/src/sgml/ref/comment.sgml doc/src/sgml/ref/commit.sgml doc/src/sgml/ref/copy.sgml doc/src/sgml/ref/create_aggregate.sgml doc/src/sgml/ref/create_constraint.sgml doc/src/sgml/ref/create_database.sgml doc/src/sgml/ref/create_domain.sgml doc/src/sgml/ref/create_function.sgml doc/src/sgml/ref/create_group.sgml doc/src/sgml/ref/create_index.sgml doc/src/sgml/ref/create_language.sgml doc/src/sgml/ref/create_operator.sgml doc/src/sgml/ref/create_rule.sgml doc/src/sgml/ref/create_schema.sgml doc/src/sgml/ref/create_sequence.sgml doc/src/sgml/ref/create_table.sgml doc/src/sgml/ref/create_table_as.sgml doc/src/sgml/ref/create_trigger.sgml doc/src/sgml/ref/create_type.sgml doc/src/sgml/ref/create_user.sgml doc/src/sgml/ref/create_view.sgml doc/src/sgml/ref/createdb.sgml doc/src/sgml/ref/createlang.sgml doc/src/sgml/ref/createuser.sgml doc/src/sgml/ref/current_date.sgml doc/src/sgml/ref/current_time.sgml doc/src/sgml/ref/current_timestamp.sgml doc/src/sgml/ref/current_user.sgml doc/src/sgml/ref/declare.sgml doc/src/sgml/ref/delete.sgml doc/src/sgml/ref/drop_aggregate.sgml doc/src/sgml/ref/drop_database.sgml doc/src/sgml/ref/drop_domain.sgml doc/src/sgml/ref/drop_function.sgml doc/src/sgml/ref/drop_group.sgml doc/src/sgml/ref/drop_index.sgml doc/src/sgml/ref/drop_language.sgml doc/src/sgml/ref/drop_operator.sgml doc/src/sgml/ref/drop_rule.sgml doc/src/sgml/ref/drop_sequence.sgml doc/src/sgml/ref/drop_table.sgml doc/src/sgml/ref/drop_trigger.sgml doc/src/sgml/ref/drop_type.sgml doc/src/sgml/ref/drop_user.sgml doc/src/sgml/ref/drop_view.sgml doc/src/sgml/ref/dropdb.sgml doc/src/sgml/ref/droplang.sgml doc/src/sgml/ref/dropuser.sgml doc/src/sgml/ref/ecpg-ref.sgml doc/src/sgml/ref/end.sgml doc/src/sgml/ref/explain.sgml doc/src/sgml/ref/fetch.sgml doc/src/sgml/ref/grant.sgml doc/src/sgml/ref/initdb.sgml doc/src/sgml/ref/initlocation.sgml doc/src/sgml/ref/insert.sgml doc/src/sgml/ref/ipcclean.sgml doc/src/sgml/ref/listen.sgml doc/src/sgml/ref/load.sgml doc/src/sgml/ref/lock.sgml doc/src/sgml/ref/move.sgml doc/src/sgml/ref/notify.sgml doc/src/sgml/ref/pg_config-ref.sgml doc/src/sgml/ref/pg_ctl-ref.sgml doc/src/sgml/ref/pg_dump.sgml doc/src/sgml/ref/pg_dumpall.sgml doc/src/sgml/ref/pg_restore.sgml doc/src/sgml/ref/pgaccess-ref.sgml doc/src/sgml/ref/pgtclsh.sgml doc/src/sgml/ref/pgtksh.sgml doc/src/sgml/ref/postgres-ref.sgml doc/src/sgml/ref/postmaster.sgml doc/src/sgml/ref/psql-ref.sgml doc/src/sgml/ref/reindex.sgml doc/src/sgml/ref/reset.sgml doc/src/sgml/ref/revoke.sgml doc/src/sgml/ref/rollback.sgml doc/src/sgml/ref/select.sgml doc/src/sgml/ref/select_into.sgml doc/src/sgml/ref/set.sgml doc/src/sgml/ref/set_constraints.sgml doc/src/sgml/ref/set_session_auth.sgml doc/src/sgml/ref/set_transaction.sgml doc/src/sgml/ref/show.sgml doc/src/sgml/ref/truncate.sgml doc/src/sgml/ref/unlisten.sgml doc/src/sgml/ref/update.sgml doc/src/sgml/ref/vacuum.sgml doc/src/sgml/ref/vacuumdb.sgml doc/src/sgml/refentry.sgml doc/src/sgml/reference.ced doc/src/sgml/reference.sgml doc/src/sgml/regress.sgml doc/src/sgml/release.sgml doc/src/sgml/rules.sgml doc/src/sgml/runtime.sgml doc/src/sgml/sources.sgml doc/src/sgml/spi.sgml doc/src/sgml/sql.sgml doc/src/sgml/standalone-install.sgml doc/src/sgml/start.sgml doc/src/sgml/stylesheet.css doc/src/sgml/stylesheet.dsl doc/src/sgml/syntax.sgml doc/src/sgml/trigger.sgml doc/src/sgml/tutorial.sgml doc/src/sgml/typeconv.sgml doc/src/sgml/user-manag.sgml doc/src/sgml/user.sgml doc/src/sgml/version.sgml doc/src/sgml/wal.sgml doc/src/sgml/xaggr.sgml doc/src/sgml/xfunc.sgml doc/src/sgml/xindex.sgml doc/src/sgml/xoper.sgml doc/src/sgml/xplang.sgml doc/src/sgml/xtypes.sgml doc/src/sgml/y2k.sgml register.txt src/DEVELOPERS src/Makefile src/Makefile.global.in src/Makefile.shlib src/backend/Makefile src/backend/access/Makefile src/backend/access/common/Makefile src/backend/access/common/heaptuple.c src/backend/access/common/indextuple.c src/backend/access/common/indexvalid.c src/backend/access/common/printtup.c src/backend/access/common/scankey.c src/backend/access/common/tupdesc.c src/backend/access/gist/Makefile src/backend/access/gist/gist.c src/backend/access/gist/gistget.c src/backend/access/gist/gistscan.c src/backend/access/gist/giststrat.c src/backend/access/hash/Makefile src/backend/access/hash/hash.c src/backend/access/hash/hashfunc.c src/backend/access/hash/hashinsert.c src/backend/access/hash/hashovfl.c src/backend/access/hash/hashpage.c src/backend/access/hash/hashscan.c src/backend/access/hash/hashsearch.c src/backend/access/hash/hashstrat.c src/backend/access/hash/hashutil.c src/backend/access/heap/Makefile src/backend/access/heap/heapam.c src/backend/access/heap/hio.c src/backend/access/heap/tuptoaster.c src/backend/access/index/Makefile src/backend/access/index/genam.c src/backend/access/index/indexam.c src/backend/access/index/istrat.c src/backend/access/nbtree/Makefile src/backend/access/nbtree/README src/backend/access/nbtree/nbtcompare.c src/backend/access/nbtree/nbtinsert.c src/backend/access/nbtree/nbtpage.c src/backend/access/nbtree/nbtree.c src/backend/access/nbtree/nbtsearch.c src/backend/access/nbtree/nbtsort.c src/backend/access/nbtree/nbtstrat.c src/backend/access/nbtree/nbtutils.c src/backend/access/rtree/Makefile src/backend/access/rtree/rtget.c src/backend/access/rtree/rtproc.c src/backend/access/rtree/rtree.c src/backend/access/rtree/rtscan.c src/backend/access/rtree/rtstrat.c src/backend/access/transam/Makefile src/backend/access/transam/clog.c src/backend/access/transam/rmgr.c src/backend/access/transam/transam.c src/backend/access/transam/varsup.c src/backend/access/transam/xact.c src/backend/access/transam/xid.c src/backend/access/transam/xlog.c src/backend/access/transam/xlogutils.c src/backend/bootstrap/.cvsignore src/backend/bootstrap/Makefile src/backend/bootstrap/bootparse.y src/backend/bootstrap/bootscanner.l src/backend/bootstrap/bootstrap.c src/backend/catalog/Makefile src/backend/catalog/README src/backend/catalog/aclchk.c src/backend/catalog/catalog.c src/backend/catalog/genbki.sh src/backend/catalog/heap.c src/backend/catalog/index.c src/backend/catalog/indexing.c src/backend/catalog/namespace.c src/backend/catalog/pg_aggregate.c src/backend/catalog/pg_largeobject.c src/backend/catalog/pg_namespace.c src/backend/catalog/pg_operator.c src/backend/catalog/pg_proc.c src/backend/catalog/pg_type.c src/backend/commands/Makefile src/backend/commands/_deadcode/recipe.c src/backend/commands/_deadcode/recipe.h src/backend/commands/_deadcode/version.c src/backend/commands/aggregatecmds.c src/backend/commands/analyze.c src/backend/commands/async.c src/backend/commands/cluster.c src/backend/commands/comment.c src/backend/commands/copy.c src/backend/commands/dbcommands.c src/backend/commands/define.c src/backend/commands/explain.c src/backend/commands/functioncmds.c src/backend/commands/indexcmds.c src/backend/commands/lockcmds.c src/backend/commands/operatorcmds.c src/backend/commands/portalcmds.c src/backend/commands/proclang.c src/backend/commands/schemacmds.c src/backend/commands/sequence.c src/backend/commands/tablecmds.c src/backend/commands/trigger.c src/backend/commands/typecmds.c src/backend/commands/user.c src/backend/commands/vacuum.c src/backend/commands/vacuumlazy.c src/backend/commands/variable.c src/backend/commands/view.c src/backend/executor/Makefile src/backend/executor/README src/backend/executor/_deadcode/nodeTee.c src/backend/executor/execAmi.c src/backend/executor/execJunk.c src/backend/executor/execMain.c src/backend/executor/execProcnode.c src/backend/executor/execQual.c src/backend/executor/execScan.c src/backend/executor/execTuples.c src/backend/executor/execUtils.c src/backend/executor/functions.c src/backend/executor/instrument.c src/backend/executor/nodeAgg.c src/backend/executor/nodeAppend.c src/backend/executor/nodeFunctionscan.c src/backend/executor/nodeGroup.c src/backend/executor/nodeHash.c src/backend/executor/nodeHashjoin.c src/backend/executor/nodeIndexscan.c src/backend/executor/nodeLimit.c src/backend/executor/nodeMaterial.c src/backend/executor/nodeMergejoin.c src/backend/executor/nodeNestloop.c src/backend/executor/nodeResult.c src/backend/executor/nodeSeqscan.c src/backend/executor/nodeSetOp.c src/backend/executor/nodeSort.c src/backend/executor/nodeSubplan.c src/backend/executor/nodeSubqueryscan.c src/backend/executor/nodeTidscan.c src/backend/executor/nodeUnique.c src/backend/executor/spi.c src/backend/lib/Makefile src/backend/lib/bit.c src/backend/lib/dllist.c src/backend/lib/lispsort.c src/backend/lib/stringinfo.c src/backend/libpq/Makefile src/backend/libpq/README.SSL src/backend/libpq/auth.c src/backend/libpq/be-fsstubs.c src/backend/libpq/be-secure.c src/backend/libpq/crypt.c src/backend/libpq/hba.c src/backend/libpq/md5.c src/backend/libpq/pg_hba.conf.sample src/backend/libpq/pg_ident.conf.sample src/backend/libpq/pqcomm.c src/backend/libpq/pqformat.c src/backend/libpq/pqsignal.c src/backend/main/Makefile src/backend/main/main.c src/backend/nodes/Makefile src/backend/nodes/README src/backend/nodes/copyfuncs.c src/backend/nodes/equalfuncs.c src/backend/nodes/list.c src/backend/nodes/makefuncs.c src/backend/nodes/nodeFuncs.c src/backend/nodes/nodes.c src/backend/nodes/outfuncs.c src/backend/nodes/print.c src/backend/nodes/read.c src/backend/nodes/readfuncs.c src/backend/optimizer/Makefile src/backend/optimizer/README src/backend/optimizer/geqo/Makefile src/backend/optimizer/geqo/geqo_copy.c src/backend/optimizer/geqo/geqo_cx.c src/backend/optimizer/geqo/geqo_erx.c src/backend/optimizer/geqo/geqo_eval.c src/backend/optimizer/geqo/geqo_main.c src/backend/optimizer/geqo/geqo_misc.c src/backend/optimizer/geqo/geqo_mutation.c src/backend/optimizer/geqo/geqo_ox1.c src/backend/optimizer/geqo/geqo_ox2.c src/backend/optimizer/geqo/geqo_pmx.c src/backend/optimizer/geqo/geqo_pool.c src/backend/optimizer/geqo/geqo_px.c src/backend/optimizer/geqo/geqo_recombination.c src/backend/optimizer/geqo/geqo_selection.c src/backend/optimizer/path/Makefile src/backend/optimizer/path/_deadcode/predmig.c src/backend/optimizer/path/_deadcode/xfunc.c src/backend/optimizer/path/allpaths.c src/backend/optimizer/path/clausesel.c src/backend/optimizer/path/costsize.c src/backend/optimizer/path/indxpath.c src/backend/optimizer/path/joinpath.c src/backend/optimizer/path/joinrels.c src/backend/optimizer/path/orindxpath.c src/backend/optimizer/path/pathkeys.c src/backend/optimizer/path/tidpath.c src/backend/optimizer/plan/Makefile src/backend/optimizer/plan/README src/backend/optimizer/plan/createplan.c src/backend/optimizer/plan/initsplan.c src/backend/optimizer/plan/planmain.c src/backend/optimizer/plan/planner.c src/backend/optimizer/plan/setrefs.c src/backend/optimizer/plan/subselect.c src/backend/optimizer/prep/Makefile src/backend/optimizer/prep/_deadcode/prepkeyset.c src/backend/optimizer/prep/prepqual.c src/backend/optimizer/prep/preptlist.c src/backend/optimizer/prep/prepunion.c src/backend/optimizer/util/Makefile src/backend/optimizer/util/clauses.c src/backend/optimizer/util/joininfo.c src/backend/optimizer/util/pathnode.c src/backend/optimizer/util/plancat.c src/backend/optimizer/util/relnode.c src/backend/optimizer/util/restrictinfo.c src/backend/optimizer/util/tlist.c src/backend/optimizer/util/var.c src/backend/parser/.cvsignore src/backend/parser/Makefile src/backend/parser/README src/backend/parser/analyze.c src/backend/parser/gram.y src/backend/parser/keywords.c src/backend/parser/parse_agg.c src/backend/parser/parse_clause.c src/backend/parser/parse_coerce.c src/backend/parser/parse_expr.c src/backend/parser/parse_func.c src/backend/parser/parse_node.c src/backend/parser/parse_oper.c src/backend/parser/parse_relation.c src/backend/parser/parse_target.c src/backend/parser/parse_type.c src/backend/parser/parser.c src/backend/parser/scan.l src/backend/parser/scansup.c src/backend/po/Makefile src/backend/po/cs.po src/backend/po/de.po src/backend/po/hu.po src/backend/po/nls.mk src/backend/po/ru.po src/backend/po/zh_CN.po src/backend/po/zh_TW.po src/backend/port/Makefile src/backend/port/aix/mkldexport.sh src/backend/port/beos/Makefile src/backend/port/beos/sem.c src/backend/port/beos/shm.c src/backend/port/beos/support.c src/backend/port/darwin/Makefile src/backend/port/darwin/README src/backend/port/darwin/system.c src/backend/port/dynloader/README.dlfcn.aix src/backend/port/dynloader/aix.c src/backend/port/dynloader/aix.h src/backend/port/dynloader/beos.c src/backend/port/dynloader/beos.h src/backend/port/dynloader/bsdi.c src/backend/port/dynloader/bsdi.h src/backend/port/dynloader/darwin.c src/backend/port/dynloader/darwin.h src/backend/port/dynloader/dgux.c src/backend/port/dynloader/dgux.h src/backend/port/dynloader/freebsd.c src/backend/port/dynloader/freebsd.h src/backend/port/dynloader/hpux.c src/backend/port/dynloader/hpux.h src/backend/port/dynloader/irix5.c src/backend/port/dynloader/irix5.h src/backend/port/dynloader/linux.c src/backend/port/dynloader/linux.h src/backend/port/dynloader/netbsd.c src/backend/port/dynloader/netbsd.h src/backend/port/dynloader/nextstep.c src/backend/port/dynloader/nextstep.h src/backend/port/dynloader/openbsd.c src/backend/port/dynloader/openbsd.h src/backend/port/dynloader/osf.c src/backend/port/dynloader/osf.h src/backend/port/dynloader/qnx4.c src/backend/port/dynloader/qnx4.h src/backend/port/dynloader/sco.c src/backend/port/dynloader/sco.h src/backend/port/dynloader/solaris.c src/backend/port/dynloader/solaris.h src/backend/port/dynloader/sunos4.c src/backend/port/dynloader/sunos4.h src/backend/port/dynloader/svr4.c src/backend/port/dynloader/svr4.h src/backend/port/dynloader/ultrix4.c src/backend/port/dynloader/ultrix4.h src/backend/port/dynloader/univel.c src/backend/port/dynloader/univel.h src/backend/port/dynloader/unixware.c src/backend/port/dynloader/unixware.h src/backend/port/dynloader/win.c src/backend/port/dynloader/win.h src/backend/port/gethostname.c src/backend/port/getrusage.c src/backend/port/hpux/tas.c.template src/backend/port/inet_aton.c src/backend/port/inet_aton.h src/backend/port/ipc_test.c src/backend/port/isinf.c src/backend/port/memcmp.c src/backend/port/nextstep/Makefile src/backend/port/nextstep/port.c src/backend/port/posix_sema.c src/backend/port/qnx4/Makefile src/backend/port/qnx4/ipc.h src/backend/port/qnx4/isnan.c src/backend/port/qnx4/rint.c src/backend/port/qnx4/sem.c src/backend/port/qnx4/sem.h src/backend/port/qnx4/shm.c src/backend/port/qnx4/shm.h src/backend/port/qnx4/tstrint.c src/backend/port/qnx4/tstsem.c src/backend/port/qnx4/tstshm.c src/backend/port/random.c src/backend/port/snprintf.c src/backend/port/srandom.c src/backend/port/strcasecmp.c src/backend/port/strerror.c src/backend/port/strtol.c src/backend/port/strtoul.c src/backend/port/sunos4/Makefile src/backend/port/sunos4/float.h src/backend/port/sysv_sema.c src/backend/port/sysv_shmem.c src/backend/port/tas/dummy.s src/backend/port/tas/hpux.s src/backend/port/tas/solaris_i386.s src/backend/port/tas/solaris_sparc.s src/backend/postmaster/Makefile src/backend/postmaster/pgstat.c src/backend/postmaster/postmaster.c src/backend/regex/COPYRIGHT src/backend/regex/Makefile src/backend/regex/WHATSNEW src/backend/regex/engine.c src/backend/regex/re_format.7 src/backend/regex/regcomp.c src/backend/regex/regerror.c src/backend/regex/regex.3 src/backend/regex/regexec.c src/backend/regex/regfree.c src/backend/regex/retest.c src/backend/rewrite/Makefile src/backend/rewrite/rewriteDefine.c src/backend/rewrite/rewriteHandler.c src/backend/rewrite/rewriteManip.c src/backend/rewrite/rewriteRemove.c src/backend/rewrite/rewriteSupport.c src/backend/storage/Makefile src/backend/storage/buffer/Makefile src/backend/storage/buffer/README src/backend/storage/buffer/buf_init.c src/backend/storage/buffer/buf_table.c src/backend/storage/buffer/bufmgr.c src/backend/storage/buffer/freelist.c src/backend/storage/buffer/localbuf.c src/backend/storage/file/Makefile src/backend/storage/file/buffile.c src/backend/storage/file/fd.c src/backend/storage/freespace/Makefile src/backend/storage/freespace/freespace.c src/backend/storage/ipc/Makefile src/backend/storage/ipc/README src/backend/storage/ipc/ipc.c src/backend/storage/ipc/ipci.c src/backend/storage/ipc/pmsignal.c src/backend/storage/ipc/shmem.c src/backend/storage/ipc/shmqueue.c src/backend/storage/ipc/sinval.c src/backend/storage/ipc/sinvaladt.c src/backend/storage/large_object/Makefile src/backend/storage/large_object/inv_api.c src/backend/storage/lmgr/Makefile src/backend/storage/lmgr/README src/backend/storage/lmgr/deadlock.c src/backend/storage/lmgr/lmgr.c src/backend/storage/lmgr/lock.c src/backend/storage/lmgr/lwlock.c src/backend/storage/lmgr/proc.c src/backend/storage/lmgr/s_lock.c src/backend/storage/lmgr/spin.c src/backend/storage/page/Makefile src/backend/storage/page/bufpage.c src/backend/storage/page/itemptr.c src/backend/storage/smgr/Makefile src/backend/storage/smgr/README src/backend/storage/smgr/md.c src/backend/storage/smgr/mm.c src/backend/storage/smgr/smgr.c src/backend/storage/smgr/smgrtype.c src/backend/tcop/Makefile src/backend/tcop/dest.c src/backend/tcop/fastpath.c src/backend/tcop/postgres.c src/backend/tcop/pquery.c src/backend/tcop/utility.c src/backend/tioga/Arr_TgRecipe.h src/backend/tioga/Makefile src/backend/tioga/Varray.c src/backend/tioga/Varray.h src/backend/tioga/tgRecipe.c src/backend/tioga/tgRecipe.h src/backend/utils/.cvsignore src/backend/utils/Gen_fmgrtab.sh src/backend/utils/Makefile src/backend/utils/adt/Makefile src/backend/utils/adt/acl.c src/backend/utils/adt/arrayfuncs.c src/backend/utils/adt/arrayutils.c src/backend/utils/adt/ascii.c src/backend/utils/adt/bool.c src/backend/utils/adt/cash.c src/backend/utils/adt/char.c src/backend/utils/adt/date.c src/backend/utils/adt/datetime.c src/backend/utils/adt/datum.c src/backend/utils/adt/encode.c src/backend/utils/adt/float.c src/backend/utils/adt/format_type.c src/backend/utils/adt/formatting.c src/backend/utils/adt/geo_ops.c src/backend/utils/adt/geo_selfuncs.c src/backend/utils/adt/inet_net_ntop.c src/backend/utils/adt/inet_net_pton.c src/backend/utils/adt/int.c src/backend/utils/adt/int8.c src/backend/utils/adt/like.c src/backend/utils/adt/like_match.c src/backend/utils/adt/mac.c src/backend/utils/adt/misc.c src/backend/utils/adt/nabstime.c src/backend/utils/adt/name.c src/backend/utils/adt/network.c src/backend/utils/adt/not_in.c src/backend/utils/adt/numeric.c src/backend/utils/adt/numutils.c src/backend/utils/adt/oid.c src/backend/utils/adt/oracle_compat.c src/backend/utils/adt/pg_locale.c src/backend/utils/adt/pg_lzcompress.c src/backend/utils/adt/pgstatfuncs.c src/backend/utils/adt/quote.c src/backend/utils/adt/regexp.c src/backend/utils/adt/regproc.c src/backend/utils/adt/ri_triggers.c src/backend/utils/adt/ruleutils.c src/backend/utils/adt/selfuncs.c src/backend/utils/adt/sets.c src/backend/utils/adt/tid.c src/backend/utils/adt/timestamp.c src/backend/utils/adt/varbit.c src/backend/utils/adt/varchar.c src/backend/utils/adt/varlena.c src/backend/utils/adt/version.c src/backend/utils/cache/Makefile src/backend/utils/cache/catcache.c src/backend/utils/cache/fcache.c src/backend/utils/cache/inval.c src/backend/utils/cache/lsyscache.c src/backend/utils/cache/relcache.c src/backend/utils/cache/syscache.c src/backend/utils/error/Makefile src/backend/utils/error/assert.c src/backend/utils/error/elog.c src/backend/utils/error/exc.c src/backend/utils/error/excabort.c src/backend/utils/error/excid.c src/backend/utils/error/format.c src/backend/utils/fmgr/Makefile src/backend/utils/fmgr/README src/backend/utils/fmgr/dfmgr.c src/backend/utils/fmgr/fmgr.c src/backend/utils/hash/Makefile src/backend/utils/hash/dynahash.c src/backend/utils/hash/hashfn.c src/backend/utils/hash/pg_crc.c src/backend/utils/init/Makefile src/backend/utils/init/findbe.c src/backend/utils/init/globals.c src/backend/utils/init/miscinit.c src/backend/utils/init/postinit.c src/backend/utils/mb/Makefile src/backend/utils/mb/README src/backend/utils/mb/Unicode/ISO10646-GB18030.TXT src/backend/utils/mb/Unicode/Makefile src/backend/utils/mb/Unicode/UCS_to_8859.pl src/backend/utils/mb/Unicode/UCS_to_BIG5.pl src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl src/backend/utils/mb/Unicode/UCS_to_GB18030.pl src/backend/utils/mb/Unicode/UCS_to_GBK.pl src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl src/backend/utils/mb/Unicode/UCS_to_SJIS.pl src/backend/utils/mb/Unicode/UCS_to_UHC.pl src/backend/utils/mb/Unicode/UCS_to_WIN874.pl src/backend/utils/mb/Unicode/UCS_to_WINX.pl src/backend/utils/mb/Unicode/UCS_to_cyrillic.pl src/backend/utils/mb/Unicode/alt_to_utf8.map src/backend/utils/mb/Unicode/big5_to_utf8.map src/backend/utils/mb/Unicode/euc_cn_to_utf8.map src/backend/utils/mb/Unicode/euc_jp_to_utf8.map src/backend/utils/mb/Unicode/euc_kr_to_utf8.map src/backend/utils/mb/Unicode/euc_tw_to_utf8.map src/backend/utils/mb/Unicode/gb18030_to_utf8.map src/backend/utils/mb/Unicode/gbk_to_utf8.map src/backend/utils/mb/Unicode/iso8859_10_to_utf8.map src/backend/utils/mb/Unicode/iso8859_13_to_utf8.map src/backend/utils/mb/Unicode/iso8859_14_to_utf8.map src/backend/utils/mb/Unicode/iso8859_15_to_utf8.map src/backend/utils/mb/Unicode/iso8859_16_to_utf8.map src/backend/utils/mb/Unicode/iso8859_2_to_utf8.map src/backend/utils/mb/Unicode/iso8859_3_to_utf8.map src/backend/utils/mb/Unicode/iso8859_4_to_utf8.map src/backend/utils/mb/Unicode/iso8859_5_to_utf8.map src/backend/utils/mb/Unicode/iso8859_6_to_utf8.map src/backend/utils/mb/Unicode/iso8859_7_to_utf8.map src/backend/utils/mb/Unicode/iso8859_8_to_utf8.map src/backend/utils/mb/Unicode/iso8859_9_to_utf8.map src/backend/utils/mb/Unicode/johab_to_utf8.map src/backend/utils/mb/Unicode/koi8r_to_utf8.map src/backend/utils/mb/Unicode/sjis_to_utf8.map src/backend/utils/mb/Unicode/tcvn_to_utf8.map src/backend/utils/mb/Unicode/ucs2utf.pl src/backend/utils/mb/Unicode/uhc_to_utf8.map src/backend/utils/mb/Unicode/utf8_to_alt.map src/backend/utils/mb/Unicode/utf8_to_big5.map src/backend/utils/mb/Unicode/utf8_to_euc_cn.map src/backend/utils/mb/Unicode/utf8_to_euc_jp.map src/backend/utils/mb/Unicode/utf8_to_euc_kr.map src/backend/utils/mb/Unicode/utf8_to_euc_tw.map src/backend/utils/mb/Unicode/utf8_to_gb18030.map src/backend/utils/mb/Unicode/utf8_to_gbk.map src/backend/utils/mb/Unicode/utf8_to_iso8859_10.map src/backend/utils/mb/Unicode/utf8_to_iso8859_13.map src/backend/utils/mb/Unicode/utf8_to_iso8859_14.map src/backend/utils/mb/Unicode/utf8_to_iso8859_15.map src/backend/utils/mb/Unicode/utf8_to_iso8859_16.map src/backend/utils/mb/Unicode/utf8_to_iso8859_2.map src/backend/utils/mb/Unicode/utf8_to_iso8859_3.map src/backend/utils/mb/Unicode/utf8_to_iso8859_4.map src/backend/utils/mb/Unicode/utf8_to_iso8859_5.map src/backend/utils/mb/Unicode/utf8_to_iso8859_6.map src/backend/utils/mb/Unicode/utf8_to_iso8859_7.map src/backend/utils/mb/Unicode/utf8_to_iso8859_8.map src/backend/utils/mb/Unicode/utf8_to_iso8859_9.map src/backend/utils/mb/Unicode/utf8_to_johab.map src/backend/utils/mb/Unicode/utf8_to_koi8r.map src/backend/utils/mb/Unicode/utf8_to_sjis.map src/backend/utils/mb/Unicode/utf8_to_tcvn.map src/backend/utils/mb/Unicode/utf8_to_uhc.map src/backend/utils/mb/Unicode/utf8_to_win1250.map src/backend/utils/mb/Unicode/utf8_to_win1251.map src/backend/utils/mb/Unicode/utf8_to_win1256.map src/backend/utils/mb/Unicode/utf8_to_win874.map src/backend/utils/mb/Unicode/win1250_to_utf8.map src/backend/utils/mb/Unicode/win1251_to_utf8.map src/backend/utils/mb/Unicode/win1256_to_utf8.map src/backend/utils/mb/Unicode/win874_to_utf8.map src/backend/utils/mb/alt.c src/backend/utils/mb/big5.c src/backend/utils/mb/conv.c src/backend/utils/mb/encnames.c src/backend/utils/mb/iso.c src/backend/utils/mb/mbutils.c src/backend/utils/mb/sjis.map src/backend/utils/mb/wchar.c src/backend/utils/mb/win.c src/backend/utils/mb/win1251.c src/backend/utils/mb/wstrcmp.c src/backend/utils/mb/wstrncmp.c src/backend/utils/misc/.cvsignore src/backend/utils/misc/Makefile src/backend/utils/misc/README src/backend/utils/misc/database.c src/backend/utils/misc/guc-file.l src/backend/utils/misc/guc.c src/backend/utils/misc/postgresql.conf.sample src/backend/utils/misc/ps_status.c src/backend/utils/misc/superuser.c src/backend/utils/mmgr/Makefile src/backend/utils/mmgr/README src/backend/utils/mmgr/aset.c src/backend/utils/mmgr/mcxt.c src/backend/utils/mmgr/portalmem.c src/backend/utils/sort/Makefile src/backend/utils/sort/logtape.c src/backend/utils/sort/tuplesort.c src/backend/utils/sort/tuplestore.c src/backend/utils/time/Makefile src/backend/utils/time/tqual.c src/bin/Makefile src/bin/initdb/Makefile src/bin/initdb/initdb.sh src/bin/initlocation/Makefile src/bin/initlocation/initlocation.sh src/bin/ipcclean/Makefile src/bin/ipcclean/ipcclean.sh src/bin/pg_config/Makefile src/bin/pg_config/pg_config.sh src/bin/pg_ctl/Makefile src/bin/pg_ctl/pg_ctl.sh src/bin/pg_dump/Makefile src/bin/pg_dump/README src/bin/pg_dump/common.c src/bin/pg_dump/cs.po src/bin/pg_dump/de.po src/bin/pg_dump/nls.mk src/bin/pg_dump/pg_backup.h src/bin/pg_dump/pg_backup_archiver.c src/bin/pg_dump/pg_backup_archiver.h src/bin/pg_dump/pg_backup_custom.c src/bin/pg_dump/pg_backup_db.c src/bin/pg_dump/pg_backup_db.h src/bin/pg_dump/pg_backup_files.c src/bin/pg_dump/pg_backup_null.c src/bin/pg_dump/pg_backup_tar.c src/bin/pg_dump/pg_backup_tar.h src/bin/pg_dump/pg_dump.c src/bin/pg_dump/pg_dump.h src/bin/pg_dump/pg_dumpall.sh src/bin/pg_dump/pg_restore.c src/bin/pg_dump/ru.po src/bin/pg_dump/sv.po src/bin/pg_dump/zh_CN.po src/bin/pg_dump/zh_TW.po src/bin/pg_encoding/Makefile src/bin/pg_encoding/pg_encoding.c src/bin/pg_id/Makefile src/bin/pg_id/pg_id.c src/bin/pgaccess/Makefile src/bin/pgaccess/README src/bin/pgaccess/copyright.html src/bin/pgaccess/demo/formdemo.sql src/bin/pgaccess/doc/html/a_right.gif src/bin/pgaccess/doc/html/addindex.gif src/bin/pgaccess/doc/html/api.html src/bin/pgaccess/doc/html/ball.gif src/bin/pgaccess/doc/html/contents.html src/bin/pgaccess/doc/html/copyright.html src/bin/pgaccess/doc/html/documentation.html src/bin/pgaccess/doc/html/download.html src/bin/pgaccess/doc/html/faq.html src/bin/pgaccess/doc/html/features.html src/bin/pgaccess/doc/html/formdemo.sql src/bin/pgaccess/doc/html/forms.gif src/bin/pgaccess/doc/html/forms.html src/bin/pgaccess/doc/html/function.gif src/bin/pgaccess/doc/html/help.gif src/bin/pgaccess/doc/html/index.html src/bin/pgaccess/doc/html/irix.html src/bin/pgaccess/doc/html/linux1.gif src/bin/pgaccess/doc/html/maillist.html src/bin/pgaccess/doc/html/main.html src/bin/pgaccess/doc/html/mainwindow.gif src/bin/pgaccess/doc/html/newtable.gif src/bin/pgaccess/doc/html/newuser.gif src/bin/pgaccess/doc/html/old_index.html src/bin/pgaccess/doc/html/permissions.gif src/bin/pgaccess/doc/html/pg93patch.html src/bin/pgaccess/doc/html/pga-rad.html src/bin/pgaccess/doc/html/qbtclet.html src/bin/pgaccess/doc/html/qbtclet.tcl src/bin/pgaccess/doc/html/screenshots.html src/bin/pgaccess/doc/html/specialchars.html src/bin/pgaccess/doc/html/todo.html src/bin/pgaccess/doc/html/tutorial/addref.jpg src/bin/pgaccess/doc/html/tutorial/altern_q.jpg src/bin/pgaccess/doc/html/tutorial/altern_v.jpg src/bin/pgaccess/doc/html/tutorial/copyright.html src/bin/pgaccess/doc/html/tutorial/index.html src/bin/pgaccess/doc/html/tutorial/intro.html src/bin/pgaccess/doc/html/tutorial/irix.html src/bin/pgaccess/doc/html/tutorial/newref.txt src/bin/pgaccess/doc/html/tutorial/newtable.jpg src/bin/pgaccess/doc/html/tutorial/newtable.tga src/bin/pgaccess/doc/html/tutorial/problems.html src/bin/pgaccess/doc/html/tutorial/screen1.jpg src/bin/pgaccess/doc/html/tutorial/sel_tbl.jpg src/bin/pgaccess/doc/html/tutorial/start.html src/bin/pgaccess/doc/html/tutorial/tut.html src/bin/pgaccess/doc/html/tutorial/tut_edit.html src/bin/pgaccess/doc/html/tutorial/tut_new.html src/bin/pgaccess/doc/html/tutorial/tut_sel1.html src/bin/pgaccess/doc/html/tutorial/tut_user.html src/bin/pgaccess/doc/html/vdesigner.gif src/bin/pgaccess/doc/html/whatsnew.html src/bin/pgaccess/doc/html/win32.html src/bin/pgaccess/images/icon_button.gif src/bin/pgaccess/images/icon_checkbutton.gif src/bin/pgaccess/images/icon_entry.gif src/bin/pgaccess/images/icon_frame.gif src/bin/pgaccess/images/icon_label.gif src/bin/pgaccess/images/icon_listbox.gif src/bin/pgaccess/images/icon_query.gif src/bin/pgaccess/images/icon_radiobutton.gif src/bin/pgaccess/images/icon_text.gif src/bin/pgaccess/lib/database.tcl src/bin/pgaccess/lib/forms.tcl src/bin/pgaccess/lib/functions.tcl src/bin/pgaccess/lib/help/abort.hlp src/bin/pgaccess/lib/help/add_records.hlp src/bin/pgaccess/lib/help/alter_table.hlp src/bin/pgaccess/lib/help/alter_user.hlp src/bin/pgaccess/lib/help/author.hlp src/bin/pgaccess/lib/help/begin.hlp src/bin/pgaccess/lib/help/close.hlp src/bin/pgaccess/lib/help/cluster.hlp src/bin/pgaccess/lib/help/commit.hlp src/bin/pgaccess/lib/help/copy.hlp src/bin/pgaccess/lib/help/copyrights.hlp src/bin/pgaccess/lib/help/create_aggregate.hlp src/bin/pgaccess/lib/help/create_database.hlp src/bin/pgaccess/lib/help/create_function.hlp src/bin/pgaccess/lib/help/create_index.hlp src/bin/pgaccess/lib/help/create_language.hlp src/bin/pgaccess/lib/help/create_operator.hlp src/bin/pgaccess/lib/help/create_rule.hlp src/bin/pgaccess/lib/help/create_sequence.hlp src/bin/pgaccess/lib/help/create_table.hlp src/bin/pgaccess/lib/help/create_table_as.hlp src/bin/pgaccess/lib/help/create_trigger.hlp src/bin/pgaccess/lib/help/create_type.hlp src/bin/pgaccess/lib/help/create_user.hlp src/bin/pgaccess/lib/help/create_view.hlp src/bin/pgaccess/lib/help/data_types.hlp src/bin/pgaccess/lib/help/datefunc.hlp src/bin/pgaccess/lib/help/declare.hlp src/bin/pgaccess/lib/help/delete.hlp src/bin/pgaccess/lib/help/drop_aggregate.hlp src/bin/pgaccess/lib/help/drop_database.hlp src/bin/pgaccess/lib/help/drop_function.hlp src/bin/pgaccess/lib/help/drop_index.hlp src/bin/pgaccess/lib/help/drop_language.hlp src/bin/pgaccess/lib/help/drop_operator.hlp src/bin/pgaccess/lib/help/drop_rule.hlp src/bin/pgaccess/lib/help/drop_sequence.hlp src/bin/pgaccess/lib/help/drop_table.hlp src/bin/pgaccess/lib/help/drop_trigger.hlp src/bin/pgaccess/lib/help/drop_type.hlp src/bin/pgaccess/lib/help/drop_user.hlp src/bin/pgaccess/lib/help/drop_view.hlp src/bin/pgaccess/lib/help/explain.hlp src/bin/pgaccess/lib/help/fetch.hlp src/bin/pgaccess/lib/help/form_design.hlp src/bin/pgaccess/lib/help/forms.hlp src/bin/pgaccess/lib/help/functions.hlp src/bin/pgaccess/lib/help/geomfunc.hlp src/bin/pgaccess/lib/help/grant.hlp src/bin/pgaccess/lib/help/history.hlp src/bin/pgaccess/lib/help/index.hlp src/bin/pgaccess/lib/help/inheritance.hlp src/bin/pgaccess/lib/help/insert.hlp src/bin/pgaccess/lib/help/ipv4func.hlp src/bin/pgaccess/lib/help/isolation.hlp src/bin/pgaccess/lib/help/keywords.hlp src/bin/pgaccess/lib/help/listen.hlp src/bin/pgaccess/lib/help/load.hlp src/bin/pgaccess/lib/help/lock.hlp src/bin/pgaccess/lib/help/mathfunc.hlp src/bin/pgaccess/lib/help/move.hlp src/bin/pgaccess/lib/help/mvcc.hlp src/bin/pgaccess/lib/help/new_query.hlp src/bin/pgaccess/lib/help/new_table.hlp src/bin/pgaccess/lib/help/notify.hlp src/bin/pgaccess/lib/help/open_query.hlp src/bin/pgaccess/lib/help/open_table.hlp src/bin/pgaccess/lib/help/pgfunctions.hlp src/bin/pgaccess/lib/help/postgresql.hlp src/bin/pgaccess/lib/help/queries.hlp src/bin/pgaccess/lib/help/reports.hlp src/bin/pgaccess/lib/help/reset.hlp src/bin/pgaccess/lib/help/revoke.hlp src/bin/pgaccess/lib/help/rollback.hlp src/bin/pgaccess/lib/help/schema.hlp src/bin/pgaccess/lib/help/scripts.hlp src/bin/pgaccess/lib/help/select.hlp src/bin/pgaccess/lib/help/select_into.hlp src/bin/pgaccess/lib/help/sequences.hlp src/bin/pgaccess/lib/help/set.hlp src/bin/pgaccess/lib/help/show.hlp src/bin/pgaccess/lib/help/sql_guide.hlp src/bin/pgaccess/lib/help/sqlfunc.hlp src/bin/pgaccess/lib/help/stringfunc.hlp src/bin/pgaccess/lib/help/tables.hlp src/bin/pgaccess/lib/help/unlisten.hlp src/bin/pgaccess/lib/help/update.hlp src/bin/pgaccess/lib/help/users.hlp src/bin/pgaccess/lib/help/vacuum.hlp src/bin/pgaccess/lib/help/view_table_structure.hlp src/bin/pgaccess/lib/help/views.hlp src/bin/pgaccess/lib/help/visual_designer.hlp src/bin/pgaccess/lib/help/y2k.hlp src/bin/pgaccess/lib/help.tcl src/bin/pgaccess/lib/languages/chinese_big5 src/bin/pgaccess/lib/languages/chinese_gb src/bin/pgaccess/lib/languages/czech src/bin/pgaccess/lib/languages/deutsch src/bin/pgaccess/lib/languages/euskara src/bin/pgaccess/lib/languages/francais src/bin/pgaccess/lib/languages/italiano src/bin/pgaccess/lib/languages/japanese src/bin/pgaccess/lib/languages/magyar src/bin/pgaccess/lib/languages/nederlands src/bin/pgaccess/lib/languages/portugues src/bin/pgaccess/lib/languages/romana src/bin/pgaccess/lib/languages/russian.koi8r src/bin/pgaccess/lib/languages/russian_win src/bin/pgaccess/lib/languages/spanish src/bin/pgaccess/lib/mainlib.tcl src/bin/pgaccess/lib/preferences.tcl src/bin/pgaccess/lib/queries.tcl src/bin/pgaccess/lib/reports.tcl src/bin/pgaccess/lib/schema.tcl src/bin/pgaccess/lib/scripts.tcl src/bin/pgaccess/lib/sequences.tcl src/bin/pgaccess/lib/tables.tcl src/bin/pgaccess/lib/users.tcl src/bin/pgaccess/lib/views.tcl src/bin/pgaccess/lib/visualqb.tcl src/bin/pgaccess/main.tcl src/bin/pgaccess/pgaccess.sh src/bin/pgtclsh/Makefile src/bin/pgtclsh/README src/bin/pgtclsh/pgtclAppInit.c src/bin/pgtclsh/pgtclUtils.tcl src/bin/pgtclsh/pgtkAppInit.c src/bin/pgtclsh/updateStats.tcl src/bin/psql/.cvsignore src/bin/psql/Makefile src/bin/psql/command.c src/bin/psql/command.h src/bin/psql/common.c src/bin/psql/common.h src/bin/psql/copy.c src/bin/psql/copy.h src/bin/psql/create_help.pl src/bin/psql/cs.po src/bin/psql/de.po src/bin/psql/describe.c src/bin/psql/describe.h src/bin/psql/fr.po src/bin/psql/help.c src/bin/psql/help.h src/bin/psql/input.c src/bin/psql/input.h src/bin/psql/large_obj.c src/bin/psql/large_obj.h src/bin/psql/mainloop.c src/bin/psql/mainloop.h src/bin/psql/mbprint.c src/bin/psql/mbprint.h src/bin/psql/nls.mk src/bin/psql/print.c src/bin/psql/print.h src/bin/psql/prompt.c src/bin/psql/prompt.h src/bin/psql/ru.po src/bin/psql/settings.h src/bin/psql/startup.c src/bin/psql/stringutils.c src/bin/psql/stringutils.h src/bin/psql/sv.po src/bin/psql/tab-complete.c src/bin/psql/tab-complete.h src/bin/psql/variables.c src/bin/psql/variables.h src/bin/psql/win32.mak src/bin/psql/zh_CN.po src/bin/psql/zh_TW.po src/bin/scripts/Makefile src/bin/scripts/createdb src/bin/scripts/createlang.sh src/bin/scripts/createuser src/bin/scripts/dropdb src/bin/scripts/droplang src/bin/scripts/dropuser src/bin/scripts/vacuumdb src/corba/CosQuery.idl src/corba/CosQueryCollection.idl src/corba/pgsql.idl src/corba/pgsql_int.idl src/corba/server.cc src/data/charset.conf src/data/isocz-wincz.tab src/data/koi-alt.tab src/data/koi-iso.tab src/data/koi-koi.tab src/data/koi-mac.tab src/data/koi-win.tab src/include/Makefile src/include/access/attnum.h src/include/access/clog.h src/include/access/genam.h src/include/access/gist.h src/include/access/gistscan.h src/include/access/hash.h src/include/access/heapam.h src/include/access/hio.h src/include/access/htup.h src/include/access/ibit.h src/include/access/iqual.h src/include/access/istrat.h src/include/access/itup.h src/include/access/nbtree.h src/include/access/printtup.h src/include/access/relscan.h src/include/access/rmgr.h src/include/access/rtree.h src/include/access/rtscan.h src/include/access/sdir.h src/include/access/skey.h src/include/access/strat.h src/include/access/transam.h src/include/access/tupdesc.h src/include/access/tupmacs.h src/include/access/tuptoaster.h src/include/access/valid.h src/include/access/xact.h src/include/access/xlog.h src/include/access/xlogdefs.h src/include/access/xlogutils.h src/include/bootstrap/bootstrap.h src/include/c.h src/include/catalog/catalog.h src/include/catalog/catname.h src/include/catalog/catversion.h src/include/catalog/duplicate_oids src/include/catalog/heap.h src/include/catalog/index.h src/include/catalog/indexing.h src/include/catalog/namespace.h src/include/catalog/pg_aggregate.h src/include/catalog/pg_am.h src/include/catalog/pg_amop.h src/include/catalog/pg_amproc.h src/include/catalog/pg_attrdef.h src/include/catalog/pg_attribute.h src/include/catalog/pg_class.h src/include/catalog/pg_control.h src/include/catalog/pg_database.h src/include/catalog/pg_description.h src/include/catalog/pg_group.h src/include/catalog/pg_index.h src/include/catalog/pg_inherits.h src/include/catalog/pg_language.h src/include/catalog/pg_largeobject.h src/include/catalog/pg_listener.h src/include/catalog/pg_namespace.h src/include/catalog/pg_opclass.h src/include/catalog/pg_operator.h src/include/catalog/pg_proc.h src/include/catalog/pg_relcheck.h src/include/catalog/pg_rewrite.h src/include/catalog/pg_shadow.h src/include/catalog/pg_statistic.h src/include/catalog/pg_trigger.h src/include/catalog/pg_type.h src/include/catalog/pg_version.h src/include/catalog/unused_oids src/include/commands/async.h src/include/commands/cluster.h src/include/commands/comment.h src/include/commands/copy.h src/include/commands/dbcommands.h src/include/commands/defrem.h src/include/commands/explain.h src/include/commands/lockcmds.h src/include/commands/portalcmds.h src/include/commands/proclang.h src/include/commands/schemacmds.h src/include/commands/sequence.h src/include/commands/tablecmds.h src/include/commands/trigger.h src/include/commands/user.h src/include/commands/vacuum.h src/include/commands/variable.h src/include/commands/version.h src/include/commands/view.h src/include/executor/execdebug.h src/include/executor/execdefs.h src/include/executor/execdesc.h src/include/executor/executor.h src/include/executor/functions.h src/include/executor/hashjoin.h src/include/executor/instrument.h src/include/executor/nodeAgg.h src/include/executor/nodeAppend.h src/include/executor/nodeFunctionscan.h src/include/executor/nodeGroup.h src/include/executor/nodeHash.h src/include/executor/nodeHashjoin.h src/include/executor/nodeIndexscan.h src/include/executor/nodeLimit.h src/include/executor/nodeMaterial.h src/include/executor/nodeMergejoin.h src/include/executor/nodeNestloop.h src/include/executor/nodeResult.h src/include/executor/nodeSeqscan.h src/include/executor/nodeSetOp.h src/include/executor/nodeSort.h src/include/executor/nodeSubplan.h src/include/executor/nodeSubqueryscan.h src/include/executor/nodeTidscan.h src/include/executor/nodeUnique.h src/include/executor/spi.h src/include/executor/spi_priv.h src/include/executor/tuptable.h src/include/fmgr.h src/include/lib/dllist.h src/include/lib/lispsort.h src/include/lib/stringinfo.h src/include/libpq/auth.h src/include/libpq/be-fsstubs.h src/include/libpq/crypt.h src/include/libpq/hba.h src/include/libpq/libpq-be.h src/include/libpq/libpq-fs.h src/include/libpq/libpq.h src/include/libpq/password.h src/include/libpq/pqcomm.h src/include/libpq/pqformat.h src/include/libpq/pqsignal.h src/include/mb/pg_wchar.h src/include/miscadmin.h src/include/nodes/execnodes.h src/include/nodes/makefuncs.h src/include/nodes/memnodes.h src/include/nodes/nodeFuncs.h src/include/nodes/nodes.h src/include/nodes/params.h src/include/nodes/parsenodes.h src/include/nodes/pg_list.h src/include/nodes/plannodes.h src/include/nodes/primnodes.h src/include/nodes/print.h src/include/nodes/readfuncs.h src/include/nodes/relation.h src/include/optimizer/_deadcode/xfunc.h src/include/optimizer/clauses.h src/include/optimizer/cost.h src/include/optimizer/geqo.h src/include/optimizer/geqo_copy.h src/include/optimizer/geqo_gene.h src/include/optimizer/geqo_misc.h src/include/optimizer/geqo_mutation.h src/include/optimizer/geqo_pool.h src/include/optimizer/geqo_random.h src/include/optimizer/geqo_recombination.h src/include/optimizer/geqo_selection.h src/include/optimizer/joininfo.h src/include/optimizer/pathnode.h src/include/optimizer/paths.h src/include/optimizer/plancat.h src/include/optimizer/planmain.h src/include/optimizer/planner.h src/include/optimizer/prep.h src/include/optimizer/restrictinfo.h src/include/optimizer/subselect.h src/include/optimizer/tlist.h src/include/optimizer/var.h src/include/parser/analyze.h src/include/parser/gramparse.h src/include/parser/keywords.h src/include/parser/parse_agg.h src/include/parser/parse_clause.h src/include/parser/parse_coerce.h src/include/parser/parse_expr.h src/include/parser/parse_func.h src/include/parser/parse_node.h src/include/parser/parse_oper.h src/include/parser/parse_relation.h src/include/parser/parse_target.h src/include/parser/parse_type.h src/include/parser/parser.h src/include/parser/parsetree.h src/include/parser/scansup.h src/include/pg_config.h.in src/include/pg_config.h.win32 src/include/pgstat.h src/include/port/aix.h src/include/port/beos.h src/include/port/bsdi.h src/include/port/darwin.h src/include/port/dgux.h src/include/port/freebsd.h src/include/port/hpux.h src/include/port/irix5.h src/include/port/linux.h src/include/port/netbsd.h src/include/port/nextstep.h src/include/port/openbsd.h src/include/port/osf.h src/include/port/qnx4.h src/include/port/sco.h src/include/port/solaris.h src/include/port/sunos4.h src/include/port/svr4.h src/include/port/ultrix4.h src/include/port/univel.h src/include/port/unixware.h src/include/port/win.h src/include/port/win32.h src/include/postgres.h src/include/postgres_ext.h src/include/postgres_fe.h src/include/regex/cclass.h src/include/regex/cname.h src/include/regex/regex.h src/include/regex/regex2.h src/include/regex/utils.h src/include/rewrite/prs2lock.h src/include/rewrite/rewriteDefine.h src/include/rewrite/rewriteHandler.h src/include/rewrite/rewriteManip.h src/include/rewrite/rewriteRemove.h src/include/rewrite/rewriteSupport.h src/include/rusagestub.h src/include/storage/backendid.h src/include/storage/block.h src/include/storage/buf.h src/include/storage/buf_internals.h src/include/storage/buffile.h src/include/storage/bufmgr.h src/include/storage/bufpage.h src/include/storage/fd.h src/include/storage/freespace.h src/include/storage/ipc.h src/include/storage/item.h src/include/storage/itemid.h src/include/storage/itempos.h src/include/storage/itemptr.h src/include/storage/large_object.h src/include/storage/lmgr.h src/include/storage/lock.h src/include/storage/lwlock.h src/include/storage/off.h src/include/storage/page.h src/include/storage/pg_sema.h src/include/storage/pg_shmem.h src/include/storage/pmsignal.h src/include/storage/pos.h src/include/storage/proc.h src/include/storage/relfilenode.h src/include/storage/s_lock.h src/include/storage/shmem.h src/include/storage/sinval.h src/include/storage/sinvaladt.h src/include/storage/smgr.h src/include/storage/spin.h src/include/strdup.h src/include/tcop/dest.h src/include/tcop/fastpath.h src/include/tcop/pquery.h src/include/tcop/tcopdebug.h src/include/tcop/tcopprot.h src/include/tcop/utility.h src/include/utils/acl.h src/include/utils/array.h src/include/utils/ascii.h src/include/utils/bit.h src/include/utils/builtins.h src/include/utils/cash.h src/include/utils/catcache.h src/include/utils/date.h src/include/utils/datetime.h src/include/utils/datum.h src/include/utils/dynahash.h src/include/utils/dynamic_loader.h src/include/utils/elog.h src/include/utils/exc.h src/include/utils/excid.h src/include/utils/fcache.h src/include/utils/fmgrtab.h src/include/utils/formatting.h src/include/utils/geo_decls.h src/include/utils/guc.h src/include/utils/hsearch.h src/include/utils/inet.h src/include/utils/int8.h src/include/utils/inval.h src/include/utils/logtape.h src/include/utils/lsyscache.h src/include/utils/memutils.h src/include/utils/nabstime.h src/include/utils/numeric.h src/include/utils/palloc.h src/include/utils/pg_crc.h src/include/utils/pg_locale.h src/include/utils/pg_lzcompress.h src/include/utils/portal.h src/include/utils/ps_status.h src/include/utils/rel.h src/include/utils/relcache.h src/include/utils/selfuncs.h src/include/utils/sets.h src/include/utils/syscache.h src/include/utils/timestamp.h src/include/utils/tqual.h src/include/utils/tuplesort.h src/include/utils/tuplestore.h src/include/utils/varbit.h src/interfaces/Makefile src/interfaces/cli/example1.c src/interfaces/cli/example2.c src/interfaces/cli/sqlcli.h src/interfaces/jdbc/CHANGELOG src/interfaces/jdbc/Implementation src/interfaces/jdbc/Makefile src/interfaces/jdbc/README src/interfaces/jdbc/build.xml src/interfaces/jdbc/example/ImageViewer.java src/interfaces/jdbc/example/Unicode.java src/interfaces/jdbc/example/basic.java src/interfaces/jdbc/example/blobtest.java src/interfaces/jdbc/example/corba/StockClient.java src/interfaces/jdbc/example/corba/StockDB.java src/interfaces/jdbc/example/corba/StockDispenserImpl.java src/interfaces/jdbc/example/corba/StockItemImpl.java src/interfaces/jdbc/example/corba/StockServer.java src/interfaces/jdbc/example/corba/readme src/interfaces/jdbc/example/corba/stock.idl src/interfaces/jdbc/example/corba/stock.sql src/interfaces/jdbc/example/datestyle.java src/interfaces/jdbc/example/metadata.java src/interfaces/jdbc/example/psql.java src/interfaces/jdbc/example/threadsafe.java src/interfaces/jdbc/jdbc.jpx src/interfaces/jdbc/org/postgresql/Connection.java src/interfaces/jdbc/org/postgresql/Driver.java.in src/interfaces/jdbc/org/postgresql/Field.java src/interfaces/jdbc/org/postgresql/PG_Stream.java src/interfaces/jdbc/org/postgresql/PostgresqlDataSource.java src/interfaces/jdbc/org/postgresql/ResultSet.java src/interfaces/jdbc/org/postgresql/Statement.java src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java src/interfaces/jdbc/org/postgresql/core/Encoding.java src/interfaces/jdbc/org/postgresql/core/MemoryPool.java src/interfaces/jdbc/org/postgresql/core/ObjectPool.java src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java src/interfaces/jdbc/org/postgresql/core/SimpleObjectPool.java src/interfaces/jdbc/org/postgresql/core/StartupPacket.java src/interfaces/jdbc/org/postgresql/errors.properties src/interfaces/jdbc/org/postgresql/errors_de.properties src/interfaces/jdbc/org/postgresql/errors_fr.properties src/interfaces/jdbc/org/postgresql/errors_it.properties src/interfaces/jdbc/org/postgresql/errors_nl.properties src/interfaces/jdbc/org/postgresql/errors_zh_TW.properties src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java src/interfaces/jdbc/org/postgresql/fastpath/FastpathArg.java src/interfaces/jdbc/org/postgresql/geometric/PGbox.java src/interfaces/jdbc/org/postgresql/geometric/PGcircle.java src/interfaces/jdbc/org/postgresql/geometric/PGline.java src/interfaces/jdbc/org/postgresql/geometric/PGlseg.java src/interfaces/jdbc/org/postgresql/geometric/PGpath.java src/interfaces/jdbc/org/postgresql/geometric/PGpoint.java src/interfaces/jdbc/org/postgresql/geometric/PGpolygon.java src/interfaces/jdbc/org/postgresql/jdbc1/CallableStatement.java src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java src/interfaces/jdbc/org/postgresql/jdbc1/Statement.java src/interfaces/jdbc/org/postgresql/jdbc2/Array.java src/interfaces/jdbc/org/postgresql/jdbc2/CallableStatement.java src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java src/interfaces/jdbc/org/postgresql/jdbc2/PBatchUpdateException.java src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java src/interfaces/jdbc/org/postgresql/jdbc2/Statement.java src/interfaces/jdbc/org/postgresql/jdbc2/UpdateableResultSet.java src/interfaces/jdbc/org/postgresql/largeobject/BlobInputStream.java src/interfaces/jdbc/org/postgresql/largeobject/BlobOutputStream.java src/interfaces/jdbc/org/postgresql/largeobject/LargeObject.java src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java src/interfaces/jdbc/org/postgresql/largeobject/PGblob.java src/interfaces/jdbc/org/postgresql/largeobject/PGclob.java src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java src/interfaces/jdbc/org/postgresql/test/README src/interfaces/jdbc/org/postgresql/test/jdbc2/ANTTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/BatchExecuteTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/BlobTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/DateTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/DriverTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/EncodingTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/TimeTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java src/interfaces/jdbc/org/postgresql/util/MD5Digest.java src/interfaces/jdbc/org/postgresql/util/MessageTranslator.java src/interfaces/jdbc/org/postgresql/util/PGbytea.java src/interfaces/jdbc/org/postgresql/util/PGmoney.java src/interfaces/jdbc/org/postgresql/util/PGobject.java src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java src/interfaces/jdbc/org/postgresql/util/PSQLException.java src/interfaces/jdbc/org/postgresql/util/Serialize.java src/interfaces/jdbc/org/postgresql/util/UnixCrypt.java src/interfaces/jdbc/org/postgresql/xa/ClientConnection.java src/interfaces/jdbc/org/postgresql/xa/TwoPhaseConnection.java src/interfaces/jdbc/org/postgresql/xa/TxConnection.java src/interfaces/jdbc/org/postgresql/xa/XAConnectionImpl.java src/interfaces/jdbc/org/postgresql/xa/XADataSourceImpl.java src/interfaces/jdbc/utils/CheckVersion.java src/interfaces/jdbc/utils/buildDriver src/interfaces/jdbc/utils/changelog.pl src/interfaces/libpgeasy/Makefile src/interfaces/libpgeasy/README src/interfaces/libpgeasy/examples/Makefile src/interfaces/libpgeasy/examples/pginsert.c src/interfaces/libpgeasy/examples/pgmultiresult.c src/interfaces/libpgeasy/examples/pgnulltest.c src/interfaces/libpgeasy/examples/pgwordcount.c src/interfaces/libpgeasy/halt.c src/interfaces/libpgeasy/halt.h src/interfaces/libpgeasy/libpgeasy.c src/interfaces/libpgeasy/libpgeasy.h src/interfaces/libpgtcl/Makefile src/interfaces/libpgtcl/README src/interfaces/libpgtcl/libpgtcl.def src/interfaces/libpgtcl/libpgtcl.h src/interfaces/libpgtcl/pgtcl.c src/interfaces/libpgtcl/pgtclCmds.c src/interfaces/libpgtcl/pgtclCmds.h src/interfaces/libpgtcl/pgtclId.c src/interfaces/libpgtcl/pgtclId.h src/interfaces/libpgtcl/win32.mak src/interfaces/libpq/Makefile src/interfaces/libpq/README src/interfaces/libpq/cs.po src/interfaces/libpq/de.po src/interfaces/libpq/fe-auth.c src/interfaces/libpq/fe-auth.h src/interfaces/libpq/fe-connect.c src/interfaces/libpq/fe-exec.c src/interfaces/libpq/fe-lobj.c src/interfaces/libpq/fe-misc.c src/interfaces/libpq/fe-print.c src/interfaces/libpq/fe-secure.c src/interfaces/libpq/fr.po src/interfaces/libpq/libpq-fe.h src/interfaces/libpq/libpq-int.h src/interfaces/libpq/libpq.rc src/interfaces/libpq/libpqdll.c src/interfaces/libpq/libpqdll.def src/interfaces/libpq/nls.mk src/interfaces/libpq/pqexpbuffer.c src/interfaces/libpq/pqexpbuffer.h src/interfaces/libpq/pqsignal.c src/interfaces/libpq/pqsignal.h src/interfaces/libpq/ru.po src/interfaces/libpq/sv.po src/interfaces/libpq/win32.c src/interfaces/libpq/win32.h src/interfaces/libpq/win32.mak src/interfaces/libpq/zh_CN.po src/interfaces/libpq/zh_TW.po src/interfaces/libpq++/CHANGES src/interfaces/libpq++/Makefile src/interfaces/libpq++/README src/interfaces/libpq++/TODO src/interfaces/libpq++/examples/Makefile src/interfaces/libpq++/examples/testlibpq0.cc src/interfaces/libpq++/examples/testlibpq1.cc src/interfaces/libpq++/examples/testlibpq2.cc src/interfaces/libpq++/examples/testlibpq2.sql src/interfaces/libpq++/examples/testlibpq3.cc src/interfaces/libpq++/examples/testlibpq3.sql src/interfaces/libpq++/examples/testlibpq4.cc src/interfaces/libpq++/examples/testlibpq4.sql src/interfaces/libpq++/examples/testlibpq5.cc src/interfaces/libpq++/examples/testlibpq5.sql src/interfaces/libpq++/examples/testlibpq6.cc src/interfaces/libpq++/examples/testlo.cc src/interfaces/libpq++/libpq++.h src/interfaces/libpq++/libpq++dll.rc src/interfaces/libpq++/pgconnection.cc src/interfaces/libpq++/pgconnection.h src/interfaces/libpq++/pgcursordb.cc src/interfaces/libpq++/pgcursordb.h src/interfaces/libpq++/pgdatabase.cc src/interfaces/libpq++/pgdatabase.h src/interfaces/libpq++/pglobject.cc src/interfaces/libpq++/pglobject.h src/interfaces/libpq++/pgtransdb.cc src/interfaces/libpq++/pgtransdb.h src/interfaces/libpq++/win32.mak src/interfaces/odbc/GNUmakefile src/interfaces/odbc/bind.c src/interfaces/odbc/bind.h src/interfaces/odbc/columninfo.c src/interfaces/odbc/columninfo.h src/interfaces/odbc/connection.c src/interfaces/odbc/connection.h src/interfaces/odbc/convert.c src/interfaces/odbc/convert.h src/interfaces/odbc/descriptor.h src/interfaces/odbc/dlg_specific.c src/interfaces/odbc/dlg_specific.h src/interfaces/odbc/dlg_wingui.c src/interfaces/odbc/drvconn.c src/interfaces/odbc/environ.c src/interfaces/odbc/environ.h src/interfaces/odbc/execute.c src/interfaces/odbc/gpps.c src/interfaces/odbc/gpps.h src/interfaces/odbc/info.c src/interfaces/odbc/info30.c src/interfaces/odbc/iodbc.h src/interfaces/odbc/isql.h src/interfaces/odbc/isqlext.h src/interfaces/odbc/license.txt src/interfaces/odbc/lobj.c src/interfaces/odbc/lobj.h src/interfaces/odbc/md5.c src/interfaces/odbc/md5.h src/interfaces/odbc/misc.c src/interfaces/odbc/misc.h src/interfaces/odbc/multibyte.c src/interfaces/odbc/multibyte.h src/interfaces/odbc/notice.txt src/interfaces/odbc/odbc.sql src/interfaces/odbc/odbcapi.c src/interfaces/odbc/odbcapi25w.c src/interfaces/odbc/odbcapi30.c src/interfaces/odbc/odbcapi30w.c src/interfaces/odbc/odbcapiw.c src/interfaces/odbc/odbcinst.ini src/interfaces/odbc/options.c src/interfaces/odbc/parse.c src/interfaces/odbc/pgapi30.c src/interfaces/odbc/pgapifunc.h src/interfaces/odbc/pgtypes.c src/interfaces/odbc/pgtypes.h src/interfaces/odbc/psqlodbc.c src/interfaces/odbc/psqlodbc.h src/interfaces/odbc/psqlodbc.rc src/interfaces/odbc/psqlodbc.reg src/interfaces/odbc/psqlodbc30.reg src/interfaces/odbc/psqlodbc30w.reg src/interfaces/odbc/psqlodbc_api30.def src/interfaces/odbc/psqlodbc_api30w.def src/interfaces/odbc/psqlodbc_apiw.def src/interfaces/odbc/psqlodbc_win32.def src/interfaces/odbc/qresult.c src/interfaces/odbc/qresult.h src/interfaces/odbc/readme.txt src/interfaces/odbc/resource.h src/interfaces/odbc/results.c src/interfaces/odbc/setup.c src/interfaces/odbc/setup.rul src/interfaces/odbc/socket.c src/interfaces/odbc/socket.h src/interfaces/odbc/statement.c src/interfaces/odbc/statement.h src/interfaces/odbc/tuple.c src/interfaces/odbc/tuple.h src/interfaces/odbc/tuplelist.c src/interfaces/odbc/tuplelist.h src/interfaces/odbc/version.h src/interfaces/odbc/win32.mak src/interfaces/odbc/win32_30.mak src/interfaces/odbc/win32_30w.mak src/interfaces/odbc/win32w.mak src/interfaces/odbc/win_md5.c src/interfaces/odbc/win_setup.h src/interfaces/odbc/win_unicode.c src/interfaces/perl5/Changes src/interfaces/perl5/GNUmakefile src/interfaces/perl5/MANIFEST src/interfaces/perl5/Makefile.PL src/interfaces/perl5/Pg.pm src/interfaces/perl5/Pg.xs src/interfaces/perl5/README src/interfaces/perl5/examples/ApachePg.pl src/interfaces/perl5/examples/example.newstyle src/interfaces/perl5/examples/example.oldstyle src/interfaces/perl5/ppport.h src/interfaces/perl5/test.pl src/interfaces/perl5/typemap src/interfaces/python/Announce src/interfaces/python/ChangeLog src/interfaces/python/GNUmakefile src/interfaces/python/PyGreSQL.spec src/interfaces/python/README src/interfaces/python/README.linux src/interfaces/python/Setup.in.raw src/interfaces/python/pg.py src/interfaces/python/pgdb.py src/interfaces/python/pgmodule.c src/interfaces/python/setup.py src/interfaces/python/tutorial/advanced.py src/interfaces/python/tutorial/basics.py src/interfaces/python/tutorial/func.py src/interfaces/python/tutorial/syscat.py src/interfaces/ssl/client.conf src/interfaces/ssl/mkcert.sh src/interfaces/ssl/pgkeygen.sh src/interfaces/ssl/root.conf src/interfaces/ssl/server.conf src/makefiles/Makefile.aix src/makefiles/Makefile.beos src/makefiles/Makefile.bsdi src/makefiles/Makefile.darwin src/makefiles/Makefile.dgux src/makefiles/Makefile.freebsd src/makefiles/Makefile.hpux src/makefiles/Makefile.irix5 src/makefiles/Makefile.linux src/makefiles/Makefile.netbsd src/makefiles/Makefile.openbsd src/makefiles/Makefile.osf src/makefiles/Makefile.qnx4 src/makefiles/Makefile.sco src/makefiles/Makefile.solaris src/makefiles/Makefile.sunos4 src/makefiles/Makefile.svr4 src/makefiles/Makefile.ultrix4 src/makefiles/Makefile.univel src/makefiles/Makefile.unixware src/makefiles/Makefile.win src/nls-global.mk src/pl/Makefile src/pl/plperl/GNUmakefile src/pl/plperl/README src/pl/plperl/SPI.xs src/pl/plperl/eloglvl.c src/pl/plperl/eloglvl.h src/pl/plperl/plperl.c src/pl/plperl/ppport.h src/pl/plpgsql/Makefile src/pl/plpgsql/src/.cvsignore src/pl/plpgsql/src/INSTALL src/pl/plpgsql/src/Makefile src/pl/plpgsql/src/gram.y src/pl/plpgsql/src/pl_comp.c src/pl/plpgsql/src/pl_exec.c src/pl/plpgsql/src/pl_funcs.c src/pl/plpgsql/src/pl_handler.c src/pl/plpgsql/src/plpgsql.h src/pl/plpgsql/src/scan.l src/pl/plpgsql/test/README src/pl/plpgsql/test/expected/tables.out src/pl/plpgsql/test/expected/test.out src/pl/plpgsql/test/expected/triggers.out src/pl/plpgsql/test/expected/views.out src/pl/plpgsql/test/runtest src/pl/plpgsql/test/tables.sql src/pl/plpgsql/test/test.sql src/pl/plpgsql/test/triggers.sql src/pl/plpgsql/test/views.sql src/pl/plpython/Makefile src/pl/plpython/README src/pl/plpython/TODO src/pl/plpython/error.expected src/pl/plpython/feature.expected src/pl/plpython/plpython.c src/pl/plpython/plpython.h src/pl/plpython/plpython_depopulate.sql src/pl/plpython/plpython_deschema.sql src/pl/plpython/plpython_drop.sql src/pl/plpython/plpython_error.sql src/pl/plpython/plpython_function.sql src/pl/plpython/plpython_populate.sql src/pl/plpython/plpython_schema.sql src/pl/plpython/plpython_setof.sql src/pl/plpython/plpython_test.sql src/pl/plpython/test.sh src/pl/tcl/Makefile src/pl/tcl/license.terms src/pl/tcl/modules/Makefile src/pl/tcl/modules/README src/pl/tcl/modules/pltcl_delmod.in src/pl/tcl/modules/pltcl_listmod.in src/pl/tcl/modules/pltcl_loadmod.in src/pl/tcl/modules/unknown.pltcl src/pl/tcl/pltcl.c src/pl/tcl/test/README src/pl/tcl/test/runtest src/pl/tcl/test/test.expected src/pl/tcl/test/test_queries.sql src/pl/tcl/test/test_setup.sql src/template/aix src/template/beos src/template/bsdi src/template/darwin src/template/dgux src/template/freebsd src/template/hpux src/template/irix5 src/template/linux src/template/netbsd src/template/nextstep src/template/openbsd src/template/osf src/template/qnx4 src/template/sco src/template/solaris src/template/sunos4 src/template/svr4 src/template/ultrix4 src/template/univel src/template/unixware src/template/win src/test/Makefile src/test/bench/Makefile src/test/bench/WISC-README src/test/bench/create.sh src/test/bench/create.source src/test/bench/perquery src/test/bench/query01 src/test/bench/query02 src/test/bench/query03 src/test/bench/query04 src/test/bench/query05 src/test/bench/query06 src/test/bench/query07 src/test/bench/query08 src/test/bench/query09 src/test/bench/query10 src/test/bench/query11 src/test/bench/query12 src/test/bench/query13 src/test/bench/query14 src/test/bench/query15 src/test/bench/query16 src/test/bench/query17 src/test/bench/query18 src/test/bench/query19 src/test/bench/query20 src/test/bench/query21 src/test/bench/query22 src/test/bench/query23 src/test/bench/query24 src/test/bench/query25 src/test/bench/query26 src/test/bench/query27 src/test/bench/query28 src/test/bench/query29 src/test/bench/query30 src/test/bench/query31 src/test/bench/query32 src/test/bench/runwisc.sh src/test/bench/wholebench.sh src/test/examples/Makefile src/test/examples/testlibpq.c src/test/examples/testlibpq2.c src/test/examples/testlibpq2.sql src/test/examples/testlibpq3.c src/test/examples/testlibpq3.sql src/test/examples/testlibpq4.c src/test/examples/testlo.c src/test/locale/Makefile src/test/locale/README src/test/locale/de_DE.ISO8859-1/Makefile src/test/locale/de_DE.ISO8859-1/README src/test/locale/de_DE.ISO8859-1/expected/de-ctype.out src/test/locale/de_DE.ISO8859-1/expected/test-de-char.sql.out src/test/locale/de_DE.ISO8859-1/expected/test-de-select.sql.out src/test/locale/de_DE.ISO8859-1/expected/test-de-sort.out src/test/locale/de_DE.ISO8859-1/expected/test-de-text.sql.out src/test/locale/de_DE.ISO8859-1/expected/test-de-upper-char.sql.out src/test/locale/de_DE.ISO8859-1/expected/test-de-upper-text.sql.out src/test/locale/de_DE.ISO8859-1/expected/test-de-upper-varchar.sql.out src/test/locale/de_DE.ISO8859-1/expected/test-de-varchar.sql.out src/test/locale/de_DE.ISO8859-1/runall src/test/locale/de_DE.ISO8859-1/test-de-select.sql.in src/test/locale/de_DE.ISO8859-1/test-de-sort.in src/test/locale/de_DE.ISO8859-1/test-de-upper.sql.in src/test/locale/de_DE.ISO8859-1/test-de.sql.in src/test/locale/gr_GR.ISO8859-7/Makefile src/test/locale/gr_GR.ISO8859-7/README src/test/locale/gr_GR.ISO8859-7/expected/gr-ctype.out src/test/locale/gr_GR.ISO8859-7/expected/test-gr-char.sql.out src/test/locale/gr_GR.ISO8859-7/expected/test-gr-select.sql.out src/test/locale/gr_GR.ISO8859-7/expected/test-gr-sort.out src/test/locale/gr_GR.ISO8859-7/expected/test-gr-text.sql.out src/test/locale/gr_GR.ISO8859-7/expected/test-gr-varchar.sql.out src/test/locale/gr_GR.ISO8859-7/runall src/test/locale/gr_GR.ISO8859-7/test-gr-select.sql.in src/test/locale/gr_GR.ISO8859-7/test-gr-sort.in src/test/locale/gr_GR.ISO8859-7/test-gr.sql.in src/test/locale/koi8-r/Makefile src/test/locale/koi8-r/expected/koi8-ctype.out src/test/locale/koi8-r/expected/test-koi8-char.sql.out src/test/locale/koi8-r/expected/test-koi8-select.sql.out src/test/locale/koi8-r/expected/test-koi8-sort.out src/test/locale/koi8-r/expected/test-koi8-text.sql.out src/test/locale/koi8-r/expected/test-koi8-varchar.sql.out src/test/locale/koi8-r/runall src/test/locale/koi8-r/test-koi8-select.sql.in src/test/locale/koi8-r/test-koi8-sort.in src/test/locale/koi8-r/test-koi8.sql.in src/test/locale/koi8-to-win1251/Makefile src/test/locale/koi8-to-win1251/README src/test/locale/koi8-to-win1251/expected/test-koi8-char.sql.out src/test/locale/koi8-to-win1251/expected/test-koi8-select.sql.out src/test/locale/koi8-to-win1251/expected/test-koi8-sort.out src/test/locale/koi8-to-win1251/expected/test-koi8-text.sql.out src/test/locale/koi8-to-win1251/expected/test-koi8-varchar.sql.out src/test/locale/koi8-to-win1251/runall src/test/locale/koi8-to-win1251/test-koi8-select.sql.in src/test/locale/koi8-to-win1251/test-koi8-sort.in src/test/locale/koi8-to-win1251/test-koi8.sql.in src/test/locale/sort-test.pl src/test/locale/sort-test.py src/test/locale/test-ctype.c src/test/locale/test-pgsql-locale.c src/test/mb/README src/test/mb/expected/big5.out src/test/mb/expected/euc_cn.out src/test/mb/expected/euc_jp.out src/test/mb/expected/euc_kr.out src/test/mb/expected/euc_tw.out src/test/mb/expected/mule_internal.out src/test/mb/expected/sjis.out src/test/mb/expected/unicode.out src/test/mb/mbregress.sh src/test/mb/sql/big5.sql src/test/mb/sql/euc_cn.sql src/test/mb/sql/euc_jp.sql src/test/mb/sql/euc_kr.sql src/test/mb/sql/euc_tw.sql src/test/mb/sql/mule_internal.sql src/test/mb/sql/sjis.sql src/test/mb/sql/unicode.sql src/test/performance/results/PgSQL.970926 src/test/performance/runtests.pl src/test/performance/sqls/connection src/test/performance/sqls/crtsimple src/test/performance/sqls/crtsimpleidx src/test/performance/sqls/drpsimple src/test/performance/sqls/inssimple src/test/performance/sqls/inssimple.data src/test/performance/sqls/orbsimple src/test/performance/sqls/slcsimple src/test/performance/sqls/slcsimple.data src/test/performance/sqls/vacuum src/test/performance/start-pgsql.sh src/test/regress/GNUmakefile src/test/regress/Makefile src/test/regress/README src/test/regress/data/agg.data src/test/regress/data/constrf.data src/test/regress/data/constro.data src/test/regress/data/dept.data src/test/regress/data/desc.data src/test/regress/data/emp.data src/test/regress/data/hash.data src/test/regress/data/onek.data src/test/regress/data/person.data src/test/regress/data/real_city.data src/test/regress/data/rect.data src/test/regress/data/streets.data src/test/regress/data/stud_emp.data src/test/regress/data/student.data src/test/regress/data/tenk.data src/test/regress/expected/abstime-solaris-1947.out src/test/regress/expected/abstime.out src/test/regress/expected/aggregates.out src/test/regress/expected/alter_table.out src/test/regress/expected/arrays.out src/test/regress/expected/bit.out src/test/regress/expected/boolean.out src/test/regress/expected/box.out src/test/regress/expected/btree_index.out src/test/regress/expected/case.out src/test/regress/expected/char.out src/test/regress/expected/char_1.out src/test/regress/expected/circle.out src/test/regress/expected/comments.out src/test/regress/expected/create_aggregate.out src/test/regress/expected/create_index.out src/test/regress/expected/create_misc.out src/test/regress/expected/create_operator.out src/test/regress/expected/create_table.out src/test/regress/expected/create_type.out src/test/regress/expected/create_view.out src/test/regress/expected/date.out src/test/regress/expected/domain.out src/test/regress/expected/errors.out src/test/regress/expected/euc_cn.out src/test/regress/expected/euc_jp.out src/test/regress/expected/euc_kr.out src/test/regress/expected/euc_tw.out src/test/regress/expected/float4-exp-three-digits.out src/test/regress/expected/float4.out src/test/regress/expected/float8-exp-three-digits.out src/test/regress/expected/float8-fp-exception.out src/test/regress/expected/float8-small-is-zero.out src/test/regress/expected/float8.out src/test/regress/expected/foreign_key.out src/test/regress/expected/geometry-alpha-precision.out src/test/regress/expected/geometry-bsdi-precision.out src/test/regress/expected/geometry-i86-gnulibc.out src/test/regress/expected/geometry-intel-beos.out src/test/regress/expected/geometry-irix.out src/test/regress/expected/geometry-positive-zeros-bsd.out src/test/regress/expected/geometry-positive-zeros.out src/test/regress/expected/geometry-powerpc-aix4.out src/test/regress/expected/geometry-powerpc-darwin.out src/test/regress/expected/geometry-powerpc-linux-gnulibc1.out src/test/regress/expected/geometry-solaris-i386-pc.out src/test/regress/expected/geometry-solaris-precision.out src/test/regress/expected/geometry-uw7-cc.out src/test/regress/expected/geometry-uw7-gcc.out src/test/regress/expected/geometry.out src/test/regress/expected/hash_index.out src/test/regress/expected/horology-no-DST-before-1970.out src/test/regress/expected/horology-solaris-1947.out src/test/regress/expected/horology.out src/test/regress/expected/inet.out src/test/regress/expected/inherit.out src/test/regress/expected/insert.out src/test/regress/expected/int2.out src/test/regress/expected/int4.out src/test/regress/expected/int8-exp-three-digits.out src/test/regress/expected/int8.out src/test/regress/expected/interval.out src/test/regress/expected/join.out src/test/regress/expected/limit.out src/test/regress/expected/lseg.out src/test/regress/expected/mule_internal.out src/test/regress/expected/name.out src/test/regress/expected/numeric.out src/test/regress/expected/numeric_big.out src/test/regress/expected/numerology.out src/test/regress/expected/oid.out src/test/regress/expected/oidjoins.out src/test/regress/expected/opr_sanity.out src/test/regress/expected/path.out src/test/regress/expected/plpgsql.out src/test/regress/expected/point.out src/test/regress/expected/polygon.out src/test/regress/expected/portals.out src/test/regress/expected/portals_p2.out src/test/regress/expected/privileges.out src/test/regress/expected/random.out src/test/regress/expected/reltime.out src/test/regress/expected/rules.out src/test/regress/expected/sanity_check.out src/test/regress/expected/select.out src/test/regress/expected/select_distinct.out src/test/regress/expected/select_distinct_on.out src/test/regress/expected/select_having.out src/test/regress/expected/select_having_1.out src/test/regress/expected/select_implicit.out src/test/regress/expected/select_implicit_1.out src/test/regress/expected/select_into.out src/test/regress/expected/select_views.out src/test/regress/expected/select_views_1.out src/test/regress/expected/sql_ascii.out src/test/regress/expected/strings.out src/test/regress/expected/subselect.out src/test/regress/expected/temp.out src/test/regress/expected/text.out src/test/regress/expected/time.out src/test/regress/expected/timestamp.out src/test/regress/expected/timestamptz.out src/test/regress/expected/timetz.out src/test/regress/expected/tinterval-solaris-1947.out src/test/regress/expected/tinterval.out src/test/regress/expected/transactions.out src/test/regress/expected/triggers.out src/test/regress/expected/type_sanity.out src/test/regress/expected/union.out src/test/regress/expected/varchar.out src/test/regress/expected/varchar_1.out src/test/regress/input/constraints.source src/test/regress/input/copy.source src/test/regress/input/create_function_1.source src/test/regress/input/create_function_2.source src/test/regress/input/misc.source src/test/regress/output/constraints.source src/test/regress/output/copy.source src/test/regress/output/create_function_1.source src/test/regress/output/create_function_2.source src/test/regress/output/misc.source src/test/regress/parallel_schedule src/test/regress/pg_regress.sh src/test/regress/regress.c src/test/regress/regressplans.sh src/test/regress/resultmap src/test/regress/serial_schedule src/test/regress/sql/abstime.sql src/test/regress/sql/aggregates.sql src/test/regress/sql/alter_table.sql src/test/regress/sql/arrays.sql src/test/regress/sql/bit.sql src/test/regress/sql/boolean.sql src/test/regress/sql/box.sql src/test/regress/sql/btree_index.sql src/test/regress/sql/case.sql src/test/regress/sql/char.sql src/test/regress/sql/circle.sql src/test/regress/sql/comments.sql src/test/regress/sql/create_aggregate.sql src/test/regress/sql/create_index.sql src/test/regress/sql/create_misc.sql src/test/regress/sql/create_operator.sql src/test/regress/sql/create_table.sql src/test/regress/sql/create_type.sql src/test/regress/sql/create_view.sql src/test/regress/sql/date.sql src/test/regress/sql/domain.sql src/test/regress/sql/drop.sql src/test/regress/sql/errors.sql src/test/regress/sql/euc_cn.sql src/test/regress/sql/euc_jp.sql src/test/regress/sql/euc_kr.sql src/test/regress/sql/euc_tw.sql src/test/regress/sql/float4.sql src/test/regress/sql/float8.sql src/test/regress/sql/foreign_key.sql src/test/regress/sql/geometry.sql src/test/regress/sql/hash_index.sql src/test/regress/sql/horology.sql src/test/regress/sql/inet.sql src/test/regress/sql/inherit.sql src/test/regress/sql/insert.sql src/test/regress/sql/int2.sql src/test/regress/sql/int4.sql src/test/regress/sql/int8.sql src/test/regress/sql/interval.sql src/test/regress/sql/join.sql src/test/regress/sql/limit.sql src/test/regress/sql/lseg.sql src/test/regress/sql/mule_internal.sql src/test/regress/sql/name.sql src/test/regress/sql/numeric.sql src/test/regress/sql/numeric_big.sql src/test/regress/sql/numerology.sql src/test/regress/sql/oid.sql src/test/regress/sql/oidjoins.sql src/test/regress/sql/opr_sanity.sql src/test/regress/sql/path.sql src/test/regress/sql/plpgsql.sql src/test/regress/sql/point.sql src/test/regress/sql/polygon.sql src/test/regress/sql/portals.sql src/test/regress/sql/portals_p2.sql src/test/regress/sql/privileges.sql src/test/regress/sql/random.sql src/test/regress/sql/reltime.sql src/test/regress/sql/rules.sql src/test/regress/sql/sanity_check.sql src/test/regress/sql/select.sql src/test/regress/sql/select_distinct.sql src/test/regress/sql/select_distinct_on.sql src/test/regress/sql/select_having.sql src/test/regress/sql/select_implicit.sql src/test/regress/sql/select_into.sql src/test/regress/sql/select_views.sql src/test/regress/sql/sql_ascii.sql src/test/regress/sql/strings.sql src/test/regress/sql/subselect.sql src/test/regress/sql/temp.sql src/test/regress/sql/text.sql src/test/regress/sql/time.sql src/test/regress/sql/timestamp.sql src/test/regress/sql/timestamptz.sql src/test/regress/sql/timetz.sql src/test/regress/sql/tinterval.sql src/test/regress/sql/transactions.sql src/test/regress/sql/triggers.sql src/test/regress/sql/type_sanity.sql src/test/regress/sql/union.sql src/test/regress/sql/varchar.sql src/tools/RELEASE_CHANGES src/tools/backend/README src/tools/backend/backend_dirs.html src/tools/backend/flow.fig src/tools/backend/flow.gif src/tools/backend/index.html src/tools/ccsym src/tools/copyright src/tools/entab/Makefile src/tools/entab/entab.c src/tools/entab/entab.man src/tools/entab/halt.c src/tools/find_badmacros src/tools/find_static src/tools/find_typedef src/tools/make_ctags src/tools/make_diff/README src/tools/make_diff/cporig src/tools/make_diff/difforig src/tools/make_diff/rmorig src/tools/make_etags src/tools/make_keywords src/tools/make_mkid src/tools/pgcvslog src/tools/pginclude/README src/tools/pginclude/pgcompinclude src/tools/pginclude/pgdefine src/tools/pginclude/pgfixinclude src/tools/pginclude/pgrminclude src/tools/pgindent/README src/tools/pgindent/indent.bsd.patch src/tools/pgindent/pgcppindent src/tools/pgindent/pgindent src/tools/pgindent/pgjindent src/tutorial/Makefile src/tutorial/README src/tutorial/advanced.source src/tutorial/basics.source src/tutorial/beard.c src/tutorial/complex.c src/tutorial/complex.source src/tutorial/funcs.c src/tutorial/funcs.source src/tutorial/funcs_new.c src/tutorial/syscat.source src/utils/Makefile src/utils/README src/utils/dllinit.c src/utils/getopt.c src/utils/strdup.c src/win32.mak
Diffstat (limited to 'src/interfaces/jdbc')
-rw-r--r--src/interfaces/jdbc/CHANGELOG467
-rw-r--r--src/interfaces/jdbc/Implementation199
-rw-r--r--src/interfaces/jdbc/Makefile42
-rw-r--r--src/interfaces/jdbc/README277
-rw-r--r--src/interfaces/jdbc/build.xml245
-rw-r--r--src/interfaces/jdbc/example/ImageViewer.java517
-rw-r--r--src/interfaces/jdbc/example/Unicode.java278
-rw-r--r--src/interfaces/jdbc/example/basic.java219
-rw-r--r--src/interfaces/jdbc/example/blobtest.java255
-rw-r--r--src/interfaces/jdbc/example/corba/StockClient.java348
-rw-r--r--src/interfaces/jdbc/example/corba/StockDB.java134
-rw-r--r--src/interfaces/jdbc/example/corba/StockDispenserImpl.java92
-rw-r--r--src/interfaces/jdbc/example/corba/StockItemImpl.java208
-rw-r--r--src/interfaces/jdbc/example/corba/StockServer.java58
-rw-r--r--src/interfaces/jdbc/example/corba/readme34
-rwxr-xr-xsrc/interfaces/jdbc/example/corba/stock.idl40
-rw-r--r--src/interfaces/jdbc/example/corba/stock.sql27
-rw-r--r--src/interfaces/jdbc/example/datestyle.java187
-rw-r--r--src/interfaces/jdbc/example/metadata.java297
-rw-r--r--src/interfaces/jdbc/example/psql.java235
-rw-r--r--src/interfaces/jdbc/example/threadsafe.java403
-rw-r--r--src/interfaces/jdbc/jdbc.jpx31
-rw-r--r--src/interfaces/jdbc/org/postgresql/Connection.java1246
-rw-r--r--src/interfaces/jdbc/org/postgresql/Driver.java.in492
-rw-r--r--src/interfaces/jdbc/org/postgresql/Field.java107
-rw-r--r--src/interfaces/jdbc/org/postgresql/PG_Stream.java374
-rw-r--r--src/interfaces/jdbc/org/postgresql/PostgresqlDataSource.java605
-rw-r--r--src/interfaces/jdbc/org/postgresql/ResultSet.java264
-rw-r--r--src/interfaces/jdbc/org/postgresql/Statement.java331
-rw-r--r--src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java100
-rw-r--r--src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java69
-rw-r--r--src/interfaces/jdbc/org/postgresql/core/Encoding.java226
-rw-r--r--src/interfaces/jdbc/org/postgresql/core/MemoryPool.java19
-rw-r--r--src/interfaces/jdbc/org/postgresql/core/ObjectPool.java49
-rw-r--r--src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java211
-rw-r--r--src/interfaces/jdbc/org/postgresql/core/SimpleObjectPool.java106
-rw-r--r--src/interfaces/jdbc/org/postgresql/core/StartupPacket.java43
-rw-r--r--src/interfaces/jdbc/org/postgresql/errors.properties85
-rw-r--r--src/interfaces/jdbc/org/postgresql/errors_de.properties78
-rw-r--r--src/interfaces/jdbc/org/postgresql/errors_fr.properties6
-rw-r--r--src/interfaces/jdbc/org/postgresql/errors_it.properties76
-rw-r--r--src/interfaces/jdbc/org/postgresql/errors_nl.properties66
-rw-r--r--src/interfaces/jdbc/org/postgresql/errors_zh_TW.properties79
-rw-r--r--src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java291
-rw-r--r--src/interfaces/jdbc/org/postgresql/fastpath/FastpathArg.java109
-rw-r--r--src/interfaces/jdbc/org/postgresql/geometric/PGbox.java106
-rw-r--r--src/interfaces/jdbc/org/postgresql/geometric/PGcircle.java112
-rw-r--r--src/interfaces/jdbc/org/postgresql/geometric/PGline.java104
-rw-r--r--src/interfaces/jdbc/org/postgresql/geometric/PGlseg.java101
-rw-r--r--src/interfaces/jdbc/org/postgresql/geometric/PGpath.java151
-rw-r--r--src/interfaces/jdbc/org/postgresql/geometric/PGpoint.java171
-rw-r--r--src/interfaces/jdbc/org/postgresql/geometric/PGpolygon.java108
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/CallableStatement.java322
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java214
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java2838
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java799
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java1006
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java476
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/Statement.java144
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/Array.java351
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/CallableStatement.java376
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java333
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java3247
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/PBatchUpdateException.java49
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java1065
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java1777
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java538
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/Statement.java381
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/UpdateableResultSet.java1391
-rw-r--r--src/interfaces/jdbc/org/postgresql/largeobject/BlobInputStream.java187
-rw-r--r--src/interfaces/jdbc/org/postgresql/largeobject/BlobOutputStream.java119
-rw-r--r--src/interfaces/jdbc/org/postgresql/largeobject/LargeObject.java320
-rw-r--r--src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java206
-rw-r--r--src/interfaces/jdbc/org/postgresql/largeobject/PGblob.java72
-rw-r--r--src/interfaces/jdbc/org/postgresql/largeobject/PGclob.java77
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java234
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/README323
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/ANTTest.java29
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/BatchExecuteTest.java199
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/BlobTest.java201
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java340
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java408
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/DateTest.java142
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/DriverTest.java84
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/EncodingTest.java62
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java70
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java102
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java86
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/TimeTest.java122
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java148
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java135
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/MD5Digest.java80
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/MessageTranslator.java79
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/PGbytea.java102
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/PGmoney.java115
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/PGobject.java101
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java204
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/PSQLException.java116
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/Serialize.java623
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/UnixCrypt.java684
-rw-r--r--src/interfaces/jdbc/org/postgresql/xa/ClientConnection.java567
-rw-r--r--src/interfaces/jdbc/org/postgresql/xa/TwoPhaseConnection.java116
-rw-r--r--src/interfaces/jdbc/org/postgresql/xa/TxConnection.java129
-rw-r--r--src/interfaces/jdbc/org/postgresql/xa/XAConnectionImpl.java956
-rw-r--r--src/interfaces/jdbc/org/postgresql/xa/XADataSourceImpl.java489
-rw-r--r--src/interfaces/jdbc/utils/CheckVersion.java74
-rwxr-xr-xsrc/interfaces/jdbc/utils/buildDriver47
-rw-r--r--src/interfaces/jdbc/utils/changelog.pl23
108 files changed, 0 insertions, 33956 deletions
diff --git a/src/interfaces/jdbc/CHANGELOG b/src/interfaces/jdbc/CHANGELOG
deleted file mode 100644
index 863f8360ba9..00000000000
--- a/src/interfaces/jdbc/CHANGELOG
+++ /dev/null
@@ -1,467 +0,0 @@
-Tue Mar 06 12:05:00 GMT 2001 peter@retep.org.uk
- - Removed org.postgresql.xa.Test from the JDBC EE driver as it's an old
- test class and prevented it from compiling.
-
-Fri Mar 02 10:00:00 GMT 2001 peter@retep.org.uk
- - Fixed build.xml so that PGclob is not built in the JDBC1.2 driver
-
-
-Fri Feb 17 18:25:00 GMT 2001 peter@retep.org.uk
- - Removed the last deprecation warnings from the Java2 driver. Now only
- the old examples give deprecation warnings.
- - Added a new class into core that (JDK1.3+) ensures all connections are
- closed when the VM terminates.
-
-Fri Feb 17 15:11:00 GMT 2001 peter@retep.org.uk
- - Reduced the object overhead in PreparedStatement by reusing the same
- StringBuffer object throughout. Similarly SimpleDateStamp's are alse
- reused in a thread save manner.
- - Implemented in PreparedStatement: setNull(), setDate/Time/Timestamp
- using Calendar, setBlob(), setCharacterStream()
- - Clob's are now implemented in ResultSet & PreparedStatement!
- - Implemented a lot of DatabaseMetaData & ResultSetMetaData methods.
- We have about 18 unimplemented methods left in JDBC2 at the current
- time.
-
-Web Feb 14 17:29:00 GMT 2001 peter@retep.org.uk
- - Fixed bug in LargeObject & BlobOutputStream where the stream's output
- was not flushed when either the stream or the blob were closed.
- - Fixed PreparedStatement.setBinaryStream() where it ignored the length
-
-Tue Feb 13 16:33:00 GMT 2001 peter@retep.org.uk
- - More TestCases implemented. Refined the test suite api's.
- - Removed need for SimpleDateFormat in ResultSet.getDate() improving
- performance.
- - Rewrote ResultSet.getTime() so that it uses JDK api's better.
-
-Tue Feb 13 10:25:00 GMT 2001 peter@retep.org.uk
- - Added MiscTest to hold reported problems from users.
- - Fixed PGMoney.
- - JBuilder4/JDBCExplorer now works with Money fields. Patched Field &
- ResultSet (lots of methods) for this one. Also changed cash/money to
- return type DOUBLE not DECIMAL. This broke JBuilder as zero scale
- BigDecimal's can't have decimal places!
- - When a Statement is reused, the previous ResultSet is now closed.
- - Removed deprecated call in ResultSet.getTime()
-
-Thu Feb 08 18:53:00 GMT 2001 peter@retep.org.uk
- - Changed a couple of settings in DatabaseMetaData where 7.1 now
- supports those features
- - Implemented the DatabaseMetaData TestCase.
-
-Wed Feb 07 18:06:00 GMT 2001 peter@retep.org.uk
- - Added comment to Connection.isClosed() explaining why we deviate from
- the JDBC2 specification.
- - Fixed bug where the Isolation Level is lost while in autocommit mode.
- - Fixed bug where several calls to getTransactionIsolationLevel()
- returned the first call's result.
-
-Tue Feb 06 19:00:00 GMT 2001 peter@retep.org.uk
- - Completed first two TestCase's for the test suite. JUnit is now
- recognised by ant.
-
-Wed Jan 31 08:46:00 GMT 2001 peter@retep.org.uk
- - Some minor additions to Statement to make our own extensions more
- portable.
- - Statement.close() will now call ResultSet.close() rather than just
- dissasociating with it.
-
-Tue Jan 30 22:24:00 GMT 2001 peter@retep.org.uk
- - Fixed bug where Statement.setMaxRows() was a global setting. Now
- limited to just itself.
- - Changed LargeObject.read(byte[],int,int) to return the actual number
- of bytes read (used to be void).
- - LargeObject now supports InputStream's!
- - PreparedStatement.setBinaryStream() now works!
- - ResultSet.getBinaryStream() now returns an InputStream that doesn't
- copy the blob into memory first!
- - Connection.isClosed() now tests to see if the connection is still alive
- rather than if it thinks it's alive.
-Thu Jan 25 09:11:00 GMT 2001 peter@retep.org.uk
- - Added an alternative constructor to PGSQLException so that debugging
- some more osteric bugs is easier. If only 1 arg is supplied and it's
- of type Exception, then that Exception's stacktrace is now included.
-
-Wed Jan 24 09:18:00 GMT 2001 peter@retep.org.uk
- - Removed the 8k limit by setting it to 64k
-
-Fri Jan 19 08:47:00 GMT 2001 peter@retep.org.uk
- - Applied patch submitted by John Schutz <schutz@austin.rr.com> that
- fixed a bug with ANT's SQL functions (not needed for building but nice
- to have fixed).
-
-Thu Jan 18 17:30:00 GMT 2001 peter@retep.org.uk
- - Added new error message into errors.properties "postgresql.notsensitive"
- This is used by jdbc2.ResultSet when a method is called that should
- fetch the current value of a row from the database refreshRow() for
- example.
- - These methods no longer throw the not implemented but the new noupdate
- error. This is in preparation for the Updateable ResultSet support
- which will overide these methods by extending the existing class to
- implement that functionality, but needed to show something other than
- notimplemented:
- moveToCurrentRow()
- moveToInsertRow()
- rowDeleted()
- rowInserted()
- all update*() methods, except those that took the column as a String
- as they were already implemented to convert the String to an int.
- - getFetchDirection() and setFetchDirection() now throws
- "postgresql.notimp" as we only support one direction.
- The CursorResultSet will overide this when its implemented.
- - Created a new class under jdbc2 UpdateableResultSet which extends
- ResultSet and overides the relevent update methods.
- This allows us to implement them easily at a later date.
- - In jdbc2.Connection, the following methods are now implemented:
- createStatement(type,concurrency);
- getTypeMap();
- setTypeMap(Map);
- - The JDBC2 type mapping scheme almost complete, just needs SQLInput &
- SQLOutput to be implemented.
- - Removed some Statement methods that somehow appeared in Connection.
- - In jdbc2.Statement()
- getResultSetConcurrency()
- getResultSetType()
- setResultSetConcurrency()
- setResultSetType()
- - Finally removed the old 6.5.x driver.
-
-Thu Jan 18 12:24:00 GMT 2001 peter@retep.org.uk
- - These methods in org.postgresql.jdbc2.ResultSet are now implemented:
- getBigDecimal(int) ie: without a scale (why did this get missed?)
- getBlob(int)
- getCharacterStream(int)
- getConcurrency()
- getDate(int,Calendar)
- getFetchDirection()
- getFetchSize()
- getTime(int,Calendar)
- getTimestamp(int,Calendar)
- getType()
- NB: Where int represents the column name, the associated version
- taking a String were already implemented by calling the int
- version.
- - These methods no longer throw the not implemented but the new noupdate
- error. This is in preparation for the Updateable ResultSet support
- which will overide these methods by extending the existing class to
- implement that functionality, but needed to show something other than
- notimplemented:
- cancelRowUpdates()
- deleteRow()
- - Added new error message into errors.properties "postgresql.noupdate"
- This is used by jdbc2.ResultSet when an update method is called and
- the ResultSet is not updateable. A new method notUpdateable() has been
- added to that class to throw this exception, keeping the binary size
- down.
- - Added new error message into errors.properties "postgresql.psqlnotimp"
- This is used instead of unimplemented when it's a feature in the
- backend that is preventing this method from being implemented.
- - Removed getKeysetSize() as its not part of the ResultSet API
-
-Thu Jan 18 09:46:00 GMT 2001 peter@retep.org.uk
- - Applied modified patch from Richard Bullington-McGuire
- <rbulling@microstate.com>. I had to modify it as some of the code
- patched now exists in different classes, and some of it actually
- patched obsolete code.
-
-Wed Jan 17 10:19:00 GMT 2001 peter@retep.org.uk
- - Updated Implementation to include both ANT & JBuilder
- - Updated README to reflect the changes since 7.0
- - Created jdbc.jpr file which allows JBuilder to be used to edit the
- source. JBuilder _CAN_NOT_ be used to compile. You must use ANT for
- that. It's only to allow JBuilders syntax checking to improve the
- drivers source. Refer to Implementation for more details
-
-Wed Dec 20 16:19:00 GMT 2000 peter@retep.org.uk
- - Finished build.xml and updated Driver.java.in and buildDriver to
- match how Makefile and ANT operate.
-
-Tue Dec 19 17:30:00 GMT 2000 peter@retep.org.uk
- - Finally created ant build.xml file
-
-Mon Nov 20 08:12:00 GMT 2000 peter@retep.org.uk
- - Encoding patch to Connection by wrobell@posexperts.com.pl
-
-Tue Oct 17 15:35:00 BST 2000 petermount@maidstone.gov.uk
- - Changed getTimestamp() again. This time Michael Stephenson's
- <mstephenson@tirin.openworld.co.uk> solution looked far better
- than the original solution put in June.
-
-Tue Oct 10 13:12:00 BST 2000 peter@retep.org.uk
- - DatabaseMetaData.supportsAlterTableWithDropColumn() as psql doesn't
- support dropping of individual columns
- - Merged in some last patches. Only 1 left, which may not be compatible
- with jdbc1
- - Merged in my old retepsql project. Makefile now includes it.
-
-Mon Oct 02 12:30:00 BST 2000 peter@retep.org.uk
- - Merged in byte[] array allocation changes submitted by Gunnar R|nning
- <gunnar@candleweb.no>
-
-Mon Sep 25 14:22:00 BST 2000 peter@retep.org.uk
- - Removed the DriverClass kludge. Now the org.postgresql.Driver class
- is compiled from a template file, and now has both the connection
- class (ie jdbc1/jdbc2) and the current version's from Makefile.global
-
-Thu Jul 20 16:30:00 BST 2000 petermount@it.maidstone.gov.uk
- - Fixed DatabaseMetaData.getTableTypes()
-
-Tue Jun 06 12:00:00 BST 2000 petermount@it.maidstone.gov.uk
- - Added org/postgresql/DriverClass.java to the list of files removed
- by make clean (it's dynamically built)
- - Fixed Statement, so that the update count is valid when an SQL
- DELETE operation is done.
- - While fixing the update count, made it easier to get the OID of
- the last insert as well. Example is in example/basic.java
-
-Tue Jun 06 08:37:00 BST 2000 petermount@it.maidstone.gov.uk
- - Removed a hardwired 8K limit on query strings
- - Added some missing org.'s in Connection that prevented
- the use of the geometric types.
-
-Thu Jun 01 07:26:00 BST 2000 petermount@it.maidstone.gov.uk
- - Removed timezone in getTimestamp() methods in ResultSet.
-
-Mon May 15 22:30:00 BST 2000 peter@retep.org.uk
- - Fixed the message Makefile produces after compiling. It still said
- about the old Driver class, not the new package. Spotted by
- Joseph Shraibman <jks@p1.selectacast.net>
-
-Thu May 04 11:38:00 BST 2000 petermount@it.maidstone.gov.uk
- - Corrected incorrect date in CHANGELOG
- - Fixed the ImageViewer example
-
-Wed May 03 16:47:00 BST 2000 petermount@it.maidstone.gov.uk
- - Fixed the Makefile so that postgresql.jar is built everytime
- the jdbc1 or jdbc2 rules are called.
- - Fixed the threadsafe example. It had problems with autocommit
-
-Wed May 03 14:32:00 BST 2000 petermount@it.maidstone.gov.uk
- - Rewrote the README file (the old one was 18 months old!)
- - Added @deprecated tags to org.postgresql.jdbc2.ResultSet
- to clear some warnings issued during compilation.
-
-Wed Apr 12 22:14:00 BST 2000 peter@retep.org.uk
- - Implemented the JDBC2 Blob interface, and ResultSet.getBlob().
-
-Wed Apr 12 20:20:00 BST 2000 peter@retep.org.uk
- - Fixed bug in ResultSet.absolute(). Negative rows are now supported.
- - Implemented ResultSet.relative(), afterLast().
-
-Tue Feb 1 21:40:00 GMT 2000 peter@retep.org.uk
- - Finally imported the contributed javax extensions by Assaf Arkin
- arkin@exoffice.com
-
-Mon Jan 24 21:00:00 GMT 2000 peter@retep.org.uk
- - Finally introduced the 7.0 additions to the core CVS repository.
- - All source files are now under the org.postgresql package (previously
- they were under postgresql). The package lines now changed
- accordingly.
- - The Makefile was rewritten so it should now work on machines that
- can't handle the $( ) syntax.
- - Dutch translation by Arnout Kuiper (ajkuiper@wxs.nl)
-
-Mon Sep 13 23:56:00 BST 1999 peter@retep.org.uk
- - PG_Stream.SendChar() optimised, increased default buffer size of
- output stream to 8k, and introduced an 8k buffer on the input stream
- Sverre H Huseby <sverrehu@online.no>
- - Added a finalize() method to Connection class in both drivers so that
- the connection to the backend is really closed.
- - Due to many JVM's not returning a meaningful value for java.version
- the decision for building the JDBC1.2 or JDBC2 driver is now a
- compile time option.
- - Replaced $$(cmd...) with `cmd...` in the Makefile. This should allow
- the driver to compile when using shells other than Bash.
-
-Thu Sep 9 01:18:39 MEST 1999 jens@jens.de
- - fixed bug in handling of DECIMAL type
-
-Wed Aug 4 00:25:18 CEST 1999 jens@jens.de
- - updated ResultSetMetaData.getColumnDisplaySize() to return
- the actual display size
- - updated driver to use postgresql FE/BE-protocol version 2
-
-Mon Aug 2 03:29:35 CEST 1999 jens@jens.de
- - fixed bug in DatabaseMetaData.getPrimaryKeys()
-
-Sun Aug 1 18:05:42 CEST 1999 jens@jens.de
- - added support for getTransactionIsolation and setTransactionIsolation
-
-Sun Jun 27 12:00:00 BST 1999
- - Fixed typo in postgresql.Driver that prevented compilation
- - Implemented getTimestamp() fix submitted by Philipp Matthias Hahn
- <pmhahn@titan.lahn.de>
- - Cleaned up some comments in Connection
-
-Wed Jun 23 06:50:00 BST 1999
- - Fixed error in errors.properties where the arguments are 0 based not
- 1 based
- - Fixed bug in postgresql.Driver where exception is thrown, then
- intercepted rather than being passed to the calling application.
- - Removed the file postgresql/CallableStatement, as it's not used and
- really exists in the jdbc1 & jdbc2 sub packages only.
-
-Wed May 19 00:20:00 BST 1999
- - Internationalisation now done. Surprising that there's 68 error
- messages in the driver ;-)
-
-Tue May 18 07:00:00 BST 1999
- - Set the ImageViewer application to use transactions
-
-Tue May 18 00:00:00 BST 1999
- - Just after committing, I realised why internationalisation isn't
- working. This is now fixed (in the Makefile).
-
-Mon May 17 23:40:00 BST 1999
- - PG_Stream.close() now attempts to send the close connection message
- to the backend before closing the streams
- - Added batch support in the JDBC2, supplied by Yutaka Tanida
- <yutaka@marin.or.jp>
- - Removed the old datestyle code. Now the driver uses only ISO.
- - Removed some files in the postgresql directory still in CVS that were
- moved since 6.4.x (DatabaseMetaData.java PreparedStatement.java
- ResultSetMetaData.java Statement.java)
- - Internationalisation of the error messages is partially implemented,
- however it's not enabled as it only works when the jar file is
- _not_ used, and work needs to be done.
-
-Sun Apr 11 17:00:00 BST 1999
- - getUpdateCount() now returns the actual update count (before it
- simply returned 1 for everything).
- - added some updates to example.basic so it would test the new update
- count code.
- - corrected typo in a comment in Statement.java
-
-Mon Jan 25 19:45:00 GMT 1999
- - created subfolders example/corba and example/corba/idl to hold the
- new example showing how to hook CORBA and PostgreSQL via JDBC
- - implemented some JDBC2 methods curtesy of Joachim.Gabler@t-online.de
-
-Sat Jan 23 10:30:00 GMT 1999
- - Changed imports in postgresql.jdbc1.ResultSetMetaData as for some
- reason it didn't want to compile under jdk1.1.6
-
-Tue Dec 29 15:45:00 GMT 1998
- - Refreshed the README (which was way out of date)
-
-Tue Dec 29 15:45:00 GMT 1998
- - Finished adding the additional methods into the JDBC2 driver.
- - Had to add some explicit package references for the JDK1.2 Javac to
- cope with the driver
-
-Tue Dec 29 12:40:00 GMT 1998
- - Fixed package imports and some references to java.sql.ResultSet in
- various files. Compiled and tested the JDBC1 driver.
-
-Mon Dec 28 19:01:37 GMT 1998
- - created a new package postgresql.jdbc2 which will contain the JDBC 2
- specific classes. A similar new package (postgresql.jdbc1) has been
- created to hold the JDBC 1 specific classes.
- - modified Makefile to allow compilation of the JDBC 1 & 2 drivers,
- with the possibility of building a dual-spec driver.
- - changed the version number in postgresql.Driver to 6.5
- - modified postgresql.Driver class to initiate the correct driver when
- used under a 1.1 or 1.2+ JVM.
- - postgresql.Connection and postgresql.jdbc2.Connection now extends the
- new class postgresql.ConnectionStub, which allows us to dynamically
- open the JDBC1 or JDBC2 drivers.
- - enabled compilation of the driver under Win32 when using the Make
- from the CygWin package (Cygnus B20.1 was used).
- - To make future development easier (now we have 2 specifications to
- work with) the following classes have moved from the postgresql to
- the postgresql.jdbc1 package:
- CallableStatement Connection
- DatabaseMetaData PreparedStatement
- ResultSet ResultSetMetaData
- Statement
- Some of these classes have common code that is not dependent on
- either JDBC specification. These common code are still in the
- postgresql package.
- Ie: postgresql.jdbc1.Connection extends postgresql.Connection
- and postgresql.jdbc2.Connection extends postgresql.Connection
-
-Web Oct 7 22:00:00 BST 1998
- - removed syncronised from Connection.ExecSQL(). See next entry.
- - added new syncronised locking in the Connection.ExecSQL() and
- FastPath.fastpath() methods. They now lock against the PG_Steam
- object for the connection, which now provides full Thread Safety.
- - Reposted ChangeLog as it's missing from CVS.
-
-Modifications done since 6.3.2 was released and Sun Aug 30 11:33:06 BST 1998
-
- - Fixed PreparedStatement.setObject as it didn't handle shorts
- - ResultSet.getDate() now handles null dates (returns null ratrher
- than a NullPointerException)
- - ResultSetMetaData.getPrecision() new returns 0 for VARCHAR
- - Field now caches the typename->oid in a Hashtable to speed things
- up. It removes the need for some unnecessary queries to the backend.
- - PreparedStatement.toString() now returns the SQL statement that it
- will send to the backend. Before it did nothing.
- - DatabaseMetaData.getTypeInfo() now does something.
- - Connection now throws an exception if either of the user or password
- properties are missing, as they are required for JDBC to work.
- This occasionally occurs when the client uses the properties version
- of getConnection(), and is a common question on the email lists.
-
-Sun Aug 30 11:33:06 BST 1998
-
- - Created ChangeLog file, and entered stuff done since 6.3.2 and today
- - Change version number to 6.4 in Driver.java
- - Added fix to DatabaseMetaData.getTables() submitted by
- Stefan Andreasen <stefan@linux.kapow.dk>
- - Added fix to DatabaseMetaData.getColumns() to handle patterns
- submitted by Stefan Andreasen <stefan@linux.kapow.dk>
- - Set TcpNoDelay on the connection, as this gives us a 10x speed
- improvement on FreeBSD (caused by a bug in their TCP Stack). They
- should fix the bug before 6.4 is released, but will keep this
- in here unless it causes more problems.
- Submitted by Jason Venner <jason@idiom.com>
- - Removed a duplicate definition of fieldCache
- - Added a more meaningful message when the connection is refused. It
- now says:
- Connection refused. Check that the hostname and port is
- correct, and that the postmaster is running with the -i flag,
- which enables TCP/IP networking.
- - Removed kludge in PreparedStatement.setDate() that acted as a
- temporary fix to a bug in SimpleDateFormat, as it broke date
- handling in JDK 1.1.6.
- - Modified PG_Stream and Connection, so that outbound data is now
- buffered. This should give us a speed improvement, and reduce the
- ammount of network packets generated.
- - Removed duplicate code and optimised PG_Stream.
- - PG_Stream now returns a more meaningful message when the connection
- is broken by the backend. It now returns:
- The backend has broken the connection. Possibly the action you
- have attempted has caused it to close.
- - Removed obsolete code from Connection.
- - The error message returned when the authentication scheme is unknown
- has been extended. It now reads:
- Authentication type ### not supported. Check that you have
- configured the pg_hba.conf file to include the client's IP
- address or Subnet, and is using a supported authentication
- scheme.
- - Connection.getMetaData() now caches the instance returned, so
- multiple calls will return the same instance.
- - Created a test application that tests the DatabaseMetaData and
- ResultSetMetaData classes.
- - Replaced getString(#).getBytes() with getBytes(#) which should speed
- things up, and reduce memory useage.
- - Optimised DatabaseMetaData.getProcedures(), and implemented patterns
- - Fixed NullPointerExceptions thrown when a field is null (Internal
- to the driver, not caused by results from the backend.
- DatabaseMetaData.getProcedures() is an example of a method that
- causes this):
- - ResultSetMetaData.getColumnName() now returns field# where
- # is the column name.
- - ResultSet.getObject() fixed
- - Fixed bug in psql example that was affected by null fields
- - DatabaseMetaData.getTables()
- - DatabaseMetaData.getPrimaryKeys() ran a query with an ambiguous field
- fixed.
- - getTypeInfo() optimised to increase speed and reduce memory useage
- - ResultSetMetaData.isCurrency() optimised and is now smaller.
- - Removed unnecessary code fromResultSetMetaData.getCatalogName()
- and getSchemaName().
- - Created new class postgresql.util.PGmoney to map the money type
- - Created new class postgresql.geometric.PGline to map the line type
-
diff --git a/src/interfaces/jdbc/Implementation b/src/interfaces/jdbc/Implementation
deleted file mode 100644
index ecfc626d9d6..00000000000
--- a/src/interfaces/jdbc/Implementation
+++ /dev/null
@@ -1,199 +0,0 @@
-This short document is provided to help programmers through the internals of
-the PostgreSQL JDBC driver.
-
-Last update: January 17 2001 peter@retep.org.uk
-
-build.xml
----------
-
-As of 7.1, we now use the ANT build tool to build the driver. ANT is part of
-the Apache/Jakarta project, and provides far superior build capabilities. You
-can find ANT from http://jakarta.apache.org/ant/index.html and being pure java
-it will run on any java platform.
-
-So far I've tested it under JDK1.2.x & JDK1.3 (both Linux & NT) but not yet with
-JDK1.1.8. Because of the latter the Makefile still works for now, but should be
-gone for 7.2.
-
-Anyhow, to build, simply type ant and the .jar file will be created and put into
-the jars directory.
-
-Tip: If you run ant from the sources root directory (ie: where the configure
-script is located) you will find another build.xml file. It is advised to run
-ant from that directory as it will then compile some auxilary Java/JDBC
-utilities that are located under the /contrib/retep directory.
-
-Makefile
---------
-
-Prior to 7.1, all compilation must be done by using Make. This is because there
-are three versions of the driver, one for JDBC1 (for JDK 1.1.x) and the others
-for JDBC2 (for JDK 1.2 or later, one standard and one enterprise).
-
-As of 7.1, ANT is the build tool of choice. Just compare Makefile and build.xml
-to see why! Make just isn't suited to Java.
-
-Building with just the JDK
---------------------------
-
-This is not advised, simply because you have to make sure you include the
-correct classes, and the fact that org.postgresql.Driver is built on the fly.
-Also, javac won't pick up all the classes because some (org.postgresql.geometric
-for example) are loaded dynamically.
-
-org/postgresql/Driver.java.in
------------------------------
-
-Because there are three versions of the driver, the org.postgresql.Driver class
-is built dynamically. To build correctly ANT copies the Driver.java.in file to
-Driver.java replacing certain values according to the required driver.
-
-The replaced values are of the format %VALUE%, ie: %MAJORVERSION% is replaced
-with 7 in the 7.1 version of the driver.
-
-postgresql.jar
---------------
-
-This jar file is produced by ANT, and contains the driver for your JDK platform.
-
-If you downloaded a precompiled binary from the web, you may find that the
-jar file will be named differently. These are identical to this file but are
-named according to the backend and jdk versions.
-
-The naming convention is of the form: jdbc-#.#-#.##.jar
-
-ie: for 7.1
- jdbc-7.1-1.1.jar JDBC Driver for JDK1.1.8
- jdbc-7.1-1.2.jar JDBC Driver for JDK1.2 & JDK1.3
- jdbc-7.1-1.2ent.jar JDBC Driver for JDK1.2 & JDK1.3 Enterprise Editions
-
-If in the future there are any 1.3 specific classes then there will be two new
-jar files.
-
-Note: All the precompiled binaries are built under Linux.
-
-jdbc.jpx
---------
-
-This is a JBuilder4 project file. It's here to allow JBuilder to be used to
-develop the driver. Mainly for it's Editor's features like syntax checking and
-auto-completion etc.
-
-IMPORTANT: You CAN NOT build the driver from within JBuilder. You must use ANT.
- This is because of the three versions of the JDK. If you try to use
- JBuilder, it will try to build everything, and it will just not work.
-
-Importing packages
-------------------
-
-In user code, you may have to import one or more packages, if and only if you
-are using the non jdbc extensions (like FastPath, or LargeObject).
-
-DO NOT import the postgresql, postgresql.jdbc1 or postgresql.jdbc2 packages!
-
-Internally, some classes will import the packages when there is a link between
-them and the other packages. However, the above rule still applies. It's there
-because Javac becomes confused between the different places that similar class
-names are present.
-
-However, there are places where they need to refer to classes in the postgresql
-package. In this case, import the individual classes, and not the entire
-package.
-
-ie: import postgresql.Field
-
- NOT import postgresql.*
-
-Package Layout
---------------
-
-The driver is split into several packages:
-
-org.postgresql core classes that can be accessed by user code
-org.postgresql.core core classes not normally used externally
-org.postgresql.jdbc1 classes used only in implementing JDBC 1
-org.postgresql.jdbc2 classes used only in implementing JDBC 2
-org.postgresql.fastpath FastPath to backend functions
-org.postgresql.geometric 2D Geometric types mapped to Java Objects
-org.postgresql.largeobject Low level Large Object access
-org.postgresql.util Utility classes
-
-
-Package org.postgresql
-------------------
-
-This package holds the core classes.
-
-Driver registers the driver when it's loaded, and determines which
- Connection class (in jdbc1 or jdbc2 packages) to use when
- connecting to a database.
-
-Field Used internally to represent a Field
-PG_Stream Used internally to manage the network stream.
-PostgresqlDataSource
- Exists in the Java2 Enterprise edition driver only and is the
- enterprise equivalent to Driver
-
- These classes contains common code that is not dependent to the
- two JDBC specifications.
-
-Connection Common code used in Connections, mainly Network Protocol stuff.
-ResultSet Common code used in ResultSet's
-
-Package org.postgresql.core
------------------------
-
-New in 7.1, this is where core classes (common to all versions) will exist. Any
-new class that would have gone into org.postgresql must go in here instead.
-
-BytePoolDim1 Handles a pool of byte[] arrays.
-BytePoolDim2 Handles a pool of byte[][] arrays
-MemoryPool Interface for managing MemoryPools. Not used (yet).
-ObjectPool Interface for an Object Pool
-SimpleObjectPool Class that implements ObjectPool and used by BytePoolDim#
-Encoding Character encoding logic, mainly for Connection and PG_Stream.
-
-Package org.postgresql.fastpath
----------------------------
-
-Fastpath Handles executing a function on the PostgreSQL Backend
-FastpathArg Defines an argument for a function call
-
-Package org.postgresql.geometric
-----------------------------
-
-PGbox Maps to postgresql type box
-PGcircle Maps to postgresql type circle
-PGline Maps to postgresql type line
-PGlseg Maps to postgresql type lseg
-PGpath Maps to postgresql type path
-PGpoint Maps to postgresql type point
-PGpolygon Maps to postgresql type polygon
-
-Package org.postgresql.jdbc1
-------------------------
-
-The classes in this package handle the JDBC 1 Specification, for JDK 1.1.x
-All interfaces in the java.sql package are present here.
-
-Package org.postgresql.jdbc2
-------------------------
-
-The classes in this package handle the JDBC 2 Specification, for JDK 1.2
-All interfaces in the java.sql, and javax.sql packages are present here.
-
-Package org.postgresql.largeobject
-------------------------------
-
-LargeObject Represents an open LargeObject
-LargeObjectManager Handles the opening and deleting of LargeObjects
-
-Package org.postgresql.util
------------------------
-
-PGmoney Maps to postgresql type money
-PGobject Used to represent postgresql types that have no Java equivalent
-PGtokenizer Helper class for the geometric types
-Serialize Used to serialise Java objects into tabes, rather than Blobs
-UnixCrypt Used to handle crypt authentication
-
diff --git a/src/interfaces/jdbc/Makefile b/src/interfaces/jdbc/Makefile
deleted file mode 100644
index 3b88af4d3c7..00000000000
--- a/src/interfaces/jdbc/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
-#-------------------------------------------------------------------------
-#
-# Makefile for JDBC driver
-#
-# Copyright (c) 2001, PostgreSQL Global Development Group
-#
-# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.34 2002/03/05 17:55:23 momjian Exp $
-#
-#-------------------------------------------------------------------------
-
-subdir = src/interfaces/jdbc
-top_builddir = ../../..
-include $(top_builddir)/src/Makefile.global
-
-majorversion := $(shell echo $(VERSION) | sed 's/^\([0-9][0-9]*\)\..*$$/\1/')
-minorversion := $(shell echo $(VERSION) | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\).*$$/\1/')
-
-properties := -Dmajor=$(majorversion) -Dminor=$(minorversion) \
- -Dfullversion=$(VERSION) \
- -Ddef_pgport=$(DEF_PGPORT) \
- -Denable_debug=$(enable_debug)
-
-all:
- $(ANT) -buildfile $(srcdir)/build.xml all \
- $(properties)
-
-install: installdirs
- $(ANT) -buildfile $(srcdir)/build.xml install \
- -Dinstall.directory=$(javadir) $(properties)
-
-installdirs:
- $(mkinstalldirs) $(javadir)
-
-uninstall:
- $(ANT) -buildfile $(srcdir)/build.xml uninstall \
- -Dinstall.directory=$(javadir)
-
-clean distclean maintainer-clean:
- $(ANT) -buildfile $(srcdir)/build.xml clean
-
-check:
- $(ANT) -buildfile $(srcdir)/build.xml test
diff --git a/src/interfaces/jdbc/README b/src/interfaces/jdbc/README
deleted file mode 100644
index 7531bc5b209..00000000000
--- a/src/interfaces/jdbc/README
+++ /dev/null
@@ -1,277 +0,0 @@
-This is a simple readme describing how to compile and use the jdbc driver.
-
-This file was amended on January 17 2001 to reflect the changes made in the 7.1
-release.
-
----------------------------------------------------------------------------
-
-This isn't a guide on how to use JDBC - for that refer to Javasoft's web site:
-
- http://www.javasoft.com/
-
-For problems with this driver, then refer to the postgres-jdbc email
-list:
-
- http://www.postgresql.org/
-
-The Driver's home page is:
-
- http://jdbc.postgresql.org/
-or http://www.retep.org.uk/postgresql/
-
-NB: They are both the same physical directory so both will always be in sync
-(unless the laws of physics break down ;-) )
-
----------------------------------------------------------------------------
-
-COMPILING
-
-To compile you will need to have ANT installed. To obtain ant go to
-http://jakarta.apache.org/ant/index.html and download the binary. Being pure
-java it will run on virtually all java platforms. If you have any problems
-please email the jdbc list.
-
-Once you have ANT, run the configure script in the top-level directory with
-the --with-java option. Then proceed with 'make' and 'make install' as
-usual. This will compile the correct driver for your JVM, and build a .jar
-file (Java ARchive) called postgresql.jar. The file will be installed in
-the directory PREFIX/share/java.
-
-That jar file will contain the driver for _your_ version of the JDK.
-
-Note: As of 7.1, you can build from the top-level directory or from
-src/interfaces/jdbc.
-
-REMEMBER: Once you have compiled the driver, it will work on ALL platforms
-that support that version of the API. You don't need to build it for each
-platform.
-
-That means you don't have to compile it on every platform. Believe me, I
-still hear from people who ask me "I've compiled it ok under Solaris, but it
-won't compile under Linux" - there's no difference.
-
-Don't try to run javac directly. Don't try to run ant directly. Neither
-will work.
-
-Possible problems
-
-You may see a message similar to:
-
-postgresql/Driver.java:87: interface java.sql.Connection is an interface. It can't be instantiated.
- return new Connection (host(), port(), props, database(), url, this);
-
-This is caused by not having the current directory in your CLASSPATH. Under
-Linux/Solaris, unset the CLASSPATH environment variable, and rerun ant.
-
-If you are still having problems, I keep a copy of the driver (for different
-versions of the backend) on my web site http://www.retep.org.uk/postgres/
-or http://jdbc.postgresql.org/
-
-More details are in the Implementation file src/interfaces/jdbc/Implementation
-
----------------------------------------------------------------------------
-
-INSTALLING THE DRIVER
-
-To install the driver, the .class files have to be in the classpath.
-
-ie: under LINUX/SOLARIS (the example here is my linux box):
-
- export CLASSPATH=.:/usr/local/pgsql/share/java/postgresql.jar
-
-Please don't be tempted to extract the files from the .jar file. There are a
-lot of files in there, and you may break the Exception handling.
-
----------------------------------------------------------------------------
-
-USING THE DRIVER
-
-To use the driver, you must introduce it to JDBC. Again, there's two ways
-of doing this:
-
-1: Hardcoded.
-
- This method hardcodes your driver into your application/applet. You
- introduce the driver using the following snippet of code:
-
- try {
- Class.forName("org.postgresql.Driver");
- } catch(Exception e) {
- // your error handling code goes here
- }
-
- Remember, this method restricts your code to just the postgresql database.
- However, this is how most people load the driver.
-
-2: Parameters
-
- This method specifies the driver from the command line. When running the
- application, you specify the driver using the option:
-
- -Djdbc.drivers=org.postgresql.Driver
-
- eg: This is an example of running one of my other projects with the driver:
-
- java -Djdbc.drivers=org.postgresql.Driver uk.org.retep.finder.Main
-
- note: This method only works with Applications (not for Applets).
- However, the application is not tied to one driver, so if you needed
- to switch databases (why I don't know ;-) ), you don't need to
- recompile the application (as long as you havent hardcoded the url's).
-
----------------------------------------------------------------------------
-
-JDBC URL syntax
-
-The driver recognises JDBC URL's of the form:
-
- jdbc:postgresql:database
-
- jdbc:postgresql://host/database
-
- jdbc:postgresql://host:port/database
-
-Also, you can supply both username and passwords as arguments, by appending
-them to the URL. eg:
-
- jdbc:postgresql:database?user=me
- jdbc:postgresql:database?user=me&password=mypass
-
-Notes:
-
-1) If you are connecting to localhost or 127.0.0.1 you can leave it out of the
- URL. ie: jdbc:postgresql://localhost/mydb can be replaced with
- jdbc:postgresql:mydb
-
-2) The port defaults to 5432 if it's left out.
-
----------------------------------------------------------------------------
-
-That's the basics related to this driver. You'll need to read the JDBC Docs
-on how to use it. However, there are some examples included in the example
-directory. To build, type: make examples
-
-To run them, they follow the same syntax. For example, the basic example shows
-how to insert data, and perform queries:
-
- java example.basic jdbc:postgresql:test user password
-
----------------------------------------------------------------------------
-
-POSTGRESQL SPECIFICS
---------------------
-
-Large Objects:
-
-A "feature" of PostgreSQL is that access to LargeObjects is only permitted
-within a Transaction. Because of this, any use of LargeObjects (also known
-as Blobs) requires that the Connection.setAutoCommit() method be called
-disabling the autocommit feature.
-
-For example:
-
- Connection db; // open the connection here
- db.setAutoCommit(false); // Turn off AutoCommit
-
- ------------------
-
-Large Object API
-
-Most of the time, you can use the getBytes()/setBytes() methods to read and
-write small Large Objects. However, PostgreSQL's own internal api's are
-available. These allow you to access the object as if it was a file.
-
-The first thing you need to do is to open the LargeObjectManager. This class
-handles the opening of existing objects, and creating new ones. To do this,
-you use the following line of code:
-
- LargeObjectManager lobj;
- lobj = ((org.postgresql.Connection)db).getLargeObjectAPI();
-
-where db is a reference to an open Connection object.
-
-Once that is done, you can use the API for the lifetime of that Connection.
-
-To create an object, you call the create() method. This takes an argument
-with the file modes you intend to use. The following line is normally
-sufficient:
-
- int oid = lobj.create(LargeObjectManager.READ|LargeObjectManager.WRITE);
-
-Here, lobj is the LargeObjectManager we have opened earlier, and oid is the
-Large Object's oid in the database.
-
-To open an existing object, you use the open() method. This takes an oid, and
-the file permissions. It then returns a LargeObject object.
-
- LargeObject obj = lobj.open(oid,LargeObjectManager.WRITE);
-
-Once the LargeObject is open, you can call methods to read, write, seek etc.
-Here's the supported methods:
-
- int oid = obj.getOID(); Return the objects oid
- obj.close(); Close the object
- byte data[] = obj.read(int len); Read len bytes
- onj.read(byte data[],int off,int len); Read into data[off] len bytes
- obj.write(byte data[]); Write the array data
- obj.write(byte data[],int off,int len); Write len bytes from data[off]
- obj.seek(int pos,int ref); As fseek in C.
- obj.seek(int pos); Move to pos (from the begining)
- int pos = obj.tell(); Returns the current position
- int size = obj.size(); Returns the objects size
-
-Caveat: If you commit(), rollback() a transaction, or turn on autocommit whilst
-an object is open PostgreSQL will close it. You will need to reopen the object
-before using it again. Using the existing LargeObject will cause an
-SQLException to be thrown.
-
- ------------------
-
-Date datatype:
-
-The driver now issues the "show datestyle;" query when it first connects, so
-any call to ResultSet.getDate() how returns the correct date.
-
-One caveat though: if you change the datestyle from within JDBC, you must also
-issue the "show datestyle" query. Without this, the driver will not know of
-the change.
-
-ie:
- Statement s = db.createStatement();
- ...
- s.executeUpdate("set datestyle='european'");
- s.executeUpdate("show datestyle");
- ..
- s.close();
-
-Please note: This may change later, so that the driver uses the same format
-internally (similar to how the ODBC driver works).
-
- ------------------
-
-JDBC supports database specific data types using the getObject() call. The
-following types have their own Java equivalents supplied by the driver:
-
- box, circle, line, lseg, path, point, polygon
-
-When using the getObject() method on a resultset, it returns a PG_Object,
-which holds the postgres type, and its value. This object also supports
-methods to retrive these types.
-
- Eg: column 3 contains a point, and rs is the ResultSet:
-
- PG_Object o = (PG_Object)rs.getObject(3);
- PGpoint p = o.getPoint();
- System.out.println("point returned x="+p.x+", y="+p.y);
-
-Also, when using these classes, their toString() methods return the correct
-syntax for writing these to the database.
-
----------------------------------------------------------------------------
-
-Peter T Mount, December 29 1998
-home email: peter@retep.org.uk http://www.retep.org.uk
-work email: petermount@it.maidstone.gov.uk or peter@taer.maidstone.gov.uk
-
-PS: Please use the home email whenever possible. If you must contact me at work
-then please cc my home one at the same time.
diff --git a/src/interfaces/jdbc/build.xml b/src/interfaces/jdbc/build.xml
deleted file mode 100644
index 81cc1bd2d01..00000000000
--- a/src/interfaces/jdbc/build.xml
+++ /dev/null
@@ -1,245 +0,0 @@
-<?xml version="1.0"?>
-<!--
-
- Build file to allow ant (http://jakarta.apache.org/ant/) to be used
- to build the PostgreSQL JDBC Driver.
-
- This file now requires Ant 1.4.1. 2002-04-18
-
- $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.23 2002/04/18 04:58:13 momjian Exp $
-
--->
-
-<!DOCTYPE project [
- <!ENTITY jarfiles "postgresql.jar,postgresql-examples.jar">
-]>
-
-<project name="postgresqlJDBC" default="all" basedir=".">
-
- <!-- set global properties for this build -->
- <property name="srcdir" value="." />
- <property name="jardir" value="jars" />
- <property name="builddir" value="build" />
- <property name="package" value="org/postgresql" />
- <property name="debug" value="off" />
-
- <!--
- This is a simpler method than utils.CheckVersion
- It defaults to jdbc1, but builds jdbc2 if the java.lang.Byte class is
- in the CLASSPATH (ie JDK1.2 or later), and then enterprise if the
- javax.sql.DataSource class is present.
-
- Important: This must have the following order: jdbc1, jdbc2, enterprise
- -->
- <target name="check_versions">
- <condition property="jdbc1">
- <equals arg1="${ant.java.version}" arg2="1.1"/>
- </condition>
- <condition property="jdbc2">
- <or>
- <equals arg1="${ant.java.version}" arg2="1.2"/>
- <equals arg1="${ant.java.version}" arg2="1.3"/>
- <equals arg1="${ant.java.version}" arg2="1.4"/>
- </or>
- </condition>
- <condition property="datasource">
- <and>
- <or>
- <equals arg1="${ant.java.version}" arg2="1.2"/>
- <equals arg1="${ant.java.version}" arg2="1.3"/>
- </or>
- <available classname="javax.sql.DataSource"/>
- </and>
- </condition>
- <available property="junit" classname="junit.framework.Test" />
- </target>
-
-
- <!-- default target -->
- <target name="all">
- <antcall target="jar" />
- </target>
-
-
- <!-- create the jar file -->
- <target name="jar" depends="compile,examples">
- <jar jarfile="${jardir}/postgresql.jar" whenempty="fail">
- <fileset dir="${builddir}">
- <include name="${package}/**/*.class" />
- <exclude name="${package}/test/**" />
- </fileset>
-
- <fileset dir="${srcdir}">
- <include name="${package}/*.properties" />
- </fileset>
- </jar>
-
- <jar jarfile="${jardir}/postgresql-examples.jar" whenempty="fail">
- <fileset dir="${builddir}">
- <include name="example/**/*.class" />
- </fileset>
-
- <fileset dir="${srcdir}">
- <include name="example/*.properties" />
- </fileset>
- </jar>
- </target>
-
-
- <!-- This is the core of the driver. It is common for all three versions. -->
- <target name="compile" depends="prepare,check_versions,driver">
- <javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
- <include name="${package}/**" />
-
- <exclude name="${package}/jdbc1/**" unless="jdbc1"/>
- <exclude name="${package}/jdbc2/**" unless="jdbc2"/>
-
- <exclude name="${package}/largeobject/PGblob.java" unless="jdbc2" />
- <exclude name="${package}/largeobject/PGclob.java" unless="jdbc2" />
-
- <exclude name="${package}/PostgresqlDataSource.java" unless="datasource" />
- <exclude name="${package}/xa/**" unless="datasource" />
-
- <exclude name="${package}/test/**" unless="junit" />
- <exclude name="${package}/test/jdbc2/**" unless="jdbc2" />
- <exclude name="${package}/test/JDBC2Tests.java" unless="jdbc2" />
- </javac>
- </target>
-
-
- <!--
- This generates Driver.java from Driver.java.in
- It's required for importing the driver version properties
- -->
- <target name="driver" depends="prepare,check_versions">
- <!-- determine the edition text -->
- <property name="edition" value="JDBC1" />
- <condition property="edition" value="JDBC2">
- <or>
- <equals arg1="${jdbc2}" arg2="true"/>
- <equals arg1="${jdbc3}" arg2="true"/> <!-- fake it for now -->
-
- </or>
- </condition>
-
- <condition property="edition" value="JDBC2 Enterprise">
- <and>
- <available classname="javax.sql.DataSource" />
- <equals arg1="${jdbc2}" arg2="true"/>
- </and>
- </condition>
-
- <!-- determine the connection class -->
- <property name="connectclass" value="org.postgresql.jdbc1.Connection" />
- <available property="connectclass" value="org.postgresql.jdbc2.Connection" classname="java.lang.ThreadLocal" />
-
- <!-- Some defaults -->
- <filter token="MAJORVERSION" value="${major}" />
- <filter token="MINORVERSION" value="${minor}" />
- <filter token="VERSION" value="PostgreSQL ${fullversion} ${edition}" />
- <filter token="JDBCCONNECTCLASS" value="${connectclass}" />
- <filter token="DEF_PGPORT" value="${def_pgport}" />
-
- <!-- Put a check for the current version here -->
-
- <!-- now copy and filter the file -->
- <copy file="${package}/Driver.java.in"
- tofile="${package}/Driver.java"
- filtering="yes" />
-
- <echo message="Configured build for the ${edition} edition driver" />
- </target>
-
-
- <!-- Prepares the build directory -->
- <target name="prepare">
- <!-- use the enable_debug option from configure -->
- <condition property="debug" value="on">
- <and>
- <equals arg1="${enable_debug}" arg2="yes" />
- </and>
- </condition>
- <mkdir dir="${builddir}" />
- <mkdir dir="${jardir}" />
- </target>
-
-
- <!-- This builds the examples -->
- <target name="examples" depends="compile">
- <javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
- <include name="example/**" />
- <exclude name="example/corba/**"/>
- <exclude name="example/blobtest.java" unless="jdk1.2+"/>
- </javac>
- </target>
-
-
- <!-- Builds the corba example -->
- <target name="corba" if="jdk1.2+">
- <exec dir="${srcdir}/example/corba" executable="idl2java">
- <arg value="stock.idl" />
- </exec>
-
- <javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
- <include name="example/corba/**" />
- </javac>
- </target>
-
-
-
- <!-- Install the jar files -->
- <target name="install" depends="all" if="install.directory">
- <copy todir="${install.directory}" overwrite="true">
- <fileset dir="${jardir}" includes="&jarfiles;" />
- </copy>
- </target>
-
-
- <!-- Uninstall the jar file -->
- <target name="uninstall" if="install.directory">
- <delete>
- <fileset dir="${install.directory}" includes="&jarfiles;" />
- </delete>
- </target>
-
-
-
- <!-- This target removes any class files from the build directory -->
- <target name="clean">
- <delete quiet="true" dir="${builddir}" />
- <delete quiet="true" dir="${jardir}" />
- <delete quiet="true" file="${package}/Driver.java" />
- </target>
-
-
-
- <!-- This compiles and executes the JUnit tests -->
-
- <!-- defaults for the tests - override these if required -->
- <property name="database" value="jdbc:postgresql:test" />
- <property name="username" value="test" />
- <!-- Password must be something. Doesn't matter if trust is used! -->
- <property name="password" value="password" />
- <!-- junit.ui is one of textui, awtui, or swingui -->
- <property name="junit.ui" value="textui" />
-
-
- <target name="test" depends="jar" if="junit">
- <javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
- <include name="${package}/test/jdbc2/**" if="jdk1.2+" />
- <include name="${package}/test/java2ee/**" if="jdk1.2e+" />
- </javac>
-
- <java fork="yes" classname="junit.${junit.ui}.TestRunner" taskname="junit" failonerror="true">
- <arg value="org.postgresql.test.JDBC2Tests" />
- <sysproperty key="database" value="${database}" />
- <sysproperty key="username" value="${username}" />
- <sysproperty key="password" value="${password}" />
- <classpath>
- <pathelement location="${builddir}" />
- <pathelement path="${java.class.path}" />
- </classpath>
- </java>
- </target>
-
-</project>
diff --git a/src/interfaces/jdbc/example/ImageViewer.java b/src/interfaces/jdbc/example/ImageViewer.java
deleted file mode 100644
index f61a8870e7b..00000000000
--- a/src/interfaces/jdbc/example/ImageViewer.java
+++ /dev/null
@@ -1,517 +0,0 @@
-package example;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-import java.sql.*;
-import org.postgresql.largeobject.*;
-
-/*
- * This example is a small application that stores and displays images
- * held on a postgresql database.
- *
- * Before running this application, you need to create a database, and
- * on the first time you run it, select "Initialise" in the "PostgreSQL"
- * menu.
- *
- * Important note: You will notice we import the org.postgresql.largeobject
- * package, but don't import the org.postgresql package. The reason for this is
- * that importing postgresql can confuse javac (we have conflicting class names
- * in org.postgresql.* and java.sql.*). This doesn't cause any problems, as
- * long as no code imports org.postgresql.
- *
- * Under normal circumstances, code using any jdbc driver only needs to import
- * java.sql, so this isn't a problem.
- *
- * It's only if you use the non jdbc facilities, do you have to take this into
- * account.
- *
- * Note: For PostgreSQL 6.4, the driver is now Thread safe, so this example
- * application has been updated to use multiple threads, especially in the
- * image storing and retrieving methods.
- */
-
-public class ImageViewer implements ItemListener
-{
- Connection db;
- Statement stat;
- LargeObjectManager lom;
- Frame frame;
- Label label; // Label used to display the current name
- List list; // The list of available images
- imageCanvas canvas; // Canvas used to display the image
- String currentImage; // The current images name
-
- // This is a simple component to display our image
- public class imageCanvas extends Canvas
- {
- // holds the image
- private Image image;
-
- // holds the background buffer
- private Image bkg;
-
- // the size of the buffer
- private Dimension size;
-
- public imageCanvas()
- {
- image = null;
- }
-
- public void setImage(Image img)
- {
- image = img;
- repaint();
- }
-
- // This defines our minimum size
- public Dimension getMinimumSize()
- {
- return new Dimension(400, 400);
- }
-
- public Dimension getPreferedSize()
- {
- return getMinimumSize();
- }
-
- public void update(Graphics g)
- {
- paint(g);
- }
-
- /*
- * Paints the image, using double buffering to prevent screen flicker
- */
- public void paint(Graphics gr)
- {
- Dimension s = getSize();
-
- if (size == null || bkg == null || !s.equals(size))
- {
- size = s;
- bkg = createImage(size.width, size.height);
- }
-
- // now set the background
- Graphics g = bkg.getGraphics();
- g.setColor(Color.gray);
- g.fillRect(0, 0, s.width, s.height);
-
- // now paint the image over the background
- if (image != null)
- g.drawImage(image, 0, 0, this);
-
- // dispose the graphics instance
- g.dispose();
-
- // paint the image onto the component
- gr.drawImage(bkg, 0, 0, this);
-
- }
-
- }
-
- public ImageViewer(Frame f, String url, String user, String password) throws ClassNotFoundException, FileNotFoundException, IOException, SQLException
- {
- frame = f;
-
- MenuBar mb = new MenuBar();
- Menu m;
- MenuItem i;
-
- f.setMenuBar(mb);
- mb.add(m = new Menu("PostgreSQL"));
- m.add(i = new MenuItem("Initialise"));
- i.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- ImageViewer.this.init();
- }
- }
- );
-
- m.add(i = new MenuItem("Exit"));
- ActionListener exitListener = new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- ImageViewer.this.close();
- }
- };
- m.addActionListener(exitListener);
-
- mb.add(m = new Menu("Image"));
- m.add(i = new MenuItem("Import"));
- ActionListener importListener = new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- ImageViewer.this.importImage();
- }
- };
- i.addActionListener(importListener);
-
- m.add(i = new MenuItem("Remove"));
- ActionListener removeListener = new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- ImageViewer.this.removeImage();
- }
- };
- i.addActionListener(removeListener);
-
- // To the north is a label used to display the current images name
- f.add("North", label = new Label());
-
- // We have a panel to the south of the frame containing the controls
- Panel p = new Panel();
- p.setLayout(new FlowLayout());
- Button b;
- p.add(b = new Button("Refresh List"));
- b.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- ImageViewer.this.refreshList();
- }
- }
- );
- p.add(b = new Button("Import new image"));
- b.addActionListener(importListener);
- p.add(b = new Button("Remove image"));
- b.addActionListener(removeListener);
- p.add(b = new Button("Quit"));
- b.addActionListener(exitListener);
- f.add("South", p);
-
- // And a panel to the west containing the list of available images
- f.add("West", list = new List());
- list.addItemListener(this);
-
- // Finally the centre contains our image
- f.add("Center", canvas = new imageCanvas());
-
- // Load the driver
- Class.forName("org.postgresql.Driver");
-
- // Connect to database
- db = DriverManager.getConnection(url, user, password);
-
- // Create a statement
- stat = db.createStatement();
-
- // Also, get the LargeObjectManager for this connection
- lom = ((org.postgresql.Connection)db).getLargeObjectAPI();
-
- // Now refresh the image selection list
- refreshList();
- }
-
-
- /*
- * This method initialises the database by creating a table that contains
- * the image names, and Large Object OID's
- */
- public void init()
- {
- try
- {
- //db.setAutoCommit(true);
- stat.executeUpdate("create table images (imgname name,imgoid oid)");
- label.setText("Initialised database");
- db.commit();
- }
- catch (SQLException ex)
- {
- label.setText(ex.toString());
- }
-
- // This must run outside the previous try{} catch{} segment
- //try {
- //db.setAutoCommit(true);
- //} catch(SQLException ex) {
- //label.setText(ex.toString());
- //}
- }
-
- /*
- * This closes the connection, and ends the application
- */
- public void close()
- {
- try
- {
- db.close();
- }
- catch (SQLException ex)
- {
- System.err.println(ex.toString());
- }
- System.exit(0);
- }
-
- /*
- * This imports an image into the database, using a Thread to do this in the
- * background.
- */
- public void importImage()
- {
- FileDialog d = new FileDialog(frame, "Import Image", FileDialog.LOAD);
- d.setVisible(true);
- String name = d.getFile();
- String dir = d.getDirectory();
- d.dispose();
-
- // now start the true importer
- Thread t = new importer(db, name, dir);
- //t.setPriority(Thread.MAX_PRIORITY);
- t.start();
- }
-
- /*
- * This is an example of using a thread to import a file into a Large Object.
- * It uses the Large Object extension, to write blocks of the file to the
- * database.
- */
- class importer extends Thread
- {
- String name, dir;
- Connection db;
-
- public importer(Connection db, String name, String dir)
- {
- this.db = db;
- this.name = name;
- this.dir = dir;
- }
-
- public void run()
- {
- // Now the real import stuff
- if (name != null && dir != null)
- {
- Statement stat = null;
-
- try
- {
- // fetch the large object manager
- LargeObjectManager lom = ((org.postgresql.Connection)db).getLargeObjectAPI();
-
- db.setAutoCommit(false);
-
- // A temporary buffer - this can be as large as you like
- byte buf[] = new byte[2048];
-
- // Open the file
- FileInputStream fis = new FileInputStream(new File(dir, name));
-
- // Now create the large object
- int oid = lom.create();
- LargeObject blob = lom.open(oid);
-
- // Now copy the file into the object.
- //
- // Note: we dont use write(buf), as the last block is rarely the same
- // size as our buffer, so we have to use the amount read.
- int s, t = 0;
- while ((s = fis.read(buf, 0, buf.length)) > 0)
- {
- t += s;
- blob.write(buf, 0, s);
- }
-
- // Close the object
- blob.close();
-
- // Now store the entry into the table
-
- // As we are a different thread to the other window, we must use
- // our own thread
- stat = db.createStatement();
- stat.executeUpdate("insert into images values ('" + name + "'," + oid + ")");
- db.commit();
- db.setAutoCommit(false);
-
- // Finally refresh the names list, and display the current image
- ImageViewer.this.refreshList();
- ImageViewer.this.displayImage(name);
- }
- catch (Exception ex)
- {
- label.setText(ex.toString());
- }
- finally
- {
- // ensure the statement is closed after us
- try
- {
- if (stat != null)
- stat.close();
- }
- catch (SQLException se)
- {
- System.err.println("closing of Statement failed");
- }
- }
- }
- }
- }
-
- /*
- * This refreshes the list of available images
- */
- public void refreshList()
- {
- try
- {
- // First, we'll run a query, retrieving all of the image names
- ResultSet rs = stat.executeQuery("select imgname from images order by imgname");
- if (rs != null)
- {
- list.removeAll();
- while (rs.next())
- list.addItem(rs.getString(1));
- rs.close();
- }
- }
- catch (SQLException ex)
- {
- label.setText(ex.toString() + " Have you initialised the database?");
- }
- }
-
- /*
- * This removes an image from the database
- *
- * Note: With postgresql, this is the only way of deleting a large object
- * using Java.
- */
- public void removeImage()
- {
- try
- {
- //
- // Delete any large objects for the current name
- //
- // Note: We don't need to worry about being in a transaction
- // here, because we are not opening any blobs, only deleting
- // them
- //
- ResultSet rs = stat.executeQuery("select imgoid from images where imgname='" + currentImage + "'");
- if (rs != null)
- {
- // Even though there should only be one image, we still have to
- // cycle through the ResultSet
- while (rs.next())
- {
- lom.delete(rs.getInt(1));
- }
- }
- rs.close();
-
- // Finally delete any entries for that name
- stat.executeUpdate("delete from images where imgname='" + currentImage + "'");
-
- label.setText(currentImage + " deleted");
- currentImage = null;
- refreshList();
- }
- catch (SQLException ex)
- {
- label.setText(ex.toString());
- }
- }
-
- /*
- * This displays an image from the database.
- *
- * For images, this is the easiest method.
- */
- public void displayImage(String name)
- {
- try
- {
- //
- // Now as we are opening and reading a large object we must
- // turn on Transactions. This includes the ResultSet.getBytes()
- // method when it's used on a field of type oid!
- //
- db.setAutoCommit(false);
-
- ResultSet rs = stat.executeQuery("select imgoid from images where imgname='" + name + "'");
- if (rs != null)
- {
- // Even though there should only be one image, we still have to
- // cycle through the ResultSet
- while (rs.next())
- {
- canvas.setImage(canvas.getToolkit().createImage(rs.getBytes(1)));
- label.setText(currentImage = name);
- }
- }
- rs.close();
- }
- catch (SQLException ex)
- {
- label.setText(ex.toString());
- }
- finally
- {
- try
- {
- db.setAutoCommit(true);
- }
- catch (SQLException ex2)
- {}
- }
- }
-
- public void itemStateChanged(ItemEvent e)
- {
- displayImage(list.getItem(((Integer)e.getItem()).intValue()));
- }
-
- /*
- * This is the command line instructions
- */
- public static void instructions()
- {
- System.err.println("java example.ImageViewer jdbc-url user password");
- System.err.println("\nExamples:\n");
- System.err.println("java -Djdbc.driver=org.postgresql.Driver example.ImageViewer jdbc:postgresql:test postgres password\n");
-
- System.err.println("This example tests the binary large object api of the driver.\nBasically, it will allow you to store and view images held in the database.");
- System.err.println("Note: If you are running this for the first time on a particular database,\nyou have to select \"Initialise\" in the \"PostgreSQL\" menu.\nThis will create a table used to store image names.");
- }
-
- /*
- * This is the application entry point
- */
- public static void main(String args[])
- {
- if (args.length != 3)
- {
- instructions();
- System.exit(1);
- }
-
- try
- {
- Frame frame = new Frame("PostgreSQL ImageViewer v7.0 rev 1");
- frame.setLayout(new BorderLayout());
- ImageViewer viewer = new ImageViewer(frame, args[0], args[1], args[2]);
- frame.pack();
- frame.setLocation(0, 50);
- frame.setVisible(true);
- }
- catch (Exception ex)
- {
- System.err.println("Exception caught.\n" + ex);
- ex.printStackTrace();
- }
- }
-}
diff --git a/src/interfaces/jdbc/example/Unicode.java b/src/interfaces/jdbc/example/Unicode.java
deleted file mode 100644
index aa8b3bf424b..00000000000
--- a/src/interfaces/jdbc/example/Unicode.java
+++ /dev/null
@@ -1,278 +0,0 @@
-package example;
-
-import java.io.*;
-import java.sql.*;
-import java.util.*;
-
-/*
- * Test inserting and extracting Unicode-encoded strings.
- *
- * Synopsis:
- * example.Unicode <url> <user> <password>
- * where <url> must specify an existing database to which <user> and
- * <password> give access and which has UNICODE as its encoding.
- * (To create a database with UNICODE encoding, you need to compile
- * postgres with "--enable-multibyte" and run createdb with the
- * flag "-E UNICODE".)
- *
- * This test only produces output on error.
- *
- * @author William Webber <william@live.com.au>
- */
-public class Unicode
-{
-
- /*
- * The url for the database to connect to.
- */
- private String url;
-
- /*
- * The user to connect as.
- */
- private String user;
-
- /*
- * The password to connect with.
- */
- private String password;
-
- private static void usage()
- {
- log("usage: example.Unicode <url> <user> <password>");
- }
-
- private static void log(String message)
- {
- System.err.println(message);
- }
-
- private static void log(String message, Exception e)
- {
- System.err.println(message);
- e.printStackTrace();
- }
-
-
- public Unicode(String url, String user, String password)
- {
- this.url = url;
- this.user = user;
- this.password = password;
- }
-
- /*
- * Establish and return a connection to the database.
- */
- private Connection getConnection() throws SQLException,
- ClassNotFoundException
- {
- Class.forName("org.postgresql.Driver");
- Properties info = new Properties();
- info.put("user", user);
- info.put("password", password);
- info.put("charSet", "utf-8");
- return DriverManager.getConnection(url, info);
- }
-
- /*
- * Get string representing a block of 256 consecutive unicode characters.
- * We exclude the null character, "'", and "\".
- */
- private String getSqlSafeUnicodeBlock(int blockNum)
- {
- if (blockNum < 0 || blockNum > 255)
- throw new IllegalArgumentException("blockNum must be from 0 to "
- + "255: " + blockNum);
- StringBuffer sb = new StringBuffer(256);
- int blockFirst = blockNum * 256;
- int blockLast = blockFirst + 256;
- for (int i = blockFirst; i < blockLast; i++)
- {
- char c = (char) i;
- if (c == '\0' || c == '\'' || c == '\\')
- continue;
- sb.append(c);
- }
- return sb.toString();
- }
-
- /*
- * Is the block a block of valid unicode values.
- * d800 to db7f is the "unassigned high surrogate" range.
- * db80 to dbff is the "private use" range.
- * These should not be used in actual Unicode strings;
- * at least, jdk1.2 will not convert them to utf-8.
- */
- private boolean isValidUnicodeBlock(int blockNum)
- {
- if (blockNum >= 0xd8 && blockNum <= 0xdb)
- return false;
- else
- return true;
- }
-
- /*
- * Report incorrect block retrieval.
- */
- private void reportRetrievalError(int blockNum, String block,
- String retrieved)
- {
- String message = "Block " + blockNum + " returned incorrectly: ";
- int i = 0;
- for (i = 0; i < block.length(); i++)
- {
- if (i >= retrieved.length())
- {
- message += "too short";
- break;
- }
- else if (retrieved.charAt(i) != block.charAt(i))
- {
- message +=
- "first changed character at position " + i + ", sent as 0x"
- + Integer.toHexString((int) block.charAt(i))
- + ", retrieved as 0x"
- + Integer.toHexString ((int) retrieved.charAt(i));
- break;
- }
- }
- if (i >= block.length())
- message += "too long";
- log(message);
- }
-
- /*
- * Do the testing.
- */
- public void runTest()
- {
- Connection connection = null;
- Statement statement = null;
- int blockNum = 0;
- final int CREATE = 0;
- final int INSERT = 1;
- final int SELECT = 2;
- final int LIKE = 3;
- int mode = CREATE;
- try
- {
- connection = getConnection();
- statement = connection.createStatement();
- statement.executeUpdate("CREATE TABLE test_unicode "
- + "( blockNum INT PRIMARY KEY, "
- + "block TEXT );");
- mode = INSERT;
- for (blockNum = 0; blockNum < 256; blockNum++)
- {
- if (isValidUnicodeBlock(blockNum))
- {
- String block = getSqlSafeUnicodeBlock(blockNum);
- statement.executeUpdate
- ("INSERT INTO test_unicode VALUES ( " + blockNum
- + ", '" + block + "');");
- }
- }
- mode = SELECT;
- for (blockNum = 0; blockNum < 256; blockNum++)
- {
- if (isValidUnicodeBlock(blockNum))
- {
- String block = getSqlSafeUnicodeBlock(blockNum);
- ResultSet rs = statement.executeQuery
- ("SELECT block FROM test_unicode WHERE blockNum = "
- + blockNum + ";");
- if (!rs.next())
- log("Could not retrieve block " + blockNum);
- else
- {
- String retrieved = rs.getString(1);
- if (!retrieved.equals(block))
- {
- reportRetrievalError(blockNum, block, retrieved);
- }
- }
- }
- }
- mode = LIKE;
- for (blockNum = 0; blockNum < 256; blockNum++)
- {
- if (isValidUnicodeBlock(blockNum))
- {
- String block = getSqlSafeUnicodeBlock(blockNum);
- String likeString = "%" +
- block.substring(2, block.length() - 3) + "%" ;
- ResultSet rs = statement.executeQuery
- ("SELECT blockNum FROM test_unicode WHERE block LIKE '"
- + likeString + "';");
- if (!rs.next())
- log("Could get block " + blockNum + " using LIKE");
- }
- }
- }
- catch (SQLException sqle)
- {
- switch (mode)
- {
- case CREATE:
- log("Exception creating database", sqle);
- break;
- case INSERT:
- log("Exception inserting block " + blockNum, sqle);
- break;
- case SELECT:
- log("Exception selecting block " + blockNum, sqle);
- break;
- case LIKE:
- log("Exception doing LIKE on block " + blockNum, sqle);
- break;
- default:
- log("Exception", sqle);
- break;
- }
- }
- catch (ClassNotFoundException cnfe)
- {
- log("Unable to load driver", cnfe);
- return;
- }
- try
- {
- if (statement != null)
- statement.close();
- if (connection != null)
- connection.close();
- }
- catch (SQLException sqle)
- {
- log("Exception closing connections", sqle);
- }
- if (mode > CREATE)
- {
- // If the backend gets what it regards as garbage on a connection,
- // that connection may become unusable. To be safe, we create
- // a fresh connection to delete the table.
- try
- {
- connection = getConnection();
- statement = connection.createStatement();
- statement.executeUpdate("DROP TABLE test_unicode;");
- }
- catch (Exception sqle)
- {
- log("*** ERROR: unable to delete test table "
- + "test_unicode; must be deleted manually", sqle);
- }
- }
- }
-
- public static void main(String [] args)
- {
- if (args.length != 3)
- {
- usage();
- System.exit(1);
- }
- new Unicode(args[0], args[1], args[2]).runTest();
- }
-}
diff --git a/src/interfaces/jdbc/example/basic.java b/src/interfaces/jdbc/example/basic.java
deleted file mode 100644
index 9a4469d83a0..00000000000
--- a/src/interfaces/jdbc/example/basic.java
+++ /dev/null
@@ -1,219 +0,0 @@
-package example;
-
-import java.io.*;
-import java.sql.*;
-import java.text.*;
-
-/*
- *
- * $Id: basic.java,v 1.11 2001/11/25 23:26:56 barry Exp $
- *
- * This example tests the basic components of the JDBC driver, and shows
- * how even the simplest of queries can be implemented.
- *
- * To use this example, you need a database to be in existence. This example
- * will create a table called basic.
- *
- * Note: This will only work with post 7.0 drivers.
- *
- */
-
-public class basic
-{
- Connection db; // The connection to the database
- Statement st; // Our statement to run queries with
-
- public basic(String args[]) throws ClassNotFoundException, FileNotFoundException, IOException, SQLException
- {
- String url = args[0];
- String usr = args[1];
- String pwd = args[2];
-
- // Load the driver
- Class.forName("org.postgresql.Driver");
-
- // Connect to database
- System.out.println("Connecting to Database URL = " + url);
- db = DriverManager.getConnection(url, usr, pwd);
-
- System.out.println("Connected...Now creating a statement");
- st = db.createStatement();
-
- // Clean up the database (in case we failed earlier) then initialise
- cleanup();
-
- // Now run tests using JDBC methods
- doexample();
-
- // Clean up the database
- cleanup();
-
- // Finally close the database
- System.out.println("Now closing the connection");
- st.close();
- db.close();
-
- //throw postgresql.Driver.notImplemented();
- }
-
- /*
- * This drops the table (if it existed). No errors are reported.
- */
- public void cleanup()
- {
- try
- {
- st.executeUpdate("drop table basic");
- }
- catch (Exception ex)
- {
- // We ignore any errors here
- }
- }
-
- /*
- * This performs the example
- */
- public void doexample() throws SQLException
- {
- System.out.println("\nRunning tests:");
-
- // First we need a table to store data in
- st.executeUpdate("create table basic (a int2, b int2)");
-
- // Now insert some data, using the Statement
- st.executeUpdate("insert into basic values (1,1)");
- st.executeUpdate("insert into basic values (2,1)");
- st.executeUpdate("insert into basic values (3,1)");
-
- // This shows how to get the oid of a just inserted row
- // updated for 7.1
- st.executeUpdate("insert into basic values (4,1)");
- long insertedOID = ((org.postgresql.Statement)st).getLastOID();
- System.out.println("Inserted row with oid " + insertedOID);
-
- // Now change the value of b from 1 to 8
- st.executeUpdate("update basic set b=8");
- System.out.println("Updated " + st.getUpdateCount() + " rows");
-
- // Now delete 2 rows
- st.executeUpdate("delete from basic where a<3");
- System.out.println("deleted " + st.getUpdateCount() + " rows");
-
- // For large inserts, a PreparedStatement is more efficient, because it
- // supports the idea of precompiling the SQL statement, and to store
- // directly, a Java object into any column. PostgreSQL doesnt support
- // precompiling, but does support setting a column to the value of a
- // Java object (like Date, String, etc).
- //
- // Also, this is the only way of writing dates in a datestyle independent
- // manner. (DateStyles are PostgreSQL's way of handling different methods
- // of representing dates in the Date data type.)
- PreparedStatement ps = db.prepareStatement("insert into basic values (?,?)");
- for (int i = 2;i < 5;i++)
- {
- ps.setInt(1, 4); // "column a" = 5
- ps.setInt(2, i); // "column b" = i
- ps.executeUpdate(); // executeUpdate because insert returns no data
- }
- ps.close(); // Always close when we are done with it
-
- // Finally perform a query on the table
- System.out.println("performing a query");
- ResultSet rs = st.executeQuery("select a, b from basic");
- if (rs != null)
- {
- // Now we run through the result set, printing out the result.
- // Note, we must call .next() before attempting to read any results
- while (rs.next())
- {
- int a = rs.getInt("a"); // This shows how to get the value by name
- int b = rs.getInt(2); // This shows how to get the value by column
- System.out.println(" a=" + a + " b=" + b);
- }
- rs.close(); // again, you must close the result when done
- }
-
- // Now run the query again, showing a more efficient way of getting the
- // result if you don't know what column number a value is in
-
-
- System.out.println("performing another query");
- rs = st.executeQuery("select * from basic where b>1");
- if (rs != null)
- {
- // First find out the column numbers.
- //
- // It's best to do this here, as calling the methods with the column
- // numbers actually performs this call each time they are called. This
- // really speeds things up on large queries.
- //
- int col_a = rs.findColumn("a");
- int col_b = rs.findColumn("b");
-
- // Now we run through the result set, printing out the result.
- // Again, we must call .next() before attempting to read any results
- while (rs.next())
- {
- int a = rs.getInt(col_a); // This shows how to get the value by name
- int b = rs.getInt(col_b); // This shows how to get the value by column
- System.out.println(" a=" + a + " b=" + b);
- }
- rs.close(); // again, you must close the result when done
- }
-
- // Now test maxrows by setting it to 3 rows
-
-
- st.setMaxRows(3);
- System.out.println("performing a query limited to " + st.getMaxRows());
- rs = st.executeQuery("select a, b from basic");
- while (rs.next())
- {
- int a = rs.getInt("a"); // This shows how to get the value by name
- int b = rs.getInt(2); // This shows how to get the value by column
- System.out.println(" a=" + a + " b=" + b);
- }
- rs.close(); // again, you must close the result when done
-
- // The last thing to do is to drop the table. This is done in the
- // cleanup() method.
- }
-
- /*
- * Display some instructions on how to run the example
- */
- public static void instructions()
- {
- System.out.println("\nThis example tests the basic components of the JDBC driver, demonstrating\nhow to build simple queries in java.\n");
- System.out.println("Useage:\n java example.basic jdbc:postgresql:database user password [debug]\n\nThe debug field can be anything. It's presence will enable DriverManager's\ndebug trace. Unless you want to see screens of items, don't put anything in\nhere.");
- System.exit(1);
- }
-
- /*
- * This little lot starts the test
- */
- public static void main(String args[])
- {
- System.out.println("PostgreSQL basic test v6.3 rev 1\n");
-
- if (args.length < 3)
- instructions();
-
- // This line outputs debug information to stderr. To enable this, simply
- // add an extra parameter to the command line
- if (args.length > 3)
- DriverManager.setLogStream(System.err);
-
- // Now run the tests
- try
- {
- basic test = new basic(args);
- }
- catch (Exception ex)
- {
- System.err.println("Exception caught.\n" + ex);
- ex.printStackTrace();
- }
- }
-}
diff --git a/src/interfaces/jdbc/example/blobtest.java b/src/interfaces/jdbc/example/blobtest.java
deleted file mode 100644
index 271026250dd..00000000000
--- a/src/interfaces/jdbc/example/blobtest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-package example;
-
-import java.io.*;
-import java.sql.*;
-import org.postgresql.largeobject.*;
-
-/*
- * This test attempts to create a blob in the database, then to read
- * it back.
- *
- * Important note: You will notice we import the org.postgresql.largeobject
- * package, but don't import the org.postgresql package. The reason for this is
- * that importing postgresql can confuse javac (we have conflicting class names
- * in org.postgresql.* and java.sql.*). This doesn't cause any problems, as
- * long as no code imports org.postgresql.
- *
- * Under normal circumstances, code using any jdbc driver only needs to import
- * java.sql, so this isn't a problem.
- *
- * It's only if you use the non jdbc facilities, do you have to take this into
- * account.
- *
- */
-
-public class blobtest
-{
- Connection db;
- Statement s;
- LargeObjectManager lobj;
-
- public blobtest(String args[]) throws ClassNotFoundException, FileNotFoundException, IOException, SQLException
- {
- String url = args[0];
- String usr = args[1];
- String pwd = args[2];
-
- // Load the driver
- Class.forName("org.postgresql.Driver");
-
- // Connect to database
- System.out.println("Connecting to Database URL = " + url);
- db = DriverManager.getConnection(url, usr, pwd);
-
- // This is required for all LargeObject calls
- System.out.println("Connected... First turn off autoCommit()");
- db.setAutoCommit(false);
-
- System.out.println("Now creating a statement");
- s = db.createStatement();
-
- // Now run tests using postgresql's own Large object api
- // NOTE: The methods shown in this example are _NOT_ JDBC, but are
- // an implementation of the calls found in libpq. Unless you need to
- // use this functionality, look at the jdbc tests on how to access blobs.
- ownapi();
-
- // Now run tests using JDBC methods
- //jdbcapi(db,s);
-
- // Finally close the database
- System.out.println("Now closing the connection");
- s.close();
- db.close();
- }
-
- /*
- * Now this is an extension to JDBC, unique to postgresql. Here we fetch
- * an PGlobj object, which provides us with access to postgresql's
- * large object api.
- */
- public void ownapi() throws FileNotFoundException, IOException, SQLException
- {
- System.out.println("\n----------------------------------------------------------------------\nTesting postgresql large object api\n----------------------------------------------------------------------\n");
-
- // Internally, the driver provides JDBC compliant methods to access large
- // objects, however the unique methods available to postgresql makes
- // things a little easier.
- System.out.println("Gaining access to large object api");
- lobj = ((org.postgresql.Connection)db).getLargeObjectAPI();
-
- int oid = ownapi_test1();
- ownapi_test2(oid);
-
- // Now call the jdbc2api test
- jdbc2api(oid);
-
- // finally delete the large object
- ownapi_test3(oid);
- System.out.println("\n\nOID=" + oid);
- }
-
- private int ownapi_test1() throws FileNotFoundException, IOException, SQLException
- {
- System.out.println("Test 1 Creating a large object\n");
-
- // Ok, test 1 is to create a large object. To do this, we use the create
- // method.
- System.out.println("Creating a large object");
- int oid = lobj.create(LargeObjectManager.READ | LargeObjectManager.WRITE);
- DriverManager.println("got large object oid=" + oid);
-
- LargeObject obj = lobj.open(oid, LargeObjectManager.WRITE);
- DriverManager.println("got large object obj=" + obj);
-
- // Now open a test file - this class will do
- System.out.println("Opening test source object");
- FileInputStream fis = new FileInputStream("example/blobtest.java");
-
- // copy the data
- System.out.println("Copying file to large object");
- byte buf[] = new byte[2048];
- int s, tl = 0;
- while ((s = fis.read(buf, 0, 2048)) > 0)
- {
- System.out.println("Block size=" + s + " offset=" + tl);
- //System.out.write(buf);
- obj.write(buf, 0, s);
- tl += s;
- }
- DriverManager.println("Copied " + tl + " bytes");
-
- // Close the object
- System.out.println("Closing object");
- obj.close();
-
- return oid;
- }
-
- private void ownapi_test2(int oid) throws FileNotFoundException, IOException, SQLException
- {
- System.out.println("Test 2 Reading a large object and save as a file\n");
-
- // Now open the large object
- System.out.println("Opening large object " + oid);
- LargeObject obj = lobj.open(oid, LargeObjectManager.READ);
- DriverManager.println("got obj=" + obj);
-
- // Now open a test file - this class will do
- System.out.println("Opening test destination object");
- FileOutputStream fos = new FileOutputStream("blob_testoutput");
-
- // copy the data
- System.out.println("Copying large object to file");
- byte buf[] = new byte[512];
- int s = obj.size();
- int tl = 0;
- while (s > 0)
- {
- int rs = buf.length;
- if (s < rs)
- rs = s;
- obj.read(buf, 0, rs);
- fos.write(buf, 0, rs);
- tl += rs;
- s -= rs;
- }
- DriverManager.println("Copied " + tl + "/" + obj.size() + " bytes");
-
- // Close the object
- System.out.println("Closing object");
- obj.close();
- }
-
- private void ownapi_test3(int oid) throws SQLException
- {
- System.out.println("Test 3 Deleting a large object\n");
-
- // Now open the large object
- System.out.println("Deleting large object " + oid);
- lobj.unlink(oid);
- }
-
- // This tests the Blob interface of the JDBC 2.0 specification
- public void jdbc2api(int oid) throws SQLException, IOException
- {
- System.out.println("Testing JDBC2 Blob interface:");
- jdbc2api_cleanup();
-
- System.out.println("Creating Blob on large object " + oid);
- s.executeUpdate("create table basic (a oid)");
-
- System.out.println("Inserting row");
- s.executeUpdate("insert into basic values (" + oid + ")");
-
- System.out.println("Selecting row");
- ResultSet rs = s.executeQuery("select a from basic");
- if (rs != null)
- {
- while (rs.next())
- {
- System.out.println("Fetching Blob");
- Blob b = rs.getBlob("a");
- System.out.println("Blob.length() = " + b.length());
- System.out.println("Characters 400-500:");
- System.out.write(b.getBytes(400l, 100));
- System.out.println();
- }
- rs.close();
- }
-
- System.out.println("Cleaning up");
- jdbc2api_cleanup();
- }
-
- private void jdbc2api_cleanup() throws SQLException
- {
- db.setAutoCommit(true);
- try
- {
- s.executeUpdate("drop table basic");
- }
- catch (Exception ex)
- {
- // We ignore any errors here
- }
- db.setAutoCommit(false);
- }
-
- public static void instructions()
- {
- System.err.println("java example.blobtest jdbc-url user password [debug]");
- System.err.println("\nExamples:\n");
- System.err.println("java -Djdbc.driver=org.postgresql.Driver example.blobtest jdbc:postgresql:test postgres password\nThis will run the tests on the database test on the local host.\n");
- System.err.println("java -Djdbc.driver=org.postgresql.Driver example.blobtest jdbc:postgresql:test postgres password debug\nThis is the same as above, but will output debug information.\n");
-
- System.err.println("This example tests the binary large object api of the driver.\nThis allows images or java objects to be stored in the database, and retrieved\nusing both postgresql's own api, and the standard JDBC api.");
- }
-
- public static void main(String args[])
- {
- System.out.println("PostgreSQL blobtest v7.0 rev 1\n");
-
- if (args.length < 3)
- {
- instructions();
- System.exit(1);
- }
-
- // This line outputs debug information to stderr. To enable this, simply
- // add an extra parameter to the command line
- if (args.length > 3)
- DriverManager.setLogStream(System.err);
-
- // Now run the tests
- try
- {
- blobtest test = new blobtest(args);
- }
- catch (Exception ex)
- {
- System.err.println("Exception caught.\n" + ex);
- ex.printStackTrace();
- }
- }
-}
diff --git a/src/interfaces/jdbc/example/corba/StockClient.java b/src/interfaces/jdbc/example/corba/StockClient.java
deleted file mode 100644
index 258d2df2f4e..00000000000
--- a/src/interfaces/jdbc/example/corba/StockClient.java
+++ /dev/null
@@ -1,348 +0,0 @@
-package example.corba;
-
-import java.io.*;
-import java.sql.*;
-import org.omg.CosNaming.*;
-
-/*
- * This class is the frontend to our mini CORBA application.
- *
- * It has no GUI, just a text frontend to keep it simple.
- *
- * $Id: StockClient.java,v 1.5 2001/11/19 23:19:20 momjian Exp $
- */
-public class StockClient
-{
- org.omg.CosNaming.NamingContext nameService;
-
- stock.StockDispenser dispenser;
- stock.StockItem item;
-
- BufferedReader in;
-
- public StockClient(String[] args)
- {
- try
- {
- // We need this for our IO
- in = new BufferedReader(new InputStreamReader(System.in));
-
- // Initialize the orb
- org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
-
- // Get a reference to the Naming Service
- org.omg.CORBA.Object nameServiceObj = orb.resolve_initial_references("NameService");
- if (nameServiceObj == null)
- {
- System.err.println("nameServiceObj == null");
- return;
- }
-
- nameService = org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj);
- if (nameService == null)
- {
- System.err.println("nameService == null");
- return;
- }
-
- // Resolve the dispenser
- NameComponent[] dispName = {
- new NameComponent("StockDispenser", "Stock")
- };
- dispenser = stock.StockDispenserHelper.narrow(nameService.resolve(dispName));
- if (dispenser == null)
- {
- System.err.println("dispenser == null");
- return;
- }
-
- // Now run the front end.
- run();
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- public static void main(String[] args)
- {
- new StockClient(args);
- }
-
- public void run()
- {
- // First reserve a StockItem
- try
- {
- item = dispenser.reserveItem();
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
- e.printStackTrace();
- System.exit(1);
- }
-
- mainMenu();
-
- // finally free the StockItem
- try
- {
- dispenser.releaseItem(item);
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- private void mainMenu()
- {
- boolean run = true;
- while (run)
- {
- System.out.println("\nCORBA Stock System\n");
- System.out.println(" 1 Display stock item");
- System.out.println(" 2 Remove item from stock");
- System.out.println(" 3 Put item into stock");
- System.out.println(" 4 Order item");
- System.out.println(" 5 Display all items");
- System.out.println(" 0 Exit");
- int i = getMenu("Main", 5);
- switch (i)
- {
- case 0:
- run = false;
- break;
-
- case 1:
- displayItem();
- break;
-
- case 2:
- bookOut();
- break;
-
- case 3:
- bookIn();
- break;
-
- case 4:
- order(0);
- break;
-
- case 5:
- displayAll();
- break;
- }
- }
- }
-
- private void displayItem()
- {
- try
- {
- int id = getMenu("\nStockID to display", item.getLastID());
- if (id > 0)
- {
- item.fetchItem(id);
- System.out.println("========================================");
-
- String status = "";
- if (!item.isItemValid())
- status = " ** Superceded **";
-
- int av = item.getAvailable();
-
- System.out.println(" Stock ID: " + id + status +
- "\nItems Available: " + av +
- "\nItems on order: " + item.getOrdered() +
- "\n Description: " + item.getDescription());
- System.out.println("========================================");
-
- if (av > 0)
- if (yn("Take this item out of stock?"))
- {
- int rem = 1;
- if (av > 1)
- rem = getMenu("How many?", av);
- if (rem > 0)
- item.removeStock(rem);
- }
-
- }
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
- e.printStackTrace();
- }
- }
-
- private void bookOut()
- {
- try
- {
- int id = getMenu("\nStockID to take out", item.getLastID());
- if (id > 0)
- {
- item.fetchItem(id);
- int av = item.getAvailable();
- if (av > 0)
- if (yn("Take this item out of stock?"))
- {
- int rem = 1;
- if (av > 1)
- rem = getMenu("How many?", av);
- if (rem > 0)
- item.removeStock(rem);
- }
- else
- {
- System.out.println("This item is not in stock.");
- int order = item.getOrdered();
- if (order > 0)
- System.out.println("There are " + item.getOrdered() + " items on order.");
- else
- {
- if (item.isItemValid())
- {
- System.out.println("You will need to order some more " + item.getDescription());
- order(id);
- }
- else
- System.out.println("This item is now obsolete");
- }
- }
- }
- else
- System.out.println(item.getDescription() + "\nThis item is out of stock");
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
- e.printStackTrace();
- }
- }
-
- // book an item into stock
- private void bookIn()
- {
- try
- {
- int id = getMenu("\nStockID to book in", item.getLastID());
- item.fetchItem(id);
- System.out.println(item.getDescription());
-
- if (item.getOrdered() > 0)
- {
- int am = getMenu("How many do you want to book in", item.getOrdered());
- if (am > 0)
- item.addNewStock(am);
- }
- else
- System.out.println("You don't have any of this item on ordered");
-
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
- e.printStackTrace();
- }
- }
-
- // Order an item
- private void order(int id)
- {
- try
- {
- if (id == 0)
- id = getMenu("\nStockID to order", item.getLastID());
- item.fetchItem(id);
- System.out.println(item.getDescription());
- int am = getMenu("How many do you want to order", 999);
- if (am > 0)
- item.orderStock(am);
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
- e.printStackTrace();
- }
- }
-
- private void displayAll()
- {
- try
- {
- boolean cont = true;
- int nr = item.getLastID();
- String header = "\nId\tAvail\tOrdered\tDescription";
- System.out.println(header);
- for (int i = 1;i <= nr && cont;i++)
- {
- item.fetchItem(i);
- System.out.println("" + i + "\t" + item.getAvailable() + "\t" + item.getOrdered() + "\t" + item.getDescription());
- if ((i % 20) == 0)
- {
- if ((cont = yn("Continue?")))
- System.out.println(header);
- }
- }
- }
- catch (Exception e)
- {
- System.out.println(e.toString());
- e.printStackTrace();
- }
- }
-
- private int getMenu(String title, int max)
- {
- int v = -1;
- while (v < 0 || v > max)
- {
- System.out.print(title);
- System.out.print(" [0-" + max + "]: ");
- System.out.flush();
- try
- {
- v = Integer.parseInt(in.readLine());
- }
- catch (Exception nfe)
- {
- v = -1;
- }
- }
- return v;
- }
-
- private boolean yn(String title)
- {
- try
- {
- while (true)
- {
- System.out.print(title);
- System.out.flush();
- String s = in.readLine();
- if (s.startsWith("y") || s.startsWith("Y"))
- return true;
- if (s.startsWith("n") || s.startsWith("N"))
- return false;
- }
- }
- catch (Exception nfe)
- {
- System.out.println(nfe.toString());
- nfe.printStackTrace();
- System.exit(1);
- }
- return false;
- }
-}
diff --git a/src/interfaces/jdbc/example/corba/StockDB.java b/src/interfaces/jdbc/example/corba/StockDB.java
deleted file mode 100644
index 47144983cda..00000000000
--- a/src/interfaces/jdbc/example/corba/StockDB.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package example.corba;
-
-import java.sql.*;
-
-/*
- * This class handles the JDBC side of things. It opens a connection to
- * the database, and performes queries on that database.
- *
- * In essence, you could use this class on it's own. The rest of the classes
- * in this example handle either the CORBA mechanism, or the frontend.
- *
- * Note: Before you ask, why perform a query on each call, you have to remember
- * that an object could be changed by another client, and we need to ensure that
- * the returned data is live and accurate.
- *
- * $Id: StockDB.java,v 1.4 2001/11/19 22:43:13 momjian Exp $
- */
-public class StockDB
-{
- Connection con;
- Statement st;
-
- // the current stock number
- int id = -1;
-
- public void connect(String url, String usr, String pwd) throws Exception
- {
- Class.forName("org.postgresql.Driver");
- System.out.println("Connecting to " + url);
- con = DriverManager.getConnection(url, usr, pwd);
- st = con.createStatement();
- }
-
- public void closeConnection() throws Exception
- {
- con.close();
- }
-
- public void fetchItem(int id) throws Exception
- {
- this.id = id;
- }
-
- public int newItem() throws Exception
- {
- // tba
- return -1;
- }
-
- public String getDescription() throws SQLException
- {
- ResultSet rs = st.executeQuery("select description from stock where id=" + id);
- if (rs != null)
- {
- rs.next();
- String s = rs.getString(1);
- rs.close();
- return s;
- }
- throw new SQLException("No ResultSet");
- }
-
- public int getAvailable() throws SQLException
- {
- ResultSet rs = st.executeQuery("select avail from stock where id=" + id);
- if (rs != null)
- {
- rs.next();
- int v = rs.getInt(1);
- rs.close();
- return v;
- }
- throw new SQLException("No ResultSet");
- }
-
- public int getOrdered() throws SQLException
- {
- ResultSet rs = st.executeQuery("select ordered from stock where id=" + id);
- if (rs != null)
- {
- rs.next();
- int v = rs.getInt(1);
- rs.close();
- return v;
- }
- throw new SQLException("No ResultSet");
- }
-
- public boolean isItemValid() throws SQLException
- {
- ResultSet rs = st.executeQuery("select valid from stock where id=" + id);
- if (rs != null)
- {
- rs.next();
- boolean b = rs.getBoolean(1);
- rs.close();
- return b;
- }
- throw new SQLException("No ResultSet");
- }
-
- public void addNewStock(int amount) throws SQLException
- {
- st.executeUpdate("update stock set avail=avail+" + amount +
- ", ordered=ordered-" + amount +
- " where id=" + id + " and ordered>=" + amount);
- }
-
- public void removeStock(int amount) throws SQLException
- {
- st.executeUpdate("update stock set avail=avail-" + amount +
- " where id=" + id);
- }
-
- public void orderStock(int amount) throws SQLException
- {
- st.executeUpdate("update stock set ordered=ordered+" + amount +
- " where id=" + id);
- }
-
- public int getLastID() throws SQLException
- {
- ResultSet rs = st.executeQuery("select max(id) from stock");
- if (rs != null)
- {
- rs.next();
- int v = rs.getInt(1);
- rs.close();
- return v;
- }
- throw new SQLException("No ResultSet");
- }
-
-}
diff --git a/src/interfaces/jdbc/example/corba/StockDispenserImpl.java b/src/interfaces/jdbc/example/corba/StockDispenserImpl.java
deleted file mode 100644
index 15adfe559bc..00000000000
--- a/src/interfaces/jdbc/example/corba/StockDispenserImpl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package example.corba;
-
-import org.omg.CosNaming.*;
-
-/*
- * This class implements the server side of the example.
- *
- * $Id: StockDispenserImpl.java,v 1.4 2001/11/19 23:19:20 momjian Exp $
- */
-public class StockDispenserImpl extends stock._StockDispenserImplBase
-{
- private int maxObjects = 10;
- private int numObjects = 0;
- private StockItemStatus[] stock = new StockItemStatus[maxObjects];
-
- public StockDispenserImpl(String[] args, String name, int num)
- {
- super();
-
- try
- {
- // get reference to orb
- org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
-
- // prestart num objects
- if (num >= maxObjects)
- num = maxObjects;
- numObjects = num;
- for (int i = 0;i < numObjects;i++)
- {
- stock[i] = new StockItemStatus();
- stock[i].ref = new StockItemImpl(args, "StockItem" + (i + 1));
- orb.connect(stock[i].ref);
- }
- }
- catch (org.omg.CORBA.SystemException e)
- {
- e.printStackTrace();
- }
- }
-
- /*
- * This method, defined in stock.idl, reserves a slot in the dispenser
- */
- public stock.StockItem reserveItem() throws stock.StockException
- {
- for (int i = 0;i < numObjects;i++)
- {
- if (!stock[i].inUse)
- {
- stock[i].inUse = true;
- System.out.println("Reserving slot " + i);
- return stock[i].ref;
- }
- }
- return null;
- }
-
- /*
- * This releases a slot from the dispenser
- */
- public void releaseItem(stock.StockItem item) throws stock.StockException
- {
- for (int i = 0;i < numObjects;i++)
- {
- if (stock[i].ref.getInstanceName().equals(item.getInstanceName()))
- {
- stock[i].inUse = false;
- System.out.println("Releasing slot " + i);
- return;
- }
- }
- System.out.println("Reserved object not a member of this dispenser");
- return;
- }
-
- /*
- * This class defines a slot in the dispenser
- */
- class StockItemStatus
- {
- StockItemImpl ref;
- boolean inUse;
-
- StockItemStatus()
- {
- ref = null;
- inUse = false;
- }
- }
-
-}
diff --git a/src/interfaces/jdbc/example/corba/StockItemImpl.java b/src/interfaces/jdbc/example/corba/StockItemImpl.java
deleted file mode 100644
index f504ab8dfe7..00000000000
--- a/src/interfaces/jdbc/example/corba/StockItemImpl.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package example.corba;
-
-import org.omg.CosNaming.*;
-
-/*
- * This class implements the server side of the example.
- *
- * $Id: StockItemImpl.java,v 1.3 2001/11/19 22:43:13 momjian Exp $
- */
-public class StockItemImpl extends stock._StockItemImplBase
-{
- private StockDB db;
- private String instanceName;
-
- public StockItemImpl(String[] args, String iname)
- {
- super();
- try
- {
- db = new StockDB();
- db.connect(args[1], args[2], args[3]);
- System.out.println("StockDB object " + iname + " created");
- instanceName = iname;
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /*
- * This is defined in stock.idl
- *
- * It sets the item to view
- */
- public void fetchItem(int id) throws stock.StockException
- {
- try
- {
- db.fetchItem(id);
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
-
- /*
- * This is defined in stock.idl
- *
- * It sets the item to view
- */
- public int newItem() throws stock.StockException
- {
- try
- {
- return db.newItem();
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
- /*
- * This is defined in stock.idl
- *
- * It returns the description of a Stock item
- */
- public String getDescription() throws stock.StockException
- {
- try
- {
- return db.getDescription();
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
- /*
- * This is defined in stock.idl
- *
- * It returns the description of a Stock item
- */
- public int getAvailable() throws stock.StockException
- {
- try
- {
- return db.getAvailable();
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
- /*
- * This is defined in stock.idl
- *
- * It returns the description of a Stock item
- */
- public int getOrdered() throws stock.StockException
- {
- try
- {
- return db.getOrdered();
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
- /*
- * This is defined in stock.idl
- *
- * It returns the description of a Stock item
- */
- public boolean isItemValid() throws stock.StockException
- {
- try
- {
- return db.isItemValid();
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
- /*
- * This is defined in stock.idl
- *
- * It returns the description of a Stock item
- */
- public void addNewStock(int id) throws stock.StockException
- {
- try
- {
- db.addNewStock(id);
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
- /*
- * This is defined in stock.idl
- *
- * It returns the description of a Stock item
- */
- public void removeStock(int id) throws stock.StockException
- {
- try
- {
- db.removeStock(id);
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
- /*
- * This is defined in stock.idl
- *
- * It returns the description of a Stock item
- */
- public void orderStock(int id) throws stock.StockException
- {
- try
- {
- db.orderStock(id);
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
- /*
- * This returns the highest id used, hence the number of items available
- */
- public int getLastID() throws stock.StockException
- {
- try
- {
- return db.getLastID();
- }
- catch (Exception e)
- {
- throw new stock.StockException(e.toString());
- }
- }
-
- /*
- * This is used by our Dispenser
- */
- public String getInstanceName()
- {
- return instanceName;
- }
-}
-
diff --git a/src/interfaces/jdbc/example/corba/StockServer.java b/src/interfaces/jdbc/example/corba/StockServer.java
deleted file mode 100644
index 43dcbc64fac..00000000000
--- a/src/interfaces/jdbc/example/corba/StockServer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package example.corba;
-
-import org.omg.CosNaming.*;
-
-/*
- * This class implements the server side of the example.
- *
- * $Id: StockServer.java,v 1.4 2001/11/19 23:19:20 momjian Exp $
- */
-public class StockServer
-{
- public static void main(String[] args)
- {
- int numInstances = 3;
-
- try
- {
- // Initialise the ORB
- org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
-
- // Create the StockDispenser object
- StockDispenserImpl dispenser = new StockDispenserImpl(args, "Stock Dispenser", numInstances);
-
- // Export the new object
- orb.connect(dispenser);
-
- // Get the naming service
- org.omg.CORBA.Object nameServiceObj = orb.resolve_initial_references("NameService");
- if (nameServiceObj == null)
- {
- System.err.println("nameServiceObj = null");
- return;
- }
-
- org.omg.CosNaming.NamingContext nameService = org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj);
- if (nameService == null)
- {
- System.err.println("nameService = null");
- return;
- }
-
- // bind the dispenser into the naming service
- NameComponent[] dispenserName = {
- new NameComponent("StockDispenser", "Stock")
- };
- nameService.rebind(dispenserName, dispenser);
-
- // Now wait forever for the current thread to die
- Thread.currentThread().join();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-}
-
-
diff --git a/src/interfaces/jdbc/example/corba/readme b/src/interfaces/jdbc/example/corba/readme
deleted file mode 100644
index d44c17613f3..00000000000
--- a/src/interfaces/jdbc/example/corba/readme
+++ /dev/null
@@ -1,34 +0,0 @@
-
-The CORBA example is the most complicated of the examples. It
-aims to show how to use JDBC & Java2's ORB to access PostgreSQL.
-
-To compile:
-
-Type "make corba" to build the example. This will create a new directory
-stock which contains the stubs needed by the orb, and all required classes
-under the example/corba directory.
-
-To run:
-
-NOTE: To run, you will need 3 shells on Win32 (under unix you can get away
-with two shells):
-
-1: Start the naming service
-
-Unix: tnameserv -ORBInitialPort 1050 &
-Win32: tnameserv -ORBInitialPort 1050
-
-2: Start the StockServer
-
- java example.corba.StockServer 3 jdbc:postgresql:dbase user passwd -ORBInitialPort 1050
-
-Where:
- 3 Number of concurrent sessions to allow
- dbase The database (including a hostname if required)
- user The PostgreSQL user name
- passwd The password
-
-3: Using a fresh shell, run the client:
-
- java example.corba.StockClient -ORBInitialPort 1050
-
diff --git a/src/interfaces/jdbc/example/corba/stock.idl b/src/interfaces/jdbc/example/corba/stock.idl
deleted file mode 100755
index a25ec78f54a..00000000000
--- a/src/interfaces/jdbc/example/corba/stock.idl
+++ /dev/null
@@ -1,40 +0,0 @@
-// $Id: stock.idl,v 1.1 1999/01/25 21:22:04 scrappy Exp $
-//
-// This is our CORBA bindings for a very simple stock control
-// system.
-//
-// $Id: stock.idl,v 1.1 1999/01/25 21:22:04 scrappy Exp $
-//
-
-// For some reason, idltojava on my setup doesn't like this to be
-// in caps. It could be a problem with Win95 & Samba, but for now,
-// this is in lowercase
-module stock
-{
- exception StockException
- {
- string reason;
- };
-
- interface StockItem
- {
- void fetchItem(in long id) raises (StockException);
- long newItem() raises (StockException);
- string getDescription() raises (StockException);
- long getAvailable() raises (StockException);
- long getOrdered() raises (StockException);
- boolean isItemValid() raises (StockException);
- void addNewStock(in long amount) raises (StockException);
- void removeStock(in long amount) raises (StockException);
- void orderStock(in long amount) raises (StockException);
- long getLastID() raises (StockException);
- string getInstanceName();
- };
-
- interface StockDispenser
- {
- StockItem reserveItem() raises (StockException);
- void releaseItem(in StockItem item) raises (StockException);
- };
-
-};
diff --git a/src/interfaces/jdbc/example/corba/stock.sql b/src/interfaces/jdbc/example/corba/stock.sql
deleted file mode 100644
index 2b56f9d8e00..00000000000
--- a/src/interfaces/jdbc/example/corba/stock.sql
+++ /dev/null
@@ -1,27 +0,0 @@
---
--- This creates the database for the stock example
--- $Id: stock.sql,v 1.1 1999/01/25 21:22:04 scrappy Exp $
---
-drop table stock;
-
-create table stock (
- id int4,
- avail int4,
- ordered int4,
- valid bool,
- description text
-);
-
-create index stock_id on stock(id);
-
-copy stock from stdin;
-1 19 0 t Dell Latitude XPi P133 Laptop
-2 3 2 t Iomega Zip Plus drive
-3 2 0 f Iomega Ext/Par drive
-4 0 4 t Iomega Ext USB drive
-5 200 0 t Blank Unbranded CDR media
-6 20 30 t Iomega Zip media 100Mb
-\.
-
-grant all on stock to public;
-grant all on stock_id to public;
diff --git a/src/interfaces/jdbc/example/datestyle.java b/src/interfaces/jdbc/example/datestyle.java
deleted file mode 100644
index 4cf40159ca1..00000000000
--- a/src/interfaces/jdbc/example/datestyle.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package example;
-
-import java.io.*;
-import java.sql.*;
-import java.text.*;
-
-/*
- * This example tests the various date styles that are available to postgresql.
- *
- * To use this example, you need a database to be in existence. This example
- * will create a table called datestyle.
- */
-
-public class datestyle
-{
- Connection db; // The connection to the database
- Statement st; // Our statement to run queries with
-
- // This is our standard to compare results with.
- java.sql.Date standard;
-
- // This is a list of the available date styles including variants.
- // These have to match what the "set datestyle" statement accepts.
- String styles[] = {
- "postgres,european",
- "postgres,us",
- "iso", // iso has no variants - us/european has no affect
- "sql,european",
- "sql,us",
- "german" // german has no variants - us/european has no affect
- };
-
- public datestyle(String args[]) throws ClassNotFoundException, FileNotFoundException, IOException, SQLException
- {
- String url = args[0];
- String usr = args[1];
- String pwd = args[2];
-
- // Load the driver
- Class.forName("org.postgresql.Driver");
-
- // Connect to database
- System.out.println("Connecting to Database URL = " + url);
- db = DriverManager.getConnection(url, usr, pwd);
-
- System.out.println("Connected...Now creating a statement");
- st = db.createStatement();
-
- // Clean up the database (in case we failed earlier) then initialise
- cleanup();
- init();
-
- // Now run tests using JDBC methods
- doexample();
-
- // Clean up the database
- cleanup();
-
- // Finally close the database
- System.out.println("Now closing the connection");
- st.close();
- db.close();
-
- }
-
- /*
- * This drops the table (if it existed). No errors are reported.
- */
- public void cleanup()
- {
- try
- {
- st.executeUpdate("drop table datestyle");
- }
- catch (Exception ex)
- {
- // We ignore any errors here
- }
- }
-
- /*
- * This initialises the database for this example
- */
- public void init() throws SQLException
- {
- // Create a table holding a single date
- st.executeUpdate("create table datestyle (dt date)");
-
- // Now create our standard date for the test.
- //
- // NB: each component of the date should be different, otherwise the tests
- // will not be valid.
- //
- // NB: January = 0 here
- //
- standard = new java.sql.Date(98, 0, 8);
-
- // Now store the result.
- //
- // This is an example of how to set a date in a date style independent way.
- // The only way of doing this is by using a PreparedStatement.
- //
- PreparedStatement ps = db.prepareStatement("insert into datestyle values (?)");
- ps.setDate(1, standard);
- ps.executeUpdate();
- ps.close();
- }
-
- /*
- * This performs the example
- */
- public void doexample() throws SQLException
- {
- System.out.println("\nRunning tests:");
-
- for (int i = 0;i < styles.length;i++)
- {
- System.out.print("Test " + i + " - " + styles[i]);
- System.out.flush();
-
- // set the style
- st.executeUpdate("set datestyle='" + styles[i] + "'");
-
- // Now because the driver needs to know what the current style is,
- // we have to run the following:
- st.executeUpdate("show datestyle");
- // This is a limitation, but there is no real way around this.
-
- // Now we query the table.
- ResultSet rs = st.executeQuery("select dt from datestyle");
-
- // Throw an exception if there is no result (if the table is empty
- // there should still be a result).
- if (rs == null)
- throw new SQLException("The test query returned no data");
-
- while (rs.next())
- {
- // The JDBC spec states we should only read each column once.
- // In the current implementation of the driver, this is not necessary.
- // Here we use this fact to see what the query really returned.
- if (standard.equals(rs.getDate(1)))
- System.out.println(" passed, returned " + rs.getString(1));
- else
- System.out.println(" failed, returned " + rs.getString(1));
- }
- rs.close();
- }
- }
-
- /*
- * Display some instructions on how to run the example
- */
- public static void instructions()
- {
- System.out.println("\nThis example tests the drivers ability to handle dates correctly if the\nbackend is running any of the various date styles that it supports.\nIdealy this should work fine. If it doesn't, then there is something wrong\npossibly in postgresql.Connection or in the backend itself. If this does occur\nthen please email a bug report.\n");
- System.out.println("Useage:\n java example.datestyle jdbc:postgresql:database user password [debug]\n\nThe debug field can be anything. It's presence will enable DriverManager's\ndebug trace. Unless you want to see screens of items, don't put anything in\nhere.");
- System.exit(1);
- }
-
- /*
- * This little lot starts the test
- */
- public static void main(String args[])
- {
- System.out.println("PostgreSQL datestyle test v6.3 rev 1\n");
-
- if (args.length < 3)
- instructions();
-
- // This line outputs debug information to stderr. To enable this, simply
- // add an extra parameter to the command line
- if (args.length > 3)
- DriverManager.setLogStream(System.err);
-
- // Now run the tests
- try
- {
- datestyle test = new datestyle(args);
- }
- catch (Exception ex)
- {
- System.err.println("Exception caught.\n" + ex);
- ex.printStackTrace();
- }
- }
-}
diff --git a/src/interfaces/jdbc/example/metadata.java b/src/interfaces/jdbc/example/metadata.java
deleted file mode 100644
index 468af6b9598..00000000000
--- a/src/interfaces/jdbc/example/metadata.java
+++ /dev/null
@@ -1,297 +0,0 @@
-package example;
-
-import java.io.*;
-import java.sql.*;
-import java.text.*;
-
-/*
- * This example application is not really an example. It actually performs
- * some tests on various methods in the DatabaseMetaData and ResultSetMetaData
- * classes.
- *
- * To use it, simply have a database created. It will create some work tables
- * and run tests on them.
- */
-
-public class metadata
-{
- Connection db; // The connection to the database
- Statement st; // Our statement to run queries with
- DatabaseMetaData dbmd; // This defines the structure of the database
-
- /*
- * These are the available tests on DatabaseMetaData
- */
- public void doDatabaseMetaData() throws SQLException
- {
- if (doTest("getProcedures() - should show all available procedures"))
- displayResult(dbmd.getProcedures(null, null, null));
-
- if (doTest("getProcedures() with pattern - should show all circle procedures"))
- displayResult(dbmd.getProcedures(null, null, "circle%"));
-
- if (doTest("getProcedureColumns() on circle procedures"))
- displayResult(dbmd.getProcedureColumns(null, null, "circle%", null));
-
- if (doTest("getTables()"))
- displayResult(dbmd.getTables(null, null, null, null));
-
- if (doTest("getColumns() - should show all tables, can take a while to run"))
- displayResult(dbmd.getColumns(null, null, null, null));
-
- if (doTest("getColumns() - should show the test_b table"))
- displayResult(dbmd.getColumns(null, null, "test_b", null));
-
- if (doTest("getColumnPrivileges() - should show all tables"))
- displayResult(dbmd.getColumnPrivileges(null, null, null, null));
-
- if (doTest("getPrimaryKeys()"))
- displayResult(dbmd.getPrimaryKeys(null, null, null));
-
- if (doTest("getTypeInfo()"))
- displayResult(dbmd.getTypeInfo());
-
- }
-
- /*
- * These are the available tests on ResultSetMetaData
- */
- public void doResultSetMetaData() throws SQLException
- {
-
- String sql = "select imagename,descr,source,cost from test_a,test_b,test_c where test_a.id=test_b.imageid and test_a.id=test_c.imageid";
-
- System.out.println("Executing query for tests");
- ResultSet rs = st.executeQuery(sql);
- ResultSetMetaData rsmd = rs.getMetaData();
-
- if (doTest("isCurrency()"))
- System.out.println("isCurrency on col 1 = " + rsmd.isCurrency(1) + " should be false\nisCurrency on col 4 = " + rsmd.isCurrency(4) + " should be true");
-
- // Finally close the query. Now give the user a chance to display the
- // ResultSet.
- //
- // NB: displayResult() actually closes the ResultSet.
- if (doTest("Display query result"))
- {
- System.out.println("Query: " + sql);
- displayResult(rs);
- }
- else
- rs.close();
- }
-
- /*
- * This creates some test data
- */
- public void init() throws SQLException
- {
- System.out.println("Creating some tables");
- cleanup();
- st.executeUpdate("create table test_a (imagename name,image oid,id int4)");
- st.executeUpdate("create table test_b (descr text,imageid int4,id int4)");
- st.executeUpdate("create table test_c (source text,cost money,imageid int4)");
-
- System.out.println("Adding some data");
- st.executeUpdate("insert into test_a values ('test1',0,1)");
- st.executeUpdate("insert into test_b values ('A test description',1,2)");
- st.executeUpdate("insert into test_c values ('nowhere particular','$10.99',1)");
- }
-
- /*
- * This removes the test data
- */
- public void cleanup() throws SQLException
- {
- try
- {
- st.executeUpdate("drop table test_a");
- st.executeUpdate("drop table test_b");
- st.executeUpdate("drop table test_c");
- }
- catch (Exception ex)
- {
- // We ignore any errors here
- }
- }
-
- public metadata(String args[]) throws ClassNotFoundException, FileNotFoundException, IOException, SQLException
- {
- String url = args[0];
- String usr = args[1];
- String pwd = args[2];
-
- // Load the driver
- Class.forName("org.postgresql.Driver");
-
- // Connect to database
- System.out.println("Connecting to Database URL = " + url);
- db = DriverManager.getConnection(url, usr, pwd);
-
- dbmd = db.getMetaData();
- st = db.createStatement();
-
- // This prints the backend's version
- System.out.println("Connected to " + dbmd.getDatabaseProductName() + " " + dbmd.getDatabaseProductVersion());
-
- init();
-
- System.out.println();
-
- // Now the tests
- if (doTest("Test DatabaseMetaData"))
- doDatabaseMetaData();
-
- if (doTest("Test ResultSetMetaData"))
- doResultSetMetaData();
-
- System.out.println("\nNow closing the connection");
- st.close();
- db.close();
-
- cleanup();
- }
-
- /*
- * This asks if the user requires to run a test.
- */
- public boolean doTest(String s)
- {
- System.out.println();
- System.out.print(s);
- System.out.print(" Perform test? Y or N:");
- System.out.flush();
- char c = ' ';
- try
- {
- while (!(c == 'n' || c == 'y' || c == 'N' || c == 'Y'))
- {
- c = (char)System.in.read();
- }
- }
- catch (IOException ioe)
- {
- return false;
- }
-
- return c == 'y' || c == 'Y';
- }
-
- /*
- * This displays a result set.
- * Note: it closes the result once complete.
- */
- public void displayResult(ResultSet rs) throws SQLException
- {
- ResultSetMetaData rsmd = rs.getMetaData();
- int count = 0;
-
- // Print the result column names
- int cols = rsmd.getColumnCount();
- for (int i = 1;i <= cols;i++)
- System.out.print(rsmd.getColumnLabel(i) + (i < cols ? "\t" : "\n"));
-
- // now the results
- while (rs.next())
- {
- count++;
- for (int i = 1;i <= cols;i++)
- {
- Object o = rs.getObject(i);
- if (rs.wasNull())
- System.out.print("{null}" + (i < cols ? "\t" : "\n"));
- else
- System.out.print(o.toString() + (i < cols ? "\t" : "\n"));
- }
- }
-
- System.out.println("Result returned " + count + " rows.");
-
- // finally close the result set
- rs.close();
- }
-
- /*
- * This process / commands (for now just /d)
- */
- public void processSlashCommand(String line) throws SQLException
- {
- if (line.startsWith("\\d"))
- {
- if (line.startsWith("\\d "))
- {
- // Display details about a table
- String table = line.substring(3);
- displayResult(dbmd.getColumns(null, null, table, "%"));
- }
- else
- {
- String types[] = null;
- if (line.equals("\\d"))
- types = allUserTables;
- else if (line.equals("\\di"))
- types = usrIndices;
- else if (line.equals("\\dt"))
- types = usrTables;
- else if (line.equals("\\ds"))
- types = usrSequences;
- else if (line.equals("\\dS"))
- types = sysTables;
- else
- throw new SQLException("Unsupported \\d command: " + line);
-
- // Display details about all system tables
- //
- // Note: the first two arguments are ignored. To keep to the spec,
- // you must put null here
- //
- displayResult(dbmd.getTables(null, null, "%", types));
- }
- }
- else
- throw new SQLException("Unsupported \\ command: " + line);
- }
-
- private static final String allUserTables[] = {"TABLE", "INDEX", "SEQUENCE"};
- private static final String usrIndices[] = {"INDEX"};
- private static final String usrTables[] = {"TABLE"};
- private static final String usrSequences[] = {"SEQUENCE"};
- private static final String sysTables[] = {"SYSTEM TABLE", "SYSTEM INDEX"};
-
- /*
- * Display some instructions on how to run the example
- */
- public static void instructions()
- {
- System.out.println("\nThis is not really an example, but is used to test the various methods in\nthe DatabaseMetaData and ResultSetMetaData classes.\n");
- System.out.println("Useage:\n java example.metadata jdbc:postgresql:database user password [debug]\n\nThe debug field can be anything. It's presence will enable DriverManager's\ndebug trace. Unless you want to see screens of debug items, don't put anything in\nhere.");
- System.exit(1);
- }
-
- /*
- * This little lot starts the test
- */
- public static void main(String args[])
- {
- System.out.println("PostgreSQL metdata tester v6.4 rev 1\n");
-
- if (args.length < 3)
- instructions();
-
- // This line outputs debug information to stderr. To enable this, simply
- // add an extra parameter to the command line
- if (args.length > 3)
- DriverManager.setLogStream(System.err);
-
- // Now run the tests
- try
- {
- metadata test = new metadata(args);
- }
- catch (Exception ex)
- {
- System.err.println("Exception caught.\n" + ex);
- ex.printStackTrace();
- }
- }
-}
diff --git a/src/interfaces/jdbc/example/psql.java b/src/interfaces/jdbc/example/psql.java
deleted file mode 100644
index 05932937279..00000000000
--- a/src/interfaces/jdbc/example/psql.java
+++ /dev/null
@@ -1,235 +0,0 @@
-package example;
-
-import java.io.*;
-import java.sql.*;
-import java.text.*;
-
-/*
- * This example application demonstrates some of the drivers other features
- * by implementing a simple psql replacement in Java.
- *
- */
-
-public class psql
-{
- Connection db; // The connection to the database
- Statement st; // Our statement to run queries with
- DatabaseMetaData dbmd; // This defines the structure of the database
- boolean done = false; // Added by CWJ to permit \q command
-
- public psql(String args[]) throws ClassNotFoundException, FileNotFoundException, IOException, SQLException
- {
- String url = args[0];
- String usr = args[1];
- String pwd = args[2];
-
- // Load the driver
- Class.forName("org.postgresql.Driver");
-
- // Connect to database
- System.out.println("Connecting to Database URL = " + url);
- db = DriverManager.getConnection(url, usr, pwd);
-
- dbmd = db.getMetaData();
- st = db.createStatement();
-
- // This prints the backend's version
- System.out.println("Connected to " + dbmd.getDatabaseProductName() + " " + dbmd.getDatabaseProductVersion());
-
- System.out.println();
-
- // This provides us the means of reading from stdin
- StreamTokenizer input = new StreamTokenizer(new InputStreamReader(System.in));
- input.resetSyntax();
- input.slashSlashComments(true); // allow // as a comment delimiter
- input.eolIsSignificant(false); // treat eol's as spaces
- input.wordChars(32, 126);
- input.whitespaceChars(59, 59);
- // input.quoteChar(39); *** CWJ: messes up literals in query string ***
-
- // Now the main loop.
- int tt = 0, lineno = 1;
- while (tt != StreamTokenizer.TT_EOF && ! done)
- {
- System.out.print("[" + lineno + "] ");
- System.out.flush();
-
- // Here, we trap SQLException so they don't terminate the application
- try
- {
- if ((tt = input.nextToken()) == StreamTokenizer.TT_WORD)
- {
- processLine(input.sval);
- lineno++;
- }
- }
- catch (SQLException ex)
- {
- System.out.println(ex.getMessage());
- }
- }
-
- System.out.println("Now closing the connection");
- st.close();
- db.close();
- }
-
- /*
- * This processes a statement
- */
- public void processLine(String line) throws SQLException
- {
- if (line.startsWith("\\"))
- {
- processSlashCommand(line);
- return;
- }
-
- boolean type = st.execute(line);
- boolean loop = true;
- while (loop)
- {
- if (type)
- {
- // A ResultSet was returned
- ResultSet rs = st.getResultSet();
- displayResult(rs);
- }
- else
- {
- int count = st.getUpdateCount();
-
- if (count == -1)
- {
- // This indicates nothing left
- loop = false;
- }
- else
- {
- // An update count was returned
- System.out.println("Updated " + st.getUpdateCount() + " rows");
- }
- }
-
- if (loop)
- type = st.getMoreResults();
- }
- }
-
- /*
- * This displays a result set.
- * Note: it closes the result once complete.
- */
- public void displayResult(ResultSet rs) throws SQLException
- {
- ResultSetMetaData rsmd = rs.getMetaData();
-
- // Print the result column names
- int cols = rsmd.getColumnCount();
- for (int i = 1;i <= cols;i++)
- System.out.print(rsmd.getColumnLabel(i) + (i < cols ? "\t" : "\n"));
-
- // now the results
- while (rs.next())
- {
- for (int i = 1;i <= cols;i++)
- {
- Object o = rs.getObject(i);
- if (rs.wasNull())
- System.out.print("{null}" + (i < cols ? "\t" : "\n"));
- else
- System.out.print(o.toString() + (i < cols ? "\t" : "\n"));
- }
- }
-
- // finally close the result set
- rs.close();
- }
-
- /*
- * This process / commands (for now just /d)
- */
- public void processSlashCommand(String line) throws SQLException
- {
- if (line.startsWith("\\d"))
- {
-
- if (line.startsWith("\\d "))
- {
- // Display details about a table
- String table = line.substring(3);
- displayResult(dbmd.getColumns(null, null, table, "%"));
- }
- else
- {
- String types[] = null;
- if (line.equals("\\d"))
- types = allUserTables;
- else if (line.equals("\\di"))
- types = usrIndices;
- else if (line.equals("\\dt"))
- types = usrTables;
- else if (line.equals("\\ds"))
- types = usrSequences;
- else if (line.equals("\\dS"))
- types = sysTables;
- else
- throw new SQLException("Unsupported \\d command: " + line);
-
- // Display details about all system tables
- //
- // Note: the first two arguments are ignored. To keep to the spec,
- // you must put null here
- //
- displayResult(dbmd.getTables(null, null, "%", types));
- }
- }
- else if (line.equals("\\q")) // Added by CWJ to permit \q command
- done = true;
- else
- throw new SQLException("Unsupported \\ command: " + line);
- }
-
- private static final String allUserTables[] = {"TABLE", "INDEX", "SEQUENCE"};
- private static final String usrIndices[] = {"INDEX"};
- private static final String usrTables[] = {"TABLE"};
- private static final String usrSequences[] = {"SEQUENCE"};
- private static final String sysTables[] = {"SYSTEM TABLE", "SYSTEM INDEX"};
-
- /*
- * Display some instructions on how to run the example
- */
- public static void instructions()
- {
- System.out.println("\nThis example shows how some of the other JDBC features work within the\ndriver. It does this by implementing a very simple psql equivalent in java.\nNot everything that psql does is implemented.\n");
- System.out.println("Useage:\n java example.psql jdbc:postgresql:database user password [debug]\n\nThe debug field can be anything. It's presence will enable DriverManager's\ndebug trace. Unless you want to see screens of items, don't put anything in\nhere.");
- System.exit(1);
- }
-
- /*
- * This little lot starts the test
- */
- public static void main(String args[])
- {
- System.out.println("PostgreSQL psql example v6.3 rev 1\n");
-
- if (args.length < 3)
- instructions();
-
- // This line outputs debug information to stderr. To enable this, simply
- // add an extra parameter to the command line
- if (args.length > 3)
- DriverManager.setLogStream(System.err);
-
- // Now run the tests
- try
- {
- psql test = new psql(args);
- }
- catch (Exception ex)
- {
- System.err.println("Exception caught.\n" + ex);
- ex.printStackTrace();
- }
- }
-}
diff --git a/src/interfaces/jdbc/example/threadsafe.java b/src/interfaces/jdbc/example/threadsafe.java
deleted file mode 100644
index cca7be75bee..00000000000
--- a/src/interfaces/jdbc/example/threadsafe.java
+++ /dev/null
@@ -1,403 +0,0 @@
-package example;
-
-import java.io.*;
-import java.sql.*;
-import java.text.*;
-
-// rare in user code, but we use the LargeObject API in this test
-import org.postgresql.largeobject.*;
-
-/*
- * This example tests the thread safety of the driver.
- *
- * It does this by performing several queries, in different threads. Each
- * thread has it's own Statement object, which is (in my understanding of the
- * jdbc specification) the minimum requirement.
- *
- */
-
-public class threadsafe
-{
- Connection db; // The connection to the database
- Statement st; // Our statement to run queries with
-
- public threadsafe(String args[]) throws ClassNotFoundException, FileNotFoundException, IOException, SQLException
- {
- String url = args[0];
- String usr = args[1];
- String pwd = args[2];
-
- // Load the driver
- Class.forName("org.postgresql.Driver");
-
- // Connect to database
- System.out.println("Connecting to Database URL = " + url);
- db = DriverManager.getConnection(url, usr, pwd);
-
- System.out.println("Connected...Now creating a statement");
- st = db.createStatement();
-
- // Clean up the database (in case we failed earlier) then initialise
- cleanup();
-
- // Because we use LargeObjects, we must use Transactions
- db.setAutoCommit(false);
-
- // Now run tests using JDBC methods, then LargeObjects
- doexample();
-
- // Clean up the database
- cleanup();
-
- // Finally close the database
- System.out.println("Now closing the connection");
- st.close();
- db.close();
- }
-
- /*
- * This drops the table (if it existed). No errors are reported.
- */
- public void cleanup()
- {
- try
- {
- st.executeUpdate("drop table basic1");
- }
- catch (Exception ex)
- {
- // We ignore any errors here
- }
-
- try
- {
- st.executeUpdate("drop table basic2");
- }
- catch (Exception ex)
- {
- // We ignore any errors here
- }
- }
-
- /*
- * This performs the example
- */
- public void doexample() throws SQLException
- {
- System.out.println("\nThis test runs three Threads. Two simply insert data into a table, then\nthey perform a query. While they are running, a third thread is running,\nand it load data into, then reads from a Large Object.\n\nIf alls well, this should run without any errors. If so, we are Thread Safe.\nWhy test JDBC & LargeObject's? Because both will run over the network\nconnection, and if locking on the stream isn't done correctly, the backend\nwill get pretty confused!\n");
-
- thread3 thread3 = null;
-
- try
- {
-
- // create the two threads
- Thread thread0 = Thread.currentThread();
- Thread thread1 = new thread1(db);
- Thread thread2 = new thread2(db);
- thread3 = new thread3(db);
-
- // now run, and wait for them
- thread1.start();
- thread2.start();
- thread3.start();
-
- // ok, I know this is bad, but it does the trick here as our main thread
- // will yield as long as either of the children are still running
- System.out.println("Waiting for threads to run");
- while (thread1.isAlive() || thread2.isAlive() || thread3.isAlive())
- thread0.yield();
- }
- finally
- {
- // clean up after thread3 (the finally ensures this is run even
- // if an exception is thrown inside the try { } construct)
- if (thread3 != null)
- thread3.cleanup();
- }
-
- System.out.println("No Exceptions have been thrown. This is a good omen, as it means that we are\npretty much thread safe as we can get.");
- }
-
- // This is the first thread. It's the same as the basic test
- class thread1 extends Thread
- {
- Connection c;
- Statement st;
-
- public thread1(Connection c) throws SQLException
- {
- this.c = c;
- st = c.createStatement();
- }
-
- public void run()
- {
- try
- {
- System.out.println("Thread 1 running...");
-
- // First we need a table to store data in
- st.executeUpdate("create table basic1 (a int2, b int2)");
-
- // Now insert some data, using the Statement
- st.executeUpdate("insert into basic1 values (1,1)");
- st.executeUpdate("insert into basic1 values (2,1)");
- st.executeUpdate("insert into basic1 values (3,1)");
-
- // For large inserts, a PreparedStatement is more efficient, because it
- // supports the idea of precompiling the SQL statement, and to store
- // directly, a Java object into any column. PostgreSQL doesnt support
- // precompiling, but does support setting a column to the value of a
- // Java object (like Date, String, etc).
- //
- // Also, this is the only way of writing dates in a datestyle independent
- // manner. (DateStyles are PostgreSQL's way of handling different methods
- // of representing dates in the Date data type.)
- PreparedStatement ps = db.prepareStatement("insert into basic1 values (?,?)");
- for (int i = 2;i < 2000;i++)
- {
- ps.setInt(1, 4); // "column a" = 5
- ps.setInt(2, i); // "column b" = i
- ps.executeUpdate(); // executeUpdate because insert returns no data
- // c.commit();
- if ((i % 50) == 0)
- DriverManager.println("Thread 1 done " + i + " inserts");
- }
- ps.close(); // Always close when we are done with it
-
- // Finally perform a query on the table
- DriverManager.println("Thread 1 performing a query");
- ResultSet rs = st.executeQuery("select a, b from basic1");
- int cnt = 0;
- if (rs != null)
- {
- // Now we run through the result set, printing out the result.
- // Note, we must call .next() before attempting to read any results
- while (rs.next())
- {
- int a = rs.getInt("a"); // This shows how to get the value by name
- int b = rs.getInt(2); // This shows how to get the value by column
- //System.out.println(" a="+a+" b="+b);
- cnt++;
- }
- rs.close(); // again, you must close the result when done
- }
- DriverManager.println("Thread 1 read " + cnt + " rows");
-
- // The last thing to do is to drop the table. This is done in the
- // cleanup() method.
- System.out.println("Thread 1 finished");
- }
- catch (SQLException se)
- {
- System.err.println("Thread 1: " + se.toString());
- se.printStackTrace();
- System.exit(1);
- }
- }
- }
-
- // This is the second thread. It's the similar to the basic test, and thread1
- // except it works on another table.
- class thread2 extends Thread
- {
- Connection c;
- Statement st;
-
- public thread2(Connection c) throws SQLException
- {
- this.c = c;
- st = c.createStatement();
- }
-
- public void run()
- {
- try
- {
- System.out.println("Thread 2 running...");
-
- // First we need a table to store data in
- st.executeUpdate("create table basic2 (a int2, b int2)");
-
- // For large inserts, a PreparedStatement is more efficient, because it
- // supports the idea of precompiling the SQL statement, and to store
- // directly, a Java object into any column. PostgreSQL doesnt support
- // precompiling, but does support setting a column to the value of a
- // Java object (like Date, String, etc).
- //
- // Also, this is the only way of writing dates in a datestyle independent
- // manner. (DateStyles are PostgreSQL's way of handling different methods
- // of representing dates in the Date data type.)
- PreparedStatement ps = db.prepareStatement("insert into basic2 values (?,?)");
- for (int i = 2;i < 2000;i++)
- {
- ps.setInt(1, 4); // "column a" = 5
- ps.setInt(2, i); // "column b" = i
- ps.executeUpdate(); // executeUpdate because insert returns no data
- // c.commit();
- if ((i % 50) == 0)
- DriverManager.println("Thread 2 done " + i + " inserts");
- }
- ps.close(); // Always close when we are done with it
-
- // Finally perform a query on the table
- DriverManager.println("Thread 2 performing a query");
- ResultSet rs = st.executeQuery("select * from basic2 where b>1");
- int cnt = 0;
- if (rs != null)
- {
- // First find out the column numbers.
- //
- // It's best to do this here, as calling the methods with the column
- // numbers actually performs this call each time they are called. This
- // really speeds things up on large queries.
- //
- int col_a = rs.findColumn("a");
- int col_b = rs.findColumn("b");
-
- // Now we run through the result set, printing out the result.
- // Again, we must call .next() before attempting to read any results
- while (rs.next())
- {
- int a = rs.getInt(col_a); // This shows how to get the value by name
- int b = rs.getInt(col_b); // This shows how to get the value by column
- //System.out.println(" a="+a+" b="+b);
- cnt++;
- }
- rs.close(); // again, you must close the result when done
- }
- DriverManager.println("Thread 2 read " + cnt + " rows");
-
- // The last thing to do is to drop the table. This is done in the
- // cleanup() method.
- System.out.println("Thread 2 finished");
- }
- catch (SQLException se)
- {
- System.err.println("Thread 2: " + se.toString());
- se.printStackTrace();
- System.exit(1);
- }
- }
- }
-
- // This is the third thread. It loads, then reads from a LargeObject, using
- // our LargeObject api.
- //
- // The purpose of this is to test that FastPath will work in between normal
- // JDBC queries.
- class thread3 extends Thread
- {
- Connection c;
- Statement st;
- LargeObjectManager lom;
- LargeObject lo;
- int oid;
-
- public thread3(Connection c) throws SQLException
- {
- this.c = c;
- //st = c.createStatement();
-
- // create a blob
- lom = ((org.postgresql.Connection)c).getLargeObjectAPI();
- oid = lom.create();
- System.out.println("Thread 3 has created a blob of oid " + oid);
- }
-
- public void run()
- {
- try
- {
- System.out.println("Thread 3 running...");
-
- DriverManager.println("Thread 3: Loading data into blob " + oid);
- lo = lom.open(oid);
- FileInputStream fis = new FileInputStream("example/threadsafe.java");
- // keep the buffer size small, to allow the other thread a chance
- byte buf[] = new byte[128];
- int rc, bc = 1, bs = 0;
- while ((rc = fis.read(buf)) > 0)
- {
- DriverManager.println("Thread 3 read block " + bc + " " + bs + " bytes");
- lo.write(buf, 0, rc);
- bc++;
- bs += rc;
- }
- lo.close();
- fis.close();
-
- DriverManager.println("Thread 3: Reading blob " + oid);
- lo = lom.open(oid);
- bc = 0;
- while (buf.length > 0)
- {
- buf = lo.read(buf.length);
- if (buf.length > 0)
- {
- String s = new String(buf);
- bc++;
- DriverManager.println("Thread 3 block " + bc);
- DriverManager.println("Block " + bc + " got " + s);
- }
- }
- lo.close();
-
- System.out.println("Thread 3 finished");
- }
- catch (Exception se)
- {
- System.err.println("Thread 3: " + se.toString());
- se.printStackTrace();
- System.exit(1);
- }
- }
-
- public void cleanup() throws SQLException
- {
- if (lom != null && oid != 0)
- {
- System.out.println("Thread 3: Removing blob oid=" + oid);
- lom.delete(oid);
- }
- }
- }
-
- /*
- * Display some instructions on how to run the example
- */
- public static void instructions()
- {
- System.out.println("\nThis tests the thread safety of the driver.\n\nThis is done in two parts, the first with standard JDBC calls, and the\nsecond mixing FastPath and LargeObject calls with queries.\n");
- System.out.println("Useage:\n java example.threadsafe jdbc:postgresql:database user password [debug]\n\nThe debug field can be anything. It's presence will enable DriverManager's\ndebug trace. Unless you want to see screens of items, don't put anything in\nhere.");
- System.exit(1);
- }
-
- /*
- * This little lot starts the test
- */
- public static void main(String args[])
- {
- System.out.println("PostgreSQL Thread Safety test v6.4 rev 1\n");
-
- if (args.length < 3)
- instructions();
-
- // This line outputs debug information to stderr. To enable this, simply
- // add an extra parameter to the command line
- if (args.length > 3)
- DriverManager.setLogStream(System.err);
-
- // Now run the tests
- try
- {
- threadsafe test = new threadsafe(args);
- }
- catch (Exception ex)
- {
- System.err.println("Exception caught.\n" + ex);
- ex.printStackTrace();
- }
- }
-}
diff --git a/src/interfaces/jdbc/jdbc.jpx b/src/interfaces/jdbc/jdbc.jpx
deleted file mode 100644
index 8c17267ca1b..00000000000
--- a/src/interfaces/jdbc/jdbc.jpx
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--JBuilder XML Project-->
-<project>
- <property category="runtime.0" name="RunnableType" value="com.borland.jbuilder.runtime.ApplicationRunner" />
- <property category="runtime.0" name="jsprunner.docbase" value="." />
- <property category="runtime.0" name="jsprunner.jspfile" value="E%|/docs/java/xml/example6" />
- <property category="sys" name="BackupPath" value="bak" />
- <property category="sys" name="CheckStable" value="1" />
- <property category="sys" name="Company" value="" />
- <property category="sys" name="Copyright" value="Copyright (c) 2001" />
- <property category="sys" name="DefaultPackage" value="org.postgresql.core" />
- <property category="sys" name="Description" value="" />
- <property category="sys" name="DocPath" value="doc" />
- <property category="sys" name="ExcludeClassEnabled" value="0" />
- <property category="sys" name="JDK" value="java 1.3.0-C" />
- <property category="sys" name="LastTag" value="0" />
- <property category="sys" name="Libraries" value="JUnit" />
- <property category="sys" name="MakeStable" value="0" />
- <property category="sys" name="OutPath" value="build" />
- <property category="sys" name="SourcePath" value="." />
- <property category="sys" name="Title" value="" />
- <property category="sys" name="Version" value="1.0" />
- <property category="sys" name="WorkingDirectory" value="." />
- <node type="Package" name="org.postgresql.core" />
- <file path="build.xml" />
- <file path="CHANGELOG" />
- <file path="Implementation" />
- <file path="README" />
- <file path="org/postgresql/jdbc2/UpdateableResultSet.java" />
-</project>
diff --git a/src/interfaces/jdbc/org/postgresql/Connection.java b/src/interfaces/jdbc/org/postgresql/Connection.java
deleted file mode 100644
index 7951ddd1ecb..00000000000
--- a/src/interfaces/jdbc/org/postgresql/Connection.java
+++ /dev/null
@@ -1,1246 +0,0 @@
-package org.postgresql;
-
-import java.io.*;
-import java.net.*;
-import java.sql.*;
-import java.util.*;
-import org.postgresql.Driver;
-import org.postgresql.Field;
-import org.postgresql.fastpath.*;
-import org.postgresql.largeobject.*;
-import org.postgresql.util.*;
-import org.postgresql.core.*;
-
-/*
- * $Id: Connection.java,v 1.48 2002/06/11 02:55:15 barry Exp $
- *
- * This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
- * JDBC2 versions of the Connection class.
- *
- */
-public abstract class Connection
-{
- // This is the network stream associated with this connection
- public PG_Stream pg_stream;
-
- private String PG_HOST;
- private int PG_PORT;
- private String PG_USER;
- private String PG_DATABASE;
- private boolean PG_STATUS;
- private String compatible;
-
- /*
- The encoding to use for this connection.
- */
- private Encoding encoding = Encoding.defaultEncoding();
-
- private String dbVersionNumber;
-
- public boolean CONNECTION_OK = true;
- public boolean CONNECTION_BAD = false;
-
- public boolean autoCommit = true;
- public boolean readOnly = false;
-
- public Driver this_driver;
- private String this_url;
- private String cursor = null; // The positioned update cursor name
-
- // These are new for v6.3, they determine the current protocol versions
- // supported by this version of the driver. They are defined in
- // src/include/libpq/pqcomm.h
- protected static final int PG_PROTOCOL_LATEST_MAJOR = 2;
- protected static final int PG_PROTOCOL_LATEST_MINOR = 0;
-
- private static final int AUTH_REQ_OK = 0;
- private static final int AUTH_REQ_KRB4 = 1;
- private static final int AUTH_REQ_KRB5 = 2;
- private static final int AUTH_REQ_PASSWORD = 3;
- private static final int AUTH_REQ_CRYPT = 4;
- private static final int AUTH_REQ_MD5 = 5;
-
-
- // These are used to cache oids, PGTypes and SQLTypes
- private static Hashtable sqlTypeCache = new Hashtable(); // oid -> SQLType
- private static Hashtable pgTypeCache = new Hashtable(); // oid -> PGType
- private static Hashtable typeOidCache = new Hashtable(); //PGType -> oid
-
- // Now handle notices as warnings, so things like "show" now work
- public SQLWarning firstWarning = null;
-
- /*
- * Cache of the current isolation level
- */
- private int isolationLevel = java.sql.Connection.TRANSACTION_READ_COMMITTED;
-
- // The PID an cancellation key we get from the backend process
- public int pid;
- public int ckey;
-
- /*
- * This is called by Class.forName() from within org.postgresql.Driver
- */
- public Connection()
- {}
-
- public void cancelQuery() throws SQLException
- {
- PG_Stream cancelStream = null;
- try {
- cancelStream = new PG_Stream(PG_HOST, PG_PORT);
- } catch (ConnectException cex) {
- // Added by Peter Mount <peter@retep.org.uk>
- // ConnectException is thrown when the connection cannot be made.
- // we trap this an return a more meaningful message for the end user
- throw new PSQLException ("postgresql.con.refused");
- } catch (IOException e) {
- throw new PSQLException ("postgresql.con.failed",e);
- }
-
- // Now we need to construct and send a cancel packet
- try {
- cancelStream.SendInteger(16, 4);
- cancelStream.SendInteger(80877102, 4);
- cancelStream.SendInteger(pid, 4);
- cancelStream.SendInteger(ckey, 4);
- cancelStream.flush();
- }
- catch(IOException e) {
- throw new PSQLException("postgresql.con.failed",e);
- }
- finally {
- try {
- if(cancelStream != null)
- cancelStream.close();
- }
- catch(IOException e) {} // Ignore
- }
- }
-
- /*
- * This method actually opens the connection. It is called by Driver.
- *
- * @param host the hostname of the database back end
- * @param port the port number of the postmaster process
- * @param info a Properties[] thing of the user and password
- * @param database the database to connect to
- * @param u the URL of the connection
- * @param d the Driver instantation of the connection
- * @return a valid connection profile
- * @exception SQLException if a database access error occurs
- */
- protected void openConnection(String host, int port, Properties info, String database, String url, Driver d) throws SQLException
- {
- firstWarning = null;
-
- // Throw an exception if the user or password properties are missing
- // This occasionally occurs when the client uses the properties version
- // of getConnection(), and is a common question on the email lists
- if (info.getProperty("user") == null)
- throw new PSQLException("postgresql.con.user");
-
- this_driver = d;
- this_url = url;
-
- PG_DATABASE = database;
- PG_USER = info.getProperty("user");
-
- String password = info.getProperty("password", "");
- PG_PORT = port;
-
- PG_HOST = host;
- PG_STATUS = CONNECTION_BAD;
-
- if (info.getProperty("compatible") == null)
- {
- compatible = d.getMajorVersion() + "." + d.getMinorVersion();
- }
- else
- {
- compatible = info.getProperty("compatible");
- }
-
- //Read loglevel arg and set the loglevel based on this value
- //in addition to setting the log level enable output to
- //standard out if no other printwriter is set
- String l_logLevelProp = info.getProperty("loglevel","0");
- int l_logLevel = 0;
- try {
- l_logLevel = Integer.parseInt(l_logLevelProp);
- if (l_logLevel > Driver.DEBUG || l_logLevel < Driver.INFO) {
- l_logLevel = 0;
- }
- } catch (Exception l_e) {
- //invalid value for loglevel ignore
- }
- if (l_logLevel > 0) {
- Driver.setLogLevel(l_logLevel);
- enableDriverManagerLogging();
- }
-
- //Print out the driver version number
- if (Driver.logInfo) Driver.info(Driver.getVersion());
-
- // Now make the initial connection
- try
- {
- pg_stream = new PG_Stream(host, port);
- }
- catch (ConnectException cex)
- {
- // Added by Peter Mount <peter@retep.org.uk>
- // ConnectException is thrown when the connection cannot be made.
- // we trap this an return a more meaningful message for the end user
- throw new PSQLException ("postgresql.con.refused");
- }
- catch (IOException e)
- {
- throw new PSQLException ("postgresql.con.failed", e);
- }
-
- // Now we need to construct and send a startup packet
- try
- {
- new StartupPacket(PG_PROTOCOL_LATEST_MAJOR,
- PG_PROTOCOL_LATEST_MINOR,
- PG_USER,
- database).writeTo(pg_stream);
-
- // now flush the startup packets to the backend
- pg_stream.flush();
-
- // Now get the response from the backend, either an error message
- // or an authentication request
- int areq = -1; // must have a value here
- do
- {
- int beresp = pg_stream.ReceiveChar();
- String salt = null;
- switch (beresp)
- {
- case 'E':
- // An error occured, so pass the error message to the
- // user.
- //
- // The most common one to be thrown here is:
- // "User authentication failed"
- //
- throw new PSQLException("postgresql.con.misc", pg_stream.ReceiveString(encoding));
-
- case 'R':
- // Get the type of request
- areq = pg_stream.ReceiveIntegerR(4);
- // Get the crypt password salt if there is one
- if (areq == AUTH_REQ_CRYPT)
- {
- byte[] rst = new byte[2];
- rst[0] = (byte)pg_stream.ReceiveChar();
- rst[1] = (byte)pg_stream.ReceiveChar();
- salt = new String(rst, 0, 2);
- if (Driver.logDebug) Driver.debug("Crypt salt=" + salt);
- }
-
- // Or get the md5 password salt if there is one
- if (areq == AUTH_REQ_MD5)
- {
- byte[] rst = new byte[4];
- rst[0] = (byte)pg_stream.ReceiveChar();
- rst[1] = (byte)pg_stream.ReceiveChar();
- rst[2] = (byte)pg_stream.ReceiveChar();
- rst[3] = (byte)pg_stream.ReceiveChar();
- salt = new String(rst, 0, 4);
- if (Driver.logDebug) Driver.debug("MD5 salt=" + salt);
- }
-
- // now send the auth packet
- switch (areq)
- {
- case AUTH_REQ_OK:
- break;
-
- case AUTH_REQ_KRB4:
- if (Driver.logDebug) Driver.debug("postgresql: KRB4");
- throw new PSQLException("postgresql.con.kerb4");
-
- case AUTH_REQ_KRB5:
- if (Driver.logDebug) Driver.debug("postgresql: KRB5");
- throw new PSQLException("postgresql.con.kerb5");
-
- case AUTH_REQ_PASSWORD:
- if (Driver.logDebug) Driver.debug("postgresql: PASSWORD");
- pg_stream.SendInteger(5 + password.length(), 4);
- pg_stream.Send(password.getBytes());
- pg_stream.SendInteger(0, 1);
- pg_stream.flush();
- break;
-
- case AUTH_REQ_CRYPT:
- if (Driver.logDebug) Driver.debug("postgresql: CRYPT");
- String crypted = UnixCrypt.crypt(salt, password);
- pg_stream.SendInteger(5 + crypted.length(), 4);
- pg_stream.Send(crypted.getBytes());
- pg_stream.SendInteger(0, 1);
- pg_stream.flush();
- break;
-
- case AUTH_REQ_MD5:
- if (Driver.logDebug) Driver.debug("postgresql: MD5");
- byte[] digest = MD5Digest.encode(PG_USER, password, salt);
- pg_stream.SendInteger(5 + digest.length, 4);
- pg_stream.Send(digest);
- pg_stream.SendInteger(0, 1);
- pg_stream.flush();
- break;
-
- default:
- throw new PSQLException("postgresql.con.auth", new Integer(areq));
- }
- break;
-
- default:
- throw new PSQLException("postgresql.con.authfail");
- }
- }
- while (areq != AUTH_REQ_OK);
-
- }
- catch (IOException e)
- {
- throw new PSQLException("postgresql.con.failed", e);
- }
-
-
- // As of protocol version 2.0, we should now receive the cancellation key and the pid
- int beresp;
- do {
- beresp = pg_stream.ReceiveChar();
- switch (beresp)
- {
- case 'K':
- pid = pg_stream.ReceiveIntegerR(4);
- ckey = pg_stream.ReceiveIntegerR(4);
- break;
- case 'E':
- throw new PSQLException("postgresql.con.backend", pg_stream.ReceiveString(encoding));
- case 'N':
- addWarning(pg_stream.ReceiveString(encoding));
- break;
- default:
- throw new PSQLException("postgresql.con.setup");
- }
- } while (beresp == 'N');
-
- // Expect ReadyForQuery packet
- do {
- beresp = pg_stream.ReceiveChar();
- switch (beresp)
- {
- case 'Z':
- break;
- case 'N':
- addWarning(pg_stream.ReceiveString(encoding));
- break;
- case 'E':
- throw new PSQLException("postgresql.con.backend", pg_stream.ReceiveString(encoding));
- default:
- throw new PSQLException("postgresql.con.setup");
- }
- } while (beresp == 'N');
- // "pg_encoding_to_char(1)" will return 'EUC_JP' for a backend compiled with multibyte,
- // otherwise it's hardcoded to 'SQL_ASCII'.
- // If the backend doesn't know about multibyte we can't assume anything about the encoding
- // used, so we denote this with 'UNKNOWN'.
- //Note: begining with 7.2 we should be using pg_client_encoding() which
- //is new in 7.2. However it isn't easy to conditionally call this new
- //function, since we don't yet have the information as to what server
- //version we are talking to. Thus we will continue to call
- //getdatabaseencoding() until we drop support for 7.1 and older versions
- //or until someone comes up with a conditional way to run one or
- //the other function depending on server version that doesn't require
- //two round trips to the server per connection
-
- final String encodingQuery =
- "case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end";
-
- // Set datestyle and fetch db encoding in a single call, to avoid making
- // more than one round trip to the backend during connection startup.
-
- java.sql.ResultSet resultSet =
- ExecSQL("set datestyle to 'ISO'; select version(), " + encodingQuery + ";");
-
- if (! resultSet.next())
- {
- throw new PSQLException("postgresql.con.failed", "failed getting backend encoding");
- }
- String version = resultSet.getString(1);
- dbVersionNumber = extractVersionNumber(version);
-
- String dbEncoding = resultSet.getString(2);
- encoding = Encoding.getEncoding(dbEncoding, info.getProperty("charSet"));
-
- // Initialise object handling
- initObjectTypes();
-
- // Mark the connection as ok, and cleanup
- PG_STATUS = CONNECTION_OK;
- }
-
- // These methods used to be in the main Connection implementation. As they
- // are common to all implementations (JDBC1 or 2), they are placed here.
- // This should make it easy to maintain the two specifications.
-
- /*
- * This adds a warning to the warning chain.
- * @param msg message to add
- */
- public void addWarning(String msg)
- {
- // Add the warning to the chain
- if (firstWarning != null)
- firstWarning.setNextWarning(new SQLWarning(msg));
- else
- firstWarning = new SQLWarning(msg);
-
- // Now check for some specific messages
-
- // This is obsolete in 6.5, but I've left it in here so if we need to use this
- // technique again, we'll know where to place it.
- //
- // This is generated by the SQL "show datestyle"
- //if (msg.startsWith("NOTICE:") && msg.indexOf("DateStyle")>0) {
- //// 13 is the length off "DateStyle is "
- //msg = msg.substring(msg.indexOf("DateStyle is ")+13);
- //
- //for(int i=0;i<dateStyles.length;i+=2)
- //if (msg.startsWith(dateStyles[i]))
- //currentDateStyle=i+1; // this is the index of the format
- //}
- }
-
- /*
- * Send a query to the backend. Returns one of the ResultSet
- * objects.
- *
- * <B>Note:</B> there does not seem to be any method currently
- * in existance to return the update count.
- *
- * @param sql the SQL statement to be executed
- * @return a ResultSet holding the results
- * @exception SQLException if a database error occurs
- */
- public java.sql.ResultSet ExecSQL(String sql) throws SQLException
- {
- return ExecSQL(sql, null);
- }
-
- /*
- * Send a query to the backend. Returns one of the ResultSet
- * objects.
- *
- * <B>Note:</B> there does not seem to be any method currently
- * in existance to return the update count.
- *
- * @param sql the SQL statement to be executed
- * @param stat The Statement associated with this query (may be null)
- * @return a ResultSet holding the results
- * @exception SQLException if a database error occurs
- */
- public java.sql.ResultSet ExecSQL(String sql, java.sql.Statement stat) throws SQLException
- {
- return new QueryExecutor(sql, stat, pg_stream, this).execute();
- }
-
- /*
- * In SQL, a result table can be retrieved through a cursor that
- * is named. The current row of a result can be updated or deleted
- * using a positioned update/delete statement that references the
- * cursor name.
- *
- * We support one cursor per connection.
- *
- * setCursorName sets the cursor name.
- *
- * @param cursor the cursor name
- * @exception SQLException if a database access error occurs
- */
- public void setCursorName(String cursor) throws SQLException
- {
- this.cursor = cursor;
- }
-
- /*
- * getCursorName gets the cursor name.
- *
- * @return the current cursor name
- * @exception SQLException if a database access error occurs
- */
- public String getCursorName() throws SQLException
- {
- return cursor;
- }
-
- /*
- * We are required to bring back certain information by
- * the DatabaseMetaData class. These functions do that.
- *
- * Method getURL() brings back the URL (good job we saved it)
- *
- * @return the url
- * @exception SQLException just in case...
- */
- public String getURL() throws SQLException
- {
- return this_url;
- }
-
- /*
- * Method getUserName() brings back the User Name (again, we
- * saved it)
- *
- * @return the user name
- * @exception SQLException just in case...
- */
- int lastMessage = 0;
- public String getUserName() throws SQLException
- {
- return PG_USER;
- }
-
- /*
- * Get the character encoding to use for this connection.
- */
- public Encoding getEncoding() throws SQLException
- {
- return encoding;
- }
-
- /*
- * This returns the Fastpath API for the current connection.
- *
- * <p><b>NOTE:</b> This is not part of JDBC, but allows access to
- * functions on the org.postgresql backend itself.
- *
- * <p>It is primarily used by the LargeObject API
- *
- * <p>The best way to use this is as follows:
- *
- * <p><pre>
- * import org.postgresql.fastpath.*;
- * ...
- * Fastpath fp = ((org.postgresql.Connection)myconn).getFastpathAPI();
- * </pre>
- *
- * <p>where myconn is an open Connection to org.postgresql.
- *
- * @return Fastpath object allowing access to functions on the org.postgresql
- * backend.
- * @exception SQLException by Fastpath when initialising for first time
- */
- public Fastpath getFastpathAPI() throws SQLException
- {
- if (fastpath == null)
- fastpath = new Fastpath(this, pg_stream);
- return fastpath;
- }
-
- // This holds a reference to the Fastpath API if already open
- private Fastpath fastpath = null;
-
- /*
- * This returns the LargeObject API for the current connection.
- *
- * <p><b>NOTE:</b> This is not part of JDBC, but allows access to
- * functions on the org.postgresql backend itself.
- *
- * <p>The best way to use this is as follows:
- *
- * <p><pre>
- * import org.postgresql.largeobject.*;
- * ...
- * LargeObjectManager lo = ((org.postgresql.Connection)myconn).getLargeObjectAPI();
- * </pre>
- *
- * <p>where myconn is an open Connection to org.postgresql.
- *
- * @return LargeObject object that implements the API
- * @exception SQLException by LargeObject when initialising for first time
- */
- public LargeObjectManager getLargeObjectAPI() throws SQLException
- {
- if (largeobject == null)
- largeobject = new LargeObjectManager(this);
- return largeobject;
- }
-
- // This holds a reference to the LargeObject API if already open
- private LargeObjectManager largeobject = null;
-
- /*
- * This method is used internally to return an object based around
- * org.postgresql's more unique data types.
- *
- * <p>It uses an internal Hashtable to get the handling class. If the
- * type is not supported, then an instance of org.postgresql.util.PGobject
- * is returned.
- *
- * You can use the getValue() or setValue() methods to handle the returned
- * object. Custom objects can have their own methods.
- *
- * In 6.4, this is extended to use the org.postgresql.util.Serialize class to
- * allow the Serialization of Java Objects into the database without using
- * Blobs. Refer to that class for details on how this new feature works.
- *
- * @return PGobject for this type, and set to value
- * @exception SQLException if value is not correct for this type
- * @see org.postgresql.util.Serialize
- */
- public Object getObject(String type, String value) throws SQLException
- {
- try
- {
- Object o = objectTypes.get(type);
-
- // If o is null, then the type is unknown, so check to see if type
- // is an actual table name. If it does, see if a Class is known that
- // can handle it
- if (o == null)
- {
- Serialize ser = new Serialize(this, type);
- objectTypes.put(type, ser);
- return ser.fetch(Integer.parseInt(value));
- }
-
- // If o is not null, and it is a String, then its a class name that
- // extends PGobject.
- //
- // This is used to implement the org.postgresql unique types (like lseg,
- // point, etc).
- if (o instanceof String)
- {
- // 6.3 style extending PG_Object
- PGobject obj = null;
- obj = (PGobject)(Class.forName((String)o).newInstance());
- obj.setType(type);
- obj.setValue(value);
- return (Object)obj;
- }
- else
- {
- // If it's an object, it should be an instance of our Serialize class
- // If so, then call it's fetch method.
- if (o instanceof Serialize)
- return ((Serialize)o).fetch(Integer.parseInt(value));
- }
- }
- catch (SQLException sx)
- {
- // rethrow the exception. Done because we capture any others next
- sx.fillInStackTrace();
- throw sx;
- }
- catch (Exception ex)
- {
- throw new PSQLException("postgresql.con.creobj", type, ex);
- }
-
- // should never be reached
- return null;
- }
-
- /*
- * This stores an object into the database. This method was
- * deprecated in 7.2 bacause an OID can be larger than the java signed
- * int returned by this method.
- * @deprecated Replaced by storeObject() in 7.2
- */
- public int putObject(Object o) throws SQLException
- {
- return (int) storeObject(o);
- }
-
- /*
- * This stores an object into the database.
- * @param o Object to store
- * @return OID of the new rectord
- * @exception SQLException if value is not correct for this type
- * @see org.postgresql.util.Serialize
- * @since 7.2
- */
- public long storeObject(Object o) throws SQLException
- {
- try
- {
- String type = o.getClass().getName();
- Object x = objectTypes.get(type);
-
- // If x is null, then the type is unknown, so check to see if type
- // is an actual table name. If it does, see if a Class is known that
- // can handle it
- if (x == null)
- {
- Serialize ser = new Serialize(this, type);
- objectTypes.put(type, ser);
- return ser.storeObject(o);
- }
-
- // If it's an object, it should be an instance of our Serialize class
- // If so, then call it's fetch method.
- if (x instanceof Serialize)
- return ((Serialize)x).storeObject(o);
-
- // Thow an exception because the type is unknown
- throw new PSQLException("postgresql.con.strobj");
-
- }
- catch (SQLException sx)
- {
- // rethrow the exception. Done because we capture any others next
- sx.fillInStackTrace();
- throw sx;
- }
- catch (Exception ex)
- {
- throw new PSQLException("postgresql.con.strobjex", ex);
- }
- }
-
- /*
- * This allows client code to add a handler for one of org.postgresql's
- * more unique data types.
- *
- * <p><b>NOTE:</b> This is not part of JDBC, but an extension.
- *
- * <p>The best way to use this is as follows:
- *
- * <p><pre>
- * ...
- * ((org.postgresql.Connection)myconn).addDataType("mytype","my.class.name");
- * ...
- * </pre>
- *
- * <p>where myconn is an open Connection to org.postgresql.
- *
- * <p>The handling class must extend org.postgresql.util.PGobject
- *
- * @see org.postgresql.util.PGobject
- */
- public void addDataType(String type, String name)
- {
- objectTypes.put(type, name);
- }
-
- // This holds the available types
- private Hashtable objectTypes = new Hashtable();
-
- // This array contains the types that are supported as standard.
- //
- // The first entry is the types name on the database, the second
- // the full class name of the handling class.
- //
- private static final String defaultObjectTypes[][] = {
- {"box", "org.postgresql.geometric.PGbox"},
- {"circle", "org.postgresql.geometric.PGcircle"},
- {"line", "org.postgresql.geometric.PGline"},
- {"lseg", "org.postgresql.geometric.PGlseg"},
- {"path", "org.postgresql.geometric.PGpath"},
- {"point", "org.postgresql.geometric.PGpoint"},
- {"polygon", "org.postgresql.geometric.PGpolygon"},
- {"money", "org.postgresql.util.PGmoney"}
- };
-
- // This initialises the objectTypes hashtable
- private void initObjectTypes()
- {
- for (int i = 0;i < defaultObjectTypes.length;i++)
- objectTypes.put(defaultObjectTypes[i][0], defaultObjectTypes[i][1]);
- }
-
- // These are required by other common classes
- public abstract java.sql.Statement createStatement() throws SQLException;
-
- /*
- * This returns a resultset. It must be overridden, so that the correct
- * version (from jdbc1 or jdbc2) are returned.
- */
- public abstract java.sql.ResultSet getResultSet(org.postgresql.Connection conn, java.sql.Statement stat, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
-
- /*
- * In some cases, it is desirable to immediately release a Connection's
- * database and JDBC resources instead of waiting for them to be
- * automatically released (cant think why off the top of my head)
- *
- * <B>Note:</B> A Connection is automatically closed when it is
- * garbage collected. Certain fatal errors also result in a closed
- * connection.
- *
- * @exception SQLException if a database access error occurs
- */
- public void close() throws SQLException
- {
- if (pg_stream != null)
- {
- try
- {
- pg_stream.SendChar('X');
- pg_stream.flush();
- pg_stream.close();
- }
- catch (IOException e)
- {}
- pg_stream = null;
- }
- }
-
- /*
- * A driver may convert the JDBC sql grammar into its system's
- * native SQL grammar prior to sending it; nativeSQL returns the
- * native form of the statement that the driver would have sent.
- *
- * @param sql a SQL statement that may contain one or more '?'
- * parameter placeholders
- * @return the native form of this statement
- * @exception SQLException if a database access error occurs
- */
- public String nativeSQL(String sql) throws SQLException
- {
- return sql;
- }
-
- /*
- * The first warning reported by calls on this Connection is
- * returned.
- *
- * <B>Note:</B> Sebsequent warnings will be changed to this
- * SQLWarning
- *
- * @return the first SQLWarning or null
- * @exception SQLException if a database access error occurs
- */
- public SQLWarning getWarnings() throws SQLException
- {
- return firstWarning;
- }
-
- /*
- * After this call, getWarnings returns null until a new warning
- * is reported for this connection.
- *
- * @exception SQLException if a database access error occurs
- */
- public void clearWarnings() throws SQLException
- {
- firstWarning = null;
- }
-
-
- /*
- * You can put a connection in read-only mode as a hunt to enable
- * database optimizations
- *
- * <B>Note:</B> setReadOnly cannot be called while in the middle
- * of a transaction
- *
- * @param readOnly - true enables read-only mode; false disables it
- * @exception SQLException if a database access error occurs
- */
- public void setReadOnly(boolean readOnly) throws SQLException
- {
- this.readOnly = readOnly;
- }
-
- /*
- * Tests to see if the connection is in Read Only Mode. Note that
- * we cannot really put the database in read only mode, but we pretend
- * we can by returning the value of the readOnly flag
- *
- * @return true if the connection is read only
- * @exception SQLException if a database access error occurs
- */
- public boolean isReadOnly() throws SQLException
- {
- return readOnly;
- }
-
- /*
- * If a connection is in auto-commit mode, than all its SQL
- * statements will be executed and committed as individual
- * transactions. Otherwise, its SQL statements are grouped
- * into transactions that are terminated by either commit()
- * or rollback(). By default, new connections are in auto-
- * commit mode. The commit occurs when the statement completes
- * or the next execute occurs, whichever comes first. In the
- * case of statements returning a ResultSet, the statement
- * completes when the last row of the ResultSet has been retrieved
- * or the ResultSet has been closed. In advanced cases, a single
- * statement may return multiple results as well as output parameter
- * values. Here the commit occurs when all results and output param
- * values have been retrieved.
- *
- * @param autoCommit - true enables auto-commit; false disables it
- * @exception SQLException if a database access error occurs
- */
- public void setAutoCommit(boolean autoCommit) throws SQLException
- {
- if (this.autoCommit == autoCommit)
- return;
- if (autoCommit)
- ExecSQL("end");
- else
- {
- if (haveMinimumServerVersion("7.1"))
- {
- ExecSQL("begin;" + getIsolationLevelSQL());
- }
- else
- {
- ExecSQL("begin");
- ExecSQL(getIsolationLevelSQL());
- }
- }
- this.autoCommit = autoCommit;
- }
-
- /*
- * gets the current auto-commit state
- *
- * @return Current state of the auto-commit mode
- * @exception SQLException (why?)
- * @see setAutoCommit
- */
- public boolean getAutoCommit() throws SQLException
- {
- return this.autoCommit;
- }
-
- /*
- * The method commit() makes all changes made since the previous
- * commit/rollback permanent and releases any database locks currently
- * held by the Connection. This method should only be used when
- * auto-commit has been disabled. (If autoCommit == true, then we
- * just return anyhow)
- *
- * @exception SQLException if a database access error occurs
- * @see setAutoCommit
- */
- public void commit() throws SQLException
- {
- if (autoCommit)
- return;
- if (haveMinimumServerVersion("7.1"))
- {
- ExecSQL("commit;begin;" + getIsolationLevelSQL());
- }
- else
- {
- ExecSQL("commit");
- ExecSQL("begin");
- ExecSQL(getIsolationLevelSQL());
- }
- }
-
- /*
- * The method rollback() drops all changes made since the previous
- * commit/rollback and releases any database locks currently held by
- * the Connection.
- *
- * @exception SQLException if a database access error occurs
- * @see commit
- */
- public void rollback() throws SQLException
- {
- if (autoCommit)
- return;
- if (haveMinimumServerVersion("7.1"))
- {
- ExecSQL("rollback; begin;" + getIsolationLevelSQL());
- }
- else
- {
- ExecSQL("rollback");
- ExecSQL("begin");
- ExecSQL(getIsolationLevelSQL());
- }
- }
-
- /*
- * Get this Connection's current transaction isolation mode.
- *
- * @return the current TRANSACTION_* mode value
- * @exception SQLException if a database access error occurs
- */
- public int getTransactionIsolation() throws SQLException
- {
- clearWarnings();
- ExecSQL("show transaction isolation level");
-
- SQLWarning warning = getWarnings();
- if (warning != null)
- {
- String message = warning.getMessage();
- clearWarnings();
- if (message.indexOf("READ COMMITTED") != -1)
- return java.sql.Connection.TRANSACTION_READ_COMMITTED;
- else if (message.indexOf("READ UNCOMMITTED") != -1)
- return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
- else if (message.indexOf("REPEATABLE READ") != -1)
- return java.sql.Connection.TRANSACTION_REPEATABLE_READ;
- else if (message.indexOf("SERIALIZABLE") != -1)
- return java.sql.Connection.TRANSACTION_SERIALIZABLE;
- }
- return java.sql.Connection.TRANSACTION_READ_COMMITTED;
- }
-
- /*
- * You can call this method to try to change the transaction
- * isolation level using one of the TRANSACTION_* values.
- *
- * <B>Note:</B> setTransactionIsolation cannot be called while
- * in the middle of a transaction
- *
- * @param level one of the TRANSACTION_* isolation values with
- * the exception of TRANSACTION_NONE; some databases may
- * not support other values
- * @exception SQLException if a database access error occurs
- * @see java.sql.DatabaseMetaData#supportsTransactionIsolationLevel
- */
- public void setTransactionIsolation(int level) throws SQLException
- {
- //In 7.1 and later versions of the server it is possible using
- //the "set session" command to set this once for all future txns
- //however in 7.0 and prior versions it is necessary to set it in
- //each transaction, thus adding complexity below.
- //When we decide to drop support for servers older than 7.1
- //this can be simplified
- isolationLevel = level;
- String isolationLevelSQL;
-
- if (!haveMinimumServerVersion("7.1"))
- {
- isolationLevelSQL = getIsolationLevelSQL();
- }
- else
- {
- isolationLevelSQL = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL ";
- switch (isolationLevel)
- {
- case java.sql.Connection.TRANSACTION_READ_COMMITTED:
- isolationLevelSQL += "READ COMMITTED";
- break;
- case java.sql.Connection.TRANSACTION_SERIALIZABLE:
- isolationLevelSQL += "SERIALIZABLE";
- break;
- default:
- throw new PSQLException("postgresql.con.isolevel",
- new Integer(isolationLevel));
- }
- }
- ExecSQL(isolationLevelSQL);
- }
-
- /*
- * Helper method used by setTransactionIsolation(), commit(), rollback()
- * and setAutoCommit(). This returns the SQL string needed to
- * set the isolation level for a transaction. In 7.1 and later it
- * is possible to set a default isolation level that applies to all
- * future transactions, this method is only necesary for 7.0 and older
- * servers, and should be removed when support for these older
- * servers are dropped
- */
- protected String getIsolationLevelSQL() throws SQLException
- {
- //7.1 and higher servers have a default specified so
- //no additional SQL is required to set the isolation level
- if (haveMinimumServerVersion("7.1"))
- {
- return "";
- }
- StringBuffer sb = new StringBuffer("SET TRANSACTION ISOLATION LEVEL");
-
- switch (isolationLevel)
- {
- case java.sql.Connection.TRANSACTION_READ_COMMITTED:
- sb.append(" READ COMMITTED");
- break;
-
- case java.sql.Connection.TRANSACTION_SERIALIZABLE:
- sb.append(" SERIALIZABLE");
- break;
-
- default:
- throw new PSQLException("postgresql.con.isolevel", new Integer(isolationLevel));
- }
- return sb.toString();
- }
-
- /*
- * A sub-space of this Connection's database may be selected by
- * setting a catalog name. If the driver does not support catalogs,
- * it will silently ignore this request
- *
- * @exception SQLException if a database access error occurs
- */
- public void setCatalog(String catalog) throws SQLException
- {
- //no-op
- }
-
- /*
- * Return the connections current catalog name, or null if no
- * catalog name is set, or we dont support catalogs.
- *
- * @return the current catalog name or null
- * @exception SQLException if a database access error occurs
- */
- public String getCatalog() throws SQLException
- {
- return PG_DATABASE;
- }
-
- /*
- * Overides finalize(). If called, it closes the connection.
- *
- * This was done at the request of Rachel Greenham
- * <rachel@enlarion.demon.co.uk> who hit a problem where multiple
- * clients didn't close the connection, and once a fortnight enough
- * clients were open to kill the org.postgres server.
- */
- public void finalize() throws Throwable
- {
- close();
- }
-
- private static String extractVersionNumber(String fullVersionString)
- {
- StringTokenizer versionParts = new StringTokenizer(fullVersionString);
- versionParts.nextToken(); /* "PostgreSQL" */
- return versionParts.nextToken(); /* "X.Y.Z" */
- }
-
- /*
- * Get server version number
- */
- public String getDBVersionNumber()
- {
- return dbVersionNumber;
- }
-
- public boolean haveMinimumServerVersion(String ver) throws SQLException
- {
- return (getDBVersionNumber().compareTo(ver) >= 0);
- }
-
- /*
- * This method returns true if the compatible level set in the connection
- * (which can be passed into the connection or specified in the URL)
- * is at least the value passed to this method. This is used to toggle
- * between different functionality as it changes across different releases
- * of the jdbc driver code. The values here are versions of the jdbc client
- * and not server versions. For example in 7.1 get/setBytes worked on
- * LargeObject values, in 7.2 these methods were changed to work on bytea
- * values. This change in functionality could be disabled by setting the
- * "compatible" level to be 7.1, in which case the driver will revert to
- * the 7.1 functionality.
- */
- public boolean haveMinimumCompatibleVersion(String ver) throws SQLException
- {
- return (compatible.compareTo(ver) >= 0);
- }
-
-
- /*
- * This returns the java.sql.Types type for a PG type oid
- *
- * @param oid PostgreSQL type oid
- * @return the java.sql.Types type
- * @exception SQLException if a database access error occurs
- */
- public int getSQLType(int oid) throws SQLException
- {
- Integer sqlType = (Integer)sqlTypeCache.get(new Integer(oid));
-
- // it's not in the cache, so perform a query, and add the result to the cache
- if (sqlType == null)
- {
- ResultSet result = (org.postgresql.ResultSet)ExecSQL("select typname from pg_type where oid = " + oid);
- if (result.getColumnCount() != 1 || result.getTupleCount() != 1)
- throw new PSQLException("postgresql.unexpected");
- result.next();
- String pgType = result.getString(1);
- Integer iOid = new Integer(oid);
- sqlType = new Integer(getSQLType(result.getString(1)));
- sqlTypeCache.put(iOid, sqlType);
- pgTypeCache.put(iOid, pgType);
- result.close();
- }
-
- return sqlType.intValue();
- }
-
- /*
- * This returns the java.sql.Types type for a PG type
- *
- * @param pgTypeName PostgreSQL type name
- * @return the java.sql.Types type
- */
- public abstract int getSQLType(String pgTypeName);
-
- /*
- * This returns the oid for a given PG data type
- * @param typeName PostgreSQL type name
- * @return PostgreSQL oid value for a field of this type
- */
- public int getOID(String typeName) throws SQLException
- {
- int oid = -1;
- if (typeName != null)
- {
- Integer oidValue = (Integer) typeOidCache.get(typeName);
- if (oidValue != null)
- {
- oid = oidValue.intValue();
- }
- else
- {
- // it's not in the cache, so perform a query, and add the result to the cache
- ResultSet result = (org.postgresql.ResultSet)ExecSQL("select oid from pg_type where typname='"
- + typeName + "'");
- if (result.getColumnCount() != 1 || result.getTupleCount() != 1)
- throw new PSQLException("postgresql.unexpected");
- result.next();
- oid = Integer.parseInt(result.getString(1));
- typeOidCache.put(typeName, new Integer(oid));
- result.close();
- }
- }
- return oid;
- }
-
- /*
- * We also need to get the PG type name as returned by the back end.
- *
- * @return the String representation of the type of this field
- * @exception SQLException if a database access error occurs
- */
- public String getPGType(int oid) throws SQLException
- {
- String pgType = (String) pgTypeCache.get(new Integer(oid));
- if (pgType == null)
- {
- getSQLType(oid);
- pgType = (String) pgTypeCache.get(new Integer(oid));
- }
- return pgType;
- }
-
- //Because the get/setLogStream methods are deprecated in JDBC2
- //we use them for JDBC1 here and override this method in the jdbc2
- //version of this class
- protected void enableDriverManagerLogging() {
- if (DriverManager.getLogStream() == null) {
- DriverManager.setLogStream(System.out);
- }
- }
-
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/Driver.java.in b/src/interfaces/jdbc/org/postgresql/Driver.java.in
deleted file mode 100644
index a199fe2bc7a..00000000000
--- a/src/interfaces/jdbc/org/postgresql/Driver.java.in
+++ /dev/null
@@ -1,492 +0,0 @@
-package org.postgresql;
-
-import java.sql.*;
-import java.util.*;
-
-import org.postgresql.util.PSQLException;
-
-/*
- * The Java SQL framework allows for multiple database drivers. Each
- * driver should supply a class that implements the Driver interface
- *
- * <p>The DriverManager will try to load as many drivers as it can find and
- * then for any given connection request, it will ask each driver in turn
- * to try to connect to the target URL.
- *
- * <p>It is strongly recommended that each Driver class should be small and
- * standalone so that the Driver class can be loaded and queried without
- * bringing in vast quantities of supporting code.
- *
- * <p>When a Driver class is loaded, it should create an instance of itself
- * and register it with the DriverManager. This means that a user can load
- * and register a driver by doing Class.forName("foo.bah.Driver")
- *
- * @see org.postgresql.Connection
- * @see java.sql.Driver
- */
-public class Driver implements java.sql.Driver
-{
-
- // make these public so they can be used in setLogLevel below
-
- public static final int DEBUG = 2;
- public static final int INFO = 1;
- public static boolean logDebug = false;
- public static boolean logInfo = false;
-
- static
- {
- try
- {
- // moved the registerDriver from the constructor to here
- // because some clients call the driver themselves (I know, as
- // my early jdbc work did - and that was based on other examples).
- // Placing it here, means that the driver is registered once only.
- java.sql.DriverManager.registerDriver(new Driver());
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
-
- /*
- * Construct a new driver and register it with DriverManager
- *
- * @exception SQLException for who knows what!
- */
- public Driver() throws SQLException
- {
- // Set the connectClass variable so that future calls will handle the correct
- // base class
- //if (System.getProperty("java.version").startsWith("1.1")) {
- //connectClass = "postgresql.jdbc1.Connection";
- //} else {
- //connectClass = "postgresql.jdbc2.Connection";
- //}
-
- // Ok, when the above code was introduced in 6.5 it's intention was to allow
- // the driver to automatically detect which version of JDBC was being used
- // and to detect the version of the JVM accordingly.
- //
- // It did this by using the java.version parameter.
- //
- // However, it was quickly discovered that not all JVM's returned an easily
- // parseable version number (ie "1.2") and some don't return a value at all.
- // The latter came from a discussion on the advanced java list.
- //
- // So, to solve this, I've moved the decision out of the driver, and it's now
- // a compile time parameter.
- //
- // For this to work, the Makefile creates a pseudo class which contains the class
- // name that will actually make the connection.
- }
-
- /*
- * Try to make a database connection to the given URL. The driver
- * should return "null" if it realizes it is the wrong kind of
- * driver to connect to the given URL. This will be common, as
- * when the JDBC driverManager is asked to connect to a given URL,
- * it passes the URL to each loaded driver in turn.
- *
- * <p>The driver should raise an SQLException if it is the right driver
- * to connect to the given URL, but has trouble connecting to the
- * database.
- *
- * <p>The java.util.Properties argument can be used to pass arbitrary
- * string tag/value pairs as connection arguments.
- *
- * user - (optional) The user to connect as
- * password - (optional) The password for the user
- * charSet - (optional) The character set to be used for converting
- * to/from the database to unicode. If multibyte is enabled on the
- * server then the character set of the database is used as the default,
- * otherwise the jvm character encoding is used as the default.
- * loglevel - (optional) Enable logging of messages from the driver.
- * The value is an integer from 1 to 2 where:
- * INFO = 1, DEBUG = 2
- * The output is sent to DriverManager.getPrintWriter() if set,
- * otherwise it is sent to System.out.
- * compatible - (optional) This is used to toggle
- * between different functionality as it changes across different releases
- * of the jdbc driver code. The values here are versions of the jdbc
- * client and not server versions. For example in 7.1 get/setBytes
- * worked on LargeObject values, in 7.2 these methods were changed
- * to work on bytea values. This change in functionality could
- * be disabled by setting the compatible level to be "7.1", in
- * which case the driver will revert to the 7.1 functionality.
- *
- * <p>Normally, at least
- * "user" and "password" properties should be included in the
- * properties. For a list of supported
- * character encoding , see
- * http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html
- * Note that you will probably want to have set up the Postgres database
- * itself to use the same encoding, with the "-E <encoding>" argument
- * to createdb.
- *
- * Our protocol takes the forms:
- * <PRE>
- * jdbc:org.postgresql://host:port/database?param1=val1&...
- * </PRE>
- *
- * @param url the URL of the database to connect to
- * @param info a list of arbitrary tag/value pairs as connection
- * arguments
- * @return a connection to the URL or null if it isnt us
- * @exception SQLException if a database access error occurs
- * @see java.sql.Driver#connect
- */
- public java.sql.Connection connect(String url, Properties info) throws SQLException
- {
- if ((props = parseURL(url, info)) == null)
- {
- if (Driver.logDebug) Driver.debug("Error in url" + url);
- return null;
- }
- try
- {
- if (Driver.logDebug) Driver.debug("connect " + url);
-
- org.postgresql.Connection con = (org.postgresql.Connection)(Class.forName("@JDBCCONNECTCLASS@").newInstance());
- con.openConnection (host(), port(), props, database(), url, this);
- return (java.sql.Connection)con;
- }
- catch (ClassNotFoundException ex)
- {
- if (Driver.logDebug) Driver.debug("error", ex);
- throw new PSQLException("postgresql.jvm.version", ex);
- }
- catch (PSQLException ex1)
- {
- // re-throw the exception, otherwise it will be caught next, and a
- // org.postgresql.unusual error will be returned instead.
- throw ex1;
- }
- catch (Exception ex2)
- {
- if (Driver.logDebug) Driver.debug("error", ex2);
- throw new PSQLException("postgresql.unusual", ex2);
- }
- }
-
- /*
- * Returns true if the driver thinks it can open a connection to the
- * given URL. Typically, drivers will return true if they understand
- * the subprotocol specified in the URL and false if they don't. Our
- * protocols start with jdbc:org.postgresql:
- *
- * @see java.sql.Driver#acceptsURL
- * @param url the URL of the driver
- * @return true if this driver accepts the given URL
- * @exception SQLException if a database-access error occurs
- * (Dont know why it would *shrug*)
- */
- public boolean acceptsURL(String url) throws SQLException
- {
- if (parseURL(url, null) == null)
- return false;
- return true;
- }
-
- /*
- * The getPropertyInfo method is intended to allow a generic GUI
- * tool to discover what properties it should prompt a human for
- * in order to get enough information to connect to a database.
- *
- * <p>Note that depending on the values the human has supplied so
- * far, additional values may become necessary, so it may be necessary
- * to iterate through several calls to getPropertyInfo
- *
- * @param url the Url of the database to connect to
- * @param info a proposed list of tag/value pairs that will be sent on
- * connect open.
- * @return An array of DriverPropertyInfo objects describing
- * possible properties. This array may be an empty array if
- * no properties are required
- * @exception SQLException if a database-access error occurs
- * @see java.sql.Driver#getPropertyInfo
- */
- public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
- {
- Properties p = parseURL(url, info);
-
- // naughty, but its best for speed. If anyone adds a property here, then
- // this _MUST_ be increased to accomodate them.
- DriverPropertyInfo d, dpi[] = new DriverPropertyInfo[0];
- //int i=0;
-
- //dpi[i++] = d = new DriverPropertyInfo("auth",p.getProperty("auth","default"));
- //d.description = "determines if password authentication is used";
- //d.choices = new String[4];
- //d.choices[0]="default"; // Get value from org.postgresql.auth property, defaults to trust
- //d.choices[1]="trust"; // No password authentication
- //d.choices[2]="password"; // Password authentication
- //d.choices[3]="ident"; // Ident (RFC 1413) protocol
-
- return dpi;
- }
-
- /*
- * Gets the drivers major version number
- *
- * @return the drivers major version number
- */
- public int getMajorVersion()
- {
- return @MAJORVERSION@;
- }
-
- /*
- * Get the drivers minor version number
- *
- * @return the drivers minor version number
- */
- public int getMinorVersion()
- {
- return @MINORVERSION@;
- }
-
- /*
- * Returns the VERSION variable from Makefile.global
- */
- public static String getVersion()
- {
- return "@VERSION@ jdbc driver build " + m_buildNumber;
- }
-
- /*
- * Report whether the driver is a genuine JDBC compliant driver. A
- * driver may only report "true" here if it passes the JDBC compliance
- * tests, otherwise it is required to return false. JDBC compliance
- * requires full support for the JDBC API and full support for SQL 92
- * Entry Level.
- *
- * <p>For PostgreSQL, this is not yet possible, as we are not SQL92
- * compliant (yet).
- */
- public boolean jdbcCompliant()
- {
- return false;
- }
-
- private Properties props;
-
- static private String[] protocols = { "jdbc", "postgresql" };
-
- /*
- * Constructs a new DriverURL, splitting the specified URL into its
- * component parts
- * @param url JDBC URL to parse
- * @param defaults Default properties
- * @return Properties with elements added from the url
- * @exception SQLException
- */
- Properties parseURL(String url, Properties defaults) throws SQLException
- {
- int state = -1;
- Properties urlProps = new Properties(defaults);
- String key = "";
- String value = "";
-
- StringTokenizer st = new StringTokenizer(url, ":/;=&?", true);
- for (int count = 0; (st.hasMoreTokens()); count++)
- {
- String token = st.nextToken();
-
- // PM Aug 2 1997 - Modified to allow multiple backends
- if (count <= 3)
- {
- if ((count % 2) == 1 && token.equals(":"))
- ;
- else if ((count % 2) == 0)
- {
- boolean found = (count == 0) ? true : false;
- for (int tmp = 0;tmp < protocols.length;tmp++)
- {
- if (token.equals(protocols[tmp]))
- {
- // PM June 29 1997 Added this property to enable the driver
- // to handle multiple backend protocols.
- if (count == 2 && tmp > 0)
- {
- urlProps.put("Protocol", token);
- found = true;
- }
- }
- }
-
- if (found == false)
- return null;
- }
- else
- return null;
- }
- else if (count > 3)
- {
- if (count == 4 && token.equals("/"))
- state = 0;
- else if (count == 4)
- {
- urlProps.put("PGDBNAME", token);
- state = -2;
- }
- else if (count == 5 && state == 0 && token.equals("/"))
- state = 1;
- else if (count == 5 && state == 0)
- return null;
- else if (count == 6 && state == 1)
- urlProps.put("PGHOST", token);
- else if (count == 7 && token.equals(":"))
- state = 2;
- else if (count == 8 && state == 2)
- {
- try
- {
- Integer portNumber = Integer.decode(token);
- urlProps.put("PGPORT", portNumber.toString());
- }
- catch (Exception e)
- {
- return null;
- }
- }
- else if ((count == 7 || count == 9) &&
- (state == 1 || state == 2) && token.equals("/"))
- state = -1;
- else if (state == -1)
- {
- urlProps.put("PGDBNAME", token);
- state = -2;
- }
- else if (state <= -2 && (count % 2) == 1)
- {
- // PM Aug 2 1997 - added tests for ? and &
- if (token.equals(";") || token.equals("?") || token.equals("&") )
- state = -3;
- else if (token.equals("="))
- state = -5;
- }
- else if (state <= -2 && (count % 2) == 0)
- {
- if (state == -3)
- key = token;
- else if (state == -5)
- {
- value = token;
- urlProps.put(key, value);
- state = -2;
- }
- }
- }
- }
-
- return urlProps;
-
- }
-
- /*
- * @return the hostname portion of the URL
- */
- public String host()
- {
- return props.getProperty("PGHOST", "localhost");
- }
-
- /*
- * @return the port number portion of the URL or -1 if no port was specified
- */
- public int port()
- {
- return Integer.parseInt(props.getProperty("PGPORT", "@DEF_PGPORT@"));
- }
-
- /*
- * @return the database name of the URL
- */
- public String database()
- {
- return props.getProperty("PGDBNAME", "");
- }
-
- /*
- * @return the value of any property specified in the URL or properties
- * passed to connect(), or null if not found.
- */
- public String property(String name)
- {
- return props.getProperty(name);
- }
-
- /*
- * This method was added in v6.5, and simply throws an SQLException
- * for an unimplemented method. I decided to do it this way while
- * implementing the JDBC2 extensions to JDBC, as it should help keep the
- * overall driver size down.
- */
- public static SQLException notImplemented()
- {
- return new PSQLException("postgresql.unimplemented");
- }
-
- /**
- * used to turn logging on to a certain level, can be called
- * by specifying fully qualified class ie org.postgresql.Driver.setLogLevel()
- * @param int logLevel sets the level which logging will respond to
- * INFO being almost no messages
- * DEBUG most verbose
- */
- public static void setLogLevel(int logLevel)
- {
- logDebug = (logLevel >= DEBUG) ? true : false;
- logInfo = (logLevel >= INFO) ? true : false;
- }
- /*
- * logging message at the debug level
- * messages will be printed if the logging level is less or equal to DEBUG
- */
- public static void debug(String msg)
- {
- if (logDebug)
- {
- DriverManager.println(msg);
- }
- }
- /*
- * logging message at the debug level
- * messages will be printed if the logging level is less or equal to DEBUG
- */
- public static void debug(String msg, Exception ex)
- {
- if (logDebug)
- {
- DriverManager.println(msg + ex != null ? ex.getMessage() : "null Exception");
- }
- }
- /*
- * logging message at info level
- * messages will be printed if the logging level is less or equal to INFO
- */
- public static void info(String msg)
- {
- if (logInfo)
- {
- DriverManager.println(msg);
- }
- }
- /*
- * logging message at info level
- * messages will be printed if the logging level is less or equal to INFO
- */
- public static void info(String msg, Exception ex)
- {
- if (logInfo)
- {
- DriverManager.println(msg + ex != null ? ex.getMessage() : "null Exception");
- }
- }
-
- //The build number should be incremented for every new build
- private static int m_buildNumber = 100;
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/Field.java b/src/interfaces/jdbc/org/postgresql/Field.java
deleted file mode 100644
index 8ab28057ef2..00000000000
--- a/src/interfaces/jdbc/org/postgresql/Field.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.postgresql;
-
-import java.lang.*;
-import java.sql.*;
-import java.util.*;
-import org.postgresql.*;
-import org.postgresql.util.*;
-
-/*
- * org.postgresql.Field is a class used to describe fields in a PostgreSQL
- * ResultSet
- */
-public class Field
-{
- private int length; // Internal Length of this field
- private int oid; // OID of the type
- private int mod; // type modifier of this field
- private String name; // Name of this field
-
- private Connection conn; // Connection Instantation
-
-
- /*
- * Construct a field based on the information fed to it.
- *
- * @param conn the connection this field came from
- * @param name the name of the field
- * @param oid the OID of the field
- * @param len the length of the field
- */
- public Field(Connection conn, String name, int oid, int length, int mod)
- {
- this.conn = conn;
- this.name = name;
- this.oid = oid;
- this.length = length;
- this.mod = mod;
- }
-
- /*
- * Constructor without mod parameter.
- *
- * @param conn the connection this field came from
- * @param name the name of the field
- * @param oid the OID of the field
- * @param len the length of the field
- */
- public Field(Connection conn, String name, int oid, int length)
- {
- this(conn, name, oid, length, 0);
- }
-
- /*
- * @return the oid of this Field's data type
- */
- public int getOID()
- {
- return oid;
- }
-
- /*
- * @return the mod of this Field's data type
- */
- public int getMod()
- {
- return mod;
- }
-
- /*
- * @return the name of this Field's data type
- */
- public String getName()
- {
- return name;
- }
-
- /*
- * @return the length of this Field's data type
- */
- public int getLength()
- {
- return length;
- }
-
- /*
- * We also need to get the PG type name as returned by the back end.
- *
- * @return the String representation of the PG type of this field
- * @exception SQLException if a database access error occurs
- */
- public String getPGType() throws SQLException
- {
- return conn.getPGType(oid);
- }
-
- /*
- * We also need to get the java.sql.types type.
- *
- * @return the int representation of the java.sql.types type of this field
- * @exception SQLException if a database access error occurs
- */
- public int getSQLType() throws SQLException
- {
- return conn.getSQLType(oid);
- }
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/PG_Stream.java b/src/interfaces/jdbc/org/postgresql/PG_Stream.java
deleted file mode 100644
index 9a85df8a256..00000000000
--- a/src/interfaces/jdbc/org/postgresql/PG_Stream.java
+++ /dev/null
@@ -1,374 +0,0 @@
-package org.postgresql;
-
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.*;
-import org.postgresql.core.*;
-import org.postgresql.util.*;
-
-/*
- * $Id: PG_Stream.java,v 1.16 2001/11/19 23:16:45 momjian Exp $
- *
- * This class is used by Connection & PGlobj for communicating with the
- * backend.
- *
- * @see java.sql.Connection
- */
-// This class handles all the Streamed I/O for a org.postgresql connection
-public class PG_Stream
-{
- private Socket connection;
- private InputStream pg_input;
- private BufferedOutputStream pg_output;
- private byte[] byte_buf = new byte[8*1024];
-
- BytePoolDim1 bytePoolDim1 = new BytePoolDim1();
- BytePoolDim2 bytePoolDim2 = new BytePoolDim2();
-
- /*
- * Constructor: Connect to the PostgreSQL back end and return
- * a stream connection.
- *
- * @param host the hostname to connect to
- * @param port the port number that the postmaster is sitting on
- * @exception IOException if an IOException occurs below it.
- */
- public PG_Stream(String host, int port) throws IOException
- {
- connection = new Socket(host, port);
-
- // Submitted by Jason Venner <jason@idiom.com> adds a 10x speed
- // improvement on FreeBSD machines (caused by a bug in their TCP Stack)
- connection.setTcpNoDelay(true);
-
- // Buffer sizes submitted by Sverre H Huseby <sverrehu@online.no>
- pg_input = new BufferedInputStream(connection.getInputStream(), 8192);
- pg_output = new BufferedOutputStream(connection.getOutputStream(), 8192);
- }
-
- /*
- * Sends a single character to the back end
- *
- * @param val the character to be sent
- * @exception IOException if an I/O error occurs
- */
- public void SendChar(int val) throws IOException
- {
- pg_output.write((byte)val);
- }
-
- /*
- * Sends an integer to the back end
- *
- * @param val the integer to be sent
- * @param siz the length of the integer in bytes (size of structure)
- * @exception IOException if an I/O error occurs
- */
- public void SendInteger(int val, int siz) throws IOException
- {
- byte[] buf = bytePoolDim1.allocByte(siz);
-
- while (siz-- > 0)
- {
- buf[siz] = (byte)(val & 0xff);
- val >>= 8;
- }
- Send(buf);
- }
-
- /*
- * Send an array of bytes to the backend
- *
- * @param buf The array of bytes to be sent
- * @exception IOException if an I/O error occurs
- */
- public void Send(byte buf[]) throws IOException
- {
- pg_output.write(buf);
- }
-
- /*
- * Send an exact array of bytes to the backend - if the length
- * has not been reached, send nulls until it has.
- *
- * @param buf the array of bytes to be sent
- * @param siz the number of bytes to be sent
- * @exception IOException if an I/O error occurs
- */
- public void Send(byte buf[], int siz) throws IOException
- {
- Send(buf, 0, siz);
- }
-
- /*
- * Send an exact array of bytes to the backend - if the length
- * has not been reached, send nulls until it has.
- *
- * @param buf the array of bytes to be sent
- * @param off offset in the array to start sending from
- * @param siz the number of bytes to be sent
- * @exception IOException if an I/O error occurs
- */
- public void Send(byte buf[], int off, int siz) throws IOException
- {
- int i;
-
- pg_output.write(buf, off, ((buf.length - off) < siz ? (buf.length - off) : siz));
- if ((buf.length - off) < siz)
- {
- for (i = buf.length - off ; i < siz ; ++i)
- {
- pg_output.write(0);
- }
- }
- }
-
- /*
- * Receives a single character from the backend
- *
- * @return the character received
- * @exception SQLException if an I/O Error returns
- */
- public int ReceiveChar() throws SQLException
- {
- int c = 0;
-
- try
- {
- c = pg_input.read();
- if (c < 0)
- throw new PSQLException("postgresql.stream.eof");
- }
- catch (IOException e)
- {
- throw new PSQLException("postgresql.stream.ioerror", e);
- }
- return c;
- }
-
- /*
- * Receives an integer from the backend
- *
- * @param siz length of the integer in bytes
- * @return the integer received from the backend
- * @exception SQLException if an I/O error occurs
- */
- public int ReceiveInteger(int siz) throws SQLException
- {
- int n = 0;
-
- try
- {
- for (int i = 0 ; i < siz ; i++)
- {
- int b = pg_input.read();
-
- if (b < 0)
- throw new PSQLException("postgresql.stream.eof");
- n = n | (b << (8 * i)) ;
- }
- }
- catch (IOException e)
- {
- throw new PSQLException("postgresql.stream.ioerror", e);
- }
- return n;
- }
-
- /*
- * Receives an integer from the backend
- *
- * @param siz length of the integer in bytes
- * @return the integer received from the backend
- * @exception SQLException if an I/O error occurs
- */
- public int ReceiveIntegerR(int siz) throws SQLException
- {
- int n = 0;
-
- try
- {
- for (int i = 0 ; i < siz ; i++)
- {
- int b = pg_input.read();
-
- if (b < 0)
- throw new PSQLException("postgresql.stream.eof");
- n = b | (n << 8);
- }
- }
- catch (IOException e)
- {
- throw new PSQLException("postgresql.stream.ioerror", e);
- }
- return n;
- }
-
- /*
- * Receives a null-terminated string from the backend. If we don't see a
- * null, then we assume something has gone wrong.
- *
- * @param encoding the charset encoding to use.
- * @return string from back end
- * @exception SQLException if an I/O error occurs, or end of file
- */
- public String ReceiveString(Encoding encoding)
- throws SQLException
- {
- int s = 0;
- byte[] rst = byte_buf;
- try
- {
- int buflen = rst.length;
- boolean done = false;
- while (!done)
- {
- while (s < buflen)
- {
- int c = pg_input.read();
- if (c < 0)
- throw new PSQLException("postgresql.stream.eof");
- else if (c == 0)
- {
- rst[s] = 0;
- done = true;
- break;
- }
- else
- {
- rst[s++] = (byte)c;
- }
- if (s >= buflen)
- { // Grow the buffer
- buflen = (int)(buflen * 2); // 100% bigger
- byte[] newrst = new byte[buflen];
- System.arraycopy(rst, 0, newrst, 0, s);
- rst = newrst;
- }
- }
- }
- }
- catch (IOException e)
- {
- throw new PSQLException("postgresql.stream.ioerror", e);
- }
- return encoding.decode(rst, 0, s);
- }
-
- /*
- * Read a tuple from the back end. A tuple is a two dimensional
- * array of bytes
- *
- * @param nf the number of fields expected
- * @param bin true if the tuple is a binary tuple
- * @return null if the current response has no more tuples, otherwise
- * an array of strings
- * @exception SQLException if a data I/O error occurs
- */
- public byte[][] ReceiveTuple(int nf, boolean bin) throws SQLException
- {
- int i, bim = (nf + 7) / 8;
- byte[] bitmask = Receive(bim);
- byte[][] answer = bytePoolDim2.allocByte(nf);
-
- int whichbit = 0x80;
- int whichbyte = 0;
-
- for (i = 0 ; i < nf ; ++i)
- {
- boolean isNull = ((bitmask[whichbyte] & whichbit) == 0);
- whichbit >>= 1;
- if (whichbit == 0)
- {
- ++whichbyte;
- whichbit = 0x80;
- }
- if (isNull)
- answer[i] = null;
- else
- {
- int len = ReceiveIntegerR(4);
- if (!bin)
- len -= 4;
- if (len < 0)
- len = 0;
- answer[i] = Receive(len);
- }
- }
- return answer;
- }
-
- /*
- * Reads in a given number of bytes from the backend
- *
- * @param siz number of bytes to read
- * @return array of bytes received
- * @exception SQLException if a data I/O error occurs
- */
- private byte[] Receive(int siz) throws SQLException
- {
- byte[] answer = bytePoolDim1.allocByte(siz);
- Receive(answer, 0, siz);
- return answer;
- }
-
- /*
- * Reads in a given number of bytes from the backend
- *
- * @param buf buffer to store result
- * @param off offset in buffer
- * @param siz number of bytes to read
- * @exception SQLException if a data I/O error occurs
- */
- public void Receive(byte[] b, int off, int siz) throws SQLException
- {
- int s = 0;
-
- try
- {
- while (s < siz)
- {
- int w = pg_input.read(b, off + s, siz - s);
- if (w < 0)
- throw new PSQLException("postgresql.stream.eof");
- s += w;
- }
- }
- catch (IOException e)
- {
- throw new PSQLException("postgresql.stream.ioerror", e);
- }
- }
-
- /*
- * This flushes any pending output to the backend. It is used primarily
- * by the Fastpath code.
- * @exception SQLException if an I/O error occurs
- */
- public void flush() throws SQLException
- {
- try
- {
- pg_output.flush();
- }
- catch (IOException e)
- {
- throw new PSQLException("postgresql.stream.flush", e);
- }
- }
-
- /*
- * Closes the connection
- *
- * @exception IOException if a IO Error occurs
- */
- public void close() throws IOException
- {
- pg_output.close();
- pg_input.close();
- connection.close();
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/PostgresqlDataSource.java b/src/interfaces/jdbc/org/postgresql/PostgresqlDataSource.java
deleted file mode 100644
index 3b37f790cf5..00000000000
--- a/src/interfaces/jdbc/org/postgresql/PostgresqlDataSource.java
+++ /dev/null
@@ -1,605 +0,0 @@
-/*
-* Redistribution and use of this software and associated documentation
-* ("Software"), with or without modification, are permitted provided
-* that the following conditions are met:
-*
-* 1. Redistributions of source code must retain copyright
-* statements and notices. Redistributions must also contain a
-* copy of this document.
-*
-* 2. Redistributions in binary form must reproduce the
-* above copyright notice, this list of conditions and the
-* following disclaimer in the documentation and/or other
-* materials provided with the distribution.
-*
-* 3. The name "Exolab" must not be used to endorse or promote
-* products derived from this Software without prior written
-* permission of Exoffice Technologies. For written permission,
-* please contact info@exolab.org.
-*
-* 4. Products derived from this Software may not be called "Exolab"
-* nor may "Exolab" appear in their names without prior written
-* permission of Exoffice Technologies. Exolab is a registered
-* trademark of Exoffice Technologies.
-*
-* 5. Due credit should be given to the Exolab Project
-* (http://www.exolab.org/).
-*
-* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
-* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
-* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-* OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
-*
-* $Id: PostgresqlDataSource.java,v 1.5 2001/11/19 23:16:45 momjian Exp $
-*/
-
-
-package org.postgresql;
-
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Properties;
-import java.util.Hashtable;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.DriverManager;
-import java.rmi.Remote;
-import javax.sql.DataSource;
-import javax.naming.Referenceable;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-import javax.naming.RefAddr;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.spi.ObjectFactory;
-// FIXME
-//import postgresql.util.PSQLException;
-//import postgresql.xa.XADataSourceImpl;
-import org.postgresql.util.PSQLException;
-import org.postgresql.xa.XADataSourceImpl;
-//---------
-
-/*
- * Implements a JDBC 2.0 {@link javax.sql.DataSource} for the
- * PostgreSQL driver with JNDI persistance support. XA and pooled
- * connection support is also available, but the application must
- * used the designated DataSource interface to obtain them.
- * <p>
- * The supported data source properties are:
- * <pre>
- * description (optional)
- * databaseName (required)
- * loginTimeout (optional)
- * user (optional)
- * password (optional)
- * serverName (optional)
- * portNumber (optional)
- * transactionTimeout (optional for XA connections)
- * </pre>
- * This data source may be serialized and stored in a JNDI
- * directory. Example of how to create a new data source and
- * register it with JNDI:
- * <pre>
- * PostgresqlDataSource ds;
- * InitialContext ctx;
- *
- * ds = new PostgresqlDataSource();
- * ds.setDatabaseName( "test" );
- * ds.setUser( "me" );
- * ds.setPassword( "secret" );
- * ctx = new InitialContext();
- * ctx.rebind( "/comp/jdbc/test", ds );
- * </pre>
- * Example for obtaining the data source from JNDI and
- * opening a new connections:
- * <pre>
- * InitialContext ctx;
- * DataSource ds;
- *
- * ctx = new InitialContext();
- * ds = (DataSource) ctx.lookup( "/comp/jdbc/test" );
- * ds.getConnection();
- * </pre>
- *
- *
- * @author <a href="arkin@exoffice.com">Assaf Arkin</a>
- * @version 1.0
- * @see XADataSourceImpl
- * @see DataSource
- * @see Connection
- */
-public class PostgresqlDataSource
- extends XADataSourceImpl
- implements DataSource, Referenceable,
- ObjectFactory, Serializable
-{
-
-
- /*
- * Holds the timeout for opening a new connection, specified
- * in seconds. The default is obtained from the JDBC driver.
- */
- private int _loginTimeout;
-
- /*
- * Holds the user's account name.
- */
- private String _user;
-
- /*
- * Holds the database password.
- */
- private String _password;
-
- /*
- * Holds the name of the particular database on the server.
- */
- private String _databaseName;
-
- /*
- * Description of this datasource.
- */
- private String _description = "PostgreSQL DataSource";
-
- /*
- * Holds the database server name. If null, this is
- * assumed to be the localhost.
- */
- private String _serverName;
-
- /*
- * Holds the port number where a server is listening.
- * The default value will open a connection with an
- * unspecified port.
- */
- private int _portNumber = DEFAULT_PORT;
-
- /*
- * The default port number. Since we open the connection
- * without specifying the port if it's the default one,
- * this value can be meaningless.
- */
- private static final int DEFAULT_PORT = 0;
-
- /*
- * Holds the log writer to which all messages should be
- * printed. The default writer is obtained from the driver
- * manager, but it can be specified at the datasource level
- * and will be passed to the driver. May be null.
- */
- private transient PrintWriter _logWriter;
-
- /*
- * Each datasource maintains it's own driver, in case of
- * driver-specific setup (e.g. pools, log writer).
- */
- // FIXME
- // private transient postgresql.Driver _driver;
- private transient org.postgresql.Driver _driver;
-
- public PostgresqlDataSource()
- {
- _logWriter = DriverManager.getLogWriter();
- _loginTimeout = DriverManager.getLoginTimeout();
- }
-
-
- public Connection getConnection()
- throws SQLException
- {
- // Uses the username and password specified for the datasource.
- return getConnection( _user, _password );
- }
-
-
- public synchronized Connection getConnection( String user, String password )
- throws SQLException
- {
- Connection conn;
- Properties info;
- String url;
-
- if ( _driver == null )
- {
- try
- {
- // Constructs a driver for use just by this data source
- // which will produce TwoPhaseConnection-s. This driver
- // is not registered with the driver manager.
- // FIXME
- // _driver = new postgresql.Driver();
- _driver = new org.postgresql.Driver();
-
- //FIXME
- // _driver.setLogWriter( _logWriter );
- // Method seems to be unavailable. Just commented it out.
- }
- catch ( SQLException except )
- {
- if ( _logWriter != null )
- _logWriter.println( "DataSource: Failed to initialize JDBC driver: " + except );
- throw except;
- }
- }
-
- // Use info to supply properties that are not in the URL.
- info = new Properties();
- info.put( "loginTimeout", Integer.toString( _loginTimeout ) );
-
- // DriverManager will do that and not rely on the URL alone.
- if ( user == null )
- {
- user = _user;
- password = _password;
- }
- if ( user == null || password == null )
- throw new PSQLException( "postgresql.ds.userpswd" );
- info.put( "user", user );
- info.put( "password", password );
-
- if ( _serverName != null )
- info.put( "PGHOST", _serverName );
- if ( _portNumber != DEFAULT_PORT )
- info.put( "PGPORT", Integer.toString( _portNumber ) );
- if ( _databaseName != null )
- info.put( "PGDBNAME", _databaseName );
-
- // Construct the URL suitable for this driver.
- url = "jdbc:postgresql:";
-
- // Attempt to establish a connection. Report a successful
- // attempt or a failure.
- try
- {
- conn = _driver.connect( url, info );
- // FIXME
- // if ( ! ( conn instanceof postgresql.jdbc2.Connection ) ) {
- if ( ! ( conn instanceof org.postgresql.jdbc2.Connection ) )
- {
- if ( _logWriter != null )
- _logWriter.println( "DataSource: JDBC 1 connections not supported" );
- throw new PSQLException( "postgresql.ds.onlyjdbc2" );
- }
- }
- catch ( SQLException except )
- {
- if ( _logWriter != null )
- _logWriter.println( "DataSource: getConnection failed " + except );
- throw except;
- }
- if ( conn != null && _logWriter != null )
- _logWriter.println( "DataSource: getConnection returning " + conn );
- return conn;
- }
-
-
- public PrintWriter getLogWriter()
- {
- return _logWriter;
- }
-
-
- public synchronized void setLogWriter( PrintWriter writer )
- {
- // Once a log writer has been set, we cannot set it since some
- // thread might be conditionally accessing it right now without
- // synchronizing.
- if ( writer != null )
- {
- if ( _driver != null )
- // FIXME
- // _driver.setLogWriter( writer );
- // Method seems to be unavailable. Commented it out.
- _logWriter = writer;
- }
- }
-
-
- public void setLoginTimeout( int seconds )
- {
- _loginTimeout = seconds;
- }
-
-
- public synchronized int getLoginTimeout()
- {
- return _loginTimeout;
- }
-
-
- /*
- * Sets the name of the particular database on the server.
- * The standard name for this property is <tt>databaseName</tt>.
- *
- * @param databaseName The name of the particular database on the server
- */
- public synchronized void setDatabaseName( String databaseName )
- {
- if ( databaseName == null )
- throw new NullPointerException( "DataSource: Argument 'databaseName' is null" );
- _databaseName = databaseName;
- }
-
-
- /*
- * Returns the name of the particular database on the server.
- * The standard name for this property is <tt>databaseName</tt>.
- *
- * @return The name of the particular database on the server
- */
- public String getDatabaseName()
- {
- return _databaseName;
- }
-
-
- /*
- * Sets the description of this datasource.
- * The standard name for this property is <tt>description</tt>.
- *
- * @param description The description of this datasource
- */
- public synchronized void setDescription( String description )
- {
- if ( description == null )
- throw new NullPointerException( "DataSource: Argument 'description' is null" );
- _description = description;
- }
-
-
- /*
- * Returns the description of this datasource.
- * The standard name for this property is <tt>description</tt>.
- *
- * @return The description of this datasource
- */
- public String getDescription()
- {
- return _description;
- }
-
-
- /*
- * Sets the database password.
- * The standard name for this property is <tt>password</tt>.
- *
- * @param password The database password
- */
- public synchronized void setPassword( String password )
- {
- _password = password;
- }
-
-
- /*
- * Returns the database password.
- * The standard name for this property is <tt>password</tt>.
- *
- * @return The database password
- */
- public String getPassword()
- {
- return _password;
- }
-
-
- /*
- * Sets the port number where a server is listening.
- * The standard name for this property is <tt>portNumber</tt>.
- *
- * @param portNumber The port number where a server is listening
- */
- public synchronized void setPortNumber( int portNumber )
- {
- _portNumber = portNumber;
- }
-
-
- /*
- * Returns the port number where a server is listening.
- * The standard name for this property is <tt>portNumber</tt>.
- *
- * @return The port number where a server is listening
- */
- public int getPortNumber()
- {
- return _portNumber;
- }
-
-
- /*
- * Sets the database server name.
-
- * The standard name for this property is <tt>serverName</tt>.
- *
- * @param serverName The database server name
- */
- public synchronized void setServerName( String serverName )
- {
- _serverName = serverName;
- }
-
-
- /*
- * Returns the database server name.
- * The standard name for this property is <tt>serverName</tt>.
- *
- * @return The database server name
- */
- public String getServerName()
- {
- return _serverName;
- }
-
-
- /*
- * Sets the user's account name.
- * The standard name for this property is <tt>user</tt>.
- *
- * @param user The user's account name
- */
- public synchronized void setUser( String user )
- {
- _user = user;
- }
-
-
- /*
- * Returns the user's account name.
- * The standard name for this property is <tt>user</tt>.
- *
- * @return The user's account name
- */
- public String getUser()
- {
- return _user;
- }
-
-
- /*
- * Returns true if this datasource and the other are equal.
- * The two datasources are equal if and only if they will produce
- * the exact same connections. Connection properties like database
- * name, user name, etc are comapred. Setup properties like
- * description, log writer, etc are not compared.
- */
- public synchronized boolean equals( Object other )
- {
- if ( other == this )
- return true;
- if ( other == null || ! ( other instanceof PostgresqlDataSource ) )
- return false;
-
- PostgresqlDataSource with;
-
- with = (PostgresqlDataSource) other;
- if ( _databaseName != null && _databaseName.equals( with._databaseName ) )
- if ( _portNumber == with._portNumber &&
- ( ( _serverName == null && with._serverName == null ) ||
- ( _serverName != null && _serverName.equals( with._serverName ) ) ) )
- if ( ( _user == null && with._user == null ) ||
- ( _user != null && _password != null && _user.equals( with._user ) &&
- _password.equals( with._password ) ) )
- return true;
- return false;
- }
-
-
- public String toString()
- {
- if ( _description != null )
- return _description;
- else
- {
- String url;
-
- url = "jdbc:postgresql:";
- if ( _serverName != null )
- {
- if ( _portNumber == DEFAULT_PORT )
- url = url + "//" + _serverName + "/";
- else
- url = url + "//" + _serverName + ":" + _portNumber + "/";
- }
- else if ( _portNumber != DEFAULT_PORT )
- url = url + "//localhost:" + _portNumber + "/";
- if ( _databaseName != null )
- url = url + _databaseName;
- return "DataSource " + url;
- }
- }
-
-
- public synchronized Reference getReference()
- {
- Reference ref;
-
- // We use same object as factory.
- ref = new Reference( getClass().getName(), getClass().getName(), null );
- // Mandatory properties
- ref.add( new StringRefAddr( "description", _description ) );
- ref.add( new StringRefAddr( "databaseName", _databaseName ) );
- ref.add( new StringRefAddr( "loginTimeout", Integer.toString( _loginTimeout ) ) );
- // Optional properties
- if ( _user != null )
- ref.add( new StringRefAddr( "user", _user ) );
- if ( _password != null )
- ref.add( new StringRefAddr( "password", _password ) );
- if ( _serverName != null )
- ref.add( new StringRefAddr( "serverName", _serverName ) );
- if ( _portNumber != DEFAULT_PORT )
- ref.add( new StringRefAddr( "portNumber", Integer.toString( _portNumber ) ) );
- ref.add( new StringRefAddr( "transactionTimeout", Integer.toString( getTransactionTimeout() ) ) );
- return ref;
- }
-
-
- public Object getObjectInstance( Object refObj, Name name, Context nameCtx, Hashtable env )
- throws NamingException
- {
- Reference ref;
-
- // Can only reconstruct from a reference.
- if ( refObj instanceof Reference )
- {
- ref = (Reference) refObj;
- // Make sure reference is of datasource class.
- if ( ref.getClassName().equals( getClass().getName() ) )
- {
-
- PostgresqlDataSource ds;
- RefAddr addr;
-
- try
- {
- ds = (PostgresqlDataSource) Class.forName( ref.getClassName() ).newInstance();
- }
- catch ( Exception except )
- {
- throw new NamingException( except.toString() );
- }
- // Mandatory properties
- ds._description = (String) ref.get( "description" ).getContent();
- ds._databaseName = (String) ref.get( "databaseName" ).getContent();
- ds._loginTimeout = Integer.parseInt( (String) ref.get( "loginTimeout" ).getContent() );
- // Optional properties
- addr = ref.get( "user" );
- if ( addr != null )
- ds._user = (String) addr.getContent();
- addr = ref.get( "password" );
- if ( addr != null )
- ds._password = (String) addr.getContent();
- addr = ref.get( "serverName" );
- if ( addr != null )
- ds._serverName = (String) addr.getContent();
- addr = ref.get( "portNumber" );
- if ( addr != null )
- ds._portNumber = Integer.parseInt( (String) addr.getContent() );
- addr = ref.get( "transactionTimeout" );
- if ( addr != null )
- setTransactionTimeout( Integer.parseInt( (String) addr.getContent() ) );
- return ds;
-
- }
- else
- throw new NamingException( "DataSource: Reference not constructed from class " + getClass().getName() );
- }
- else if ( refObj instanceof Remote )
- return refObj;
- else
- return null;
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/ResultSet.java b/src/interfaces/jdbc/org/postgresql/ResultSet.java
deleted file mode 100644
index 6e533eed010..00000000000
--- a/src/interfaces/jdbc/org/postgresql/ResultSet.java
+++ /dev/null
@@ -1,264 +0,0 @@
-package org.postgresql;
-
-import java.lang.*;
-import java.io.*;
-import java.math.*;
-import java.text.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.largeobject.*;
-import org.postgresql.util.*;
-
-/*
- * This class implements the common internal methods used by both JDBC 1 and
- * JDBC 2 specifications.
- */
-public abstract class ResultSet
-{
- protected Vector rows; // The results
- protected Field fields[]; // The field descriptions
- protected String status; // Status of the result
- protected boolean binaryCursor = false; // is the data binary or Strings
- protected int updateCount; // How many rows did we get back?
- protected long insertOID; // The oid of an inserted row
- protected int current_row; // Our pointer to where we are at
- protected byte[][] this_row; // the current row result
- protected Connection connection; // the connection which we returned from
- protected SQLWarning warnings = null; // The warning chain
- protected boolean wasNullFlag = false; // the flag for wasNull()
-
- // We can chain multiple resultSets together - this points to
- // next resultSet in the chain.
- protected ResultSet next = null;
-
- /*
- * Create a new ResultSet - Note that we create ResultSets to
- * represent the results of everything.
- *
- * @param fields an array of Field objects (basically, the
- * ResultSet MetaData)
- * @param tuples Vector of the actual data
- * @param status the status string returned from the back end
- * @param updateCount the number of rows affected by the operation
- * @param cursor the positioned update/delete cursor name
- */
- public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
- {
- this.connection = conn;
- this.fields = fields;
- this.rows = tuples;
- this.status = status;
- this.updateCount = updateCount;
- this.insertOID = insertOID;
- this.this_row = null;
- this.current_row = -1;
- this.binaryCursor = binaryCursor;
- }
-
-
- /*
- * Create a new ResultSet - Note that we create ResultSets to
- * represent the results of everything.
- *
- * @param fields an array of Field objects (basically, the
- * ResultSet MetaData)
- * @param tuples Vector of the actual data
- * @param status the status string returned from the back end
- * @param updateCount the number of rows affected by the operation
- * @param cursor the positioned update/delete cursor name
- */
- public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
- {
- this(conn, fields, tuples, status, updateCount, 0, false);
- }
-
- /*
- * We at times need to know if the resultSet we are working
- * with is the result of an UPDATE, DELETE or INSERT (in which
- * case, we only have a row count), or of a SELECT operation
- * (in which case, we have multiple fields) - this routine
- * tells us.
- *
- * @return true if we have tuples available
- */
- public boolean reallyResultSet()
- {
- return (fields != null);
- }
-
- /*
- * Since ResultSets can be chained, we need some method of
- * finding the next one in the chain. The method getNext()
- * returns the next one in the chain.
- *
- * @return the next ResultSet, or null if there are none
- */
- public java.sql.ResultSet getNext()
- {
- return (java.sql.ResultSet)next;
- }
-
- /*
- * This following method allows us to add a ResultSet object
- * to the end of the current chain.
- *
- * @param r the resultset to add to the end of the chain.
- */
- public void append(ResultSet r)
- {
- if (next == null)
- next = r;
- else
- next.append(r);
- }
-
- /*
- * If we are just a place holder for results, we still need
- * to get an updateCount. This method returns it.
- *
- * @return the updateCount
- */
- public int getResultCount()
- {
- return updateCount;
- }
-
- /*
- * We also need to provide a couple of auxiliary functions for
- * the implementation of the ResultMetaData functions. In
- * particular, we need to know the number of rows and the
- * number of columns. Rows are also known as Tuples
- *
- * @return the number of rows
- */
- public int getTupleCount()
- {
- return rows.size();
- }
-
- /*
- * getColumnCount returns the number of columns
- *
- * @return the number of columns
- */
- public int getColumnCount()
- {
- return fields.length;
- }
-
- /*
- * Returns the status message from the backend.<p>
- * It is used internally by the driver.
- *
- * @return the status string from the backend
- */
- public String getStatusString()
- {
- return status;
- }
-
- /*
- * returns the OID of a field.<p>
- * It is used internally by the driver.
- *
- * @param field field id
- * @return the oid of that field's type
- */
- public int getColumnOID(int field)
- {
- return fields[field -1].getOID();
- }
-
- /*
- * returns the OID of the last inserted row. Deprecated in 7.2 because
- * range for OID values is greater than java signed int.
- * @deprecated Replaced by getLastOID() in 7.2
- */
- public int getInsertedOID()
- {
- return (int) getLastOID();
- }
-
-
- /*
- * returns the OID of the last inserted row
- * @since 7.2
- */
- public long getLastOID()
- {
- return insertOID;
- }
-
- /*
- * This is part of the JDBC API, but is required by org.postgresql.Field
- */
- public abstract void close() throws SQLException;
- public abstract boolean next() throws SQLException;
- public abstract String getString(int i) throws SQLException;
-
- /*
- * This is used to fix get*() methods on Money fields. It should only be
- * used by those methods!
- *
- * It converts ($##.##) to -##.## and $##.## to ##.##
- */
- public String getFixedString(int col) throws SQLException
- {
- String s = getString(col);
-
- // Handle SQL Null
- wasNullFlag = (this_row[col - 1] == null);
- if (wasNullFlag)
- return null;
-
- // Handle Money
- if (s.charAt(0) == '(')
- {
- s = "-" + org.postgresql.util.PGtokenizer.removePara(s).substring(1);
- }
- if (s.charAt(0) == '$')
- {
- s = s.substring(1);
- }
-
- return s;
- }
-
- /**
- * The first warning reported by calls on this ResultSet is
- * returned. Subsequent ResultSet warnings will be chained
- * to this SQLWarning.
- *
- * <p>The warning chain is automatically cleared each time a new
- * row is read.
- *
- * <p><B>Note:</B> This warning chain only covers warnings caused by
- * ResultSet methods. Any warnings caused by statement methods
- * (such as reading OUT parameters) will be chained on the
- * Statement object.
- *
- * @return the first SQLWarning or null;
- * @exception SQLException if a database access error occurs.
- */
- public SQLWarning getWarnings() throws SQLException
- {
- return warnings;
- }
-
- /**
- * Add a warning chain to the current warning chain
- * @param warnings warnings to add
- */
- public void addWarnings(SQLWarning warnings) {
- if ( this.warnings != null )
- this.warnings.setNextWarning(warnings);
- else
- this.warnings = warnings;
- }
- protected void checkResultSet( int column ) throws SQLException
- {
- if ( this_row == null ) throw new PSQLException("postgresql.res.nextrequired");
- if ( column < 1 || column > fields.length ) throw new PSQLException("postgresql.res.colrange" );
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/Statement.java b/src/interfaces/jdbc/org/postgresql/Statement.java
deleted file mode 100644
index ea2cc0d0c33..00000000000
--- a/src/interfaces/jdbc/org/postgresql/Statement.java
+++ /dev/null
@@ -1,331 +0,0 @@
-package org.postgresql;
-
-import java.sql.*;
-import org.postgresql.util.PSQLException;
-
-/*
- * This class defines methods implemented by the two subclasses
- * org.postgresql.jdbc1.Statement and org.postgresql.jdbc2.Statement that are
- * unique to PostgreSQL's JDBC driver.
- *
- */
-
-public abstract class Statement
-{
-
- /** The warnings chain. */
- protected SQLWarning warnings = null;
-
- /** The current results */
- protected java.sql.ResultSet result = null;
-
- /** Maximum number of rows to return, 0 = unlimited */
- protected int maxrows = 0;
-
- /** Timeout (in seconds) for a query (not used) */
- protected int timeout = 0;
-
- protected boolean escapeProcessing = true;
-
- // Static variables for parsing SQL when escapeProcessing is true.
- private static final short IN_SQLCODE = 0;
- private static final short IN_STRING = 1;
- private static final short BACKSLASH = 2;
- private static final short ESC_TIMEDATE = 3;
-
- public Statement()
- {}
-
- /*
- * Returns the status message from the current Result.<p>
- * This is used internally by the driver.
- *
- * @return status message from backend
- */
- public String getResultStatusString()
- {
- if (result == null)
- return null;
- return ((org.postgresql.ResultSet) result).getStatusString();
- }
-
- /*
- * The maxRows limit is set to limit the number of rows that
- * any ResultSet can contain. If the limit is exceeded, the
- * excess rows are silently dropped.
- *
- * @return the current maximum row limit; zero means unlimited
- * @exception SQLException if a database access error occurs
- */
- public int getMaxRows() throws SQLException
- {
- return maxrows;
- }
-
- /*
- * Set the maximum number of rows
- *
- * @param max the new max rows limit; zero means unlimited
- * @exception SQLException if a database access error occurs
- * @see getMaxRows
- */
- public void setMaxRows(int max) throws SQLException
- {
- maxrows = max;
- }
-
- /*
- * If escape scanning is on (the default), the driver will do escape
- * substitution before sending the SQL to the database.
- *
- * @param enable true to enable; false to disable
- * @exception SQLException if a database access error occurs
- */
- public void setEscapeProcessing(boolean enable) throws SQLException
- {
- escapeProcessing = enable;
- }
-
- /*
- * The queryTimeout limit is the number of seconds the driver
- * will wait for a Statement to execute. If the limit is
- * exceeded, a SQLException is thrown.
- *
- * @return the current query timeout limit in seconds; 0 = unlimited
- * @exception SQLException if a database access error occurs
- */
- public int getQueryTimeout() throws SQLException
- {
- return timeout;
- }
-
- /*
- * Sets the queryTimeout limit
- *
- * @param seconds - the new query timeout limit in seconds
- * @exception SQLException if a database access error occurs
- */
- public void setQueryTimeout(int seconds) throws SQLException
- {
- timeout = seconds;
- }
-
- /**
- * This adds a warning to the warning chain.
- * @param msg message to add
- */
- public void addWarning(String msg)
- {
- if (warnings != null)
- warnings.setNextWarning(new SQLWarning(msg));
- else
- warnings = new SQLWarning(msg);
- }
-
- /*
- * The first warning reported by calls on this Statement is
- * returned. A Statement's execute methods clear its SQLWarning
- * chain. Subsequent Statement warnings will be chained to this
- * SQLWarning.
- *
- * <p>The Warning chain is automatically cleared each time a statement
- * is (re)executed.
- *
- * <p><B>Note:</B> If you are processing a ResultSet then any warnings
- * associated with ResultSet reads will be chained on the ResultSet
- * object.
- *
- * @return the first SQLWarning on null
- * @exception SQLException if a database access error occurs
- */
- public SQLWarning getWarnings() throws SQLException
- {
- return warnings;
- }
-
- /*
- * The maxFieldSize limit (in bytes) is the maximum amount of
- * data returned for any column value; it only applies to
- * BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR and LONGVARCHAR
- * columns. If the limit is exceeded, the excess data is silently
- * discarded.
- *
- * @return the current max column size limit; zero means unlimited
- * @exception SQLException if a database access error occurs
- */
- public int getMaxFieldSize() throws SQLException
- {
- return 8192; // We cannot change this
- }
-
- /*
- * Sets the maxFieldSize - NOT! - We throw an SQLException just
- * to inform them to stop doing this.
- *
- * @param max the new max column size limit; zero means unlimited
- * @exception SQLException if a database access error occurs
- */
- public void setMaxFieldSize(int max) throws SQLException
- {
- throw new PSQLException("postgresql.stat.maxfieldsize");
- }
-
- /*
- * After this call, getWarnings returns null until a new warning
- * is reported for this Statement.
- *
- * @exception SQLException if a database access error occurs
- */
- public void clearWarnings() throws SQLException
- {
- warnings = null;
- }
-
- /*
- * Cancel can be used by one thread to cancel a statement that
- * is being executed by another thread.
- * <p>
- * Not implemented, this method is a no-op.
- *
- * @exception SQLException only because thats the spec.
- */
- public void cancel() throws SQLException
- {
- throw new PSQLException("postgresql.unimplemented");
- }
-
- /*
- * Returns the Last inserted/updated oid. Deprecated in 7.2 because
- * range of OID values is greater than a java signed int.
- * @deprecated Replaced by getLastOID in 7.2
- */
- public int getInsertedOID() throws SQLException
- {
- if (result == null)
- return 0;
- return (int)((org.postgresql.ResultSet) result).getLastOID();
- }
-
- /*
- * Returns the Last inserted/updated oid.
- * @return OID of last insert
- * @since 7.2
- */
- public long getLastOID() throws SQLException
- {
- if (result == null)
- return 0;
- return ((org.postgresql.ResultSet) result).getLastOID();
- }
-
- /*
- * getResultSet returns the current result as a ResultSet. It
- * should only be called once per result.
- *
- * @return the current result set; null if there are no more
- * @exception SQLException if a database access error occurs (why?)
- */
- public java.sql.ResultSet getResultSet() throws SQLException
- {
- if (result != null && ((org.postgresql.ResultSet) result).reallyResultSet())
- return result;
- return null;
- }
-
- /*
- * In many cases, it is desirable to immediately release a
- * Statement's database and JDBC resources instead of waiting
- * for this to happen when it is automatically closed. The
- * close method provides this immediate release.
- *
- * <p><B>Note:</B> A Statement is automatically closed when it is
- * garbage collected. When a Statement is closed, its current
- * ResultSet, if one exists, is also closed.
- *
- * @exception SQLException if a database access error occurs (why?)
- */
- public void close() throws SQLException
- {
- // Force the ResultSet to close
- java.sql.ResultSet rs = getResultSet();
- if (rs != null)
- rs.close();
-
- // Disasociate it from us (For Garbage Collection)
- result = null;
- }
-
- /*
- * Filter the SQL string of Java SQL Escape clauses.
- *
- * Currently implemented Escape clauses are those mentioned in 11.3
- * in the specification. Basically we look through the sql string for
- * {d xxx}, {t xxx} or {ts xxx} in non-string sql code. When we find
- * them, we just strip the escape part leaving only the xxx part.
- * So, something like "select * from x where d={d '2001-10-09'}" would
- * return "select * from x where d= '2001-10-09'".
- */
- protected static String escapeSQL(String sql)
- {
- // Since escape codes can only appear in SQL CODE, we keep track
- // of if we enter a string or not.
- StringBuffer newsql = new StringBuffer();
- short state = IN_SQLCODE;
-
- int i = -1;
- int len = sql.length();
- while (++i < len)
- {
- char c = sql.charAt(i);
- switch (state)
- {
- case IN_SQLCODE:
- if (c == '\'') // start of a string?
- state = IN_STRING;
- else if (c == '{') // start of an escape code?
- if (i + 1 < len)
- {
- char next = sql.charAt(i + 1);
- if (next == 'd')
- {
- state = ESC_TIMEDATE;
- i++;
- break;
- }
- else if (next == 't')
- {
- state = ESC_TIMEDATE;
- i += (i + 2 < len && sql.charAt(i + 2) == 's') ? 2 : 1;
- break;
- }
- }
- newsql.append(c);
- break;
-
- case IN_STRING:
- if (c == '\'') // end of string?
- state = IN_SQLCODE;
- else if (c == '\\') // a backslash?
- state = BACKSLASH;
-
- newsql.append(c);
- break;
-
- case BACKSLASH:
- state = IN_STRING;
-
- newsql.append(c);
- break;
-
- case ESC_TIMEDATE:
- if (c == '}')
- state = IN_SQLCODE; // end of escape code.
- else
- newsql.append(c);
- break;
- } // end switch
- }
-
- return newsql.toString();
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java b/src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java
deleted file mode 100644
index e879a5ed763..00000000000
--- a/src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.postgresql.core;
-
-/*
- * A simple and efficient class to pool one dimensional byte arrays
- * of different sizes.
- */
-public class BytePoolDim1
-{
- /*
- * The maximum size of the array we manage.
- */
- int maxsize = 256;
- /*
- * The pools not currently in use
- */
- ObjectPool notusemap[] = new ObjectPool[maxsize + 1];
- /*
- * The pools currently in use
- */
- ObjectPool inusemap[] = new ObjectPool[maxsize + 1];
- /*
- *
- */
- byte binit[][] = new byte[maxsize + 1][0];
-
- /*
- * Construct a new pool
- */
- public BytePoolDim1()
- {
- for (int i = 0; i <= maxsize; i++)
- {
- binit[i] = new byte[i];
- inusemap[i] = new SimpleObjectPool();
- notusemap[i] = new SimpleObjectPool();
- }
- }
-
- /*
- * Allocate a byte[] of a specified size and put it in the pool. If it's
- * larger than maxsize then it is not pooled.
- * @return the byte[] allocated
- */
- public byte[] allocByte(int size)
- {
- // for now until the bug can be removed
- return new byte[size];
- /*
- // Don't pool if >maxsize
- if (size > maxsize){
- return new byte[size];
- }
-
- ObjectPool not_usel = notusemap[size];
- ObjectPool in_usel = inusemap[size];
- byte b[] = null;
-
- // Fetch from the unused pool if available otherwise allocate a new
- // now array
- if (!not_usel.isEmpty()) {
- Object o = not_usel.remove();
- b = (byte[]) o;
- } else
- b = new byte[size];
- in_usel.add(b);
-
- return b;
- */
- }
-
- /*
- * Release an array
- * @param b byte[] to release
- */
- public void release(byte[] b)
- {
- // If it's larger than maxsize then we don't touch it
- if (b.length > maxsize)
- return;
-
- ObjectPool not_usel = notusemap[b.length];
- ObjectPool in_usel = inusemap[b.length];
-
- in_usel.remove(b);
- not_usel.add(b);
- }
-
- /*
- * Deallocate all
- * @deprecated Real bad things happen if this is called!
- */
- public void deallocate()
- {
- //for(int i = 0; i <= maxsize; i++){
- // notusemap[i].addAll(inusemap[i]);
- // inusemap[i].clear();
- //}
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java b/src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java
deleted file mode 100644
index 963320070de..00000000000
--- a/src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.postgresql.core;
-
-public class BytePoolDim2
-{
- int maxsize = 32;
- ObjectPool notusemap[] = new ObjectPool[maxsize + 1];
- ObjectPool inusemap[] = new ObjectPool[maxsize + 1];
-
- public BytePoolDim2()
- {
- for (int i = 0; i <= maxsize; i++)
- {
- inusemap[i] = new SimpleObjectPool();
- notusemap[i] = new SimpleObjectPool();
- }
- }
-
- public byte[][] allocByte(int size)
- {
- // For now until the bug can be removed
- return new byte[size][0];
- /*
- if (size > maxsize){
- return new byte[size][0];
- }
- ObjectPool not_usel = notusemap[size];
- ObjectPool in_usel = inusemap[size];
-
- byte b[][] = null;
-
- if (!not_usel.isEmpty()) {
- Object o = not_usel.remove();
- b = (byte[][]) o;
- } else
- b = new byte[size][0];
- in_usel.add(b);
- return b;
- */
- }
-
- public void release(byte[][] b)
- {
- if (b.length > maxsize)
- {
- return;
- }
- ObjectPool not_usel = notusemap[b.length];
- ObjectPool in_usel = inusemap[b.length];
-
- in_usel.remove(b);
- not_usel.add(b);
- }
-
- /*
- * Deallocate the object cache.
- * PM 17/01/01: Commented out this code as it blows away any hope of
- * multiple queries on the same connection. I'll redesign the allocation
- * code to use some form of Statement context, so the buffers are per
- * Statement and not per Connection/PG_Stream as it is now.
- */
- public void deallocate()
- {
- //for(int i = 0; i <= maxsize; i++){
- // notusemap[i].addAll(inusemap[i]);
- // inusemap[i].clear();
- //}
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/core/Encoding.java b/src/interfaces/jdbc/org/postgresql/core/Encoding.java
deleted file mode 100644
index 2c4b0d34806..00000000000
--- a/src/interfaces/jdbc/org/postgresql/core/Encoding.java
+++ /dev/null
@@ -1,226 +0,0 @@
-package org.postgresql.core;
-
-import java.io.*;
-import java.util.*;
-import java.sql.SQLException;
-import org.postgresql.util.*;
-
-/*
- * Converts to and from the character encoding used by the backend.
- *
- * $Id: Encoding.java,v 1.5 2002/03/19 02:48:45 momjian Exp $
- */
-
-public class Encoding
-{
-
- private static final Encoding DEFAULT_ENCODING = new Encoding(null);
-
- /*
- * Preferred JVM encodings for backend encodings.
- */
- private static final Hashtable encodings = new Hashtable();
-
- static {
- //Note: this list should match the set of supported server
- // encodings found in backend/util/mb/encnames.c
- encodings.put("SQL_ASCII", new String[] { "ASCII", "us-ascii" });
- encodings.put("UNICODE", new String[] { "UTF-8", "UTF8" });
- encodings.put("LATIN1", new String[] { "ISO8859_1" });
- encodings.put("LATIN2", new String[] { "ISO8859_2" });
- encodings.put("LATIN3", new String[] { "ISO8859_3" });
- encodings.put("LATIN4", new String[] { "ISO8859_4" });
- encodings.put("ISO_8859_5", new String[] { "ISO8859_5" });
- encodings.put("ISO_8859_6", new String[] { "ISO8859_6" });
- encodings.put("ISO_8859_7", new String[] { "ISO8859_7" });
- encodings.put("ISO_8859_8", new String[] { "ISO8859_8" });
- encodings.put("LATIN5", new String[] { "ISO8859_9" });
- encodings.put("LATIN7", new String[] { "ISO8859_13" });
- encodings.put("LATIN9", new String[] { "ISO8859_15_FDIS" });
- encodings.put("EUC_JP", new String[] { "EUC_JP" });
- encodings.put("EUC_CN", new String[] { "EUC_CN" });
- encodings.put("EUC_KR", new String[] { "EUC_KR" });
- encodings.put("JOHAB", new String[] { "Johab" });
- encodings.put("EUC_TW", new String[] { "EUC_TW" });
- encodings.put("SJIS", new String[] { "MS932","SJIS" });
- encodings.put("BIG5", new String[] { "Big5","MS950","Cp950" });
- encodings.put("GBK", new String[] { "GBK","MS936" });
- encodings.put("UHC", new String[] { "MS949","Cp949","Cp949C" });
- encodings.put("TCVN", new String[] { "Cp1258" });
- encodings.put("WIN1256", new String[] { "Cp1256" });
- encodings.put("WIN1250", new String[] { "Cp1250" });
- encodings.put("WIN874", new String[] { "MS874","Cp874" });
- encodings.put("WIN", new String[] { "Cp1251" });
- encodings.put("ALT", new String[] { "Cp866" });
- // We prefer KOI8-U, since it is a superset of KOI8-R.
- encodings.put("KOI8", new String[] { "KOI8_U", "KOI8_R" });
- // If the database isn't encoding-aware then we can't have
- // any preferred encodings.
- encodings.put("UNKNOWN", new String[0]);
- // The following encodings do not have a java equivalent
- encodings.put("MULE_INTERNAL", new String[0]);
- encodings.put("LATIN6", new String[0]);
- encodings.put("LATIN8", new String[0]);
- encodings.put("LATIN10", new String[0]);
- }
-
- private final String encoding;
-
- private Encoding(String encoding)
- {
- this.encoding = encoding;
- }
-
- /*
- * Get an Encoding for from the given database encoding and
- * the encoding passed in by the user.
- */
- public static Encoding getEncoding(String databaseEncoding,
- String passedEncoding)
- {
- if (passedEncoding != null)
- {
- if (isAvailable(passedEncoding))
- {
- return new Encoding(passedEncoding);
- }
- else
- {
- return defaultEncoding();
- }
- }
- else
- {
- return encodingForDatabaseEncoding(databaseEncoding);
- }
- }
-
- /*
- * Get an Encoding matching the given database encoding.
- */
- private static Encoding encodingForDatabaseEncoding(String databaseEncoding)
- {
- // If the backend encoding is known and there is a suitable
- // encoding in the JVM we use that. Otherwise we fall back
- // to the default encoding of the JVM.
-
- if (encodings.containsKey(databaseEncoding))
- {
- String[] candidates = (String[]) encodings.get(databaseEncoding);
- for (int i = 0; i < candidates.length; i++)
- {
- if (isAvailable(candidates[i]))
- {
- return new Encoding(candidates[i]);
- }
- }
- }
- return defaultEncoding();
- }
-
- /*
- * Name of the (JVM) encoding used.
- */
- public String name()
- {
- return encoding;
- }
-
- /*
- * Encode a string to an array of bytes.
- */
- public byte[] encode(String s) throws SQLException
- {
- try
- {
- if (encoding == null)
- {
- return s.getBytes();
- }
- else
- {
- return s.getBytes(encoding);
- }
- }
- catch (UnsupportedEncodingException e)
- {
- throw new PSQLException("postgresql.stream.encoding", e);
- }
- }
-
- /*
- * Decode an array of bytes into a string.
- */
- public String decode(byte[] encodedString, int offset, int length) throws SQLException
- {
- try
- {
- if (encoding == null)
- {
- return new String(encodedString, offset, length);
- }
- else
- {
- return new String(encodedString, offset, length, encoding);
- }
- }
- catch (UnsupportedEncodingException e)
- {
- throw new PSQLException("postgresql.stream.encoding", e);
- }
- }
-
- /*
- * Decode an array of bytes into a string.
- */
- public String decode(byte[] encodedString) throws SQLException
- {
- return decode(encodedString, 0, encodedString.length);
- }
-
- /*
- * Get a Reader that decodes the given InputStream.
- */
- public Reader getDecodingReader(InputStream in) throws SQLException
- {
- try
- {
- if (encoding == null)
- {
- return new InputStreamReader(in);
- }
- else
- {
- return new InputStreamReader(in, encoding);
- }
- }
- catch (UnsupportedEncodingException e)
- {
- throw new PSQLException("postgresql.res.encoding", e);
- }
- }
-
- /*
- * Get an Encoding using the default encoding for the JVM.
- */
- public static Encoding defaultEncoding()
- {
- return DEFAULT_ENCODING;
- }
-
- /*
- * Test if an encoding is available in the JVM.
- */
- private static boolean isAvailable(String encodingName)
- {
- try
- {
- "DUMMY".getBytes(encodingName);
- return true;
- }
- catch (UnsupportedEncodingException e)
- {
- return false;
- }
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/core/MemoryPool.java b/src/interfaces/jdbc/org/postgresql/core/MemoryPool.java
deleted file mode 100644
index 3f0c2cb51de..00000000000
--- a/src/interfaces/jdbc/org/postgresql/core/MemoryPool.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.postgresql.core;
-
-/*
- * This interface defines the methods to access the memory pool classes.
- */
-public interface MemoryPool
-{
- /*
- * Allocate an array from the pool
- * @return byte[] allocated
- */
- public byte[] allocByte(int size);
-
- /*
- * Frees an object back to the pool
- * @param o Object to release
- */
- public void release(Object o);
-}
diff --git a/src/interfaces/jdbc/org/postgresql/core/ObjectPool.java b/src/interfaces/jdbc/org/postgresql/core/ObjectPool.java
deleted file mode 100644
index 341bba20247..00000000000
--- a/src/interfaces/jdbc/org/postgresql/core/ObjectPool.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.postgresql.core;
-
-/*
- * This interface defines methods needed to implement a simple object pool.
- * There are two known classes that implement this, one for jdk1.1 and the
- * other for jdk1.2+
- */
-
-public interface ObjectPool
-{
- /*
- * Adds an object to the pool
- * @param o Object to add
- */
- public void add(Object o);
-
- /*
- * Removes an object from the pool
- * @param o Object to remove
- */
- public void remove(Object o);
-
- /*
- * Removes the top object from the pool
- * @return Object from the top.
- */
- public Object remove();
-
- /*
- * @return true if the pool is empty
- */
- public boolean isEmpty();
-
- /*
- * @return the number of objects in the pool
- */
- public int size();
-
- /*
- * Adds all objects in one pool to this one
- * @param pool The pool to take the objects from
- */
- public void addAll(ObjectPool pool);
-
- /*
- * Clears the pool of all objects
- */
- public void clear();
-}
diff --git a/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java b/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
deleted file mode 100644
index bfa6af35723..00000000000
--- a/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
+++ /dev/null
@@ -1,211 +0,0 @@
-
-package org.postgresql.core;
-
-import java.util.Vector;
-import java.io.IOException;
-import java.sql.*;
-import org.postgresql.*;
-import org.postgresql.util.PSQLException;
-
-/*
- * Executes a query on the backend.
- *
- * <p>The lifetime of a QueryExecutor object is from sending the query
- * until the response has been received from the backend.
- *
- * $Id: QueryExecutor.java,v 1.12 2002/03/26 05:52:49 barry Exp $
- */
-
-public class QueryExecutor
-{
-
- private final String sql;
- private final java.sql.Statement statement;
- private final PG_Stream pg_stream;
- private final org.postgresql.Connection connection;
-
- public QueryExecutor(String sql,
- java.sql.Statement statement,
- PG_Stream pg_stream,
- org.postgresql.Connection connection)
- throws SQLException
- {
- this.sql = sql;
- this.statement = statement;
- this.pg_stream = pg_stream;
- this.connection = connection;
-
- if (statement != null)
- maxRows = statement.getMaxRows();
- else
- maxRows = 0;
- }
-
- private Field[] fields = null;
- private Vector tuples = new Vector();
- private boolean binaryCursor = false;
- private String status = null;
- private int update_count = 1;
- private long insert_oid = 0;
- private int maxRows;
-
- /*
- * Execute a query on the backend.
- */
- public java.sql.ResultSet execute() throws SQLException
- {
-
- StringBuffer errorMessage = null;
-
- synchronized (pg_stream)
- {
-
- sendQuery(sql);
-
- int c;
- boolean l_endQuery = false;
- while (!l_endQuery)
- {
- c = pg_stream.ReceiveChar();
-
- switch (c)
- {
- case 'A': // Asynchronous Notify
- int pid = pg_stream.ReceiveInteger(4);
- String msg = pg_stream.ReceiveString(connection.getEncoding());
- break;
- case 'B': // Binary Data Transfer
- receiveTuple(true);
- break;
- case 'C': // Command Status
- receiveCommandStatus();
- break;
- case 'D': // Text Data Transfer
- receiveTuple(false);
- break;
- case 'E': // Error Message
-
- // it's possible to get more than one error message for a query
- // see libpq comments wrt backend closing a connection
- // so, append messages to a string buffer and keep processing
- // check at the bottom to see if we need to throw an exception
-
- if ( errorMessage == null )
- errorMessage = new StringBuffer();
-
- errorMessage.append(pg_stream.ReceiveString(connection.getEncoding()));
- // keep processing
- break;
- case 'I': // Empty Query
- int t = pg_stream.ReceiveChar();
- break;
- case 'N': // Error Notification
- connection.addWarning(pg_stream.ReceiveString(connection.getEncoding()));
- break;
- case 'P': // Portal Name
- String pname = pg_stream.ReceiveString(connection.getEncoding());
- break;
- case 'T': // MetaData Field Description
- receiveFields();
- break;
- case 'Z':
- l_endQuery = true;
- break;
- default:
- throw new PSQLException("postgresql.con.type",
- new Character((char) c));
- }
-
- }
-
- // did we get an error during this query?
- if ( errorMessage != null )
- throw new SQLException( errorMessage.toString() );
-
- return connection.getResultSet(connection, statement, fields, tuples, status, update_count, insert_oid, binaryCursor);
- }
- }
-
- /*
- * Send a query to the backend.
- */
- private void sendQuery(String query) throws SQLException
- {
- try
- {
- pg_stream.SendChar('Q');
- pg_stream.Send(connection.getEncoding().encode(query));
- pg_stream.SendChar(0);
- pg_stream.flush();
-
- }
- catch (IOException e)
- {
- throw new PSQLException("postgresql.con.ioerror", e);
- }
- }
-
- /*
- * Receive a tuple from the backend.
- *
- * @param isBinary set if the tuple should be treated as binary data
- */
- private void receiveTuple(boolean isBinary) throws SQLException
- {
- if (fields == null)
- throw new PSQLException("postgresql.con.tuple");
- Object tuple = pg_stream.ReceiveTuple(fields.length, isBinary);
- if (isBinary)
- binaryCursor = true;
- if (maxRows == 0 || tuples.size() < maxRows)
- tuples.addElement(tuple);
- }
-
- /*
- * Receive command status from the backend.
- */
- private void receiveCommandStatus() throws SQLException
- {
-
- status = pg_stream.ReceiveString(connection.getEncoding());
-
- try
- {
- // Now handle the update count correctly.
- if (status.startsWith("INSERT") || status.startsWith("UPDATE") || status.startsWith("DELETE") || status.startsWith("MOVE"))
- {
- update_count = Integer.parseInt(status.substring(1 + status.lastIndexOf(' ')));
- }
- if (status.startsWith("INSERT"))
- {
- insert_oid = Long.parseLong(status.substring(1 + status.indexOf(' '),
- status.lastIndexOf(' ')));
- }
- }
- catch (NumberFormatException nfe)
- {
- throw new PSQLException("postgresql.con.fathom", status);
- }
- }
-
- /*
- * Receive the field descriptions from the back end.
- */
- private void receiveFields() throws SQLException
- {
- if (fields != null)
- throw new PSQLException("postgresql.con.multres");
-
- int size = pg_stream.ReceiveIntegerR(2);
- fields = new Field[size];
-
- for (int i = 0; i < fields.length; i++)
- {
- String typeName = pg_stream.ReceiveString(connection.getEncoding());
- int typeOid = pg_stream.ReceiveIntegerR(4);
- int typeLength = pg_stream.ReceiveIntegerR(2);
- int typeModifier = pg_stream.ReceiveIntegerR(4);
- fields[i] = new Field(connection, typeName, typeOid, typeLength, typeModifier);
- }
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/core/SimpleObjectPool.java b/src/interfaces/jdbc/org/postgresql/core/SimpleObjectPool.java
deleted file mode 100644
index d64126456d9..00000000000
--- a/src/interfaces/jdbc/org/postgresql/core/SimpleObjectPool.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.postgresql.core;
-
-/*
- * A simple and fast object pool implementation that can pool objects
- * of any type. This implementation is not thread safe, it is up to the users
- * of this class to assure thread safety.
- */
-
-public class SimpleObjectPool implements ObjectPool
-{
- // This was originally in PG_Stream but moved out to fix the major problem
- // where more than one query (usually all the time) overwrote the results
- // of another query.
- int cursize = 0;
- int maxsize = 16;
- Object arr[] = new Object[maxsize];
-
- /*
- * Adds an object to the pool
- * @param o Object to add
- */
- public void add(Object o)
- {
- if (cursize >= maxsize)
- {
- Object newarr[] = new Object[maxsize * 2];
- System.arraycopy(arr, 0, newarr, 0, maxsize);
- maxsize = maxsize * 2;
- arr = newarr;
- }
- arr[cursize++] = o;
- }
-
- /*
- * Removes the top object from the pool
- * @return Object from the top.
- */
- public Object remove()
- {
- return arr[--cursize];
- }
-
- /*
- * Removes the given object from the pool
- * @param o Object to remove
- */
- public void remove(Object o)
- {
- int p = 0;
- while (p < cursize && !arr[p].equals(o))
- p++;
- if (arr[p].equals(o))
- {
- // This should be ok as there should be no overlap conflict
- System.arraycopy(arr, p + 1, arr, p, cursize - p);
- cursize--;
- }
- }
-
- /*
- * @return true if the pool is empty
- */
- public boolean isEmpty()
- {
- return cursize == 0;
- }
-
- /*
- * @return the number of objects in the pool
- */
- public int size()
- {
- return cursize;
- }
-
- /*
- * Adds all objects in one pool to this one
- * @param pool The pool to take the objects from
- */
- public void addAll(ObjectPool p)
- {
- SimpleObjectPool pool = (SimpleObjectPool)p;
-
- int srcsize = pool.size();
- if (srcsize == 0)
- return;
- int totalsize = srcsize + cursize;
- if (totalsize > maxsize)
- {
- Object newarr[] = new Object[totalsize * 2];
- System.arraycopy(arr, 0, newarr, 0, cursize);
- maxsize = maxsize = totalsize * 2;
- arr = newarr;
- }
- System.arraycopy(pool.arr, 0, arr, cursize, srcsize);
- cursize = totalsize;
- }
-
- /*
- * Clears the pool of all objects
- */
- public void clear()
- {
- cursize = 0;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/core/StartupPacket.java b/src/interfaces/jdbc/org/postgresql/core/StartupPacket.java
deleted file mode 100644
index 223f16ebd47..00000000000
--- a/src/interfaces/jdbc/org/postgresql/core/StartupPacket.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.postgresql.core;
-
-import org.postgresql.PG_Stream;
-import java.io.IOException;
-
-/**
- * Sent to the backend to initialize a newly created connection.
- *
- * $Id: StartupPacket.java,v 1.1 2002/03/21 02:40:03 davec Exp $
- */
-
-public class StartupPacket
-{
- private static final int SM_DATABASE = 64;
- private static final int SM_USER = 32;
- private static final int SM_OPTIONS = 64;
- private static final int SM_UNUSED = 64;
- private static final int SM_TTY = 64;
-
- private int protocolMajor;
- private int protocolMinor;
- private String user;
- private String database;
-
- public StartupPacket(int protocolMajor, int protocolMinor, String user, String database) {
- this.protocolMajor = protocolMajor;
- this.protocolMinor = protocolMinor;
- this.user = user;
- this.database = database;
- }
-
- public void writeTo(PG_Stream stream) throws IOException
- {
- stream.SendInteger(4 + 4 + SM_DATABASE + SM_USER + SM_OPTIONS + SM_UNUSED + SM_TTY, 4);
- stream.SendInteger(protocolMajor, 2);
- stream.SendInteger(protocolMinor, 2);
- stream.Send(database.getBytes(), SM_DATABASE);
-
- // This last send includes the unused fields
- stream.Send(user.getBytes(), SM_USER + SM_OPTIONS + SM_UNUSED + SM_TTY);
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/errors.properties b/src/interfaces/jdbc/org/postgresql/errors.properties
deleted file mode 100644
index c2e529ee999..00000000000
--- a/src/interfaces/jdbc/org/postgresql/errors.properties
+++ /dev/null
@@ -1,85 +0,0 @@
-# This is the default errors
-postgresql.arr.range:The array index is out of range.
-postgresql.drv.version:An internal error has occured. Please recompile the driver.
-postgresql.con.auth:The authentication type {0} is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or Subnet, and that it is using an authentication scheme supported by the driver.
-postgresql.con.authfail:An error occured while getting the authentication request.
-postgresql.con.backend:Backend start-up failed: {0}
-postgresql.con.call:Callable Statements are not supported at this time.
-postgresql.con.creobj:Failed to create object for {0} {1}
-postgresql.con.failed:The connection attempt failed because {0}
-postgresql.con.fathom:Unable to fathom update count {0}
-postgresql.con.garbled:Garbled data received.
-postgresql.con.ioerror:An IO erro occured while sending to the backend - {0}
-postgresql.con.kerb4:Kerberos 4 authentication is not supported by this driver.
-postgresql.con.kerb5:Kerberos 5 authentication is not supported by this driver.
-postgresql.con.misc:A connection error has occurred: {0}
-postgresql.con.multres:Cannot handle multiple result groups.
-postgresql.con.pass:The password property is missing. It is mandatory.
-postgresql.con.refused:Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
-postgresql.con.setup:Protocol error. Session setup failed.
-postgresql.con.strobj:The object could not be stored. Check that any tables required have already been created in the database.
-postgresql.con.strobjex:Failed to store object - {0}
-postgresql.con.toolong:The SQL Statement is too long - {0}
-postgresql.con.isolevel:Transaction isolation level {0} is not supported.
-postgresql.con.tuple:Tuple received before MetaData.
-postgresql.con.type:Unknown Response Type {0}
-postgresql.con.user:The user property is missing. It is mandatory.
-postgresql.fp.error:FastPath call returned {0}
-postgresql.fp.expint:Fastpath call {0} - No result was returned and we expected an integer.
-postgresql.fp.protocol:FastPath protocol error: {0}
-postgresql.fp.send:Failed to send fastpath call {0} {1}
-postgresql.fp.unknown:The fastpath function {0} is unknown.
-postgresql.geo.box:Conversion of box failed - {0}
-postgresql.geo.circle:Conversion of circle failed - {0}
-postgresql.geo.line:Conversion of line failed - {0}
-postgresql.geo.lseg:Conversion of lseg failed - {0}
-postgresql.geo.path:Cannot tell if path is open or closed.
-postgresql.geo.point:Conversion of point failed - {0}
-postgresql.jvm.version:The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding. If that fails, try forcing the version supplying it to the command line using the argument -Djava.version=1.1 or -Djava.version=1.2\nException thrown was {0}
-postgresql.lo.init:failed to initialise LargeObject API
-postgresql.metadata.unavailable:Metadata unavailable.
-postgresql.money:conversion of money failed - {0}
-postgresql.noupdate:This ResultSet is not updateable.
-postgresql.notsensitive:This ResultSet is not sensitive to realtime updates after the query has run.
-postgresql.psqlnotimp:The backend currently does not support this feature.
-postgresql.prep.is:InputStream as parameter not supported
-postgresql.prep.param:No value specified for parameter {0}
-postgresql.prep.range:Parameter index out of range.
-postgresql.prep.type:Unknown Types value.
-postgresql.res.badbigdec:Bad BigDecimal {0}
-postgresql.res.badbyte:Bad Byte {0}
-postgresql.res.baddate:Bad Date Format at {0} in {1}
-postgresql.res.baddouble:Bad Double {0}
-postgresql.res.badfloat:Bad Float {0}
-postgresql.res.badint:Bad Integer {0}
-postgresql.res.badlong:Bad Long {0}
-postgresql.res.badshort:Bad Short {0}
-postgresql.res.badtime:Bad Time {0}
-postgresql.res.badtimestamp:Bad Timestamp Format at {0} in {1}
-postgresql.res.closed:Result set is closed. Operation is not permitted.
-postgresql.res.colname:The column name {0} not found.
-postgresql.res.colrange:The column index is out of range.
-postgresql.res.nextrequired:Result set not positioned properly, perhaps you need to call next().
-postgresql.serial.interface:You cannot serialize an interface.
-postgresql.serial.namelength:Class & Package name length cannot be longer than 32 characters. {0} is {1} characters.
-postgresql.serial.noclass:No class found for {0}
-postgresql.serial.table:The table for {0} is not in the database. Contact the DBA, as the database is in an inconsistent state.
-postgresql.serial.underscore:Class names may not have _ in them. You supplied {0}.
-postgresql.stat.batch.error:Batch entry {0} {1} was aborted.
-postgresql.stat.maxfieldsize:An attempt to setMaxFieldSize() failed - compile time default in force.
-postgresql.stat.noresult:No results were returned by the query.
-postgresql.stream.eof:The backend has broken the connection. Possibly the action you have attempted has caused it to close.
-postgresql.stream.flush:An I/O error has occured while flushing the output - {0}
-postgresql.stream.ioerror:An I/O error occured while reading from backend - {0}
-postgresql.stream.toomuch:Too much data was received.
-postgresql.unusual:Something unusual has occured to cause the driver to fail. Please report this exception: {0}
-postgresql.unimplemented:This method is not yet implemented.
-postgresql.unexpected:An unexpected result was returned by a query.
-postgresql.updateable.notupdateable: Result Set not updateable. The query that generated this result set must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.
-postgresql.updateable.oninsertrow:Can not call deleteRow() when on insert row
-postgresql.updateable.emptydelete:Can't deleteRow() on empty result set
-postgresql.updateable.beforestartdelete:Before start of result set. Can not call deleteRow().
-postgresql.updateable.afterlastdelete:After end of result set. Can not call deleteRow().
-postgresql.updateable.notoninsertrow:Not on insert row.
-postgresql.updateable.inputstream:Input Stream is null.
-postgresql.updateable.ioerror:Input Stream Error.
diff --git a/src/interfaces/jdbc/org/postgresql/errors_de.properties b/src/interfaces/jdbc/org/postgresql/errors_de.properties
deleted file mode 100644
index 0146bde928d..00000000000
--- a/src/interfaces/jdbc/org/postgresql/errors_de.properties
+++ /dev/null
@@ -1,78 +0,0 @@
-# Message translation file for PostgreSQL JDBC driver
-# Peter Eisentraut <peter_e@gmx.net>, 2001.
-#
-# $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/errors_de.properties,v 1.3 2002/04/02 06:24:09 barry Exp $
-
-postgresql.con.auth:Der Authentifizierungstyp »{0}« wird nicht unterstützt.
-postgresql.con.authfail:Ein Fehler trat auf während die Authentifizierungsanfrage empfangen wurde.
-postgresql.con.call:CallableStatement wird nicht unterstützt.
-postgresql.con.creobj:Konnte Objekt vom Typ {0} nicht erstellen: {1}
-postgresql.con.encoding:Nicht unterstützte Kodierung: {0}
-postgresql.con.failed:Der Verbindungsversuch schlug fehl: {0}
-postgresql.con.fathom:Kann Anzahl der veränderten Zeilen nicht ermitteln: {0}
-postgresql.con.garbled:Unverständliche Daten wurden empfangen.
-postgresql.con.ioerror:Eingabe/Ausgabe-Fehler: {0}
-postgresql.con.isolevel:Transaktionsisolation {0} wird nicht unterstützt.
-postgresql.con.kerb4:Kerberos-IV-Authentifizierung wird von diesem Treiber nicht unterstützt.
-postgresql.con.kerb5:Kerberos-V-Authentifizierung wird von diesem Treiber nicht unterstützt.
-postgresql.con.multres:Mehrere Ergebnisgruppen können nicht verarbeitet werden.
-postgresql.con.pass:Das Paßwort fehlt.
-postgresql.con.refused:Verbindung verweigert. Prüfen Sie, daß der Server TCP/IP-Verbindungen annimmt.
-postgresql.con.setup:Protokollfehler - Sitzung konnte nicht gestartet werden.
-postgresql.con.strobj:Konnte Objekt nicht speichern - {0}
-postgresql.con.strobjex:Das Objekt konnte nicht gespeichert werden. Prüfen Sie, daß die benötigten Tabellen bereits erstellt wurden.
-postgresql.con.tuple:Ergebnisdaten wurden empfangen, als sie nicht erwartet wurden.
-postgresql.con.type:Unbekannte Antwort vom Server: »{0}«
-postgresql.con.user:Benutzername wurde nicht angegeben.
-postgresql.ds.onlyjdbc2:Es werden nur JDBC2-Verbindungen unterstützt.
-postgresql.ds.userpswd:Kein Benutzername oder Paßwort angegeben.
-postgresql.fp.error:FastPath-Aufruf ergab »{0}«.
-postgresql.fp.expint:FastPath-Aufruf »{0}« gab kein Ergebnis zurück, aber ein Integer wurde erwartet.
-postgresql.fp.protocol:FastPath-Protokollfehler: {0}
-postgresql.fp.send:Konnte FastPath-Aufruf »{0}« nicht senden: {1}
-postgresql.fp.unknown:Die FastPath-Funktion »{0}« ist nicht bekannt.
-postgresql.geo.box:Konnte »{0}« nicht in Typ »box« umwandeln
-postgresql.geo.circle:Konnte »{0}« nicht in Typ »circle« umwandeln
-postgresql.geo.line:Konnte »{0}« nicht in Typ »line« umwandeln
-postgresql.geo.lseg:Konnte »{0}« nicht in Typ »lseg« umwandeln
-postgresql.geo.path:Konnte nicht in Typ »path« umwandeln - konnte nicht ermitteln ob der Pfad offen oder geschlossen ist
-postgresql.geo.point:Konnte »{0}« nicht in Typ »point« umwandeln
-postgresql.jvm.version:Die Datei postgresql.jar enthält nicht die benötigten Klassen für diese JVM-Version. Versuchen Sie, den Treiber neu zu übersetzen. Falls das nicht hilft, bestimmen Sie die Version mit den Kommandozeilenoptionen -Djava.version=1.1 oder -Djava.version=1.2. Der Fehler war »{0}«
-postgresql.lo.init:Konnte Large-Object-API nicht initialisieren.
-postgresql.money:Ungültiges Format für Typ »money«: {0}
-postgresql.notsensitive:Dieses ResultSet ermöglicht keine Auffrischungen nach der Abfrage.
-postgresql.noupdate:Dieses ResultSet kann nicht verändert werden.
-postgresql.prep.is:InputStream als Parameter wird nicht unterstützt.
-postgresql.prep.param:Keinen Wert für Parameter {0} angegeben
-postgresql.prep.range:Parameterindex außerhalb des gültigen Bereichs
-postgresql.prep.type:Unbekannter Zieltyp
-postgresql.psqlnotimp:Der Server unterstützt diese Funktion nicht.
-postgresql.res.badbigdec:Ungültiges Format für BigDecimal: {0}
-postgresql.res.badbyte:Ungültiges Format für Byte: {0}
-postgresql.res.baddate:Ungültiger Datumswert »{0}«
-postgresql.res.baddouble:Ungültiges Format für Double: {0}
-postgresql.res.badfloat:Ungültiges Format für Float: {0}
-postgresql.res.badint:Ungültiges Format für Integer: {0}
-postgresql.res.badlong:Ungültiges Format für Long: {0}
-postgresql.res.badshort:Ungültiges Format für Short: {0}
-postgresql.res.badtime:Ungültiger Zeitwert »{0}«
-postgresql.res.badtimestamp:Ungültiger Wert für Timestamp (Datum und Zeit), in »{1}« bei Position {1}
-postgresql.res.colname:Spaltenname »{0}« nicht gefunden
-postgresql.res.colrange:Spaltenindex außerhalb des gültigen Bereichs
-postgresql.res.encoding:Nicht unterstützte Kodierung: {0}
-postgresql.serial.interface:Ein Interface kann nicht serialisiert werden.
-postgresql.serial.namelength:Klassen- und Paketname können nicht länger als 32 Zeichen sein. »{0}« ist {1} Zeichen lang.
-postgresql.serial.noclass:Keine Klasse für Typ »{0}« gefunden
-postgresql.serial.table:Keine Tabelle für Typ »{0}« in der Datenbank gefunden. Die Datenbank ist in einem unbeständigen Zustand.
-postgresql.serial.underscore:Zu serialisierende Klassennamen dürfen keine Unterstriche (_) enthälten. Der angegebene Name war »{0}«.
-postgresql.stat.batch.error:Batch-Anweisung Nummer {0} ({1}) wurde abgebrochen.
-postgresql.stat.maxfieldsize:setMaxFieldSize() is nicht möglich; die Grenze ist fest eingebaut.
-postgresql.stat.noresult:Die Abfrage ergab kein Ergebnis.
-postgresql.stream.encoding:Nicht unterstützte Kodierung: {0}
-postgresql.stream.eof:Unerwarteter Verbindungsabbruch vom Server
-postgresql.stream.flush:Eingabe/Ausgabe-Fehler beim Flush zum Server: {0}
-postgresql.stream.ioerror:Eingabe/Ausgabe-Fehler beim Empfang vom Server: {0}
-postgresql.stream.toomuch:Zu viele Daten wurden empfangen.
-postgresql.unexpected:Ein unerwartetes Resultat wurde nach einer Abfrage zurückgesendet.
-postgresql.unimplemented:Diese Methode ist noch nicht implementiert.
-postgresql.unusual:Etwas ungewöhnliches ist passiert. Bitte Teilen Sie diesem Fehler mit: {0}
diff --git a/src/interfaces/jdbc/org/postgresql/errors_fr.properties b/src/interfaces/jdbc/org/postgresql/errors_fr.properties
deleted file mode 100644
index 79d40e29743..00000000000
--- a/src/interfaces/jdbc/org/postgresql/errors_fr.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# This is the french version of some errors. Errors not in this file
-# are handled by the parent errors.properties file.
-postgresql.jvm.version:Le fichier de postgresql.jar ne contient pas les classes correctes de JDBC pour ce JVM. Try que rebuilding.\nException jetées était {0}
-postgresql.metadata.unavailable: Les métadonnées ne sont pas disponibles.
-postgresql.unusual:Quelque chose de peu commun s'est produit pour faire échouer le gestionnaire. Veuillez enregistrer cette exception: {0}
-postgresql.unimplemented:Cette méthode n'est pas encore appliquée.
diff --git a/src/interfaces/jdbc/org/postgresql/errors_it.properties b/src/interfaces/jdbc/org/postgresql/errors_it.properties
deleted file mode 100644
index 76e6168110e..00000000000
--- a/src/interfaces/jdbc/org/postgresql/errors_it.properties
+++ /dev/null
@@ -1,76 +0,0 @@
-# This is the italian version of some errors. Errors not in this file
-# are handled by the parent errors.properties file.
-#
-# Daniele Arduini <darduini@cinetica.it <mailto:darduini@cinetica.it>>
-# Tue Aug 21 09:26:47 CEST 2001
-#
-postgresql.drv.version:Si è verificato un errore interno. Si consiglia di ricompilare il driver.
-postgresql.con.auth:L'autenticazione di tipo {0} non è supportata. Verificare che nel file di configurazione pg_hba.conf sia presente l'indirizzo IP o la sotto-rete del client, e che lo schema di autenticazione utilizzato sia supportato dal driver.
-postgresql.con.authfail:Si è verificato un errore durante la richiesta di autenticazione.
-postgresql.con.call:I ``Callable Statements'' non sono supportati al momento.
-postgresql.con.creobj:Fallita la creazione dell'oggetto per {0} {1}
-postgresql.con.failed:Il tentativo di connessione è fallito perché {0}
-postgresql.con.fathom:Impossibile il conteggio di ``update'' {0}
-postgresql.con.garbled:Ricevuti dati incomprensibili.
-postgresql.con.ioerror:Si è verificato un errore di I/O nella spedizione di dati al processo server - {0}
-postgresql.con.kerb4:L'autenticazione di tipo ``Kerberos 4'' non è supportata da questo driver.
-postgresql.con.kerb5:L'autenticazione di tipo ``Kerberos 5'' non è supportata da questo driver.
-postgresql.con.multres:Impossibile gestire gruppi multipli di risultati.
-postgresql.con.pass:La proprietà ``password'' è mancante. E` obbligatoria.
-postgresql.con.refused:Connessione rifiutata. Controllare che il nome dell'host e la porta siano corretti, e che il server (postmaster) è in esecuzione con l'opzione -i, che abilita le connessioni attraverso la rete TCP/IP.
-postgresql.con.setup:Errore di protocollo. Fallita l'impostazione della sessione.
-postgresql.con.strobj:L'oggetto potrebbe non essere stato memorizzato. Controllare che ogni tabella richiesta è stata creata nel database.
-postgresql.con.strobjex:Fallita la memorizzazione dell'oggetto - {0}
-postgresql.con.toolong:L'istruzione SQL è troppo lunga - {0}
-postgresql.con.isolevel:Il livello d'isolamento delle transazioni {0} non è supportato.
-postgresql.con.tuple:Tupla ricevuta prima del MetaData.
-postgresql.con.type:Tipo di risposta sconosciuta {0}
-postgresql.con.user:La proprietà ``user'' è mancante. E` obbligatoria.
-postgresql.fp.error:La chiamata a FastPath ha restituito {0}
-postgresql.fp.expint:Chiamata Fastpath {0} - Nessun risultato restituito mentre ci si aspettava un intero.
-postgresql.fp.protocol:Errore nel protocollo FastPath: {0}
-postgresql.fp.send:Fallito l'invio della chiamata fastpath {0} {1}
-postgresql.fp.unknown:La funzione fastpath {0} è sconosciuta.
-postgresql.geo.box:Fallita la conversione di un ``box'' - {0}
-postgresql.geo.circle:Fallita la conversione di un ``circle'' - {0}
-postgresql.geo.line:Fallita la conversione di una ``line'' - {0}
-postgresql.geo.lseg:Fallita la conversione di un ``lseg'' - {0}
-postgresql.geo.path:Impossibile stabilire se il percorso è aperto o chiuso.
-postgresql.geo.point:Fallita la conversione di un ``point'' - {0}
-postgresql.jvm.version:Il file ``postgresql.jar'' non contiene le classi JDBC corrette per questa JVM. Provare a ricompilarle. Se il problema persiste, tentare di forzare la versione fornendo sulla linea di comando l'opzione -Djava.version=1.1 oppure -Djava.version=1.2\nL'eccezione ricevuta è stata {0}
-postgresql.lo.init:Inizializzazione di LargeObject API fallita.
-postgresql.money:Fallita la conversione di un ``money'' - {0}.
-postgresql.noupdate:Questo ResultSet non è modificabile.
-postgresql.notsensitive:Questo ResultSet non risente delle modifiche in tempo reale dopo che la query è stata eseguita.
-postgresql.psqlnotimp:Il processo server al momento non supporta questa funzionalità.
-postgresql.prep.is:InputStream come parametro non è supportato
-postgresql.prep.param:Nessun valore specificato come parametro {0}.
-postgresql.prep.range:Indice del parametro fuori dall'intervallo ammissibile.
-postgresql.prep.type:Valore di tipo sconosciuto.
-postgresql.res.badbigdec:BigDecimal non corretto {0}
-postgresql.res.badbyte:Byte non corretto {0}
-postgresql.res.baddate:Date Format non corretto a {0} in {1}
-postgresql.res.baddouble:Double non corretto {0}
-postgresql.res.badfloat:Float non corretto {0}
-postgresql.res.badint:Integer non corretto {0}
-postgresql.res.badlong:Long non corretto {0}
-postgresql.res.badshort:Short non corretto {0}
-postgresql.res.badtime:Time non corretto {0}
-postgresql.res.badtimestamp:Timestamp Format non corretto a {0} in {1}
-postgresql.res.colname:Colonna denominata {0} non trovata.
-postgresql.res.colrange:Indice di colonna fuori dall'intervallo ammissibile.
-postgresql.serial.interface:Impossibile serializzare un'interfaccia.
-postgresql.serial.namelength:La lunghezza dei nomi per Class & Package non può essere superiore a 32 caratteri. {0} è di {1} caratteri.
-postgresql.serial.noclass:Nessuna classe trovata per {0}.
-postgresql.serial.table:La tabella per {0} non è nel database. Contattare l'amministratore del DB, visto che il database è in uno stato incosistente.
-postgresql.serial.underscore:Il nome di una classe non può contenere il carattere ``_''. E` stato fornito {0}.
-postgresql.stat.batch.error:L'operazione {0} {1} della sequenza è stata annullata.
-postgresql.stat.maxfieldsize:Fallito un tentativo a setMaxFieldSize() - verrà utilizzato il valore predefinito a tempo di compilazione.
-postgresql.stat.noresult:Nessun risultato è stato restituito dalla query.
-postgresql.stream.eof:Il backend ha interrotto la connessione. Probabilmente la tua azione ha causato la sua uscita.
-postgresql.stream.flush:Si è verificato un errore di I/O mentre si svuotava il buffer d'uscita - {0}
-postgresql.stream.ioerror:Si è verificato un errore di I/O mentre si leggevano dati dal backend - {0}
-postgresql.stream.toomuch:Troppi dati ricevuti.
-postgresql.unusual:Qualcosa di insolito si è verificato causando il fallimento del driver. Per favore riferire all'autore del driver questa eccezione: {0}
-postgresql.unimplemented:Questo metodo non è stato ancora implementato.
-postgresql.unexpected:Un risultato inaspettato è stato ricevuto dalla query.
diff --git a/src/interfaces/jdbc/org/postgresql/errors_nl.properties b/src/interfaces/jdbc/org/postgresql/errors_nl.properties
deleted file mode 100644
index 2e5388a2278..00000000000
--- a/src/interfaces/jdbc/org/postgresql/errors_nl.properties
+++ /dev/null
@@ -1,66 +0,0 @@
-# This is the default errors
-# Dutch translation by Arnout Kuiper (ajkuiper@wxs.nl)
-postgresql.con.auth:Het authenticatie type {0} wordt niet ondersteund. Controleer dat het IP adres of subnet van de client is geconfigureerd in de pg_hba.conf file, en dat het een authenticatie protocol gebruikt dat door de driver ondersteund wordt.
-postgresql.con.authfail:Een fout trad op tijdens het ophalen van het authenticatie verzoek.
-postgresql.con.call:Callable Statements worden op dit moment niet ondersteund.
-postgresql.con.creobj:Kon geen object aanmaken voor {0} {1}
-postgresql.con.failed:De poging om verbinding the maken faalde omdat {0}
-postgresql.con.fathom:Niet in staat om the update telling te peilen {0}
-postgresql.con.garbled:Verminkte data ontvangen.
-postgresql.con.ioerror:Een I/O fout trad op tijdens het zenden naar de achterkant - {0}
-postgresql.con.kerb4:Kerberos 4 authenticatie wordt niet ondersteund door deze driver.
-postgresql.con.kerb5:Kerberos 5 authenticatie wordt niet ondersteund door deze driver.
-postgresql.con.multres:Kan niet omgaan met meerdere resultaat groepen.
-postgresql.con.pass:Het password, welke verplicht is, ontbreekt.
-postgresql.con.refused:Verbinding geweigerd. Controleer dat de hostnaam en poort correct zijn, en dat de postmaster is opgestart met de -i vlag, welke TCP/IP networking aanzet.
-postgresql.con.strobj:Het object kon niet worden opgeslagen. Controleer dat alle benodigde tabellen aangemaakt zijn in de database.
-postgresql.con.strobjex:Kon niet object opslaan - {0}
-postgresql.con.toolong:Het SQL Statement is te lang - {0}
-postgresql.con.tuple:Tuple ontvangen voor MetaData.
-postgresql.con.type:Onbekend antwoord type {0}
-postgresql.con.user:De user, welke verplicht is, ontbreekt.
-postgresql.fp.error:FastPath aanroep retourneerde {0}
-postgresql.fp.expint:Fastpath aanroep {0} - Geen resultaat werd teruggegeven, terwijl we een integer verwacht hadden.
-postgresql.fp.protocol:FastPath protocol fout: {0}
-postgresql.fp.send:Kon geen fastpath aanroep verzenden {0} {1}
-postgresql.fp.unknown:De fastpath functie {0} is onbekend.
-postgresql.geo.box:Conversie van box faalde - {0}
-postgresql.geo.circle:Conversie van circle faalde - {0}
-postgresql.geo.line:Conversie van line faalde - {0}
-postgresql.geo.lseg:Conversie van lseg faalde - {0}
-postgresql.geo.path:Kan niet zeggen of path open of gesloten is.
-postgresql.geo.point:Conversie van point faalde - {0}
-postgresql.jvm.version:De postgresql.jar file bevat niet de correcte JDBC classen voor deze JVM. Probeer opnieuw te bouwen. Als dat niet werkt, probeer de versie te forceren via de command line met het argument -Djava.version=1.1 of -Djava.version=1.2\nAfgevuurde exceptie was {0}
-postgresql.lo.init:Kon LargeObject API niet initialiseren
-postgresql.money:Conversie van money faalde - {0}.
-postgresql.prep.is:InputStream als parameter wordt niet ondersteund
-postgresql.prep.param:Geen waarde opgegeven voor parameter {0}.
-postgresql.prep.range:Parameterindex is buiten bereik.
-postgresql.prep.type:Onbekende Types waarde.
-postgresql.res.badbigdec:Foute BigDecimal {0}
-postgresql.res.badbyte:Foute Byte {0}
-postgresql.res.baddate:Foutief Date Formaat op {0} in {1}
-postgresql.res.baddouble:Foute Double {0}
-postgresql.res.badfloat:Foute Float {0}
-postgresql.res.badint:Foute Integer {0}
-postgresql.res.badlong:Foute Long {0}
-postgresql.res.badshort:Foute Short {0}
-postgresql.res.badtime:Foute Time {0}
-postgresql.res.badtimestamp:Foutief Timestamp Formaat op {0} in {1}
-postgresql.res.colname:De kolom naam {0} is niet gevonden.
-postgresql.res.colrange:De kolom index is buiten bereik.
-postgresql.serial.interface:Je can geen interface serializeren.
-postgresql.serial.namelength:Class & Package name length cannot be longer than 32 characters. {0} is {1} characters.
-postgresql.serial.noclass:Geen class gevonden voor {0}.
-postgresql.serial.table:De tabel voor {0} is niet in de database. Neem contact op met de DBA, omdat de database in een inconsistente staat verkeert.
-postgresql.serial.underscore:Class namen mogen geen _ in zich hebben. Jij voerde {0} in.
-postgresql.stat.batch.error:Batch invoer {0} {1} werd afgebroken.
-postgresql.stat.maxfieldsize:Een poging om setMaxFieldSize() faalde - compiletime standaardwaarde van kracht.
-postgresql.stat.noresult:Geen resultaten werden teruggegeven door de query.
-postgresql.stream.eof:De achterkant heeft de verbinding verbroken. Mogelijk was de actie die je probeerde de oorzaak hiervan.
-postgresql.stream.flush:Een I/O fout trad op tijdens het legen van de uitvoer - {0}
-postgresql.stream.ioerror:Een I/O fout trad op tijdens het lezen van de achterkant - {0}
-postgresql.stream.toomuch:Teveel gegevens werden ontvangen
-postgresql.unusual:Iets ongewoons is opgetreden, wat deze driver doet falen. Rapporteer deze fout AUB: {0}
-postgresql.unimplemented:Deze methode is nog niet geimplementeerd
-postgresql.unexpected:Een onverwacht resultaat werd teruggegeven door een query
diff --git a/src/interfaces/jdbc/org/postgresql/errors_zh_TW.properties b/src/interfaces/jdbc/org/postgresql/errors_zh_TW.properties
deleted file mode 100644
index 1aef1703a0a..00000000000
--- a/src/interfaces/jdbc/org/postgresql/errors_zh_TW.properties
+++ /dev/null
@@ -1,79 +0,0 @@
-# 2002-04-15 Zhenbang Wei <forth@mail.net.tw>
-postgresql.arr.range:\u9663\u5217\u7d22\u5f15\u8d85\u904e\u8a31\u53ef\u7bc4\u570d\u3002
-postgresql.drv.version:\u5167\u90e8\u932f\u8aa4\uff0c\u8acb\u91cd\u65b0\u7de8\u8b6f\u9a45\u52d5\u7a0b\u5f0f\u3002
-postgresql.con.auth:\u4e0d\u652f\u63f4 {0} \u8a8d\u8b49\uff0c\u8acb\u78ba\u5b9a\u60a8\u5df2\u7d93\u5c07\u5ba2\u6236\u7aef\u7684 IP \u4f4d\u5740\u6216\u7db2\u8def\u5340\u6bb5\u4ee5\u53ca\u9a45\u52d5\u7a0b\u5f0f\u6240\u652f\u63f4\u7684\u8a8d\u8b49\u985e\u578b\u52a0\u5165 pg_hba.conf\u3002
-postgresql.con.authfail:\u8b80\u53d6\u8a8d\u8b49\u8acb\u6c42\u6642\u767c\u751f\u932f\u8aa4\u3002
-postgresql.con.backend:\u5f8c\u7aef\u555f\u52d5\u5931\u6557: {0}
-postgresql.con.call:\u76ee\u524d\u4e0d\u652f\u63f4 Callable Statement\u3002
-postgresql.con.creobj:\u70ba {0} {1} \u5efa\u7acb\u7269\u4ef6\u5931\u6557
-postgresql.con.failed:\u7121\u6cd5\u9023\u7dda\uff0c\u56e0\u70ba {0}
-postgresql.con.fathom:\u7121\u6cd5\u53d6\u5f97\u66f4\u65b0\u7684\u8cc7\u6599\u7b46\u6578 {0}
-postgresql.con.garbled:\u6536\u5230\u7121\u6548\u7684\u8cc7\u6599\u3002
-postgresql.con.ioerror:\u50b3\u9001\u8cc7\u6599\u81f3\u5f8c\u7aef\u6642\u767c\u751f IO \u932f\u8aa4 - {0}
-postgresql.con.kerb4:\u9a45\u52d5\u7a0b\u5f0f\u4e0d\u652f\u63f4 Kerberos 4 \u8a8d\u8b49\u3002
-postgresql.con.kerb5:\u9a45\u52d5\u7a0b\u5f0f\u4e0d\u652f\u63f4 Kerberos 5 \u8a8d\u8b49\u3002
-postgresql.con.misc:\u767c\u751f\u9023\u7dda\u932f\u8aa4: {0}
-postgresql.con.multres:\u7121\u6cd5\u8655\u7406\u591a\u91cd\u67e5\u8a62\u7d50\u679c\u3002
-postgresql.con.pass:\u6c92\u6709 password \u5c6c\u6027\uff0c\u9019\u9805\u5c6c\u6027\u662f\u5fc5\u9700\u7684\u3002
-postgresql.con.refused:\u62d2\u7d55\u9023\u7dda\uff0c\u8acb\u6aa2\u67e5\u4e3b\u6a5f\u540d\u7a31\u548c\u57e0\u865f\uff0c\u4e26\u78ba\u5b9a postmaster \u555f\u52d5\u6642\u4f7f\u7528\u4e86 -i \u53c3\u6578\u958b\u555f TCP/IP \u7db2\u8def\u529f\u80fd\u3002
-postgresql.con.setup:\u901a\u8a0a\u5354\u5b9a\u932f\u8aa4\u3002Session \u521d\u59cb\u5316\u5931\u6557\u3002
-postgresql.con.strobj:\u7121\u6cd5\u5132\u5b58\u7269\u4ef6\uff0c\u8acb\u78ba\u5b9a\u5df2\u7d93\u5728\u8cc7\u6599\u5eab\u4e2d\u5efa\u7acb\u8981\u4f7f\u7528\u7684\u8cc7\u6599\u8868\u3002
-postgresql.con.strobjex:\u5132\u5b58\u7269\u4ef6\u5931\u6557 - {0}
-postgresql.con.toolong:SQL \u6558\u8ff0\u904e\u9577 - {0}
-postgresql.con.isolevel:\u4e0d\u652f\u63f4\u4ea4\u6613\u9694\u7d55\u7b49\u7d1a {0}\u3002
-postgresql.con.tuple:Tuple \u5728 MetaData \u4e4b\u524d\u50b3\u56de\u3002
-postgresql.con.type:\u4e0d\u660e\u7684\u56de\u61c9\u985e\u578b {0}
-postgresql.con.user:\u6c92\u6709 user \u5c6c\u6027\uff0c\u9019\u9805\u5c6c\u6027\u662f\u5fc5\u9700\u7684\u3002
-postgresql.fp.error:FastPath \u547c\u53eb\u50b3\u56de {0}
-postgresql.fp.expint:Fastpath \u547c\u53eb {0} - \u6c92\u6709\u50b3\u56de\u503c\uff0c\u61c9\u8a72\u50b3\u56de\u4e00\u500b\u6574\u6578\u3002
-postgresql.fp.protocol:FastPath \u5354\u5b9a\u932f\u8aa4: {0}
-postgresql.fp.send:\u50b3\u9001 fastpath \u547c\u53eb {0} {1} \u5931\u6557
-postgresql.fp.unknown:\u4e0d\u660e\u7684 fastpath \u51fd\u5f0f {0}\u3002
-postgresql.geo.box:\u8f49\u63db box \u5931\u6557 - {0}
-postgresql.geo.circle:\u8f49\u63db circle \u5931\u6557 - {0}
-postgresql.geo.line:\u8f49\u63db line \u5931\u6557 - {0}
-postgresql.geo.lseg:\u8f49\u63db lseg \u5931\u6557 - {0}
-postgresql.geo.path:\u7121\u6cd5\u5f97\u77e5 path \u662f\u5c01\u9589\u6216\u958b\u653e\u3002
-postgresql.geo.point:\u8f49\u63db point \u5931\u6557 - {0}
-postgresql.jvm.version:\u5728 postgresql.jar \u4e2d\u627e\u4e0d\u5230\u6b63\u78ba\u7684 JDBC \u985e\u5225\u4f9b JVM \u4f7f\u7528\uff0c\u8acb\u91cd\u65b0\u7de8\u8b6f\uff0c\u5982\u679c\u4ecd\u7136\u767c\u751f\u932f\u8aa4\uff0c\u8acb\u5728\u57f7\u884c\u6642\u7528 -Djava.version=1.1 \u6216 -Djava.version=1.2 \u5f37\u5236\u6307\u5b9a\u7248\u672c\n\u7522\u751f\u7684\u4f8b\u5916\u662f {0}
-postgresql.lo.init:\u521d\u59cb\u5316 LargeObject API \u5931\u6557\u3002
-postgresql.metadata.unavailable:\u7121\u6cd5\u53d6\u5f97 Metadata\u3002
-postgresql.money:\u8f49\u63db money \u5931\u6557 - {0}\u3002
-postgresql.noupdate:\u67e5\u8a62\u7d50\u679c\u4e0d\u53ef\u66f4\u65b0\u3002
-postgresql.notsensitive:\u67e5\u8a62\u7d50\u679c\u4e0d\u80fd\u5373\u6642\u53cd\u6620\u8b8a\u52d5\u7684\u8cc7\u6599\u3002
-postgresql.psqlnotimp:\u5f8c\u7aef\u76ee\u524d\u4e0d\u652f\u63f4\u9019\u9805\u529f\u80fd\u3002
-postgresql.prep.is:\u4e0d\u652f\u63f4\u4ee5 InputStream \u505a\u70ba\u53c3\u6578\u3002
-postgresql.prep.param:\u672a\u8a2d\u5b9a\u53c3\u6578 {0} \u7684\u5167\u5bb9\u3002
-postgresql.prep.range:\u53c3\u6578\u7d22\u5f15\u8d85\u904e\u8a31\u53ef\u7bc4\u570d\u3002
-postgresql.prep.type:\u4e0d\u660e\u7684\u578b\u5225\u3002
-postgresql.res.badbigdec:\u932f\u8aa4\u7684 BigDecimal {0}
-postgresql.res.badbyte:\u932f\u8aa4\u7684 Byte {0}
-postgresql.res.baddate:\u932f\u8aa4\u7684 Date \u683c\u5f0f {1} \u65bc {0}
-postgresql.res.baddouble:\u932f\u8aa4\u7684 Double {0}
-postgresql.res.badfloat:\u932f\u8aa4\u7684 Float {0}
-postgresql.res.badint:\u932f\u8aa4\u7684 Integer {0}
-postgresql.res.badlong:\u932f\u8aa4\u7684 Long {0}
-postgresql.res.badshort:\u932f\u8aa4\u7684 Short {0}
-postgresql.res.badtime:\u932f\u8aa4\u7684 Time {0}
-postgresql.res.badtimestamp:\u932f\u8aa4\u7684 Timestamp \u683c\u5f0f {1} \u65bc {0}
-postgresql.res.closed:ResultSet \u5df2\u7d93\u95dc\u9589\uff0c\u4e0d\u5141\u8a31\u5176\u5b83\u64cd\u4f5c\u3002
-postgresql.res.colname:\u627e\u4e0d\u5230\u6b04\u4f4d\u540d\u7a31 {0}\u3002
-postgresql.res.colrange:\u6b04\u4f4d\u7d22\u5f15\u8d85\u904e\u8a31\u53ef\u7bc4\u570d\u3002
-postgresql.res.nextrequired:\u67e5\u8a62\u7d50\u679c\u6307\u6a19\u4f4d\u7f6e\u4e0d\u6b63\u78ba\uff0c\u60a8\u4e5f\u8a31\u9700\u8981\u547c\u53eb ResultSet \u7684 next() \u65b9\u6cd5.
-postgresql.serial.interface:\u4e0d\u5141\u8a31\u5c07\u4ecb\u9762\u5e8f\u5217\u5316\u3002
-postgresql.serial.namelength:\u985e\u5225\u548c\u5305\u88dd\u7684\u540d\u7a31\uff0c\u9577\u5ea6\u4e0d\u80fd\u8d85\u904e 32 \u5b57\u5143\uff0c{0} \u7684\u9577\u5ea6\u662f {1} \u5b57\u5143\u3002
-postgresql.serial.noclass:\u627e\u4e0d\u5230\u985e\u5225 {0}\u3002
-postgresql.serial.table:\u8655\u7406 {0} \u6642\u627e\u4e0d\u5230\u8cc7\u6599\u8868\uff0c\u8cc7\u6599\u5eab\u72c0\u614b\u4e0d\u6b63\u5e38\uff0c\u8acb\u806f\u7d61 DBA \u8655\u7406\u3002
-postgresql.serial.underscore:\u985e\u5225\u540d\u7a31\u4e0d\u80fd\u4f7f\u7528 _ \u5b57\u5143\uff0c\u60a8\u7528\u7684\u540d\u7a31\u662f {0}\u3002
-postgresql.stat.batch.error:\u6279\u6b21\u8655\u7406\u5ffd\u7565 {0} {1}\u3002
-postgresql.stat.maxfieldsize:setMaxFieldSize() \u5931\u6557 - \u4f7f\u7528\u9810\u8a2d\u503c
-postgresql.stat.noresult:\u6c92\u6709\u50b3\u56de\u4efb\u4f55\u67e5\u8a62\u7d50\u679c\u3002
-postgresql.stat.result:\u50b3\u56de\u975e\u9810\u671f\u7684\u67e5\u8a62\u7d50\u679c\u3002
-postgresql.stream.eof:\u5f8c\u7aef\u7d50\u675f\u9023\u7dda\uff0c\u4e5f\u8a31\u662f\u56e0\u70ba\u60a8\u6240\u57f7\u884c\u7684\u52d5\u4f5c\u5c0e\u81f4\u9023\u7dda\u4e2d\u65b7\u3002
-postgresql.stream.flush:\u9001\u51fa\u8cc7\u6599\u6642\u767c\u751f I/O \u932f\u8aa4 - {0}
-postgresql.stream.ioerror:\u5f9e\u5f8c\u7aef\u8b80\u53d6\u8cc7\u6599\u6642\u767c\u751f I/O \u932f\u8aa4 - {0}
-postgresql.stream.toomuch:\u63a5\u6536\u904e\u591a\u8cc7\u6599\u3002
-postgresql.unusual:\u4e0d\u660e\u7684\u539f\u56e0\u5c0e\u81f4\u9a45\u52d5\u7a0b\u5f0f\u767c\u751f\u932f\u8aa4\uff0c\u8acb\u56de\u5831\u9019\u500b\u4f8b\u5916\uff1a{0}
-postgresql.unimplemented:\u9019\u500b\u65b9\u6cd5\u5c1a\u672a\u5be6\u4f5c\u3002
-postgresql.unexpected:\u50b3\u56de\u975e\u9810\u671f\u7684\u67e5\u8a62\u7d50\u679c\u3002
-
diff --git a/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java b/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java
deleted file mode 100644
index 20f5a6f3e26..00000000000
--- a/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java
+++ /dev/null
@@ -1,291 +0,0 @@
-package org.postgresql.fastpath;
-
-import org.postgresql.Driver;
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-// Important: There are a lot of debug code commented out. Please do not
-// delete these.
-
-/*
- * This class implements the Fastpath api.
- *
- * <p>This is a means of executing functions imbeded in the org.postgresql backend
- * from within a java application.
- *
- * <p>It is based around the file src/interfaces/libpq/fe-exec.c
- *
- * @see org.postgresql.FastpathFastpathArg
- * @see org.postgresql.LargeObject
- */
-public class Fastpath
-{
- // This maps the functions names to their id's (possible unique just
- // to a connection).
- protected Hashtable func = new Hashtable();
-
- protected org.postgresql.Connection conn; // our connection
- protected org.postgresql.PG_Stream stream; // the network stream
-
- /*
- * Initialises the fastpath system
- *
- * <p><b>Important Notice</b>
- * <br>This is called from org.postgresql.Connection, and should not be called
- * from client code.
- *
- * @param conn org.postgresql.Connection to attach to
- * @param stream The network stream to the backend
- */
- public Fastpath(org.postgresql.Connection conn, org.postgresql.PG_Stream stream)
- {
- this.conn = conn;
- this.stream = stream;
- }
-
- /*
- * Send a function call to the PostgreSQL backend
- *
- * @param fnid Function id
- * @param resulttype True if the result is an integer, false for other results
- * @param args FastpathArguments to pass to fastpath
- * @return null if no data, Integer if an integer result, or byte[] otherwise
- * @exception SQLException if a database-access error occurs.
- */
- public Object fastpath(int fnid, boolean resulttype, FastpathArg[] args) throws SQLException
- {
- // added Oct 7 1998 to give us thread safety
- synchronized (stream)
- {
- // send the function call
- try
- {
- // 70 is 'F' in ASCII. Note: don't use SendChar() here as it adds padding
- // that confuses the backend. The 0 terminates the command line.
- stream.SendInteger(70, 1);
- stream.SendInteger(0, 1);
-
- stream.SendInteger(fnid, 4);
- stream.SendInteger(args.length, 4);
-
- for (int i = 0;i < args.length;i++)
- args[i].send(stream);
-
- // This is needed, otherwise data can be lost
- stream.flush();
-
- }
- catch (IOException ioe)
- {
- throw new PSQLException("postgresql.fp.send", new Integer(fnid), ioe);
- }
-
- // Now handle the result
-
- // Now loop, reading the results
- Object result = null; // our result
- StringBuffer errorMessage = null;
- int c;
- boolean l_endQuery = false;
- while (!l_endQuery)
- {
- c = stream.ReceiveChar();
-
- switch (c)
- {
- case 'A': // Asynchronous Notify
- int pid = stream.ReceiveInteger(4);
- String msg = stream.ReceiveString(conn.getEncoding());
- break;
-
- //------------------------------
- // Error message returned
- case 'E':
- if ( errorMessage == null )
- errorMessage = new StringBuffer();
- errorMessage.append(stream.ReceiveString(conn.getEncoding()));
- break;
-
- //------------------------------
- // Notice from backend
- case 'N':
- conn.addWarning(stream.ReceiveString(conn.getEncoding()));
- break;
-
- case 'V':
- int l_nextChar = stream.ReceiveChar();
- if (l_nextChar == 'G') {
- int sz = stream.ReceiveIntegerR(4);
- // Return an Integer if
- if (resulttype)
- result = new Integer(stream.ReceiveIntegerR(sz));
- else
- {
- byte buf[] = new byte[sz];
- stream.Receive(buf, 0, sz);
- result = buf;
- }
- //There should be a trailing '0'
- int l_endChar = stream.ReceiveChar();
- } else {
- //it must have been a '0', thus no results
- }
- break;
-
- case 'Z':
- l_endQuery = true;
- break;
-
- default:
- throw new PSQLException("postgresql.fp.protocol", new Character((char)c));
- }
- }
-
- if ( errorMessage != null )
- throw new PSQLException("postgresql.fp.error", errorMessage.toString());
-
- return result;
- }
- }
-
- /*
- * Send a function call to the PostgreSQL backend by name.
- *
- * Note: the mapping for the procedure name to function id needs to exist,
- * usually to an earlier call to addfunction().
- *
- * This is the prefered method to call, as function id's can/may change
- * between versions of the backend.
- *
- * For an example of how this works, refer to org.postgresql.LargeObject
- *
- * @param name Function name
- * @param resulttype True if the result is an integer, false for other
- * results
- * @param args FastpathArguments to pass to fastpath
- * @return null if no data, Integer if an integer result, or byte[] otherwise
- * @exception SQLException if name is unknown or if a database-access error
- * occurs.
- * @see org.postgresql.LargeObject
- */
- public Object fastpath(String name, boolean resulttype, FastpathArg[] args) throws SQLException
- {
- if (Driver.logDebug) Driver.debug("Fastpath: calling "+name);
- return fastpath(getID(name), resulttype, args);
- }
-
- /*
- * This convenience method assumes that the return value is an Integer
- * @param name Function name
- * @param args Function arguments
- * @return integer result
- * @exception SQLException if a database-access error occurs or no result
- */
- public int getInteger(String name, FastpathArg[] args) throws SQLException
- {
- Integer i = (Integer)fastpath(name, true, args);
- if (i == null)
- throw new PSQLException("postgresql.fp.expint", name);
- return i.intValue();
- }
-
- /*
- * This convenience method assumes that the return value is an Integer
- * @param name Function name
- * @param args Function arguments
- * @return byte[] array containing result
- * @exception SQLException if a database-access error occurs or no result
- */
- public byte[] getData(String name, FastpathArg[] args) throws SQLException
- {
- return (byte[])fastpath(name, false, args);
- }
-
- /*
- * This adds a function to our lookup table.
- *
- * <p>User code should use the addFunctions method, which is based upon a
- * query, rather than hard coding the oid. The oid for a function is not
- * guaranteed to remain static, even on different servers of the same
- * version.
- *
- * @param name Function name
- * @param fnid Function id
- */
- public void addFunction(String name, int fnid)
- {
- func.put(name, new Integer(fnid));
- }
-
- /*
- * This takes a ResultSet containing two columns. Column 1 contains the
- * function name, Column 2 the oid.
- *
- * <p>It reads the entire ResultSet, loading the values into the function
- * table.
- *
- * <p><b>REMEMBER</b> to close() the resultset after calling this!!
- *
- * <p><b><em>Implementation note about function name lookups:</em></b>
- *
- * <p>PostgreSQL stores the function id's and their corresponding names in
- * the pg_proc table. To speed things up locally, instead of querying each
- * function from that table when required, a Hashtable is used. Also, only
- * the function's required are entered into this table, keeping connection
- * times as fast as possible.
- *
- * <p>The org.postgresql.LargeObject class performs a query upon it's startup,
- * and passes the returned ResultSet to the addFunctions() method here.
- *
- * <p>Once this has been done, the LargeObject api refers to the functions by
- * name.
- *
- * <p>Dont think that manually converting them to the oid's will work. Ok,
- * they will for now, but they can change during development (there was some
- * discussion about this for V7.0), so this is implemented to prevent any
- * unwarranted headaches in the future.
- *
- * @param rs ResultSet
- * @exception SQLException if a database-access error occurs.
- * @see org.postgresql.LargeObjectManager
- */
- public void addFunctions(ResultSet rs) throws SQLException
- {
- while (rs.next())
- {
- func.put(rs.getString(1), new Integer(rs.getInt(2)));
- }
- }
-
- /*
- * This returns the function id associated by its name
- *
- * <p>If addFunction() or addFunctions() have not been called for this name,
- * then an SQLException is thrown.
- *
- * @param name Function name to lookup
- * @return Function ID for fastpath call
- * @exception SQLException is function is unknown.
- */
- public int getID(String name) throws SQLException
- {
- Integer id = (Integer)func.get(name);
-
- // may be we could add a lookup to the database here, and store the result
- // in our lookup table, throwing the exception if that fails.
- // We must, however, ensure that if we do, any existing ResultSet is
- // unaffected, otherwise we could break user code.
- //
- // so, until we know we can do this (needs testing, on the TODO list)
- // for now, we throw the exception and do no lookups.
- if (id == null)
- throw new PSQLException("postgresql.fp.unknown", name);
-
- return id.intValue();
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/fastpath/FastpathArg.java b/src/interfaces/jdbc/org/postgresql/fastpath/FastpathArg.java
deleted file mode 100644
index 1539ee8a144..00000000000
--- a/src/interfaces/jdbc/org/postgresql/fastpath/FastpathArg.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.postgresql.fastpath;
-
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-/*
- * Each fastpath call requires an array of arguments, the number and type
- * dependent on the function being called.
- *
- * <p>This class implements methods needed to provide this capability.
- *
- * <p>For an example on how to use this, refer to the org.postgresql.largeobject
- * package
- *
- * @see org.postgresql.fastpath.Fastpath
- * @see org.postgresql.largeobject.LargeObjectManager
- * @see org.postgresql.largeobject.LargeObject
- */
-public class FastpathArg
-{
- /*
- * Type of argument, true=integer, false=byte[]
- */
- public boolean type;
-
- /*
- * Integer value if type=true
- */
- public int value;
-
- /*
- * Byte value if type=false;
- */
- public byte[] bytes;
-
- /*
- * Constructs an argument that consists of an integer value
- * @param value int value to set
- */
- public FastpathArg(int value)
- {
- type = true;
- this.value = value;
- }
-
- /*
- * Constructs an argument that consists of an array of bytes
- * @param bytes array to store
- */
- public FastpathArg(byte bytes[])
- {
- type = false;
- this.bytes = bytes;
- }
-
- /*
- * Constructs an argument that consists of part of a byte array
- * @param buf source array
- * @param off offset within array
- * @param len length of data to include
- */
- public FastpathArg(byte buf[], int off, int len)
- {
- type = false;
- bytes = new byte[len];
- System.arraycopy(buf, off, bytes, 0, len);
- }
-
- /*
- * Constructs an argument that consists of a String.
- * @param s String to store
- */
- public FastpathArg(String s)
- {
- this(s.getBytes());
- }
-
- /*
- * This sends this argument down the network stream.
- *
- * <p>The stream sent consists of the length.int4 then the contents.
- *
- * <p><b>Note:</b> This is called from Fastpath, and cannot be called from
- * client code.
- *
- * @param s output stream
- * @exception IOException if something failed on the network stream
- */
- protected void send(org.postgresql.PG_Stream s) throws IOException
- {
- if (type)
- {
- // argument is an integer
- s.SendInteger(4, 4); // size of an integer
- s.SendInteger(value, 4); // integer value of argument
- }
- else
- {
- // argument is a byte array
- s.SendInteger(bytes.length, 4); // size of array
- s.Send(bytes);
- }
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGbox.java b/src/interfaces/jdbc/org/postgresql/geometric/PGbox.java
deleted file mode 100644
index e57297c7dd3..00000000000
--- a/src/interfaces/jdbc/org/postgresql/geometric/PGbox.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.postgresql.geometric;
-
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-/*
- * This represents the box datatype within org.postgresql.
- */
-public class PGbox extends PGobject implements Serializable, Cloneable
-{
- /*
- * These are the two points.
- */
- public PGpoint point[] = new PGpoint[2];
-
- /*
- * @param x1 first x coordinate
- * @param y1 first y coordinate
- * @param x2 second x coordinate
- * @param y2 second y coordinate
- */
- public PGbox(double x1, double y1, double x2, double y2)
- {
- this();
- this.point[0] = new PGpoint(x1, y1);
- this.point[1] = new PGpoint(x2, y2);
- }
-
- /*
- * @param p1 first point
- * @param p2 second point
- */
- public PGbox(PGpoint p1, PGpoint p2)
- {
- this();
- this.point[0] = p1;
- this.point[1] = p2;
- }
-
- /*
- * @param s Box definition in PostgreSQL syntax
- * @exception SQLException if definition is invalid
- */
- public PGbox(String s) throws SQLException
- {
- this();
- setValue(s);
- }
-
- /*
- * Required constructor
- */
- public PGbox()
- {
- setType("box");
- }
-
- /*
- * This method sets the value of this object. It should be overidden,
- * but still called by subclasses.
- *
- * @param value a string representation of the value of the object
- * @exception SQLException thrown if value is invalid for this type
- */
- public void setValue(String value) throws SQLException
- {
- PGtokenizer t = new PGtokenizer(value, ',');
- if (t.getSize() != 2)
- throw new PSQLException("postgresql.geo.box", value);
-
- point[0] = new PGpoint(t.getToken(0));
- point[1] = new PGpoint(t.getToken(1));
- }
-
- /*
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
- public boolean equals(Object obj)
- {
- if (obj instanceof PGbox)
- {
- PGbox p = (PGbox)obj;
- return (p.point[0].equals(point[0]) && p.point[1].equals(point[1])) ||
- (p.point[0].equals(point[1]) && p.point[1].equals(point[0]));
- }
- return false;
- }
-
- /*
- * This must be overidden to allow the object to be cloned
- */
- public Object clone()
- {
- return new PGbox((PGpoint)point[0].clone(), (PGpoint)point[1].clone());
- }
-
- /*
- * @return the PGbox in the syntax expected by org.postgresql
- */
- public String getValue()
- {
- return point[0].toString() + "," + point[1].toString();
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGcircle.java b/src/interfaces/jdbc/org/postgresql/geometric/PGcircle.java
deleted file mode 100644
index 05e60c55267..00000000000
--- a/src/interfaces/jdbc/org/postgresql/geometric/PGcircle.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.postgresql.geometric;
-
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-/*
- * This represents org.postgresql's circle datatype, consisting of a point and
- * a radius
- */
-public class PGcircle extends PGobject implements Serializable, Cloneable
-{
- /*
- * This is the centre point
- */
- public PGpoint center;
-
- /*
- * This is the radius
- */
- double radius;
-
- /*
- * @param x coordinate of centre
- * @param y coordinate of centre
- * @param r radius of circle
- */
- public PGcircle(double x, double y, double r)
- {
- this(new PGpoint(x, y), r);
- }
-
- /*
- * @param c PGpoint describing the circle's centre
- * @param r radius of circle
- */
- public PGcircle(PGpoint c, double r)
- {
- this();
- this.center = c;
- this.radius = r;
- }
-
- /*
- * @param s definition of the circle in PostgreSQL's syntax.
- * @exception SQLException on conversion failure
- */
- public PGcircle(String s) throws SQLException
- {
- this();
- setValue(s);
- }
-
- /*
- * This constructor is used by the driver.
- */
- public PGcircle()
- {
- setType("circle");
- }
-
- /*
- * @param s definition of the circle in PostgreSQL's syntax.
- * @exception SQLException on conversion failure
- */
- public void setValue(String s) throws SQLException
- {
- PGtokenizer t = new PGtokenizer(PGtokenizer.removeAngle(s), ',');
- if (t.getSize() != 2)
- throw new PSQLException("postgresql.geo.circle", s);
-
- try
- {
- center = new PGpoint(t.getToken(0));
- radius = Double.valueOf(t.getToken(1)).doubleValue();
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.geo.circle", e);
- }
- }
-
- /*
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
- public boolean equals(Object obj)
- {
- if (obj instanceof PGcircle)
- {
- PGcircle p = (PGcircle)obj;
- return p.center.equals(center) && p.radius == radius;
- }
- return false;
- }
-
- /*
- * This must be overidden to allow the object to be cloned
- */
- public Object clone()
- {
- return new PGcircle((PGpoint)center.clone(), radius);
- }
-
- /*
- * @return the PGcircle in the syntax expected by org.postgresql
- */
- public String getValue()
- {
- return "<" + center + "," + radius + ">";
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGline.java b/src/interfaces/jdbc/org/postgresql/geometric/PGline.java
deleted file mode 100644
index e91f416be22..00000000000
--- a/src/interfaces/jdbc/org/postgresql/geometric/PGline.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.postgresql.geometric;
-
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-/*
- * This implements a line consisting of two points.
- *
- * Currently line is not yet implemented in the backend, but this class
- * ensures that when it's done were ready for it.
- */
-public class PGline extends PGobject implements Serializable, Cloneable
-{
- /*
- * These are the two points.
- */
- public PGpoint point[] = new PGpoint[2];
-
- /*
- * @param x1 coordinate for first point
- * @param y1 coordinate for first point
- * @param x2 coordinate for second point
- * @param y2 coordinate for second point
- */
- public PGline(double x1, double y1, double x2, double y2)
- {
- this(new PGpoint(x1, y1), new PGpoint(x2, y2));
- }
-
- /*
- * @param p1 first point
- * @param p2 second point
- */
- public PGline(PGpoint p1, PGpoint p2)
- {
- this();
- this.point[0] = p1;
- this.point[1] = p2;
- }
-
- /*
- * @param s definition of the circle in PostgreSQL's syntax.
- * @exception SQLException on conversion failure
- */
- public PGline(String s) throws SQLException
- {
- this();
- setValue(s);
- }
-
- /*
- * reuired by the driver
- */
- public PGline()
- {
- setType("line");
- }
-
- /*
- * @param s Definition of the line segment in PostgreSQL's syntax
- * @exception SQLException on conversion failure
- */
- public void setValue(String s) throws SQLException
- {
- PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ',');
- if (t.getSize() != 2)
- throw new PSQLException("postgresql.geo.line", s);
-
- point[0] = new PGpoint(t.getToken(0));
- point[1] = new PGpoint(t.getToken(1));
- }
-
- /*
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
- public boolean equals(Object obj)
- {
- if (obj instanceof PGline)
- {
- PGline p = (PGline)obj;
- return (p.point[0].equals(point[0]) && p.point[1].equals(point[1])) ||
- (p.point[0].equals(point[1]) && p.point[1].equals(point[0]));
- }
- return false;
- }
-
- /*
- * This must be overidden to allow the object to be cloned
- */
- public Object clone()
- {
- return new PGline((PGpoint)point[0].clone(), (PGpoint)point[1].clone());
- }
-
- /*
- * @return the PGline in the syntax expected by org.postgresql
- */
- public String getValue()
- {
- return "[" + point[0] + "," + point[1] + "]";
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGlseg.java b/src/interfaces/jdbc/org/postgresql/geometric/PGlseg.java
deleted file mode 100644
index 6d5af7e7d7b..00000000000
--- a/src/interfaces/jdbc/org/postgresql/geometric/PGlseg.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.postgresql.geometric;
-
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-/*
- * This implements a lseg (line segment) consisting of two points
- */
-public class PGlseg extends PGobject implements Serializable, Cloneable
-{
- /*
- * These are the two points.
- */
- public PGpoint point[] = new PGpoint[2];
-
- /*
- * @param x1 coordinate for first point
- * @param y1 coordinate for first point
- * @param x2 coordinate for second point
- * @param y2 coordinate for second point
- */
- public PGlseg(double x1, double y1, double x2, double y2)
- {
- this(new PGpoint(x1, y1), new PGpoint(x2, y2));
- }
-
- /*
- * @param p1 first point
- * @param p2 second point
- */
- public PGlseg(PGpoint p1, PGpoint p2)
- {
- this();
- this.point[0] = p1;
- this.point[1] = p2;
- }
-
- /*
- * @param s definition of the circle in PostgreSQL's syntax.
- * @exception SQLException on conversion failure
- */
- public PGlseg(String s) throws SQLException
- {
- this();
- setValue(s);
- }
-
- /*
- * reuired by the driver
- */
- public PGlseg()
- {
- setType("lseg");
- }
-
- /*
- * @param s Definition of the line segment in PostgreSQL's syntax
- * @exception SQLException on conversion failure
- */
- public void setValue(String s) throws SQLException
- {
- PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ',');
- if (t.getSize() != 2)
- throw new PSQLException("postgresql.geo.lseg");
-
- point[0] = new PGpoint(t.getToken(0));
- point[1] = new PGpoint(t.getToken(1));
- }
-
- /*
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
- public boolean equals(Object obj)
- {
- if (obj instanceof PGlseg)
- {
- PGlseg p = (PGlseg)obj;
- return (p.point[0].equals(point[0]) && p.point[1].equals(point[1])) ||
- (p.point[0].equals(point[1]) && p.point[1].equals(point[0]));
- }
- return false;
- }
-
- /*
- * This must be overidden to allow the object to be cloned
- */
- public Object clone()
- {
- return new PGlseg((PGpoint)point[0].clone(), (PGpoint)point[1].clone());
- }
-
- /*
- * @return the PGlseg in the syntax expected by org.postgresql
- */
- public String getValue()
- {
- return "[" + point[0] + "," + point[1] + "]";
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGpath.java b/src/interfaces/jdbc/org/postgresql/geometric/PGpath.java
deleted file mode 100644
index 60a4c924883..00000000000
--- a/src/interfaces/jdbc/org/postgresql/geometric/PGpath.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package org.postgresql.geometric;
-
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-/*
- * This implements a path (a multiple segmented line, which may be closed)
- */
-public class PGpath extends PGobject implements Serializable, Cloneable
-{
- /*
- * True if the path is open, false if closed
- */
- public boolean open;
-
- /*
- * The points defining this path
- */
- public PGpoint points[];
-
- /*
- * @param points the PGpoints that define the path
- * @param open True if the path is open, false if closed
- */
- public PGpath(PGpoint[] points, boolean open)
- {
- this();
- this.points = points;
- this.open = open;
- }
-
- /*
- * Required by the driver
- */
- public PGpath()
- {
- setType("path");
- }
-
- /*
- * @param s definition of the circle in PostgreSQL's syntax.
- * @exception SQLException on conversion failure
- */
- public PGpath(String s) throws SQLException
- {
- this();
- setValue(s);
- }
-
- /*
- * @param s Definition of the path in PostgreSQL's syntax
- * @exception SQLException on conversion failure
- */
- public void setValue(String s) throws SQLException
- {
- // First test to see if were open
- if (s.startsWith("[") && s.endsWith("]"))
- {
- open = true;
- s = PGtokenizer.removeBox(s);
- }
- else if (s.startsWith("(") && s.endsWith(")"))
- {
- open = false;
- s = PGtokenizer.removePara(s);
- }
- else
- throw new PSQLException("postgresql.geo.path");
-
- PGtokenizer t = new PGtokenizer(s, ',');
- int npoints = t.getSize();
- points = new PGpoint[npoints];
- for (int p = 0;p < npoints;p++)
- points[p] = new PGpoint(t.getToken(p));
- }
-
- /*
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
- public boolean equals(Object obj)
- {
- if (obj instanceof PGpath)
- {
- PGpath p = (PGpath)obj;
-
- if (p.points.length != points.length)
- return false;
-
- if (p.open != open)
- return false;
-
- for (int i = 0;i < points.length;i++)
- if (!points[i].equals(p.points[i]))
- return false;
-
- return true;
- }
- return false;
- }
-
- /*
- * This must be overidden to allow the object to be cloned
- */
- public Object clone()
- {
- PGpoint ary[] = new PGpoint[points.length];
- for (int i = 0;i < points.length;i++)
- ary[i] = (PGpoint)points[i].clone();
- return new PGpath(ary, open);
- }
-
- /*
- * This returns the polygon in the syntax expected by org.postgresql
- */
- public String getValue()
- {
- StringBuffer b = new StringBuffer(open ? "[" : "(");
-
- for (int p = 0;p < points.length;p++)
- {
- if (p > 0)
- b.append(",");
- b.append(points[p].toString());
- }
- b.append(open ? "]" : ")");
-
- return b.toString();
- }
-
- public boolean isOpen()
- {
- return open;
- }
-
- public boolean isClosed()
- {
- return !open;
- }
-
- public void closePath()
- {
- open = false;
- }
-
- public void openPath()
- {
- open = true;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGpoint.java b/src/interfaces/jdbc/org/postgresql/geometric/PGpoint.java
deleted file mode 100644
index c7df1362bed..00000000000
--- a/src/interfaces/jdbc/org/postgresql/geometric/PGpoint.java
+++ /dev/null
@@ -1,171 +0,0 @@
-package org.postgresql.geometric;
-
-import java.awt.Point;
-import java.io.*;
-import java.sql.*;
-
-import org.postgresql.util.*;
-
-/*
- * This implements a version of java.awt.Point, except it uses double
- * to represent the coordinates.
- *
- * <p>It maps to the point datatype in org.postgresql.
- */
-public class PGpoint extends PGobject implements Serializable, Cloneable
-{
- /*
- * The X coordinate of the point
- */
- public double x;
-
- /*
- * The Y coordinate of the point
- */
- public double y;
-
- /*
- * @param x coordinate
- * @param y coordinate
- */
- public PGpoint(double x, double y)
- {
- this();
- this.x = x;
- this.y = y;
- }
-
- /*
- * This is called mainly from the other geometric types, when a
- * point is imbeded within their definition.
- *
- * @param value Definition of this point in PostgreSQL's syntax
- */
- public PGpoint(String value) throws SQLException
- {
- this();
- setValue(value);
- }
-
- /*
- * Required by the driver
- */
- public PGpoint()
- {
- setType("point");
- }
-
- /*
- * @param s Definition of this point in PostgreSQL's syntax
- * @exception SQLException on conversion failure
- */
- public void setValue(String s) throws SQLException
- {
- PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ',');
- try
- {
- x = Double.valueOf(t.getToken(0)).doubleValue();
- y = Double.valueOf(t.getToken(1)).doubleValue();
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.geo.point", e.toString());
- }
- }
-
- /*
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
- public boolean equals(Object obj)
- {
- if (obj instanceof PGpoint)
- {
- PGpoint p = (PGpoint)obj;
- return x == p.x && y == p.y;
- }
- return false;
- }
-
- /*
- * This must be overidden to allow the object to be cloned
- */
- public Object clone()
- {
- return new PGpoint(x, y);
- }
-
- /*
- * @return the PGpoint in the syntax expected by org.postgresql
- */
- public String getValue()
- {
- return "(" + x + "," + y + ")";
- }
-
- /*
- * Translate the point with the supplied amount.
- * @param x integer amount to add on the x axis
- * @param y integer amount to add on the y axis
- */
- public void translate(int x, int y)
- {
- translate((double)x, (double)y);
- }
-
- /*
- * Translate the point with the supplied amount.
- * @param x double amount to add on the x axis
- * @param y double amount to add on the y axis
- */
- public void translate(double x, double y)
- {
- this.x += x;
- this.y += y;
- }
-
- /*
- * Moves the point to the supplied coordinates.
- * @param x integer coordinate
- * @param y integer coordinate
- */
- public void move(int x, int y)
- {
- setLocation(x, y);
- }
-
- /*
- * Moves the point to the supplied coordinates.
- * @param x double coordinate
- * @param y double coordinate
- */
- public void move(double x, double y)
- {
- this.x = x;
- this.y = y;
- }
-
- /*
- * Moves the point to the supplied coordinates.
- * refer to java.awt.Point for description of this
- * @param x integer coordinate
- * @param y integer coordinate
- * @see java.awt.Point
- */
- public void setLocation(int x, int y)
- {
- move((double)x, (double)y);
- }
-
- /*
- * Moves the point to the supplied java.awt.Point
- * refer to java.awt.Point for description of this
- * @param p Point to move to
- * @see java.awt.Point
- */
- public void setLocation(Point p)
- {
- setLocation(p.x, p.y);
- }
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGpolygon.java b/src/interfaces/jdbc/org/postgresql/geometric/PGpolygon.java
deleted file mode 100644
index 5ae18ed3f4d..00000000000
--- a/src/interfaces/jdbc/org/postgresql/geometric/PGpolygon.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.postgresql.geometric;
-
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-/*
- * This implements the polygon datatype within PostgreSQL.
- */
-public class PGpolygon extends PGobject implements Serializable, Cloneable
-{
- /*
- * The points defining the polygon
- */
- public PGpoint points[];
-
- /*
- * Creates a polygon using an array of PGpoints
- *
- * @param points the points defining the polygon
- */
- public PGpolygon(PGpoint[] points)
- {
- this();
- this.points = points;
- }
-
- /*
- * @param s definition of the circle in PostgreSQL's syntax.
- * @exception SQLException on conversion failure
- */
- public PGpolygon(String s) throws SQLException
- {
- this();
- setValue(s);
- }
-
- /*
- * Required by the driver
- */
- public PGpolygon()
- {
- setType("polygon");
- }
-
- /*
- * @param s Definition of the polygon in PostgreSQL's syntax
- * @exception SQLException on conversion failure
- */
- public void setValue(String s) throws SQLException
- {
- PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ',');
- int npoints = t.getSize();
- points = new PGpoint[npoints];
- for (int p = 0;p < npoints;p++)
- points[p] = new PGpoint(t.getToken(p));
- }
-
- /*
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
- public boolean equals(Object obj)
- {
- if (obj instanceof PGpolygon)
- {
- PGpolygon p = (PGpolygon)obj;
-
- if (p.points.length != points.length)
- return false;
-
- for (int i = 0;i < points.length;i++)
- if (!points[i].equals(p.points[i]))
- return false;
-
- return true;
- }
- return false;
- }
-
- /*
- * This must be overidden to allow the object to be cloned
- */
- public Object clone()
- {
- PGpoint ary[] = new PGpoint[points.length];
- for (int i = 0;i < points.length;i++)
- ary[i] = (PGpoint)points[i].clone();
- return new PGpolygon(ary);
- }
-
- /*
- * @return the PGpolygon in the syntax expected by org.postgresql
- */
- public String getValue()
- {
- StringBuffer b = new StringBuffer();
- b.append("(");
- for (int p = 0;p < points.length;p++)
- {
- if (p > 0)
- b.append(",");
- b.append(points[p].toString());
- }
- b.append(")");
- return b.toString();
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/CallableStatement.java b/src/interfaces/jdbc/org/postgresql/jdbc1/CallableStatement.java
deleted file mode 100644
index 4a006cd2208..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/CallableStatement.java
+++ /dev/null
@@ -1,322 +0,0 @@
-package org.postgresql.jdbc1;
-
-// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 2 class in the
-// org.postgresql.jdbc2 package.
-
-import java.sql.*;
-import java.math.*;
-
-/*
- * CallableStatement is used to execute SQL stored procedures.
- *
- * <p>JDBC provides a stored procedure SQL escape that allows stored
- * procedures to be called in a standard way for all RDBMS's. This escape
- * syntax has one form that includes a result parameter and one that does
- * not. If used, the result parameter must be registered as an OUT
- * parameter. The other parameters may be used for input, output or both.
- * Parameters are refered to sequentially, by number. The first parameter
- * is 1.
- *
- * {?= call <procedure-name>[<arg1>,<arg2>, ...]}
- * {call <procedure-name>[<arg1>,<arg2>, ...]}
- *
- *
- * <p>IN parameter values are set using the set methods inherited from
- * PreparedStatement. The type of all OUT parameters must be registered
- * prior to executing the stored procedure; their values are retrieved
- * after execution via the get methods provided here.
- *
- * <p>A Callable statement may return a ResultSet or multiple ResultSets.
- * Multiple ResultSets are handled using operations inherited from
- * Statement.
- *
- * <p>For maximum portability, a call's ResultSets and update counts should
- * be processed prior to getting the values of output parameters.
- *
- * @see Connection#prepareCall
- * @see ResultSet
- */
-
-public class CallableStatement extends PreparedStatement implements java.sql.CallableStatement
-{
- /*
- * @exception SQLException on failure
- */
- CallableStatement(Connection c, String q) throws SQLException
- {
- super(c, q);
- }
-
- /*
- * Before executing a stored procedure call you must explicitly
- * call registerOutParameter to register the java.sql.Type of each
- * out parameter.
- *
- * <p>Note: When reading the value of an out parameter, you must use
- * the getXXX method whose Java type XXX corresponds to the
- * parameter's registered SQL type.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @param sqlType SQL type code defined by java.sql.Types; for
- * parameters of type Numeric or Decimal use the version of
- * registerOutParameter that accepts a scale value
- * @exception SQLException if a database-access error occurs.
- */
- public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException
- {}
-
- /*
- * You must also specify the scale for numeric/decimal types:
- *
- * <p>Note: When reading the value of an out parameter, you must use
- * the getXXX method whose Java type XXX corresponds to the
- * parameter's registered SQL type.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @param sqlType use either java.sql.Type.NUMERIC or java.sql.Type.DECIMAL
- * @param scale a value greater than or equal to zero representing the
- * desired number of digits to the right of the decimal point
- * @exception SQLException if a database-access error occurs.
- */
- public void registerOutParameter(int parameterIndex, int sqlType,
- int scale) throws SQLException
- {}
-
- // Old api?
- //public boolean isNull(int parameterIndex) throws SQLException {
- //return true;
- //}
-
- /*
- * An OUT parameter may have the value of SQL NULL; wasNull
- * reports whether the last value read has this special value.
- *
- * <p>Note: You must first call getXXX on a parameter to read its
- * value and then call wasNull() to see if the value was SQL NULL.
- * @return true if the last parameter read was SQL NULL
- * @exception SQLException if a database-access error occurs.
- */
- public boolean wasNull() throws SQLException
- {
- // check to see if the last access threw an exception
- return false; // fake it for now
- }
-
- // Old api?
- //public String getChar(int parameterIndex) throws SQLException {
- //return null;
- //}
-
- /*
- * Get the value of a CHAR, VARCHAR, or LONGVARCHAR parameter as a
- * Java String.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public String getString(int parameterIndex) throws SQLException
- {
- return null;
- }
- //public String getVarChar(int parameterIndex) throws SQLException {
- // return null;
- //}
-
- //public String getLongVarChar(int parameterIndex) throws SQLException {
- //return null;
- //}
-
- /*
- * Get the value of a BIT parameter as a Java boolean.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is false
- * @exception SQLException if a database-access error occurs.
- */
- public boolean getBoolean(int parameterIndex) throws SQLException
- {
- return false;
- }
-
- /*
- * Get the value of a TINYINT parameter as a Java byte.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public byte getByte(int parameterIndex) throws SQLException
- {
- return 0;
- }
-
- /*
- * Get the value of a SMALLINT parameter as a Java short.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public short getShort(int parameterIndex) throws SQLException
- {
- return 0;
- }
-
- /*
- * Get the value of an INTEGER parameter as a Java int.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public int getInt(int parameterIndex) throws SQLException
- {
- return 0;
- }
-
- /*
- * Get the value of a BIGINT parameter as a Java long.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public long getLong(int parameterIndex) throws SQLException
- {
- return 0;
- }
-
- /*
- * Get the value of a FLOAT parameter as a Java float.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public float getFloat(int parameterIndex) throws SQLException
- {
- return (float) 0.0;
- }
-
- /*
- * Get the value of a DOUBLE parameter as a Java double.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public double getDouble(int parameterIndex) throws SQLException
- {
- return 0.0;
- }
-
- /*
- * Get the value of a NUMERIC parameter as a java.math.BigDecimal
- * object.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @param scale a value greater than or equal to zero representing the
- * desired number of digits to the right of the decimal point
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public BigDecimal getBigDecimal(int parameterIndex, int scale)
- throws SQLException
- {
- return null;
- }
-
- /*
- * Get the value of a SQL BINARY or VARBINARY parameter as a Java
- * byte[]
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public byte[] getBytes(int parameterIndex) throws SQLException
- {
- return null;
- }
-
- // New API (JPM) (getLongVarBinary)
- //public byte[] getBinaryStream(int parameterIndex) throws SQLException {
- //return null;
- //}
-
- /*
- * Get the value of a SQL DATE parameter as a java.sql.Date object
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public java.sql.Date getDate(int parameterIndex) throws SQLException
- {
- return null;
- }
-
- /*
- * Get the value of a SQL TIME parameter as a java.sql.Time object.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public java.sql.Time getTime(int parameterIndex) throws SQLException
- {
- return null;
- }
-
- /*
- * Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public java.sql.Timestamp getTimestamp(int parameterIndex)
- throws SQLException
- {
- return null;
- }
-
- //----------------------------------------------------------------------
- // Advanced features:
-
- // You can obtain a ParameterMetaData object to get information
- // about the parameters to this CallableStatement.
- //public DatabaseMetaData getMetaData() {
- //return null;
- //}
-
- // getObject returns a Java object for the parameter.
- // See the JDBC spec's "Dynamic Programming" chapter for details.
- /*
- * Get the value of a parameter as a Java object.
- *
- * <p>This method returns a Java object whose type coresponds to the
- * SQL type that was registered for this parameter using
- * registerOutParameter.
- *
- * <P>Note that this method may be used to read datatabase-specific,
- * abstract data types. This is done by specifying a targetSqlType
- * of java.sql.types.OTHER, which allows the driver to return a
- * database-specific Java type.
- *
- * <p>See the JDBC spec's "Dynamic Programming" chapter for details.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return A java.lang.Object holding the OUT parameter value.
- * @exception SQLException if a database-access error occurs.
- */
- public Object getObject(int parameterIndex)
- throws SQLException
- {
- return null;
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java b/src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java
deleted file mode 100644
index 4d3e087f76b..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java
+++ /dev/null
@@ -1,214 +0,0 @@
-package org.postgresql.jdbc1;
-
-// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 2 class in the
-// org.postgresql.jdbc2 package.
-
-import java.io.*;
-import java.lang.*;
-import java.lang.reflect.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.Field;
-import org.postgresql.fastpath.*;
-import org.postgresql.largeobject.*;
-import org.postgresql.util.*;
-
-/*
- * $Id: Connection.java,v 1.15 2002/01/15 06:55:13 barry Exp $
- *
- * A Connection represents a session with a specific database. Within the
- * context of a Connection, SQL statements are executed and results are
- * returned.
- *
- * <P>A Connection's database is able to provide information describing
- * its tables, its supported SQL grammar, its stored procedures, the
- * capabilities of this connection, etc. This information is obtained
- * with the getMetaData method.
- *
- * <p><B>Note:</B> By default, the Connection automatically commits changes
- * after executing each statement. If auto-commit has been disabled, an
- * explicit commit must be done or database changes will not be saved.
- *
- * @see java.sql.Connection
- */
-public class Connection extends org.postgresql.Connection implements java.sql.Connection
-{
- // This is a cache of the DatabaseMetaData instance for this connection
- protected DatabaseMetaData metadata;
-
- /*
- * SQL statements without parameters are normally executed using
- * Statement objects. If the same SQL statement is executed many
- * times, it is more efficient to use a PreparedStatement
- *
- * @return a new Statement object
- * @exception SQLException passed through from the constructor
- */
- public java.sql.Statement createStatement() throws SQLException
- {
- return new Statement(this);
- }
-
- /*
- * A SQL statement with or without IN parameters can be pre-compiled
- * and stored in a PreparedStatement object. This object can then
- * be used to efficiently execute this statement multiple times.
- *
- * <B>Note:</B> This method is optimized for handling parametric
- * SQL statements that benefit from precompilation if the drivers
- * supports precompilation. PostgreSQL does not support precompilation.
- * In this case, the statement is not sent to the database until the
- * PreparedStatement is executed. This has no direct effect on users;
- * however it does affect which method throws certain SQLExceptions
- *
- * @param sql a SQL statement that may contain one or more '?' IN
- * parameter placeholders
- * @return a new PreparedStatement object containing the pre-compiled
- * statement.
- * @exception SQLException if a database access error occurs.
- */
- public java.sql.PreparedStatement prepareStatement(String sql) throws SQLException
- {
- return new PreparedStatement(this, sql);
- }
-
- /*
- * A SQL stored procedure call statement is handled by creating a
- * CallableStatement for it. The CallableStatement provides methods
- * for setting up its IN and OUT parameters and methods for executing
- * it.
- *
- * <B>Note:</B> This method is optimised for handling stored procedure
- * call statements. Some drivers may send the call statement to the
- * database when the prepareCall is done; others may wait until the
- * CallableStatement is executed. This has no direct effect on users;
- * however, it does affect which method throws certain SQLExceptions
- *
- * @param sql a SQL statement that may contain one or more '?' parameter
- * placeholders. Typically this statement is a JDBC function call
- * escape string.
- * @return a new CallableStatement object containing the pre-compiled
- * SQL statement
- * @exception SQLException if a database access error occurs
- */
- public java.sql.CallableStatement prepareCall(String sql) throws SQLException
- {
- throw new PSQLException("postgresql.con.call");
- // return new CallableStatement(this, sql);
- }
-
- /*
- * Tests to see if a Connection is closed
- *
- * @return the status of the connection
- * @exception SQLException (why?)
- */
- public boolean isClosed() throws SQLException
- {
- return (pg_stream == null);
- }
-
- /*
- * A connection's database is able to provide information describing
- * its tables, its supported SQL grammar, its stored procedures, the
- * capabilities of this connection, etc. This information is made
- * available through a DatabaseMetaData object.
- *
- * @return a DatabaseMetaData object for this connection
- * @exception SQLException if a database access error occurs
- */
- public java.sql.DatabaseMetaData getMetaData() throws SQLException
- {
- if (metadata == null)
- metadata = new DatabaseMetaData(this);
- return metadata;
- }
-
- /*
- * This overides the method in org.postgresql.Connection and returns a
- * ResultSet.
- */
- public java.sql.ResultSet getResultSet(org.postgresql.Connection conn, java.sql.Statement stat, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
- {
- // in jdbc1 stat is ignored.
- return new org.postgresql.jdbc1.ResultSet((org.postgresql.jdbc1.Connection)conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
- }
-
-
- /* An implementation of the abstract method in the parent class.
- * This implemetation uses the jdbc1Types array to support the jdbc1
- * datatypes. Basically jdbc1 and jdbc2 are the same, except that
- * jdbc2 adds the Array types.
- */
- public int getSQLType(String pgTypeName)
- {
- int sqlType = Types.OTHER; // default value
- for (int i = 0;i < jdbc1Types.length;i++)
- {
- if (pgTypeName.equals(jdbc1Types[i]))
- {
- sqlType = jdbc1Typei[i];
- break;
- }
- }
- return sqlType;
- }
-
- /*
- * This table holds the org.postgresql names for the types supported.
- * Any types that map to Types.OTHER (eg POINT) don't go into this table.
- * They default automatically to Types.OTHER
- *
- * Note: This must be in the same order as below.
- *
- * Tip: keep these grouped together by the Types. value
- */
- private static final String jdbc1Types[] = {
- "int2",
- "int4", "oid",
- "int8",
- "cash", "money",
- "numeric",
- "float4",
- "float8",
- "bpchar", "char", "char2", "char4", "char8", "char16",
- "varchar", "text", "name", "filename",
- "bytea",
- "bool",
- "date",
- "time",
- "abstime", "timestamp", "timestamptz"
- };
-
- /*
- * This table holds the JDBC type for each entry above.
- *
- * Note: This must be in the same order as above
- *
- * Tip: keep these grouped together by the Types. value
- */
- private static final int jdbc1Typei[] = {
- Types.SMALLINT,
- Types.INTEGER, Types.INTEGER,
- Types.BIGINT,
- Types.DOUBLE, Types.DOUBLE,
- Types.NUMERIC,
- Types.REAL,
- Types.DOUBLE,
- Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR,
- Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
- Types.BINARY,
- Types.BIT,
- Types.DATE,
- Types.TIME,
- Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP
- };
-
-
-}
-
-// ***********************************************************************
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
deleted file mode 100644
index 5fba1d68c00..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
+++ /dev/null
@@ -1,2838 +0,0 @@
-package org.postgresql.jdbc1;
-
-// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 2 class in the
-// org.postgresql.jdbc2 package.
-
-import java.sql.*;
-import java.util.*;
-import org.postgresql.Field;
-import org.postgresql.util.PSQLException;
-
-/*
- * This class provides information about the database as a whole.
- *
- * $Id: DatabaseMetaData.java,v 1.47 2002/06/20 16:00:44 momjian Exp $
- *
- * <p>Many of the methods here return lists of information in ResultSets. You
- * can use the normal ResultSet methods such as getString and getInt to
- * retrieve the data from these ResultSets. If a given form of metadata is
- * not available, these methods should throw a SQLException.
- *
- * <p>Some of these methods take arguments that are String patterns. These
- * arguments all have names such as fooPattern. Within a pattern String,
- * "%" means match any substring of 0 or more characters, and "_" means
- * match any one character. Only metadata entries matching the search
- * pattern are returned. if a search pattern argument is set to a null
- * ref, it means that argument's criteria should be dropped from the
- * search.
- *
- * <p>A SQLException will be throws if a driver does not support a meta
- * data method. In the case of methods that return a ResultSet, either
- * a ResultSet (which may be empty) is returned or a SQLException is
- * thrown.
- *
- * @see java.sql.DatabaseMetaData
- */
-public class DatabaseMetaData implements java.sql.DatabaseMetaData
-{
- Connection connection; // The connection association
-
- // These define various OID's. Hopefully they will stay constant.
- static final int iVarcharOid = 1043; // OID for varchar
- static final int iBoolOid = 16; // OID for bool
- static final int iInt2Oid = 21; // OID for int2
- static final int iInt4Oid = 23; // OID for int4
- static final int VARHDRSZ = 4; // length for int4
-
- public DatabaseMetaData(Connection conn)
- {
- this.connection = conn;
- }
-
- /*
- * Can all the procedures returned by getProcedures be called
- * by the current user?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean allProceduresAreCallable() throws SQLException
- {
- return true; // For now...
- }
-
- /*
- * Can all the tables returned by getTable be SELECTed by
- * the current user?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean allTablesAreSelectable() throws SQLException
- {
- return true; // For now...
- }
-
- /*
- * What is the URL for this database?
- *
- * @return the url or null if it cannott be generated
- * @exception SQLException if a database access error occurs
- */
- public String getURL() throws SQLException
- {
- return connection.getURL();
- }
-
- /*
- * What is our user name as known to the database?
- *
- * @return our database user name
- * @exception SQLException if a database access error occurs
- */
- public String getUserName() throws SQLException
- {
- return connection.getUserName();
- }
-
- /*
- * Is the database in read-only mode?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isReadOnly() throws SQLException
- {
- return connection.isReadOnly();
- }
-
- /*
- * Are NULL values sorted high?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullsAreSortedHigh() throws SQLException
- {
- return connection.haveMinimumServerVersion("7.2");
- }
-
- /*
- * Are NULL values sorted low?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullsAreSortedLow() throws SQLException
- {
- return false;
- }
-
- /*
- * Are NULL values sorted at the start regardless of sort order?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullsAreSortedAtStart() throws SQLException
- {
- return false;
- }
-
- /*
- * Are NULL values sorted at the end regardless of sort order?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullsAreSortedAtEnd() throws SQLException
- {
- return ! connection.haveMinimumServerVersion("7.2");
- }
-
- /*
- * What is the name of this database product - we hope that it is
- * PostgreSQL, so we return that explicitly.
- *
- * @return the database product name
- * @exception SQLException if a database access error occurs
- */
- public String getDatabaseProductName() throws SQLException
- {
- return "PostgreSQL";
- }
-
- /*
- * What is the version of this database product.
- *
- * @return the database version
- * @exception SQLException if a database access error occurs
- */
- public String getDatabaseProductVersion() throws SQLException
- {
- return connection.getDBVersionNumber();
- }
-
- /*
- * What is the name of this JDBC driver? If we don't know this
- * we are doing something wrong!
- *
- * @return the JDBC driver name
- * @exception SQLException why?
- */
- public String getDriverName() throws SQLException
- {
- return "PostgreSQL Native Driver";
- }
-
- /*
- * What is the version string of this JDBC driver? Again, this is
- * static.
- *
- * @return the JDBC driver name.
- * @exception SQLException why?
- */
- public String getDriverVersion() throws SQLException
- {
- return connection.this_driver.getVersion();
- }
-
- /*
- * What is this JDBC driver's major version number?
- *
- * @return the JDBC driver major version
- */
- public int getDriverMajorVersion()
- {
- return connection.this_driver.getMajorVersion();
- }
-
- /*
- * What is this JDBC driver's minor version number?
- *
- * @return the JDBC driver minor version
- */
- public int getDriverMinorVersion()
- {
- return connection.this_driver.getMinorVersion();
- }
-
- /*
- * Does the database store tables in a local file? No - it
- * stores them in a file on the server.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean usesLocalFiles() throws SQLException
- {
- return false;
- }
-
- /*
- * Does the database use a file for each table? Well, not really,
- * since it doesnt use local files.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean usesLocalFilePerTable() throws SQLException
- {
- return false;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers
- * as case sensitive and as a result store them in mixed case?
- * A JDBC-Compliant driver will always return false.
- *
- * <p>Predicament - what do they mean by "SQL identifiers" - if it
- * means the names of the tables and columns, then the answers
- * given below are correct - otherwise I don't know.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMixedCaseIdentifiers() throws SQLException
- {
- return false;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers as
- * case insensitive and store them in upper case?
- *
- * @return true if so
- */
- public boolean storesUpperCaseIdentifiers() throws SQLException
- {
- return false;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers as
- * case insensitive and store them in lower case?
- *
- * @return true if so
- */
- public boolean storesLowerCaseIdentifiers() throws SQLException
- {
- return true;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers as
- * case insensitive and store them in mixed case?
- *
- * @return true if so
- */
- public boolean storesMixedCaseIdentifiers() throws SQLException
- {
- return false;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as
- * case sensitive and as a result store them in mixed case? A
- * JDBC compliant driver will always return true.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException
- {
- return true;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as
- * case insensitive and store them in upper case?
- *
- * @return true if so
- */
- public boolean storesUpperCaseQuotedIdentifiers() throws SQLException
- {
- return false;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as case
- * insensitive and store them in lower case?
- *
- * @return true if so
- */
- public boolean storesLowerCaseQuotedIdentifiers() throws SQLException
- {
- return false;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as case
- * insensitive and store them in mixed case?
- *
- * @return true if so
- */
- public boolean storesMixedCaseQuotedIdentifiers() throws SQLException
- {
- return false;
- }
-
- /*
- * What is the string used to quote SQL identifiers? This returns
- * a space if identifier quoting isn't supported. A JDBC Compliant
- * driver will always use a double quote character.
- *
- * @return the quoting string
- * @exception SQLException if a database access error occurs
- */
- public String getIdentifierQuoteString() throws SQLException
- {
- return "\"";
- }
-
- /*
- * Get a comma separated list of all a database's SQL keywords that
- * are NOT also SQL92 keywords.
- *
- * <p>Within PostgreSQL, the keywords are found in
- * src/backend/parser/keywords.c
- *
- * <p>For SQL Keywords, I took the list provided at
- * <a href="http://web.dementia.org/~shadow/sql/sql3bnf.sep93.txt">
- * http://web.dementia.org/~shadow/sql/sql3bnf.sep93.txt</a>
- * which is for SQL3, not SQL-92, but it is close enough for
- * this purpose.
- *
- * @return a comma separated list of keywords we use
- * @exception SQLException if a database access error occurs
- */
- public String getSQLKeywords() throws SQLException
- {
- return "abort,acl,add,aggregate,append,archive,arch_store,backward,binary,change,cluster,copy,database,delimiter,delimiters,do,extend,explain,forward,heavy,index,inherits,isnull,light,listen,load,merge,nothing,notify,notnull,oids,purge,rename,replace,retrieve,returns,rule,recipe,setof,stdin,stdout,store,vacuum,verbose,version";
- }
-
- public String getNumericFunctions() throws SQLException
- {
- // XXX-Not Implemented
- return "";
- }
-
- public String getStringFunctions() throws SQLException
- {
- // XXX-Not Implemented
- return "";
- }
-
- public String getSystemFunctions() throws SQLException
- {
- // XXX-Not Implemented
- return "";
- }
-
- public String getTimeDateFunctions() throws SQLException
- {
- // XXX-Not Implemented
- return "";
- }
-
- /*
- * This is the string that can be used to escape '_' and '%' in
- * a search string pattern style catalog search parameters
- *
- * @return the string used to escape wildcard characters
- * @exception SQLException if a database access error occurs
- */
- public String getSearchStringEscape() throws SQLException
- {
- return "\\";
- }
-
- /*
- * Get all the "extra" characters that can be used in unquoted
- * identifier names (those beyond a-zA-Z0-9 and _)
- *
- * <p>From the file src/backend/parser/scan.l, an identifier is
- * {letter}{letter_or_digit} which makes it just those listed
- * above.
- *
- * @return a string containing the extra characters
- * @exception SQLException if a database access error occurs
- */
- public String getExtraNameCharacters() throws SQLException
- {
- return "";
- }
-
- /*
- * Is "ALTER TABLE" with an add column supported?
- * Yes for PostgreSQL 6.1
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsAlterTableWithAddColumn() throws SQLException
- {
- return true;
- }
-
- /*
- * Is "ALTER TABLE" with a drop column supported?
- * Peter 10/10/2000 This was set to true, but 7.1devel doesn't support it!
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsAlterTableWithDropColumn() throws SQLException
- {
- return false;
- }
-
- /*
- * Is column aliasing supported?
- *
- * <p>If so, the SQL AS clause can be used to provide names for
- * computed columns or to provide alias names for columns as
- * required. A JDBC Compliant driver always returns true.
- *
- * <p>e.g.
- *
- * <br><pre>
- * select count(C) as C_COUNT from T group by C;
- *
- * </pre><br>
- * should return a column named as C_COUNT instead of count(C)
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsColumnAliasing() throws SQLException
- {
- return true;
- }
-
- /*
- * Are concatenations between NULL and non-NULL values NULL? A
- * JDBC Compliant driver always returns true
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullPlusNonNullIsNull() throws SQLException
- {
- return true;
- }
-
- public boolean supportsConvert() throws SQLException
- {
- // XXX-Not Implemented
- return false;
- }
-
- public boolean supportsConvert(int fromType, int toType) throws SQLException
- {
- // XXX-Not Implemented
- return false;
- }
-
- /*
- * Are table correlation names supported? A JDBC Compliant
- * driver always returns true.
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsTableCorrelationNames() throws SQLException
- {
- return true;
- }
-
- /*
- * If table correlation names are supported, are they restricted to
- * be different from the names of the tables?
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsDifferentTableCorrelationNames() throws SQLException
- {
- return false;
- }
-
- /*
- * Are expressions in "ORDER BY" lists supported?
- *
- * <br>e.g. select * from t order by a + b;
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsExpressionsInOrderBy() throws SQLException
- {
- return true;
- }
-
- /*
- * Can an "ORDER BY" clause use columns not in the SELECT?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOrderByUnrelated() throws SQLException
- {
- return connection.haveMinimumServerVersion("6.4");
- }
-
- /*
- * Is some form of "GROUP BY" clause supported?
- * I checked it, and yes it is.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsGroupBy() throws SQLException
- {
- return true;
- }
-
- /*
- * Can a "GROUP BY" clause use columns not in the SELECT?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsGroupByUnrelated() throws SQLException
- {
- return connection.haveMinimumServerVersion("6.4");
- }
-
- /*
- * Can a "GROUP BY" clause add columns not in the SELECT provided
- * it specifies all the columns in the SELECT? Does anyone actually
- * understand what they mean here?
- *
- * (I think this is a subset of the previous function. -- petere)
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsGroupByBeyondSelect() throws SQLException
- {
- return supportsGroupByUnrelated();
- }
-
- /*
- * Is the escape character in "LIKE" clauses supported? A
- * JDBC compliant driver always returns true.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsLikeEscapeClause() throws SQLException
- {
- return connection.haveMinimumServerVersion("7.1");
- }
-
- /*
- * Are multiple ResultSets from a single execute supported?
- * Well, I implemented it, but I dont think this is possible from
- * the back ends point of view.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMultipleResultSets() throws SQLException
- {
- return false;
- }
-
- /*
- * Can we have multiple transactions open at once (on different
- * connections?)
- * I guess we can have, since Im relying on it.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMultipleTransactions() throws SQLException
- {
- return true;
- }
-
- /*
- * Can columns be defined as non-nullable. A JDBC Compliant driver
- * always returns true.
- *
- * <p>This changed from false to true in v6.2 of the driver, as this
- * support was added to the backend.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsNonNullableColumns() throws SQLException
- {
- return true;
- }
-
- /*
- * Does this driver support the minimum ODBC SQL grammar. This
- * grammar is defined at:
- *
- * <p><a href="http://www.microsoft.com/msdn/sdk/platforms/doc/odbc/src/intropr.htm">http://www.microsoft.com/msdn/sdk/platforms/doc/odbc/src/intropr.htm</a>
- *
- * <p>In Appendix C. From this description, we seem to support the
- * ODBC minimal (Level 0) grammar.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMinimumSQLGrammar() throws SQLException
- {
- return true;
- }
-
- /*
- * Does this driver support the Core ODBC SQL grammar. We need
- * SQL-92 conformance for this.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCoreSQLGrammar() throws SQLException
- {
- return false;
- }
-
- /*
- * Does this driver support the Extended (Level 2) ODBC SQL
- * grammar. We don't conform to the Core (Level 1), so we can't
- * conform to the Extended SQL Grammar.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsExtendedSQLGrammar() throws SQLException
- {
- return false;
- }
-
- /*
- * Does this driver support the ANSI-92 entry level SQL grammar?
- * All JDBC Compliant drivers must return true. We currently
- * report false until 'schema' support is added. Then this
- * should be changed to return true, since we will be mostly
- * compliant (probably more compliant than many other databases)
- * And since this is a requirement for all JDBC drivers we
- * need to get to the point where we can return true.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsANSI92EntryLevelSQL() throws SQLException
- {
- return false;
- }
-
- /*
- * Does this driver support the ANSI-92 intermediate level SQL
- * grammar?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsANSI92IntermediateSQL() throws SQLException
- {
- return false;
- }
-
- /*
- * Does this driver support the ANSI-92 full SQL grammar?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsANSI92FullSQL() throws SQLException
- {
- return false;
- }
-
- /*
- * Is the SQL Integrity Enhancement Facility supported?
- * I haven't seen this mentioned anywhere, so I guess not
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsIntegrityEnhancementFacility() throws SQLException
- {
- return false;
- }
-
- /*
- * Is some form of outer join supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOuterJoins() throws SQLException
- {
- return connection.haveMinimumServerVersion("7.1");
- }
-
- /*
- * Are full nexted outer joins supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsFullOuterJoins() throws SQLException
- {
- return connection.haveMinimumServerVersion("7.1");
- }
-
- /*
- * Is there limited support for outer joins?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsLimitedOuterJoins() throws SQLException
- {
- return supportsFullOuterJoins();
- }
-
- /*
- * What is the database vendor's preferred term for "schema"?
- * PostgreSQL doesn't have schemas, but when it does, we'll use the
- * term "schema".
- *
- * @return the vendor term
- * @exception SQLException if a database access error occurs
- */
- public String getSchemaTerm() throws SQLException
- {
- return "schema";
- }
-
- /*
- * What is the database vendor's preferred term for "procedure"?
- * Traditionally, "function" has been used.
- *
- * @return the vendor term
- * @exception SQLException if a database access error occurs
- */
- public String getProcedureTerm() throws SQLException
- {
- return "function";
- }
-
- /*
- * What is the database vendor's preferred term for "catalog"?
- *
- * @return the vendor term
- * @exception SQLException if a database access error occurs
- */
- public String getCatalogTerm() throws SQLException
- {
- return "database";
- }
-
- /*
- * Does a catalog appear at the start of a qualified table name?
- * (Otherwise it appears at the end).
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isCatalogAtStart() throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /*
- * What is the Catalog separator.
- *
- * @return the catalog separator string
- * @exception SQLException if a database access error occurs
- */
- public String getCatalogSeparator() throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /*
- * Can a schema name be used in a data manipulation statement? Nope.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInDataManipulation() throws SQLException
- {
- return false;
- }
-
- /*
- * Can a schema name be used in a procedure call statement? Nope.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInProcedureCalls() throws SQLException
- {
- return false;
- }
-
- /*
- * Can a schema be used in a table definition statement? Nope.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInTableDefinitions() throws SQLException
- {
- return false;
- }
-
- /*
- * Can a schema name be used in an index definition statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInIndexDefinitions() throws SQLException
- {
- return false;
- }
-
- /*
- * Can a schema name be used in a privilege definition statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException
- {
- return false;
- }
-
- /*
- * Can a catalog name be used in a data manipulation statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInDataManipulation() throws SQLException
- {
- return false;
- }
-
- /*
- * Can a catalog name be used in a procedure call statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInProcedureCalls() throws SQLException
- {
- return false;
- }
-
- /*
- * Can a catalog name be used in a table definition statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInTableDefinitions() throws SQLException
- {
- return false;
- }
-
- /*
- * Can a catalog name be used in an index definition?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInIndexDefinitions() throws SQLException
- {
- return false;
- }
-
- /*
- * Can a catalog name be used in a privilege definition statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException
- {
- return false;
- }
-
- /*
- * We support cursors for gets only it seems. I dont see a method
- * to get a positioned delete.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsPositionedDelete() throws SQLException
- {
- return false; // For now...
- }
-
- /*
- * Is positioned UPDATE supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsPositionedUpdate() throws SQLException
- {
- return false; // For now...
- }
-
- /*
- * Is SELECT for UPDATE supported?
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSelectForUpdate() throws SQLException
- {
- return connection.haveMinimumServerVersion("6.5");
- }
-
- /*
- * Are stored procedure calls using the stored procedure escape
- * syntax supported?
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsStoredProcedures() throws SQLException
- {
- return false;
- }
-
- /*
- * Are subqueries in comparison expressions supported? A JDBC
- * Compliant driver always returns true.
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSubqueriesInComparisons() throws SQLException
- {
- return true;
- }
-
- /*
- * Are subqueries in 'exists' expressions supported? A JDBC
- * Compliant driver always returns true.
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSubqueriesInExists() throws SQLException
- {
- return true;
- }
-
- /*
- * Are subqueries in 'in' statements supported? A JDBC
- * Compliant driver always returns true.
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSubqueriesInIns() throws SQLException
- {
- return true;
- }
-
- /*
- * Are subqueries in quantified expressions supported? A JDBC
- * Compliant driver always returns true.
- *
- * (No idea what this is, but we support a good deal of
- * subquerying.)
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSubqueriesInQuantifieds() throws SQLException
- {
- return true;
- }
-
- /*
- * Are correlated subqueries supported? A JDBC Compliant driver
- * always returns true.
- *
- * (a.k.a. subselect in from?)
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsCorrelatedSubqueries() throws SQLException
- {
- return connection.haveMinimumServerVersion("7.1");
- }
-
- /*
- * Is SQL UNION supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsUnion() throws SQLException
- {
- return true; // since 6.3
- }
-
- /*
- * Is SQL UNION ALL supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsUnionAll() throws SQLException
- {
- return connection.haveMinimumServerVersion("7.1");
- }
-
- /*
- * In PostgreSQL, Cursors are only open within transactions.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOpenCursorsAcrossCommit() throws SQLException
- {
- return false;
- }
-
- /*
- * Do we support open cursors across multiple transactions?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOpenCursorsAcrossRollback() throws SQLException
- {
- return false;
- }
-
- /*
- * Can statements remain open across commits? They may, but
- * this driver cannot guarentee that. In further reflection.
- * we are talking a Statement object here, so the answer is
- * yes, since the Statement is only a vehicle to ExecSQL()
- *
- * @return true if they always remain open; false otherwise
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOpenStatementsAcrossCommit() throws SQLException
- {
- return true;
- }
-
- /*
- * Can statements remain open across rollbacks? They may, but
- * this driver cannot guarentee that. In further contemplation,
- * we are talking a Statement object here, so the answer is yes,
- * since the Statement is only a vehicle to ExecSQL() in Connection
- *
- * @return true if they always remain open; false otherwise
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOpenStatementsAcrossRollback() throws SQLException
- {
- return true;
- }
-
- /*
- * How many hex characters can you have in an inline binary literal
- *
- * @return the max literal length
- * @exception SQLException if a database access error occurs
- */
- public int getMaxBinaryLiteralLength() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What is the maximum length for a character literal
- * I suppose it is 8190 (8192 - 2 for the quotes)
- *
- * @return the max literal length
- * @exception SQLException if a database access error occurs
- */
- public int getMaxCharLiteralLength() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * Whats the limit on column name length. The description of
- * pg_class would say '32' (length of pg_class.relname) - we
- * should probably do a query for this....but....
- *
- * @return the maximum column name length
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnNameLength() throws SQLException
- {
- return 32;
- }
-
- /*
- * What is the maximum number of columns in a "GROUP BY" clause?
- *
- * @return the max number of columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInGroupBy() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What's the maximum number of columns allowed in an index?
- * 6.0 only allowed one column, but 6.1 introduced multi-column
- * indices, so, theoretically, its all of them.
- *
- * @return max number of columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInIndex() throws SQLException
- {
- return getMaxColumnsInTable();
- }
-
- /*
- * What's the maximum number of columns in an "ORDER BY clause?
- *
- * @return the max columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInOrderBy() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What is the maximum number of columns in a "SELECT" list?
- *
- * @return the max columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInSelect() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What is the maximum number of columns in a table? From the
- * CREATE TABLE reference page...
- *
- * <p>"The new class is created as a heap with no initial data. A
- * class can have no more than 1600 attributes (realistically,
- * this is limited by the fact that tuple sizes must be less than
- * 8192 bytes)..."
- *
- * @return the max columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInTable() throws SQLException
- {
- return 1600;
- }
-
- /*
- * How many active connection can we have at a time to this
- * database? Well, since it depends on postmaster, which just
- * does a listen() followed by an accept() and fork(), its
- * basically very high. Unless the system runs out of processes,
- * it can be 65535 (the number of aux. ports on a TCP/IP system).
- * I will return 8192 since that is what even the largest system
- * can realistically handle,
- *
- * @return the maximum number of connections
- * @exception SQLException if a database access error occurs
- */
- public int getMaxConnections() throws SQLException
- {
- return 8192;
- }
-
- /*
- * What is the maximum cursor name length (the same as all
- * the other F***** identifiers!)
- *
- * @return max cursor name length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxCursorNameLength() throws SQLException
- {
- return 32;
- }
-
- /*
- * Retrieves the maximum number of bytes for an index, including all
- * of the parts of the index.
- *
- * @return max index length in bytes, which includes the composite
- * of all the constituent parts of the index; a result of zero means
- * that there is no limit or the limit is not known
- * @exception SQLException if a database access error occurs
- */
- public int getMaxIndexLength() throws SQLException
- {
- return 0; // no limit (larger than an int anyway)
- }
-
- public int getMaxSchemaNameLength() throws SQLException
- {
- // XXX-Not Implemented
- return 0;
- }
-
- /*
- * What is the maximum length of a procedure name?
- * (length of pg_proc.proname used) - again, I really
- * should do a query here to get it.
- *
- * @return the max name length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxProcedureNameLength() throws SQLException
- {
- return 32;
- }
-
- public int getMaxCatalogNameLength() throws SQLException
- {
- // XXX-Not Implemented
- return 0;
- }
-
- /*
- * What is the maximum length of a single row?
- *
- * @return max row size in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxRowSize() throws SQLException
- {
- if (connection.haveMinimumServerVersion("7.1"))
- return 1073741824; // 1 GB
- else
- return 8192; // XXX could be altered
- }
-
- /*
- * Did getMaxRowSize() include LONGVARCHAR and LONGVARBINARY
- * blobs? We don't handle blobs yet
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean doesMaxRowSizeIncludeBlobs() throws SQLException
- {
- return false;
- }
-
- /*
- * What is the maximum length of a SQL statement?
- *
- * @return max length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxStatementLength() throws SQLException
- {
- if (connection.haveMinimumServerVersion("7.0"))
- return 0; // actually whatever fits in size_t
- else
- return 16384;
- }
-
- /*
- * How many active statements can we have open at one time to
- * this database? Basically, since each Statement downloads
- * the results as the query is executed, we can have many. However,
- * we can only really have one statement per connection going
- * at once (since they are executed serially) - so we return
- * one.
- *
- * @return the maximum
- * @exception SQLException if a database access error occurs
- */
- public int getMaxStatements() throws SQLException
- {
- return 1;
- }
-
- /*
- * What is the maximum length of a table name? This was found
- * from pg_class.relname length
- *
- * @return max name length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxTableNameLength() throws SQLException
- {
- return 32;
- }
-
- /*
- * What is the maximum number of tables that can be specified
- * in a SELECT?
- *
- * @return the maximum
- * @exception SQLException if a database access error occurs
- */
- public int getMaxTablesInSelect() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What is the maximum length of a user name? Well, we generally
- * use UNIX like user names in PostgreSQL, so I think this would
- * be 8. However, showing the schema for pg_user shows a length
- * for username of 32.
- *
- * @return the max name length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxUserNameLength() throws SQLException
- {
- return 32;
- }
-
-
- /*
- * What is the database's default transaction isolation level? We
- * do not support this, so all transactions are SERIALIZABLE.
- *
- * @return the default isolation level
- * @exception SQLException if a database access error occurs
- * @see Connection
- */
- public int getDefaultTransactionIsolation() throws SQLException
- {
- return Connection.TRANSACTION_READ_COMMITTED;
- }
-
- /*
- * Are transactions supported? If not, commit and rollback are noops
- * and the isolation level is TRANSACTION_NONE. We do support
- * transactions.
- *
- * @return true if transactions are supported
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsTransactions() throws SQLException
- {
- return true;
- }
-
- /*
- * Does the database support the given transaction isolation level?
- * We only support TRANSACTION_SERIALIZABLE and TRANSACTION_READ_COMMITTED
- *
- * @param level the values are defined in java.sql.Connection
- * @return true if so
- * @exception SQLException if a database access error occurs
- * @see Connection
- */
- public boolean supportsTransactionIsolationLevel(int level) throws SQLException
- {
- if (level == Connection.TRANSACTION_SERIALIZABLE ||
- level == Connection.TRANSACTION_READ_COMMITTED)
- return true;
- else
- return false;
- }
-
- /*
- * Are both data definition and data manipulation transactions
- * supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException
- {
- return true;
- }
-
- /*
- * Are only data manipulation statements withing a transaction
- * supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsDataManipulationTransactionsOnly() throws SQLException
- {
- return false;
- }
-
- /*
- * Does a data definition statement within a transaction force
- * the transaction to commit? I think this means something like:
- *
- * <p><pre>
- * CREATE TABLE T (A INT);
- * INSERT INTO T (A) VALUES (2);
- * BEGIN;
- * UPDATE T SET A = A + 1;
- * CREATE TABLE X (A INT);
- * SELECT A FROM T INTO X;
- * COMMIT;
- * </pre><p>
- *
- * does the CREATE TABLE call cause a commit? The answer is no.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean dataDefinitionCausesTransactionCommit() throws SQLException
- {
- return false;
- }
-
- /*
- * Is a data definition statement within a transaction ignored?
- * It seems to be (from experiment in previous method)
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean dataDefinitionIgnoredInTransactions() throws SQLException
- {
- return true;
- }
-
- /*
- * Get a description of stored procedures available in a catalog
- *
- * <p>Only procedure descriptions matching the schema and procedure
- * name criteria are returned. They are ordered by PROCEDURE_SCHEM
- * and PROCEDURE_NAME
- *
- * <p>Each procedure description has the following columns:
- * <ol>
- * <li><b>PROCEDURE_CAT</b> String => procedure catalog (may be null)
- * <li><b>PROCEDURE_SCHEM</b> String => procedure schema (may be null)
- * <li><b>PROCEDURE_NAME</b> String => procedure name
- * <li><b>Field 4</b> reserved (make it null)
- * <li><b>Field 5</b> reserved (make it null)
- * <li><b>Field 6</b> reserved (make it null)
- * <li><b>REMARKS</b> String => explanatory comment on the procedure
- * <li><b>PROCEDURE_TYPE</b> short => kind of procedure
- * <ul>
- * <li> procedureResultUnknown - May return a result
- * <li> procedureNoResult - Does not return a result
- * <li> procedureReturnsResult - Returns a result
- * </ul>
- * </ol>
- *
- * @param catalog - a catalog name; "" retrieves those without a
- * catalog; null means drop catalog name from criteria
- * @param schemaParrern - a schema name pattern; "" retrieves those
- * without a schema - we ignore this parameter
- * @param procedureNamePattern - a procedure name pattern
- * @return ResultSet - each row is a procedure description
- * @exception SQLException if a database access error occurs
- */
- public java.sql.ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException
- {
- // the field descriptors for the new ResultSet
- Field f[] = new Field[8];
- java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "PROCEDURE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "PROCEDURE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "PROCEDURE_NAME", iVarcharOid, 32);
- f[3] = f[4] = f[5] = new Field(connection, "reserved", iVarcharOid, 32); // null; // reserved, must be null for now
- f[6] = new Field(connection, "REMARKS", iVarcharOid, 8192);
- f[7] = new Field(connection, "PROCEDURE_TYPE", iInt2Oid, 2);
-
- // If the pattern is null, then set it to the default
- if (procedureNamePattern == null)
- procedureNamePattern = "%";
-
- r = connection.ExecSQL("select proname, proretset from pg_proc where proname like '" + procedureNamePattern.toLowerCase() + "' order by proname");
-
- while (r.next())
- {
- byte[][] tuple = new byte[8][0];
-
- tuple[0] = null; // Catalog name
- tuple[1] = null; // Schema name
- tuple[2] = r.getBytes(1); // Procedure name
- tuple[3] = tuple[4] = tuple[5] = null; // Reserved
- tuple[6] = null; // Remarks
-
- if (r.getBoolean(2))
- tuple[7] = Integer.toString(java.sql.DatabaseMetaData.procedureReturnsResult).getBytes();
- else
- tuple[7] = Integer.toString(java.sql.DatabaseMetaData.procedureNoResult).getBytes();
-
- v.addElement(tuple);
- }
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of a catalog's stored procedure parameters
- * and result columns.
- *
- * <p>Only descriptions matching the schema, procedure and parameter
- * name criteria are returned. They are ordered by PROCEDURE_SCHEM
- * and PROCEDURE_NAME. Within this, the return value, if any, is
- * first. Next are the parameter descriptions in call order. The
- * column descriptions follow in column number order.
- *
- * <p>Each row in the ResultSet is a parameter description or column
- * description with the following fields:
- * <ol>
- * <li><b>PROCEDURE_CAT</b> String => procedure catalog (may be null)
- * <li><b>PROCEDURE_SCHE</b>M String => procedure schema (may be null)
- * <li><b>PROCEDURE_NAME</b> String => procedure name
- * <li><b>COLUMN_NAME</b> String => column/parameter name
- * <li><b>COLUMN_TYPE</b> Short => kind of column/parameter:
- * <ul><li>procedureColumnUnknown - nobody knows
- * <li>procedureColumnIn - IN parameter
- * <li>procedureColumnInOut - INOUT parameter
- * <li>procedureColumnOut - OUT parameter
- * <li>procedureColumnReturn - procedure return value
- * <li>procedureColumnResult - result column in ResultSet
- * </ul>
- * <li><b>DATA_TYPE</b> short => SQL type from java.sql.Types
- * <li><b>TYPE_NAME</b> String => SQL type name
- * <li><b>PRECISION</b> int => precision
- * <li><b>LENGTH</b> int => length in bytes of data
- * <li><b>SCALE</b> short => scale
- * <li><b>RADIX</b> short => radix
- * <li><b>NULLABLE</b> short => can it contain NULL?
- * <ul><li>procedureNoNulls - does not allow NULL values
- * <li>procedureNullable - allows NULL values
- * <li>procedureNullableUnknown - nullability unknown
- * <li><b>REMARKS</b> String => comment describing parameter/column
- * </ol>
- * @param catalog This is ignored in org.postgresql, advise this is set to null
- * @param schemaPattern This is ignored in org.postgresql, advise this is set to null
- * @param procedureNamePattern a procedure name pattern
- * @param columnNamePattern a column name pattern
- * @return each row is a stored procedure parameter or column description
- * @exception SQLException if a database-access error occurs
- * @see #getSearchStringEscape
- */
- // Implementation note: This is required for Borland's JBuilder to work
- public java.sql.ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException
- {
- if (procedureNamePattern == null)
- procedureNamePattern = "%";
-
- if (columnNamePattern == null)
- columnNamePattern = "%";
-
- // for now, this returns an empty result set.
- Field f[] = new Field[13];
- ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "PROCEDURE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "PROCEDURE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "PROCEDURE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "COLUMN_TYPE", iInt2Oid, 2);
- f[5] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
- f[6] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
- f[7] = new Field(connection, "PRECISION", iInt4Oid, 4);
- f[8] = new Field(connection, "LENGTH", iInt4Oid, 4);
- f[9] = new Field(connection, "SCALE", iInt2Oid, 2);
- f[10] = new Field(connection, "RADIX", iInt2Oid, 2);
- f[11] = new Field(connection, "NULLABLE", iInt2Oid, 2);
- f[12] = new Field(connection, "REMARKS", iVarcharOid, 32);
-
- // add query loop here
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of tables available in a catalog.
- *
- * <p>Only table descriptions matching the catalog, schema, table
- * name and type criteria are returned. They are ordered by
- * TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
- *
- * <p>Each table description has the following columns:
- *
- * <ol>
- * <li><b>TABLE_CAT</b> String => table catalog (may be null)
- * <li><b>TABLE_SCHEM</b> String => table schema (may be null)
- * <li><b>TABLE_NAME</b> String => table name
- * <li><b>TABLE_TYPE</b> String => table type. Typical types are "TABLE",
- * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL
- * TEMPORARY", "ALIAS", "SYNONYM".
- * <li><b>REMARKS</b> String => explanatory comment on the table
- * </ol>
- *
- * <p>The valid values for the types parameter are:
- * "TABLE", "INDEX", "SEQUENCE", "SYSTEM TABLE" and "SYSTEM INDEX"
- *
- * @param catalog a catalog name; For org.postgresql, this is ignored, and
- * should be set to null
- * @param schemaPattern a schema name pattern; For org.postgresql, this is ignored, and
- * should be set to null
- * @param tableNamePattern a table name pattern. For all tables this should be "%"
- * @param types a list of table types to include; null returns
- * all types
- * @return each row is a table description
- * @exception SQLException if a database-access error occurs.
- */
- public java.sql.ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SQLException
- {
- // Handle default value for types
- if (types == null)
- types = defaultTableTypes;
-
- if (tableNamePattern == null)
- tableNamePattern = "%";
-
- // the field descriptors for the new ResultSet
- Field f[] = new Field[5];
- java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "TABLE_TYPE", iVarcharOid, 32);
- f[4] = new Field(connection, "REMARKS", iVarcharOid, 32);
-
- // Now form the query
- StringBuffer sql = new StringBuffer("select relname,oid,relkind from pg_class where (");
-
- boolean notFirst = false;
- for (int i = 0;i < types.length;i++)
- {
- for (int j = 0;j < getTableTypes.length;j++)
- if (getTableTypes[j][0].equals(types[i]))
- {
- if (notFirst)
- sql.append(" or ");
- sql.append(getTableTypes[j][1]);
- notFirst = true;
- }
- }
-
- // Added by Stefan Andreasen <stefan@linux.kapow.dk>
- // Now take the pattern into account
- sql.append(") and relname like '");
- sql.append(tableNamePattern.toLowerCase());
- sql.append("' order by relkind, relname");
-
- // Now run the query
- r = connection.ExecSQL(sql.toString());
-
- while (r.next())
- {
- byte[][] tuple = new byte[5][0];
-
- // Fetch the description for the table (if any)
- String getDescriptionStatement =
- connection.haveMinimumServerVersion("7.2") ?
- "select obj_description(" + r.getInt(2) + ",'pg_class')" :
- "select description from pg_description where objoid=" + r.getInt(2);
-
- java.sql.ResultSet dr = connection.ExecSQL(getDescriptionStatement);
-
- byte remarks[] = null;
-
- if (((org.postgresql.ResultSet)dr).getTupleCount() == 1)
- {
- dr.next();
- remarks = dr.getBytes(1);
- }
- dr.close();
-
- String relKind;
- switch (r.getBytes(3)[0])
- {
- case (byte) 'r':
- if ( r.getString(1).startsWith("pg_") )
- {
- relKind = "SYSTEM TABLE";
- }
- else
- {
- relKind = "TABLE";
- }
- break;
- case (byte) 'i':
- relKind = "INDEX";
- break;
- case (byte) 'S':
- relKind = "SEQUENCE";
- break;
- case (byte) 'v':
- relKind = "VIEW";
- break;
- default:
- relKind = null;
- }
-
- tuple[0] = null; // Catalog name
- tuple[1] = null; // Schema name
- tuple[2] = r.getBytes(1); // Table name
- tuple[3] = (relKind == null) ? null : relKind.getBytes(); // Table type
- tuple[4] = remarks; // Remarks
- v.addElement(tuple);
- }
- r.close();
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- // This array contains the valid values for the types argument
- // in getTables().
- //
- // Each supported type consists of it's name, and the sql where
- // clause to retrieve that value.
- //
- // IMPORTANT: the query must be enclosed in ( )
- private static final String getTableTypes[][] = {
- {"TABLE", "(relkind='r' and relhasrules='f' and relname !~ '^pg_' and relname !~ '^xinv')"},
- {"VIEW", "(relkind='v' and relname !~ '^pg_')"},
- {"INDEX", "(relkind='i' and relname !~ '^pg_')"},
- {"SEQUENCE", "(relkind='S' and relname !~ '^pg_')"},
- {"SYSTEM TABLE", "(relkind='r' and relname ~ '^pg_')"},
- {"SYSTEM INDEX", "(relkind='i' and relname ~ '^pg_')"}
- };
-
- // These are the default tables, used when NULL is passed to getTables
- // The choice of these provide the same behaviour as psql's \d
- private static final String defaultTableTypes[] = {
- "TABLE", "VIEW", "INDEX", "SEQUENCE"
- };
-
- /*
- * Get the schema names available in this database. The results
- * are ordered by schema name.
- *
- * <P>The schema column is:
- * <OL>
- * <LI><B>TABLE_SCHEM</B> String => schema name
- * </OL>
- *
- * @return ResultSet each row has a single String column that is a
- * schema name
- */
- public java.sql.ResultSet getSchemas() throws SQLException
- {
- // We don't use schemas, so we simply return a single schema name "".
- //
- Field f[] = new Field[1];
- Vector v = new Vector();
- byte[][] tuple = new byte[1][0];
- f[0] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- tuple[0] = "".getBytes();
- v.addElement(tuple);
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get the catalog names available in this database. The results
- * are ordered by catalog name.
- *
- * <P>The catalog column is:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => catalog name
- * </OL>
- *
- * @return ResultSet each row has a single String column that is a
- * catalog name
- */
- public java.sql.ResultSet getCatalogs() throws SQLException
- {
- return connection.createStatement().executeQuery("select datname as TABLE_CAT from pg_database;");
- }
-
- /*
- * Get the table types available in this database. The results
- * are ordered by table type.
- *
- * <P>The table type is:
- * <OL>
- * <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
- * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
- * "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
- * </OL>
- *
- * @return ResultSet each row has a single String column that is a
- * table type
- */
- public java.sql.ResultSet getTableTypes() throws SQLException
- {
- Field f[] = new Field[1];
- Vector v = new Vector();
- f[0] = new Field(connection, new String("TABLE_TYPE"), iVarcharOid, 32);
- for (int i = 0;i < getTableTypes.length;i++)
- {
- byte[][] tuple = new byte[1][0];
- tuple[0] = getTableTypes[i][0].getBytes();
- v.addElement(tuple);
- }
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of table columns available in a catalog.
- *
- * <P>Only column descriptions matching the catalog, schema, table
- * and column name criteria are returned. They are ordered by
- * TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION.
- *
- * <P>Each column description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
- * <LI><B>TYPE_NAME</B> String => Data source dependent type name
- * <LI><B>COLUMN_SIZE</B> int => column size. For char or date
- * types this is the maximum number of characters, for numeric or
- * decimal types this is precision.
- * <LI><B>BUFFER_LENGTH</B> is not used.
- * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
- * <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
- * <LI><B>NULLABLE</B> int => is NULL allowed?
- * <UL>
- * <LI> columnNoNulls - might not allow NULL values
- * <LI> columnNullable - definitely allows NULL values
- * <LI> columnNullableUnknown - nullability unknown
- * </UL>
- * <LI><B>REMARKS</B> String => comment describing column (may be null)
- * <LI><B>COLUMN_DEF</B> String => default value (may be null)
- * <LI><B>SQL_DATA_TYPE</B> int => unused
- * <LI><B>SQL_DATETIME_SUB</B> int => unused
- * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
- * maximum number of bytes in the column
- * <LI><B>ORDINAL_POSITION</B> int => index of column in table
- * (starting at 1)
- * <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
- * does not allow NULL values; "YES" means the column might
- * allow NULL values. An empty string means nobody knows.
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schemaPattern a schema name pattern; "" retrieves those
- * without a schema
- * @param tableNamePattern a table name pattern
- * @param columnNamePattern a column name pattern
- * @return ResultSet each row is a column description
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException
- {
- Vector v = new Vector(); // The new ResultSet tuple stuff
- Field f[] = new Field[18]; // The field descriptors for the new ResultSet
-
- f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
- f[5] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
- f[6] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
- f[7] = new Field(connection, "BUFFER_LENGTH", iVarcharOid, 32);
- f[8] = new Field(connection, "DECIMAL_DIGITS", iInt4Oid, 4);
- f[9] = new Field(connection, "NUM_PREC_RADIX", iInt4Oid, 4);
- f[10] = new Field(connection, "NULLABLE", iInt4Oid, 4);
- f[11] = new Field(connection, "REMARKS", iVarcharOid, 32);
- f[12] = new Field(connection, "COLUMN_DEF", iVarcharOid, 32);
- f[13] = new Field(connection, "SQL_DATA_TYPE", iInt4Oid, 4);
- f[14] = new Field(connection, "SQL_DATETIME_SUB", iInt4Oid, 4);
- f[15] = new Field(connection, "CHAR_OCTET_LENGTH", iVarcharOid, 32);
- f[16] = new Field(connection, "ORDINAL_POSITION", iInt4Oid, 4);
- f[17] = new Field(connection, "IS_NULLABLE", iVarcharOid, 32);
-
- StringBuffer sql = new StringBuffer(512);
-
- /* Build a >= 7.1 SQL statement to list all columns */
- sql.append("select " +
- (connection.haveMinimumServerVersion("7.2") ? "a.attrelid, " : "a.oid, ") +
- " c.relname, " +
- " a.attname, " +
- " a.atttypid, " +
- " a.attnum, " +
- " a.attnotnull, " +
- " a.attlen, " +
- " a.atttypmod, " +
- " d.adsrc, " +
- " t.typname, " +
- /* Use the new col_description in 7.2 or an additional outer join in 7.1 */
- (connection.haveMinimumServerVersion("7.2") ? "col_description(a.attrelid, a.attnum) " : "e.description ") +
- "from" +
- " (" +
- " (pg_class c inner join pg_attribute a on" +
- " (" +
- " a.attrelid=c.oid");
-
- if ((tableNamePattern != null) && ! tableNamePattern.equals("%"))
- {
- sql.append(" and c.relname like \'" + tableNamePattern.toLowerCase() + "\'");
- }
-
- if ((columnNamePattern != null) && ! columnNamePattern.equals("%"))
- {
- sql.append(" and a.attname like \'" + columnNamePattern.toLowerCase() + "\'");
- }
-
- sql.append(
- " and a.attnum > 0" +
- " )" +
- " ) inner join pg_type t on" +
- " (" +
- " t.oid = a.atttypid" +
- " )" +
- " )" +
- " left outer join pg_attrdef d on" +
- " (" +
- " c.oid = d.adrelid" +
- " and a.attnum = d.adnum" +
- " ) ");
-
- if (!connection.haveMinimumServerVersion("7.2"))
- {
- /* Only for 7.1 */
- sql.append(
- " left outer join pg_description e on" +
- " (" +
- " e.objoid = a.oid" +
- " ) ");
- }
-
- sql.append("order by" +
- " c.relname, a.attnum");
-
- java.sql.ResultSet r = connection.ExecSQL(sql.toString());
- while (r.next())
- {
- byte[][] tuple = new byte[18][0];
-
- String nullFlag = r.getString(6);
- String typname = r.getString(10);
-
- tuple[0] = null; // Catalog name, not supported
- tuple[1] = null; // Schema name, not supported
- tuple[2] = r.getBytes(2); // Table name
- tuple[3] = r.getBytes(3); // Column name
- tuple[4] = Integer.toString(connection.getSQLType(typname)).getBytes(); // Data type
- tuple[5] = typname.getBytes(); // Type name
-
- // Column size
- // Looking at the psql source,
- // I think the length of a varchar as specified when the table was created
- // should be extracted from atttypmod which contains this length + sizeof(int32)
- if (typname.equals("bpchar") || typname.equals("varchar"))
- {
- int atttypmod = r.getInt(8);
- tuple[6] = Integer.toString(atttypmod != -1 ? atttypmod - VARHDRSZ : 0).getBytes();
- }
- else
- {
- tuple[6] = r.getBytes(7);
- }
-
- tuple[7] = null; // Buffer length
- // Decimal digits = scale
- // From the source (see e.g. backend/utils/adt/numeric.c,
- // function numeric()) the scale and precision can be calculated
- // from the typmod value.
- if (typname.equals("numeric") || typname.equals("decimal"))
- {
- int attypmod = r.getInt(8) - VARHDRSZ;
- tuple[8] =
- Integer.toString(attypmod & 0xffff).getBytes();
- tuple[9] =
- Integer.toString( ( attypmod >> 16 ) & 0xffff ).getBytes();
- }
- else
- {
- tuple[8] = "0".getBytes();
- tuple[9] = "10".getBytes(); // Num Prec Radix - assume decimal
- }
- tuple[10] = Integer.toString(nullFlag.equals("f") ?
- java.sql.DatabaseMetaData.columnNullable :
- java.sql.DatabaseMetaData.columnNoNulls).getBytes(); // Nullable
- tuple[11] = r.getBytes(11); // Description (if any)
- tuple[12] = r.getBytes(9); // Column default
- tuple[13] = null; // sql data type (unused)
- tuple[14] = null; // sql datetime sub (unused)
- tuple[15] = tuple[6]; // char octet length
- tuple[16] = r.getBytes(5); // ordinal position
- tuple[17] = (nullFlag.equals("f") ? "YES" : "NO").getBytes(); // Is nullable
-
- v.addElement(tuple);
- }
- r.close();
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of the access rights for a table's columns.
- *
- * <P>Only privileges matching the column name criteria are
- * returned. They are ordered by COLUMN_NAME and PRIVILEGE.
- *
- * <P>Each privilige description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>GRANTOR</B> => grantor of access (may be null)
- * <LI><B>GRANTEE</B> String => grantee of access
- * <LI><B>PRIVILEGE</B> String => name of access (SELECT,
- * INSERT, UPDATE, REFRENCES, ...)
- * <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
- * to grant to others; "NO" if not; null if unknown
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name; "" retrieves those without a schema
- * @param table a table name
- * @param columnNamePattern a column name pattern
- * @return ResultSet each row is a column privilege description
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException
- {
- Field f[] = new Field[8];
- Vector v = new Vector();
-
- if (table == null)
- table = "%";
-
- if (columnNamePattern == null)
- columnNamePattern = "%";
- else
- columnNamePattern = columnNamePattern.toLowerCase();
-
- f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "GRANTOR", iVarcharOid, 32);
- f[5] = new Field(connection, "GRANTEE", iVarcharOid, 32);
- f[6] = new Field(connection, "PRIVILEGE", iVarcharOid, 32);
- f[7] = new Field(connection, "IS_GRANTABLE", iVarcharOid, 32);
-
- // This is taken direct from the psql source
- java.sql.ResultSet r = connection.ExecSQL("SELECT relname, relacl FROM pg_class, pg_user WHERE ( relkind = 'r' OR relkind = 'i') and relname !~ '^pg_' and relname !~ '^xin[vx][0-9]+' and usesysid = relowner and relname like '" + table.toLowerCase() + "' ORDER BY relname");
- while (r.next())
- {
- byte[][] tuple = new byte[8][0];
- tuple[0] = tuple[1] = "".getBytes();
-
- // For now, don't add to the result as relacl needs to be processed.
- //v.addElement(tuple);
- }
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of the access rights for each table available
- * in a catalog.
- *
- * This method is currently unimplemented.
- *
- * <P>Only privileges matching the schema and table name
- * criteria are returned. They are ordered by TABLE_SCHEM,
- * TABLE_NAME, and PRIVILEGE.
- *
- * <P>Each privilige description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>GRANTOR</B> => grantor of access (may be null)
- * <LI><B>GRANTEE</B> String => grantee of access
- * <LI><B>PRIVILEGE</B> String => name of access (SELECT,
- * INSERT, UPDATE, REFRENCES, ...)
- * <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
- * to grant to others; "NO" if not; null if unknown
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schemaPattern a schema name pattern; "" retrieves those
- * without a schema
- * @param tableNamePattern a table name pattern
- * @return ResultSet each row is a table privilege description
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /*
- * Get a description of a table's optimal set of columns that
- * uniquely identifies a row. They are ordered by SCOPE.
- *
- * <P>Each column description has the following columns:
- * <OL>
- * <LI><B>SCOPE</B> short => actual scope of result
- * <UL>
- * <LI> bestRowTemporary - very temporary, while using row
- * <LI> bestRowTransaction - valid for remainder of current transaction
- * <LI> bestRowSession - valid for remainder of current session
- * </UL>
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
- * <LI><B>TYPE_NAME</B> String => Data source dependent type name
- * <LI><B>COLUMN_SIZE</B> int => precision
- * <LI><B>BUFFER_LENGTH</B> int => not used
- * <LI><B>DECIMAL_DIGITS</B> short => scale
- * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
- * like an Oracle ROWID
- * <UL>
- * <LI> bestRowUnknown - may or may not be pseudo column
- * <LI> bestRowNotPseudo - is NOT a pseudo column
- * <LI> bestRowPseudo - is a pseudo column
- * </UL>
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name; "" retrieves those without a schema
- * @param table a table name
- * @param scope the scope of interest; use same values as SCOPE
- * @param nullable include columns that are nullable?
- * @return ResultSet each row is a column description
- */
- // Implementation note: This is required for Borland's JBuilder to work
- public java.sql.ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException
- {
- // for now, this returns an empty result set.
- Field f[] = new Field[8];
- ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "SCOPE", iInt2Oid, 2);
- f[1] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[2] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
- f[3] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
- f[5] = new Field(connection, "BUFFER_LENGTH", iInt4Oid, 4);
- f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
- f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of a table's columns that are automatically
- * updated when any value in a row is updated. They are
- * unordered.
- *
- * This method is currently unimplemented.
- *
- * <P>Each column description has the following columns:
- * <OL>
- * <LI><B>SCOPE</B> short => is not used
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
- * <LI><B>TYPE_NAME</B> String => Data source dependent type name
- * <LI><B>COLUMN_SIZE</B> int => precision
- * <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
- * <LI><B>DECIMAL_DIGITS</B> short => scale
- * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
- * like an Oracle ROWID
- * <UL>
- * <LI> versionColumnUnknown - may or may not be pseudo column
- * <LI> versionColumnNotPseudo - is NOT a pseudo column
- * <LI> versionColumnPseudo - is a pseudo column
- * </UL>
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name; "" retrieves those without a schema
- * @param table a table name
- * @return ResultSet each row is a column description
- */
- public java.sql.ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /*
- * Get a description of a table's primary key columns. They
- * are ordered by COLUMN_NAME.
- *
- * <P>Each column description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>KEY_SEQ</B> short => sequence number within primary key
- * <LI><B>PK_NAME</B> String => primary key name (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those
- * without a schema
- * @param table a table name
- * @return ResultSet each row is a primary key column description
- */
- public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
- {
- return connection.createStatement().executeQuery("SELECT " +
- "'' as TABLE_CAT," +
- "'' AS TABLE_SCHEM," +
- "bc.relname AS TABLE_NAME," +
- "a.attname AS COLUMN_NAME," +
- "a.attnum as KEY_SEQ," +
- "ic.relname as PK_NAME " +
- " FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
- " WHERE bc.relkind = 'r' " + // -- not indices
- " and upper(bc.relname) = upper('" + table + "')" +
- " and i.indrelid = bc.oid" +
- " and i.indexrelid = ic.oid" +
- " and ic.oid = a.attrelid" +
- " and i.indisprimary='t' " +
- " ORDER BY table_name, pk_name, key_seq"
- );
- }
-
- private java.sql.ResultSet getImportedExportedKeys(String catalog, String schema, String primaryTable, String foreignTable) throws SQLException
- {
- Field f[] = new Field[14];
-
- f[0] = new Field(connection, "PKTABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "PKTABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "PKTABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "PKCOLUMN_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "FKTABLE_CAT", iVarcharOid, 32);
- f[5] = new Field(connection, "FKTABLE_SCHEM", iVarcharOid, 32);
- f[6] = new Field(connection, "FKTABLE_NAME", iVarcharOid, 32);
- f[7] = new Field(connection, "FKCOLUMN_NAME", iVarcharOid, 32);
- f[8] = new Field(connection, "KEY_SEQ", iInt2Oid, 2);
- f[9] = new Field(connection, "UPDATE_RULE", iInt2Oid, 2);
- f[10] = new Field(connection, "DELETE_RULE", iInt2Oid, 2);
- f[11] = new Field(connection, "FK_NAME", iVarcharOid, 32);
- f[12] = new Field(connection, "PK_NAME", iVarcharOid, 32);
- f[13] = new Field(connection, "DEFERRABILITY", iInt2Oid, 2);
-
- java.sql.ResultSet rs = connection.ExecSQL("SELECT c.relname,c2.relname,"
- + "t.tgconstrname,ic.relname,"
- + "t.tgdeferrable,t.tginitdeferred,"
- + "t.tgnargs,t.tgargs,p.proname "
- + "FROM pg_trigger t,pg_class c,pg_class c2,"
- + "pg_class ic,pg_proc p, pg_index i "
- + "WHERE t.tgrelid=c.oid AND t.tgconstrrelid=c2.oid "
- + "AND t.tgfoid=p.oid AND tgisconstraint "
- + ((primaryTable != null) ? "AND c.relname='" + primaryTable + "' " : "")
- + ((foreignTable != null) ? "AND c2.relname='" + foreignTable + "' " : "")
- + "AND i.indrelid=c.oid "
- + "AND i.indexrelid=ic.oid AND i.indisprimary "
- + "ORDER BY c.relname,c2.relname"
- );
- Vector tuples = new Vector();
- short seq = 0;
- if (rs.next())
- {
- boolean hasMore;
- do
- {
- byte tuple[][] = new byte[14][0];
- for (int k = 0;k < 14;k++)
- tuple[k] = null;
-
- String fKeyName = rs.getString(3);
- boolean foundRule = false;
- do
- {
- String proname = rs.getString(9);
- if (proname != null && proname.startsWith("RI_FKey_"))
- {
- int col = -1;
- if (proname.endsWith("_upd"))
- col = 9; // UPDATE_RULE
- else if (proname.endsWith("_del"))
- col = 10; // DELETE_RULE
- if (col > -1)
- {
- String rule = proname.substring(8, proname.length() - 4);
- int action = importedKeyNoAction;
- if ("cascade".equals(rule))
- action = importedKeyCascade;
- else if ("setnull".equals(rule))
- action = importedKeySetNull;
- else if ("setdefault".equals(rule))
- action = importedKeySetDefault;
- tuple[col] = Integer.toString(action).getBytes();
-
- if (!foundRule)
- {
- tuple[2] = rs.getBytes(1); //PKTABLE_NAME
- tuple[6] = rs.getBytes(2); //FKTABLE_NAME
-
- // Parse the tgargs data
- StringBuffer fkeyColumns = new StringBuffer();
- StringBuffer pkeyColumns = new StringBuffer();
- int numColumns = (rs.getInt(7) >> 1) - 2;
- String s = rs.getString(8);
- int pos = s.lastIndexOf("\\000");
- for (int c = 0;c < numColumns;c++)
- {
- if (pos > -1)
- {
- int pos2 = s.lastIndexOf("\\000", pos - 1);
- if (pos2 > -1)
- {
- if (pkeyColumns.length() > 0)
- pkeyColumns.insert(0, ',');
- pkeyColumns.insert(0, s.substring(pos2 + 4, pos)); //PKCOLUMN_NAME
- pos = s.lastIndexOf("\\000", pos2 - 1);
- if (pos > -1)
- {
- if (fkeyColumns.length() > 0)
- fkeyColumns.insert(0, ',');
- fkeyColumns.insert(0, s.substring(pos + 4, pos2)); //FKCOLUMN_NAME
- }
- }
- }
- }
- tuple[3] = pkeyColumns.toString().getBytes(); //PKCOLUMN_NAME
- tuple[7] = fkeyColumns.toString().getBytes(); //FKCOLUMN_NAME
-
- tuple[8] = Integer.toString(seq++).getBytes(); //KEY_SEQ
- tuple[11] = fKeyName.getBytes(); //FK_NAME
- tuple[12] = rs.getBytes(4); //PK_NAME
-
- // DEFERRABILITY
- int deferrability = importedKeyNotDeferrable;
- boolean deferrable = rs.getBoolean(5);
- boolean initiallyDeferred = rs.getBoolean(6);
- if (deferrable)
- {
- if (initiallyDeferred)
- deferrability = importedKeyInitiallyDeferred;
- else
- deferrability = importedKeyInitiallyImmediate;
- }
- tuple[13] = Integer.toString(deferrability).getBytes();
-
- foundRule = true;
- }
- }
- }
- }
- while ((hasMore = rs.next()) && fKeyName.equals(rs.getString(3)));
-
- if(foundRule) tuples.addElement(tuple);
-
- }
- while (hasMore);
- }
-
- return new ResultSet(connection, f, tuples, "OK", 1);
- }
-
- /*
- * Get a description of the primary key columns that are
- * referenced by a table's foreign key columns (the primary keys
- * imported by a table). They are ordered by PKTABLE_CAT,
- * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
- *
- * <P>Each primary key column description has the following columns:
- * <OL>
- * <LI><B>PKTABLE_CAT</B> String => primary key table catalog
- * being imported (may be null)
- * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema
- * being imported (may be null)
- * <LI><B>PKTABLE_NAME</B> String => primary key table name
- * being imported
- * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
- * being imported
- * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
- * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
- * <LI><B>FKTABLE_NAME</B> String => foreign key table name
- * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
- * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
- * <LI><B>UPDATE_RULE</B> short => What happens to
- * foreign key when primary is updated:
- * <UL>
- * <LI> importedKeyCascade - change imported key to agree
- * with primary key update
- * <LI> importedKeyRestrict - do not allow update of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been updated
- * </UL>
- * <LI><B>DELETE_RULE</B> short => What happens to
- * the foreign key when primary is deleted.
- * <UL>
- * <LI> importedKeyCascade - delete rows that import a deleted key
- * <LI> importedKeyRestrict - do not allow delete of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been deleted
- * </UL>
- * <LI><B>FK_NAME</B> String => foreign key name (may be null)
- * <LI><B>PK_NAME</B> String => primary key name (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those
- * without a schema
- * @param table a table name
- * @return ResultSet each row is a primary key column description
- * @see #getExportedKeys
- */
- public java.sql.ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException
- {
- return getImportedExportedKeys(catalog, schema, null, table);
- }
-
- /*
- * Get a description of a foreign key columns that reference a
- * table's primary key columns (the foreign keys exported by a
- * table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
- * FKTABLE_NAME, and KEY_SEQ.
- *
- * This method is currently unimplemented.
- *
- * <P>Each foreign key column description has the following columns:
- * <OL>
- * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
- * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
- * <LI><B>PKTABLE_NAME</B> String => primary key table name
- * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
- * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
- * being exported (may be null)
- * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
- * being exported (may be null)
- * <LI><B>FKTABLE_NAME</B> String => foreign key table name
- * being exported
- * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
- * being exported
- * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
- * <LI><B>UPDATE_RULE</B> short => What happens to
- * foreign key when primary is updated:
- * <UL>
- * <LI> importedKeyCascade - change imported key to agree
- * with primary key update
- * <LI> importedKeyRestrict - do not allow update of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been updated
- * </UL>
- * <LI><B>DELETE_RULE</B> short => What happens to
- * the foreign key when primary is deleted.
- * <UL>
- * <LI> importedKeyCascade - delete rows that import a deleted key
- * <LI> importedKeyRestrict - do not allow delete of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been deleted
- * </UL>
- * <LI><B>FK_NAME</B> String => foreign key identifier (may be null)
- * <LI><B>PK_NAME</B> String => primary key identifier (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those
- * without a schema
- * @param table a table name
- * @return ResultSet each row is a foreign key column description
- * @see #getImportedKeys
- */
- public java.sql.ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException
- {
- return getImportedExportedKeys(catalog, schema, table, null);
- }
-
- /*
- * Get a description of the foreign key columns in the foreign key
- * table that reference the primary key columns of the primary key
- * table (describe how one table imports another's key.) This
- * should normally return a single foreign key/primary key pair
- * (most tables only import a foreign key from a table once.) They
- * are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
- * KEY_SEQ.
- *
- * This method is currently unimplemented.
- *
- * <P>Each foreign key column description has the following columns:
- * <OL>
- * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
- * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
- * <LI><B>PKTABLE_NAME</B> String => primary key table name
- * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
- * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
- * being exported (may be null)
- * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
- * being exported (may be null)
- * <LI><B>FKTABLE_NAME</B> String => foreign key table name
- * being exported
- * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
- * being exported
- * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
- * <LI><B>UPDATE_RULE</B> short => What happens to
- * foreign key when primary is updated:
- * <UL>
- * <LI> importedKeyCascade - change imported key to agree
- * with primary key update
- * <LI> importedKeyRestrict - do not allow update of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been updated
- * </UL>
- * <LI><B>DELETE_RULE</B> short => What happens to
- * the foreign key when primary is deleted.
- * <UL>
- * <LI> importedKeyCascade - delete rows that import a deleted key
- * <LI> importedKeyRestrict - do not allow delete of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been deleted
- * </UL>
- * <LI><B>FK_NAME</B> String => foreign key identifier (may be null)
- * <LI><B>PK_NAME</B> String => primary key identifier (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those
- * without a schema
- * @param table a table name
- * @return ResultSet each row is a foreign key column description
- * @see #getImportedKeys
- */
- public java.sql.ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException
- {
- return getImportedExportedKeys(primaryCatalog, primarySchema, primaryTable, foreignTable);
- }
-
- /*
- * Get a description of all the standard SQL types supported by
- * this database. They are ordered by DATA_TYPE and then by how
- * closely the data type maps to the corresponding JDBC SQL type.
- *
- * <P>Each type description has the following columns:
- * <OL>
- * <LI><B>TYPE_NAME</B> String => Type name
- * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
- * <LI><B>PRECISION</B> int => maximum precision
- * <LI><B>LITERAL_PREFIX</B> String => prefix used to quote a literal
- * (may be null)
- * <LI><B>LITERAL_SUFFIX</B> String => suffix used to quote a literal
- (may be null)
- * <LI><B>CREATE_PARAMS</B> String => parameters used in creating
- * the type (may be null)
- * <LI><B>NULLABLE</B> short => can you use NULL for this type?
- * <UL>
- * <LI> typeNoNulls - does not allow NULL values
- * <LI> typeNullable - allows NULL values
- * <LI> typeNullableUnknown - nullability unknown
- * </UL>
- * <LI><B>CASE_SENSITIVE</B> boolean=> is it case sensitive?
- * <LI><B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
- * <UL>
- * <LI> typePredNone - No support
- * <LI> typePredChar - Only supported with WHERE .. LIKE
- * <LI> typePredBasic - Supported except for WHERE .. LIKE
- * <LI> typeSearchable - Supported for all WHERE ..
- * </UL>
- * <LI><B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned?
- * <LI><B>FIXED_PREC_SCALE</B> boolean => can it be a money value?
- * <LI><B>AUTO_INCREMENT</B> boolean => can it be used for an
- * auto-increment value?
- * <LI><B>LOCAL_TYPE_NAME</B> String => localized version of type name
- * (may be null)
- * <LI><B>MINIMUM_SCALE</B> short => minimum scale supported
- * <LI><B>MAXIMUM_SCALE</B> short => maximum scale supported
- * <LI><B>SQL_DATA_TYPE</B> int => unused
- * <LI><B>SQL_DATETIME_SUB</B> int => unused
- * <LI><B>NUM_PREC_RADIX</B> int => usually 2 or 10
- * </OL>
- *
- * @return ResultSet each row is a SQL type description
- */
- public java.sql.ResultSet getTypeInfo() throws SQLException
- {
- java.sql.ResultSet rs = connection.ExecSQL("select typname from pg_type");
- if (rs != null)
- {
- Field f[] = new Field[18];
- ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
- f[1] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
- f[2] = new Field(connection, "PRECISION", iInt4Oid, 4);
- f[3] = new Field(connection, "LITERAL_PREFIX", iVarcharOid, 32);
- f[4] = new Field(connection, "LITERAL_SUFFIX", iVarcharOid, 32);
- f[5] = new Field(connection, "CREATE_PARAMS", iVarcharOid, 32);
- f[6] = new Field(connection, "NULLABLE", iInt2Oid, 2);
- f[7] = new Field(connection, "CASE_SENSITIVE", iBoolOid, 1);
- f[8] = new Field(connection, "SEARCHABLE", iInt2Oid, 2);
- f[9] = new Field(connection, "UNSIGNED_ATTRIBUTE", iBoolOid, 1);
- f[10] = new Field(connection, "FIXED_PREC_SCALE", iBoolOid, 1);
- f[11] = new Field(connection, "AUTO_INCREMENT", iBoolOid, 1);
- f[12] = new Field(connection, "LOCAL_TYPE_NAME", iVarcharOid, 32);
- f[13] = new Field(connection, "MINIMUM_SCALE", iInt2Oid, 2);
- f[14] = new Field(connection, "MAXIMUM_SCALE", iInt2Oid, 2);
- f[15] = new Field(connection, "SQL_DATA_TYPE", iInt4Oid, 4);
- f[16] = new Field(connection, "SQL_DATETIME_SUB", iInt4Oid, 4);
- f[17] = new Field(connection, "NUM_PREC_RADIX", iInt4Oid, 4);
-
- // cache some results, this will keep memory useage down, and speed
- // things up a little.
- byte b9[] = "9".getBytes();
- byte b10[] = "10".getBytes();
- byte bf[] = "f".getBytes();
- byte bnn[] = Integer.toString(typeNoNulls).getBytes();
- byte bts[] = Integer.toString(typeSearchable).getBytes();
-
- while (rs.next())
- {
- byte[][] tuple = new byte[18][];
- String typname = rs.getString(1);
- tuple[0] = typname.getBytes();
- tuple[1] = Integer.toString(connection.getSQLType(typname)).getBytes();
- tuple[2] = b9; // for now
- tuple[6] = bnn; // for now
- tuple[7] = bf; // false for now - not case sensitive
- tuple[8] = bts;
- tuple[9] = bf; // false for now - it's signed
- tuple[10] = bf; // false for now - must handle money
- tuple[11] = bf; // false for now - handle autoincrement
- // 12 - LOCAL_TYPE_NAME is null
- // 13 & 14 ?
- // 15 & 16 are unused so we return null
- tuple[17] = b10; // everything is base 10
- v.addElement(tuple);
- }
- rs.close();
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- throw new PSQLException("postgresql.metadata.unavailable");
- }
-
- /*
- * Get a description of a table's indices and statistics. They are
- * ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
- *
- * <P>Each index column description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>NON_UNIQUE</B> boolean => Can index values be non-unique?
- * false when TYPE is tableIndexStatistic
- * <LI><B>INDEX_QUALIFIER</B> String => index catalog (may be null);
- * null when TYPE is tableIndexStatistic
- * <LI><B>INDEX_NAME</B> String => index name; null when TYPE is
- * tableIndexStatistic
- * <LI><B>TYPE</B> short => index type:
- * <UL>
- * <LI> tableIndexStatistic - this identifies table statistics that are
- * returned in conjuction with a table's index descriptions
- * <LI> tableIndexClustered - this is a clustered index
- * <LI> tableIndexHashed - this is a hashed index
- * <LI> tableIndexOther - this is some other style of index
- * </UL>
- * <LI><B>ORDINAL_POSITION</B> short => column sequence number
- * within index; zero when TYPE is tableIndexStatistic
- * <LI><B>COLUMN_NAME</B> String => column name; null when TYPE is
- * tableIndexStatistic
- * <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending
- * "D" => descending, may be null if sort sequence is not supported;
- * null when TYPE is tableIndexStatistic
- * <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatisic then
- * this is the number of rows in the table; otherwise it is the
- * number of unique values in the index.
- * <LI><B>PAGES</B> int => When TYPE is tableIndexStatisic then
- * this is the number of pages used for the table, otherwise it
- * is the number of pages used for the current index.
- * <LI><B>FILTER_CONDITION</B> String => Filter condition, if any.
- * (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those without a schema
- * @param table a table name
- * @param unique when true, return only indices for unique values;
- * when false, return indices regardless of whether unique or not
- * @param approximate when true, result is allowed to reflect approximate
- * or out of data values; when false, results are requested to be
- * accurate
- * @return ResultSet each row is an index column description
- */
- // Implementation note: This is required for Borland's JBuilder to work
- public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tableName, boolean unique, boolean approximate) throws SQLException
- {
- Field f[] = new Field[13];
- java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "NON_UNIQUE", iBoolOid, 1);
- f[4] = new Field(connection, "INDEX_QUALIFIER", iVarcharOid, 32);
- f[5] = new Field(connection, "INDEX_NAME", iVarcharOid, 32);
- f[6] = new Field(connection, "TYPE", iInt2Oid, 2);
- f[7] = new Field(connection, "ORDINAL_POSITION", iInt2Oid, 2);
- f[8] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[9] = new Field(connection, "ASC_OR_DESC", iVarcharOid, 32);
- f[10] = new Field(connection, "CARDINALITY", iInt4Oid, 4);
- f[11] = new Field(connection, "PAGES", iInt4Oid, 4);
- f[12] = new Field(connection, "FILTER_CONDITION", iVarcharOid, 32);
-
- r = connection.ExecSQL("select " +
- "c.relname, " +
- "x.indisunique, " +
- "i.relname, " +
- "x.indisclustered, " +
- "a.amname, " +
- "x.indkey, " +
- "c.reltuples, " +
- "c.relpages, " +
- "x.indexrelid " +
- "FROM pg_index x, pg_class c, pg_class i, pg_am a " +
- "WHERE ((c.relname = '" + tableName.toLowerCase() + "') " +
- " AND (c.oid = x.indrelid) " +
- " AND (i.oid = x.indexrelid) " +
- " AND (i.relam = a.oid)) " +
- "ORDER BY x.indisunique DESC, " +
- " x.indisclustered, a.amname, i.relname");
- while (r.next())
- {
- // indkey is an array of column ordinals (integers). In the JDBC
- // interface, this has to be separated out into a separate
- // tuple for each indexed column. Also, getArray() is not yet
- // implemented for Postgres JDBC, so we parse by hand.
- String columnOrdinalString = r.getString(6);
- StringTokenizer stok = new StringTokenizer(columnOrdinalString);
- int [] columnOrdinals = new int[stok.countTokens()];
- int o = 0;
- while (stok.hasMoreTokens())
- {
- columnOrdinals[o++] = Integer.parseInt(stok.nextToken());
- }
- java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE a.attrelid = " + r.getInt(9));
- for (int i = 0; i < columnOrdinals.length; i++)
- {
- byte [] [] tuple = new byte [13] [];
- tuple[0] = "".getBytes();
- tuple[1] = "".getBytes();
- tuple[2] = r.getBytes(1);
- tuple[3] = r.getBoolean(2) ? "false".getBytes() : "true".getBytes();
- tuple[4] = null;
- tuple[5] = r.getBytes(3);
- tuple[6] = r.getBoolean(4) ?
- Integer.toString(tableIndexClustered).getBytes() :
- r.getString(5).equals("hash") ?
- Integer.toString(tableIndexHashed).getBytes() :
- Integer.toString(tableIndexOther).getBytes();
- tuple[7] = Integer.toString(i + 1).getBytes();
- if (columnNameRS.next())
- {
- tuple[8] = columnNameRS.getBytes(1);
- }
- else
- {
- tuple[8] = "".getBytes();
- }
- tuple[9] = null; // sort sequence ???
- tuple[10] = r.getBytes(7); // inexact
- tuple[11] = r.getBytes(8);
- tuple[12] = null;
- v.addElement(tuple);
- }
- }
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java b/src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java
deleted file mode 100644
index 7084887cfd7..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java
+++ /dev/null
@@ -1,799 +0,0 @@
-package org.postgresql.jdbc1;
-
-// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 2 class in the
-// org.postgresql.jdbc2 package.
-
-import java.io.*;
-import java.math.*;
-import java.sql.*;
-import java.text.*;
-import java.util.*;
-import org.postgresql.largeobject.*;
-import org.postgresql.util.*;
-
-/*
- * A SQL Statement is pre-compiled and stored in a PreparedStatement object.
- * This object can then be used to efficiently execute this statement multiple
- * times.
- *
- * <p><B>Note:</B> The setXXX methods for setting IN parameter values must
- * specify types that are compatible with the defined SQL type of the input
- * parameter. For instance, if the IN parameter has SQL type Integer, then
- * setInt should be used.
- *
- * <p>If arbitrary parameter type conversions are required, then the setObject
- * method should be used with a target SQL type.
- *
- * @see ResultSet
- * @see java.sql.PreparedStatement
- */
-public class PreparedStatement extends Statement implements java.sql.PreparedStatement
-{
- String sql;
- String[] templateStrings;
- String[] inStrings;
- Connection connection;
-
- /*
- * Constructor for the PreparedStatement class.
- * Split the SQL statement into segments - separated by the arguments.
- * When we rebuild the thing with the arguments, we can substitute the
- * args and join the whole thing together.
- *
- * @param conn the instanatiating connection
- * @param sql the SQL statement with ? for IN markers
- * @exception SQLException if something bad occurs
- */
- public PreparedStatement(Connection connection, String sql) throws SQLException
- {
- super(connection);
-
- Vector v = new Vector();
- boolean inQuotes = false;
- int lastParmEnd = 0, i;
-
- this.sql = sql;
- this.connection = connection;
- for (i = 0; i < sql.length(); ++i)
- {
- int c = sql.charAt(i);
-
- if (c == '\'')
- inQuotes = !inQuotes;
- if (c == '?' && !inQuotes)
- {
- v.addElement(sql.substring (lastParmEnd, i));
- lastParmEnd = i + 1;
- }
- }
- v.addElement(sql.substring (lastParmEnd, sql.length()));
-
- templateStrings = new String[v.size()];
- inStrings = new String[v.size() - 1];
- clearParameters();
-
- for (i = 0 ; i < templateStrings.length; ++i)
- templateStrings[i] = (String)v.elementAt(i);
- }
-
- /*
- * A Prepared SQL query is executed and its ResultSet is returned
- *
- * @return a ResultSet that contains the data produced by the
- * * query - never null
- * @exception SQLException if a database access error occurs
- */
- public java.sql.ResultSet executeQuery() throws SQLException
- {
- StringBuffer s = new StringBuffer();
- int i;
-
- for (i = 0 ; i < inStrings.length ; ++i)
- {
- if (inStrings[i] == null)
- throw new PSQLException("postgresql.prep.param", new Integer(i + 1));
- s.append (templateStrings[i]);
- s.append (inStrings[i]);
- }
- s.append(templateStrings[inStrings.length]);
- return super.executeQuery(s.toString()); // in Statement class
- }
-
- /*
- * Execute a SQL INSERT, UPDATE or DELETE statement. In addition,
- * SQL statements that return nothing such as SQL DDL statements can
- * be executed.
- *
- * @return either the row count for INSERT, UPDATE or DELETE; or
- * * 0 for SQL statements that return nothing.
- * @exception SQLException if a database access error occurs
- */
- public int executeUpdate() throws SQLException
- {
- StringBuffer s = new StringBuffer();
- int i;
-
- for (i = 0 ; i < inStrings.length ; ++i)
- {
- if (inStrings[i] == null)
- throw new PSQLException("postgresql.prep.param", new Integer(i + 1));
- s.append (templateStrings[i]);
- s.append (inStrings[i]);
- }
- s.append(templateStrings[inStrings.length]);
- return super.executeUpdate(s.toString()); // in Statement class
- }
-
- /*
- * Set a parameter to SQL NULL
- *
- * <p><B>Note:</B> You must specify the parameters SQL type (although
- * PostgreSQL ignores it)
- *
- * @param parameterIndex the first parameter is 1, etc...
- * @param sqlType the SQL type code defined in java.sql.Types
- * @exception SQLException if a database access error occurs
- */
- public void setNull(int parameterIndex, int sqlType) throws SQLException
- {
- set(parameterIndex, "null");
- }
-
- /*
- * Set a parameter to a Java boolean value. The driver converts this
- * to a SQL BIT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setBoolean(int parameterIndex, boolean x) throws SQLException
- {
- set(parameterIndex, x ? "'t'" : "'f'");
- }
-
- /*
- * Set a parameter to a Java byte value. The driver converts this to
- * a SQL TINYINT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setByte(int parameterIndex, byte x) throws SQLException
- {
- set(parameterIndex, Integer.toString(x));
- }
-
- /*
- * Set a parameter to a Java short value. The driver converts this
- * to a SQL SMALLINT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setShort(int parameterIndex, short x) throws SQLException
- {
- set(parameterIndex, Integer.toString(x));
- }
-
- /*
- * Set a parameter to a Java int value. The driver converts this to
- * a SQL INTEGER value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setInt(int parameterIndex, int x) throws SQLException
- {
- set(parameterIndex, Integer.toString(x));
- }
-
- /*
- * Set a parameter to a Java long value. The driver converts this to
- * a SQL BIGINT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setLong(int parameterIndex, long x) throws SQLException
- {
- set(parameterIndex, Long.toString(x));
- }
-
- /*
- * Set a parameter to a Java float value. The driver converts this
- * to a SQL FLOAT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setFloat(int parameterIndex, float x) throws SQLException
- {
- set(parameterIndex, Float.toString(x));
- }
-
- /*
- * Set a parameter to a Java double value. The driver converts this
- * to a SQL DOUBLE value when it sends it to the database
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setDouble(int parameterIndex, double x) throws SQLException
- {
- set(parameterIndex, Double.toString(x));
- }
-
- /*
- * Set a parameter to a java.lang.BigDecimal value. The driver
- * converts this to a SQL NUMERIC value when it sends it to the
- * database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
- {
- if (x == null)
- setNull(parameterIndex, Types.OTHER);
- else
- {
- set(parameterIndex, x.toString());
- }
- }
-
- /*
- * Set a parameter to a Java String value. The driver converts this
- * to a SQL VARCHAR or LONGVARCHAR value (depending on the arguments
- * size relative to the driver's limits on VARCHARs) when it sends it
- * to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setString(int parameterIndex, String x) throws SQLException
- {
- // if the passed string is null, then set this column to null
- if (x == null)
- setNull(parameterIndex, Types.OTHER);
- else
- {
- StringBuffer b = new StringBuffer();
- int i;
-
- b.append('\'');
- for (i = 0 ; i < x.length() ; ++i)
- {
- char c = x.charAt(i);
- if (c == '\\' || c == '\'')
- b.append((char)'\\');
- b.append(c);
- }
- b.append('\'');
- set(parameterIndex, b.toString());
- }
- }
-
- /*
- * Set a parameter to a Java array of bytes. The driver converts this
- * to a SQL VARBINARY or LONGVARBINARY (depending on the argument's
- * size relative to the driver's limits on VARBINARYs) when it sends
- * it to the database.
- *
- * <p>Implementation note:
- * <br>With org.postgresql, this creates a large object, and stores the
- * objects oid in this column.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setBytes(int parameterIndex, byte x[]) throws SQLException
- {
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports the bytea datatype for byte arrays
- if (null == x)
- {
- setNull(parameterIndex, Types.OTHER);
- }
- else
- {
- setString(parameterIndex, PGbytea.toPGString(x));
- }
- }
- else
- {
- //Version 7.1 and earlier support done as LargeObjects
- LargeObjectManager lom = connection.getLargeObjectAPI();
- int oid = lom.create();
- LargeObject lob = lom.open(oid);
- lob.write(x);
- lob.close();
- setInt(parameterIndex, oid);
- }
- }
-
- /*
- * Set a parameter to a java.sql.Date value. The driver converts this
- * to a SQL DATE value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setDate(int parameterIndex, java.sql.Date x) throws SQLException
- {
- if (null == x)
- {
- setNull(parameterIndex, Types.OTHER);
- }
- else
- {
- SimpleDateFormat df = new SimpleDateFormat("''yyyy-MM-dd''");
- set(parameterIndex, df.format(x));
- }
- // The above is how the date should be handled.
- //
- // However, in JDK's prior to 1.1.6 (confirmed with the
- // Linux jdk1.1.3 and the Win95 JRE1.1.5), SimpleDateFormat seems
- // to format a date to the previous day. So the fix is to add a day
- // before formatting.
- //
- // PS: 86400000 is one day
- //
- //set(parameterIndex, df.format(new java.util.Date(x.getTime()+86400000)));
- }
-
- /*
- * Set a parameter to a java.sql.Time value. The driver converts
- * this to a SQL TIME value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...));
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setTime(int parameterIndex, Time x) throws SQLException
- {
- if (null == x)
- {
- setNull(parameterIndex, Types.OTHER);
- }
- else
- {
- set(parameterIndex, "'" + x.toString() + "'");
- }
- }
-
- /*
- * Set a parameter to a java.sql.Timestamp value. The driver converts
- * this to a SQL TIMESTAMP value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
- {
- if (null == x)
- {
- setNull(parameterIndex, Types.OTHER);
- }
- else
- {
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- df.setTimeZone(TimeZone.getTimeZone("GMT"));
-
- // Make decimal from nanos.
- StringBuffer decimal = new StringBuffer("000000000"); // max nanos length
- String nanos = String.valueOf(x.getNanos());
- decimal.setLength(decimal.length() - nanos.length());
- decimal.append(nanos);
- if (! connection.haveMinimumServerVersion("7.2")) {
- // Because 7.1 include bug that "hh:mm:59.999" becomes "hh:mm:60.00".
- decimal.setLength(2);
- }
-
- StringBuffer strBuf = new StringBuffer("'");
- strBuf.append(df.format(x)).append('.').append(decimal).append("+00'");
- set(parameterIndex, strBuf.toString());
- }
- }
-
- /*
- * When a very large ASCII value is input to a LONGVARCHAR parameter,
- * it may be more practical to send it via a java.io.InputStream.
- * JDBC will read the data from the stream as needed, until it reaches
- * end-of-file. The JDBC driver will do any necessary conversion from
- * ASCII to the database char format.
- *
- * <P><B>Note:</B> This stream object can either be a standard Java
- * stream object or your own subclass that implements the standard
- * interface.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @param length the number of bytes in the stream
- * @exception SQLException if a database access error occurs
- */
- public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports AsciiStream for all PG text types (char, varchar, text)
- //As the spec/javadoc for this method indicate this is to be used for
- //large String values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long varchar datatype, but with toast all text datatypes are capable of
- //handling very large values. Thus the implementation ends up calling
- //setString() since there is no current way to stream the value to the server
- try
- {
- InputStreamReader l_inStream = new InputStreamReader(x, "ASCII");
- char[] l_chars = new char[length];
- int l_charsRead = l_inStream.read(l_chars, 0, length);
- setString(parameterIndex, new String(l_chars, 0, l_charsRead));
- }
- catch (UnsupportedEncodingException l_uee)
- {
- throw new PSQLException("postgresql.unusual", l_uee);
- }
- catch (IOException l_ioe)
- {
- throw new PSQLException("postgresql.unusual", l_ioe);
- }
- }
- else
- {
- //Version 7.1 supported only LargeObjects by treating everything
- //as binary data
- setBinaryStream(parameterIndex, x, length);
- }
- }
-
- /*
- * When a very large Unicode value is input to a LONGVARCHAR parameter,
- * it may be more practical to send it via a java.io.InputStream.
- * JDBC will read the data from the stream as needed, until it reaches
- * end-of-file. The JDBC driver will do any necessary conversion from
- * UNICODE to the database char format.
- *
- * <P><B>Note:</B> This stream object can either be a standard Java
- * stream object or your own subclass that implements the standard
- * interface.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports AsciiStream for all PG text types (char, varchar, text)
- //As the spec/javadoc for this method indicate this is to be used for
- //large String values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long varchar datatype, but with toast all text datatypes are capable of
- //handling very large values. Thus the implementation ends up calling
- //setString() since there is no current way to stream the value to the server
- try
- {
- InputStreamReader l_inStream = new InputStreamReader(x, "UTF-8");
- char[] l_chars = new char[length];
- int l_charsRead = l_inStream.read(l_chars, 0, length);
- setString(parameterIndex, new String(l_chars, 0, l_charsRead));
- }
- catch (UnsupportedEncodingException l_uee)
- {
- throw new PSQLException("postgresql.unusual", l_uee);
- }
- catch (IOException l_ioe)
- {
- throw new PSQLException("postgresql.unusual", l_ioe);
- }
- }
- else
- {
- //Version 7.1 supported only LargeObjects by treating everything
- //as binary data
- setBinaryStream(parameterIndex, x, length);
- }
- }
-
- /*
- * When a very large binary value is input to a LONGVARBINARY parameter,
- * it may be more practical to send it via a java.io.InputStream.
- * JDBC will read the data from the stream as needed, until it reaches
- * end-of-file.
- *
- * <P><B>Note:</B> This stream object can either be a standard Java
- * stream object or your own subclass that implements the standard
- * interface.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports BinaryStream for for the PG bytea type
- //As the spec/javadoc for this method indicate this is to be used for
- //large binary values (i.e. LONGVARBINARY) PG doesn't have a separate
- //long binary datatype, but with toast the bytea datatype is capable of
- //handling very large values. Thus the implementation ends up calling
- //setBytes() since there is no current way to stream the value to the server
- byte[] l_bytes = new byte[length];
- int l_bytesRead;
- try
- {
- l_bytesRead = x.read(l_bytes, 0, length);
- }
- catch (IOException l_ioe)
- {
- throw new PSQLException("postgresql.unusual", l_ioe);
- }
- if (l_bytesRead == length)
- {
- setBytes(parameterIndex, l_bytes);
- }
- else
- {
- //the stream contained less data than they said
- byte[] l_bytes2 = new byte[l_bytesRead];
- System.arraycopy(l_bytes, 0, l_bytes2, 0, l_bytesRead);
- setBytes(parameterIndex, l_bytes2);
- }
- }
- else
- {
- //Version 7.1 only supported streams for LargeObjects
- //but the jdbc spec indicates that streams should be
- //available for LONGVARBINARY instead
- LargeObjectManager lom = connection.getLargeObjectAPI();
- int oid = lom.create();
- LargeObject lob = lom.open(oid);
- OutputStream los = lob.getOutputStream();
- try
- {
- // could be buffered, but then the OutputStream returned by LargeObject
- // is buffered internally anyhow, so there would be no performance
- // boost gained, if anything it would be worse!
- int c = x.read();
- int p = 0;
- while (c > -1 && p < length)
- {
- los.write(c);
- c = x.read();
- p++;
- }
- los.close();
- }
- catch (IOException se)
- {
- throw new PSQLException("postgresql.unusual", se);
- }
- // lob is closed by the stream so don't call lob.close()
- setInt(parameterIndex, oid);
- }
- }
-
- /*
- * In general, parameter values remain in force for repeated used of a
- * Statement. Setting a parameter value automatically clears its
- * previous value. However, in coms cases, it is useful to immediately
- * release the resources used by the current parameter values; this
- * can be done by calling clearParameters
- *
- * @exception SQLException if a database access error occurs
- */
- public void clearParameters() throws SQLException
- {
- int i;
-
- for (i = 0 ; i < inStrings.length ; i++)
- inStrings[i] = null;
- }
-
- /*
- * Set the value of a parameter using an object; use the java.lang
- * equivalent objects for integral values.
- *
- * <P>The given Java object will be converted to the targetSqlType before
- * being sent to the database.
- *
- * <P>note that this method may be used to pass database-specific
- * abstract data types. This is done by using a Driver-specific
- * Java type and using a targetSqlType of java.sql.Types.OTHER
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the object containing the input parameter value
- * @param targetSqlType The SQL type to be send to the database
- * @param scale For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC
- * * types this is the number of digits after the decimal. For
- * * all other types this value will be ignored.
- * @exception SQLException if a database access error occurs
- */
- public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
- {
- if (x == null)
- {
- setNull(parameterIndex, Types.OTHER);
- return;
- }
- switch (targetSqlType)
- {
- case Types.TINYINT:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.REAL:
- case Types.FLOAT:
- case Types.DOUBLE:
- case Types.DECIMAL:
- case Types.NUMERIC:
- if (x instanceof Boolean)
- set(parameterIndex, ((Boolean)x).booleanValue() ? "1" : "0");
- else
- set(parameterIndex, x.toString());
- break;
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- setString(parameterIndex, x.toString());
- break;
- case Types.DATE:
- setDate(parameterIndex, (java.sql.Date)x);
- break;
- case Types.TIME:
- setTime(parameterIndex, (Time)x);
- break;
- case Types.TIMESTAMP:
- setTimestamp(parameterIndex, (Timestamp)x);
- break;
- case Types.BIT:
- if (x instanceof Boolean)
- {
- set(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE");
- }
- else
- {
- throw new PSQLException("postgresql.prep.type");
- }
- break;
- case Types.BINARY:
- case Types.VARBINARY:
- setObject(parameterIndex, x);
- break;
- case Types.OTHER:
- setString(parameterIndex, ((PGobject)x).getValue());
- break;
- default:
- throw new PSQLException("postgresql.prep.type");
- }
- }
-
- public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
- {
- setObject(parameterIndex, x, targetSqlType, 0);
- }
-
- /*
- * This stores an Object into a parameter.
- * <p>New for 6.4, if the object is not recognised, but it is
- * Serializable, then the object is serialised using the
- * org.postgresql.util.Serialize class.
- */
- public void setObject(int parameterIndex, Object x) throws SQLException
- {
- if (x == null)
- {
- setNull(parameterIndex, Types.OTHER);
- return;
- }
- if (x instanceof String)
- setString(parameterIndex, (String)x);
- else if (x instanceof BigDecimal)
- setBigDecimal(parameterIndex, (BigDecimal)x);
- else if (x instanceof Short)
- setShort(parameterIndex, ((Short)x).shortValue());
- else if (x instanceof Integer)
- setInt(parameterIndex, ((Integer)x).intValue());
- else if (x instanceof Long)
- setLong(parameterIndex, ((Long)x).longValue());
- else if (x instanceof Float)
- setFloat(parameterIndex, ((Float)x).floatValue());
- else if (x instanceof Double)
- setDouble(parameterIndex, ((Double)x).doubleValue());
- else if (x instanceof byte[])
- setBytes(parameterIndex, (byte[])x);
- else if (x instanceof java.sql.Date)
- setDate(parameterIndex, (java.sql.Date)x);
- else if (x instanceof Time)
- setTime(parameterIndex, (Time)x);
- else if (x instanceof Timestamp)
- setTimestamp(parameterIndex, (Timestamp)x);
- else if (x instanceof Boolean)
- setBoolean(parameterIndex, ((Boolean)x).booleanValue());
- else if (x instanceof PGobject)
- setString(parameterIndex, ((PGobject)x).getValue());
- else
- setLong(parameterIndex, connection.storeObject(x));
- }
-
- /*
- * Some prepared statements return multiple results; the execute method
- * handles these complex statements as well as the simpler form of
- * statements handled by executeQuery and executeUpdate
- *
- * @return true if the next result is a ResultSet; false if it is an
- * * update count or there are no more results
- * @exception SQLException if a database access error occurs
- */
- public boolean execute() throws SQLException
- {
- StringBuffer s = new StringBuffer();
- int i;
-
- for (i = 0 ; i < inStrings.length ; ++i)
- {
- if (inStrings[i] == null)
- throw new PSQLException("postgresql.prep.param", new Integer(i + 1));
- s.append (templateStrings[i]);
- s.append (inStrings[i]);
- }
- s.append(templateStrings[inStrings.length]);
- return super.execute(s.toString()); // in Statement class
- }
-
- /*
- * Returns the SQL statement with the current template values
- * substituted.
- */
- public String toString()
- {
- StringBuffer s = new StringBuffer();
- int i;
-
- for (i = 0 ; i < inStrings.length ; ++i)
- {
- if (inStrings[i] == null)
- s.append( '?' );
- else
- s.append (templateStrings[i]);
- s.append (inStrings[i]);
- }
- s.append(templateStrings[inStrings.length]);
- return s.toString();
- }
-
- // **************************************************************
- // END OF PUBLIC INTERFACE
- // **************************************************************
-
- /*
- * There are a lot of setXXX classes which all basically do
- * the same thing. We need a method which actually does the
- * set for us.
- *
- * @param paramIndex the index into the inString
- * @param s a string to be stored
- * @exception SQLException if something goes wrong
- */
- private void set(int paramIndex, String s) throws SQLException
- {
- if (paramIndex < 1 || paramIndex > inStrings.length)
- throw new PSQLException("postgresql.prep.range");
- inStrings[paramIndex - 1] = s;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
deleted file mode 100644
index a7d0389d560..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
+++ /dev/null
@@ -1,1006 +0,0 @@
-package org.postgresql.jdbc1;
-
-// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 2 class in the
-// org.postgresql.jdbc2 package.
-
-import java.lang.*;
-import java.io.*;
-import java.math.*;
-import java.text.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.Field;
-import org.postgresql.largeobject.*;
-import org.postgresql.util.*;
-import org.postgresql.core.Encoding;
-
-/*
- * A ResultSet provides access to a table of data generated by executing a
- * Statement. The table rows are retrieved in sequence. Within a row its
- * column values can be accessed in any order.
- *
- * <P>A ResultSet maintains a cursor pointing to its current row of data.
- * Initially the cursor is positioned before the first row. The 'next'
- * method moves the cursor to the next row.
- *
- * <P>The getXXX methods retrieve column values for the current row. You can
- * retrieve values either using the index number of the column, or by using
- * the name of the column. In general using the column index will be more
- * efficient. Columns are numbered from 1.
- *
- * <P>For maximum portability, ResultSet columns within each row should be read
- * in left-to-right order and each column should be read only once.
- *
- *<P> For the getXXX methods, the JDBC driver attempts to convert the
- * underlying data to the specified Java type and returns a suitable Java
- * value. See the JDBC specification for allowable mappings from SQL types
- * to Java types with the ResultSet getXXX methods.
- *
- * <P>Column names used as input to getXXX methods are case insenstive. When
- * performing a getXXX using a column name, if several columns have the same
- * name, then the value of the first matching column will be returned. The
- * column name option is designed to be used when column names are used in the
- * SQL Query. For columns that are NOT explicitly named in the query, it is
- * best to use column numbers. If column names were used there is no way for
- * the programmer to guarentee that they actually refer to the intended
- * columns.
- *
- * <P>A ResultSet is automatically closed by the Statement that generated it
- * when that Statement is closed, re-executed, or is used to retrieve the
- * next result from a sequence of multiple results.
- *
- * <P>The number, types and properties of a ResultSet's columns are provided by
- * the ResultSetMetaData object returned by the getMetaData method.
- *
- * @see ResultSetMetaData
- * @see java.sql.ResultSet
- */
-public class ResultSet extends org.postgresql.ResultSet implements java.sql.ResultSet
-{
- /*
- * Create a new ResultSet - Note that we create ResultSets to
- * represent the results of everything.
- *
- * @param fields an array of Field objects (basically, the
- * ResultSet MetaData)
- * @param tuples Vector of the actual data
- * @param status the status string returned from the back end
- * @param updateCount the number of rows affected by the operation
- * @param cursor the positioned update/delete cursor name
- */
- public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
- {
- super(conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
- }
-
- /*
- * Create a new ResultSet - Note that we create ResultSets to
- * represent the results of everything.
- *
- * @param fields an array of Field objects (basically, the
- * ResultSet MetaData)
- * @param tuples Vector of the actual data
- * @param status the status string returned from the back end
- * @param updateCount the number of rows affected by the operation
- * @param cursor the positioned update/delete cursor name
- */
- public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
- {
- super(conn, fields, tuples, status, updateCount, 0, false);
- }
-
- /*
- * A ResultSet is initially positioned before its first row,
- * the first call to next makes the first row the current row;
- * the second call makes the second row the current row, etc.
- *
- * <p>If an input stream from the previous row is open, it is
- * implicitly closed. The ResultSet's warning chain is cleared
- * when a new row is read
- *
- * @return true if the new current is valid; false if there are no
- * more rows
- * @exception SQLException if a database access error occurs
- */
- public boolean next() throws SQLException
- {
- if (rows == null)
- throw new PSQLException("postgresql.con.closed");
-
- if (++current_row >= rows.size())
- return false;
- this_row = (byte [][])rows.elementAt(current_row);
- return true;
- }
-
- /*
- * In some cases, it is desirable to immediately release a ResultSet
- * database and JDBC resources instead of waiting for this to happen
- * when it is automatically closed. The close method provides this
- * immediate release.
- *
- * <p><B>Note:</B> A ResultSet is automatically closed by the Statement
- * the Statement that generated it when that Statement is closed,
- * re-executed, or is used to retrieve the next result from a sequence
- * of multiple results. A ResultSet is also automatically closed
- * when it is garbage collected.
- *
- * @exception SQLException if a database access error occurs
- */
- public void close() throws SQLException
- {
- //release resources held (memory for tuples)
- rows.setSize(0);
- }
-
- /*
- * A column may have the value of SQL NULL; wasNull() reports whether
- * the last column read had this special value. Note that you must
- * first call getXXX on a column to try to read its value and then
- * call wasNull() to find if the value was SQL NULL
- *
- * @return true if the last column read was SQL NULL
- * @exception SQLException if a database access error occurred
- */
- public boolean wasNull() throws SQLException
- {
- return wasNullFlag;
- }
-
- /*
- * Get the value of a column in the current row as a Java String
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value, null for SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public String getString(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (wasNullFlag)
- return null;
-
- Encoding encoding = connection.getEncoding();
- return encoding.decode(this_row[columnIndex - 1]);
- }
-
- /*
- * Get the value of a column in the current row as a Java boolean
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value, false for SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public boolean getBoolean(int columnIndex) throws SQLException
- {
- String s = getString(columnIndex);
-
- if (s != null)
- {
- int c = s.charAt(0);
- return ((c == 't') || (c == 'T') || (c == '1'));
- }
- return false; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a Java byte.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public byte getByte(int columnIndex) throws SQLException
- {
- String s = getString(columnIndex);
-
- if (s != null)
- {
- try
- {
- return Byte.parseByte(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.res.badbyte", s);
- }
- }
- return 0; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a Java short.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public short getShort(int columnIndex) throws SQLException
- {
- String s = getFixedString(columnIndex);
-
- if (s != null)
- {
- try
- {
- return Short.parseShort(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.res.badshort", s);
- }
- }
- return 0; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a Java int.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public int getInt(int columnIndex) throws SQLException
- {
- String s = getFixedString(columnIndex);
-
- if (s != null)
- {
- try
- {
- return Integer.parseInt(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.badint", s);
- }
- }
- return 0; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a Java long.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public long getLong(int columnIndex) throws SQLException
- {
- String s = getFixedString(columnIndex);
-
- if (s != null)
- {
- try
- {
- return Long.parseLong(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.badlong", s);
- }
- }
- return 0; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a Java float.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public float getFloat(int columnIndex) throws SQLException
- {
- String s = getFixedString(columnIndex);
-
- if (s != null)
- {
- try
- {
- return Float.valueOf(s).floatValue();
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.badfloat", s);
- }
- }
- return 0; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a Java double.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public double getDouble(int columnIndex) throws SQLException
- {
- String s = getFixedString(columnIndex);
-
- if (s != null)
- {
- try
- {
- return Double.valueOf(s).doubleValue();
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.baddouble", s);
- }
- }
- return 0; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a
- * java.math.BigDecimal object
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @param scale the number of digits to the right of the decimal
- * @return the column value; if the value is SQL NULL, null
- * @exception SQLException if a database access error occurs
- */
- public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException
- {
- String s = getFixedString(columnIndex);
- BigDecimal val;
-
- if (s != null)
- {
- try
- {
- val = new BigDecimal(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.badbigdec", s);
- }
- try
- {
- return val.setScale(scale);
- }
- catch (ArithmeticException e)
- {
- throw new PSQLException ("postgresql.res.badbigdec", s);
- }
- }
- return null; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a Java byte array.
- *
- * <p>In normal use, the bytes represent the raw values returned by the
- * backend. However, if the column is an OID, then it is assumed to
- * refer to a Large Object, and that object is returned as a byte array.
- *
- * <p><b>Be warned</b> If the large object is huge, then you may run out
- * of memory.
- *
- * @param columnIndex the first column is 1, the second is 2, ...
- * @return the column value; if the value is SQL NULL, the result
- * is null
- * @exception SQLException if a database access error occurs
- */
- public byte[] getBytes(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (!wasNullFlag)
- {
- if (binaryCursor)
- {
- //If the data is already binary then just return it
- return this_row[columnIndex - 1];
- }
- else if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports the bytea datatype for byte arrays
- if (fields[columnIndex - 1].getPGType().equals("bytea"))
- {
- return PGbytea.toBytes(this_row[columnIndex - 1]);
- }
- else
- {
- return this_row[columnIndex - 1];
- }
- }
- else
- {
- //Version 7.1 and earlier supports LargeObjects for byte arrays
- // Handle OID's as BLOBS
- if ( fields[columnIndex - 1].getOID() == 26)
- {
- LargeObjectManager lom = connection.getLargeObjectAPI();
- LargeObject lob = lom.open(getInt(columnIndex));
- byte buf[] = lob.read(lob.size());
- lob.close();
- return buf;
- }
- else
- {
- return this_row[columnIndex - 1];
- }
- }
- }
- return null;
- }
-
- /*
- * Get the value of a column in the current row as a java.sql.Date
- * object
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value; null if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public java.sql.Date getDate(int columnIndex) throws SQLException
- {
- String s = getString(columnIndex);
- if (s == null)
- return null;
- // length == 10: SQL Date
- // length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
- try
- {
- return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0, 10));
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.res.baddate", s);
- }
- }
-
- /*
- * Get the value of a column in the current row as a java.sql.Time
- * object
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value; null if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public Time getTime(int columnIndex) throws SQLException
- {
- String s = getString(columnIndex);
-
- if (s != null)
- {
- try
- {
- if (s.length() != 5 && s.length() != 8)
- throw new NumberFormatException("Wrong Length!");
- int hr = Integer.parseInt(s.substring(0, 2));
- int min = Integer.parseInt(s.substring(3, 5));
- int sec = (s.length() == 5) ? 0 : Integer.parseInt(s.substring(6));
- return new Time(hr, min, sec);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.badtime", s);
- }
- }
- return null; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a
- * java.sql.Timestamp object
- *
- * The driver is set to return ISO date formated strings. We modify this
- * string from the ISO format to a format that Java can understand. Java
- * expects timezone info as 'GMT+09:00' where as ISO gives '+09'.
- * Java also expects fractional seconds to 3 places where postgres
- * will give, none, 2 or 6 depending on the time and postgres version.
- * From version 7.2 postgres returns fractional seconds to 6 places.
- * If available, we drop the last 3 digits.
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value; null if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public Timestamp getTimestamp(int columnIndex) throws SQLException
- {
- String s = getString(columnIndex);
-
- if (s == null)
- return null;
-
- StringBuffer sbuf = new StringBuffer(s);
- SimpleDateFormat df = null;
-
- int slen = s.length();
-
- if (slen > 19)
- {
- // The len of the ISO string to the second value is 19 chars. If
- // greater then 19, there should be tz info and perhaps fractional
- // second info which we need to change to java to read it.
-
- // cut the copy to second value "2001-12-07 16:29:22"
- int i = 19;
- sbuf.setLength(i);
-
- char c = s.charAt(i++);
- if (c == '.')
- {
- // Found a fractional value. Append up to 3 digits including
- // the leading '.'
- do
- {
- if (i < 24)
- sbuf.append(c);
- c = s.charAt(i++);
- } while (i < slen && Character.isDigit(c));
-
- // If there wasn't at least 3 digits we should add some zeros
- // to make up the 3 digits we tell java to expect.
- for (int j = i; j < 24; j++)
- sbuf.append('0');
- }
- else
- {
- // No fractional seconds, lets add some.
- sbuf.append(".000");
- }
-
- if (i < slen)
- {
- // prepend the GMT part and then add the remaining bit of
- // the string.
- sbuf.append(" GMT");
- sbuf.append(c);
- sbuf.append(s.substring(i, slen));
-
- // Lastly, if the tz part doesn't specify the :MM part then
- // we add ":00" for java.
- if (slen - i < 5)
- sbuf.append(":00");
-
- // we'll use this dateformat string to parse the result.
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
- }
- else
- {
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- }
- }
- else if (slen == 19)
- {
- // No tz or fractional second info.
- // I'm not sure if it is
- // possible to have a string in this format, as pg
- // should give us tz qualified timestamps back, but it was
- // in the old code, so I'm handling it for now.
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- }
- else
- {
- // We must just have a date. This case is
- // needed if this method is called on a date column
- df = new SimpleDateFormat("yyyy-MM-dd");
- }
-
- try
- {
- // All that's left is to parse the string and return the ts.
- return new Timestamp(df.parse(sbuf.toString()).getTime());
- }
- catch (ParseException e)
- {
- throw new PSQLException("postgresql.res.badtimestamp", new Integer(e.getErrorOffset()), s);
- }
- }
-
- /*
- * A column value can be retrieved as a stream of ASCII characters
- * and then read in chunks from the stream. This method is
- * particular suitable for retrieving large LONGVARCHAR values.
- * The JDBC driver will do any necessary conversion from the
- * database format into ASCII.
- *
- * <p><B>Note:</B> All the data in the returned stream must be read
- * prior to getting the value of any other column. The next call
- * to a get method implicitly closes the stream. Also, a stream
- * may return 0 for available() whether there is data available
- * or not.
- *
- *<p> We implement an ASCII stream as a Binary stream - we should really
- * do the data conversion, but I cannot be bothered to implement this
- * right now.
- *
- * @param columnIndex the first column is 1, the second is 2, ...
- * @return a Java InputStream that delivers the database column
- * value as a stream of one byte ASCII characters. If the
- * value is SQL NULL then the result is null
- * @exception SQLException if a database access error occurs
- * @see getBinaryStream
- */
- public InputStream getAsciiStream(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (wasNullFlag)
- return null;
-
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports AsciiStream for all the PG text types
- //As the spec/javadoc for this method indicate this is to be used for
- //large text values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long string datatype, but with toast the text datatype is capable of
- //handling very large values. Thus the implementation ends up calling
- //getString() since there is no current way to stream the value from the server
- try
- {
- return new ByteArrayInputStream(getString(columnIndex).getBytes("ASCII"));
- }
- catch (UnsupportedEncodingException l_uee)
- {
- throw new PSQLException("postgresql.unusual", l_uee);
- }
- }
- else
- {
- // In 7.1 Handle as BLOBS so return the LargeObject input stream
- return getBinaryStream(columnIndex);
- }
- }
-
- /*
- * A column value can also be retrieved as a stream of Unicode
- * characters. We implement this as a binary stream.
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return a Java InputStream that delivers the database column value
- * as a stream of two byte Unicode characters. If the value is
- * SQL NULL, then the result is null
- * @exception SQLException if a database access error occurs
- * @see getAsciiStream
- * @see getBinaryStream
- */
- public InputStream getUnicodeStream(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (wasNullFlag)
- return null;
-
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports AsciiStream for all the PG text types
- //As the spec/javadoc for this method indicate this is to be used for
- //large text values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long string datatype, but with toast the text datatype is capable of
- //handling very large values. Thus the implementation ends up calling
- //getString() since there is no current way to stream the value from the server
- try
- {
- return new ByteArrayInputStream(getString(columnIndex).getBytes("UTF-8"));
- }
- catch (UnsupportedEncodingException l_uee)
- {
- throw new PSQLException("postgresql.unusual", l_uee);
- }
- }
- else
- {
- // In 7.1 Handle as BLOBS so return the LargeObject input stream
- return getBinaryStream(columnIndex);
- }
- }
-
- /*
- * A column value can also be retrieved as a binary strea. This
- * method is suitable for retrieving LONGVARBINARY values.
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return a Java InputStream that delivers the database column value
- * as a stream of bytes. If the value is SQL NULL, then the result
- * is null
- * @exception SQLException if a database access error occurs
- * @see getAsciiStream
- * @see getUnicodeStream
- */
- public InputStream getBinaryStream(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (wasNullFlag)
- return null;
-
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports BinaryStream for all PG bytea type
- //As the spec/javadoc for this method indicate this is to be used for
- //large binary values (i.e. LONGVARBINARY) PG doesn't have a separate
- //long binary datatype, but with toast the bytea datatype is capable of
- //handling very large values. Thus the implementation ends up calling
- //getBytes() since there is no current way to stream the value from the server
- byte b[] = getBytes(columnIndex);
- if (b != null)
- return new ByteArrayInputStream(b);
- }
- else
- {
- // In 7.1 Handle as BLOBS so return the LargeObject input stream
- if ( fields[columnIndex - 1].getOID() == 26)
- {
- LargeObjectManager lom = connection.getLargeObjectAPI();
- LargeObject lob = lom.open(getInt(columnIndex));
- return lob.getInputStream();
- }
- }
- return null;
- }
-
- /*
- * The following routines simply convert the columnName into
- * a columnIndex and then call the appropriate routine above.
- *
- * @param columnName is the SQL name of the column
- * @return the column value
- * @exception SQLException if a database access error occurs
- */
- public String getString(String columnName) throws SQLException
- {
- return getString(findColumn(columnName));
- }
-
- public boolean getBoolean(String columnName) throws SQLException
- {
- return getBoolean(findColumn(columnName));
- }
-
- public byte getByte(String columnName) throws SQLException
- {
-
- return getByte(findColumn(columnName));
- }
-
- public short getShort(String columnName) throws SQLException
- {
- return getShort(findColumn(columnName));
- }
-
- public int getInt(String columnName) throws SQLException
- {
- return getInt(findColumn(columnName));
- }
-
- public long getLong(String columnName) throws SQLException
- {
- return getLong(findColumn(columnName));
- }
-
- public float getFloat(String columnName) throws SQLException
- {
- return getFloat(findColumn(columnName));
- }
-
- public double getDouble(String columnName) throws SQLException
- {
- return getDouble(findColumn(columnName));
- }
-
- public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException
- {
- return getBigDecimal(findColumn(columnName), scale);
- }
-
- public byte[] getBytes(String columnName) throws SQLException
- {
- return getBytes(findColumn(columnName));
- }
-
- public java.sql.Date getDate(String columnName) throws SQLException
- {
- return getDate(findColumn(columnName));
- }
-
- public Time getTime(String columnName) throws SQLException
- {
- return getTime(findColumn(columnName));
- }
-
- public Timestamp getTimestamp(String columnName) throws SQLException
- {
- return getTimestamp(findColumn(columnName));
- }
-
- public InputStream getAsciiStream(String columnName) throws SQLException
- {
- return getAsciiStream(findColumn(columnName));
- }
-
- public InputStream getUnicodeStream(String columnName) throws SQLException
- {
- return getUnicodeStream(findColumn(columnName));
- }
-
- public InputStream getBinaryStream(String columnName) throws SQLException
- {
- return getBinaryStream(findColumn(columnName));
- }
-
- /*
- * The first warning reported by calls on this ResultSet is
- * returned. Subsequent ResultSet warnings will be chained
- * to this SQLWarning.
- *
- * <p>The warning chain is automatically cleared each time a new
- * row is read.
- *
- * <p><B>Note:</B> This warning chain only covers warnings caused by
- * ResultSet methods. Any warnings caused by statement methods
- * (such as reading OUT parameters) will be chained on the
- * Statement object.
- *
- * @return the first SQLWarning or null;
- * @exception SQLException if a database access error occurs.
- */
- public SQLWarning getWarnings() throws SQLException
- {
- return warnings;
- }
-
- /*
- * After this call, getWarnings returns null until a new warning
- * is reported for this ResultSet
- *
- * @exception SQLException if a database access error occurs
- */
- public void clearWarnings() throws SQLException
- {
- warnings = null;
- }
-
- /*
- * Get the name of the SQL cursor used by this ResultSet
- *
- * <p>In SQL, a result table is retrieved though a cursor that is
- * named. The current row of a result can be updated or deleted
- * using a positioned update/delete statement that references
- * the cursor name.
- *
- * <p>JDBC supports this SQL feature by providing the name of the
- * SQL cursor used by a ResultSet. The current row of a ResulSet
- * is also the current row of this SQL cursor.
- *
- * <p><B>Note:</B> If positioned update is not supported, a SQLException
- * is thrown.
- *
- * @return the ResultSet's SQL cursor name.
- * @exception SQLException if a database access error occurs
- */
- public String getCursorName() throws SQLException
- {
- return connection.getCursorName();
- }
-
- /*
- * The numbers, types and properties of a ResultSet's columns are
- * provided by the getMetaData method
- *
- * @return a description of the ResultSet's columns
- * @exception SQLException if a database access error occurs
- */
- public java.sql.ResultSetMetaData getMetaData() throws SQLException
- {
- return new ResultSetMetaData(rows, fields);
- }
-
- /*
- * Get the value of a column in the current row as a Java object
- *
- * <p>This method will return the value of the given column as a
- * Java object. The type of the Java object will be the default
- * Java Object type corresponding to the column's SQL type, following
- * the mapping specified in the JDBC specification.
- *
- * <p>This method may also be used to read database specific abstract
- * data types.
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return a Object holding the column value
- * @exception SQLException if a database access error occurs
- */
- public Object getObject(int columnIndex) throws SQLException
- {
- Field field;
-
- if (columnIndex < 1 || columnIndex > fields.length)
- throw new PSQLException("postgresql.res.colrange");
- field = fields[columnIndex - 1];
-
- // some fields can be null, mainly from those returned by MetaData methods
- if (field == null)
- {
- wasNullFlag = true;
- return null;
- }
-
- switch (field.getSQLType())
- {
- case Types.BIT:
- return new Boolean(getBoolean(columnIndex));
- case Types.SMALLINT:
- return new Short((short)getInt(columnIndex));
- case Types.INTEGER:
- return new Integer(getInt(columnIndex));
- case Types.BIGINT:
- return new Long(getLong(columnIndex));
- case Types.NUMERIC:
- return getBigDecimal(columnIndex, ((field.getMod() - 4) & 0xffff));
- case Types.REAL:
- return new Float(getFloat(columnIndex));
- case Types.DOUBLE:
- return new Double(getDouble(columnIndex));
- case Types.CHAR:
- case Types.VARCHAR:
- return getString(columnIndex);
- case Types.DATE:
- return getDate(columnIndex);
- case Types.TIME:
- return getTime(columnIndex);
- case Types.TIMESTAMP:
- return getTimestamp(columnIndex);
- case Types.BINARY:
- case Types.VARBINARY:
- return getBytes(columnIndex);
- default:
- String type = field.getPGType();
- // if the backend doesn't know the type then coerce to String
- if (type.equals("unknown"))
- {
- return getString(columnIndex);
- }
- else
- {
- return connection.getObject(field.getPGType(), getString(columnIndex));
- }
- }
- }
-
- /*
- * Get the value of a column in the current row as a Java object
- *
- *<p> This method will return the value of the given column as a
- * Java object. The type of the Java object will be the default
- * Java Object type corresponding to the column's SQL type, following
- * the mapping specified in the JDBC specification.
- *
- * <p>This method may also be used to read database specific abstract
- * data types.
- *
- * @param columnName is the SQL name of the column
- * @return a Object holding the column value
- * @exception SQLException if a database access error occurs
- */
- public Object getObject(String columnName) throws SQLException
- {
- return getObject(findColumn(columnName));
- }
-
- /*
- * Map a ResultSet column name to a ResultSet column index
- *
- * @param columnName the name of the column
- * @return the column index
- * @exception SQLException if a database access error occurs
- */
- public int findColumn(String columnName) throws SQLException
- {
- int i;
-
- for (i = 0 ; i < fields.length; ++i)
- if (fields[i].getName().equalsIgnoreCase(columnName))
- return (i + 1);
- throw new PSQLException ("postgresql.res.colname", columnName);
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java
deleted file mode 100644
index ee737604a1e..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java
+++ /dev/null
@@ -1,476 +0,0 @@
-package org.postgresql.jdbc1;
-
-// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 2 class in the
-// org.postgresql.jdbc2 package.
-
-import java.lang.*;
-import java.util.*;
-import org.postgresql.*;
-import org.postgresql.util.*;
-
-// We explicitly import classes here as the original line:
-//import java.sql.*;
-// causes javac to get confused.
-import java.sql.SQLException;
-import java.sql.Types;
-
-/*
- * A ResultSetMetaData object can be used to find out about the types and
- * properties of the columns in a ResultSet
- *
- * @see java.sql.ResultSetMetaData
- */
-public class ResultSetMetaData implements java.sql.ResultSetMetaData
-{
- Vector rows;
- Field[] fields;
-
- /*
- * Initialise for a result with a tuple set and
- * a field descriptor set
- *
- * @param rows the Vector of rows returned by the ResultSet
- * @param fields the array of field descriptors
- */
- public ResultSetMetaData(Vector rows, Field[] fields)
- {
- this.rows = rows;
- this.fields = fields;
- }
-
- /*
- * Whats the number of columns in the ResultSet?
- *
- * @return the number
- * @exception SQLException if a database access error occurs
- */
- public int getColumnCount() throws SQLException
- {
- return fields.length;
- }
-
- /*
- * Is the column automatically numbered (and thus read-only)
- * I believe that PostgreSQL does not support this feature.
- *
- * @param column the first column is 1, the second is 2...
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isAutoIncrement(int column) throws SQLException
- {
- return false;
- }
-
- /*
- * Does a column's case matter? ASSUMPTION: Any field that is
- * not obviously case insensitive is assumed to be case sensitive
- *
- * @param column the first column is 1, the second is 2...
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isCaseSensitive(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- switch (sql_type)
- {
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- return false;
- default:
- return true;
- }
- }
-
- /*
- * Can the column be used in a WHERE clause? Basically for
- * this, I split the functions into two types: recognised
- * types (which are always useable), and OTHER types (which
- * may or may not be useable). The OTHER types, for now, I
- * will assume they are useable. We should really query the
- * catalog to see if they are useable.
- *
- * @param column the first column is 1, the second is 2...
- * @return true if they can be used in a WHERE clause
- * @exception SQLException if a database access error occurs
- */
- public boolean isSearchable(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- // This switch is pointless, I know - but it is a set-up
- // for further expansion.
- switch (sql_type)
- {
- case Types.OTHER:
- return true;
- default:
- return true;
- }
- }
-
- /*
- * Is the column a cash value? 6.1 introduced the cash/money
- * type, which haven't been incorporated as of 970414, so I
- * just check the type name for both 'cash' and 'money'
- *
- * @param column the first column is 1, the second is 2...
- * @return true if its a cash column
- * @exception SQLException if a database access error occurs
- */
- public boolean isCurrency(int column) throws SQLException
- {
- String type_name = getField(column).getPGType();
-
- return type_name.equals("cash") || type_name.equals("money");
- }
-
- /*
- * Indicates the nullability of values in the designated column.
- *
- * @param column the first column is 1, the second is 2...
- * @return one of the columnNullable values
- * @exception SQLException if a database access error occurs
- */
- public int isNullable(int column) throws SQLException
- {
- /*
- * TODO This needs a real implementation, taking into account columns
- * defined with NOT NULL or PRIMARY KEY, CHECK constraints, views,
- * functions etc.
- */
- return columnNullableUnknown;
- }
-
- /*
- * Is the column a signed number? In PostgreSQL, all numbers
- * are signed, so this is trivial. However, strings are not
- * signed (duh!)
- *
- * @param column the first column is 1, the second is 2...
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isSigned(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- switch (sql_type)
- {
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- return true;
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- return false; // I don't know about these?
- default:
- return false;
- }
- }
-
- /*
- * What is the column's normal maximum width in characters?
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the maximum width
- * @exception SQLException if a database access error occurs
- */
- public int getColumnDisplaySize(int column) throws SQLException
- {
- Field f = getField(column);
- String type_name = f.getPGType();
- int sql_type = f.getSQLType();
- int typmod = f.getMod();
-
- // I looked at other JDBC implementations and couldn't find a consistent
- // interpretation of the "display size" for numeric values, so this is our's
- // FIXME: currently, only types with a SQL92 or SQL3 pendant are implemented - jens@jens.de
-
- // fixed length data types
- if (type_name.equals( "int2" ))
- return 6; // -32768 to +32768 (5 digits and a sign)
- if (type_name.equals( "int4" )
- || type_name.equals( "oid" ))
- return 11; // -2147483648 to +2147483647
- if (type_name.equals( "int8" ))
- return 20; // -9223372036854775808 to +9223372036854775807
- if (type_name.equals( "money" ))
- return 12; // MONEY = DECIMAL(9,2)
- if (type_name.equals( "float4" ))
- return 11; // i checked it out ans wasn't able to produce more than 11 digits
- if (type_name.equals( "float8" ))
- return 20; // dito, 20
- if (type_name.equals( "char" ))
- return 1;
- if (type_name.equals( "bool" ))
- return 1;
- if (type_name.equals( "date" ))
- return 14; // "01/01/4713 BC" - "31/12/32767 AD"
- if (type_name.equals( "time" ))
- return 8; // 00:00:00-23:59:59
- if (type_name.equals( "timestamp" ))
- return 22; // hhmmm ... the output looks like this: 1999-08-03 22:22:08+02
-
- // variable length fields
- typmod -= 4;
- if (type_name.equals( "bpchar" )
- || type_name.equals( "varchar" ))
- return typmod; // VARHDRSZ=sizeof(int32)=4
- if (type_name.equals( "numeric" ))
- return ( (typmod >> 16) & 0xffff )
- + 1 + ( typmod & 0xffff ); // DECIMAL(p,s) = (p digits).(s digits)
-
- // if we don't know better
- return f.getLength();
- }
-
- /*
- * What is the suggested column title for use in printouts and
- * displays? We suggest the ColumnName!
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the column label
- * @exception SQLException if a database access error occurs
- */
- public String getColumnLabel(int column) throws SQLException
- {
- return getColumnName(column);
- }
-
- /*
- * What's a column's name?
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the column name
- * @exception SQLException if a database access error occurs
- */
- public String getColumnName(int column) throws SQLException
- {
- Field f = getField(column);
- if (f != null)
- return f.getName();
- return "field" + column;
- }
-
- /*
- * What is a column's table's schema? This relies on us knowing
- * the table name....which I don't know how to do as yet. The
- * JDBC specification allows us to return "" if this is not
- * applicable.
- *
- * @param column the first column is 1, the second is 2...
- * @return the Schema
- * @exception SQLException if a database access error occurs
- */
- public String getSchemaName(int column) throws SQLException
- {
- return "";
- }
-
- /*
- * What is a column's number of decimal digits.
- *
- * @param column the first column is 1, the second is 2...
- * @return the precision
- * @exception SQLException if a database access error occurs
- */
- public int getPrecision(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- switch (sql_type)
- {
- case Types.SMALLINT:
- return 5;
- case Types.INTEGER:
- return 10;
- case Types.REAL:
- return 8;
- case Types.FLOAT:
- return 16;
- case Types.DOUBLE:
- return 16;
- case Types.VARCHAR:
- return 0;
- case Types.NUMERIC:
- Field f = getField(column);
- if (f != null)
- return ((0xFFFF0000)&f.getMod()) >> 16;
- else
- return 0;
- default:
- return 0;
- }
- }
-
- /*
- * What is a column's number of digits to the right of the
- * decimal point?
- *
- * @param column the first column is 1, the second is 2...
- * @return the scale
- * @exception SQLException if a database access error occurs
- */
- public int getScale(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- switch (sql_type)
- {
- case Types.SMALLINT:
- return 0;
- case Types.INTEGER:
- return 0;
- case Types.REAL:
- return 8;
- case Types.FLOAT:
- return 16;
- case Types.DOUBLE:
- return 16;
- case Types.VARCHAR:
- return 0;
- case Types.NUMERIC:
- Field f = getField(column);
- if (f != null)
- return (((0x0000FFFF)&f.getMod()) - 4);
- else
- return 0;
- default:
- return 0;
- }
- }
-
- /*
- * Whats a column's table's name? How do I find this out? Both
- * getSchemaName() and getCatalogName() rely on knowing the table
- * Name, so we need this before we can work on them.
- *
- * @param column the first column is 1, the second is 2...
- * @return column name, or "" if not applicable
- * @exception SQLException if a database access error occurs
- */
- public String getTableName(int column) throws SQLException
- {
- return "";
- }
-
- /*
- * What's a column's table's catalog name? As with getSchemaName(),
- * we can say that if getTableName() returns n/a, then we can too -
- * otherwise, we need to work on it.
- *
- * @param column the first column is 1, the second is 2...
- * @return catalog name, or "" if not applicable
- * @exception SQLException if a database access error occurs
- */
- public String getCatalogName(int column) throws SQLException
- {
- return "";
- }
-
- /*
- * What is a column's SQL Type? (java.sql.Type int)
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the java.sql.Type value
- * @exception SQLException if a database access error occurs
- * @see org.postgresql.Field#getSQLType
- * @see java.sql.Types
- */
- public int getColumnType(int column) throws SQLException
- {
- return getField(column).getSQLType();
- }
-
- /*
- * Whats is the column's data source specific type name?
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the type name
- * @exception SQLException if a database access error occurs
- */
- public String getColumnTypeName(int column) throws SQLException
- {
- return getField(column).getPGType();
- }
-
- /*
- * Is the column definitely not writable? In reality, we would
- * have to check the GRANT/REVOKE stuff for this to be effective,
- * and I haven't really looked into that yet, so this will get
- * re-visited.
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isReadOnly(int column) throws SQLException
- {
- return false;
- }
-
- /*
- * Is it possible for a write on the column to succeed? Again, we
- * would in reality have to check the GRANT/REVOKE stuff, which
- * I haven't worked with as yet. However, if it isn't ReadOnly, then
- * it is obviously writable.
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isWritable(int column) throws SQLException
- {
- return !isReadOnly(column);
- }
-
- /*
- * Will a write on this column definately succeed? Hmmm...this
- * is a bad one, since the two preceding functions have not been
- * really defined. I cannot tell is the short answer. I thus
- * return isWritable() just to give us an idea.
- *
- * @param column the first column is 1, the second is 2, etc..
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isDefinitelyWritable(int column) throws SQLException
- {
- return false;
- }
-
- // ********************************************************
- // END OF PUBLIC INTERFACE
- // ********************************************************
-
- /*
- * For several routines in this package, we need to convert
- * a columnIndex into a Field[] descriptor. Rather than do
- * the same code several times, here it is.
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the Field description
- * @exception SQLException if a database access error occurs
- */
- private Field getField(int columnIndex) throws SQLException
- {
- if (columnIndex < 1 || columnIndex > fields.length)
- throw new PSQLException("postgresql.res.colrange");
- return fields[columnIndex - 1];
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/Statement.java b/src/interfaces/jdbc/org/postgresql/jdbc1/Statement.java
deleted file mode 100644
index 8898f5a69dd..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/Statement.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.postgresql.jdbc1;
-
-// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 2 class in the
-// org.postgresql.jdbc2 package.
-
-import java.sql.*;
-
-import org.postgresql.util.PSQLException;
-
-/*
- * A Statement object is used for executing a static SQL statement and
- * obtaining the results produced by it.
- *
- * <p>Only one ResultSet per Statement can be open at any point in time.
- * Therefore, if the reading of one ResultSet is interleaved with the
- * reading of another, each must have been generated by different
- * Statements. All statement execute methods implicitly close a
- * statement's current ResultSet if an open one exists.
- *
- * @see java.sql.Statement
- * @see ResultSet
- */
-public class Statement extends org.postgresql.Statement implements java.sql.Statement
-{
- private Connection connection; // The connection who created us
-
- /*
- * Constructor for a Statement. It simply sets the connection
- * that created us.
- *
- * @param c the Connection instantation that creates us
- */
- public Statement (Connection c)
- {
- connection = c;
- }
-
- /*
- * Execute a SQL statement that retruns a single ResultSet
- *
- * @param sql typically a static SQL SELECT statement
- * @return a ResulSet that contains the data produced by the query
- * @exception SQLException if a database access error occurs
- */
- public java.sql.ResultSet executeQuery(String sql) throws SQLException
- {
- this.execute(sql);
- while (result != null && !((org.postgresql.ResultSet)result).reallyResultSet())
- result = ((org.postgresql.ResultSet)result).getNext();
- if (result == null)
- throw new PSQLException("postgresql.stat.noresult");
- return result;
- }
-
- /*
- * Execute a SQL INSERT, UPDATE or DELETE statement. In addition
- * SQL statements that return nothing such as SQL DDL statements
- * can be executed
- *
- * @param sql a SQL statement
- * @return either a row count, or 0 for SQL commands
- * @exception SQLException if a database access error occurs
- */
- public int executeUpdate(String sql) throws SQLException
- {
- this.execute(sql);
- return this.getUpdateCount();
- }
-
- /*
- * setCursorName defines the SQL cursor name that will be used by
- * subsequent execute methods. This name can then be used in SQL
- * positioned update/delete statements to identify the current row
- * in the ResultSet generated by this statement. If a database
- * doesn't support positioned update/delete, this method is a
- * no-op.
- *
- * <p><B>Note:</B> By definition, positioned update/delete execution
- * must be done by a different Statement than the one which
- * generated the ResultSet being used for positioning. Also, cursor
- * names must be unique within a Connection.
- *
- * <p>We throw an additional constriction. There can only be one
- * cursor active at any one time.
- *
- * @param name the new cursor name
- * @exception SQLException if a database access error occurs
- */
- public void setCursorName(String name) throws SQLException
- {
- connection.setCursorName(name);
- }
-
- /*
- * Execute a SQL statement that may return multiple results. We
- * don't have to worry about this since we do not support multiple
- * ResultSets. You can use getResultSet or getUpdateCount to
- * retrieve the result.
- *
- * @param sql any SQL statement
- * @return true if the next result is a ResulSet, false if it is
- * an update count or there are no more results
- * @exception SQLException if a database access error occurs
- */
- public boolean execute(String sql) throws SQLException
- {
- if (escapeProcessing)
- sql = escapeSQL(sql);
- result = connection.ExecSQL(sql);
- return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
- }
-
- /*
- * getUpdateCount returns the current result as an update count,
- * if the result is a ResultSet or there are no more results, -1
- * is returned. It should only be called once per result.
- *
- * @return the current result as an update count.
- * @exception SQLException if a database access error occurs
- */
- public int getUpdateCount() throws SQLException
- {
- if (result == null)
- return -1;
- if (((org.postgresql.ResultSet)result).reallyResultSet())
- return -1;
- return ((org.postgresql.ResultSet)result).getResultCount();
- }
-
- /*
- * getMoreResults moves to a Statement's next result. If it returns
- * true, this result is a ResulSet.
- *
- * @return true if the next ResultSet is valid
- * @exception SQLException if a database access error occurs
- */
- public boolean getMoreResults() throws SQLException
- {
- result = ((org.postgresql.ResultSet)result).getNext();
- return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/Array.java b/src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
deleted file mode 100644
index 90b56eb92d8..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
+++ /dev/null
@@ -1,351 +0,0 @@
-package org.postgresql.jdbc2;
-
-import java.text.*;
-import java.sql.*;
-import java.util.*;
-import java.math.BigDecimal;
-import org.postgresql.Field;
-import org.postgresql.util.*;
-
-/*
- * Array is used collect one column of query result data.
- *
- * <p>Read a field of type Array into either a natively-typed
- * Java array object or a ResultSet. Accessor methods provide
- * the ability to capture array slices.
- *
- * <p>Other than the constructor all methods are direct implementations
- * of those specified for java.sql.Array. Please refer to the javadoc
- * for java.sql.Array for detailed descriptions of the functionality
- * and parameters of the methods of this class.
- *
- * @see ResultSet#getArray
- */
-
-
-public class Array implements java.sql.Array
-{
- private org.postgresql.Connection conn = null;
- private org.postgresql.Field field = null;
- private org.postgresql.jdbc2.ResultSet rs = null;
- private int idx = 0;
- private String rawString = null;
-
- /*
- * Create a new Array
- *
- * @param conn a database connection
- * @param idx 1-based index of the query field to load into this Array
- * @param field the Field descriptor for the field to load into this Array
- * @param rs the ResultSet from which to get the data for this Array
- */
- public Array( org.postgresql.Connection conn, int idx, Field field, org.postgresql.jdbc2.ResultSet rs )
- throws SQLException
- {
- this.conn = conn;
- this.field = field;
- this.rs = rs;
- this.idx = idx;
- this.rawString = rs.getFixedString(idx);
- }
-
- public Object getArray() throws SQLException
- {
- return getArray( 1, 0, null );
- }
-
- public Object getArray(long index, int count) throws SQLException
- {
- return getArray( index, count, null );
- }
-
- public Object getArray(Map map) throws SQLException
- {
- return getArray( 1, 0, map );
- }
-
- public Object getArray(long index, int count, Map map) throws SQLException
- {
- if ( map != null ) // For now maps aren't supported.
- throw org.postgresql.Driver.notImplemented();
-
- if (index < 1)
- throw new PSQLException("postgresql.arr.range");
- Object retVal = null;
-
- ArrayList array = new ArrayList();
-
- /* Check if the String is also not an empty array
- * otherwise there will be an exception thrown below
- * in the ResultSet.toX with an empty string.
- * -- Doug Fields <dfields-pg-jdbc@pexicom.com> Feb 20, 2002 */
-
- if ( rawString != null && !rawString.equals("{}") )
- {
- char[] chars = rawString.toCharArray();
- StringBuffer sbuf = new StringBuffer();
- boolean foundOpen = false;
- boolean insideString = false;
- for ( int i = 0; i < chars.length; i++ )
- {
- if ( chars[i] == '{' )
- {
- if ( foundOpen ) // Only supports 1-D arrays for now
- throw org.postgresql.Driver.notImplemented();
- foundOpen = true;
- continue;
- }
- if ( chars[i] == '"' )
- {
- insideString = !insideString;
- continue;
- }
- if ( (!insideString && chars[i] == ',') || chars[i] == '}' || i == chars.length - 1)
- {
- if ( chars[i] != '"' && chars[i] != '}' && chars[i] != ',' )
- sbuf.append(chars[i]);
- array.add( sbuf.toString() );
- sbuf = new StringBuffer();
- continue;
- }
- sbuf.append( chars[i] );
- }
- }
- String[] arrayContents = (String[]) array.toArray( new String[array.size()] );
- if ( count == 0 )
- count = arrayContents.length;
- index--;
- if ( index + count > arrayContents.length )
- throw new PSQLException("postgresql.arr.range");
-
- int i = 0;
- switch ( getBaseType() )
- {
- case Types.BIT:
- retVal = new boolean[ count ];
- for ( ; count > 0; count-- )
- ((boolean[])retVal)[i++] = ResultSet.toBoolean( arrayContents[(int)index++] );
- break;
- case Types.SMALLINT:
- case Types.INTEGER:
- retVal = new int[ count ];
- for ( ; count > 0; count-- )
- ((int[])retVal)[i++] = ResultSet.toInt( arrayContents[(int)index++] );
- break;
- case Types.BIGINT:
- retVal = new long[ count ];
- for ( ; count > 0; count-- )
- ((long[])retVal)[i++] = ResultSet.toLong( arrayContents[(int)index++] );
- break;
- case Types.NUMERIC:
- retVal = new BigDecimal[ count ];
- for ( ; count > 0; count-- )
- ((BigDecimal[])retVal)[i++] = ResultSet.toBigDecimal( arrayContents[(int)index++], 0 );
- break;
- case Types.REAL:
- retVal = new float[ count ];
- for ( ; count > 0; count-- )
- ((float[])retVal)[i++] = ResultSet.toFloat( arrayContents[(int)index++] );
- break;
- case Types.DOUBLE:
- retVal = new double[ count ];
- for ( ; count > 0; count-- )
- ((double[])retVal)[i++] = ResultSet.toDouble( arrayContents[(int)index++] );
- break;
- case Types.CHAR:
- case Types.VARCHAR:
- retVal = new String[ count ];
- for ( ; count > 0; count-- )
- ((String[])retVal)[i++] = arrayContents[(int)index++];
- break;
- case Types.DATE:
- retVal = new java.sql.Date[ count ];
- for ( ; count > 0; count-- )
- ((java.sql.Date[])retVal)[i++] = ResultSet.toDate( arrayContents[(int)index++] );
- break;
- case Types.TIME:
- retVal = new java.sql.Time[ count ];
- for ( ; count > 0; count-- )
- ((java.sql.Time[])retVal)[i++] = ResultSet.toTime( arrayContents[(int)index++] );
- break;
- case Types.TIMESTAMP:
- retVal = new Timestamp[ count ];
- StringBuffer sbuf = null;
- for ( ; count > 0; count-- )
- ((java.sql.Timestamp[])retVal)[i++] = ResultSet.toTimestamp( arrayContents[(int)index++], rs );
- break;
-
- // Other datatypes not currently supported. If you are really using other types ask
- // yourself if an array of non-trivial data types is really good database design.
- default:
- throw org.postgresql.Driver.notImplemented();
- }
- return retVal;
- }
-
- public int getBaseType() throws SQLException
- {
- return conn.getSQLType(getBaseTypeName());
- }
-
- public String getBaseTypeName() throws SQLException
- {
- String fType = field.getPGType();
- if ( fType.charAt(0) == '_' )
- fType = fType.substring(1);
- return fType;
- }
-
- public java.sql.ResultSet getResultSet() throws SQLException
- {
- return getResultSet( 1, 0, null );
- }
-
- public java.sql.ResultSet getResultSet(long index, int count) throws SQLException
- {
- return getResultSet( index, count, null );
- }
-
- public java.sql.ResultSet getResultSet(Map map) throws SQLException
- {
- return getResultSet( 1, 0, map );
- }
-
- public java.sql.ResultSet getResultSet(long index, int count, java.util.Map map) throws SQLException
- {
- Object array = getArray( index, count, map );
- Vector rows = new Vector();
- Field[] fields = new Field[2];
- fields[0] = new Field(conn, "INDEX", conn.getOID("int2"), 2);
- switch ( getBaseType() )
- {
- case Types.BIT:
- boolean[] booleanArray = (boolean[]) array;
- fields[1] = new Field(conn, "VALUE", conn.getOID("bool"), 1);
- for ( int i = 0; i < booleanArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( (booleanArray[i] ? "YES" : "NO") ); // Value
- rows.addElement(tuple);
- }
- case Types.SMALLINT:
- fields[1] = new Field(conn, "VALUE", conn.getOID("int2"), 2);
- case Types.INTEGER:
- int[] intArray = (int[]) array;
- if ( fields[1] == null )
- fields[1] = new Field(conn, "VALUE", conn.getOID("int4"), 4);
- for ( int i = 0; i < intArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( Integer.toString(intArray[i]) ); // Value
- rows.addElement(tuple);
- }
- break;
- case Types.BIGINT:
- long[] longArray = (long[]) array;
- fields[1] = new Field(conn, "VALUE", conn.getOID("int8"), 8);
- for ( int i = 0; i < longArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( Long.toString(longArray[i]) ); // Value
- rows.addElement(tuple);
- }
- break;
- case Types.NUMERIC:
- BigDecimal[] bdArray = (BigDecimal[]) array;
- fields[1] = new Field(conn, "VALUE", conn.getOID("numeric"), -1);
- for ( int i = 0; i < bdArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( bdArray[i].toString() ); // Value
- rows.addElement(tuple);
- }
- break;
- case Types.REAL:
- float[] floatArray = (float[]) array;
- fields[1] = new Field(conn, "VALUE", conn.getOID("float4"), 4);
- for ( int i = 0; i < floatArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( Float.toString(floatArray[i]) ); // Value
- rows.addElement(tuple);
- }
- break;
- case Types.DOUBLE:
- double[] doubleArray = (double[]) array;
- fields[1] = new Field(conn, "VALUE", conn.getOID("float8"), 8);
- for ( int i = 0; i < doubleArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( Double.toString(doubleArray[i]) ); // Value
- rows.addElement(tuple);
- }
- break;
- case Types.CHAR:
- fields[1] = new Field(conn, "VALUE", conn.getOID("char"), 1);
- case Types.VARCHAR:
- String[] strArray = (String[]) array;
- if ( fields[1] == null )
- fields[1] = new Field(conn, "VALUE", conn.getOID("varchar"), -1);
- for ( int i = 0; i < strArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( strArray[i] ); // Value
- rows.addElement(tuple);
- }
- break;
- case Types.DATE:
- java.sql.Date[] dateArray = (java.sql.Date[]) array;
- fields[1] = new Field(conn, "VALUE", conn.getOID("date"), 4);
- for ( int i = 0; i < dateArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( dateArray[i].toString() ); // Value
- rows.addElement(tuple);
- }
- break;
- case Types.TIME:
- java.sql.Time[] timeArray = (java.sql.Time[]) array;
- fields[1] = new Field(conn, "VALUE", conn.getOID("time"), 8);
- for ( int i = 0; i < timeArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( timeArray[i].toString() ); // Value
- rows.addElement(tuple);
- }
- break;
- case Types.TIMESTAMP:
- java.sql.Timestamp[] timestampArray = (java.sql.Timestamp[]) array;
- fields[1] = new Field(conn, "VALUE", conn.getOID("timestamp"), 8);
- for ( int i = 0; i < timestampArray.length; i++ )
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
- tuple[1] = conn.getEncoding().encode( timestampArray[i].toString() ); // Value
- rows.addElement(tuple);
- }
- break;
-
- // Other datatypes not currently supported. If you are really using other types ask
- // yourself if an array of non-trivial data types is really good database design.
- default:
- throw org.postgresql.Driver.notImplemented();
- }
- return new ResultSet((org.postgresql.jdbc2.Connection)conn, fields, rows, "OK", 1 );
- }
-
- public String toString()
- {
- return rawString;
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/CallableStatement.java b/src/interfaces/jdbc/org/postgresql/jdbc2/CallableStatement.java
deleted file mode 100644
index 2f316234c23..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/CallableStatement.java
+++ /dev/null
@@ -1,376 +0,0 @@
-package org.postgresql.jdbc2;
-
-// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 1 class in the
-// org.postgresql.jdbc1 package.
-
-import java.sql.*;
-import java.math.*;
-
-/*
- * CallableStatement is used to execute SQL stored procedures.
- *
- * <p>JDBC provides a stored procedure SQL escape that allows stored
- * procedures to be called in a standard way for all RDBMS's. This escape
- * syntax has one form that includes a result parameter and one that does
- * not. If used, the result parameter must be registered as an OUT
- * parameter. The other parameters may be used for input, output or both.
- * Parameters are refered to sequentially, by number. The first parameter
- * is 1.
- *
- * {?= call <procedure-name>[<arg1>,<arg2>, ...]}
- * {call <procedure-name>[<arg1>,<arg2>, ...]}
- *
- *
- * <p>IN parameter values are set using the set methods inherited from
- * PreparedStatement. The type of all OUT parameters must be registered
- * prior to executing the stored procedure; their values are retrieved
- * after execution via the get methods provided here.
- *
- * <p>A Callable statement may return a ResultSet or multiple ResultSets.
- * Multiple ResultSets are handled using operations inherited from
- * Statement.
- *
- * <p>For maximum portability, a call's ResultSets and update counts should
- * be processed prior to getting the values of output parameters.
- *
- * @see Connection#prepareCall
- * @see ResultSet
- */
-
-public class CallableStatement extends org.postgresql.jdbc2.PreparedStatement implements java.sql.CallableStatement
-{
- /*
- * @exception SQLException on failure
- */
- public CallableStatement(Connection c, String q) throws SQLException
- {
- super(c, q);
- }
-
- /*
- * Before executing a stored procedure call you must explicitly
- * call registerOutParameter to register the java.sql.Type of each
- * out parameter.
- *
- * <p>Note: When reading the value of an out parameter, you must use
- * the getXXX method whose Java type XXX corresponds to the
- * parameter's registered SQL type.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @param sqlType SQL type code defined by java.sql.Types; for
- * parameters of type Numeric or Decimal use the version of
- * registerOutParameter that accepts a scale value
- * @exception SQLException if a database-access error occurs.
- */
- public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException
- {}
-
- /*
- * You must also specify the scale for numeric/decimal types:
- *
- * <p>Note: When reading the value of an out parameter, you must use
- * the getXXX method whose Java type XXX corresponds to the
- * parameter's registered SQL type.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @param sqlType use either java.sql.Type.NUMERIC or java.sql.Type.DECIMAL
- * @param scale a value greater than or equal to zero representing the
- * desired number of digits to the right of the decimal point
- * @exception SQLException if a database-access error occurs.
- */
- public void registerOutParameter(int parameterIndex, int sqlType,
- int scale) throws SQLException
- {}
-
- // Old api?
- //public boolean isNull(int parameterIndex) throws SQLException {
- //return true;
- //}
-
- /*
- * An OUT parameter may have the value of SQL NULL; wasNull
- * reports whether the last value read has this special value.
- *
- * <p>Note: You must first call getXXX on a parameter to read its
- * value and then call wasNull() to see if the value was SQL NULL.
- * @return true if the last parameter read was SQL NULL
- * @exception SQLException if a database-access error occurs.
- */
- public boolean wasNull() throws SQLException
- {
- // check to see if the last access threw an exception
- return false; // fake it for now
- }
-
- // Old api?
- //public String getChar(int parameterIndex) throws SQLException {
- //return null;
- //}
-
- /*
- * Get the value of a CHAR, VARCHAR, or LONGVARCHAR parameter as a
- * Java String.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public String getString(int parameterIndex) throws SQLException
- {
- return null;
- }
- //public String getVarChar(int parameterIndex) throws SQLException {
- // return null;
- //}
-
- //public String getLongVarChar(int parameterIndex) throws SQLException {
- //return null;
- //}
-
- /*
- * Get the value of a BIT parameter as a Java boolean.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is false
- * @exception SQLException if a database-access error occurs.
- */
- public boolean getBoolean(int parameterIndex) throws SQLException
- {
- return false;
- }
-
- /*
- * Get the value of a TINYINT parameter as a Java byte.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public byte getByte(int parameterIndex) throws SQLException
- {
- return 0;
- }
-
- /*
- * Get the value of a SMALLINT parameter as a Java short.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public short getShort(int parameterIndex) throws SQLException
- {
- return 0;
- }
-
- /*
- * Get the value of an INTEGER parameter as a Java int.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public int getInt(int parameterIndex) throws SQLException
- {
- return 0;
- }
-
- /*
- * Get the value of a BIGINT parameter as a Java long.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public long getLong(int parameterIndex) throws SQLException
- {
- return 0;
- }
-
- /*
- * Get the value of a FLOAT parameter as a Java float.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public float getFloat(int parameterIndex) throws SQLException
- {
- return (float) 0.0;
- }
-
- /*
- * Get the value of a DOUBLE parameter as a Java double.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is 0
- * @exception SQLException if a database-access error occurs.
- */
- public double getDouble(int parameterIndex) throws SQLException
- {
- return 0.0;
- }
-
- /*
- * Get the value of a NUMERIC parameter as a java.math.BigDecimal
- * object.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @param scale a value greater than or equal to zero representing the
- * desired number of digits to the right of the decimal point
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- * @deprecated in Java2.0
- */
- public BigDecimal getBigDecimal(int parameterIndex, int scale)
- throws SQLException
- {
- return null;
- }
-
- /*
- * Get the value of a SQL BINARY or VARBINARY parameter as a Java
- * byte[]
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public byte[] getBytes(int parameterIndex) throws SQLException
- {
- return null;
- }
-
- // New API (JPM) (getLongVarBinary)
- //public byte[] getBinaryStream(int parameterIndex) throws SQLException {
- //return null;
- //}
-
- /*
- * Get the value of a SQL DATE parameter as a java.sql.Date object
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public java.sql.Date getDate(int parameterIndex) throws SQLException
- {
- return null;
- }
-
- /*
- * Get the value of a SQL TIME parameter as a java.sql.Time object.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public java.sql.Time getTime(int parameterIndex) throws SQLException
- {
- return null;
- }
-
- /*
- * Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return the parameter value; if the value is SQL NULL, the result is null
- * @exception SQLException if a database-access error occurs.
- */
- public java.sql.Timestamp getTimestamp(int parameterIndex)
- throws SQLException
- {
- return null;
- }
-
- //----------------------------------------------------------------------
- // Advanced features:
-
- // You can obtain a ParameterMetaData object to get information
- // about the parameters to this CallableStatement.
- //public DatabaseMetaData getMetaData() {
- //return null;
- //}
-
- // getObject returns a Java object for the parameter.
- // See the JDBC spec's "Dynamic Programming" chapter for details.
- /*
- * Get the value of a parameter as a Java object.
- *
- * <p>This method returns a Java object whose type coresponds to the
- * SQL type that was registered for this parameter using
- * registerOutParameter.
- *
- * <P>Note that this method may be used to read datatabase-specific,
- * abstract data types. This is done by specifying a targetSqlType
- * of java.sql.types.OTHER, which allows the driver to return a
- * database-specific Java type.
- *
- * <p>See the JDBC spec's "Dynamic Programming" chapter for details.
- *
- * @param parameterIndex the first parameter is 1, the second is 2,...
- * @return A java.lang.Object holding the OUT parameter value.
- * @exception SQLException if a database-access error occurs.
- */
- public Object getObject(int parameterIndex)
- throws SQLException
- {
- return null;
- }
-
- // ** JDBC 2 Extensions **
-
- public java.sql.Array getArray(int i) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public java.math.BigDecimal getBigDecimal(int i) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public Blob getBlob(int i) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public Clob getClob(int i) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public Object getObject(int i, java.util.Map map) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public Ref getRef(int i) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public java.sql.Date getDate(int i, java.util.Calendar cal) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public Time getTime(int i, java.util.Calendar cal) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public Timestamp getTimestamp(int i, java.util.Calendar cal) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java b/src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java
deleted file mode 100644
index 86b1a4fc79c..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java
+++ /dev/null
@@ -1,333 +0,0 @@
-package org.postgresql.jdbc2;
-
-// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 1 class in the
-// org.postgresql.jdbc1 package.
-
-import java.io.*;
-import java.lang.*;
-import java.lang.reflect.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.Field;
-import org.postgresql.fastpath.*;
-import org.postgresql.largeobject.*;
-import org.postgresql.util.*;
-
-/*
- * $Id: Connection.java,v 1.19 2002/06/11 02:55:16 barry Exp $
- *
- * A Connection represents a session with a specific database. Within the
- * context of a Connection, SQL statements are executed and results are
- * returned.
- *
- * <P>A Connection's database is able to provide information describing
- * its tables, its supported SQL grammar, its stored procedures, the
- * capabilities of this connection, etc. This information is obtained
- * with the getMetaData method.
- *
- * <p><B>Note:</B> By default, the Connection automatically commits changes
- * after executing each statement. If auto-commit has been disabled, an
- * explicit commit must be done or database changes will not be saved.
- *
- * @see java.sql.Connection
- */
-public class Connection extends org.postgresql.Connection implements java.sql.Connection
-{
- // This is a cache of the DatabaseMetaData instance for this connection
- protected DatabaseMetaData metadata;
-
- /*
- * The current type mappings
- */
- protected java.util.Map typemap;
-
- /*
- * SQL statements without parameters are normally executed using
- * Statement objects. If the same SQL statement is executed many
- * times, it is more efficient to use a PreparedStatement
- *
- * @return a new Statement object
- * @exception SQLException passed through from the constructor
- */
- public java.sql.Statement createStatement() throws SQLException
- {
- // The spec says default of TYPE_FORWARD_ONLY but everyone is used to
- // using TYPE_SCROLL_INSENSITIVE
- return createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
- }
-
- /*
- * SQL statements without parameters are normally executed using
- * Statement objects. If the same SQL statement is executed many
- * times, it is more efficient to use a PreparedStatement
- *
- * @param resultSetType to use
- * @param resultSetCuncurrency to use
- * @return a new Statement object
- * @exception SQLException passed through from the constructor
- */
- public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- {
- Statement s = new Statement(this);
- s.setResultSetType(resultSetType);
- s.setResultSetConcurrency(resultSetConcurrency);
- return s;
- }
-
-
- /*
- * A SQL statement with or without IN parameters can be pre-compiled
- * and stored in a PreparedStatement object. This object can then
- * be used to efficiently execute this statement multiple times.
- *
- * <B>Note:</B> This method is optimized for handling parametric
- * SQL statements that benefit from precompilation if the drivers
- * supports precompilation. PostgreSQL does not support precompilation.
- * In this case, the statement is not sent to the database until the
- * PreparedStatement is executed. This has no direct effect on users;
- * however it does affect which method throws certain SQLExceptions
- *
- * @param sql a SQL statement that may contain one or more '?' IN
- * parameter placeholders
- * @return a new PreparedStatement object containing the pre-compiled
- * statement.
- * @exception SQLException if a database access error occurs.
- */
- public java.sql.PreparedStatement prepareStatement(String sql) throws SQLException
- {
- return prepareStatement(sql, java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
- }
-
- public java.sql.PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- {
- PreparedStatement s = new PreparedStatement(this, sql);
- s.setResultSetType(resultSetType);
- s.setResultSetConcurrency(resultSetConcurrency);
- return s;
- }
-
- /*
- * A SQL stored procedure call statement is handled by creating a
- * CallableStatement for it. The CallableStatement provides methods
- * for setting up its IN and OUT parameters and methods for executing
- * it.
- *
- * <B>Note:</B> This method is optimised for handling stored procedure
- * call statements. Some drivers may send the call statement to the
- * database when the prepareCall is done; others may wait until the
- * CallableStatement is executed. This has no direct effect on users;
- * however, it does affect which method throws certain SQLExceptions
- *
- * @param sql a SQL statement that may contain one or more '?' parameter
- * placeholders. Typically this statement is a JDBC function call
- * escape string.
- * @return a new CallableStatement object containing the pre-compiled
- * SQL statement
- * @exception SQLException if a database access error occurs
- */
- public java.sql.CallableStatement prepareCall(String sql) throws SQLException
- {
- return prepareCall(sql, java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
- }
-
- public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- {
- throw new PSQLException("postgresql.con.call");
- //CallableStatement s = new CallableStatement(this,sql);
- //s.setResultSetType(resultSetType);
- //s.setResultSetConcurrency(resultSetConcurrency);
- //return s;
- }
-
- /*
- * Tests to see if a Connection is closed.
- *
- * Peter Feb 7 2000: Now I've discovered that this doesn't actually obey the
- * specifications. Under JDBC2.1, this should only be valid _after_ close()
- * has been called. It's result is not guraranteed to be valid before, and
- * client code should not use it to see if a connection is open. The spec says
- * that the client should monitor the SQLExceptions thrown when their queries
- * fail because the connection is dead.
- *
- * I don't like this definition. As it doesn't hurt breaking it here, our
- * isClosed() implementation does test the connection, so for PostgreSQL, you
- * can rely on isClosed() returning a valid result.
- *
- * @return the status of the connection
- * @exception SQLException (why?)
- */
- public boolean isClosed() throws SQLException
- {
- // If the stream is gone, then close() was called
- if (pg_stream == null)
- return true;
- return false;
- }
-
- /*
- * A connection's database is able to provide information describing
- * its tables, its supported SQL grammar, its stored procedures, the
- * capabilities of this connection, etc. This information is made
- * available through a DatabaseMetaData object.
- *
- * @return a DatabaseMetaData object for this connection
- * @exception SQLException if a database access error occurs
- */
- public java.sql.DatabaseMetaData getMetaData() throws SQLException
- {
- if (metadata == null)
- metadata = new DatabaseMetaData(this);
- return metadata;
- }
-
- /*
- * This overides the method in org.postgresql.Connection and returns a
- * ResultSet.
- */
- public java.sql.ResultSet getResultSet(org.postgresql.Connection conn, java.sql.Statement stat, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
- {
- // In 7.1 we now test concurrency to see which class to return. If we are not working with a
- // Statement then default to a normal ResultSet object.
- if (stat != null)
- {
- if (stat.getResultSetConcurrency() == java.sql.ResultSet.CONCUR_UPDATABLE)
- return new org.postgresql.jdbc2.UpdateableResultSet((org.postgresql.jdbc2.Connection)conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
- }
-
- return new org.postgresql.jdbc2.ResultSet((org.postgresql.jdbc2.Connection)conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
- }
-
- // *****************
- // JDBC 2 extensions
- // *****************
-
- public java.util.Map getTypeMap() throws SQLException
- {
- // new in 7.1
- return typemap;
- }
-
-
- public void setTypeMap(java.util.Map map) throws SQLException
- {
- // new in 7.1
- typemap = map;
- }
-
- /*
- * This overides the standard internal getObject method so that we can
- * check the jdbc2 type map first
- *
- * @return PGobject for this type, and set to value
- * @exception SQLException if value is not correct for this type
- * @see org.postgresql.util.Serialize
- */
- public Object getObject(String type, String value) throws SQLException
- {
- if (typemap != null)
- {
- SQLData d = (SQLData) typemap.get(type);
- if (d != null)
- {
- // Handle the type (requires SQLInput & SQLOutput classes to be implemented)
- throw org.postgresql.Driver.notImplemented();
- }
- }
-
- // Default to the original method
- return super.getObject(type, value);
- }
-
- /* An implementation of the abstract method in the parent class.
- * This implemetation uses the jdbc2Types array to support the jdbc2
- * datatypes. Basically jdbc1 and jdbc2 are the same, except that
- * jdbc2 adds the Array types.
- */
- public int getSQLType(String pgTypeName)
- {
- int sqlType = Types.OTHER; // default value
- for (int i = 0;i < jdbc2Types.length;i++)
- {
- if (pgTypeName.equals(jdbc2Types[i]))
- {
- sqlType = jdbc2Typei[i];
- break;
- }
- }
- return sqlType;
- }
-
- /*
- * This table holds the org.postgresql names for the types supported.
- * Any types that map to Types.OTHER (eg POINT) don't go into this table.
- * They default automatically to Types.OTHER
- *
- * Note: This must be in the same order as below.
- *
- * Tip: keep these grouped together by the Types. value
- */
- private static final String jdbc2Types[] = {
- "int2",
- "int4", "oid",
- "int8",
- "cash", "money",
- "numeric",
- "float4",
- "float8",
- "bpchar", "char", "char2", "char4", "char8", "char16",
- "varchar", "text", "name", "filename",
- "bytea",
- "bool",
- "date",
- "time",
- "abstime", "timestamp", "timestamptz",
- "_bool", "_char", "_int2", "_int4", "_text",
- "_oid", "_varchar", "_int8", "_float4", "_float8",
- "_abstime", "_date", "_time", "_timestamp", "_numeric",
- "_bytea"
- };
-
- /*
- * This table holds the JDBC type for each entry above.
- *
- * Note: This must be in the same order as above
- *
- * Tip: keep these grouped together by the Types. value
- */
- private static final int jdbc2Typei[] = {
- Types.SMALLINT,
- Types.INTEGER, Types.INTEGER,
- Types.BIGINT,
- Types.DOUBLE, Types.DOUBLE,
- Types.NUMERIC,
- Types.REAL,
- Types.DOUBLE,
- Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR,
- Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
- Types.BINARY,
- Types.BIT,
- Types.DATE,
- Types.TIME,
- Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP,
- Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
- Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
- Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
- Types.ARRAY
- };
-
- //Because the get/setLogStream methods are deprecated in JDBC2
- //we use the get/setLogWriter methods here for JDBC2 by overriding
- //the base version of this method
- protected void enableDriverManagerLogging() {
- if (DriverManager.getLogWriter() == null) {
- DriverManager.setLogWriter(new PrintWriter(System.out));
- }
- }
-
-}
-
-// ***********************************************************************
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
deleted file mode 100644
index e38f4c18e5a..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
+++ /dev/null
@@ -1,3247 +0,0 @@
-package org.postgresql.jdbc2;
-
-// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 1 class in the
-// org.postgresql.jdbc1 package.
-
-import java.sql.*;
-import java.util.*;
-
-import org.postgresql.Driver;
-import org.postgresql.Field;
-import org.postgresql.util.PSQLException;
-
-/*
- * This class provides information about the database as a whole.
- *
- * $Id: DatabaseMetaData.java,v 1.56 2002/06/20 16:00:44 momjian Exp $
- *
- * <p>Many of the methods here return lists of information in ResultSets. You
- * can use the normal ResultSet methods such as getString and getInt to
- * retrieve the data from these ResultSets. If a given form of metadata is
- * not available, these methods should throw a SQLException.
- *
- * <p>Some of these methods take arguments that are String patterns. These
- * arguments all have names such as fooPattern. Within a pattern String,
- * "%" means match any substring of 0 or more characters, and "_" means
- * match any one character. Only metadata entries matching the search
- * pattern are returned. if a search pattern argument is set to a null
- * ref, it means that argument's criteria should be dropped from the
- * search.
- *
- * <p>A SQLException will be throws if a driver does not support a meta
- * data method. In the case of methods that return a ResultSet, either
- * a ResultSet (which may be empty) is returned or a SQLException is
- * thrown.
- *
- * @see java.sql.DatabaseMetaData
- */
-public class DatabaseMetaData implements java.sql.DatabaseMetaData
-{
- Connection connection; // The connection association
-
- // These define various OID's. Hopefully they will stay constant.
- static final int iVarcharOid = 1043; // OID for varchar
- static final int iBoolOid = 16; // OID for bool
- static final int iInt2Oid = 21; // OID for int2
- static final int iInt4Oid = 23; // OID for int4
- static final int VARHDRSZ = 4; // length for int4
-
- public DatabaseMetaData(Connection conn)
- {
- this.connection = conn;
- }
-
- /*
- * Can all the procedures returned by getProcedures be called
- * by the current user?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean allProceduresAreCallable() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("allProceduresAreCallable");
- return true; // For now...
- }
-
- /*
- * Can all the tables returned by getTable be SELECTed by
- * the current user?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean allTablesAreSelectable() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("allTablesAreSelectable");
- return true; // For now...
- }
-
- /*
- * What is the URL for this database?
- *
- * @return the url or null if it cannott be generated
- * @exception SQLException if a database access error occurs
- */
- public String getURL() throws SQLException
- {
- String url = connection.getURL();
- if (Driver.logDebug) Driver.debug("getURL " + url);
- return url;
- }
-
- /*
- * What is our user name as known to the database?
- *
- * @return our database user name
- * @exception SQLException if a database access error occurs
- */
- public String getUserName() throws SQLException
- {
- String userName = connection.getUserName();
- if (Driver.logDebug) Driver.debug("getUserName " + userName);
- return userName;
- }
-
- /*
- * Is the database in read-only mode?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isReadOnly() throws SQLException
- {
- boolean isReadOnly = connection.isReadOnly();
- if (Driver.logDebug) Driver.debug("isReadOnly " + isReadOnly);
- return isReadOnly;
- }
-
- /*
- * Are NULL values sorted high?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullsAreSortedHigh() throws SQLException
- {
- boolean nullSortedHigh = connection.haveMinimumServerVersion("7.2");
- if (Driver.logDebug) Driver.debug("nullsAreSortedHigh " + nullSortedHigh);
- return nullSortedHigh;
- }
-
- /*
- * Are NULL values sorted low?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullsAreSortedLow() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("nullsAreSortedLow false");
- return false;
- }
-
- /*
- * Are NULL values sorted at the start regardless of sort order?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullsAreSortedAtStart() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("nullsAreSortedAtStart false");
- return false;
- }
-
- /*
- * Are NULL values sorted at the end regardless of sort order?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullsAreSortedAtEnd() throws SQLException
- {
- boolean nullsAreSortedAtEnd = ! connection.haveMinimumServerVersion("7.2");
- if (Driver.logDebug) Driver.debug("nullsAreSortedAtEnd " + nullsAreSortedAtEnd);
- return nullsAreSortedAtEnd;
- }
-
- /*
- * What is the name of this database product - we hope that it is
- * PostgreSQL, so we return that explicitly.
- *
- * @return the database product name
- * @exception SQLException if a database access error occurs
- */
- public String getDatabaseProductName() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("getDatabaseProductName PostgresSQL");
- return "PostgreSQL";
- }
-
- /*
- * What is the version of this database product.
- *
- * @return the database version
- * @exception SQLException if a database access error occurs
- */
- public String getDatabaseProductVersion() throws SQLException
- {
- String versionNumber = connection.getDBVersionNumber();
- if (Driver.logDebug) Driver.debug("getDatabaseProductVersion " + versionNumber);
- return versionNumber;
- }
-
- /*
- * What is the name of this JDBC driver? If we don't know this
- * we are doing something wrong!
- *
- * @return the JDBC driver name
- * @exception SQLException why?
- */
- public String getDriverName() throws SQLException
- {
- String driverName = "PostgreSQL Native Driver";
- if (Driver.logDebug) Driver.debug("getDriverName" + driverName);
- return driverName;
- }
-
- /*
- * What is the version string of this JDBC driver? Again, this is
- * static.
- *
- * @return the JDBC driver name.
- * @exception SQLException why?
- */
- public String getDriverVersion() throws SQLException
- {
- String driverVersion = connection.this_driver.getVersion();
- if (Driver.logDebug) Driver.debug("getDriverVersion " + driverVersion);
- return driverVersion;
- }
-
- /*
- * What is this JDBC driver's major version number?
- *
- * @return the JDBC driver major version
- */
- public int getDriverMajorVersion()
- {
- int majorVersion = connection.this_driver.getMajorVersion();
- if (Driver.logDebug) Driver.debug("getMajorVersion " + majorVersion);
- return majorVersion;
- }
-
- /*
- * What is this JDBC driver's minor version number?
- *
- * @return the JDBC driver minor version
- */
- public int getDriverMinorVersion()
- {
- int minorVersion = connection.this_driver.getMinorVersion();
- if (Driver.logDebug) Driver.debug("getMinorVersion " + minorVersion);
- return minorVersion;
- }
-
- /*
- * Does the database store tables in a local file? No - it
- * stores them in a file on the server.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean usesLocalFiles() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("usesLocalFiles " + false);
- return false;
- }
-
- /*
- * Does the database use a file for each table? Well, not really,
- * since it doesnt use local files.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean usesLocalFilePerTable() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("usesLocalFilePerTable " + false);
- return false;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers
- * as case sensitive and as a result store them in mixed case?
- * A JDBC-Compliant driver will always return false.
- *
- * <p>Predicament - what do they mean by "SQL identifiers" - if it
- * means the names of the tables and columns, then the answers
- * given below are correct - otherwise I don't know.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMixedCaseIdentifiers() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsMixedCaseIdentifiers " + false);
- return false;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers as
- * case insensitive and store them in upper case?
- *
- * @return true if so
- */
- public boolean storesUpperCaseIdentifiers() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("storesUpperCaseIdentifiers " + false);
- return false;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers as
- * case insensitive and store them in lower case?
- *
- * @return true if so
- */
- public boolean storesLowerCaseIdentifiers() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("storesLowerCaseIdentifiers " + true);
- return true;
- }
-
- /*
- * Does the database treat mixed case unquoted SQL identifiers as
- * case insensitive and store them in mixed case?
- *
- * @return true if so
- */
- public boolean storesMixedCaseIdentifiers() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("storesMixedCaseIdentifiers " + false);
- return false;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as
- * case sensitive and as a result store them in mixed case? A
- * JDBC compliant driver will always return true.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsMixedCaseQuotedIdentifiers " + true);
- return true;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as
- * case insensitive and store them in upper case?
- *
- * @return true if so
- */
- public boolean storesUpperCaseQuotedIdentifiers() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("storesUpperCaseQuotedIdentifiers " + false);
- return false;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as case
- * insensitive and store them in lower case?
- *
- * @return true if so
- */
- public boolean storesLowerCaseQuotedIdentifiers() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("storesLowerCaseQuotedIdentifiers " + false);
- return false;
- }
-
- /*
- * Does the database treat mixed case quoted SQL identifiers as case
- * insensitive and store them in mixed case?
- *
- * @return true if so
- */
- public boolean storesMixedCaseQuotedIdentifiers() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("storesMixedCaseQuotedIdentifiers " + false);
- return false;
- }
-
- /*
- * What is the string used to quote SQL identifiers? This returns
- * a space if identifier quoting isn't supported. A JDBC Compliant
- * driver will always use a double quote character.
- *
- * @return the quoting string
- * @exception SQLException if a database access error occurs
- */
- public String getIdentifierQuoteString() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("getIdentifierQuoteString \"" );
- return "\"";
- }
-
- /*
- * Get a comma separated list of all a database's SQL keywords that
- * are NOT also SQL92 keywords.
- *
- * <p>Within PostgreSQL, the keywords are found in
- * src/backend/parser/keywords.c
- *
- * <p>For SQL Keywords, I took the list provided at
- * <a href="http://web.dementia.org/~shadow/sql/sql3bnf.sep93.txt">
- * http://web.dementia.org/~shadow/sql/sql3bnf.sep93.txt</a>
- * which is for SQL3, not SQL-92, but it is close enough for
- * this purpose.
- *
- * @return a comma separated list of keywords we use
- * @exception SQLException if a database access error occurs
- */
- public String getSQLKeywords() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("getSQLKeyWords");
- return "abort,acl,add,aggregate,append,archive,arch_store,backward,binary,change,cluster,copy,database,delimiter,delimiters,do,extend,explain,forward,heavy,index,inherits,isnull,light,listen,load,merge,nothing,notify,notnull,oids,purge,rename,replace,retrieve,returns,rule,recipe,setof,stdin,stdout,store,vacuum,verbose,version";
- }
-
- public String getNumericFunctions() throws SQLException
- {
- // XXX-Not Implemented
- if (Driver.logDebug) Driver.debug("getNumericFunctions");
- return "";
- }
-
- public String getStringFunctions() throws SQLException
- {
- // XXX-Not Implemented
- if (Driver.logDebug) Driver.debug("getStringFunctions");
- return "";
- }
-
- public String getSystemFunctions() throws SQLException
- {
- // XXX-Not Implemented
- if (Driver.logDebug) Driver.debug("getSystemFunctions");
- return "";
- }
-
- public String getTimeDateFunctions() throws SQLException
- {
- // XXX-Not Implemented
- if (Driver.logDebug) Driver.debug("getTimeDateFunctions");
- return "";
- }
-
- /*
- * This is the string that can be used to escape '_' and '%' in
- * a search string pattern style catalog search parameters
- *
- * @return the string used to escape wildcard characters
- * @exception SQLException if a database access error occurs
- */
- public String getSearchStringEscape() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("getSearchStringEscape");
- return "\\";
- }
-
- /*
- * Get all the "extra" characters that can be used in unquoted
- * identifier names (those beyond a-zA-Z0-9 and _)
- *
- * <p>From the file src/backend/parser/scan.l, an identifier is
- * {letter}{letter_or_digit} which makes it just those listed
- * above.
- *
- * @return a string containing the extra characters
- * @exception SQLException if a database access error occurs
- */
- public String getExtraNameCharacters() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("getExtraNameCharacters");
- return "";
- }
-
- /*
- * Is "ALTER TABLE" with an add column supported?
- * Yes for PostgreSQL 6.1
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsAlterTableWithAddColumn() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsAlterTableWithAddColumn " + true);
- return true;
- }
-
- /*
- * Is "ALTER TABLE" with a drop column supported?
- * Peter 10/10/2000 This was set to true, but 7.1devel doesn't support it!
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsAlterTableWithDropColumn() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsAlterTableWithDropColumn " + false);
- return false;
- }
-
- /*
- * Is column aliasing supported?
- *
- * <p>If so, the SQL AS clause can be used to provide names for
- * computed columns or to provide alias names for columns as
- * required. A JDBC Compliant driver always returns true.
- *
- * <p>e.g.
- *
- * <br><pre>
- * select count(C) as C_COUNT from T group by C;
- *
- * </pre><br>
- * should return a column named as C_COUNT instead of count(C)
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsColumnAliasing() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsColumnAliasing " + true);
- return true;
- }
-
- /*
- * Are concatenations between NULL and non-NULL values NULL? A
- * JDBC Compliant driver always returns true
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean nullPlusNonNullIsNull() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("nullPlusNonNullIsNull " + true);
- return true;
- }
-
- public boolean supportsConvert() throws SQLException
- {
- // XXX-Not Implemented
- if (Driver.logDebug) Driver.debug("supportsConvert " + false);
- return false;
- }
-
- public boolean supportsConvert(int fromType, int toType) throws SQLException
- {
- // XXX-Not Implemented
- if (Driver.logDebug) Driver.debug("supportsConvert " + false);
- return false;
- }
-
- /*
- * Are table correlation names supported? A JDBC Compliant
- * driver always returns true.
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsTableCorrelationNames() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsTableCorrelationNames " + true);
- return true;
- }
-
- /*
- * If table correlation names are supported, are they restricted to
- * be different from the names of the tables?
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsDifferentTableCorrelationNames() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsDifferentTableCorrelationNames " + false);
- return false;
- }
-
- /*
- * Are expressions in "ORDER BY" lists supported?
- *
- * <br>e.g. select * from t order by a + b;
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsExpressionsInOrderBy() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsExpressionsInOrderBy " + true);
- return true;
- }
-
- /*
- * Can an "ORDER BY" clause use columns not in the SELECT?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOrderByUnrelated() throws SQLException
- {
- boolean supportsOrderByUnrelated = connection.haveMinimumServerVersion("6.4");
- if (Driver.logDebug) Driver.debug("supportsOrderByUnrelated " + supportsOrderByUnrelated);
- return supportsOrderByUnrelated;
- }
-
- /*
- * Is some form of "GROUP BY" clause supported?
- * I checked it, and yes it is.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsGroupBy() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsGroupBy " + true);
- return true;
- }
-
- /*
- * Can a "GROUP BY" clause use columns not in the SELECT?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsGroupByUnrelated() throws SQLException
- {
- boolean supportsGroupByUnrelated = connection.haveMinimumServerVersion("6.4");
- if (Driver.logDebug) Driver.debug("supportsGroupByUnrelated " + supportsGroupByUnrelated);
- return supportsGroupByUnrelated;
- }
-
- /*
- * Can a "GROUP BY" clause add columns not in the SELECT provided
- * it specifies all the columns in the SELECT? Does anyone actually
- * understand what they mean here?
- *
- * (I think this is a subset of the previous function. -- petere)
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsGroupByBeyondSelect() throws SQLException
- {
- boolean supportsGroupByBeyondSelect = connection.haveMinimumServerVersion("6.4");
- if (Driver.logDebug) Driver.debug("supportsGroupByUnrelated " + supportsGroupByBeyondSelect);
- return supportsGroupByBeyondSelect;
- }
-
- /*
- * Is the escape character in "LIKE" clauses supported? A
- * JDBC compliant driver always returns true.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsLikeEscapeClause() throws SQLException
- {
- boolean supportsLikeEscapeClause = connection.haveMinimumServerVersion("7.1");
- if (Driver.logDebug) Driver.debug("supportsLikeEscapeClause " + supportsLikeEscapeClause);
- return supportsLikeEscapeClause;
- }
-
- /*
- * Are multiple ResultSets from a single execute supported?
- * Well, I implemented it, but I dont think this is possible from
- * the back ends point of view.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMultipleResultSets() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsMultipleResultSets " + false);
- return false;
- }
-
- /*
- * Can we have multiple transactions open at once (on different
- * connections?)
- * I guess we can have, since Im relying on it.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMultipleTransactions() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsMultipleTransactions " + true);
- return true;
- }
-
- /*
- * Can columns be defined as non-nullable. A JDBC Compliant driver
- * always returns true.
- *
- * <p>This changed from false to true in v6.2 of the driver, as this
- * support was added to the backend.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsNonNullableColumns() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsNonNullableColumns true");
- return true;
- }
-
- /*
- * Does this driver support the minimum ODBC SQL grammar. This
- * grammar is defined at:
- *
- * <p><a href="http://www.microsoft.com/msdn/sdk/platforms/doc/odbc/src/intropr.htm">http://www.microsoft.com/msdn/sdk/platforms/doc/odbc/src/intropr.htm</a>
- *
- * <p>In Appendix C. From this description, we seem to support the
- * ODBC minimal (Level 0) grammar.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsMinimumSQLGrammar() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsMinimumSQLGrammar TRUE");
- return true;
- }
-
- /*
- * Does this driver support the Core ODBC SQL grammar. We need
- * SQL-92 conformance for this.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCoreSQLGrammar() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsCoreSQLGrammar FALSE ");
- return false;
- }
-
- /*
- * Does this driver support the Extended (Level 2) ODBC SQL
- * grammar. We don't conform to the Core (Level 1), so we can't
- * conform to the Extended SQL Grammar.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsExtendedSQLGrammar() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsExtendedSQLGrammar FALSE");
- return false;
- }
-
- /*
- * Does this driver support the ANSI-92 entry level SQL grammar?
- * All JDBC Compliant drivers must return true. We currently
- * report false until 'schema' support is added. Then this
- * should be changed to return true, since we will be mostly
- * compliant (probably more compliant than many other databases)
- * And since this is a requirement for all JDBC drivers we
- * need to get to the point where we can return true.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsANSI92EntryLevelSQL() throws SQLException
- {
- boolean schemas = connection.haveMinimumServerVersion("7.3");
- if (Driver.logDebug) Driver.debug("supportsANSI92EntryLevelSQL " + schemas);
- return schemas;
-
- }
-
- /*
- * Does this driver support the ANSI-92 intermediate level SQL
- * grammar?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsANSI92IntermediateSQL() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsANSI92IntermediateSQL false ");
- return false;
- }
-
- /*
- * Does this driver support the ANSI-92 full SQL grammar?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsANSI92FullSQL() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsANSI92FullSQL false ");
- return false;
- }
-
- /*
- * Is the SQL Integrity Enhancement Facility supported?
- * I haven't seen this mentioned anywhere, so I guess not
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsIntegrityEnhancementFacility() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsIntegrityEnhancementFacility false ");
- return false;
- }
-
- /*
- * Is some form of outer join supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOuterJoins() throws SQLException
- {
- boolean supportsOuterJoins = connection.haveMinimumServerVersion("7.1");
- if (Driver.logDebug) Driver.debug("supportsOuterJoins " + supportsOuterJoins);
- return supportsOuterJoins;
- }
-
- /*
- * Are full nexted outer joins supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsFullOuterJoins() throws SQLException
- {
- boolean supportsFullOuterJoins = connection.haveMinimumServerVersion("7.1");
- if (Driver.logDebug) Driver.debug("supportsFullOuterJoins " + supportsFullOuterJoins);
- return supportsFullOuterJoins;
- }
-
- /*
- * Is there limited support for outer joins?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsLimitedOuterJoins() throws SQLException
- {
- boolean supportsLimitedOuterJoins = connection.haveMinimumServerVersion("7.1");
- if (Driver.logDebug) Driver.debug("supportsFullOuterJoins " + supportsLimitedOuterJoins);
- return supportsLimitedOuterJoins;
- }
-
- /*
- * What is the database vendor's preferred term for "schema"?
- * PostgreSQL doesn't have schemas, but when it does, we'll use the
- * term "schema".
- *
- * @return the vendor term
- * @exception SQLException if a database access error occurs
- */
- public String getSchemaTerm() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("getSchemaTerm schema");
- return "schema";
- }
-
- /*
- * What is the database vendor's preferred term for "procedure"?
- * Traditionally, "function" has been used.
- *
- * @return the vendor term
- * @exception SQLException if a database access error occurs
- */
- public String getProcedureTerm() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("getProcedureTerm function ");
- return "function";
- }
-
- /*
- * What is the database vendor's preferred term for "catalog"?
- *
- * @return the vendor term
- * @exception SQLException if a database access error occurs
- */
- public String getCatalogTerm() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("getCatalogTerm database ");
- return "database";
- }
-
- /*
- * Does a catalog appear at the start of a qualified table name?
- * (Otherwise it appears at the end).
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isCatalogAtStart() throws SQLException
- {
- // return true here; we return false for every other catalog function
- // so it won't matter what we return here D.C.
- if (Driver.logDebug) Driver.debug("isCatalogAtStart not implemented");
- return true;
- }
-
- /*
- * What is the Catalog separator.
- *
- * @return the catalog separator string
- * @exception SQLException if a database access error occurs
- */
- public String getCatalogSeparator() throws SQLException
- {
- // Give them something to work with here
- // everything else returns false so it won't matter what we return here D.C.
- if (Driver.logDebug) Driver.debug("getCatalogSeparator not implemented ");
- return ".";
- }
-
- /*
- * Can a schema name be used in a data manipulation statement? Nope.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInDataManipulation() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsSchemasInDataManipulation false");
- return false;
- }
-
- /*
- * Can a schema name be used in a procedure call statement? Nope.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInProcedureCalls() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsSchemasInProcedureCalls false");
- return false;
- }
-
- /*
- * Can a schema be used in a table definition statement? Nope.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInTableDefinitions() throws SQLException
- {
- boolean schemas = connection.haveMinimumServerVersion("7.3");
-
- if (Driver.logDebug) Driver.debug("supportsSchemasInTableDefinitions " + schemas);
- return schemas;
- }
-
- /*
- * Can a schema name be used in an index definition statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInIndexDefinitions() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsSchemasInIndexDefinitions false");
- return false;
- }
-
- /*
- * Can a schema name be used in a privilege definition statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsSchemasInPrivilegeDefinitions false");
- return false;
- }
-
- /*
- * Can a catalog name be used in a data manipulation statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInDataManipulation() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsCatalogsInDataManipulation false");
- return false;
- }
-
- /*
- * Can a catalog name be used in a procedure call statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInProcedureCalls() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsCatalogsInDataManipulation false");
- return false;
- }
-
- /*
- * Can a catalog name be used in a table definition statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInTableDefinitions() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsCatalogsInTableDefinitions false");
- return false;
- }
-
- /*
- * Can a catalog name be used in an index definition?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInIndexDefinitions() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsCatalogsInIndexDefinitions false");
- return false;
- }
-
- /*
- * Can a catalog name be used in a privilege definition statement?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsCatalogsInPrivilegeDefinitions false");
- return false;
- }
-
- /*
- * We support cursors for gets only it seems. I dont see a method
- * to get a positioned delete.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsPositionedDelete() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsPositionedDelete false");
- return false; // For now...
- }
-
- /*
- * Is positioned UPDATE supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsPositionedUpdate() throws SQLException
- {
- if (Driver.logDebug) Driver.debug("supportsPositionedUpdate false");
- return false; // For now...
- }
-
- /*
- * Is SELECT for UPDATE supported?
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSelectForUpdate() throws SQLException
- {
- return connection.haveMinimumServerVersion("6.5");
- }
-
- /*
- * Are stored procedure calls using the stored procedure escape
- * syntax supported?
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsStoredProcedures() throws SQLException
- {
- return false;
- }
-
- /*
- * Are subqueries in comparison expressions supported? A JDBC
- * Compliant driver always returns true.
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSubqueriesInComparisons() throws SQLException
- {
- return true;
- }
-
- /*
- * Are subqueries in 'exists' expressions supported? A JDBC
- * Compliant driver always returns true.
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSubqueriesInExists() throws SQLException
- {
- return true;
- }
-
- /*
- * Are subqueries in 'in' statements supported? A JDBC
- * Compliant driver always returns true.
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSubqueriesInIns() throws SQLException
- {
- return true;
- }
-
- /*
- * Are subqueries in quantified expressions supported? A JDBC
- * Compliant driver always returns true.
- *
- * (No idea what this is, but we support a good deal of
- * subquerying.)
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsSubqueriesInQuantifieds() throws SQLException
- {
- return true;
- }
-
- /*
- * Are correlated subqueries supported? A JDBC Compliant driver
- * always returns true.
- *
- * (a.k.a. subselect in from?)
- *
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsCorrelatedSubqueries() throws SQLException
- {
- return connection.haveMinimumServerVersion("7.1");
- }
-
- /*
- * Is SQL UNION supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsUnion() throws SQLException
- {
- return true; // since 6.3
- }
-
- /*
- * Is SQL UNION ALL supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsUnionAll() throws SQLException
- {
- return connection.haveMinimumServerVersion("7.1");
- }
-
- /*
- * In PostgreSQL, Cursors are only open within transactions.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOpenCursorsAcrossCommit() throws SQLException
- {
- return false;
- }
-
- /*
- * Do we support open cursors across multiple transactions?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOpenCursorsAcrossRollback() throws SQLException
- {
- return false;
- }
-
- /*
- * Can statements remain open across commits? They may, but
- * this driver cannot guarentee that. In further reflection.
- * we are talking a Statement object here, so the answer is
- * yes, since the Statement is only a vehicle to ExecSQL()
- *
- * @return true if they always remain open; false otherwise
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOpenStatementsAcrossCommit() throws SQLException
- {
- return true;
- }
-
- /*
- * Can statements remain open across rollbacks? They may, but
- * this driver cannot guarentee that. In further contemplation,
- * we are talking a Statement object here, so the answer is yes,
- * since the Statement is only a vehicle to ExecSQL() in Connection
- *
- * @return true if they always remain open; false otherwise
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsOpenStatementsAcrossRollback() throws SQLException
- {
- return true;
- }
-
- /*
- * How many hex characters can you have in an inline binary literal
- *
- * @return the max literal length
- * @exception SQLException if a database access error occurs
- */
- public int getMaxBinaryLiteralLength() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What is the maximum length for a character literal
- * I suppose it is 8190 (8192 - 2 for the quotes)
- *
- * @return the max literal length
- * @exception SQLException if a database access error occurs
- */
- public int getMaxCharLiteralLength() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * Whats the limit on column name length. The description of
- * pg_class would say '32' (length of pg_class.relname) - we
- * should probably do a query for this....but....
- *
- * @return the maximum column name length
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnNameLength() throws SQLException
- {
- return 32;
- }
-
- /*
- * What is the maximum number of columns in a "GROUP BY" clause?
- *
- * @return the max number of columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInGroupBy() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What's the maximum number of columns allowed in an index?
- * 6.0 only allowed one column, but 6.1 introduced multi-column
- * indices, so, theoretically, its all of them.
- *
- * @return max number of columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInIndex() throws SQLException
- {
- return getMaxColumnsInTable();
- }
-
- /*
- * What's the maximum number of columns in an "ORDER BY clause?
- *
- * @return the max columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInOrderBy() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What is the maximum number of columns in a "SELECT" list?
- *
- * @return the max columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInSelect() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What is the maximum number of columns in a table? From the
- * CREATE TABLE reference page...
- *
- * <p>"The new class is created as a heap with no initial data. A
- * class can have no more than 1600 attributes (realistically,
- * this is limited by the fact that tuple sizes must be less than
- * 8192 bytes)..."
- *
- * @return the max columns
- * @exception SQLException if a database access error occurs
- */
- public int getMaxColumnsInTable() throws SQLException
- {
- return 1600;
- }
-
- /*
- * How many active connection can we have at a time to this
- * database? Well, since it depends on postmaster, which just
- * does a listen() followed by an accept() and fork(), its
- * basically very high. Unless the system runs out of processes,
- * it can be 65535 (the number of aux. ports on a TCP/IP system).
- * I will return 8192 since that is what even the largest system
- * can realistically handle,
- *
- * @return the maximum number of connections
- * @exception SQLException if a database access error occurs
- */
- public int getMaxConnections() throws SQLException
- {
- return 8192;
- }
-
- /*
- * What is the maximum cursor name length (the same as all
- * the other F***** identifiers!)
- *
- * @return max cursor name length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxCursorNameLength() throws SQLException
- {
- return 32;
- }
-
- /*
- * Retrieves the maximum number of bytes for an index, including all
- * of the parts of the index.
- *
- * @return max index length in bytes, which includes the composite
- * of all the constituent parts of the index; a result of zero means
- * that there is no limit or the limit is not known
- * @exception SQLException if a database access error occurs
- */
- public int getMaxIndexLength() throws SQLException
- {
- return 0; // no limit (larger than an int anyway)
- }
-
- public int getMaxSchemaNameLength() throws SQLException
- {
- // XXX-Not Implemented
- return 0;
- }
-
- /*
- * What is the maximum length of a procedure name?
- * (length of pg_proc.proname used) - again, I really
- * should do a query here to get it.
- *
- * @return the max name length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxProcedureNameLength() throws SQLException
- {
- return 32;
- }
-
- public int getMaxCatalogNameLength() throws SQLException
- {
- // XXX-Not Implemented
- return 0;
- }
-
- /*
- * What is the maximum length of a single row?
- *
- * @return max row size in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxRowSize() throws SQLException
- {
- if (connection.haveMinimumServerVersion("7.1"))
- return 1073741824; // 1 GB
- else
- return 8192; // XXX could be altered
- }
-
- /*
- * Did getMaxRowSize() include LONGVARCHAR and LONGVARBINARY
- * blobs? We don't handle blobs yet
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean doesMaxRowSizeIncludeBlobs() throws SQLException
- {
- return false;
- }
-
- /*
- * What is the maximum length of a SQL statement?
- *
- * @return max length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxStatementLength() throws SQLException
- {
- if (connection.haveMinimumServerVersion("7.0"))
- return 0; // actually whatever fits in size_t
- else
- return 16384;
- }
-
- /*
- * How many active statements can we have open at one time to
- * this database? Basically, since each Statement downloads
- * the results as the query is executed, we can have many. However,
- * we can only really have one statement per connection going
- * at once (since they are executed serially) - so we return
- * one.
- *
- * @return the maximum
- * @exception SQLException if a database access error occurs
- */
- public int getMaxStatements() throws SQLException
- {
- return 1;
- }
-
- /*
- * What is the maximum length of a table name? This was found
- * from pg_class.relname length
- *
- * @return max name length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxTableNameLength() throws SQLException
- {
- return 32;
- }
-
- /*
- * What is the maximum number of tables that can be specified
- * in a SELECT?
- *
- * @return the maximum
- * @exception SQLException if a database access error occurs
- */
- public int getMaxTablesInSelect() throws SQLException
- {
- return 0; // no limit
- }
-
- /*
- * What is the maximum length of a user name? Well, we generally
- * use UNIX like user names in PostgreSQL, so I think this would
- * be 8. However, showing the schema for pg_user shows a length
- * for username of 32.
- *
- * @return the max name length in bytes
- * @exception SQLException if a database access error occurs
- */
- public int getMaxUserNameLength() throws SQLException
- {
- return 32;
- }
-
-
- /*
- * What is the database's default transaction isolation level? We
- * do not support this, so all transactions are SERIALIZABLE.
- *
- * @return the default isolation level
- * @exception SQLException if a database access error occurs
- * @see Connection
- */
- public int getDefaultTransactionIsolation() throws SQLException
- {
- return Connection.TRANSACTION_READ_COMMITTED;
- }
-
- /*
- * Are transactions supported? If not, commit and rollback are noops
- * and the isolation level is TRANSACTION_NONE. We do support
- * transactions.
- *
- * @return true if transactions are supported
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsTransactions() throws SQLException
- {
- return true;
- }
-
- /*
- * Does the database support the given transaction isolation level?
- * We only support TRANSACTION_SERIALIZABLE and TRANSACTION_READ_COMMITTED
- *
- * @param level the values are defined in java.sql.Connection
- * @return true if so
- * @exception SQLException if a database access error occurs
- * @see Connection
- */
- public boolean supportsTransactionIsolationLevel(int level) throws SQLException
- {
- if (level == Connection.TRANSACTION_SERIALIZABLE ||
- level == Connection.TRANSACTION_READ_COMMITTED)
- return true;
- else
- return false;
- }
-
- /*
- * Are both data definition and data manipulation transactions
- * supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException
- {
- return true;
- }
-
- /*
- * Are only data manipulation statements withing a transaction
- * supported?
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean supportsDataManipulationTransactionsOnly() throws SQLException
- {
- return false;
- }
-
- /*
- * Does a data definition statement within a transaction force
- * the transaction to commit? I think this means something like:
- *
- * <p><pre>
- * CREATE TABLE T (A INT);
- * INSERT INTO T (A) VALUES (2);
- * BEGIN;
- * UPDATE T SET A = A + 1;
- * CREATE TABLE X (A INT);
- * SELECT A FROM T INTO X;
- * COMMIT;
- * </pre><p>
- *
- * does the CREATE TABLE call cause a commit? The answer is no.
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean dataDefinitionCausesTransactionCommit() throws SQLException
- {
- return false;
- }
-
- /*
- * Is a data definition statement within a transaction ignored?
- * It seems to be (from experiment in previous method)
- *
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean dataDefinitionIgnoredInTransactions() throws SQLException
- {
- return true;
- }
-
- /*
- * Get a description of stored procedures available in a catalog
- *
- * <p>Only procedure descriptions matching the schema and procedure
- * name criteria are returned. They are ordered by PROCEDURE_SCHEM
- * and PROCEDURE_NAME
- *
- * <p>Each procedure description has the following columns:
- * <ol>
- * <li><b>PROCEDURE_CAT</b> String => procedure catalog (may be null)
- * <li><b>PROCEDURE_SCHEM</b> String => procedure schema (may be null)
- * <li><b>PROCEDURE_NAME</b> String => procedure name
- * <li><b>Field 4</b> reserved (make it null)
- * <li><b>Field 5</b> reserved (make it null)
- * <li><b>Field 6</b> reserved (make it null)
- * <li><b>REMARKS</b> String => explanatory comment on the procedure
- * <li><b>PROCEDURE_TYPE</b> short => kind of procedure
- * <ul>
- * <li> procedureResultUnknown - May return a result
- * <li> procedureNoResult - Does not return a result
- * <li> procedureReturnsResult - Returns a result
- * </ul>
- * </ol>
- *
- * @param catalog - a catalog name; "" retrieves those without a
- * catalog; null means drop catalog name from criteria
- * @param schemaParrern - a schema name pattern; "" retrieves those
- * without a schema - we ignore this parameter
- * @param procedureNamePattern - a procedure name pattern
- * @return ResultSet - each row is a procedure description
- * @exception SQLException if a database access error occurs
- */
- public java.sql.ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException
- {
- // the field descriptors for the new ResultSet
- Field f[] = new Field[8];
- java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "PROCEDURE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "PROCEDURE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "PROCEDURE_NAME", iVarcharOid, 32);
- f[3] = f[4] = f[5] = new Field(connection, "reserved", iVarcharOid, 32); // null; // reserved, must be null for now
- f[6] = new Field(connection, "REMARKS", iVarcharOid, 8192);
- f[7] = new Field(connection, "PROCEDURE_TYPE", iInt2Oid, 2);
-
- // If the pattern is null, then set it to the default
- if (procedureNamePattern == null)
- procedureNamePattern = "%";
-
- r = connection.ExecSQL("select proname, proretset from pg_proc where proname like '" + procedureNamePattern.toLowerCase() + "' order by proname");
-
- while (r.next())
- {
- byte[][] tuple = new byte[8][0];
-
- tuple[0] = null; // Catalog name
- tuple[1] = null; // Schema name
- tuple[2] = r.getBytes(1); // Procedure name
- tuple[3] = tuple[4] = tuple[5] = null; // Reserved
- tuple[6] = null;
-
- if (r.getBoolean(2))
- tuple[7] = Integer.toString(java.sql.DatabaseMetaData.procedureReturnsResult).getBytes();
- else
- tuple[7] = Integer.toString(java.sql.DatabaseMetaData.procedureNoResult).getBytes();
-
- v.addElement(tuple);
- }
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of a catalog's stored procedure parameters
- * and result columns.
- *
- * <p>Only descriptions matching the schema, procedure and parameter
- * name criteria are returned. They are ordered by PROCEDURE_SCHEM
- * and PROCEDURE_NAME. Within this, the return value, if any, is
- * first. Next are the parameter descriptions in call order. The
- * column descriptions follow in column number order.
- *
- * <p>Each row in the ResultSet is a parameter description or column
- * description with the following fields:
- * <ol>
- * <li><b>PROCEDURE_CAT</b> String => procedure catalog (may be null)
- * <li><b>PROCEDURE_SCHE</b>M String => procedure schema (may be null)
- * <li><b>PROCEDURE_NAME</b> String => procedure name
- * <li><b>COLUMN_NAME</b> String => column/parameter name
- * <li><b>COLUMN_TYPE</b> Short => kind of column/parameter:
- * <ul><li>procedureColumnUnknown - nobody knows
- * <li>procedureColumnIn - IN parameter
- * <li>procedureColumnInOut - INOUT parameter
- * <li>procedureColumnOut - OUT parameter
- * <li>procedureColumnReturn - procedure return value
- * <li>procedureColumnResult - result column in ResultSet
- * </ul>
- * <li><b>DATA_TYPE</b> short => SQL type from java.sql.Types
- * <li><b>TYPE_NAME</b> String => SQL type name
- * <li><b>PRECISION</b> int => precision
- * <li><b>LENGTH</b> int => length in bytes of data
- * <li><b>SCALE</b> short => scale
- * <li><b>RADIX</b> short => radix
- * <li><b>NULLABLE</b> short => can it contain NULL?
- * <ul><li>procedureNoNulls - does not allow NULL values
- * <li>procedureNullable - allows NULL values
- * <li>procedureNullableUnknown - nullability unknown
- * <li><b>REMARKS</b> String => comment describing parameter/column
- * </ol>
- * @param catalog This is ignored in org.postgresql, advise this is set to null
- * @param schemaPattern This is ignored in org.postgresql, advise this is set to null
- * @param procedureNamePattern a procedure name pattern
- * @param columnNamePattern a column name pattern
- * @return each row is a stored procedure parameter or column description
- * @exception SQLException if a database-access error occurs
- * @see #getSearchStringEscape
- */
- // Implementation note: This is required for Borland's JBuilder to work
- public java.sql.ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException
- {
- if (procedureNamePattern == null)
- procedureNamePattern = "%";
-
- if (columnNamePattern == null)
- columnNamePattern = "%";
-
- // for now, this returns an empty result set.
- Field f[] = new Field[13];
- ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "PROCEDURE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "PROCEDURE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "PROCEDURE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "COLUMN_TYPE", iInt2Oid, 2);
- f[5] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
- f[6] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
- f[7] = new Field(connection, "PRECISION", iInt4Oid, 4);
- f[8] = new Field(connection, "LENGTH", iInt4Oid, 4);
- f[9] = new Field(connection, "SCALE", iInt2Oid, 2);
- f[10] = new Field(connection, "RADIX", iInt2Oid, 2);
- f[11] = new Field(connection, "NULLABLE", iInt2Oid, 2);
- f[12] = new Field(connection, "REMARKS", iVarcharOid, 32);
-
- // add query loop here
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of tables available in a catalog.
- *
- * <p>Only table descriptions matching the catalog, schema, table
- * name and type criteria are returned. They are ordered by
- * TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
- *
- * <p>Each table description has the following columns:
- *
- * <ol>
- * <li><b>TABLE_CAT</b> String => table catalog (may be null)
- * <li><b>TABLE_SCHEM</b> String => table schema (may be null)
- * <li><b>TABLE_NAME</b> String => table name
- * <li><b>TABLE_TYPE</b> String => table type. Typical types are "TABLE",
- * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL
- * TEMPORARY", "ALIAS", "SYNONYM".
- * <li><b>REMARKS</b> String => explanatory comment on the table
- * </ol>
- *
- * <p>The valid values for the types parameter are:
- * "TABLE", "INDEX", "SEQUENCE", "SYSTEM TABLE" and "SYSTEM INDEX"
- *
- * @param catalog a catalog name; For org.postgresql, this is ignored, and
- * should be set to null
- * @param schemaPattern a schema name pattern; For org.postgresql, this is ignored, and
- * should be set to null
- * @param tableNamePattern a table name pattern. For all tables this should be "%"
- * @param types a list of table types to include; null returns
- * all types
- * @return each row is a table description
- * @exception SQLException if a database-access error occurs.
- */
- public java.sql.ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SQLException
- {
- // Handle default value for types
- if (types == null)
- types = defaultTableTypes;
-
- if (tableNamePattern == null)
- tableNamePattern = "%";
-
- // the field descriptors for the new ResultSet
- Field f[] = new Field[5];
- java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "TABLE_TYPE", iVarcharOid, 32);
- f[4] = new Field(connection, "REMARKS", iVarcharOid, 32);
-
- // Now form the query
- StringBuffer sql = new StringBuffer("select relname,oid,relkind from pg_class where (");
-
- boolean notFirst = false;
- for (int i = 0;i < types.length;i++)
- {
- for (int j = 0;j < getTableTypes.length;j++)
- if (getTableTypes[j][0].equals(types[i]))
- {
- if (notFirst)
- sql.append(" or ");
- sql.append(getTableTypes[j][1]);
- notFirst = true;
- }
- }
-
- // Added by Stefan Andreasen <stefan@linux.kapow.dk>
- // Now take the pattern into account
- sql.append(") and relname like '");
- sql.append(tableNamePattern.toLowerCase());
- sql.append("' order by relkind, relname");
-
- // Now run the query
- r = connection.ExecSQL(sql.toString());
-
- while (r.next())
- {
- byte[][] tuple = new byte[5][0];
-
- // Fetch the description for the table (if any)
- String getDescriptionStatement =
- connection.haveMinimumServerVersion("7.2") ?
- "select obj_description(" + r.getInt(2) + ",'pg_class')" :
- "select description from pg_description where objoid=" + r.getInt(2);
-
- java.sql.ResultSet dr = connection.ExecSQL(getDescriptionStatement);
-
- byte remarks[] = null;
-
- if (((org.postgresql.ResultSet)dr).getTupleCount() == 1)
- {
- dr.next();
- remarks = dr.getBytes(1);
- }
- dr.close();
-
- String relKind;
- switch (r.getBytes(3)[0])
- {
- case (byte) 'r':
- if ( r.getString(1).startsWith("pg_") )
- {
- relKind = "SYSTEM TABLE";
- }
- else
- {
- relKind = "TABLE";
- }
- break;
- case (byte) 'i':
- relKind = "INDEX";
- break;
- case (byte) 'S':
- relKind = "SEQUENCE";
- break;
- case (byte) 'v':
- relKind = "VIEW";
- break;
- default:
- relKind = null;
- }
-
- tuple[0] = null; // Catalog name
- tuple[1] = null; // Schema name
- tuple[2] = r.getBytes(1); // Table name
- tuple[3] = (relKind == null) ? null : relKind.getBytes(); // Table type
- tuple[4] = remarks; // Remarks
- v.addElement(tuple);
- }
- r.close();
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- // This array contains the valid values for the types argument
- // in getTables().
- //
- // Each supported type consists of it's name, and the sql where
- // clause to retrieve that value.
- //
- // IMPORTANT: the query must be enclosed in ( )
- private static final String getTableTypes[][] = {
- {"TABLE", "(relkind='r' and relhasrules='f' and relname !~ '^pg_' and relname !~ '^xinv')"},
- {"VIEW", "(relkind='v' and relname !~ '^pg_')"},
- {"INDEX", "(relkind='i' and relname !~ '^pg_')"},
- {"SEQUENCE", "(relkind='S' and relname !~ '^pg_')"},
- {"SYSTEM TABLE", "(relkind='r' and relname ~ '^pg_')"},
- {"SYSTEM INDEX", "(relkind='i' and relname ~ '^pg_')"}
- };
-
- // These are the default tables, used when NULL is passed to getTables
- // The choice of these provide the same behaviour as psql's \d
- private static final String defaultTableTypes[] = {
- "TABLE", "VIEW", "INDEX", "SEQUENCE"
- };
-
- /*
- * Get the schema names available in this database. The results
- * are ordered by schema name.
- *
- * <P>The schema column is:
- * <OL>
- * <LI><B>TABLE_SCHEM</B> String => schema name
- * </OL>
- *
- * @return ResultSet each row has a single String column that is a
- * schema name
- */
- public java.sql.ResultSet getSchemas() throws SQLException
- {
- // We don't use schemas, so we simply return a single schema name "".
- //
- Field f[] = new Field[1];
- Vector v = new Vector();
- byte[][] tuple = new byte[1][0];
- f[0] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- tuple[0] = "".getBytes();
- v.addElement(tuple);
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get the catalog names available in this database. The results
- * are ordered by catalog name.
- *
- * <P>The catalog column is:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => catalog name
- * </OL>
- *
- * @return ResultSet each row has a single String column that is a
- * catalog name
- */
- public java.sql.ResultSet getCatalogs() throws SQLException
- {
- return connection.createStatement().executeQuery("select datname as TABLE_CAT from pg_database;");
- }
-
- /*
- * Get the table types available in this database. The results
- * are ordered by table type.
- *
- * <P>The table type is:
- * <OL>
- * <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
- * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
- * "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
- * </OL>
- *
- * @return ResultSet each row has a single String column that is a
- * table type
- */
- public java.sql.ResultSet getTableTypes() throws SQLException
- {
- Field f[] = new Field[1];
- Vector v = new Vector();
- f[0] = new Field(connection, new String("TABLE_TYPE"), iVarcharOid, 32);
- for (int i = 0;i < getTableTypes.length;i++)
- {
- byte[][] tuple = new byte[2][0];
- tuple[0] = getTableTypes[i][0].getBytes();
- v.addElement(tuple);
- }
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of table columns available in a catalog.
- *
- * <P>Only column descriptions matching the catalog, schema, table
- * and column name criteria are returned. They are ordered by
- * TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION.
- *
- * <P>Each column description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
- * <LI><B>TYPE_NAME</B> String => Data source dependent type name
- * <LI><B>COLUMN_SIZE</B> int => column size. For char or date
- * types this is the maximum number of characters, for numeric or
- * decimal types this is precision.
- * <LI><B>BUFFER_LENGTH</B> is not used.
- * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
- * <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
- * <LI><B>NULLABLE</B> int => is NULL allowed?
- * <UL>
- * <LI> columnNoNulls - might not allow NULL values
- * <LI> columnNullable - definitely allows NULL values
- * <LI> columnNullableUnknown - nullability unknown
- * </UL>
- * <LI><B>REMARKS</B> String => comment describing column (may be null)
- * <LI><B>COLUMN_DEF</B> String => default value (may be null)
- * <LI><B>SQL_DATA_TYPE</B> int => unused
- * <LI><B>SQL_DATETIME_SUB</B> int => unused
- * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
- * maximum number of bytes in the column
- * <LI><B>ORDINAL_POSITION</B> int => index of column in table
- * (starting at 1)
- * <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
- * does not allow NULL values; "YES" means the column might
- * allow NULL values. An empty string means nobody knows.
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schemaPattern a schema name pattern; "" retrieves those
- * without a schema
- * @param tableNamePattern a table name pattern
- * @param columnNamePattern a column name pattern
- * @return ResultSet each row is a column description
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException
- {
- Vector v = new Vector(); // The new ResultSet tuple stuff
- Field f[] = new Field[18]; // The field descriptors for the new ResultSet
-
- f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
- f[5] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
- f[6] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
- f[7] = new Field(connection, "BUFFER_LENGTH", iVarcharOid, 32);
- f[8] = new Field(connection, "DECIMAL_DIGITS", iInt4Oid, 4);
- f[9] = new Field(connection, "NUM_PREC_RADIX", iInt4Oid, 4);
- f[10] = new Field(connection, "NULLABLE", iInt4Oid, 4);
- f[11] = new Field(connection, "REMARKS", iVarcharOid, 32);
- f[12] = new Field(connection, "COLUMN_DEF", iVarcharOid, 32);
- f[13] = new Field(connection, "SQL_DATA_TYPE", iInt4Oid, 4);
- f[14] = new Field(connection, "SQL_DATETIME_SUB", iInt4Oid, 4);
- f[15] = new Field(connection, "CHAR_OCTET_LENGTH", iVarcharOid, 32);
- f[16] = new Field(connection, "ORDINAL_POSITION", iInt4Oid, 4);
- f[17] = new Field(connection, "IS_NULLABLE", iVarcharOid, 32);
-
- StringBuffer sql = new StringBuffer(512);
-
- /* Build a >= 7.1 SQL statement to list all columns */
- sql.append("select " +
- (connection.haveMinimumServerVersion("7.2") ? "a.attrelid, " : "a.oid, ") +
- " c.relname, " +
- " a.attname, " +
- " a.atttypid, " +
- " a.attnum, " +
- " a.attnotnull, " +
- " a.attlen, " +
- " a.atttypmod, " +
- " d.adsrc, " +
- " t.typname, " +
- /* Use the new col_description in 7.2 or an additional outer join in 7.1 */
- (connection.haveMinimumServerVersion("7.2") ? "col_description(a.attrelid, a.attnum) " : "e.description ") +
- "from" +
- " (" +
- " (pg_class c inner join pg_attribute a on" +
- " (" +
- " a.attrelid=c.oid");
-
- if ((tableNamePattern != null) && ! tableNamePattern.equals("%"))
- {
- sql.append(" and c.relname like \'" + tableNamePattern.toLowerCase() + "\'");
- }
-
- if ((columnNamePattern != null) && ! columnNamePattern.equals("%"))
- {
- sql.append(" and a.attname like \'" + columnNamePattern + "\'");
- }
-
- sql.append(
- " and a.attnum > 0" +
- " )" +
- " ) inner join pg_type t on" +
- " (" +
- " t.oid = a.atttypid" +
- " )" +
- " )" +
- " left outer join pg_attrdef d on" +
- " (" +
- " c.oid = d.adrelid" +
- " and a.attnum = d.adnum" +
- " ) ");
-
- if (!connection.haveMinimumServerVersion("7.2"))
- {
- /* Only for 7.1 */
- sql.append(
- " left outer join pg_description e on" +
- " (" +
- " e.objoid = a.oid" +
- " ) ");
- }
-
- sql.append("order by" +
- " c.relname, a.attnum");
-
- java.sql.ResultSet r = connection.ExecSQL(sql.toString());
- while (r.next())
- {
- byte[][] tuple = new byte[18][0];
-
- String nullFlag = r.getString(6);
- String typname = r.getString(10);
-
- tuple[0] = null; // Catalog name, not supported
- tuple[1] = null; // Schema name, not supported
- tuple[2] = r.getBytes(2); // Table name
- tuple[3] = r.getBytes(3); // Column name
- tuple[4] = Integer.toString(connection.getSQLType(typname)).getBytes(); // Data type
- tuple[5] = typname.getBytes(); // Type name
-
- // Column size
- // Looking at the psql source,
- // I think the length of a varchar as specified when the table was created
- // should be extracted from atttypmod which contains this length + sizeof(int32)
- if (typname.equals("bpchar") || typname.equals("varchar"))
- {
- int atttypmod = r.getInt(8);
- tuple[6] = Integer.toString(atttypmod != -1 ? atttypmod - VARHDRSZ : 0).getBytes();
- }
- else
- {
- tuple[6] = r.getBytes(7);
- }
-
- tuple[7] = null; // Buffer length
- // Decimal digits = scale
- // From the source (see e.g. backend/utils/adt/format_type.c,
- // function numeric()) the scale and precision can be calculated
- // from the typmod value.
- if (typname.equals("numeric") || typname.equals("decimal"))
- {
- int attypmod = r.getInt(8) - VARHDRSZ;
- tuple[8] =
- Integer.toString( attypmod & 0xffff ).getBytes();
- tuple[9] =
- Integer.toString( ( attypmod >> 16 ) & 0xffff ).getBytes();
- }
- else
- {
- tuple[8] = "0".getBytes();
- tuple[9] = "10".getBytes(); // Num Prec Radix - assume decimal
- }
- tuple[10] = Integer.toString(nullFlag.equals("f") ?
- java.sql.DatabaseMetaData.columnNullable :
- java.sql.DatabaseMetaData.columnNoNulls).getBytes(); // Nullable
- tuple[11] = r.getBytes(11); // Description (if any)
- tuple[12] = r.getBytes(9); // Column default
- tuple[13] = null; // sql data type (unused)
- tuple[14] = null; // sql datetime sub (unused)
- tuple[15] = tuple[6]; // char octet length
- tuple[16] = r.getBytes(5); // ordinal position
- tuple[17] = (nullFlag.equals("f") ? "YES" : "NO").getBytes(); // Is nullable
-
- v.addElement(tuple);
- }
- r.close();
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of the access rights for a table's columns.
- *
- * <P>Only privileges matching the column name criteria are
- * returned. They are ordered by COLUMN_NAME and PRIVILEGE.
- *
- * <P>Each privilige description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>GRANTOR</B> => grantor of access (may be null)
- * <LI><B>GRANTEE</B> String => grantee of access
- * <LI><B>PRIVILEGE</B> String => name of access (SELECT,
- * INSERT, UPDATE, REFRENCES, ...)
- * <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
- * to grant to others; "NO" if not; null if unknown
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name; "" retrieves those without a schema
- * @param table a table name
- * @param columnNamePattern a column name pattern
- * @return ResultSet each row is a column privilege description
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException
- {
- Field f[] = new Field[8];
- Vector v = new Vector();
-
- if (table == null)
- table = "%";
-
- if (columnNamePattern == null)
- columnNamePattern = "%";
- else
- columnNamePattern = columnNamePattern.toLowerCase();
-
- f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "GRANTOR", iVarcharOid, 32);
- f[5] = new Field(connection, "GRANTEE", iVarcharOid, 32);
- f[6] = new Field(connection, "PRIVILEGE", iVarcharOid, 32);
- f[7] = new Field(connection, "IS_GRANTABLE", iVarcharOid, 32);
-
- // This is taken direct from the psql source
- java.sql.ResultSet r = connection.ExecSQL("SELECT relname, relacl FROM pg_class, pg_user WHERE ( relkind = 'r' OR relkind = 'i') and relname !~ '^pg_' and relname !~ '^xin[vx][0-9]+' and usesysid = relowner and relname like '" + table.toLowerCase() + "' ORDER BY relname");
- while (r.next())
- {
- byte[][] tuple = new byte[8][0];
- tuple[0] = tuple[1] = "".getBytes();
- if (Driver.logDebug) Driver.debug("relname=\"" + r.getString(1) + "\" relacl=\"" + r.getString(2) + "\"");
-
- // For now, don't add to the result as relacl needs to be processed.
- //v.addElement(tuple);
- }
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of the access rights for each table available
- * in a catalog.
- *
- * This method is currently unimplemented.
- *
- * <P>Only privileges matching the schema and table name
- * criteria are returned. They are ordered by TABLE_SCHEM,
- * TABLE_NAME, and PRIVILEGE.
- *
- * <P>Each privilige description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>GRANTOR</B> => grantor of access (may be null)
- * <LI><B>GRANTEE</B> String => grantee of access
- * <LI><B>PRIVILEGE</B> String => name of access (SELECT,
- * INSERT, UPDATE, REFRENCES, ...)
- * <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
- * to grant to others; "NO" if not; null if unknown
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schemaPattern a schema name pattern; "" retrieves those
- * without a schema
- * @param tableNamePattern a table name pattern
- * @return ResultSet each row is a table privilege description
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException
- {
- Field f[] = new Field[8];
- Vector v = new Vector();
-
- if (tableNamePattern == null)
- tableNamePattern = "%";
-
- f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "GRANTOR", iVarcharOid, 32);
- f[5] = new Field(connection, "GRANTEE", iVarcharOid, 32);
- f[6] = new Field(connection, "PRIVILEGE", iVarcharOid, 32);
- f[7] = new Field(connection, "IS_GRANTABLE", iVarcharOid, 32);
-
- // This is taken direct from the psql source
- java.sql.ResultSet r = connection.ExecSQL("SELECT relname, relacl FROM pg_class, pg_user WHERE ( relkind = 'r' OR relkind = 'i') and relname !~ '^pg_' and relname !~ '^xin[vx][0-9]+' and usesysid = relowner and relname like '" + tableNamePattern.toLowerCase() + "' ORDER BY relname");
- while (r.next())
- {
- byte[][] tuple = new byte[8][0];
- tuple[0] = tuple[1] = "".getBytes();
- if (Driver.logDebug) Driver.debug("relname=\"" + r.getString(1) + "\" relacl=\"" + r.getString(2) + "\"");
-
- // For now, don't add to the result as relacl needs to be processed.
- //v.addElement(tuple);
- }
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of a table's optimal set of columns that
- * uniquely identifies a row. They are ordered by SCOPE.
- *
- * This method is currently not implemented.
- *
- * <P>Each column description has the following columns:
- * <OL>
- * <LI><B>SCOPE</B> short => actual scope of result
- * <UL>
- * <LI> bestRowTemporary - very temporary, while using row
- * <LI> bestRowTransaction - valid for remainder of current transaction
- * <LI> bestRowSession - valid for remainder of current session
- * </UL>
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
- * <LI><B>TYPE_NAME</B> String => Data source dependent type name
- * <LI><B>COLUMN_SIZE</B> int => precision
- * <LI><B>BUFFER_LENGTH</B> int => not used
- * <LI><B>DECIMAL_DIGITS</B> short => scale
- * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
- * like an Oracle ROWID
- * <UL>
- * <LI> bestRowUnknown - may or may not be pseudo column
- * <LI> bestRowNotPseudo - is NOT a pseudo column
- * <LI> bestRowPseudo - is a pseudo column
- * </UL>
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name; "" retrieves those without a schema
- * @param table a table name
- * @param scope the scope of interest; use same values as SCOPE
- * @param nullable include columns that are nullable?
- * @return ResultSet each row is a column description
- */
- // Implementation note: This is required for Borland's JBuilder to work
- public java.sql.ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException
- {
- // for now, this returns an empty result set.
- Field f[] = new Field[8];
- ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "SCOPE", iInt2Oid, 2);
- f[1] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[2] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
- f[3] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
- f[5] = new Field(connection, "BUFFER_LENGTH", iInt4Oid, 4);
- f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
- f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- /*
- * Get a description of a table's columns that are automatically
- * updated when any value in a row is updated. They are
- * unordered.
- *
- * This method is currently unimplemented.
- *
- * <P>Each column description has the following columns:
- * <OL>
- * <LI><B>SCOPE</B> short => is not used
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
- * <LI><B>TYPE_NAME</B> String => Data source dependent type name
- * <LI><B>COLUMN_SIZE</B> int => precision
- * <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
- * <LI><B>DECIMAL_DIGITS</B> short => scale
- * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
- * like an Oracle ROWID
- * <UL>
- * <LI> versionColumnUnknown - may or may not be pseudo column
- * <LI> versionColumnNotPseudo - is NOT a pseudo column
- * <LI> versionColumnPseudo - is a pseudo column
- * </UL>
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name; "" retrieves those without a schema
- * @param table a table name
- * @return ResultSet each row is a column description
- */
- public java.sql.ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /*
- * Get a description of a table's primary key columns. They
- * are ordered by COLUMN_NAME.
- *
- * <P>Each column description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>COLUMN_NAME</B> String => column name
- * <LI><B>KEY_SEQ</B> short => sequence number within primary key
- * <LI><B>PK_NAME</B> String => primary key name (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those
- * without a schema
- * @param table a table name
- * @return ResultSet each row is a primary key column description
- */
- public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
- {
- return connection.createStatement().executeQuery("SELECT " +
- "'' as TABLE_CAT," +
- "'' AS TABLE_SCHEM," +
- "bc.relname AS TABLE_NAME," +
- "a.attname AS COLUMN_NAME," +
- "a.attnum as KEY_SEQ," +
- "ic.relname as PK_NAME " +
- " FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
- " WHERE bc.relkind = 'r' " + // -- not indices
- " and upper(bc.relname) = upper('" + table + "')" +
- " and i.indrelid = bc.oid" +
- " and i.indexrelid = ic.oid" +
- " and ic.oid = a.attrelid" +
- " and i.indisprimary='t' " +
- " ORDER BY table_name, pk_name, key_seq"
- );
- }
-/*
- SELECT
- c.relname as primary,
- c2.relname as foreign,
- t.tgconstrname,
- ic.relname as fkeyname,
- af.attnum as fkeyseq,
- ipc.relname as pkeyname,
- ap.attnum as pkeyseq,
- t.tgdeferrable,
- t.tginitdeferred,
- t.tgnargs,t.tgargs,
- p1.proname as updaterule,
- p2.proname as deleterule
-FROM
- pg_trigger t,
- pg_trigger t1,
- pg_class c,
- pg_class c2,
- pg_class ic,
- pg_class ipc,
- pg_proc p1,
- pg_proc p2,
- pg_index if,
- pg_index ip,
- pg_attribute af,
- pg_attribute ap
-WHERE
- (t.tgrelid=c.oid
- AND t.tgisconstraint
- AND t.tgconstrrelid=c2.oid
- AND t.tgfoid=p1.oid
- and p1.proname like '%%upd')
-
- and
- (t1.tgrelid=c.oid
- and t1.tgisconstraint
- and t1.tgconstrrelid=c2.oid
- AND t1.tgfoid=p2.oid
- and p2.proname like '%%del')
-
- AND c2.relname='users'
-
- AND
- (if.indrelid=c.oid
- AND if.indexrelid=ic.oid
- and ic.oid=af.attrelid
- AND if.indisprimary)
-
- and
- (ip.indrelid=c2.oid
- and ip.indexrelid=ipc.oid
- and ipc.oid=ap.attrelid
- and ip.indisprimary)
-
-*/
-/**
- *
- * @param catalog
- * @param schema
- * @param primaryTable if provided will get the keys exported by this table
- * @param foreignTable if provided will get the keys imported by this table
- * @return ResultSet
- * @throws SQLException
- */
-
- private java.sql.ResultSet getImportedExportedKeys(String catalog, String schema, String primaryTable, String foreignTable) throws SQLException
- {
- Field f[] = new Field[14];
-
- f[0] = new Field(connection, "PKTABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "PKTABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "PKTABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "PKCOLUMN_NAME", iVarcharOid, 32);
- f[4] = new Field(connection, "FKTABLE_CAT", iVarcharOid, 32);
- f[5] = new Field(connection, "FKTABLE_SCHEM", iVarcharOid, 32);
- f[6] = new Field(connection, "FKTABLE_NAME", iVarcharOid, 32);
- f[7] = new Field(connection, "FKCOLUMN_NAME", iVarcharOid, 32);
- f[8] = new Field(connection, "KEY_SEQ", iInt2Oid, 2);
- f[9] = new Field(connection, "UPDATE_RULE", iInt2Oid, 2);
- f[10] = new Field(connection, "DELETE_RULE", iInt2Oid, 2);
- f[11] = new Field(connection, "FK_NAME", iVarcharOid, 32);
- f[12] = new Field(connection, "PK_NAME", iVarcharOid, 32);
- f[13] = new Field(connection, "DEFERRABILITY", iInt2Oid, 2);
-
- java.sql.ResultSet rs = connection.ExecSQL(
- "SELECT "
- + "c.relname as prelname, "
- + "c2.relname as frelname, "
- + "t.tgconstrname, "
- + "a.attnum as keyseq, "
- + "ic.relname as fkeyname, "
- + "t.tgdeferrable, "
- + "t.tginitdeferred, "
- + "t.tgnargs,t.tgargs, "
- + "p1.proname as updaterule, "
- + "p2.proname as deleterule "
- + "FROM "
- + "pg_trigger t, "
- + "pg_trigger t1, "
- + "pg_class c, "
- + "pg_class c2, "
- + "pg_class ic, "
- + "pg_proc p1, "
- + "pg_proc p2, "
- + "pg_index i, "
- + "pg_attribute a "
- + "WHERE "
- // isolate the update rule
- + "(t.tgrelid=c.oid "
- + "AND t.tgisconstraint "
- + "AND t.tgconstrrelid=c2.oid "
- + "AND t.tgfoid=p1.oid "
- + "and p1.proname like '%%upd') "
-
- + "and "
- // isolate the delete rule
- + "(t1.tgrelid=c.oid "
- + "and t1.tgisconstraint "
- + "and t1.tgconstrrelid=c2.oid "
- + "AND t1.tgfoid=p2.oid "
- + "and p2.proname like '%%del') "
-
- // if we are looking for exported keys then primary table will be used
- + ((primaryTable != null) ? "AND c.relname='" + primaryTable + "' " : "")
-
- // if we are looking for imported keys then the foreign table will be used
- + ((foreignTable != null) ? "AND c2.relname='" + foreignTable + "' " : "")
- + "AND i.indrelid=c.oid "
- + "AND i.indexrelid=ic.oid "
- + "AND ic.oid=a.attrelid "
- + "AND i.indisprimary "
- + "ORDER BY "
-
- // orderby is as follows getExported, orders by FKTABLE,
- // getImported orders by PKTABLE
- // getCrossReference orders by FKTABLE, so this should work for both,
- // since when getting crossreference, primaryTable will be defined
-
- + (primaryTable != null ? "frelname" : "prelname") + ",keyseq");
-
-// returns the following columns
-// and some example data with a table defined as follows
-
-// create table people ( id int primary key);
-// create table policy ( id int primary key);
-// create table users ( id int primary key, people_id int references people(id), policy_id int references policy(id))
-
-// prelname | frelname | tgconstrname | keyseq | fkeyName | tgdeferrable | tginitdeferred
-// 1 | 2 | 3 | 4 | 5 | 6 | 7
-
-// people | users | <unnamed> | 1 | people_pkey | f | f
-
-// | tgnargs | tgargs | updaterule | deleterule
-// | 8 | 9 | 10 | 11
-// | 6 | <unnamed>\000users\000people\000UNSPECIFIED\000people_id\000id\000 | RI_FKey_noaction_upd | RI_FKey_noaction_del
-
- Vector tuples = new Vector();
-
-
- while ( rs.next() )
- {
- byte tuple[][] = new byte[14][];
-
- tuple[2] = rs.getBytes(1); //PKTABLE_NAME
- tuple[6] = rs.getBytes(2); //FKTABLE_NAME
- String fKeyName = rs.getString(3);
- String updateRule = rs.getString(10);
-
- if (updateRule != null )
- {
- // Rules look like this RI_FKey_noaction_del so we want to pull out the part between the 'Key_' and the last '_' s
-
- String rule = updateRule.substring(8, updateRule.length() - 4);
-
- int action = importedKeyNoAction;
-
- if ( rule == null || "noaction".equals(rule) )
- action = importedKeyNoAction;
- if ("cascade".equals(rule))
- action = importedKeyCascade;
- else if ("setnull".equals(rule))
- action = importedKeySetNull;
- else if ("setdefault".equals(rule))
- action = importedKeySetDefault;
- else if ("restrict".equals(rule))
- action = importedKeyRestrict;
-
- tuple[9] = Integer.toString(action).getBytes();
-
- }
-
- String deleteRule = rs.getString(11);
-
- if ( deleteRule != null )
- {
-
- String rule = updateRule.substring(8, updateRule.length() - 4);
-
- int action = importedKeyNoAction;
- if ("cascade".equals(rule))
- action = importedKeyCascade;
- else if ("setnull".equals(rule))
- action = importedKeySetNull;
- else if ("setdefault".equals(rule))
- action = importedKeySetDefault;
- tuple[10] = Integer.toString(action).getBytes();
- }
-
-
- // Parse the tgargs data
- StringBuffer fkeyColumns = new StringBuffer();
- StringBuffer pkeyColumns = new StringBuffer();
-
-
- // Note, I am guessing at most of this, but it should be close
- // if not, please correct
- // the keys are in pairs and start after the first four arguments
- // the arguments are seperated by \000
-
- int numColumns = (rs.getInt(8) >> 1) - 2;
-
-
-
- // get the args
- String targs = rs.getString(9);
-
- // start parsing from the end
- int pos = targs.lastIndexOf("\\000");
-
- for (int c = 0;c < numColumns;c++)
- {
- // this should never be, since we should never get to the beginning of the string
- // as the number of columns should override this, but it is a safe test
- if (pos > -1)
- {
- int pos2 = targs.lastIndexOf("\\000", pos - 1);
- if (pos2 > -1)
- {
- // seperate the pkColumns by ',' s
- if (pkeyColumns.length() > 0)
- pkeyColumns.insert(0, ',');
-
- // extract the column name out 4 characters ahead essentially removing the /000
- pkeyColumns.insert(0, targs.substring(pos2 + 4, pos)); //PKCOLUMN_NAME
-
- // now find the associated fkColumn
- pos = targs.lastIndexOf("\\000", pos2 - 1);
- if (pos > -1)
- {
- if (fkeyColumns.length() > 0)
- fkeyColumns.insert(0, ',');
- fkeyColumns.insert(0, targs.substring(pos + 4, pos2)); //FKCOLUMN_NAME
- }
- }
- }
- }
-
- tuple[3] = pkeyColumns.toString().getBytes(); //PKCOLUMN_NAME
- tuple[7] = fkeyColumns.toString().getBytes(); //FKCOLUMN_NAME
-
- tuple[8] = rs.getBytes(4); //KEY_SEQ
- tuple[11] = rs.getBytes(5); //FK_NAME
- tuple[12] = rs.getBytes(3); //PK_NAME
-
- // DEFERRABILITY
- int deferrability = importedKeyNotDeferrable;
- boolean deferrable = rs.getBoolean(6);
- boolean initiallyDeferred = rs.getBoolean(7);
- if (deferrable)
- {
- if (initiallyDeferred)
- deferrability = importedKeyInitiallyDeferred;
- else
- deferrability = importedKeyInitiallyImmediate;
- }
- tuple[13] = Integer.toString(deferrability).getBytes();
-
- tuples.addElement(tuple);
- }
-
- return new ResultSet(connection, f, tuples, "OK", 1);
- }
-
- /*
- * Get a description of the primary key columns that are
- * referenced by a table's foreign key columns (the primary keys
- * imported by a table). They are ordered by PKTABLE_CAT,
- * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
- *
- * <P>Each primary key column description has the following columns:
- * <OL>
- * <LI><B>PKTABLE_CAT</B> String => primary key table catalog
- * being imported (may be null)
- * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema
- * being imported (may be null)
- * <LI><B>PKTABLE_NAME</B> String => primary key table name
- * being imported
- * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
- * being imported
- * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
- * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
- * <LI><B>FKTABLE_NAME</B> String => foreign key table name
- * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
- * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
- * <LI><B>UPDATE_RULE</B> short => What happens to
- * foreign key when primary is updated:
- * <UL>
- * <LI> importedKeyCascade - change imported key to agree
- * with primary key update
- * <LI> importedKeyRestrict - do not allow update of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been updated
- * </UL>
- * <LI><B>DELETE_RULE</B> short => What happens to
- * the foreign key when primary is deleted.
- * <UL>
- * <LI> importedKeyCascade - delete rows that import a deleted key
- * <LI> importedKeyRestrict - do not allow delete of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been deleted
- * </UL>
- * <LI><B>FK_NAME</B> String => foreign key name (may be null)
- * <LI><B>PK_NAME</B> String => primary key name (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those
- * without a schema
- * @param table a table name
- * @return ResultSet each row is a primary key column description
- * @see #getExportedKeys
- */
- public java.sql.ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException
- {
- return getImportedExportedKeys(catalog, schema, null, table);
- }
-
- /*
- * Get a description of a foreign key columns that reference a
- * table's primary key columns (the foreign keys exported by a
- * table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
- * FKTABLE_NAME, and KEY_SEQ.
- *
- * This method is currently unimplemented.
- *
- * <P>Each foreign key column description has the following columns:
- * <OL>
- * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
- * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
- * <LI><B>PKTABLE_NAME</B> String => primary key table name
- * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
- * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
- * being exported (may be null)
- * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
- * being exported (may be null)
- * <LI><B>FKTABLE_NAME</B> String => foreign key table name
- * being exported
- * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
- * being exported
- * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
- * <LI><B>UPDATE_RULE</B> short => What happens to
- * foreign key when primary is updated:
- * <UL>
- * <LI> importedKeyCascade - change imported key to agree
- * with primary key update
- * <LI> importedKeyRestrict - do not allow update of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been updated
- * </UL>
- * <LI><B>DELETE_RULE</B> short => What happens to
- * the foreign key when primary is deleted.
- * <UL>
- * <LI> importedKeyCascade - delete rows that import a deleted key
- * <LI> importedKeyRestrict - do not allow delete of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been deleted
- * </UL>
- * <LI><B>FK_NAME</B> String => foreign key identifier (may be null)
- * <LI><B>PK_NAME</B> String => primary key identifier (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those
- * without a schema
- * @param table a table name
- * @return ResultSet each row is a foreign key column description
- * @see #getImportedKeys
- */
- public java.sql.ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException
- {
- return getImportedExportedKeys(catalog, schema, table, null);
- }
-
- /*
- * Get a description of the foreign key columns in the foreign key
- * table that reference the primary key columns of the primary key
- * table (describe how one table imports another's key.) This
- * should normally return a single foreign key/primary key pair
- * (most tables only import a foreign key from a table once.) They
- * are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
- * KEY_SEQ.
- *
- * This method is currently unimplemented.
- *
- * <P>Each foreign key column description has the following columns:
- * <OL>
- * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
- * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
- * <LI><B>PKTABLE_NAME</B> String => primary key table name
- * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
- * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
- * being exported (may be null)
- * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
- * being exported (may be null)
- * <LI><B>FKTABLE_NAME</B> String => foreign key table name
- * being exported
- * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
- * being exported
- * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
- * <LI><B>UPDATE_RULE</B> short => What happens to
- * foreign key when primary is updated:
- * <UL>
- * <LI> importedKeyCascade - change imported key to agree
- * with primary key update
- * <LI> importedKeyRestrict - do not allow update of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been updated
- * </UL>
- * <LI><B>DELETE_RULE</B> short => What happens to
- * the foreign key when primary is deleted.
- * <UL>
- * <LI> importedKeyCascade - delete rows that import a deleted key
- * <LI> importedKeyRestrict - do not allow delete of primary
- * key if it has been imported
- * <LI> importedKeySetNull - change imported key to NULL if
- * its primary key has been deleted
- * </UL>
- * <LI><B>FK_NAME</B> String => foreign key identifier (may be null)
- * <LI><B>PK_NAME</B> String => primary key identifier (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those
- * without a schema
- * @param table a table name
- * @return ResultSet each row is a foreign key column description
- * @see #getImportedKeys
- */
- public java.sql.ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException
- {
- return getImportedExportedKeys(primaryCatalog, primarySchema, primaryTable, foreignTable);
- }
-
- /*
- * Get a description of all the standard SQL types supported by
- * this database. They are ordered by DATA_TYPE and then by how
- * closely the data type maps to the corresponding JDBC SQL type.
- *
- * <P>Each type description has the following columns:
- * <OL>
- * <LI><B>TYPE_NAME</B> String => Type name
- * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
- * <LI><B>PRECISION</B> int => maximum precision
- * <LI><B>LITERAL_PREFIX</B> String => prefix used to quote a literal
- * (may be null)
- * <LI><B>LITERAL_SUFFIX</B> String => suffix used to quote a literal
- (may be null)
- * <LI><B>CREATE_PARAMS</B> String => parameters used in creating
- * the type (may be null)
- * <LI><B>NULLABLE</B> short => can you use NULL for this type?
- * <UL>
- * <LI> typeNoNulls - does not allow NULL values
- * <LI> typeNullable - allows NULL values
- * <LI> typeNullableUnknown - nullability unknown
- * </UL>
- * <LI><B>CASE_SENSITIVE</B> boolean=> is it case sensitive?
- * <LI><B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
- * <UL>
- * <LI> typePredNone - No support
- * <LI> typePredChar - Only supported with WHERE .. LIKE
- * <LI> typePredBasic - Supported except for WHERE .. LIKE
- * <LI> typeSearchable - Supported for all WHERE ..
- * </UL>
- * <LI><B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned?
- * <LI><B>FIXED_PREC_SCALE</B> boolean => can it be a money value?
- * <LI><B>AUTO_INCREMENT</B> boolean => can it be used for an
- * auto-increment value?
- * <LI><B>LOCAL_TYPE_NAME</B> String => localized version of type name
- * (may be null)
- * <LI><B>MINIMUM_SCALE</B> short => minimum scale supported
- * <LI><B>MAXIMUM_SCALE</B> short => maximum scale supported
- * <LI><B>SQL_DATA_TYPE</B> int => unused
- * <LI><B>SQL_DATETIME_SUB</B> int => unused
- * <LI><B>NUM_PREC_RADIX</B> int => usually 2 or 10
- * </OL>
- *
- * @return ResultSet each row is a SQL type description
- */
- public java.sql.ResultSet getTypeInfo() throws SQLException
- {
- java.sql.ResultSet rs = connection.ExecSQL("select typname from pg_type");
- if (rs != null)
- {
- Field f[] = new Field[18];
- ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "TYPE_NAME", iVarcharOid, 32);
- f[1] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
- f[2] = new Field(connection, "PRECISION", iInt4Oid, 4);
- f[3] = new Field(connection, "LITERAL_PREFIX", iVarcharOid, 32);
- f[4] = new Field(connection, "LITERAL_SUFFIX", iVarcharOid, 32);
- f[5] = new Field(connection, "CREATE_PARAMS", iVarcharOid, 32);
- f[6] = new Field(connection, "NULLABLE", iInt2Oid, 2);
- f[7] = new Field(connection, "CASE_SENSITIVE", iBoolOid, 1);
- f[8] = new Field(connection, "SEARCHABLE", iInt2Oid, 2);
- f[9] = new Field(connection, "UNSIGNED_ATTRIBUTE", iBoolOid, 1);
- f[10] = new Field(connection, "FIXED_PREC_SCALE", iBoolOid, 1);
- f[11] = new Field(connection, "AUTO_INCREMENT", iBoolOid, 1);
- f[12] = new Field(connection, "LOCAL_TYPE_NAME", iVarcharOid, 32);
- f[13] = new Field(connection, "MINIMUM_SCALE", iInt2Oid, 2);
- f[14] = new Field(connection, "MAXIMUM_SCALE", iInt2Oid, 2);
- f[15] = new Field(connection, "SQL_DATA_TYPE", iInt4Oid, 4);
- f[16] = new Field(connection, "SQL_DATETIME_SUB", iInt4Oid, 4);
- f[17] = new Field(connection, "NUM_PREC_RADIX", iInt4Oid, 4);
-
- // cache some results, this will keep memory useage down, and speed
- // things up a little.
- byte b9[] = "9".getBytes();
- byte b10[] = "10".getBytes();
- byte bf[] = "f".getBytes();
- byte bnn[] = Integer.toString(typeNoNulls).getBytes();
- byte bts[] = Integer.toString(typeSearchable).getBytes();
-
- while (rs.next())
- {
- byte[][] tuple = new byte[18][];
- String typname = rs.getString(1);
- tuple[0] = typname.getBytes();
- tuple[1] = Integer.toString(connection.getSQLType(typname)).getBytes();
- tuple[2] = b9; // for now
- tuple[6] = bnn; // for now
- tuple[7] = bf; // false for now - not case sensitive
- tuple[8] = bts;
- tuple[9] = bf; // false for now - it's signed
- tuple[10] = bf; // false for now - must handle money
- tuple[11] = bf; // false for now - handle autoincrement
- // 12 - LOCAL_TYPE_NAME is null
- // 13 & 14 ?
- // 15 & 16 are unused so we return null
- tuple[17] = b10; // everything is base 10
- v.addElement(tuple);
- }
- rs.close();
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
- throw new PSQLException("postgresql.metadata.unavailable");
- }
-
- /*
- * Get a description of a table's indices and statistics. They are
- * ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
- *
- * <P>Each index column description has the following columns:
- * <OL>
- * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
- * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
- * <LI><B>TABLE_NAME</B> String => table name
- * <LI><B>NON_UNIQUE</B> boolean => Can index values be non-unique?
- * false when TYPE is tableIndexStatistic
- * <LI><B>INDEX_QUALIFIER</B> String => index catalog (may be null);
- * null when TYPE is tableIndexStatistic
- * <LI><B>INDEX_NAME</B> String => index name; null when TYPE is
- * tableIndexStatistic
- * <LI><B>TYPE</B> short => index type:
- * <UL>
- * <LI> tableIndexStatistic - this identifies table statistics that are
- * returned in conjuction with a table's index descriptions
- * <LI> tableIndexClustered - this is a clustered index
- * <LI> tableIndexHashed - this is a hashed index
- * <LI> tableIndexOther - this is some other style of index
- * </UL>
- * <LI><B>ORDINAL_POSITION</B> short => column sequence number
- * within index; zero when TYPE is tableIndexStatistic
- * <LI><B>COLUMN_NAME</B> String => column name; null when TYPE is
- * tableIndexStatistic
- * <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending
- * "D" => descending, may be null if sort sequence is not supported;
- * null when TYPE is tableIndexStatistic
- * <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatisic then
- * this is the number of rows in the table; otherwise it is the
- * number of unique values in the index.
- * <LI><B>PAGES</B> int => When TYPE is tableIndexStatisic then
- * this is the number of pages used for the table, otherwise it
- * is the number of pages used for the current index.
- * <LI><B>FILTER_CONDITION</B> String => Filter condition, if any.
- * (may be null)
- * </OL>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name pattern; "" retrieves those without a schema
- * @param table a table name
- * @param unique when true, return only indices for unique values;
- * when false, return indices regardless of whether unique or not
- * @param approximate when true, result is allowed to reflect approximate
- * or out of data values; when false, results are requested to be
- * accurate
- * @return ResultSet each row is an index column description
- */
- // Implementation note: This is required for Borland's JBuilder to work
- public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tableName, boolean unique, boolean approximate) throws SQLException
- {
- Field f[] = new Field[13];
- java.sql.ResultSet r; // ResultSet for the SQL query that we need to do
- Vector v = new Vector(); // The new ResultSet tuple stuff
-
- f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
- f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
- f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
- f[3] = new Field(connection, "NON_UNIQUE", iBoolOid, 1);
- f[4] = new Field(connection, "INDEX_QUALIFIER", iVarcharOid, 32);
- f[5] = new Field(connection, "INDEX_NAME", iVarcharOid, 32);
- f[6] = new Field(connection, "TYPE", iInt2Oid, 2);
- f[7] = new Field(connection, "ORDINAL_POSITION", iInt2Oid, 2);
- f[8] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
- f[9] = new Field(connection, "ASC_OR_DESC", iVarcharOid, 32);
- f[10] = new Field(connection, "CARDINALITY", iInt4Oid, 4);
- f[11] = new Field(connection, "PAGES", iInt4Oid, 4);
- f[12] = new Field(connection, "FILTER_CONDITION", iVarcharOid, 32);
-
- r = connection.ExecSQL("select " +
- "c.relname, " +
- "x.indisunique, " +
- "i.relname, " +
- "x.indisclustered, " +
- "a.amname, " +
- "x.indkey, " +
- "c.reltuples, " +
- "c.relpages, " +
- "x.indexrelid " +
- "FROM pg_index x, pg_class c, pg_class i, pg_am a " +
- "WHERE ((c.relname = '" + tableName.toLowerCase() + "') " +
- " AND (c.oid = x.indrelid) " +
- " AND (i.oid = x.indexrelid) " +
- " AND (i.relam = a.oid)) " +
- "ORDER BY x.indisunique DESC, " +
- " x.indisclustered, a.amname, i.relname");
- while (r.next())
- {
- // indkey is an array of column ordinals (integers). In the JDBC
- // interface, this has to be separated out into a separate
- // tuple for each indexed column. Also, getArray() is not yet
- // implemented for Postgres JDBC, so we parse by hand.
- String columnOrdinalString = r.getString(6);
- StringTokenizer stok = new StringTokenizer(columnOrdinalString);
- int [] columnOrdinals = new int[stok.countTokens()];
- int o = 0;
- while (stok.hasMoreTokens())
- {
- columnOrdinals[o++] = Integer.parseInt(stok.nextToken());
- }
-
- java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE a.attrelid = " + r.getInt(9));
- for (int i = 0; i < columnOrdinals.length; i++)
- {
- byte [] [] tuple = new byte [13] [];
- tuple[0] = "".getBytes();
- tuple[1] = "".getBytes();
- tuple[2] = r.getBytes(1);
- tuple[3] = r.getBoolean(2) ? "false".getBytes() : "true".getBytes();
- tuple[4] = null;
- tuple[5] = r.getBytes(3);
- tuple[6] = r.getBoolean(4) ?
- Integer.toString(tableIndexClustered).getBytes() :
- r.getString(5).equals("hash") ?
- Integer.toString(tableIndexHashed).getBytes() :
- Integer.toString(tableIndexOther).getBytes();
- tuple[7] = Integer.toString(i + 1).getBytes();
- if (columnNameRS.next())
- tuple[8] = columnNameRS.getBytes(1);
- else
- tuple[8] = "".getBytes();
-
- tuple[9] = null; // sort sequence ???
- tuple[10] = r.getBytes(7); // inexact
- tuple[11] = r.getBytes(8);
- tuple[12] = null;
- v.addElement(tuple);
- }
- }
-
- return new ResultSet(connection, f, v, "OK", 1);
- }
-
-
- // ** JDBC 2 Extensions **
-
- /*
- * Does the database support the given result set type?
- *
- * @param type - defined in java.sql.ResultSet
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsResultSetType(int type) throws SQLException
- {
- // The only type we don't support
- return type != java.sql.ResultSet.TYPE_SCROLL_SENSITIVE;
- }
-
-
- /*
- * Does the database support the concurrency type in combination
- * with the given result set type?
- *
- * @param type - defined in java.sql.ResultSet
- * @param concurrency - type defined in java.sql.ResultSet
- * @return true if so; false otherwise
- * @exception SQLException - if a database access error occurs
- */
- public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException
- {
- // These combinations are not supported!
- if (type == java.sql.ResultSet.TYPE_SCROLL_SENSITIVE)
- return false;
-
- // We don't yet support Updateable ResultSets
- if (concurrency == java.sql.ResultSet.CONCUR_UPDATABLE)
- return false;
-
- // Everything else we do
- return true;
- }
-
-
- /* lots of unsupported stuff... */
- public boolean ownUpdatesAreVisible(int type) throws SQLException
- {
- return false;
- }
-
- public boolean ownDeletesAreVisible(int type) throws SQLException
- {
- return false;
- }
-
- public boolean ownInsertsAreVisible(int type) throws SQLException
- {
- return false;
- }
-
- public boolean othersUpdatesAreVisible(int type) throws SQLException
- {
- return false;
- }
-
- public boolean othersDeletesAreVisible(int i) throws SQLException
- {
- return false;
- }
-
- public boolean othersInsertsAreVisible(int type) throws SQLException
- {
- return false;
- }
-
- public boolean updatesAreDetected(int type) throws SQLException
- {
- return false;
- }
-
- public boolean deletesAreDetected(int i) throws SQLException
- {
- return false;
- }
-
- public boolean insertsAreDetected(int type) throws SQLException
- {
- return false;
- }
-
- /*
- * Indicates whether the driver supports batch updates.
- */
- public boolean supportsBatchUpdates() throws SQLException
- {
- return true;
- }
-
- /*
- * Return user defined types in a schema
- */
- public java.sql.ResultSet getUDTs(String catalog,
- String schemaPattern,
- String typeNamePattern,
- int[] types
- ) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
-
- /*
- * Retrieves the connection that produced this metadata object.
- *
- * @return the connection that produced this metadata object
- */
- public java.sql.Connection getConnection() throws SQLException
- {
- return (java.sql.Connection)connection;
- }
-
- /* I don't find these in the spec!?! */
-
- public boolean rowChangesAreDetected(int type) throws SQLException
- {
- return false;
- }
-
- public boolean rowChangesAreVisible(int type) throws SQLException
- {
- return false;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/PBatchUpdateException.java b/src/interfaces/jdbc/org/postgresql/jdbc2/PBatchUpdateException.java
deleted file mode 100644
index ba58702f8ce..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/PBatchUpdateException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.postgresql.jdbc2;
-
-import org.postgresql.util.*;
-import java.sql.*;
-
-/*
- * This class extends java.sql.BatchUpdateException, and provides our
- * internationalisation handling.
- */
-class PBatchUpdateException extends java.sql.BatchUpdateException
-{
-
- private String message;
-
- public PBatchUpdateException(
- String error, Object arg1, Object arg2, int[] updateCounts )
- {
-
- super(updateCounts);
-
- Object[] argv = new Object[2];
- argv[0] = arg1;
- argv[1] = arg2;
- translate(error, argv);
- }
-
- private void translate(String error, Object[] args)
- {
- message = MessageTranslator.translate(error, args);
- }
-
- // Overides Throwable
- public String getLocalizedMessage()
- {
- return message;
- }
-
- // Overides Throwable
- public String getMessage()
- {
- return message;
- }
-
- // Overides Object
- public String toString()
- {
- return message;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java b/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
deleted file mode 100644
index d0c07718bdb..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java
+++ /dev/null
@@ -1,1065 +0,0 @@
-package org.postgresql.jdbc2;
-
-// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 1 class in the
-// org.postgresql.jdbc1 package.
-
-import java.io.*;
-import java.math.*;
-import java.sql.*;
-import java.text.*;
-import java.util.*;
-import org.postgresql.largeobject.*;
-import org.postgresql.util.*;
-
-/*
- * A SQL Statement is pre-compiled and stored in a PreparedStatement object.
- * This object can then be used to efficiently execute this statement multiple
- * times.
- *
- * <p><B>Note:</B> The setXXX methods for setting IN parameter values must
- * specify types that are compatible with the defined SQL type of the input
- * parameter. For instance, if the IN parameter has SQL type Integer, then
- * setInt should be used.
- *
- * <p>If arbitrary parameter type conversions are required, then the setObject
- * method should be used with a target SQL type.
- *
- * @see ResultSet
- * @see java.sql.PreparedStatement
- */
-public class PreparedStatement extends Statement implements java.sql.PreparedStatement
-{
- String sql;
- String[] templateStrings;
- String[] inStrings;
- Connection connection;
-
- // Some performance caches
- private StringBuffer sbuf = new StringBuffer();
-
- // We use ThreadLocal for SimpleDateFormat's because they are not that
- // thread safe, so each calling thread has its own object.
- private static ThreadLocal tl_df = new ThreadLocal(); // setDate() SimpleDateFormat
- private static ThreadLocal tl_tsdf = new ThreadLocal(); // setTimestamp() SimpleDateFormat
-
- /*
- * Constructor for the PreparedStatement class.
- * Split the SQL statement into segments - separated by the arguments.
- * When we rebuild the thing with the arguments, we can substitute the
- * args and join the whole thing together.
- *
- * @param conn the instanatiating connection
- * @param sql the SQL statement with ? for IN markers
- * @exception SQLException if something bad occurs
- */
- public PreparedStatement(Connection connection, String sql) throws SQLException
- {
- super(connection);
-
- Vector v = new Vector();
- boolean inQuotes = false;
- int lastParmEnd = 0, i;
-
- this.sql = sql;
- this.connection = connection;
-
- for (i = 0; i < sql.length(); ++i)
- {
- int c = sql.charAt(i);
-
- if (c == '\'')
- inQuotes = !inQuotes;
- if (c == '?' && !inQuotes)
- {
- v.addElement(sql.substring (lastParmEnd, i));
- lastParmEnd = i + 1;
- }
- }
- v.addElement(sql.substring (lastParmEnd, sql.length()));
-
- templateStrings = new String[v.size()];
- inStrings = new String[v.size() - 1];
- clearParameters();
-
- for (i = 0 ; i < templateStrings.length; ++i)
- templateStrings[i] = (String)v.elementAt(i);
- }
-
- /*
- * A Prepared SQL query is executed and its ResultSet is returned
- *
- * @return a ResultSet that contains the data produced by the
- * * query - never null
- * @exception SQLException if a database access error occurs
- */
- public java.sql.ResultSet executeQuery() throws SQLException
- {
- return super.executeQuery(compileQuery()); // in Statement class
- }
-
- /*
- * Execute a SQL INSERT, UPDATE or DELETE statement. In addition,
- * SQL statements that return nothing such as SQL DDL statements can
- * be executed.
- *
- * @return either the row count for INSERT, UPDATE or DELETE; or
- * * 0 for SQL statements that return nothing.
- * @exception SQLException if a database access error occurs
- */
- public int executeUpdate() throws SQLException
- {
- return super.executeUpdate(compileQuery()); // in Statement class
- }
-
- /*
- * Helper - this compiles the SQL query from the various parameters
- * This is identical to toString() except it throws an exception if a
- * parameter is unused.
- */
- private synchronized String compileQuery()
- throws SQLException
- {
- sbuf.setLength(0);
- int i;
-
- for (i = 0 ; i < inStrings.length ; ++i)
- {
- if (inStrings[i] == null)
- throw new PSQLException("postgresql.prep.param", new Integer(i + 1));
- sbuf.append (templateStrings[i]).append (inStrings[i]);
- }
- sbuf.append(templateStrings[inStrings.length]);
- return sbuf.toString();
- }
-
- /*
- * Set a parameter to SQL NULL
- *
- * <p><B>Note:</B> You must specify the parameters SQL type (although
- * PostgreSQL ignores it)
- *
- * @param parameterIndex the first parameter is 1, etc...
- * @param sqlType the SQL type code defined in java.sql.Types
- * @exception SQLException if a database access error occurs
- */
- public void setNull(int parameterIndex, int sqlType) throws SQLException
- {
- set(parameterIndex, "null");
- }
-
- /*
- * Set a parameter to a Java boolean value. The driver converts this
- * to a SQL BIT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setBoolean(int parameterIndex, boolean x) throws SQLException
- {
- set(parameterIndex, x ? "'t'" : "'f'");
- }
-
- /*
- * Set a parameter to a Java byte value. The driver converts this to
- * a SQL TINYINT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setByte(int parameterIndex, byte x) throws SQLException
- {
- set(parameterIndex, Integer.toString(x));
- }
-
- /*
- * Set a parameter to a Java short value. The driver converts this
- * to a SQL SMALLINT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setShort(int parameterIndex, short x) throws SQLException
- {
- set(parameterIndex, Integer.toString(x));
- }
-
- /*
- * Set a parameter to a Java int value. The driver converts this to
- * a SQL INTEGER value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setInt(int parameterIndex, int x) throws SQLException
- {
- set(parameterIndex, Integer.toString(x));
- }
-
- /*
- * Set a parameter to a Java long value. The driver converts this to
- * a SQL BIGINT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setLong(int parameterIndex, long x) throws SQLException
- {
- set(parameterIndex, Long.toString(x));
- }
-
- /*
- * Set a parameter to a Java float value. The driver converts this
- * to a SQL FLOAT value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setFloat(int parameterIndex, float x) throws SQLException
- {
- set(parameterIndex, Float.toString(x));
- }
-
- /*
- * Set a parameter to a Java double value. The driver converts this
- * to a SQL DOUBLE value when it sends it to the database
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setDouble(int parameterIndex, double x) throws SQLException
- {
- set(parameterIndex, Double.toString(x));
- }
-
- /*
- * Set a parameter to a java.lang.BigDecimal value. The driver
- * converts this to a SQL NUMERIC value when it sends it to the
- * database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
- {
- if (x == null) {
- setNull(parameterIndex, Types.OTHER);
- } else {
- set(parameterIndex, x.toString());
- }
- }
-
- /*
- * Set a parameter to a Java String value. The driver converts this
- * to a SQL VARCHAR or LONGVARCHAR value (depending on the arguments
- * size relative to the driver's limits on VARCHARs) when it sends it
- * to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setString(int parameterIndex, String x) throws SQLException
- {
- // if the passed string is null, then set this column to null
- if (x == null)
- setNull(parameterIndex, Types.OTHER);
- else
- {
- // use the shared buffer object. Should never clash but this makes
- // us thread safe!
- synchronized (sbuf)
- {
- sbuf.setLength(0);
- int i;
-
- sbuf.append('\'');
- for (i = 0 ; i < x.length() ; ++i)
- {
- char c = x.charAt(i);
- if (c == '\\' || c == '\'')
- sbuf.append((char)'\\');
- sbuf.append(c);
- }
- sbuf.append('\'');
- set(parameterIndex, sbuf.toString());
- }
- }
- }
-
- /*
- * Set a parameter to a Java array of bytes. The driver converts this
- * to a SQL VARBINARY or LONGVARBINARY (depending on the argument's
- * size relative to the driver's limits on VARBINARYs) when it sends
- * it to the database.
- *
- * <p>Implementation note:
- * <br>With org.postgresql, this creates a large object, and stores the
- * objects oid in this column.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setBytes(int parameterIndex, byte x[]) throws SQLException
- {
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports the bytea datatype for byte arrays
- if (null == x)
- {
- setNull(parameterIndex, Types.OTHER);
- }
- else
- {
- setString(parameterIndex, PGbytea.toPGString(x));
- }
- }
- else
- {
- //Version 7.1 and earlier support done as LargeObjects
- LargeObjectManager lom = connection.getLargeObjectAPI();
- int oid = lom.create();
- LargeObject lob = lom.open(oid);
- lob.write(x);
- lob.close();
- setInt(parameterIndex, oid);
- }
- }
-
- /*
- * Set a parameter to a java.sql.Date value. The driver converts this
- * to a SQL DATE value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setDate(int parameterIndex, java.sql.Date x) throws SQLException
- {
- if (null == x)
- {
- setNull(parameterIndex, Types.OTHER);
- }
- else
- {
- SimpleDateFormat df = (SimpleDateFormat) tl_df.get();
- if (df == null)
- {
- df = new SimpleDateFormat("''yyyy-MM-dd''");
- tl_df.set(df);
- }
- set(parameterIndex, df.format(x));
- }
- // The above is how the date should be handled.
- //
- // However, in JDK's prior to 1.1.6 (confirmed with the
- // Linux jdk1.1.3 and the Win95 JRE1.1.5), SimpleDateFormat seems
- // to format a date to the previous day. So the fix is to add a day
- // before formatting.
- //
- // PS: 86400000 is one day
- //
- //set(parameterIndex, df.format(new java.util.Date(x.getTime()+86400000)));
- }
-
- /*
- * Set a parameter to a java.sql.Time value. The driver converts
- * this to a SQL TIME value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...));
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setTime(int parameterIndex, Time x) throws SQLException
- {
- if (null == x)
- {
- setNull(parameterIndex, Types.OTHER);
- }
- else
- {
- set(parameterIndex, "'" + x.toString() + "'");
- }
- }
-
- /*
- * Set a parameter to a java.sql.Timestamp value. The driver converts
- * this to a SQL TIMESTAMP value when it sends it to the database.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
- {
- if (null == x)
- {
- setNull(parameterIndex, Types.OTHER);
- }
- else
- {
- SimpleDateFormat df = (SimpleDateFormat) tl_tsdf.get();
- if (df == null)
- {
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- df.setTimeZone(TimeZone.getTimeZone("GMT"));
- tl_tsdf.set(df);
- }
-
- // Make decimal from nanos.
- StringBuffer decimal = new StringBuffer("000000000"); // max nanos length
- String nanos = String.valueOf(x.getNanos());
- decimal.setLength(decimal.length() - nanos.length());
- decimal.append(nanos);
- if (! connection.haveMinimumServerVersion("7.2")) {
- // Because 7.1 include bug that "hh:mm:59.999" becomes "hh:mm:60.00".
- decimal.setLength(2);
- }
-
- // Use the shared StringBuffer
- synchronized (sbuf)
- {
- sbuf.setLength(0);
- sbuf.append("'").append(df.format(x)).append('.').append(decimal).append("+00'");
- set(parameterIndex, sbuf.toString());
- }
-
- // The above works, but so does the following. I'm leaving the above in, but this seems
- // to be identical. Pays to read the docs ;-)
- //set(parameterIndex,"'"+x.toString()+"'");
- }
- }
-
- /*
- * When a very large ASCII value is input to a LONGVARCHAR parameter,
- * it may be more practical to send it via a java.io.InputStream.
- * JDBC will read the data from the stream as needed, until it reaches
- * end-of-file. The JDBC driver will do any necessary conversion from
- * ASCII to the database char format.
- *
- * <P><B>Note:</B> This stream object can either be a standard Java
- * stream object or your own subclass that implements the standard
- * interface.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @param length the number of bytes in the stream
- * @exception SQLException if a database access error occurs
- */
- public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports AsciiStream for all PG text types (char, varchar, text)
- //As the spec/javadoc for this method indicate this is to be used for
- //large String values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long varchar datatype, but with toast all text datatypes are capable of
- //handling very large values. Thus the implementation ends up calling
- //setString() since there is no current way to stream the value to the server
- try
- {
- InputStreamReader l_inStream = new InputStreamReader(x, "ASCII");
- char[] l_chars = new char[length];
- int l_charsRead = l_inStream.read(l_chars, 0, length);
- setString(parameterIndex, new String(l_chars, 0, l_charsRead));
- }
- catch (UnsupportedEncodingException l_uee)
- {
- throw new PSQLException("postgresql.unusual", l_uee);
- }
- catch (IOException l_ioe)
- {
- throw new PSQLException("postgresql.unusual", l_ioe);
- }
- }
- else
- {
- //Version 7.1 supported only LargeObjects by treating everything
- //as binary data
- setBinaryStream(parameterIndex, x, length);
- }
- }
-
- /*
- * When a very large Unicode value is input to a LONGVARCHAR parameter,
- * it may be more practical to send it via a java.io.InputStream.
- * JDBC will read the data from the stream as needed, until it reaches
- * end-of-file. The JDBC driver will do any necessary conversion from
- * UNICODE to the database char format.
- *
- * ** DEPRECIATED IN JDBC 2 **
- *
- * <P><B>Note:</B> This stream object can either be a standard Java
- * stream object or your own subclass that implements the standard
- * interface.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- * @deprecated
- */
- public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports AsciiStream for all PG text types (char, varchar, text)
- //As the spec/javadoc for this method indicate this is to be used for
- //large String values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long varchar datatype, but with toast all text datatypes are capable of
- //handling very large values. Thus the implementation ends up calling
- //setString() since there is no current way to stream the value to the server
- try
- {
- InputStreamReader l_inStream = new InputStreamReader(x, "UTF-8");
- char[] l_chars = new char[length];
- int l_charsRead = l_inStream.read(l_chars, 0, length);
- setString(parameterIndex, new String(l_chars, 0, l_charsRead));
- }
- catch (UnsupportedEncodingException l_uee)
- {
- throw new PSQLException("postgresql.unusual", l_uee);
- }
- catch (IOException l_ioe)
- {
- throw new PSQLException("postgresql.unusual", l_ioe);
- }
- }
- else
- {
- //Version 7.1 supported only LargeObjects by treating everything
- //as binary data
- setBinaryStream(parameterIndex, x, length);
- }
- }
-
- /*
- * When a very large binary value is input to a LONGVARBINARY parameter,
- * it may be more practical to send it via a java.io.InputStream.
- * JDBC will read the data from the stream as needed, until it reaches
- * end-of-file.
- *
- * <P><B>Note:</B> This stream object can either be a standard Java
- * stream object or your own subclass that implements the standard
- * interface.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the parameter value
- * @exception SQLException if a database access error occurs
- */
- public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
- {
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports BinaryStream for for the PG bytea type
- //As the spec/javadoc for this method indicate this is to be used for
- //large binary values (i.e. LONGVARBINARY) PG doesn't have a separate
- //long binary datatype, but with toast the bytea datatype is capable of
- //handling very large values. Thus the implementation ends up calling
- //setBytes() since there is no current way to stream the value to the server
- byte[] l_bytes = new byte[length];
- int l_bytesRead;
- try
- {
- l_bytesRead = x.read(l_bytes, 0, length);
- }
- catch (IOException l_ioe)
- {
- throw new PSQLException("postgresql.unusual", l_ioe);
- }
- if (l_bytesRead == length)
- {
- setBytes(parameterIndex, l_bytes);
- }
- else
- {
- //the stream contained less data than they said
- byte[] l_bytes2 = new byte[l_bytesRead];
- System.arraycopy(l_bytes, 0, l_bytes2, 0, l_bytesRead);
- setBytes(parameterIndex, l_bytes2);
- }
- }
- else
- {
- //Version 7.1 only supported streams for LargeObjects
- //but the jdbc spec indicates that streams should be
- //available for LONGVARBINARY instead
- LargeObjectManager lom = connection.getLargeObjectAPI();
- int oid = lom.create();
- LargeObject lob = lom.open(oid);
- OutputStream los = lob.getOutputStream();
- try
- {
- // could be buffered, but then the OutputStream returned by LargeObject
- // is buffered internally anyhow, so there would be no performance
- // boost gained, if anything it would be worse!
- int c = x.read();
- int p = 0;
- while (c > -1 && p < length)
- {
- los.write(c);
- c = x.read();
- p++;
- }
- los.close();
- }
- catch (IOException se)
- {
- throw new PSQLException("postgresql.unusual", se);
- }
- // lob is closed by the stream so don't call lob.close()
- setInt(parameterIndex, oid);
- }
- }
-
- /*
- * In general, parameter values remain in force for repeated used of a
- * Statement. Setting a parameter value automatically clears its
- * previous value. However, in coms cases, it is useful to immediately
- * release the resources used by the current parameter values; this
- * can be done by calling clearParameters
- *
- * @exception SQLException if a database access error occurs
- */
- public void clearParameters() throws SQLException
- {
- int i;
-
- for (i = 0 ; i < inStrings.length ; i++)
- inStrings[i] = null;
- }
-
- /*
- * Set the value of a parameter using an object; use the java.lang
- * equivalent objects for integral values.
- *
- * <P>The given Java object will be converted to the targetSqlType before
- * being sent to the database.
- *
- * <P>note that this method may be used to pass database-specific
- * abstract data types. This is done by using a Driver-specific
- * Java type and using a targetSqlType of java.sql.Types.OTHER
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the object containing the input parameter value
- * @param targetSqlType The SQL type to be send to the database
- * @param scale For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC
- * types this is the number of digits after the decimal. For
- * all other types this value will be ignored.
- * @exception SQLException if a database access error occurs
- */
- public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
- {
- if (x == null)
- {
- setNull(parameterIndex, Types.OTHER);
- return;
- }
- switch (targetSqlType)
- {
- case Types.TINYINT:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.REAL:
- case Types.FLOAT:
- case Types.DOUBLE:
- case Types.DECIMAL:
- case Types.NUMERIC:
- if (x instanceof Boolean)
- set(parameterIndex, ((Boolean)x).booleanValue() ? "1" : "0");
- else
- set(parameterIndex, x.toString());
- break;
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- setString(parameterIndex, x.toString());
- break;
- case Types.DATE:
- setDate(parameterIndex, (java.sql.Date)x);
- break;
- case Types.TIME:
- setTime(parameterIndex, (Time)x);
- break;
- case Types.TIMESTAMP:
- setTimestamp(parameterIndex, (Timestamp)x);
- break;
- case Types.BIT:
- if (x instanceof Boolean)
- {
- set(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE");
- }
- else
- {
- throw new PSQLException("postgresql.prep.type");
- }
- break;
- case Types.BINARY:
- case Types.VARBINARY:
- setObject(parameterIndex, x);
- break;
- case Types.OTHER:
- setString(parameterIndex, ((PGobject)x).getValue());
- break;
- default:
- throw new PSQLException("postgresql.prep.type");
- }
- }
-
- public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
- {
- setObject(parameterIndex, x, targetSqlType, 0);
- }
-
- /*
- * This stores an Object into a parameter.
- * <p>New for 6.4, if the object is not recognised, but it is
- * Serializable, then the object is serialised using the
- * org.postgresql.util.Serialize class.
- */
- public void setObject(int parameterIndex, Object x) throws SQLException
- {
- if (x == null)
- {
- setNull(parameterIndex, Types.OTHER);
- return;
- }
- if (x instanceof String)
- setString(parameterIndex, (String)x);
- else if (x instanceof BigDecimal)
- setBigDecimal(parameterIndex, (BigDecimal)x);
- else if (x instanceof Short)
- setShort(parameterIndex, ((Short)x).shortValue());
- else if (x instanceof Integer)
- setInt(parameterIndex, ((Integer)x).intValue());
- else if (x instanceof Long)
- setLong(parameterIndex, ((Long)x).longValue());
- else if (x instanceof Float)
- setFloat(parameterIndex, ((Float)x).floatValue());
- else if (x instanceof Double)
- setDouble(parameterIndex, ((Double)x).doubleValue());
- else if (x instanceof byte[])
- setBytes(parameterIndex, (byte[])x);
- else if (x instanceof java.sql.Date)
- setDate(parameterIndex, (java.sql.Date)x);
- else if (x instanceof Time)
- setTime(parameterIndex, (Time)x);
- else if (x instanceof Timestamp)
- setTimestamp(parameterIndex, (Timestamp)x);
- else if (x instanceof Boolean)
- setBoolean(parameterIndex, ((Boolean)x).booleanValue());
- else if (x instanceof PGobject)
- setString(parameterIndex, ((PGobject)x).getValue());
- else
- // Try to store java object in database
- setSerialize(parameterIndex, connection.storeObject(x), x.getClass().getName() );
- }
-
- /*
- * Some prepared statements return multiple results; the execute method
- * handles these complex statements as well as the simpler form of
- * statements handled by executeQuery and executeUpdate
- *
- * @return true if the next result is a ResultSet; false if it is an
- * update count or there are no more results
- * @exception SQLException if a database access error occurs
- */
- public boolean execute() throws SQLException
- {
- return super.execute(compileQuery()); // in Statement class
- }
-
- /*
- * Returns the SQL statement with the current template values
- * substituted.
- * NB: This is identical to compileQuery() except instead of throwing
- * SQLException if a parameter is null, it places ? instead.
- */
- public String toString()
- {
- synchronized (sbuf)
- {
- sbuf.setLength(0);
- int i;
-
- for (i = 0 ; i < inStrings.length ; ++i)
- {
- if (inStrings[i] == null)
- sbuf.append( '?' );
- else
- sbuf.append (templateStrings[i]);
- sbuf.append (inStrings[i]);
- }
- sbuf.append(templateStrings[inStrings.length]);
- return sbuf.toString();
- }
- }
-
- // **************************************************************
- // END OF PUBLIC INTERFACE
- // **************************************************************
-
- /*
- * There are a lot of setXXX classes which all basically do
- * the same thing. We need a method which actually does the
- * set for us.
- *
- * @param paramIndex the index into the inString
- * @param s a string to be stored
- * @exception SQLException if something goes wrong
- */
- private void set(int paramIndex, String s) throws SQLException
- {
- if (paramIndex < 1 || paramIndex > inStrings.length)
- throw new PSQLException("postgresql.prep.range");
- inStrings[paramIndex - 1] = s;
- }
-
- /*
- * Set a parameter to a tablerow-type oid reference.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the oid of the object from org.postgresql.util.Serialize.store
- * @param classname the classname of the java object x
- * @exception SQLException if a database access error occurs
- */
- private void setSerialize(int parameterIndex, long x, String classname) throws SQLException
- {
- // converts . to _, toLowerCase, and ensures length<32
- String tablename = Serialize.toPostgreSQL( classname );
- DriverManager.println("setSerialize: setting " + x + "::" + tablename );
-
- // OID reference to tablerow-type must be cast like: <oid>::<tablename>
- // Note that postgres support for tablerow data types is incomplete/broken.
- // This cannot be just a plain OID because then there would be ambiguity
- // between when you want the oid itself and when you want the object
- // an oid references.
- set(parameterIndex, Long.toString(x) + "::" + tablename );
- }
-
-
- // ** JDBC 2 Extensions **
-
- /*
- * This parses the query and adds it to the current batch
- */
- public void addBatch() throws SQLException
- {
- super.addBatch(compileQuery());
- }
-
- /*
- * Not sure what this one does, so I'm saying this returns the MetaData for
- * the last ResultSet returned!
- */
- public java.sql.ResultSetMetaData getMetaData() throws SQLException
- {
- java.sql.ResultSet rs = getResultSet();
- if (rs != null)
- return rs.getMetaData();
-
- // Does anyone really know what this method does?
- return null;
- }
-
- public void setArray(int i, java.sql.Array x) throws SQLException
- {
- setString(i, x.toString());
- }
-
- /*
- * Sets a Blob
- */
- public void setBlob(int i, Blob x) throws SQLException
- {
- InputStream l_inStream = x.getBinaryStream();
- int l_length = (int) x.length();
- LargeObjectManager lom = connection.getLargeObjectAPI();
- int oid = lom.create();
- LargeObject lob = lom.open(oid);
- OutputStream los = lob.getOutputStream();
- try
- {
- // could be buffered, but then the OutputStream returned by LargeObject
- // is buffered internally anyhow, so there would be no performance
- // boost gained, if anything it would be worse!
- int c = l_inStream.read();
- int p = 0;
- while (c > -1 && p < l_length)
- {
- los.write(c);
- c = l_inStream.read();
- p++;
- }
- los.close();
- }
- catch (IOException se)
- {
- throw new PSQLException("postgresql.unusual", se);
- }
- // lob is closed by the stream so don't call lob.close()
- setInt(i, oid);
- }
-
- /*
- * This is similar to setBinaryStream except it uses a Reader instead of
- * InputStream.
- */
- public void setCharacterStream(int i, java.io.Reader x, int length) throws SQLException
- {
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports CharacterStream for for the PG text types
- //As the spec/javadoc for this method indicate this is to be used for
- //large text values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long varchar datatype, but with toast all the text datatypes are capable of
- //handling very large values. Thus the implementation ends up calling
- //setString() since there is no current way to stream the value to the server
- char[] l_chars = new char[length];
- int l_charsRead;
- try
- {
- l_charsRead = x.read(l_chars, 0, length);
- }
- catch (IOException l_ioe)
- {
- throw new PSQLException("postgresql.unusual", l_ioe);
- }
- setString(i, new String(l_chars, 0, l_charsRead));
- }
- else
- {
- //Version 7.1 only supported streams for LargeObjects
- //but the jdbc spec indicates that streams should be
- //available for LONGVARCHAR instead
- LargeObjectManager lom = connection.getLargeObjectAPI();
- int oid = lom.create();
- LargeObject lob = lom.open(oid);
- OutputStream los = lob.getOutputStream();
- try
- {
- // could be buffered, but then the OutputStream returned by LargeObject
- // is buffered internally anyhow, so there would be no performance
- // boost gained, if anything it would be worse!
- int c = x.read();
- int p = 0;
- while (c > -1 && p < length)
- {
- los.write(c);
- c = x.read();
- p++;
- }
- los.close();
- }
- catch (IOException se)
- {
- throw new PSQLException("postgresql.unusual", se);
- }
- // lob is closed by the stream so don't call lob.close()
- setInt(i, oid);
- }
- }
-
- /*
- * New in 7.1
- */
- public void setClob(int i, Clob x) throws SQLException
- {
- InputStream l_inStream = x.getAsciiStream();
- int l_length = (int) x.length();
- LargeObjectManager lom = connection.getLargeObjectAPI();
- int oid = lom.create();
- LargeObject lob = lom.open(oid);
- OutputStream los = lob.getOutputStream();
- try
- {
- // could be buffered, but then the OutputStream returned by LargeObject
- // is buffered internally anyhow, so there would be no performance
- // boost gained, if anything it would be worse!
- int c = l_inStream.read();
- int p = 0;
- while (c > -1 && p < l_length)
- {
- los.write(c);
- c = l_inStream.read();
- p++;
- }
- los.close();
- }
- catch (IOException se)
- {
- throw new PSQLException("postgresql.unusual", se);
- }
- // lob is closed by the stream so don't call lob.close()
- setInt(i, oid);
- }
-
- /*
- * At least this works as in PostgreSQL null represents anything null ;-)
- *
- * New in 7,1
- */
- public void setNull(int i, int t, String s) throws SQLException
- {
- setNull(i, t);
- }
-
- public void setRef(int i, Ref x) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /*
- * New in 7,1
- */
- public void setDate(int i, java.sql.Date d, java.util.Calendar cal) throws SQLException
- {
- if (cal == null)
- setDate(i, d);
- else
- {
- cal.setTime(d);
- setDate(i, new java.sql.Date(cal.getTime().getTime()));
- }
- }
-
- /*
- * New in 7,1
- */
- public void setTime(int i, Time t, java.util.Calendar cal) throws SQLException
- {
- if (cal == null)
- setTime(i, t);
- else
- {
- cal.setTime(t);
- setTime(i, new java.sql.Time(cal.getTime().getTime()));
- }
- }
-
- /*
- * New in 7,1
- */
- public void setTimestamp(int i, Timestamp t, java.util.Calendar cal) throws SQLException
- {
- if (cal == null)
- setTimestamp(i, t);
- else
- {
- cal.setTime(t);
- setTimestamp(i, new java.sql.Timestamp(cal.getTime().getTime()));
- }
- }
-
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
deleted file mode 100644
index ce6daf69a90..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
+++ /dev/null
@@ -1,1777 +0,0 @@
-package org.postgresql.jdbc2;
-
-// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 1 class in the
-// org.postgresql.jdbc1 package.
-
-import java.lang.*;
-import java.io.*;
-import java.math.*;
-import java.text.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.Field;
-import org.postgresql.largeobject.*;
-import org.postgresql.util.*;
-import org.postgresql.core.Encoding;
-
-/*
- * A ResultSet provides access to a table of data generated by executing a
- * Statement. The table rows are retrieved in sequence. Within a row its
- * column values can be accessed in any order.
- *
- * <P>A ResultSet maintains a cursor pointing to its current row of data.
- * Initially the cursor is positioned before the first row. The 'next'
- * method moves the cursor to the next row.
- *
- * <P>The getXXX methods retrieve column values for the current row. You can
- * retrieve values either using the index number of the column, or by using
- * the name of the column. In general using the column index will be more
- * efficient. Columns are numbered from 1.
- *
- * <P>For maximum portability, ResultSet columns within each row should be read
- * in left-to-right order and each column should be read only once.
- *
- *<P> For the getXXX methods, the JDBC driver attempts to convert the
- * underlying data to the specified Java type and returns a suitable Java
- * value. See the JDBC specification for allowable mappings from SQL types
- * to Java types with the ResultSet getXXX methods.
- *
- * <P>Column names used as input to getXXX methods are case insenstive. When
- * performing a getXXX using a column name, if several columns have the same
- * name, then the value of the first matching column will be returned. The
- * column name option is designed to be used when column names are used in the
- * SQL Query. For columns that are NOT explicitly named in the query, it is
- * best to use column numbers. If column names were used there is no way for
- * the programmer to guarentee that they actually refer to the intended
- * columns.
- *
- * <P>A ResultSet is automatically closed by the Statement that generated it
- * when that Statement is closed, re-executed, or is used to retrieve the
- * next result from a sequence of multiple results.
- *
- * <P>The number, types and properties of a ResultSet's columns are provided by
- * the ResultSetMetaData object returned by the getMetaData method.
- *
- * @see ResultSetMetaData
- * @see java.sql.ResultSet
- */
-public class ResultSet extends org.postgresql.ResultSet implements java.sql.ResultSet
-{
- protected org.postgresql.jdbc2.Statement statement;
-
- private StringBuffer sbuf = null;
- protected byte[][] rowBuffer=null;
- protected String sqlQuery=null;
-
- /*
- * Create a new ResultSet - Note that we create ResultSets to
- * represent the results of everything.
- *
- * @param fields an array of Field objects (basically, the
- * ResultSet MetaData)
- * @param tuples Vector of the actual data
- * @param status the status string returned from the back end
- * @param updateCount the number of rows affected by the operation
- * @param cursor the positioned update/delete cursor name
- */
- public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
- {
- super(conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
- }
-
- /*
- * Create a new ResultSet - Note that we create ResultSets to
- * represent the results of everything.
- *
- * @param fields an array of Field objects (basically, the
- * ResultSet MetaData)
- * @param tuples Vector of the actual data
- * @param status the status string returned from the back end
- * @param updateCount the number of rows affected by the operation
- * @param cursor the positioned update/delete cursor name
- */
- public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
- {
- super(conn, fields, tuples, status, updateCount, 0, false);
- }
-
- /*
- * A ResultSet is initially positioned before its first row,
- * the first call to next makes the first row the current row;
- * the second call makes the second row the current row, etc.
- *
- * <p>If an input stream from the previous row is open, it is
- * implicitly closed. The ResultSet's warning chain is cleared
- * when a new row is read
- *
- * @return true if the new current is valid; false if there are no
- * more rows
- * @exception SQLException if a database access error occurs
- */
- public boolean next() throws SQLException
- {
- if (rows == null)
- throw new PSQLException("postgresql.con.closed");
-
-
- if (++current_row >= rows.size())
- return false;
-
- this_row = (byte [][])rows.elementAt(current_row);
-
- rowBuffer=new byte[this_row.length][];
- System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
- return true;
- }
-
- /*
- * In some cases, it is desirable to immediately release a ResultSet
- * database and JDBC resources instead of waiting for this to happen
- * when it is automatically closed. The close method provides this
- * immediate release.
- *
- * <p><B>Note:</B> A ResultSet is automatically closed by the Statement
- * the Statement that generated it when that Statement is closed,
- * re-executed, or is used to retrieve the next result from a sequence
- * of multiple results. A ResultSet is also automatically closed
- * when it is garbage collected.
- *
- * @exception SQLException if a database access error occurs
- */
- public void close() throws SQLException
- {
- //release resources held (memory for tuples)
- if (rows != null)
- {
- rows = null;
- }
- }
-
- /*
- * A column may have the value of SQL NULL; wasNull() reports whether
- * the last column read had this special value. Note that you must
- * first call getXXX on a column to try to read its value and then
- * call wasNull() to find if the value was SQL NULL
- *
- * @return true if the last column read was SQL NULL
- * @exception SQLException if a database access error occurred
- */
- public boolean wasNull() throws SQLException
- {
- return wasNullFlag;
- }
-
- /*
- * Get the value of a column in the current row as a Java String
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value, null for SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public String getString(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (wasNullFlag)
- return null;
-
- Encoding encoding = connection.getEncoding();
- return encoding.decode(this_row[columnIndex - 1]);
- }
-
- /*
- * Get the value of a column in the current row as a Java boolean
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value, false for SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public boolean getBoolean(int columnIndex) throws SQLException
- {
- return toBoolean( getString(columnIndex) );
- }
-
- /*
- * Get the value of a column in the current row as a Java byte.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public byte getByte(int columnIndex) throws SQLException
- {
- String s = getString(columnIndex);
-
- if (s != null)
- {
- try
- {
- return Byte.parseByte(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.res.badbyte", s);
- }
- }
- return 0; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a Java short.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public short getShort(int columnIndex) throws SQLException
- {
- String s = getFixedString(columnIndex);
-
- if (s != null)
- {
- try
- {
- return Short.parseShort(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.res.badshort", s);
- }
- }
- return 0; // SQL NULL
- }
-
- /*
- * Get the value of a column in the current row as a Java int.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public int getInt(int columnIndex) throws SQLException
- {
- return toInt( getFixedString(columnIndex) );
- }
-
- /*
- * Get the value of a column in the current row as a Java long.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public long getLong(int columnIndex) throws SQLException
- {
- return toLong( getFixedString(columnIndex) );
- }
-
- /*
- * Get the value of a column in the current row as a Java float.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public float getFloat(int columnIndex) throws SQLException
- {
- return toFloat( getFixedString(columnIndex) );
- }
-
- /*
- * Get the value of a column in the current row as a Java double.
- *
- * @param columnIndex the first column is 1, the second is 2,...
- * @return the column value; 0 if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public double getDouble(int columnIndex) throws SQLException
- {
- return toDouble( getFixedString(columnIndex) );
- }
-
- /*
- * Get the value of a column in the current row as a
- * java.math.BigDecimal object
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @param scale the number of digits to the right of the decimal
- * @return the column value; if the value is SQL NULL, null
- * @exception SQLException if a database access error occurs
- * @deprecated
- */
- public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException
- {
- return toBigDecimal( getFixedString(columnIndex), scale );
- }
-
- /*
- * Get the value of a column in the current row as a Java byte array.
- *
- * <p>In normal use, the bytes represent the raw values returned by the
- * backend. However, if the column is an OID, then it is assumed to
- * refer to a Large Object, and that object is returned as a byte array.
- *
- * <p><b>Be warned</b> If the large object is huge, then you may run out
- * of memory.
- *
- * @param columnIndex the first column is 1, the second is 2, ...
- * @return the column value; if the value is SQL NULL, the result
- * is null
- * @exception SQLException if a database access error occurs
- */
- public byte[] getBytes(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (!wasNullFlag)
- {
- if (binaryCursor)
- {
- //If the data is already binary then just return it
- return this_row[columnIndex - 1];
- }
- else if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports the bytea datatype for byte arrays
- if (fields[columnIndex - 1].getPGType().equals("bytea"))
- {
- return PGbytea.toBytes(this_row[columnIndex - 1]);
- }
- else
- {
- return this_row[columnIndex - 1];
- }
- }
- else
- {
- //Version 7.1 and earlier supports LargeObjects for byte arrays
- // Handle OID's as BLOBS
- if ( fields[columnIndex - 1].getOID() == 26)
- {
- LargeObjectManager lom = connection.getLargeObjectAPI();
- LargeObject lob = lom.open(getInt(columnIndex));
- byte buf[] = lob.read(lob.size());
- lob.close();
- return buf;
- }
- else
- {
- return this_row[columnIndex - 1];
- }
- }
- }
- return null;
- }
-
- /*
- * Get the value of a column in the current row as a java.sql.Date
- * object
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value; null if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public java.sql.Date getDate(int columnIndex) throws SQLException
- {
- return toDate( getString(columnIndex) );
- }
-
- /*
- * Get the value of a column in the current row as a java.sql.Time
- * object
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value; null if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public Time getTime(int columnIndex) throws SQLException
- {
- return toTime( getString(columnIndex) );
- }
-
- /*
- * Get the value of a column in the current row as a
- * java.sql.Timestamp object
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the column value; null if SQL NULL
- * @exception SQLException if a database access error occurs
- */
- public Timestamp getTimestamp(int columnIndex) throws SQLException
- {
- return toTimestamp( getString(columnIndex), this );
- }
-
- /*
- * A column value can be retrieved as a stream of ASCII characters
- * and then read in chunks from the stream. This method is
- * particular suitable for retrieving large LONGVARCHAR values.
- * The JDBC driver will do any necessary conversion from the
- * database format into ASCII.
- *
- * <p><B>Note:</B> All the data in the returned stream must be read
- * prior to getting the value of any other column. The next call
- * to a get method implicitly closes the stream. Also, a stream
- * may return 0 for available() whether there is data available
- * or not.
- *
- *<p> We implement an ASCII stream as a Binary stream - we should really
- * do the data conversion, but I cannot be bothered to implement this
- * right now.
- *
- * @param columnIndex the first column is 1, the second is 2, ...
- * @return a Java InputStream that delivers the database column
- * value as a stream of one byte ASCII characters. If the
- * value is SQL NULL then the result is null
- * @exception SQLException if a database access error occurs
- * @see getBinaryStream
- */
- public InputStream getAsciiStream(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (wasNullFlag)
- return null;
-
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports AsciiStream for all the PG text types
- //As the spec/javadoc for this method indicate this is to be used for
- //large text values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long string datatype, but with toast the text datatype is capable of
- //handling very large values. Thus the implementation ends up calling
- //getString() since there is no current way to stream the value from the server
- try
- {
- return new ByteArrayInputStream(getString(columnIndex).getBytes("ASCII"));
- }
- catch (UnsupportedEncodingException l_uee)
- {
- throw new PSQLException("postgresql.unusual", l_uee);
- }
- }
- else
- {
- // In 7.1 Handle as BLOBS so return the LargeObject input stream
- return getBinaryStream(columnIndex);
- }
- }
-
- /*
- * A column value can also be retrieved as a stream of Unicode
- * characters. We implement this as a binary stream.
- *
- * ** DEPRECATED IN JDBC 2 **
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return a Java InputStream that delivers the database column value
- * as a stream of two byte Unicode characters. If the value is
- * SQL NULL, then the result is null
- * @exception SQLException if a database access error occurs
- * @see getAsciiStream
- * @see getBinaryStream
- * @deprecated in JDBC2.0
- */
- public InputStream getUnicodeStream(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (wasNullFlag)
- return null;
-
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports AsciiStream for all the PG text types
- //As the spec/javadoc for this method indicate this is to be used for
- //large text values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long string datatype, but with toast the text datatype is capable of
- //handling very large values. Thus the implementation ends up calling
- //getString() since there is no current way to stream the value from the server
- try
- {
- return new ByteArrayInputStream(getString(columnIndex).getBytes("UTF-8"));
- }
- catch (UnsupportedEncodingException l_uee)
- {
- throw new PSQLException("postgresql.unusual", l_uee);
- }
- }
- else
- {
- // In 7.1 Handle as BLOBS so return the LargeObject input stream
- return getBinaryStream(columnIndex);
- }
- }
-
- /*
- * A column value can also be retrieved as a binary strea. This
- * method is suitable for retrieving LONGVARBINARY values.
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return a Java InputStream that delivers the database column value
- * as a stream of bytes. If the value is SQL NULL, then the result
- * is null
- * @exception SQLException if a database access error occurs
- * @see getAsciiStream
- * @see getUnicodeStream
- */
- public InputStream getBinaryStream(int columnIndex) throws SQLException
- {
- checkResultSet( columnIndex );
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (wasNullFlag)
- return null;
-
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports BinaryStream for all PG bytea type
- //As the spec/javadoc for this method indicate this is to be used for
- //large binary values (i.e. LONGVARBINARY) PG doesn't have a separate
- //long binary datatype, but with toast the bytea datatype is capable of
- //handling very large values. Thus the implementation ends up calling
- //getBytes() since there is no current way to stream the value from the server
- byte b[] = getBytes(columnIndex);
- if (b != null)
- return new ByteArrayInputStream(b);
- }
- else
- {
- // In 7.1 Handle as BLOBS so return the LargeObject input stream
- if ( fields[columnIndex - 1].getOID() == 26)
- {
- LargeObjectManager lom = connection.getLargeObjectAPI();
- LargeObject lob = lom.open(getInt(columnIndex));
- return lob.getInputStream();
- }
- }
- return null;
- }
-
- /*
- * The following routines simply convert the columnName into
- * a columnIndex and then call the appropriate routine above.
- *
- * @param columnName is the SQL name of the column
- * @return the column value
- * @exception SQLException if a database access error occurs
- */
- public String getString(String columnName) throws SQLException
- {
- return getString(findColumn(columnName));
- }
-
- public boolean getBoolean(String columnName) throws SQLException
- {
- return getBoolean(findColumn(columnName));
- }
-
- public byte getByte(String columnName) throws SQLException
- {
-
- return getByte(findColumn(columnName));
- }
-
- public short getShort(String columnName) throws SQLException
- {
- return getShort(findColumn(columnName));
- }
-
- public int getInt(String columnName) throws SQLException
- {
- return getInt(findColumn(columnName));
- }
-
- public long getLong(String columnName) throws SQLException
- {
- return getLong(findColumn(columnName));
- }
-
- public float getFloat(String columnName) throws SQLException
- {
- return getFloat(findColumn(columnName));
- }
-
- public double getDouble(String columnName) throws SQLException
- {
- return getDouble(findColumn(columnName));
- }
-
- /*
- * @deprecated
- */
- public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException
- {
- return getBigDecimal(findColumn(columnName), scale);
- }
-
- public byte[] getBytes(String columnName) throws SQLException
- {
- return getBytes(findColumn(columnName));
- }
-
- public java.sql.Date getDate(String columnName) throws SQLException
- {
- return getDate(findColumn(columnName));
- }
-
- public Time getTime(String columnName) throws SQLException
- {
- return getTime(findColumn(columnName));
- }
-
- public Timestamp getTimestamp(String columnName) throws SQLException
- {
- return getTimestamp(findColumn(columnName));
- }
-
- public InputStream getAsciiStream(String columnName) throws SQLException
- {
- return getAsciiStream(findColumn(columnName));
- }
-
- /*
- *
- * ** DEPRECATED IN JDBC 2 **
- *
- * @deprecated
- */
- public InputStream getUnicodeStream(String columnName) throws SQLException
- {
- return getUnicodeStream(findColumn(columnName));
- }
-
- public InputStream getBinaryStream(String columnName) throws SQLException
- {
- return getBinaryStream(findColumn(columnName));
- }
-
- public java.net.URL getURL(int columnIndex) throws SQLException
- {
- return null;
- }
-
- public java.net.URL getURL(String columnName) throws SQLException
- {
- return null;
-
- }
-
- public void updateRef(int colIndex,java.sql.Ref ref) throws SQLException {
-
- }
- public void updateRef(String colName,java.sql.Ref ref) throws SQLException {
- }
- public void updateBlob(int colIndex,java.sql.Blob blob) throws SQLException {
- }
- public void updateBlob(String colName,java.sql.Blob blob) throws SQLException {
- }
- public void updateClob(int colIndex,java.sql.Clob clob) throws SQLException {
- }
- public void updateClob(String colName,java.sql.Clob clob) throws SQLException {
- }
- public void updateArray(int colIndex,java.sql.Array array) throws SQLException {
- }
- public void updateArray(String colName,java.sql.Array array) throws SQLException {
- }
-
- /*
- * The first warning reported by calls on this ResultSet is
- * returned. Subsequent ResultSet warnings will be chained
- * to this SQLWarning.
- *
- * <p>The warning chain is automatically cleared each time a new
- * row is read.
- *
- * <p><B>Note:</B> This warning chain only covers warnings caused by
- * ResultSet methods. Any warnings caused by statement methods
- * (such as reading OUT parameters) will be chained on the
- * Statement object.
- *
- * @return the first SQLWarning or null;
- * @exception SQLException if a database access error occurs.
- */
- public SQLWarning getWarnings() throws SQLException
- {
- return warnings;
- }
-
- /*
- * After this call, getWarnings returns null until a new warning
- * is reported for this ResultSet
- *
- * @exception SQLException if a database access error occurs
- */
- public void clearWarnings() throws SQLException
- {
- warnings = null;
- }
-
- /*
- * Get the name of the SQL cursor used by this ResultSet
- *
- * <p>In SQL, a result table is retrieved though a cursor that is
- * named. The current row of a result can be updated or deleted
- * using a positioned update/delete statement that references
- * the cursor name.
- *
- * <p>JDBC supports this SQL feature by providing the name of the
- * SQL cursor used by a ResultSet. The current row of a ResulSet
- * is also the current row of this SQL cursor.
- *
- * <p><B>Note:</B> If positioned update is not supported, a SQLException
- * is thrown.
- *
- * @return the ResultSet's SQL cursor name.
- * @exception SQLException if a database access error occurs
- */
- public String getCursorName() throws SQLException
- {
- return connection.getCursorName();
- }
-
- /*
- * The numbers, types and properties of a ResultSet's columns are
- * provided by the getMetaData method
- *
- * @return a description of the ResultSet's columns
- * @exception SQLException if a database access error occurs
- */
- public java.sql.ResultSetMetaData getMetaData() throws SQLException
- {
- return new ResultSetMetaData(rows, fields);
- }
-
- /*
- * Get the value of a column in the current row as a Java object
- *
- * <p>This method will return the value of the given column as a
- * Java object. The type of the Java object will be the default
- * Java Object type corresponding to the column's SQL type, following
- * the mapping specified in the JDBC specification.
- *
- * <p>This method may also be used to read database specific abstract
- * data types.
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return a Object holding the column value
- * @exception SQLException if a database access error occurs
- */
- public Object getObject(int columnIndex) throws SQLException
- {
- Field field;
-
- checkResultSet( columnIndex );
-
- wasNullFlag = (this_row[columnIndex - 1] == null);
- if (wasNullFlag)
- return null;
-
- field = fields[columnIndex - 1];
-
- // some fields can be null, mainly from those returned by MetaData methods
- if (field == null)
- {
- wasNullFlag = true;
- return null;
- }
-
- switch (field.getSQLType())
- {
- case Types.BIT:
- return new Boolean(getBoolean(columnIndex));
- case Types.SMALLINT:
- return new Short((short)getInt(columnIndex));
- case Types.INTEGER:
- return new Integer(getInt(columnIndex));
- case Types.BIGINT:
- return new Long(getLong(columnIndex));
- case Types.NUMERIC:
- return getBigDecimal
- (columnIndex, (field.getMod() == -1) ? -1 : ((field.getMod() - 4) & 0xffff));
- case Types.REAL:
- return new Float(getFloat(columnIndex));
- case Types.DOUBLE:
- return new Double(getDouble(columnIndex));
- case Types.CHAR:
- case Types.VARCHAR:
- return getString(columnIndex);
- case Types.DATE:
- return getDate(columnIndex);
- case Types.TIME:
- return getTime(columnIndex);
- case Types.TIMESTAMP:
- return getTimestamp(columnIndex);
- case Types.BINARY:
- case Types.VARBINARY:
- return getBytes(columnIndex);
- case Types.ARRAY:
- return getArray(columnIndex);
- default:
- String type = field.getPGType();
- // if the backend doesn't know the type then coerce to String
- if (type.equals("unknown"))
- {
- return getString(columnIndex);
- }
- else
- {
- return connection.getObject(field.getPGType(), getString(columnIndex));
- }
- }
- }
-
- /*
- * Get the value of a column in the current row as a Java object
- *
- *<p> This method will return the value of the given column as a
- * Java object. The type of the Java object will be the default
- * Java Object type corresponding to the column's SQL type, following
- * the mapping specified in the JDBC specification.
- *
- * <p>This method may also be used to read database specific abstract
- * data types.
- *
- * @param columnName is the SQL name of the column
- * @return a Object holding the column value
- * @exception SQLException if a database access error occurs
- */
- public Object getObject(String columnName) throws SQLException
- {
- return getObject(findColumn(columnName));
- }
-
- /*
- * Map a ResultSet column name to a ResultSet column index
- *
- * @param columnName the name of the column
- * @return the column index
- * @exception SQLException if a database access error occurs
- */
- public int findColumn(String columnName) throws SQLException
- {
- int i;
-
- final int flen = fields.length;
- for (i = 0 ; i < flen; ++i)
- if (fields[i].getName().equalsIgnoreCase(columnName))
- return (i + 1);
- throw new PSQLException ("postgresql.res.colname", columnName);
- }
-
- // ** JDBC 2 Extensions **
-
- public boolean absolute(int index) throws SQLException
- {
- // index is 1-based, but internally we use 0-based indices
- int internalIndex;
-
- if (index == 0)
- throw new SQLException("Cannot move to index of 0");
-
- final int rows_size = rows.size();
-
- //if index<0, count from the end of the result set, but check
- //to be sure that it is not beyond the first index
- if (index < 0)
- {
- if (index >= -rows_size)
- internalIndex = rows_size + index;
- else
- {
- beforeFirst();
- return false;
- }
- }
- else
- {
- //must be the case that index>0,
- //find the correct place, assuming that
- //the index is not too large
- if (index <= rows_size)
- internalIndex = index - 1;
- else
- {
- afterLast();
- return false;
- }
- }
-
- current_row = internalIndex;
- this_row = (byte [][])rows.elementAt(internalIndex);
- return true;
- }
-
- public void afterLast() throws SQLException
- {
- final int rows_size = rows.size();
- if (rows_size > 0)
- current_row = rows_size;
- }
-
- public void beforeFirst() throws SQLException
- {
- if (rows.size() > 0)
- current_row = -1;
- }
-
- public void cancelRowUpdates() throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void deleteRow() throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public boolean first() throws SQLException
- {
- if (rows.size() <= 0)
- return false;
-
- current_row = 0;
- this_row = (byte [][])rows.elementAt(current_row);
-
- rowBuffer=new byte[this_row.length][];
- System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
-
- return true;
- }
-
- public java.sql.Array getArray(String colName) throws SQLException
- {
- return getArray(findColumn(colName));
- }
-
- public java.sql.Array getArray(int i) throws SQLException
- {
- wasNullFlag = (this_row[i - 1] == null);
- if (wasNullFlag)
- return null;
-
- if (i < 1 || i > fields.length)
- throw new PSQLException("postgresql.res.colrange");
- return (java.sql.Array) new org.postgresql.jdbc2.Array( connection, i, fields[i - 1], this );
- }
-
- public java.math.BigDecimal getBigDecimal(int columnIndex) throws SQLException
- {
- return getBigDecimal(columnIndex, -1);
- }
-
- public java.math.BigDecimal getBigDecimal(String columnName) throws SQLException
- {
- return getBigDecimal(findColumn(columnName));
- }
-
- public Blob getBlob(String columnName) throws SQLException
- {
- return getBlob(findColumn(columnName));
- }
-
- public Blob getBlob(int i) throws SQLException
- {
- return new org.postgresql.largeobject.PGblob(connection, getInt(i));
- }
-
- public java.io.Reader getCharacterStream(String columnName) throws SQLException
- {
- return getCharacterStream(findColumn(columnName));
- }
-
- public java.io.Reader getCharacterStream(int i) throws SQLException
- {
- checkResultSet( i );
- wasNullFlag = (this_row[i - 1] == null);
- if (wasNullFlag)
- return null;
-
- if (connection.haveMinimumCompatibleVersion("7.2"))
- {
- //Version 7.2 supports AsciiStream for all the PG text types
- //As the spec/javadoc for this method indicate this is to be used for
- //large text values (i.e. LONGVARCHAR) PG doesn't have a separate
- //long string datatype, but with toast the text datatype is capable of
- //handling very large values. Thus the implementation ends up calling
- //getString() since there is no current way to stream the value from the server
- return new CharArrayReader(getString(i).toCharArray());
- }
- else
- {
- // In 7.1 Handle as BLOBS so return the LargeObject input stream
- Encoding encoding = connection.getEncoding();
- InputStream input = getBinaryStream(i);
- return encoding.getDecodingReader(input);
- }
- }
-
- /*
- * New in 7.1
- */
- public Clob getClob(String columnName) throws SQLException
- {
- return getClob(findColumn(columnName));
- }
-
- /*
- * New in 7.1
- */
- public Clob getClob(int i) throws SQLException
- {
- return new org.postgresql.largeobject.PGclob(connection, getInt(i));
- }
-
- public int getConcurrency() throws SQLException
- {
- // New in 7.1 - The standard ResultSet class will now return
- // CONCUR_READ_ONLY. A sub-class will overide this if the query was
- // updateable.
- return CONCUR_READ_ONLY;
- }
-
- public java.sql.Date getDate(int i, java.util.Calendar cal) throws SQLException
- {
- // new in 7.1: If I read the specs, this should use cal only if we don't
- // store the timezone, and if we do, then act just like getDate()?
- // for now...
- return getDate(i);
- }
-
- public Time getTime(int i, java.util.Calendar cal) throws SQLException
- {
- // new in 7.1: If I read the specs, this should use cal only if we don't
- // store the timezone, and if we do, then act just like getTime()?
- // for now...
- return getTime(i);
- }
-
- public Timestamp getTimestamp(int i, java.util.Calendar cal) throws SQLException
- {
- // new in 7.1: If I read the specs, this should use cal only if we don't
- // store the timezone, and if we do, then act just like getDate()?
- // for now...
- return getTimestamp(i);
- }
-
- public java.sql.Date getDate(String c, java.util.Calendar cal) throws SQLException
- {
- return getDate(findColumn(c), cal);
- }
-
- public Time getTime(String c, java.util.Calendar cal) throws SQLException
- {
- return getTime(findColumn(c), cal);
- }
-
- public Timestamp getTimestamp(String c, java.util.Calendar cal) throws SQLException
- {
- return getTimestamp(findColumn(c), cal);
- }
-
- public int getFetchDirection() throws SQLException
- {
- // new in 7.1: PostgreSQL normally sends rows first->last
- return FETCH_FORWARD;
- }
-
- public int getFetchSize() throws SQLException
- {
- // new in 7.1: In this implementation we return the entire result set, so
- // here return the number of rows we have. Sub-classes can return a proper
- // value
- return rows.size();
- }
-
- public Object getObject(String columnName, java.util.Map map) throws SQLException
- {
- return getObject(findColumn(columnName), map);
- }
-
- /*
- * This checks against map for the type of column i, and if found returns
- * an object based on that mapping. The class must implement the SQLData
- * interface.
- */
- public Object getObject(int i, java.util.Map map) throws SQLException
- {
- /* In preparation
- SQLInput s = new PSQLInput(this,i);
- String t = getTypeName(i);
- SQLData o = (SQLData) map.get(t);
- // If the type is not in the map, then pass to the existing code
- if (o==null)
- return getObject(i);
- o.readSQL(s,t);
- return o;
- */throw org.postgresql.Driver.notImplemented();
- }
-
- public Ref getRef(String columnName) throws SQLException
- {
- return getRef(findColumn(columnName));
- }
-
- public Ref getRef(int i) throws SQLException
- {
- // new in 7.1: The backend doesn't yet have SQL3 REF types
- throw new PSQLException("postgresql.psqlnotimp");
- }
-
- public int getRow() throws SQLException
- {
- final int rows_size = rows.size();
-
- if (current_row < 0 || current_row >= rows_size)
- return 0;
-
- return current_row + 1;
- }
-
- // This one needs some thought, as not all ResultSets come from a statement
- public java.sql.Statement getStatement() throws SQLException
- {
- return statement;
- }
-
- public int getType() throws SQLException
- {
- // New in 7.1. This implementation allows scrolling but is not able to
- // see any changes. Sub-classes may overide this to return a more
- // meaningful result.
- return TYPE_SCROLL_INSENSITIVE;
- }
-
- public void insertRow() throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public boolean isAfterLast() throws SQLException
- {
- final int rows_size = rows.size();
- return (current_row >= rows_size && rows_size > 0);
- }
-
- public boolean isBeforeFirst() throws SQLException
- {
- return (current_row < 0 && rows.size() > 0);
- }
-
- public boolean isFirst() throws SQLException
- {
- return (current_row == 0 && rows.size() >= 0);
- }
-
- public boolean isLast() throws SQLException
- {
- final int rows_size = rows.size();
- return (current_row == rows_size - 1 && rows_size > 0);
- }
-
- public boolean last() throws SQLException
- {
- final int rows_size = rows.size();
- if (rows_size <= 0)
- return false;
-
- current_row = rows_size - 1;
- this_row = (byte [][])rows.elementAt(current_row);
-
- rowBuffer=new byte[this_row.length][];
- System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
-
- return true;
- }
-
- public void moveToCurrentRow() throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void moveToInsertRow() throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public boolean previous() throws SQLException
- {
- if (--current_row < 0)
- return false;
- this_row = (byte [][])rows.elementAt(current_row);
- System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
- return true;
- }
-
- public void refreshRow() throws SQLException
- {
- throw new PSQLException("postgresql.notsensitive");
- }
-
- // Peter: Implemented in 7.0
- public boolean relative(int rows) throws SQLException
- {
- //have to add 1 since absolute expects a 1-based index
- return absolute(current_row + 1 + rows);
- }
-
- public boolean rowDeleted() throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- return false; // javac complains about not returning a value!
- }
-
- public boolean rowInserted() throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- return false; // javac complains about not returning a value!
- }
-
- public boolean rowUpdated() throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- return false; // javac complains about not returning a value!
- }
-
- public void setFetchDirection(int direction) throws SQLException
- {
- // In 7.1, the backend doesn't yet support this
- throw new PSQLException("postgresql.psqlnotimp");
- }
-
- public void setFetchSize(int rows) throws SQLException
- {
- // Sub-classes should implement this as part of their cursor support
- throw org.postgresql.Driver.notImplemented();
- }
-
- public void updateAsciiStream(int columnIndex,
- java.io.InputStream x,
- int length
- ) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateAsciiStream(String columnName,
- java.io.InputStream x,
- int length
- ) throws SQLException
- {
- updateAsciiStream(findColumn(columnName), x, length);
- }
-
- public void updateBigDecimal(int columnIndex,
- java.math.BigDecimal x
- ) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateBigDecimal(String columnName,
- java.math.BigDecimal x
- ) throws SQLException
- {
- updateBigDecimal(findColumn(columnName), x);
- }
-
- public void updateBinaryStream(int columnIndex,
- java.io.InputStream x,
- int length
- ) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateBinaryStream(String columnName,
- java.io.InputStream x,
- int length
- ) throws SQLException
- {
- updateBinaryStream(findColumn(columnName), x, length);
- }
-
- public void updateBoolean(int columnIndex, boolean x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateBoolean(String columnName, boolean x) throws SQLException
- {
- updateBoolean(findColumn(columnName), x);
- }
-
- public void updateByte(int columnIndex, byte x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateByte(String columnName, byte x) throws SQLException
- {
- updateByte(findColumn(columnName), x);
- }
-
- public void updateBytes(String columnName, byte[] x) throws SQLException
- {
- updateBytes(findColumn(columnName), x);
- }
-
- public void updateBytes(int columnIndex, byte[] x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateCharacterStream(int columnIndex,
- java.io.Reader x,
- int length
- ) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateCharacterStream(String columnName,
- java.io.Reader x,
- int length
- ) throws SQLException
- {
- updateCharacterStream(findColumn(columnName), x, length);
- }
-
- public void updateDate(int columnIndex, java.sql.Date x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateDate(String columnName, java.sql.Date x) throws SQLException
- {
- updateDate(findColumn(columnName), x);
- }
-
- public void updateDouble(int columnIndex, double x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateDouble(String columnName, double x) throws SQLException
- {
- updateDouble(findColumn(columnName), x);
- }
-
- public void updateFloat(int columnIndex, float x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateFloat(String columnName, float x) throws SQLException
- {
- updateFloat(findColumn(columnName), x);
- }
-
- public void updateInt(int columnIndex, int x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateInt(String columnName, int x) throws SQLException
- {
- updateInt(findColumn(columnName), x);
- }
-
- public void updateLong(int columnIndex, long x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateLong(String columnName, long x) throws SQLException
- {
- updateLong(findColumn(columnName), x);
- }
-
- public void updateNull(int columnIndex) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateNull(String columnName) throws SQLException
- {
- updateNull(findColumn(columnName));
- }
-
- public void updateObject(int columnIndex, Object x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateObject(String columnName, Object x) throws SQLException
- {
- updateObject(findColumn(columnName), x);
- }
-
- public void updateObject(int columnIndex, Object x, int scale) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateObject(String columnName, Object x, int scale) throws SQLException
- {
- updateObject(findColumn(columnName), x, scale);
- }
-
- public void updateRow() throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateShort(int columnIndex, short x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateShort(String columnName, short x) throws SQLException
- {
- updateShort(findColumn(columnName), x);
- }
-
- public void updateString(int columnIndex, String x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateString(String columnName, String x) throws SQLException
- {
- updateString(findColumn(columnName), x);
- }
-
- public void updateTime(int columnIndex, Time x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateTime(String columnName, Time x) throws SQLException
- {
- updateTime(findColumn(columnName), x);
- }
-
- public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException
- {
- // only sub-classes implement CONCUR_UPDATEABLE
- notUpdateable();
- }
-
- public void updateTimestamp(String columnName, Timestamp x) throws SQLException
- {
- updateTimestamp(findColumn(columnName), x);
- }
-
- // helper method. Throws an SQLException when an update is not possible
- public void notUpdateable() throws SQLException
- {
- throw new PSQLException("postgresql.noupdate");
- }
-
- /*
- * This is called by Statement to register itself with this statement.
- * It's used currently by getStatement() but may also with the new core
- * package.
- */
- public void setStatement(org.postgresql.jdbc2.Statement statement)
- {
- this.statement = statement;
- }
-
- //----------------- Formatting Methods -------------------
-
- public static boolean toBoolean(String s)
- {
- if (s != null)
- {
- int c = s.charAt(0);
- return ((c == 't') || (c == 'T') || (c == '1'));
- }
- return false; // SQL NULL
- }
-
- public static int toInt(String s) throws SQLException
- {
- if (s != null)
- {
- try
- {
- return Integer.parseInt(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.badint", s);
- }
- }
- return 0; // SQL NULL
- }
-
- public static long toLong(String s) throws SQLException
- {
- if (s != null)
- {
- try
- {
- return Long.parseLong(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.badlong", s);
- }
- }
- return 0; // SQL NULL
- }
-
- public static BigDecimal toBigDecimal(String s, int scale) throws SQLException
- {
- BigDecimal val;
- if (s != null)
- {
- try
- {
- val = new BigDecimal(s);
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.badbigdec", s);
- }
- if (scale == -1)
- return val;
- try
- {
- return val.setScale(scale);
- }
- catch (ArithmeticException e)
- {
- throw new PSQLException ("postgresql.res.badbigdec", s);
- }
- }
- return null; // SQL NULL
- }
-
- public static float toFloat(String s) throws SQLException
- {
- if (s != null)
- {
- try
- {
- return Float.valueOf(s).floatValue();
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.badfloat", s);
- }
- }
- return 0; // SQL NULL
- }
-
- public static double toDouble(String s) throws SQLException
- {
- if (s != null)
- {
- try
- {
- return Double.valueOf(s).doubleValue();
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException ("postgresql.res.baddouble", s);
- }
- }
- return 0; // SQL NULL
- }
-
- public static java.sql.Date toDate(String s) throws SQLException
- {
- if (s == null)
- return null;
- // length == 10: SQL Date
- // length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
- try
- {
- return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0, 10));
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.res.baddate", s);
- }
- }
-
- public static Time toTime(String s) throws SQLException
- {
- if (s == null)
- return null; // SQL NULL
- // length == 8: SQL Time
- // length > 8: SQL Timestamp
- try
- {
- return java.sql.Time.valueOf((s.length() == 8) ? s : s.substring(11, 19));
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.res.badtime", s);
- }
- }
-
- /**
- * Parse a string and return a timestamp representing its value.
- *
- * The driver is set to return ISO date formated strings. We modify this
- * string from the ISO format to a format that Java can understand. Java
- * expects timezone info as 'GMT+09:00' where as ISO gives '+09'.
- * Java also expects fractional seconds to 3 places where postgres
- * will give, none, 2 or 6 depending on the time and postgres version.
- * From version 7.2 postgres returns fractional seconds to 6 places.
- * If available, we drop the last 3 digits.
- *
- * @param s The ISO formated date string to parse.
- * @param resultSet The ResultSet this date is part of.
- *
- * @return null if s is null or a timestamp of the parsed string s.
- *
- * @throws SQLException if there is a problem parsing s.
- **/
- public static Timestamp toTimestamp(String s, ResultSet resultSet)
- throws SQLException
- {
- if (s == null)
- return null;
-
- // We must be synchronized here incase more theads access the ResultSet
- // bad practice but possible. Anyhow this is to protect sbuf and
- // SimpleDateFormat objects
- synchronized (resultSet)
- {
- SimpleDateFormat df = null;
- if ( org.postgresql.Driver.logDebug ) org.postgresql.Driver.debug("the data from the DB is "+s);
-
- // If first time, create the buffer, otherwise clear it.
- if (resultSet.sbuf == null)
- resultSet.sbuf = new StringBuffer();
- else
- resultSet.sbuf.setLength(0);
-
- // Copy s into sbuf for parsing.
- resultSet.sbuf.append(s);
- int slen = s.length();
-
- if (slen > 19)
- {
- // The len of the ISO string to the second value is 19 chars. If
- // greater then 19, there may be tz info and perhaps fractional
- // second info which we need to change to java to read it.
-
- // cut the copy to second value "2001-12-07 16:29:22"
- int i = 19;
- resultSet.sbuf.setLength(i);
-
- char c = s.charAt(i++);
- if (c == '.')
- {
- // Found a fractional value. Append up to 3 digits including
- // the leading '.'
- do
- {
- if (i < 24)
- resultSet.sbuf.append(c);
- c = s.charAt(i++);
- } while (i < slen && Character.isDigit(c));
-
- // If there wasn't at least 3 digits we should add some zeros
- // to make up the 3 digits we tell java to expect.
- for (int j = i; j < 24; j++)
- resultSet.sbuf.append('0');
- }
- else
- {
- // No fractional seconds, lets add some.
- resultSet.sbuf.append(".000");
- }
-
- if (i < slen)
- {
- // prepend the GMT part and then add the remaining bit of
- // the string.
- resultSet.sbuf.append(" GMT");
- resultSet.sbuf.append(c);
- resultSet.sbuf.append(s.substring(i, slen));
-
- // Lastly, if the tz part doesn't specify the :MM part then
- // we add ":00" for java.
- if (slen - i < 5)
- resultSet.sbuf.append(":00");
-
- // we'll use this dateformat string to parse the result.
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
- }
- else
- {
- // Just found fractional seconds but no timezone.
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- }
- }
- else if (slen == 19)
- {
- // No tz or fractional second info.
- // I'm not sure if it is
- // possible to have a string in this format, as pg
- // should give us tz qualified timestamps back, but it was
- // in the old code, so I'm handling it for now.
- df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- }
- else
- {
- // We must just have a date. This case is
- // needed if this method is called on a date
- // column
- df = new SimpleDateFormat("yyyy-MM-dd");
- }
-
- try
- {
- // All that's left is to parse the string and return the ts.
- if ( org.postgresql.Driver.logDebug ) org.postgresql.Driver.debug( "" + df.parse(resultSet.sbuf.toString()).getTime() );
-
- return new Timestamp(df.parse(resultSet.sbuf.toString()).getTime());
- }
- catch (ParseException e)
- {
- throw new PSQLException("postgresql.res.badtimestamp", new Integer(e.getErrorOffset()), s);
- }
- }
- }
-
- public void setSQLQuery(String sqlQuery) {
- this.sqlQuery=sqlQuery;
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java
deleted file mode 100644
index 6ff6094b64d..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java
+++ /dev/null
@@ -1,538 +0,0 @@
-package org.postgresql.jdbc2;
-
-// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 1 class in the
-// org.postgresql.jdbc1 package.
-
-import java.lang.*;
-import java.sql.*;
-import java.util.*;
-import org.postgresql.*;
-import org.postgresql.util.*;
-
-/**
- * A ResultSetMetaData object can be used to find out about the types and
- * properties of the columns in a ResultSet
- *
- * @see java.sql.ResultSetMetaData
- */
-public class ResultSetMetaData implements java.sql.ResultSetMetaData
-{
- Vector rows;
- Field[] fields;
-
- /*
- * Initialise for a result with a tuple set and
- * a field descriptor set
- *
- * @param rows the Vector of rows returned by the ResultSet
- * @param fields the array of field descriptors
- */
- public ResultSetMetaData(Vector rows, Field[] fields)
- {
- this.rows = rows;
- this.fields = fields;
- }
-
- /*
- * Whats the number of columns in the ResultSet?
- *
- * @return the number
- * @exception SQLException if a database access error occurs
- */
- public int getColumnCount() throws SQLException
- {
- return fields.length;
- }
-
- /*
- * Is the column automatically numbered (and thus read-only)
- * I believe that PostgreSQL does not support this feature.
- *
- * @param column the first column is 1, the second is 2...
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isAutoIncrement(int column) throws SQLException
- {
- return false;
- }
-
- /*
- * Does a column's case matter? ASSUMPTION: Any field that is
- * not obviously case insensitive is assumed to be case sensitive
- *
- * @param column the first column is 1, the second is 2...
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isCaseSensitive(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- switch (sql_type)
- {
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- return false;
- default:
- return true;
- }
- }
-
- /*
- * Can the column be used in a WHERE clause? Basically for
- * this, I split the functions into two types: recognised
- * types (which are always useable), and OTHER types (which
- * may or may not be useable). The OTHER types, for now, I
- * will assume they are useable. We should really query the
- * catalog to see if they are useable.
- *
- * @param column the first column is 1, the second is 2...
- * @return true if they can be used in a WHERE clause
- * @exception SQLException if a database access error occurs
- */
- public boolean isSearchable(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- // This switch is pointless, I know - but it is a set-up
- // for further expansion.
- switch (sql_type)
- {
- case Types.OTHER:
- return true;
- default:
- return true;
- }
- }
-
- /*
- * Is the column a cash value? 6.1 introduced the cash/money
- * type, which haven't been incorporated as of 970414, so I
- * just check the type name for both 'cash' and 'money'
- *
- * @param column the first column is 1, the second is 2...
- * @return true if its a cash column
- * @exception SQLException if a database access error occurs
- */
- public boolean isCurrency(int column) throws SQLException
- {
- String type_name = getField(column).getPGType();
-
- return type_name.equals("cash") || type_name.equals("money");
- }
-
- /*
- * Indicates the nullability of values in the designated column.
- *
- * @param column the first column is 1, the second is 2...
- * @return one of the columnNullable values
- * @exception SQLException if a database access error occurs
- */
- public int isNullable(int column) throws SQLException
- {
- /*
- * TODO This needs a real implementation, taking into account columns
- * defined with NOT NULL or PRIMARY KEY, CHECK constraints, views,
- * functions etc.
- */
- return columnNullableUnknown;
- }
-
- /*
- * Is the column a signed number? In PostgreSQL, all numbers
- * are signed, so this is trivial. However, strings are not
- * signed (duh!)
- *
- * @param column the first column is 1, the second is 2...
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isSigned(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- switch (sql_type)
- {
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- return true;
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- return false; // I don't know about these?
- default:
- return false;
- }
- }
-
- /*
- * What is the column's normal maximum width in characters?
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the maximum width
- * @exception SQLException if a database access error occurs
- */
- public int getColumnDisplaySize(int column) throws SQLException
- {
- Field f = getField(column);
- String type_name = f.getPGType();
- int sql_type = f.getSQLType();
- int typmod = f.getMod();
-
- // I looked at other JDBC implementations and couldn't find a consistent
- // interpretation of the "display size" for numeric values, so this is our's
- // FIXME: currently, only types with a SQL92 or SQL3 pendant are implemented - jens@jens.de
-
- // fixed length data types
- if (type_name.equals( "int2" ))
- return 6; // -32768 to +32768 (5 digits and a sign)
- if (type_name.equals( "int4" )
- || type_name.equals( "oid" ))
- return 11; // -2147483648 to +2147483647
- if (type_name.equals( "int8" ))
- return 20; // -9223372036854775808 to +9223372036854775807
- if (type_name.equals( "money" ))
- return 12; // MONEY = DECIMAL(9,2)
- if (type_name.equals( "float4" ))
- return 11; // i checked it out ans wasn't able to produce more than 11 digits
- if (type_name.equals( "float8" ))
- return 20; // dito, 20
- if (type_name.equals( "char" ))
- return 1;
- if (type_name.equals( "bool" ))
- return 1;
- if (type_name.equals( "date" ))
- return 14; // "01/01/4713 BC" - "31/12/32767 AD"
- if (type_name.equals( "time" ))
- return 8; // 00:00:00-23:59:59
- if (type_name.equals( "timestamp" ))
- return 22; // hhmmm ... the output looks like this: 1999-08-03 22:22:08+02
-
- // variable length fields
- typmod -= 4;
- if (type_name.equals( "bpchar" )
- || type_name.equals( "varchar" ))
- return typmod; // VARHDRSZ=sizeof(int32)=4
- if (type_name.equals( "numeric" ))
- return ( (typmod >> 16) & 0xffff )
- + 1 + ( typmod & 0xffff ); // DECIMAL(p,s) = (p digits).(s digits)
-
- // if we don't know better
- return f.getLength();
- }
-
- /*
- * What is the suggested column title for use in printouts and
- * displays? We suggest the ColumnName!
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the column label
- * @exception SQLException if a database access error occurs
- */
- public String getColumnLabel(int column) throws SQLException
- {
- return getColumnName(column);
- }
-
- /*
- * What's a column's name?
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the column name
- * @exception SQLException if a database access error occurs
- */
- public String getColumnName(int column) throws SQLException
- {
- Field f = getField(column);
- if (f != null)
- return f.getName();
- return "field" + column;
- }
-
- /*
- * What is a column's table's schema? This relies on us knowing
- * the table name....which I don't know how to do as yet. The
- * JDBC specification allows us to return "" if this is not
- * applicable.
- *
- * @param column the first column is 1, the second is 2...
- * @return the Schema
- * @exception SQLException if a database access error occurs
- */
- public String getSchemaName(int column) throws SQLException
- {
- return "";
- }
-
- /*
- * What is a column's number of decimal digits.
- *
- * @param column the first column is 1, the second is 2...
- * @return the precision
- * @exception SQLException if a database access error occurs
- */
- public int getPrecision(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- switch (sql_type)
- {
- case Types.SMALLINT:
- return 5;
- case Types.INTEGER:
- return 10;
- case Types.REAL:
- return 8;
- case Types.FLOAT:
- return 16;
- case Types.DOUBLE:
- return 16;
- case Types.VARCHAR:
- return 0;
- case Types.NUMERIC:
- Field f = getField(column);
- if (f != null)
- return ((0xFFFF0000)&f.getMod()) >> 16;
- else
- return 0;
- default:
- return 0;
- }
- }
-
- /*
- * What is a column's number of digits to the right of the
- * decimal point?
- *
- * @param column the first column is 1, the second is 2...
- * @return the scale
- * @exception SQLException if a database access error occurs
- */
- public int getScale(int column) throws SQLException
- {
- int sql_type = getField(column).getSQLType();
-
- switch (sql_type)
- {
- case Types.SMALLINT:
- return 0;
- case Types.INTEGER:
- return 0;
- case Types.REAL:
- return 8;
- case Types.FLOAT:
- return 16;
- case Types.DOUBLE:
- return 16;
- case Types.VARCHAR:
- return 0;
- case Types.NUMERIC:
- Field f = getField(column);
- if (f != null)
- return (((0x0000FFFF)&f.getMod()) - 4);
- else
- return 0;
- default:
- return 0;
- }
- }
-
- /*
- * Whats a column's table's name? How do I find this out? Both
- * getSchemaName() and getCatalogName() rely on knowing the table
- * Name, so we need this before we can work on them.
- *
- * @param column the first column is 1, the second is 2...
- * @return column name, or "" if not applicable
- * @exception SQLException if a database access error occurs
- */
- public String getTableName(int column) throws SQLException
- {
- return "";
- }
-
- /*
- * What's a column's table's catalog name? As with getSchemaName(),
- * we can say that if getTableName() returns n/a, then we can too -
- * otherwise, we need to work on it.
- *
- * @param column the first column is 1, the second is 2...
- * @return catalog name, or "" if not applicable
- * @exception SQLException if a database access error occurs
- */
- public String getCatalogName(int column) throws SQLException
- {
- return "";
- }
-
- /*
- * What is a column's SQL Type? (java.sql.Type int)
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the java.sql.Type value
- * @exception SQLException if a database access error occurs
- * @see org.postgresql.Field#getSQLType
- * @see java.sql.Types
- */
- public int getColumnType(int column) throws SQLException
- {
- return getField(column).getSQLType();
- }
-
- /*
- * Whats is the column's data source specific type name?
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return the type name
- * @exception SQLException if a database access error occurs
- */
- public String getColumnTypeName(int column) throws SQLException
- {
- return getField(column).getPGType();
- }
-
- /**
- * Is the column definitely not writable? In reality, we would
- * have to check the GRANT/REVOKE stuff for this to be effective,
- * and I haven't really looked into that yet, so this will get
- * re-visited.
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isReadOnly(int column) throws SQLException
- {
- return false;
- }
-
- /**
- * Is it possible for a write on the column to succeed? Again, we
- * would in reality have to check the GRANT/REVOKE stuff, which
- * I haven't worked with as yet. However, if it isn't ReadOnly, then
- * it is obviously writable.
- *
- * @param column the first column is 1, the second is 2, etc.
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isWritable(int column) throws SQLException
- {
- return !isReadOnly(column);
- }
-
- /**
- * Will a write on this column definately succeed? Hmmm...this
- * is a bad one, since the two preceding functions have not been
- * really defined. I cannot tell is the short answer. I thus
- * return isWritable() just to give us an idea.
- *
- * @param column the first column is 1, the second is 2, etc..
- * @return true if so
- * @exception SQLException if a database access error occurs
- */
- public boolean isDefinitelyWritable(int column) throws SQLException
- {
- return false;
- }
-
- // ********************************************************
- // END OF PUBLIC INTERFACE
- // ********************************************************
-
- /**
- * For several routines in this package, we need to convert
- * a columnIndex into a Field[] descriptor. Rather than do
- * the same code several times, here it is.
- *
- * @param columnIndex the first column is 1, the second is 2...
- * @return the Field description
- * @exception SQLException if a database access error occurs
- */
- private Field getField(int columnIndex) throws SQLException
- {
- if (columnIndex < 1 || columnIndex > fields.length)
- throw new PSQLException("postgresql.res.colrange");
- return fields[columnIndex - 1];
- }
-
- // ** JDBC 2 Extensions **
-
- // This can hook into our PG_Object mechanism
- public String getColumnClassName(int column) throws SQLException
- {
- /*
- The following data type mapping came from ../Field.java.
-
- "int2",
- "int4","oid",
- "int8",
- "cash","money",
- "numeric",
- "float4",
- "float8",
- "bpchar","char","char2","char4","char8","char16",
- "varchar","text","name","filename",
- "bool",
- "date",
- "time",
- "abstime","timestamp"
-
- Types.SMALLINT,
- Types.INTEGER,Types.INTEGER,
- Types.BIGINT,
- Types.DOUBLE,Types.DOUBLE,
- Types.NUMERIC,
- Types.REAL,
- Types.DOUBLE,
- Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,Types.CHAR,
- Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,
- Types.BIT,
- Types.DATE,
- Types.TIME,
- Types.TIMESTAMP,Types.TIMESTAMP
- */
-
- int sql_type = getField(column).getSQLType();
-
- switch (sql_type)
- {
- case Types.BIT:
- return("java.lang.Boolean");
- case Types.SMALLINT:
- return("java.lang.Integer");
- case Types.INTEGER:
- return("java.lang.Integer");
- case Types.BIGINT:
- return("java.lang.Long");
- case Types.NUMERIC:
- return("java.math.BigDecimal");
- case Types.REAL:
- return("java.lang.Float");
- case Types.DOUBLE:
- return("java.lang.Double");
- case Types.CHAR:
- case Types.VARCHAR:
- return("java.lang.String");
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- return("java.sql.Timestamp");
- default:
- throw org.postgresql.Driver.notImplemented();
- }
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/Statement.java b/src/interfaces/jdbc/org/postgresql/jdbc2/Statement.java
deleted file mode 100644
index a00025ff72a..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/Statement.java
+++ /dev/null
@@ -1,381 +0,0 @@
-package org.postgresql.jdbc2;
-
-// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 1 class in the
-// org.postgresql.jdbc1 package.
-
-import java.sql.*;
-import java.util.Vector;
-import org.postgresql.util.*;
-
-/*
- * A Statement object is used for executing a static SQL statement and
- * obtaining the results produced by it.
- *
- * <p>Only one ResultSet per Statement can be open at any point in time.
- * Therefore, if the reading of one ResultSet is interleaved with the
- * reading of another, each must have been generated by different
- * Statements. All statement execute methods implicitly close a
- * statement's current ResultSet if an open one exists.
- *
- * @see java.sql.Statement
- * @see ResultSet
- */
-public class Statement extends org.postgresql.Statement implements java.sql.Statement
-{
- private Connection connection; // The connection who created us
- private Vector batch = null;
- private int resultsettype; // the resultset type to return
- private int concurrency; // is it updateable or not?
-
- /*
- * Constructor for a Statement. It simply sets the connection
- * that created us.
- *
- * @param c the Connection instantation that creates us
- */
- public Statement (Connection c)
- {
- connection = c;
- resultsettype = java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE;
- concurrency = java.sql.ResultSet.CONCUR_READ_ONLY;
- }
-
- /*
- * Execute a SQL statement that retruns a single ResultSet
- *
- * @param sql typically a static SQL SELECT statement
- * @return a ResulSet that contains the data produced by the query
- * @exception SQLException if a database access error occurs
- */
- public java.sql.ResultSet executeQuery(String sql) throws SQLException
- {
- this.execute(sql);
- while (result != null && !((org.postgresql.ResultSet)result).reallyResultSet())
- result = ((org.postgresql.ResultSet)result).getNext();
- if (result == null)
- throw new PSQLException("postgresql.stat.noresult");
- return result;
- }
-
- /*
- * Execute a SQL INSERT, UPDATE or DELETE statement. In addition
- * SQL statements that return nothing such as SQL DDL statements
- * can be executed
- *
- * @param sql a SQL statement
- * @return either a row count, or 0 for SQL commands
- * @exception SQLException if a database access error occurs
- */
- public int executeUpdate(String sql) throws SQLException
- {
- this.execute(sql);
- if (((org.postgresql.ResultSet)result).reallyResultSet())
- throw new PSQLException("postgresql.stat.result");
- return this.getUpdateCount();
- }
-
- /*
- * setCursorName defines the SQL cursor name that will be used by
- * subsequent execute methods. This name can then be used in SQL
- * positioned update/delete statements to identify the current row
- * in the ResultSet generated by this statement. If a database
- * doesn't support positioned update/delete, this method is a
- * no-op.
- *
- * <p><B>Note:</B> By definition, positioned update/delete execution
- * must be done by a different Statement than the one which
- * generated the ResultSet being used for positioning. Also, cursor
- * names must be unique within a Connection.
- *
- * <p>We throw an additional constriction. There can only be one
- * cursor active at any one time.
- *
- * @param name the new cursor name
- * @exception SQLException if a database access error occurs
- */
- public void setCursorName(String name) throws SQLException
- {
- connection.setCursorName(name);
- }
-
- /*
- * Execute a SQL statement that may return multiple results. We
- * don't have to worry about this since we do not support multiple
- * ResultSets. You can use getResultSet or getUpdateCount to
- * retrieve the result.
- *
- * @param sql any SQL statement
- * @return true if the next result is a ResulSet, false if it is
- * an update count or there are no more results
- * @exception SQLException if a database access error occurs
- */
- public boolean execute(String sql) throws SQLException
- {
- if (escapeProcessing)
- sql = escapeSQL(sql);
-
- // New in 7.1, if we have a previous resultset then force it to close
- // This brings us nearer to compliance, and helps memory management.
- // Internal stuff will call ExecSQL directly, bypassing this.
- if (result != null)
- {
- java.sql.ResultSet rs = getResultSet();
- if (rs != null)
- rs.close();
- }
-
-
- // New in 7.1, pass Statement so that ExecSQL can customise to it
- result = connection.ExecSQL(sql, this);
-
- // New in 7.1, required for ResultSet.getStatement() to work
- ((org.postgresql.jdbc2.ResultSet)result).setStatement(this);
-
- // Added this so that the Updateable resultset knows the query that gave this
- ((org.postgresql.jdbc2.ResultSet)result).setSQLQuery(sql);
-
-
- return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
- }
-
- /*
- * getUpdateCount returns the current result as an update count,
- * if the result is a ResultSet or there are no more results, -1
- * is returned. It should only be called once per result.
- *
- * @return the current result as an update count.
- * @exception SQLException if a database access error occurs
- */
- public int getUpdateCount() throws SQLException
- {
- if (result == null)
- return -1;
- if (((org.postgresql.ResultSet)result).reallyResultSet())
- return -1;
- return ((org.postgresql.ResultSet)result).getResultCount();
- }
-
- /*
- * getMoreResults moves to a Statement's next result. If it returns
- * true, this result is a ResulSet.
- *
- * @return true if the next ResultSet is valid
- * @exception SQLException if a database access error occurs
- */
- public boolean getMoreResults() throws SQLException
- {
- result = ((org.postgresql.ResultSet)result).getNext();
- return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
- }
-
- // ** JDBC 2 Extensions **
-
- public void addBatch(String sql) throws SQLException
- {
- if (batch == null)
- batch = new Vector();
- batch.addElement(sql);
- }
-
- public void clearBatch() throws SQLException
- {
- if (batch != null)
- batch.removeAllElements();
- }
-
- public int[] executeBatch() throws SQLException
- {
- if (batch == null)
- batch = new Vector();
- int size = batch.size();
- int[] result = new int[size];
- int i = 0;
- try
- {
- for (i = 0;i < size;i++)
- result[i] = this.executeUpdate((String)batch.elementAt(i));
- }
- catch (SQLException e)
- {
- int[] resultSucceeded = new int[i];
- System.arraycopy(result, 0, resultSucceeded, 0, i);
-
- PBatchUpdateException updex =
- new PBatchUpdateException("postgresql.stat.batch.error",
- new Integer(i), batch.elementAt(i), resultSucceeded);
- updex.setNextException(e);
-
- throw updex;
- }
- finally
- {
- batch.removeAllElements();
- }
- return result;
- }
-
- public void cancel() throws SQLException
- {
- connection.cancelQuery();
- }
-
- public java.sql.Connection getConnection() throws SQLException
- {
- return (java.sql.Connection)connection;
- }
-
- public int getFetchDirection() throws SQLException
- {
- throw new PSQLException("postgresql.psqlnotimp");
- }
-
- public int getFetchSize() throws SQLException
- {
- // This one can only return a valid value when were a cursor?
- throw org.postgresql.Driver.notImplemented();
- }
-
- public int getResultSetConcurrency() throws SQLException
- {
- // new in 7.1
- return concurrency;
- }
-
- public int getResultSetType() throws SQLException
- {
- // new in 7.1
- return resultsettype;
- }
-
- public void setFetchDirection(int direction) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- public void setFetchSize(int rows) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /*
- * New in 7.1
- */
- public void setResultSetConcurrency(int value) throws SQLException
- {
- concurrency = value;
- }
-
- /*
- * New in 7.1
- */
- public void setResultSetType(int value) throws SQLException
- {
- resultsettype = value;
- }
-
- // In JDK 1.4 not implemented
- /**
- *
- * @param num
- * @return
- * @throws SQLException
- */
- public boolean getMoreResults(int num) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /**
- *
- * @return
- * @throws SQLException
- */
- public java.sql.ResultSet getGeneratedKeys() throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /**
- *
- * @param a
- * @param b
- * @return
- * @throws SQLException
- */
- public int executeUpdate(String a, int b) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /**
- *
- * @param a
- * @param b
- * @return
- * @throws SQLException
- */
- public int executeUpdate(String a, int[] b) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
-
- }
-
- public int executeUpdate(String a, String[] b) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
-
- }
-
- /**
- *
- * @param a
- * @param b
- * @return
- * @throws SQLException
- */
- public boolean execute(String a, int b) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
-
- }
-
- /**
- *
- * @param a
- * @param b
- * @return
- * @throws SQLException
- */
- public boolean execute(String a, int[] b) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
-
- }
-
- /**
- *
- * @param a
- * @param b
- * @return
- * @throws SQLException
- */
- public boolean execute(String a, String[] b) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
-
- }
-
- /**
- *
- * @return
- * @throws SQLException
- */
- public int getResultSetHoldability() throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
-
- }
-
-} \ No newline at end of file
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/UpdateableResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc2/UpdateableResultSet.java
deleted file mode 100644
index 9ff8be4080d..00000000000
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/UpdateableResultSet.java
+++ /dev/null
@@ -1,1391 +0,0 @@
-package org.postgresql.jdbc2;
-
-// IMPORTANT NOTE: This is the begining of supporting updateable ResultSets.
-// It is not a working solution (yet)!
-//
-// You will notice here we really do throw org.postgresql.Driver.notImplemented()
-// This is because here we should be updateable, so any unimplemented methods
-// must say so.
-//
-// Also you'll notice that the String columnName based calls are not present.
-// They are not required as they are in the super class.
-//
-
-import java.lang.*;
-import java.io.*;
-import java.math.*;
-import java.text.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.Field;
-import org.postgresql.largeobject.*;
-import org.postgresql.util.*;
-import org.postgresql.Driver;
-
-/*
- * @see ResultSet
- * @see ResultSetMetaData
- * @see java.sql.ResultSet
- */
-public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
-{
-
-
- class PrimaryKey
- {
- int index; // where in the result set is this primaryKey
- String name; // what is the columnName of this primary Key
-
- PrimaryKey( int index, String name)
- {
- this.index = index;
- this.name = name;
- }
- Object getValue() throws SQLException
- {
- return getObject(index);
- }
- };
-
- private boolean usingOID = false; // are we using the OID for the primary key?
-
- private Vector primaryKeys; // list of primary keys
-
- private int numKeys = 0;
-
- private boolean singleTable = false;
-
- protected String tableName = null;
-
- /**
- * PreparedStatement used to delete data
- */
-
- protected java.sql.PreparedStatement updateStatement = null;
-
- /**
- * PreparedStatement used to insert data
- */
-
- protected java.sql.PreparedStatement insertStatement = null;
-
- /**
- * PreparedStatement used to delete data
- */
-
- protected java.sql.PreparedStatement deleteStatement = null;
-
-
- /**
- * PreparedStatement used to refresh data
- */
- private java.sql.PreparedStatement selectStatement = null;
-
-
- /**
- * Is this result set updateable?
- */
-
- protected boolean updateable = false;
-
- /**
- * Are we in the middle of doing updates to the current row?
- */
-
- protected boolean doingUpdates = false;
-
-
- /**
- * Are we on the insert row?
- */
-
- protected boolean onInsertRow = false;
-
-
- protected Hashtable updateValues = new Hashtable();
-
- // The Row Buffer will be used to cache updated rows..then we shall sync this with the rows vector
-
-
- /*
- * Create a new ResultSet - Note that we create ResultSets to
- * represent the results of everything.
- *
- * @param fields an array of Field objects (basically, the
- * ResultSet MetaData)
- * @param tuples Vector of the actual data
- * @param status the status string returned from the back end
- * @param updateCount the number of rows affected by the operation
- * @param cursor the positioned update/delete cursor name
- */
- public UpdateableResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
- {
- super(conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
- }
-
- /**
- *
- * @throws SQLException
- */
- public synchronized void cancelRowUpdates() throws SQLException
- {
- if (doingUpdates)
- {
- doingUpdates = false;
-
- clearRowBuffer();
- }
- }
-
- /**
- *
- * @throws SQLException
- */
- public synchronized void deleteRow() throws SQLException
- {
- if ( !isUpdateable() )
- {
- throw new PSQLException( "postgresql.updateable.notupdateable" );
- }
-
- if (onInsertRow)
- {
- throw new PSQLException( "postgresql.updateable.oninsertrow" );
- }
-
- if (rows.size() == 0)
- {
- throw new PSQLException( "postgresql.updateable.emptydelete" );
- }
- if (isBeforeFirst())
- {
- throw new PSQLException( "postgresql.updateable.beforestartdelete" );
- }
- if (isAfterLast())
- {
- throw new PSQLException( "postgresql.updateable.afterlastdelete" );
- }
-
-
- int numKeys = primaryKeys.size();
- if ( deleteStatement == null )
- {
-
-
- StringBuffer deleteSQL= new StringBuffer("DELETE FROM " ).append(tableName).append(" where " );
-
- for ( int i=0; i < numKeys ; i++ )
- {
- deleteSQL.append( ((PrimaryKey)primaryKeys.get(i)).name ).append( " = ? " );
- if ( i < numKeys-1 )
- {
- deleteSQL.append( " and " );
- }
- }
-
- deleteStatement = ((java.sql.Connection)connection).prepareStatement(deleteSQL.toString());
- }
- deleteStatement.clearParameters();
-
- for ( int i =0; i < numKeys; i++ )
- {
- deleteStatement.setObject(i+1, ((PrimaryKey)primaryKeys.get(i)).getValue());
- }
-
-
- deleteStatement.executeUpdate();
-
- rows.removeElementAt(current_row);
- }
-
-
- /**
- *
- * @return
- * @throws SQLException
- */
- public int getConcurrency() throws SQLException
- {
- // New in 7.1 - The updateable ResultSet class will now return
- // CONCURuPDATEABLE.
- return CONCUR_UPDATABLE;
- }
-
- /**
- *
- * @throws SQLException
- */
-
- public synchronized void insertRow() throws SQLException
- {
- if ( !isUpdateable() )
- {
- throw new PSQLException( "postgresql.updateable.notupdateable" );
- }
-
- if (!onInsertRow)
- {
- throw new PSQLException( "postgresql.updateable.notoninsertrow" );
- }
- else
- {
-
- // loop through the keys in the insertTable and create the sql statement
- // we have to create the sql every time since the user could insert different
- // columns each time
-
- StringBuffer insertSQL=new StringBuffer("INSERT INTO ").append(tableName).append(" (");
- StringBuffer paramSQL = new StringBuffer(") values (" );
-
- Enumeration columnNames = updateValues.keys();
- int numColumns = updateValues.size();
-
- for ( int i=0; columnNames.hasMoreElements() ; i++ )
- {
- String columnName = (String)columnNames.nextElement();
-
- insertSQL.append( columnName );
- if ( i < numColumns - 1 )
- {
- insertSQL.append(", ");
- paramSQL.append("?,");
- }
- else
- {
- paramSQL.append("?)");
- }
-
- }
-
- insertSQL.append(paramSQL.toString());
- insertStatement = ((java.sql.Connection)connection).prepareStatement(insertSQL.toString());
-
- Enumeration keys = updateValues.keys();
-
- for( int i=1; keys.hasMoreElements() ; i++)
- {
- String key = (String)keys.nextElement();
- insertStatement.setObject(i, updateValues.get( key ) );
- }
-
- insertStatement.executeUpdate();
-
- if ( usingOID )
- {
- // we have to get the last inserted OID and put it in the resultset
-
- long insertedOID = ((org.postgresql.Statement)insertStatement).getLastOID();
-
- updateValues.put("oid", new Long(insertedOID) );
-
- }
-
- // update the underlying row to the new inserted data
- updateRowBuffer();
-
- rows.addElement(rowBuffer);
-
- // we should now reflect the current data in this_row
- // that way getXXX will get the newly inserted data
- this_row = rowBuffer;
-
- // need to clear this in case of another insert
- clearRowBuffer();
-
-
- }
- }
-
-
- /**
- *
- * @throws SQLException
- */
-
- public synchronized void moveToCurrentRow() throws SQLException
- {
- this_row = (byte [][])rows.elementAt(current_row);
-
- rowBuffer=new byte[this_row.length][];
- System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
-
- onInsertRow = false;
- doingUpdates = false;
- }
-
- /**
- *
- * @throws SQLException
- */
- public synchronized void moveToInsertRow() throws SQLException
- {
- // only sub-classes implement CONCURuPDATEABLE
- if (!updateable)
- {
- throw new PSQLException( "postgresql.updateable.notupdateable" );
- }
-
- if (insertStatement != null)
- {
- insertStatement = null;
- }
-
-
- // make sure the underlying data is null
- clearRowBuffer();
-
- onInsertRow = true;
- doingUpdates = false;
-
- }
-
- /**
- *
- * @throws SQLException
- */
- private synchronized void clearRowBuffer() throws SQLException
- {
- // rowBuffer is the temporary storage for the row
- rowBuffer=new byte[fields.length][];
-
- // clear the updateValues hashTable for the next set of updates
- updateValues.clear();
-
- }
-
-
- /**
- *
- * @return
- * @throws SQLException
- */
- public boolean rowDeleted() throws SQLException
- {
- // only sub-classes implement CONCURuPDATEABLE
- throw Driver.notImplemented();
- }
-
- /**
- *
- * @return
- * @throws SQLException
- */
- public boolean rowInserted() throws SQLException
- {
- // only sub-classes implement CONCURuPDATEABLE
- throw Driver.notImplemented();
- }
-
- /**
- *
- * @return
- * @throws SQLException
- */
- public boolean rowUpdated() throws SQLException
- {
- // only sub-classes implement CONCURuPDATEABLE
- throw Driver.notImplemented();
- }
-
- /**
- *
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- */
- public synchronized void updateAsciiStream(int columnIndex,
- java.io.InputStream x,
- int length
- ) throws SQLException
- {
-
- byte[] theData=null;
-
- try
- {
- x.read(theData,0,length);
- }
- catch (NullPointerException ex )
- {
- throw new PSQLException("postgresql.updateable.inputstream");
- }
- catch (IOException ie)
- {
- throw new PSQLException("postgresql.updateable.ioerror" + ie);
- }
-
- doingUpdates = !onInsertRow;
-
- updateValues.put( fields[columnIndex-1].getName(), theData );
-
- }
-
- /**
- *
- * @param columnIndex
- * @param x
- * @throws SQLException
- */
- public synchronized void updateBigDecimal(int columnIndex,
- java.math.BigDecimal x )
- throws SQLException
- {
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), x );
-
- }
-
- /**
- *
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- */
- public synchronized void updateBinaryStream(int columnIndex,
- java.io.InputStream x,
- int length
- ) throws SQLException
- {
-
-
- byte[] theData=null;
-
- try {
- x.read(theData,0,length);
-
- }
- catch( NullPointerException ex )
- {
- throw new PSQLException("postgresql.updateable.inputstream");
- }
- catch (IOException ie)
- {
- throw new PSQLException("postgresql.updateable.ioerror" + ie);
- }
-
- doingUpdates = !onInsertRow;
-
- updateValues.put( fields[columnIndex-1].getName(), theData );
-
- }
-
- /**
- *
- * @param columnIndex
- * @param x
- * @throws SQLException
- */
- public synchronized void updateBoolean(int columnIndex, boolean x) throws SQLException
- {
-
- if ( Driver.logDebug ) Driver.debug("updating boolean "+fields[columnIndex-1].getName()+"="+x);
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), new Boolean(x) );
-
- }
-
- /**
- *
- * @param columnIndex
- * @param x
- * @throws SQLException
- */
- public synchronized void updateByte(int columnIndex, byte x) throws SQLException
- {
-
- doingUpdates = true;
- updateValues.put( fields[columnIndex-1].getName(), String.valueOf(x) );
- }
-
- /**
- *
- * @param columnIndex
- * @param x
- * @throws SQLException
- */
- public synchronized void updateBytes(int columnIndex, byte[] x) throws SQLException
- {
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), x );
-
- }
-
- /**
- *
- * @param columnIndex
- * @param x
- * @param length
- * @throws SQLException
- */
- public synchronized void updateCharacterStream(int columnIndex,
- java.io.Reader x,
- int length
- ) throws SQLException
- {
-
-
- char[] theData=null;
-
- try
- {
- x.read(theData,0,length);
-
- }
- catch (NullPointerException ex)
- {
- throw new PSQLException("postgresql.updateable.inputstream");
- }
- catch (IOException ie)
- {
- throw new PSQLException("postgresql.updateable.ioerror" + ie);
- }
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), theData);
-
- }
-
- public synchronized void updateDate(int columnIndex, java.sql.Date x) throws SQLException
- {
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), x );
- }
-
- public synchronized void updateDouble(int columnIndex, double x) throws SQLException
- {
- if ( Driver.logDebug ) Driver.debug("updating double "+fields[columnIndex-1].getName()+"="+x);
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), new Double(x) );
-
- }
-
- public synchronized void updateFloat(int columnIndex, float x) throws SQLException
- {
- if ( Driver.logDebug ) Driver.debug("updating float "+fields[columnIndex-1].getName()+"="+x);
-
- doingUpdates = !onInsertRow;
-
- updateValues.put( fields[columnIndex-1].getName(), new Float(x) );
-
- }
-
- public synchronized void updateInt(int columnIndex, int x) throws SQLException
- {
- if ( Driver.logDebug ) Driver.debug("updating int "+fields[columnIndex-1].getName()+"="+x);
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), new Integer(x) );
-
- }
-
- public synchronized void updateLong(int columnIndex, long x) throws SQLException
- {
- if ( Driver.logDebug ) Driver.debug("updating long "+fields[columnIndex-1].getName()+"="+x);
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), new Long(x) );
-
- }
-
- public synchronized void updateNull(int columnIndex) throws SQLException
- {
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), null);
-
-
- }
-
- public synchronized void updateObject(int columnIndex, Object x) throws SQLException
- {
-
-
- if ( Driver.logDebug ) Driver.debug("updating object " + fields[columnIndex-1].getName() + " = " + x);
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), x );
- }
-
- public synchronized void updateObject(int columnIndex, Object x, int scale) throws SQLException
- {
-
- this.updateObject(columnIndex, x);
-
- }
-
-
- public void refreshRow() throws SQLException
- {
- if ( !isUpdateable() )
- {
- throw new PSQLException( "postgresql.updateable.notupdateable" );
- }
-
- try
- {
- StringBuffer selectSQL = new StringBuffer( "select ");
-
- final int numColumns = java.lang.reflect.Array.getLength(fields);
-
- for (int i=0; i < numColumns ; i++ )
- {
-
- selectSQL.append( fields[i].getName() );
-
- if ( i < numColumns - 1 )
- {
-
- selectSQL.append(", ");
- }
-
- }
- selectSQL.append(" from " ).append(tableName).append(" where ");
-
- int numKeys = primaryKeys.size();
-
- for ( int i = 0; i < numKeys; i++ )
- {
-
- PrimaryKey primaryKey = ((PrimaryKey)primaryKeys.get(i));
- selectSQL.append(primaryKey.name).append("= ?");
-
- if ( i < numKeys -1 )
- {
- selectSQL.append(" and ");
- }
- }
- if ( Driver.logDebug ) Driver.debug("selecting "+ selectSQL.toString());
- selectStatement = ((java.sql.Connection)connection).prepareStatement(selectSQL.toString());
-
-
- for( int j=0, i=1; j < numKeys; j++, i++)
- {
- selectStatement.setObject( i, ((PrimaryKey)primaryKeys.get(j)).getValue() );
- }
-
- org.postgresql.jdbc2.ResultSet rs = (org.postgresql.jdbc2.ResultSet) selectStatement.executeQuery();
-
- if( rs.first() )
- {
- rowBuffer = rs.rowBuffer;
- }
-
- rows.setElementAt( rowBuffer, current_row );
- if ( Driver.logDebug ) Driver.debug("done updates");
-
- rs.close();
- selectStatement.close();
- selectStatement = null;
-
- }
- catch (Exception e)
- {
- if ( Driver.logDebug ) Driver.debug(e.getClass().getName()+e);
- throw new SQLException( e.getMessage() );
- }
-
- }
- /**
- *
- * @throws SQLException
- */
- public synchronized void updateRow() throws SQLException
- {
- if ( !isUpdateable() )
- {
- throw new PSQLException( "postgresql.updateable.notupdateable" );
- }
-
- if (doingUpdates)
- {
-
- try
- {
-
- StringBuffer updateSQL=new StringBuffer("UPDATE "+tableName+" SET ");
-
- int numColumns = updateValues.size();
- Enumeration columns = updateValues.keys();
-
- for (int i=0; columns.hasMoreElements() ; i++ )
- {
-
- String column = (String)columns.nextElement();
- updateSQL.append( column + "= ?");
-
- if ( i < numColumns - 1 )
- {
-
- updateSQL.append(", ");
- }
-
- }
- updateSQL.append( " WHERE " );
-
- int numKeys = primaryKeys.size();
-
- for ( int i = 0; i < numKeys; i++ )
- {
-
- PrimaryKey primaryKey = ((PrimaryKey)primaryKeys.get(i));
- updateSQL.append(primaryKey.name).append("= ?");
-
- if ( i < numKeys -1 )
- {
- updateSQL.append(" and ");
- }
- }
- if ( Driver.logDebug ) Driver.debug("updating "+updateSQL.toString());
- updateStatement = ((java.sql.Connection)connection).prepareStatement(updateSQL.toString());
-
- int i = 0;
- Iterator iterator = updateValues.values().iterator();
- for (; iterator.hasNext(); i++)
- {
- updateStatement.setObject( i+1, iterator.next() );
-
- }
- for( int j=0; j < numKeys; j++, i++)
- {
- updateStatement.setObject( i+1, ((PrimaryKey)primaryKeys.get(j)).getValue() );
- }
-
- updateStatement.executeUpdate();
- updateStatement.close();
-
- updateStatement = null;
- updateRowBuffer();
-
-
- if ( Driver.logDebug ) Driver.debug("copying data");
- System.arraycopy(rowBuffer,0,this_row,0,rowBuffer.length);
-
- rows.setElementAt( rowBuffer, current_row );
- if ( Driver.logDebug ) Driver.debug("done updates");
-
- doingUpdates = false;
- }
- catch(Exception e)
- {
- if ( Driver.logDebug ) Driver.debug(e.getClass().getName()+e);
- throw new SQLException( e.getMessage() );
- }
-
- }
-
- }
-
- public synchronized void updateShort(int columnIndex, short x) throws SQLException
- {
- if ( Driver.logDebug ) Driver.debug("in update Short "+fields[columnIndex-1].getName()+" = "+x);
-
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), new Short(x) );
-
- }
-
- public synchronized void updateString(int columnIndex, String x) throws SQLException
- {
- if ( Driver.logDebug ) Driver.debug("in update String "+fields[columnIndex-1].getName()+" = "+x);
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), x );
-
- }
-
- public synchronized void updateTime(int columnIndex, Time x) throws SQLException
- {
- if ( Driver.logDebug ) Driver.debug("in update Time "+fields[columnIndex-1].getName()+" = "+x);
-
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), x );
-
- }
-
- public synchronized void updateTimestamp(int columnIndex, Timestamp x) throws SQLException
- {
- if ( Driver.logDebug ) Driver.debug("updating Timestamp "+fields[columnIndex-1].getName()+" = "+x);
-
- doingUpdates = !onInsertRow;
- updateValues.put( fields[columnIndex-1].getName(), x );
-
-
- }
-
- public synchronized void updateNull(String columnName) throws SQLException
- {
- updateNull(findColumn(columnName));
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a boolean value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateBoolean(String columnName, boolean x) throws SQLException
- {
- updateBoolean(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a byte value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateByte(String columnName, byte x) throws SQLException
- {
- updateByte(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a short value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateShort(String columnName, short x) throws SQLException
- {
- updateShort(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with an integer value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateInt(String columnName, int x) throws SQLException
- {
- updateInt(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a long value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateLong(String columnName, long x) throws SQLException
- {
- updateLong(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a float value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateFloat(String columnName, float x) throws SQLException
- {
- updateFloat(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a double value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateDouble(String columnName, double x) throws SQLException
- {
- updateDouble(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a BigDecimal value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateBigDecimal(String columnName, BigDecimal x)
- throws SQLException
- {
- updateBigDecimal(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a String value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateString(String columnName, String x) throws SQLException
- {
- updateString(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a byte array value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateBytes(String columnName, byte x[]) throws SQLException
- {
- updateBytes(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a Date value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateDate(String columnName, java.sql.Date x)
- throws SQLException
- {
- updateDate(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a Time value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateTime(String columnName, java.sql.Time x)
- throws SQLException
- {
- updateTime(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a Timestamp value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateTimestamp(String columnName, java.sql.Timestamp x)
- throws SQLException
- {
- updateTimestamp(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with an ascii stream value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @param length of the stream
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateAsciiStream(
- String columnName,
- java.io.InputStream x,
- int length)
- throws SQLException
- {
- updateAsciiStream(findColumn(columnName), x, length);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a binary stream value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @param length of the stream
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateBinaryStream(
- String columnName,
- java.io.InputStream x,
- int length)
- throws SQLException
- {
- updateBinaryStream(findColumn(columnName), x, length);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with a character stream value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @param length of the stream
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateCharacterStream(
- String columnName,
- java.io.Reader reader,
- int length)
- throws SQLException
- {
- updateCharacterStream(findColumn(columnName), reader,length);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with an Object value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @param scale For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types
- * this is the number of digits after the decimal. For all other
- * types this value will be ignored.
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateObject(String columnName, Object x, int scale)
- throws SQLException
- {
- updateObject(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0
- *
- * Update a column with an Object value.
- *
- * The updateXXX() methods are used to update column values in the
- * current row, or the insert row. The updateXXX() methods do not
- * update the underlying database, instead the updateRow() or insertRow()
- * methods are called to update the database.
- *
- * @param columnName the name of the column
- * @param x the new column value
- * @exception SQLException if a database-access error occurs
- */
-
- public synchronized void updateObject(String columnName, Object x) throws SQLException
- {
- updateObject(findColumn(columnName), x);
- }
-
-
-
- private int _findColumn( String columnName )
- {
- int i;
-
- final int flen = fields.length;
- for (i = 0 ; i < flen; ++i)
- {
- if (fields[i].getName().equalsIgnoreCase(columnName))
- {
- return (i + 1);
- }
- }
- return -1;
- }
-
-
- /**
- * Is this ResultSet updateable?
- */
-
- boolean isUpdateable() throws SQLException
- {
-
- if (updateable) return true;
-
- if ( Driver.logDebug ) Driver.debug("checking if rs is updateable");
-
- parseQuery();
-
- if ( singleTable == false )
- {
- if ( Driver.logDebug ) Driver.debug("not a single table");
- return false;
- }
-
- if ( Driver.logDebug ) Driver.debug("getting primary keys");
-
- //
- // Contains the primary key?
- //
-
- primaryKeys = new Vector();
-
- // this is not stricty jdbc spec, but it will make things much faster if used
- // the user has to select oid, * from table and then we will just use oid
-
-
- usingOID = false;
- int oidIndex = _findColumn( "oid" );
- int i = 0;
-
-
- // if we find the oid then just use it
-
- if ( oidIndex > 0 )
- {
- i++;
- primaryKeys.add( new PrimaryKey( oidIndex, "oid" ) );
- usingOID = true;
- }
- else
- {
- // otherwise go and get the primary keys and create a hashtable of keys
- java.sql.ResultSet rs = ((org.postgresql.jdbc2.Connection)connection).getMetaData().getPrimaryKeys("","",tableName);
-
-
- for( ; rs.next(); i++ )
- {
- String columnName = rs.getString(4); // get the columnName
-
- int index = findColumn( columnName );
-
- if ( index > 0 )
- {
- primaryKeys.add( new PrimaryKey(index, columnName ) ); // get the primary key information
- }
- }
-
- rs.close();
- }
-
- numKeys = primaryKeys.size();
-
- if ( Driver.logDebug ) Driver.debug( "no of keys=" + i );
-
- if ( i < 1 )
- {
- throw new SQLException("No Primary Keys");
- }
-
- updateable = primaryKeys.size() > 0;
-
- if ( Driver.logDebug ) Driver.debug( "checking primary key " + updateable );
-
- return updateable;
- }
-
-
- /**
- *
- */
- public void parseQuery()
- {
- StringTokenizer st=new StringTokenizer(sqlQuery," \r\t");
- boolean tableFound=false, tablesChecked = false;
- String name="";
-
- singleTable = true;
-
- while ( !tableFound && !tablesChecked && st.hasMoreTokens() )
- {
- name=st.nextToken();
- if ( !tableFound )
- {
- if (name.toLowerCase().equals("from"))
- {
- tableName=st.nextToken();
- tableFound=true;
- }
- }
- else
- {
- tablesChecked = true;
- // if the very next token is , then there are multiple tables
- singleTable = !name.equalsIgnoreCase(",");
- }
- }
- }
-
-
- private void updateRowBuffer() throws SQLException
- {
-
- Enumeration columns = updateValues.keys();
-
- while( columns.hasMoreElements() )
- {
- String columnName = (String)columns.nextElement();
- int columnIndex = _findColumn( columnName ) - 1;
-
- switch ( connection.getSQLType( fields[columnIndex].getPGType() ) )
- {
-
- case Types.DECIMAL:
- case Types.BIGINT:
- case Types.DOUBLE:
- case Types.BIT:
- case Types.VARCHAR:
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- case Types.SMALLINT:
- case Types.FLOAT:
- case Types.INTEGER:
- case Types.CHAR:
- case Types.NUMERIC:
- case Types.REAL:
- case Types.TINYINT:
-
- try
- {
- rowBuffer[columnIndex] = String.valueOf( updateValues.get( columnName ) ).getBytes(connection.getEncoding().name() );
- }
- catch ( UnsupportedEncodingException ex)
- {
- throw new SQLException("Unsupported Encoding "+connection.getEncoding().name());
- }
- case Types.NULL:
- continue;
- default:
- rowBuffer[columnIndex] = (byte [])updateValues.get( columnName );
- }
-
- }
- }
-
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/largeobject/BlobInputStream.java b/src/interfaces/jdbc/org/postgresql/largeobject/BlobInputStream.java
deleted file mode 100644
index 0e508cfd32c..00000000000
--- a/src/interfaces/jdbc/org/postgresql/largeobject/BlobInputStream.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package org.postgresql.largeobject;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.sql.SQLException;
-
-/*
- * This is an initial implementation of an InputStream from a large object.
- * For now, the bare minimum is implemented. Later (after 7.1) we will overide
- * the other read methods to optimise them.
- */
-public class BlobInputStream extends InputStream
-{
- /*
- * The parent LargeObject
- */
- private LargeObject lo;
-
- /*
- * Buffer used to improve performance
- */
- private byte[] buffer;
-
- /*
- * Position within buffer
- */
- private int bpos;
-
- /*
- * The buffer size
- */
- private int bsize;
-
- /*
- * The mark position
- */
- private int mpos = 0;
-
- /*
- * @param lo LargeObject to read from
- */
- public BlobInputStream(LargeObject lo)
- {
- this(lo, 1024);
- }
-
- /*
- * @param lo LargeObject to read from
- * @param bsize buffer size
- */
- public BlobInputStream(LargeObject lo, int bsize)
- {
- this.lo = lo;
- buffer = null;
- bpos = 0;
- this.bsize = bsize;
- }
-
- /*
- * The minimum required to implement input stream
- */
- public int read() throws java.io.IOException
- {
- try
- {
- if (buffer == null || bpos >= buffer.length)
- {
- buffer = lo.read(bsize);
- bpos = 0;
- }
-
- // Handle EOF
- if (bpos >= buffer.length)
- {
- return -1;
- }
-
- int ret = (buffer[bpos] & 0x7F);
- if ((buffer[bpos] &0x80) == 0x80)
- {
- ret |= 0x80;
- }
-
- bpos++;
-
- return ret;
- }
- catch (SQLException se)
- {
- throw new IOException(se.toString());
- }
- }
-
-
- /*
- * Closes this input stream and releases any system resources associated
- * with the stream.
- *
- * <p> The <code>close</code> method of <code>InputStream</code> does
- * nothing.
- *
- * @exception IOException if an I/O error occurs.
- */
- public void close() throws IOException
- {
- try
- {
- lo.close();
- lo = null;
- }
- catch (SQLException se)
- {
- throw new IOException(se.toString());
- }
- }
-
- /*
- * Marks the current position in this input stream. A subsequent call to
- * the <code>reset</code> method repositions this stream at the last marked
- * position so that subsequent reads re-read the same bytes.
- *
- * <p> The <code>readlimit</code> arguments tells this input stream to
- * allow that many bytes to be read before the mark position gets
- * invalidated.
- *
- * <p> The general contract of <code>mark</code> is that, if the method
- * <code>markSupported</code> returns <code>true</code>, the stream somehow
- * remembers all the bytes read after the call to <code>mark</code> and
- * stands ready to supply those same bytes again if and whenever the method
- * <code>reset</code> is called. However, the stream is not required to
- * remember any data at all if more than <code>readlimit</code> bytes are
- * read from the stream before <code>reset</code> is called.
- *
- * <p> The <code>mark</code> method of <code>InputStream</code> does
- * nothing.
- *
- * @param readlimit the maximum limit of bytes that can be read before
- * the mark position becomes invalid.
- * @see java.io.InputStream#reset()
- */
- public synchronized void mark(int readlimit)
- {
- try
- {
- mpos = lo.tell();
- }
- catch (SQLException se)
- {
- //throw new IOException(se.toString());
- }
- }
-
- /*
- * Repositions this stream to the position at the time the
- * <code>mark</code> method was last called on this input stream.
- * NB: If mark is not called we move to the begining.
- * @see java.io.InputStream#mark(int)
- * @see java.io.IOException
- */
- public synchronized void reset()
- throws IOException
- {
- try
- {
- lo.seek(mpos);
- }
- catch (SQLException se)
- {
- throw new IOException(se.toString());
- }
- }
-
- /*
- * Tests if this input stream supports the <code>mark</code> and
- * <code>reset</code> methods. The <code>markSupported</code> method of
- * <code>InputStream</code> returns <code>false</code>.
- *
- * @return <code>true</code> if this true type supports the mark and reset
- * method; <code>false</code> otherwise.
- * @see java.io.InputStream#mark(int)
- * @see java.io.InputStream#reset()
- */
- public boolean markSupported()
- {
- return true;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/largeobject/BlobOutputStream.java b/src/interfaces/jdbc/org/postgresql/largeobject/BlobOutputStream.java
deleted file mode 100644
index b56de6e5430..00000000000
--- a/src/interfaces/jdbc/org/postgresql/largeobject/BlobOutputStream.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.postgresql.largeobject;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.sql.SQLException;
-
-/*
- * This implements a basic output stream that writes to a LargeObject
- */
-public class BlobOutputStream extends OutputStream
-{
- /*
- * The parent LargeObject
- */
- private LargeObject lo;
-
- /*
- * Buffer
- */
- private byte buf[];
-
- /*
- * Size of the buffer (default 1K)
- */
- private int bsize;
-
- /*
- * Position within the buffer
- */
- private int bpos;
-
- /*
- * Create an OutputStream to a large object
- * @param lo LargeObject
- */
- public BlobOutputStream(LargeObject lo)
- {
- this(lo, 1024);
- }
-
- /*
- * Create an OutputStream to a large object
- * @param lo LargeObject
- * @param bsize The size of the buffer used to improve performance
- */
- public BlobOutputStream(LargeObject lo, int bsize)
- {
- this.lo = lo;
- this.bsize = bsize;
- buf = new byte[bsize];
- bpos = 0;
- }
-
- public void write(int b) throws java.io.IOException
- {
- try
- {
- if (bpos >= bsize)
- {
- lo.write(buf);
- bpos = 0;
- }
- buf[bpos++] = (byte)b;
- }
- catch (SQLException se)
- {
- throw new IOException(se.toString());
- }
- }
-
- /*
- * Flushes this output stream and forces any buffered output bytes
- * to be written out. The general contract of <code>flush</code> is
- * that calling it is an indication that, if any bytes previously
- * written have been buffered by the implementation of the output
- * stream, such bytes should immediately be written to their
- * intended destination.
- *
- * @exception IOException if an I/O error occurs.
- */
- public void flush() throws IOException
- {
- try
- {
- if (bpos > 0)
- lo.write(buf, 0, bpos);
- bpos = 0;
- }
- catch (SQLException se)
- {
- throw new IOException(se.toString());
- }
- }
-
- /*
- * Closes this output stream and releases any system resources
- * associated with this stream. The general contract of <code>close</code>
- * is that it closes the output stream. A closed stream cannot perform
- * output operations and cannot be reopened.
- * <p>
- * The <code>close</code> method of <code>OutputStream</code> does nothing.
- *
- * @exception IOException if an I/O error occurs.
- */
- public void close() throws IOException
- {
- try
- {
- flush();
- lo.close();
- lo = null;
- }
- catch (SQLException se)
- {
- throw new IOException(se.toString());
- }
- }
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/largeobject/LargeObject.java b/src/interfaces/jdbc/org/postgresql/largeobject/LargeObject.java
deleted file mode 100644
index f5eab8310f7..00000000000
--- a/src/interfaces/jdbc/org/postgresql/largeobject/LargeObject.java
+++ /dev/null
@@ -1,320 +0,0 @@
-package org.postgresql.largeobject;
-
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-
-import org.postgresql.fastpath.*;
-
-/*
- * This class implements the large object interface to org.postgresql.
- *
- * <p>It provides the basic methods required to run the interface, plus
- * a pair of methods that provide InputStream and OutputStream classes
- * for this object.
- *
- * <p>Normally, client code would use the getAsciiStream, getBinaryStream,
- * or getUnicodeStream methods in ResultSet, or setAsciiStream,
- * setBinaryStream, or setUnicodeStream methods in PreparedStatement to
- * access Large Objects.
- *
- * <p>However, sometimes lower level access to Large Objects are required,
- * that are not supported by the JDBC specification.
- *
- * <p>Refer to org.postgresql.largeobject.LargeObjectManager on how to gain access
- * to a Large Object, or how to create one.
- *
- * @see org.postgresql.largeobject.LargeObjectManager
- * @see org.postgresql.ResultSet#getAsciiStream
- * @see org.postgresql.ResultSet#getBinaryStream
- * @see org.postgresql.ResultSet#getUnicodeStream
- * @see org.postgresql.PreparedStatement#setAsciiStream
- * @see org.postgresql.PreparedStatement#setBinaryStream
- * @see org.postgresql.PreparedStatement#setUnicodeStream
- * @see java.sql.ResultSet#getAsciiStream
- * @see java.sql.ResultSet#getBinaryStream
- * @see java.sql.ResultSet#getUnicodeStream
- * @see java.sql.PreparedStatement#setAsciiStream
- * @see java.sql.PreparedStatement#setBinaryStream
- * @see java.sql.PreparedStatement#setUnicodeStream
- *
- */
-public class LargeObject
-{
- /*
- * Indicates a seek from the begining of a file
- */
- public static final int SEEK_SET = 0;
-
- /*
- * Indicates a seek from the current position
- */
- public static final int SEEK_CUR = 1;
-
- /*
- * Indicates a seek from the end of a file
- */
- public static final int SEEK_END = 2;
-
- private Fastpath fp; // Fastpath API to use
- private int oid; // OID of this object
- private int fd; // the descriptor of the open large object
-
- private BlobOutputStream os; // The current output stream
-
- private boolean closed = false; // true when we are closed
-
- /*
- * This opens a large object.
- *
- * <p>If the object does not exist, then an SQLException is thrown.
- *
- * @param fp FastPath API for the connection to use
- * @param oid of the Large Object to open
- * @param mode Mode of opening the large object
- * (defined in LargeObjectManager)
- * @exception SQLException if a database-access error occurs.
- * @see org.postgresql.largeobject.LargeObjectManager
- */
- protected LargeObject(Fastpath fp, int oid, int mode) throws SQLException
- {
- this.fp = fp;
- this.oid = oid;
-
- FastpathArg args[] = new FastpathArg[2];
- args[0] = new FastpathArg(oid);
- args[1] = new FastpathArg(mode);
- this.fd = fp.getInteger("lo_open", args);
- }
-
- /* Release large object resources during garbage cleanup */
- protected void finalize() throws SQLException
- {
- close();
- }
-
- /*
- * @return the OID of this LargeObject
- */
- public int getOID()
- {
- return oid;
- }
-
- /*
- * This method closes the object. You must not call methods in this
- * object after this is called.
- * @exception SQLException if a database-access error occurs.
- */
- public void close() throws SQLException
- {
- if (!closed)
- {
- // flush any open output streams
- if (os != null)
- {
- try
- {
- // we can't call os.close() otherwise we go into an infinite loop!
- os.flush();
- }
- catch (IOException ioe)
- {
- throw new SQLException(ioe.getMessage());
- }
- finally
- {
- os = null;
- }
- }
-
- // finally close
- FastpathArg args[] = new FastpathArg[1];
- args[0] = new FastpathArg(fd);
- fp.fastpath("lo_close", false, args); // true here as we dont care!!
- closed = true;
- }
- }
-
- /*
- * Reads some data from the object, and return as a byte[] array
- *
- * @param len number of bytes to read
- * @return byte[] array containing data read
- * @exception SQLException if a database-access error occurs.
- */
- public byte[] read(int len) throws SQLException
- {
- // This is the original method, where the entire block (len bytes)
- // is retrieved in one go.
- FastpathArg args[] = new FastpathArg[2];
- args[0] = new FastpathArg(fd);
- args[1] = new FastpathArg(len);
- return fp.getData("loread", args);
-
- // This version allows us to break this down into 4k blocks
- //if (len<=4048) {
- //// handle as before, return the whole block in one go
- //FastpathArg args[] = new FastpathArg[2];
- //args[0] = new FastpathArg(fd);
- //args[1] = new FastpathArg(len);
- //return fp.getData("loread",args);
- //} else {
- //// return in 4k blocks
- //byte[] buf=new byte[len];
- //int off=0;
- //while (len>0) {
- //int bs=4048;
- //len-=bs;
- //if (len<0) {
- //bs+=len;
- //len=0;
- //}
- //read(buf,off,bs);
- //off+=bs;
- //}
- //return buf;
- //}
- }
-
- /*
- * Reads some data from the object into an existing array
- *
- * @param buf destination array
- * @param off offset within array
- * @param len number of bytes to read
- * @return the number of bytes actually read
- * @exception SQLException if a database-access error occurs.
- */
- public int read(byte buf[], int off, int len) throws SQLException
- {
- byte b[] = read(len);
- if (b.length < len)
- len = b.length;
- System.arraycopy(b, 0, buf, off, len);
- return len;
- }
-
- /*
- * Writes an array to the object
- *
- * @param buf array to write
- * @exception SQLException if a database-access error occurs.
- */
- public void write(byte buf[]) throws SQLException
- {
- FastpathArg args[] = new FastpathArg[2];
- args[0] = new FastpathArg(fd);
- args[1] = new FastpathArg(buf);
- fp.fastpath("lowrite", false, args);
- }
-
- /*
- * Writes some data from an array to the object
- *
- * @param buf destination array
- * @param off offset within array
- * @param len number of bytes to write
- * @exception SQLException if a database-access error occurs.
- */
- public void write(byte buf[], int off, int len) throws SQLException
- {
- byte data[] = new byte[len];
- System.arraycopy(buf, off, data, 0, len);
- write(data);
- }
-
- /*
- * Sets the current position within the object.
- *
- * <p>This is similar to the fseek() call in the standard C library. It
- * allows you to have random access to the large object.
- *
- * @param pos position within object
- * @param ref Either SEEK_SET, SEEK_CUR or SEEK_END
- * @exception SQLException if a database-access error occurs.
- */
- public void seek(int pos, int ref) throws SQLException
- {
- FastpathArg args[] = new FastpathArg[3];
- args[0] = new FastpathArg(fd);
- args[1] = new FastpathArg(pos);
- args[2] = new FastpathArg(ref);
- fp.fastpath("lo_lseek", false, args);
- }
-
- /*
- * Sets the current position within the object.
- *
- * <p>This is similar to the fseek() call in the standard C library. It
- * allows you to have random access to the large object.
- *
- * @param pos position within object from begining
- * @exception SQLException if a database-access error occurs.
- */
- public void seek(int pos) throws SQLException
- {
- seek(pos, SEEK_SET);
- }
-
- /*
- * @return the current position within the object
- * @exception SQLException if a database-access error occurs.
- */
- public int tell() throws SQLException
- {
- FastpathArg args[] = new FastpathArg[1];
- args[0] = new FastpathArg(fd);
- return fp.getInteger("lo_tell", args);
- }
-
- /*
- * This method is inefficient, as the only way to find out the size of
- * the object is to seek to the end, record the current position, then
- * return to the original position.
- *
- * <p>A better method will be found in the future.
- *
- * @return the size of the large object
- * @exception SQLException if a database-access error occurs.
- */
- public int size() throws SQLException
- {
- int cp = tell();
- seek(0, SEEK_END);
- int sz = tell();
- seek(cp, SEEK_SET);
- return sz;
- }
-
- /*
- * Returns an InputStream from this object.
- *
- * <p>This InputStream can then be used in any method that requires an
- * InputStream.
- *
- * @exception SQLException if a database-access error occurs.
- */
- public InputStream getInputStream() throws SQLException
- {
- return new BlobInputStream(this);
- }
-
- /*
- * Returns an OutputStream to this object
- *
- * <p>This OutputStream can then be used in any method that requires an
- * OutputStream.
- *
- * @exception SQLException if a database-access error occurs.
- */
- public OutputStream getOutputStream() throws SQLException
- {
- if (os == null)
- os = new BlobOutputStream(this);
- return os;
- }
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java b/src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java
deleted file mode 100644
index e5296189cdc..00000000000
--- a/src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java
+++ /dev/null
@@ -1,206 +0,0 @@
-package org.postgresql.largeobject;
-
-import org.postgresql.Driver;
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-
-import org.postgresql.fastpath.*;
-import org.postgresql.util.*;
-
-/*
- * This class implements the large object interface to org.postgresql.
- *
- * <p>It provides methods that allow client code to create, open and delete
- * large objects from the database. When opening an object, an instance of
- * org.postgresql.largeobject.LargeObject is returned, and its methods then allow
- * access to the object.
- *
- * <p>This class can only be created by org.postgresql.Connection
- *
- * <p>To get access to this class, use the following segment of code:
- * <br><pre>
- * import org.postgresql.largeobject.*;
- *
- * Connection conn;
- * LargeObjectManager lobj;
- *
- * ... code that opens a connection ...
- *
- * lobj = ((org.postgresql.Connection)myconn).getLargeObjectAPI();
- * </pre>
- *
- * <p>Normally, client code would use the getAsciiStream, getBinaryStream,
- * or getUnicodeStream methods in ResultSet, or setAsciiStream,
- * setBinaryStream, or setUnicodeStream methods in PreparedStatement to
- * access Large Objects.
- *
- * <p>However, sometimes lower level access to Large Objects are required,
- * that are not supported by the JDBC specification.
- *
- * <p>Refer to org.postgresql.largeobject.LargeObject on how to manipulate the
- * contents of a Large Object.
- *
- * @see org.postgresql.largeobject.LargeObject
- * @see org.postgresql.ResultSet#getAsciiStream
- * @see org.postgresql.ResultSet#getBinaryStream
- * @see org.postgresql.ResultSet#getUnicodeStream
- * @see org.postgresql.PreparedStatement#setAsciiStream
- * @see org.postgresql.PreparedStatement#setBinaryStream
- * @see org.postgresql.PreparedStatement#setUnicodeStream
- * @see java.sql.ResultSet#getAsciiStream
- * @see java.sql.ResultSet#getBinaryStream
- * @see java.sql.ResultSet#getUnicodeStream
- * @see java.sql.PreparedStatement#setAsciiStream
- * @see java.sql.PreparedStatement#setBinaryStream
- * @see java.sql.PreparedStatement#setUnicodeStream
- */
-public class LargeObjectManager
-{
- // the fastpath api for this connection
- private Fastpath fp;
-
- /*
- * This mode indicates we want to write to an object
- */
- public static final int WRITE = 0x00020000;
-
- /*
- * This mode indicates we want to read an object
- */
- public static final int READ = 0x00040000;
-
- /*
- * This mode is the default. It indicates we want read and write access to
- * a large object
- */
- public static final int READWRITE = READ | WRITE;
-
- /*
- * This prevents us being created by mere mortals
- */
- private LargeObjectManager()
- {}
-
- /*
- * Constructs the LargeObject API.
- *
- * <p><b>Important Notice</b>
- * <br>This method should only be called by org.postgresql.Connection
- *
- * <p>There should only be one LargeObjectManager per Connection. The
- * org.postgresql.Connection class keeps track of the various extension API's
- * and it's advised you use those to gain access, and not going direct.
- */
- public LargeObjectManager(org.postgresql.Connection conn) throws SQLException
- {
- // We need Fastpath to do anything
- this.fp = conn.getFastpathAPI();
-
- // Now get the function oid's for the api
- //
- // This is an example of Fastpath.addFunctions();
- //
- java.sql.ResultSet res = (java.sql.ResultSet)conn.createStatement().executeQuery("select proname, oid from pg_proc" +
- " where proname = 'lo_open'" +
- " or proname = 'lo_close'" +
- " or proname = 'lo_creat'" +
- " or proname = 'lo_unlink'" +
- " or proname = 'lo_lseek'" +
- " or proname = 'lo_tell'" +
- " or proname = 'loread'" +
- " or proname = 'lowrite'");
-
- if (res == null)
- throw new PSQLException("postgresql.lo.init");
-
- fp.addFunctions(res);
- res.close();
- if (Driver.logDebug) Driver.debug("Large Object initialised");
- }
-
- /*
- * This opens an existing large object, based on its OID. This method
- * assumes that READ and WRITE access is required (the default).
- *
- * @param oid of large object
- * @return LargeObject instance providing access to the object
- * @exception SQLException on error
- */
- public LargeObject open(int oid) throws SQLException
- {
- return new LargeObject(fp, oid, READWRITE);
- }
-
- /*
- * This opens an existing large object, based on its OID
- *
- * @param oid of large object
- * @param mode mode of open
- * @return LargeObject instance providing access to the object
- * @exception SQLException on error
- */
- public LargeObject open(int oid, int mode) throws SQLException
- {
- return new LargeObject(fp, oid, mode);
- }
-
- /*
- * This creates a large object, returning its OID.
- *
- * <p>It defaults to READWRITE for the new object's attributes.
- *
- * @return oid of new object
- * @exception SQLException on error
- */
- public int create() throws SQLException
- {
- FastpathArg args[] = new FastpathArg[1];
- args[0] = new FastpathArg(READWRITE);
- return fp.getInteger("lo_creat", args);
- }
-
- /*
- * This creates a large object, returning its OID
- *
- * @param mode a bitmask describing different attributes of the new object
- * @return oid of new object
- * @exception SQLException on error
- */
- public int create(int mode) throws SQLException
- {
- FastpathArg args[] = new FastpathArg[1];
- args[0] = new FastpathArg(mode);
- return fp.getInteger("lo_creat", args);
- }
-
- /*
- * This deletes a large object.
- *
- * @param oid describing object to delete
- * @exception SQLException on error
- */
- public void delete(int oid) throws SQLException
- {
- FastpathArg args[] = new FastpathArg[1];
- args[0] = new FastpathArg(oid);
- fp.fastpath("lo_unlink", false, args);
- }
-
- /*
- * This deletes a large object.
- *
- * <p>It is identical to the delete method, and is supplied as the C API uses
- * unlink.
- *
- * @param oid describing object to delete
- * @exception SQLException on error
- */
- public void unlink(int oid) throws SQLException
- {
- delete(oid);
- }
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/largeobject/PGblob.java b/src/interfaces/jdbc/org/postgresql/largeobject/PGblob.java
deleted file mode 100644
index 12e04e4c14a..00000000000
--- a/src/interfaces/jdbc/org/postgresql/largeobject/PGblob.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.postgresql.largeobject;
-
-// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 1 class in the
-// org.postgresql.jdbc1 package.
-
-
-import java.lang.*;
-import java.io.*;
-import java.math.*;
-import java.text.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.Field;
-import org.postgresql.largeobject.*;
-import org.postgresql.largeobject.*;
-
-/*
- * This implements the Blob interface, which is basically another way to
- * access a LargeObject.
- *
- * $Id: PGblob.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
- *
- */
-public class PGblob implements java.sql.Blob
-{
- private org.postgresql.Connection conn;
- private int oid;
- private LargeObject lo;
-
- public PGblob(org.postgresql.Connection conn, int oid) throws SQLException
- {
- this.conn = conn;
- this.oid = oid;
- LargeObjectManager lom = conn.getLargeObjectAPI();
- this.lo = lom.open(oid);
- }
-
- public long length() throws SQLException
- {
- return lo.size();
- }
-
- public InputStream getBinaryStream() throws SQLException
- {
- return lo.getInputStream();
- }
-
- public byte[] getBytes(long pos, int length) throws SQLException
- {
- lo.seek((int)pos, LargeObject.SEEK_SET);
- return lo.read(length);
- }
-
- /*
- * For now, this is not implemented.
- */
- public long position(byte[] pattern, long start) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /*
- * This should be simply passing the byte value of the pattern Blob
- */
- public long position(Blob pattern, long start) throws SQLException
- {
- return position(pattern.getBytes(0, (int)pattern.length()), start);
- }
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/largeobject/PGclob.java b/src/interfaces/jdbc/org/postgresql/largeobject/PGclob.java
deleted file mode 100644
index 63d39c07b0f..00000000000
--- a/src/interfaces/jdbc/org/postgresql/largeobject/PGclob.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.postgresql.largeobject;
-
-// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
-// If you make any modifications to this file, you must make sure that the
-// changes are also made (if relevent) to the related JDBC 1 class in the
-// org.postgresql.jdbc1 package.
-
-
-import java.lang.*;
-import java.io.*;
-import java.math.*;
-import java.text.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.Field;
-import org.postgresql.largeobject.*;
-import org.postgresql.largeobject.*;
-
-/*
- * This implements the Blob interface, which is basically another way to
- * access a LargeObject.
- *
- * $Id: PGclob.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
- *
- */
-public class PGclob implements java.sql.Clob
-{
- private org.postgresql.Connection conn;
- private int oid;
- private LargeObject lo;
-
- public PGclob(org.postgresql.Connection conn, int oid) throws SQLException
- {
- this.conn = conn;
- this.oid = oid;
- LargeObjectManager lom = conn.getLargeObjectAPI();
- this.lo = lom.open(oid);
- }
-
- public long length() throws SQLException
- {
- return lo.size();
- }
-
- public InputStream getAsciiStream() throws SQLException
- {
- return lo.getInputStream();
- }
-
- public Reader getCharacterStream() throws SQLException
- {
- return new InputStreamReader(lo.getInputStream());
- }
-
- public String getSubString(long i, int j) throws SQLException
- {
- lo.seek((int)i - 1);
- return new String(lo.read(j));
- }
-
- /*
- * For now, this is not implemented.
- */
- public long position(String pattern, long start) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
- /*
- * This should be simply passing the byte value of the pattern Blob
- */
- public long position(Clob pattern, long start) throws SQLException
- {
- throw org.postgresql.Driver.notImplemented();
- }
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java b/src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java
deleted file mode 100644
index bacad690281..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java
+++ /dev/null
@@ -1,234 +0,0 @@
-package org.postgresql.test;
-
-import junit.framework.TestSuite;
-import junit.framework.TestCase;
-
-import org.postgresql.test.jdbc2.*;
-import java.sql.*;
-
-/*
- * Executes all known tests for JDBC2 and includes some utility methods.
- */
-public class JDBC2Tests extends TestSuite
-{
- /*
- * Returns the Test database JDBC URL
- */
- public static String getURL()
- {
- return System.getProperty("database");
- }
-
- /*
- * Returns the Postgresql username
- */
- public static String getUser()
- {
- return System.getProperty("username");
- }
-
- /*
- * Returns the user's password
- */
- public static String getPassword()
- {
- return System.getProperty("password");
- }
-
- /*
- * Helper - opens a connection.
- */
- public static java.sql.Connection openDB()
- {
- try
- {
- Class.forName("org.postgresql.Driver");
- return java.sql.DriverManager.getConnection(JDBC2Tests.getURL(), JDBC2Tests.getUser(), JDBC2Tests.getPassword());
- }
- catch (ClassNotFoundException ex)
- {
- TestCase.fail(ex.getMessage());
- }
- catch (SQLException ex)
- {
- TestCase.fail(ex.getMessage());
- }
- return null;
- }
-
- /*
- * Helper - closes an open connection. This rewrites SQLException to a failed
- * assertion. It's static so other classes can use it.
- */
- public static void closeDB(Connection con)
- {
- try
- {
- if (con != null)
- con.close();
- }
- catch (SQLException ex)
- {
- TestCase.fail(ex.getMessage());
- }
- }
-
- /*
- * Helper - creates a test table for use by a test
- */
- public static void createTable(Connection con,
- String table,
- String columns)
- {
- try
- {
- Statement st = con.createStatement();
- try
- {
- // Drop the table
- dropTable(con, table);
-
- // Now create the table
- st.executeUpdate("create table " + table + " (" + columns + ")");
- }
- finally
- {
- st.close();
- }
- }
- catch (SQLException ex)
- {
- TestCase.fail(ex.getMessage());
- }
- }
-
- /*
- * Helper - drops a table
- */
- public static void dropTable(Connection con, String table)
- {
- try
- {
- Statement stmt = con.createStatement();
- try
- {
- stmt.executeUpdate("DROP TABLE " + table);
- }
- catch (SQLException ex)
- {
- // ignore
- }
- }
- catch (SQLException ex)
- {
- TestCase.fail(ex.getMessage());
- }
- }
-
- /*
- * Helper - generates INSERT SQL - very simple
- */
- public static String insertSQL(String table, String values)
- {
- return insertSQL(table, null, values);
- }
-
- public static String insertSQL(String table, String columns, String values)
- {
- String s = "INSERT INTO " + table;
-
- if (columns != null)
- s = s + " (" + columns + ")";
-
- return s + " VALUES (" + values + ")";
- }
-
- /*
- * Helper - generates SELECT SQL - very simple
- */
- public static String selectSQL(String table, String columns)
- {
- return selectSQL(table, columns, null, null);
- }
-
- public static String selectSQL(String table, String columns, String where)
- {
- return selectSQL(table, columns, where, null);
- }
-
- public static String selectSQL(String table, String columns, String where, String other)
- {
- String s = "SELECT " + columns + " FROM " + table;
-
- if (where != null)
- s = s + " WHERE " + where;
- if (other != null)
- s = s + " " + other;
-
- return s;
- }
-
- /*
- * Helper to prefix a number with leading zeros - ugly but it works...
- * @param v value to prefix
- * @param l number of digits (0-10)
- */
- public static String fix(int v, int l)
- {
- String s = "0000000000".substring(0, l) + Integer.toString(v);
- return s.substring(s.length() - l);
- }
-
- /*
- * The main entry point for JUnit
- */
- public static TestSuite suite()
- {
- TestSuite suite = new TestSuite();
-
- //
- // Add one line per class in our test cases. These should be in order of
- // complexity.
-
- // ANTTest should be first as it ensures that test parameters are
- // being sent to the suite. It also initialises the database (if required)
- // with some simple global tables (will make each testcase use its own later).
- //
- suite.addTestSuite(ANTTest.class);
-
- // Basic Driver internals
- suite.addTestSuite(DriverTest.class);
- suite.addTestSuite(ConnectionTest.class);
- suite.addTestSuite(DatabaseMetaDataTest.class);
- suite.addTestSuite(EncodingTest.class);
-
- // Connectivity/Protocols
-
- // ResultSet
- suite.addTestSuite(ResultSetTest.class);
-
- // Time, Date, Timestamp
- suite.addTestSuite(DateTest.class);
- suite.addTestSuite(TimeTest.class);
- suite.addTestSuite(TimestampTest.class);
-
- // PreparedStatement
-
- // BatchExecute
- suite.addTestSuite(BatchExecuteTest.class);
-
- // MetaData
-
- // Other misc tests, based on previous problems users have had or specific
- // features some applications require.
- suite.addTestSuite(JBuilderTest.class);
- suite.addTestSuite(MiscTest.class);
-
- // Fastpath/LargeObject
- suite.addTestSuite(BlobTest.class);
- suite.addTestSuite( UpdateableResultTest.class );
-
- // That's all folks
- return suite;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/README b/src/interfaces/jdbc/org/postgresql/test/README
deleted file mode 100644
index 27abba33769..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/README
+++ /dev/null
@@ -1,323 +0,0 @@
-PostgreSQL/JDBC Test Suite Howto
-================================
-1 Introduction
-2 Installation
-3 Configuration
-4 Running the test suite
-5 Extending the test suite with new tests
-6 Guidelines for developing new tests
-7 Example
-8 Running the JDBC 2 test suite from Sun against PostgreSQL
-9 Credits, feedback
-
-
-1 Introduction
---------------
-The PostgreSQL source tree contains an automated test suite for
-the JDBC driver. This document explains how to install,
-configure and run this test suite. Furthermore, it offers
-guidelines and an example for developers to add new test cases.
-
-Sun provides two standard JDBC test suites that you may also
-find useful.
-http://java.sun.com/products/jdbc/download2.html (JDBC 1)
-http://java.sun.com/products/jdbc/jdbctestsuite-1_2_1.html (JDBC
-2, including J2EE requirements)
-The JDBC 2 test suite is covered in section 8 below. The JDBC 1
-test suite is not currently covered in this document.
-
-2 Installation
---------------
-Of course, you need to have a Java 2 JDK or JRE installed. The
-standard JDK from Sun is OK. You can download it from
-http://java.sun.com/.
-
-You need to install the Ant build utility. You can download it
-from http://jakarta.apache.org/ant/.
-
-You also need to install the JUnit testing framework. You can
-download it from http://www.junit.org/. Add junit.jar to your
-CLASSPATH before you perform the following steps. Ant will
-dynamically detect that JUnit is present and then build the JDBC
-test suite.
-
-You need to install and build the PostgreSQL source tree. You
-can download it from http://www.postgresql.org/devel-corner/.
-See README and INSTALL in the top of the tree for more
-information.
-
-You should run ./configure with the command line option
---with-java. You may also want to use --with-pgport to compile a
-non-standard default port number (e.g. 5433) into all
-components. This will cause the server to listen on this
-non-standard port and it will cause the JDBC driver to connect
-to this port by default. In this way your testing environment is
-easily separated from other PostgreSQL applications on the same
-system.
-
-In this Howto we'll use $JDBC_SRC to refer to the directory
-src/interfaces/jdbc of the PostgreSQL source tree in your
-environment. The test suite is located in the subdirectory
-$JDBC_SRC/org/postgresql/test.
-
-3 Configuration
----------------
-The test suite requires a PostgreSQL database to run the tests
-against and a user to login as. For a full regression test of
-the entire PostgreSQL system, you should run the test against a
-server built from the same source tree as the driver you're
-testing. The tests will create and drop many objects in this
-database, so it should not contain production tables to avoid
-loss of data. We recommend you assign the following names:
-
- database: test
- username: test
- password: password
-
-These names correspond with the default names set for the test
-suite in $JDBC_SRC/build.xml. If you have chosen other names you
-need to edit this file and change the properties "database",
-"username" and "password" accordingly.
-
-4 Running the test suite
-------------------------
-%cd $JDBC_SRC
-%make
-%make check
-
-This will run the command line version of JUnit. If you'd like
-to see an animated coloured progress bar as the tests are
-executed, you may want to use one of the GUI versions of the
-test runner. See the JUnit documentation for more information.
-
-If the test suite reports errors or failures that you cannot
-explain, please post the relevant parts of the output to the
-mailing list pgsql-jdbc@postgresql.org.
-
-5 Extending the test suite with new tests
------------------------------------------
-If you're not familiar with JUnit, we recommend that you
-first read the introductory article "JUnit Test Infected:
-Programmers Love Writing Tests" on
-http://junit.sourceforge.net/doc/testinfected/testing.htm.
-Before continuing, you should ensure you understand the
-following concepts: test suite, test case, test, fixture,
-assertion, failure.
-
-The test suite consists of test cases, which consist of tests.
-A test case is a collection of tests that test a particular
-feature. The test suite is a collection of test cases that
-together test the driver - and to an extent the PostgreSQL
-backend - as a whole.
-
-If you decide to add a test to an existing test case, all you
-need to do is add a method with a name that begins with "test"
-and which takes no arguments. JUnit will dynamically find this
-method using reflection and run it when it runs the test case.
-In your test method you can use the fixture that is setup for it
-by the test case.
-
-If you decide to add a new test case, you should do two things:
-1) Add a class that extends junit.framework.TestCase. It should
-contain setUp() and tearDown() methods that create and destroy
-the fixture respectively.
-2) Edit $JDBC_SRC/org/postgresql/test/JDBC2Tests.java and add a
-suite.addTestSuite() call for your class. This will make the
-test case part of the test suite.
-
-6 Guidelines for developing new tests
--------------------------------------
-Every test should create and drop its own tables. We suggest to
-consider database objects (e.g. tables) part of the fixture for
-the tests in the test case. The test should also succeed when a
-table by the same name already exists in the test database, e.g.
-by dropping the table before running the test (ignoring errors).
-The recommended pattern for creating and dropping tables can be
-found in the example in section 7 below.
-
-Please note that JUnit provides several convenience methods to
-check for conditions. See the TestCase class in the Javadoc
-documentation of JUnit, which is installed on your system. For
-example, you can compare two integers using
-TestCase.assertEquals(int expected, int actual). This method
-will print both values in case of a failure.
-
-To simply report a failure use TestCase.fail().
-
-The JUnit FAQ explains how to test for a thrown exception.
-
-Avoid the use of the deprecated TestCase.assert(), since it will
-collide with the new assert keyword in the Java 2 platform
-version 1.4.
-
-As a rule, the test suite should succeed. Any errors or failures
-- which may be caused by bugs in the JDBC driver, the backend or
-the test suite - should be fixed ASAP. Don't let a test fail
-just to make it clear that something needs to be fixed somewhere.
-That's what the TODO lists are for.
-
-Add some comments to your tests to explain to others what it is
-you're testing. A long sequence of JDBC method calls and JUnit
-assertions can be hard to comprehend.
-
-For example, in the comments you can explain where a certain test
-condition originates from. Is it a JDBC requirement, PostgreSQL
-behaviour or the intended implementation of a feature?
-
-7 Example (incomplete)
-----------------------
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-
-/*
- * Test case for ...
- */
-public class FooTest extends TestCase {
-
- private Connection con;
- private Statement stmt;
-
- public FooTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- con = JDBC2Tests.openDB();
- stmt = con.createStatement();
-
- // Drop the test table if it already exists for some
- // reason. It is not an error if it doesn't exist.
- try {
- stmt.executeUpdate("DROP TABLE testfoo");
- } catch (SQLException e) {
- // Intentionally ignore. We cannot distinguish
- // "table does not exist" from other errors, since
- // PostgreSQL doesn't support error codes yet.
- }
-
- stmt.executeUpdate(
- "CREATE TABLE testfoo(pk INTEGER, col1 INTEGER)");
- stmt.executeUpdate("INSERT INTO testfoo VALUES(1, 0)");
-
- // You may want to call con.setAutoCommit(false) at
- // this point, if most tests in this test case require
- // the use of transactions.
- }
-
- protected void tearDown() throws Exception {
- con.setAutoCommit(true);
- if (stmt != null) {
- stmt.executeUpdate("DROP TABLE testfoo");
- stmt.close();
- }
- if (con != null) {
- JDBC2Tests.closeDB(con);
- }
- }
-
- public void testFoo() {
- // Use the assert methods in junit.framework.TestCase
- // for the actual tests
-
- // Just some silly examples
- assertNotNull(con);
- if (stmt == null) {
- fail("Where is my statement?");
- }
- }
-
- public void testBar() {
- // Another test.
- }
-}
-
-8. Running the JDBC 2 test suite from Sun against PostgreSQL
-------------------------------------------------------------
-Download the test suite from
-http://java.sun.com/products/jdbc/jdbctestsuite-1_2_1.html
-This is the JDBC 2 test suite that includes J2EE requirements.
-
-1. Configure PostgreSQL so that it accepts TCP/IP connections and
- start the server. Prepare PostgreSQL by creating two users (cts1
- and cts2) and two databases (DB1 and DB2) in the cluster that is
- going to be used for JDBC testing.
-
-2. Download the latest release versions of the J2EE, J2SE, and JDBC
- test suite from Sun's Java site (http://java.sun.com), and install
- according to Sun's documentation.
-
-3. The following environment variables should be set:
-
- CTS_HOME=<path where JDBC test suite installed (eg: /usr/local/jdbccts)>
- J2EE_HOME=<path where J2EE installed (eg: /usr/local/j2sdkee1.2.1)>
- JAVA_HOME=<path where J2SE installed (eg: /usr/local/jdk1.3.1)>
- NO_JAVATEST=Y
- LOCAL_CLASSES=<path to PostgreSQL JDBC driver jar>
-
-4. In $J2EE_HOME/config/default.properties:
-
- jdbc.drivers=org.postgresql.Driver
- jdbc.datasources=jdbc/DB1|jdbc:postgresql://localhost:5432/DB1|jdbc/DB2|jdbc:postgresq://localhost:5432/DB2
-
- Of course, if PostgreSQL is running on a computer different from
- the one running the application server, localhost should be changed
- to the proper host. Also, 5432 should be changed to whatever port
- PostgreSQL is listening on (5432 is the default).
-
- In $J2EE_HOME/bin/userconfig.sh:
-
- Add $CTS_HOME/lib/harness.jar, $CTS_HOME/lib/moo.jar,
- $CTS_HOME/lib/util.jar to J2EE_CLASSPATH. Also add the path to
- the PostgreSQL JDBC jar to J2EE_CLASSPATH. Set the JAVA_HOME
- variable to where you installed the J2SE. You should end up with
- something like this:
-
- CTS_HOME=/home/liams/linux/java/jdbccts
- J2EE_CLASSPATH=/home/liams/work/inst/postgresql-7.1.2/share/java/postgresql.jar:$CTS_HOME/lib/harness.jar:$CTS_HOME/lib/moo.jar:$CTS_HOME/lib/util.jar
- export J2EE_CLASSPATH
-
- JAVA_HOME=/home/liams/linux/java/jdk1.3.1
- export JAVA_HOME
-
- In $CTS_HOME/bin/cts.jte:
-
- webServerHost=localhost
- webServerPort=8000
- servletServerHost=localhost
- servletServerPort=8000
-
-5. Start the application server (j2ee):
-
- $ cd $J2EE_HOME
- $ bin/j2ee -verbose
-
- The server can be stopped after the tests have finished:
-
- $ cd $J2EE_HOME
- $ bin/j2ee -stop
-
-6. Run the JDBC tests:
-
- $ cd $CTS_HOME/tests/jdbc/ee
- $ make jdbc-tests
-
-At the time of writing of this document, a great number of tests
-in this test suite fail.
-
-9 Credits, feedback
--------------------
-The parts of this document describing the PostgreSQL test suite
-were originally written by Rene Pijlman. Liam Stewart contributed
-the section on the Sun JDBC 2 test suite.
-
-Please send your questions about the JDBC test suites or suggestions
-for improvement to the pgsql-jdbc@postgresql.org mailing list.
-
-The source of this document is maintained in
-src/interfaces/jdbc/org/postgresql/test/README in CVS. Patches for
-improvement can be send to the mailing list
-pgsql-patches@postgresql.org.
-
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/ANTTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/ANTTest.java
deleted file mode 100644
index b503ff422b9..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/ANTTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import junit.framework.TestCase;
-
-public class ANTTest extends TestCase
-{
- public ANTTest(String name)
- {
- super(name);
- }
-
- /*
- * This tests the acceptsURL() method with a couple of good and badly formed
- * jdbc urls
- */
- public void testANT()
- {
- String url = System.getProperty("database");
- String usr = System.getProperty("username");
- String psw = System.getProperty("password");
-
- assertNotNull(url);
- assertNotNull(usr);
- assertNotNull(psw);
-
- assertTrue(! url.equals(""));
- assertTrue(! usr.equals(""));
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/BatchExecuteTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/BatchExecuteTest.java
deleted file mode 100644
index 26229b88560..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/BatchExecuteTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-
-/* TODO tests that can be added to this test case
- * - SQLExceptions chained to a BatchUpdateException
- * - test PreparedStatement as thoroughly as Statement
- */
-
-/*
- * Test case for Statement.batchExecute()
- */
-public class BatchExecuteTest extends TestCase
-{
-
- private Connection con;
-
- public BatchExecuteTest(String name)
- {
- super(name);
- }
-
- // Set up the fixture for this testcase: a connection to a database with
- // a table for this test.
- protected void setUp() throws Exception
- {
- con = JDBC2Tests.openDB();
- Statement stmt = con.createStatement();
-
- // Drop the test table if it already exists for some reason. It is
- // not an error if it doesn't exist.
- JDBC2Tests.createTable(con, "testbatch", "pk INTEGER, col1 INTEGER");
-
- stmt.executeUpdate("INSERT INTO testbatch VALUES (1, 0)");
-
- // Generally recommended with batch updates. By default we run all
- // tests in this test case with autoCommit disabled.
- con.setAutoCommit(false);
- }
-
- // Tear down the fixture for this test case.
- protected void tearDown() throws Exception
- {
- con.setAutoCommit(true);
-
- JDBC2Tests.dropTable(con, "testbatch");
- JDBC2Tests.closeDB(con);
- }
-
- public void testSupportsBatchUpdates() throws Exception
- {
- DatabaseMetaData dbmd = con.getMetaData();
- assertTrue(dbmd.supportsBatchUpdates());
- }
-
- private void assertCol1HasValue(int expected) throws Exception
- {
- Statement getCol1 = con.createStatement();
-
- ResultSet rs =
- getCol1.executeQuery("SELECT col1 FROM testbatch WHERE pk = 1");
- assertTrue(rs.next());
-
- int actual = rs.getInt("col1");
-
- assertEquals(expected, actual);
-
- assertEquals(false, rs.next());
-
- rs.close();
- getCol1.close();
- }
-
- public void testExecuteEmptyBatch() throws Exception
- {
- Statement stmt = con.createStatement();
- int[] updateCount = stmt.executeBatch();
- assertEquals(0, updateCount.length);
-
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 1 WHERE pk = 1");
- stmt.clearBatch();
- updateCount = stmt.executeBatch();
- assertEquals(0, updateCount.length);
- stmt.close();
- }
-
- public void testClearBatch() throws Exception
- {
- Statement stmt = con.createStatement();
-
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 1 WHERE pk = 1");
- assertCol1HasValue(0);
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 2 WHERE pk = 1");
- assertCol1HasValue(0);
- stmt.clearBatch();
- assertCol1HasValue(0);
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 4 WHERE pk = 1");
- assertCol1HasValue(0);
- stmt.executeBatch();
- assertCol1HasValue(4);
- con.commit();
- assertCol1HasValue(4);
-
- stmt.close();
- }
-
- public void testSelectThrowsException() throws Exception
- {
- Statement stmt = con.createStatement();
-
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 1 WHERE pk = 1");
- stmt.addBatch("SELECT col1 FROM testbatch WHERE pk = 1");
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 2 WHERE pk = 1");
-
- try
- {
- stmt.executeBatch();
- fail("Should raise a BatchUpdateException because of the SELECT");
- }
- catch (BatchUpdateException e)
- {
- int [] updateCounts = e.getUpdateCounts();
- assertEquals(1, updateCounts.length);
- assertEquals(1, updateCounts[0]);
- }
- catch (SQLException e)
- {
- fail( "Should throw a BatchUpdateException instead of " +
- "a generic SQLException: " + e);
- }
-
- stmt.close();
- }
-
- public void testPreparedStatement() throws Exception
- {
- PreparedStatement pstmt = con.prepareStatement(
- "UPDATE testbatch SET col1 = col1 + ? WHERE PK = ?" );
-
- // Note that the first parameter changes for every statement in the
- // batch, whereas the second parameter remains constant.
- pstmt.setInt(1, 1);
- pstmt.setInt(2, 1);
- pstmt.addBatch();
- assertCol1HasValue(0);
-
- pstmt.setInt(1, 2);
- pstmt.addBatch();
- assertCol1HasValue(0);
-
- pstmt.setInt(1, 4);
- pstmt.addBatch();
- assertCol1HasValue(0);
-
- pstmt.executeBatch();
- assertCol1HasValue(7);
-
- con.commit();
- assertCol1HasValue(7);
-
- con.rollback();
- assertCol1HasValue(7);
-
- pstmt.close();
- }
-
- public void testTransactionalBehaviour() throws Exception
- {
- Statement stmt = con.createStatement();
-
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 1 WHERE pk = 1");
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 2 WHERE pk = 1");
- stmt.executeBatch();
- con.rollback();
- assertCol1HasValue(0);
-
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 4 WHERE pk = 1");
- stmt.addBatch("UPDATE testbatch SET col1 = col1 + 8 WHERE pk = 1");
-
- // The statement has been added to the batch, but it should not yet
- // have been executed.
- assertCol1HasValue(0);
-
- int[] updateCounts = stmt.executeBatch();
- assertEquals(2, updateCounts.length);
- assertEquals(1, updateCounts[0]);
- assertEquals(1, updateCounts[1]);
-
- assertCol1HasValue(12);
- con.commit();
- assertCol1HasValue(12);
- con.rollback();
- assertCol1HasValue(12);
-
- stmt.close();
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/BlobTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/BlobTest.java
deleted file mode 100644
index ae436fbf18b..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/BlobTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.io.*;
-import java.sql.*;
-
-import org.postgresql.largeobject.*;
-
-/*
- * $Id: BlobTest.java,v 1.5 2001/11/19 23:16:46 momjian Exp $
- *
- * Some simple tests based on problems reported by users. Hopefully these will
- * help prevent previous problems from re-occuring ;-)
- *
- */
-public class BlobTest extends TestCase
-{
-
- private Connection con;
-
- private static final int LOOP = 0; // LargeObject API using loop
- private static final int NATIVE_STREAM = 1; // LargeObject API using OutputStream
- private static final int JDBC_STREAM = 2; // JDBC API using OutputStream
-
- public BlobTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- con = JDBC2Tests.openDB();
- JDBC2Tests.createTable(con, "testblob", "id name,lo oid");
- }
-
- protected void tearDown() throws Exception
- {
- JDBC2Tests.dropTable(con, "testblob");
- JDBC2Tests.closeDB(con);
- }
-
- /*
- * Tests one method of uploading a blob to the database
- */
- public void testUploadBlob_LOOP()
- {
- try
- {
- con.setAutoCommit(false);
- assertTrue(!con.getAutoCommit());
-
- assertTrue(uploadFile("build.xml", LOOP) > 0);
-
- // Now compare the blob & the file. Note this actually tests the
- // InputStream implementation!
- assertTrue(compareBlobs());
-
- con.setAutoCommit(true);
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Tests one method of uploading a blob to the database
- */
- public void testUploadBlob_NATIVE()
- {
- try
- {
- con.setAutoCommit(false);
- assertTrue(!con.getAutoCommit());
-
- assertTrue(uploadFile("build.xml", NATIVE_STREAM) > 0);
-
- // Now compare the blob & the file. Note this actually tests the
- // InputStream implementation!
- assertTrue(compareBlobs());
-
- con.setAutoCommit(true);
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Helper - uploads a file into a blob using old style methods. We use this
- * because it always works, and we can use it as a base to test the new
- * methods.
- */
- private int uploadFile(String file, int method) throws Exception
- {
- LargeObjectManager lom = ((org.postgresql.Connection)con).getLargeObjectAPI();
-
- FileInputStream fis = new FileInputStream(file);
-
- int oid = lom.create(LargeObjectManager.READWRITE);
- LargeObject blob = lom.open(oid);
-
- int s, t;
- byte buf[];
- OutputStream os;
-
- switch (method)
- {
- case LOOP:
- buf = new byte[2048];
- t = 0;
- while ((s = fis.read(buf, 0, buf.length)) > 0)
- {
- t += s;
- blob.write(buf, 0, s);
- }
- break;
-
- case NATIVE_STREAM:
- os = blob.getOutputStream();
- s = fis.read();
- while (s > -1)
- {
- os.write(s);
- s = fis.read();
- }
- os.close();
- break;
-
- case JDBC_STREAM:
- File f = new File(file);
- PreparedStatement ps = con.prepareStatement(JDBC2Tests.insertSQL("testblob", "?"));
- ps.setBinaryStream(1, fis, (int) f.length());
- ps.execute();
- break;
-
- default:
- assertTrue("Unknown method in uploadFile", false);
- }
-
- blob.close();
- fis.close();
-
- // Insert into the table
- Statement st = con.createStatement();
- st.executeUpdate(JDBC2Tests.insertSQL("testblob", "id,lo", "'" + file + "'," + oid));
- con.commit();
- st.close();
-
- return oid;
- }
-
- /*
- * Helper - compares the blobs in a table with a local file. Note this alone
- * tests the InputStream methods!
- */
- private boolean compareBlobs() throws Exception
- {
- boolean result = true;
-
- LargeObjectManager lom = ((org.postgresql.Connection)con).getLargeObjectAPI();
-
- Statement st = con.createStatement();
- ResultSet rs = st.executeQuery(JDBC2Tests.selectSQL("testblob", "id,lo"));
- assertNotNull(rs);
-
- while (rs.next())
- {
- String file = rs.getString(1);
- int oid = rs.getInt(2);
-
- FileInputStream fis = new FileInputStream(file);
- LargeObject blob = lom.open(oid);
- InputStream bis = blob.getInputStream();
-
- int f = fis.read();
- int b = bis.read();
- int c = 0;
- while (f >= 0 && b >= 0 & result)
- {
- result = (f == b);
- f = fis.read();
- b = bis.read();
- c++;
- }
- result = result && f == -1 && b == -1;
-
- if (!result)
- System.out.println("\nBlob compare failed at " + c + " of " + blob.size());
-
- blob.close();
- fis.close();
- }
- rs.close();
- st.close();
-
- return result;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java
deleted file mode 100644
index 6db4f412184..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java
+++ /dev/null
@@ -1,340 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-
-/*
- * TestCase to test the internal functionality of org.postgresql.jdbc2.Connection
- * and it's superclass.
- *
- * PS: Do you know how difficult it is to type on a train? ;-)
- *
- * $Id: ConnectionTest.java,v 1.7 2001/11/19 22:33:39 momjian Exp $
- */
-
-public class ConnectionTest extends TestCase
-{
-
- /*
- * Constructor
- */
- public ConnectionTest(String name)
- {
- super(name);
- }
-
- // Set up the fixture for this testcase: the tables for this test.
- protected void setUp() throws Exception
- {
- Connection con = JDBC2Tests.openDB();
-
- JDBC2Tests.createTable(con, "test_a", "imagename name,image oid,id int4");
- JDBC2Tests.createTable(con, "test_c", "source text,cost money,imageid int4");
-
- JDBC2Tests.closeDB(con);
- }
-
- // Tear down the fixture for this test case.
- protected void tearDown() throws Exception
- {
- Connection con = JDBC2Tests.openDB();
-
- JDBC2Tests.dropTable(con, "test_a");
- JDBC2Tests.dropTable(con, "test_c");
-
- JDBC2Tests.closeDB(con);
- }
-
- /*
- * Tests the two forms of createStatement()
- */
- public void testCreateStatement()
- {
- try
- {
- java.sql.Connection conn = JDBC2Tests.openDB();
-
- // A standard Statement
- java.sql.Statement stat = conn.createStatement();
- assertNotNull(stat);
- stat.close();
-
- // Ask for Updateable ResultSets
- stat = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_UPDATABLE);
- assertNotNull(stat);
- stat.close();
-
- }
- catch (SQLException ex)
- {
- assertTrue(ex.getMessage(), false);
- }
- }
-
- /*
- * Tests the two forms of prepareStatement()
- */
- public void testPrepareStatement()
- {
- try
- {
- java.sql.Connection conn = JDBC2Tests.openDB();
-
- String sql = "select source,cost,imageid from test_c";
-
- // A standard Statement
- java.sql.PreparedStatement stat = conn.prepareStatement(sql);
- assertNotNull(stat);
- stat.close();
-
- // Ask for Updateable ResultSets
- stat = conn.prepareStatement(sql, java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_UPDATABLE);
- assertNotNull(stat);
- stat.close();
-
- }
- catch (SQLException ex)
- {
- assertTrue(ex.getMessage(), false);
- }
- }
-
- /*
- * Put the test for createPrepareCall here
- */
- public void testPrepareCall()
- {}
-
- /*
- * Test nativeSQL
- */
- public void testNativeSQL()
- {
- // For now do nothing as it returns itself
- }
-
- /*
- * Test autoCommit (both get & set)
- */
- public void testTransactions()
- {
- try
- {
- java.sql.Connection con = JDBC2Tests.openDB();
- java.sql.Statement st;
- java.sql.ResultSet rs;
-
- // Turn it off
- con.setAutoCommit(false);
- assertTrue(!con.getAutoCommit());
-
- // Turn it back on
- con.setAutoCommit(true);
- assertTrue(con.getAutoCommit());
-
- // Now test commit
- st = con.createStatement();
- st.executeUpdate("insert into test_a (imagename,image,id) values ('comttest',1234,5678)");
-
- con.setAutoCommit(false);
-
- // Now update image to 9876 and commit
- st.executeUpdate("update test_a set image=9876 where id=5678");
- con.commit();
- rs = st.executeQuery("select image from test_a where id=5678");
- assertTrue(rs.next());
- assertEquals(9876, rs.getInt(1));
- rs.close();
-
- // Now try to change it but rollback
- st.executeUpdate("update test_a set image=1111 where id=5678");
- con.rollback();
- rs = st.executeQuery("select image from test_a where id=5678");
- assertTrue(rs.next());
- assertEquals(9876, rs.getInt(1)); // Should not change!
- rs.close();
-
- JDBC2Tests.closeDB(con);
- }
- catch (SQLException ex)
- {
- assertTrue(ex.getMessage(), false);
- }
- }
-
- /*
- * Simple test to see if isClosed works.
- */
- public void testIsClosed()
- {
- try
- {
- Connection con = JDBC2Tests.openDB();
-
- // Should not say closed
- assertTrue(!con.isClosed());
-
- JDBC2Tests.closeDB(con);
-
- // Should now say closed
- assertTrue(con.isClosed());
-
- }
- catch (SQLException ex)
- {
- assertTrue(ex.getMessage(), false);
- }
- }
-
- /*
- * Test the warnings system
- */
- public void testWarnings()
- {
- try
- {
- Connection con = JDBC2Tests.openDB();
-
- String testStr = "This Is OuR TeSt message";
-
- // The connection must be ours!
- assertTrue(con instanceof org.postgresql.Connection);
-
- // Clear any existing warnings
- con.clearWarnings();
-
- // Set the test warning
- ((org.postgresql.Connection)con).addWarning(testStr);
-
- // Retrieve it
- SQLWarning warning = con.getWarnings();
- assertNotNull(warning);
- assertEquals(testStr, warning.getMessage());
-
- // Finally test clearWarnings() this time there must be something to delete
- con.clearWarnings();
- assertTrue(con.getWarnings() == null);
-
- JDBC2Tests.closeDB(con);
- }
- catch (SQLException ex)
- {
- assertTrue(ex.getMessage(), false);
- }
- }
-
- /*
- * Transaction Isolation Levels
- */
- public void testTransactionIsolation()
- {
- try
- {
- Connection con = JDBC2Tests.openDB();
-
- // PostgreSQL defaults to READ COMMITTED
- assertEquals(Connection.TRANSACTION_READ_COMMITTED,
- con.getTransactionIsolation());
-
- // Begin a transaction
- con.setAutoCommit(false);
-
- // The isolation level should not have changed
- assertEquals(Connection.TRANSACTION_READ_COMMITTED,
- con.getTransactionIsolation());
-
- // Now change the default for future transactions
- con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
-
- // Since the call to setTransactionIsolation() above was made
- // inside the transaction, the isolation level of the current
- // transaction did not change. It affects only future transactions.
- // This behaviour is recommended by the JDBC spec.
- assertEquals(Connection.TRANSACTION_READ_COMMITTED,
- con.getTransactionIsolation());
-
- // Begin a new transaction
- con.commit();
-
- // Now we should see the new isolation level
- assertEquals(Connection.TRANSACTION_SERIALIZABLE,
- con.getTransactionIsolation());
-
- // Repeat the steps above with the transition back to
- // READ COMMITTED.
- con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
- assertEquals(Connection.TRANSACTION_SERIALIZABLE,
- con.getTransactionIsolation());
- con.commit();
- assertEquals(Connection.TRANSACTION_READ_COMMITTED,
- con.getTransactionIsolation());
-
- // Now run some tests with autocommit enabled.
- con.setAutoCommit(true);
-
- assertEquals(Connection.TRANSACTION_READ_COMMITTED,
- con.getTransactionIsolation());
-
- con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
- assertEquals(Connection.TRANSACTION_SERIALIZABLE,
- con.getTransactionIsolation());
-
- con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
- assertEquals(Connection.TRANSACTION_READ_COMMITTED, con.getTransactionIsolation());
-
- // Test if a change of isolation level before beginning the
- // transaction affects the isolation level inside the transaction.
- con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
- assertEquals(Connection.TRANSACTION_SERIALIZABLE,
- con.getTransactionIsolation());
- con.setAutoCommit(false);
- assertEquals(Connection.TRANSACTION_SERIALIZABLE,
- con.getTransactionIsolation());
- con.setAutoCommit(true);
- assertEquals(Connection.TRANSACTION_SERIALIZABLE,
- con.getTransactionIsolation());
- con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
- assertEquals(Connection.TRANSACTION_READ_COMMITTED,
- con.getTransactionIsolation());
- con.setAutoCommit(false);
- assertEquals(Connection.TRANSACTION_READ_COMMITTED,
- con.getTransactionIsolation());
-
- JDBC2Tests.closeDB(con);
- }
- catch ( SQLException ex )
- {
- fail( ex.getMessage() );
- }
- }
-
- /*
- * JDBC2 Type mappings
- */
- public void testTypeMaps()
- {
- try
- {
- Connection con = JDBC2Tests.openDB();
-
- // preserve the current map
- java.util.Map oldmap = con.getTypeMap();
-
- // now change it for an empty one
- java.util.Map newmap = new java.util.HashMap();
- con.setTypeMap(newmap);
- assertEquals(newmap, con.getTypeMap());
-
- // restore the old one
- con.setTypeMap(oldmap);
- assertEquals(oldmap, con.getTypeMap());
-
- JDBC2Tests.closeDB(con);
- }
- catch (SQLException ex)
- {
- assertTrue(ex.getMessage(), false);
- }
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
deleted file mode 100644
index e6acfc0d700..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
+++ /dev/null
@@ -1,408 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-
-/*
- * TestCase to test the internal functionality of org.postgresql.jdbc2.DatabaseMetaData
- *
- * PS: Do you know how difficult it is to type on a train? ;-)
- *
- * $Id: DatabaseMetaDataTest.java,v 1.8 2002/06/05 19:12:01 davec Exp $
- */
-
-public class DatabaseMetaDataTest extends TestCase
-{
-
- private Connection con;
- /*
- * Constructor
- */
- public DatabaseMetaDataTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- con = JDBC2Tests.openDB();
- JDBC2Tests.createTable( con, "testmetadata", "id int4, name text, updated timestamp" );
- }
- protected void tearDown() throws Exception
- {
- JDBC2Tests.dropTable( con, "testmetadata" );
-
- JDBC2Tests.closeDB( con );
- }
- /*
- * The spec says this may return null, but we always do!
- */
- public void testGetMetaData()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- ResultSet rs = dbmd.getTables( null, null, "test%", new String[] {"TABLE"});
- assertTrue( rs.next() );
- assertTrue( rs.getString("TABLE_NAME").equals("testmetadata") );
-
- rs.close();
-
- rs = dbmd.getColumns("", "", "test%", "%" );
- assertTrue( rs.next() );
- assertTrue( rs.getString("TABLE_NAME").equals("testmetadata") );
- assertTrue( rs.getString("COLUMN_NAME").equals("id") );
- assertTrue( rs.getInt("DATA_TYPE") == java.sql.Types.INTEGER );
-
- assertTrue( rs.next() );
- assertTrue( rs.getString("TABLE_NAME").equals("testmetadata") );
- assertTrue( rs.getString("COLUMN_NAME").equals("name") );
- assertTrue( rs.getInt("DATA_TYPE") == java.sql.Types.VARCHAR );
-
- assertTrue( rs.next() );
- assertTrue( rs.getString("TABLE_NAME").equals("testmetadata") );
- assertTrue( rs.getString("COLUMN_NAME").equals("updated") );
- assertTrue( rs.getInt("DATA_TYPE") == java.sql.Types.TIMESTAMP );
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Test default capabilities
- */
- public void testCapabilities()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- assertTrue(dbmd.allProceduresAreCallable());
- assertTrue(dbmd.allTablesAreSelectable()); // not true all the time
-
- // This should always be false for postgresql (at least for 7.x)
- assertTrue(!dbmd.isReadOnly());
-
- // does the backend support this yet? The protocol does...
- assertTrue(!dbmd.supportsMultipleResultSets());
-
- // yes, as multiple backends can have transactions open
- assertTrue(dbmd.supportsMultipleTransactions());
-
- assertTrue(dbmd.supportsMinimumSQLGrammar());
- assertTrue(!dbmd.supportsCoreSQLGrammar());
- assertTrue(!dbmd.supportsExtendedSQLGrammar());
- assertTrue(!dbmd.supportsANSI92EntryLevelSQL());
- assertTrue(!dbmd.supportsANSI92IntermediateSQL());
- assertTrue(!dbmd.supportsANSI92FullSQL());
-
- assertTrue(!dbmd.supportsIntegrityEnhancementFacility());
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
-
- public void testJoins()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- assertTrue(dbmd.supportsOuterJoins());
- assertTrue(dbmd.supportsFullOuterJoins());
- assertTrue(dbmd.supportsLimitedOuterJoins());
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testCursors()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- assertTrue(!dbmd.supportsPositionedDelete());
- assertTrue(!dbmd.supportsPositionedUpdate());
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testNulls()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- // We need to type cast the connection to get access to the
- // PostgreSQL-specific method haveMinimumServerVersion().
- // This is not available through the java.sql.Connection interface.
- assertTrue( con instanceof org.postgresql.Connection );
-
- assertTrue(!dbmd.nullsAreSortedAtStart());
- assertTrue( dbmd.nullsAreSortedAtEnd() !=
- ((org.postgresql.Connection)con).haveMinimumServerVersion("7.2"));
- assertTrue( dbmd.nullsAreSortedHigh() ==
- ((org.postgresql.Connection)con).haveMinimumServerVersion("7.2"));
- assertTrue(!dbmd.nullsAreSortedLow());
-
- assertTrue(dbmd.nullPlusNonNullIsNull());
-
- assertTrue(dbmd.supportsNonNullableColumns());
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testLocalFiles()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- assertTrue(!dbmd.usesLocalFilePerTable());
- assertTrue(!dbmd.usesLocalFiles());
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testIdentifiers()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- assertTrue(!dbmd.supportsMixedCaseIdentifiers()); // always false
- assertTrue(dbmd.supportsMixedCaseQuotedIdentifiers()); // always true
-
- assertTrue(!dbmd.storesUpperCaseIdentifiers()); // always false
- assertTrue(dbmd.storesLowerCaseIdentifiers()); // always true
- assertTrue(!dbmd.storesUpperCaseQuotedIdentifiers()); // always false
- assertTrue(!dbmd.storesLowerCaseQuotedIdentifiers()); // always false
- assertTrue(!dbmd.storesMixedCaseQuotedIdentifiers()); // always false
-
- assertTrue(dbmd.getIdentifierQuoteString().equals("\""));
-
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testForeignKeys()
- {
- try
- {
- Connection con1 = JDBC2Tests.openDB();
- JDBC2Tests.createTable( con1, "people", "id int4 primary key, name text" );
- JDBC2Tests.createTable( con1, "policy", "id int4 primary key, name text" );
-
- JDBC2Tests.createTable( con1, "users", "id int4 primary key, people_id int4, policy_id int4,"+
- "CONSTRAINT people FOREIGN KEY (people_id) references people(id),"+
- "constraint policy FOREIGN KEY (policy_id) references policy(id)" );
-
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- ResultSet rs = dbmd.getImportedKeys(null, "", "users" );
- int j = 0;
- for (; rs.next(); j++ )
- {
-
- String pkTableName = rs.getString( "PKTABLE_NAME" );
- assertTrue ( pkTableName.equals("people") || pkTableName.equals("policy") );
-
- String pkColumnName = rs.getString( "PKCOLUMN_NAME" );
- assertTrue( pkColumnName.equals("id") );
-
- String fkTableName = rs.getString( "FKTABLE_NAME" );
- assertTrue( fkTableName.equals( "users" ) );
-
- String fkColumnName = rs.getString( "FKCOLUMN_NAME" );
- assertTrue( fkColumnName.equals( "people_id" ) || fkColumnName.equals( "policy_id" ) ) ;
-
- String fkName = rs.getString( "FK_NAME" );
- assertTrue( fkName.equals( "people_pkey") || fkName.equals( "policy_pkey" ) );
-
- String pkName = rs.getString( "PK_NAME" );
-// assertTrue( pkName.equals("users") );
-
- }
-
- assertTrue ( j== 2 );
-
- rs = dbmd.getExportedKeys( null, "", "people" );
-
- // this is hacky, but it will serve the purpose
- assertTrue ( rs.next() );
-
- assertTrue( rs.getString( "PKTABLE_NAME" ).equals( "people" ) );
- assertTrue( rs.getString( "PKCOLUMN_NAME" ).equals( "id" ) );
-
- assertTrue( rs.getString( "FKTABLE_NAME" ).equals( "users" ) );
- assertTrue( rs.getString( "FKCOLUMN_NAME" ).equals( "people_id" ) );
-
- assertTrue( rs.getString( "FK_NAME" ).equals( "people_pkey" ) );
-
-
- JDBC2Tests.dropTable( con1, "users" );
- JDBC2Tests.dropTable( con1, "people" );
- JDBC2Tests.dropTable( con1, "policy" );
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
- public void testTables()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- // we can add columns
- assertTrue(dbmd.supportsAlterTableWithAddColumn());
-
- // we can't drop columns (yet)
- assertTrue(!dbmd.supportsAlterTableWithDropColumn());
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testSelect()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- // yes we can?: SELECT col a FROM a;
- assertTrue(dbmd.supportsColumnAliasing());
-
- // yes we can have expressions in ORDERBY
- assertTrue(dbmd.supportsExpressionsInOrderBy());
-
- // Yes, an ORDER BY clause can contain columns that are not in the
- // SELECT clause.
- assertTrue(dbmd.supportsOrderByUnrelated());
-
- assertTrue(dbmd.supportsGroupBy());
- assertTrue(dbmd.supportsGroupByUnrelated());
- assertTrue(dbmd.supportsGroupByBeyondSelect()); // needs checking
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testDBParams()
- {
- try
- {
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- assertTrue(dbmd.getURL().equals(JDBC2Tests.getURL()));
- assertTrue(dbmd.getUserName().equals(JDBC2Tests.getUser()));
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testDbProductDetails()
- {
- try
- {
- assertTrue(con instanceof org.postgresql.Connection);
- org.postgresql.Connection pc = (org.postgresql.Connection) con;
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- assertTrue(dbmd.getDatabaseProductName().equals("PostgreSQL"));
- assertTrue(dbmd.getDatabaseProductVersion().startsWith(Integer.toString(pc.this_driver.getMajorVersion()) + "." + Integer.toString(pc.this_driver.getMinorVersion())));
- assertTrue(dbmd.getDriverName().equals("PostgreSQL Native Driver"));
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testDriverVersioning()
- {
- try
- {
- assertTrue(con instanceof org.postgresql.Connection);
- org.postgresql.Connection pc = (org.postgresql.Connection) con;
-
- DatabaseMetaData dbmd = con.getMetaData();
- assertNotNull(dbmd);
-
- assertTrue(dbmd.getDriverVersion().equals(pc.this_driver.getVersion()));
- assertTrue(dbmd.getDriverMajorVersion() == pc.this_driver.getMajorVersion());
- assertTrue(dbmd.getDriverMinorVersion() == pc.this_driver.getMinorVersion());
-
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/DateTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/DateTest.java
deleted file mode 100644
index 300d1549bbd..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/DateTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-
-/*
- * $Id: DateTest.java,v 1.4 2001/11/19 22:33:39 momjian Exp $
- *
- * Some simple tests based on problems reported by users. Hopefully these will
- * help prevent previous problems from re-occuring ;-)
- *
- */
-public class DateTest extends TestCase
-{
-
- private Connection con;
-
- public DateTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- con = JDBC2Tests.openDB();
- JDBC2Tests.createTable(con, "testdate", "dt date");
- }
-
- protected void tearDown() throws Exception
- {
- JDBC2Tests.dropTable(con, "testdate");
- JDBC2Tests.closeDB(con);
- }
-
- /*
- * Tests the time methods in ResultSet
- */
- public void testGetDate()
- {
- try
- {
- Statement stmt = con.createStatement();
-
- assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testdate", "'1950-02-07'")));
- assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testdate", "'1970-06-02'")));
- assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testdate", "'1999-08-11'")));
- assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testdate", "'2001-02-13'")));
-
- /* dateTest() contains all of the tests */
- dateTest();
-
- assertEquals(4, stmt.executeUpdate("DELETE FROM " + "testdate"));
- stmt.close();
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Tests the time methods in PreparedStatement
- */
- public void testSetDate()
- {
- try
- {
- Statement stmt = con.createStatement();
- PreparedStatement ps = con.prepareStatement(JDBC2Tests.insertSQL("testdate", "?"));
-
- ps.setDate(1, makeDate(1950, 2, 7));
- assertEquals(1, ps.executeUpdate());
-
- ps.setDate(1, makeDate(1970, 6, 2));
- assertEquals(1, ps.executeUpdate());
-
- ps.setDate(1, makeDate(1999, 8, 11));
- assertEquals(1, ps.executeUpdate());
-
- ps.setDate(1, makeDate(2001, 2, 13));
- assertEquals(1, ps.executeUpdate());
-
- ps.close();
-
- // Fall through helper
- dateTest();
-
- assertEquals(4, stmt.executeUpdate("DELETE FROM testdate"));
- stmt.close();
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Helper for the date tests. It tests what should be in the db
- */
- private void dateTest() throws SQLException
- {
- Statement st = con.createStatement();
- ResultSet rs;
- java.sql.Date d;
-
- rs = st.executeQuery(JDBC2Tests.selectSQL("testdate", "dt"));
- assertNotNull(rs);
-
- assertTrue(rs.next());
- d = rs.getDate(1);
- assertNotNull(d);
- assertEquals(d, makeDate(1950, 2, 7));
-
- assertTrue(rs.next());
- d = rs.getDate(1);
- assertNotNull(d);
- assertEquals(d, makeDate(1970, 6, 2));
-
- assertTrue(rs.next());
- d = rs.getDate(1);
- assertNotNull(d);
- assertEquals(d, makeDate(1999, 8, 11));
-
- assertTrue(rs.next());
- d = rs.getDate(1);
- assertNotNull(d);
- assertEquals(d, makeDate(2001, 2, 13));
-
- assertTrue(!rs.next());
-
- rs.close();
- st.close();
- }
-
- private java.sql.Date makeDate(int y, int m, int d)
- {
- return java.sql.Date.valueOf(JDBC2Tests.fix(y, 4) + "-" +
- JDBC2Tests.fix(m, 2) + "-" +
- JDBC2Tests.fix(d, 2));
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/DriverTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/DriverTest.java
deleted file mode 100644
index f2ec356c5ae..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/DriverTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-
-/*
- * $Id: DriverTest.java,v 1.4 2001/11/19 22:33:39 momjian Exp $
- *
- * Tests the dynamically created class org.postgresql.Driver
- *
- */
-public class DriverTest extends TestCase
-{
-
- public DriverTest(String name)
- {
- super(name);
- }
-
- /*
- * This tests the acceptsURL() method with a couple of good and badly formed
- * jdbc urls
- */
- public void testAcceptsURL()
- {
- try
- {
-
- // Load the driver (note clients should never do it this way!)
- org.postgresql.Driver drv = new org.postgresql.Driver();
- assertNotNull(drv);
-
- // These are always correct
- assertTrue(drv.acceptsURL("jdbc:postgresql:test"));
- assertTrue(drv.acceptsURL("jdbc:postgresql://localhost/test"));
- assertTrue(drv.acceptsURL("jdbc:postgresql://localhost:5432/test"));
- assertTrue(drv.acceptsURL("jdbc:postgresql://127.0.0.1/anydbname"));
- assertTrue(drv.acceptsURL("jdbc:postgresql://127.0.0.1:5433/hidden"));
-
- // Badly formatted url's
- assertTrue(!drv.acceptsURL("jdbc:postgres:test"));
- assertTrue(!drv.acceptsURL("postgresql:test"));
-
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Tests parseURL (internal)
- */
- /*
- * Tests the connect method by connecting to the test database
- */
- public void testConnect()
- {
- Connection con = null;
- try
- {
- Class.forName("org.postgresql.Driver");
-
- // Test with the url, username & password
- con = DriverManager.getConnection(JDBC2Tests.getURL(), JDBC2Tests.getUser(), JDBC2Tests.getPassword());
- assertNotNull(con);
- con.close();
-
- // Test with the username in the url
- con = DriverManager.getConnection(JDBC2Tests.getURL() + "?user=" + JDBC2Tests.getUser() + "&password=" + JDBC2Tests.getPassword());
- assertNotNull(con);
- con.close();
- }
- catch (ClassNotFoundException ex)
- {
- fail(ex.getMessage());
- }
- catch (SQLException ex)
- {
- fail(ex.getMessage());
- }
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/EncodingTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/EncodingTest.java
deleted file mode 100644
index f40bb5eae17..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/EncodingTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-
-package org.postgresql.test.jdbc2;
-
-import junit.framework.*;
-import org.postgresql.core.Encoding;
-import java.io.*;
-
-/*
- * Tests for the Encoding class.
- *
- * $Id: EncodingTest.java,v 1.4 2001/11/19 22:33:39 momjian Exp $
- */
-
-
-public class EncodingTest extends TestCase
-{
-
- public EncodingTest(String name)
- {
- super(name);
- }
-
- public void testCreation() throws Exception
- {
- Encoding encoding;
- encoding = Encoding.getEncoding("UNICODE", null);
- assertEquals("UTF", encoding.name().substring(0, 3).toUpperCase());
- encoding = Encoding.getEncoding("SQL_ASCII", null);
- assertTrue(encoding.name().toUpperCase().indexOf("ASCII") != -1);
- assertEquals("When encoding is unknown the default encoding should be used",
- Encoding.defaultEncoding(),
- Encoding.getEncoding("UNKNOWN", null));
- encoding = Encoding.getEncoding("SQL_ASCII", "utf-8");
- assertTrue("Encoding passed in by the user should be preferred",
- encoding.name().toUpperCase().indexOf("UTF") != -1);
- }
-
- public void testTransformations() throws Exception
- {
- Encoding encoding = Encoding.getEncoding("UNICODE", null);
- assertEquals("ab", encoding.decode(new byte[] { 97, 98 }));
-
- assertEquals(2, encoding.encode("ab").length);
- assertEquals(97, encoding.encode("a")[0]);
- assertEquals(98, encoding.encode("b")[0]);
-
- encoding = Encoding.defaultEncoding();
- assertEquals("a".getBytes()[0], encoding.encode("a")[0]);
- assertEquals(new String(new byte[] { 97 }),
- encoding.decode(new byte[] { 97 }));
- }
-
- public void testReader() throws Exception
- {
- Encoding encoding = Encoding.getEncoding("SQL_ASCII", null);
- InputStream stream = new ByteArrayInputStream(new byte[] { 97, 98 });
- Reader reader = encoding.getDecodingReader(stream);
- assertEquals(97, reader.read());
- assertEquals(98, reader.read());
- assertEquals( -1, reader.read());
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
deleted file mode 100644
index 456a514613e..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-import java.math.BigDecimal;
-
-/*
- * $Id: JBuilderTest.java,v 1.5 2001/11/19 22:33:39 momjian Exp $
- *
- * Some simple tests to check that the required components needed for JBuilder
- * stay working
- *
- */
-public class JBuilderTest extends TestCase
-{
-
- public JBuilderTest(String name)
- {
- super(name);
- }
-
- // Set up the fixture for this testcase: the tables for this test.
- protected void setUp() throws Exception
- {
- Connection con = JDBC2Tests.openDB();
-
- JDBC2Tests.createTable( con, "test_c",
- "source text,cost money,imageid int4" );
-
- JDBC2Tests.closeDB(con);
- }
-
- // Tear down the fixture for this test case.
- protected void tearDown() throws Exception
- {
- Connection con = JDBC2Tests.openDB();
- JDBC2Tests.dropTable(con, "test_c");
- JDBC2Tests.closeDB(con);
- }
-
- /*
- * This tests that Money types work. JDBCExplorer barfs if this fails.
- */
- public void testMoney()
- {
- try
- {
- Connection con = JDBC2Tests.openDB();
-
- Statement st = con.createStatement();
- ResultSet rs = st.executeQuery("select cost from test_c");
- assertNotNull(rs);
-
- while (rs.next())
- {
- double bd = rs.getDouble(1);
- }
-
- rs.close();
- st.close();
-
- JDBC2Tests.closeDB(con);
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java
deleted file mode 100644
index 753d33a3e6a..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-
-/*
- * $Id: MiscTest.java,v 1.6 2002/06/14 10:56:13 davec Exp $
- *
- * Some simple tests based on problems reported by users. Hopefully these will
- * help prevent previous problems from re-occuring ;-)
- *
- */
-public class MiscTest extends TestCase
-{
-
- public MiscTest(String name)
- {
- super(name);
- }
-
- /*
- * Some versions of the driver would return rs as a null?
- *
- * Sasha <ber0806@iperbole.bologna.it> was having this problem.
- *
- * Added Feb 13 2001
- */
- public void testDatabaseSelectNullBug()
- {
- try
- {
- Connection con = JDBC2Tests.openDB();
-
- Statement st = con.createStatement();
- ResultSet rs = st.executeQuery("select datname from pg_database");
- assertNotNull(rs);
-
- while (rs.next())
- {
- String s = rs.getString(1);
- }
-
- rs.close();
- st.close();
-
- JDBC2Tests.closeDB(con);
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
- public void testError()
- {
- Connection con = JDBC2Tests.openDB();
- try
- {
-
- // transaction mode
- con.setAutoCommit(false);
- Statement stmt = con.createStatement();
- stmt.execute("select 1/0");
- fail( "Should not execute this, as a SQLException s/b thrown" );
- con.commit();
- }
- catch ( Exception ex )
- {
- }
- try
- {
- con.commit();
- con.close();
- }catch ( Exception ex) {}
- }
-
- public void xtestLocking()
- {
-
- System.out.println("testing lock");
- try
- {
- Connection con = JDBC2Tests.openDB();
- Connection con2 = JDBC2Tests.openDB();
-
- JDBC2Tests.createTable(con, "test_lock", "name text");
- Statement st = con.createStatement();
- Statement st2 = con2.createStatement();
- con.setAutoCommit(false);
- st.execute("lock table test_lock");
- st2.executeUpdate( "insert into test_lock ( name ) values ('hello')" );
- con.commit();
- JDBC2Tests.dropTable(con, "test_lock");
- con.close();
- }
- catch ( Exception ex )
- {
- fail( ex.getMessage() );
- }
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
deleted file mode 100644
index 49af9e5ce9f..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.io.*;
-import java.sql.*;
-
-/*
- * ResultSet tests.
- */
-public class ResultSetTest extends TestCase
-{
- private Connection con;
-
- public ResultSetTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- con = JDBC2Tests.openDB();
- Statement stmt = con.createStatement();
-
- JDBC2Tests.createTable(con, "testrs", "id integer");
-
- stmt.executeUpdate("INSERT INTO testrs VALUES (1)");
- stmt.executeUpdate("INSERT INTO testrs VALUES (2)");
- stmt.executeUpdate("INSERT INTO testrs VALUES (3)");
- stmt.executeUpdate("INSERT INTO testrs VALUES (4)");
- stmt.executeUpdate("INSERT INTO testrs VALUES (6)");
- stmt.executeUpdate("INSERT INTO testrs VALUES (9)");
-
- stmt.close();
- }
-
- protected void tearDown() throws Exception
- {
- JDBC2Tests.dropTable(con, "testrs");
- JDBC2Tests.closeDB(con);
- }
-
- public void testAbsolute() throws Exception
- {
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM testrs");
-
- assertTrue(rs.absolute( -1));
- assertEquals(6, rs.getRow());
-
- assertTrue(rs.absolute(1));
- assertEquals(1, rs.getRow());
-
- assertTrue(!rs.absolute( -10));
- assertEquals(0, rs.getRow());
- assertTrue(rs.next());
- assertEquals(1, rs.getRow());
-
- assertTrue(!rs.absolute(10));
- assertEquals(0, rs.getRow());
- assertTrue(rs.previous());
- assertEquals(6, rs.getRow());
-
- stmt.close();
- }
- public void testEmptyResult()
- {
- try
- {
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM testrs where id=100");
- rs.beforeFirst();
- rs.afterLast();
- assertTrue(!rs.first());
- assertTrue(!rs.last());
- assertTrue(!rs.next());
-
-
- }
- catch ( Exception ex )
- {
- fail( ex.getMessage() );
- }
-
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/TimeTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/TimeTest.java
deleted file mode 100644
index 88ba63f76aa..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/TimeTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-
-/*
- * $Id: TimeTest.java,v 1.4 2001/11/19 22:33:39 momjian Exp $
- *
- * Some simple tests based on problems reported by users. Hopefully these will
- * help prevent previous problems from re-occuring ;-)
- *
- */
-public class TimeTest extends TestCase
-{
-
- private Connection con;
-
- public TimeTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- con = JDBC2Tests.openDB();
- JDBC2Tests.createTable(con, "testtime", "tm time");
- }
-
- protected void tearDown() throws Exception
- {
- JDBC2Tests.dropTable(con, "testtime");
- JDBC2Tests.closeDB(con);
- }
-
- /*
- * Tests the time methods in ResultSet
- */
- public void testGetTime()
- {
- try
- {
- Statement stmt = con.createStatement();
-
- assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testtime", "'01:02:03'")));
- assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testtime", "'23:59:59'")));
-
- // Fall through helper
- timeTest();
-
- assertEquals(2, stmt.executeUpdate("DELETE FROM testtime"));
- stmt.close();
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Tests the time methods in PreparedStatement
- */
- public void testSetTime()
- {
- try
- {
- PreparedStatement ps = con.prepareStatement(JDBC2Tests.insertSQL("testtime", "?"));
- Statement stmt = con.createStatement();
-
- ps.setTime(1, makeTime(1, 2, 3));
- assertEquals(1, ps.executeUpdate());
-
- ps.setTime(1, makeTime(23, 59, 59));
- assertEquals(1, ps.executeUpdate());
-
- // Fall through helper
- timeTest();
-
- assertEquals(2, stmt.executeUpdate("DELETE FROM testtime"));
- stmt.close();
- ps.close();
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Helper for the TimeTests. It tests what should be in the db
- */
- private void timeTest() throws SQLException
- {
- Statement st = con.createStatement();
- ResultSet rs;
- java.sql.Time t;
-
- rs = st.executeQuery(JDBC2Tests.selectSQL("testtime", "tm"));
- assertNotNull(rs);
-
- assertTrue(rs.next());
- t = rs.getTime(1);
- assertNotNull(t);
- assertEquals(makeTime(1, 2, 3), t);
-
- assertTrue(rs.next());
- t = rs.getTime(1);
- assertNotNull(t);
- assertEquals(makeTime(23, 59, 59), t);
-
- assertTrue(! rs.next());
-
- rs.close();
- }
-
- private java.sql.Time makeTime(int h, int m, int s)
- {
- return java.sql.Time.valueOf(JDBC2Tests.fix(h, 2) + ":" +
- JDBC2Tests.fix(m, 2) + ":" +
- JDBC2Tests.fix(s, 2));
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java
deleted file mode 100644
index f7bf62e6d60..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.JDBC2Tests;
-import junit.framework.TestCase;
-import java.sql.*;
-
-/*
- * $Id: TimestampTest.java,v 1.6 2001/11/19 22:33:39 momjian Exp $
- *
- * This has been the most controversial pair of methods since 6.5 was released!
- *
- * From now on, any changes made to either getTimestamp or setTimestamp
- * MUST PASS this TestCase!!!
- *
- */
-public class TimestampTest extends TestCase
-{
-
- private Connection con;
-
- public TimestampTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- con = JDBC2Tests.openDB();
- Statement stmt = con.createStatement();
-
- JDBC2Tests.createTable(con, "testtimestamp", "ts timestamp");
- }
-
- protected void tearDown() throws Exception
- {
- JDBC2Tests.dropTable(con, "testtimestamp");
- JDBC2Tests.closeDB(con);
- }
-
- /*
- * Tests the time methods in ResultSet
- */
- public void testGetTimestamp()
- {
- try
- {
- Statement stmt = con.createStatement();
-
- assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testtimestamp",
- "'1950-02-07 15:00:00'")));
-
- assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testtimestamp", "'" +
- getTimestamp(1970, 6, 2, 8, 13, 0, 0).toString() +
- "'")));
-
- assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testtimestamp",
- "'1970-06-02 08:13:00'")));
-
- // Fall through helper
- timestampTest();
-
- assertEquals(3, stmt.executeUpdate("DELETE FROM testtimestamp"));
-
- stmt.close();
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Tests the time methods in PreparedStatement
- */
- public void testSetTimestamp()
- {
- try
- {
- Statement stmt = con.createStatement();
- PreparedStatement pstmt = con.prepareStatement(JDBC2Tests.insertSQL("testtimestamp", "?"));
-
- pstmt.setTimestamp(1, getTimestamp(1950, 2, 7, 15, 0, 0, 0));
- assertEquals(1, pstmt.executeUpdate());
-
- pstmt.setTimestamp(1, getTimestamp(1970, 6, 2, 8, 13, 0, 0));
- assertEquals(1, pstmt.executeUpdate());
-
- pstmt.setTimestamp(1, getTimestamp(1970, 6, 2, 8, 13, 0, 0));
- assertEquals(1, pstmt.executeUpdate());
-
- // Fall through helper
- timestampTest();
-
- assertEquals(3, stmt.executeUpdate("DELETE FROM testtimestamp"));
-
- pstmt.close();
- stmt.close();
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
- /*
- * Helper for the TimeTests. It tests what should be in the db
- */
- private void timestampTest() throws SQLException
- {
- Statement stmt = con.createStatement();
- ResultSet rs;
- java.sql.Timestamp t;
-
- rs = stmt.executeQuery(JDBC2Tests.selectSQL("testtimestamp", "ts"));
- assertNotNull(rs);
-
- assertTrue(rs.next());
- t = rs.getTimestamp(1);
- assertNotNull(t);
- assertTrue(t.equals(getTimestamp(1950, 2, 7, 15, 0, 0, 0)));
-
- assertTrue(rs.next());
- t = rs.getTimestamp(1);
- assertNotNull(t);
- assertTrue(t.equals(getTimestamp(1970, 6, 2, 8, 13, 0, 0)));
-
- assertTrue(rs.next());
- t = rs.getTimestamp(1);
- assertNotNull(t);
- assertTrue(t.equals(getTimestamp(1970, 6, 2, 8, 13, 0, 0)));
-
- assertTrue(! rs.next()); // end of table. Fail if more entries exist.
-
- rs.close();
- stmt.close();
- }
-
- private java.sql.Timestamp getTimestamp(int y, int m, int d, int h, int mn, int se, int f)
- {
- return java.sql.Timestamp.valueOf(JDBC2Tests.fix(y, 4) + "-" +
- JDBC2Tests.fix(m, 2) + "-" +
- JDBC2Tests.fix(d, 2) + " " +
- JDBC2Tests.fix(h, 2) + ":" +
- JDBC2Tests.fix(mn, 2) + ":" +
- JDBC2Tests.fix(se, 2) + "." +
- JDBC2Tests.fix(f, 9));
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
deleted file mode 100644
index 722dd78398a..00000000000
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package org.postgresql.test.jdbc2;
-
-import java.sql.*;
-import junit.framework.TestCase;
-
-import org.postgresql.test.JDBC2Tests;
-/**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2001</p>
- * <p>Company: </p>
- * @author unascribed
- * @version 1.0
- */
-
-public class UpdateableResultTest extends TestCase
-{
-
- public UpdateableResultTest( String name )
- {
- super( name );
- }
-
- public void testUpdateable()
- {
- try
- {
- Connection con = JDBC2Tests.openDB();
- JDBC2Tests.createTable(con, "updateable","id int primary key, name text, notselected text");
- JDBC2Tests.createTable(con, "second","id1 int primary key, name1 text");
-
- Statement st1 = con.createStatement();
- boolean retVal = st1.execute( "insert into updateable ( id, name, notselected ) values (1, 'jake', 'avalue')" );
- assert( retVal== false );
-
- retVal = st1.execute( "insert into second (id1, name1) values (1, 'jake')" );
- assertTrue( !retVal );
- st1.close();
-
- Statement st = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );
- ResultSet rs = st.executeQuery( "select id, name, notselected from updateable" );
-
- assertNotNull(rs);
-
- while (rs.next())
- {
- rs.updateInt( "id",2 );
- rs.updateString( "name","dave" );
- rs.updateRow();
- assertTrue( rs.getInt("id") == 2 );
- assertTrue( rs.getString("name").equals("dave"));
- assertTrue( rs.getString("notselected").equals("avalue") );
-
- rs.deleteRow();
- rs.moveToInsertRow();
- rs.updateInt("id",3);
- rs.updateString("name", "paul");
-
- rs.insertRow();
- rs.refreshRow();
- assertTrue( rs.getInt("id") == 3 );
- assertTrue( rs.getString("name").equals("paul"));
- assertTrue( rs.getString("notselected") == null );
-
- }
-
- rs.close();
-
- rs = st.executeQuery("select id1, id, name, name1 from updateable, second" );
- try
- {
- while( rs.next() )
- {
- rs.updateInt( "id",2 );
- rs.updateString( "name","dave" );
- rs.updateRow();
- }
-
-
- assertTrue( "should not get here, update should fail", false );
- }
- catch (SQLException ex){}
-
- try
- {
- rs = st.executeQuery("select oid,* from updateable");
- if ( rs.first() )
- {
- rs.updateInt( "id", 3 );
- rs.updateString( "name", "dave3");
- rs.updateRow();
- assertTrue(rs.getInt("id") == 3 );
- assertTrue(rs.getString("name").equals("dave3"));
-
- rs.moveToInsertRow();
- rs.updateInt( "id", 4 );
- rs.updateString( "name", "dave4" );
-
- rs.insertRow();
- rs.updateInt("id", 5 );
- rs.updateString( "name", "dave5" );
- rs.insertRow();
-
- rs.moveToCurrentRow();
- assertTrue(rs.getInt("id") == 3 );
- assertTrue(rs.getString("name").equals("dave3"));
-
- assertTrue( rs.next() );
- assertTrue(rs.getInt("id") == 4 );
- assertTrue(rs.getString("name").equals("dave4"));
-
- assertTrue( rs.next() );
- assertTrue(rs.getInt("id") == 5 );
- assertTrue(rs.getString("name").equals("dave5"));
-
- }
- }
- catch(SQLException ex)
- {
- fail(ex.getMessage());
- }
-
- st.close();
-
- JDBC2Tests.dropTable( con,"updateable" );
- JDBC2Tests.closeDB( con );
- }
- catch (Exception ex)
- {
- fail(ex.getMessage());
- }
- }
-
-
-} \ No newline at end of file
diff --git a/src/interfaces/jdbc/org/postgresql/util/MD5Digest.java b/src/interfaces/jdbc/org/postgresql/util/MD5Digest.java
deleted file mode 100644
index 4090289dbc3..00000000000
--- a/src/interfaces/jdbc/org/postgresql/util/MD5Digest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.postgresql.util;
-
-/*
- * MD5-based utility function to obfuscate passwords before network transmission
- *
- * @author Jeremy Wohl
- * $Id: MD5Digest.java,v 1.3 2001/11/25 23:26:59 barry Exp $
- */
-
-import java.security.*;
-
-public class MD5Digest
-{
- private MD5Digest()
- {}
-
-
- /*
- * Encodes user/password/salt information in the following way:
- * MD5(MD5(password + user) + salt)
- *
- * @param user The connecting user.
- * @param password The connecting user's password.
- * @param salt A four-character string sent by the server.
- *
- * @return A 35-byte array, comprising the string "md5" and an MD5 digest.
- */
- public static byte[] encode(String user, String password, String salt)
- {
- MessageDigest md;
- byte[] temp_digest, pass_digest;
- byte[] hex_digest = new byte[35];
-
- try
- {
- md = MessageDigest.getInstance("MD5");
-
- md.update(password.getBytes());
- md.update(user.getBytes());
- temp_digest = md.digest();
-
- bytesToHex(temp_digest, hex_digest, 0);
- md.update(hex_digest, 0, 32);
- md.update(salt.getBytes());
- pass_digest = md.digest();
-
- bytesToHex(pass_digest, hex_digest, 3);
- hex_digest[0] = (byte) 'm';
- hex_digest[1] = (byte) 'd';
- hex_digest[2] = (byte) '5';
- }
- catch (Exception e)
- {
- ; // "MessageDigest failure; " + e
- }
-
- return hex_digest;
- }
-
-
- /*
- * Turn 16-byte stream into a human-readable 32-byte hex string
- */
- private static void bytesToHex(byte[] bytes, byte[] hex, int offset)
- {
- final char lookup[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'a', 'b', 'c', 'd', 'e', 'f' };
-
- int i, c, j, pos = offset;
-
- for (i = 0; i < 16; i++)
- {
- c = bytes[i] & 0xFF;
- j = c >> 4;
- hex[pos++] = (byte) lookup[j];
- j = (c & 0xF);
- hex[pos++] = (byte) lookup[j];
- }
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/util/MessageTranslator.java b/src/interfaces/jdbc/org/postgresql/util/MessageTranslator.java
deleted file mode 100644
index 4e16d012ab4..00000000000
--- a/src/interfaces/jdbc/org/postgresql/util/MessageTranslator.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.postgresql.util;
-
-import java.util.*;
-import java.text.*;
-
-/*
- * A singleton class to translate JDBC driver messages in SQLException's.
- */
-public class MessageTranslator
-{
-
- // The singleton instance.
- private static MessageTranslator instance = null;
-
- private ResourceBundle bundle;
-
- private MessageTranslator()
- {
- try
- {
- bundle = ResourceBundle.getBundle("org.postgresql.errors");
- }
- catch (MissingResourceException e)
- {
- // translation files have not been installed.
- bundle = null;
- }
- }
-
- // Synchronized, otherwise multiple threads may perform the test and
- // assign to the singleton instance simultaneously.
- private synchronized final static MessageTranslator getInstance()
- {
- if (instance == null)
- {
- instance = new MessageTranslator();
- }
- return instance;
- }
-
- public final static String translate(String id, Object[] args)
- {
-
- MessageTranslator translator = MessageTranslator.getInstance();
-
- return translator._translate(id, args);
- }
-
- private final String _translate(String id, Object[] args)
- {
- String message;
-
- if (bundle != null && id != null)
- {
- // Now look up a localized message. If one is not found, then use
- // the supplied message instead.
- try
- {
- message = bundle.getString(id);
- }
- catch (MissingResourceException e)
- {
- message = id;
- }
- }
- else
- {
- message = id;
- }
-
- // Expand any arguments
- if (args != null && message != null)
- {
- message = MessageFormat.format(message, args);
- }
-
- return message;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/util/PGbytea.java b/src/interfaces/jdbc/org/postgresql/util/PGbytea.java
deleted file mode 100644
index 93e8afae5ae..00000000000
--- a/src/interfaces/jdbc/org/postgresql/util/PGbytea.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.postgresql.util;
-
-import java.sql.*;
-
-/*
- * Converts to and from the postgresql bytea datatype used by the backend.
- *
- * $Id: PGbytea.java,v 1.4 2002/01/05 22:26:23 barry Exp $
- */
-
-public class PGbytea
-{
-
- /*
- * Converts a PG bytea raw value (i.e. the raw binary representation
- * of the bytea data type) into a java byte[]
- */
- public static byte[] toBytes(byte[] s) throws SQLException
- {
- if (s == null)
- return null;
- int slength = s.length;
- byte[] buf = new byte[slength];
- int bufpos = 0;
- int thebyte;
- byte nextbyte;
- byte secondbyte;
- for (int i = 0; i < slength; i++)
- {
- nextbyte = s[i];
- if (nextbyte == (byte)'\\')
- {
- secondbyte = s[++i];
- if (secondbyte == (byte)'\\')
- {
- //escaped \
- buf[bufpos++] = (byte)'\\';
- }
- else
- {
- thebyte = (secondbyte - 48) * 64 + (s[++i] - 48) * 8 + (s[++i] - 48);
- if (thebyte > 127)
- thebyte -= 256;
- buf[bufpos++] = (byte)thebyte;
- }
- }
- else
- {
- buf[bufpos++] = nextbyte;
- }
- }
- byte[] l_return = new byte[bufpos];
- System.arraycopy(buf, 0, l_return, 0, bufpos);
- return l_return;
- }
-
- /*
- * Converts a java byte[] into a PG bytea string (i.e. the text
- * representation of the bytea data type)
- */
- public static String toPGString(byte[] p_buf) throws SQLException
- {
- if (p_buf == null)
- return null;
- StringBuffer l_strbuf = new StringBuffer();
- for (int i = 0; i < p_buf.length; i++)
- {
- int l_int = (int)p_buf[i];
- if (l_int < 0)
- {
- l_int = 256 + l_int;
- }
- //we escape the same non-printable characters as the backend
- //we must escape all 8bit characters otherwise when convering
- //from java unicode to the db character set we may end up with
- //question marks if the character set is SQL_ASCII
- if (l_int < 040 || l_int > 0176)
- {
- //escape charcter with the form \000, but need two \\ because of
- //the parser
- l_strbuf.append("\\");
- l_strbuf.append((char)(((l_int >> 6) & 0x3) + 48));
- l_strbuf.append((char)(((l_int >> 3) & 0x7) + 48));
- l_strbuf.append((char)((l_int & 0x07) + 48));
- }
- else if (p_buf[i] == (byte)'\\')
- {
- //escape the backslash character as \\, but need four \\\\ because
- //of the parser
- l_strbuf.append("\\\\");
- }
- else
- {
- //other characters are left alone
- l_strbuf.append((char)p_buf[i]);
- }
- }
- return l_strbuf.toString();
- }
-
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/util/PGmoney.java b/src/interfaces/jdbc/org/postgresql/util/PGmoney.java
deleted file mode 100644
index 77e019d7240..00000000000
--- a/src/interfaces/jdbc/org/postgresql/util/PGmoney.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.postgresql.util;
-
-import java.io.*;
-import java.sql.*;
-
-/*
- * This implements a class that handles the PostgreSQL money and cash types
- */
-public class PGmoney extends PGobject implements Serializable, Cloneable
-{
- /*
- * The value of the field
- */
- public double val;
-
- /*
- * @param value of field
- */
- public PGmoney(double value)
- {
- this();
- val = value;
- }
-
- /*
- * This is called mainly from the other geometric types, when a
- * point is imbeded within their definition.
- *
- * @param value Definition of this point in PostgreSQL's syntax
- */
- public PGmoney(String value) throws SQLException
- {
- this();
- setValue(value);
- }
-
- /*
- * Required by the driver
- */
- public PGmoney()
- {
- setType("money");
- }
-
- /*
- * @param s Definition of this point in PostgreSQL's syntax
- * @exception SQLException on conversion failure
- */
- public void setValue(String s) throws SQLException
- {
- try
- {
- String s1;
- boolean negative;
-
- negative = (s.charAt(0) == '(') ;
-
- // Remove any () (for negative) & currency symbol
- s1 = PGtokenizer.removePara(s).substring(1);
-
- // Strip out any , in currency
- int pos = s1.indexOf(',');
- while (pos != -1)
- {
- s1 = s1.substring(0, pos) + s1.substring(pos + 1);
- pos = s1.indexOf(',');
- }
-
- val = Double.valueOf(s1).doubleValue();
- val = negative ? -val : val;
-
- }
- catch (NumberFormatException e)
- {
- throw new PSQLException("postgresql.money", e);
- }
- }
-
- /*
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
- public boolean equals(Object obj)
- {
- if (obj instanceof PGmoney)
- {
- PGmoney p = (PGmoney)obj;
- return val == p.val;
- }
- return false;
- }
-
- /*
- * This must be overidden to allow the object to be cloned
- */
- public Object clone()
- {
- return new PGmoney(val);
- }
-
- /*
- * @return the PGpoint in the syntax expected by org.postgresql
- */
- public String getValue()
- {
- if (val < 0)
- {
- return "-$" + ( -val);
- }
- else
- {
- return "$" + val;
- }
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/util/PGobject.java b/src/interfaces/jdbc/org/postgresql/util/PGobject.java
deleted file mode 100644
index 3370c66eefd..00000000000
--- a/src/interfaces/jdbc/org/postgresql/util/PGobject.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.postgresql.util;
-
-import java.io.*;
-import java.lang.*;
-import java.sql.*;
-import java.util.*;
-
-/*
- * org.postgresql.PG_Object is a class used to describe unknown types
- * An unknown type is any type that is unknown by JDBC Standards
- *
- * <p>As of PostgreSQL 6.3, this allows user code to add their own
- * handlers via a call to org.postgresql.Connection. These handlers
- * must extend this class.
- */
-public class PGobject implements Serializable, Cloneable
-{
- protected String type;
- protected String value;
-
- /*
- * This is called by org.postgresql.Connection.getObject() to create the
- * object.
- */
- public PGobject()
- {}
-
- /*
- * This method sets the type of this object.
- *
- * <p>It should not be extended by subclasses, hence its final
- *
- * @param type a string describing the type of the object
- */
- public final void setType(String type)
- {
- this.type = type;
- }
-
- /*
- * This method sets the value of this object. It must be overidden.
- *
- * @param value a string representation of the value of the object
- * @exception SQLException thrown if value is invalid for this type
- */
- public void setValue(String value) throws SQLException
- {
- this.value = value;
- }
-
- /*
- * As this cannot change during the life of the object, it's final.
- * @return the type name of this object
- */
- public final String getType()
- {
- return type;
- }
-
- /*
- * This must be overidden, to return the value of the object, in the
- * form required by org.postgresql.
- * @return the value of this object
- */
- public String getValue()
- {
- return value;
- }
-
- /*
- * This must be overidden to allow comparisons of objects
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
- public boolean equals(Object obj)
- {
- if (obj instanceof PGobject)
- return ((PGobject)obj).getValue().equals(getValue());
- return false;
- }
-
- /*
- * This must be overidden to allow the object to be cloned
- */
- public Object clone()
- {
- PGobject obj = new PGobject();
- obj.type = type;
- obj.value = value;
- return obj;
- }
-
- /*
- * This is defined here, so user code need not overide it.
- * @return the value of this object, in the syntax expected by org.postgresql
- */
- public String toString()
- {
- return getValue();
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java b/src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java
deleted file mode 100644
index f5fe685e808..00000000000
--- a/src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java
+++ /dev/null
@@ -1,204 +0,0 @@
-package org.postgresql.util;
-
-import java.sql.*;
-import java.util.*;
-
-/*
- * This class is used to tokenize the text output of org.postgres.
- *
- * <p>It's mainly used by the geometric classes, but is useful in parsing any
- * output from custom data types output from org.postgresql.
- *
- * @see org.postgresql.geometric.PGbox
- * @see org.postgresql.geometric.PGcircle
- * @see org.postgresql.geometric.PGlseg
- * @see org.postgresql.geometric.PGpath
- * @see org.postgresql.geometric.PGpoint
- * @see org.postgresql.geometric.PGpolygon
- */
-public class PGtokenizer
-{
- // Our tokens
- protected Vector tokens;
-
- /*
- * Create a tokeniser.
- *
- * <p>We could have used StringTokenizer to do this, however, we needed to
- * handle nesting of '(' ')' '[' ']' '&lt;' and '&gt;' as these are used
- * by the geometric data types.
- *
- * @param string containing tokens
- * @param delim single character to split the tokens
- */
- public PGtokenizer(String string, char delim)
- {
- tokenize(string, delim);
- }
-
- /*
- * This resets this tokenizer with a new string and/or delimiter.
- *
- * @param string containing tokens
- * @param delim single character to split the tokens
- */
- public int tokenize(String string, char delim)
- {
- tokens = new Vector();
-
- // nest holds how many levels we are in the current token.
- // if this is > 0 then we don't split a token when delim is matched.
- //
- // The Geometric datatypes use this, because often a type may have others
- // (usualls PGpoint) imbedded within a token.
- //
- // Peter 1998 Jan 6 - Added < and > to the nesting rules
- int nest = 0, p, s;
-
- for (p = 0, s = 0;p < string.length();p++)
- {
- char c = string.charAt(p);
-
- // increase nesting if an open character is found
- if (c == '(' || c == '[' || c == '<')
- nest++;
-
- // decrease nesting if a close character is found
- if (c == ')' || c == ']' || c == '>')
- nest--;
-
- if (nest == 0 && c == delim)
- {
- tokens.addElement(string.substring(s, p));
- s = p + 1; // +1 to skip the delimiter
- }
-
- }
-
- // Don't forget the last token ;-)
-
-
- if (s < string.length())
- tokens.addElement(string.substring(s));
-
- return tokens.size();
- }
-
- /*
- * @return the number of tokens available
- */
- public int getSize()
- {
- return tokens.size();
- }
-
- /*
- * @param n Token number ( 0 ... getSize()-1 )
- * @return The token value
- */
- public String getToken(int n)
- {
- return (String)tokens.elementAt(n);
- }
-
- /*
- * This returns a new tokenizer based on one of our tokens.
- *
- * The geometric datatypes use this to process nested tokens (usually
- * PGpoint).
- *
- * @param n Token number ( 0 ... getSize()-1 )
- * @param delim The delimiter to use
- * @return A new instance of PGtokenizer based on the token
- */
- public PGtokenizer tokenizeToken(int n, char delim)
- {
- return new PGtokenizer(getToken(n), delim);
- }
-
- /*
- * This removes the lead/trailing strings from a string
- * @param s Source string
- * @param l Leading string to remove
- * @param t Trailing string to remove
- * @return String without the lead/trailing strings
- */
- public static String remove(String s, String l, String t)
- {
- if (s.startsWith(l))
- s = s.substring(l.length());
- if (s.endsWith(t))
- s = s.substring(0, s.length() - t.length());
- return s;
- }
-
- /*
- * This removes the lead/trailing strings from all tokens
- * @param l Leading string to remove
- * @param t Trailing string to remove
- */
- public void remove(String l, String t)
- {
- for (int i = 0;i < tokens.size();i++)
- {
- tokens.setElementAt(remove((String)tokens.elementAt(i), l, t), i);
- }
- }
-
- /*
- * Removes ( and ) from the beginning and end of a string
- * @param s String to remove from
- * @return String without the ( or )
- */
- public static String removePara(String s)
- {
- return remove(s, "(", ")");
- }
-
- /*
- * Removes ( and ) from the beginning and end of all tokens
- * @return String without the ( or )
- */
- public void removePara()
- {
- remove("(", ")");
- }
-
- /*
- * Removes [ and ] from the beginning and end of a string
- * @param s String to remove from
- * @return String without the [ or ]
- */
- public static String removeBox(String s)
- {
- return remove(s, "[", "]");
- }
-
- /*
- * Removes [ and ] from the beginning and end of all tokens
- * @return String without the [ or ]
- */
- public void removeBox()
- {
- remove("[", "]");
- }
-
- /*
- * Removes &lt; and &gt; from the beginning and end of a string
- * @param s String to remove from
- * @return String without the &lt; or &gt;
- */
- public static String removeAngle(String s)
- {
- return remove(s, "<", ">");
- }
-
- /*
- * Removes &lt; and &gt; from the beginning and end of all tokens
- * @return String without the &lt; or &gt;
- */
- public void removeAngle()
- {
- remove("<", ">");
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/util/PSQLException.java b/src/interfaces/jdbc/org/postgresql/util/PSQLException.java
deleted file mode 100644
index 46c71fab11f..00000000000
--- a/src/interfaces/jdbc/org/postgresql/util/PSQLException.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.postgresql.util;
-
-import java.io.*;
-import java.sql.*;
-
-/*
- * This class extends SQLException, and provides our internationalisation handling
- */
-public class PSQLException extends SQLException
-{
- private String message;
-
- /*
- * This provides the same functionality to SQLException
- * @param error Error string
- */
- public PSQLException(String error)
- {
- super();
- translate(error, null);
- }
-
- /*
- * A more generic entry point.
- * @param error Error string or standard message id
- * @param args Array of arguments
- */
- public PSQLException(String error, Object[] args)
- {
- //super();
- translate(error, args);
- }
-
- /*
- * Helper version for 1 arg
- */
- public PSQLException(String error, Object arg)
- {
- super();
- Object[] argv = new Object[1];
- argv[0] = arg;
- translate(error, argv);
- }
-
- /*
- * Helper version for 1 arg. This is used for debug purposes only with
- * some unusual Exception's. It allows the originiating Exceptions stack
- * trace to be returned.
- */
- public PSQLException(String error, Exception ex)
- {
- super();
-
- Object[] argv = new Object[1];
-
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintWriter pw = new PrintWriter(baos);
- pw.println("Exception: " + ex.toString() + "\nStack Trace:\n");
- ex.printStackTrace(pw);
- pw.println("End of Stack Trace");
- pw.flush();
- argv[0] = baos.toString();
- pw.close();
- baos.close();
- }
- catch (Exception ioe)
- {
- argv[0] = ex.toString() + "\nIO Error on stack trace generation! " + ioe.toString();
- }
-
- translate(error, argv);
- }
-
- /*
- * Helper version for 2 args
- */
- public PSQLException(String error, Object arg1, Object arg2)
- {
- super();
- Object[] argv = new Object[2];
- argv[0] = arg1;
- argv[1] = arg2;
- translate(error, argv);
- }
-
- private void translate(String error, Object[] args)
- {
- message = MessageTranslator.translate(error, args);
- }
-
- /*
- * Overides Throwable
- */
- public String getLocalizedMessage()
- {
- return message;
- }
-
- /*
- * Overides Throwable
- */
- public String getMessage()
- {
- return message;
- }
-
- /*
- * Overides Object
- */
- public String toString()
- {
- return message;
- }
-}
diff --git a/src/interfaces/jdbc/org/postgresql/util/Serialize.java b/src/interfaces/jdbc/org/postgresql/util/Serialize.java
deleted file mode 100644
index 80d10bc5410..00000000000
--- a/src/interfaces/jdbc/org/postgresql/util/Serialize.java
+++ /dev/null
@@ -1,623 +0,0 @@
-package org.postgresql.util;
-
-import org.postgresql.Driver;
-import java.io.*;
-import java.lang.*;
-import java.lang.reflect.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-
-/*
- * This class uses PostgreSQL's object oriented features to store Java Objects.<p>
- *
- * It does this by mapping a Java Class name to a table in the database. Each
- * entry in this new table then represents a Serialized instance of this
- * class. As each entry has an OID (Object IDentifier), this OID can be
- * included in another table.<p>
- *
- * Serialize depends on a feature of Postgres that allows
- * a table to be used as a data type. However, Postgres support of
- * this feature is incomplete. The basic ability to create and use
- * a table as a field type in another table exists:<br>
- * CREATE TABLE myclass( var1 TEXT, var2 INTEGER );<br>
- * CREATE TABLE othertable( field1 TEXT, field2 myclass );<br>
- * INSERT INTO myclass VALUES ('Hello', 1);<br>
- * INSERT INTO othertable VALUES ('World', xxxx::myclass);<br>
- * where xxxx is the OID of a row in myclass<br>
- * This lets othertable reference a myclass instance but
- * the support to actually make any use of the myclass data type
- * is not there. For instance, you cannot compare the myclass field
- * with ANY other data type, not even with other myclass values.
- * Casting to and from the myclass type will also not work.
- * From the limited testing done, only the literal xxxx::myclass
- * syntax appears to work.<p>
- *
- * Queries like:<br>
- * SELECT othertable.field2.var1 FROM othertable;<br>
- * will not work but were suggested in the original Postgres
- * design documents.<p>
- * Because support is incomplete for table data types, tables
- * such as othertable that hold java instances should also
- * hold an oid field for the same java instance:<br>
- * CREATE othertable( field1 TEXT, field2 myclass, myclassOID oid);<br>
- * This oid-type field would be set with setInt() immediately after
- * setting the myclass-type field with setObject(). The order of these
- * set calls matters since the oid is not available until after
- * setting the object when inserting a new object. With the oid,
- * queries and comparisons etc. can be done to locate a myclass.
- * Read below about how to include an int oid field in your java class
- * that is updated by setObject() when it is inserted.<p>
- *
- * The myclass table represents a java class. This table is created
- * by Serialize.create(). Serialize.create() must be called before
- * the first use of the myclass java class in PreparedStatement.setObject()
- * calls. This is a one-time initialization step.<p>
- *
- * There are a number of limitations placed on the java class to be
- * used by Serialize:
- * <ul>
- * <li>The class name must be less than 32 chars long and must be all lowercase.
- * This is due to limitations in Postgres about the size of table names.
- * The name must be all lowercase since table names in Postgres are
- * case insensitive and the relname is stored in lowercase. Unless some
- * additional table were to be maintained about the names of java classes,
- * there is no way to know how to go from a Postgres table name back to
- * a java class name with knowledge of case of the letters in the name.
- * <li>The class name must not contain the underscore '_' character since
- * any dots in a java class name are converted to an underscore in
- * its table name and vice versa going back.
- * <li>The class should only contain java primitive types and String.
- * Support for recursively "serializing" a class is not tested but
- * some code for this does exist and you may wish to take a look at it.
- * <li>Only the public fields of the class will be stored in and fetched from
- * the database. Protected and private fields are ignored.
- * <li>Must have a no-arg constructor so that Class.newInstance() may
- * instantiate the class in fetch().
- * <li>Should implement the Serializable interface. This interface
- * may be used more in future releases or in providing an alternative
- * method of storing the java classes in the database. The Serializable
- * interface allows a class instance to be written out as a binary
- * stream of data and is a standard java feature.
- * <li>The class should contain a field defined as:<br>
- * int oid = 0;<br>
- * This field is actually optional and its use by jdbc2.PreparedStatement.setObject()
- * is as follows:<br>
- * If oid does not exist in the class, the class instance is stored in a new table row
- * everytime setObject() is called on it. If oid field exists and is 0, then the class
- * instance is stored into a new row in the table and that row's oid is set in the class by setObject().
- * If oid field exists and is > 0, then the existing table row for the class instance is
- * updated. The oid field should be thought of as read-only unless you want to set it to 0
- * so that a new instance is created in the database rather than doing an update.<p>
- * </ul>
- *
- * Suggested usage:
- * <ol>
- * <li>Create your javaclass and include an int oid = 0; field.
- * <li>Run Serialize.create( conn, javaclass ) to create the table for javaclass (once).
- * <li>Create mytable in the database with fields like: jclassoid INTEGER, jclass JAVACLASS<br>
- * <li>Use a jdbc2.PreparedStatement to insert, update, or select from mytable.
- * Use setObject(2, jclass), followed by setInt(1, jclass.oid) to setup an insert.
- * <li>Use jclass.oid and jclassoid to do queries since the jclass field cannot be used
- * for anything but fetching the javaclass instance with getObject("jclass").
- * </ol>
- * Finally, Serialize is a work in progress and being a utility class, it is not supported.
- * You are "on your own" if you use it. If you use it and make any enhancements,
- * please consider joining the email lists pgsql-jdbc@postgresql.org and pgsql-patches@postgresql.org
- * and contributing your additions.
- */
-public class Serialize
-{
- // This is the connection that the instance refers to
- protected org.postgresql.Connection conn;
-
- // This is the table name
- protected String tableName;
-
- // This is the class name
- protected String className;
-
- // This is the Class for this serialzed object
- protected Class ourClass;
-
- /*
- * This creates an instance that can be used to serialize or deserialize
- * a Java object from a PostgreSQL table.
- */
- public Serialize(org.postgresql.Connection c, String type) throws SQLException
- {
- try
- {
- conn = c;
- if (Driver.logDebug) Driver.debug("Serialize: initializing instance for type: " + type);
- tableName = toPostgreSQL(type);
- className = type;
- ourClass = Class.forName(className);
- }
- catch (ClassNotFoundException cnfe)
- {
- if (Driver.logDebug) Driver.debug("Serialize: " + className + " java class not found");
- throw new PSQLException("postgresql.serial.noclass", type);
- }
-
- // Second check, the type must be a table
- boolean status = false;
- ResultSet rs = conn.ExecSQL("select typname from pg_type,pg_class where typname=relname and typname='" + tableName + "'");
- if (rs != null)
- {
- if (rs.next())
- {
- status = true;
- if (Driver.logDebug) Driver.debug("Serialize: " + tableName + " table found");
- }
- rs.close();
- }
- // This should never occur, as org.postgresql has it's own internal checks
- if (!status)
- {
- if (Driver.logDebug) Driver.debug("Serialize: " + tableName + " table not found");
- throw new PSQLException("postgresql.serial.table", type);
- }
- // Finally cache the fields within the table
- }
-
- /*
- * Constructor when Object is passed in
- */
- public Serialize(org.postgresql.Connection c, Object o) throws SQLException
- {
- this(c, o.getClass().getName());
- }
-
- /*
- * Constructor when Class is passed in
- */
- public Serialize(org.postgresql.Connection c, Class cls) throws SQLException
- {
- this(c, cls.getName());
- }
-
- /*
- * This fetches an object from a table, given it's OID
- * @param oid The oid of the object
- * @return Object relating to oid
- * @exception SQLException on error
- */
- public Object fetch(int oid) throws SQLException
- {
- try
- {
- if (Driver.logDebug) Driver.debug("Serialize.fetch: " + "attempting to instantiate object of type: " + ourClass.getName() );
- Object obj = ourClass.newInstance();
- if (Driver.logDebug) Driver.debug("Serialize.fetch: " + "instantiated object of type: " + ourClass.getName() );
-
- // NB: we use java.lang.reflect here to prevent confusion with
- // the org.postgresql.Field
-
- // used getFields to get only public fields. We have no way to set values
- // for other declarations. Maybe look for setFieldName() methods?
- java.lang.reflect.Field f[] = ourClass.getFields();
- boolean hasOID = false;
- int oidFIELD = -1;
-
- StringBuffer sb = new StringBuffer("select");
- char sep = ' ';
- // build a select for the fields. Look for the oid field to use in the where
- for (int i = 0;i < f.length;i++)
- {
- String n = f[i].getName();
- if (n.equals("oid"))
- {
- hasOID = true;
- oidFIELD = i;
- }
- sb.append(sep);
- sb.append(n);
- sep = ',';
- }
- sb.append(" from ");
- sb.append(tableName);
- sb.append(" where oid=");
- sb.append(oid);
-
- if (Driver.logDebug) Driver.debug("Serialize.fetch: " + sb.toString());
- ResultSet rs = conn.ExecSQL(sb.toString());
-
- if (rs != null)
- {
- if (rs.next())
- {
- for (int i = 0;i < f.length;i++)
- {
- if ( !Modifier.isFinal(f[i].getModifiers()) )
- {
- if ( f[i].getType().getName().equals("short") )
- f[i].setShort(obj, rs.getShort(i + 1));
- else if ( f[i].getType().getName().equals("char") )
- f[i].setChar(obj, rs.getString(i + 1).toCharArray()[0]);
- else if ( f[i].getType().getName().equals("byte"))
- f[i].setByte(obj, rs.getByte(i + 1));
- else if ( f[i].getType().getName().equals("boolean") )
- {
- // booleans come out of pgsql as a t or an f
- if ( rs.getString(i + 1).equals("t") )
- f[i].setBoolean(obj, true);
- else
- f[i].setBoolean(obj, false);
- }
- else
- f[i].set(obj, rs.getObject(i + 1));
- }
- }
- }
- rs.close();
- }
- else
- throw new PSQLException("postgresql.unexpected");
-
- return obj;
-
- }
- catch (IllegalAccessException iae)
- {
- throw new SQLException(iae.toString());
- }
- catch (InstantiationException ie)
- {
- throw new SQLException(ie.toString());
- }
- }
-
- /*
- * This stores an object into a table, returning it's OID.<p>
- * This method was deprecated in 7.2 because the value of an OID
- * can be larger than a java signed int.
- * @deprecated Replaced by storeObject() in 7.2
- */
- public int store(Object o) throws SQLException
- {
- return (int) storeObject(o);
- }
-
- /*
- * This stores an object into a table, returning it's OID.<p>
- *
- * If the object has an int called OID, and it is > 0, then
- * that value is used for the OID, and the table will be updated.
- * If the value of OID is 0, then a new row will be created, and the
- * value of OID will be set in the object. This enables an object's
- * value in the database to be updateable.
- *
- * If the object has no int called OID, then the object is stored. However
- * if the object is later retrieved, amended and stored again, it's new
- * state will be appended to the table, and will not overwrite the old
- * entries.
- *
- * @param o Object to store (must implement Serializable)
- * @return oid of stored object
- * @exception SQLException on error
- * @since 7.2
- */
- public long storeObject(Object o) throws SQLException
- {
- try
- {
- // NB: we use java.lang.reflect here to prevent confusion with
- // the org.postgresql.Field
-
- // don't save private fields since we would not be able to fetch them
- java.lang.reflect.Field f[] = ourClass.getFields();
-
- boolean hasOID = false;
- int oidFIELD = -1;
- boolean update = false;
-
- // Find out if we have an oid value
- for (int i = 0;i < f.length;i++)
- {
- String n = f[i].getName();
- if (n.equals("oid"))
- {
- hasOID = true;
- oidFIELD = i;
- // Do update if oid != 0
- update = f[i].getInt(o) > 0;
- }
- }
-
- StringBuffer sb = new StringBuffer(update ? "update " + tableName + " set" : "insert into " + tableName + " ");
- char sep = update ? ' ' : '(';
- for (int i = 0;i < f.length;i++)
- {
- String n = f[i].getName();
- // oid cannot be updated!
- if ( n.equals("oid") )
- continue;
- sb.append(sep);
- sep = ',';
- sb.append(n);
- if (update)
- {
- sb.append('=');
- // handle unset values
- if (f[i].get(o) == null)
- sb.append("null");
- else if (
- f[i].getType().getName().equals("java.lang.String")
- || f[i].getType().getName().equals("char") )
- {
- sb.append('\'');
- // don't allow single qoutes or newlines in the string
- sb.append(fixString(f[i].get(o).toString()));
- sb.append('\'');
- }
- else
- sb.append(f[i].get(o).toString());
- }
- }
-
- if (update)
- sb.append(" where oid = " + f[oidFIELD].getInt(o) );
-
- if (!update)
- {
- sb.append(") values ");
- sep = '(';
- for (int i = 0;i < f.length;i++)
- {
- String n = f[i].getName();
- // oid cannot be set!
- if ( n.equals("oid") )
- continue;
- sb.append(sep);
- sep = ',';
- // handle unset values
- if (f[i].get(o) == null)
- sb.append("null");
- else if (
- f[i].getType().getName().equals("java.lang.String")
- || f[i].getType().getName().equals("char"))
- {
- sb.append('\'');
- // don't allow single quotes or newlines in the string
- sb.append(fixString(f[i].get(o).toString()));
- sb.append('\'');
- }
- else
- sb.append(f[i].get(o).toString());
- }
- sb.append(')');
- }
-
- if (Driver.logDebug) Driver.debug("Serialize.store: " + sb.toString() );
- org.postgresql.ResultSet rs = (org.postgresql.ResultSet) conn.ExecSQL(sb.toString());
-
- // fetch the OID for returning
- if (update)
- {
- // object has oid already, so return it
- if (rs != null)
- rs.close();
- return f[oidFIELD].getInt(o);
- }
- else
- {
- // new record inserted has new oid; rs should be not null
- long newOID = ((org.postgresql.ResultSet)rs).getLastOID();
- rs.close();
- // update the java object's oid field if it has the oid field
- if (hasOID)
- f[oidFIELD].setLong(o, newOID);
- // new object stored, return newly inserted oid
- return newOID;
- }
-
- }
- catch (IllegalAccessException iae)
- {
- throw new SQLException(iae.toString());
- }
- }
-
- /*
- * Escape literal single quote and backslashes embedded in strings/chars.
- * Otherwise, postgres will bomb on the single quote and remove the
- * the backslashes.
- */
- private String fixString(String s)
- {
- int idx = -1;
-
- // handle null
- if (s == null)
- return "";
-
- // if the string has single quotes in it escape them as ''
- if ((idx = s.indexOf("'")) > -1)
- {
- StringBuffer buf = new StringBuffer();
- StringTokenizer tok = new StringTokenizer(s, "'");
- // handle quote as 1St charater
- if (idx > 0)
- buf.append(tok.nextToken());
-
- while (tok.hasMoreTokens())
- buf.append("''").append(tok.nextToken());
-
- s = buf.toString();
- }
-
- // if the string has backslashes in it escape them them as \\
- if ((idx = s.indexOf("\\")) > -1)
- {
- StringBuffer buf = new StringBuffer();
- StringTokenizer tok = new StringTokenizer(s, "\\");
- if (idx > 0)
- buf.append(tok.nextToken());
-
- while (tok.hasMoreTokens())
- buf.append("\\\\").append(tok.nextToken());
-
- s = buf.toString();
- }
-
- return s;
- }
-
- /*
- * This method is not used by the driver, but it creates a table, given
- * a Serializable Java Object. It should be used before serializing any
- * objects.
- * @param c Connection to database
- * @param o Object to base table on
- * @exception SQLException on error
- */
- public static void create(org.postgresql.Connection con, Object o) throws SQLException
- {
- create(con, o.getClass());
- }
-
- /*
- * This method is not used by the driver, but it creates a table, given
- * a Serializable Java Object. It should be used before serializing any
- * objects.
- * @param c Connection to database
- * @param o Class to base table on
- * @exception SQLException on error
- */
- public static void create(org.postgresql.Connection con, Class c) throws SQLException
- {
- if (c.isInterface())
- throw new PSQLException("postgresql.serial.interface");
-
- // See if the table exists
- String tableName = toPostgreSQL(c.getName());
-
- ResultSet rs = con.ExecSQL("select relname from pg_class where relname = '" + tableName + "'");
- if ( rs.next() )
- {
- if (Driver.logDebug) Driver.debug("Serialize.create: table " + tableName + " exists, skipping");
- rs.close();
- return;
- }
-
- // else table not found, so create it
- if (Driver.logDebug) Driver.debug("Serialize.create: table " + tableName + " not found, creating" );
- // No entries returned, so the table doesn't exist
-
- StringBuffer sb = new StringBuffer("create table ");
- sb.append(tableName);
- char sep = '(';
-
- // java.lang.reflect.Field[] fields = c.getDeclaredFields();
- // Only store public fields, another limitation!
- java.lang.reflect.Field[] fields = c.getFields();
- for (int i = 0;i < fields.length;i++)
- {
- Class type = fields[i].getType();
- // oid is a special field
- if (!fields[i].getName().equals("oid"))
- {
- sb.append(sep);
- sb.append(fields[i].getName());
- sb.append(' ');
- sep = ',';
-
- if (type.isArray())
- {
- // array handling
- }
- else
- {
- // convert the java type to org.postgresql, recursing if a class
- // is found
- String n = type.getName();
- int j = 0;
- for (;j < tp.length && !tp[j][0].equals(n);j++)
- ;
- if (j < tp.length)
- sb.append(tp[j][1]);
- else
- {
- create(con, type);
- sb.append(toPostgreSQL(n));
- }
- }
- }
- }
- sb.append(")");
-
- // Now create the table
- if (Driver.logDebug) Driver.debug("Serialize.create: " + sb );
- con.ExecSQL(sb.toString());
- }
-
- // This is used to translate between Java primitives and PostgreSQL types.
- private static final String tp[][] = {
- // {"boolean", "int1"},
- {"boolean", "bool"},
- {"double", "float8"},
- {"float", "float4"},
- {"int", "int4"},
- // {"long", "int4"},
- {"long", "int8"},
- {"short", "int2"},
- {"java.lang.String", "text"},
- {"java.lang.Integer", "int4"},
- {"java.lang.Float", "float4"},
- {"java.lang.Double", "float8"},
- {"java.lang.Short", "int2"},
- {"char", "char"},
- {"byte", "int2"}
- };
-
- /*
- * This converts a Java Class name to a org.postgresql table, by replacing . with
- * _<p>
- *
- * Because of this, a Class name may not have _ in the name.<p>
- * Another limitation, is that the entire class name (including packages)
- * cannot be longer than 32 characters (a limit forced by PostgreSQL).
- *
- * @param name Class name
- * @return PostgreSQL table name
- * @exception SQLException on error
- */
- public static String toPostgreSQL(String name) throws SQLException
- {
- name = name.toLowerCase();
-
- if (name.indexOf("_") > -1)
- throw new PSQLException("postgresql.serial.underscore");
-
- // Postgres table names can only be 32 character long.
- // Reserve 1 char, so allow only up to 31 chars.
- // If the full class name with package is too long
- // then just use the class name. If the class name is
- // too long throw an exception.
- //
- if ( name.length() > 31 )
- {
- name = name.substring(name.lastIndexOf(".") + 1);
- if ( name.length() > 31 )
- throw new PSQLException("postgresql.serial.namelength", name, new Integer(name.length()));
- }
- return name.replace('.', '_');
- }
-
-
- /*
- * This converts a org.postgresql table to a Java Class name, by replacing _ with
- * .<p>
- *
- * @param name PostgreSQL table name
- * @return Class name
- * @exception SQLException on error
- */
- public static String toClassName(String name) throws SQLException
- {
- name = name.toLowerCase();
- return name.replace('_', '.');
- }
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/util/UnixCrypt.java b/src/interfaces/jdbc/org/postgresql/util/UnixCrypt.java
deleted file mode 100644
index 049cb80c1e9..00000000000
--- a/src/interfaces/jdbc/org/postgresql/util/UnixCrypt.java
+++ /dev/null
@@ -1,684 +0,0 @@
-package org.postgresql.util;
-
-/*
- * This class provides us with the ability to encrypt passwords when sent
- * over the network stream
- *
- * <P>Contains static methods to encrypt and compare
- * passwords with Unix encrypted passwords.</P>
- *
- * <P>See <A HREF="http://www.zeh.com/local/jfd/crypt.html">
- * John Dumas's Java Crypt page</A> for the original source.</P>
- *
- * @author jdumas@zgs.com (John Dumas)
- */
-public class UnixCrypt extends Object
-{
- //
- // Null constructor - can't instantiate class
- private UnixCrypt()
- {}
-
- private static final char[] saltChars =
- ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./".toCharArray());
-
- private static final int ITERATIONS = 16;
-
- private static final int con_salt[] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
- 0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
- 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12,
- 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A,
- 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22,
- 0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24,
- 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
- 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
- 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
- 0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
-
- private static final boolean shifts2[] =
- {
- false, false, true, true, true, true, true, true,
- false, true, true, true, true, true, true, false
- };
-
- private static final int skb[][] =
- {
- {
- /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
- 0x00000000, 0x00000010, 0x20000000, 0x20000010,
- 0x00010000, 0x00010010, 0x20010000, 0x20010010,
- 0x00000800, 0x00000810, 0x20000800, 0x20000810,
- 0x00010800, 0x00010810, 0x20010800, 0x20010810,
- 0x00000020, 0x00000030, 0x20000020, 0x20000030,
- 0x00010020, 0x00010030, 0x20010020, 0x20010030,
- 0x00000820, 0x00000830, 0x20000820, 0x20000830,
- 0x00010820, 0x00010830, 0x20010820, 0x20010830,
- 0x00080000, 0x00080010, 0x20080000, 0x20080010,
- 0x00090000, 0x00090010, 0x20090000, 0x20090010,
- 0x00080800, 0x00080810, 0x20080800, 0x20080810,
- 0x00090800, 0x00090810, 0x20090800, 0x20090810,
- 0x00080020, 0x00080030, 0x20080020, 0x20080030,
- 0x00090020, 0x00090030, 0x20090020, 0x20090030,
- 0x00080820, 0x00080830, 0x20080820, 0x20080830,
- 0x00090820, 0x00090830, 0x20090820, 0x20090830,
- },
- {
- /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
- 0x00000000, 0x02000000, 0x00002000, 0x02002000,
- 0x00200000, 0x02200000, 0x00202000, 0x02202000,
- 0x00000004, 0x02000004, 0x00002004, 0x02002004,
- 0x00200004, 0x02200004, 0x00202004, 0x02202004,
- 0x00000400, 0x02000400, 0x00002400, 0x02002400,
- 0x00200400, 0x02200400, 0x00202400, 0x02202400,
- 0x00000404, 0x02000404, 0x00002404, 0x02002404,
- 0x00200404, 0x02200404, 0x00202404, 0x02202404,
- 0x10000000, 0x12000000, 0x10002000, 0x12002000,
- 0x10200000, 0x12200000, 0x10202000, 0x12202000,
- 0x10000004, 0x12000004, 0x10002004, 0x12002004,
- 0x10200004, 0x12200004, 0x10202004, 0x12202004,
- 0x10000400, 0x12000400, 0x10002400, 0x12002400,
- 0x10200400, 0x12200400, 0x10202400, 0x12202400,
- 0x10000404, 0x12000404, 0x10002404, 0x12002404,
- 0x10200404, 0x12200404, 0x10202404, 0x12202404,
- },
- {
- /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
- 0x00000000, 0x00000001, 0x00040000, 0x00040001,
- 0x01000000, 0x01000001, 0x01040000, 0x01040001,
- 0x00000002, 0x00000003, 0x00040002, 0x00040003,
- 0x01000002, 0x01000003, 0x01040002, 0x01040003,
- 0x00000200, 0x00000201, 0x00040200, 0x00040201,
- 0x01000200, 0x01000201, 0x01040200, 0x01040201,
- 0x00000202, 0x00000203, 0x00040202, 0x00040203,
- 0x01000202, 0x01000203, 0x01040202, 0x01040203,
- 0x08000000, 0x08000001, 0x08040000, 0x08040001,
- 0x09000000, 0x09000001, 0x09040000, 0x09040001,
- 0x08000002, 0x08000003, 0x08040002, 0x08040003,
- 0x09000002, 0x09000003, 0x09040002, 0x09040003,
- 0x08000200, 0x08000201, 0x08040200, 0x08040201,
- 0x09000200, 0x09000201, 0x09040200, 0x09040201,
- 0x08000202, 0x08000203, 0x08040202, 0x08040203,
- 0x09000202, 0x09000203, 0x09040202, 0x09040203,
- },
- {
- /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
- 0x00000000, 0x00100000, 0x00000100, 0x00100100,
- 0x00000008, 0x00100008, 0x00000108, 0x00100108,
- 0x00001000, 0x00101000, 0x00001100, 0x00101100,
- 0x00001008, 0x00101008, 0x00001108, 0x00101108,
- 0x04000000, 0x04100000, 0x04000100, 0x04100100,
- 0x04000008, 0x04100008, 0x04000108, 0x04100108,
- 0x04001000, 0x04101000, 0x04001100, 0x04101100,
- 0x04001008, 0x04101008, 0x04001108, 0x04101108,
- 0x00020000, 0x00120000, 0x00020100, 0x00120100,
- 0x00020008, 0x00120008, 0x00020108, 0x00120108,
- 0x00021000, 0x00121000, 0x00021100, 0x00121100,
- 0x00021008, 0x00121008, 0x00021108, 0x00121108,
- 0x04020000, 0x04120000, 0x04020100, 0x04120100,
- 0x04020008, 0x04120008, 0x04020108, 0x04120108,
- 0x04021000, 0x04121000, 0x04021100, 0x04121100,
- 0x04021008, 0x04121008, 0x04021108, 0x04121108,
- },
- {
- /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
- 0x00000000, 0x10000000, 0x00010000, 0x10010000,
- 0x00000004, 0x10000004, 0x00010004, 0x10010004,
- 0x20000000, 0x30000000, 0x20010000, 0x30010000,
- 0x20000004, 0x30000004, 0x20010004, 0x30010004,
- 0x00100000, 0x10100000, 0x00110000, 0x10110000,
- 0x00100004, 0x10100004, 0x00110004, 0x10110004,
- 0x20100000, 0x30100000, 0x20110000, 0x30110000,
- 0x20100004, 0x30100004, 0x20110004, 0x30110004,
- 0x00001000, 0x10001000, 0x00011000, 0x10011000,
- 0x00001004, 0x10001004, 0x00011004, 0x10011004,
- 0x20001000, 0x30001000, 0x20011000, 0x30011000,
- 0x20001004, 0x30001004, 0x20011004, 0x30011004,
- 0x00101000, 0x10101000, 0x00111000, 0x10111000,
- 0x00101004, 0x10101004, 0x00111004, 0x10111004,
- 0x20101000, 0x30101000, 0x20111000, 0x30111000,
- 0x20101004, 0x30101004, 0x20111004, 0x30111004,
- },
- {
- /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
- 0x00000000, 0x08000000, 0x00000008, 0x08000008,
- 0x00000400, 0x08000400, 0x00000408, 0x08000408,
- 0x00020000, 0x08020000, 0x00020008, 0x08020008,
- 0x00020400, 0x08020400, 0x00020408, 0x08020408,
- 0x00000001, 0x08000001, 0x00000009, 0x08000009,
- 0x00000401, 0x08000401, 0x00000409, 0x08000409,
- 0x00020001, 0x08020001, 0x00020009, 0x08020009,
- 0x00020401, 0x08020401, 0x00020409, 0x08020409,
- 0x02000000, 0x0A000000, 0x02000008, 0x0A000008,
- 0x02000400, 0x0A000400, 0x02000408, 0x0A000408,
- 0x02020000, 0x0A020000, 0x02020008, 0x0A020008,
- 0x02020400, 0x0A020400, 0x02020408, 0x0A020408,
- 0x02000001, 0x0A000001, 0x02000009, 0x0A000009,
- 0x02000401, 0x0A000401, 0x02000409, 0x0A000409,
- 0x02020001, 0x0A020001, 0x02020009, 0x0A020009,
- 0x02020401, 0x0A020401, 0x02020409, 0x0A020409,
- },
- {
- /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
- 0x00000000, 0x00000100, 0x00080000, 0x00080100,
- 0x01000000, 0x01000100, 0x01080000, 0x01080100,
- 0x00000010, 0x00000110, 0x00080010, 0x00080110,
- 0x01000010, 0x01000110, 0x01080010, 0x01080110,
- 0x00200000, 0x00200100, 0x00280000, 0x00280100,
- 0x01200000, 0x01200100, 0x01280000, 0x01280100,
- 0x00200010, 0x00200110, 0x00280010, 0x00280110,
- 0x01200010, 0x01200110, 0x01280010, 0x01280110,
- 0x00000200, 0x00000300, 0x00080200, 0x00080300,
- 0x01000200, 0x01000300, 0x01080200, 0x01080300,
- 0x00000210, 0x00000310, 0x00080210, 0x00080310,
- 0x01000210, 0x01000310, 0x01080210, 0x01080310,
- 0x00200200, 0x00200300, 0x00280200, 0x00280300,
- 0x01200200, 0x01200300, 0x01280200, 0x01280300,
- 0x00200210, 0x00200310, 0x00280210, 0x00280310,
- 0x01200210, 0x01200310, 0x01280210, 0x01280310,
- },
- {
- /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
- 0x00000000, 0x04000000, 0x00040000, 0x04040000,
- 0x00000002, 0x04000002, 0x00040002, 0x04040002,
- 0x00002000, 0x04002000, 0x00042000, 0x04042000,
- 0x00002002, 0x04002002, 0x00042002, 0x04042002,
- 0x00000020, 0x04000020, 0x00040020, 0x04040020,
- 0x00000022, 0x04000022, 0x00040022, 0x04040022,
- 0x00002020, 0x04002020, 0x00042020, 0x04042020,
- 0x00002022, 0x04002022, 0x00042022, 0x04042022,
- 0x00000800, 0x04000800, 0x00040800, 0x04040800,
- 0x00000802, 0x04000802, 0x00040802, 0x04040802,
- 0x00002800, 0x04002800, 0x00042800, 0x04042800,
- 0x00002802, 0x04002802, 0x00042802, 0x04042802,
- 0x00000820, 0x04000820, 0x00040820, 0x04040820,
- 0x00000822, 0x04000822, 0x00040822, 0x04040822,
- 0x00002820, 0x04002820, 0x00042820, 0x04042820,
- 0x00002822, 0x04002822, 0x00042822, 0x04042822,
- },
- };
-
- private static final int SPtrans[][] =
- {
- {
- /* nibble 0 */
- 0x00820200, 0x00020000, 0x80800000, 0x80820200,
- 0x00800000, 0x80020200, 0x80020000, 0x80800000,
- 0x80020200, 0x00820200, 0x00820000, 0x80000200,
- 0x80800200, 0x00800000, 0x00000000, 0x80020000,
- 0x00020000, 0x80000000, 0x00800200, 0x00020200,
- 0x80820200, 0x00820000, 0x80000200, 0x00800200,
- 0x80000000, 0x00000200, 0x00020200, 0x80820000,
- 0x00000200, 0x80800200, 0x80820000, 0x00000000,
- 0x00000000, 0x80820200, 0x00800200, 0x80020000,
- 0x00820200, 0x00020000, 0x80000200, 0x00800200,
- 0x80820000, 0x00000200, 0x00020200, 0x80800000,
- 0x80020200, 0x80000000, 0x80800000, 0x00820000,
- 0x80820200, 0x00020200, 0x00820000, 0x80800200,
- 0x00800000, 0x80000200, 0x80020000, 0x00000000,
- 0x00020000, 0x00800000, 0x80800200, 0x00820200,
- 0x80000000, 0x80820000, 0x00000200, 0x80020200,
- },
- {
- /* nibble 1 */
- 0x10042004, 0x00000000, 0x00042000, 0x10040000,
- 0x10000004, 0x00002004, 0x10002000, 0x00042000,
- 0x00002000, 0x10040004, 0x00000004, 0x10002000,
- 0x00040004, 0x10042000, 0x10040000, 0x00000004,
- 0x00040000, 0x10002004, 0x10040004, 0x00002000,
- 0x00042004, 0x10000000, 0x00000000, 0x00040004,
- 0x10002004, 0x00042004, 0x10042000, 0x10000004,
- 0x10000000, 0x00040000, 0x00002004, 0x10042004,
- 0x00040004, 0x10042000, 0x10002000, 0x00042004,
- 0x10042004, 0x00040004, 0x10000004, 0x00000000,
- 0x10000000, 0x00002004, 0x00040000, 0x10040004,
- 0x00002000, 0x10000000, 0x00042004, 0x10002004,
- 0x10042000, 0x00002000, 0x00000000, 0x10000004,
- 0x00000004, 0x10042004, 0x00042000, 0x10040000,
- 0x10040004, 0x00040000, 0x00002004, 0x10002000,
- 0x10002004, 0x00000004, 0x10040000, 0x00042000,
- },
- {
- /* nibble 2 */
- 0x41000000, 0x01010040, 0x00000040, 0x41000040,
- 0x40010000, 0x01000000, 0x41000040, 0x00010040,
- 0x01000040, 0x00010000, 0x01010000, 0x40000000,
- 0x41010040, 0x40000040, 0x40000000, 0x41010000,
- 0x00000000, 0x40010000, 0x01010040, 0x00000040,
- 0x40000040, 0x41010040, 0x00010000, 0x41000000,
- 0x41010000, 0x01000040, 0x40010040, 0x01010000,
- 0x00010040, 0x00000000, 0x01000000, 0x40010040,
- 0x01010040, 0x00000040, 0x40000000, 0x00010000,
- 0x40000040, 0x40010000, 0x01010000, 0x41000040,
- 0x00000000, 0x01010040, 0x00010040, 0x41010000,
- 0x40010000, 0x01000000, 0x41010040, 0x40000000,
- 0x40010040, 0x41000000, 0x01000000, 0x41010040,
- 0x00010000, 0x01000040, 0x41000040, 0x00010040,
- 0x01000040, 0x00000000, 0x41010000, 0x40000040,
- 0x41000000, 0x40010040, 0x00000040, 0x01010000,
- },
- {
- /* nibble 3 */
- 0x00100402, 0x04000400, 0x00000002, 0x04100402,
- 0x00000000, 0x04100000, 0x04000402, 0x00100002,
- 0x04100400, 0x04000002, 0x04000000, 0x00000402,
- 0x04000002, 0x00100402, 0x00100000, 0x04000000,
- 0x04100002, 0x00100400, 0x00000400, 0x00000002,
- 0x00100400, 0x04000402, 0x04100000, 0x00000400,
- 0x00000402, 0x00000000, 0x00100002, 0x04100400,
- 0x04000400, 0x04100002, 0x04100402, 0x00100000,
- 0x04100002, 0x00000402, 0x00100000, 0x04000002,
- 0x00100400, 0x04000400, 0x00000002, 0x04100000,
- 0x04000402, 0x00000000, 0x00000400, 0x00100002,
- 0x00000000, 0x04100002, 0x04100400, 0x00000400,
- 0x04000000, 0x04100402, 0x00100402, 0x00100000,
- 0x04100402, 0x00000002, 0x04000400, 0x00100402,
- 0x00100002, 0x00100400, 0x04100000, 0x04000402,
- 0x00000402, 0x04000000, 0x04000002, 0x04100400,
- },
- {
- /* nibble 4 */
- 0x02000000, 0x00004000, 0x00000100, 0x02004108,
- 0x02004008, 0x02000100, 0x00004108, 0x02004000,
- 0x00004000, 0x00000008, 0x02000008, 0x00004100,
- 0x02000108, 0x02004008, 0x02004100, 0x00000000,
- 0x00004100, 0x02000000, 0x00004008, 0x00000108,
- 0x02000100, 0x00004108, 0x00000000, 0x02000008,
- 0x00000008, 0x02000108, 0x02004108, 0x00004008,
- 0x02004000, 0x00000100, 0x00000108, 0x02004100,
- 0x02004100, 0x02000108, 0x00004008, 0x02004000,
- 0x00004000, 0x00000008, 0x02000008, 0x02000100,
- 0x02000000, 0x00004100, 0x02004108, 0x00000000,
- 0x00004108, 0x02000000, 0x00000100, 0x00004008,
- 0x02000108, 0x00000100, 0x00000000, 0x02004108,
- 0x02004008, 0x02004100, 0x00000108, 0x00004000,
- 0x00004100, 0x02004008, 0x02000100, 0x00000108,
- 0x00000008, 0x00004108, 0x02004000, 0x02000008,
- },
- {
- /* nibble 5 */
- 0x20000010, 0x00080010, 0x00000000, 0x20080800,
- 0x00080010, 0x00000800, 0x20000810, 0x00080000,
- 0x00000810, 0x20080810, 0x00080800, 0x20000000,
- 0x20000800, 0x20000010, 0x20080000, 0x00080810,
- 0x00080000, 0x20000810, 0x20080010, 0x00000000,
- 0x00000800, 0x00000010, 0x20080800, 0x20080010,
- 0x20080810, 0x20080000, 0x20000000, 0x00000810,
- 0x00000010, 0x00080800, 0x00080810, 0x20000800,
- 0x00000810, 0x20000000, 0x20000800, 0x00080810,
- 0x20080800, 0x00080010, 0x00000000, 0x20000800,
- 0x20000000, 0x00000800, 0x20080010, 0x00080000,
- 0x00080010, 0x20080810, 0x00080800, 0x00000010,
- 0x20080810, 0x00080800, 0x00080000, 0x20000810,
- 0x20000010, 0x20080000, 0x00080810, 0x00000000,
- 0x00000800, 0x20000010, 0x20000810, 0x20080800,
- 0x20080000, 0x00000810, 0x00000010, 0x20080010,
- },
- {
- /* nibble 6 */
- 0x00001000, 0x00000080, 0x00400080, 0x00400001,
- 0x00401081, 0x00001001, 0x00001080, 0x00000000,
- 0x00400000, 0x00400081, 0x00000081, 0x00401000,
- 0x00000001, 0x00401080, 0x00401000, 0x00000081,
- 0x00400081, 0x00001000, 0x00001001, 0x00401081,
- 0x00000000, 0x00400080, 0x00400001, 0x00001080,
- 0x00401001, 0x00001081, 0x00401080, 0x00000001,
- 0x00001081, 0x00401001, 0x00000080, 0x00400000,
- 0x00001081, 0x00401000, 0x00401001, 0x00000081,
- 0x00001000, 0x00000080, 0x00400000, 0x00401001,
- 0x00400081, 0x00001081, 0x00001080, 0x00000000,
- 0x00000080, 0x00400001, 0x00000001, 0x00400080,
- 0x00000000, 0x00400081, 0x00400080, 0x00001080,
- 0x00000081, 0x00001000, 0x00401081, 0x00400000,
- 0x00401080, 0x00000001, 0x00001001, 0x00401081,
- 0x00400001, 0x00401080, 0x00401000, 0x00001001,
- },
- {
- /* nibble 7 */
- 0x08200020, 0x08208000, 0x00008020, 0x00000000,
- 0x08008000, 0x00200020, 0x08200000, 0x08208020,
- 0x00000020, 0x08000000, 0x00208000, 0x00008020,
- 0x00208020, 0x08008020, 0x08000020, 0x08200000,
- 0x00008000, 0x00208020, 0x00200020, 0x08008000,
- 0x08208020, 0x08000020, 0x00000000, 0x00208000,
- 0x08000000, 0x00200000, 0x08008020, 0x08200020,
- 0x00200000, 0x00008000, 0x08208000, 0x00000020,
- 0x00200000, 0x00008000, 0x08000020, 0x08208020,
- 0x00008020, 0x08000000, 0x00000000, 0x00208000,
- 0x08200020, 0x08008020, 0x08008000, 0x00200020,
- 0x08208000, 0x00000020, 0x00200020, 0x08008000,
- 0x08208020, 0x00200000, 0x08200000, 0x08000020,
- 0x00208000, 0x00008020, 0x08008020, 0x08200000,
- 0x00000020, 0x08208000, 0x00208020, 0x00000000,
- 0x08000000, 0x08200020, 0x00008000, 0x00208020
- }
- };
-
- private static final int cov_2char[] =
- {
- 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
- 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44,
- 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C,
- 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
- 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62,
- 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
- 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72,
- 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
- };
-
- private static final int byteToUnsigned(byte b)
- {
- int value = (int)b;
-
- return (value >= 0 ? value : value + 256);
- }
-
- private static int fourBytesToInt(byte b[], int offset)
- {
- int value;
-
- value = byteToUnsigned(b[offset++]);
- value |= (byteToUnsigned(b[offset++]) << 8);
- value |= (byteToUnsigned(b[offset++]) << 16);
- value |= (byteToUnsigned(b[offset++]) << 24);
-
- return (value);
- }
-
- private static final void intToFourBytes(int iValue, byte b[], int offset)
- {
- b[offset++] = (byte)((iValue) & 0xff);
- b[offset++] = (byte)((iValue >>> 8 ) & 0xff);
- b[offset++] = (byte)((iValue >>> 16) & 0xff);
- b[offset++] = (byte)((iValue >>> 24) & 0xff);
- }
-
- private static final void PERM_OP(int a, int b, int n, int m, int results[])
- {
- int t;
-
- t = ((a >>> n) ^ b) & m;
- a ^= t << n;
- b ^= t;
-
- results[0] = a;
- results[1] = b;
- }
-
- private static final int HPERM_OP(int a, int n, int m)
- {
- int t;
-
- t = ((a << (16 - n)) ^ a) & m;
- a = a ^ t ^ (t >>> (16 - n));
-
- return (a);
- }
-
- private static int [] des_set_key(byte key[])
- {
- int schedule[] = new int[ITERATIONS * 2];
-
- int c = fourBytesToInt(key, 0);
- int d = fourBytesToInt(key, 4);
-
- int results[] = new int[2];
-
- PERM_OP(d, c, 4, 0x0f0f0f0f, results);
- d = results[0];
- c = results[1];
-
- c = HPERM_OP(c, -2, 0xcccc0000);
- d = HPERM_OP(d, -2, 0xcccc0000);
-
- PERM_OP(d, c, 1, 0x55555555, results);
- d = results[0];
- c = results[1];
-
- PERM_OP(c, d, 8, 0x00ff00ff, results);
- c = results[0];
- d = results[1];
-
- PERM_OP(d, c, 1, 0x55555555, results);
- d = results[0];
- c = results[1];
-
- d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) |
- ((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4));
- c &= 0x0fffffff;
-
- int s, t;
- int j = 0;
-
- for (int i = 0; i < ITERATIONS; i ++)
- {
- if (shifts2[i])
- {
- c = (c >>> 2) | (c << 26);
- d = (d >>> 2) | (d << 26);
- }
- else
- {
- c = (c >>> 1) | (c << 27);
- d = (d >>> 1) | (d << 27);
- }
-
- c &= 0x0fffffff;
- d &= 0x0fffffff;
-
- s = skb[0][ (c ) & 0x3f ] |
- skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)] |
- skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)] |
- skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) |
- ((c >>> 22) & 0x38)];
-
- t = skb[4][ (d ) & 0x3f ] |
- skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)] |
- skb[6][ (d >>> 15) & 0x3f ] |
- skb[7][((d >>> 21) & 0x0f) | ((d >>> 22) & 0x30)];
-
- schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff;
- s = ((s >>> 16) | (t & 0xffff0000));
-
- s = (s << 4) | (s >>> 28);
- schedule[j++] = s & 0xffffffff;
- }
- return (schedule);
- }
-
- private static final int D_ENCRYPT
- (
- int L, int R, int S, int E0, int E1, int s[]
- )
- {
- int t, u, v;
-
- v = R ^ (R >>> 16);
- u = v & E0;
- v = v & E1;
- u = (u ^ (u << 16)) ^ R ^ s[S];
- t = (v ^ (v << 16)) ^ R ^ s[S + 1];
- t = (t >>> 4) | (t << 28);
-
- L ^= SPtrans[1][(t ) & 0x3f] |
- SPtrans[3][(t >>> 8) & 0x3f] |
- SPtrans[5][(t >>> 16) & 0x3f] |
- SPtrans[7][(t >>> 24) & 0x3f] |
- SPtrans[0][(u ) & 0x3f] |
- SPtrans[2][(u >>> 8) & 0x3f] |
- SPtrans[4][(u >>> 16) & 0x3f] |
- SPtrans[6][(u >>> 24) & 0x3f];
-
- return (L);
- }
-
- private static final int [] body(int schedule[], int Eswap0, int Eswap1)
- {
- int left = 0;
- int right = 0;
- int t = 0;
-
- for (int j = 0; j < 25; j ++)
- {
- for (int i = 0; i < ITERATIONS * 2; i += 4)
- {
- left = D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule);
- right = D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule);
- }
- t = left;
- left = right;
- right = t;
- }
-
- t = right;
-
- right = (left >>> 1) | (left << 31);
- left = (t >>> 1) | (t << 31);
-
- left &= 0xffffffff;
- right &= 0xffffffff;
-
- int results[] = new int[2];
-
- PERM_OP(right, left, 1, 0x55555555, results);
- right = results[0];
- left = results[1];
-
- PERM_OP(left, right, 8, 0x00ff00ff, results);
- left = results[0];
- right = results[1];
-
- PERM_OP(right, left, 2, 0x33333333, results);
- right = results[0];
- left = results[1];
-
- PERM_OP(left, right, 16, 0x0000ffff, results);
- left = results[0];
- right = results[1];
-
- PERM_OP(right, left, 4, 0x0f0f0f0f, results);
- right = results[0];
- left = results[1];
-
- int out[] = new int[2];
-
- out[0] = left;
- out[1] = right;
-
- return (out);
- }
-
- /*
- * <P>Encrypt a password given the cleartext password and a "salt".</P>
- * @param salt A two-character string representing the salt used to
- * iterate the encryption engine in lots of different ways. If you
- * are generating a new encryption then this value should be
- * randomised.
- * @param original The password to be encrypted.
- * @return A string consisting of the 2-character salt followed by the
- * encrypted password.
- */
- public static final String crypt(String salt, String original)
- {
- while (salt.length() < 2)
- salt += "A";
-
- StringBuffer buffer = new StringBuffer(" ");
-
- char charZero = salt.charAt(0);
- char charOne = salt.charAt(1);
-
- buffer.setCharAt(0, charZero);
- buffer.setCharAt(1, charOne);
-
- int Eswap0 = con_salt[(int)charZero];
- int Eswap1 = con_salt[(int)charOne] << 4;
-
- byte key[] = new byte[8];
-
- for (int i = 0; i < key.length; i ++)
- key[i] = (byte)0;
-
- for (int i = 0; i < key.length && i < original.length(); i ++)
- {
- int iChar = (int)original.charAt(i);
-
- key[i] = (byte)(iChar << 1);
- }
-
- int schedule[] = des_set_key(key);
- int out[] = body(schedule, Eswap0, Eswap1);
-
- byte b[] = new byte[9];
-
- intToFourBytes(out[0], b, 0);
- intToFourBytes(out[1], b, 4);
- b[8] = 0;
-
- for (int i = 2, y = 0, u = 0x80; i < 13; i ++)
- {
- for (int j = 0, c = 0; j < 6; j ++)
- {
- c <<= 1;
-
- if (((int)b[y] & u) != 0)
- c |= 1;
-
- u >>>= 1;
-
- if (u == 0)
- {
- y++;
- u = 0x80;
- }
- buffer.setCharAt(i, (char)cov_2char[c]);
- }
- }
- return (buffer.toString());
- }
-
- /*
- * <P>Encrypt a password given the cleartext password. This method
- * generates a random salt using the 'java.util.Random' class.</P>
- * @param original The password to be encrypted.
- * @return A string consisting of the 2-character salt followed by the
- * encrypted password.
- */
- public static final String crypt(String original)
- {
- java.util.Random randomGenerator = new java.util.Random();
- int numSaltChars = saltChars.length;
- String salt;
-
- salt = (new StringBuffer()).append(saltChars[Math.abs(randomGenerator.nextInt()) % numSaltChars]).append(saltChars[Math.abs(randomGenerator.nextInt()) % numSaltChars]).toString();
-
- return crypt(salt, original);
- }
-
- /*
- * <P>Check that <I>enteredPassword</I> encrypts to
- * <I>encryptedPassword</I>.</P>
- * @param encryptedPassword The <I>encryptedPassword</I>. The first
- * two characters are assumed to be the salt. This string would
- * be the same as one found in a Unix <U>/etc/passwd</U> file.
- * @param enteredPassword The password as entered by the user (or
- * otherwise aquired).
- * @return <B>true</B> if the password should be considered correct.
- */
- public final static boolean matches(String encryptedPassword, String enteredPassword)
- {
- String salt = encryptedPassword.substring(0, 3);
- String newCrypt = crypt(salt, enteredPassword);
-
- return newCrypt.equals(encryptedPassword);
- }
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/xa/ClientConnection.java b/src/interfaces/jdbc/org/postgresql/xa/ClientConnection.java
deleted file mode 100644
index dc46c873e8c..00000000000
--- a/src/interfaces/jdbc/org/postgresql/xa/ClientConnection.java
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
-* Redistribution and use of this software and associated documentation
-* ("Software"), with or without modification, are permitted provided
-* that the following conditions are met:
-*
-* 1. Redistributions of source code must retain copyright
-* statements and notices. Redistributions must also contain a
-* copy of this document.
-*
-* 2. Redistributions in binary form must reproduce the
-* above copyright notice, this list of conditions and the
-* following disclaimer in the documentation and/or other
-* materials provided with the distribution.
-*
-* 3. The name "Exolab" must not be used to endorse or promote
-* products derived from this Software without prior written
-* permission of Exoffice Technologies. For written permission,
-* please contact info@exolab.org.
-*
-* 4. Products derived from this Software may not be called "Exolab"
-* nor may "Exolab" appear in their names without prior written
-* permission of Exoffice Technologies. Exolab is a registered
-* trademark of Exoffice Technologies.
-*
-* 5. Due credit should be given to the Exolab Project
-* (http://www.exolab.org/).
-*
-* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
-* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
-* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-* OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
-*
-* $Id: ClientConnection.java,v 1.4 2001/11/19 23:19:21 momjian Exp $
-*/
-
-
-package org.postgresql.xa;
-
-
-import java.util.*;
-import java.sql.*;
-
-
-/*
- * Encapsulates an application's view of an XA/pooled connection.
- * The XA connection is managed by the application server through it's
- * {@link javax.sql.XAConnection} interface. The underlying JDBC
- * connection is a standard JDBC connection. The application's
- * JDBC connection gives access to the underlying JDBC connection but
- * is managed by the application server. The application is given an
- * instance of this class and not the underlying connection directly.
- *
- *
- * @author <a href="arkin@exoffice.com">Assaf Arkin</a>
- * @version 1.0
- * @see XAConnectionImpl
- * @see XADataSourceImpl
- * @see Connection
- */
-final class ClientConnection
- implements Connection
-{
-
-
- /*
- * The pooled XA connection that created this client connection
- * and should be used to report closure and fatal errors.
- */
- private XAConnectionImpl _xaConn;
-
-
- /*
- * This identifier was handed on to use when we were created by
- * {@link XAConnection}. If since then the XA connection was asked
- * to create another connection or was closed, our identifier will
- * no longer be valid and any call to {@link
- * XAConnection#getUnderlying} will throw an exception. Previously,
- * the XA connection would hold a reference to use and tell us to
- * terminate, but that prevented ClientConnection from being
- * finalized.
- */
- private int _clientId;
-
-
-
-
- /*
- * Construct a new client connection to provide access to the
- * underlying JDBC connection (<tt>underlying</tt>) on behalf of
- * an XA/pooled connection (<tt>xaConn<tt/>). The pooled connection
- * is required to notify of connection closure and fatal errors.
- *
- * @param xaConn The XA/pooled connection that created this
- * client connection
- * @param clientId A unique identifier handed to us by
- * {@link XAConnection}
- * @param underlying The underlying JDBC connection
- */
- ClientConnection( XAConnectionImpl xaConn, int clientId )
- {
- _xaConn = xaConn;
- _clientId = clientId;
- }
-
-
- public Statement createStatement()
- throws SQLException
- {
- try
- {
- return getUnderlying().createStatement();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public Statement createStatement( int resultSetType, int resultSetConcurrency )
- throws SQLException
- {
- try
- {
- return getUnderlying().createStatement( resultSetType, resultSetConcurrency );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public PreparedStatement prepareStatement( String sql )
- throws SQLException
- {
- try
- {
- return getUnderlying().prepareStatement( sql );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public PreparedStatement prepareStatement( String sql, int resultSetType, int resultSetConcurrency )
- throws SQLException
- {
- try
- {
- return getUnderlying().prepareStatement( sql, resultSetType, resultSetConcurrency );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public CallableStatement prepareCall( String sql )
- throws SQLException
- {
- try
- {
- return getUnderlying().prepareCall( sql );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public CallableStatement prepareCall( String sql, int resultSetType, int resultSetConcurrency )
- throws SQLException
- {
- try
- {
- return getUnderlying().prepareCall( sql, resultSetType, resultSetConcurrency );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public String nativeSQL( String sql )
- throws SQLException
- {
- try
- {
- return getUnderlying().nativeSQL( sql );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public DatabaseMetaData getMetaData()
- throws SQLException
- {
- try
- {
- return getUnderlying().getMetaData();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public void setCatalog( String catalog )
- throws SQLException
- {
- try
- {
- getUnderlying().setCatalog( catalog );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public String getCatalog()
- throws SQLException
- {
- try
- {
- return getUnderlying().getCatalog();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public SQLWarning getWarnings()
- throws SQLException
- {
- try
- {
- return getUnderlying().getWarnings();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public void clearWarnings()
- throws SQLException
- {
- try
- {
- getUnderlying().clearWarnings();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public Map getTypeMap()
- throws SQLException
- {
- try
- {
- return getUnderlying().getTypeMap();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public void setTypeMap( Map map )
- throws SQLException
- {
- try
- {
- getUnderlying().setTypeMap( map );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public void setAutoCommit( boolean autoCommit )
- throws SQLException
- {
- // Cannot set auto-commit inside a transaction.
- if ( _xaConn.insideGlobalTx() )
- throw new SQLException( "Cannot commit/rollback a connection managed by the transaction manager" );
- try
- {
- getUnderlying().setAutoCommit( autoCommit );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public boolean getAutoCommit()
- throws SQLException
- {
- try
- {
- return getUnderlying().getAutoCommit();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public void commit()
- throws SQLException
- {
- // Cannot commit directly if we're inside a global transaction.
- if ( _xaConn.insideGlobalTx() )
- throw new SQLException( "Cannot commit/rollback a connection managed by the transaction manager" );
- // Cannot commit a read-only transaction.
- if ( isReadOnly() )
- throw new SQLException( "Cannot commit/rollback a read-only transaction" );
-
- // This only occurs if not inside a local transaction.
- try
- {
- getUnderlying().commit();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
-
- public void rollback()
- throws SQLException
- {
- // Cannot commit directly if we're inside a global transaction.
- if ( _xaConn.insideGlobalTx() )
- throw new SQLException( "Cannot commit/rollback a connection managed by the transaction manager" );
-
- // This only occurs if not inside a local transaction.
- try
- {
- getUnderlying().rollback();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public void setReadOnly( boolean readOnly )
- throws SQLException
- {
- try
- {
- getUnderlying().setReadOnly( readOnly );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public boolean isReadOnly()
- throws SQLException
- {
- try
- {
- return getUnderlying().isReadOnly();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public void setTransactionIsolation( int level )
- throws SQLException
- {
- try
- {
- getUnderlying().setTransactionIsolation( level );
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public int getTransactionIsolation()
- throws SQLException
- {
- try
- {
- return getUnderlying().getTransactionIsolation();
- }
- catch ( SQLException except )
- {
- notifyError( except );
- throw except;
- }
- }
-
-
- public synchronized void close()
- throws SQLException
- {
- if ( _xaConn == null )
- return;
-
- // Notify the XA connection that we are no longer going
- // to be used. Whether the underlying connection is released,
- // held until the transaction terminates, etc is not
- // a concern of us.
- _xaConn.notifyClose( _clientId );
- _xaConn = null;
- }
-
-
- public synchronized boolean isClosed()
- {
- // Simple way of determining if this connection is closed.
- // The actual connection is never closed, it is pooled.
- return ( _xaConn == null );
- }
-
-
- /*
- * Called by {@link XAConnectionImpl} to terminate this connection
- * by dissociating it from the underlying JDBC connection.
- * The application would call {@link #close} but {@link
- * XAConnectionImpl} cannot, since pooled connection requirements
- * will cause an inifinite loop. This method should not attempt
- * to notify either a closure or fatal error, but rather throw an
- * exception if it fails.
- */
- /* Deprecated: see XAConnection._clientId
- void terminate()
-{
- _xaConn = null;
-}
- */
-
-
- protected void finalize()
- throws Throwable
- {
- close();
- }
-
-
- public String toString()
- {
- try
- {
- return getUnderlying().toString();
- }
- catch ( SQLException except )
- {
- return "XAConnection: Connection closed";
- }
- }
-
-
- /*
- * Called when an exception is thrown by the underlying connection
- * to determine whether the exception is critical or not. If the
- * exception is critical, notifies the XA connection to forget
- * about this connection.
- *
- * @param except The exception thrown by the underlying
- * connection
- */
- void notifyError( SQLException except )
- {
- if ( _xaConn != null )
- _xaConn.notifyError( _clientId, except );
- }
-
-
- /*
- * Called to retrieve the underlying JDBC connection. Actual JDBC
- * operations are performed against it. Throws an SQLException if
- * this connection has been closed.
- */
- Connection getUnderlying()
- throws SQLException
- {
- if ( _xaConn == null )
- throw new SQLException( "This connection has been closed" );
- // Must pass the client identifier so XAConnection can determine
- // whether we are still valid. If it tells us we're no longer
- // valid, we have little to do.
- try
- {
- return _xaConn.getUnderlying( _clientId );
- }
- catch ( SQLException except )
- {
- _xaConn = null;
- throw except;
- }
- }
-
-
-}
-
-
-
diff --git a/src/interfaces/jdbc/org/postgresql/xa/TwoPhaseConnection.java b/src/interfaces/jdbc/org/postgresql/xa/TwoPhaseConnection.java
deleted file mode 100644
index 7b0ce88f498..00000000000
--- a/src/interfaces/jdbc/org/postgresql/xa/TwoPhaseConnection.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-* Redistribution and use of this software and associated documentation
-* ("Software"), with or without modification, are permitted provided
-* that the following conditions are met:
-*
-* 1. Redistributions of source code must retain copyright
-* statements and notices. Redistributions must also contain a
-* copy of this document.
-*
-* 2. Redistributions in binary form must reproduce the
-* above copyright notice, this list of conditions and the
-* following disclaimer in the documentation and/or other
-* materials provided with the distribution.
-*
-* 3. The name "Exolab" must not be used to endorse or promote
-* products derived from this Software without prior written
-* permission of Exoffice Technologies. For written permission,
-* please contact info@exolab.org.
-*
-* 4. Products derived from this Software may not be called "Exolab"
-* nor may "Exolab" appear in their names without prior written
-* permission of Exoffice Technologies. Exolab is a registered
-* trademark of Exoffice Technologies.
-*
-* 5. Due credit should be given to the Exolab Project
-* (http://www.exolab.org/).
-*
-* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
-* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
-* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-* OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
-*
-* $Id: TwoPhaseConnection.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
-*/
-
-
-package org.postgresql.xa;
-
-
-import java.sql.SQLException;
-
-
-/*
- * Defines two-phase commit support for a JDBC connection used by
- * {@link XAConnection}. A JDBC connection that can implement any of
- * these features should extend this interface and attempt to
- * implement as much as it can.
- * <p>
- * {@link #prepare} is used as part of the two phase commit protocol
- * to determine whether the transaction can commit or must rollback.
- * Failure to implement this method will cause all connections to vote
- * for commit, whether or not they can actually commit, leading to
- * mixed heuristics.
- * <p>
- * {@link #enableSQLTransactions} allows the SQL begin/commit/rollback
- * commands to be disabled for the duration of a transaction managed
- * through an {@link javax.transaction.xaXAResource}, preventing the
- * application from demarcating transactions directly.
- * <p>
- * {@link #isCriticalError} is used to tell if an exception thrown by
- * the connection is fatal and the connection should not be returned
- * to the pool.
- *
- *
- * @author <a href="arkin@exoffice.com">Assaf Arkin</a>
- * @version 1.0
- */
-public interface TwoPhaseConnection
-{
-
-
- /*
- * Enables or disables transaction demarcation through SQL commit
- * and rollback. When the connection falls under control of
- * {@link XAConnection}, SQL commit/rollback commands will be
- * disabled to prevent direct transaction demarcation.
- *
- * @param flag True to enable SQL transactions (the default)
- */
- public void enableSQLTransactions( boolean flag );
-
-
- /*
- * Called to prepare the transaction for commit. Returns true if
- * the transaction is prepared, false if the transaction is
- * read-only. If the transaction has been marked for rollback,
- * throws a {@link RollbackException}.
- *
- * @return True if can commit, false if read-only
- * @throws SQLException If transaction has been marked for
- * rollback or cannot commit for any other reason
- */
- public boolean prepare()
- throws SQLException;
-
-
- /*
- * Returns true if the error issued by this connection is a
- * critical error and the connection should be terminated.
- *
- * @param except The exception thrown by this connection
- */
- public boolean isCriticalError( SQLException except );
-
-
-}
diff --git a/src/interfaces/jdbc/org/postgresql/xa/TxConnection.java b/src/interfaces/jdbc/org/postgresql/xa/TxConnection.java
deleted file mode 100644
index ef2179285f0..00000000000
--- a/src/interfaces/jdbc/org/postgresql/xa/TxConnection.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-* Redistribution and use of this software and associated documentation
-* ("Software"), with or without modification, are permitted provided
-* that the following conditions are met:
-*
-* 1. Redistributions of source code must retain copyright
-* statements and notices. Redistributions must also contain a
-* copy of this document.
-*
-* 2. Redistributions in binary form must reproduce the
-* above copyright notice, this list of conditions and the
-* following disclaimer in the documentation and/or other
-* materials provided with the distribution.
-*
-* 3. The name "Exolab" must not be used to endorse or promote
-* products derived from this Software without prior written
-* permission of Exoffice Technologies. For written permission,
-* please contact info@exolab.org.
-*
-* 4. Products derived from this Software may not be called "Exolab"
-* nor may "Exolab" appear in their names without prior written
-* permission of Exoffice Technologies. Exolab is a registered
-* trademark of Exoffice Technologies.
-*
-* 5. Due credit should be given to the Exolab Project
-* (http://www.exolab.org/).
-*
-* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
-* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
-* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-* OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
-*
-* $Id: TxConnection.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
-*/
-
-
-package org.postgresql.xa;
-
-
-import java.sql.Connection;
-import javax.transaction.xa.Xid;
-
-
-/*
- * Describes an open connection associated with a transaction. When a
- * transaction is opened for a connection, this record is created for
- * the connection. It indicates the underlying JDBC connection and
- * transaction Xid. Multiple XA connection that fall under the same
- * transaction Xid will share the same TxConnection object.
- *
- *
- * @author <a href="arkin@exoffice.com">Assaf Arkin</a>
- * @version 1.0
- * @see Xid
- * @see XAConnectionImpl
- */
-final class TxConnection
-{
-
-
- /*
- * The Xid of the transactions. Connections that are not
- * associated with a transaction are not represented here.
- */
- Xid xid;
-
-
- /*
- * Holds the underlying JDBC connection for as long as this
- * connection is useable. If the connection has been rolled back,
- * timed out or had any other error, this variable will null
- * and the connection is considered failed.
- */
- Connection conn;
-
-
-
- /*
- * Indicates the clock time (in ms) when the transaction should
- * time out. The transaction times out when
- * <tt>System.currentTimeMillis() > timeout</tt>.
- */
- long timeout;
-
-
- /*
- * Indicates the clock time (in ms) when the transaction started.
- */
- long started;
-
-
- /*
- * Reference counter indicates how many XA connections share this
- * underlying connection and transaction. Always one or more.
- */
- int count;
-
-
- /*
- * True if the transaction has failed due to time out.
- */
- boolean timedOut;
-
-
- /*
- * True if the transaction has already been prepared.
- */
- boolean prepared;
-
-
- /*
- * True if the transaction has been prepared and found out to be
- * read-only. Read-only transactions do not require commit/rollback.
- */
- boolean readOnly;
-
-
-}
-
diff --git a/src/interfaces/jdbc/org/postgresql/xa/XAConnectionImpl.java b/src/interfaces/jdbc/org/postgresql/xa/XAConnectionImpl.java
deleted file mode 100644
index 776badfd6d4..00000000000
--- a/src/interfaces/jdbc/org/postgresql/xa/XAConnectionImpl.java
+++ /dev/null
@@ -1,956 +0,0 @@
-/*
-* Redistribution and use of this software and associated documentation
-* ("Software"), with or without modification, are permitted provided
-* that the following conditions are met:
-*
-* 1. Redistributions of source code must retain copyright
-* statements and notices. Redistributions must also contain a
-* copy of this document.
-*
-* 2. Redistributions in binary form must reproduce the
-* above copyright notice, this list of conditions and the
-* following disclaimer in the documentation and/or other
-* materials provided with the distribution.
-*
-* 3. The name "Exolab" must not be used to endorse or promote
-* products derived from this Software without prior written
-* permission of Exoffice Technologies. For written permission,
-* please contact info@exolab.org.
-*
-* 4. Products derived from this Software may not be called "Exolab"
-* nor may "Exolab" appear in their names without prior written
-* permission of Exoffice Technologies. Exolab is a registered
-* trademark of Exoffice Technologies.
-*
-* 5. Due credit should be given to the Exolab Project
-* (http://www.exolab.org/).
-*
-* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
-* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
-* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-* OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
-*
-* $Id: XAConnectionImpl.java,v 1.4 2001/11/19 23:19:21 momjian Exp $
-*/
-
-
-package org.postgresql.xa;
-
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Vector;
-import javax.sql.XAConnection;
-import javax.sql.PooledConnection;
-import javax.sql.ConnectionEvent;
-import javax.sql.ConnectionEventListener;
-import javax.transaction.RollbackException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import javax.transaction.xa.XAException;
-
-
-/*
- * Implements an X/A connection that can be pooled and managed from
- * inside a transaction monitor. This is the XA connection returned
- * to the application server from the {@link XADataSourceImpl} and
- * will be used to obtain {@link ClientConnection} for the
- * application.
- * <p>
- * If the transaction is managed through the JDBC interface, this
- * connection will reference the underlying JDBC connection directly.
- * If this resource is enlisted with a global transaction through
- * the {@link XAResource} interface, it will reference a transactional
- * connection, or {@link TxConnection}. Such a connection may be
- * shared by two or more XA connections enlisted with the same
- * transaction.
- *
- *
- * @author <a href="arkin@exoffice.com">Assaf Arkin</a>
- * @version 1.0
- * @see ClientConnection
- * @see ConnectionEventListener
- * @see TxConnection
- */
-public final class XAConnectionImpl
- implements XAConnection, XAResource
-{
-
-
- /*
- * This is the underlying JDBC connection represented
- * by this pooled connection. This variable may initially be null,
- * in which case {@link #getUnderlying} will return a new
- * connection and set this variable. This variable is mutually
- * exclusive with {@link #_txConn} and is always null for
- * connections inside a transaction.
- */
- Connection _underlying;
-
-
- /*
- * If this connection is part of a global transaction, this
- * object identifies the transaction. The transaction's
- * underlying JDBC connection is exposed through this object and
- * {@link #_underlying} is null. If this connection is closed,
- * then the connection has been timedout. Commit/rollback will
- * always set this variable to null.
- */
- private TxConnection _txConn;
-
-
- /*
- * The client connection last handed to the application. If the
- * application calls {@link #getConnection} again, we should hand
- * out a new client connection and render the previous one closed.
- */
- // No longer in use, see _clientId
- //private ClientConnection _clientConn;
-
-
- /*
- * An event listener can be registered and notified when the
- * client connection has been closed by the application or a
- * fatal error rendered it unuseable.
- */
- private ConnectionEventListener _listener;
-
-
- /*
- * The resource manager is used to share connections within the
- * same transaction.
- */
- private XADataSourceImpl _resManager;
-
-
- /*
- * This is an identifier we hand to the client connection when we
- * create it. When the client connection asks for the underlying
- * connection, we compare the identifiers. If since that point we
- * created a new client connection, we regard an old client
- * connection as discarded and do not hand it the underlying
- * connection.
- * <p>
- * Previously, when a new client connection was created, we used
- * a reference to the old one to terminate it. This proved to
- * not work well, since the client connection could never be
- * finalized.
- */
- private int _clientId = 1;
-
-
- /*
- * Construct a new XA/pooled connection with the underlying JDBC
- * connection suitable for this driver only. This is a one to one
- * mapping between this connection and the underlying connection.
- * The underlying connection is only provided for pooled
- * connections. XA connections are suspect of being enlisted with
- * a global transaction which might already bear an underlying
- * connection. If not, one will be created later on.
- */
- XAConnectionImpl( XADataSourceImpl resManager,
- Connection underlying )
- {
- _underlying = underlying;
- _resManager = resManager;
- }
-
-
- public synchronized void close()
- throws SQLException
- {
- // This is our indication that this connection has been
- // closed programmatically.
- if ( _resManager == null )
- throw new SQLException( "This connection has been closed" );
-
- // The client connection is no longer useable.
- /* Deprecated: see _clientId
- if ( _clientConn != null )
- _clientConn.terminate();
- */
- _clientId = -1;
-
- // The underlying connection is closed and this connection
- // is no longer useable. This method can be called any number
- // of times (e.g. we use it in finalizer). We do not handle
- // transactions, we just kill the connection.
- try
- {
- if ( _underlying != null )
- {
- _underlying.commit();
- _underlying.close();
- }
- else if ( _txConn != null )
- {
- try
- {
- end( _txConn.xid, TMSUCCESS );
- }
- catch ( XAException except )
- { }
- }
- }
- finally
- {
- _resManager = null;
- _underlying = null;
- _txConn = null;
- _listener = null;
- }
- }
-
-
- public XAResource getXAResource()
- {
- // The connection acts as it's own resource manager
- return this;
- }
-
-
- public synchronized void addConnectionEventListener( ConnectionEventListener listener )
- {
- if ( listener == null )
- throw new NullPointerException( "XAConnection: Argument 'listener' is null" );
- if ( _listener != null )
- throw new IllegalStateException( "XAConnection: Only one listener supported per connection" );
- _listener = listener;
- }
-
-
- public synchronized void removeConnectionEventListener( ConnectionEventListener listener )
- {
- if ( listener == null )
- throw new NullPointerException( "XAConnection: Argument 'listener' is null" );
- if ( _listener == null || _listener != listener )
- throw new IllegalStateException( "XAConnection: Listener never registered with this pooled connection" );
- _listener = null;
- }
-
-
- public synchronized java.sql.Connection getConnection()
- throws SQLException
- {
- // If this pooled connection has been closed, throw an exception.
- if ( _resManager == null )
- throw new SQLException( "This connection has been closed" );
-
- // If getConnection() was called before and the underlying
- // connection was not closed, we take it away from the previous
- // recieved as per the PooledConnection design.
- /* Deprecated: see _clientId
- if ( _clientConn != null )
- _clientConn.terminate();
- */
-
- // If we are handling an underlying connection, we commit the
- // old transaction and are ready to work for a new one.
- // If we are part of a global transaction we hope that end/
- // start were called properly, but we're not longer in that
- // transaction.
- if ( _underlying != null )
- {
- try
- {
- _underlying.commit();
- }
- catch ( SQLException except )
- {
- ConnectionEvent event;
-
- if ( _listener != null )
- {
- event = new ConnectionEvent( this, except );
- _listener.connectionErrorOccurred( event );
- }
- }
- }
-
- // Create a new ClientConnection which will be returned to the
- // application. The ClientConnection cannot be closed directly
- // and cannot manage it's own transactions.
- /* Deprecated: see _clientId
- _clientConn = new ClientConnection( this );
- return _clientConn;
- */
- return new ClientConnection( this, ++_clientId );
- }
-
-
- /*
- * Called by {@link ClientConnection} to notify that the application
- * has attempted to close the connection. After this call, the client
- * connection is no longer useable and this pooled connection can be
- * reused. The event listener is notified immediately.
- *
- * @param clientId The {@link ClientConnection} identifier
- */
- synchronized void notifyClose( int clientId )
- {
- ConnectionEvent event;
-
- // ClientConnection has been closed, we dissociated it from
- // the underlying connection and notify any listener that this
- // pooled connection can be reused.
- /* Deprecated: see clientId
- _clientConn.terminate();
- _clientConn = null;
- */
- // We have to expect being called by a ClientConnection that we
- // no longer regard as valid. That's acceptable, we just ignore.
- if ( clientId != _clientId )
- return;
-
- // If we are handling an underlying connection, we commit the
- // old transaction and are ready to work for a new one.
- // If we are part of a global transaction we hope that end/
- // start were called properly.
- if ( _underlying != null )
- {
- try
- {
- _underlying.commit();
- }
- catch ( SQLException except )
- {
- if ( _listener != null )
- {
- event = new ConnectionEvent( this, except );
- _listener.connectionErrorOccurred( event );
- }
- return;
- }
- }
- // Notify the listener.
- if ( _listener != null )
- {
- event = new ConnectionEvent( this );
- _listener.connectionClosed( event );
- }
- }
-
-
- /*
- * Called by {@link ClientConnection} to notify that an error
- * occured with the underlying connection. If the error is
- * critical, the underlying connection is closed and the listener
- * is notified.
- *
- * @param clientId The {@link ClientConnection} identifier
- * @param except The exception raised by the underlying connection
- */
- synchronized void notifyError( int clientId, SQLException except )
- {
- ConnectionEvent event;
-
- if ( clientId != _clientId )
- return;
-
- // If the connection is not two-phase commit we cannot determine
- // whether the error is critical, we just return. If the connection
- // is two phase commit, but the error is not critical, we return.
- if ( _underlying != null )
- {
- if ( ! ( _underlying instanceof TwoPhaseConnection ) ||
- ! ( (TwoPhaseConnection) _underlying ).isCriticalError( except ) )
- return;
- if ( _txConn.conn == null ||
- ! ( _txConn.conn instanceof TwoPhaseConnection ) ||
- ! ( (TwoPhaseConnection) _txConn.conn ).isCriticalError( except ) )
- return;
- }
-
- // The client connection is no longer useable, the underlying
- // connection (if used) is closed, the TxConnection (if used)
- // is rolledback and this connection dies (but close() may
- // still be called).
- ++_clientId;
- if ( _underlying != null )
- {
- try
- {
- _underlying.close();
- }
- catch ( SQLException e2 )
- {
- // Ignore that, we know there's an error.
- }
- _underlying = null;
- }
- else if ( _txConn != null )
- {
- try
- {
- end( _txConn.xid, TMFAIL );
- }
- catch ( XAException e2 )
- {
- // Ignore that, we know there's an error.
- }
- _txConn = null;
- }
-
- // Notify the listener.
- if ( _listener != null )
- {
- event = new ConnectionEvent( this, except );
- _listener.connectionErrorOccurred( event );
- }
- }
-
-
- protected void finalize()
- throws Throwable
- {
- // We are no longer referenced by anyone (including the
- // connection pool). Time to close down.
- close();
- }
-
-
- public String toString()
- {
- if ( _underlying != null )
- return "XAConnection: " + _underlying;
- else
- return "XAConnection: unused";
- }
-
-
- public synchronized void start( Xid xid, int flags )
- throws XAException
- {
- // General checks.
- if ( xid == null )
- throw new XAException( XAException.XAER_INVAL );
- if ( _txConn != null )
- throw new XAException( XAException.XAER_OUTSIDE );
-
- synchronized ( _resManager )
- {
- if ( flags == TMNOFLAGS )
- {
- // Starting a new transaction. First, make sure it is
- // not shared with any other connection (need to join
- // for that).
- if ( _resManager.getTxConnection( xid ) != null )
- throw new XAException( XAException.XAER_DUPID );
-
- // Create a new TxConnection to describe this
- // connection in the context of a transaction and
- // register it with the resource manager so it can
- // be shared.
- try
- {
- _txConn = new TxConnection();
- if ( _underlying != null )
- {
- _txConn.conn = _underlying;
- _underlying = null;
- }
- else
- _txConn.conn = _resManager.newConnection();
- _txConn.xid = xid;
- _txConn.count = 1;
- _txConn.started = System.currentTimeMillis();
- _txConn.timeout = _txConn.started + ( _resManager.getTransactionTimeout() * 1000 );
- _resManager.setTxConnection( xid, _txConn );
- }
- catch ( SQLException except )
- {
- // If error occured at this point, we can only
- // report it as resource manager error.
- if ( _resManager.getLogWriter() != null )
- _resManager.getLogWriter().println( "XAConnection: failed to begin a transaction: " + except );
- throw new XAException( XAException.XAER_RMERR );
- }
-
- try
- {
- _txConn.conn.setAutoCommit( false );
- try
- {
- if ( _resManager.isolationLevel() != Connection.TRANSACTION_NONE )
- _txConn.conn.setTransactionIsolation( _resManager.isolationLevel() );
- }
- catch ( SQLException e )
- {
- // The underlying driver might not support this
- // isolation level that we use by default.
- }
- if ( _txConn.conn instanceof TwoPhaseConnection )
- ( (TwoPhaseConnection) _txConn.conn ).enableSQLTransactions( false );
- }
- catch ( SQLException except )
- {
- // If error occured at this point, we can only
- // report it as resource manager error.
- if ( _resManager.getLogWriter() != null )
- _resManager.getLogWriter().println( "XAConnection: failed to begin a transaction: " + except );
- throw new XAException( XAException.XAER_RMERR );
- }
- }
- else if ( flags == TMJOIN || flags == TMRESUME )
- {
- // We are joining another transaction with an
- // existing TxConnection.
- _txConn = _resManager.getTxConnection( xid );
- if ( _txConn == null )
- throw new XAException( XAException.XAER_INVAL );
-
- // Update the number of XAConnections sharing this
- // transaction connection.
- if ( flags == TMJOIN && _txConn.count == 0 )
- throw new XAException( XAException.XAER_PROTO );
- ++_txConn.count;
-
- // If we already have an underlying connection (as we can
- // expect to), we should release that underlying connection
- // and make it available to the resource manager.
- if ( _underlying != null )
- {
- _resManager.releaseConnection( _underlying );
- _underlying = null;
- }
- }
- else
- // No other flags supported in start().
- throw new XAException( XAException.XAER_INVAL );
- }
- }
-
-
- public synchronized void end( Xid xid, int flags )
- throws XAException
- {
- // General checks.
- if ( xid == null )
- throw new XAException( XAException.XAER_INVAL );
- // Note: we could get end with success or failure even it
- // we were previously excluded from the transaction.
- if ( _txConn == null && flags == TMSUSPEND )
- throw new XAException( XAException.XAER_NOTA );
-
- synchronized ( _resManager )
- {
- if ( flags == TMSUCCESS || flags == TMFAIL)
- {
- // We are now leaving a transaction we started or
- // joined before. We can expect any of prepare/
- // commit/rollback to be called next, so TxConnection
- // is still valid.
-
- // If we were suspended from the transaction, we'll
- // join it for the duration of this operation.
- // Make sure the reference count reaches zero by the
- // time we get to prepare.
- if ( _txConn == null )
- {
- _txConn = _resManager.getTxConnection( xid );
- if ( _txConn == null )
- throw new XAException( XAException.XAER_NOTA );
- }
- else
- {
- if ( _txConn.xid != null && ! _txConn.xid.equals( xid ) )
- throw new XAException( XAException.XAER_NOTA );
- --_txConn.count;
- }
-
- // If transaction failed, we can rollback the
- // transaction and release the underlying connection.
- // We can expect all other resources to recieved the
- // same end notification. We don't expect forget to happen.
- if ( flags == TMFAIL && _txConn.conn != null )
- {
- try
- {
- if ( _txConn.conn instanceof TwoPhaseConnection )
- ( (TwoPhaseConnection) _txConn.conn ).enableSQLTransactions( true );
- _txConn.conn.rollback();
- _resManager.releaseConnection( _txConn.conn );
- }
- catch ( SQLException except )
- {
- // There is a problem with the underlying
- // connection, but it was not added to the poll.
- }
- _resManager.setTxConnection( _txConn.xid, null );
- _txConn.conn = null;
- _txConn.xid = null;
- }
-
- if ( flags == TMSUCCESS)
- {
- // We should be looking for a new transaction.
- // Next thing we might be participating in a new
- // transaction while the current one is being
- // rolled back.
- _txConn = null;
- }
- }
- else if ( flags == TMSUSPEND )
- {
- // We no longer take part in this transaction.
- // Possibly we'll be asked to resume later on, but
- // right now we have to forget about the transaction
- // and the underlying connection.
- --_txConn.count;
- _txConn = null;
- }
- else
- // No other flags supported in end().
- throw new XAException( XAException.XAER_INVAL );
- }
- }
-
-
- public synchronized void forget( Xid xid )
- throws XAException
- {
- TxConnection txConn;
-
- // General checks.
- if ( xid == null )
- throw new XAException( XAException.XAER_INVAL );
- synchronized ( _resManager )
- {
- // We have to forget about the transaction, meaning the
- // transaction no longer exists for this or any other
- // connection. We might be called multiple times.
- txConn = _resManager.setTxConnection( xid, null );
- if ( _txConn == txConn )
- _txConn = null;
- if ( txConn != null )
- {
- if ( txConn.conn != null )
- {
- _resManager.releaseConnection( txConn.conn );
- txConn.conn = null;
- }
- txConn.xid = null;
- }
- }
- }
-
-
- public synchronized int prepare( Xid xid )
- throws XAException
- {
- TxConnection txConn;
-
- // General checks.
- if ( xid == null )
- throw new XAException( XAException.XAER_INVAL );
-
- synchronized ( _resManager )
- {
- // Technically, prepare may be called for any connection,
- // not just this one.
- txConn = _resManager.getTxConnection( xid );
- if ( txConn == null )
- throw new XAException( XAException.XAER_NOTA );
-
- // This is an error and should never happen. All other
- // parties in the transaction should have left it before.
- if ( txConn.count > 0 )
- throw new XAException( XAException.XAER_PROTO );
-
- // If the transaction failed, we have to force a rollback.
- // We track the case of failure due to a timeout.
- if ( txConn.timedOut )
- throw new XAException( XAException.XA_RBTIMEOUT );
- if ( txConn.conn == null )
- throw new XAException( XAException.XA_RBROLLBACK );
-
- // Since there is no preparation mechanism in a generic
- // JDBC driver, we only test for read-only transaction
- // but do not commit at this point.
- try
- {
- txConn.prepared = true;
- if ( txConn.conn instanceof TwoPhaseConnection )
- {
- // For 2pc connection we ask it to prepare and determine
- // whether it's commiting or read-only. If a rollback
- // exception happens, we report it.
- try
- {
- if ( ( (TwoPhaseConnection) txConn.conn ).prepare() )
- return XA_OK;
- else
- {
- txConn.readOnly = true;
- return XA_RDONLY;
- }
- }
- catch ( SQLException except )
- {
- throw new XAException( XAException.XA_RBROLLBACK );
- }
- }
- else
- {
- // For standard connection we cannot prepare, we can
- // only guess if it's read only.
- if ( txConn.conn.isReadOnly() )
- {
- txConn.readOnly = true;
- return XA_RDONLY;
- }
- return XA_OK;
- }
- }
- catch ( SQLException except )
- {
- try
- {
- // Fatal error in the connection, kill it.
- txConn.conn.close();
- }
- catch ( SQLException e )
- { }
- txConn.conn = null;
- if ( _resManager.getLogWriter() != null )
- _resManager.getLogWriter().println( "XAConnection: failed to commit a transaction: " + except );
- // If we cannot commit the transaction, force a rollback.
- throw new XAException( XAException.XA_RBROLLBACK );
- }
- }
- }
-
-
- public Xid[] recover( int flags )
- throws XAException
- {
- synchronized ( _resManager )
- {
- return _resManager.getTxRecover();
- }
- }
-
-
- public synchronized void commit( Xid xid, boolean onePhase )
- throws XAException
- {
- TxConnection txConn;
-
- // General checks.
- if ( xid == null )
- throw new XAException( XAException.XAER_INVAL );
-
- synchronized ( _resManager )
- {
- // Technically, commit may be called for any connection,
- // not just this one.
- txConn = _resManager.getTxConnection( xid );
- if ( txConn == null )
- throw new XAException( XAException.XAER_NOTA );
-
- // If the transaction failed, we have to force
- // a rollback.
- if ( txConn.conn == null )
- throw new XAException( XAException.XA_RBROLLBACK );
-
- // If connection has been prepared and is read-only,
- // nothing to do at this stage.
- if ( txConn.readOnly )
- return;
-
- // This must be a one-phase commite, or the connection
- // should have been prepared before.
- if ( onePhase || txConn.prepared )
- {
- try
- {
- // Prevent multiple commit attempts.
- txConn.readOnly = true;
- if ( txConn.conn instanceof TwoPhaseConnection )
- ( (TwoPhaseConnection) txConn.conn ).enableSQLTransactions( true );
- txConn.conn.commit();
- }
- catch ( SQLException except )
- {
- try
- {
- // Unknown error in the connection, better kill it.
- txConn.conn.close();
- }
- catch ( SQLException e )
- { }
- txConn.conn = null;
- if ( _resManager.getLogWriter() != null )
- _resManager.getLogWriter().println( "XAConnection: failed to commit a transaction: " + except );
- // If we cannot commit the transaction, a heuristic tollback.
- throw new XAException( XAException.XA_HEURRB );
- }
- }
- else
- {
- // 2pc we should have prepared before.
- if ( ! txConn.prepared )
- throw new XAException( XAException.XAER_PROTO );
- }
- }
- }
-
-
- public synchronized void rollback( Xid xid )
- throws XAException
- {
- TxConnection txConn;
-
-
- // General checks.
- if ( xid == null )
- throw new XAException( XAException.XAER_INVAL );
-
- synchronized ( _resManager )
- {
- // Technically, rollback may be called for any connection,
- // not just this one.
- txConn = _resManager.getTxConnection( xid );
- if ( txConn == null )
- throw new XAException( XAException.XAER_NOTA );
-
- // If connection has been prepared and is read-only,
- // nothing to do at this stage. If connection has
- // been terminated any other way, nothing to do
- // either.
- if ( txConn.readOnly || txConn.conn == null )
- return;
-
- try
- {
- txConn.prepared = false;
- if ( txConn.conn instanceof TwoPhaseConnection )
- ( (TwoPhaseConnection) txConn.conn ).enableSQLTransactions( true );
- txConn.conn.rollback();
- }
- catch ( SQLException except )
- {
- try
- {
- // Unknown error in the connection, better kill it.
- txConn.conn.close();
- }
- catch ( SQLException e )
- { }
- txConn.conn = null;
- if ( _resManager.getLogWriter() != null )
- _resManager.getLogWriter().println( "XAConnection: failed to rollback a transaction: " + except );
- // If we cannot commit the transaction, a heuristic tollback.
- throw new XAException( XAException.XA_RBROLLBACK );
- }
- finally
- {
- forget( xid );
- }
- }
- }
-
-
- public synchronized boolean isSameRM( XAResource xaRes )
- throws XAException
- {
- // Two resource managers are equal if they produce equivalent
- // connection (i.e. same database, same user). If the two are
- // equivalent they would share a transaction by joining.
- if ( xaRes == null || ! ( xaRes instanceof XAConnectionImpl ) )
- return false;
- if ( _resManager.equals( ( (XAConnectionImpl) xaRes )._resManager ) )
- return true;
- return false;
- }
-
-
- public synchronized boolean setTransactionTimeout( int seconds )
- throws XAException
- {
- if ( seconds < 0 )
- throw new XAException( XAException.XAER_INVAL );
- // Zero resets to the default for all transactions.
- if ( seconds == 0 )
- seconds = _resManager.getTransactionTimeout();
- // If a transaction has started, change it's timeout to the new value.
- if ( _txConn != null )
- {
- _txConn.timeout = _txConn.started + ( seconds * 1000 );
- return true;
- }
- return false;
- }
-
-
- public int getTransactionTimeout()
- {
- long timeout;
-
- if ( _txConn == null )
- return 0;
- return (int) ( _txConn.timeout - _txConn.started ) / 1000;
- }
-
-
- /*
- * Returns true if this connection is inside a global transaction.
- * If the connection is inside a global transaction it will not
- * allow commit/rollback directly from the {@link
- * java.sql.Connection} interface.
- */
- boolean insideGlobalTx()
- {
- return ( _txConn != null );
- }
-
- /*
- * Called to obtain the underlying connections. If this connection
- * is part of a transaction, the transction's underlying connection
- * is returned, or an exception is thrown if the connection was
- * terminated due to timeout. If this connection is not part of a
- * transaction, a non-transactional connection is returned.
- *
- * @param clientId The {@link ClientConnection} identifier
- */
- Connection getUnderlying( int clientId )
- throws SQLException
- {
- // If we were notified of the client closing, or have been
- // requested to have a new client connection since then,
- // the client id will not match to that of the caller.
- // We use that to decide that the caller has been closed.
- if ( clientId != _clientId )
- throw new SQLException( "This application connection has been closed" );
-
- if ( _txConn != null )
- {
- if ( _txConn.timedOut )
- throw new SQLException( "The transaction has timed out and has been rolledback and closed" );
- if ( _txConn.conn == null )
- throw new SQLException( "The transaction has been terminated and this connection has been closed" );
- return _txConn.conn;
- }
- if ( _underlying == null )
- {
- _underlying = _resManager.newConnection();
- _underlying.setAutoCommit( true );
- }
- return _underlying;
- }
-
-
-}
-
-
-
diff --git a/src/interfaces/jdbc/org/postgresql/xa/XADataSourceImpl.java b/src/interfaces/jdbc/org/postgresql/xa/XADataSourceImpl.java
deleted file mode 100644
index ae34143cb23..00000000000
--- a/src/interfaces/jdbc/org/postgresql/xa/XADataSourceImpl.java
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
-* Redistribution and use of this software and associated documentation
-* ("Software"), with or without modification, are permitted provided
-* that the following conditions are met:
-*
-* 1. Redistributions of source code must retain copyright
-* statements and notices. Redistributions must also contain a
-* copy of this document.
-*
-* 2. Redistributions in binary form must reproduce the
-* above copyright notice, this list of conditions and the
-* following disclaimer in the documentation and/or other
-* materials provided with the distribution.
-*
-* 3. The name "Exolab" must not be used to endorse or promote
-* products derived from this Software without prior written
-* permission of Exoffice Technologies. For written permission,
-* please contact info@exolab.org.
-*
-* 4. Products derived from this Software may not be called "Exolab"
-* nor may "Exolab" appear in their names without prior written
-* permission of Exoffice Technologies. Exolab is a registered
-* trademark of Exoffice Technologies.
-*
-* 5. Due credit should be given to the Exolab Project
-* (http://www.exolab.org/).
-*
-* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
-* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
-* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-* OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
-*
-* $Id: XADataSourceImpl.java,v 1.4 2001/11/19 23:16:46 momjian Exp $
-*/
-
-
-package org.postgresql.xa;
-
-
-import java.io.Serializable;
-import java.io.PrintWriter;
-import java.util.Hashtable;
-import java.util.Vector;
-import java.util.Stack;
-import java.util.Enumeration;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import javax.sql.DataSource;
-import javax.sql.PooledConnection;
-import javax.sql.ConnectionPoolDataSource;
-import javax.sql.XAConnection;
-import javax.sql.XADataSource;
-import javax.transaction.xa.Xid;
-
-
-
-/*
- * Implements a JDBC 2.0 {@link XADataSource} for any JDBC driver
- * with JNDI persistance support. The base implementation is actually
- * provided by a different {@link DataSource} class; although this is
- * the super class, it only provides the pooling and XA specific
- * implementation.
- *
- *
- * @author <a href="arkin@exoffice.com">Assaf Arkin</a>
- * @version 1.0
- */
-public abstract class XADataSourceImpl
- implements DataSource, ConnectionPoolDataSource,
- XADataSource, Serializable, Runnable
-{
-
-
- /*
- * Maps underlying JDBC connections into global transaction Xids.
- */
- private transient Hashtable _txConnections = new Hashtable();
-
-
- /*
- * This is a pool of free underlying JDBC connections. If two
- * XA connections are used in the same transaction, the second
- * one will make its underlying JDBC connection available to
- * the pool. This is not a real connection pool, only a marginal
- * efficiency solution for dealing with shared transactions.
- */
- private transient Stack _pool = new Stack();
-
-
- /*
- * A background deamon thread terminating connections that have
- * timed out.
- */
- private transient Thread _background;
-
-
- /*
- * The default timeout for all new transactions.
- */
- private int _txTimeout = DEFAULT_TX_TIMEOUT;
-
-
- /*
- * The default timeout for all new transactions is 10 seconds.
- */
- public final static int DEFAULT_TX_TIMEOUT = 10;
-
-
-
-
- /*
- * Implementation details:
- * If two XAConnections are associated with the same transaction
- * (one with a start the other with a join) they must use the
- * same underlying JDBC connection. They lookup the underlying
- * JDBC connection based on the transaction's Xid in the
- * originating XADataSource.
- *
- * Currently the XADataSource must be the exact same object,
- * this should be changed so all XADataSources that are equal
- * share a table of all enlisted connections
- *
- * To test is two connections should fall under the same
- * transaction we match the resource managers by comparing the
- * database/user they fall under using a comparison of the
- * XADataSource properties.
- */
-
-
- public XADataSourceImpl()
- {
- super();
-
- // Create a background thread that will track transactions
- // that timeout, abort them and release the underlying
- // connections to the pool.
- _background = new Thread( this, "XADataSource Timeout Daemon" );
- _background.setPriority( Thread.MIN_PRIORITY );
- _background.setDaemon( true );
- _background.start();
- }
-
-
- public XAConnection getXAConnection()
- throws SQLException
- {
- // Construct a new XAConnection with no underlying connection.
- // When a JDBC method requires an underlying connection, one
- // will be created. We don't create the underlying connection
- // beforehand, as it might be coming from an existing
- // transaction.
- return new XAConnectionImpl( this, null );
- }
-
-
- public XAConnection getXAConnection( String user, String password )
- throws SQLException
- {
- // Since we create the connection on-demand with newConnection
- // or obtain it from a transaction, we cannot support XA
- // connections with a caller specified user name.
- throw new SQLException( "XAConnection does not support connections with caller specified user name" );
- }
-
-
- public PooledConnection getPooledConnection()
- throws SQLException
- {
- // Construct a new pooled connection and an underlying JDBC
- // connection to go along with it.
- return new XAConnectionImpl( this, getConnection() );
- }
-
-
- public PooledConnection getPooledConnection( String user, String password )
- throws SQLException
- {
- // Construct a new pooled connection and an underlying JDBC
- // connection to go along with it.
- return new XAConnectionImpl( this, getConnection( user, password ) );
- }
-
-
- /*
- * Returns the default timeout for all transactions.
- */
- public int getTransactionTimeout()
- {
- return _txTimeout;
- }
-
-
- /*
- * This method is defined in the interface and implemented in the
- * derived class, we re-define it just to make sure it does not
- * throw an {@link SQLException} and that we do not need to
- * catch one.
- */
- public abstract java.io.PrintWriter getLogWriter();
-
-
- /*
- * Sets the default timeout for all transactions. The timeout is
- * specified in seconds. Use zero for the default timeout. Calling
- * this method does not affect transactions in progress.
- *
- * @param seconds The timeout in seconds
- */
- public void setTransactionTimeout( int seconds )
- {
- if ( seconds <= 0 )
- _txTimeout = DEFAULT_TX_TIMEOUT;
- else
- _txTimeout = seconds;
- _background.interrupt();
- }
-
-
- /*
- * Returns an underlying connection for the global transaction,
- * if one has been associated before.
- *
- * @param xid The transaction Xid
- * @return A connection associated with that transaction, or null
- */
- TxConnection getTxConnection( Xid xid )
- {
- return (TxConnection) _txConnections.get( xid );
- }
-
-
- /*
- * Associates the global transaction with an underlying connection,
- * or dissociate it when null is passed.
- *
- * @param xid The transaction Xid
- * @param conn The connection to associate, null to dissociate
- */
- TxConnection setTxConnection( Xid xid, TxConnection txConn )
- {
- if ( txConn == null )
- return (TxConnection) _txConnections.remove( xid );
- else
- return (TxConnection) _txConnections.put( xid, txConn );
- }
-
-
- /*
- * Release an unused connection back to the pool. If an XA
- * connection has been asked to join an existing transaction,
- * it will no longer use it's own connection and make it available
- * to newly created connections.
- *
- * @param conn An open connection that is no longer in use
- */
- void releaseConnection( Connection conn )
- {
- _pool.push( conn );
- }
-
-
- /*
- * Creates a new underlying connection. Used by XA connection
- * that lost it's underlying connection when joining a
- * transaction and is now asked to produce a new connection.
- *
- * @return An open connection ready for use
- * @throws SQLException An error occured trying to open
- * a connection
- */
- Connection newConnection()
- throws SQLException
- {
- Connection conn;
-
- // Check in the pool first.
- if ( ! _pool.empty() )
- {
- conn = (Connection) _pool.pop();
- return conn;
- }
- return getConnection();
- }
-
-
- /*
- * XXX Not fully implemented yet and no code to really
- * test it.
- */
- Xid[] getTxRecover()
- {
- Vector list;
- Enumeration enum;
- TxConnection txConn;
-
- list = new Vector();
- enum = _txConnections.elements();
- while ( enum.hasMoreElements() )
- {
- txConn = (TxConnection) enum.nextElement();
- if ( txConn.conn != null && txConn.prepared )
- list.add( txConn.xid );
- }
- return (Xid[]) list.toArray();
- }
-
-
- /*
- * Returns the transaction isolation level to use with all newly
- * created transactions, or {@link Connection#TRANSACTION_NONE}
- * if using the driver's default isolation level.
- */
- public int isolationLevel()
- {
- return Connection.TRANSACTION_NONE;
- }
-
-
- public void run()
- {
- Enumeration enum;
- int reduce;
- long timeout;
- TxConnection txConn;
-
- while ( true )
- {
- // Go to sleep for the duration of a transaction
- // timeout. This mean transactions will timeout on average
- // at _txTimeout * 1.5.
- try
- {
- Thread.sleep( _txTimeout * 1000 );
- }
- catch ( InterruptedException except )
- {}
-
- try
- {
- // Check to see if there are any pooled connections
- // we can release. We release 10% of the pooled
- // connections each time, so in a heavy loaded
- // environment we don't get to release that many, but
- // as load goes down we do. These are not actually
- // pooled connections, but connections that happen to
- // get in and out of a transaction, not that many.
- reduce = _pool.size() - ( _pool.size() / 10 ) - 1;
- if ( reduce >= 0 && _pool.size() > reduce )
- {
- if ( getLogWriter() != null )
- getLogWriter().println( "DataSource " + toString() +
- ": Reducing internal connection pool size from " +
- _pool.size() + " to " + reduce );
- while ( _pool.size() > reduce )
- {
- try
- {
- ( (Connection) _pool.pop() ).close();
- }
- catch ( SQLException except )
- { }
- }
- }
- }
- catch ( Exception except )
- { }
-
- // Look for all connections inside a transaction that
- // should have timed out by now.
-
-
- timeout = System.currentTimeMillis();
- enum = _txConnections.elements();
- while ( enum.hasMoreElements() )
- {
- txConn = (TxConnection) enum.nextElement();
- // If the transaction timed out, we roll it back and
- // invalidate it, but do not remove it from the transaction
- // list yet. We wait for the next iteration, minimizing the
- // chance of a NOTA exception.
- if ( txConn.conn == null )
- {
- _txConnections.remove( txConn.xid );
- // Chose not to use an iterator so we must
- // re-enumerate the list after removing
- // an element from it.
- enum = _txConnections.elements();
- }
- else if ( txConn.timeout < timeout )
- {
-
- try
- {
- Connection underlying;
-
- synchronized ( txConn )
- {
- if ( txConn.conn == null )
- continue;
- if ( getLogWriter() != null )
- getLogWriter().println( "DataSource " + toString() +
- ": Transaction timed out and being aborted: " +
- txConn.xid );
- // Remove the connection from the transaction
- // association. XAConnection will now have
- // no underlying connection and attempt to
- // create a new one.
- underlying = txConn.conn;
- txConn.conn = null;
- txConn.timedOut = true;
-
- // Rollback the underlying connection to
- // abort the transaction and release the
- // underlying connection to the pool.
- try
- {
- underlying.rollback();
- releaseConnection( underlying );
- }
- catch ( SQLException except )
- {
- if ( getLogWriter() != null )
- getLogWriter().println( "DataSource " + toString() +
- ": Error aborting timed out transaction: " + except );
- try
- {
- underlying.close();
- }
- catch ( SQLException e2 )
- { }
- }
- }
- }
- catch ( Exception except )
- { }
-
- }
- }
- }
- }
-
-
-
- public void debug( PrintWriter writer )
- {
- Enumeration enum;
- TxConnection txConn;
- StringBuffer buffer;
-
- writer.println( "Debug info for XADataSource:" );
- enum = _txConnections.elements();
- if ( ! enum.hasMoreElements() )
- writer.println( "Empty" );
- while ( enum.hasMoreElements() )
- {
- buffer = new StringBuffer();
- txConn = (TxConnection) enum.nextElement();
- buffer.append( "TxConnection " );
- if ( txConn.xid != null )
- buffer.append( txConn.xid );
- if ( txConn.conn != null )
- buffer.append( ' ' ).append( txConn.conn );
- buffer.append( " count: " ).append( txConn.count );
- if ( txConn.prepared )
- buffer.append( " prepared" );
- if ( txConn.timedOut )
- buffer.append( " timed-out" );
- if ( txConn.readOnly )
- buffer.append( " read-only" );
- writer.println( buffer.toString() );
- }
- enum = _pool.elements();
- while ( enum.hasMoreElements() )
- writer.println( "Pooled underlying: " + enum.nextElement().toString() );
- }
-
-
-}
diff --git a/src/interfaces/jdbc/utils/CheckVersion.java b/src/interfaces/jdbc/utils/CheckVersion.java
deleted file mode 100644
index a2438cd4f9f..00000000000
--- a/src/interfaces/jdbc/utils/CheckVersion.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package utils;
-
-/*
- * This little app checks to see what version of JVM is being used.
- * It does this by checking first the java.vm.version property, and
- * if that fails, it looks for certain classes that should be present.
- */
-public class CheckVersion
-{
- /*
- * Check for the existence of a class by attempting to load it
- */
- public static boolean checkClass(String c)
- {
- try
- {
- Class.forName(c);
- }
- catch (Exception e)
- {
- return false;
- }
- return true;
- }
-
- /*
- * This first checks java.vm.version for 1.1, 1.2 or 1.3.
- *
- * It writes jdbc1 to stdout for the 1.1.x VM.
- *
- * For 1.2 or 1.3, it checks for the existence of the javax.sql.DataSource
- * interface, and if found writes enterprise to stdout. If the interface
- * is not found, it writes jdbc2 to stdout.
- *
- * PS: It also looks for the existence of java.lang.Byte which appeared in
- * JDK1.1.0 incase java.vm.version is not heeded by some JVM's.
- *
- * If it can't work it out, it writes huho to stdout.
- *
- * The make file uses the written results to determine which rule to run.
- *
- * Bugs: This needs thorough testing.
- */
- public static void main(String args[])
- {
- String vmversion = System.getProperty("java.vm.version");
-
- System.out.println("postgresql.jdbc=" + System.getProperty("postgresql.jdbc"));
-
- // We are running a 1.1 JVM
- if (vmversion.startsWith("1.1"))
- {
- System.out.println("jdbc1");
- //System.exit(0);
- }
- else
- // We are running a 1.2 or 1.3 JVM
- if (vmversion.startsWith("1.2") ||
- vmversion.startsWith("1.3") ||
- checkClass("java.lang.Byte")
- )
- {
-
- // Check to see if we have the standard extensions. If so, then
- // we want the enterprise edition, otherwise the jdbc2 driver.
- if (checkClass("javax.sql.DataSource"))
- System.out.println("enterprise");
- else
- System.out.println("jdbc2");
- //System.exit(0);
- }
- System.setProperty("postgresql.jdbc", "yoyo");
- }
-}
diff --git a/src/interfaces/jdbc/utils/buildDriver b/src/interfaces/jdbc/utils/buildDriver
deleted file mode 100755
index 8cca1d9c36d..00000000000
--- a/src/interfaces/jdbc/utils/buildDriver
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-#
-# $Id: buildDriver,v 1.2 2000/12/20 16:22:49 peter Exp $
-#
-# This script generates the org/postgresql/Driver.java file from the template
-# org/postgresql/Driver.java.in
-#
-# We do this because we need to include the version number from Makefile.global
-# and some other goodies.
-#
-# This used to be in Makefile, but as it's now done three times, it's better
-# to have it as a separate script.
-#
-# If you have any problems, please let us know ;-)
-#
-# Syntax: buildDriver version class
-#
-# Where:
-# version The version string from Makefile.global
-# class The class implementing java.sql.Connection
-# edition The driver edition being built
-# source The file to build. We assume that ${source}.in exists
-#
-
-VERSION=$1
-CLASS=$2
-EDITION=$3
-SOURCE=$4
-
-#---------------------------------------------------------------------------
-# Extract the version. This will work until version x.9 (and assuming we don't
-# have 7.10 etc). We only handle 1 digit for MINORVERSION to handle things like
-# 7.1devel etc
-#
-MAJORVERSION=`echo $VERSION | cut -f1 -d'.'`
-MINORVERSION=`echo $VERSION | cut -f2 -d'.' | cut -c1`
-
-#---------------------------------------------------------------------------
-# Now finally build the driver
-sed \
- -e "s/@JDBCCONNECTCLASS@/$CLASS/g" \
- -e "s/@VERSION@/$VERSION $EDITION/g" \
- -e "s/@MAJORVERSION@/$MAJORVERSION/g" \
- -e "s/@MINORVERSION@/$MINORVERSION/g" \
- <${SOURCE}.in \
- >$SOURCE
-#---------------------------------------------------------------------------
diff --git a/src/interfaces/jdbc/utils/changelog.pl b/src/interfaces/jdbc/utils/changelog.pl
deleted file mode 100644
index 3cba15aa91d..00000000000
--- a/src/interfaces/jdbc/utils/changelog.pl
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/perl
-
-while(<>) {
- chomp();
- s/\t+/ /g;
- if(substr($_,0,3) eq ' - ') {
- print "<ul>" if !$inlist;
- $inlist=1;
- print "<li>".substr($_,3)."\n";
- } else {
- if($_ eq "" || $_ eq " ") {
- print "</ul>" if $inlist;
- $inlist=0;
- print "<br>\n";
- } elsif(substr($_,0,1) eq " ") {
- print $_;
- } else {
- print "</ul>" if $inlist;
- $inlist=0;
- print "<h4>".$_."</h4>\n";
- }
- }
-}