Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id BC180F7659; Wed, 11 Apr 2012 11:48:07 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SHyq4-0008Jc-An; Wed, 11 Apr 2012 14:48:06 +0000 Received: by pbcun15 with SMTP id un15so1314071pbc.19 for ; Wed, 11 Apr 2012 07:47:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-type:content-transfer-encoding:x-mailer :thread-index:content-language; bh=SdkwyAeHVIfZxdY786bWeCNLnem6aDtPsmua2pb06nI=; b=kecwoeU8FFqadR/UNu3hhVP7CX1CX6UbsbVh5rqkDOJlG0NnS2PXJIqvScyFG8rffC o+8VfX82sZchgGMxeI4c07KBr514diT1pYi06l4YcUqqHbo0oAlb9+uJ6F83konJLGY8 tOR+OAvV+nbuaRS5qerdBzWc5bgcUtNuAnSUefFjgonMr6cTUFMLKKUIyi+IxLyTfDIr pFVJXnwTboy7azfqMTeZtUg/IWNsTBpPrXA9sPruSV/QKzSxNN74jed87gZnvcRk99Jq 9tuWLzJWEti8Gh6l9GHxurTcfiKs3MMGB78cQhefrtBEGyQZKxvpjMyuf6pcv4TVcB5k scjQ== Received: by 10.68.217.201 with SMTP id pa9mr38609962pbc.73.1334155670259; Wed, 11 Apr 2012 07:47:50 -0700 (PDT) Received: from GITCPC ([122.177.230.99]) by mx.google.com with ESMTPS id f8sm3064766pbe.42.2012.04.11.07.47.45 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Apr 2012 07:47:49 -0700 (PDT) From: "Atri Sharma" To: "'Merlin Moncure'" Cc: "'Tom Lane'" , "'Andrew Dunstan'" , "'Dave Cramer'" , "'Pg Hackers'" , References: <4f802005.cc76440a.668b.ffffcd8e@mx.google.com> <4F831234.7040209@dunslane.net> <4F8438AD.7060503@dunslane.net> <4F844089.2050308@dunslane.net> <4F84480F.1020905@dunslane.net> <9511.1334071505@sss.pgh.pa.us> <9745.1334072198@sss.pgh.pa.us> < CAHyXU0z93NV5Q=UeaeSLkYN272KDsVX0Wrd=VHLMJ_-qeGEvug@mail.gmail.com> <4f84fd5f.a93b440a.2eed.42c4@mx.google.com> In-Reply-To: Subject: Re: [JDBC] Regarding GSoc Application Date: Wed, 11 Apr 2012 20:17:40 +0530 Message-ID: <4f859995.8813440a.399d.ffffa11c@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac0X8I0SEOlJRUPASsiWzBYkLf5AgAAAFoow Content-Language: en-in X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201204/580 X-Sequence-Number: 206383 On Tue, Apr 10, 2012 at 10:41 PM, Atri Sharma wrote: >>>Well. maybe I spoke too soon...JNI is probably the best route. Since >>>SPI is off the table, all we're really pulling in from pl/java is the >>>(non-trivial) proper installation of a jvm into a postgres process. >>>pl/java is essentially a wrapper to JNI that does postgres to jni type >>>conversion and builds a database driven class lookup system that >>>allows building the java environment inside the database. That part >>>is not needed at all; since we're not going to install our routines as >>>pl/java installed they will be installed into a separate and more >>>typical class path from a jvm point of view. There are no exposed >>>routines in pljava.so that allow for easy manual invocation of a java >>>routine -- it's all pretty much hardwired to the language function >>>call handler system. >>> >>>This begs the question about why pl/java should be used at all. Well, >>>as I said the jvm insertion into postgres is non-trivial so that alone >>>is worth something. Maybe though we should just rip out the jvm guts >>>that we really need (mostly some parts of backend.c and some of the >>>type files) and do a completely standalone jni wrapper. pl/java's >>>build system is a mess anyways so we're not losing all that much in >>>trying to go off on our own and do something. OTOH, throwing a build >>>system on top of the growing pile of things to do is turning this into >>>a daunting project vs the (admittedly cobbled together) approach I was >>>hoping to do earlier. Anyways, it's really Atri's call if he's >>>comfortable proceeding. >> >> Hi All, >> >> I think we are back on the initial approach I proposed(hooking directly into >> the JVM and executing Java code that calls JDBC).I think the best way to do >> this is create a JVM that executes the Java code and give the control of the >> JVM to the native API. >> >> I agree,the only need of Pl/Java that is apparent here is the need of the >> Java internals(JDK et al).If we set them up independently,then,we can have >> the FDW wrapping JDBC directly through JNI.JNI would call pure Java >> functions to connect to the JDBC. >> >> I think we can proceed with this.Once we are done with the API calling Java >> functions,I think the rest of the path is easily mapped(writing Java >> functions to connect to JDBC). > >yeah -- it sound plausible. I think the next step is to pull one of >the fdw projects that is working and currently builds with pgxs. Make >sure it is bsd licensed and that you retain the original copyright in >the code (feel free to add your own). The mysql_fdw project for >example is a good candidate. After that we need to strip out all the >mysql specific parts so that we have a basic skeleton of the fdw >wrapper that still builds. From there we will need to build in the >jni calls as well as jvm initialization code we are going to more or >less directly copy from pl/java, but one thing at a time: IMO, >getting the jvm installed and executing a 'hello world' jni is a good >milestone to reach before getting into all the mechanics of the remote >querying. > >The jvm initialization code in pl/java we are going to use is in >src/C/pljava/backend.c. A lot of the initialization work done there >is irrelevant to what we are trying to do but there are some very >important bits like the on_proc_exit handler that does cleanup when >the postgres process exits. Ideally we can drop just the stuff we >need from there and get our project to compile. > I agree,atm I'll work on getting JNI set up and to build a JVM using it and getting the "Hello,World" running in it in PostGreSQl. I'll keep you posted, Atri