Exemplo n.º 1
0
        public int WriteText(string value)
        {
            long begin = LengthCheckReset();

            unsafe
            {
#if !WIN32
                PqsqlUTF8Statement.SetText(mExpBuf, value);
#else
                fixed(char *sp = value)
                {
                    PqsqlBinaryFormat.pqbf_set_unicode_text(mExpBuf, sp);
                }
#endif
                long end = PqsqlBinaryFormat.pqbf_get_buflen(mExpBuf);
                long len = end - begin;

                sbyte *val = PqsqlBinaryFormat.pqbf_get_bufval(mExpBuf) + begin;
                return(PutColumn(val, (uint)len));
            }
        }
Exemplo n.º 2
0
        // adds o as string array element to PQExpBuffer a
        internal static void SetTextArray(IntPtr a, object o)
        {
            string v = (string)o;

            long len0 = PqsqlBinaryFormat.pqbf_get_buflen(a);             // get start position

            PqsqlBinaryFormat.pqbf_set_array_itemlength(a, -2);           // first set an invalid item length

#if !WIN32
            PqsqlUTF8Statement.SetText(a, v);
#else
            unsafe
            {
                fixed(char *t = v)
                {
                    PqsqlBinaryFormat.pqbf_set_unicode_text(a, t);                     // encode text value (variable length)
                }
            }
#endif

            int len = (int)(PqsqlBinaryFormat.pqbf_get_buflen(a) - len0);              // get new buffer length
            // update array item length == len - 4 bytes
            PqsqlBinaryFormat.pqbf_update_array_itemlength(a, -len, len - 4);
        }