From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kevin Jenkins <gameprogrammer(at)rakkar(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: ERROR: there is no parameter $1 |
Date: | 2006-06-20 03:51:00 |
Message-ID: | 24116.1150775460@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Kevin Jenkins <gameprogrammer(at)rakkar(dot)org> writes:
> Tom Lane wrote:
>> Hm, nothing obviously wrong there. What PG version is this exactly?
>> Can you supply a self-contained test case?
> I made the smallest test case that I can and uploaded it here:
> http://www.rakkarsoft.com/PostgreBug.zip
> I'm sorry in advance I couldn't make it smaller but hopefully this is
> still manageable.
I tried to extract a non-Windows-dependent test case out of this,
without much luck. Anyone else care to try?
I made the attached by plugging your PQexecParams call into
src/test/examples/testlibpq3.c, and it works fine after having
manually created the FileVersionHistory table.
regards, tom lane
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "libpq-fe.h"
/* for ntohl/htonl */
#include <netinet/in.h>
#include <arpa/inet.h>
static void
exit_nicely(PGconn *conn)
{
PQfinish(conn);
exit(1);
}
int
main(int argc, char **argv)
{
const char *conninfo;
PGconn *conn;
PGresult *res;
char query[512];
const char *outTemp[3];
int outLengths[3];
int formats[3];
/*
* If the user supplies a parameter on the command line, use it as the
* conninfo string; otherwise default to setting dbname=postgres and using
* environment variables or defaults for all other connection parameters.
*/
if (argc > 1)
conninfo = argv[1];
else
conninfo = "dbname = test";
/* Make a connection to the database */
conn = PQconnectdb(conninfo);
/* Check to see that the backend connection was successfully made */
if (PQstatus(conn) != CONNECTION_OK)
{
fprintf(stderr, "Connection to database failed: %s",
PQerrorMessage(conn));
exit_nicely(conn);
}
sprintf(query, "INSERT INTO FileVersionHistory(applicationID, filename, createFile, changeSetID, userName) VALUES (%i, $1::text,FALSE,%i,'%s');",
42, 77, "user");
outTemp[0]="foo";
outLengths[0]=strlen(outTemp[0]);
formats[0]=0;
res = PQexecParams(conn, query,1,0,outTemp,outLengths,formats,1);
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "INSERT failed: %s", PQerrorMessage(conn));
PQclear(res);
exit_nicely(conn);
}
PQclear(res);
/* close the connection to the database and cleanup */
PQfinish(conn);
return 0;
}
From | Date | Subject | |
---|---|---|---|
Next Message | Arie Nugraha | 2006-06-20 04:11:23 | Database Clustering on multiple harddisk |
Previous Message | Bill Moran | 2006-06-20 03:29:54 | Re: incremental backup? |