db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satheesh Bandaram <sathe...@Sourcery.Org>
Subject Re: [jira] Updated: (DERBY-353) It is desirable to have IDENTITY_VAL_LOCAL() function return last recent user specified value or system generated value for BY DEFAULT identity columns.
Date Wed, 31 Aug 2005 00:45:52 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hope you have seen the note from Rick. Once you address test failure, I
will look into committing the patch.<br>
<br>
Satheesh<br>
<br>
V.Narayanan (JIRA) wrote:<br>
<blockquote
 cite="mid273229927.1123734219720.JavaMail.jira@ajax.apache.org"
 type="cite">
  <pre wrap="">     [ <a class="moz-txt-link-freetext" href="http://issues.apache.org/jira/browse/DERBY-353?page=all">http://issues.apache.org/jira/browse/DERBY-353?page=all</a>
]

V.Narayanan updated DERBY-353:
------------------------------

    Attachment: xyz.diff

Hi,
I have attached with this email the diff file of the fix for DERBY-353 and DERBY-439.

About the fix
-------------

a) Inside the InsertResultSet class getSetAutoincrementValue function the Data Dictionary
is accessed to get the current identity value.Which is then updated in the identityVal variable
which is then used by the identity_val_local() function to display to the user.

b) The above process did not happen when there was a user supplied value. The system table
was not accessed and the setIdentity() function in the GenericLanguageContext class was not
called.

c) My fix attacked the case when the user supplies a value for the identity column which can
be done in the case of Generated by default and calls the setIdentity function to store the
value in this case also.

    This involved

    c.1) Identifying if the column has a autoincremented value. Done by constants.hasAutoincrement()
    c.2) If it does then finding which of the columns is an autoincrement done by

        for(col=1;col&lt;=maxColumns;col++)
                {
                      ColumnDescriptor cd = td.getColumnDescriptor(col);
                      if(cd.isAutoincrement())
                      {
                                break;
                      }
                }
    c.3) getting the user inserted value

        if(col &lt;= maxColumns)
            {
               DataValueDescriptor dvd = row.cloneColumn(col);
               user_autoinc = dvd.getLong();
            }
   
      c.4) calling the setIdentity() function in the GenericLanguageContext class with this
value.

Pls review the patch and give me your comments
thanx
Narayanan
        

  </pre>
  <blockquote type="cite">
    <pre wrap="">It is desirable to have IDENTITY_VAL_LOCAL() function return last recent
user specified value or system generated value for BY DEFAULT identity columns.
--------------------------------------------------------------------------------------------------------------------------------------------------------

         Key: DERBY-353
         URL: <a class="moz-txt-link-freetext" href="http://issues.apache.org/jira/browse/DERBY-353">http://issues.apache.org/jira/browse/DERBY-353</a>
     Project: Derby
        Type: Bug
  Components: SQL
    Versions: 10.1.1.0
 Environment: Generic
    Reporter: Satheesh Bandaram
 Attachments: xyz.diff

Derby was recently enhanced to support BY DEFAULT identity column. While the behavior of this
feature is not documented yet, I think, it is desirable for IDENTITY_VAL_LOCAL() function,
that is used to retrieve last single statement insert value for identity column, to return
user specified value for the default column.
For GENERATED ALWAYS identity columns, this issue doesn't apply, since users can't provide
a value. But for GENERATED BY DEFAULT identity columns, users can optionally specify a value.
IDENTITY_VAL_LOCAL() function should return this value. Derby currently doesn't support this
behavior.
ij&gt; create table tauto ( i int generated by default as identity, j int, k int);
0 rows inserted/updated/deleted
ij&gt; insert into tauto (j,k) values (1,1);
1 row inserted/updated/deleted
ij&gt; values identity_val_local();
1
-------------------------------
1
1 row selected
ij&gt; insert into tauto (j,k) values (1,1);
1 row inserted/updated/deleted
ij&gt; values identity_val_local();
1
-------------------------------
2
1 row selected
ij&gt; insert into tauto values (5,1,1);
1 row inserted/updated/deleted
ij&gt; values identity_val_local();
1
-------------------------------
2                                                                     &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;=============
This needs be '5'
1 row selected
ij&gt; select * from tauto;
I          |J          |K
-----------------------------------
1          |1          |1
2          |1          |1
5          |1          |1
3 rows selected
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
</body>
</html>


Mime
View raw message