On Thu, Feb 02, 2006 at 04:14:18AM -0700, Warren Young wrote:
> 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.
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.
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
########################################################################
# custom.pl - Generates custom.h and custom-macros.h, as these files
@@ -38,6 +38,8 @@
# No user-serviceable parts below.
+use strict;
+
open (OUT0, ">custom.h");
open (OUT, ">custom-macros.h");
@@ -65,9 +67,9 @@
}
---
-@types = ("char", "unsigned char", "tiny_int", "int", "unsigned int",
+my @types = ("char", "unsigned char", "tiny_int", "int", "unsigned int",
"short int", "unsigned short int");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
inline int sql_cmp($type a,$type b) {
@@ -77,7 +79,7 @@
}
@types = ("double", "float");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
inline int sql_cmp($type a,$type b) {
@@ -89,7 +91,7 @@
}
@types = ("longlong", "ulonglong");
-foreach $type (@types) {
+foreach my $type (@types) {
print OUT0 << "---";
inline int sql_cmp($type a,$type b) {
@@ -140,7 +142,9 @@
{return sql_compare_##NAME<mysqlpp::sql_dummy>(*this,other);}
---
-foreach $j (1..$max_data_members) {
+my ($parm0, $parm1);
+
+foreach my $j (1..$max_data_members) {
$parm0 .= "T$j, C$j";
$parm0 .= ", " unless $j == $max_data_members;
$parm1 .= "C$j";
@@ -166,11 +170,13 @@
// ---------------------------------------------------
---
-foreach $i (1..$max_data_members) {
+
+foreach my $i (1..$max_data_members) {
+ my ($compr, $define, $compp, $set, $parm2);
$compr = ""; $parm2 = ""; $define = "";
$compr = " int cmp; \\\n" unless $i == 1;
$compp = "";
- foreach $j (1..$i) {
+ foreach my $j (1..$i) {
$compr .= " if (cmp = mysqlpp::sql_cmp(x.C$j , y.C$j )) return cmp; \\\n"
unless $j == $i;
$compr .= " return mysqlpp::sql_cmp(x.C$j , y.C$j );" if $j == $i;
@@ -228,20 +234,20 @@
---
-foreach $i (1..$max_data_members) {
- $parm_complete = "";
- $parm_order = ""; $parm_order2c = "";
- $parm_simple = ""; $parm_simple2c = "";
- $parm_simple_b = ""; $parm_simple2c_b = "";
- $parm_names = ""; $parm_names2c = "";
- $defs = ""; $popul = ""; $parmc = ""; $parmC = "";
- $value_list = ""; $field_list = ""; $equal_list = "";
- $value_list_cus = ""; $cus_field_list = ""; $cus_equal_list = "";
- $create_bool = ""; $create_list = "";
- $cusparms1 = ""; $cusparms2 = ""; $cusparmsv = "";
- $cusparms11 = ""; $cusparms22 = "";
- $names = "";$enums = "";
- foreach $j (1 .. $i) {
+foreach my $i (1..$max_data_members) {
+ my $parm_complete = "";
+ my $parm_order = ""; my $parm_order2c = "";
+ my $parm_simple = ""; my $parm_simple2c = "";
+ my $parm_simple_b = ""; my $parm_simple2c_b = "";
+ my $parm_names = ""; my $parm_names2c = "";
+ my $defs = ""; my $popul = ""; my $parmc = ""; my $parmC = "";
+ my $value_list = ""; my $field_list = ""; my $equal_list = "";
+ my $value_list_cus = ""; my $cus_field_list = ""; my $cus_equal_list = "";
+ my $create_bool = ""; my $create_list = "";
+ my $cusparms1 = ""; my $cusparms2 = ""; my $cusparmsv = "";
+ my $cusparms11 = ""; my $cusparms22 = "";
+ my $names = "";my $enums = "";
+ foreach my $j (1 .. $i) {
$parm_complete .= "T$j, I$j, N$j, O$j";
$parm_complete .= ", " unless $j == $i;
$parm_order .= "T$j, I$j, O$j";
@@ -315,7 +321,7 @@
$parmc .= "I$j";
$parmc .= ", " unless $j == $max_data_members;
}
- foreach $j ($i+1 .. $max_data_members) {
+ foreach my $j ($i+1 .. $max_data_members) {
$parmC .= "0, 0";
$parmC .= ", " unless $j == $max_data_members;
$parmc .= "0";
@@ -327,7 +333,7 @@
// Begin Create $i
// ---------------------------------------------------
---
- $out = <<"---";
+ my $out = <<"---";
#define sql_create_basic_c_order_$i(NAME, CMP, CONTR, $parm_order)
struct NAME;
@@ -878,7 +884,7 @@
sub prepare {
- local $_ = @_[0];
+ local $_ = $_[0];
s/\n+$//;
s/\n[\n ]*\n/\n/g;
s/\n+/\\\n/g;
This patch empties $set after each pass, preventing unnecessary code from
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 = ""; $parm2 = ""; $define = "";
$compr = " int cmp; \\\n" unless $i == 1;
$compp = "";
+ $set = "";
foreach my $j (1..$i) {
$compr .= " if (cmp = mysqlpp::sql_cmp(x.C$j , y.C$j )) return cmp; \\\n"
unless $j == $i;
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 @@
---
my @types = ("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 << "---";
Attachment: [application/pgp-signature] Digital signature signature.asc