ThinkPart

Andrey's blog

 

The ultimate MySQL server machine

 

Ulf was pushing me today to file a MySQL bug, which actually doesn't exist anymore, but his programs crash with 5.1.31, where it seems still exists. For a long time we were thinking about the ultimate testing matrix which includes as many as possible MySQL Server instances to check differences in result of the connectors.

I've heard that Paul DuBois have all existing MySQL versions running on a secret box.


Read more ...

MySQL Server versions

 

Throughout the years MySQL has seen many version suffixes


Read more ...

MySQL Protocol quirks

 

The MySQL Protocol is a very old thing. Current version is 10, however I have never seen a server which uses anything but version 10. And new features are added without bumping the number. The changes are usually backwards compatible and sometimes you break stuff to be backward compatible.

You know that character set, and most notably Unicode, support was introduced in 4.1 . Other things got added to 4.1 but let's stay with the charsets.


Read more ...

mysqli got arginfo

 

JohannesS is a developer who is a hard-core user of the console. Thus, he doesn't like using a browser to visit php.net just for reading documentation.


Read more ...

Replacing mysqli's Connection, Result and Statement classes

 

Have you ever though about extending mysqli's classes. It's pretty simple to subclass the connection class mysqli. However, subclassing mysqli_result and mysqli_stmt is not so obvious, actually I though that it's even not possible.

However, never say never! After discussing mysqli's OO interface for an hour yesterday, with Johannes and Ulf, and breaking two tests of mysqli - 062.phpt and 063.phpt, because I tried to final-ize mysqli_result and mysqli_stmt, as well as make their constructors private, I found out how one can plug his own classes.


Read more ...

PHP/MySQL micro optimisation

 

You probably know it, but anyways. I am profiling a script of mysqli's test suite to look for unefficiencies in mysqlnd. Callgrind shows me that if you use mysqli_fetch_assoc you lose 5% of the runtime (of the script) compared to the situation when you use mysqli_fetch_row() or mysqli_fetch_assoc().

mysqlnd is pretty efficient if you use mysqli_fetch_assoc(). Zend's hash has a quick API, one passes an already precomputed hash value to it and the hash value doesn't need to be computed. Because mysqlnd knows what the names of the columns in the array in advance will be they are precomputed. How does mysqlnd know? Well, the MySQL server sends metadata about the columns selected, at this time mysqlnd precomputes the hash values, 32bit integer, and then on every fetch_assoc()/fetch_array() call reuses them.

My UltraSparc5 got an upgrade

 

I have a SUN UltraSparc5, which sports a 64bit 270MHz fast CPU. I got it with a 6.4GB HDD and 64MB RAM.


Read more ...

SSL_read bug in openssl

 

Today I committed the SSL patch for mysqlnd. On my box, an Ubuntu 8.10 with KDE3, a timeout test was failing. I found it strange. The found that SSL_read in ext/openssl/xp_ssl.c doesn't regard the network read_timeout, on the contrary to what recv does.



Read more ...

Find the bug in Zend

 

Here it comes...


Read more ...

PHP Streams suck, again...

 

First it was registering every persistent stream as a resource in EG(persistent_list). mysqlnd has a hack around this, everyone has a hack.


Read more ...

My NAS - QNAP TS 119 Turbo NAS

 

Few weeks ago I got new hardware for my home network, a QNAP TS 119 Turbo NAS.


Read more ...

mysqlnd and the compressed protocol, again

 

mysqlnd patched for compressed protocol passes almost all tests, but all of the most relevant and those who test with big result sets. I have a few failures due to "Packet out of order" which is due to the crippled packet numbering when com...pressed is turned on-the outter layer has different counter than the inner, compressed one, and it is unknown how the server resets them (for example in the COM_CHANGE_USER tests).

 


Read more ...

The MySQL compressed protocol

 

MySQL's compressed protocol is not so widely used, but there are still users that use it. Thus, the need to implement it in mysqlnd.

Unfortunately the compressed protocol is full of landmines, a lot of them, exploding one by one.


Read more ...

Compressed protocol for mysqlnd

 

Compressed protocol support for mysqlnd has ready alpha patch. Tested with simple queries, not tested against the test suite or big packets.

100 000 queries per second against MySQL

 

No! There is no error in the topic. You can see yourself:


Read more ...

Where is the problem in the following code?

 
#define MYSQLND_INC_GLOBAL_STATISTIC(statistic) \
 { \
     if (MYSQLND_G(collect_statistics) && statistic != STAT_LAST) { \
        mysqlnd_global_stats->values[statistic]++; \
    } \
 }

I usually don't make this mistake, but in this particular case I did. Can you spot it?

Query caching in PHP/mysqlnd - Reloaded

 

The MySQL UC 2009 is over and I got bored in the evening before I had to leave Santa Clara and decided to play again with query caching in mysqlnd. I have always said that mysqlnd is ready for it, the infrastructure is there and that we need just few changes to make it work. Well, I decided to bite the bullet and do it. Spent about 4h in the evening and on the next day 2h while waiting on the San Jose (SJC) airport and continued on the flight to Denver, where I am having vacation. On the plane I was almost ready and today I made the final changes to the preliminary patch, that seems to work :)

I did a small benchmark, a microbenchmark.


Read more ...

mysqlnd talk this afternoon

 

In a few hours I will give my talk on mysqlnd. Well, the talk is not mine but we wrote it together with Ulf Wendel, of the MySQL Connectors Team fame. Although we haven't added much functionality to mysqlnd in the recent months mysqlnd is still pretty advanced and started to mature. I will talk about why mysqlnd is unique, why is it cool, why is it fast, and why you should use it!


Read more ...

Connector/C++ talk already in the history

 

Yesterday I gave my talk, in front of not that many people, about Connector/C++ at the MySQL UC 2009. Not too many questions came from the public, but this is a new product which very specific target group. You know, almost nobody writes Web applications in C++. And Java is the server language for the Enterprise. So I should have expected not many people in the room.

If you have missed the talk, don't worry. In May there will be a webinar which you can attend and if you miss it, you can just watch it at later time. The webinars are recorded and offered freely.

Yesterday the Connector/C++ got the GA stamp and we officially support it. Although we are going to make changes, mostly backward compatible, because this GA, 1.0.5, added the basic functionality the people need to use MySQL with C++ without using the weird libmysql API, which makes your life hard, if you don't use boost and start to get exceptions - you are gonna leak big time.


Read more ...

Connector/C++ @ MySQL UC 2009

 

I will give a talk about Connector/C++ (and mysqlnd in another slot) next week at the MySQL UC 2009. We had to fit the presentation in about 20 slides to be able to fit in the small timeframe of 45 mins. So far I have given only presentations of about 90 minutes, incl. the shoot me with your questions part. I rehearsed today, both talks. Everything seems fine and I will fit. So, if you are an ISV that uses MySQL and use C++ come to see my presentation, there is something to learn. If you are open source developer, who uses C++, come to the room and allow me to introduce MySQL Connector/C++ to you. I am sure you will never get back to libmysql and MySQL Connector/C Wink

The long waited Connector/C++ review article is there

 

Hurry up. Click here to read Giri Mandalika's article on MySQL Connection C++. He is using 1.0.4-beta for his tests and shows how simple it is to use the connector. It is all about developing in C++ for MySQL that became easier!

Broken dual-head in Ubuntu and how to fix it

 

Since some time I am a dual-head user. I recently bought a 19" Ilyama 1680x1050 (cool resolution for 19") and it served me well. It is much more smaller than the 24" Dell UltraSharp I have. The differences in the resolution is not that big. The Dell is 1920x1200. Yesterday I saw that Ilyama have a Prolite series monitor, the same as the 19", 22" which has 1920x1200. I have followed in the recent times the 23" line of Samsung - the 2343 NW. Which is about 160 Euro and offers not that standard resolution (2048 x 1152 / 16:9). The resolution is strange, right? But gives the possibility to have 2 browsers at 1024 pixel width next to each other. In the last years the monitors got bigger and cheaper, more real estate. And they got wider. Probably driven by the multimedia market, although widescreen is good also for those who use IDEs.


Read more ...

How big are the basic types on the most used systems

 

After I yesterday checked the size of wchar_t on range number of platforms I decided to extend this to many more types. Again the same systems were used, a few more were added (MacOSX 10.5 x86 and x86_64 are the ones most used). The information is in pretty raw state bug my blog software is not able to present big tables correctly, thus I am going the raw way.

What is most interesting?

  • long double varies a lot. Between 8 bytes (AIX 5.2 and 5.3 (ppc32/ppc64), Windows 32 & 64) through 12 bytes (Linux/FreeBSD/Solaris but not MacOSX on  x86) to 16 byte (x86_64, ia64, hppa32, hppa64, ia64, ppc32/ppc64 (all MacOSX), sparc32, sparc64)
  • Windows is missing few types
  • MacOSX (10.4 & 10.5) doesn't have clock_id and timer_t
  • time_t is 4 bytes on x86, ppc32, hppa32
  • time_t is 8 bytes on x86_64, ia64, ppc64, hppa64, Windows 32&64
  • int is always 4 bytes :)
  • long is always 4 bytes on 32bit
  • long is always 8 bytes on 64bit except on Win64
  • long long is present on all systems and is always 8 bytes
  • float is always 4 bytes and double 8 bytes
  • as expected size_t is 4 byte on 32bit and 8byte on 64bit, the same is valid for ssize_t, where available
  • off_t is 4 byte on AIX 5.x ppc32, i5OS ppc32, x86(Linux, Solaris), sparc32, Win32 & 64
  • off_t is 8 byte on x86 (FreeBSD 6&7, MacOSX), x86_64, ia64, hppa64, ppc64, sparc64, MacOSX 10.x ppc32
  • intmax_t/uintmax_t are always 8 byte but missing on Win32 & 64
  • short is always 2 bytes

 


Read more ...

Named pipe support in MySQL Connector/C++

 

I suppose you have already heard from Ulf what MySQL Connector/C++ is. Today Ulf was looking at the test cases and out of the blue asked whether we support named pipes. Well, it wasn't tested but one can pass OPT_NAMED_PIPE to the connect method of the driver (or the MySQL_Connection constructor).


Read more ...

Of wchar_t

 

wchar_t was introduced long ago as wider version of char that should be enough while doing programs that grok Unicode. Unfortunately, as with all other C types the standard doesn't define the length. Thus some platforms have 2 byte others 4 byte wchar_t. I decided to check what are the sizes using an internal build tool at SUN/MySQL. And here are the results.


Read more ...

We just broke Connector C++'s interface

 

The topic sounds scary, right? Don't be afraid, we just wanted to mention that we introduced a change in the interface, after we released the beta yesterday. Previous examples which use ConnectionMetaData, ResultSetMetaData and ParameterMetaData won't work anymore. They used to use std::auto_ptr to keep the code from leaking.


Read more ...

Maybe PHP should be the first programming language learnt

 

My girlfriend is a freshgirl at the local University of Applied Sciences since beginning of March. She chose to study Computer Science. Maybe affected from the area of my own studies.


Read more ...

Someone, please fix Zend Engine!

 

I am writing a PHP extension which uses a library written in C++, which means that the actual extension should partially be compiled with a C++ compiler. C++ is stricter when talking about char *.


Read more ...

Query Cache in mysqlnd

 

I hope you know what mysqlnd is. If not, then.... mysqlnd is the replacement for libmysql in the PHP world. Starting from PHP 5.3 you might use mysqlnd to connect to your MySQL Server(s) without installing libmysql on your web servers/client hosts. mysqlnd also promises reduced memory usage compared to the scenario when libmysql is used and should be at least as quick as libmysql. To be able to beat libmysql and create incentives to let you migrate to mysqlnd we had brainstorming sessions. We came with a list of possible features.


Read more ...

mysql client cmdline option which easies the life of the connector developer

 

MySQL 5.1 was released as GA not long ago (current version 5.1.32). I work at SUN/MySQL as a connector developer. Currently working on Connector/C++, previously I used to develop mysqlnd of the PHP fame, currently I maintain it. Every single day I work with the MySQL Server and like everything in this world, it's imperfect. You know perpetuum mobile doesn't exist.


Read more ...

I have a dream*

 

You probably saw that I started experimenting with Zend Framework. I used to develop in PHP for 5 years, between 2000 and 2005. Worked for almost 2 years at Dorten, renamed 100 Days, later bought by Zend - their Stuttgart office. Before the Zend time we had in-house CMS system, closed source. Nobody had the time and resources to have it released. It's name was EWMS (Eierlegende WollMilchSau - Wikipedia has an entry about this animal ). This CMS allowed us quickly to build applications. However, it wasn't just clicking and using wizzardry to generate new sites, then fill them with content.

After I saw what Zend_Form might can do, according to the slides of its author, which I read, I have a dream*.


Read more ...

Of strtold, strto(u), strto(u)ll, strtoumax(), strtoimax()

 

We are trying to compile Connector/C++ in the OpenOffice.Org environment, however dmake, the OO.Org build too (Ubuntu/Debian has it) can't work currently with CMake. CMake is the meta-make system we use for Connector/C++ to easy the portability. I had a blog entry which platforms are supported, a vast number. Without CMake this wouldn't have been that easy.


Read more ...

MySQL Connector/C++ 1.0.4-beta comming soon

 

We are in the last stages of preparing the next release, which will be the first beta. I expect that Ulf will blog thoroughly on it.


Read more ...

V1agra emails just got better

 

I was amazed when I saw this

V1agra Email

Viagra is shown using a HTML table with white and non-white cells.

Zend_Form madness

 

It all started with a tutorial from Rob Allen, maybe from his book "Zend Framework in Action". A simple site to organize a CD collection list. Zend Framework seems very powerful but it will be insanity for someone to understand it without a tutorial of some kind.


Read more ...

Hey, I want PHP and I don't want XML, what to do?!?

 

One might ask why do I want a PHP without XML. This is not the first time I want PHP without XML. When developing mysqlnd I needed a binary that builds as quick as possible - linking time with too many libraries is an issue. However, today the reason is other. I want a PHP5 CLI and unfortunately Zend Server CE, of the Zend fame doesn't come with it.


Read more ...

i5OS, what are you doing?

 

Very strange results when executing CMake on within MySQL Connector/C++ on i5OS.


Read more ...

Want a nice PHP logo for your website, get one!

 

Johannes, the RM of PHP 5.3, found these


Read more ...

First MySQL post

 

First MySQL post


Read more ...

My (new) first post

 

Installed new blogging system as WordPress just got too big. I will blog technical and non-technical stuff, from time to time. Stay tuned!


Read more ...