Commit 5c373a20 authored by monty@donna.mysql.com's avatar monty@donna.mysql.com

Merge work:/my/mysql into donna.mysql.com:/home/my/bk/mysql

parents f0ea0b79 728b63e0
......@@ -22,7 +22,7 @@ if [ "x$strip" = "xyes" ]
then
commands="$commands
mkdir tmp
mkdir -p tmp
nm --numeric-sort sql/mysqld > tmp/mysqld.sym
objdump -d sql/mysqld > tmp/mysqld.S
strip sql/mysqld"
......
......@@ -2990,18 +2990,21 @@ carefully and make sure that all the information described here is included
in your report.
@cindex bug reports, email address
If you can make a test case that clearly shows the bug, you should post
it to the @email{bugs@@lists.mysql.com} list. Note that on this list you
should only post a full, repeatable bug report using the @code{mysqlbug}
script. If you are running on Windows, you should include a
description of the operating system and the @strong{MySQL} version.
Preferably, you should test the problem using the latest stable or development
version of @strong{MySQL} before posting! Anyone should be able to repeat the
bug by just using ``@code{mysql test < script}'' on the included test case or
run the shell or perl script that is included in the bug report. All bugs
posted on this list will be corrected or documented in the next @strong{MySQL}
release! If there are only small code changes involved to correct this
problem, we will also post a patch that fixes the problem.
The normal plase to report bugs and problems is
@email{mysql@@lists.mysql.com}. If you can make a test case that clearly
shows the bug, you should post it to the @email{bugs@@lists.mysql.com}
list. Note that on this list you should only post a full, repeatable bug
report using the @code{mysqlbug} script. If you are running on Windows,
you should include a description of the operating system and the
@strong{MySQL} version. Preferably, you should test the problem using
the latest stable or development version of @strong{MySQL} before
posting! Anyone should be able to repeat the bug by just using
``@code{mysql test < script}'' on the included test case or run the
shell or perl script that is included in the bug report. All bugs
posted on the @code{bugs} list will be corrected or documented in the next
@strong{MySQL} release! If there are only small code changes involved
to correct this problem, we will also post a patch that fixes the
problem.
Remember that it is possible to respond to a message containing too much
information, but not to one containing too little. Often people omit facts
......@@ -3036,7 +3039,7 @@ It is most helpful when a good description of the problem is included in the
bug report. That is, a good example of all the things you did that led to
the problem and the problem itself exactly described. The best reports are
those that include a full example showing how to reproduce the bug or
problem.
problem. @xref{Reproducable test case}.
If a program produces an error message, it is very important to include the
message in your report! If we try to search for something from the archives
......@@ -3088,6 +3091,11 @@ If the problem occurs during compilation, include the exact error
message(s) and also a few lines of context around the offending code in the
file where the error occurred.
@item
If @code{mysqld} died, you should also report query that crashed
@code{mysqld}. You can usually find this out by running @code{mysqld} with
logging enabled. @xref{Using log files}.
@item
If any database table is related to the problem, include the output from
@code{mysqldump --no-data db_name tbl_name1 tbl_name2 ...}. This is very easy
......@@ -3121,15 +3129,27 @@ mysql> SHOW STATUS;
@end example
@item
If a bug or problem occurs while running @strong{MySQL}, try to provide an
If a bug or problem occurs while running @strong{mysqld}, try to provide an
input script that will reproduce the anomaly. This script should include any
necessary source files. The more closely the script can reproduce your
situation, the better.
situation, the better. If you can make a repeatable test case, you should
post this to @email{bugs@@lists.mysql.com} for a high priority treatment!
If you can't provide a script, you should at least include the output
from @code{mysqladmin variables extended-status processlist} in your mail to
provide some information of how your system is performing!
@item
If you can't produce a test case in a few rows, or if the test table
is too big to be mailed to the mailing list (more than 10 rows), you should
dump your tables using @code{mysqldump} and create a @file{README} file
that describes your problem.
Create a compressed archive of your files using
@code{tar} and @code{gzip} or @code{zip}, and use @code{ftp}
to transfer the archive to @uref{ftp://support.mysql.com/pub/mysql/secret/}.
Then send a short description of the problem to @email{bugs@@lists.mysql.com}.
@item
If you think that @strong{MySQL} produces a strange result from a query,
include not only the result, but also your opinion of what the result
......@@ -3157,17 +3177,6 @@ options to programs like @code{mysqld} and @code{mysql}, and to the
It is never a bad idea to include them anyway! If you use any modules, such
as Perl or PHP, please include the version number(s) of those as well.
@item
If you can't produce a test case in a few rows, or if the test table
is too big to be mailed to the mailing list (more than 10 rows), you should
dump your tables using @code{mysqldump} and create a @file{README} file
that describes your problem.
Create a compressed archive of your files using
@code{tar} and @code{gzip} or @code{zip}, and use @code{ftp}
to transfer the archive to @uref{ftp://support.mysql.com/pub/mysql/secret/}.
Then send a short description of the problem to @email{mysql@@lists.mysql.com}.
@item
If your question is related to the privilege system, please include the
output of @code{mysqlaccess}, the output of @code{mysqladmin reload}, and all
......@@ -31851,6 +31860,15 @@ operating system must support dynamic loading. The @strong{MySQL} source
distribution includes a file @file{sql/udf_example.cc} that defines 5 new
functions. Consult this file to see how UDF calling conventions work.
For mysqld to be able to use UDF functions, you should configure MySQL
with @code{--with-mysqld-ldflags=-rdynamic} The reason is that to on
many platforms you can load a dynamic library (with @code{dlopen()})
from a static linked program, which you would get if you are using
@code{--with-mysqld-ldflags=-all-static} If you want to use an UDF that
needs to access symbols from mysqld (like the @code{methaphone} example
in @file{sql/udf_example.cc} that uses @code{default_charset_info}), you must
link the program with @code{-rdynamic}. (see @code{man dlopen}).
For each function that you want to use in SQL statements, you should define
corresponding C (or C++) functions. In the discussion below, the name
``xxx'' is used for an example function name. To distinquish between SQL and
......@@ -32179,6 +32197,9 @@ characters in its arguments, divided by the sum of the length of its arguments.
@item
@code{myfunc_int()} returns the sum of the length of its arguments.
@item
@code{sequence([const int])} returns an sequence starting from the given
number or 1 if no number has been given.
@item
@code{lookup()} returns the IP number for a hostname.
@item
@code{reverse_lookup()} returns the hostname for an IP number.
......@@ -32335,6 +32356,9 @@ can be done on row-by-row or @code{GROUP BY} level.
We have created an example procedure in @strong{MySQL} Version 3.23 to
show you what can be done.
Additionally we recommend you to take a look at 'mylua', which you can find in the Contrib directory. @xref{Contrib}. Which this you can use the LUA
language to load a procedure at runtime into @code{mysqld}.
@menu
* procedure analyse:: Procedure analyse
* Writing a procedure:: Writing a procedure.
......@@ -34597,6 +34621,21 @@ If you get performance problems in making backups on your system, you can
solve this by setting up replication and do the backups on the slave
instead of on the master. @xref{Replication Intro}.
If you are using a Veritas file system, you can do:
@enumerate
@item
Execute in a client (perl ?) @code{FLUSH TABLES WITH READ LOCK}
@item
Fork a shell or execute in another client @code{mount vxfs snapshot}.
@item
Execute in the first client @code{UNLOCK TABLES}
@item
Copy files from snapshot
@item
Unmount snapshot
@end enumerate
@cindex multiple servers
@cindex servers, multiple
@cindex running, multiple servers
......@@ -39966,6 +40005,16 @@ MySQL ActiveX Object for directly accessing your MySQL servers from IIS/ASP,
VB, VC++ skipping the slower ODBC methods. Fully updateble, multithreaded with full support
for all MySQL fieldtypes (version 2001.1.1). By SciBit @uref{http://www.scibit.com/}.
@item @uref{http://www.fastflow.it/mylua/, MyLUA home page}
How to use the LUA language to write @code{MySQL} @code{PROCEDURE} that can
be loaded runtime.
@itemize @bullet
@item @uref{http://www.mysql.com/Downloads/Contrib/lua-4.0.tar.gz, Lua 4.0}
LUA 4.0
@item @uref{http://www.mysql.com/Downloads/Contrib/mylua-3.23.32.1.tar.gz, mylua-3.23.32.1.tar.gz}
Patch for MySQL 3.23.32 to use LUA 4.0. By Cristian Giussani.
@end itemize
@end itemize
@appendixsec Clients
......@@ -41007,6 +41056,14 @@ not yet 100 % confident in this code.
@appendixsubsec Changes in release 3.23.33
@itemize bullet
@item
Fixed core-dump bug when using @code{GROUP BY} on an @code{ALIAS}, where
the @code{ALIAS} was the same as an existing column name.
@item
Added @code{SEQUENCE()} as an example UDF function.
@item
Changed @code{mysql_install_db} to use @code{BINARY} for @code{CHAR}
columns in the privilege tables.
@item
Changed @code{TRUNCATE table_name} to @code{TRUNCATE TABLE table_name}
to use the same syntax as Oracle. Until 4.0 we will also allow
@code{TRUNCATE table_name} to not crash old code.
......@@ -46657,25 +46714,35 @@ Execute @code{resolve_stack_dump -s /tmp/mysqld.sym -n mysqld.stack}.
This will print out where @code{mysqld} died. If this doesn't help you
find out why @code{mysqld} died, you should make a bug report and include
the output from the above commend with the bug report. @xref{Bug reports}.
the output from the above commend with the bug report.
Note however that in most cases it will not help us to just have a stack
trace to find the reason for the problem. To be able to locate the bug
or provide a workaround, we would in most cases need to know the query
that killed @code{mysqld} and preferable a test case so that we can
repeat the problem! @xref{Bug reports}.
@end enumerate
@node Using log files, Reproducable test case, Using stack trace, Debugging server
@appendixsubsec Using log files to find cause of errors in mysqld
Note that before starting @code{mysqld} with @code{--log} you should
check all your tables with @code{myisamchk}. @xref{Maintenance}.
If @code{mysqld} dies or hangs, you should start @code{mysqld} with
@code{--log}. When @code{mysqld} dies again, you can check in the log
file for the query that killed @code{mysqld}. Note that before starting
@code{mysqld} with @code{--log} you should check all your tables with
@code{myisamchk}. @xref{Maintenance}.
If you are using a log file, @code{mysqld --log}, you should check the
'hostname' log files, that you can find in the database directory, for
any queries that could cause a problem. Try the command @code{EXPLAIN}
on all @code{SELECT} statements that takes a long time to ensure that
mysqld are using indexes properly. @xref{EXPLAIN, , @code{EXPLAIN}}. You
should also test complicated queries that didn't complete within the
@code{mysql} command line tool.
@code{--log}. When @code{mysqld} dies again, you can examine the end of
the log file for the query that killed @code{mysqld}.
If you are using @code{--log} without a file name, the log is stored in
the database directory as 'hostname'.log In most cases it's the last
query in the log file that killed @code{mysqld}, but if possible you
should verify this by restarting @code{mysqld} and executing the found
query from the @code{mysql} command line tools. If this works, you
should also test all complicated queries that didn't complete.
You can also try the command @code{EXPLAIN} on all @code{SELECT}
statements that takes a long time to ensure that mysqld are using
indexes properly. @xref{EXPLAIN, , @code{EXPLAIN}}.
You can find the queries that take a long time to execute by starting
@code{mysqld} with @code{--log-slow-queries}. @xref{Slow query log}.
Kundentyp kategorie
Privat (Private Nutzung) Mobilfunk
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
cont_nr int(11) NOT NULL auto_increment,
ver_nr int(11) NOT NULL default '0',
aufnr int(11) NOT NULL default '0',
username varchar(50) NOT NULL default '',
hdl_nr int(11) NOT NULL default '0',
eintrag date NOT NULL default '0000-00-00',
st_klasse varchar(40) NOT NULL default '',
st_wert varchar(40) NOT NULL default '',
st_zusatz varchar(40) NOT NULL default '',
st_bemerkung varchar(255) NOT NULL default '',
kunden_art varchar(40) NOT NULL default '',
mcbs_knr int(11) default NULL,
mcbs_aufnr int(11) NOT NULL default '0',
schufa_status char(1) default '?',
bemerkung text,
wirknetz text,
wf_igz int(11) NOT NULL default '0',
tarifcode varchar(80) default NULL,
recycle char(1) default NULL,
sim varchar(30) default NULL,
mcbs_tpl varchar(30) default NULL,
emp_nr int(11) NOT NULL default '0',
laufzeit int(11) default NULL,
hdl_name varchar(30) default NULL,
prov_hdl_nr int(11) NOT NULL default '0',
auto_wirknetz varchar(50) default NULL,
auto_billing varchar(50) default NULL,
touch timestamp(14) NOT NULL,
kategorie varchar(50) default NULL,
kundentyp varchar(20) NOT NULL default '',
sammel_rech_msisdn varchar(30) NOT NULL default '',
p_nr varchar(9) NOT NULL default '',
suffix char(3) NOT NULL default '',
PRIMARY KEY (cont_nr),
KEY idx_aufnr(aufnr),
KEY idx_hdl_nr(hdl_nr),
KEY idx_st_klasse(st_klasse),
KEY ver_nr(ver_nr),
KEY eintrag_idx(eintrag),
KEY emp_nr_idx(emp_nr),
KEY wf_igz(wf_igz),
KEY touch(touch),
KEY hdl_tag(eintrag,hdl_nr),
KEY prov_hdl_nr(prov_hdl_nr),
KEY mcbs_aufnr(mcbs_aufnr),
KEY kundentyp(kundentyp),
KEY p_nr(p_nr,suffix)
) TYPE=MyISAM;
INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007');
INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. mchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
# This died because we used the field Kundentyp twice
SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie;
drop table t1;
......@@ -72,6 +72,9 @@ void my_init(void)
#ifdef THREAD
#if defined(HAVE_PTHREAD_INIT)
pthread_init(); /* Must be called before DBUG_ENTER */
#endif
#ifdef UNIXWARE7
(void) isatty(0); /* Go around connect() bug in UW7 */
#endif
my_thread_global_init();
#ifndef __WIN__
......
......@@ -41,9 +41,8 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include <time.h>
#if defined (HAVE_SELECT)
# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX) || defined(TIME_WITH_SYS_TIME)
# include <sys/time.h>
# endif
#endif /* HAVE_SELECT */
......
......@@ -150,9 +150,9 @@ then
# mysqld --bootstrap wants one command/line
c_d="$c_d CREATE TABLE db ("
c_d="$c_d Host char(60) DEFAULT '' NOT NULL,"
c_d="$c_d Db char(64) DEFAULT '' NOT NULL,"
c_d="$c_d User char(16) DEFAULT '' NOT NULL,"
c_d="$c_d Host char(60) binary DEFAULT '' NOT NULL,"
c_d="$c_d Db char(64) binary DEFAULT '' NOT NULL,"
c_d="$c_d User char(16) binary DEFAULT '' NOT NULL,"
c_d="$c_d Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
......@@ -177,8 +177,8 @@ then
echo "Preparing host table"
c_h="$c_h CREATE TABLE host ("
c_h="$c_h Host char(60) DEFAULT '' NOT NULL,"
c_h="$c_h Db char(64) DEFAULT '' NOT NULL,"
c_h="$c_h Host char(60) binary DEFAULT '' NOT NULL,"
c_h="$c_h Db char(64) binary DEFAULT '' NOT NULL,"
c_h="$c_h Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
......@@ -199,9 +199,9 @@ then
echo "Preparing user table"
c_u="$c_u CREATE TABLE user ("
c_u="$c_u Host char(60) DEFAULT '' NOT NULL,"
c_u="$c_u User char(16) DEFAULT '' NOT NULL,"
c_u="$c_u Password char(16) DEFAULT '' NOT NULL,"
c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL,"
c_u="$c_u User char(16) binary DEFAULT '' NOT NULL,"
c_u="$c_u Password char(16) binary DEFAULT '' NOT NULL,"
c_u="$c_u Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
......@@ -235,7 +235,7 @@ then
echo "Preparing func table"
c_f="$c_f CREATE TABLE func ("
c_f="$c_f name char(64) DEFAULT '' NOT NULL,"
c_f="$c_f name char(64) binary DEFAULT '' NOT NULL,"
c_f="$c_f ret tinyint(1) DEFAULT '0' NOT NULL,"
c_f="$c_f dl char(128) DEFAULT '' NOT NULL,"
c_f="$c_f type enum ('function','aggregate') NOT NULL,"
......@@ -249,10 +249,10 @@ then
echo "Preparing tables_priv table"
c_t="$c_t CREATE TABLE tables_priv ("
c_t="$c_t Host char(60) DEFAULT '' NOT NULL,"
c_t="$c_t Db char(64) DEFAULT '' NOT NULL,"
c_t="$c_t User char(16) DEFAULT '' NOT NULL,"
c_t="$c_t Table_name char(60) DEFAULT '' NOT NULL,"
c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL,"
c_t="$c_t Db char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t User char(16) binary DEFAULT '' NOT NULL,"
c_t="$c_t Table_name char(60) binary DEFAULT '' NOT NULL,"
c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
c_t="$c_t Timestamp timestamp(14),"
c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,"
......@@ -268,11 +268,11 @@ then
echo "Preparing columns_priv table"
c_c="$c_c CREATE TABLE columns_priv ("
c_c="$c_c Host char(60) DEFAULT '' NOT NULL,"
c_c="$c_c Db char(64) DEFAULT '' NOT NULL,"
c_c="$c_c User char(16) DEFAULT '' NOT NULL,"
c_c="$c_c Table_name char(64) DEFAULT '' NOT NULL,"
c_c="$c_c Column_name char(64) DEFAULT '' NOT NULL,"
c_c="$c_c Host char(60) binary DEFAULT '' NOT NULL,"
c_c="$c_c Db char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c User char(16) binary DEFAULT '' NOT NULL,"
c_c="$c_c Table_name char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c Column_name char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c Timestamp timestamp(14),"
c_c="$c_c Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)"
......
......@@ -520,11 +520,17 @@ public:
void update_used_tables()
{
item->update_used_tables() ; Item_func::update_used_tables();
used_tables_cache|=item->used_tables();
used_tables_cache|= item->used_tables();
const_item_cache&= item->const_item();
}
const char *func_name() const { return "field"; }
void fix_length_and_dec()
{ maybe_null=0; max_length=2; used_tables_cache|=item->used_tables();}
{
maybe_null=0; max_length=3;
used_tables_cache|= item->used_tables();
const_item_cache&= item->const_item();
with_sum_func= with_sum_func || item->with_sum_func;
}
};
......
......@@ -1199,6 +1199,7 @@ void Item_func_elt::fix_length_and_dec()
set_if_bigger(decimals,args[i]->decimals);
}
maybe_null=1; // NULL if wrong first arg
with_sum_func= with_sum_func || item->with_sum_func;
used_tables_cache|=item->used_tables();
const_item_cache&=item->const_item();
}
......
......@@ -23,3 +23,6 @@ install-data-local:
$(INSTALL_DATA) $(srcdir)/charsets/README $(DESTDIR)$(pkgdatadir)/charsets/README
$(INSTALL_DATA) $(srcdir)/charsets/Index $(DESTDIR)$(pkgdatadir)/charsets/Index
$(INSTALL_DATA) $(srcdir)/charsets/*.conf $(DESTDIR)$(pkgdatadir)/charsets
# Don't update the files from bitkeeper
%::SCCS/s.%
......@@ -3288,7 +3288,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
KEY_PART_INFO *key_part_info;
Item_result_field **copy_func;
MI_COLUMNDEF *recinfo;
uint temp_pool_slot;
uint temp_pool_slot=MY_BIT_NONE;
DBUG_ENTER("create_tmp_table");
DBUG_PRINT("enter",("distinct: %d save_sum_fields: %d allow_distinct_limit: %d group: %d",
......@@ -3297,18 +3297,15 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
statistic_increment(created_tmp_tables, &LOCK_status);
if(use_temp_pool) {
if (use_temp_pool)
temp_pool_slot = bitmap_set_next(temp_pool, TEMP_POOL_SIZE);
if(temp_pool_slot != MY_BIT_NONE) // we got a slot
sprintf(path, "%s%s_%lx_%i", mysql_tmpdir, tmp_file_prefix,
current_pid, temp_pool_slot);
else // if we run out of slots in the pool, fall back to old behavior
sprintf(path,"%s%s%lx_%lx_%x",mysql_tmpdir,tmp_file_prefix,current_pid,
thd->thread_id, thd->tmp_table++);
} else {
if (temp_pool_slot != MY_BIT_NONE) // we got a slot
sprintf(path, "%s%s_%lx_%i", mysql_tmpdir, tmp_file_prefix,
current_pid, temp_pool_slot);
else // if we run out of slots or we are not using tempool
sprintf(path,"%s%s%lx_%lx_%x",mysql_tmpdir,tmp_file_prefix,current_pid,
thd->thread_id, thd->tmp_table++);
};
if (group)
{
......
......@@ -56,11 +56,13 @@
**
** Function 'myfunc_int' returns summary length of all its arguments.
**
** Function 'sequence' returns an sequence starting from a certain number
**
** On the end is a couple of functions that converts hostnames to ip and
** vice versa.
**
** A dynamicly loadable file should be compiled sharable
** (something like: gcc -shared -o udf_example.so myfunc.cc).
** (something like: gcc -shared -o my_func.so myfunc.cc).
** You can easily get all switches right by doing:
** cd sql ; make udf_example.o
** Take the compile line that make writes, remove the '-c' near the end of
......@@ -74,6 +76,7 @@
** CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so";
** CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so";
** CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "udf_example.so";
** CREATE FUNCTION sequence RETURNS INTEGER SONAME "udf_example.so";
** CREATE FUNCTION lookup RETURNS STRING SONAME "udf_example.so";
** CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so";
** CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "udf_example.so";
......@@ -121,6 +124,10 @@ double myfunc_double(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
char *error);
longlong myfunc_int(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
char *error);
my_bool sequence_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
void sequence_deinit(UDF_INIT *initid);
long long sequence(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
char *error);
}
......@@ -535,6 +542,8 @@ double myfunc_double(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
** This function should return the result as a long long
***************************************************************************/
/* This function returns the sum of all arguments */
long long myfunc_int(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
char *error)
{
......@@ -559,6 +568,50 @@ long long myfunc_int(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
}
/*
Simple example of how to get a sequences starting from the first argument
or 1 if no arguments have been given
*/
my_bool sequence_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
if (args->arg_count > 1)
{
strmov(message,"This function takes none or 1 argument");
return 1;
}
if (args->arg_count)
args->arg_type[0]= INT_RESULT; // Force argument to int
if (!(initid->ptr=(char*) malloc(sizeof(longlong))))
{
strmov(message,"Couldn't allocate memory");
return 1;
}
bzero(initid->ptr,sizeof(longlong));
// Fool MySQL to think that this function is a constant
// This will ensure that MySQL only evalutes the function
// when the rows are sent to the client and not before any ORDER BY
// clauses
initid->const_item=1;
return 0;
}
void sequence_deinit(UDF_INIT *initid)
{
if (initid->ptr)
free(initid->ptr);
}
long long sequence(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
char *error)
{
ulonglong val=0;
if (args->arg_count)
val= *((long long*) args->args[0]);
return ++ *((longlong*) initid->ptr) + val;
}
/****************************************************************************
** Some functions that handles IP and hostname conversions
** The orignal function was from Zeev Suraski.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment