[postgis] Is there any solution to exceed the limit of PGLIB
Paul Ramsey
pramsey at refractions.net
Tue Nov 27 10:28:14 PST 2001
Is it possible the libpq you are using, Tony, is precompiled with a
restriction? 8K is sometimes a restriction in the ODBC driver, but I've
never seen a restriction in libpq itself.
Dave Blasby wrote:
>
> "TONY J.Y." wrote:
> >
> > I am using the PGLIB C lib to connect to PgSql to finish the update of
> > the GEOMETRY of a table.
> >
> > At first, everything is OK. I can insert, update, delete and select of
> > whatever I want.
> >
> > However, I got a fatal running error. There is an error when my SQL
> > string length exceeds 8190 Bytes.
>
> I couldnt reproduce your error, I wrote a simple program that uses libpq
> to insert large strings into a table. Even with queries larger than
> 20,000 characters, I got no errors.
>
> #include "libpq-fe.h"
> #include <stdio.h>
> #include <string.h>
>
> PGconn *conn;
> PGresult *rs;
>
> // check the connection string for your database
> // create table testt (mytext text);
> // cc test.c -lpq -I/data3/postgresql-7.1.2/include -g
> // a.out
> // select length(mytext) from testt;
>
> main()
> {
> char sql[50000];
> char mytext[50000];
> char temp[100];
> int t;
>
> //connect to DB
>
> conn = PQconnectdb("host=localhost user=postgres port=5555 dbname=t1");
>
> if (PQstatus(conn) == CONNECTION_BAD)
> {
> printf ("couldnt connect to postgresql\n");
> exit (-1);
> }
>
> // build a long (but boring) string
>
> mytext[0] = 0;
>
> for (t=0;t<4000;t++)
> {
> sprintf(temp,"-%i-",t);
> strcat(mytext,temp);
> }
>
> printf("about to insert a string of length %i\n", strlen(mytext));
>
> // create SQL statement
> sprintf(sql,"INSERT INTO testt values ('%s');", mytext);
>
> // execute the statement
> rs = PQexec(conn,sql);
>
> // did it work?
> if (PQresultStatus(rs) != PGRES_COMMAND_OK)
> {
> printf ("an error occured in the sql insert statement:\n");
> printf ("%s\n", PQerrorMessage(conn) );
> exit (-1);
> }
> //clean up
> PQclear(rs); // should close the connection too
> printf("worked ok!\n");
> }
>
>
> To unsubscribe from this group, send an email to:
> postgis-unsubscribe at yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
--
__
/
| Paul Ramsey
| Refractions Research
| Email: pramsey at refractions.net
| Phone: (250) 885-0632
\_
------------------------ Yahoo! Groups Sponsor ---------------------~-->
E-mail viral marketing - with FastTree
Email to 50. You might reach 500.
Unlimited use and tracking, $20/mo.
http://www.fasttree.com/s/11.htm
http://us.click.yahoo.com/UGVLpD/MJRDAA/yigFAA/PhFolB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the postgis-users
mailing list