[
https://issues.apache.org/jira/browse/DERBY-5818?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rick Hillegas updated DERBY-5818:
---------------------------------
Attachment: derby-5818-01-aa-dictionaryVersionFunction.diff
Attaching derby-5818-01-aa-dictionaryVersionFunction.diff. This is a possible
approach to adding a supported mechanism to the public api for querying the
version level of the on-disk data. If this seems like a useful approach, I can
add tests.
The patch adds a new builtin method: dictionary_version(). This method reverses
the tricky encoding which DD_Version performs. The decoding is likely to be
wrong for databases created with development versions of Derby which are beta
but not alpha. I am not convinced that the encoding is a 1-1 mapping when the
beta flag is set and I don't think that this edge case is worth puzzling
through at this time.
I decided to make dictionary_version() a builtin, schema-less function rather
than a function in SYSCS_UTIL. No metadata changes are needed for the first
kind of function. That means that you do not have to hard-upgrade to use it.
Requiring hard-upgrade in order to determine the version of a database would be
self-defeating.
For a newly created 10.10.0.0 database, dictionary_version() returns the string
"10.10.0.0 alpha".
I have created databases at many version levels, both read-write versions and
read-only versions stored in jar files. See below for the list of versions I
hand-tested. For all these versions, I have observed the following when I boot
them with this patch:
1) For the read-write databases, dictionary_version() returns the string X.Y
2) For the read-only databases, dictionary_version() returns the string
X.Y.Z.W, where X = major, Y = minor, Z = fixpack, and W = point.
These are the versions I hand-tested:
10.0.2.1
10.1.1.0
10.1.2.1
10.1.3.1
10.2.1.6
10.2.2.0
10.2.2.1
10.3.1.4
10.3.2.1
10.3.3.0
10.4.1.3
10.4.2.0
10.4.2.1
10.5.1.1
10.5.2.0
10.5.3.0
10.6.1.0
10.6.2.1
10.7.1.1
10.8.1.2
10.8.1.6
10.8.2.1
10.8.2.2
10.9.1.0
Here, for instance, is a fragment of the result:
ij(CONNECTION20)> connect 'jdbc:derby:db10.4.1.3';
ij(CONNECTION21)> values dictionary_version();
1
--------------------------------------------------------------------------------------------------------------------------------
10.4
1 row selected
ij(CONNECTION21)> connect 'jdbc:derby:jar:(db10.4.1.3.jar)db10.4.1.3';
ij(CONNECTION22)> values dictionary_version();
1
--------------------------------------------------------------------------------------------------------------------------------
10.4.1.3
1 row selected
I would appreciate feedback on whether this approach is worth pursuing.
Touches the following files:
----------
M java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
Added a new method to decode a DD_Version into a full version string.
----------
M java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
M java/engine/org/apache/derby/catalog/SystemProcedures.java
Added a builtin, schema-less function to call the new DD_Version code.
----------
M java/storeless/org/apache/derby/impl/storeless/EmptyDictionary.java
M java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
Interface boilerplate.
> values syscs_util.syscs_get_database_property('DataDictionaryVersion' ) does
> not return full version information
> ----------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-5818
> URL: https://issues.apache.org/jira/browse/DERBY-5818
> Project: Derby
> Issue Type: Bug
> Reporter: Saurabh Kejriwal
> Attachments: derby-5818-01-aa-dictionaryVersionFunction.diff
>
>
> Details
> ------------
> $ ./sysinfo
> ------------------ Java Information ------------------
> Java Version: 1.6.0
> Java Vendor: Sun Microsystems Inc.
> Java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre
> Java classpath:
> /scratch/ansverma/JavaDBnew/db-derby-10.8.2.2-bin/lib/derby.jar:/scratch/ansverma/JavaDBnew/db-derby-10.8.2.2-bin/lib/derbynet.jar:/scratch/ansverma/JavaDBnew/db-derby-10.8.2.2-bin/lib/derbytools.jar:/scratch/ansverma/JavaDBnew/db-derby-10.8.2.2-bin/lib/derbyclient.jar
> OS name: Linux
> OS architecture: i386
> OS version: 2.6.18-164.0.0.0.1.el5xen
> Java user name: ansverma
> Java user home: /home/ansverma
> Java user dir: /scratch/ansverma/JavaDBnew/db-derby-10.8.2.2-bin/bin
> java.specification.name: Java Platform API Specification
> java.specification.version: 1.6
> java.runtime.version: 1.6.0-b09
> --------- Derby Information --------
> JRE - JDBC: Java SE 6 - JDBC 4.0
> [/scratch/ansverma/JavaDBnew/db-derby-10.8.2.2-bin/lib/derby.jar] 10.8.2.2 -
> (1181258)
> [/scratch/ansverma/JavaDBnew/db-derby-10.8.2.2-bin/lib/derbytools.jar]
> 10.8.2.2 - (1181258)
> [/scratch/ansverma/JavaDBnew/db-derby-10.8.2.2-bin/lib/derbynet.jar] 10.8.2.2
> - (1181258)
> [/scratch/ansverma/JavaDBnew/db-derby-10.8.2.2-bin/lib/derbyclient.jar]
> 10.8.2.2 - (1181258)
> ------------------------------------------------------
> ----------------- Locale Information -----------------
> Current Locale : [English/United States [en_US]]
> Found support for locale: [cs]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [de_DE]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [es]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [fr]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [hu]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [it]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [ja_JP]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [ko_KR]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [pl]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [pt_BR]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [ru]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [zh_CN]
> version: 10.8.2.2 - (1181258)
> Found support for locale: [zh_TW]
> version: 10.8.2.2 - (1181258)
> ------------------------------------------------------
> Description
> -----------------
> I am using Derby 10.8.2.2. I want to get derby version details through SQL. I
> ran following query to retrieve version information.
> $ java -jar
> /scratch/ansverma/JavaDBnew//db-derby-10.8.2.2-bin/lib/derbyrun.jar ij
> ij version 10.8
> ij> CONNECT 'jdbc:derby:test2;user=test2;password=test2';
> ij> values syscs_util.syscs_get_database_property('DataDictionaryVersion');
>
> 1
>
> --------------------------------------------------------------------------------------------------------------------------------
> 10.8
>
> 1 row selected
> It did not return full version information (10.8.2.2) for Derby.
> Expected result = 10.8.2.2
> Actual result = 10.8
> I want the version details through SQL query.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira