Skip to main content

Posts

Showing posts with the label postgresql

When simple SQL can be complex

I think SQL is a very simple language, but ofcourse I'm biased. But even a simple statement might have more complexity to it than you might think. Do you know what the result is of this statement? SELECT FALSE = FALSE = TRUE; scroll down for the answer. The answer is: it depends. You might expect it to return false because the 3 items in the comparison are not equal. But that's not the case. In PostgreSQL this is the result: postgres=# SELECT FALSE = FALSE = TRUE; ?column? ---------- t (1 row) So it compares FALSE against FALSE, which results in TRUE and then That is compared against TRUE, which results in TRUE. PostgreSQL has proper boolean literals . Next up is MySQL: mysql> SELECT FALSE = FALSE = TRUE; +----------------------+ | FALSE = FALSE = TRUE | +----------------------+ | 1 | +----------------------+ 1 row in set (0.00 sec) This is similar but it's slightly different. The result is 1 because in My...

Installing Multicorn on RHEL6

The Multicorn project makes it possible to write Foreign Data Wrappers for PostgreSQL in Python. To install Multicorn on RHEL6 the following is needed: PostgreSQL 9.2 Python 2.7 make, GCC, etc. Installing PostgreSQL 9.2 is easy as it's available in the PostgreSQL Yum repository . Unfortunately Python 2.7 is not included in RHEL6. And replacing the 'system' python is a bad idea. The solution is to do an 'altinstall' of Python. The "--shared" and ucs4 options are required. The altinstall will install a python binary with the name python2.7 instead of just python. This allows you to have multiple python versions on 1 system. wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz tar zxf Python-2.7.3.tgz cd Python-2.7.3 ./configure --shared --enable-unicode=ucs4 make make altinstall This will result in a /usr/local/bin/python2.7 which doesn't work. This is due to the fact that the libraries are installed /usr/local/lib, which is...

How to install PGXN on RHEL6

Installing PGXN on RHEL 6.3 is not as easy as it might sound. First you need to install the PostgreSQL yum repo: rpm -ivh http://yum.postgresql.org/9.2/redhat/rhel-6.3-x86_64/pgdg-redhat92-9.2-7.noarch.rpm Then you need to install pgxnclient: yum install pgxnclient The pgxn client has 2 dependencies which are not listed in the package: setuptools simplejson 2.1 To satisfy the first dependency we need to install python-setuptools yum install python-setuptools The second one is not that easy as the simplejson version in RHEL6.3 is 2.0, which is too old. We can use PIP to install a newer version: yum remove python-simplejson yum install python-pip python-devel python-pip install simplejson And now the pgxn command will work.

XA Transactions between TokuDB and InnoDB

The recently released TokuDB brings many features. One of those features is support for XA Transactions. InnoDB already has support for XA Transactions. XA Transactions are transactions which span multiple databases and or applications. XA Transactions use 2-phase commit, which is also the same method which MySQL Cluster uses. Internal XA Transactions are used to keep the binary log and InnoDB in sync. Demo 1: XA Transaction on 1 node: mysql55-tokudb6> XA START 'demo01'; Query OK, 0 rows affected (0.00 sec) mysql55-tokudb6> INSERT INTO xatest(name) VALUES('demo01'); Query OK, 1 row affected (0.01 sec) mysql55-tokudb6> SELECT * FROM xatest; +----+--------+ | id | name | +----+--------+ | 3 | demo01 | +----+--------+ 1 row in set (0.00 sec) mysql55-tokudb6> XA END 'demo01'; Query OK, 0 rows affected (0.00 sec) mysql55-tokudb6> XA PREPARE 'demo01'; Query OK, 0 rows affected (0.00 sec) mysql55-tokudb6> XA COMMIT 'demo01...

Same query, 3 databases, 3 different results

The SQL standard leaves a lot of room for different implementations. This is a little demonstration of one of such differences. SQLite  3.7.4 sqlite> create table t1 (id serial, t time); sqlite> insert into t1(t) values ('00:05:10'); sqlite> select t,t*1.5 from t1; 00:05:10|0.0 MySQL 5.6.4-m5 mysql> create table t1 (id serial, t time); Query OK, 0 rows affected (0.01 sec) mysql> insert into t1(t) values ('00:05:10'); Query OK, 1 row affected (0.00 sec) mysql> select t,t*1.5 from t1; +----------+-------+ | t        | t*1.5 | +----------+-------+ | 00:05:10 |   765 | +----------+-------+ 1 row in set (0.00 sec) PostgreSQL 9.0.3 test=# create table t1 (id serial, t time); NOTICE:  CREATE TABLE will create implicit sequence "t1_id_seq" for serial column "t1.id" CREATE TABLE test=# insert into t1(t) values ('00:05:10'); INSERT 0 1 test=# select t,t*1.5 from t1;     t ...

OSS-DB Database certification

What will be first? The new and updated MySQL certification or the new OSS-DB exam which is announced by LPI in Japan? The OSS-DB is only for PostgreSQL for now, but will cover more opensource databases in the future. There seem to be two levels: Silver: Management consulting engineers who can improve large-scale database Gold: Engineers who can design, development, implementation and operation of the database The google translate version can be found here . I found this info on Tatsuo Ishii's blog