From: Michael Widenius Date: March 21 1999 12:07pm Subject: adding variables to 'mysql' program List-Archive: http://lists.mysql.com/mysql/710 Message-Id: <14068.57407.643977.275839@monty.pp.sci.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit >>>>> "Thimble" == Thimble Smith writes: Thimble> Hi. I've got an idea that it would be nice (and not too hard) to Thimble> add some notion of variables to the 'mysql' program. Then some Thimble> operations that have to be done in >2 queries would be a whole Thimble> lot easier to perform. It would obviate the need for writing a Thimble> throw-away script for one-time database fixes. Thimble> For example, I do one query that returns a list of IDs, and another Thimble> query to DELETE FROM table WHERE table_id IN (${stored list of ids}). Thimble> I know that sub-selects will make this example obselete, but does Thimble> something like this sound like a good idea? Does anyone have good Thimble> ideas about the syntax to use? If there is enough interest (and I Thimble> can figure out a good way to do it), I'll try to implement it (no Thimble> guarantees on time, though, 'cause ). Thimble> Tim Hi! Yes, this could be good idea (even if you have sub selects). The problem is what syntax to use for variables to distinguish them from column/table names. Tim, You can simply implement this by adding a hashed variable name list in the THD structure and some small modifications to: - sql/sql_lex.cc ; To parse variable names. - sql/sql_yacc.yy ; To convert a variable name to an Item - sql/item.cc ; Create an item to access variable names - sql/item.h ; Prototype for the Item_varible :) Regards, Monty