[postgis] Is there any solution to exceed the limit of PGLIB
Dave Blasby
dblasby at refractions.net
Tue Nov 27 10:18:48 PST 2001
"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");
}
------------------------ 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