Christian Ullrich | 1 Oct 2010 04:21

Re: libpq (C++) - Insert binary data

* GOO Creations wrote:

> This is what I have until now to insert data
>
> char *query = "insert into table1 (bytes) values ($1)";
> QByteArray chip = <assignment of bytes>;
> const char *data = chip->data();
> const char* params[]={data};
> const int params_length[]={chip->length()};
> const int params_format[]={1};
> result = PQexecParams(mDatabase, query, 1, in_oid, params,
> params_length, params_format, 0);
>
> The first problem I have is that I'm not sure if const int
> params_length[]={chip->length()}; is the correct way to provide the
> length. Second of all, is this actually the correct way of doing it,
> isn't there a beter way?

It is certainly the simplest way of doing it in plain libpq, as long as 
you're using the binary format (which you are doing here). According to 
the documentation, QByteArray::length() returns the number of bytes in 
the array, so it is the correct size.

I'm not sure if the (internal) binary format of bytea is guaranteed not 
to change in future versions of PostgreSQL. Currently, as you obviously 
found out yourself, it's pretty simple -- no transformation at all, the 
binary format is just the data.

To make sure that your application supports any changes in future 
versions, you should consider using the "hex" text format instead. See 
(Continue reading)

GOO Creations | 1 Oct 2010 08:58
Picon

Re: libpq (C++) - Insert binary data

  thanks for this tip, but as far as I understand it libpqtypes is not 
part of the original lipq libary .
This will result in the same problem as with the Qt libraries, it will 
add another dependecy to my plugin, which is not allowed.

Chris

On 2010/09/30 10:59 PM, Merlin Moncure wrote:
> On Thu, Sep 30, 2010 at 11:42 AM, GOO Creations<goocreations <at> gmail.com>  wrote:
>>   Yes there is a reason I'm not using Qt's libraries. Qt doesn't come out
>> with PSQL as default driver (meaning you have to manually download the
>> driver for Qt postgres). I'm developing a plugin for an app that restricts
>> Qt, no extra depedncies are allowed. But the app has libpq as dependcy, so
>> I'm able to use that.
> here is my response from the previous time I answered the question.
> There a number of ways to deal with this (my favorite by far is
> libpqtypes, but I'm quite biased!):
>
> On Wed, Jul 21, 2010 at 9:27 AM, Merlin Moncure<mmoncure <at> gmail.com>  wrote:
>> On Mon, Jul 19, 2010 at 8:14 PM, vinicius_bra<viniciusams <at> yahoo.com.br>  wrote:
>>> Hi All,
>>>
>>> I'm developing a system in C and I have a unsigned char pointer that
>>> represents a struct and I like to store it in a bytea column in postgreSQL.
>>> How can I do it?
>>> Example:
>> you have several options:
>> *) encode the memory for the structure PQescapeStringConn and send to
>> PQexec (my least favorite method)
>> *) set up a call to PQexecParams (more work, but faster and no escaping)
(Continue reading)

Michele Petrazzo - Unipex | 1 Oct 2010 09:02
Picon

Re: [9.0] hot standby plus streaming replication

Gabriele Bartolini ha scritto:
> Ciao Michele,

Ciao ;)

>
>> both server (master and standby) need a common directory where
>> read
>>
> and write the wal files?
>
> Not necessarily. You can use for instance scp to ship the WAL file
> from the master to the standby using the network.
>

Thanks for the explain, but...
- why in my tests, _whitout_ common direcotory, master and slave keep in
sync also if I shutdown slave, add (in my last tests) something about
100k record (although little ones) on the master and then after woke up
the slave in about 2/3 seconds I have all the dbs in sync? It's just
luck or there are something that I don't understand?
- If I have to copy (scp / rsync / etc...) the files, which interval I
have to follow? And also, when the slave will read these files? There
are something like inotify or I have to say to slave "my friend, there
are updates from master. Keep in sync!"

>> Just another question about replication: there is the possibility
>> to
> build a sync between a 32 and a 64 bit (on linux)?
>
(Continue reading)

Jayadevan M | 1 Oct 2010 09:07

Re: [9.0] hot standby plus streaming replication

> 
> P.s. Glad to see that also in Italy there are PostgreSQL guru ;)
> 
Glad to see that more people are using Indian words (Guru) :)
http://en.wikipedia.org/wiki/Guru

Regards,
Jayadevan

DISCLAIMER: 

"The information in this e-mail and any attachment is intended only for 
the person to whom it is addressed and may contain confidential and/or 
privileged material. If you have received this e-mail in error, kindly 
contact the sender and destroy all copies of the original communication. 
IBS makes no warranty, express or implied, nor guarantees the accuracy, 
adequacy or completeness of the information contained in this email or any 
attachment and is not liable for any errors, defects, omissions, viruses 
or for resultant loss or damage, if any, direct or indirect."

--

-- 
Sent via pgsql-general mailing list (pgsql-general <at> postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

John R Pierce | 1 Oct 2010 09:08
Favicon

Re: libpq (C++) - Insert binary data

  On 09/30/10 11:58 PM, GOO Creations wrote:
>  thanks for this tip, but as far as I understand it libpqtypes is not 
> part of the original lipq libary .
> This will result in the same problem as with the Qt libraries, it will 
> add another dependecy to my plugin, which is not allowed.

take the source to libpqtypes, and static link it with your plugin.

--

-- 
Sent via pgsql-general mailing list (pgsql-general <at> postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Fujii Masao | 1 Oct 2010 09:42
Picon

Re: [9.0] hot standby plus streaming replication

On Fri, Oct 1, 2010 at 4:02 PM, Michele Petrazzo - Unipex
<michele.petrazzo <at> unipex.it> wrote:
> - why in my tests, _whitout_ common direcotory, master and slave keep in
> sync also if I shutdown slave, add (in my last tests) something about
> 100k record (although little ones) on the master and then after woke up
> the slave in about 2/3 seconds I have all the dbs in sync?

Because the master had the WAL files containing that 100k record in its
pg_xlog directory. If those WAL files were unfortunately removed from
the master before you started the standby, the standby would not have
been in sync with the master.

You can specify how many WAL files you'd keep in the master by using
wal_keep_segments parameter.
http://developer.postgresql.org/pgdocs/postgres/runtime-config-wal.html#RUNTIME-CONFIG-REPLICATION

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

--

-- 
Sent via pgsql-general mailing list (pgsql-general <at> postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Magnus Hagander | 1 Oct 2010 10:21

Re: Missing path in pg_config

On Thu, Sep 30, 2010 at 17:45, Turner, John J <JJTurner <at> statestreet.com> wrote:
>
> It sounds like I'm in quite a fix here.  If PGXS is currently a no-go in Windows, then that renders the
temporal extension incompatible with Windows since it uses PGXS to install...

It's not entirely a no-go. If you really want it, you could download
and build postgresql using mingw. That will give you the pgxs files to
build it with. Yes, it's a really hard and painful way to do it, but
it can be done :-)

> OTOH, if there's some remote possibility of some workaround solution for Windows to get PGXS and/or the
temporal extension installed, I'd be grateful if someone could help me along with it (further to your
below suggestions, since I'm floundering around in unfamiliar territory here).

I wonder how hard it would be to make MSVC build files for the
temporal extensions. IIRC it's a very simple project. Jeff - have you
looked at this?

-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

--

-- 
Sent via pgsql-general mailing list (pgsql-general <at> postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Willy-Bas Loos | 1 Oct 2010 10:47
Picon
Gravatar

Re: where does postgres keep the query result until it is returned?

On Thu, Sep 30, 2010 at 7:29 PM, Willy-Bas Loos <willybas <at> gmail.com> wrote:
> One thing that i think works is to create a table from your results.
> That is, if your result is not one big chunk in one row that won't fit
> in memory, but lots of rows.

On second thought, that helps for the scenario where your client
looses connection or otherwise stops functioning before it has
received the whole query result, it isn't really related to the topic.
-- 
"Patriotism is the conviction that your country is superior to all
others because you were born in it." -- George Bernard Shaw

--

-- 
Sent via pgsql-general mailing list (pgsql-general <at> postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Vincenzo Romano | 1 Oct 2010 11:20
Picon

Re: [9.0] On temporary tables

2010/9/30 Vincenzo Romano <vincenzo.romano <at> notorand.it>:
> 2010/9/30 Tom Lane <tgl <at> sss.pgh.pa.us>:
>> Vincenzo Romano <vincenzo.romano <at> notorand.it> writes:
>>> create or replace function session_init()
>>> returns void
>>> language plpgsql
>>> as $body$
>>> declare
>>>   t text;
>>> begin
>>>   select valu into t from session where name='SESSION_ID';
>>>   if not found then
>>>     create temporary table session ( like public.session including all );
>>>     insert into session values ( 'SESSION_ID',current_user );
>>>   end if;
>>> end;
>>> $body$;
>>
>>> The idea is to create a temporary table to store session variables
>>> only of there's no temporary table with that name.
>>
>> That isn't going to work tremendously well.  plpgsql will cache a plan
>> for that SELECT on first use, and creation of the temp table is not an
>> event that will cause replanning of a select that doesn't already use
>> the temp table.

Quoting from documentation (v9.0.0 at chapter 35.6, v8.4.4 at chapter 34.6)
"A VOLATILE function can do anything, including modifying the
database. It can return different
results on successive calls with the same arguments. The optimizer
(Continue reading)

Dave Page | 1 Oct 2010 11:27
Favicon
Gravatar

Re: PostgreSQL 9.0 (x86-64) and Windows 7 (x86-64) - Unable to install

For the benefit of the list, I've raised this issue with the people
who supply the installer technology, as I can't see any reason why our
code would get this wrong.

On Thu, Sep 30, 2010 at 9:53 PM, Dr. Peter Voigt <pvoigt <at> uos.de> wrote:
> Dave Page <dpage <at> pgadmin.org> writes:
>
>> A couple of questions for you Peter (and thanks for bearing with us
>> while we figure this out):
>>
>> - How are you running the installer? Are you logged in as
>> "Administrator", or are you using "Run As Administrator" or something
>> similar?
>
> I am logged in as "Administrator" when running the installer.
>
>>
>> - What's the output from the "SET" command when run in the same user
>> environment as the installer (ie. from an Administrator command
>> prompt, or one launched however you've escalated your privileges).
>
> Please find the environment of user "Administrator" attached:
>
>
> ACR_BIN=C:\Program Files (x86)\Adobe\Reader 9.0\Reader
> ALLUSERSPROFILE=C:\ProgramData
> APACHE2_HOME=C:\Program Files\Apache Group\Apache22
> APACHESRC=C:\Programme\Apache Group\Apache22
> APPDATA=C:\Users\Administrator\AppData\Roaming
> asl.log=Destination=file;OnFirstLog=command,environment,parent
(Continue reading)


Gmane