Bit string help, please - Mailing list pgsql-sql

From tyrrill_ed@emc.com
Subject Bit string help, please
Date
Msg-id 4FB0C599D8D0B14FA37B46EAD92F2153036EEC5E@CORPUSMX60C.corp.emc.com
Whole thread Raw
Responses Re: Bit string help, please
List pgsql-sql
Hey PostgreSQL Gurus,

I am experimenting with PostgreSQL bit strings to see if they might help
with some performance issues I am having.  I added a "bit varying"
column to one of my tables.  I have a PL/pgSQL function with an insert
statement into this table.  For the bit varying column I would like to
insert a bit string of length n with the highest order bit being 1 and
all the other bits being 0.  Given a table definition:

create table table1 (  a int,  b bit varying
);

I hoped I could use the feature where casting right pads 0s to do
something like this:

insert into table1 values( DEFAULT, B'1'::bit( n ) );

Where n is one of the parameters to the PL/pgSQL function, but that
doesn't work.  PostgreSQL doesn't like having a variable for the bit
string length.  Does anyone have any ideas how I could achieve this?

Thanks,
Ed Tyrrill


pgsql-sql by date:

Previous
From: Jeff Frost
Date:
Subject: Re: finding columns that have three or fewer distinct characters
Next
From: "Yura Gal"
Date:
Subject: RETURN QUERY generates error