List:General Discussion« Previous MessageNext Message »
From:James Manning Date:September 15 1999 3:02pm
Subject:Re: How to delete a member from a SET column
View as plain text  
[ Wednesday, September 15, 1999 ] Martin Ramsch wrote:
> Yea, I also think SET handling still is very rough.

Too true...

> The best I can think of, as things are now up to MySQL V3.23.3,
> is to deal with the numerical values of set members and then use
> bit arithmetik.

sure, but I'd rather be able to abstract away like some kind of
to_num('element') that will keep you from having to deal with the bits
at the application (since this would mean, in perl for instance, possibly
making sure you can have some kind of 64-bit value available)

> If you know all the names of allowed list members, I suggest you first
> get their numerical values with the help of 'DESCRIBE table'.
> (I don't understand your argument above against this approach, though.)

could you post a little perl to do such?  it'd be nice to see how its done.

> Then, with the numerical values, it's easy to delete/add elements
> from/to a set:
> 
> adding an element:
>    UPDATE settable SET setfield = setfield | elementvalue;

I'd rather do 
   UPDATE settable SET setfield = setfield | to_num('element');
or
   UPDATE settable SET_BIT(setfield,'element');
:)

> deleting an element:
>    UPDATE settable SET setfield = setfield - (setfield & elementvalue);
>    (it's this complicated, because there's no bitwise not operator)

or if you happen to *know* its set, I guess you could xor if there's
support for such a beast

> > UPDATE test SET field=STRIP(field, 'one', 'two');
> > 
> > (or STRIP(field, 'one,two')) 
> > would be nice (choose whatever name you like for STRIP).
> 
> Yea, sounds like good an idea!

Sounds like something that at least stored procedures would allow you
to hack in... forcing applications to deal with how MySQL chooses to
handle sets sure seems to expose more underlying implementation to the
application than one would/should feel comfortable with :)

James
-- 
Miscellaneous Engineer --- IBM Netfinity Performance Development
Thread
How to delete a member from a SET columnBenjamin Pflugmann7 Jul
  • Re: How to delete a member from a SET columnMartin Ramsch15 Sep
    • Re: How to delete a member from a SET columnJames Manning15 Sep
      • Re: How to delete a member from a SET columnMartin Ramsch16 Sep
        • Re: How to delete a member from a SET columnMartin Ramsch16 Sep
          • Re: How to delete a member from a SET columnJames Manning17 Sep
            • Re: How to delete a member from a SET columnMartin Ramsch17 Sep
              • Re: How to delete a member from a SET columnJames Manning17 Sep
                • Re: How to delete a member from a SET columnMartin Ramsch17 Sep
                  • placeholdersjice17 Sep
                    • Re: placeholdersBob Kline17 Sep
                  • Re: How to delete a member from a SET columnJames Manning17 Sep
        • Re: How to delete a member from a SET columnJames Manning17 Sep
          • Re: How to delete a member from a SET columnMartin Ramsch17 Sep