dbTalk Databases Forums  

[PATCH] Re: equal_list() using a bool vector

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss [PATCH] Re: equal_list() using a bool vector in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chris Frey
 
Posts: n/a

Default [PATCH] Re: equal_list() using a bool vector - 05-10-2005 , 03:14 PM






On Tue, May 10, 2005 at 11:10:31AM -0600, Warren Young wrote:
Quote:
Also, can you explain what you found in the library that prevented your
example code from working in the first place? I.e., precisely what
problem this patch solves?
From my research, there is a problem in custom.pl, on line 603 (in 1.7.34)
.... there is a template member function that has no definition in the
rest of the header. Specifically:

template <class Manip>
NAME##_cus_equal_list<Manip> equal_list(cchar *d, cchar *c, Manip m,
std::vector<bool> *i) const;

Mark found some more.


Quote:
An example of using it....

vector<bool> a(5, false);
a[stock_weight] = true;
a[stock_price] = true;
query << "SELECT * FROM stock WHERE " << q.equal_list(" AND ",
&a);
This example tickles the bug, since equal_list(cchar*, vector<bool>*)
calls the above missing member function.

Below is Mark's patch, diff-ified, plus some warning fixes for out-of-order
constructor arguments (gcc complains about this regularly). I ran the simple
example which I also included in this patch. If Mark could retest this,
that would be great.

- Chris


Index: software/mysql++/examples/custom1.cpp
diff -u software/mysql++/examples/custom1.cpp:1.1.1.2 software/mysql++/examples/custom1.cpp:1.2
--- software/mysql++/examples/custom1.cpp:1.1.1.2 Thu Mar 3 23:27:00 2005
+++ software/mysql++/examples/custom1.cpp Tue May 10 16:08:02 2005
@@ -43,6 +43,17 @@
// this is storing the results into a vector of the custom struct
// "stock" which was created my the macro above.

+ {
+ Query query = con.query();
+ vector<bool> a(5, false);
+ a[stock_weight] = true;
+ a[stock_price] = true;
+ query << "select * from stock where " <<
+ res[0].equal_list(" and ", &a);
+ cout << "Test query:" << endl;
+ cout << query.preview() << endl;
+ }
+
cout.setf(ios::left);
cout << setw(17) << "Item"
<< setw(4) << "Num"
Index: software/mysql++/lib/custom.pl
diff -u software/mysql++/lib/custom.pl:1.7 software/mysql++/lib/custom.pl:1.9
--- software/mysql++/lib/custom.pl:1.7 Mon May 2 06:25:53 2005
+++ software/mysql++/lib/custom.pl Tue May 10 16:08:02 2005
@@ -376,10 +376,10 @@
const NAME##_cus_value_list<Manip>&); */
public:
const NAME *obj;
- cchar *delem;
- Manip manip;
std::vector<bool> *include;
bool del_vector;
+ cchar *delem;
+ Manip manip;
public:
~NAME##_cus_value_list () {if (del_vector) delete include;}
NAME##_cus_value_list (const NAME *o, cchar *d, Manip m, $cusparms11);
@@ -394,10 +394,10 @@
const NAME##_cus_field_list<Manip>&); */
public:
const NAME *obj;
- cchar *delem;
- Manip manip;
std::vector<bool> *include;
bool del_vector;
+ cchar *delem;
+ Manip manip;
public:
~NAME##_cus_field_list () {if (del_vector) delete include;}
NAME##_cus_field_list (const NAME *o, cchar *d, Manip m, $cusparms11);
@@ -772,6 +772,24 @@
}

template <class Manip>
+ inline NAME##_cus_value_list<Manip> NAME::value_list(cchar *d, Manip m,
+ std::vector<bool> *i) const {
+ return NAME##_cus_value_list<Manip> (this, d, m, i);
+ }
+
+ template <class Manip>
+ inline NAME##_cus_field_list<Manip> NAME::field_list(cchar *d, Manip m,
+ std::vector<bool> *i) const {
+ return NAME##_cus_field_list<Manip> (this, d, m, i);
+ }
+
+ template <class Manip>
+ inline NAME##_cus_equal_list<Manip> NAME::equal_list(cchar *d, cchar *c, Manip m,
+ std::vector<bool> *i) const {
+ return NAME##_cus_equal_list<Manip> (this, d, c, m, i);
+ }
+
+ template <class Manip>
inline NAME##_cus_value_list<Manip>
NAME::value_list(cchar *d, Manip m, sql_cmp_type /*sc*/) const {
sql_compare_type_def_##CMP (NAME, value, NUM);


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: [PATCH] Re: equal_list() using a bool vector - 05-10-2005 , 03:35 PM






Chris Frey wrote:

Quote:
... there is a template member function that has no definition in the
rest of the header. Specifically:
Thank you for the explanation.

Quote:
Below is Mark's patch, diff-ified,
Thanks again.

Quote:
plus some warning fixes for out-of-order
constructor arguments
This is good to fix, but you should to do it by reordering the
initializer list, not by reordering the member declarations. I don't
think it's an ABI breakage to make the change as you have, but it is
needless.

Quote:
Index: software/mysql++/examples/custom1.cpp
I'd rather that you created a new example, rather than modify
custom1.cpp. Disk space is cheap; adding custom5.cpp won't be a problem.

Quote:
+ a[stock_weight] = true;
+ a[stock_price] = true;
I retract my wish for bare constants here. I didn't realize that
custom.h defined these constants for you. It will be good to document
this in an example.

Last but not least, can we get a DocBook comment for the new functions?
I'm going to request this increasingly, so you all might as well get
used to it. I'm not going to have all that hard work in the new
docs go to waste by letting them slip back into irrelevancy.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Chris Frey
 
Posts: n/a

Default Re: [PATCH] Re: equal_list() using a bool vector - 05-10-2005 , 04:06 PM



On Tue, May 10, 2005 at 02:35:42PM -0600, Warren Young wrote:
Quote:
plus some warning fixes for out-of-order
constructor arguments

This is good to fix, but you should to do it by reordering the
initializer list, not by reordering the member declarations. I don't
think it's an ABI breakage to make the change as you have, but it is
needless.
I thought that at first too, but then I noticed there were other instances
of the same type of constructor, with variables in different order.
I figured if someone else was going to wade through custom.pl, it might help
to have constructor lists in the same order, for grep reasons.


Quote:
Index: software/mysql++/examples/custom1.cpp

I'd rather that you created a new example, rather than modify
custom1.cpp. Disk space is cheap; adding custom5.cpp won't be a problem.
Agreed.


Quote:
+ a[stock_weight] = true;
+ a[stock_price] = true;

I retract my wish for bare constants here. I didn't realize that
custom.h defined these constants for you. It will be good to document
this in an example.
Thanks to Mark for showing this in his example. I had no idea either.


Quote:
Last but not least, can we get a DocBook comment for the new functions?
I'm going to request this increasingly, so you all might as well get
used to it. I'm not going to have all that hard work in the new
docs go to waste by letting them slip back into irrelevancy.
I hope to do my share adding Doxygen comments wherever possible. Doxygen
isn't really possible in custom.pl, as far as I know.

For DocBook, I assume straight patches to doc/userman/userman.xml are
the preferred format? I haven't finished reading it all, so
don't feel qualified to change it yet. :-)

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Mark Merendino
 
Posts: n/a

Default RE: [PATCH] Re: equal_list() using a bool vector - 05-11-2005 , 07:51 AM



=20
Quote:
... there is a template member function that has no definition in the=20
rest of the header. Specifically:
Chris, Thanks for explaining that.

Quote:
Below is Mark's patch, diff-ified,
Chris, Thanks for doing this.

To all, sorry I have not presented things in the form that is expected.
I am new to this list and still learning how you would like to see
patches presented. I will catch on soon. Sorry.

Quote:
+ a[stock_weight] =3D true;
+ a[stock_price] =3D true;
=20
I retract my wish for bare constants here. I didn't realize that=20
custom.h defined these constants for you. It will be good to document

this in an example.
I learned about the equal_list() function and the constants from section
7.7 of the old document. Personally I find them very useful, but I
believe they were removed in the new document. My suggestion would to
be to add back in the info and examples that were previously in section
7.7. Maybe just updated a bit or something.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #5  
Old   
Warren Young
 
Posts: n/a

Default Re: [PATCH] Re: equal_list() using a bool vector - 05-11-2005 , 01:53 PM



Chris Frey wrote:
Quote:
I thought that at first too, but then I noticed there were other instances
of the same type of constructor, with variables in different order.
Hmmm, okay, I buy that. I'm going to accept it provisionally, on the
condition that it doesn't break my existing binaries.

Quote:
Doxygen isn't really possible in custom.pl, as far as I know.
Instruction to self: open mouth, insert foot.

Sorry, I wasn't thinking when I wrote that. The sentiment is still
valid, though.

Quote:
For DocBook, I assume straight patches to doc/userman/userman.xml are
the preferred format?
Yes, that's the source file. See the README file in that directory for
sources of information on DocBook. It really isn't all that different
from HTML, so if you know that, the learning curve should be pretty shallow.

Quote:
I haven't finished reading it all, so
don't feel qualified to change it yet. :-)
I won't be asking as much for changes to the userman as to the refman.
"Voice" is important in the userman, so it there should be as few
fingers as practical in that pie. In the refman, it's just a recounting
of hard facts using a well-defined format, so there are few style
concerns with it.

Don't worry about documenting custom5. I'll handle that.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #6  
Old   
Chris Frey
 
Posts: n/a

Default Re: [PATCH] Re: equal_list() using a bool vector - 05-11-2005 , 03:35 PM



On Wed, May 11, 2005 at 08:51:52AM -0400, Mark Merendino wrote:
Quote:
Below is Mark's patch, diff-ified,

Chris, Thanks for doing this.

To all, sorry I have not presented things in the form that is expected.
I am new to this list and still learning how you would like to see
patches presented. I will catch on soon. Sorry.
No worries, you did the bulk of the brain work on that. :-)

You probably know this by now, but "diff -ruN mysql++-olddir mysql++-newdir"
is your friend.

I actually use CVS to keep track of all this, which uses less disk space.
Every time a new tarball comes out, I import it on the vendor branch like
this:

cvs -d /home/cvs import -m "Version 1.7.35" software/mysql++ \
mysql++ mysql++-1_7_35

Update HEAD like this:

cd mysql++
cvs update -PdA
cvs update -j HEAD -j mysql++-1_7_35 -Pd
cvs ci -m "merged 1.7.35 into HEAD"
cvs tag mysql++-1_7_35-merged

Then any changes I make can easily be tracked, and diffs can be produced
with rdiff.

vi lib/custom.pl
cvs ci -m "Mark Merendino's equal_list() fix"
cvs tag mysql++-1_7_35-equal_list
cvs rdiff -u -r mysql++-1_7_35 -r mysql++-1_7_35_equal_list \
$(cat CVS/Repository) > equal_list.patch

This may all change when Warren goes to a public subversion repository,
but it works well for me, and I have it all on my local machine.

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #7  
Old   
Warren Young
 
Posts: n/a

Default Re: [PATCH] Re: equal_list() using a bool vector - 05-11-2005 , 04:08 PM



Chris Frey wrote:

Quote:
You probably know this by now, but "diff -ruN mysql++-olddir mysql++-newdir"
etc...

I've added this information to the HACKERS file. Thanks for taking the
time to write it up, Chris!

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.