>>> On Tue, Nov 20, 2007 at 3:47 PM, in message <[EMAIL PROTECTED]>, Cade Cairns <[EMAIL PROTECTED]> wrote: > On 20-Nov-07, at 2:42 PM, Heikki Linnakangas wrote: >> >> http://www.postgresql.org/docs/8.1/interactive/datatype-bit.html >> >> "Note: If one explicitly casts a bit-string value to bit(n), it >> will be truncated or zero-padded on the right to be exactly n bits, >> without raising an error. Similarly, if one explicitly casts a bit- >> string value to bit varying(n), it will be truncated on the right if >> it is more than n bits." > > Can anyone explain why this is the case? That's the correct result, as I read the CAST specification in the ANSI standard; although I think this should generate a warning. d) If SD is fixed-length bit string or variable-length bit string, then let LSV be the value of BIT_LENGTH(SV) and let B be the BIT_LENGTH of the character with the smallest BIT_ LENGTH in the form-of-use of TD. Let PAD be the value of the remainder of the division LSV/B. Let NC be a character whose bits all have the value 0.
If PAD is not 0, then append (B - PAD) 0-valued bits to the least significant end of SV; a completion condition is raised: warning-implicit zero-bit padding. Let SVC be the possibly padded value of SV expressed as a character string without regard to valid character encodings and let LTDS be a character string of LTD characters of value NC characters in the form-of-use of TD. TV is the result of SUBSTRING (SVC | LTDS FROM 1 FOR LTD) Case: i) If the length of TV is less than the length of SVC, then a completion condition is raised: warning-string data, right truncation. ii) If the length of TV is greater than the length of SVC, then a completion condition is raised: warning-implicit zero-bit padding. -Kevin ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings