Home |  MySQL Buzz |  FAQ |  Feeds |  Submit your blog feed |  Feedback |  Archive |  Aggregate feed RSS 2.0 English Deutsch Español Français Italiano 日本語 Русский Português 中文
Showing entries 1 to 18

Displaying posts with tag: c (reset)

Why Stored Programs?
+0 Vote Up -0Vote Down

Why should you use stored programs? Great question, here’s my little insight into a situation that I heard about in a large organization.

A very large organization is having a technology argument. In someway, like politics, half-truth drives this type of discussion. This company has hundreds of databases and they’re about half SQL Server and Oracle. The argument (half-truth) states that using T-SQL or PL/SQL yields “spaghetti” code!

It seems like an old argument from my perspective. After all, I’ve been working with T-SQL and PL/SQL for a long time. Spaghetti code exists in every language when unskilled programmers solve problems but the point here is one of software architecture, and an attempt to malign stored programming in general. Let’s examine the merit of the argument against stored programs.

First of all, the argument against stored

  [Read more...]
Separate docs for MySQL Connectors
+1 Vote Up -0Vote Down
The MySQL documentation section has always had this Topic Guides page containing links to the docs for the various MySQL Connectors -- the official database drivers for various languages and programming technologies. That is the most convenient way to get the information for each Connector in PDF form, rather than downloading the entire Ref Man PDF. For HTML, it was more of a shortcut, because
MySQL LDAP Authentication Plugin (Clear password client plugin)
+1 Vote Up -0Vote Down

Based on my last post MySQL LDAP Authentication Plugin, I received feedback from MySql Joro Blog by Oracle.

They told me:

Insted of writing (and having to deply) your own client plugin you probably can reuse the cleartext client side plugin, specially because it’s available in a number of mysql clients already. Check sql-common/client.c on MySQL 5.5+ for details.

This is very useful because you only need to put the plugin in server side, and in the client side you only need to check if the clear password plugin is enabled.

Now, I present the updated code with the only server side plugin, and I reused the cleartext client side plugin from MySql, it’s more short

  [Read more...]
MySQL LDAP Authentication Plugin
+3 Vote Up -0Vote Down

As a continuation of previous post, now, I will show how to make a mysql plugin for ldap authentication.

Get the mysql-server source code at http://dev.mysql.com/downloads/mysql/ (http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz/from/http://cdn.mysql.com/)

Installing necessary packages

yum groupinstall 'Development Tools'
yum install cmake ncurses-devel

Download source code, build and start MySQL Server

wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz/from/http://cdn.mysql.com/
tar -xzf mysql-5.5.27.tar.gz
cd mysql-5.5.25

# Preconfiguration setup
groupadd mysql
useradd -r -g mysql mysql

# Beginning of source-build specific instructions
cmake .
make
make install

# Postinstallation setup
chown -R mysql .
chgrp -R mysql .
./scripts/mysql_install_db
  [Read more...]
LDAP C Client Authentication Example (with OpenLDAP)
+0 Vote Up -0Vote Down

I have the goal of authenticate MySQL users with an LDAP server, currently, employees of my company are authenticated in several services (ftp, ssh, svn) through my LDAP server, except MySQL. (As you can imagine, I need to add manually every user in MySQL, a very tedious task).

In this post I only leave the example with LDAP authentication.

Installing necessary packages


yum groupinstall 'Development Tools'
yum install openldap-devel

Source ldapClient.c

#include <stdio.h>
#include <ldap.h>
/* LDAP Server settings */
#define LDAP_SERVER "ldap://nafiux.com:389"
int
main( int argc, char **argv )
{
LDAP        *ld;
int        rc;
char        bind_dn[100];

/* Get username and password */
if( argc != 3 )
{
perror( "invalid
  [Read more...]
Integer overflow
+0 Vote Up -1Vote Down

What do you think of this piece of C code?

  void foo(long v) {
    unsigned long u;
    unsigned sign;
    if (v < 0) {
      u = -v;
      sign = 1;
    } else {
      u = v;
      sign = 0;
    }
    ...
Seems pretty simple, right? Then what do you think of this output from MySQL:
  mysql> create table t1 (a bigint) as select '-9223372036854775807.5' as a;
  mysql> select * from t1;
  +----------------------+
  | a                    |
  +----------------------+
  | -'..--).0-*(+,))+(0( | 
  +----------------------+
Yes, that is authentic output from older versions of MySQL. Not just the wrong number, the output is complete garbage! This is my all-time favorite MySQL bug#31799. It was caused by code like the above C snippet.

So can you spot what is wrong with the code? Looks pretty simple, does it

  [Read more...]
Dennis Ritchie, the creator of C, dies at 70..
+2 Vote Up -0Vote Down
When I first got in touch with C it was in the early 1980's. I was a sysadmin at a Swedish telco operator (then THE Swedish Telco operator, Televerket, nowadays called Telia) for a system used for software development for a PABX system called A345 in Sweden, better known as Meridian in the rest of the world (co-developed by Televrket and Nortel). The Meridian system was the biggest of the non-custom built PABXes in those days. The language used to program it was called SL-1 (Switching Language 1) and the development system, like editors (vi / ined), compilers etc was running on a Unix system.

This sure was one of the earliest commercial uses for Unix, the Unix variant was version 6 and was not a BSD or anything like that, this was way before BSD really. Rather, the system was built by Interactive Systems which was the first commercial Unix

  [Read more...]
New algorithm for calculating 95 percentile
+1 Vote Up -0Vote Down

The 95 percentile for query response times is and old concept; Peter and Roland blogged about it in 2008. Since then, MySQL tools have calculated the 95 percentile by collecting all values, either exactly or approximately, and returning all_values[int(number_of_values * 0.95)] (that’s an extreme simplification). But recently I asked myself*: must we save all values? The answer is no. I created a new algorithm** for calculating the 95 percentile that is faster, more accurate, and saves only 100 values.***

Firstly, my basis of comparison is the 95 percentile algo used by

  [Read more...]
Hidden Features Of Perl, PHP, Javascript, C, C++, C#, Java, Ruby, Python, And Others [Collection Of Incredibly Useful Lists]
+2 Vote Up -0Vote Down

Introduction

StackOverflow is an amazing site for coding questions. It was created by Joel Spolsky of joelonsoftware.com, Jeff Atwood of codinghorror.com, and some other incredibly smart guys who truly care about user experience. I have been a total fan of SO since it went mainstream and it's now a borderline addiction (you can see my StackOverflow badge on the right sidebar).

The Story

Update 6/21/09: This server is currently under very heavy load (10-200), even with caching plugins enabled. Please bear with me as I try to

  [Read more...]
Three Great Beta Deliveries in One Week
Employee +0 Vote Up -0Vote Down

Three great beta deliveries in one week!

MySQL Connector/.Net 6.0.2 beta, a new version of the all-managed .NET driver for MySQL.

MySQL Connector/C++ 1.0.4 beta, a new release providing  C++ API for connecting client applications to the MySQL Server. If you know JDBC, this should be familiar to you.

MySQL Connector/C 6.0.0 beta, a new version of the C API for accessing MySQL database servers

Use them and let us know what you think.

Learn more about Connector/C++




  [Read more...]
Three Great Beta Deliveries in One Week
Employee +0 Vote Up -0Vote Down

Three great beta deliveries in one week!

MySQL Connector/.Net 6.0.2 beta, a new version of the all-managed .NET driver for MySQL.

MySQL Connector/C++ 1.0.4 beta, a new release providing  C++ API for connecting client applications to the MySQL Server. If you know JDBC, this should be familiar to you.

MySQL Connector/C 6.0.0 beta, a new version of the C API for accessing MySQL database servers

Use them and let us know what you think.

Learn more about Connector/C++




  [Read more...]
Three Great Beta Deliveries in One Week
Employee +0 Vote Up -0Vote Down

Three great beta deliveries in one week!

MySQL Connector/.Net 6.0.2 beta, a new version of the all-managed .NET driver for MySQL.

MySQL Connector/C++ 1.0.4 beta, a new release providing  C++ API for connecting client applications to the MySQL Server. If you know JDBC, this should be familiar to you.

MySQL Connector/C 6.0.0 beta, a new version of the C API for accessing MySQL database servers

Use them and let us know what you think.

Learn more about Connector/C++




  [Read more...]
A very fast FNV hash function for MySQL
+0 Vote Up -0Vote Down

I wrote a User-Defined Function that implements the FNV (Fowler-Voll-No) hash function for MySQL. I’m not the first person to do this — in fact, I was inspired by the Google patches for MySQL. But my implementation is a little bit different from most, in a very important way that leads directly to much higher performance, especially suited for the Maatkit tools.

A bit of background: FNV hashing is a very fast hash algorithm that operates in fixed memory. It is widely used in lots of important areas in computer science. My implementation requires absolutely no malloc() calls, which is a darn good thing because I am not to be trusted with

  [Read more...]
PBXT & DBT2: Dubugging C/C++ 101
+0 Vote Up -0Vote Down
Yesterday I starting testing PBXT using the DBT2 benchmark. Following the implementation of durability and SELECT FOR UPDATE for the engine I was more interested in the benchmark as a test for stability and concurrency than performance. I was not disappointed...

Which bug first?

Well I immediately ran into 3 bugs. Isn't it funny how bugs often come in batches, which leaves you thinking: "Oh sh.. where do I start?". Here's my advice: start with the bug that is most likely to disappear if you fix the others!

A simple example, you have 2 bugs: an unexpected exception is occurring, and you're loosing memory. First look for the memory loss, because it may disappear when you fix the exception (because you may be loosing memory in the error handler).

Take things one problem at time:

Another thing: once you have decided for one of the bugs,









  [Read more...]
How I patched InnoDB to show locks held
+0 Vote Up -0Vote Down

I've written before about how to figure out which connection is holding the InnoDB locks for which other connections are waiting. In other words, how to figure out who's blocking you from getting work done. The short and sweet: turn on the InnoDB lock monitor and use innotop to look at the locks held and waited-for. This has some disadvantages, so I made a patch to solve the issue the way I like it. The result is significantly more ability to find and solve InnoDB lock wait issues.

How I built the NOW_USEC() UDF for MySQL
+0 Vote Up -0Vote Down

Last week I wrote about my efforts to measure MySQL's replication speed precisely. The most important ingredient in that recipe was the user-defined function to get the system time with microsecond precision. This post is about that function, which turned out to be surprisingly easy to write.

The case of a color-blind painter.
+0 Vote Up -0Vote Down
I'm happy it turned out to be that simple, but the amount of such bugs and devastating consequences are humiliating.
Bug#7209 is a case of an intermittent failure when the best brain of Support department and dozens of man hours had to be spent to track the issue down to a repeatable test case. And the cause is such a trivial design mistake:
typedef struct st_hash {
  uint key_offset,key_length;           /* Length of key if const length */

  uint records,blength,


  [Read more...]
Description of MaxDB code tree
+0 Vote Up -0Vote Down
I had a conversation with Daniel Dittmar, one of the developers on the SAP team today. I am trying to get familiar with the MaxDB codebase, and it's difficult to do without at least a bit of explanation. The inline English documentation is written by native German speakers, so it's often difficult to discern. Having this map will help me quite a bit. I hope it helps some others as well.

Thanks very much to Daniel for putting an evening in to documenting this.





12:56 DanielD: can you point me to some docs on the maxdb source code?
12:56 why are the different parts named with such short and
difficult-to-remember names? :)
12:57 partly, because if you work with them day in, day out, you
remember them anyway and they are easier to type
12:57 :)
12:58 what documentation












  [Read more...]
Showing entries 1 to 18

Planet MySQL © 1995, 2014, Oracle Corporation and/or its affiliates   Legal Policies | Your Privacy Rights | Terms of Use

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.