0

I'm using postgresql 9.0 beta 4.

After inserting a lot of data into a partitioned table, i found a weird thing. When I query the table, i can see an empty row with null-like values in 'not-null' fields.

That weird query result is like below.

alt text

689th row is empty. The first 3 fields, (stid, d, ticker), are composing primary key. So they should not be null. The query i used is this.

select * from st_daily2 where stid=267408 order by d

I can even do the group by on this data.

select stid, date_trunc('month', d) ym, count(*) from st_daily2 
where stid=267408 group by stid, date_trunc('month', d)

The 'group by' results still has the empty row.

alt text

The 1st row is empty. But if i query where 'stid' or 'd' is null, then it returns nothing.

Is this a bug of postgresql 9b4? Or some data corruption?

EDIT :

  1. I added my table definition.

    CREATE TABLE st_daily
    (
    stid integer NOT NULL,
    d date NOT NULL,
    ticker character varying(15) NOT NULL,
    mp integer NOT NULL,
    settlep double precision NOT NULL,
    prft integer NOT NULL,
    atr20 double precision NOT NULL,
    upd timestamp with time zone,
    ntrds double precision
    )
    WITH (
    OIDS=FALSE
    );
    
    
    CREATE TABLE st_daily2
    (
    CONSTRAINT st_daily2_pk PRIMARY KEY (stid, d, ticker),
    CONSTRAINT st_daily2_strgs_fk FOREIGN KEY (stid)
        REFERENCES strgs (stid) MATCH SIMPLE
        ON UPDATE CASCADE ON DELETE CASCADE,
    CONSTRAINT st_daily2_ck CHECK (stid >= 200000 AND stid < 300000)
    )
    INHERITS (st_daily)
    WITH (
    OIDS=FALSE
    );
    
  2. The data in this table is simulation results. Multithreaded multiple simulation engines written in c# insert data into the database using Npgsql.

  3. psql also shows the empty row.

alt text

3 Answers 3

1

You'd better leave a posting at http://www.postgresql.org/support/submitbug

Some questions:

  1. Could you show use the table definitions and constraints for the partions?
  2. How did you load your data?
  3. You get the same result when using another tool, like psql?
2
  • Thanks for your answer. I added answers for your questions on my post.
    – tk.
    Aug 30, 2010 at 13:45
  • I submitted a bug report to the postgresql.org and got the reply that it requires the approval of the moderators.
    – tk.
    Aug 30, 2010 at 13:51
1

The answer to your problem may very well lie in your first sentence:

I'm using postgresql 9.0 beta 4.

Why would you do that? Upgrade to a stable release. Preferably the latest point-release of the current version. This is 9.1.4 as of today.

0

I got to the same point: "what in the heck is that blank value?"
No, it's not a NULL, it's a -infinity.

To filter for such a row use:

WHERE 
  case when mytestcolumn = '-infinity'::timestamp or
            mytestcolumn = 'infinity'::timestamp 
  then NULL else mytestcolumn end IS NULL

instead of:

WHERE mytestcolumn IS NULL
2
  • Neither psql nor pgAdmin show an empty cell for infinity or -infinity. Also, the row has all kinds of data types. Aug 6, 2012 at 17:22
  • "infinity" and "-infinity" might only occur when using NpgSql (=.NET Connector for PgSql) as I did - and not on direct access using psql nor pgAdmin.
    – Jochen
    Mar 2, 2016 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.