[GENERAL] False unique constraint violation (exception block)

2013-04-12 Thread whiplash
Hello. This is simple example for describe my problem. I created a table: CREATE TABLE table0 ( id serial NOT NULL, field0 integer, field1 text ); I created an unique index for this table: CREATE UNIQUE INDEX idx_table0_unique ON table0 ( field0, coalesce ( field1, 'INDEX_COLUMN_N

Re: [GENERAL] False unique constraint violation (exception block)

2013-04-13 Thread whiplash
PostgreSQL version: PostgreSQL 9.2.2 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit OS: Ubuntu 12.10 Linux machine0 3.5.0-26-generic #42-Ubuntu SMP Fri Mar 8 23:18:20 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux As for my case, I use this function as fun

Re: [GENERAL] False unique constraint violation (exception block)

2013-04-15 Thread whiplash
I found error in my DB - sequence for column id had value less "SELECT max ( id ) FROM table0" (sequence throwed unique violation exception too). I set valid value for sequence and issue was resolved. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your

[GENERAL] C-language stored function and float4 type

2013-10-06 Thread whiplash
Hello! I have C-language stored function like this: #include #include #ifdef PG_MODULE_MAGIC PG_MODULE_MAGIC; #endif PG_FUNCTION_INFO_V1(testfunc); Datum testfunc(PG_FUNCTION_ARGS) { float4 x = PG_GETARG_FLOAT4(0); float4 y = PG_GETARG_FLOAT4(1); PG_RETURN_FLOAT4(x + y); }

Re: [GENERAL] C-language stored function and float4 type

2013-10-17 Thread whiplash
Sorry, I created an overloaded function and forgot about it. whiplash writes: Hello! I have C-language stored function like this: CREATE FUNCTION testfunc ( x real, y real ) RETURNS real AS 'testfunc' LANGUAGE C STRICT; If i use this function (SELECT testfunc ( 0.1, 0.2 )) I get r

[GENERAL] Cast user defined type to composite type

2013-10-19 Thread whiplash
Hello! I need use user defined type and operate it with low-level functions on language C. In databasepreferred using composite type. Can i write more performance casting that vector3_cast_vector3c? // in C typedef struct { x, y, z double; } vector3; input, output and other functions...

[GENERAL] Save many data chunks to file

2013-11-15 Thread whiplash
Hello! I have a table with image data: /CREATE TABLE images// //(// //id serial,// //image_data bytea,// //...// //);/ This is function for store image data to file: /CREATE OR REPLACE FUNCTION write_bytea ( p_data bytea, p_filename text )// //RETURNS void AS// //$BODY$// //DECLARE/

[GENERAL] Client-site "lo_export"

2011-10-28 Thread whiplash
Hello! I use client-side "lo_export" for save large object to file. If i login as database owner then i do not have error (output file exists), but if i login as not database owner then function "lo_export" returning -1. My code is simple: PGresult *res = PQexec(pg_conn, "begin"); PQclear(r