[GENERAL] licensing/distribution of DLL's question

2009-08-14 Thread Jim Michaels
I wrote a postgres embedded application that uses libpq and requires the 
postgres DLL's in the bin directory to run. I am curious if I am allowed to 
package my app with the DLL's without distributing the entire postgres database 
application, though I could include all of postgres.

postgres is under a different license than my app.  my app is under the GPL3 
license.  Since I wrote it, I can always change it. (it just got practically 
finished)

also, I am curious - if I include those DLL's and somebody has a newer version 
of postgres, will the program still run against the database, or will a fresh 
set of DLL's have to be copied out from the bin dir again?

Jim Michaels 



  

[GENERAL] PQoidValue - isn't it for...?

2009-08-12 Thread Jim Michaels
I am struggling to learn libpq.

for some reason, I could not get an INSERT to produce an Oid.  actually, what I 
am looking for, is to get the ID of the last record inserted or to verify that 
I inserted a record successfully.  I think you use PQresultStatus() for that.(?)

Isn't PQoidValue() for getting the last INSERT id?  or am I misunderstanding it?


I just figured out how to set the start id of a BIGSERIAL to 1000.



SAMPLE OUTPUT:

firstname:Horatio
middlename:P
lastname:Algers
homephone:345-678-9012
workphone:
cellphone:
pager:
company:
address1:
address2:
city:
mailstop:
stateprovince:
postalcode:
country:
comment:abc,123,456
website:
emailhome:
emailwork:
QUERY:"INSERT INTO 
s_phonelist.phonelist(firstname,middlename,lastname,homephone,workphone,cellphone,pager,company,address1,address2,city,mailstop,stateprovi
,postalcode,country,_comment,website,emailhome,emailwork)
VALUES('Horatio','P','Algers','345-678-9012','','','','','','','','','','','','abc,123,456','','','')"
ERROR: INSERT operation failed!
done.





sprintf(querystr, "INSERT INTO s_phonelist.phonelist(%s)\n"
 "VALUES(%s)", fnl, vl);
printf("QUERY:\"%s\"\n", querystr);
pgr = PQexec(pgc,querystr);

if (PGRES_COMMAND_OK!=PQresultStatus(pgr)) {
printf("INSERT result is not OK\n");
} else {
Oid oid =  PQoidValue(pgr);
if (0 == oid) {
 printf("ERROR: INSERT operation failed!\n");
}
}

Jim Michaels 


  

Re: [GENERAL] libpq

2009-08-10 Thread Jim Michaels
these are straight dll calls as outlined in Using Run-Time Dynamic Linking 
(Windows) 
that's why they look funny.  it is impossible to link VC++ .lib files with 
mingw(gcc) .a libraries.

yeah, I just found the PQntuples bug myself too, and got the program finished.  
thank you for the tips on using libpq, I may still need to implement those.  

I didn't remember seeing anywhere in the docs that you were supposed to check 
for pqr==NULL, I wish they would document that in PQexec. must be a 
documentation bug. There is no mention of return values! 
http://www.postgresql.org/docs/8.4/interactive/libpq-exec.html

still doesn't solve the need for MingW *.a  libraries version of libpq.  I 
wouldn't have had to rewrite the whole thing for this to work with mingw.  The 
DLL's are VC++/MinGW compatible, but the .lib files are not.


Jim Michaels
jmich...@yahoo.com
http://JesusnJim.com






____
From: Scott Ribe 
To: Jim Michaels ; pgsql general 

Sent: Sunday, August 9, 2009 9:16:34 AM
Subject: Re: [GENERAL] libpq

That's pretty confused C code. The most obvious problem is that you're not
calling the Pqntuples function; you're just examining the value of a
variable called ntuples, when you haven't set that value after calling
Pqexec (and maybe have never set it).

Take it step by step, and check error returns at each step--including
connecting to the database, and of course especially check errors after
calling PQexec--first checking that pgr is not null, then if not null using
the PQresultStatus, PQresStatus, PQresultErroMessage functions, otherwise
the PQstatus, PQerrorMessage functions.

Then if you still have problems, post more complete code that includes
important things like connecting to the database, and declarations &
assignments to key variables.

Also, what is this "(function)(args)" stuff? Normally, the PQ functions are
plain C functions, called as "function(args)". Do you really have some setup
where you have function pointer variables and your compiler requires that
outdated syntax? Or is this more basic C confusion?

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


  

[GENERAL] libpq

2009-08-08 Thread Jim Michaels
I am trying to compile a program with libpq using boirland c++ 5.5.1 free 
edition and with mingw(gcc), and SELECT queries are returning PQntuples with 
results of 0, but I can do the same query in pgadmin and get 1 result.



there is no way to link on the .lib files because they are in COFF format.  
what compiler did they use to make these libs?  could somebody please make libs 
and separate DLLs (that is important - they are different inside) available for 
the mingw compiler?  It is a free compiler available at mingw.org.

the borland c++ 5.5.1 (free)-compiled program does absolutely nothing, I think 
because the DLL's are not compatible.

sprintf(querystr,
"SELECT * FROM s_phonelist.phonelist\n"
"WHERE %s\n"
"ORDER BY 
lastname,firstname,middlename,country,stateprovince,city,mailstop,company"
, s
);
#if defined(_DEBUG)
printf("QUERY:\"%s\"\n", querystr);
#endif
pgr = (PQexec)(pgc,querystr);


if (0 == ntuples) {
printf("--no records.--\n");
(PQfinish)(pgc);
return 0;
} else {

for (index=0; index < ntuples; index++) {
//copy values from row to Crecord row
val = (PQgetvalue)(pgr,index, 
0);strcpy(row.firstname, val);
val = (PQgetvalue)(pgr,index, 
1);strcpy(row.middlename   , val);
val = (PQgetvalue)(pgr,index, 
2);strcpy(row.lastname , val);
val = (PQgetvalue)(pgr,index, 
3);strcpy(row.homephone, val);
val = (PQgetvalue)(pgr,index, 
4);strcpy(row.workphone, val);
val = (PQgetvalue)(pgr,index, 
5);strcpy(row.cellphone, val);
val = (PQgetvalue)(pgr,index, 6);strcpy(row.pager   
 , val);
val = (PQgetvalue)(pgr,index, 7);strcpy(row.company 
 , val);
val = (PQgetvalue)(pgr,index, 
8);strcpy(row.address1 , val);
val = (PQgetvalue)(pgr,index, 
9);strcpy(row.address2 , val);
val = (PQgetvalue)(pgr,index,10);strcpy(row.city
 , val);
val = 
(PQgetvalue)(pgr,index,11);strcpy(row.mailstop , val);
val = 
(PQgetvalue)(pgr,index,12);strcpy(row.stateprovince, val);
val = 
(PQgetvalue)(pgr,index,13);strcpy(row.postalcode   , val);
val = (PQgetvalue)(pgr,index,14);strcpy(row.country 
 , val);
val = (PQgetvalue)(pgr,index,15);strcpy(row.comment 
 , val);
val = (PQgetvalue)(pgr,index,16);strcpy(row.website 
 , val);
val = 
(PQgetvalue)(pgr,index,17);strcpy(row.emailhome, val);
val = 
(PQgetvalue)(pgr,index,18);strcpy(row.emailwork, val);
//now display in an orderly fashion.
showrecord(row);
}
}



Jim Michaels
jmich...@yahoo.com
http://JesusnJim.com




while (stone != rolling) moss++;
---
Computer memory/disk size measurements:
[KB KiB] [MB MiB] [GB GiB] [TB TiB]
[10^3B=1000B=1KB][10^6B=100B=1MB][10^9B=10B=1GB][10^12B=1B=1TB]
[2^10B=1024B=1KiB][2^20B=1048576B=1MiB][2^30B=1073741824B=1GiB][2^40B=1099511627776B=1TiB]
Note that with disks, a disk size is measured in GB or TB, not in GiB or TiB.  
computer memory (RAM) is measured in MiB and GiB.
---
new cyber dog food: Cables n' Bits
---


  

[GENERAL] problem with pg_restore?

2009-07-14 Thread Jim Michaels
I am having problems with pg_restore.  pg_restore 
--file=c:\pg-jmichae3-7-13-2009.sql --verbose --host=localhost --port=5432 
--username=postgres

this just hangs.
I am restoring from 8.3.7 to 8.4 - what did I do wrong?

could somebody rewrite pg_dumpall and pg_dump so that it makes editable dumps?
most programmer's text editors can't handle more than 2000 characters per line.
and I want to be able to edit my dumps.

 


Jim Michaels
jmich...@yahoo.com
http://JesusnJim.com


  

[GENERAL]

2009-07-13 Thread Jim Michaels
I already miss the pginstall installers from postgresql.org.  they had 
everything in them.  I was thinking of switching over from the EnterpriseDB 
installers to the postgresql installers on next rev (8.4) but now I can't 
because they are not available anymore.

I am not so sure the EnterpriseDB installers are as well-featured.  I don't 
think they come at least with all the languages and the hot backups, etc.  
correct me if I am wrong.  

it's hard to tell from a list of executables, but I am pretty sure the 
languages support isn't all there.

 could somebody bring it back?


Jim Michaels
jmich...@yahoo.com
http://JesusnJim.com