OpenIndiana and PostgreSQL

The magic begins

Subscribe to RSS feed

Sticky post

503 Anyone?

, ,

Apparently My Opera has been experiencing a DDoS attack and has had to shut down a few services. This results in spurious 503 and 502 error messages.

Performing SQL with PL/Java in PostgreSQL

, , , ...

Here we give an example of SQL in PL/Java. The first one shows how a function can perform a simple query based on a primary key and return the results. The next example shows how the JDBC driver can be used to connect to external PostgreSQL database instances; or the same one for semi–autonomous transactions. The final example shows how the Oracle JDBC driver can be used to achieve the same thing.

This final example can be extremely useful when Postgres is run on a system for which there is no native driver for Oracle and hence the PostgreSQL Foreign Data Wrapper for Oracle is unlikely to work. People running Postgres on FreeBSD may benefit from this.

While knowledge of PostgreSQL and PL/Java is assumed, the installation instructions and the provided script should help novices to get started.

The examples are PostgreSQL licensed.

Read more...

Parsing command line parameters with Yacc & Flex

, , ,

Every once in a while someone comes along and asks how to parse command line parameters with Yacc & Flex. This is rather straight forward, but requires some knowledge of the generated code to get right.

Here we present a source template that does this. The user only has to edit the grammar and scanning rules. Some knowledge of C, Yacc and Flex is assumed.

The code is Boost licensed

The template is written for Berkeley Yacc and the reflex variant of Flex. It may be made to work with GNU Bison and SourceForge Flex, possibly with a few changes.

Read more...

Set Returning Functions with PL/Java in PostgreSQL

, , ,

There are three different ways to return sets from PL/Java stored procedures in PostgreSQL. Here we go through the steps necessary to return a set of the basic types using an Iterator and complex types with the ResultSetProvider interface.

Further information can be found on the PL/Java wiki: Functions Returning Sets.

The reader is assumed to be familiar with writing and installing Java stored procedures.

Read more...

Passing parameters to Yacc and Flex

, , ,

Here we go through the steps needed to pass parameters to the yyparse() and from that to yylex(). Familiarity with C, Flex and Yacc is assumed.

This document is written for Berkeley Yacc and the reflex variant of Flex. Presumably GNU Bison and SourceForge Flex will work as well.

Read more...

Using libcurl to shorten links with bitly in C++

, ,

Using both libcurl and bitly is fairly easy. The following can be viewed as a tutorial of either.

Here we go through the steps of using libcurl to call the bitly API access point for shortening an URL given on the command line. It is assumed libcurl has been installed correctly. It is also up to the reader to create a bitly account and find the API key.

Read more...

PostgreSQL JDBC with GCJ

, , ,

It is fairly easy to use the PostgreSQL JDBC driver with GCJ.

As of GCC 4.1 (used in this example) it does not compile the JDBC 4 driver, so JDBC 3 was used.

Step 1: Download the JDBC 3 driver from the PostgreSQL JDBC website.

Step 2: Compile the jar file:
gcj -c postgresql-9.1-901.jdbc3.jar

Step 3: In the application, load the driver with
Class.forName( "org.postgresql.Driver" );
Note that this is not needed when using the JDBC 4 driver with Oracle Java or OpenJDK.

Step 4: Compile the application
gcj -c Hello.java

Step 5: Link the object files with postgresql-9.1-901.jdbc3.o:
gcj -o hello --main=Hello Hello.o postgresql-9.1-901.jdbc3.o

The example application does nothing but print out the connection object to demonstrate it was able to connect to the database. If it does not connect an exception is thrown which prints a stack trace instead.

Downloads

Using identd to authenticate local connections to PostgreSQL

,

The steps needed to setup and use identd to authenticate PostgreSQL are not very well documented with few examples floating on the web.

Here we go over the steps needed. The examples as shown are done on a virgin CentOS installation. The presence of a PostgreSQL server is presumed.

Read more...

Building a relocatable PostgreSQL server

,

Normally, when building a Postgres server the run-time link path is hard coded to the installation directory. This article goes through the steps neccesary to make it depend on the location of the executables instead so the server installation can safely be moved around. Some familiarity with building a Postgres server is assumed.

Note: This article applies only to Unix systems; at least FreeBSD, Linux and Solaris. Some commands are prefixed with g to emphasize we're using the GNU versions.

Read more...

Debugging PL/Java Applications with Solaris Studio dbx

,

Debugging PL/Java applications as well as PL/Java itself, whether the Java or C code is pretty straight forward. It does however require some setup. Here we go into the details of the setup and demonstrate debugging of a simple "Hello World!" application with Solaris Studio dbx.

This is not a PL/Java tutorial. Some familiarity with it is assumed.

Note: This demonstration applies to dbx on Solaris amd64. Using it on ia32 as well as Linux should be identical.

Read more...