dbTalk Databases Forums  

Patch for custom.pl

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


Discuss Patch for custom.pl in the mailing.database.mysql-plusplus forum.



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

Default Patch for custom.pl - 02-02-2006 , 01:21 AM






--R3G7APHDIzY6R/pk
Content-Type: multipart/mixed; boundary="82I3+IH0IqGh5yIs"
Content-Disposition: inline


--82I3+IH0IqGh5yIs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

During the investigation of some SSQLS problem, I noticed that the
custom.pl script generated unnecessary code for the set() functions, due
to the $set variable not being emptied after a pass. Have a look at your
custom-macros.h, look for "Begin Compare 3" and you'll notice that the
elements 1,1,2,1,2,3 are being assigned, instead of just 1,2,3.

While at it, I did some other changes, here is the summary:
- Reset $set.
- Have custom.pl work in strict+warning mode.
- Generate sql_cmp() for unsigned long and long too. Pros: I saw no=20
reason not to include them, and it allows to have long fields in=20
SQLSS structures.

All in all, nothing critical - for now. I'm indeed preparing a patch
that lets one have nullable fields in a SQLSS struct...

Best regards,
-Waba.

--82I3+IH0IqGh5yIs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="custom.patch"
Content-Transfer-Encoding: quoted-printable

--- ./mysql++-2.0.7/lib/custom.pl 2006-02-01 22:13:35.000000000 +0100
+++ custom.pl 2006-02-01 23:17:30.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
=20
################################################## ######################
# custom.pl - Generates custom.h and custom-macros.h, as these files
@@ -38,6 +38,8 @@
=20
# No user-serviceable parts below.
=20
+use strict;
+
open (OUT0, ">custom.h");
open (OUT, ">custom-macros.h");
=20
@@ -65,9 +67,9 @@
}
---
=20
-@types =3D ("char", "unsigned char", "tiny_int", "int", "unsigned int",
- "short int", "unsigned short int");
-foreach $type (@types) {
+my @types =3D ("char", "unsigned char", "tiny_int", "int", "unsigned int",
+ "short int", "unsigned short int", "unsigned long", "long");
+foreach my $type (@types) {
print OUT0 << "---";
=20
inline int sql_cmp($type a,$type b) {
@@ -77,7 +79,7 @@
}
=20
@types =3D ("double", "float");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
=20
inline int sql_cmp($type a,$type b) {
@@ -89,7 +91,7 @@
}=09
=20
@types =3D ("longlong", "ulonglong");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
=20
inline int sql_cmp($type a,$type b) {
@@ -140,7 +142,9 @@
{return sql_compare_##NAME<mysqlpp::sql_dummy>(*this,other );}
---
=20
-foreach $j (1..$max_data_members) {
+my ($parm0, $parm1);
+
+foreach my $j (1..$max_data_members) {
$parm0 .=3D "T$j, C$j";
$parm0 .=3D ", " unless $j =3D=3D $max_data_members;
$parm1 .=3D "C$j";
@@ -166,11 +170,14 @@
// ---------------------------------------------------
---
=20
-foreach $i (1..$max_data_members) {
+
+foreach my $i (1..$max_data_members) {
+ my ($compr, $define, $compp, $set, $parm2);
$compr =3D ""; $parm2 =3D ""; $define =3D "";
$compr =3D " int cmp; \\\n" unless $i =3D=3D 1;
$compp =3D "";
- foreach $j (1..$i) {
+ $set =3D "";
+ foreach my $j (1..$i) {
$compr .=3D " if (cmp =3D mysqlpp::sql_cmp(x.C$j , y.C$j )) retur=
n cmp; \\\n"
unless $j =
=3D=3D $i;
$compr .=3D " return mysqlpp::sql_cmp(x.C$j , y.C$j );" if $j =
=3D=3D $i;
@@ -228,20 +235,20 @@
---
=20
=20
-foreach $i (1..$max_data_members) {
- $parm_complete =3D "";=20
- $parm_order =3D ""; $parm_order2c =3D "";
- $parm_simple =3D ""; $parm_simple2c =3D "";
- $parm_simple_b =3D ""; $parm_simple2c_b =3D "";
- $parm_names =3D ""; $parm_names2c =3D "";
- $defs =3D ""; $popul =3D ""; $parmc =3D ""; $parmC =3D "";
- $value_list =3D ""; $field_list =3D ""; $equal_list =3D "";
- $value_list_cus =3D ""; $cus_field_list =3D ""; $cus_equal_list =3D "";
- $create_bool =3D ""; $create_list =3D "";
- $cusparms1 =3D ""; $cusparms2 =3D ""; $cusparmsv =3D ""; =20
- $cusparms11 =3D ""; $cusparms22 =3D "";
- $names =3D "";$enums =3D "";
- foreach $j (1 .. $i) {
+foreach my $i (1..$max_data_members) {
+ my $parm_complete =3D "";=20
+ my $parm_order =3D ""; my $parm_order2c =3D "";
+ my $parm_simple =3D ""; my $parm_simple2c =3D "";
+ my $parm_simple_b =3D ""; my $parm_simple2c_b =3D "";
+ my $parm_names =3D ""; my $parm_names2c =3D "";
+ my $defs =3D ""; my $popul =3D ""; my $parmc =3D ""; my $parmC =3D "";
+ my $value_list =3D ""; my $field_list =3D ""; my $equal_list =3D "";
+ my $value_list_cus =3D ""; my $cus_field_list =3D ""; my $cus_equal_li=
st =3D "";
+ my $create_bool =3D ""; my $create_list =3D "";
+ my $cusparms1 =3D ""; my $cusparms2 =3D ""; my $cusparmsv =3D ""; =
=20
+ my $cusparms11 =3D ""; my $cusparms22 =3D "";
+ my $names =3D "";my $enums =3D "";
+ foreach my $j (1 .. $i) {
$parm_complete .=3D "T$j, I$j, N$j, O$j";
$parm_complete .=3D ", " unless $j =3D=3D $i;
$parm_order .=3D "T$j, I$j, O$j";
@@ -315,7 +322,7 @@
$parmc .=3D "I$j";
$parmc .=3D ", " unless $j =3D=3D $max_data_members;
}
- foreach $j ($i+1 .. $max_data_members) {
+ foreach my $j ($i+1 .. $max_data_members) {
$parmC .=3D "0, 0";
$parmC .=3D ", " unless $j =3D=3D $max_data_members;
$parmc .=3D "0";
@@ -327,7 +334,7 @@
// Begin Create $i
// ---------------------------------------------------
---
- $out =3D <<"---";
+ my $out =3D <<"---";
#define sql_create_basic_c_order_$i(NAME, CMP, CONTR, $parm_order)
=20
struct NAME;=20
@@ -878,7 +885,7 @@
=20
=20
sub prepare {
- local $_ =3D @_[0];
+ local $_ =3D $_[0];
s/\n+$//;
s/\n[\n ]*\n/\n/g;=20
s/\n+/\\\n/g;

--82I3+IH0IqGh5yIs--

--R3G7APHDIzY6R/pk
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD4TRfUQHbkgA+2bIRAmI9AJ0QDA/uvx815enREoU+F+A/GJvzWgCfYBry
UP1BlMi8Sj04HY1N2UULkxg=
=p5bJ
-----END PGP SIGNATURE-----

--R3G7APHDIzY6R/pk--

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

Default Re: Patch for custom.pl - 02-02-2006 , 05:14 AM






Waba wrote:
Quote:
While at it, I did some other changes, here is the summary:
- Reset $set.
- Have custom.pl work in strict+warning mode.
- Generate sql_cmp() for unsigned long and long too. Pros: I saw no
reason not to include them, and it allows to have long fields in
SQLSS structures.
Can you please split this up into three separate patches? When you have
three separate things going on in a single patch, it is hard to evaluate
it. If I did accept it as-is, it would also make the svn change history
more convoluted.

I don't see anything preventing inclusion other than that, but of course
I'll need to reevaluate it once I can see the trees instead of the forest.

--
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   
Waba
 
Posts: n/a

Default Re: Patch for custom.pl - 02-02-2006 , 06:48 AM



--Fba/0zbH8Xs+Fj9o
Content-Type: multipart/mixed; boundary="wac7ysb48OaltWcw"
Content-Disposition: inline


--wac7ysb48OaltWcw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Feb 02, 2006 at 04:14:18AM -0700, Warren Young wrote:
Quote:
Can you please split this up into three separate patches? When you have=
=20
three separate things going on in a single patch, it is hard to evaluate=
=20
it. If I did accept it as-is, it would also make the svn change history=
=20
more convoluted.
Ok, I understand. Here are the three patches, expected to be applied in
this order:
- custom01.patch makes custom.pl work in strict+warning mode.
- custom12.patch empties $set after each pass, preventing unnecessary
code from being generated.
- custom23.patch makes custom.pl generate sql_cmp() functions for long
fields.


On a related topic, I noticed that (as mentioned in my previous post)
there was no way to use nullable fields in SSQLS structures, so I am
preparing a patch that lets one use the Null<> template in there. It
surprises me, however, that, first, this feature is lacking, and next,
that it only returns a few matches in the list's archives. Did I miss
something obvious?


Best regards,
-Waba.

--wac7ysb48OaltWcw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="custom01.patch"
Content-Transfer-Encoding: quoted-printable

This patch makes custom.pl work in strict+warning mode.

--- custom0.pl 2006-02-02 13:14:22.000000000 +0100
+++ custom1.pl 2006-02-02 13:15:21.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
=20
################################################## ######################
# custom.pl - Generates custom.h and custom-macros.h, as these files
@@ -38,6 +38,8 @@
=20
# No user-serviceable parts below.
=20
+use strict;
+
open (OUT0, ">custom.h");
open (OUT, ">custom-macros.h");
=20
@@ -65,9 +67,9 @@
}
---
=20
-@types =3D ("char", "unsigned char", "tiny_int", "int", "unsigned int",
+my @types =3D ("char", "unsigned char", "tiny_int", "int", "unsigned int",
"short int", "unsigned short int");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
=20
inline int sql_cmp($type a,$type b) {
@@ -77,7 +79,7 @@
}
=20
@types =3D ("double", "float");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
=20
inline int sql_cmp($type a,$type b) {
@@ -89,7 +91,7 @@
}=09
=20
@types =3D ("longlong", "ulonglong");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
=20
inline int sql_cmp($type a,$type b) {
@@ -140,7 +142,9 @@
{return sql_compare_##NAME<mysqlpp::sql_dummy>(*this,other );}
---
=20
-foreach $j (1..$max_data_members) {
+my ($parm0, $parm1);
+
+foreach my $j (1..$max_data_members) {
$parm0 .=3D "T$j, C$j";
$parm0 .=3D ", " unless $j =3D=3D $max_data_members;
$parm1 .=3D "C$j";
@@ -166,11 +170,13 @@
// ---------------------------------------------------
---
=20
-foreach $i (1..$max_data_members) {
+
+foreach my $i (1..$max_data_members) {
+ my ($compr, $define, $compp, $set, $parm2);
$compr =3D ""; $parm2 =3D ""; $define =3D "";
$compr =3D " int cmp; \\\n" unless $i =3D=3D 1;
$compp =3D "";
- foreach $j (1..$i) {
+ foreach my $j (1..$i) {
$compr .=3D " if (cmp =3D mysqlpp::sql_cmp(x.C$j , y.C$j )) retur=
n cmp; \\\n"
unless $j =
=3D=3D $i;
$compr .=3D " return mysqlpp::sql_cmp(x.C$j , y.C$j );" if $j =
=3D=3D $i;
@@ -228,20 +234,20 @@
---
=20
=20
-foreach $i (1..$max_data_members) {
- $parm_complete =3D "";=20
- $parm_order =3D ""; $parm_order2c =3D "";
- $parm_simple =3D ""; $parm_simple2c =3D "";
- $parm_simple_b =3D ""; $parm_simple2c_b =3D "";
- $parm_names =3D ""; $parm_names2c =3D "";
- $defs =3D ""; $popul =3D ""; $parmc =3D ""; $parmC =3D "";
- $value_list =3D ""; $field_list =3D ""; $equal_list =3D "";
- $value_list_cus =3D ""; $cus_field_list =3D ""; $cus_equal_list =3D "";
- $create_bool =3D ""; $create_list =3D "";
- $cusparms1 =3D ""; $cusparms2 =3D ""; $cusparmsv =3D ""; =20
- $cusparms11 =3D ""; $cusparms22 =3D "";
- $names =3D "";$enums =3D "";
- foreach $j (1 .. $i) {
+foreach my $i (1..$max_data_members) {
+ my $parm_complete =3D "";=20
+ my $parm_order =3D ""; my $parm_order2c =3D "";
+ my $parm_simple =3D ""; my $parm_simple2c =3D "";
+ my $parm_simple_b =3D ""; my $parm_simple2c_b =3D "";
+ my $parm_names =3D ""; my $parm_names2c =3D "";
+ my $defs =3D ""; my $popul =3D ""; my $parmc =3D ""; my $parmC =3D "";
+ my $value_list =3D ""; my $field_list =3D ""; my $equal_list =3D "";
+ my $value_list_cus =3D ""; my $cus_field_list =3D ""; my $cus_equal_li=
st =3D "";
+ my $create_bool =3D ""; my $create_list =3D "";
+ my $cusparms1 =3D ""; my $cusparms2 =3D ""; my $cusparmsv =3D ""; =
=20
+ my $cusparms11 =3D ""; my $cusparms22 =3D "";
+ my $names =3D "";my $enums =3D "";
+ foreach my $j (1 .. $i) {
$parm_complete .=3D "T$j, I$j, N$j, O$j";
$parm_complete .=3D ", " unless $j =3D=3D $i;
$parm_order .=3D "T$j, I$j, O$j";
@@ -315,7 +321,7 @@
$parmc .=3D "I$j";
$parmc .=3D ", " unless $j =3D=3D $max_data_members;
}
- foreach $j ($i+1 .. $max_data_members) {
+ foreach my $j ($i+1 .. $max_data_members) {
$parmC .=3D "0, 0";
$parmC .=3D ", " unless $j =3D=3D $max_data_members;
$parmc .=3D "0";
@@ -327,7 +333,7 @@
// Begin Create $i
// ---------------------------------------------------
---
- $out =3D <<"---";
+ my $out =3D <<"---";
#define sql_create_basic_c_order_$i(NAME, CMP, CONTR, $parm_order)
=20
struct NAME;=20
@@ -878,7 +884,7 @@
=20
=20
sub prepare {
- local $_ =3D @_[0];
+ local $_ =3D $_[0];
s/\n+$//;
s/\n[\n ]*\n/\n/g;=20
s/\n+/\\\n/g;

--wac7ysb48OaltWcw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="custom12.patch"
Content-Transfer-Encoding: quoted-printable

This patch empties $set after each pass, preventing unnecessary code from=
=20
being generated.

--- custom1.pl 2006-02-02 13:15:21.000000000 +0100
+++ custom2.pl 2006-02-02 13:15:54.000000000 +0100
@@ -176,6 +176,7 @@
$compr =3D ""; $parm2 =3D ""; $define =3D "";
$compr =3D " int cmp; \\\n" unless $i =3D=3D 1;
$compp =3D "";
+ $set =3D "";
foreach my $j (1..$i) {
$compr .=3D " if (cmp =3D mysqlpp::sql_cmp(x.C$j , y.C$j )) retur=
n cmp; \\\n"
unless $j =
=3D=3D $i;

--wac7ysb48OaltWcw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="custom23.patch"
Content-Transfer-Encoding: quoted-printable

This patch makes custom.pl generate sql_cmp() functions for long fields.

--- custom2.pl 2006-02-02 13:15:54.000000000 +0100
+++ custom3.pl 2006-02-02 13:16:13.000000000 +0100
@@ -68,7 +68,7 @@
---
=20
my @types =3D ("char", "unsigned char", "tiny_int", "int", "unsigned int",
- "short int", "unsigned short int");
+ "short int", "unsigned short int", "unsigned long", "long");
foreach my $type (@types) {
print OUT0 << "---";
=20

--wac7ysb48OaltWcw--

--Fba/0zbH8Xs+Fj9o
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD4f+9UQHbkgA+2bIRAlWkAJ9MkThgTjVTtP6W2n/VQQIlO9U/JACdElJU
LHiJn3l9twmymlnGPqRMb6A=
=+p4U
-----END PGP SIGNATURE-----

--Fba/0zbH8Xs+Fj9o--


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

Default Re: Patch for custom.pl - 02-02-2006 , 10:15 AM



On Thu, Feb 02, 2006 at 01:49:02PM +0100, Waba wrote:
Quote:
Ok, I understand. Here are the three patches, expected to be applied in
this order:
- custom01.patch makes custom.pl work in strict+warning mode.
- custom12.patch empties $set after each pass, preventing unnecessary
code from being generated.
These look good to me. Good catch.


Quote:
- custom23.patch makes custom.pl generate sql_cmp() functions for long
fields.
One reason for this could be that on 32 bit architectures, long is 4 bytes,
and not enough to hold the assumed BIGINT type, according to:

http://dev.mysql.com/doc/refman/5.1/...ric-types.html

Each data type in an SSQLS struct must be large enough to hold its
corresponding SQL field type. On 32 bit machines, long is redundant.


For your upcoming changes you mentioned, if you happen to have any test
code for your new features, please toss it in examples/ and include it in
your patch set too.

- 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
  #5  
Old   
Warren Young
 
Posts: n/a

Default Re: Patch for custom.pl - 03-04-2006 , 02:41 AM



Waba wrote:
Quote:
Ok, I understand. Here are the three patches, expected to be applied in
this order:
Thanks for your patches. They will appear in v2.1.0.alpha3.

--
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.