Sunday, July 27, 2008

apache didn't start after installing subversion

I installed apache long before. Recently I installed subversion and thought everything is OK. But actually it wasn't. When I tried to start apache, i got this error:

$ /usr/local/apache2/bin/apachectl start
[Mon Jul 28 11:13:10 2008] [warn] module ferite_module is already loaded, skipping
[Mon Jul 28 11:13:11 2008] [warn] module php5_module is already loaded, skipping
Syntax error on line 1048 of /usr/local/apache2/conf/httpd.conf:
Cannot load /usr/local/apache2/modules/ into server: /usr/local/apache2/modules/ undefined symbol: dav_xml_get_cdata

This time, it took little time to solve this problem. I reinstalled apache using these steps:

$ ./configure --prefix=/usr/local/apache2 --enable-dav --enable-so
$ make
$ sudo make install

And everything is ok now :)

Monday, July 21, 2008

Using svn and got "Unrecognized URL scheme."

This morning, I built subversion-1.5.0 from source using the ./configure, make and make install. Then I tried to check out a repository and got this error:
$ svn checkout --username azim.babu
svn: Unrecognized URL scheme for ''

It seemed to be a curious problem to analyze. So I did some googling and found these from :

Subversion uses a plugin system to allow access to repositories. Currently there are three of these plugins: ra_local allows access to a local repository, ra_dav which allows access to a repository via WebDAV, and ra_svn allows local or remote access via the svnserve server. When you attempt to perform an operation in Subversion, the program tries to dynamically load a plugin based on the URL scheme. A `file://' URL will try to load ra_local, and an `http://' URL will try to load ra_dav.

The error you are seeing means that the dynamic linker/loader can't find the plugins to load. This normally happens when you build Subversion with shared libraries, then attempt to run it without first running 'make install'. Another possible cause is that you ran make install, but the libraries were installed in a location that the dynamic linker/loader doesn't recognize. Under Linux, you can allow the linker/loader to find the libraries by adding the library directory to /etc/ and running ldconfig. If you don't wish to do this, or you don't have root access, you can also specify the library directory in the LD_LIBRARY_PATH environment variable.

So what I got is that I was not able to setup the SVN on my ubuntu box properly. Here even after compiling the source I was not able to enable the support of ra_dav module for http and https protocol. So I did a little googling again and found that I was missing neon. So I download neon from , extract the tarball and install neon using ./configure, make and make install.
Then I recompile subversion as follows:
$ ./configure --with-ssl --with-apr=/usr/local/apache2/bin/apr-config --with-apr-util=/usr/local/apache2/bin/apu-config --with-neon=/usr/local
$ make
$ sudo make install

A little explanation of the above options are:

--with-apr : prefix for installed APR, path to APR build tree, or the full path to apr-config

--with-apr-util : prefix for installed APU, path to APU build tree, or the full path to apu-config

--with-neon : Determine neon library configuration based on 'PREFIX/bin/neon-config'. Default is to search for in a subdirectory of the top source directory.

As I installaed neon without any option during configure, it should be /usr/local for my case :P

Although all these steps may seem to be very much intuitive for many, I think for newbies, this type of blog post may provide some sort of quick help. :)

Monday, March 31, 2008

libdbi..TEXT Datatype..MySQL VS PostgreSQL

I am currently working with porting a very much sophisticated & advanced NLP software/system written in C++ which is actually targeted to run using a MySQL Database.

My current or short term target is to port it to PostgreSQL.

After created necessary & equivalent tables in PostgreSQL database, I wrote a script to transfer data from MySQL database to PostgreSQL database.
After some fixing it worked fine.

Then I ran the software using PostgreSQL database. loading failed :(

I found that if I just changed the database driver from "pgsql" to "mysql" it worked fine.
The problem occurred if database driver is changed from "mysql" to "pgsql"

I thoroughly investigated the table definitions and data in various tables and found that the problem was not originated from the database end.

So, why I faced the problem?? Why???? :(

After loosing some valuable hairs:(, I found this:

In case of MySQL database, libdbi-driver for MySQL wants to fetch TEXT as binary and thats why in the original source code of the software, dbi_result_get_binary was used to fetch TEXT type data.

But, in case of PostgreSQL database, this is different. i.e. libdbi-driver for PostgreSQL wants to fetch TEXT as string not binary.
So, the fix is to replace dbi_result_get_binary with dbi_result_get_string

Ahh...The world is beautiful again :D

Saturday, March 29, 2008

Adding custom DISTINCT ON behavior

In a typical query we sometimes use Distinct keyword to eliminate duplicate rows.

SELECT DISTINCT column1, column2, column3.... FROM table1 WHERE ....

This elimination of duplicate rows occurs after the result table has been generated & the selected columns has been processed (if needed)

Two rows are considered distinct if they differ in at least one column value.
Null values are considered equal in this case.

But this default & obvious consideration can be customized. How? Ok..let me explain with an example.

Say we have a table named Student

Name Bengali English Math
Alex 70 85 96
Barnabus 96 70 85
Alfred 96 70 84

Say, you want to consider those students as distinct who has different total marks of Bengali, English & Math.
So the first two students are not distinct, the first & third are distinct and the 2nd & third are distinct.

SELECT DISTINCT ON (Bengali+English+Math) Name
FROM Student;

Now think yourself about a case where you can apply this custom behavior of Distinct and if you find any then don't hesitate to let me know ;P

SQL..Problems with Distinct ON

The DISTINCT ON clause is not part of the SQL standard &
its result is not always determinate.
So although it is often the most obvious alternative & convenient also, think twice before using it.
Ask yourself:
1. Do I want sql written by me to be portable to sometoher DBMS?
2. Do I want to avoid indeterminate nature of result?

If any of the above question is NO, then try to use GROUP BY and subqueries in FROM to implement the same thing and avoid Distinct ON.


When using LIMIT, it is important to use an ORDER BY clause that constrains the result rows into a unique order. Otherwise you will get an unpredictable subset of the query's rows.

Don't forget to use an ORDER BY clause while using LIMIT. Why?

It's because it will prevent you to get an unpredictable subset of the whole result set.
Say, you have 30 rows whole result set (i.e. the result set without LIMIT and OFFSET) First you provide LIMIT 2 OFFSET 15. Next you provide LIMIT 5 OFFSET 15. Now you cant say it with full confidence that there will be common rows in these two cases. Your natural intuition says it should be. But it may not be.

Why this happend?

It is because, the query optimizer takes LIMIT into account when making a query plan, so you may get different plans (yielding different row orders) depending on your provided LIMIT and OFFSET.

Monday, March 10, 2008

Get list of databases and tables in a database..Postgresql

To get list of databases in MySQL you can simply run :
SO what is the equivalent sql statement in Postgresql:
select datname from pg_database;

To get list of tables in a postgres database:

SELECT * FROM pg_tables;

Offcourse you can get list of tables using \dt from the command
prompt for postgres.I am just telling about doing it using sql
query which you can also use outside of command prompt for

very simple indeed.. Isn't it;P

Sunday, February 24, 2008

CUET Workshop

The weekend went on in its own way without giving me any sort of control on it. But this time I didn't mind.
So much ups and downs happened that I wont forget it...Well I hope so but cant give any guaranty for it. ;)
The train journey from Dhaka to Chittagong was joss. That night was really nice....nice to see...nice to enjoy
The first day of workshop was nice before my presentation session on that day.
Honestly speaking, I wasn't happy in any sense about the way I gave my presentation on shell scripting. The slides were not bad. The content was good. I spent sometime for making them . But may be because of tiredness for not sleeping at all the night before that day or perhaps being interrupted 2/3 times by someone during my presentation, I couldn't give the young guys 100% according my plan. But besides this, I am happy that one guy personally talked with me and showed his interest on shell scripting. Thanks Allah. Something is better than nothing :)
Personally, I cant be happy until I m convinced that I make technical stuffs crystal clear for ppl to understand it 100%. Anyway...
After my presenation I wasn't in a good shape mentally...But when we did a trip of CUET campus by bus the shape changed again :) The campus is nice..beautiful..amazing. The photo session using A-man's camera was joss along with our teammates & off course with Tareq bhai. Btw, Tareq bhai is my boss :)
The shape changed again at late night..I couldnt push myself to sleep that night. Man....what a bullshit night that was. So much stupid and unfortunate I was...couldn't sleep for two nights in a row :(
I was in two minds whether I would go to CUET again or catch any thing like bus ..train etc. for returning Dhaka in the morning 1st hour. I did the first one and thanks Allah...the shape changed again. We passed so lively so energetic day that It's difficult even for a ppl having 256 RAM like me to forget it ;)
Thanks A-man...U r just great (Btw dont forget abt my fees, A-man ;)) Thanks all other guys like Adnan, Yaffi (Pardon me If misspelled) ...thank you guys. We did something that day which deserves a party :D
I am happy on my presentation on AJAX. I love AJAX..I m so passionate abt it. This time my love & my passion didn't betray with me. I think this time I did better than shell script stuffs ;)
Btw, Shahnur bhai is a nice man.
The return from CUET to ctg town was nice...nice session...nice guys around me.
It made a guy like me to sing in public...(well , although I m a good bathroom singer) The students with us in the bus like ......... Damn my memory leaks again :( Anyway, sorry but nice bus journey.