Alignment of predefined UDT
Posted in 2012
Topics: Data Types & Schema Design
According to the incl/public/sqltypes.h */* Alignment required by predefined UDT's. * Only a few are currently defined. At a minimum, * all with alignment not 1 should be defined here * and used throughout the code. */ #define ALNINDEXKEYARRAY 4 #define ALNSTAT 8* and through query table "sysxtdtypes", I can find the definition of xtd types. BUT, I wonder where has the definition of these alignments? for example: extended_id name type align 1 lvarchar 40 1 10 blob 41 4 11 clob 41 4 in my test, the alignment is not static, like the alignment of blob could be 1 or 4 in different table in same database. So my question is "is there a table defined each column of a table's alignment length?", or "how alignments used? " regards. BlackThought --e89a8f23458f816f3504ba6b0d27
Alignment is required when the data within the opaque type is store 'as is'. As an example, suppose that an opaque type contains an integer data type and is stored as is. Then the opaque type would have to be stored on a word boundary. So the number of alignment bytes would depend on the byte that it was stored. If the definition of the table was... define table tab ( col1 char(2), col2 my_UDT_containing_an_integer )... Then it would be required to have 2 alignment bytes. However, if col1 was char(4), then no alignment bytes would be required. (Actually the UDT contains an additional flag so the actual alignment bytes would be different. But to make my point, we'll ignore that for now.) So the key thing determining how many alignment bytes is not so much the UDT type as where the UDT falls within the row. The definition of the UDT, however, does contain an alignment value and that is based on any alignment requirements within the UDT itself. From: "Wang Shiyi" <osdbms@gmail.com> To: ids@iiug.org Date: 03/04/2012 07:48 AM Subject: Alignment of predefined UDT [26437] Sent by: ids-bounces@iiug.org According to the incl/public/sqltypes.h */* Alignment required by predefined UDT's. * Only a few are currently defined. At a minimum, * all with alignment not 1 should be defined here * and used throughout the code. */ #define ALNINDEXKEYARRAY 4 #define ALNSTAT 8* and through query table "sysxtdtypes", I can find the definition of xtd types. BUT, I wonder where has the definition of these alignments? for example: extended_id name type align 1 lvarchar 40 1 10 blob 41 4 11 clob 41 4 in my test, the alignment is not static, like the alignment of blob could be 1 or 4 in different table in same database. So my question is "is there a table defined each column of a table's alignment length?", or "how alignments used? " regards. BlackThought --e89a8f23458f816f3504ba6b0d27 ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
Great, I solved the problem of SBLOB's alignment. I spend whole for testing the alignment, different database collate and different ids version and different table rowsize. Finally, I found it. It is a little strange that the alignment is depend on the table definition not the real data. Thanks Pruet. BlackThought On Mon, Mar 5, 2012 at 7:55 AM, Madison Pruet <mpruet@us.ibm.com> wrote: > Alignment is required when the data within the opaque type is store 'as > is'. > > As an example, suppose that an opaque type contains an integer data type > and is stored as is. Then the opaque type would have to be stored on a > word boundary. So the number of alignment bytes would depend on the byte > that it was stored. If the definition of the table was... > > define table tab ( > > col1 char(2), > > col2 my_UDT_containing_an_integer > > )... > > Then it would be required to have 2 alignment bytes. However, if col1 was > char(4), then no alignment bytes would be required. > > (Actually the UDT contains an additional flag so the actual alignment bytes > would be different. But to make my point, we'll ignore that for now.) > > So the key thing determining how many alignment bytes is not so much the > UDT type as where the UDT falls within the row. The definition of the UDT, > however, does contain an alignment value and that is based on any alignment > requirements within the UDT itself. > > From: "Wang Shiyi" <osdbms@gmail.com> > > To: ids@iiug.org > > Date: 03/04/2012 07:48 AM > > Subject: Alignment of predefined UDT [26437] > > Sent by: ids-bounces@iiug.org > > According to the incl/public/sqltypes.h > > */* Alignment required by predefined UDT's. > * Only a few are currently defined. At a minimum, > * all with alignment not 1 should be defined here > * and used throughout the code. > */ > #define ALNINDEXKEYARRAY 4 > #define ALNSTAT 8* > > and through query table "sysxtdtypes", I can find the definition of xtd > types. > > BUT, I wonder where has the definition of these alignments? > > for example: extended_id name > type align > > 1 > lvarchar 40 1 > > 10 > blob 41 4 > > 11 > clob 41 4 > > in my test, the alignment is not static, like the alignment of blob could > be 1 or 4 in different table in same database. > > So my question is "is there a table defined each column of a table's > alignment length?", or "how alignments used? " > > regards. > > BlackThought > > --e89a8f23458f816f3504ba6b0d27 > > > > ******************************************************************************* > > Forum Note: Use "Reply" to post a response in the discussion forum. > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --f46d0401fceddd1eab04ba79bd6c
Not strange at all because the data has to be properly aligned in the return buffer when it is sent back to your applications to be processed and the data in the buffer includes all of the columns selected. So, actually it is dependent on the selected columns, not the table definition. So, if the table is defined as: define table tab ( col1 char(2), col3 int, col2 my_UDT_containing_an_integer )... I think you will find that the alignment is different depending on whether or not you select col1. Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Mon, Mar 5, 2012 at 2:19 AM, Wang Shiyi <osdbms@gmail.com> wrote: > Great, I solved the problem of SBLOB's alignment. > > I spend whole for testing the alignment, different database collate and > different ids version and different table rowsize. > Finally, I found it. It is a little strange that the alignment is depend on > the table definition not the real data. > > Thanks Pruet. > > BlackThought > > On Mon, Mar 5, 2012 at 7:55 AM, Madison Pruet <mpruet@us.ibm.com> wrote: > > > Alignment is required when the data within the opaque type is store 'as > > is'. > > > > As an example, suppose that an opaque type contains an integer data type > > and is stored as is. Then the opaque type would have to be stored on a > > word boundary. So the number of alignment bytes would depend on the byte > > that it was stored. If the definition of the table was... > > > > define table tab ( > > > > col1 char(2), > > > > col2 my_UDT_containing_an_integer > > > > )... > > > > Then it would be required to have 2 alignment bytes. However, if col1 was > > char(4), then no alignment bytes would be required. > > > > (Actually the UDT contains an additional flag so the actual alignment > bytes > > would be different. But to make my point, we'll ignore that for now.) > > > > So the key thing determining how many alignment bytes is not so much the > > UDT type as where the UDT falls within the row. The definition of the > UDT, > > however, does contain an alignment value and that is based on any > alignment > > requirements within the UDT itself. > > > > From: "Wang Shiyi" <osdbms@gmail.com> > > > > To: ids@iiug.org > > > > Date: 03/04/2012 07:48 AM > > > > Subject: Alignment of predefined UDT [26437] > > > > Sent by: ids-bounces@iiug.org > > > > According to the incl/public/sqltypes.h > > > > */* Alignment required by predefined UDT's. > > * Only a few are currently defined. At a minimum, > > * all with alignment not 1 should be defined here > > * and used throughout the code. > > */ > > #define ALNINDEXKEYARRAY 4 > > #define ALNSTAT 8* > > > > and through query table "sysxtdtypes", I can find the definition of xtd > > types. > > > > BUT, I wonder where has the definition of these alignments? > > > > for example: extended_id name > > type align > > > > 1 > > lvarchar 40 1 > > > > 10 > > blob 41 4 > > > > 11 > > clob 41 4 > > > > in my test, the alignment is not static, like the alignment of blob could > > be 1 or 4 in different table in same database. > > > > So my question is "is there a table defined each column of a table's > > alignment length?", or "how alignments used? " > > > > regards. > > > > BlackThought > > > > --e89a8f23458f816f3504ba6b0d27 > > > > > > > > > > ******************************************************************************* > > > > Forum Note: Use "Reply" to post a response in the discussion forum. > > > > > > > > > > ******************************************************************************* > > Forum Note: Use "Reply" to post a response in the discussion forum. > > > > > > --f46d0401fceddd1eab04ba79bd6c > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --14dae9340cbdac0e0e04ba7cb6af