Git Product home page Git Product logo

Comments (3)

jcflack avatar jcflack commented on August 19, 2024

Hi @paulbrasted

I don't know whether you are still in a position to give more details on this issue, but I have tried to construct a test case based on what you've reported. Here's what I came up with. The trouble is, in my environment it works as expected and doesn't crash. I wonder if you could try it in an empty db in yours.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;

import java.util.logging.Logger;

import org.postgresql.pljava.annotation.SQLAction;
import org.postgresql.pljava.annotation.SQLActions;
import org.postgresql.pljava.annotation.Function;

@SQLActions({
  @SQLAction(provides="invoice_batch table", install=
    "CREATE TABLE invoice_batch AS " +
    "SELECT now() AS time_created, 42 AS id", remove=
    "DROP TABLE invoice_batch"
  ),
  @SQLAction(requires={"invoice_batch table","whenCreated fn"}, install=
    "SELECT whenCreated(42)"
  )
})
public class ttest
{
  @Function(provides="whenCreated fn")
  public static void whenCreated(Integer batch)
  throws SQLException
  {
    Timestamp createTimeStamp = null;
    java.sql.Connection sqlConnection =
      DriverManager.getConnection("jdbc:default:connection");
    String sql = "SELECT time_created FROM invoice_batch where id = "
      + batch.toString();
    ResultSet result = sqlConnection.createStatement().executeQuery(sql);
    if (result.next()) {
      createTimeStamp = result.getTimestamp("time_created");
    }
    Logger.getAnonymousLogger().warning(String.valueOf(createTimeStamp));
  }
}

If you build a jar from the above, say ttest.jar, you can run the test simply with SELECT sqlj.install_jar('file:///path/to/ttest.jar', 'ttest', true); and if things are working it should produce a WARNING with the timestamp value. In your case, I guess it should crash. Or if it doesn't crash, perhaps you could look for how it is different from your first example and what needs to be changed until it does crash?

Thanks,
-Chap

from pljava.

paulbrasted avatar paulbrasted commented on August 19, 2024

Hi Chap
Thanks for response. Give me a couple of days
Paul
On 5 Oct 2015 04:51, "Chapman Flack" [email protected] wrote:

Hi @paulbrasted https://github.com/paulbrasted

I don't know whether you are still in a position to give more details on
this issue, but I have tried to construct a test case based on what you've
reported. Here's what I came up with. The trouble is, in my environment it
works as expected and doesn't crash. I wonder if you could try it in an
empty db in yours.

import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Timestamp;
import java.util.logging.Logger;
import org.postgresql.pljava.annotation.SQLAction;import org.postgresql.pljava.annotation.SQLActions;import org.postgresql.pljava.annotation.Function;

@SQLActions({
@SQLAction(provides="invoice_batch table", install=
"CREATE TABLE invoice_batch AS " +
"SELECT now() AS time_created, 42 AS id", remove=
"DROP TABLE invoice_batch"
),
@SQLAction(requires={"invoice_batch table","whenCreated fn"}, install=
"SELECT whenCreated(42)"
)
})public class ttest
{
@function(provides="whenCreated fn")
public static void whenCreated(Integer batch)
throws SQLException
{
Timestamp createTimeStamp = null;
java.sql.Connection sqlConnection =
DriverManager.getConnection("jdbc:default:connection");
String sql = "SELECT time_created FROM invoice_batch where id = "
+ batch.toString();
ResultSet result = sqlConnection.createStatement().executeQuery(sql);
if (result.next()) {
createTimeStamp = result.getTimestamp("time_created");
}
Logger.getAnonymousLogger().warning(String.valueOf(createTimeStamp));
}
}

If you build a jar from the above, say ttest.jar, you can run the test
simply with SELECT sqlj.install_jar('file:///path/to/ttest.jar', 'ttest',
true); and if things are working it should produce a WARNING with the
timestamp value. In your case, I guess it should crash. Or if it doesn't
crash, perhaps you could look for how it is different from your first
example and what needs to be changed until it does crash?

Thanks,
-Chap


Reply to this email directly or view it on GitHub
#47 (comment).

from pljava.

jcflack avatar jcflack commented on August 19, 2024

Have not heard from Paul since October, but noticing this involved timestamps and Windows gives it a very strong smell of the MSVC global-variable mislinkage business and I would bet it is fixed by 1f1e8fe.

Closing.

from pljava.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.