[GENERAL] Protocol 2 and query parameters support

2017-04-23 Thread Konstantin Izmailov
Does Postgres protocol 2 support query parameters? e.g.: SELECT colA FROM tbl WHERE colB=$1 Some systems (Presto) are still using protocol 2, and I need to understand the scope of changes in the middleware to support protocol 2.

Re: [GENERAL] arrays returned in text format

2016-03-05 Thread Konstantin Izmailov
wrote: > Konstantin Izmailov writes: > > Whole point of my question was why PG does not return > > binary formatted field when requested (this is a feature supported in the > > protocol). > > You haven't presented a test case demonstrating that that happens in > un

Re: [GENERAL] arrays returned in text format

2016-03-04 Thread Konstantin Izmailov
ane wrote: > Konstantin Izmailov writes: > > Oops, I forgot to mention that we slightly modified libpq to request > > resulting fields formats (since Postgres protocol v3 supports this). > > Um. I'm not that excited about supporting bugs in modified variants of > PG. If yo

Re: [GENERAL] arrays returned in text format

2016-03-04 Thread Konstantin Izmailov
being used for about 10 years in our variant of libpq. It works for everything except for the case with ARRAY. Thank you for the quick reply! On Fri, Mar 4, 2016 at 10:03 PM, Tom Lane wrote: > Konstantin Izmailov writes: > > I'm using libpq to read array values, and I notice

[GENERAL] arrays returned in text format

2016-03-04 Thread Konstantin Izmailov
I'm using libpq to read array values, and I noticed that sometimes the values are returned in Binary and sometimes - in Text format. 1. Returned in Binary format: int formats[1] = { 1 }; // request binary format res = PQexec(conn, "SELECT rgField FROM aTable", 1, formats); assert(PQfforma

Re: [GENERAL] inserting into "date" field returns error (COPY/BINARY)

2013-04-23 Thread Konstantin Izmailov
Merlin, it worked like a charm! Thank you tons! Konstantin

[GENERAL] inserting into "date" field returns error (COPY/BINARY)

2013-04-23 Thread Konstantin Izmailov
I have implemented a C++ procedure for inserting data using libpq and COPY WITH BINARY command. All field types are working as expected in PG9.2, except "date": ERROR: incorrect binary data format CONTEXT: COPY table, line 1, column date_xyz The passed value for "date" is a 64-bit integer, c

[GENERAL] bug in COPY implementation (all versions of Postgres)?

2013-04-04 Thread Konstantin Izmailov
I came across an issue that looks like a bug in COPY. There are many similar posts, e.g. http://stackoverflow.com/questions/13485030/strange-postgresql-value-too-long-for-type-character-varying500, without a good unswer. Simplified steps to reproduce the issue: 1. CREATE TABLE TEST (description va

Re: [GENERAL] [HACKERS] money with 4 digits after dot

2013-03-27 Thread Konstantin Izmailov
I found a workaround: domain type defined as: CREATE DOMAIN currency AS numeric(16,4); Thank you!

[GENERAL] why cannot UNION both SELECT and SHOW?

2011-08-01 Thread Konstantin Izmailov
Is it possible instead of executing following two statements: SHOW search_path; SELECT version(); to execute just one statement returning both search_path and version? I'm using Postgres 9.0 and need the result either as two tuples or two fields... Could you suggest how to rewrite the two state

Re: [GENERAL] pg_temp 101 question

2011-01-03 Thread Konstantin Izmailov
Tom, thank you for the suggestion - it looks like it is working! I've found another solution by looking into psql source code: nspname like 'pg_temp%' AND pg_catalog.pg_table_is_visible(C.oid) can also be added to the query for the purpose. On 1/3/11, Tom Lane wrote: > K

[GENERAL] pg_temp 101 question

2011-01-03 Thread Konstantin Izmailov
My application creates/uses a temporary table "X" via multiple connections at the same time. Is there a way to determine which pg_temp_N belongs to the current connection? I need this to obtain list of attributes for the temporary table... All connections are using the same temp table name (by des

Re: [GENERAL] number of rows returned by a query

2010-12-02 Thread Konstantin Izmailov
MOVE ALL, then PQcmdTuples to get number of rows, > then MOVE BACKWARD ALL to point cursor at initial position. > > 2010/12/2 Konstantin Izmailov > > Maybe this question was discussed previously, but I could not find an >> answer: >> >> An application used PQntupl

[GENERAL] number of rows returned by a query

2010-12-01 Thread Konstantin Izmailov
Maybe this question was discussed previously, but I could not find an answer: An application used PQntuples function to obtain number of tuples after executing each query. Since number of rows increased we decided to use DECLARE CURSOR/FETCH commands to retrieve tuples. However, it seems that numb

Re: [GENERAL] Does Postgres support bookmarks (tuples ids)?

2010-12-01 Thread Konstantin Izmailov
the case, then just get a PostgreSQL OLEDB provider that > supports bookmarks. > > > > *From:* pgsql-general-ow...@postgresql.org [mailto: > pgsql-general-ow...@postgresql.org] *On Behalf Of *Konstantin Izmailov > *Sent:* Tuesday, November 30, 2010 9:50 PM > *To:* pgsql-

[GENERAL] Does Postgres support bookmarks (tuples ids)?

2010-11-30 Thread Konstantin Izmailov
Dear experts, I've noticed that commercial databases (e.g. SQLServer) and some open source databases (e.g. Cubrid) support so called "bookmarks". As far as I understood, a bookmark allows quickly jump to a row for retrieval or modification. Here is scenario that I'm trying to deal with: A BI/ETL a

Re: [GENERAL] Is there a logical reason for 25P02?

2010-10-05 Thread Konstantin Izmailov
o insert a duplicate row. Is using of a SAVEPOINT only solution? Thank you Konstantin On Tue, Oct 5, 2010 at 4:13 AM, Craig Ringer wrote: > On 10/05/2010 12:39 PM, Konstantin Izmailov wrote: > >> Howdy, >> I've noticed that there is a difference in result of execut

[GENERAL] Is there a logical reason for 25P02?

2010-10-04 Thread Konstantin Izmailov
Howdy, I've noticed that there is a difference in result of execution of the following statement: INSERT INTO testtable(col1) VALUES(NULL); depending on whether the command is prepared or not. If I call PQprepare/PQexecPrepared for the statement, the error "transaction aborted" is returned with

Re: [GENERAL] PQprepare in PostgreSQL 7.4 (lack of SAVEPOINTs)

2010-06-28 Thread Konstantin Izmailov
} res = ::PQexec(conn, "ABORT", 0, 0); On Mon, Jun 28, 2010 at 9:11 AM, Konstantin Izmailov wrote: > Looks like other people were asking similar question, but there is no > answer: > http://forums.devshed.com/postgresql-help-21/combine-prepare-and-declare-cursor-437562.

Re: [GENERAL] PQprepare in PostgreSQL 7.4 (lack of SAVEPOINTs)

2010-06-28 Thread Konstantin Izmailov
Looks like other people were asking similar question, but there is no answer: http://forums.devshed.com/postgresql-help-21/combine-prepare-and-declare-cursor-437562.html On Mon, Jun 28, 2010 at 1:00 AM, Konstantin Izmailov wrote: > lol > > Seriosly, this customer issues resulted in im

Re: [GENERAL] PQprepare in PostgreSQL 7.4 (lack of SAVEPOINTs)

2010-06-28 Thread Konstantin Izmailov
CLARE csr1 CURSOR FOR EXECUTE abcd; Thank you! Konstantin On Wed, Jun 23, 2010 at 9:41 PM, Tom Lane wrote: > Scott Marlowe writes: > > On Wed, Jun 23, 2010 at 10:55 PM, Konstantin Izmailov > wrote: > >> The company is not willing to upgrade from 7.4 to a later version due to &g

Re: [GENERAL] PQprepare in PostgreSQL 7.4 (lack of SAVEPOINTs)

2010-06-23 Thread Konstantin Izmailov
Scott, thank you for the quick answer! I think it would work if our software tracks which statements have already been prepared on the connection. On Wed, Jun 23, 2010 at 8:25 PM, Scott Marlowe wrote: > On Wed, Jun 23, 2010 at 10:55 PM, Konstantin Izmailov > wrote: > > Is th

[GENERAL] PQprepare in PostgreSQL 7.4 (lack of SAVEPOINTs)

2010-06-23 Thread Konstantin Izmailov
Is there a way to prevent transaction abort when preparing command in version 7.4? I googled but haven't been able to find the answer. The issue occurs when our software trys to prepare a command that is already prepared (by the same or different app). PQprepare returns error and aborts current tr

Re: [GENERAL] parsing geometric operators

2010-06-04 Thread Konstantin Izmailov
Please ignore my question. I found "Op" tokens definition in scan.l! On Fri, Jun 4, 2010 at 6:15 PM, Konstantin Izmailov wrote: > I'm creating my own parser/regex combination for fast and lightweight > Postgres queries processing (in a user app). So I wanted to double check

[GENERAL] parsing geometric operators

2010-06-04 Thread Konstantin Izmailov
I'm creating my own parser/regex combination for fast and lightweight Postgres queries processing (in a user app). So I wanted to double check some details in PG source, but could not find the geometric operators ( http://www.postgresql.org/docs/8.4/static/functions-geometry.html) definition/rules

Re: [GENERAL] Savepoint and prepared transactions

2010-05-05 Thread Konstantin Izmailov
yep, thank you! On Wed, May 5, 2010 at 5:47 AM, Scott Marlowe wrote: > Should work. I'm not sure 2.5 release savepoint is necessary. > > On Wed, May 5, 2010 at 12:53 AM, Konstantin Izmailov > wrote: > > I expect that only changes on step 2.7 persisted in DB. > >

Re: [GENERAL] Savepoint and prepared transactions

2010-05-04 Thread Konstantin Izmailov
I expect that only changes on step 2.7 persisted in DB. On Tue, May 4, 2010 at 11:18 PM, Scott Marlowe wrote: > On Tue, May 4, 2010 at 11:52 PM, Konstantin Izmailov > wrote: > > Hi, > > I'm working on a solution that utilizes 2 phase commit protocol (between > SQL

[GENERAL] Savepoint and prepared transactions

2010-05-04 Thread Konstantin Izmailov
Hi, I'm working on a solution that utilizes 2 phase commit protocol (between SQL Server and PostgreSQL). Normally PostgreSQL statements sequense is: 1. START 2. 3. PREPARE TRANSACTION 'uuid' 4. COMMIT PREPARED 'uuid' What if on step 2 user application issues statements with SAVEPOINTs, e.g. 2.1.

Re: [GENERAL] pg_attribute.attnum - wrong column ordinal?

2009-11-24 Thread Konstantin Izmailov
e the table name changes. Thank you tons! On Tue, Nov 24, 2009 at 8:04 PM, Greg Stark wrote: > On Wed, Nov 25, 2009 at 2:00 AM, Konstantin Izmailov > wrote: > > Greg, > > this is brilliant - thank you very much! > > > > Is "partition by" compa

Re: [GENERAL] pg_attribute.attnum - wrong column ordinal?

2009-11-24 Thread Konstantin Izmailov
09 at 1:03 AM, Konstantin Izmailov > wrote: > > > My question: can pg_attribute.attnum be used to determine the sequential > > ordinal positions of columns in a table? What is a right way to get the > > ordinal numbers? > > You could use something like: > > row_nu

[GENERAL] pg_attribute.attnum - wrong column ordinal?

2009-11-24 Thread Konstantin Izmailov
Today I was contacted by a Microsoft (!) developer Kamil who was working on issues in Linked Servers to PostgreSQL. He brought the following scenario: if a column is dropped then ordinal positions of remaining columns are reported incorrectly. Here is test scenario: 1) create a table in PGAdmin:

Re: [GENERAL] passing parameters to multiple statements

2009-11-18 Thread Konstantin Izmailov
e. Thank you for the valuable discussion! Konstantin On Tue, Nov 17, 2009 at 9:16 PM, David Fetter wrote: > On Tue, Nov 17, 2009 at 09:33:05AM -0700, Konstantin Izmailov wrote: > > Some companies have policy to stay DB agnostic, i.e. use standard > > SQL only. > > Th

Re: [GENERAL] passing parameters to multiple statements

2009-11-17 Thread Konstantin Izmailov
n one statement? If PQexecParams does not support multiple statements, it needs to be extended for the support, or new function created for the purpose. If I do the change in libpq, may I submit the code to community? Thank you! Konstantin On Mon, Nov 16, 2009 at 2:11 PM, wrote: > Ko

[GENERAL] passing parameters to multiple statements

2009-11-15 Thread Konstantin Izmailov
I'm planning to use multiple statements via libpq. Before starting coding I'm trying to understand are there any limitations on passing parameters. E.g. would the following work: PQexecParams(conn, "BEGIN;INSERT INTO tbl VALUES($1,$2);SELECT lastval();SELECT * INTO AUDIT FROM (SELECT $3, 'tbl act

Re: [GENERAL] "money" binary representation

2009-11-15 Thread Konstantin Izmailov
Right, the value is '$51.20'! Now I understand how to interpret the bytes - thank you! I had to work with an existing database and I do not know why they still use "money" fields. On Sun, Nov 15, 2009 at 9:38 PM, John R Pierce wrote: > Konstantin Izmailov wrote: > &g

[GENERAL] "money" binary representation

2009-11-15 Thread Konstantin Izmailov
I'm trying to read "money" field using PQgetvalue (PostgreSQL 8.3.7). The function returns 9 bytes, smth like 0h 0h 0h 0h 0h 0h 14h 0h 0h, for the value '$50.2'. I could not find description anywhere on how to convert the binary data into, for example, a double precision number. Would you please h

[GENERAL] howto determine rows count to be returned by DECLARE ... SELECT ...

2009-07-06 Thread Konstantin Izmailov
Dear Community, I'm working on implementation of virtual grid using DECLARE... SELECT Advantage of virtual grid is that it loads only rows that a user is willing to see (with FETCH). However, it is not clear how to determine max rows count that the cursor can return. The count is necessary for

Re: [GENERAL] issue with lo_lseek - it returns 4

2009-06-17 Thread Konstantin Izmailov
implementation already. On Wed, Jun 17, 2009 at 4:05 PM, Tom Lane wrote: > Konstantin Izmailov writes: > > Out of curiosity, what if lo object has size > 4GB, how lo_tell return > its > > size? Looks like this is an interface issue. > > That's simple: it can't have such

Re: [GENERAL] issue with lo_lseek - it returns 4

2009-06-17 Thread Konstantin Izmailov
Out of curiosity, what if lo object has size > 4GB, how lo_tell return its size? Looks like this is an interface issue. I found a post dated back to 1998, when somebody pointed it out and a posgres developer promised to fix it. Thank you all On Wed, Jun 17, 2009 at 3:15 PM, Konstantin Izmai

Re: [GENERAL] issue with lo_lseek - it returns 4

2009-06-17 Thread Konstantin Izmailov
I found the reason - it was bug in my code when inserting lo object. It's size was actually 4. Please ignore or delete my post. On Wed, Jun 17, 2009 at 11:38 AM, Konstantin Izmailov wrote: > Hi, > I'm trying to get lo size via libpq before starting reading it (postgres > serv

[GENERAL] issue with lo_lseek - it returns 4

2009-06-17 Thread Konstantin Izmailov
Hi, I'm trying to get lo size via libpq before starting reading it (postgres server 8.3.5). lo_lseek always returns 4 (actual size is > 1M). I query table with "select photo from employee where id=''". It returns lo oid integer as expected. Then I use following code to obtain size of the lo obj

Re: [GENERAL] question about SSIS

2009-05-22 Thread Konstantin Izmailov
just cannot provide required modes due to DB limitation. On May 22, 2009, at 3:18 PM, Magnus Hagander wrote: Tom Lane wrote: Konstantin Izmailov writes: I've asked a few people at pgcon2009 about the issue of connecting users differently: some in SSIS mode, some - with password.

[GENERAL] question about SSIS

2009-05-22 Thread Konstantin Izmailov
I've asked a few people at pgcon2009 about the issue of connecting users differently: some in SSIS mode, some - with password. This is still an issue: if server is configured for SSIS, there is no way to connect with password. It appears that the solution of the issue is to introduce connection str

Re: [GENERAL] [Oledb-dev] A major rewrite of the Postgres OLE DB Provider.

2006-12-16 Thread Konstantin Izmailov
Great! I will take a look and let you know. I had rewritten the Provider about a year ago as well. However, I did not have time to clean-up most of the new bugs and decided to keep the code for myself. There is certain interest in the US to the more capable Provider. On 12/15/06, Jeremy Lea <[EMA