Merge lp:~jim-cirrusql/stado/spatial into lp:stado

Proposed by Jim Mlodgenski
Status: Merged
Merged at revision: 2
Proposed branch: lp:~jim-cirrusql/stado/spatial
Merge into: lp:stado
Diff against target: 241906 lines (+180804/-37586)
1093 files modified
.classpath (+10/-0)
.project (+17/-0)
build.xml (+20/-5)
docs/stado_admin_guide.xml (+3/-3)
docs/stado_loader.xml (+2/-2)
docs/stado_sql_reference.xml (+0/-10)
lib/postgresql_license.txt (+0/-26)
src/org/postgresql/driver/Driver.java (+792/-0)
src/org/postgresql/driver/PGConnection.java (+116/-0)
src/org/postgresql/driver/PGNotification.java (+52/-0)
src/org/postgresql/driver/PGRefCursorResultSet.java (+40/-0)
src/org/postgresql/driver/PGResultSetMetaData.java (+54/-0)
src/org/postgresql/driver/PGStatement.java (+98/-0)
src/org/postgresql/driver/copy/CopyIn.java (+56/-0)
src/org/postgresql/driver/copy/CopyManager.java (+202/-0)
src/org/postgresql/driver/copy/CopyOperation.java (+68/-0)
src/org/postgresql/driver/copy/CopyOut.java (+29/-0)
src/org/postgresql/driver/copy/PGCopyInputStream.java (+166/-0)
src/org/postgresql/driver/copy/PGCopyOutputStream.java (+185/-0)
src/org/postgresql/driver/core/BaseConnection.java (+163/-0)
src/org/postgresql/driver/core/BaseResultSet.java (+44/-0)
src/org/postgresql/driver/core/BaseStatement.java (+76/-0)
src/org/postgresql/driver/core/ConnectionFactory.java (+104/-0)
src/org/postgresql/driver/core/Encoding.java (+306/-0)
src/org/postgresql/driver/core/Field.java (+275/-0)
src/org/postgresql/driver/core/Logger.java (+110/-0)
src/org/postgresql/driver/core/Notification.java (+67/-0)
src/org/postgresql/driver/core/Oid.java (+83/-0)
src/org/postgresql/driver/core/PGBindException.java (+38/-0)
src/org/postgresql/driver/core/PGStream.java (+565/-0)
src/org/postgresql/driver/core/ParameterList.java (+171/-0)
src/org/postgresql/driver/core/Parser.java (+316/-0)
src/org/postgresql/driver/core/ProtocolConnection.java (+148/-0)
src/org/postgresql/driver/core/Query.java (+69/-0)
src/org/postgresql/driver/core/QueryExecutor.java (+236/-0)
src/org/postgresql/driver/core/ResultCursor.java (+40/-0)
src/org/postgresql/driver/core/ResultHandler.java (+96/-0)
src/org/postgresql/driver/core/TypeInfo.java (+116/-0)
src/org/postgresql/driver/core/UTF8Encoding.java (+180/-0)
src/org/postgresql/driver/core/Utils.java (+169/-0)
src/org/postgresql/driver/core/VisibleBufferedInputStream.java (+316/-0)
src/org/postgresql/driver/core/types/PGBigDecimal.java (+87/-0)
src/org/postgresql/driver/core/types/PGBoolean.java (+86/-0)
src/org/postgresql/driver/core/types/PGByte.java (+87/-0)
src/org/postgresql/driver/core/types/PGDouble.java (+87/-0)
src/org/postgresql/driver/core/types/PGFloat.java (+87/-0)
src/org/postgresql/driver/core/types/PGInteger.java (+84/-0)
src/org/postgresql/driver/core/types/PGLong.java (+85/-0)
src/org/postgresql/driver/core/types/PGNumber.java (+86/-0)
src/org/postgresql/driver/core/types/PGShort.java (+82/-0)
src/org/postgresql/driver/core/types/PGString.java (+97/-0)
src/org/postgresql/driver/core/types/PGType.java (+34/-0)
src/org/postgresql/driver/core/types/PGUnknown.java (+51/-0)
src/org/postgresql/driver/core/v2/ConnectionFactoryImpl.java (+516/-0)
src/org/postgresql/driver/core/v2/FastpathParameterList.java (+172/-0)
src/org/postgresql/driver/core/v2/ProtocolConnectionImpl.java (+233/-0)
src/org/postgresql/driver/core/v2/QueryExecutorImpl.java (+625/-0)
src/org/postgresql/driver/core/v2/SimpleParameterList.java (+193/-0)
src/org/postgresql/driver/core/v2/V2Query.java (+126/-0)
src/org/postgresql/driver/core/v3/CompositeParameterList.java (+159/-0)
src/org/postgresql/driver/core/v3/CompositeQuery.java (+73/-0)
src/org/postgresql/driver/core/v3/ConnectionFactoryImpl.java (+522/-0)
src/org/postgresql/driver/core/v3/CopyInImpl.java (+76/-0)
src/org/postgresql/driver/core/v3/CopyOperationImpl.java (+78/-0)
src/org/postgresql/driver/core/v3/CopyOutImpl.java (+67/-0)
src/org/postgresql/driver/core/v3/Portal.java (+82/-0)
src/org/postgresql/driver/core/v3/ProtocolConnectionImpl.java (+232/-0)
src/org/postgresql/driver/core/v3/QueryExecutorImpl.java (+2210/-0)
src/org/postgresql/driver/core/v3/SimpleParameterList.java (+343/-0)
src/org/postgresql/driver/core/v3/SimpleQuery.java (+196/-0)
src/org/postgresql/driver/core/v3/V3ParameterList.java (+64/-0)
src/org/postgresql/driver/core/v3/V3Query.java (+43/-0)
src/org/postgresql/driver/ds/.cvsignore (+3/-0)
src/org/postgresql/driver/ds/PGConnectionPoolDataSource.java (+119/-0)
src/org/postgresql/driver/ds/PGPooledConnection.java (+59/-0)
src/org/postgresql/driver/ds/PGPoolingDataSource.java (+65/-0)
src/org/postgresql/driver/ds/PGSimpleDataSource.java (+39/-0)
src/org/postgresql/driver/ds/common/BaseDataSource.java (+524/-0)
src/org/postgresql/driver/ds/common/PGObjectFactory.java (+143/-0)
src/org/postgresql/driver/ds/jdbc23/AbstractJdbc23PooledConnection.java (+478/-0)
src/org/postgresql/driver/ds/jdbc23/AbstractJdbc23PoolingDataSource.java (+531/-0)
src/org/postgresql/driver/ds/jdbc23/AbstractJdbc23SimpleDataSource.java (+59/-0)
src/org/postgresql/driver/ds/jdbc4/AbstractJdbc4PooledConnection.java (+46/-0)
src/org/postgresql/driver/ds/jdbc4/AbstractJdbc4PoolingDataSource.java (+42/-0)
src/org/postgresql/driver/ds/jdbc4/AbstractJdbc4SimpleDataSource.java (+41/-0)
src/org/postgresql/driver/jdbc2/AbstractJdbc2Array.java (+706/-0)
src/org/postgresql/driver/jdbc2/AbstractJdbc2Connection.java (+1052/-0)
src/org/postgresql/driver/jdbc2/AbstractJdbc2DatabaseMetaData.java (+4283/-0)
src/org/postgresql/driver/jdbc2/AbstractJdbc2ResultSet.java (+2962/-0)
src/org/postgresql/driver/jdbc2/AbstractJdbc2ResultSetMetaData.java (+486/-0)
src/org/postgresql/driver/jdbc2/AbstractJdbc2Statement.java (+3061/-0)
src/org/postgresql/driver/jdbc2/EscapedFunctions.java (+611/-0)
src/org/postgresql/driver/jdbc2/ResultWrapper.java (+75/-0)
src/org/postgresql/driver/jdbc2/TimestampUtils.java (+638/-0)
src/org/postgresql/driver/jdbc2/TypeInfoCache.java (+705/-0)
src/org/postgresql/driver/jdbc3/AbstractJdbc3Connection.java (+492/-0)
src/org/postgresql/driver/jdbc3/AbstractJdbc3DatabaseMetaData.java (+391/-0)
src/org/postgresql/driver/jdbc3/AbstractJdbc3ParameterMetaData.java (+99/-0)
src/org/postgresql/driver/jdbc3/AbstractJdbc3ResultSet.java (+229/-0)
src/org/postgresql/driver/jdbc3/AbstractJdbc3Statement.java (+1534/-0)
src/org/postgresql/driver/jdbc3/Jdbc3Array.java (+65/-0)
src/org/postgresql/driver/jdbc3/Jdbc3CallableStatement.java (+414/-0)
src/org/postgresql/driver/jdbc3/Jdbc3Connection.java (+167/-0)
src/org/postgresql/driver/jdbc3/Jdbc3ConnectionPool.java (+29/-0)
src/org/postgresql/driver/jdbc3/Jdbc3DatabaseMetaData.java (+96/-0)
src/org/postgresql/driver/jdbc3/Jdbc3ParameterMetaData.java (+50/-0)
src/org/postgresql/driver/jdbc3/Jdbc3PoolingDataSource.java (+29/-0)
src/org/postgresql/driver/jdbc3/Jdbc3PreparedStatement.java (+204/-0)
src/org/postgresql/driver/jdbc3/Jdbc3ResultSet.java (+419/-0)
src/org/postgresql/driver/jdbc3/Jdbc3ResultSetMetaData.java (+50/-0)
src/org/postgresql/driver/jdbc3/Jdbc3SimpleDataSource.java (+29/-0)
src/org/postgresql/driver/jdbc3/Jdbc3Statement.java (+93/-0)
src/org/postgresql/driver/jdbc3/PSQLSavepoint.java (+96/-0)
src/org/postgresql/driver/ssl/MakeSSL.java (+82/-0)
src/org/postgresql/driver/ssl/NonValidatingFactory.java (+69/-0)
src/org/postgresql/driver/ssl/WrappedFactory.java (+68/-0)
src/org/postgresql/driver/util/.cvsignore (+1/-0)
src/org/postgresql/driver/util/Base64.java (+599/-0)
src/org/postgresql/driver/util/GT.java (+103/-0)
src/org/postgresql/driver/util/MD5Digest.java (+103/-0)
src/org/postgresql/driver/util/PGInterval.java (+453/-0)
src/org/postgresql/driver/util/PGbytea.java (+189/-0)
src/org/postgresql/driver/util/PGmoney.java (+113/-0)
src/org/postgresql/driver/util/PGobject.java (+115/-0)
src/org/postgresql/driver/util/PGtokenizer.java (+234/-0)
src/org/postgresql/driver/util/PSQLDriverVersion.java (+45/-0)
src/org/postgresql/driver/util/PSQLException.java (+54/-0)
src/org/postgresql/driver/util/PSQLState.java (+95/-0)
src/org/postgresql/driver/util/PSQLWarning.java (+56/-0)
src/org/postgresql/driver/util/ServerErrorMessage.java (+201/-0)
src/org/postgresql/driver/util/StreamWrapper.java (+74/-0)
src/org/postgresql/driver/util/UnixCrypt.java (+665/-0)
src/org/postgresql/stado/common/ActivityLog.java (+14/-13)
src/org/postgresql/stado/common/ColumnMetaData.java (+14/-13)
src/org/postgresql/stado/common/CommandLog.java (+14/-13)
src/org/postgresql/stado/common/ErrorMessages.java (+14/-13)
src/org/postgresql/stado/common/ResultSetImpl.java (+14/-13)
src/org/postgresql/stado/common/XDBResultSetMetaData.java (+14/-13)
src/org/postgresql/stado/common/util/ErrorCodes.java (+14/-13)
src/org/postgresql/stado/common/util/MetaDataUtil.java (+50/-14)
src/org/postgresql/stado/common/util/OutputFormatter.java (+14/-13)
src/org/postgresql/stado/common/util/ParseCmdLine.java (+14/-13)
src/org/postgresql/stado/common/util/Property.java (+14/-13)
src/org/postgresql/stado/common/util/Props.java (+22/-18)
src/org/postgresql/stado/common/util/SQLErrorHandler.java (+14/-13)
src/org/postgresql/stado/common/util/SQLTypeConverter.java (+14/-13)
src/org/postgresql/stado/common/util/SqlWordWrap.java (+14/-13)
src/org/postgresql/stado/common/util/StreamGobbler.java (+22/-13)
src/org/postgresql/stado/common/util/XDBPipedInputStream.java (+14/-13)
src/org/postgresql/stado/common/util/XDBServerPropNames.java (+14/-13)
src/org/postgresql/stado/common/util/XLevel.java (+14/-13)
src/org/postgresql/stado/common/util/XLogger.java (+14/-13)
src/org/postgresql/stado/communication/AbstractAgent.java (+14/-13)
src/org/postgresql/stado/communication/AbstractConnector.java (+14/-13)
src/org/postgresql/stado/communication/BroadcastConnector.java (+14/-13)
src/org/postgresql/stado/communication/ClusteredBroadcastConnector.java (+14/-13)
src/org/postgresql/stado/communication/ClusteredConnector.java (+14/-13)
src/org/postgresql/stado/communication/ConnectorFactory.java (+14/-13)
src/org/postgresql/stado/communication/CoordinatorAgent.java (+14/-13)
src/org/postgresql/stado/communication/IMessageListener.java (+14/-13)
src/org/postgresql/stado/communication/LocalConnector.java (+14/-13)
src/org/postgresql/stado/communication/NodeAgent.java (+14/-13)
src/org/postgresql/stado/communication/SendMessageHelper.java (+14/-13)
src/org/postgresql/stado/communication/SocketConnector.java (+14/-13)
src/org/postgresql/stado/communication/message/AbortMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/BatchResultMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/CommandExtMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/CommandMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/ConnectMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/DataRowsMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/NodeMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/ResultSetMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/SendRowsMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/StepDetailMessage.java (+14/-13)
src/org/postgresql/stado/communication/message/UpdateResultMessage.java (+14/-13)
src/org/postgresql/stado/constraintchecker/AbstractConstraintChecker.java (+14/-13)
src/org/postgresql/stado/constraintchecker/DeleteForeignReferenceChecker.java (+14/-13)
src/org/postgresql/stado/constraintchecker/IConstraintChecker.java (+14/-13)
src/org/postgresql/stado/constraintchecker/InsertForeignKeyChecker.java (+14/-13)
src/org/postgresql/stado/constraintchecker/InsertPrimaryKeyChecker.java (+14/-13)
src/org/postgresql/stado/constraintchecker/UpdateForeignKeyChecker.java (+14/-13)
src/org/postgresql/stado/constraintchecker/UpdateForeignReferenceChecker.java (+14/-13)
src/org/postgresql/stado/constraintchecker/UpdatePrimaryKeyChecker.java (+14/-13)
src/org/postgresql/stado/engine/AckTracker.java (+14/-13)
src/org/postgresql/stado/engine/BatchHandler.java (+14/-13)
src/org/postgresql/stado/engine/BatchInsertGroup.java (+14/-13)
src/org/postgresql/stado/engine/CoordinatorPools.java (+14/-13)
src/org/postgresql/stado/engine/DeclaredCursor.java (+107/-0)
src/org/postgresql/stado/engine/Engine.java (+54/-13)
src/org/postgresql/stado/engine/ExecutableRequest.java (+14/-13)
src/org/postgresql/stado/engine/ExecutionResult.java (+20/-13)
src/org/postgresql/stado/engine/IExecutable.java (+14/-13)
src/org/postgresql/stado/engine/IParametrizedSql.java (+14/-13)
src/org/postgresql/stado/engine/IPreparable.java (+14/-13)
src/org/postgresql/stado/engine/JDBCPool.java (+17/-13)
src/org/postgresql/stado/engine/MessageMonitor.java (+14/-13)
src/org/postgresql/stado/engine/MultinodeExecutor.java (+14/-13)
src/org/postgresql/stado/engine/NodeProducerThread.java (+14/-13)
src/org/postgresql/stado/engine/NodeResultSetImpl.java (+14/-13)
src/org/postgresql/stado/engine/NodeThread.java (+14/-13)
src/org/postgresql/stado/engine/NodeThreadPool.java (+14/-13)
src/org/postgresql/stado/engine/ObjectPool.java (+14/-13)
src/org/postgresql/stado/engine/ProducerSender.java (+14/-13)
src/org/postgresql/stado/engine/ServerStatement.java (+14/-13)
src/org/postgresql/stado/engine/XDBSessionContext.java (+38/-21)
src/org/postgresql/stado/engine/copy/CopyIn.java (+14/-13)
src/org/postgresql/stado/engine/copy/CopyManager.java (+16/-15)
src/org/postgresql/stado/engine/copy/CopyOut.java (+14/-13)
src/org/postgresql/stado/engine/copy/PgCopyIn.java (+16/-15)
src/org/postgresql/stado/engine/copy/PgCopyManager.java (+15/-14)
src/org/postgresql/stado/engine/copy/PgCopyOut.java (+16/-15)
src/org/postgresql/stado/engine/datatypes/BigDecimalType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/BlobType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/BooleanType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/ByteArrayType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/ByteType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/ClobType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/DateType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/FloatType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/IntegerType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/LongType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/ShortType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/TimeType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/TimestampType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/VarcharType.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/XBlob.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/XClob.java (+14/-13)
src/org/postgresql/stado/engine/datatypes/XData.java (+14/-13)
src/org/postgresql/stado/engine/io/CopyResponse.java (+14/-13)
src/org/postgresql/stado/engine/io/DataTypes.java (+15/-40)
src/org/postgresql/stado/engine/io/MessageTypes.java (+14/-13)
src/org/postgresql/stado/engine/io/RequestMessage.java (+14/-13)
src/org/postgresql/stado/engine/io/ResponseMessage.java (+14/-13)
src/org/postgresql/stado/engine/io/ResultSetResponse.java (+15/-14)
src/org/postgresql/stado/engine/io/XMessage.java (+14/-13)
src/org/postgresql/stado/engine/loader/CopyOutReaderThread.java (+14/-13)
src/org/postgresql/stado/engine/loader/CsvProcessorThread.java (+14/-13)
src/org/postgresql/stado/engine/loader/DataProcessorThread.java (+14/-13)
src/org/postgresql/stado/engine/loader/DataReaderAndProcessorBuffer.java (+14/-13)
src/org/postgresql/stado/engine/loader/DefaultWriter.java (+14/-13)
src/org/postgresql/stado/engine/loader/DefaultWriterFactory.java (+14/-13)
src/org/postgresql/stado/engine/loader/ILoaderConfigInformation.java (+14/-13)
src/org/postgresql/stado/engine/loader/INodeWriter.java (+14/-13)
src/org/postgresql/stado/engine/loader/INodeWriterFactory.java (+14/-13)
src/org/postgresql/stado/engine/loader/IUniqueValueProvider.java (+14/-13)
src/org/postgresql/stado/engine/loader/Loader.java (+14/-13)
src/org/postgresql/stado/engine/loader/LoaderConnectionPool.java (+14/-13)
src/org/postgresql/stado/engine/loader/PostgresWriter.java (+14/-13)
src/org/postgresql/stado/engine/loader/PostgresWriterFactory.java (+14/-13)
src/org/postgresql/stado/engine/loader/ResultSetProcessorThread.java (+14/-13)
src/org/postgresql/stado/engine/loader/ResultSetReaderThread.java (+14/-13)
src/org/postgresql/stado/engine/loader/StreamReaderThread.java (+14/-13)
src/org/postgresql/stado/engine/loader/TableColumnDescription.java (+14/-13)
src/org/postgresql/stado/engine/loader/TextProcessorThread.java (+14/-13)
src/org/postgresql/stado/exception/ColumnNotFoundException.java (+14/-13)
src/org/postgresql/stado/exception/ErrorMessageRepository.java (+19/-14)
src/org/postgresql/stado/exception/InvalidExpressionException.java (+14/-13)
src/org/postgresql/stado/exception/NoParentTreeException.java (+14/-13)
src/org/postgresql/stado/exception/NotAlphaNumericException.java (+14/-13)
src/org/postgresql/stado/exception/NotNumericException.java (+14/-13)
src/org/postgresql/stado/exception/XDBBaseException.java (+14/-13)
src/org/postgresql/stado/exception/XDBDataReaderException.java (+14/-13)
src/org/postgresql/stado/exception/XDBGeneratorException.java (+14/-13)
src/org/postgresql/stado/exception/XDBMessageMonitorException.java (+14/-13)
src/org/postgresql/stado/exception/XDBSecurityException.java (+14/-13)
src/org/postgresql/stado/exception/XDBServerException.java (+14/-13)
src/org/postgresql/stado/exception/XDBUnexpectedMessageException.java (+14/-13)
src/org/postgresql/stado/exception/XDBUnexpectedStateException.java (+14/-13)
src/org/postgresql/stado/exception/XDBWrappedException.java (+14/-13)
src/org/postgresql/stado/exception/XDBWrappedSQLException.java (+14/-13)
src/org/postgresql/stado/metadata/DBNode.java (+14/-13)
src/org/postgresql/stado/metadata/HelperSysIndex.java (+14/-13)
src/org/postgresql/stado/metadata/IMetaDataUpdate.java (+14/-13)
src/org/postgresql/stado/metadata/MetaData.java (+62/-21)
src/org/postgresql/stado/metadata/MetaUtils.java (+24/-29)
src/org/postgresql/stado/metadata/Node.java (+15/-14)
src/org/postgresql/stado/metadata/NodeDBConnectionInfo.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterDropColumn.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterOwner.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterTableAddColumn.java (+30/-21)
src/org/postgresql/stado/metadata/SyncAlterTableCheck.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterTableDropConstraint.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterTableDropPrimaryKey.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterTableForeignKey.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterTableInherit.java (+29/-30)
src/org/postgresql/stado/metadata/SyncAlterTableModifyColumn.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterTablePrimaryKey.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterTableRenameColumn.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterTableSetTablespace.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterTablespace.java (+14/-13)
src/org/postgresql/stado/metadata/SyncAlterUser.java (+14/-13)
src/org/postgresql/stado/metadata/SyncCreateIndex.java (+14/-13)
src/org/postgresql/stado/metadata/SyncCreateTable.java (+24/-30)
src/org/postgresql/stado/metadata/SyncCreateTablespace.java (+24/-25)
src/org/postgresql/stado/metadata/SyncCreateUser.java (+14/-13)
src/org/postgresql/stado/metadata/SyncCreateView.java (+14/-13)
src/org/postgresql/stado/metadata/SyncDropIndex.java (+14/-13)
src/org/postgresql/stado/metadata/SyncDropTable.java (+14/-13)
src/org/postgresql/stado/metadata/SyncDropTablespace.java (+14/-13)
src/org/postgresql/stado/metadata/SyncDropUser.java (+14/-13)
src/org/postgresql/stado/metadata/SyncDropView.java (+14/-13)
src/org/postgresql/stado/metadata/SyncGrant.java (+14/-13)
src/org/postgresql/stado/metadata/SyncRenameTable.java (+14/-13)
src/org/postgresql/stado/metadata/SyncRevoke.java (+14/-13)
src/org/postgresql/stado/metadata/SyncTempCreateTable.java (+14/-13)
src/org/postgresql/stado/metadata/SysAgent.java (+15/-14)
src/org/postgresql/stado/metadata/SysCheck.java (+14/-13)
src/org/postgresql/stado/metadata/SysColumn.java (+14/-13)
src/org/postgresql/stado/metadata/SysConstraint.java (+14/-13)
src/org/postgresql/stado/metadata/SysDatabase.java (+23/-15)
src/org/postgresql/stado/metadata/SysForeignKey.java (+14/-13)
src/org/postgresql/stado/metadata/SysIndex.java (+14/-13)
src/org/postgresql/stado/metadata/SysIndexKey.java (+14/-13)
src/org/postgresql/stado/metadata/SysLogin.java (+14/-13)
src/org/postgresql/stado/metadata/SysPermission.java (+14/-13)
src/org/postgresql/stado/metadata/SysReference.java (+14/-13)
src/org/postgresql/stado/metadata/SysRowIDHandler.java (+14/-13)
src/org/postgresql/stado/metadata/SysSerialGenerator.java (+14/-13)
src/org/postgresql/stado/metadata/SysSerialIDHandler.java (+14/-13)
src/org/postgresql/stado/metadata/SysTable.java (+27/-14)
src/org/postgresql/stado/metadata/SysTablespace.java (+14/-13)
src/org/postgresql/stado/metadata/SysUser.java (+14/-13)
src/org/postgresql/stado/metadata/SysView.java (+14/-13)
src/org/postgresql/stado/metadata/SysViewColumns.java (+14/-13)
src/org/postgresql/stado/metadata/partitions/HashPartitionMap.java (+14/-13)
src/org/postgresql/stado/metadata/partitions/PartitionMap.java (+14/-13)
src/org/postgresql/stado/metadata/partitions/ReplicatedPartitionMap.java (+14/-13)
src/org/postgresql/stado/metadata/partitions/RobinPartitionMap.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/Balancer.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/BatchCost.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/ILockCost.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/ITransaction.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/Lock.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/LockManager.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/LockSpecification.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/LockTable.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/LockType.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/RequestCost.java (+14/-13)
src/org/postgresql/stado/metadata/scheduler/Scheduler.java (+14/-13)
src/org/postgresql/stado/misc/RSHelper.java (+14/-13)
src/org/postgresql/stado/misc/SortedLongVector.java (+14/-13)
src/org/postgresql/stado/misc/SortedVector.java (+14/-13)
src/org/postgresql/stado/misc/Timer.java (+14/-13)
src/org/postgresql/stado/misc/combinedresultset/ResultSetPosManager.java (+14/-13)
src/org/postgresql/stado/misc/combinedresultset/ServerResultSet.java (+14/-13)
src/org/postgresql/stado/misc/combinedresultset/ServerResultSetImpl.java (+14/-13)
src/org/postgresql/stado/misc/combinedresultset/SortCriteria.java (+14/-13)
src/org/postgresql/stado/optimizer/AttributeColumn.java (+14/-13)
src/org/postgresql/stado/optimizer/FunctionAnalysis.java (+14/-25)
src/org/postgresql/stado/optimizer/IRebuildString.java (+14/-13)
src/org/postgresql/stado/optimizer/Optimizer.java (+14/-13)
src/org/postgresql/stado/optimizer/OrderByElement.java (+14/-13)
src/org/postgresql/stado/optimizer/QueryCondition.java (+14/-13)
src/org/postgresql/stado/optimizer/QueryNode.java (+14/-13)
src/org/postgresql/stado/optimizer/QuerySubTreeHelper.java (+14/-13)
src/org/postgresql/stado/optimizer/QueryTree.java (+53/-13)
src/org/postgresql/stado/optimizer/RelationNode.java (+16/-13)
src/org/postgresql/stado/optimizer/SpatialFunctionAnalysis.java (+1777/-0)
src/org/postgresql/stado/optimizer/SqlExpression.java (+4398/-3554)
src/org/postgresql/stado/parser/Command.java (+16/-13)
src/org/postgresql/stado/parser/ExprTypeHelper.java (+14/-13)
src/org/postgresql/stado/parser/ExpressionType.java (+152/-30)
src/org/postgresql/stado/parser/IXDBSql.java (+14/-13)
src/org/postgresql/stado/parser/Lexer.java (+50/-13)
src/org/postgresql/stado/parser/Parser.java (+59/-13)
src/org/postgresql/stado/parser/ParserHelper.java (+17/-13)
src/org/postgresql/stado/parser/SqlAddGeometryColumn.java (+307/-0)
src/org/postgresql/stado/parser/SqlAddNodesToDB.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterAddCheck.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterAddColumn.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterAddForeignKey.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterAddPrimary.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterDropColumn.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterDropConstraint.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterDropPrimarykey.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterInherit.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterModifyColumn.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterOwner.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterRenameColumn.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterSetTablespace.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterTable.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterTableSpace.java (+14/-13)
src/org/postgresql/stado/parser/SqlAlterUser.java (+14/-13)
src/org/postgresql/stado/parser/SqlAnalyzeDatabase.java (+14/-13)
src/org/postgresql/stado/parser/SqlBeginTransaction.java (+14/-13)
src/org/postgresql/stado/parser/SqlBulkInsert.java (+14/-13)
src/org/postgresql/stado/parser/SqlBulkInsertNext.java (+14/-13)
src/org/postgresql/stado/parser/SqlCloseCursor.java (+158/-0)
src/org/postgresql/stado/parser/SqlCluster.java (+14/-13)
src/org/postgresql/stado/parser/SqlCommitTransaction.java (+14/-13)
src/org/postgresql/stado/parser/SqlCopyData.java (+14/-13)
src/org/postgresql/stado/parser/SqlCreateDatabase.java (+111/-19)
src/org/postgresql/stado/parser/SqlCreateIndex.java (+14/-13)
src/org/postgresql/stado/parser/SqlCreateIndexKey.java (+14/-13)
src/org/postgresql/stado/parser/SqlCreateTable.java (+14/-13)
src/org/postgresql/stado/parser/SqlCreateTableColumn.java (+14/-13)
src/org/postgresql/stado/parser/SqlCreateTableSpace.java (+14/-13)
src/org/postgresql/stado/parser/SqlCreateUser.java (+14/-13)
src/org/postgresql/stado/parser/SqlCreateView.java (+14/-13)
src/org/postgresql/stado/parser/SqlDeallocate.java (+14/-13)
src/org/postgresql/stado/parser/SqlDeclareCursor.java (+148/-0)
src/org/postgresql/stado/parser/SqlDeleteTable.java (+14/-13)
src/org/postgresql/stado/parser/SqlDescribeTable.java (+14/-13)
src/org/postgresql/stado/parser/SqlDropDatabase.java (+14/-13)
src/org/postgresql/stado/parser/SqlDropIndex.java (+14/-13)
src/org/postgresql/stado/parser/SqlDropNodesFromDB.java (+14/-13)
src/org/postgresql/stado/parser/SqlDropTable.java (+14/-13)
src/org/postgresql/stado/parser/SqlDropTableSpace.java (+14/-13)
src/org/postgresql/stado/parser/SqlDropTempTables.java (+14/-13)
src/org/postgresql/stado/parser/SqlDropUser.java (+14/-13)
src/org/postgresql/stado/parser/SqlDropView.java (+14/-13)
src/org/postgresql/stado/parser/SqlExecDirect.java (+14/-13)
src/org/postgresql/stado/parser/SqlExplain.java (+14/-13)
src/org/postgresql/stado/parser/SqlFetchCursor.java (+380/-0)
src/org/postgresql/stado/parser/SqlGrant.java (+14/-13)
src/org/postgresql/stado/parser/SqlInsertTable.java (+14/-13)
src/org/postgresql/stado/parser/SqlKill.java (+14/-13)
src/org/postgresql/stado/parser/SqlModifyTable.java (+14/-13)
src/org/postgresql/stado/parser/SqlRenameTable.java (+14/-13)
src/org/postgresql/stado/parser/SqlRollbackTransaction.java (+14/-13)
src/org/postgresql/stado/parser/SqlSelect.java (+16/-15)
src/org/postgresql/stado/parser/SqlSetProperty.java (+19/-22)
src/org/postgresql/stado/parser/SqlShowAgents.java (+41/-15)
src/org/postgresql/stado/parser/SqlShowConstraints.java (+14/-13)
src/org/postgresql/stado/parser/SqlShowDatabases.java (+14/-13)
src/org/postgresql/stado/parser/SqlShowIndexes.java (+14/-13)
src/org/postgresql/stado/parser/SqlShowProperty.java (+14/-13)
src/org/postgresql/stado/parser/SqlShowStatements.java (+14/-13)
src/org/postgresql/stado/parser/SqlShowTables.java (+14/-13)
src/org/postgresql/stado/parser/SqlShowTranIsolation.java (+14/-13)
src/org/postgresql/stado/parser/SqlShowUsers.java (+14/-13)
src/org/postgresql/stado/parser/SqlShowViews.java (+14/-13)
src/org/postgresql/stado/parser/SqlShutdownServer.java (+14/-13)
src/org/postgresql/stado/parser/SqlStartDatabase.java (+14/-13)
src/org/postgresql/stado/parser/SqlStopDatabase.java (+14/-13)
src/org/postgresql/stado/parser/SqlTruncate.java (+14/-13)
src/org/postgresql/stado/parser/SqlUnlisten.java (+14/-13)
src/org/postgresql/stado/parser/SqlUpdateTable.java (+14/-13)
src/org/postgresql/stado/parser/Tuple.java (+14/-13)
src/org/postgresql/stado/parser/core/CSQLParser.java (+47145/-17637)
src/org/postgresql/stado/parser/core/CSQLParserConstants.java (+1485/-875)
src/org/postgresql/stado/parser/core/CSQLParserTokenManager.java (+9112/-7575)
src/org/postgresql/stado/parser/core/ParseException.java (+22/-1)
src/org/postgresql/stado/parser/core/SimpleCharStream.java (+22/-1)
src/org/postgresql/stado/parser/core/Token.java (+22/-1)
src/org/postgresql/stado/parser/core/TokenMgrError.java (+22/-1)
src/org/postgresql/stado/parser/core/jtb.out.jj (+10680/-1528)
src/org/postgresql/stado/parser/core/sql_extendb.jj (+2264/-734)
src/org/postgresql/stado/parser/core/syntaxtree/AddDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AddNodeToDB.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AliasName.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Alter.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AlterDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AlterDefOperation.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AlterDefOperationSet.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AlterDefOperationType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AlterTable.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AlterTableActon.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AlterTableSpace.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AlterUser.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/AnalyzeDatabase.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/BLOBDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/BeginTransaction.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/BigIntDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/BigSerialDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/BitDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/BooleanDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Box2DDataType.java (+50/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Box3DDataType.java (+50/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Box3DExtentDataType.java (+50/-0)
src/org/postgresql/stado/parser/core/syntaxtree/CharString.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CharachterDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CheckDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CidrDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CidrLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CloseCursor.java (+54/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Cluster.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ColumnDeclare.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ColumnNameList.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ColumnNameListWithParenthesis.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CommitTransaction.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Constraint.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CopyData.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CreateDatabase.java (+23/-2)
src/org/postgresql/stado/parser/core/syntaxtree/CreateDefinition.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CreateTablespace.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/CreateUser.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DateDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DateLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DatetimeField.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Deallocate.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DecimalDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DeclareCursor.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/DefaultSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Delete.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DescribeTable.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DoublePrecision.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DropDatabase.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DropDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DropDefaultNotNull.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DropIndex.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DropNodeFromDB.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DropTablespace.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DropUser.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/DropView.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ExecDirect.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ExistsClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Explain.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FetchCursor.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/FixedDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FloatDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FloatingPointNumber.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ForeignKeyDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FormatDefCSV.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FormatDefDelimiter.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FormatDefNull.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FormatDefOIDS.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FromClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FromTableSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Abbrev.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Abs.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_AddDate.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_AddMonths.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_AddTime.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Age.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Ascii.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Avg.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_BitAnd.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_BitLength.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_BitOr.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_BoolAnd.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_BoolOr.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Broadcast.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Btrim.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Case.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Cast.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Cbrt.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Ceil.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Ceiling.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_CharLength.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Chr.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ClockTimeStamp.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Coalesce.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Concat.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Convert.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_CorrCov.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Count.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_CurrentDatabase.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_CurrentDate.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_CurrentSchema.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_CurrentTime.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Custom.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Database.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Date.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_DateDiff.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_DatePart.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_DateTrunc.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Day.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_DayName.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_DayOfMonth.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_DayOfWeek.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_DayOfYear.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Decode.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Encode.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Exp.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Extract.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Family.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Float.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Floor.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_GetBit.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_GetByte.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Greatest.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Host.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Hostmask.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Hour.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Index.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_InitCap.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_IsFinite.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_JustifyDays.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_JustifyHours.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_JustifyInterval.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_LFill.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_LN.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_LastDay.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Least.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Left.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Length.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_LocalTime.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_LocalTimeStamp.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Log.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Log10.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Lower.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Lpad.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Ltrim.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_MapChar.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Masklen.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Max.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Md5.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Min.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Minute.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Mod.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Month.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_MonthName.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_MonthsBetween.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_NUM.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Netmask.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Network.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_NextDay.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Now.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_NullIf.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Nvl.java (+0/-26)
src/org/postgresql/stado/parser/core/syntaxtree/Func_OctetLength.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Overlay.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_PI.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_POSTGIS_DROPBBOX.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_PgClientEncoding.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_PgCurrentDate.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_PgCurrentTime.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_PgCurrentTimeStamp.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Position.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Power.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_QuoteIdent.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_QuoteLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Radians.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Random.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_RegexReplace.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Regr.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Repeat.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Replace.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Right.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Round.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Rpad.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Rtrim.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ADDMEASURE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ADDPOINT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_AFFINE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_AREA2D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ASEWKB.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ASEWKT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ASGEOJSON.java (+74/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ASGML.java (+74/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ASHEXEWKB.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ASKML.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ASSVG.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_AZIMUTH.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_Area.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_AsBinary.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_AsText.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_BDMPOLYFROMTEXT.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_BDPOLYFROMTEXT.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_BOX2D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_BOX3D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_BUILDAREA.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_BYTEA.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_Boundary.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_Buffer.java (+74/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_CHIP_IN.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_CHIP_OUT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_CLOSESTPOINT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_COLLECT.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_COLLECTIONEXTRACT.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_COMBINE_BBOX.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_COMPRESSION.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_CONTAINS.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_CONTAINSPROPERLY.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_CONVEXHULL.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_COORDDIM.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_COVEREDBY.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_COVERS.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_CROSSES.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_CURVETOLINE.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_Centroid.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_DATATYPE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_DFULLYWITHIN.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_DIFFERENCE.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_DIMENSION.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_DISJOINT.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_DISTANCE_SPHERE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_DISTANCE_SPHEROID.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_DWithin.java (+78/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_Distance.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ENDPOINT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ENVELOPE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_EQUALS.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_EXTENT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_EXTENT3D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_EXTERIORRING.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_FACTOR.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_FIND_EXTENT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_FORCERHR.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_FORCE_2D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_FORCE_3D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_FORCE_3DM.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_FORCE_3DZ.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_FORCE_4D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_FORCE_COLLECTION.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOGFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOGFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOGRAPHYFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOHASH.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMCOLLFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMCOLLFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMETRY.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMETRYN.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMETRYTYPE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMFROMEWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMFROMEWKT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMFROMGML.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMFROMKML.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMFROMTEXT.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GEOMFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_GMLTOSQL.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_HASARC.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_HAUSDORFFDISTANCE.java (+74/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_HEIGHT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_INTERIORRINGN.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_INTERSECTION.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_INTERSECTS.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ISCLOSED.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ISEMPTY.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ISRING.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ISSIMPLE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ISVALID.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ISVALIDREASON.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LENGTH2D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LENGTH2D_SPHEROID.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LENGTH3D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LENGTH3D_SPHEROID.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LENGTH_SPHEROID.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINECROSSINGDIRECTION.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINEFROMMULTIPOINT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINEFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINEFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINEMERGE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINESTRINGFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINETOCURVE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINE_INTERPOLATE_POINT.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINE_LOCATE_POINT.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LINE_SUBSTRING.java (+78/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LOCATEBETWEENELEVATIONS.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LOCATE_ALONG_MEASURE.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LOCATE_BETWEEN_MEASURES.java (+78/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_LONGESTLINE.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_Length.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_M.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MAKEENVELOPE.java (+94/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MAKEPOINT.java (+78/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MAKEPOINTM.java (+78/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MAKEPOLYGON.java (+66/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MAXDISTANCE.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MEMCOLLECT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MEM_SIZE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MINIMUMBOUNDINGCIRCLE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MLINEFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MLINEFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MPOINTFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MPOINTFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MPOLYFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MPOLYFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MULTI.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MULTILINEFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MULTILINESTRINGFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MULTIPOINTFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MULTIPOINTFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MULTIPOLYFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_MULTIPOLYGONFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_NDIMS.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_NPOINTS.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_NRINGS.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_NUMGEOMETRIES.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_NUMINTERIORRING.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_NUMINTERIORRINGS.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_NUMPOINTS.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ORDERINGEQUALS.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_OVERLAPS.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_PERIMETER.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_PERIMETER2D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_PERIMETER3D.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POINT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POINTFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POINTFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POINTN.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POINTONSURFACE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POINT_INSIDE_CIRCLE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POLYFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POLYFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POLYGON.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POLYGONFROMTEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POLYGONFROMWKB.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POSTGIS_GIST_JOINSEL.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_POSTGIS_GIST_SEL.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_RELATE.java (+74/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_REMOVEPOINT.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_REVERSE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ROTATEX.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ROTATEY.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ROTATEZ.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SCALE.java (+82/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SEGMENTIZE.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SETFACTOR.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SETPOINT.java (+78/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SETSRID.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SHIFT_LONGITUDE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SHORTESTLINE.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SIMPLIFY.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SIMPLIFYPRESERVETOPOLOGY.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SNAPTOGRID.java (+86/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SRID.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_STARTPOINT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SUMMARY.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SYMDIFFERENCE.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_SYMMETRICDIFFERENCE.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_TEXT.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_TOUCHES.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_TRANSLATE.java (+82/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_TRANSSCALE.java (+94/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_Transform.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_WIDTH.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_WITHIN.java (+70/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_WKBTOSQL.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_WKTTOSQL.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_X.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_Y.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_Z.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ST_ZMFLAG.java (+62/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Second.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_SetBit.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_SetByte.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Set_Masklen.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Setseed.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Sign.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Sin.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_SoundEx.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_SplitPart.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Sqrt.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_StatementTimeStamp.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Stdev.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_StrPos.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_SubDate.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_SubStr.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_SubTime.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Substring.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Sum.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_SysDate.java (+0/-29)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TACos.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TATan2.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TATn2.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TAsin.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TAtan.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TCos.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TCosh.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TCot.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TDegree.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Tan.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Text.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Time.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TimeOfDay.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TimeStamp.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ToAscii.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ToChar.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ToDate.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ToHex.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ToNumber.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_ToTimestamp.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_TransactionTimeStamp.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Translate.java (+31/-6)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Trim.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Trunc.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Upper.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_User.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Value.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Variance.java (+23/-2)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Version.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_WeekOfYear.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Width_bucket.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Func_Year.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/FunctionCall.java (+215/-3)
src/org/postgresql/stado/parser/core/syntaxtree/GeometryDataType.java (+50/-0)
src/org/postgresql/stado/parser/core/syntaxtree/GeometryLiteral.java (+50/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Grant.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Grantee.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/GranteeList.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/GroupByClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/HavingClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Identifier.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/InetDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/InetLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Inherit.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/InsertTable.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/IntegerDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/IntegerLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/IntervalDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/IntervalLiterals.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/IntervalQualifier.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/IntoClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/IsBooleanClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/IsNullClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/IsolationLevel.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/JoinSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Kill.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/LengthSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/LimitClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/MacAddrDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/MacaddrLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NationalCharDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Node.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NodeChoice.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NodeList.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NodeListInterface.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NodeListOptional.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NodeOptional.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NodePartitionList.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NodeSequence.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NodeToken.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NullLiterals.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/NumericDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/OffsetClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/OnCommitClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/OrderByClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/OrderByItem.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/OwnerDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/PartitionChoice.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/PartitionDeclare.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/PrecisionSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/PreparedStmtParameter.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/PrimaryKeyDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Privilege.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/PrivilegeList.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/PseudoColumn.java (+31/-6)
src/org/postgresql/stado/parser/core/syntaxtree/RealDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/RegClassDataType.java (+50/-0)
src/org/postgresql/stado/parser/core/syntaxtree/Relop.java (+23/-2)
src/org/postgresql/stado/parser/core/syntaxtree/RenameDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/RenameTable.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Revoke.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/RollbackTransaction.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLAndExp.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLAndExpression.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLArgument.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLArgumentList.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLBetweenClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLComplexExpression.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLCondResult.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLExpressionList.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLExpressionListItem.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLInClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLLikeClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLMultiplicativeExpression.java (+23/-2)
src/org/postgresql/stado/parser/core/syntaxtree/SQLMultiplicativeExpressionOperand.java (+23/-2)
src/org/postgresql/stado/parser/core/syntaxtree/SQLORExpression.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLPrimaryExpression.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLRelationalExpression.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLRelationalOperatorExpression.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLSimpleExpression.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SQLUnaryLogicalExpression.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Select.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SelectAddGeometryColumn.java (+106/-0)
src/org/postgresql/stado/parser/core/syntaxtree/SelectAliasSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SelectList.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SelectTupleSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SelectWithParenthesis.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SelectWithoutOrder.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SelectWithoutOrderAndSet.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SelectWithoutOrderAndSetWithParenthesis.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SelectWithoutOrderWithParenthesis.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SerialDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SetProperty.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SetTablespace.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SetUpdateClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowAgents.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowConstraints.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowDatabases.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowIndexes.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowProperty.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowStatements.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowTables.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowTranIsolation.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowUsers.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShowViews.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/ShutdownXDB.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SimpleExpressionOperand.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SmallIntDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/StartDatabase.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/StopDatabase.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/SubQuery.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TableColumn.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TableList.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TableListForGrant.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TableName.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TableSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TablespaceLocation.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TextDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TextLiterals.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TimeDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TimeLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TimeStampDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/TimeStampLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Truncate.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/UnionSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/Unlisten.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/UnreservedWords.java (+304/-5)
src/org/postgresql/stado/parser/core/syntaxtree/UnsignedZeroFillSpecs.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/UpdateStats.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/UpdateTable.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/VacuumDatabase.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/VarBitDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/VarCharDataType.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/WhereClause.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/WithXRowID.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/binaryLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/booleanLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/columnListIndexSpec.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/createIndex.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/createTable.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/createView.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/dropTable.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/extendbObject.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/hex_decimalLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/inheritsDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/length.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/numberValue.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/position.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/process.java (+23/-2)
src/org/postgresql/stado/parser/core/syntaxtree/skip_to_matching_brace.java (+14/-13)
src/org/postgresql/stado/parser/core/syntaxtree/stringLiteral.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/tablespaceDef.java (+22/-1)
src/org/postgresql/stado/parser/core/syntaxtree/types.java (+27/-1)
src/org/postgresql/stado/parser/core/visitor/DepthFirstVisitor.java (+3527/-37)
src/org/postgresql/stado/parser/core/visitor/ObjectDepthFirst.java (+3949/-43)
src/org/postgresql/stado/parser/core/visitor/ObjectVisitor.java (+2335/-31)
src/org/postgresql/stado/parser/core/visitor/Visitor.java (+2335/-31)
src/org/postgresql/stado/parser/handler/AliasSpecHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/CIntoClauseHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/CastTemplates.java (+14/-13)
src/org/postgresql/stado/parser/handler/ColumnNameListHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/DataTypeHandler.java (+92/-70)
src/org/postgresql/stado/parser/handler/ExpressionArgumentHelper.java (+14/-13)
src/org/postgresql/stado/parser/handler/ForeignKeyHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/FromClauseHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/FunctionHandler.java (+2055/-43)
src/org/postgresql/stado/parser/handler/GroupByClauseHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/IFunctionID.java (+223/-16)
src/org/postgresql/stado/parser/handler/IdentifierHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/OrderByClauseHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/ProjectionListHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/QCHelperColumnList.java (+14/-13)
src/org/postgresql/stado/parser/handler/QueryConditionHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/QueryConditionHelper.java (+14/-13)
src/org/postgresql/stado/parser/handler/QueryTreeHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/QueryTreeTracker.java (+14/-13)
src/org/postgresql/stado/parser/handler/RawImageHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/SQLExpressionHandler.java (+266/-18)
src/org/postgresql/stado/parser/handler/SQLExpressionListHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/TableNameHandler.java (+14/-13)
src/org/postgresql/stado/parser/handler/TypeConstants.java (+36/-66)
src/org/postgresql/stado/parser/handler/WhereClauseHandler.java (+14/-13)
src/org/postgresql/stado/planner/ExecutionPlan.java (+14/-13)
src/org/postgresql/stado/planner/ExecutionPlanPreparedHandler.java (+14/-13)
src/org/postgresql/stado/planner/ExecutionStep.java (+14/-13)
src/org/postgresql/stado/planner/Leaf.java (+14/-13)
src/org/postgresql/stado/planner/NodeUsage.java (+14/-13)
src/org/postgresql/stado/planner/QueryPlan.java (+39/-13)
src/org/postgresql/stado/planner/StepDetail.java (+14/-13)
src/org/postgresql/stado/protocol/AbstractProtocolHandler.java (+14/-13)
src/org/postgresql/stado/protocol/PgProtocolHandler.java (+14/-13)
src/org/postgresql/stado/protocol/PgProtocolMessage.java (+14/-13)
src/org/postgresql/stado/protocol/PgProtocolSession.java (+154/-40)
src/org/postgresql/stado/protocol/ProtocolManager.java (+14/-13)
src/org/postgresql/stado/protocol/RequestAnalyzer.java (+14/-13)
src/org/postgresql/stado/queryproc/QueryCombiner.java (+14/-13)
src/org/postgresql/stado/queryproc/QueryProcessor.java (+14/-13)
src/org/postgresql/stado/server/Server.java (+14/-13)
src/org/postgresql/stado/util/CmdLine.java (+14/-13)
src/org/postgresql/stado/util/CreateDb.java (+14/-13)
src/org/postgresql/stado/util/CreateMdDb.java (+18/-16)
src/org/postgresql/stado/util/DbGateway.java (+73/-20)
src/org/postgresql/stado/util/DropDb.java (+14/-13)
src/org/postgresql/stado/util/ExecDb.java (+14/-13)
src/org/postgresql/stado/util/LockUnlockTable.java (+14/-13)
src/org/postgresql/stado/util/ParseArgs.java (+14/-13)
src/org/postgresql/stado/util/PasswordPrompt.java (+14/-13)
src/org/postgresql/stado/util/Util.java (+15/-20)
src/org/postgresql/stado/util/XdbAgent.java (+14/-13)
src/org/postgresql/stado/util/XdbDbStart.java (+14/-13)
src/org/postgresql/stado/util/XdbDbStop.java (+14/-13)
src/org/postgresql/stado/util/XdbImpEx.java (+15/-14)
src/org/postgresql/stado/util/XdbLoader.java (+14/-13)
src/org/postgresql/stado/util/XdbServer.java (+14/-13)
src/org/postgresql/stado/util/XdbShutdown.java (+14/-13)
src/share/postgis.sql (+7787/-0)
src/share/spatial_ref_sys.sql (+15139/-0)
src/share/stado_schema.sql (+10/-0)
stado.config (+173/-0)
To merge this branch: bzr merge lp:~jim-cirrusql/stado/spatial
Reviewer Review Type Date Requested Status
Jim Mlodgenski Pending
Review via email: mp+73437@code.launchpad.net

Description of the change

Spatial support

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.classpath'
2--- .classpath 1970-01-01 00:00:00 +0000
3+++ .classpath 2011-08-30 20:30:24 +0000
4@@ -0,0 +1,10 @@
5+<?xml version="1.0" encoding="UTF-8"?>
6+<classpath>
7+ <classpathentry kind="src" path="src"/>
8+ <classpathentry kind="lib" path="lib/javacc.jar"/>
9+ <classpathentry kind="lib" path="lib/jline-0_9_5.jar"/>
10+ <classpathentry kind="lib" path="lib/jtb.jar"/>
11+ <classpathentry kind="lib" path="lib/log4j.jar"/>
12+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
13+ <classpathentry kind="output" path="bin"/>
14+</classpath>
15
16=== added file '.project'
17--- .project 1970-01-01 00:00:00 +0000
18+++ .project 2011-08-30 20:30:24 +0000
19@@ -0,0 +1,17 @@
20+<?xml version="1.0" encoding="UTF-8"?>
21+<projectDescription>
22+ <name>stado</name>
23+ <comment></comment>
24+ <projects>
25+ </projects>
26+ <buildSpec>
27+ <buildCommand>
28+ <name>org.eclipse.jdt.core.javabuilder</name>
29+ <arguments>
30+ </arguments>
31+ </buildCommand>
32+ </buildSpec>
33+ <natures>
34+ <nature>org.eclipse.jdt.core.javanature</nature>
35+ </natures>
36+</projectDescription>
37
38=== added directory 'bin'
39=== modified file 'build.xml'
40--- build.xml 2011-05-01 15:49:41 +0000
41+++ build.xml 2011-08-30 20:30:24 +0000
42@@ -20,8 +20,10 @@
43 <property name="builddir" value="build" />
44 <property name="distdir" value="dist" />
45 <property name="package" value="org/postgresql/stado" />
46+ <property name="driver" value="org/postgresql/driver" />
47 <property name="packdir" value="${srcdir}/${package}" />
48- <property name="version" value="2_0_beta" />
49+ <property name="driverdir" value="${srcdir}/${driver}" />
50+ <property name="version" value="2_5_beta" />
51
52 <target name="clean">
53 <delete quiet="true" dir="${builddir}" />
54@@ -45,16 +47,31 @@
55 <jar jarfile="${jardir}/stado.jar">
56 <fileset dir="${builddir}">
57 <include name="${package}/**/*.class" />
58+ <include name="${driver}/**/*.class" />
59 </fileset>
60 </jar>
61 </target>
62
63 <target name="compile" depends="prepare">
64+ <javac srcdir="${driverdir}" destdir="${builddir}" source="1.6" includeAntRuntime="false">
65+ <classpath>
66+ <pathelement path="${builddir}" />
67+ </classpath>
68+
69+ <include name="*.java" />
70+ <include name="copy/**" />
71+ <include name="core/**" />
72+ <include name="ds/**" />
73+ <include name="jdbc2/**" />
74+ <include name="jdbc3/**" />
75+ <include name="ssl/**" />
76+ <include name="util/**" />
77+ </javac>
78+
79 <javac srcdir="${packdir}" destdir="${builddir}" source="1.6" includeAntRuntime="false">
80 <classpath>
81 <pathelement location="${libdir}/log4j.jar" />
82 <pathelement location="${libdir}/jline-0_9_5.jar" />
83- <pathelement location="${libdir}/postgresql.jar" />
84 <pathelement path="${builddir}" />
85 </classpath>
86
87@@ -96,11 +113,9 @@
88 <copy file="${jardir}/stado.jar" todir="${distdir}/stado/lib"/>
89 <copy file="${libdir}/jline-0_9_5.jar" todir="${distdir}/stado/lib"/>
90 <copy file="${libdir}/log4j.jar" todir="${distdir}/stado/lib"/>
91- <copy file="${libdir}/postgresql.jar" todir="${distdir}/stado/lib"/>
92-
93+
94 <copy file="${libdir}/jline_license.txt" todir="${distdir}/stado/license"/>
95 <copy file="${libdir}/log4j_license.txt" todir="${distdir}/stado/license"/>
96- <copy file="${libdir}/postgresql_license.txt" todir="${distdir}/stado/license"/>
97 <copy file="misc/license.txt" todir="${distdir}/stado/license"/>
98
99 <copy file="${srcdir}/config/server/stado.config" todir="${distdir}/stado/config"/>
100
101=== modified file 'docs/stado_admin_guide.xml'
102--- docs/stado_admin_guide.xml 2011-05-01 15:49:41 +0000
103+++ docs/stado_admin_guide.xml 2011-08-30 20:30:24 +0000
104@@ -1532,7 +1532,7 @@
105 <para>xdb.metadata.jdbcdriver</para>
106 </entry>
107 <entry>
108- <para>org.postgresql.Driver</para>
109+ <para>org.postgresql.driver.Driver</para>
110 </entry>
111 <entry>
112 <para>The class name of the JDBC Driver to use with underlying metadata database</para>
113@@ -1635,7 +1635,7 @@
114 <para>xdb.default.jdbcdriver</para>
115 </entry>
116 <entry>
117- <para>org.postgresql.Driver</para>
118+ <para>org.postgresql.driver.Driver</para>
119 </entry>
120 <entry>
121 <para>The default driver name to use for all connections</para>
122@@ -4488,7 +4488,7 @@
123
124 create table xsyscolumns
125 (
126- colid int not null,
127+ colid serial,
128 tableid int not null,
129 colseq smallint not null,
130 colname varchar(255) not null,
131
132=== modified file 'docs/stado_loader.xml'
133--- docs/stado_loader.xml 2011-05-01 15:49:41 +0000
134+++ docs/stado_loader.xml 2011-08-30 20:30:24 +0000
135@@ -848,7 +848,7 @@
136 <entry>
137 <para>
138 The driver class name, if exporting from other databases,
139- for example, like: org.postgresql.Driver.
140+ for example, like: org.postgresql.driver.Driver.
141 </para>
142 </entry>
143 </row>
144@@ -951,7 +951,7 @@
145 <programlisting>
146 <![CDATA[
147 EXTRACT=select * from atable
148- DRIVERCLASS=org.postgresql.Driver
149+ DRIVERCLASS=org.postgresql.driver.Driver
150 JDBC_URL=jdbc:postgresql://localhost/mydb?user=myuser&password=mypassword
151 OUTFILE=/tmp/atable.txt
152 ]]>
153
154=== modified file 'docs/stado_sql_reference.xml'
155--- docs/stado_sql_reference.xml 2011-05-01 15:49:41 +0000
156+++ docs/stado_sql_reference.xml 2011-08-30 20:30:24 +0000
157@@ -1090,10 +1090,6 @@
158
159 <para>Returns current date and time (at the start of current statement).</para>
160
161- <para><emphasis role="bold">SYSDATE</emphasis></para>
162-
163- <para>Returns current date and time.</para>
164-
165 <para><emphasis role="bold">TIMEOFDAY()</emphasis></para>
166
167 <para>Returns the current date and time as a timestamp.</para>
168@@ -1155,12 +1151,6 @@
169 <para><emphasis role="bold">MD5(string)</emphasis></para>
170 <para>Calculates the MD5 hash of string, returning the result in hexadecimal.</para>
171
172- <para><emphasis role="bold">NVL(expr1, expr2)</emphasis></para>
173- <para>If expr1 is not null, then nvl returns expr2.</para>
174-
175- <para><emphasis role="bold">NVL2(expr1,expr2,expr3)</emphasis></para>
176- <para>Returns expr3 if expr1 is null, otherwise returns expr2.</para>
177-
178 <para><emphasis role="bold">OCTET_LENGTH(s)</emphasis></para>
179 <para>Returns the number of bytes in the string</para>
180
181
182=== removed file 'lib/postgresql.jar'
183Binary files lib/postgresql.jar 2011-05-01 15:49:41 +0000 and lib/postgresql.jar 1970-01-01 00:00:00 +0000 differ
184=== removed file 'lib/postgresql_license.txt'
185--- lib/postgresql_license.txt 2011-05-01 15:49:41 +0000
186+++ lib/postgresql_license.txt 1970-01-01 00:00:00 +0000
187@@ -1,26 +0,0 @@
188-Copyright (c) 1997-2008, PostgreSQL Global Development Group
189-All rights reserved.
190-
191-Redistribution and use in source and binary forms, with or without
192-modification, are permitted provided that the following conditions are met:
193-
194-1. Redistributions of source code must retain the above copyright notice,
195- this list of conditions and the following disclaimer.
196-2. Redistributions in binary form must reproduce the above copyright notice,
197- this list of conditions and the following disclaimer in the documentation
198- and/or other materials provided with the distribution.
199-3. Neither the name of the PostgreSQL Global Development Group nor the names
200- of its contributors may be used to endorse or promote products derived
201- from this software without specific prior written permission.
202-
203-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
204-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
205-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
206-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
207-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
208-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
209-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
210-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
211-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
212-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
213-POSSIBILITY OF SUCH DAMAGE.
214
215=== added directory 'src/org/postgresql/driver'
216=== added file 'src/org/postgresql/driver/Driver.java'
217--- src/org/postgresql/driver/Driver.java 1970-01-01 00:00:00 +0000
218+++ src/org/postgresql/driver/Driver.java 2011-08-30 20:30:24 +0000
219@@ -0,0 +1,792 @@
220+/*****************************************************************************
221+ * Copyright (C) 2008 EnterpriseDB Corporation.
222+ * Copyright (C) 2011 Stado Global Development Group.
223+ *
224+ * This file is part of Stado.
225+ *
226+ * Stado is free software: you can redistribute it and/or modify
227+ * it under the terms of the GNU General Public License as published by
228+ * the Free Software Foundation, either version 3 of the License, or
229+ * (at your option) any later version.
230+ *
231+ * Stado is distributed in the hope that it will be useful,
232+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
233+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
234+ * GNU General Public License for more details.
235+ *
236+ * You should have received a copy of the GNU General Public License
237+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
238+ *
239+ * You can find Stado at http://www.stado.us
240+ *
241+ ****************************************************************************/
242+package org.postgresql.driver;
243+
244+import java.io.*;
245+import java.sql.*;
246+import java.util.*;
247+import java.net.URL;
248+
249+import java.security.AccessController;
250+import java.security.PrivilegedActionException;
251+import java.security.PrivilegedExceptionAction;
252+
253+
254+import org.postgresql.driver.core.Logger;
255+import org.postgresql.driver.util.GT;
256+import org.postgresql.driver.util.PSQLDriverVersion;
257+import org.postgresql.driver.util.PSQLException;
258+import org.postgresql.driver.util.PSQLState;
259+
260+/**
261+ * The Java SQL framework allows for multiple database drivers. Each
262+ * driver should supply a class that implements the Driver interface
263+ *
264+ * <p>The DriverManager will try to load as many drivers as it can find and
265+ * then for any given connection request, it will ask each driver in turn
266+ * to try to connect to the target URL.
267+ *
268+ * <p>It is strongly recommended that each Driver class should be small and
269+ * standalone so that the Driver class can be loaded and queried without
270+ * bringing in vast quantities of supporting code.
271+ *
272+ * <p>When a Driver class is loaded, it should create an instance of itself
273+ * and register it with the DriverManager. This means that a user can load
274+ * and register a driver by doing Class.forName("foo.bah.Driver")
275+ *
276+ * @see org.postgresql.driver.PGConnection
277+ * @see java.sql.Driver
278+ */
279+public class Driver implements java.sql.Driver
280+{
281+
282+ // make these public so they can be used in setLogLevel below
283+
284+ public static final int DEBUG = 2;
285+ public static final int INFO = 1;
286+
287+ private static final Logger logger = new Logger();
288+ private static boolean logLevelSet = false;
289+
290+ static
291+ {
292+ try
293+ {
294+ // moved the registerDriver from the constructor to here
295+ // because some clients call the driver themselves (I know, as
296+ // my early jdbc work did - and that was based on other examples).
297+ // Placing it here, means that the driver is registered once only.
298+ java.sql.DriverManager.registerDriver(new Driver());
299+ }
300+ catch (SQLException e)
301+ {
302+ e.printStackTrace();
303+ }
304+ }
305+
306+ // Helper to retrieve default properties from classloader resource
307+ // properties files.
308+ private Properties defaultProperties;
309+ private synchronized Properties getDefaultProperties() throws IOException {
310+ if (defaultProperties != null)
311+ return defaultProperties;
312+
313+ // Make sure we load properties with the maximum possible
314+ // privileges.
315+ try
316+ {
317+ defaultProperties = (Properties)
318+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
319+ public Object run() throws IOException {
320+ return loadDefaultProperties();
321+ }
322+ });
323+ }
324+ catch (PrivilegedActionException e)
325+ {
326+ throw (IOException)e.getException();
327+ }
328+
329+ // Use the loglevel from the default properties (if any)
330+ // as the driver-wide default unless someone explicitly called
331+ // setLogLevel() already.
332+ synchronized (Driver.class) {
333+ if (!logLevelSet) {
334+ String driverLogLevel = defaultProperties.getProperty("loglevel");
335+ if (driverLogLevel != null) {
336+ try {
337+ setLogLevel(Integer.parseInt(driverLogLevel));
338+ } catch (Exception l_e) {
339+ // XXX revisit
340+ // invalid value for loglevel; ignore it
341+ }
342+ }
343+ }
344+ }
345+
346+ return defaultProperties;
347+ }
348+
349+ private Properties loadDefaultProperties() throws IOException {
350+ Properties merged = new Properties();
351+
352+ try {
353+ merged.setProperty("user", System.getProperty("user.name"));
354+ } catch (java.lang.SecurityException se) {
355+ // We're just trying to set a default, so if we can't
356+ // it's not a big deal.
357+ }
358+
359+ // If we are loaded by the bootstrap classloader, getClassLoader()
360+ // may return null. In that case, try to fall back to the system
361+ // classloader.
362+ //
363+ // We should not need to catch SecurityException here as we are
364+ // accessing either our own classloader, or the system classloader
365+ // when our classloader is null. The ClassLoader javadoc claims
366+ // neither case can throw SecurityException.
367+ ClassLoader cl = getClass().getClassLoader();
368+ if (cl == null)
369+ cl = ClassLoader.getSystemClassLoader();
370+
371+ if (cl == null) {
372+ logger.debug("Can't find a classloader for the Driver; not loading driver configuration");
373+ return merged; // Give up on finding defaults.
374+ }
375+
376+ logger.debug("Loading driver configuration via classloader " + cl);
377+
378+ // When loading the driver config files we don't want settings found
379+ // in later files in the classpath to override settings specified in
380+ // earlier files. To do this we've got to read the returned
381+ // Enumeration into temporary storage.
382+ ArrayList urls = new ArrayList();
383+ Enumeration urlEnum = cl.getResources("org/postgresql/driverconfig.properties");
384+ while (urlEnum.hasMoreElements())
385+ {
386+ urls.add(urlEnum.nextElement());
387+ }
388+
389+ for (int i=urls.size()-1; i>=0; i--) {
390+ URL url = (URL)urls.get(i);
391+ logger.debug("Loading driver configuration from: " + url);
392+ InputStream is = url.openStream();
393+ merged.load(is);
394+ is.close();
395+ }
396+
397+ return merged;
398+ }
399+
400+ /**
401+ * Try to make a database connection to the given URL. The driver
402+ * should return "null" if it realizes it is the wrong kind of
403+ * driver to connect to the given URL. This will be common, as
404+ * when the JDBC driverManager is asked to connect to a given URL,
405+ * it passes the URL to each loaded driver in turn.
406+ *
407+ * <p>The driver should raise an SQLException if it is the right driver
408+ * to connect to the given URL, but has trouble connecting to the
409+ * database.
410+ *
411+ * <p>The java.util.Properties argument can be used to pass arbitrary
412+ * string tag/value pairs as connection arguments.
413+ *
414+ * user - (required) The user to connect as
415+ * password - (optional) The password for the user
416+ * ssl - (optional) Use SSL when connecting to the server
417+ * charSet - (optional) The character set to be used for converting
418+ * to/from the database to unicode. If multibyte is enabled on the
419+ * server then the character set of the database is used as the default,
420+ * otherwise the jvm character encoding is used as the default.
421+ * This value is only used when connecting to a 7.2 or older server.
422+ * loglevel - (optional) Enable logging of messages from the driver.
423+ * The value is an integer from 1 to 2 where:
424+ * INFO = 1, DEBUG = 2
425+ * The output is sent to DriverManager.getPrintWriter() if set,
426+ * otherwise it is sent to System.out.
427+ * compatible - (optional) This is used to toggle
428+ * between different functionality as it changes across different releases
429+ * of the jdbc driver code. The values here are versions of the jdbc
430+ * client and not server versions. For example in 7.1 get/setBytes
431+ * worked on LargeObject values, in 7.2 these methods were changed
432+ * to work on bytea values. This change in functionality could
433+ * be disabled by setting the compatible level to be "7.1", in
434+ * which case the driver will revert to the 7.1 functionality.
435+ *
436+ * <p>Normally, at least
437+ * "user" and "password" properties should be included in the
438+ * properties. For a list of supported
439+ * character encoding , see
440+ * http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html
441+ * Note that you will probably want to have set up the Postgres database
442+ * itself to use the same encoding, with the "-E <encoding>" argument
443+ * to createdb.
444+ *
445+ * Our protocol takes the forms:
446+ * <PRE>
447+ * jdbc:postgresql://host:port/database?param1=val1&...
448+ * </PRE>
449+ *
450+ * @param url the URL of the database to connect to
451+ * @param info a list of arbitrary tag/value pairs as connection
452+ * arguments
453+ * @return a connection to the URL or null if it isnt us
454+ * @exception SQLException if a database access error occurs
455+ * @see java.sql.Driver#connect
456+ */
457+ public java.sql.Connection connect(String url, Properties info) throws SQLException
458+ {
459+ // get defaults
460+ Properties defaults;
461+ try
462+ {
463+ defaults = getDefaultProperties();
464+ }
465+ catch (IOException ioe)
466+ {
467+ throw new PSQLException(GT.tr("Error loading default settings from driverconfig.properties"),
468+ PSQLState.UNEXPECTED_ERROR, ioe);
469+ }
470+
471+ // override defaults with provided properties
472+ Properties props = new Properties(defaults);
473+ for (Enumeration e = info.propertyNames(); e.hasMoreElements(); )
474+ {
475+ String propName = (String)e.nextElement();
476+ props.setProperty(propName, info.getProperty(propName));
477+ }
478+
479+ // parse URL and add more properties
480+ if ((props = parseURL(url, props)) == null)
481+ {
482+ logger.debug("Error in url: " + url);
483+ return null;
484+ }
485+ try
486+ {
487+ logger.debug("Connecting with URL: " + url);
488+
489+ // Enforce login timeout, if specified, by running the connection
490+ // attempt in a separate thread. If we hit the timeout without the
491+ // connection completing, we abandon the connection attempt in
492+ // the calling thread, but the separate thread will keep trying.
493+ // Eventually, the separate thread will either fail or complete
494+ // the connection; at that point we clean up the connection if
495+ // we managed to establish one after all. See ConnectThread for
496+ // more details.
497+ long timeout = timeout(props);
498+ if (timeout <= 0)
499+ return makeConnection(url, props);
500+
501+ ConnectThread ct = new ConnectThread(url, props);
502+ new Thread(ct, "PostgreSQL JDBC driver connection thread").start();
503+ return ct.getResult(timeout);
504+ }
505+ catch (PSQLException ex1)
506+ {
507+ logger.debug("Connection error:", ex1);
508+ // re-throw the exception, otherwise it will be caught next, and a
509+ // org.postgresql.unusual error will be returned instead.
510+ throw ex1;
511+ }
512+ catch (java.security.AccessControlException ace)
513+ {
514+ throw new PSQLException(GT.tr("Your security policy has prevented the connection from being attempted. You probably need to grant the connect java.net.SocketPermission to the database server host and port that you wish to connect to."), PSQLState.UNEXPECTED_ERROR, ace);
515+ }
516+ catch (Exception ex2)
517+ {
518+ logger.debug("Unexpected connection error:", ex2);
519+ throw new PSQLException(GT.tr("Something unusual has occured to cause the driver to fail. Please report this exception."),
520+ PSQLState.UNEXPECTED_ERROR, ex2);
521+ }
522+ }
523+
524+ /**
525+ * Perform a connect in a separate thread; supports
526+ * getting the results from the original thread while enforcing
527+ * a login timout.
528+ */
529+ private static class ConnectThread implements Runnable {
530+ ConnectThread(String url, Properties props) {
531+ this.url = url;
532+ this.props = props;
533+ }
534+
535+ public void run() {
536+ Connection conn;
537+ Throwable error;
538+
539+ try {
540+ conn = makeConnection(url, props);
541+ error = null;
542+ } catch (Throwable t) {
543+ conn = null;
544+ error = t;
545+ }
546+
547+ synchronized (this) {
548+ if (abandoned) {
549+ if (conn != null) {
550+ try {
551+ conn.close();
552+ } catch (SQLException e) {}
553+ }
554+ } else {
555+ result = conn;
556+ resultException = error;
557+ notify();
558+ }
559+ }
560+ }
561+
562+ /**
563+ * Get the connection result from this (assumed running) thread.
564+ * If the timeout is reached without a result being available,
565+ * a SQLException is thrown.
566+ *
567+ * @param timeout timeout in milliseconds
568+ * @return the new connection, if successful
569+ * @throws SQLException if a connection error occurs or the timeout is reached
570+ */
571+ public Connection getResult(long timeout) throws SQLException {
572+ long expiry = System.currentTimeMillis() + timeout;
573+ synchronized (this) {
574+ while (true) {
575+ if (result != null)
576+ return result;
577+
578+ if (resultException != null) {
579+ if (resultException instanceof SQLException) {
580+ resultException.fillInStackTrace();
581+ throw (SQLException)resultException;
582+ } else {
583+ throw new PSQLException(GT.tr("Something unusual has occured to cause the driver to fail. Please report this exception."),
584+ PSQLState.UNEXPECTED_ERROR, resultException);
585+ }
586+ }
587+
588+ long delay = expiry - System.currentTimeMillis();
589+ if (delay <= 0) {
590+ abandoned = true;
591+ throw new PSQLException(GT.tr("Connection attempt timed out."),
592+ PSQLState.CONNECTION_UNABLE_TO_CONNECT);
593+ }
594+
595+ try {
596+ wait(delay);
597+ } catch (InterruptedException ie) {
598+ abandoned = true;
599+ throw new PSQLException(GT.tr("Interrupted while attempting to connect."),
600+ PSQLState.CONNECTION_UNABLE_TO_CONNECT);
601+ }
602+ }
603+ }
604+ }
605+
606+ private final String url;
607+ private final Properties props;
608+ private Connection result;
609+ private Throwable resultException;
610+ private boolean abandoned;
611+ }
612+
613+ /**
614+ * Create a connection from URL and properties. Always
615+ * does the connection work in the current thread without
616+ * enforcing a timeout, regardless of any timeout specified
617+ * in the properties.
618+ *
619+ * @param url the original URL
620+ * @param props the parsed/defaulted connection properties
621+ * @return a new connection
622+ * @throws SQLException if the connection could not be made
623+ */
624+ private static Connection makeConnection(String url, Properties props) throws SQLException {
625+ return new org.postgresql.driver.jdbc3.Jdbc3Connection(host(props), port(props),
626+ user(props), database(props),
627+ props, url);
628+ }
629+
630+ /**
631+ * Returns true if the driver thinks it can open a connection to the
632+ * given URL. Typically, drivers will return true if they understand
633+ * the subprotocol specified in the URL and false if they don't. Our
634+ * protocols start with jdbc:postgresql:
635+ *
636+ * @see java.sql.Driver#acceptsURL
637+ * @param url the URL of the driver
638+ * @return true if this driver accepts the given URL
639+ * @exception SQLException if a database-access error occurs
640+ * (Dont know why it would *shrug*)
641+ */
642+ public boolean acceptsURL(String url) throws SQLException
643+ {
644+ if (parseURL(url, null) == null)
645+ return false;
646+ return true;
647+ }
648+
649+ private static final Object[][] knownProperties = {
650+ { "PGDBNAME", Boolean.TRUE,
651+ "Database name to connect to; may be specified directly in the JDBC URL." },
652+ { "user", Boolean.TRUE,
653+ "Username to connect to the database as.", null },
654+ { "PGHOST", Boolean.FALSE,
655+ "Hostname of the PostgreSQL server; may be specified directly in the JDBC URL." },
656+ { "PGPORT", Boolean.FALSE,
657+ "Port number to connect to the PostgreSQL server on; may be specified directly in the JDBC URL.", },
658+ { "password", Boolean.FALSE,
659+ "Password to use when authenticating.", },
660+ { "protocolVersion", Boolean.FALSE,
661+ "Force use of a particular protocol version when connecting; if set, disables protocol version fallback.", },
662+ { "ssl", Boolean.FALSE,
663+ "Control use of SSL; any nonnull value causes SSL to be required." },
664+ { "sslfactory", Boolean.FALSE,
665+ "Provide a SSLSocketFactory class when using SSL." },
666+ { "sslfactoryarg", Boolean.FALSE,
667+ "Argument forwarded to constructor of SSLSocketFactory class." },
668+ { "loglevel", Boolean.FALSE,
669+ "Control the driver's log verbosity: 0 is off, 1 is INFO, 2 is DEBUG.",
670+ new String[] { "0", "1", "2" } },
671+ { "allowEncodingChanges", Boolean.FALSE,
672+ "Allow the user to change the client_encoding variable." },
673+ { "logUnclosedConnections", Boolean.FALSE,
674+ "When connections that are not explicitly closed are garbage collected, log the stacktrace from the opening of the connection to trace the leak source."},
675+ { "prepareThreshold", Boolean.FALSE,
676+ "Default statement prepare threshold (numeric)." },
677+ { "charSet", Boolean.FALSE,
678+ "When connecting to a pre-7.3 server, the database encoding to assume is in use." },
679+ { "compatible", Boolean.FALSE,
680+ "Force compatibility of some features with an older version of the driver.",
681+ new String[] { "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" } },
682+ { "loginTimeout", Boolean.FALSE,
683+ "The login timeout, in seconds; 0 means no timeout beyond the normal TCP connection timout." },
684+ { "socketTimeout", Boolean.FALSE,
685+ "The timeout value for socket read operations, in seconds; 0 means no timeout." },
686+ { "tcpKeepAlive", Boolean.FALSE,
687+ "Enable or disable TCP keep-alive probe." },
688+ { "stringtype", Boolean.FALSE,
689+ "The type to bind String parameters as (usually 'varchar'; 'unspecified' allows implicit casting to other types)",
690+ new String[] { "varchar", "unspecified" } },
691+ { "kerberosServerName", Boolean.FALSE,
692+ "The Kerberos service name to use when authenticating with GSSAPI. This is equivalent to libpq's PGKRBSRVNAME environment variable." },
693+ { "jaasApplicationName", Boolean.FALSE,
694+ "Specifies the name of the JAAS system or application login configuration." }
695+ };
696+
697+ /**
698+ * The getPropertyInfo method is intended to allow a generic GUI
699+ * tool to discover what properties it should prompt a human for
700+ * in order to get enough information to connect to a database.
701+ *
702+ * <p>Note that depending on the values the human has supplied so
703+ * far, additional values may become necessary, so it may be necessary
704+ * to iterate through several calls to getPropertyInfo
705+ *
706+ * @param url the Url of the database to connect to
707+ * @param info a proposed list of tag/value pairs that will be sent on
708+ * connect open.
709+ * @return An array of DriverPropertyInfo objects describing
710+ * possible properties. This array may be an empty array if
711+ * no properties are required
712+ * @exception SQLException if a database-access error occurs
713+ * @see java.sql.Driver#getPropertyInfo
714+ */
715+ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
716+ {
717+ Properties copy = new Properties(info);
718+ parseURL(url, copy);
719+
720+ DriverPropertyInfo[] props = new DriverPropertyInfo[knownProperties.length];
721+ for (int i = 0; i < knownProperties.length; ++i)
722+ {
723+ String name = (String) knownProperties[i][0];
724+ props[i] = new DriverPropertyInfo(name, copy.getProperty(name));
725+ props[i].required = ((Boolean) knownProperties[i][1]).booleanValue();
726+ props[i].description = (String) knownProperties[i][2];
727+ if (knownProperties[i].length > 3)
728+ props[i].choices = (String[]) knownProperties[i][3];
729+ }
730+
731+ return props;
732+ }
733+
734+ public static final int MAJORVERSION = 9;
735+ /**
736+ * Gets the drivers major version number
737+ *
738+ * @return the drivers major version number
739+ */
740+ public int getMajorVersion()
741+ {
742+ return MAJORVERSION;
743+ }
744+
745+
746+ public static final int MINORVERSION = 0;
747+ /**
748+ * Get the drivers minor version number
749+ *
750+ * @return the drivers minor version number
751+ */
752+ public int getMinorVersion()
753+ {
754+ return MINORVERSION;
755+ }
756+
757+ /**
758+ * Returns the server version series of this driver and the
759+ * specific build number.
760+ */
761+ public static String getVersion()
762+ {
763+ return "PostgreSQL 9.0 JDBC4 (build " + PSQLDriverVersion.buildNumber + ")";
764+ }
765+
766+ /**
767+ * Report whether the driver is a genuine JDBC compliant driver. A
768+ * driver may only report "true" here if it passes the JDBC compliance
769+ * tests, otherwise it is required to return false. JDBC compliance
770+ * requires full support for the JDBC API and full support for SQL 92
771+ * Entry Level.
772+ *
773+ * <p>For PostgreSQL, this is not yet possible, as we are not SQL92
774+ * compliant (yet).
775+ */
776+ public boolean jdbcCompliant()
777+ {
778+ return false;
779+ }
780+
781+ static private String[] protocols = { "jdbc", "postgresql" };
782+
783+ /**
784+ * Constructs a new DriverURL, splitting the specified URL into its
785+ * component parts
786+ * @param url JDBC URL to parse
787+ * @param defaults Default properties
788+ * @return Properties with elements added from the url
789+ * @exception SQLException
790+ */
791+ Properties parseURL(String url, Properties defaults) throws SQLException
792+ {
793+ int state = -1;
794+ Properties urlProps = new Properties(defaults);
795+
796+ String l_urlServer = url;
797+ String l_urlArgs = "";
798+
799+ int l_qPos = url.indexOf('?');
800+ if (l_qPos != -1)
801+ {
802+ l_urlServer = url.substring(0, l_qPos);
803+ l_urlArgs = url.substring(l_qPos + 1);
804+ }
805+
806+ // look for an IPv6 address that is enclosed by []
807+ // the upcoming parsing that uses colons as identifiers can't handle
808+ // the colons in an IPv6 address.
809+ int ipv6start = l_urlServer.indexOf("[");
810+ int ipv6end = l_urlServer.indexOf("]");
811+ String ipv6address = null;
812+ if (ipv6start != -1 && ipv6end > ipv6start)
813+ {
814+ ipv6address = l_urlServer.substring(ipv6start + 1, ipv6end);
815+ l_urlServer = l_urlServer.substring(0, ipv6start) + "ipv6host" + l_urlServer.substring(ipv6end + 1);
816+ }
817+
818+ //parse the server part of the url
819+ StringTokenizer st = new StringTokenizer(l_urlServer, ":/", true);
820+ int count;
821+ for (count = 0; (st.hasMoreTokens()); count++)
822+ {
823+ String token = st.nextToken();
824+
825+ // PM Aug 2 1997 - Modified to allow multiple backends
826+ if (count <= 3)
827+ {
828+ if ((count % 2) == 1 && token.equals(":"))
829+ ;
830+ else if ((count % 2) == 0)
831+ {
832+ boolean found = (count == 0) ? true : false;
833+ for (int tmp = 0;tmp < protocols.length;tmp++)
834+ {
835+ if (token.equals(protocols[tmp]))
836+ {
837+ // PM June 29 1997 Added this property to enable the driver
838+ // to handle multiple backend protocols.
839+ if (count == 2 && tmp > 0)
840+ {
841+ urlProps.setProperty("Protocol", token);
842+ found = true;
843+ }
844+ }
845+ }
846+
847+ if (found == false)
848+ return null;
849+ }
850+ else
851+ return null;
852+ }
853+ else if (count > 3)
854+ {
855+ if (count == 4 && token.equals("/"))
856+ state = 0;
857+ else if (count == 4)
858+ {
859+ urlProps.setProperty("PGDBNAME", token);
860+ state = -2;
861+ }
862+ else if (count == 5 && state == 0 && token.equals("/"))
863+ state = 1;
864+ else if (count == 5 && state == 0)
865+ return null;
866+ else if (count == 6 && state == 1)
867+ urlProps.setProperty("PGHOST", token);
868+ else if (count == 7 && token.equals(":"))
869+ state = 2;
870+ else if (count == 8 && state == 2)
871+ {
872+ try
873+ {
874+ Integer portNumber = Integer.decode(token);
875+ urlProps.setProperty("PGPORT", portNumber.toString());
876+ }
877+ catch (Exception e)
878+ {
879+ return null;
880+ }
881+ }
882+ else if ((count == 7 || count == 9) &&
883+ (state == 1 || state == 2) && token.equals("/"))
884+ state = -1;
885+ else if (state == -1)
886+ {
887+ urlProps.setProperty("PGDBNAME", token);
888+ state = -2;
889+ }
890+ }
891+ }
892+ if (count <= 1)
893+ {
894+ return null;
895+ }
896+
897+ // if we extracted an IPv6 address out earlier put it back
898+ if (ipv6address != null)
899+ urlProps.setProperty("PGHOST", ipv6address);
900+
901+ //parse the args part of the url
902+ StringTokenizer qst = new StringTokenizer(l_urlArgs, "&");
903+ for (count = 0; (qst.hasMoreTokens()); count++)
904+ {
905+ String token = qst.nextToken();
906+ int l_pos = token.indexOf('=');
907+ if (l_pos == -1)
908+ {
909+ urlProps.setProperty(token, "");
910+ }
911+ else
912+ {
913+ urlProps.setProperty(token.substring(0, l_pos), token.substring(l_pos + 1));
914+ }
915+ }
916+
917+ return urlProps;
918+ }
919+
920+ /**
921+ * @return the hostname portion of the URL
922+ */
923+ private static String host(Properties props)
924+ {
925+ return props.getProperty("PGHOST", "localhost");
926+ }
927+
928+ /**
929+ * @return the port number portion of the URL or the default if no port was specified
930+ */
931+ private static int port(Properties props)
932+ {
933+ return Integer.parseInt(props.getProperty("PGPORT", "5432"));
934+ }
935+
936+ /**
937+ * @return the username of the URL
938+ */
939+ private static String user(Properties props)
940+ {
941+ return props.getProperty("user", "");
942+ }
943+
944+ /**
945+ * @return the database name of the URL
946+ */
947+ private static String database(Properties props)
948+ {
949+ return props.getProperty("PGDBNAME", "");
950+ }
951+
952+ /**
953+ * @return the timeout from the URL, in milliseconds
954+ */
955+ private static long timeout(Properties props)
956+ {
957+ String timeout = props.getProperty("loginTimeout");
958+ if (timeout != null) {
959+ try {
960+ return (long) (Float.parseFloat(timeout) * 1000);
961+ } catch (NumberFormatException e) {
962+ // Log level isn't set yet, so this doesn't actually
963+ // get printed.
964+ logger.debug("Couldn't parse loginTimeout value: " + timeout);
965+ }
966+ }
967+ return DriverManager.getLoginTimeout() * 1000;
968+ }
969+
970+ /*
971+ * This method was added in v6.5, and simply throws an SQLException
972+ * for an unimplemented method. I decided to do it this way while
973+ * implementing the JDBC2 extensions to JDBC, as it should help keep the
974+ * overall driver size down.
975+ * It now requires the call Class and the function name to help when the
976+ * driver is used with closed software that don't report the stack strace
977+ * @param callClass the call Class
978+ * @param functionName the name of the unimplemented function with the type
979+ * of its arguments
980+ * @return PSQLException with a localized message giving the complete
981+ * description of the unimplemeted function
982+ */
983+ public static SQLException notImplemented(Class callClass, String functionName)
984+ {
985+ return new PSQLException(GT.tr("Method {0} is not yet implemented.", callClass.getName() + "." + functionName),
986+ PSQLState.NOT_IMPLEMENTED);
987+ }
988+
989+ /**
990+ * used to turn logging on to a certain level, can be called
991+ * by specifying fully qualified class ie org.postgresql.Driver.setLogLevel()
992+ * @param logLevel sets the level which logging will respond to
993+ * INFO being almost no messages
994+ * DEBUG most verbose
995+ */
996+ public static void setLogLevel(int logLevel)
997+ {
998+ synchronized (Driver.class) {
999+ logger.setLogLevel(logLevel);
1000+ logLevelSet = true;
1001+ }
1002+ }
1003+
1004+ public static int getLogLevel()
1005+ {
1006+ synchronized (Driver.class) {
1007+ return logger.getLogLevel();
1008+ }
1009+ }
1010+
1011+}
1012
1013=== added file 'src/org/postgresql/driver/PGConnection.java'
1014--- src/org/postgresql/driver/PGConnection.java 1970-01-01 00:00:00 +0000
1015+++ src/org/postgresql/driver/PGConnection.java 2011-08-30 20:30:24 +0000
1016@@ -0,0 +1,116 @@
1017+/*****************************************************************************
1018+ * Copyright (C) 2008 EnterpriseDB Corporation.
1019+ * Copyright (C) 2011 Stado Global Development Group.
1020+ *
1021+ * This file is part of Stado.
1022+ *
1023+ * Stado is free software: you can redistribute it and/or modify
1024+ * it under the terms of the GNU General Public License as published by
1025+ * the Free Software Foundation, either version 3 of the License, or
1026+ * (at your option) any later version.
1027+ *
1028+ * Stado is distributed in the hope that it will be useful,
1029+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1030+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1031+ * GNU General Public License for more details.
1032+ *
1033+ * You should have received a copy of the GNU General Public License
1034+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1035+ *
1036+ * You can find Stado at http://www.stado.us
1037+ *
1038+ ****************************************************************************/
1039+package org.postgresql.driver;
1040+
1041+import java.sql.*;
1042+
1043+import org.postgresql.driver.copy.CopyManager;
1044+
1045+/**
1046+ * This interface defines the public PostgreSQL extensions to
1047+ * java.sql.Connection. All Connections returned by the PostgreSQL driver
1048+ * implement PGConnection.
1049+ */
1050+public interface PGConnection
1051+{
1052+ /**
1053+ * This method returns any notifications that have been received
1054+ * since the last call to this method.
1055+ * Returns null if there have been no notifications.
1056+ * @since 7.3
1057+ */
1058+ public PGNotification[] getNotifications() throws SQLException;
1059+
1060+ /**
1061+ * This returns the COPY API for the current connection.
1062+ * @since 8.4
1063+ */
1064+ public CopyManager getCopyAPI() throws SQLException;
1065+
1066+ /**
1067+ * This allows client code to add a handler for one of org.postgresql's
1068+ * more unique data types. It is approximately equivalent to
1069+ * <code>addDataType(type, Class.forName(name))</code>.
1070+ *
1071+ * @deprecated As of 8.0, replaced by
1072+ * {@link #addDataType(String,Class)}. This deprecated method does not
1073+ * work correctly for registering classes that cannot be directly loaded
1074+ * by the JDBC driver's classloader.
1075+ * @throws RuntimeException if the type cannot be registered (class not
1076+ * found, etc).
1077+ */
1078+ public void addDataType(String type, String name);
1079+
1080+ /**
1081+ * This allows client code to add a handler for one of org.postgresql's
1082+ * more unique data types.
1083+ *
1084+ * <p><b>NOTE:</b> This is not part of JDBC, but an extension.
1085+ *
1086+ * <p>The best way to use this is as follows:
1087+ *
1088+ * <p><pre>
1089+ * ...
1090+ * ((org.postgresql.PGConnection)myconn).addDataType("mytype", my.class.name.class);
1091+ * ...
1092+ * </pre>
1093+ *
1094+ * <p>where myconn is an open Connection to org.postgresql.
1095+ *
1096+ * <p>The handling class must extend org.postgresql.driver.util.PGobject
1097+ *
1098+ * @since 8.0
1099+ *
1100+ * @param type the PostgreSQL type to register
1101+ * @param klass the class implementing the Java representation of the type;
1102+ * this class must implement {@link org.postgresql.driver.util.PGobject}).
1103+ *
1104+ * @throws SQLException if <code>klass</code> does not implement
1105+ * {@link org.postgresql.driver.util.PGobject}).
1106+ *
1107+ * @see org.postgresql.driver.util.PGobject
1108+ */
1109+ public void addDataType(String type, Class klass)
1110+ throws SQLException;
1111+
1112+ /**
1113+ * Set the default statement reuse threshold before enabling server-side
1114+ * prepare. See {@link org.postgresql.driver.PGStatement#setPrepareThreshold(int)} for
1115+ * details.
1116+ *
1117+ * @since build 302
1118+ * @param threshold the new threshold
1119+ */
1120+ public void setPrepareThreshold(int threshold);
1121+
1122+ /**
1123+ * Get the default server-side prepare reuse threshold for statements created
1124+ * from this connection.
1125+ *
1126+ * @since build 302
1127+ * @return the current threshold
1128+ */
1129+ public int getPrepareThreshold();
1130+
1131+}
1132+
1133
1134=== added file 'src/org/postgresql/driver/PGNotification.java'
1135--- src/org/postgresql/driver/PGNotification.java 1970-01-01 00:00:00 +0000
1136+++ src/org/postgresql/driver/PGNotification.java 2011-08-30 20:30:24 +0000
1137@@ -0,0 +1,52 @@
1138+/*****************************************************************************
1139+ * Copyright (C) 2008 EnterpriseDB Corporation.
1140+ * Copyright (C) 2011 Stado Global Development Group.
1141+ *
1142+ * This file is part of Stado.
1143+ *
1144+ * Stado is free software: you can redistribute it and/or modify
1145+ * it under the terms of the GNU General Public License as published by
1146+ * the Free Software Foundation, either version 3 of the License, or
1147+ * (at your option) any later version.
1148+ *
1149+ * Stado is distributed in the hope that it will be useful,
1150+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1151+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1152+ * GNU General Public License for more details.
1153+ *
1154+ * You should have received a copy of the GNU General Public License
1155+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1156+ *
1157+ * You can find Stado at http://www.stado.us
1158+ *
1159+ ****************************************************************************/
1160+package org.postgresql.driver;
1161+
1162+/**
1163+ * This interface defines the public PostgreSQL extension for Notifications
1164+ */
1165+public interface PGNotification
1166+{
1167+ /**
1168+ * Returns name of this notification
1169+ * @since 7.3
1170+ */
1171+ public String getName();
1172+
1173+ /**
1174+ * Returns the process id of the backend process making this notification
1175+ * @since 7.3
1176+ */
1177+ public int getPID();
1178+
1179+ /**
1180+ * Returns additional information from the notifying process.
1181+ * This feature has only been implemented in server versions 9.0
1182+ * and later, so previous versions will always return an empty String.
1183+ *
1184+ * @since 8.0
1185+ */
1186+ public String getParameter();
1187+
1188+}
1189+
1190
1191=== added file 'src/org/postgresql/driver/PGRefCursorResultSet.java'
1192--- src/org/postgresql/driver/PGRefCursorResultSet.java 1970-01-01 00:00:00 +0000
1193+++ src/org/postgresql/driver/PGRefCursorResultSet.java 2011-08-30 20:30:24 +0000
1194@@ -0,0 +1,40 @@
1195+/*****************************************************************************
1196+ * Copyright (C) 2008 EnterpriseDB Corporation.
1197+ * Copyright (C) 2011 Stado Global Development Group.
1198+ *
1199+ * This file is part of Stado.
1200+ *
1201+ * Stado is free software: you can redistribute it and/or modify
1202+ * it under the terms of the GNU General Public License as published by
1203+ * the Free Software Foundation, either version 3 of the License, or
1204+ * (at your option) any later version.
1205+ *
1206+ * Stado is distributed in the hope that it will be useful,
1207+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1208+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1209+ * GNU General Public License for more details.
1210+ *
1211+ * You should have received a copy of the GNU General Public License
1212+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1213+ *
1214+ * You can find Stado at http://www.stado.us
1215+ *
1216+ ****************************************************************************/
1217+package org.postgresql.driver;
1218+
1219+/**
1220+ * A ref cursor based result set.
1221+ *
1222+ * @deprecated As of 8.0, this interface is only present for backwards-
1223+ * compatibility purposes. New code should call getString() on the ResultSet
1224+ * that contains the refcursor to obtain the underlying cursor name.
1225+ */
1226+public interface PGRefCursorResultSet
1227+{
1228+
1229+ /** @return the name of the cursor.
1230+ * @deprecated As of 8.0, replaced with calling getString() on
1231+ * the ResultSet that this ResultSet was obtained from.
1232+ */
1233+ public String getRefCursor ();
1234+}
1235
1236=== added file 'src/org/postgresql/driver/PGResultSetMetaData.java'
1237--- src/org/postgresql/driver/PGResultSetMetaData.java 1970-01-01 00:00:00 +0000
1238+++ src/org/postgresql/driver/PGResultSetMetaData.java 2011-08-30 20:30:24 +0000
1239@@ -0,0 +1,54 @@
1240+/*****************************************************************************
1241+ * Copyright (C) 2008 EnterpriseDB Corporation.
1242+ * Copyright (C) 2011 Stado Global Development Group.
1243+ *
1244+ * This file is part of Stado.
1245+ *
1246+ * Stado is free software: you can redistribute it and/or modify
1247+ * it under the terms of the GNU General Public License as published by
1248+ * the Free Software Foundation, either version 3 of the License, or
1249+ * (at your option) any later version.
1250+ *
1251+ * Stado is distributed in the hope that it will be useful,
1252+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1253+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1254+ * GNU General Public License for more details.
1255+ *
1256+ * You should have received a copy of the GNU General Public License
1257+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1258+ *
1259+ * You can find Stado at http://www.stado.us
1260+ *
1261+ ****************************************************************************/
1262+package org.postgresql.driver;
1263+
1264+import java.sql.SQLException;
1265+
1266+public interface PGResultSetMetaData
1267+{
1268+
1269+ /**
1270+ * Returns the underlying column name of a query result, or ""
1271+ * if it is unable to be determined.
1272+ *
1273+ * @since 8.0
1274+ */
1275+ public String getBaseColumnName(int column) throws SQLException;
1276+
1277+ /**
1278+ * Returns the underlying table name of query result, or ""
1279+ * if it is unable to be determined.
1280+ *
1281+ * @since 8.0
1282+ */
1283+ public String getBaseTableName(int column) throws SQLException;
1284+
1285+ /**
1286+ * Returns the underlying table name of query result, or ""
1287+ * if it is unable to be determined.
1288+ *
1289+ * @since 8.0
1290+ */
1291+ public String getBaseSchemaName(int column) throws SQLException;
1292+
1293+}
1294
1295=== added file 'src/org/postgresql/driver/PGStatement.java'
1296--- src/org/postgresql/driver/PGStatement.java 1970-01-01 00:00:00 +0000
1297+++ src/org/postgresql/driver/PGStatement.java 2011-08-30 20:30:24 +0000
1298@@ -0,0 +1,98 @@
1299+/*****************************************************************************
1300+ * Copyright (C) 2008 EnterpriseDB Corporation.
1301+ * Copyright (C) 2011 Stado Global Development Group.
1302+ *
1303+ * This file is part of Stado.
1304+ *
1305+ * Stado is free software: you can redistribute it and/or modify
1306+ * it under the terms of the GNU General Public License as published by
1307+ * the Free Software Foundation, either version 3 of the License, or
1308+ * (at your option) any later version.
1309+ *
1310+ * Stado is distributed in the hope that it will be useful,
1311+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1312+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313+ * GNU General Public License for more details.
1314+ *
1315+ * You should have received a copy of the GNU General Public License
1316+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1317+ *
1318+ * You can find Stado at http://www.stado.us
1319+ *
1320+ ****************************************************************************/
1321+package org.postgresql.driver;
1322+
1323+import java.sql.*;
1324+
1325+/**
1326+ * This interface defines the public PostgreSQL extensions to
1327+ * java.sql.Statement. All Statements constructed by the PostgreSQL
1328+ * driver implement PGStatement.
1329+ */
1330+public interface PGStatement
1331+{
1332+ // We can't use Long.MAX_VALUE or Long.MIN_VALUE for java.sql.date
1333+ // because this would break the 'normalization contract' of the
1334+ // java.sql.Date API.
1335+ // The follow values are the nearest MAX/MIN values with hour,
1336+ // minute, second, millisecond set to 0 - this is used for
1337+ // -infinity / infinity representation in Java
1338+ public static final long DATE_POSITIVE_INFINITY = 9223372036825200000l;
1339+ public static final long DATE_NEGATIVE_INFINITY = -9223372036832400000l;
1340+
1341+
1342+ /**
1343+ * Returns the Last inserted/updated oid.
1344+ * @return OID of last insert
1345+ * @since 7.3
1346+ */
1347+ public long getLastOID() throws SQLException;
1348+
1349+ /**
1350+ * Turn on the use of prepared statements in the server (server side
1351+ * prepared statements are unrelated to jdbc PreparedStatements)
1352+ * As of build 302, this method is equivalent to
1353+ * <code>setPrepareThreshold(1)</code>.
1354+ *
1355+ * @deprecated As of build 302, replaced by {@link #setPrepareThreshold(int)}
1356+ * @since 7.3
1357+ */
1358+ public void setUseServerPrepare(boolean flag) throws SQLException;
1359+
1360+ /**
1361+ * Checks if this statement will be executed as a server-prepared
1362+ * statement. A return value of <code>true</code> indicates that the next
1363+ * execution of the statement will be done as a server-prepared statement,
1364+ * assuming the underlying protocol supports it.
1365+ *
1366+ * @return true if the next reuse of this statement will use a
1367+ * server-prepared statement
1368+ */
1369+ public boolean isUseServerPrepare();
1370+
1371+ /**
1372+ * Sets the reuse threshold for using server-prepared statements.
1373+ *<p>
1374+ * If <code>threshold</code> is a non-zero value N, the Nth and subsequent
1375+ * reuses of a PreparedStatement will use server-side prepare.
1376+ *<p>
1377+ * If <code>threshold</code> is zero, server-side prepare will not be used.
1378+ *<p>
1379+ * The reuse threshold is only used by PreparedStatement and
1380+ * CallableStatement objects; it is ignored for plain Statements.
1381+ *
1382+ * @since build 302
1383+ * @param threshold the new threshold for this statement
1384+ * @throws SQLException if an exception occurs while changing the threshold
1385+ */
1386+ public void setPrepareThreshold(int threshold) throws SQLException;
1387+
1388+ /**
1389+ * Gets the server-side prepare reuse threshold in use for this statement.
1390+ *
1391+ * @since build 302
1392+ * @return the current threshold
1393+ * @see #setPrepareThreshold(int)
1394+ */
1395+ public int getPrepareThreshold();
1396+}
1397
1398=== added directory 'src/org/postgresql/driver/copy'
1399=== added file 'src/org/postgresql/driver/copy/CopyIn.java'
1400--- src/org/postgresql/driver/copy/CopyIn.java 1970-01-01 00:00:00 +0000
1401+++ src/org/postgresql/driver/copy/CopyIn.java 2011-08-30 20:30:24 +0000
1402@@ -0,0 +1,56 @@
1403+/*****************************************************************************
1404+ * Copyright (C) 2008 EnterpriseDB Corporation.
1405+ * Copyright (C) 2011 Stado Global Development Group.
1406+ *
1407+ * This file is part of Stado.
1408+ *
1409+ * Stado is free software: you can redistribute it and/or modify
1410+ * it under the terms of the GNU General Public License as published by
1411+ * the Free Software Foundation, either version 3 of the License, or
1412+ * (at your option) any later version.
1413+ *
1414+ * Stado is distributed in the hope that it will be useful,
1415+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1416+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1417+ * GNU General Public License for more details.
1418+ *
1419+ * You should have received a copy of the GNU General Public License
1420+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1421+ *
1422+ * You can find Stado at http://www.stado.us
1423+ *
1424+ ****************************************************************************/
1425+package org.postgresql.driver.copy;
1426+
1427+import java.sql.SQLException;
1428+
1429+/**
1430+ * Copy bulk data from client into a PostgreSQL table very fast.
1431+ */
1432+public interface CopyIn extends CopyOperation {
1433+
1434+ /**
1435+ * Writes specified part of given byte array to an open and writable copy operation.
1436+ * @param buf array of bytes to write
1437+ * @param off offset of first byte to write (normally zero)
1438+ * @param siz number of bytes to write (normally buf.length)
1439+ * @throws SQLException if the operation fails
1440+ */
1441+ void writeToCopy(byte[] buf, int off, int siz) throws SQLException;
1442+
1443+ /**
1444+ * Force any buffered output to be sent over the network to the
1445+ * backend. In general this is a useless operation as it will get
1446+ * pushed over in due time or when endCopy is called. Some specific
1447+ * modified server versions (Truviso) want this data sooner.
1448+ * If you are unsure if you need to use this method, don't.
1449+ */
1450+ void flushCopy() throws SQLException;
1451+
1452+ /**
1453+ * Finishes copy operation succesfully.
1454+ * @return number of updated rows for server 8.2 or newer (see getHandledRowCount())
1455+ * @throws SQLException if the operation fails.
1456+ */
1457+ public long endCopy() throws SQLException;
1458+}
1459
1460=== added file 'src/org/postgresql/driver/copy/CopyManager.java'
1461--- src/org/postgresql/driver/copy/CopyManager.java 1970-01-01 00:00:00 +0000
1462+++ src/org/postgresql/driver/copy/CopyManager.java 2011-08-30 20:30:24 +0000
1463@@ -0,0 +1,202 @@
1464+/*****************************************************************************
1465+ * Copyright (C) 2008 EnterpriseDB Corporation.
1466+ * Copyright (C) 2011 Stado Global Development Group.
1467+ *
1468+ * This file is part of Stado.
1469+ *
1470+ * Stado is free software: you can redistribute it and/or modify
1471+ * it under the terms of the GNU General Public License as published by
1472+ * the Free Software Foundation, either version 3 of the License, or
1473+ * (at your option) any later version.
1474+ *
1475+ * Stado is distributed in the hope that it will be useful,
1476+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1477+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1478+ * GNU General Public License for more details.
1479+ *
1480+ * You should have received a copy of the GNU General Public License
1481+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1482+ *
1483+ * You can find Stado at http://www.stado.us
1484+ *
1485+ ****************************************************************************/
1486+
1487+/**
1488+ * Bulk data copy for PostgreSQL
1489+ */
1490+package org.postgresql.driver.copy;
1491+
1492+import java.io.IOException;
1493+import java.io.OutputStream;
1494+import java.io.InputStream;
1495+import java.io.Reader;
1496+import java.io.Writer;
1497+import java.sql.SQLException;
1498+
1499+import org.postgresql.driver.core.BaseConnection;
1500+import org.postgresql.driver.core.Encoding;
1501+import org.postgresql.driver.core.QueryExecutor;
1502+import org.postgresql.driver.util.GT;
1503+import org.postgresql.driver.util.PSQLException;
1504+import org.postgresql.driver.util.PSQLState;
1505+
1506+/**
1507+ * API for PostgreSQL COPY bulk data transfer
1508+ */
1509+public class CopyManager {
1510+ // I don't know what the best buffer size is, so we let people specify it if
1511+ // they want, and if they don't know, we don't make them guess, so that if we
1512+ // do figure it out we can just set it here and they reap the rewards.
1513+ // Note that this is currently being used for both a number of bytes and a number
1514+ // of characters.
1515+ final static int DEFAULT_BUFFER_SIZE = 65536;
1516+
1517+ private final Encoding encoding;
1518+ private final QueryExecutor queryExecutor;
1519+ private final BaseConnection connection;
1520+
1521+ public CopyManager(BaseConnection connection) throws SQLException {
1522+ this.encoding = connection.getEncoding();
1523+ this.queryExecutor = connection.getQueryExecutor();
1524+ this.connection = connection;
1525+ }
1526+
1527+ public CopyIn copyIn(String sql) throws SQLException {
1528+ CopyOperation op = null;
1529+ try {
1530+ op = queryExecutor.startCopy(sql, connection.getAutoCommit());
1531+ return (CopyIn) op;
1532+ } catch(ClassCastException cce) {
1533+ op.cancelCopy();
1534+ throw new PSQLException(GT.tr("Requested CopyIn but got {0}", op.getClass().getName()), PSQLState.WRONG_OBJECT_TYPE, cce);
1535+ }
1536+ }
1537+
1538+ public CopyOut copyOut(String sql) throws SQLException {
1539+ CopyOperation op = null;
1540+ try {
1541+ op = queryExecutor.startCopy(sql, connection.getAutoCommit());
1542+ return (CopyOut) op;
1543+ } catch(ClassCastException cce) {
1544+ op.cancelCopy();
1545+ throw new PSQLException(GT.tr("Requested CopyOut but got {0}", op.getClass().getName()), PSQLState.WRONG_OBJECT_TYPE, cce);
1546+ }
1547+ }
1548+
1549+ /**
1550+ * Pass results of a COPY TO STDOUT query from database into a Writer.
1551+ * @param sql COPY TO STDOUT statement
1552+ * @param to the stream to write the results to (row by row)
1553+ * @return number of rows updated for server 8.2 or newer; -1 for older
1554+ * @throws SQLException on database usage errors
1555+ * @throws IOException upon writer or database connection failure
1556+ */
1557+ public long copyOut(final String sql, Writer to) throws SQLException, IOException {
1558+ byte[] buf;
1559+ CopyOut cp = copyOut(sql);
1560+ try {
1561+ while ( (buf = cp.readFromCopy()) != null ) {
1562+ to.write(encoding.decode(buf));
1563+ }
1564+ return cp.getHandledRowCount();
1565+ } finally { // see to it that we do not leave the connection locked
1566+ if(cp.isActive())
1567+ cp.cancelCopy();
1568+ }
1569+ }
1570+
1571+ /**
1572+ * Pass results of a COPY TO STDOUT query from database into an OutputStream.
1573+ * @param sql COPY TO STDOUT statement
1574+ * @param to the stream to write the results to (row by row)
1575+ * @return number of rows updated for server 8.2 or newer; -1 for older
1576+ * @throws SQLException on database usage errors
1577+ * @throws IOException upon output stream or database connection failure
1578+ */
1579+ public long copyOut(final String sql, OutputStream to) throws SQLException, IOException {
1580+ byte[] buf;
1581+ CopyOut cp = copyOut(sql);
1582+ try {
1583+ while( (buf = cp.readFromCopy()) != null ) {
1584+ to.write(buf);
1585+ }
1586+ return cp.getHandledRowCount();
1587+ } finally { // see to it that we do not leave the connection locked
1588+ if(cp.isActive())
1589+ cp.cancelCopy();
1590+ }
1591+ }
1592+
1593+ /**
1594+ * Use COPY FROM STDIN for very fast copying from a Reader into a database table.
1595+ * @param sql COPY FROM STDIN statement
1596+ * @param from a CSV file or such
1597+ * @return number of rows updated for server 8.2 or newer; -1 for older
1598+ * @throws SQLException on database usage issues
1599+ * @throws IOException upon reader or database connection failure
1600+ */
1601+ public long copyIn(final String sql, Reader from) throws SQLException, IOException {
1602+ return copyIn(sql, from, DEFAULT_BUFFER_SIZE);
1603+ }
1604+
1605+ /**
1606+ * Use COPY FROM STDIN for very fast copying from a Reader into a database table.
1607+ * @param sql COPY FROM STDIN statement
1608+ * @param from a CSV file or such
1609+ * @param bufferSize number of characters to buffer and push over network to server at once
1610+ * @return number of rows updated for server 8.2 or newer; -1 for older
1611+ * @throws SQLException on database usage issues
1612+ * @throws IOException upon reader or database connection failure
1613+ */
1614+ public long copyIn(final String sql, Reader from, int bufferSize) throws SQLException, IOException {
1615+ char[] cbuf = new char[bufferSize];
1616+ int len;
1617+ CopyIn cp = copyIn(sql);
1618+ try {
1619+ while ( (len = from.read(cbuf)) > 0) {
1620+ byte[] buf = encoding.encode(new String(cbuf, 0, len));
1621+ cp.writeToCopy(buf, 0, buf.length);
1622+ }
1623+ return cp.endCopy();
1624+ } finally { // see to it that we do not leave the connection locked
1625+ if(cp.isActive())
1626+ cp.cancelCopy();
1627+ }
1628+ }
1629+
1630+ /**
1631+ * Use COPY FROM STDIN for very fast copying from an InputStream into a database table.
1632+ * @param sql COPY FROM STDIN statement
1633+ * @param from a CSV file or such
1634+ * @return number of rows updated for server 8.2 or newer; -1 for older
1635+ * @throws SQLException on database usage issues
1636+ * @throws IOException upon input stream or database connection failure
1637+ */
1638+ public long copyIn(final String sql, InputStream from) throws SQLException, IOException {
1639+ return copyIn(sql, from, DEFAULT_BUFFER_SIZE);
1640+ }
1641+
1642+ /**
1643+ * Use COPY FROM STDIN for very fast copying from an InputStream into a database table.
1644+ * @param sql COPY FROM STDIN statement
1645+ * @param from a CSV file or such
1646+ * @param bufferSize number of bytes to buffer and push over network to server at once
1647+ * @return number of rows updated for server 8.2 or newer; -1 for older
1648+ * @throws SQLException on database usage issues
1649+ * @throws IOException upon input stream or database connection failure
1650+ */
1651+ public long copyIn(final String sql, InputStream from, int bufferSize) throws SQLException, IOException {
1652+ byte[] buf = new byte[bufferSize];
1653+ int len;
1654+ CopyIn cp = copyIn(sql);
1655+ try {
1656+ while( (len = from.read(buf)) > 0 ) {
1657+ cp.writeToCopy(buf, 0, len);
1658+ }
1659+ return cp.endCopy();
1660+ } finally { // see to it that we do not leave the connection locked
1661+ if(cp.isActive())
1662+ cp.cancelCopy();
1663+ }
1664+ }
1665+}
1666
1667=== added file 'src/org/postgresql/driver/copy/CopyOperation.java'
1668--- src/org/postgresql/driver/copy/CopyOperation.java 1970-01-01 00:00:00 +0000
1669+++ src/org/postgresql/driver/copy/CopyOperation.java 2011-08-30 20:30:24 +0000
1670@@ -0,0 +1,68 @@
1671+/*****************************************************************************
1672+ * Copyright (C) 2008 EnterpriseDB Corporation.
1673+ * Copyright (C) 2011 Stado Global Development Group.
1674+ *
1675+ * This file is part of Stado.
1676+ *
1677+ * Stado is free software: you can redistribute it and/or modify
1678+ * it under the terms of the GNU General Public License as published by
1679+ * the Free Software Foundation, either version 3 of the License, or
1680+ * (at your option) any later version.
1681+ *
1682+ * Stado is distributed in the hope that it will be useful,
1683+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1684+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1685+ * GNU General Public License for more details.
1686+ *
1687+ * You should have received a copy of the GNU General Public License
1688+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1689+ *
1690+ * You can find Stado at http://www.stado.us
1691+ *
1692+ ****************************************************************************/
1693+package org.postgresql.driver.copy;
1694+
1695+import java.sql.SQLException;
1696+
1697+/**
1698+ * Exchange bulk data between client and PostgreSQL database tables.
1699+ * See CopyIn and CopyOut for full interfaces for corresponding copy directions.
1700+ */
1701+public interface CopyOperation {
1702+
1703+ /**
1704+ * @return number of fields in each row for this operation
1705+ */
1706+ int getFieldCount();
1707+
1708+ /**
1709+ * @return overall format of each row: 0 = textual, 1 = binary
1710+ */
1711+ int getFormat();
1712+
1713+ /**
1714+ * @param field number of field (0..fieldCount()-1)
1715+ * @return format of requested field: 0 = textual, 1 = binary
1716+ */
1717+ int getFieldFormat(int field);
1718+
1719+ /**
1720+ * @return is connection reserved for this Copy operation?
1721+ */
1722+ boolean isActive();
1723+
1724+ /**
1725+ * Cancels this copy operation, discarding any exchanged data.
1726+ * @throws SQLException if cancelling fails
1727+ */
1728+ void cancelCopy() throws SQLException;
1729+
1730+ /**
1731+ * After succesful end of copy, returns the number
1732+ * of database records handled in that operation.
1733+ * Only implemented in PostgreSQL server version 8.2 and up.
1734+ * Otherwise, returns -1.
1735+ * @return number of handled rows or -1
1736+ */
1737+ public long getHandledRowCount();
1738+}
1739
1740=== added file 'src/org/postgresql/driver/copy/CopyOut.java'
1741--- src/org/postgresql/driver/copy/CopyOut.java 1970-01-01 00:00:00 +0000
1742+++ src/org/postgresql/driver/copy/CopyOut.java 2011-08-30 20:30:24 +0000
1743@@ -0,0 +1,29 @@
1744+/*****************************************************************************
1745+ * Copyright (C) 2008 EnterpriseDB Corporation.
1746+ * Copyright (C) 2011 Stado Global Development Group.
1747+ *
1748+ * This file is part of Stado.
1749+ *
1750+ * Stado is free software: you can redistribute it and/or modify
1751+ * it under the terms of the GNU General Public License as published by
1752+ * the Free Software Foundation, either version 3 of the License, or
1753+ * (at your option) any later version.
1754+ *
1755+ * Stado is distributed in the hope that it will be useful,
1756+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1757+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1758+ * GNU General Public License for more details.
1759+ *
1760+ * You should have received a copy of the GNU General Public License
1761+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1762+ *
1763+ * You can find Stado at http://www.stado.us
1764+ *
1765+ ****************************************************************************/
1766+package org.postgresql.driver.copy;
1767+
1768+import java.sql.SQLException;
1769+
1770+public interface CopyOut extends CopyOperation {
1771+ byte[] readFromCopy() throws SQLException;
1772+}
1773
1774=== added file 'src/org/postgresql/driver/copy/PGCopyInputStream.java'
1775--- src/org/postgresql/driver/copy/PGCopyInputStream.java 1970-01-01 00:00:00 +0000
1776+++ src/org/postgresql/driver/copy/PGCopyInputStream.java 2011-08-30 20:30:24 +0000
1777@@ -0,0 +1,166 @@
1778+/*****************************************************************************
1779+ * Copyright (C) 2008 EnterpriseDB Corporation.
1780+ * Copyright (C) 2011 Stado Global Development Group.
1781+ *
1782+ * This file is part of Stado.
1783+ *
1784+ * Stado is free software: you can redistribute it and/or modify
1785+ * it under the terms of the GNU General Public License as published by
1786+ * the Free Software Foundation, either version 3 of the License, or
1787+ * (at your option) any later version.
1788+ *
1789+ * Stado is distributed in the hope that it will be useful,
1790+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1791+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1792+ * GNU General Public License for more details.
1793+ *
1794+ * You should have received a copy of the GNU General Public License
1795+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1796+ *
1797+ * You can find Stado at http://www.stado.us
1798+ *
1799+ ****************************************************************************/
1800+package org.postgresql.driver.copy;
1801+
1802+import java.io.IOException;
1803+import java.io.InputStream;
1804+import java.sql.SQLException;
1805+
1806+import org.postgresql.driver.PGConnection;
1807+import org.postgresql.driver.util.GT;
1808+import org.postgresql.driver.util.PSQLException;
1809+import org.postgresql.driver.util.PSQLState;
1810+
1811+/**
1812+ * InputStream for reading from a PostgreSQL COPY TO STDOUT operation
1813+ */
1814+public class PGCopyInputStream extends InputStream implements CopyOut {
1815+ private CopyOut op;
1816+ private byte[] buf;
1817+ private int at, len;
1818+
1819+ /**
1820+ * Uses given connection for specified COPY TO STDOUT operation
1821+ * @param connection database connection to use for copying (protocol version 3 required)
1822+ * @param sql COPY TO STDOUT statement
1823+ * @throws SQLException if initializing the operation fails
1824+ */
1825+ public PGCopyInputStream(PGConnection connection, String sql) throws SQLException {
1826+ this(connection.getCopyAPI().copyOut(sql));
1827+ }
1828+
1829+ /**
1830+ * Use given CopyOut operation for reading
1831+ * @param op COPY TO STDOUT operation
1832+ * @throws SQLException if initializing the operation fails
1833+ */
1834+ public PGCopyInputStream(CopyOut op) {
1835+ this.op = op;
1836+ }
1837+
1838+ private boolean gotBuf() throws IOException {
1839+ if(at >= len) {
1840+ try {
1841+ buf = op.readFromCopy();
1842+ } catch(SQLException sqle) {
1843+ throw new IOException(GT.tr("Copying from database failed: {0}", sqle));
1844+ }
1845+ if(buf == null) {
1846+ at = -1;
1847+ return false;
1848+ } else {
1849+ at = 0;
1850+ len = buf.length;
1851+ return true;
1852+ }
1853+ }
1854+ return buf != null;
1855+ }
1856+
1857+ private void checkClosed() throws IOException {
1858+ if (op == null) {
1859+ throw new IOException(GT.tr("This copy stream is closed."));
1860+ }
1861+ }
1862+
1863+
1864+ public int available() throws IOException {
1865+ checkClosed();
1866+ return ( buf != null ? len - at : 0 );
1867+ }
1868+
1869+ public int read() throws IOException {
1870+ checkClosed();
1871+ return gotBuf() ? buf[at++] : -1;
1872+ }
1873+
1874+ public int read(byte[] buf) throws IOException {
1875+ return read(buf, 0, buf.length);
1876+ }
1877+
1878+ public int read(byte[] buf, int off, int siz) throws IOException {
1879+ checkClosed();
1880+ int got = 0;
1881+ while( got < siz && gotBuf() ) {
1882+ buf[off+got++] = this.buf[at++];
1883+ }
1884+ return got;
1885+ }
1886+
1887+ public byte[] readFromCopy() throws SQLException {
1888+ byte[] result = buf;
1889+ try {
1890+ if(gotBuf()) {
1891+ if(at>0 || len < buf.length) {
1892+ byte[] ba = new byte[len-at];
1893+ for(int i=at; i<len; i++)
1894+ ba[i-at] = buf[i];
1895+ result = ba;
1896+ }
1897+ at = len; // either partly or fully returned, buffer is exhausted
1898+ }
1899+ } catch(IOException ioe) {
1900+ throw new PSQLException(GT.tr("Read from copy failed."), PSQLState.CONNECTION_FAILURE);
1901+ }
1902+ return result;
1903+ }
1904+
1905+ public void close() throws IOException {
1906+ // Don't complain about a double close.
1907+ if (op == null)
1908+ return;
1909+
1910+ try {
1911+ op.cancelCopy();
1912+ } catch(SQLException se) {
1913+ IOException ioe = new IOException("Failed to close copy reader.");
1914+ ioe.initCause(se);
1915+ throw ioe;
1916+ }
1917+ op = null;
1918+ }
1919+
1920+ public void cancelCopy() throws SQLException {
1921+ op.cancelCopy();
1922+ }
1923+
1924+ public int getFormat() {
1925+ return op.getFormat();
1926+ }
1927+
1928+ public int getFieldFormat(int field) {
1929+ return op.getFieldFormat(field);
1930+ }
1931+
1932+ public int getFieldCount() {
1933+ return op.getFieldCount();
1934+ }
1935+
1936+ public boolean isActive() {
1937+ return op.isActive();
1938+ }
1939+
1940+ public long getHandledRowCount() {
1941+ return op.getHandledRowCount();
1942+ }
1943+}
1944
1945=== added file 'src/org/postgresql/driver/copy/PGCopyOutputStream.java'
1946--- src/org/postgresql/driver/copy/PGCopyOutputStream.java 1970-01-01 00:00:00 +0000
1947+++ src/org/postgresql/driver/copy/PGCopyOutputStream.java 2011-08-30 20:30:24 +0000
1948@@ -0,0 +1,185 @@
1949+/*****************************************************************************
1950+ * Copyright (C) 2008 EnterpriseDB Corporation.
1951+ * Copyright (C) 2011 Stado Global Development Group.
1952+ *
1953+ * This file is part of Stado.
1954+ *
1955+ * Stado is free software: you can redistribute it and/or modify
1956+ * it under the terms of the GNU General Public License as published by
1957+ * the Free Software Foundation, either version 3 of the License, or
1958+ * (at your option) any later version.
1959+ *
1960+ * Stado is distributed in the hope that it will be useful,
1961+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1962+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1963+ * GNU General Public License for more details.
1964+ *
1965+ * You should have received a copy of the GNU General Public License
1966+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
1967+ *
1968+ * You can find Stado at http://www.stado.us
1969+ *
1970+ ****************************************************************************/
1971+package org.postgresql.driver.copy;
1972+
1973+import java.io.IOException;
1974+import java.io.OutputStream;
1975+import java.sql.SQLException;
1976+
1977+import org.postgresql.driver.PGConnection;
1978+import org.postgresql.driver.util.GT;
1979+
1980+/**
1981+ * OutputStream for buffered input into a PostgreSQL COPY FROM STDIN operation
1982+ */
1983+public class PGCopyOutputStream extends OutputStream implements CopyIn {
1984+ private CopyIn op;
1985+ private final byte[] copyBuffer;
1986+ private final byte[] singleByteBuffer = new byte[1];
1987+ private int at = 0;
1988+
1989+ /**
1990+ * Uses given connection for specified COPY FROM STDIN operation
1991+ * @param connection database connection to use for copying (protocol version 3 required)
1992+ * @param sql COPY FROM STDIN statement
1993+ * @throws SQLException if initializing the operation fails
1994+ */
1995+ public PGCopyOutputStream(PGConnection connection, String sql) throws SQLException {
1996+ this(connection, sql, CopyManager.DEFAULT_BUFFER_SIZE);
1997+ }
1998+
1999+ /**
2000+ * Uses given connection for specified COPY FROM STDIN operation
2001+ * @param connection database connection to use for copying (protocol version 3 required)
2002+ * @param sql COPY FROM STDIN statement
2003+ * @param bufferSize try to send this many bytes at a time
2004+ * @throws SQLException if initializing the operation fails
2005+ */
2006+ public PGCopyOutputStream(PGConnection connection, String sql, int bufferSize) throws SQLException {
2007+ this(connection.getCopyAPI().copyIn(sql), bufferSize);
2008+ }
2009+
2010+ /**
2011+ * Use given CopyIn operation for writing
2012+ * @param op COPY FROM STDIN operation
2013+ */
2014+ public PGCopyOutputStream(CopyIn op) {
2015+ this(op, CopyManager.DEFAULT_BUFFER_SIZE);
2016+ }
2017+
2018+ /**
2019+ * Use given CopyIn operation for writing
2020+ * @param op COPY FROM STDIN operation
2021+ * @param bufferSize try to send this many bytes at a time
2022+ */
2023+ public PGCopyOutputStream(CopyIn op, int bufferSize) {
2024+ this.op = op;
2025+ copyBuffer = new byte[bufferSize];
2026+ }
2027+
2028+ public void write(int b) throws IOException {
2029+ checkClosed();
2030+ if(b<0 || b>255)
2031+ throw new IOException(GT.tr("Cannot write to copy a byte of value {0}", new Integer(b)));
2032+ singleByteBuffer[0] = (byte)b;
2033+ write(singleByteBuffer, 0, 1);
2034+ }
2035+
2036+ public void write(byte[] buf) throws IOException {
2037+ write(buf, 0, buf.length);
2038+ }
2039+
2040+ public void write(byte[] buf, int off, int siz) throws IOException {
2041+ checkClosed();
2042+ try {
2043+ writeToCopy(buf, off, siz);
2044+ } catch(SQLException se) {
2045+ IOException ioe = new IOException("Write to copy failed.");
2046+ ioe.initCause(se);
2047+ throw ioe;
2048+ }
2049+ }
2050+
2051+ private void checkClosed() throws IOException {
2052+ if (op == null) {
2053+ throw new IOException(GT.tr("This copy stream is closed."));
2054+ }
2055+ }
2056+
2057+ public void close() throws IOException {
2058+ // Don't complain about a double close.
2059+ if (op == null)
2060+ return;
2061+
2062+ try{
2063+ endCopy();
2064+ } catch(SQLException se) {
2065+ IOException ioe = new IOException("Ending write to copy failed.");
2066+ ioe.initCause(se);
2067+ throw ioe;
2068+ }
2069+ op = null;
2070+ }
2071+
2072+ public void flush() throws IOException {
2073+ try {
2074+ op.writeToCopy(copyBuffer, 0, at);
2075+ at = 0;
2076+ op.flushCopy();
2077+ } catch (SQLException e) {
2078+ IOException ioe = new IOException("Unable to flush stream");
2079+ ioe.initCause(e);
2080+ throw ioe;
2081+ }
2082+ }
2083+
2084+ public void writeToCopy(byte[] buf, int off, int siz) throws SQLException {
2085+ if(at > 0 && siz > copyBuffer.length - at) { // would not fit into rest of our buf, so flush buf
2086+ op.writeToCopy(copyBuffer, 0, at);
2087+ at = 0;
2088+ }
2089+ if(siz > copyBuffer.length) { // would still not fit into buf, so just pass it through
2090+ op.writeToCopy(buf, off, siz);
2091+ } else { // fits into our buf, so save it there
2092+ System.arraycopy(buf, off, copyBuffer, at, siz);
2093+ at += siz;
2094+ }
2095+ }
2096+
2097+ public int getFormat() {
2098+ return op.getFormat();
2099+ }
2100+
2101+ public int getFieldFormat(int field) {
2102+ return op.getFieldFormat(field);
2103+ }
2104+
2105+ public void cancelCopy() throws SQLException {
2106+ op.cancelCopy();
2107+ }
2108+
2109+ public int getFieldCount() {
2110+ return op.getFieldCount();
2111+ }
2112+
2113+ public boolean isActive() {
2114+ return op.isActive();
2115+ }
2116+
2117+ public void flushCopy() throws SQLException {
2118+ op.flushCopy();
2119+ }
2120+
2121+ public long endCopy() throws SQLException {
2122+ if(at > 0) {
2123+ op.writeToCopy(copyBuffer, 0, at);
2124+ }
2125+ op.endCopy();
2126+ return getHandledRowCount();
2127+ }
2128+
2129+ public long getHandledRowCount() {
2130+ return op.getHandledRowCount();
2131+ }
2132+
2133+}
2134
2135=== added directory 'src/org/postgresql/driver/core'
2136=== added file 'src/org/postgresql/driver/core/BaseConnection.java'
2137--- src/org/postgresql/driver/core/BaseConnection.java 1970-01-01 00:00:00 +0000
2138+++ src/org/postgresql/driver/core/BaseConnection.java 2011-08-30 20:30:24 +0000
2139@@ -0,0 +1,163 @@
2140+/*****************************************************************************
2141+ * Copyright (C) 2008 EnterpriseDB Corporation.
2142+ * Copyright (C) 2011 Stado Global Development Group.
2143+ *
2144+ * This file is part of Stado.
2145+ *
2146+ * Stado is free software: you can redistribute it and/or modify
2147+ * it under the terms of the GNU General Public License as published by
2148+ * the Free Software Foundation, either version 3 of the License, or
2149+ * (at your option) any later version.
2150+ *
2151+ * Stado is distributed in the hope that it will be useful,
2152+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2153+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2154+ * GNU General Public License for more details.
2155+ *
2156+ * You should have received a copy of the GNU General Public License
2157+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
2158+ *
2159+ * You can find Stado at http://www.stado.us
2160+ *
2161+ ****************************************************************************/
2162+package org.postgresql.driver.core;
2163+
2164+import java.sql.*;
2165+
2166+import org.postgresql.driver.PGConnection;
2167+import org.postgresql.driver.jdbc2.TimestampUtils;
2168+
2169+/**
2170+ * Driver-internal connection interface. Application code should not use
2171+ * this interface.
2172+ */
2173+public interface BaseConnection extends PGConnection, Connection
2174+{
2175+ /**
2176+ * Cancel the current query executing on this connection.
2177+ *
2178+ * @throws SQLException if something goes wrong.
2179+ */
2180+ public void cancelQuery() throws SQLException;
2181+
2182+ /**
2183+ * Execute a SQL query that returns a single resultset.
2184+ * Never causes a new transaction to be started regardless of the autocommit setting.
2185+ *
2186+ * @param s the query to execute
2187+ * @return the (non-null) returned resultset
2188+ * @throws SQLException if something goes wrong.
2189+ */
2190+ public ResultSet execSQLQuery(String s) throws SQLException;
2191+
2192+ public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency) throws SQLException;
2193+
2194+ /**
2195+ * Execute a SQL query that does not return results.
2196+ * Never causes a new transaction to be started regardless of the autocommit setting.
2197+ *
2198+ * @param s the query to execute
2199+ * @throws SQLException if something goes wrong.
2200+ */
2201+ public void execSQLUpdate(String s) throws SQLException;
2202+
2203+ /**
2204+ * Get the QueryExecutor implementation for this connection.
2205+ *
2206+ * @return the (non-null) executor
2207+ */
2208+ public QueryExecutor getQueryExecutor();
2209+
2210+ /**
2211+ * Construct and return an appropriate object for the given
2212+ * type and value. This only considers the types registered via
2213+ * {@link org.postgresql.driver.PGConnection#addDataType(String,Class)} and
2214+ * {@link org.postgresql.driver.PGConnection#addDataType(String,String)}.
2215+ *<p>
2216+ * If no class is registered as handling the given type, then a generic
2217+ * {@link org.postgresql.driver.util.PGobject} instance is returned.
2218+ *
2219+ * @param type the backend typename
2220+ * @param value the type-specific string representation of the value
2221+ * @return an appropriate object; never null.
2222+ * @throws SQLException if something goes wrong
2223+ */
2224+ public Object getObject(String type, String value) throws SQLException;
2225+
2226+ public Encoding getEncoding() throws SQLException;
2227+
2228+ public TypeInfo getTypeInfo();
2229+
2230+ /**
2231+ * Check if we should use driver behaviour introduced in a particular
2232+ * driver version. This defaults to behaving as the actual driver's version
2233+ * but can be overridden by the "compatible" URL parameter.
2234+ *
2235+ * @param ver the driver version to check
2236+ * @return true if the driver's behavioural version is at least "ver".
2237+ * @throws SQLException if something goes wrong
2238+ */
2239+ public boolean haveMinimumCompatibleVersion(String ver);
2240+
2241+ /**
2242+ * Check if we have at least a particular server version.
2243+ *
2244+ * @param ver the server version to check
2245+ * @return true if the server version is at least "ver".
2246+ * @throws SQLException if something goes wrong
2247+ */
2248+ public boolean haveMinimumServerVersion(String ver);
2249+
2250+ /**
2251+ * Encode a string using the database's client_encoding
2252+ * (usually UNICODE, but can vary on older server versions).
2253+ * This is used when constructing synthetic resultsets (for
2254+ * example, in metadata methods).
2255+ *
2256+ * @param str the string to encode
2257+ * @return an encoded representation of the string
2258+ * @throws SQLException if something goes wrong.
2259+ */
2260+ public byte[] encodeString(String str) throws SQLException;
2261+
2262+ /**
2263+ * Escapes a string for use as string-literal within an SQL command. The
2264+ * method chooses the applicable escaping rules based on the value of
2265+ * {@link #getStandardConformingStrings()}.
2266+ *
2267+ * @param str a string value
2268+ * @return the escaped representation of the string
2269+ * @throws SQLException if the string contains a <tt>\0</tt> character
2270+ */
2271+ public String escapeString(String str) throws SQLException;
2272+
2273+ /**
2274+ * Returns whether the server treats string-literals according to the SQL
2275+ * standard or if it uses traditional PostgreSQL escaping rules. Versions
2276+ * up to 8.1 always treated backslashes as escape characters in
2277+ * string-literals. Since 8.2, this depends on the value of the
2278+ * <tt>standard_conforming_strings<tt> server variable.
2279+ *
2280+ * @return true if the server treats string literals according to the SQL
2281+ * standard
2282+ *
2283+ * @see ProtocolConnection#getStandardConformingStrings()
2284+ */
2285+ public boolean getStandardConformingStrings();
2286+
2287+ // Ew. Quick hack to give access to the connection-specific utils implementation.
2288+ public TimestampUtils getTimestampUtils();
2289+
2290+ // Get the per-connection logger.
2291+ public Logger getLogger();
2292+
2293+ // Get the bind-string-as-varchar config flag
2294+ public boolean getStringVarcharFlag();
2295+
2296+ /**
2297+ * Get the current transaction state of this connection.
2298+ *
2299+ * @return a ProtocolConnection.TRANSACTION_* constant.
2300+ */
2301+ public int getTransactionState();
2302+}
2303
2304=== added file 'src/org/postgresql/driver/core/BaseResultSet.java'
2305--- src/org/postgresql/driver/core/BaseResultSet.java 1970-01-01 00:00:00 +0000
2306+++ src/org/postgresql/driver/core/BaseResultSet.java 2011-08-30 20:30:24 +0000
2307@@ -0,0 +1,44 @@
2308+/*****************************************************************************
2309+ * Copyright (C) 2008 EnterpriseDB Corporation.
2310+ * Copyright (C) 2011 Stado Global Development Group.
2311+ *
2312+ * This file is part of Stado.
2313+ *
2314+ * Stado is free software: you can redistribute it and/or modify
2315+ * it under the terms of the GNU General Public License as published by
2316+ * the Free Software Foundation, either version 3 of the License, or
2317+ * (at your option) any later version.
2318+ *
2319+ * Stado is distributed in the hope that it will be useful,
2320+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2321+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2322+ * GNU General Public License for more details.
2323+ *
2324+ * You should have received a copy of the GNU General Public License
2325+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
2326+ *
2327+ * You can find Stado at http://www.stado.us
2328+ *
2329+ ****************************************************************************/
2330+package org.postgresql.driver.core;
2331+
2332+import java.sql.*;
2333+
2334+/**
2335+ * Driver-internal resultset interface. Application code should not use
2336+ * this interface.
2337+ */
2338+public interface BaseResultSet extends ResultSet
2339+{
2340+ /**
2341+ * Return a sanitized numeric string for a column. This handles
2342+ * "money" representations, stripping $ and () as appropriate.
2343+ *
2344+ * @param col the 1-based column to retrieve
2345+ * @return the sanitized string
2346+ * @throws SQLException if something goes wrong
2347+ */
2348+ public String getFixedString(int col) throws SQLException;
2349+
2350+ public Array createArray(int col) throws SQLException;
2351+}
2352
2353=== added file 'src/org/postgresql/driver/core/BaseStatement.java'
2354--- src/org/postgresql/driver/core/BaseStatement.java 1970-01-01 00:00:00 +0000
2355+++ src/org/postgresql/driver/core/BaseStatement.java 2011-08-30 20:30:24 +0000
2356@@ -0,0 +1,76 @@
2357+/*****************************************************************************
2358+ * Copyright (C) 2008 EnterpriseDB Corporation.
2359+ * Copyright (C) 2011 Stado Global Development Group.
2360+ *
2361+ * This file is part of Stado.
2362+ *
2363+ * Stado is free software: you can redistribute it and/or modify
2364+ * it under the terms of the GNU General Public License as published by
2365+ * the Free Software Foundation, either version 3 of the License, or
2366+ * (at your option) any later version.
2367+ *
2368+ * Stado is distributed in the hope that it will be useful,
2369+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2370+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2371+ * GNU General Public License for more details.
2372+ *
2373+ * You should have received a copy of the GNU General Public License
2374+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
2375+ *
2376+ * You can find Stado at http://www.stado.us
2377+ *
2378+ ****************************************************************************/
2379+package org.postgresql.driver.core;
2380+
2381+import org.postgresql.driver.PGStatement;
2382+
2383+import java.sql.*;
2384+import java.util.Vector;
2385+
2386+/**
2387+ * Driver-internal statement interface. Application code should not use
2388+ * this interface.
2389+ */
2390+public interface BaseStatement extends PGStatement, Statement
2391+{
2392+ /**
2393+ * Create a synthetic resultset from data provided by the driver.
2394+ *
2395+ * @param fields the column metadata for the resultset
2396+ * @param tuples the resultset data
2397+ * @return the new ResultSet
2398+ * @throws SQLException if something goes wrong
2399+ */
2400+ public ResultSet createDriverResultSet(Field[] fields, Vector tuples) throws SQLException;
2401+
2402+ /**
2403+ * Create a resultset from data retrieved from the server.
2404+ *
2405+ * @param originalQuery the query that generated this resultset; used when dealing with updateable resultsets
2406+ * @param fields the column metadata for the resultset
2407+ * @param tuples the resultset data
2408+ * @param cursor the cursor to use to retrieve more data from the server; if null, no additional data is present.
2409+ * @return the new ResultSet
2410+ * @throws SQLException if something goes wrong
2411+ */
2412+ public ResultSet createResultSet(Query originalQuery, Field[] fields, Vector tuples, ResultCursor cursor) throws SQLException;
2413+
2414+ /**
2415+ * Execute a query, passing additional query flags.
2416+ *
2417+ * @param p_sql the query to execute
2418+ * @param flags additional {@link QueryExecutor} flags for execution; these
2419+ * are bitwise-ORed into the default flags.
2420+ * @throws SQLException if something goes wrong.
2421+ */
2422+ public boolean executeWithFlags(String p_sql, int flags) throws SQLException;
2423+
2424+ /**
2425+ * Execute a prepared query, passing additional query flags.
2426+ *
2427+ * @param flags additional {@link QueryExecutor} flags for execution; these
2428+ * are bitwise-ORed into the default flags.
2429+ * @throws SQLException if something goes wrong.
2430+ */
2431+ public boolean executeWithFlags(int flags) throws SQLException;
2432+}
2433
2434=== added file 'src/org/postgresql/driver/core/ConnectionFactory.java'
2435--- src/org/postgresql/driver/core/ConnectionFactory.java 1970-01-01 00:00:00 +0000
2436+++ src/org/postgresql/driver/core/ConnectionFactory.java 2011-08-30 20:30:24 +0000
2437@@ -0,0 +1,104 @@
2438+/*****************************************************************************
2439+ * Copyright (C) 2008 EnterpriseDB Corporation.
2440+ * Copyright (C) 2011 Stado Global Development Group.
2441+ *
2442+ * This file is part of Stado.
2443+ *
2444+ * Stado is free software: you can redistribute it and/or modify
2445+ * it under the terms of the GNU General Public License as published by
2446+ * the Free Software Foundation, either version 3 of the License, or
2447+ * (at your option) any later version.
2448+ *
2449+ * Stado is distributed in the hope that it will be useful,
2450+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2451+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2452+ * GNU General Public License for more details.
2453+ *
2454+ * You should have received a copy of the GNU General Public License
2455+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
2456+ *
2457+ * You can find Stado at http://www.stado.us
2458+ *
2459+ ****************************************************************************/
2460+package org.postgresql.driver.core;
2461+
2462+import java.util.Properties;
2463+import java.sql.SQLException;
2464+
2465+import org.postgresql.driver.util.GT;
2466+import org.postgresql.driver.util.PSQLException;
2467+import org.postgresql.driver.util.PSQLState;
2468+
2469+/**
2470+ * Handles protocol-specific connection setup.
2471+ *
2472+ * @author Oliver Jowett (oliver@opencloud.com)
2473+ */
2474+public abstract class ConnectionFactory {
2475+ /**
2476+ * Protocol version to implementation instance map.
2477+ * If no protocol version is specified, instances are
2478+ * tried in order until an exception is thrown or a non-null
2479+ * connection is returned.
2480+ */
2481+ private static final Object[][] versions = {
2482+ { "3", new org.postgresql.driver.core.v3.ConnectionFactoryImpl() },
2483+ { "2", new org.postgresql.driver.core.v2.ConnectionFactoryImpl() },
2484+ };
2485+
2486+ /**
2487+ * Establishes and initializes a new connection.
2488+ *<p>
2489+ * If the "protocolVersion" property is specified, only that protocol
2490+ * version is tried. Otherwise, all protocols are tried in order, falling
2491+ * back to older protocols as necessary.
2492+ *<p>
2493+ * Currently, protocol versions 3 (7.4+) and 2 (pre-7.4) are supported.
2494+ *
2495+ * @param host the host to connect to
2496+ * @param port the port to connect to
2497+ * @param user the username to authenticate with; may not be null.
2498+ * @param database the database on the server to connect to; may not be null.
2499+ * @param info extra properties controlling the connection;
2500+ * notably, "password" if present supplies the password to authenticate with.
2501+ * @param logger the logger to use for this connection
2502+ * @return the new, initialized, connection
2503+ * @throws SQLException if the connection could not be established.
2504+ */
2505+ public static ProtocolConnection openConnection(String host, int port, String user, String database, Properties info, Logger logger) throws SQLException {
2506+ String protoName = info.getProperty("protocolVersion");
2507+
2508+ for (int i = 0; i < versions.length; ++i)
2509+ {
2510+ String versionProtoName = (String) versions[i][0];
2511+ if (protoName != null && !protoName.equals(versionProtoName))
2512+ continue;
2513+
2514+ ConnectionFactory factory = (ConnectionFactory) versions[i][1];
2515+ ProtocolConnection connection = factory.openConnectionImpl(host, port, user, database, info, logger);
2516+ if (connection != null)
2517+ return connection;
2518+ }
2519+
2520+ throw new PSQLException(GT.tr("A connection could not be made using the requested protocol {0}.", protoName),
2521+ PSQLState.CONNECTION_UNABLE_TO_CONNECT);
2522+ }
2523+
2524+ /**
2525+ * Implementation of {@link #openConnection} for a particular protocol version.
2526+ * Implemented by subclasses of {@link ConnectionFactory}.
2527+ *
2528+ * @param host the host to connect to
2529+ * @param port the port to connect to
2530+ * @param user the username to authenticate with; may not be null.
2531+ * @param database the database on the server to connect to; may not be null.
2532+ * @param info extra properties controlling the connection;
2533+ * notably, "password" if present supplies the password to authenticate with.
2534+ * @param logger the logger to use for this connection
2535+ * @return the new, initialized, connection, or <code>null</code> if this protocol
2536+ * version is not supported by the server.
2537+ * @throws SQLException if the connection could not be established for a reason other
2538+ * than protocol version incompatibility.
2539+ */
2540+ public abstract ProtocolConnection openConnectionImpl(String host, int port, String user, String database, Properties info, Logger logger) throws SQLException;
2541+}
2542
2543=== added file 'src/org/postgresql/driver/core/Encoding.java'
2544--- src/org/postgresql/driver/core/Encoding.java 1970-01-01 00:00:00 +0000
2545+++ src/org/postgresql/driver/core/Encoding.java 2011-08-30 20:30:24 +0000
2546@@ -0,0 +1,306 @@
2547+/*****************************************************************************
2548+ * Copyright (C) 2008 EnterpriseDB Corporation.
2549+ * Copyright (C) 2011 Stado Global Development Group.
2550+ *
2551+ * This file is part of Stado.
2552+ *
2553+ * Stado is free software: you can redistribute it and/or modify
2554+ * it under the terms of the GNU General Public License as published by
2555+ * the Free Software Foundation, either version 3 of the License, or
2556+ * (at your option) any later version.
2557+ *
2558+ * Stado is distributed in the hope that it will be useful,
2559+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2560+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2561+ * GNU General Public License for more details.
2562+ *
2563+ * You should have received a copy of the GNU General Public License
2564+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
2565+ *
2566+ * You can find Stado at http://www.stado.us
2567+ *
2568+ ****************************************************************************/
2569+package org.postgresql.driver.core;
2570+
2571+import java.io.InputStream;
2572+import java.io.InputStreamReader;
2573+import java.io.Reader;
2574+import java.io.OutputStream;
2575+import java.io.OutputStreamWriter;
2576+import java.io.Writer;
2577+import java.io.IOException;
2578+import java.util.HashMap;
2579+
2580+/**
2581+ * Representation of a particular character encoding.
2582+ */
2583+public class Encoding
2584+{
2585+ private static final Encoding DEFAULT_ENCODING = new Encoding(null);
2586+
2587+ /*
2588+ * Preferred JVM encodings for backend encodings.
2589+ */
2590+ private static final HashMap encodings = new HashMap();
2591+
2592+ static {
2593+ //Note: this list should match the set of supported server
2594+ // encodings found in backend/util/mb/encnames.c
2595+ encodings.put("SQL_ASCII", new String[] { "ASCII", "us-ascii" });
2596+ encodings.put("UNICODE", new String[] { "UTF-8", "UTF8" });
2597+ encodings.put("UTF8", new String[] { "UTF-8", "UTF8" }); // 8.1's canonical name for UNICODE changed.
2598+ encodings.put("LATIN1", new String[] { "ISO8859_1" });
2599+ encodings.put("LATIN2", new String[] { "ISO8859_2" });
2600+ encodings.put("LATIN3", new String[] { "ISO8859_3" });
2601+ encodings.put("LATIN4", new String[] { "ISO8859_4" });
2602+ encodings.put("ISO_8859_5", new String[] { "ISO8859_5" });
2603+ encodings.put("ISO_8859_6", new String[] { "ISO8859_6" });
2604+ encodings.put("ISO_8859_7", new String[] { "ISO8859_7" });
2605+ encodings.put("ISO_8859_8", new String[] { "ISO8859_8" });
2606+ encodings.put("LATIN5", new String[] { "ISO8859_9" });
2607+ encodings.put("LATIN7", new String[] { "ISO8859_13" });
2608+ encodings.put("LATIN9", new String[] { "ISO8859_15_FDIS" });
2609+ encodings.put("EUC_JP", new String[] { "EUC_JP" });
2610+ encodings.put("EUC_CN", new String[] { "EUC_CN" });
2611+ encodings.put("EUC_KR", new String[] { "EUC_KR" });
2612+ encodings.put("JOHAB", new String[] { "Johab" });
2613+ encodings.put("EUC_TW", new String[] { "EUC_TW" });
2614+ encodings.put("SJIS", new String[] { "MS932", "SJIS" });
2615+ encodings.put("BIG5", new String[] { "Big5", "MS950", "Cp950" });
2616+ encodings.put("GBK", new String[] { "GBK", "MS936" });
2617+ encodings.put("UHC", new String[] { "MS949", "Cp949", "Cp949C" });
2618+ encodings.put("TCVN", new String[] { "Cp1258" });
2619+ encodings.put("WIN1256", new String[] { "Cp1256" });
2620+ encodings.put("WIN1250", new String[] { "Cp1250" });
2621+ encodings.put("WIN874", new String[] { "MS874", "Cp874" });
2622+ encodings.put("WIN", new String[] { "Cp1251" });
2623+ encodings.put("ALT", new String[] { "Cp866" });
2624+ // We prefer KOI8-U, since it is a superset of KOI8-R.
2625+ encodings.put("KOI8", new String[] { "KOI8_U", "KOI8_R" });
2626+ // If the database isn't encoding-aware then we can't have
2627+ // any preferred encodings.
2628+ encodings.put("UNKNOWN", new String[0]);
2629+ // The following encodings do not have a java equivalent
2630+ encodings.put("MULE_INTERNAL", new String[0]);
2631+ encodings.put("LATIN6", new String[0]);
2632+ encodings.put("LATIN8", new String[0]);
2633+ encodings.put("LATIN10", new String[0]);
2634+ }
2635+
2636+ private final String encoding;
2637+ private final boolean fastASCIINumbers;
2638+
2639+ protected Encoding(String encoding)
2640+ {
2641+ this.encoding = encoding;
2642+ fastASCIINumbers = testAsciiNumbers();
2643+ }
2644+
2645+ /**
2646+ * Returns true if this encoding has characters
2647+ * '-' and '0'..'9' in exactly same posision as ascii.
2648+ *
2649+ * @return true if the bytes can be scanned directly for ascii numbers.
2650+ */
2651+ public boolean hasAsciiNumbers() {
2652+ return fastASCIINumbers;
2653+ }
2654+
2655+ /**
2656+ * Construct an Encoding for a given JVM encoding.
2657+ *
2658+ * @param jvmEncoding the name of the JVM encoding
2659+ * @return an Encoding instance for the specified encoding,
2660+ * or an Encoding instance for the default JVM encoding if the
2661+ * specified encoding is unavailable.
2662+ */
2663+ public static Encoding getJVMEncoding(String jvmEncoding) {
2664+ if (isAvailable(jvmEncoding))
2665+ {
2666+ if (jvmEncoding.equals("UTF-8") || jvmEncoding.equals("UTF8"))
2667+ return new UTF8Encoding(jvmEncoding);
2668+ else
2669+ return new Encoding(jvmEncoding);
2670+ }
2671+ else
2672+ return defaultEncoding();
2673+ }
2674+
2675+ /**
2676+ * Construct an Encoding for a given database encoding.
2677+ *
2678+ * @param databaseEncoding the name of the database encoding
2679+ * @return an Encoding instance for the specified encoding,
2680+ * or an Encoding instance for the default JVM encoding if the
2681+ * specified encoding is unavailable.
2682+ */
2683+ public static Encoding getDatabaseEncoding(String databaseEncoding)
2684+ {
2685+ // If the backend encoding is known and there is a suitable
2686+ // encoding in the JVM we use that. Otherwise we fall back
2687+ // to the default encoding of the JVM.
2688+
2689+ String[] candidates = (String[]) encodings.get(databaseEncoding);
2690+ if (candidates != null)
2691+ {
2692+ for (int i = 0; i < candidates.length; i++)
2693+ {
2694+ if (isAvailable(candidates[i]))
2695+ {
2696+ return new Encoding(candidates[i]);
2697+ }
2698+ }
2699+ }
2700+
2701+ // Try the encoding name directly -- maybe the charset has been
2702+ // provided by the user.
2703+ if (isAvailable(databaseEncoding))
2704+ return new Encoding(databaseEncoding);
2705+
2706+ // Fall back to default JVM encoding.
2707+ return defaultEncoding();
2708+ }
2709+
2710+ /**
2711+ * Get the name of the (JVM) encoding used.
2712+ *
2713+ * @return the JVM encoding name used by this instance.
2714+ */
2715+ public String name()
2716+ {
2717+ return encoding;
2718+ }
2719+
2720+ /**
2721+ * Encode a string to an array of bytes.
2722+ *
2723+ * @param s the string to encode
2724+ * @return a bytearray containing the encoded string
2725+ * @throws IOException if something goes wrong
2726+ */
2727+ public byte[] encode(String s) throws IOException
2728+ {
2729+ if (s == null)
2730+ return null;
2731+
2732+ if (encoding == null)
2733+ return s.getBytes();
2734+
2735+ return s.getBytes(encoding);
2736+ }
2737+
2738+ /**
2739+ * Decode an array of bytes into a string.
2740+ *
2741+ * @param encodedString a bytearray containing the encoded string the string to encod
2742+ * @param offset the offset in <code>encodedString</code> of the first byte of the encoded representation
2743+ * @param length the length, in bytes, of the encoded representation
2744+ * @return the decoded string
2745+ * @throws IOException if something goes wrong
2746+ */
2747+ public String decode(byte[] encodedString, int offset, int length) throws IOException
2748+ {
2749+ if (encoding == null)
2750+ return new String(encodedString, offset, length);
2751+
2752+ return new String(encodedString, offset, length, encoding);
2753+ }
2754+
2755+ /**
2756+ * Decode an array of bytes into a string.
2757+ *
2758+ * @param encodedString a bytearray containing the encoded string the string to encod
2759+ * @return the decoded string
2760+ * @throws IOException if something goes wrong
2761+ */
2762+ public String decode(byte[] encodedString) throws IOException
2763+ {
2764+ return decode(encodedString, 0, encodedString.length);
2765+ }
2766+
2767+ /**
2768+ * Get a Reader that decodes the given InputStream using this encoding.
2769+ *
2770+ * @param in the underlying stream to decode from
2771+ * @return a non-null Reader implementation.
2772+ * @throws IOException if something goes wrong
2773+ */
2774+ public Reader getDecodingReader(InputStream in) throws IOException
2775+ {
2776+ if (encoding == null)
2777+ return new InputStreamReader(in);
2778+
2779+ return new InputStreamReader(in, encoding);
2780+ }
2781+
2782+ /**
2783+ * Get a Writer that encodes to the given OutputStream using this encoding.
2784+ *
2785+ * @param out the underlying stream to encode to
2786+ * @return a non-null Writer implementation.
2787+ * @throws IOException if something goes wrong
2788+ */
2789+ public Writer getEncodingWriter(OutputStream out) throws IOException
2790+ {
2791+ if (encoding == null)
2792+ return new OutputStreamWriter(out);
2793+
2794+ return new OutputStreamWriter(out, encoding);
2795+ }
2796+
2797+ /**
2798+ * Get an Encoding using the default encoding for the JVM.
2799+ * @return an Encoding instance
2800+ */
2801+ public static Encoding defaultEncoding()
2802+ {
2803+ return DEFAULT_ENCODING;
2804+ }
2805+
2806+ /**
2807+ * Test if an encoding is available in the JVM.
2808+ *
2809+ * @param encodingName the JVM encoding name to test
2810+ * @return true iff the encoding is supported
2811+ */
2812+ private static boolean isAvailable(String encodingName)
2813+ {
2814+ try
2815+ {
2816+ "DUMMY".getBytes(encodingName);
2817+ return true;
2818+ }
2819+ catch (java.io.UnsupportedEncodingException e)
2820+ {
2821+ return false;
2822+ }
2823+ }
2824+
2825+ public String toString() {
2826+ return (encoding == null ? "<default JVM encoding>" : encoding);
2827+ }
2828+
2829+ /**
2830+ * Checks weather this encoding is compatible with ASCII for the number
2831+ * characters '-' and '0'..'9'. Where compatible means that they are encoded
2832+ * with exactly same values.
2833+ *
2834+ * @return If faster ASCII number parsing can be used with this encoding.
2835+ */
2836+ private boolean testAsciiNumbers() {
2837+ // TODO: test all postgres supported encoding to see if there are
2838+ // any which do _not_ have ascii numbers in same location
2839+ // at least all the encoding listed in the encodings hashmap have
2840+ // working ascii numbers
2841+ try {
2842+ String test = "-0123456789";
2843+ byte[] bytes = encode(test);
2844+ String res = new String(bytes, "US-ASCII");
2845+ return test.equals(res);
2846+ } catch (java.io.UnsupportedEncodingException e) {
2847+ return false;
2848+ } catch (IOException e) {
2849+ return false;
2850+ }
2851+ }
2852+}
2853
2854=== added file 'src/org/postgresql/driver/core/Field.java'
2855--- src/org/postgresql/driver/core/Field.java 1970-01-01 00:00:00 +0000
2856+++ src/org/postgresql/driver/core/Field.java 2011-08-30 20:30:24 +0000
2857@@ -0,0 +1,275 @@
2858+/*****************************************************************************
2859+ * Copyright (C) 2008 EnterpriseDB Corporation.
2860+ * Copyright (C) 2011 Stado Global Development Group.
2861+ *
2862+ * This file is part of Stado.
2863+ *
2864+ * Stado is free software: you can redistribute it and/or modify
2865+ * it under the terms of the GNU General Public License as published by
2866+ * the Free Software Foundation, either version 3 of the License, or
2867+ * (at your option) any later version.
2868+ *
2869+ * Stado is distributed in the hope that it will be useful,
2870+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2871+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2872+ * GNU General Public License for more details.
2873+ *
2874+ * You should have received a copy of the GNU General Public License
2875+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
2876+ *
2877+ * You can find Stado at http://www.stado.us
2878+ *
2879+ ****************************************************************************/
2880+package org.postgresql.driver.core;
2881+
2882+import java.sql.*;
2883+
2884+/*
2885+ */
2886+public class Field
2887+{
2888+ //The V3 protocol defines two constants for the format of data
2889+ public static final int TEXT_FORMAT = 0;
2890+ public static final int BINARY_FORMAT = 1;
2891+
2892+ private final int length; // Internal Length of this field
2893+ private final int oid; // OID of the type
2894+ private final int mod; // type modifier of this field
2895+ private final String columnLabel; // Column label
2896+ private String columnName; // Column name; null if undetermined
2897+ private Integer nullable; // Is this column nullable? null if undetermined.
2898+ private Boolean autoIncrement; // Is this column automatically numbered?
2899+
2900+ private int format = TEXT_FORMAT; // In the V3 protocol each field has a format
2901+ // 0 = text, 1 = binary
2902+ // In the V2 protocol all fields in a
2903+ // binary cursor are binary and all
2904+ // others are text
2905+
2906+ private final int tableOid; // OID of table ( zero if no table )
2907+ private final int positionInTable;
2908+
2909+ // cache-fields
2910+
2911+ /*
2912+ * Construct a field based on the information fed to it.
2913+ *
2914+ * @param name the name (column name and label) of the field
2915+ * @param oid the OID of the field
2916+ * @param len the length of the field
2917+ */
2918+ public Field(String name, int oid, int length, int mod)
2919+ {
2920+ this(name, name, oid, length, mod, 0, 0);
2921+ }
2922+
2923+ /*
2924+ * Constructor without mod parameter.
2925+ *
2926+ * @param name the name (column name and label) of the field
2927+ * @param oid the OID of the field
2928+ * @param len the length of the field
2929+ */
2930+ public Field(String name, int oid)
2931+ {
2932+ this(name, oid, 0, -1);
2933+ }
2934+
2935+ /*
2936+ * Construct a field based on the information fed to it.
2937+ *
2938+ * @param columnLabel the column label of the field
2939+ * @param columnName the column label the name of the field
2940+ * @param oid the OID of the field
2941+ * @param length the length of the field
2942+ * @param tableOid the OID of the columns' table
2943+ * @param positionInTable the position of column in the table (first column is 1, second column is 2, etc...)
2944+ */
2945+ public Field(String columnLabel, String columnName, int oid, int length, int mod, int tableOid, int positionInTable)
2946+ {
2947+ this.columnLabel = columnLabel;
2948+ this.columnName = columnName;
2949+ this.oid = oid;
2950+ this.length = length;
2951+ this.mod = mod;
2952+ this.tableOid = tableOid;
2953+ this.positionInTable = positionInTable;
2954+ }
2955+
2956+ /*
2957+ * @return the oid of this Field's data type
2958+ */
2959+ public int getOID()
2960+ {
2961+ return oid;
2962+ }
2963+
2964+ /*
2965+ * @return the mod of this Field's data type
2966+ */
2967+ public int getMod()
2968+ {
2969+ return mod;
2970+ }
2971+
2972+ /*
2973+ * @return the column label of this Field's data type
2974+ */
2975+ public String getColumnLabel()
2976+ {
2977+ return columnLabel;
2978+ }
2979+
2980+ /*
2981+ * @return the length of this Field's data type
2982+ */
2983+ public int getLength()
2984+ {
2985+ return length;
2986+ }
2987+
2988+ /*
2989+ * @return the format of this Field's data (text=0, binary=1)
2990+ */
2991+ public int getFormat()
2992+ {
2993+ return format;
2994+ }
2995+
2996+ /*
2997+ * @param format the format of this Field's data (text=0, binary=1)
2998+ */
2999+ public void setFormat(int format)
3000+ {
3001+ this.format = format;
3002+ }
3003+
3004+ /*
3005+ * @return the columns' table oid, zero if no oid available
3006+ */
3007+ public int getTableOid()
3008+ {
3009+ return tableOid;
3010+ }
3011+
3012+ public int getPositionInTable()
3013+ {
3014+ return positionInTable;
3015+ }
3016+
3017+ public int getNullable(Connection con) throws SQLException
3018+ {
3019+ if (nullable != null)
3020+ return nullable.intValue();
3021+
3022+ if (tableOid == 0 || positionInTable == 0)
3023+ {
3024+ nullable = new Integer(ResultSetMetaData.columnNullableUnknown);
3025+ return nullable.intValue();
3026+ }
3027+
3028+ ResultSet res = null;
3029+ PreparedStatement ps = null;
3030+ try
3031+ {
3032+ ps = con.prepareStatement("SELECT attnotnull FROM pg_catalog.pg_attribute WHERE attrelid = ? AND attnum = ?;");
3033+ ps.setInt(1, tableOid);
3034+ ps.setInt(2, positionInTable);
3035+ res = ps.executeQuery();
3036+
3037+ int nullResult = ResultSetMetaData.columnNullableUnknown;
3038+ if (res.next())
3039+ nullResult = res.getBoolean(1) ? ResultSetMetaData.columnNoNulls : ResultSetMetaData.columnNullable;
3040+
3041+ nullable = new Integer(nullResult);
3042+ return nullResult;
3043+ }
3044+ finally
3045+ {
3046+ if (res != null)
3047+ res.close();
3048+ if (ps != null)
3049+ ps.close();
3050+ }
3051+ }
3052+
3053+ public boolean getAutoIncrement(Connection con) throws SQLException
3054+ {
3055+ if (autoIncrement != null)
3056+ return autoIncrement.booleanValue();
3057+
3058+ if (tableOid == 0 || positionInTable == 0)
3059+ {
3060+ autoIncrement = Boolean.FALSE;
3061+ return autoIncrement.booleanValue();
3062+ }
3063+
3064+ ResultSet res = null;
3065+ PreparedStatement ps = null;
3066+ try
3067+ {
3068+ final String sql = "SELECT 1 "
3069+ + " FROM pg_catalog.pg_attrdef "
3070+ + " WHERE adrelid = ? AND adnum = ? "
3071+ + " AND pg_catalog.pg_get_expr(adbin, adrelid) "
3072+ + " LIKE '%nextval(%'";
3073+
3074+ ps = con.prepareStatement(sql);
3075+
3076+ ps.setInt(1, tableOid);
3077+ ps.setInt(2, positionInTable);
3078+ res = ps.executeQuery();
3079+
3080+ if (res.next())
3081+ {
3082+ autoIncrement = Boolean.TRUE;
3083+ }
3084+ else
3085+ {
3086+ autoIncrement = Boolean.FALSE;
3087+ }
3088+ return autoIncrement.booleanValue();
3089+
3090+ }
3091+ finally
3092+ {
3093+ if (res != null)
3094+ res.close();
3095+ if (ps != null)
3096+ ps.close();
3097+ }
3098+ }
3099+
3100+ public String getColumnName(Connection con) throws SQLException
3101+ {
3102+ if (columnName != null)
3103+ return columnName;
3104+
3105+ columnName = "";
3106+ if (tableOid == 0 || positionInTable == 0)
3107+ {
3108+ return columnName;
3109+ }
3110+
3111+ ResultSet res = null;
3112+ PreparedStatement ps = null;
3113+ try
3114+ {
3115+ ps = con.prepareStatement("SELECT attname FROM pg_catalog.pg_attribute WHERE attrelid = ? AND attnum = ?");
3116+ ps.setInt(1, tableOid);
3117+ ps.setInt(2, positionInTable);
3118+ res = ps.executeQuery();
3119+ if (res.next())
3120+ columnName = res.getString(1);
3121+
3122+ return columnName;
3123+ }
3124+ finally
3125+ {
3126+ if (res != null)
3127+ res.close();
3128+ if (ps != null)
3129+ ps.close();
3130+ }
3131+ }
3132+}
3133
3134=== added file 'src/org/postgresql/driver/core/Logger.java'
3135--- src/org/postgresql/driver/core/Logger.java 1970-01-01 00:00:00 +0000
3136+++ src/org/postgresql/driver/core/Logger.java 2011-08-30 20:30:24 +0000
3137@@ -0,0 +1,110 @@
3138+/*****************************************************************************
3139+ * Copyright (C) 2008 EnterpriseDB Corporation.
3140+ * Copyright (C) 2011 Stado Global Development Group.
3141+ *
3142+ * This file is part of Stado.
3143+ *
3144+ * Stado is free software: you can redistribute it and/or modify
3145+ * it under the terms of the GNU General Public License as published by
3146+ * the Free Software Foundation, either version 3 of the License, or
3147+ * (at your option) any later version.
3148+ *
3149+ * Stado is distributed in the hope that it will be useful,
3150+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3151+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3152+ * GNU General Public License for more details.
3153+ *
3154+ * You should have received a copy of the GNU General Public License
3155+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
3156+ *
3157+ * You can find Stado at http://www.stado.us
3158+ *
3159+ ****************************************************************************/
3160+package org.postgresql.driver.core;
3161+
3162+import java.text.SimpleDateFormat;
3163+import java.text.FieldPosition;
3164+import java.sql.DriverManager;
3165+import java.io.PrintWriter;
3166+import java.util.Date;
3167+
3168+import org.postgresql.driver.Driver;
3169+
3170+/**
3171+ * Poor man's logging infrastructure. This just deals with maintaining a per-
3172+ * connection ID and log level, and timestamping output.
3173+ */
3174+public final class Logger {
3175+ // For brevity we only log the time, not date or timezone (the main reason
3176+ // for the timestamp is to see delays etc. between log lines, not to pin
3177+ // down an instant in time)
3178+ private final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS ");
3179+ private final FieldPosition dummyPosition = new FieldPosition(0);
3180+ private final StringBuffer buffer = new StringBuffer();
3181+ private final String connectionIDString;
3182+
3183+ private int level = 0;
3184+
3185+ public Logger() {
3186+ connectionIDString = "(driver) ";
3187+ }
3188+
3189+ public Logger(int connectionID) {
3190+ connectionIDString = "(" + connectionID + ") ";
3191+ }
3192+
3193+ public void setLogLevel(int level) {
3194+ this.level = level;
3195+ }
3196+
3197+ public int getLogLevel() {
3198+ return level;
3199+ }
3200+
3201+ public boolean logDebug() {
3202+ return level >= Driver.DEBUG;
3203+ }
3204+
3205+ public boolean logInfo() {
3206+ return level >= Driver.INFO;
3207+ }
3208+
3209+ public void debug(String str) {
3210+ debug(str, null);
3211+ }
3212+
3213+ public void debug(String str, Throwable t) {
3214+ if (logDebug())
3215+ log(str, t);
3216+ }
3217+
3218+ public void info(String str) {
3219+ info(str, null);
3220+ }
3221+
3222+ public void info(String str, Throwable t) {
3223+ if (logInfo())
3224+ log(str, t);
3225+ }
3226+
3227+ public void log(String str, Throwable t) {
3228+ PrintWriter writer = DriverManager.getLogWriter();
3229+ if (writer == null)
3230+ return;
3231+
3232+ synchronized (this) {
3233+ buffer.setLength(0);
3234+ dateFormat.format(new Date(), buffer, dummyPosition);
3235+ buffer.append(connectionIDString);
3236+ buffer.append(str);
3237+
3238+ // synchronize to ensure that the exception (if any) does
3239+ // not get split up from the corresponding log message
3240+ synchronized (writer) {
3241+ writer.println(buffer.toString());
3242+ if (t != null)
3243+ t.printStackTrace(writer);
3244+ }
3245+ }
3246+ }
3247+}
3248
3249=== added file 'src/org/postgresql/driver/core/Notification.java'
3250--- src/org/postgresql/driver/core/Notification.java 1970-01-01 00:00:00 +0000
3251+++ src/org/postgresql/driver/core/Notification.java 2011-08-30 20:30:24 +0000
3252@@ -0,0 +1,67 @@
3253+/*****************************************************************************
3254+ * Copyright (C) 2008 EnterpriseDB Corporation.
3255+ * Copyright (C) 2011 Stado Global Development Group.
3256+ *
3257+ * This file is part of Stado.
3258+ *
3259+ * Stado is free software: you can redistribute it and/or modify
3260+ * it under the terms of the GNU General Public License as published by
3261+ * the Free Software Foundation, either version 3 of the License, or
3262+ * (at your option) any later version.
3263+ *
3264+ * Stado is distributed in the hope that it will be useful,
3265+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3266+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3267+ * GNU General Public License for more details.
3268+ *
3269+ * You should have received a copy of the GNU General Public License
3270+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
3271+ *
3272+ * You can find Stado at http://www.stado.us
3273+ *
3274+ ****************************************************************************/
3275+package org.postgresql.driver.core;
3276+
3277+import org.postgresql.driver.PGNotification;
3278+
3279+public class Notification implements PGNotification
3280+{
3281+ public Notification(String p_name, int p_pid)
3282+ {
3283+ this(p_name, p_pid, "");
3284+ }
3285+
3286+ public Notification(String p_name, int p_pid, String p_parameter)
3287+ {
3288+ m_name = p_name;
3289+ m_pid = p_pid;
3290+ m_parameter = p_parameter;
3291+ }
3292+
3293+ /*
3294+ * Returns name of this notification
3295+ */
3296+ public String getName()
3297+ {
3298+ return m_name;
3299+ }
3300+
3301+ /*
3302+ * Returns the process id of the backend process making this notification
3303+ */
3304+ public int getPID()
3305+ {
3306+ return m_pid;
3307+ }
3308+
3309+ public String getParameter()
3310+ {
3311+ return m_parameter;
3312+ }
3313+
3314+ private String m_name;
3315+ private String m_parameter;
3316+ private int m_pid;
3317+
3318+}
3319+
3320
3321=== added file 'src/org/postgresql/driver/core/Oid.java'
3322--- src/org/postgresql/driver/core/Oid.java 1970-01-01 00:00:00 +0000
3323+++ src/org/postgresql/driver/core/Oid.java 2011-08-30 20:30:24 +0000
3324@@ -0,0 +1,83 @@
3325+/*****************************************************************************
3326+ * Copyright (C) 2008 EnterpriseDB Corporation.
3327+ * Copyright (C) 2011 Stado Global Development Group.
3328+ *
3329+ * This file is part of Stado.
3330+ *
3331+ * Stado is free software: you can redistribute it and/or modify
3332+ * it under the terms of the GNU General Public License as published by
3333+ * the Free Software Foundation, either version 3 of the License, or
3334+ * (at your option) any later version.
3335+ *
3336+ * Stado is distributed in the hope that it will be useful,
3337+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3338+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3339+ * GNU General Public License for more details.
3340+ *
3341+ * You should have received a copy of the GNU General Public License
3342+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
3343+ *
3344+ * You can find Stado at http://www.stado.us
3345+ *
3346+ ****************************************************************************/
3347+package org.postgresql.driver.core;
3348+
3349+/**
3350+ * Provides constants for well-known backend OIDs for the types we commonly
3351+ * use.
3352+ */
3353+public class Oid {
3354+ public static final int UNSPECIFIED = 0;
3355+ public static final int INT2 = 21;
3356+ public static final int INT2_ARRAY = 1005;
3357+ public static final int INT4 = 23;
3358+ public static final int INT4_ARRAY = 1007;
3359+ public static final int INT8 = 20;
3360+ public static final int INT8_ARRAY = 1016;
3361+ public static final int TEXT = 25;
3362+ public static final int TEXT_ARRAY = 1009;
3363+ public static final int NUMERIC = 1700;
3364+ public static final int NUMERIC_ARRAY = 1231;
3365+ public static final int FLOAT4 = 700;
3366+ public static final int FLOAT4_ARRAY = 1021;
3367+ public static final int FLOAT8 = 701;
3368+ public static final int FLOAT8_ARRAY = 1022;
3369+ public static final int BOOL = 16;
3370+ public static final int BOOL_ARRAY = 1000;
3371+ public static final int DATE = 1082;
3372+ public static final int DATE_ARRAY = 1182;
3373+ public static final int TIME = 1083;
3374+ public static final int TIME_ARRAY = 1183;
3375+ public static final int TIMETZ = 1266;
3376+ public static final int TIMETZ_ARRAY = 1270;
3377+ public static final int TIMESTAMP = 1114;
3378+ public static final int TIMESTAMP_ARRAY = 1115;
3379+ public static final int TIMESTAMPTZ = 1184;
3380+ public static final int TIMESTAMPTZ_ARRAY = 1185;
3381+ public static final int BYTEA = 17;
3382+ public static final int BYTEA_ARRAY = 1001;
3383+ public static final int VARCHAR = 1043;
3384+ public static final int VARCHAR_ARRAY = 1015;
3385+ public static final int OID = 26;
3386+ public static final int OID_ARRAY = 1028;
3387+ public static final int BPCHAR = 1042;
3388+ public static final int BPCHAR_ARRAY = 1014;
3389+ public static final int MONEY = 790;
3390+ public static final int MONEY_ARRAY = 791;
3391+ public static final int NAME = 19;
3392+ public static final int NAME_ARRAY = 1003;
3393+ public static final int BIT = 1560;
3394+ public static final int BIT_ARRAY = 1561;
3395+ public static final int VOID = 2278;
3396+ public static final int INTERVAL = 1186;
3397+ public static final int INTERVAL_ARRAY = 1187;
3398+ public static final int CHAR = 18; // This is not char(N), this is "char" a single byte type.
3399+ public static final int CHAR_ARRAY = 1002;
3400+ public static final int VARBIT = 1562;
3401+ public static final int VARBIT_ARRAY = 1563;
3402+ public static final int UUID = 2950;
3403+ public static final int UUID_ARRAY = 2951;
3404+ public static final int XML = 142;
3405+ public static final int XML_ARRAY = 143;
3406+
3407+}
3408
3409=== added file 'src/org/postgresql/driver/core/PGBindException.java'
3410--- src/org/postgresql/driver/core/PGBindException.java 1970-01-01 00:00:00 +0000
3411+++ src/org/postgresql/driver/core/PGBindException.java 2011-08-30 20:30:24 +0000
3412@@ -0,0 +1,38 @@
3413+/*****************************************************************************
3414+ * Copyright (C) 2008 EnterpriseDB Corporation.
3415+ * Copyright (C) 2011 Stado Global Development Group.
3416+ *
3417+ * This file is part of Stado.
3418+ *
3419+ * Stado is free software: you can redistribute it and/or modify
3420+ * it under the terms of the GNU General Public License as published by
3421+ * the Free Software Foundation, either version 3 of the License, or
3422+ * (at your option) any later version.
3423+ *
3424+ * Stado is distributed in the hope that it will be useful,
3425+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3426+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3427+ * GNU General Public License for more details.
3428+ *
3429+ * You should have received a copy of the GNU General Public License
3430+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
3431+ *
3432+ * You can find Stado at http://www.stado.us
3433+ *
3434+ ****************************************************************************/
3435+package org.postgresql.driver.core;
3436+
3437+import java.io.IOException;
3438+
3439+public class PGBindException extends IOException {
3440+
3441+ private IOException _ioe;
3442+
3443+ public PGBindException(IOException ioe) {
3444+ _ioe = ioe;
3445+ }
3446+
3447+ public IOException getIOException() {
3448+ return _ioe;
3449+ }
3450+}
3451
3452=== added file 'src/org/postgresql/driver/core/PGStream.java'
3453--- src/org/postgresql/driver/core/PGStream.java 1970-01-01 00:00:00 +0000
3454+++ src/org/postgresql/driver/core/PGStream.java 2011-08-30 20:30:24 +0000
3455@@ -0,0 +1,565 @@
3456+/*****************************************************************************
3457+ * Copyright (C) 2008 EnterpriseDB Corporation.
3458+ * Copyright (C) 2011 Stado Global Development Group.
3459+ *
3460+ * This file is part of Stado.
3461+ *
3462+ * Stado is free software: you can redistribute it and/or modify
3463+ * it under the terms of the GNU General Public License as published by
3464+ * the Free Software Foundation, either version 3 of the License, or
3465+ * (at your option) any later version.
3466+ *
3467+ * Stado is distributed in the hope that it will be useful,
3468+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3469+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3470+ * GNU General Public License for more details.
3471+ *
3472+ * You should have received a copy of the GNU General Public License
3473+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
3474+ *
3475+ * You can find Stado at http://www.stado.us
3476+ *
3477+ ****************************************************************************/
3478+package org.postgresql.driver.core;
3479+
3480+import java.io.BufferedOutputStream;
3481+import java.io.InputStream;
3482+import java.io.OutputStream;
3483+import java.io.FilterOutputStream;
3484+import java.io.IOException;
3485+import java.io.EOFException;
3486+import java.io.Writer;
3487+import java.net.Socket;
3488+import java.sql.*;
3489+
3490+import org.postgresql.driver.util.GT;
3491+import org.postgresql.driver.util.PSQLException;
3492+import org.postgresql.driver.util.PSQLState;
3493+
3494+/**
3495+ * Wrapper around the raw connection to the server that implements some basic
3496+ * primitives (reading/writing formatted data, doing string encoding, etc).
3497+ *<p>
3498+ * In general, instances of PGStream are not threadsafe; the caller must ensure
3499+ * that only one thread at a time is accessing a particular PGStream instance.
3500+ */
3501+public class PGStream
3502+{
3503+ private final String host;
3504+ private final int port;
3505+
3506+ private final byte[] _int4buf;
3507+ private final byte[] _int2buf;
3508+
3509+ private Socket connection;
3510+ private VisibleBufferedInputStream pg_input;
3511+ private OutputStream pg_output;
3512+ private byte[] streamBuffer;
3513+
3514+ private Encoding encoding;
3515+ private Writer encodingWriter;
3516+
3517+ /**
3518+ * Constructor: Connect to the PostgreSQL back end and return
3519+ * a stream connection.
3520+ *
3521+ * @param host the hostname to connect to
3522+ * @param port the port number that the postmaster is sitting on
3523+ * @exception IOException if an IOException occurs below it.
3524+ */
3525+ public PGStream(String host, int port) throws IOException
3526+ {
3527+ this.host = host;
3528+ this.port = port;
3529+
3530+ changeSocket(new Socket(host, port));
3531+ setEncoding(Encoding.getJVMEncoding("US-ASCII"));
3532+
3533+ _int2buf = new byte[2];
3534+ _int4buf = new byte[4];
3535+ }
3536+
3537+ public String getHost() {
3538+ return host;
3539+ }
3540+
3541+ public int getPort() {
3542+ return port;
3543+ }
3544+
3545+ public Socket getSocket() {
3546+ return connection;
3547+ }
3548+
3549+ /**
3550+ * Check for pending backend messages without blocking.
3551+ * Might return false when there actually are messages
3552+ * waiting, depending on the characteristics of the
3553+ * underlying socket. This is used to detect asynchronous
3554+ * notifies from the backend, when available.
3555+ *
3556+ * @return true if there is a pending backend message
3557+ */
3558+ public boolean hasMessagePending() throws IOException {
3559+ return pg_input.available() > 0 || connection.getInputStream().available() > 0;
3560+ }
3561+
3562+ /**
3563+ * Switch this stream to using a new socket. Any existing socket
3564+ * is <em>not</em> closed; it's assumed that we are changing to
3565+ * a new socket that delegates to the original socket (e.g. SSL).
3566+ *
3567+ * @param socket the new socket to change to
3568+ * @throws IOException if something goes wrong
3569+ */
3570+ public void changeSocket(Socket socket) throws IOException {
3571+ this.connection = socket;
3572+
3573+ // Submitted by Jason Venner <jason@idiom.com>. Disable Nagle
3574+ // as we are selective about flushing output only when we
3575+ // really need to.
3576+ connection.setTcpNoDelay(true);
3577+
3578+ // Buffer sizes submitted by Sverre H Huseby <sverrehu@online.no>
3579+ pg_input = new VisibleBufferedInputStream(connection.getInputStream(), 8192);
3580+ pg_output = new BufferedOutputStream(connection.getOutputStream(), 8192);
3581+
3582+ if (encoding != null)
3583+ setEncoding(encoding);
3584+ }
3585+
3586+ public Encoding getEncoding() {
3587+ return encoding;
3588+ }
3589+
3590+ /**
3591+ * Change the encoding used by this connection.
3592+ *
3593+ * @param encoding the new encoding to use
3594+ * @throws IOException if something goes wrong
3595+ */
3596+ public void setEncoding(Encoding encoding) throws IOException {
3597+ // Close down any old writer.
3598+ if (encodingWriter != null)
3599+ encodingWriter.close();
3600+
3601+ this.encoding = encoding;
3602+
3603+ // Intercept flush() downcalls from the writer; our caller
3604+ // will call PGStream.flush() as needed.
3605+ OutputStream interceptor = new FilterOutputStream(pg_output) {
3606+ public void flush() throws IOException {
3607+ }
3608+ public void close() throws IOException {
3609+ super.flush();
3610+ }
3611+ };
3612+
3613+ encodingWriter = encoding.getEncodingWriter(interceptor);
3614+ }
3615+
3616+ /**
3617+ * Get a Writer instance that encodes directly onto the underlying stream.
3618+ *<p>
3619+ * The returned Writer should not be closed, as it's a shared object.
3620+ * Writer.flush needs to be called when switching between use of the Writer and
3621+ * use of the PGStream write methods, but it won't actually flush output
3622+ * all the way out -- call {@link #flush} to actually ensure all output
3623+ * has been pushed to the server.
3624+ *
3625+ * @return the shared Writer instance
3626+ * @throws IOException if something goes wrong.
3627+ */
3628+ public Writer getEncodingWriter() throws IOException {
3629+ if (encodingWriter == null)
3630+ throw new IOException("No encoding has been set on this connection");
3631+ return encodingWriter;
3632+ }
3633+
3634+ /**
3635+ * Sends a single character to the back end
3636+ *
3637+ * @param val the character to be sent
3638+ * @exception IOException if an I/O error occurs
3639+ */
3640+ public void SendChar(int val) throws IOException
3641+ {
3642+ pg_output.write(val);
3643+ }
3644+
3645+ /**
3646+ * Sends a 4-byte integer to the back end
3647+ *
3648+ * @param val the integer to be sent
3649+ * @exception IOException if an I/O error occurs
3650+ */
3651+ public void SendInteger4(int val) throws IOException
3652+ {
3653+ _int4buf[0] = (byte)(val >>> 24);
3654+ _int4buf[1] = (byte)(val >>> 16);
3655+ _int4buf[2] = (byte)(val >>> 8);
3656+ _int4buf[3] = (byte)(val);
3657+ pg_output.write(_int4buf);
3658+ }
3659+
3660+ /**
3661+ * Sends a 2-byte integer (short) to the back end
3662+ *
3663+ * @param val the integer to be sent
3664+ * @exception IOException if an I/O error occurs or <code>val</code> cannot be encoded in 2 bytes
3665+ */
3666+ public void SendInteger2(int val) throws IOException
3667+ {
3668+ if (val < Short.MIN_VALUE || val > Short.MAX_VALUE)
3669+ throw new IOException("Tried to send an out-of-range integer as a 2-byte value: " + val);
3670+
3671+ _int2buf[0] = (byte)(val >>> 8);
3672+ _int2buf[1] = (byte)val;
3673+ pg_output.write(_int2buf);
3674+ }
3675+
3676+ /**
3677+ * Send an array of bytes to the backend
3678+ *
3679+ * @param buf The array of bytes to be sent
3680+ * @exception IOException if an I/O error occurs
3681+ */
3682+ public void Send(byte buf[]) throws IOException
3683+ {
3684+ pg_output.write(buf);
3685+ }
3686+
3687+ /**
3688+ * Send a fixed-size array of bytes to the backend. If buf.length < siz,
3689+ * pad with zeros. If buf.lengh > siz, truncate the array.
3690+ *
3691+ * @param buf the array of bytes to be sent
3692+ * @param siz the number of bytes to be sent
3693+ * @exception IOException if an I/O error occurs
3694+ */
3695+ public void Send(byte buf[], int siz) throws IOException
3696+ {
3697+ Send(buf, 0, siz);
3698+ }
3699+
3700+ /**
3701+ * Send a fixed-size array of bytes to the backend. If length < siz,
3702+ * pad with zeros. If length > siz, truncate the array.
3703+ *
3704+ * @param buf the array of bytes to be sent
3705+ * @param off offset in the array to start sending from
3706+ * @param siz the number of bytes to be sent
3707+ * @exception IOException if an I/O error occurs
3708+ */
3709+ public void Send(byte buf[], int off, int siz) throws IOException
3710+ {
3711+ int bufamt = buf.length - off;
3712+ pg_output.write(buf, off, bufamt < siz ? bufamt : siz);
3713+ for (int i = bufamt ; i < siz ; ++i)
3714+ {
3715+ pg_output.write(0);
3716+ }
3717+ }
3718+
3719+ /**
3720+ * Receives a single character from the backend, without
3721+ * advancing the current protocol stream position.
3722+ *
3723+ * @return the character received
3724+ * @exception IOException if an I/O Error occurs
3725+ */
3726+ public int PeekChar() throws IOException
3727+ {
3728+ int c = pg_input.peek();
3729+ if (c < 0)
3730+ throw new EOFException();
3731+ return c;
3732+ }
3733+
3734+ /**
3735+ * Receives a single character from the backend
3736+ *
3737+ * @return the character received
3738+ * @exception IOException if an I/O Error occurs
3739+ */
3740+ public int ReceiveChar() throws IOException
3741+ {
3742+ int c = pg_input.read();
3743+ if (c < 0)
3744+ throw new EOFException();
3745+ return c;
3746+ }
3747+
3748+ /**
3749+ * Receives a four byte integer from the backend
3750+ *
3751+ * @return the integer received from the backend
3752+ * @exception IOException if an I/O error occurs
3753+ */
3754+ public int ReceiveInteger4() throws IOException
3755+ {
3756+ if (pg_input.read(_int4buf) != 4)
3757+ throw new EOFException();
3758+
3759+ return (_int4buf[0] & 0xFF) << 24 | (_int4buf[1] & 0xFF) << 16 | (_int4buf[2] & 0xFF) << 8 | _int4buf[3] & 0xFF;
3760+ }
3761+
3762+ /**
3763+ * Receives a two byte integer from the backend
3764+ *
3765+ * @return the integer received from the backend
3766+ * @exception IOException if an I/O error occurs
3767+ */
3768+ public int ReceiveInteger2() throws IOException
3769+ {
3770+ if (pg_input.read(_int2buf) != 2)
3771+ throw new EOFException();
3772+
3773+ return (_int2buf[0] & 0xFF) << 8 | _int2buf[1] & 0xFF;
3774+ }
3775+
3776+ /**
3777+ * Receives a fixed-size string from the backend.
3778+ *
3779+ * @param len the length of the string to receive, in bytes.
3780+ * @return the decoded string
3781+ */
3782+ public String ReceiveString(int len) throws IOException {
3783+ if (!pg_input.ensureBytes(len)) {
3784+ throw new EOFException();
3785+ }
3786+
3787+ String res = encoding.decode(pg_input.getBuffer(), pg_input.getIndex(),
3788+ len);
3789+ pg_input.skip(len);
3790+ return res;
3791+ }
3792+
3793+ /**
3794+ * Receives a null-terminated string from the backend. If we don't see a
3795+ * null, then we assume something has gone wrong.
3796+ *
3797+ * @return string from back end
3798+ * @exception IOException if an I/O error occurs, or end of file
3799+ */
3800+ public String ReceiveString() throws IOException
3801+ {
3802+ int len = pg_input.scanCStringLength();
3803+ String res = encoding.decode(pg_input.getBuffer(), pg_input.getIndex(),
3804+ len - 1);
3805+ pg_input.skip(len);
3806+ return res;
3807+ }
3808+
3809+ /**
3810+ * Read a tuple from the back end. A tuple is a two dimensional
3811+ * array of bytes. This variant reads the V3 protocol's tuple
3812+ * representation.
3813+ *
3814+ * @return null if the current response has no more tuples, otherwise
3815+ * an array of bytearrays
3816+ * @exception IOException if a data I/O error occurs
3817+ */
3818+ public byte[][] ReceiveTupleV3() throws IOException, OutOfMemoryError
3819+ {
3820+ //TODO: use l_msgSize
3821+ int l_msgSize = ReceiveInteger4();
3822+ int i;
3823+ int l_nf = ReceiveInteger2();
3824+ byte[][] answer = new byte[l_nf][];
3825+
3826+ OutOfMemoryError oom = null;
3827+ for (i = 0 ; i < l_nf ; ++i)
3828+ {
3829+ int l_size = ReceiveInteger4();
3830+ if (l_size != -1) {
3831+ try {
3832+ answer[i] = new byte[l_size];
3833+ Receive(answer[i], 0, l_size);
3834+ } catch(OutOfMemoryError oome) {
3835+ oom = oome;
3836+ Skip(l_size);
3837+ }
3838+ }
3839+ }
3840+
3841+ if (oom != null)
3842+ throw oom;
3843+
3844+ return answer;
3845+ }
3846+
3847+ /**
3848+ * Read a tuple from the back end. A tuple is a two dimensional
3849+ * array of bytes. This variant reads the V2 protocol's tuple
3850+ * representation.
3851+ *
3852+ * @param nf the number of fields expected
3853+ * @param bin true if the tuple is a binary tuple
3854+ * @return null if the current response has no more tuples, otherwise
3855+ * an array of bytearrays
3856+ * @exception IOException if a data I/O error occurs
3857+ */
3858+ public byte[][] ReceiveTupleV2(int nf, boolean bin) throws IOException, OutOfMemoryError
3859+ {
3860+ int i, bim = (nf + 7) / 8;
3861+ byte[] bitmask = Receive(bim);
3862+ byte[][] answer = new byte[nf][];
3863+
3864+ int whichbit = 0x80;
3865+ int whichbyte = 0;
3866+
3867+ OutOfMemoryError oom = null;
3868+ for (i = 0 ; i < nf ; ++i)
3869+ {
3870+ boolean isNull = ((bitmask[whichbyte] & whichbit) == 0);
3871+ whichbit >>= 1;
3872+ if (whichbit == 0)
3873+ {
3874+ ++whichbyte;
3875+ whichbit = 0x80;
3876+ }
3877+ if (!isNull)
3878+ {
3879+ int len = ReceiveInteger4();
3880+ if (!bin)
3881+ len -= 4;
3882+ if (len < 0)
3883+ len = 0;
3884+ try {
3885+ answer[i] = new byte[len];
3886+ Receive(answer[i], 0, len);
3887+ } catch(OutOfMemoryError oome) {
3888+ oom = oome;
3889+ Skip(len);
3890+ }
3891+ }
3892+ }
3893+
3894+ if (oom != null)
3895+ throw oom;
3896+
3897+ return answer;
3898+ }
3899+
3900+ /**
3901+ * Reads in a given number of bytes from the backend
3902+ *
3903+ * @param siz number of bytes to read
3904+ * @return array of bytes received
3905+ * @exception IOException if a data I/O error occurs
3906+ */
3907+ public byte[] Receive(int siz) throws IOException
3908+ {
3909+ byte[] answer = new byte[siz];
3910+ Receive(answer, 0, siz);
3911+ return answer;
3912+ }
3913+
3914+ /**
3915+ * Reads in a given number of bytes from the backend
3916+ *
3917+ * @param buf buffer to store result
3918+ * @param off offset in buffer
3919+ * @param siz number of bytes to read
3920+ * @exception IOException if a data I/O error occurs
3921+ */
3922+ public void Receive(byte[] buf, int off, int siz) throws IOException
3923+ {
3924+ int s = 0;
3925+
3926+ while (s < siz)
3927+ {
3928+ int w = pg_input.read(buf, off + s, siz - s);
3929+ if (w < 0)
3930+ throw new EOFException();
3931+ s += w;
3932+ }
3933+ }
3934+
3935+ public void Skip(int size) throws IOException {
3936+ long s = 0;
3937+ while (s < size) {
3938+ s += pg_input.skip(size - s);
3939+ }
3940+ }
3941+
3942+
3943+ /**
3944+ * Copy data from an input stream to the connection.
3945+ *
3946+ * @param inStream the stream to read data from
3947+ * @param remaining the number of bytes to copy
3948+ */
3949+ public void SendStream(InputStream inStream, int remaining) throws IOException {
3950+ int expectedLength = remaining;
3951+ if (streamBuffer == null)
3952+ streamBuffer = new byte[8192];
3953+
3954+ while (remaining > 0)
3955+ {
3956+ int count = (remaining > streamBuffer.length ? streamBuffer.length : remaining);
3957+ int readCount;
3958+
3959+ try
3960+ {
3961+ readCount = inStream.read(streamBuffer, 0, count);
3962+ if (readCount < 0)
3963+ throw new EOFException(GT.tr("Premature end of input stream, expected {0} bytes, but only read {1}.", new Object[]{new Integer(expectedLength), new Integer(expectedLength - remaining)}));
3964+ }
3965+ catch (IOException ioe)
3966+ {
3967+ while (remaining > 0)
3968+ {
3969+ Send(streamBuffer, count);
3970+ remaining -= count;
3971+ count = (remaining > streamBuffer.length ? streamBuffer.length : remaining);
3972+ }
3973+ throw new PGBindException(ioe);
3974+ }
3975+
3976+ Send(streamBuffer, readCount);
3977+ remaining -= readCount;
3978+ }
3979+ }
3980+
3981+
3982+
3983+ /**
3984+ * Flush any pending output to the backend.
3985+ * @exception IOException if an I/O error occurs
3986+ */
3987+ public void flush() throws IOException
3988+ {
3989+ if (encodingWriter != null)
3990+ encodingWriter.flush();
3991+ pg_output.flush();
3992+ }
3993+
3994+ /**
3995+ * Consume an expected EOF from the backend
3996+ * @exception SQLException if we get something other than an EOF
3997+ */
3998+ public void ReceiveEOF() throws SQLException, IOException
3999+ {
4000+ int c = pg_input.read();
4001+ if (c < 0)
4002+ return;
4003+ throw new PSQLException(GT.tr("Expected an EOF from server, got: {0}", new Integer(c)), PSQLState.COMMUNICATION_ERROR);
4004+ }
4005+
4006+ /**
4007+ * Closes the connection
4008+ *
4009+ * @exception IOException if an I/O Error occurs
4010+ */
4011+ public void close() throws IOException
4012+ {
4013+ if (encodingWriter != null)
4014+ encodingWriter.close();
4015+
4016+ pg_output.close();
4017+ pg_input.close();
4018+ connection.close();
4019+ }
4020+}
4021
4022=== added file 'src/org/postgresql/driver/core/ParameterList.java'
4023--- src/org/postgresql/driver/core/ParameterList.java 1970-01-01 00:00:00 +0000
4024+++ src/org/postgresql/driver/core/ParameterList.java 2011-08-30 20:30:24 +0000
4025@@ -0,0 +1,171 @@
4026+/*****************************************************************************
4027+ * Copyright (C) 2008 EnterpriseDB Corporation.
4028+ * Copyright (C) 2011 Stado Global Development Group.
4029+ *
4030+ * This file is part of Stado.
4031+ *
4032+ * Stado is free software: you can redistribute it and/or modify
4033+ * it under the terms of the GNU General Public License as published by
4034+ * the Free Software Foundation, either version 3 of the License, or
4035+ * (at your option) any later version.
4036+ *
4037+ * Stado is distributed in the hope that it will be useful,
4038+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4039+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4040+ * GNU General Public License for more details.
4041+ *
4042+ * You should have received a copy of the GNU General Public License
4043+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
4044+ *
4045+ * You can find Stado at http://www.stado.us
4046+ *
4047+ ****************************************************************************/
4048+package org.postgresql.driver.core;
4049+
4050+import java.sql.SQLException;
4051+import java.io.InputStream;
4052+
4053+/**
4054+ * Abstraction of a list of parameters to be substituted into a Query.
4055+ * The protocol-specific details of how to efficiently store and stream
4056+ * the parameters is hidden behind implementations of this interface.
4057+ *<p>
4058+ * In general, instances of ParameterList are associated with a particular
4059+ * Query object (the one that created them) and shouldn't be used against
4060+ * another Query.
4061+ *<p>
4062+ * Parameter indexes are 1-based to match JDBC's PreparedStatement, i.e.
4063+ * the first parameter has index 1.
4064+ *
4065+ * @author Oliver Jowett (oliver@opencloud.com)
4066+ */
4067+public interface ParameterList {
4068+
4069+
4070+ void registerOutParameter( int index, int sqlType ) throws SQLException;
4071+ /**
4072+ * Get the number of parameters in this list. This value never changes
4073+ * for a particular instance, and might be zero.
4074+ *
4075+ * @return the number of parameters in this list.
4076+ */
4077+ int getParameterCount();
4078+
4079+ /**
4080+ * Get the number of IN parameters in this list.
4081+ *
4082+ * @return the number of IN parameters in this list
4083+ */
4084+ int getInParameterCount();
4085+
4086+ /**
4087+ * Get the number of OUT parameters in this list.
4088+ *
4089+ * @return the number of OUT parameters in this list
4090+ */
4091+ int getOutParameterCount();
4092+
4093+ /**
4094+ * Return the oids of the parameters in this list. May be null for
4095+ * a ParameterList that does not support typing of parameters.
4096+ */
4097+ public int[] getTypeOIDs();
4098+
4099+ /**
4100+ * Binds an integer value to a parameter. The type of the parameter is
4101+ * implicitly 'int4'.
4102+ *
4103+ * @param index the 1-based parameter index to bind.
4104+ * @param value the integer value to use.
4105+ * @throws SQLException on error or if <code>index</code> is out of range
4106+ */
4107+ void setIntParameter(int index, int value) throws SQLException;
4108+
4109+ /**
4110+ * Binds a String value that is an unquoted literal to the
4111+ * server's query parser (for example, a bare integer) to a parameter.
4112+ * Associated with the parameter is a typename for the parameter that
4113+ * should correspond to an entry in pg_types.
4114+ *
4115+ * @param index the 1-based parameter index to bind.
4116+ * @param value the unquoted literal string to use.
4117+ * @param oid the type OID of the parameter, or <code>0</code>
4118+ * to infer the type.
4119+ * @throws SQLException on error or if <code>index</code> is out of range
4120+ */
4121+ void setLiteralParameter(int index, String value, int oid) throws SQLException;
4122+
4123+ /**
4124+ * Binds a String value that needs to be quoted for the server's parser
4125+ * to understand (for example, a timestamp) to a parameter.
4126+ * Associated with the parameter is a typename for the parameter that
4127+ * should correspond to an entry in pg_types.
4128+ *
4129+ * @param index the 1-based parameter index to bind.
4130+ * @param value the quoted string to use.
4131+ * @param oid the type OID of the parameter, or <code>0</code>
4132+ * to infer the type.
4133+ * @throws SQLException on error or if <code>index</code> is out of range
4134+ */
4135+ void setStringParameter(int index, String value, int oid) throws SQLException;
4136+
4137+ /**
4138+ * Binds a binary bytea value stored as a bytearray to a parameter. The
4139+ * parameter's type is implicitly set to 'bytea'. The bytearray's
4140+ * contains should remain unchanged until query execution has completed.
4141+ *
4142+ * @param index the 1-based parameter index to bind.
4143+ * @param data an array containing the raw data value
4144+ * @param offset the offset within <code>data</code> of the start of the parameter data.
4145+ * @param length the number of bytes of parameter data within <code>data</code> to use.
4146+ * @throws SQLException on error or if <code>index</code> is out of range
4147+ */
4148+ void setBytea(int index, byte[] data, int offset, int length) throws SQLException;
4149+
4150+ /**
4151+ * Binds a binary bytea value stored as an InputStream. The
4152+ * parameter's type is implicitly set to 'bytea'. The stream should
4153+ * remain valid until query execution has completed.
4154+ *
4155+ * @param index the 1-based parameter index to bind.
4156+ * @param stream a stream containing the parameter data.
4157+ * @param length the number of bytes of parameter data to read from <code>stream</code>.
4158+ * @throws SQLException on error or if <code>index</code> is out of range
4159+ */
4160+ void setBytea(int index, InputStream stream, int length) throws SQLException;
4161+
4162+ /**
4163+ * Binds a SQL NULL value to a parameter.
4164+ * Associated with the parameter is a typename for the parameter that
4165+ * should correspond to an entry in pg_types.
4166+ *
4167+ * @param index the 1-based parameter index to bind.
4168+ * @param oid the type OID of the parameter, or <code>0</code>
4169+ * to infer the type.
4170+ * @throws SQLException on error or if <code>index</code> is out of range
4171+ */
4172+ void setNull(int index, int oid) throws SQLException;
4173+
4174+ /**
4175+ * Perform a shallow copy of this ParameterList, returning a new instance
4176+ * (still suitable for passing to the owning Query). If this ParameterList
4177+ * is immutable, copy() may return the same immutable object.
4178+ *
4179+ * @return a new ParameterList instance
4180+ */
4181+ ParameterList copy();
4182+
4183+ /**
4184+ * Unbind all parameter values bound in this list.
4185+ */
4186+ void clear();
4187+
4188+ /**
4189+ * Return a human-readable representation of a particular parameter in
4190+ * this ParameterList. If the parameter is not bound, returns "?".
4191+ *
4192+ * @param index the 1-based parameter index to bind.
4193+ * @return a string representation of the parameter.
4194+ */
4195+ String toString(int index);
4196+}
4197
4198=== added file 'src/org/postgresql/driver/core/Parser.java'
4199--- src/org/postgresql/driver/core/Parser.java 1970-01-01 00:00:00 +0000
4200+++ src/org/postgresql/driver/core/Parser.java 2011-08-30 20:30:24 +0000
4201@@ -0,0 +1,316 @@
4202+/*****************************************************************************
4203+ * Copyright (C) 2008 EnterpriseDB Corporation.
4204+ * Copyright (C) 2011 Stado Global Development Group.
4205+ *
4206+ * This file is part of Stado.
4207+ *
4208+ * Stado is free software: you can redistribute it and/or modify
4209+ * it under the terms of the GNU General Public License as published by
4210+ * the Free Software Foundation, either version 3 of the License, or
4211+ * (at your option) any later version.
4212+ *
4213+ * Stado is distributed in the hope that it will be useful,
4214+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4215+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4216+ * GNU General Public License for more details.
4217+ *
4218+ * You should have received a copy of the GNU General Public License
4219+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
4220+ *
4221+ * You can find Stado at http://www.stado.us
4222+ *
4223+ ****************************************************************************/
4224+package org.postgresql.driver.core;
4225+
4226+/**
4227+ * Basic query parser infrastructure.
4228+ *
4229+ * @author Michael Paesold (mpaesold@gmx.at)
4230+ */
4231+public class Parser {
4232+
4233+ /**
4234+ * Find the end of the single-quoted string starting at the given offset.
4235+ *
4236+ * Note: for <tt>'single '' quote in string'</tt>, this method currently
4237+ * returns the offset of first <tt>'</tt> character after the initial
4238+ * one. The caller must call the method a second time for the second
4239+ * part of the quoted string.
4240+ */
4241+ public static int parseSingleQuotes(final char[] query, int offset,
4242+ boolean standardConformingStrings) {
4243+ // check for escape string syntax (E'')
4244+ if (standardConformingStrings
4245+ && offset >= 2
4246+ && (query[offset-1] == 'e' || query[offset-1] == 'E')
4247+ && charTerminatesIdentifier(query[offset-2]))
4248+ {
4249+ standardConformingStrings = false;
4250+ }
4251+
4252+ if (standardConformingStrings)
4253+ {
4254+ // do NOT treat backslashes as escape characters
4255+ while (++offset < query.length)
4256+ {
4257+ switch (query[offset])
4258+ {
4259+ case '\'':
4260+ return offset;
4261+ default:
4262+ break;
4263+ }
4264+ }
4265+ }
4266+ else
4267+ {
4268+ // treat backslashes as escape characters
4269+ while (++offset < query.length)
4270+ {
4271+ switch (query[offset])
4272+ {
4273+ case '\\':
4274+ ++offset;
4275+ break;
4276+ case '\'':
4277+ return offset;
4278+ default:
4279+ break;
4280+ }
4281+ }
4282+ }
4283+
4284+ return query.length;
4285+ }
4286+
4287+ /**
4288+ * Find the end of the double-quoted string starting at the given offset.
4289+ *
4290+ * Note: for <tt>&quot;double &quot;&quot; quote in string&quot;</tt>,
4291+ * this method currently returns the offset of first <tt>&quot;</tt>
4292+ * character after the initial one. The caller must call the method a
4293+ * second time for the second part of the quoted string.
4294+ */
4295+ public static int parseDoubleQuotes(final char[] query, int offset) {
4296+ while (++offset < query.length && query[offset] != '"') ;
4297+ return offset;
4298+ }
4299+
4300+ /**
4301+ * Test if the dollar character (<tt>$</tt>) at the given offset starts
4302+ * a dollar-quoted string and return the offset of the ending dollar
4303+ * character.
4304+ */
4305+ public static int parseDollarQuotes(final char[] query, int offset) {
4306+ if (offset + 1 < query.length
4307+ && (offset == 0 || !isIdentifierContChar(query[offset-1])))
4308+ {
4309+ int endIdx = -1;
4310+ if (query[offset + 1] == '$')
4311+ endIdx = offset + 1;
4312+ else if (isDollarQuoteStartChar(query[offset + 1]))
4313+ {
4314+ for (int d = offset + 2; d < query.length; ++d)
4315+ {
4316+ if (query[d] == '$')
4317+ {
4318+ endIdx = d;
4319+ break;
4320+ }
4321+ else if (!isDollarQuoteContChar(query[d]))
4322+ break;
4323+ }
4324+ }
4325+ if (endIdx > 0)
4326+ {
4327+ // found; note: tag includes start and end $ character
4328+ int tagIdx = offset, tagLen = endIdx - offset + 1;
4329+ offset = endIdx; // loop continues at endIdx + 1
4330+ for (++offset; offset < query.length; ++offset)
4331+ {
4332+ if (query[offset] == '$' &&
4333+ subArraysEqual(query, tagIdx, offset, tagLen))
4334+ {
4335+ offset += tagLen - 1;
4336+ break;
4337+ }
4338+ }
4339+ }
4340+ }
4341+ return offset;
4342+ }
4343+
4344+ /**
4345+ * Test if the <tt>-</tt> character at <tt>offset</tt> starts a
4346+ * <tt>--</tt> style line comment, and return the position of the first
4347+ * <tt>\r</tt> or <tt>\n</tt> character.
4348+ */
4349+ public static int parseLineComment(final char[] query, int offset) {
4350+ if (offset + 1 < query.length && query[offset + 1] == '-')
4351+ {
4352+ while (++offset < query.length)
4353+ {
4354+ if (query[offset] == '\r' || query[offset] == '\n')
4355+ break;
4356+ }
4357+ }
4358+ return offset;
4359+ }
4360+
4361+ /**
4362+ * Test if the <tt>/</tt> character at <tt>offset</tt> starts a block
4363+ * comment, and return the position of the last <tt>/</tt> character.
4364+ */
4365+ public static int parseBlockComment(final char[] query, int offset) {
4366+ if (offset + 1 < query.length && query[offset + 1] == '*')
4367+ {
4368+ // /* /* */ */ nest, according to SQL spec
4369+ int level = 1;
4370+ for (offset += 2; offset < query.length; ++offset)
4371+ {
4372+ switch (query[offset-1])
4373+ {
4374+ case '*':
4375+ if (query[offset] == '/')
4376+ {
4377+ --level;
4378+ ++offset; // don't parse / in */* twice
4379+ }
4380+ break;
4381+ case '/':
4382+ if (query[offset] == '*')
4383+ {
4384+ ++level;
4385+ ++offset; // don't parse * in /*/ twice
4386+ }
4387+ break;
4388+ default:
4389+ break;
4390+ }
4391+
4392+ if (level == 0)
4393+ {
4394+ --offset; // reset position to last '/' char
4395+ break;
4396+ }
4397+ }
4398+ }
4399+ return offset;
4400+ }
4401+
4402+ /**
4403+ * @return true if the character is a whitespace character as defined
4404+ * in the backend's parser
4405+ */
4406+ public static boolean isSpace(char c) {
4407+ return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f';
4408+ }
4409+
4410+ /**
4411+ * @return true if the given character is a valid character for an
4412+ * operator in the backend's parser
4413+ */
4414+ public static boolean isOperatorChar(char c) {
4415+ /*
4416+ * Extracted from operators defined by {self} and {op_chars}
4417+ * in pgsql/src/backend/parser/scan.l.
4418+ */
4419+ return ",()[].;:+-*/%^<>=~!@#&|`?".indexOf(c) != -1;
4420+ }
4421+
4422+ /**
4423+ * Checks if a character is valid as the start of an identifier.
4424+ *
4425+ * @param c the character to check
4426+ * @return true if valid as first character of an identifier; false if not
4427+ */
4428+ public static boolean isIdentifierStartChar(char c) {
4429+ /*
4430+ * Extracted from {ident_start} and {ident_cont} in
4431+ * pgsql/src/backend/parser/scan.l:
4432+ * ident_start [A-Za-z\200-\377_]
4433+ * ident_cont [A-Za-z\200-\377_0-9\$]
4434+ */
4435+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
4436+ || c == '_' || c > 127 ;
4437+ }
4438+
4439+ /**
4440+ * Checks if a character is valid as the second or later character of an
4441+ * identifier.
4442+ *
4443+ * @param c the character to check
4444+ * @return true if valid as second or later character of an identifier; false if not
4445+ */
4446+ public static boolean isIdentifierContChar(char c) {
4447+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
4448+ || c == '_' || c > 127
4449+ || (c >= '0' && c <= '9')
4450+ || c == '$';
4451+ }
4452+
4453+ /**
4454+ * @return true if the character terminates an identifier
4455+ */
4456+ public static boolean charTerminatesIdentifier(char c) {
4457+ return c == '"' || isSpace(c) || isOperatorChar(c);
4458+ }
4459+
4460+ /**
4461+ * Checks if a character is valid as the start of a dollar quoting tag.
4462+ *
4463+ * @param c the character to check
4464+ * @return true if valid as first character of a dollar quoting tag; false if not
4465+ */
4466+ public static boolean isDollarQuoteStartChar(char c) {
4467+ /*
4468+ * The allowed dollar quote start and continuation characters
4469+ * must stay in sync with what the backend defines in
4470+ * pgsql/src/backend/parser/scan.l
4471+ */
4472+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
4473+ || c == '_' || c > 127;
4474+ }
4475+
4476+ /**
4477+ * Checks if a character is valid as the second or later character of a
4478+ * dollar quoting tag.
4479+ *
4480+ * @param c the character to check
4481+ * @return true if valid as second or later character of a dollar quoting tag;
4482+ * false if not
4483+ */
4484+ public static boolean isDollarQuoteContChar(char c) {
4485+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
4486+ || c == '_' || c > 127
4487+ || (c >= '0' && c <= '9');
4488+ }
4489+
4490+ /**
4491+ * Compares two sub-arrays of the given character array for equalness.
4492+ * If the length is zero, the result is true if and only if the offsets
4493+ * are within the bounds of the array.
4494+ *
4495+ * @param arr a char array
4496+ * @param offA first sub-array start offset
4497+ * @param offB second sub-array start offset
4498+ * @param len length of the sub arrays to compare
4499+ * @return true if the sub-arrays are equal; false if not
4500+ */
4501+ private static boolean subArraysEqual(final char[] arr,
4502+ final int offA, final int offB,
4503+ final int len) {
4504+ if (offA < 0 || offB < 0
4505+ || offA >= arr.length || offB >= arr.length
4506+ || offA + len > arr.length || offB + len > arr.length)
4507+ return false;
4508+
4509+ for (int i = 0; i < len; ++i)
4510+ {
4511+ if (arr[offA + i] != arr[offB + i])
4512+ return false;
4513+ }
4514+
4515+ return true;
4516+ }
4517+}
4518
4519=== added file 'src/org/postgresql/driver/core/ProtocolConnection.java'
4520--- src/org/postgresql/driver/core/ProtocolConnection.java 1970-01-01 00:00:00 +0000
4521+++ src/org/postgresql/driver/core/ProtocolConnection.java 2011-08-30 20:30:24 +0000
4522@@ -0,0 +1,148 @@
4523+/*****************************************************************************
4524+ * Copyright (C) 2008 EnterpriseDB Corporation.
4525+ * Copyright (C) 2011 Stado Global Development Group.
4526+ *
4527+ * This file is part of Stado.
4528+ *
4529+ * Stado is free software: you can redistribute it and/or modify
4530+ * it under the terms of the GNU General Public License as published by
4531+ * the Free Software Foundation, either version 3 of the License, or
4532+ * (at your option) any later version.
4533+ *
4534+ * Stado is distributed in the hope that it will be useful,
4535+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4536+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4537+ * GNU General Public License for more details.
4538+ *
4539+ * You should have received a copy of the GNU General Public License
4540+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
4541+ *
4542+ * You can find Stado at http://www.stado.us
4543+ *
4544+ ****************************************************************************/
4545+package org.postgresql.driver.core;
4546+
4547+import org.postgresql.driver.PGNotification;
4548+
4549+import java.sql.*;
4550+
4551+/**
4552+ * Provides access to protocol-level connection operations.
4553+ *
4554+ * @author Oliver Jowett (oliver@opencloud.com)
4555+ */
4556+public interface ProtocolConnection {
4557+ /**
4558+ * Constant returned by {@link #getTransactionState} indicating that no
4559+ * transaction is currently open.
4560+ */
4561+ static final int TRANSACTION_IDLE = 0;
4562+
4563+ /**
4564+ * Constant returned by {@link #getTransactionState} indicating that a
4565+ * transaction is currently open.
4566+ */
4567+ static final int TRANSACTION_OPEN = 1;
4568+
4569+ /**
4570+ * Constant returned by {@link #getTransactionState} indicating that a
4571+ * transaction is currently open, but it has seen errors and will
4572+ * refuse subsequent queries until a ROLLBACK.
4573+ */
4574+ static final int TRANSACTION_FAILED = 2;
4575+
4576+ /**
4577+ * @return the hostname this connection is connected to.
4578+ */
4579+ String getHost();
4580+
4581+ /**
4582+ * @return the port number this connection is connected to.
4583+ */
4584+ int getPort();
4585+
4586+ /**
4587+ * @return the user this connection authenticated as.
4588+ */
4589+ String getUser();
4590+
4591+ /**
4592+ * @return the database this connection is connected to.
4593+ */
4594+ String getDatabase();
4595+
4596+ /**
4597+ * @return the server version of the connected server, formatted as X.Y.Z.
4598+ */
4599+ String getServerVersion();
4600+
4601+ /**
4602+ * @return the current encoding in use by this connection
4603+ */
4604+ Encoding getEncoding();
4605+
4606+ /**
4607+ * Returns whether the server treats string-literals according to the SQL
4608+ * standard or if it uses traditional PostgreSQL escaping rules. Versions
4609+ * up to 8.1 always treated backslashes as escape characters in
4610+ * string-literals. Since 8.2, this depends on the value of the
4611+ * <tt>standard_conforming_strings<tt> server variable.
4612+ *
4613+ * @return true if the server treats string literals according to the SQL
4614+ * standard
4615+ */
4616+ boolean getStandardConformingStrings();
4617+
4618+ /**
4619+ * Get the current transaction state of this connection.
4620+ *
4621+ * @return a ProtocolConnection.TRANSACTION_* constant.
4622+ */
4623+ int getTransactionState();
4624+
4625+ /**
4626+ * Retrieve and clear the set of asynchronous notifications pending on this
4627+ * connection.
4628+ *
4629+ * @return an array of notifications; if there are no notifications, an empty
4630+ * array is returned.
4631+ */
4632+ PGNotification[] getNotifications() throws SQLException;
4633+
4634+ /**
4635+ * Retrieve and clear the chain of warnings accumulated on this connection.
4636+ *
4637+ * @return the first SQLWarning in the chain; subsequent warnings can be
4638+ * found via SQLWarning.getNextWarning().
4639+ */
4640+ SQLWarning getWarnings();
4641+
4642+ /**
4643+ * @return the QueryExecutor instance for this connection.
4644+ */
4645+ QueryExecutor getQueryExecutor();
4646+
4647+ /**
4648+ * Sends a query cancellation for this connection.
4649+ * @throws SQLException if something goes wrong.
4650+ */
4651+ void sendQueryCancel() throws SQLException;
4652+
4653+ /**
4654+ * Close this connection cleanly.
4655+ */
4656+ void close();
4657+
4658+ /**
4659+ * Check if this connection is closed.
4660+ *
4661+ * @return true iff the connection is closed.
4662+ */
4663+ boolean isClosed();
4664+
4665+ /**
4666+ *
4667+ * @return the version of the implementation
4668+ */
4669+ public int getProtocolVersion();
4670+}
4671
4672=== added file 'src/org/postgresql/driver/core/Query.java'
4673--- src/org/postgresql/driver/core/Query.java 1970-01-01 00:00:00 +0000
4674+++ src/org/postgresql/driver/core/Query.java 2011-08-30 20:30:24 +0000
4675@@ -0,0 +1,69 @@
4676+/*****************************************************************************
4677+ * Copyright (C) 2008 EnterpriseDB Corporation.
4678+ * Copyright (C) 2011 Stado Global Development Group.
4679+ *
4680+ * This file is part of Stado.
4681+ *
4682+ * Stado is free software: you can redistribute it and/or modify
4683+ * it under the terms of the GNU General Public License as published by
4684+ * the Free Software Foundation, either version 3 of the License, or
4685+ * (at your option) any later version.
4686+ *
4687+ * Stado is distributed in the hope that it will be useful,
4688+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4689+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4690+ * GNU General Public License for more details.
4691+ *
4692+ * You should have received a copy of the GNU General Public License
4693+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
4694+ *
4695+ * You can find Stado at http://www.stado.us
4696+ *
4697+ ****************************************************************************/
4698+package org.postgresql.driver.core;
4699+
4700+/**
4701+ * Abstraction of a generic Query, hiding the details of
4702+ * any protocol-version-specific data needed to execute
4703+ * the query efficiently.
4704+ *<p>
4705+ * Query objects should be explicitly closed when no longer
4706+ * needed; if resources are allocated on the server for this
4707+ * query, their cleanup is triggered by closing the Query.
4708+ *
4709+ * @author Oliver Jowett (oliver@opencloud.com)
4710+ */
4711+public interface Query {
4712+ /**
4713+ * Create a ParameterList suitable for storing parameters
4714+ * associated with this Query.
4715+ *<p>
4716+ * If this query has no parameters, a ParameterList will
4717+ * be returned, but it may be a shared immutable object.
4718+ * If this query does have parameters, the returned
4719+ * ParameterList is a new list, unshared by other callers.
4720+ *
4721+ * @return a suitable ParameterList instance for this query
4722+ */
4723+ ParameterList createParameterList();
4724+
4725+ /**
4726+ * Stringize this query to a human-readable form, substituting
4727+ * particular parameter values for parameter placeholders.
4728+ *
4729+ * @param parameters a ParameterList returned by this Query's
4730+ * {@link #createParameterList} method, or <code>null</code> to
4731+ * leave the parameter placeholders unsubstituted.
4732+ * @return a human-readable representation of this query
4733+ */
4734+ String toString(ParameterList parameters);
4735+
4736+ /**
4737+ * Close this query and free any server-side resources associated
4738+ * with it. The resources may not be immediately deallocated, but
4739+ * closing a Query may make the deallocation more prompt.
4740+ *<p>
4741+ * A closed Query should not be executed.
4742+ */
4743+ void close();
4744+}
4745
4746=== added file 'src/org/postgresql/driver/core/QueryExecutor.java'
4747--- src/org/postgresql/driver/core/QueryExecutor.java 1970-01-01 00:00:00 +0000
4748+++ src/org/postgresql/driver/core/QueryExecutor.java 2011-08-30 20:30:24 +0000
4749@@ -0,0 +1,236 @@
4750+/*****************************************************************************
4751+ * Copyright (C) 2008 EnterpriseDB Corporation.
4752+ * Copyright (C) 2011 Stado Global Development Group.
4753+ *
4754+ * This file is part of Stado.
4755+ *
4756+ * Stado is free software: you can redistribute it and/or modify
4757+ * it under the terms of the GNU General Public License as published by
4758+ * the Free Software Foundation, either version 3 of the License, or
4759+ * (at your option) any later version.
4760+ *
4761+ * Stado is distributed in the hope that it will be useful,
4762+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4763+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4764+ * GNU General Public License for more details.
4765+ *
4766+ * You should have received a copy of the GNU General Public License
4767+ * along with Stado. If not, see <http://www.gnu.org/licenses/>.
4768+ *
4769+ * You can find Stado at http://www.stado.us
4770+ *
4771+ ****************************************************************************/
4772+package org.postgresql.driver.core;
4773+
4774+import java.sql.SQLException;
4775+
4776+import org.postgresql.driver.copy.CopyOperation;
4777+
4778+/**
4779+ * Abstracts the protocol-specific details of executing a query.
4780+ *<p>
4781+ * Every connection has a single QueryExecutor implementation associated with it.
4782+ * This object provides:
4783+ *
4784+ * <ul>
4785+ * <li> factory methods for Query objects ({@link #createSimpleQuery}
4786+ * and {@link #createParameterizedQuery})
4787+ * <li> execution methods for created Query objects ({@link #execute(Query,ParameterList,ResultHandler,int,int,int)}
4788+ * for single queries and {@link #execute(Query[],ParameterList[],ResultHandler,int,int,int)} for batches of
4789+ * queries)
4790+ * <li> a fastpath call interface ({@link #createFastpathParameters}
4791+ * and {@link #fastpathCall}).
4792+ * </ul>
4793+ *
4794+ *<p>
4795+ * Query objects may represent a query that has parameter placeholders. To provide
4796+ * actual values for these parameters, a {@link ParameterList} object is created
4797+ * via a factory method ({@link Query#createParameterList}). The parameters are filled
4798+ * in by the caller and passed along with the query to the query execution methods.
4799+ * Several ParameterLists for a given query might exist at one time (or over time);
4800+ * this allows the underlying Query to be reused for several executions, or for
4801+ * batch execution of the same Query.
4802+ *
4803+ *<p>
4804+ * In general, a Query created by a particular QueryExecutor may only be
4805+ * executed by that QueryExecutor, and a ParameterList created by a particular
4806+ * Query may only be used as parameters to that Query. Unpredictable things will
4807+ * happen if this isn't done.
4808+ *
4809+ * @author Oliver Jowett (oliver@opencloud.com)
4810+ */
4811+public interface QueryExecutor {
4812+ /**
4813+ * Flag for query execution that indicates the given Query object is unlikely
4814+ * to be reused.
4815+ */
4816+ static int QUERY_ONESHOT = 1;
4817+
4818+ /**
4819+ * Flag for query execution that indicates that resultset metadata isn't needed
4820+ * and can be safely omitted.
4821+ */
4822+ static int QUERY_NO_METADATA = 2;
4823+
4824+ /**
4825+ * Flag for query execution that indicates that a resultset isn't expected and
4826+ * the query executor can safely discard any rows (although the resultset should
4827+ * still appear to be from a resultset-returning query).
4828+ */
4829+ static int QUERY_NO_RESULTS = 4;
4830+
4831+ /**
4832+ * Flag for query execution that indicates a forward-fetch-capable cursor should
4833+ * be used if possible.
4834+ */
4835+ static int QUERY_FORWARD_CURSOR = 8;
4836+
4837+ /**
4838+ * Flag for query execution that indicates the automatic BEGIN on the first statement
4839+ * when outside a transaction should not be done.
4840+ */
4841+ static int QUERY_SUPPRESS_BEGIN = 16;
4842+
4843+ /**
4844+ * Flag for query execution when we don't really want to execute, we just
4845+ * want to get the parameter metadata for the statement.
4846+ */
4847+ static int QUERY_DESCRIBE_ONLY = 32;
4848+
4849+ /**
4850+ * Flag for query execution used by generated keys where we want to receive
4851+ * both the ResultSet and associated update count from the command status.
4852+ */
4853+ static int QUERY_BOTH_ROWS_AND_STATUS = 64;
4854+
4855+ /**
4856+ * Execute a Query, passing results to a provided ResultHandler.
4857+ *
4858+ * @param query the query to execute; must be a query returned from
4859+ * calling {@link #createSimpleQuery(String)} or {@link #createParameterizedQuery(String)}
4860+ * on this QueryExecutor object.
4861+ * @param parameters the parameters for the query. Must be non-<code>null</code>
4862+ * if the query takes parameters. Must be a parameter object returned by
4863+ * {@link org.postgresql.driver.core.Query#createParameterList()}.
4864+ * @param handler a ResultHandler responsible for handling results generated
4865+ * by this query
4866+ * @param maxRows the maximum number of rows to retrieve
4867+ * @param fetchSize if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
4868+ * @param flags a combination of QUERY_* flags indicating how to handle the query.
4869+ *
4870+ * @throws SQLException if query execution fails
4871+ */
4872+ void execute(Query query,
4873+ ParameterList parameters,
4874+ ResultHandler handler,
4875+ int maxRows,
4876+ int fetchSize,
4877+ int flags)
4878+ throws SQLException;
4879+
4880+ /**
4881+ * Execute several Query, passing results to a provided ResultHandler.
4882+ *
4883+ * @param queries the queries to execute; each must be a query returned from
4884+ * calling {@link #createSimpleQuery(String)} or {@link #createParameterizedQuery(String)}
4885+ * on this QueryExecutor object.
4886+ * @param parameterLists the parameter lists for the queries. The parameter lists
4887+ * correspond 1:1 to the queries passed in the <code>queries</code> array. Each must be
4888+ * non-<code>null</code> if the corresponding query takes parameters, and must
4889+ * be a parameter object returned by {@link org.postgresql.driver.core.Query#createParameterList()}
4890+ * created by the corresponding query.
4891+ * @param handler a ResultHandler responsible for handling results generated
4892+ * by this query
4893+ * @param maxRows the maximum number of rows to retrieve
4894+ * @param fetchSize if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
4895+ * @param flags a combination of QUERY_* flags indicating how to handle the query.
4896+ *
4897+ * @throws SQLException if query execution fails
4898+ */
4899+ void execute(Query[] queries,
4900+ ParameterList[] parameterLists,
4901+ ResultHandler handler,
4902+ int maxRows,
4903+ int fetchSize,
4904+ int flags)
4905+ throws SQLException;
4906+
4907+ /**
4908+ * Fetch additional rows from a cursor.
4909+ *
4910+ * @param cursor the cursor to fetch from
4911+ * @param handler the handler to feed results to
4912+ * @param fetchSize the preferred number of rows to retrieve before suspending
4913+ * @throws SQLException if query execution fails
4914+ */
4915+ void fetch(ResultCursor cursor, ResultHandler handler, int fetchSize) throws SQLException;
4916+
4917+ /**
4918+ * Create an unparameterized Query object suitable for execution by
4919+ * this QueryExecutor. The provided query string is not parsed for
4920+ * parameter placeholders ('?' characters), and the
4921+ * {@link Query#createParameterList} of the returned object will
4922+ * always return an empty ParameterList.
4923+ *
4924+ * @param sql the SQL for the query to create
4925+ * @return a new Query object
4926+ */
4927+ Query createSimpleQuery(String sql);
4928+
4929+ /**
4930+ * Create a parameterized Query object suitable for execution by
4931+ * this QueryExecutor. The provided query string is parsed for
4932+ * parameter placeholders ('?' characters), and the
4933+ * {@link Query#createParameterList} of the returned object will
4934+ * create an appropriately-sized ParameterList.
4935+ *
4936+ * @param sql the SQL for the query to create, with '?' placeholders for
4937+ * parameters.
4938+ * @return a new Query object
4939+ */
4940+ Query createParameterizedQuery(String sql); // Parsed for parameter placeholders ('?')
4941+
4942+ /**
4943+ * Prior to attempting to retrieve notifications, we need to pull
4944+ * any recently received notifications off of the network buffers.
4945+ * The notification retrieval in ProtocolConnection cannot do this
4946+ * as it is prone to deadlock, so the higher level caller must be
4947+ * responsible which requires exposing this method.
4948+ */
4949+ void processNotifies() throws SQLException;
4950+
4951+ //
4952+ // Fastpath interface.
4953+ //
4954+
4955+ /**
4956+ * Create a new ParameterList implementation suitable for invoking a
4957+ * fastpath function via {@link #fastpathCall}.
4958+ *
4959+ * @param count the number of parameters the fastpath call will take
4960+ * @return a ParameterList suitable for passing to {@link #fastpathCall}.
4961+ */
4962+ ParameterList createFastpathParameters(int count);
4963+
4964+ /**
4965+ * Invoke a backend function via the fastpath interface.
4966+ *
4967+ * @param fnid the OID of the backend function to invoke
4968+ * @param params a ParameterList returned from {@link #createFastpathParameters}
4969+ * containing the parameters to pass to the backend function
4970+ *
4971+ * @return the binary-format result of the fastpath call, or <code>null</code>
4972+ * if a void result was returned
4973+ * @throws SQLException if an error occurs while executing the fastpath call
4974+ */
4975+ byte[] fastpathCall(int fnid, ParameterList params, boolean suppressBegin) throws SQLException;
4976+
4977+ /**
4978+ * Issues a COPY FROM STDIN / COPY TO STDOUT statement and returns
4979+ * handler for associated operation. Until the copy operation completes,
4980+ * no other database operation may be performed.
4981+ * Implemented for protocol version 3 only.
4982+ * @throws SQLException when initializing the given query fails
4983+ */
4984+ CopyOperation startCopy(String sql, boolean suppressBegin) throws SQLException;
4985+}
4986
4987=== added file 'src/org/postgresql/driver/core/ResultCursor.java'
4988--- src/org/postgresql/driver/core/ResultCursor.java 1970-01-01 00:00:00 +0000
4989+++ src/org/postgresql/driver/core/ResultCursor.java 2011-08-30 20:30:24 +0000
4990@@ -0,0 +1,40 @@
4991+/*****************************************************************************
4992+ * Copyright (C) 2008 EnterpriseDB Corporation.
4993+ * Copyright (C) 2011 Stado Global Development Group.
4994+ *
4995+ * This file is part of Stado.
4996+ *
4997+ * Stado is free software: you can redistribute it and/or modify
4998+ * it under the terms of the GNU General Public License as published by
4999+ * the Free Software Foundation, either version 3 of the License, or
5000+ * (at your option) any later version.
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches