Re: [GENERAL] PostgreSQL 9.0.3 - collate/ctype order by hu_HU.UTF8 is not correct sorting

2011-02-05 Thread Pavel Stehule
2011/2/5 Adam PAPAI : > Pavel Stehule wrote: >> Hello >> >> You should to initialize database with correct locale. You can't to >> change locale after database is created. >> >> /usr/local/pgsql91/bin/createdb test --locale=cs_CZ.utf-8 -e UTF-8 >

Re: [GENERAL] many schemas or many databases

2011-02-08 Thread Pavel Stehule
or when you has more hw Depends on application and size of data - if you has lot of logs, or some like OLAP data, then is very practical use more than one database. Regards Pavel Stehule > regards > thomas > > > Am 08.02.2011 09:30, schrieb Szymon Guz: >> >> Hi, >>

Re: [GENERAL] pl/pgSQL variable substitution

2011-02-16 Thread Pavel Stehule
ORDER BY foo.' || quote_ident("desc") || ' DESC' Regards Pavel Stehule 2011/2/17 Jeremy Palmer : > Hi, > > I'm creating a pl/pgSQL function that returns a table that has a column name > which is the same as a PostgreSQL reserved.  In the below example a have

Re: [GENERAL] string_agg hanging?

2011-02-21 Thread Pavel Stehule
se, send a execute plans - see statement EXPLAIN Regards Pavel Stehule 2011/2/21 Joel Reed : > Hoping someone will be kind enough to share how to write a query that uses > 9.0's string_agg with a subselect, something like... > > select m.id,m.subject,m.from_address,m.date_sen

Re: [GENERAL] EXECUTE of a 'create table' string is not happening

2011-02-22 Thread Pavel Stehule
; I'm forced to use v7.4. > > If this is a known error, can I (with the version  ; ^)  ) get around it? > > Ultimately I need to FOR..LOOP through through records and the table and > cols will change.  Any suggestions??? > use a EXECUTE statement and FOR IN EXECUTE statement rega

Re: [GENERAL] Dynamic binding in plpgsql function

2011-03-01 Thread Pavel Stehule
er; >        y integer; >    BEGIN >        y := somecalculation; >        x := 'callback'(y);  --This is what I need EXECUTE 'SELECT ' || callback || '($1)' USING y INTO x; there are no other way than EXECUTE attention - there is a sql injection risk

Re: [GENERAL] PHP array to PlPgSQL arrat. How to?

2011-03-05 Thread Pavel Stehule
Hello there isn't a simple way :( the most simply way is using string_to_array function SELECT func(string_to_array('1,2,3,4,5',',')); Regards Pavel Stehule 2011/3/5 Andre Lopes : > Hi, > > I need to transform an PHP array to an PlPgSQL array. The PH

Re: [GENERAL] PHP array to PlPgSQL arrat. How to?

2011-03-05 Thread Pavel Stehule
ocs/9.0/static/hstore.html attention - it doesn't allow a nested values Regards Pavel Stehule for more complex values is other was - using a temp tables - you can fill a temp table and in next step a plpgsql code use this temp table. But it should have a performance impacts. > Best

Re: [GENERAL] PHP array to PlPgSQL arrat. How to?

2011-03-05 Thread Pavel Stehule
2011/3/5 Dmitriy Igrishin : > > > 2011/3/5 Pavel Stehule >> >> 2011/3/5 Andre Lopes : >> > Hi Pavel, >> > >> > Thanks for the reply. >> > >> > In PlpgSQL there is possible to define arrays with "Key => Value, Key => >

Re: [GENERAL] PHP array to PlPgSQL arrat. How to?

2011-03-05 Thread Pavel Stehule
2011/3/5 Dmitriy Igrishin : > > > 2011/3/5 Pavel Stehule >> >> 2011/3/5 Dmitriy Igrishin : >> > >> > >> > 2011/3/5 Pavel Stehule >> >> >> >> 2011/3/5 Andre Lopes : >> >> > Hi Pavel, >> >> >

Re: [GENERAL] PHP array to PlPgSQL arrat. How to?

2011-03-06 Thread Pavel Stehule
Hello look on array_lower and array_upper functions http://www.postgresql.org/docs/8.2/static/functions-array.html for one dimensional arrays - select array_upper(var,1) - array_lower(var,1) Regards Pavel Stehule 2011/3/6 Andre Lopes : > Hi, > > Just another question about thi

Re: [GENERAL] procedure in db

2011-03-08 Thread Pavel Stehule
Hello 2011/3/9 abcdef : > I use postgresql in red hat linux . > I want to know how I can find out all the procedure stored in the database . > Any SQL command to do it ??? > you can try \df in psql or select * from pg_proc Regards Pavel Stehule > > -- > View this messag

Re: [GENERAL] Why length(to_char(1::integer, '9')) = 2 ?

2011-03-09 Thread Pavel Stehule
2011/3/9 Dmitriy Igrishin : > Hey all, > > dmitigr=> select to_char(1, '9'); >  to_char > - >   1 > > dmitigr=> select length(to_char(1, '9')); >  length > >   2 > > Why to_char() includes preceding blank space in the result ? it is compatibility with Oracle? Regards Pavel

Re: [GENERAL] Why length(to_char(1::integer, '9')) = 2 ?

2011-03-09 Thread Pavel Stehule
2011/3/9 Dmitriy Igrishin : > > > 2011/3/9 Pavel Stehule >> >> 2011/3/9 Dmitriy Igrishin : >> > Hey all, >> > >> > dmitigr=> select to_char(1, '9'); >> >  to_char >> > - >> >   1 >> > >

Re: [GENERAL] output screen in psql

2011-03-09 Thread Pavel Stehule
e oralce to fit my > requirement ??? > So, the whole table can be view within the screen of psql ??? > try wrap mode http://archives.postgresql.org/pgsql-committers/2008-05/msg00126.php you can try http://www.pgsql.cz/index.php/PostgreSQL_SQL_Tricks#psql_together_with_less

Re: [GENERAL] Postgres 8.3 vs. 8.4 - Query plans and performance

2011-03-14 Thread Pavel Stehule
gt; these outputs are not too helpful - send a EXPLAIN ANALYZE result you can use a small aplication for storing plans http://explain.depesz.com/ regards Pavel Stehule > > * > The beginning of the 8.4: > * > &

Re: [GENERAL] query taking much longer since Postgres 8.4 upgrade

2011-03-16 Thread Pavel Stehule
ression to_char(course_begin_date, 'MMDD'::text) = '20101025'::text should be a problem much better is test on equality in date domain like: course_begin_date = to_date('20101025', 'MMDD') this is faster and probably better estimated Regards Pav

Re: [GENERAL] query taking much longer since Postgres 8.4 upgrade

2011-03-16 Thread Pavel Stehule
.4. > Thanks much. > > ok, sorry, do column_course_begin::date = ... :) Pavel > > > -Original Message- > From: Tomas Vondra [mailto:t...@fuzzy.cz] > Sent: Wednesday, March 16, 2011 4:40 PM > To: Pavel Stehule > Cc: pgsql-general@postgresql.org; Davenport, J

Re: [GENERAL] How do I do this in plpgsql ?

2011-03-18 Thread Pavel Stehule
? No, it's not supported :( Regards Pavel Stehule > > Best Regards > Dan S > > -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Passing a table as parameter

2011-03-21 Thread Pavel Stehule
E id = $1; > $$; > > you can pass a table name as parameter only: CREATE FUNCTION foo(tablename text) RETURNS SETOF text AS $$ BEGIN RETURN QUERY EXECUTE 'SELECT content FROM ' || quote_ident(tablename); END; $$ LANGUAGE plpgsql; Regards Pavel Stehule > > > >

Re: [GENERAL] Passing a table as parameter

2011-03-21 Thread Pavel Stehule
sql; it can work too, but there is sql injection risk. Do newer 'SELECT ... FROM ' || tabname || ' ... Regards Pavel Stehule > > > Thanks & Regards, > Vibhor Kumar > EnterpriseDB Corporation > The Enterprise PostgreSQL Company > vibhor.ku...@en

Re: [GENERAL] Passing a table as parameter

2011-03-21 Thread Pavel Stehule
2011/3/21 Vibhor Kumar : > > On Mar 22, 2011, at 1:32 AM, Pavel Stehule wrote: > >> it can work too, but there is sql injection risk. >> >> Do newer 'SELECT ... FROM ' || tabname || ' ... >> >> Regards >> >> Pavel Stehule > >

Re: [GENERAL] Passing a table as parameter

2011-03-21 Thread Pavel Stehule
2011/3/21 Vibhor Kumar : > > On Mar 22, 2011, at 1:52 AM, Pavel Stehule wrote: > >> simply thinks as using USAGE clause or functions quote_ident, >> quote_literal are faster and absolutly secure :). Software like SQL > > I don't think usage of quote_ident in cu

Re: [GENERAL] Dynamic Assignment

2011-03-23 Thread Pavel Stehule
ey bigint; > begin >  execute 'select NEW.esid' into pkey; > end; > $$ language plpgsql > > Obviously this particular code could be re-written as a simple assignment > but I need the > "esid" part to be dynamic.  Is this possible? yes, it's possibl

Re: [GENERAL] In what cases can SPI_finish crash postgres backend?

2011-03-23 Thread Pavel Stehule
Hello SPI_finish try to release resources and memory. Maybe you has broken memory. Try to compile postgres with --enable-debug and --enable-cassert flags. You can take more info from core dump. Regards Pavel Stehule 2011/3/23 Jorge Arévalo : > Hello, > > I'm writing my own

Re: [GENERAL] Understanding Datum

2011-03-23 Thread Pavel Stehule
DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(buf.data))); PG_RETURN_TEXT_P(result); } CREATE OR REPLACE FUNCTION quote_literal(anyelement) RETURNS text AS 'MODULE_PATHNAME' LANGUAGE C STRICT; CREATE OR REPLACE FUNCTION quote_literal(text) RETURNS text AS 'MODULE_PATH

Re: [GENERAL] DO Statement Body Parameters

2011-03-24 Thread Pavel Stehule
l > HTH, > WBL you can't prepare a DO statement - it has no plan :(. I worked on parametrized DO statement, but this patch was rejected as premature optimalization. Regards Pavel Stehule >> >> >> >> >> >> >> >> -- >> Sent via pgsql-

Re: [GENERAL] cursor with dinamic string

2011-03-25 Thread Pavel Stehule
r IN EXECUTE 'SELECT .. FROM ' || quote_ident(tableName) || ' ' LOOP ... you can use OPEN FOR EXECUTE too, but FOR statement is preferable Regards Pavel Stehule http://www.postgresql.org/docs/9.0/interactive/plpgsql-cursors.html#PLPGSQL-CURSOR-OPENING > then I creat

Re: [GENERAL] can a function have a setof (returned from another function) as input

2011-03-28 Thread Pavel Stehule
Hello 2011/3/28 Terry Kop : > I'm trying to create a function that will take setof results from various > other functions (they all produce the same output format). Is this possible? > if so how do call it. No, this isn't possible. Regards Pavel Stehule > > ex. >

Re: [GENERAL] Integrating New Data Type

2011-04-05 Thread Pavel Stehule
functions, you have to register new type look to postgresql sources - contrib, there is very simple type citext http://doxygen.postgresql.org/dir_23dd6926f287bddac2c9dcb7db5b1712.html http://doxygen.postgresql.org/citext_8c-source.html Any contrib module has sql file with registrations Regards

Re: [GENERAL] Functions as first-class values

2011-04-06 Thread Pavel Stehule
TE FUNCTION do_stuff ... > BEGIN >        CASE cond >                WHEN 'a' THEN func := f1; >                WHEN 'b' THEN func := f2; >                WHEN 'c' THEN func := f3; >        END CASE > >        SELECT * FROM foobar WHERE func (foobar.age); >

Re: [GENERAL] cast list of oid

2011-04-08 Thread Pavel Stehule
y(select unnest(array[25,26,27]::oid[])::regtype); ?column? {text,oid,tid} (1 row) Regards Pavel Stehule > >  Regards > > Best Regard > > Eng. Salah Al Jubeh > Palestine Polytechnic University > College of Applied Science > Computer Science &

Re: [GENERAL] Using Function returning setof record in JOIN

2011-04-08 Thread Pavel Stehule
2011/4/8 Merlin Moncure : > On Fri, Apr 8, 2011 at 5:57 AM, gmb wrote: >> Hi >> >> Is it possible to do a JOIN between a VIEW and the output of a FUNCTION? > > yes. yes, it is possible. Just I am not sure if original query wasn't directed to >>lateral<< feature. Pavel > > merlin > > -- > Sent

Re: [GENERAL] Howto use "COPY FROM" with the native API?

2011-04-11 Thread Pavel Stehule
ROM STDIN" with the > native C API? look to source code on \copy implementation in psql http://doxygen.postgresql.org/bin_2psql_2copy_8c.html http://www.postgresql.org/docs/8.1/static/libpq-copy.html Regards Pavel Stehule > I found some documentation, however as I am no C na

Re: [GENERAL] Code for user-defined type

2014-05-28 Thread Pavel Stehule
Hello 2014-05-27 20:30 GMT+02:00 Paul Jones : > I have written a user-defined type that allows direct import and printing > of > DB2 timestamps.It does correctly import and export DB2 timestamps, > butI'm wondering ifsomeone could tell me if I made anymistakes in > the C code, particularly w.r.t

Re: [GENERAL] Code for user-defined type

2014-05-29 Thread Pavel Stehule
2014-05-29 18:04 GMT+02:00 Paul Jones : > On Wed, May 28, 2014 at 10:51:43AM +0200, Pavel Stehule wrote: > > > > Hello > > > > > > 2014-05-27 20:30 GMT+02:00 Paul Jones : > > > > > I have written a user-defined type that allows direct import and

Re: [GENERAL] Function Syntax Help

2014-06-26 Thread Pavel Stehule
Hello You are using PLpgSQL CASE statement this start by CASE keyword and finishing by END CASE keywords CREATE OR REPLACE FUNCTION sn_dm_b.pm_insert_trigger() RETURNS TRIGGER AS $$ BEGIN CASE WHEN NEW.period = 201001 THEN INSERT INTO sn_dm_b.pm201001 VALUES (NEW.*);

Re: [GENERAL] Function Syntax Help

2014-06-26 Thread Pavel Stehule
2014-06-26 18:28 GMT+02:00 Shaun Thomas : > On 06/25/2014 05:19 PM, Dennis Ryan wrote: > > CASE >> WHEN NEW.period = 201001 >> THEN INSERT INTO sn_dm_b.pm201001 VALUES (NEW.*); >> END; >> > > You can't just have a bare CASE statement in plpgsql. Try this: > > > CREATE OR REPL

Re: [GENERAL] Function Syntax Help

2014-06-26 Thread Pavel Stehule
2014-06-26 18:26 GMT+02:00 Raymond O'Donnell : > On 25/06/2014 23:19, Dennis Ryan wrote: > > I having trouble with correct syntax to get this trigger function to > > compile. I have tried every combination of removing the ‘;’ characters > > but the function will not compile. Can someone tell me

[GENERAL] plpgsql_check is for PostgreSQL 9.2 now

2014-06-27 Thread Pavel Stehule
Hello plpgsql_check is PostgreSQL extension for deep check of plpgsql functions. Only PostgreSQL 9.3 was supported. Today I did a backport for PostgreSQL 9.2 https://github.com/okbob/plpgsql_check Regards Pavel Stehule

Re: [GENERAL] Track changes to function code

2014-07-21 Thread Pavel Stehule
> > psql -f myfile.sql > yes, it is good way stored procedures are code as any other and there are same rules. Use files, use a your preferred editor, use makefiles, use GIT Regards Pavel Stehule > > -- > Jacob > > > > -- > Sent via pgsql-general mailing list

Re: [GENERAL] event triggers in 9.3.4

2014-07-25 Thread Pavel Stehule
Hello I found a interesting extension http://code.malloclabs.com/pg_schema_triggers Regards Pavel 2014-07-25 20:01 GMT+02:00 Alvaro Herrera : > Vasudevan, Ramya wrote: > > >> You could compare list of tables before (_start) and after (_end) the > ddl. Doing it in plpgsql will be tricky, but i

Re: [GENERAL] event triggers in 9.3.4

2014-07-26 Thread Pavel Stehule
Hello 2014-07-25 20:46 GMT+02:00 Alvaro Herrera : > Pavel Stehule wrote: > > Hello > > > > I found a interesting extension > > http://code.malloclabs.com/pg_schema_triggers > > Ah, I remember that. I find that approach more cumbersome to use than > mine.

Re: [GENERAL] How can I create null value from function call with no results?

2014-07-30 Thread Pavel Stehule
: 1.698 ms world=# SELECT * FROM xx(2); a | b ---+--- | (1 row) Regards Pavel Stehule 2014-07-30 20:13 GMT+02:00 Seref Arikan : > Greetings, > I want to call a function using a column of a table as the parameter and > return the parameter and function results together. > Th

Re: [GENERAL] Trigger function cannot reference field name with capital letter

2014-08-13 Thread Pavel Stehule
Hi 2014-08-14 8:10 GMT+02:00 Patrick Dung : > Thanks all for the help. > > BTW, letter casing is just a preference. > Some people liked to use all small caps, some liked to use all big caps. > I sometimes found that mixed case is more meaningful for the filed (eg. > serialnumber vs serialNumber)

Re: [GENERAL] SELECT 'NOW()' - OK, SELECT 'CLOCK_TIMESTAMP()' - ERROR

2014-08-22 Thread Pavel Stehule
Hi 2014-08-22 9:05 GMT+02:00 David G Johnston : > Piotr Gasidło wrote > > Hello, > > > > I found strange PostgreSQL 9.3 behavior: > > > >> select now()::timestamp, 'now()'::timestamp; > > now | timestamp > > +---

Re: [GENERAL] Deletion

2014-08-27 Thread Pavel Stehule
Hi psql variables has different format and its is not directly related to psql options. But you can do: [pavel@localhost ~]$ psql postgres --set=myproname=upper psql (9.5devel) Type "help" for help. postgres=# select proname, prosrc from pg_proc where proname = :'myproname'; proname | prosrc

Re: [GENERAL] || operator

2014-09-03 Thread Pavel Stehule
Hi you can define || operator for char(N) type postgres=# select oprname, oprleft::regtype, oprright::regtype from pg_operator where oprname = '||' ; oprname | oprleft | oprright -+-+- || | bytea | bytea || | text| text || | te

Re: [GENERAL] || operator

2014-09-03 Thread Pavel Stehule
2014-09-03 15:25 GMT+02:00 Szymon Guz : > > > > On 3 September 2014 15:20, Pavel Stehule wrote: > >> Hi >> >> you can define || operator for char(N) type >> >> postgres=# select oprname, oprleft::regtype, oprright::regtype from >> pg_operato

Re: [GENERAL] || operator

2014-09-03 Thread Pavel Stehule
2014-09-03 16:01 GMT+02:00 Kevin Grittner : > Pavel Stehule wrote: > > 2014-09-03 15:25 GMT+02:00 Szymon Guz : > > >> I think we should have this in core, as this definitely is a bug. > > > > hard to say - anything about CHAR(N) is strange, > > On a quick

Re: [GENERAL] || operator

2014-09-03 Thread Pavel Stehule
2014-09-04 6:27 GMT+02:00 Vinayak : > Hello Pavel, > > Thank you for reply. > >postgres=# select 'abc '::char(7) || 'dbe '::char(6); > >?column? > > > > *abcabc* > >(1 row) > but it gives the result "abcabc". It should be "abcdbe". > > yes create or replace f

Re: [GENERAL] || operator

2014-09-04 Thread Pavel Stehule
2014-09-04 11:13 GMT+02:00 Vinayak : > Hi, > > The || operator with arguments (character,character) works fine and even || > operator(character,varchar) also works fine. > but || operator is not working as expected with arguments character data > type and any other data type like integer,smallint,

Re: [GENERAL] Why isn't Java support part of Postgresql core?

2014-09-15 Thread Pavel Stehule
2014-09-15 19:34 GMT+02:00 cowwoc : > On 15/09/2014 7:03 AM, Chris Travers wrote: > > I have a few questions on this, the answers of which may help answer your > question: > > 1. How well does having a server-side JVM work, resource-wise, when you > have a forked process model like PostgreSQL?

Re: [GENERAL] Why isn't Java support part of Postgresql core?

2014-09-15 Thread Pavel Stehule
2014-09-15 19:37 GMT+02:00 cowwoc : > On 15/09/2014 7:58 AM, Bill Moran wrote: > >> On Sun, 14 Sep 2014 22:22:21 -0700 (PDT) >> cowwoc wrote: >> >>> Out of curiosity, why is Postgresql's Java support so poor? >>> >> To trampoline off what others have said: it gets implemented and >> maintained if

Re: [GENERAL] Why isn't Java support part of Postgresql core?

2014-09-15 Thread Pavel Stehule
2014-09-15 19:46 GMT+02:00 Pavel Stehule : > > > 2014-09-15 19:37 GMT+02:00 cowwoc : > >> On 15/09/2014 7:58 AM, Bill Moran wrote: >> >>> On Sun, 14 Sep 2014 22:22:21 -0700 (PDT) >>> cowwoc wrote: >>> >>>> Out of curiosity, why i

Re: [GENERAL] Why isn't Java support part of Postgresql core?

2014-09-15 Thread Pavel Stehule
2014-09-15 19:49 GMT+02:00 cowwoc : > Hi Pavel, > > On 15/09/2014 1:40 PM, Pavel Stehule wrote: > > The main drivers are: > >> >>1. Not having to learn yet another language. I find the >>expressiveness and readability of the other scripting languag

Re: [GENERAL] pg_dump does not include database-level user-defined GUC variables?

2014-09-16 Thread Pavel Stehule
2014-09-16 17:39 GMT+02:00 Kevin Grittner : > Abelard Hoffman wrote: > > > I have a user-defined GUC variable that was set at the db level. e.g., > > > > ALTER DATABASE mydb SET myapp.user_id TO '1' > > > > Works fine. When I do a pg_dump, however, that variable isn't included. > > Is that expe

Re: [GENERAL] Why isn't Java support part of Postgresql core?

2014-09-17 Thread Pavel Stehule
2014-09-17 22:54 GMT+02:00 Peter Eisentraut : > On 9/15/14 1:46 PM, Pavel Stehule wrote: > > I am strong sceptic. There is relative slow progress in JDBC driver, > > that is 100x more important project than PL/Java - so It is hard to > > believe, so there can be 3 developers,

Re: [GENERAL] How to clone CURRENT_DATE to SYSDATE ?

2014-09-25 Thread Pavel Stehule
Hi 2014-09-25 12:24 GMT+02:00 Emanuel Araújo : > Thank's Adrian, > > I want really create another CURRENT_DATE called SYSDATE. > It needs a hack to postgres. Pseudoconstant functions needs a support in PostgreSQL parser. There is no other possibility Pavel > > postgres=# SELECT CURRENT_DATE ;

Re: [GENERAL] [SQL] how to see "where" SQL is better than PLPGSQL

2014-09-28 Thread Pavel Stehule
2014-09-28 20:30 GMT+02:00 Gerardo Herzig : > Hi all. I see an entire database, with all the stored procedures writen in > plpgsql. Off course, many (if not all) of that SP are simple inserts, > updates, selects and so on. > > So, i want to test and show the differences between doing the same > fu

Re: [GENERAL] [SQL] how to see "where" SQL is better than PLPGSQL

2014-09-28 Thread Pavel Stehule
2014-09-28 21:29 GMT+02:00 Gerardo Herzig : > > Hi all. I see an entire database, with all the stored procedures > > writen in plpgsql. Off course, many (if not all) of that SP are > > simple inserts, updates, selects and so on. > > > > So, i want to test and show the differences between doing the

Re: [GENERAL] How to Install Extensions

2014-10-16 Thread Pavel Stehule
ension_name; Regards Pavel Stehule > > > > With Regards > M N Muralikrishna > > >

Re: [GENERAL] DBlink, postgres to DB2

2014-10-22 Thread Pavel Stehule
Hi try to use a Perl implementation https://github.com/davidfetter/DBI-Link There is a DBD driver for DB2 http://search.cpan.org/dist/DBD-DB2/DB2.pod Or you can use a mentioned fdw wrapper - there is ODBC wrapper https://wiki.postgresql.org/wiki/Foreign_data_wrappers#odbc_fdw and you can access

Re: [GENERAL] DBlink, postgres to DB2

2014-10-30 Thread Pavel Stehule
erlin and Pavel...I will give it a try. >> >> On Wed, Oct 22, 2014 at 6:36 AM, Merlin Moncure > <https://e.mail.ru/compose/?mailto=mailto%3ammonc...@gmail.com>> wrote: >> >> On Wed, Oct 22, 2014 at 5:56 AM, Pavel Stehule > <https://e.mail.ru/compose

Re: [GENERAL] HINT: Perhaps you need a different "datestyle" setting - postgresql

2014-12-28 Thread Pavel Stehule
S or more exactly: postgres=# set datestyle to SQL,DMY; SET postgres=# SELECT '19/08/2014'::date; date 19/08/2014 (1 row) http://www.postgresql.org/docs/9.4/static/datatype-datetime.html Regards Pavel Stehule 2014-12-28 11:43 GMT+01:00 Arup Rakshit : > Hi, > >

Re: [GENERAL] HINT: Perhaps you need a different "datestyle" setting - postgresql

2014-12-28 Thread Pavel Stehule
2014-12-28 12:06 GMT+01:00 Arup Rakshit : > On Sunday, December 28, 2014 12:54:30 PM Pavel Stehule wrote: > > Hi > > > > try > > > > postgres=# set datestyle to DMY; > > SET > > postgres=# SELECT '19/08/2014'::date; > > date

Re: [GENERAL] Getting a delta of two json-typed objects? (a breeze w/ hstore)

2015-01-22 Thread Pavel Stehule
Hi it should to work for JSON too http://8kb.co.uk/blog/2015/01/16/wanting-for-a-hstore-style-delete-operator-in-jsonb/ Regards Pavel 2015-01-22 20:37 GMT+01:00 Wells Oliver : > Hey all. I have a trigger function which does a delta of two hstore values > just doing a - b; this check is perform

Re: [GENERAL] [SQL] commit inside a function failing

2015-01-23 Thread Pavel Stehule
Hi 2015-01-23 20:56 GMT+01:00 Suresh Raja : > Hi All: > > We are running a function with a loop in it. We tried > commit; > We are getting error with above command. How can i easily commit withing > a function. > > It is not possible in PostgreSQL Regards Pavel Stehule > > Thanks, > -SR >

Re: [GENERAL] Postgresql 9.4 session vars

2015-01-24 Thread Pavel Stehule
postgres 9.4? > This limit was removed. You can use any session vars with patter "someprefix.somevar" without necessity to enable class "someprefix" Regards Pavel Stehule > > Thank you > > > > -- ><http://www.avast

Re: [GENERAL] How to access large objects in Postgresql c-language functions?

2015-01-26 Thread Pavel Stehule
Hi you can use a lo_* (lo_open, lo_close, ...) functions called via FirectFunctionCall http://michael.otacoo.com/postgresql-2/playing-with-large-objects-in-postgres/ http://www.postgresql.org/docs/9.3/static/lo-interfaces.html Regards Pavel Stehule 2015-01-26 20:19 GMT+01:00 Spiros Ioannou

Re: [GENERAL] [SQL] check if the same function is already running, then exit!

2015-01-26 Thread Pavel Stehule
Hi you can use a advisory locks for singleton implementation http://www.postgresql.org/docs/9.4/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS Regards Pavel 2015-01-26 20:58 GMT+01:00 Suresh Raja : > Before running a running a function, i would check only 1 instance is > running. If al

Re: [GENERAL] How to access large objects in Postgresql c-language functions?

2015-01-26 Thread Pavel Stehule
2015-01-26 20:54 GMT+01:00 Spiros Ioannou : > But these need a connection to the postgresql backend. It seems an > overkill for postgresql to connect to itself, I would prefer something more > optimal. It seems for now that reading libpq's source code is the only way > to go. > No, it doesn't ne

Re: [GENERAL] dbmsscheduler

2015-02-08 Thread Pavel Stehule
Hi PostgreSQL doesn't have a dbms_scheduler. If you need it, you can use a EnterpriseDB - commercial fork with Oracle migration tools. There it is. You can use a scheduler pgAgent - https://github.com/postgres/pgagent http://www.pgadmin.org/docs/dev/pgagent.html Regards Pavel 2015-02-03 14:16

Re: [GENERAL] postgres cust types

2015-02-08 Thread Pavel Stehule
--create or replace type suborder_list_table as table of suborder_list; > this on *oracle *formate > This syntax is not supported in Pg - resp. a collections are not supported by PostgreSQL. use a arrays instead DECLARE array_var order_list[]; http://www.postgresql.org/docs/9.4/static/arrays.html Regards

Re: [GENERAL] How to hide stored procedure's bodies from specific user

2015-02-12 Thread Pavel Stehule
Hi It is currently impossible on unpatched postgres. I am selling a patch to postgres that does a obfuscation of procedure body Regards Pavel Stehule 2015-02-11 10:54 GMT+01:00 Saimon Lim : > Hi > I want to hide my own stored procedures' bodies from the specific user. > As

Re: [GENERAL] Initializing JsonbValue from cstring

2015-02-13 Thread Pavel Stehule
Hi you can call "input function" - jsonb_in Jsonb *targetjsonbvar = DatumGetJsonb(DirectFunctionCall1(json_in, CStringGetDatum(cstrvalue))); Regards Pavel Stehule 2015-02-13 11:32 GMT+01:00 Igor Stassiy : > Hi, > > Is there a way to initialize JsonbValue from cstring f

Re: [GENERAL] Collection

2015-02-13 Thread Pavel Stehule
2015-02-13 14:13 GMT+01:00 Ramesh T : > COLLECT Hi Depends on what you needs. The collections are not supported by PostgreSQL - use a arrays instead. http://www.postgresql.org/docs/9.4/static/arrays.html Regards Pavel Stehule

Re: [GENERAL] dbmsscheduler

2015-02-14 Thread Pavel Stehule
2015-02-14 17:22 GMT+01:00 Ramesh T : > dbms_scheduler.create_job( > job_name => 'DELETE_EMPTY_PART_NUMS' > ,job_type => 'PLSQL_BLOCK') > > without pgagent or cron is not possible..? > Not in PostgreSQL Regards Pavel Stehule > &

Re: [GENERAL] stored procedure variable names

2015-02-19 Thread Pavel Stehule
27;t think so it is necessary in this moment (so I am against a introduction new prefix) a) PostgreSQL safely solves conflicts between plpgsql and SQL - what Oracle doesn't b) Usual prefix for plpgsql variables is "_" - I don't see a difference between @,?,: Regards Pavel Stehule

Re: [GENERAL] PL/PgSQL and pg_temp pseudo-schema

2015-02-20 Thread Pavel Stehule
Hi It is little bit strange, it works for me postgres=# create temp table foo(a int); CREATE TABLE postgres=# do $$ begin insert into foo values(10); end $$; -- plpgsql DO postgres=# select * from foo; a 10 (1 row) Regards Pavel 2015-02-20 9:07 GMT+01:00 Vincenzo Romano : > PL/PgSQL

Re: [GENERAL] rollback in function

2015-02-23 Thread Pavel Stehule
Hi 2015-02-19 21:42 GMT+01:00 Juan Pablo L. : > Hello, i have created a function (in C) that receives an array that > contains tuples of ID's and values. > > The function is to execute updates on each ID assigning the value, but if > one of these operation fails (does not meet certain criteria) >

Re: [GENERAL] What is the alternate of FILTER below Postgresql 9.4 ?

2015-02-24 Thread Pavel Stehule
> "people"; > non_x_loc | x_loc > ---+--- > 1 | 2 > (1 row) > > This *FILTER* method is available from 9.4, How can I get the same output > below 9.4 version ? > > use SQL CASE SELECT COUNT(CASE lower(location) &

Re: [GENERAL] Longest prefix matching CTE

2015-02-25 Thread Pavel Stehule
Some other solutions http://postgres.cz/wiki/PostgreSQL_SQL_Tricks_II#Fast_searching_of_longer_prefix 2015-02-25 9:04 GMT+01:00 Tim Smith : > Will take a look. Thanks steve. > > On 24 February 2015 at 23:57, Steve Atkins wrote: > > > > On Feb 24, 2015, at 3:50 PM, Tim Smith > wrote: > > > >>

Re: [GENERAL] recasting to timestamp from varchar

2013-01-04 Thread Pavel Stehule
xpression to perform the conversion. postgres=# alter table foo alter column a type timestamp using a::timestamp; ALTER TABLE postgres=# Regards Pavel Stehule

Re: [GENERAL] Curious unnest behavior

2013-01-04 Thread Pavel Stehule
(array[1,2,3,4]); unnest │ unnest ┼ 1 │ 1 2 │ 2 1 │ 3 2 │ 4 (4 rows) so result is - don't use SRF (set returning funtion) in column list if you don't need. 9.3 will support LATERAL clause, and I hope so we can drop this f

Re: [GENERAL] psql copy from through bash

2013-01-11 Thread Pavel Stehule
Hello >> >> Once more quickie. It seems that I am going to be asked for my password >> every time psql loops through the copy statement. >> >> What is considered best practices to handle authentication? I am >> connecting locally, as myself as the user and I'm being asked for my user >> password.

Re: [GENERAL] Enhancement proposal - detect chain of triggers from inside the trigger

2013-01-16 Thread Pavel Stehule
rigger). -1 building dynamic used array, that should or should not used can significantly decrease performance :( if you need it, you can use workaround - session variables. Regards Pavel Stehule > > Would help debug database triggers that have cascaded events. > > Regards, > >

Re: [GENERAL] Temp table's effect on performance

2013-01-18 Thread Pavel Stehule
Hello 2013/1/18 Robert James : > I'd like to understand better why manually using a temp table can > improve performance so much. one possible effect - there should be different statistic did you look on EXPLAIN ANALYZE? Regards Pavel Stehule > > I had one complicated que

Re: [GENERAL] Logging successful SELECTS?

2013-01-24 Thread Pavel Stehule
lf). How do I do this? use log_min_duration_statement = 0 Regards Pavel Stehule > > Thanks, > > Matthew > > -- > Matthew Vernon > Quantitative Veterinary Epidemiologist > Epidemiology Research Unit, SAC Inverness > > > -- > Sent via pgsql-general mailing list (pgsql-gen

Re: [GENERAL] Postfresql 8.4 Problem

2013-01-26 Thread Pavel Stehule
Hello what did you do exactly? please, can you send more details? https://wiki.postgresql.org/wiki/Guide_to_reporting_problems Regards Pavel Stehule 2013/1/25 Electric Boy : > I have a problem with posgresql 8.4, yesterday when I tried to reinstall and > do restore the old database no

Re: [GENERAL] Optimizing query?

2013-01-31 Thread Pavel Stehule
join where result is related to some function result can be very slow, because estimation will be out and any repeated function evaluation is just expensive. You can try use a functional index. create index on tab2 ((substring(tab1.code from 1 for 5)) Regards Pavel Stehule >> >> R

Re: [GENERAL] Optimizing query?

2013-01-31 Thread Pavel Stehule
2013/1/31 Vincent Veyron : > Le jeudi 31 janvier 2013 à 09:49 +0100, Pavel Stehule a écrit : > >> any join where result is related to some function result can be very >> slow, because estimation will be out and any repeated function >> evaluation is just expensive. >&g

Re: [GENERAL] Optimizing query?

2013-01-31 Thread Pavel Stehule
2013/1/31 Vincent Veyron : > Le jeudi 31 janvier 2013 à 11:06 +0100, Pavel Stehule a écrit : >> 2013/1/31 Vincent Veyron : >> > >> > Suppose I have a query of the form >> > >> > SELECT my_function(column_1), column_2 >> > FROM my_table >>

Re: [GENERAL] Optimizing query?

2013-01-31 Thread Pavel Stehule
Hello 2013/1/31 : > > Pavel Stehlule wrote: > >>> >> Hi, >>> >> >>> >> I am trying to match items from 2 tables based on a common string. >>> >> One is a big table which has one column with entries like XY123, ABC44, = >>> etc >>> >> The table has an index on that column. >>> >> The second table

Re: [GENERAL] Optimizing query?

2013-02-02 Thread Pavel Stehule
2013/2/2 : > Pavel Stehule wrote: > >>> >>> but maybe https://github.com/dimitri/prefix can help >>> > > Hi Pavel, > > thanks - this works perfect. However, it does not seem to play well > with the optimizer, so I ended up with > > select

Re: [GENERAL] Optimizing query?

2013-02-02 Thread Pavel Stehule
2013/2/2 Pavel Stehule : > 2013/2/2 : >> Pavel Stehule wrote: >> >>>> >>>> but maybe https://github.com/dimitri/prefix can help >>>> >> >> Hi Pavel, >> >> thanks - this works perfect. However, it does not seem to play

Re: [GENERAL] Diferences between IN and EXISTS?

2013-02-02 Thread Pavel Stehule
Hello 2013/2/3 Edson Richter : > Hi! > > Assumptions: PostgreSQL 9.2.2, Win64, already run vacumm full freeze > analyze. No problems in the database. I know there are 1247 records to be > found. > Why does these queries return different results: > > > select count(*) from parcela > where id not in

Re: [GENERAL] Options for passing values to triggers?

2013-02-04 Thread Pavel Stehule
to the audit table (meaning that any logging is > going to have to occur via a function with SECURITY DEFINER). > > Any advice or "you don't want to it that way" abuse would be much > appreciated. Moving and too "smart" logic to triggers is usually bad idea

Re: [GENERAL] What language is faster, C or PL/PgSQL?

2013-02-04 Thread Pavel Stehule
2013/2/5 Bruce Momjian : > On Mon, Feb 4, 2013 at 08:33:02AM -0600, Merlin Moncure wrote: >> On Sat, Feb 2, 2013 at 11:36 AM, Carlo Stonebanks >> wrote: >> > Here is an advantage Plpgsql has: >> > http://www.postgresql.org/docs/9.1/static/plpgsql-expressions.html >> > >> > I guess you can offset

Re: [GENERAL] "explain analyze" a procedure verbosely - to find which statement in it takes longer

2013-02-06 Thread Pavel Stehule
e a way to make the > "explain analyze" output more verbose? > > Or do I have to run each of procedure's > statements by hand, preprending them > with "explain analyze"? > no, it is not possible http://blog.guillaume.lelarge.info/index.php/post/2012/03/31/Prof

<    1   2   3   4   5   6   7   8   9   10   >