January 29th, 2010
| Sonstige
Die letzten Wochen brachten einen neuen Rang: Knipser.
Seit zwei Tage gelten neue Regeln für Blogpostings, welche sich auf Arbeit beziehen. Das Kleingedruckte enthält Anweisungen, die mein Blogverhalten verändern werden.
Nach einem fast einjährigem Umweg über den MySQL Connector/OpenOffice.org und MySQL Connector/C++ arbeite ich derzeit wieder an mysqlnd (MySQL native driver for PHP). Die Implementierung des MySQL Client-Server-Protokolls ist weitestgehend abgeschlossen. Wir experimentieren mit verschiedenen Ideen. Vereinzelt vergreife auch ich mich an den ".c"-Dateien - sehr zum Leid von Andrey. Mehr mag ich zur Arbeit nicht sagen.
Derweil vergnügt sich der elePHPant im Winter-Wunderland. Seine Lebensfreude ist ansteckend. Wenn er einmal nicht das Model aus der Kälte spielen will, müssen die für Flickr obligatorischen Blümchenbilder herhalten. Vielleicht sollte ich eine elePHPant-Model-WG eröffnen, um seine Karriere zu fördern…

Keine Kommentare »
November 15th, 2009
| Sonstige
Die 7 ist eine aufregende Zahl. Heute ist Sonntag. Der siebte Tag in der Woche. Zwei mal sieben ist 14. Vor 14 Jahren wurde mir die staatliche Erlaubnis erteilt motorisierte Zweiräder mit einer Leistung von fast fünf mal sieben Pferdestärken zu fahren. Etwa siebzehn Monate lang ritt ich auf einer Gummikuh, einer Strich 7, durch die Lande, bis ein Ventilabriss die Reise beendete. Vor sieben Tagen jährte sich der Erwerb des Autoführerscheins, den ich seit zwei mal sieben minus eins Jahren erwarb, obwohl ich während der Fahrprüfung die Ohren eines parkenden Wagens touchierte.
In einem Peugeot 407 habe ich bei 30 mal sieben km/h die lebenswichtige Bedeutung eines Sicherheitskäfigs erfahren. Geschätzte 10 mal sieben km/h Geschwindigkeitsunterschied zum Vordermann ließen sich nicht schnell genug abbauen als dieser unverhofft die Spur wechselte.
Nach 37.000 km im eigenen PKW, sieben Jahren ohne eigenes Fahrzeug und 77.777 km in Mietwagen zurückgelegten Kilometern drohte meine KFZ-Schadenfreiheitsklasse in 07/2009 zu erlöschen. Aus diesem Grunde erwarb ich vor sieben Monaten einen sieben PS starken Roller dessen theoretische Höchstgeschwindigkeit über 77 km/h liegt. "Uwe, gibt mir was für die Versicherung - ich stell das Ding in den Keller nur der Versicherung wegen". Ich bin ein Lügner: sieben Monate, 7.000 km. Heute waren es 170 km. Früher habe ich das mit dem Fahrrad gemacht, früher…
1 Kommentar »
November 2nd, 2009
| MySQL, PlanetMySQL (english), PHP (english), PlanetPHP (english)
C and PHP MySQL clients can set a connection timeout before a connection is established to MySQL. The MySQL C API manual states about MYSQL_OPT_CONNECT_TIMEOUT , which is equal to PHPs MYSQLI_OPT_CONNECT_TIMEOUT:
MYSQL_OPT_CONNECT_TIMEOUT
Connect timeout in seconds.
From: http://dev.mysql.com/doc/refman/5.1/en/mysql-options.html
That is half of the story. The actual behaviour depends on the library you use, the operating system and the transport protocol (TCP/IP, Unix domain sockets, Windows named pipes, Shared Memory).
C users can choose between the MySQL Client Library, which ships with the MySQL server, and the MySQL Connector/C, a new standalone version of the client library. PHP users have a third library option. PHP users can also choose to use the MySQL native driver for PHP (mysqlnd). All three libraries create TCP/IP connections differently resulting in different behaviour.
This article focusses on PHP and TCP/IP. Nevertheless it may be a valuable read for C developers, because PHP itself is written in C. Therefore, PHP inherits all limitations of the underlying MySQL Client Library, just like any other C client.
| Library |
Supports connection timeout since |
TCP/IP timeout works on Windows? |
| MySQL Client Library |
MySQL 3.23 (= ever since?) |
No |
| MySQL Connector/C |
6.0 (= first release) |
No |
| mysqlnd |
PHP 5.3.1 |
Yes |
Weiter lesen »
Keine Kommentare »
October 23rd, 2009
| PlanetMySQL (english), PHP (english), PlanetPHP (english)
Sometimes you forget about what you did years ago, for example the ability of mysqlnd write back traces of slow queries into the PHP error log . Regardless if you use mysqlnd with ext/mysql, ext/mysqli or PDO_MYSQL, mysqlnd is able to tell you which of your code has executed a slow query. To enable the feature, you need to compile PHP with CFLAGS="-D A0". A0? Yeah, we must have had some doubts about the usefulness.
Weiter lesen »
Keine Kommentare »
October 16th, 2009
| PlanetMySQL (english), PlanetPHP (english)
Yes, 150 means we added some 30 performance statistics to the MySQL native driver for PHP (mysqlnd) since monday. The new statistics are explained in three words: counting COM_* commands. COM_* commands refers to the command packets of the MySQL client server protocol. For example, COM_QUERY is used to execute nonprepared SQL statements.
Please check the earlier blog postings on how to use and access the statistics: PHP: 59 tuning screws for mysqlnd, PHP: 120 tuning screws for mysqlnd. The information given in those articles will find its way into the PHP and MySQL manual. The MySQL documentation team is working on an update. But for now, an hour after the latest commit, you are requested to check the blog postings.
Weiter lesen »
Keine Kommentare »
October 13th, 2009
| PHP (deutsch)
Es gibt drei Extensions mit deren Hilfe ein PHP-Skript auf einen MySQL Server zugreifen kann: ext/mysql, ext/mysqli und PDO_MYSQL. Alle drei sind geeignet, um die Entwicklungsgeschichte von PHP und MySQL Revue passieren zu lassen, alle drei sind geeignet, um Kopfschütteln oder Staunen hervorzurufen. Heute: Grundlagen des Verbindungsaufbaus mit ext/mysql - wie verbinde ich PHP mit MySQL?
Was wird folgendes Kommando ausgeben?
time MYSQL_TCP_PORT=3307 sapi/cli/php -r '$link = mysql_connect(\"127.0.0.1\", \"root\", \"root\"); mysql_query(\"SELECT SLEEP(10)\"); var_dump($link);'
Um zu beantworten was passieren wird, ist es notwendig das Betriebssystem, die verwendete Client Bibliothek und mindestens eine PHP-Konfigurationsdirektive zu kennen. Das Betriebssystem ergibt sich aus dem Beispiel: es ist ein Unix. Die verwendete Client Bibliothek ist MySQL Client Library (libmysql). Es ist ein Standardbuild, genauso wie PHP und MySQL unverändert aus der Tüte gefallen sind. Es wurden keine PHP-Konfigurationsdirektiven gesetzt und die Standardeinstellungen von PHP 5.3 werden benutzt.
Das Betriebssystem und die PHP-Konfigurationsdirektive mysql.default_port entscheidet darüber ob das Setzen der Umgebungsvariablen MYSQL_TCP_PORT einen Einfluß auf ext/mysql hat. Unter Windows oder Netware wird die Umgebungsvariable nicht ausgewertet. Im Beispiel wird ein Unix verwendet. Auf diesem System wird die Umgebungsvariable einen etwaigen “mysql” Eintrag aus der TCP-Sektion in /etc/services überstimmen, sofern kein Wert für mysql.default_port gesetzt ist, welches die Standardeinstellung ist. Ist das dokumentiert? Ja, in der php.ini-production findet sich eine Notiz. Dort wird auch die Bedeutung des Compile-Flags MYSQL_PORT erklärt.
Da als Hostname die IP-Adresse “127.0.0.1″ angegeben ist und der Port 3307 benutzt wird gemäß der Umgebungsvariable MYSQL_TCP_PORT, baut die MySQL Client Library (libmysql) eine TCP/IP Verbindung auf. Die Verbindung schlägt fehl, weil es sich beim MySQL Server um eine Standardinstallation handelt, die auf Port 3306 horcht. Der Fehler führt zu einer PHP Warnung die, je nach Wert der PHP-Direktive error_reporting, leicht übersehen werden kann: Warning: mysql_connect(): Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in Command line code on line 1.
Anschließend macht PHP unbeirrt weiter und der Aufruf von mysql_query() baut implizit eine neue Verbindung auf, weil - wie bei ext/mysql üblich und möglich - kein Handle angegeben wurde. Ja, das ist dokumentiert. Die Verbindung wird zum Host = NULL auf Port 3307 aufgebaut. Host = NULL findet Anwendung, weil kein Wert für die PHP-Konfigurationsdirektive mysql.default_host gesetzt ist. Eine leere Hostangabe bewirkt unter Unix in der MySQL Client Bibliothek einen Fallback auf localhost und Unix Domain Sockets. Auf Windows würde etwas anderes passieren.
Mit der Hostangabe localhost und mit dem Standardwert einer leeren PHP-Konfigurationsdirektive mysql.default_socket wird das Socket /tmp/mysql.sock verwendet. Aber auch nur, wenn es sich um einen Standardbuild von PHP handelt, PHP_MYSQL_UNIX_SOCK_ADDR nicht beim Kompilieren definiert wurde und es sich auch um einen Standardbuild der MySQL Client Library handelt. Ist das dokumentiert? Sicher, ich habe es doch hiermit gerade dokumentiert!
Schlußendlich gelingt es SELECT SLEEP(10) über einer Unix Domain Socket Verbindung an MySQL zu senden und das Skript wird nach etwa 10 Sekunden beendet. var_dump($link) gibt false aus, da der Verbindungsaufbau fehlgeschlagen ist. Hier noch einmal das korrekte und fehlerfreie Ergebnis im Überblick:
time MYSQL_TCP_PORT=3307 sapi/cli/php -r '$link = mysql_connect(\"127.0.0.1\", \"root\", \"root\"); mysql_query(\"SELECT SLEEP(10)\"); var_dump($link);'
Warning: mysql_connect(): Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in Command line code on line 1
bool(false)
real 0m10.024s
user 0m0.008s
sys 0m0.004s
Alles gaaanz easy…. Und bloß nicht ext/mysqli verwenden. Das baut nicht implizit Verbindungen auf, unterbindet die Verwendung von Umgebungsvariablen, verhindert das Bauen von optimierten und angepassten Binaries mit verbesserten Standardeinstellungen, verlangt bei jedem Kommando die Angabe eines Verbindungshandle und unterstützt neben irrelevanten Dingen wie Prepared Statements auch noch performanzkritische C API Funktionen wie mysql_warning_count().
Keine Kommentare »
October 13th, 2009
| PHP (deutsch)
Ohne Kommentar, da zu neu für mich. Urteilt selbst was Gabriele, die sich auch in der PHP UG München engagiert, auf die Beine stellt:
http://www.phpblogstars.de/ - Alle deutschsprachigen PHPBlogs an einer Stelle
Keine Kommentare »
October 12th, 2009
| PlanetMySQL (english), PHP (english), PlanetPHP (english)
The MySQL native driver for PHP (mysqlnd) is capable of collecting some 120 performance statistics. This is about twice as much as it was when I blogged about the 59 tuning screws for mysqlnd. While the basics have not not changed and the API calls for accessing the data remained the same (see previous posting) the new figures have never been described before.
The figures are for those of you who want to squeeze the last out of the PHP. Many of the statistics have been written for those who have developed mysqlnd and not for PHP users. The data is certainly still of interest for PHP experts but let me stress out again that it is for experts.
Weiter lesen »
2 Kommentare »
September 14th, 2009
| PlanetMySQL (deutsch), PHP (deutsch)
"Sie organisieren das hobbymäßig?" erkundigt sich ungläubig die Organisation einer im gleichen Gebäude stattfindenden Konferenz. Nicht ohne Stolz und völlig zu Recht macht die Frage die Runde. Die Runde besteht aus 220 Teilnehmern der PHP Unconference 2009 (Hamburg, 12.-13.09) deren untenstehenden Rückmeldungen und Kommentare das Erstaunen erklären (weitere Fotos).


Die PHP-Anwendergruppe Hamburg übertrifft mit der dritten Auflage der "Unconference" ihre Erfolge von den Vorjahren. Dank zahlreicher Sponsoren (Soprado, Mayflower, Microsoft, MySQL) und Supporter (Beasts Associated, O’Reilly, SinnerSchrader, Addison-Wesley) konnte das Geomatikum der Universität Hamburg angemietet werden und die Teilnehmer angemessen verpflegt werden. Nirgendwo sonst kann man für 25 Euro das Wer-ist-Wer der deutschsprachigen PHP-Szene zwei Tage lang treffen. Die PHP Unconference in Hamburg bleibt ein Muß für PHP- und MySQL-Anwender.
Unconf?
Auf der PHP "Unconf" bestimmt das Volk der Teilnehmer die Inhalte. Anders als bei einer Konferenz bestimmt nicht eine Gruppe von honorierten Wahlmännern, ein Programmkomitee, welches Thema vorgetragen wird. In einer morgendlichen Versammlung entscheiden die Teilnehmer welche der zuvor auf einer Webseite gesammelten Veranstaltungsthemen in einem großzügigen Hörsaal besprochen werden. Welche Form der Interaktion gewählt wird - Diskussion, Schulung, Vortrag, … -, um ein Thema zu bearbeiten ist der Gruppe überlassen. Es gibt nur zwei Regeln: nach Ablauf von 45 Minuten erfolgt ein striktes Ende und durch die Direktheit einer Unconference ist passiver Konsum fehl am Platze. Dieses Konzept funktioniert sehr gut wie Skeptiker am Tagesprogramm vom Samstag ablesen können.
Pausen und die Protokollierung der Veranstaltung nehmen einen breiten Raum im Gesamtkonzept ein, um den Austausch der Teilnehmer in den Vordergrund zu stellen.
Wie schon in den Vorjahren blieben die Teilnehmer auch abends zusammen, was weiteren Raum zum Erfahrungsaustausch bietet. Abends versammelte sich ein PHPmob zum PHProst an einem Treffpunkt nahe der Partymeile an der Sankt Pauli Hafenstraße. Eine tolle Idee! Wer wollte konnte sich in kleineren privaten Gruppen in einem der zahlreichen Restaurants zum Abendessen verabreden, um im Anschluß zum PHPmob zu gehen. Nachtschwärmer beendeten den Erfahrungsaustausch auf der nahegelegenen Reeperbahn, deren Lichter magische Anziehungskräfte auswirkten.
2010 die Meisterprüfung?
Im dritten Lehrjahr haben die Eventmanager vom OrgaTeam (Judith Andresen , Florian Blasel, Ekkehard Dörre, Jonathan Maron, Stefan J. Morgenroth, Hinrich Sager, Edouard Simon, Tobias Struckmeier, Markus Wolff) eine hervorragende Gesellenarbeit abgeliefert. Ich bin gespannt auf die Meisterprüfung in 2010. Darf man auf der PHP Unconference 2010 die Detailverliebtheit von Darren Cooper (PHP UG Frankfurt und mehr!) erwarten, der Community-Events mit einem gesponsorten Begrüßungscocktail perfektioniert? Inhaltlich sehe ich wenig Verbesserungspotential und hoffe dennoch nächstes Jahr wieder positiv überrascht zu werden.
Keine Kommentare »
September 11th, 2009
| PlanetMySQL (english), PlanetPHP (english)
How large can a column of the data type POINT be: 10 bytes, 100 bytes, 1k, 10k? No… think Enterprise! PHP will allocate 4GB of RAM if you use the Prepared Statements of ext/mysqli and the MySQL Client Library (AKA libmysql) to fetch a POINT column. Of course, the MySQL native driver for PHP (mysqlnd) does better!
To understand why ext/mysqli can allocate up to 4 GB of RAM to fetch a POINT column we need to have a look at the MySQL C API. PHP itself is written in C and in a way ext/mysqli is just a plain vanilla C API client application. The C API is provided by the MySQL Client Library which has been called "libmysql" in the past. The MySQL Client Library implements the MySQL Client Server Protocol. The MySQL native driver for PHP (mysqlnd) is an alternative implementation of the MySQL Client Server Protocol and it is part of PHP source code as of PHP 5.3. If that is a new to you, please have a look at the PHP manual.
Weiter lesen »
Keine Kommentare »
September 10th, 2009
| MySQL, PlanetMySQL (english)
The first production version of the MySQL Connector for OpenOffice.org has been released. You can download it from http://extensions.services.openoffice.org/project/mysql_connector. The driver is implemented as an OpenOffice.org extension and thus it is very easy to install. The driver can be used in OpenOffice.org 3.1.1 and the upcoming OpenOffice.org 3.2 to connect to MySQL 5.1 or newer. Installation and first steps are described on http://wiki.services.openoffice.org/wiki/Database/Drivers/MySQL_Native/1.0.
Weiter lesen »
Keine Kommentare »
September 7th, 2009
| MySQL, PlanetMySQL (english)
Andrey mentioned it long ago: MySQL Connector/C++ 1.1.0 makes use of some Boost components. The change impacts those who compile the MySQL driver for C++ from source. You need to have Boost 1.34.0 or newer installed on your build system. Users of a binary distribution do not need to take any action. Boost is not required when using the pre-compiled binaries. Nor is Boost needed to run client applications that make use of Connector/C++.
Boost is a highly regarded cross-platform library for C++ development used by many projects, for example OpenOffice.org. Some parts of Boost are included in the C++ Standards Committee’s Library Technical Report (TR1) and will be in the new C++0x Standard. Several other parts are either additions to TR1 or proposed for TR2. Boost is licensed under the terms of the Boost Software License which allows both commercial and non-commercial use.
Connector/C++ 1.1.0 uses a couple of "headers only" components. Among them the Any and Variant datatypes and some useful (smart|auto) pointers. They are all implemented as templates. Therefore you do not need to have any Boost binaries installed for building the driver nor does the driver link any binaries from Boost. You just need to have some Boost header files available for the build.
Weiter lesen »
Keine Kommentare »
September 4th, 2009
| MySQL, PlanetMySQL (english)
From 1.1.0 on, Connector/C++ can optionally use run-time dynamic linking to access the MySQL Client Library (AKA libmysql). If you make use of this new feature, it will not only change the application binary interface (ABI) but also has some impact on your client applications. The new expert setting is not enabled by default. By default, you will not notice any differences.
The next version of MySQL Connector/C++ will be numbered 1.1.0. 1.1.0 marks the successful end of the first year of development. The driver finally offers everything needed by its two "internal customers". Also, feedback from MySQL Workbench and Connector/OpenOffice.org and the bug inflow demonstrated the maturity that has been reached making it a logical step to bump up the version number.
While MySQL Workbench has been happy with the feature set for a while, we implemented a couple of changes in 1.1.0 to also please Connector/OpenOffice.org. The biggest change is on how MySQL Connector/C++ can load the MySQL Client Library to connect to the MySQL Server. As you may know, the MySQL driver for C++ does not implement the MySQL Client-Server Protocol itself. Instead the driver wraps and uses the MySQL Client Library, the C-API, to talk to the MySQL Server. From version 1.0.0 to 1.0.5 the driver has just linked the MySQL Client Library at compile time. But from 1.1.0 on you can either link the MySQL Client Library at compile time, which remains the "safe" and proven default, or you can instruct the driver to use run-time dynamic linking (dlopen() resp. LoadLibrary()) to load the library.
Weiter lesen »
Keine Kommentare »
July 24th, 2009
| Sonstige
Irgendwie, spiele ich gerade mehr mit Rollator und Knipser als mit dem Rechner. Vielleicht, weil es Sommer ist? Ich habe nie verstanden warum Google einen "Summer of Code" veranstaltet. Es gibt doch auch im Winter Semesterferien.
Keine Kommentare »
July 20th, 2009
| MySQL, PHP (deutsch)
Bei MySQL laufen rund um die Uhr automatisierte Testsysteme. Seit Jahren löst jede Änderung am Quellcode des MySQL Servers diverse Testläufe aus. Der Server wird automatisch auf allerlei Testmaschinen kompiliert und es wird die komplette Testsammlung ausgeführt. Am Ende steht man vor einer Matrix mit einigen tausend oder zehntausend einzelnen Testergebnissen. Aus den Daten werde im nächsten Schritt Zusammenfassungen generiert, die dem Entwickler helfen sollen die Nebenwirkungen einer Änderung frühzeitig zu erkennen.
Kontinuierliches Testen findet auch im Connectors-Team statt. Und es führt regelmäßig zum Streit. Vor jedem neuen MySQL-Release läßt der QA-Abgesandte alle Tests, deren er habhaft werden kann, auf einer Platform gegen den MySQL Release-Kandidaten laufen. Der weitere Verlauf des Freitagabend, es ist immer ein Freitag, weil die Testsysteme das Wochenende als Rechenzeit bekommen, ist monotoner als ein schwarz-weißer Stummfilm. Irgendein Test schlägt immer fehl. Wie im Fernsehen kommt es zur Wiederholung: welche Version vom Treiber soll getestet werden, welche Tests sollen benutzt werden, warum gibt es Testfehler und welche sind relevant?
Es gibt rund 20,000 Permutationen aus PHP-Test (ca. 560) und MySQL Buildplatformen (über 40). Ich habe keine Ahnung welche davon mit welcher PHP-Version, welchem MySQL-Server und welcher Codeversion auf welcher Platform welches Ergebnis liefern. Diese Antwort ist dem QA-Abgesandten zu wenig. Er fordert deshalb so lange an den Tests zu arbeiten bis alle Tests auf allen Platformen mit allen nur erdenklichen Randvariablen durchlaufen egal wie groß der Aufwand ist. Der Wunsch nach 0-Testfehlern scheint extrem ausgeprägt: ich habe erlebt wie Tests deaktiviert wurden, nur um die 0-Testfehler zu erreichen.
Weder ist es immer ökonomisch sinnvoll zu versuchen alles zu testen und stets 0-Testsfehler zu erreichen noch ist es eine gute Idee ungewünschte Tests zu deaktivieren. Die Grenze des Testens ist erreicht, wenn die Kosten für Bugfixes unter denen des Testens liegen. Das deaktivieren eines Tests, um 0-Testfehler zu erreichen ist falsch, da auch die Gleichheit eines Fehlers eine sinnvolle Information ist.
Andrey ist im Urlaub, Johannes war mit PHP 5.3 beschäftigt - Zeit für mich Testergebnisse in eine Datenbank einzulesen und die 0-Testfehler-Regel auszutauschen gegen eine Fuzzy-Logik, welche Testläufe vergleicht. Was interessiert es den QA-Abgesandten einer Randbedingung (MySQL Server, PHP Version) wie die Tests sich verhalten solange sie sich nur gleich verhalten, wenn die Randbedingung geändert wird. Er braucht das Delta. Siehe iframes (gefakte Testdaten).
Keine Kommentare »
July 16th, 2009
| Sonstige
… Roller halt.
Keine Kommentare »
July 16th, 2009
| PlanetMySQL (english), PHP (english)
(JavaScript countdown - less than 48 hours…)
Keine Kommentare »
July 14th, 2009
| MySQL, PlanetMySQL (english)
The subject says it. I will be giving a free german language webinar on the MySQL Connector/C++ today at 15:00 local time. Registration is still open. The headline says it is specifically for OEM users. I don’t agree. The webinar is a good overview presentation on the product suitable for any MySQL developer developing applications with C++ .
Due to vacation season we have not released Connector/C++ 1.0.6 yet. Both Andrey and I have huge amounts of accured vacation from MySQL times - the time when MySQL was still an independent company. The 24th of August has been scheduled as a build date for 1.0.6. If you check the bugs database at MySQL, you will find a couple of minor issues reported for 1.0.5. For example, you get an error if you don’t call cmake in the root directory of the source tree. I hope you understand that we don’t put extra force on release schedules when we only get reports about such minor issues.
For 1.0.6 we aim to support dynamic loading of the MySQL Client Library, we start to use some basic Boost data types where it makes sense and of course we will try to fix the issues reported by you.
Keine Kommentare »