adding validated services? patching forcad_local.py
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
typedef unsigned Oid;
|
||||
typedef struct { int dummy; } PGconn;
|
||||
|
||||
static int myexecParams(PGconn *c, const char *cmd, int nParams,
|
||||
const Oid *paramTypes,
|
||||
const char *const *paramValues,
|
||||
const int *paramLengths,
|
||||
const int *paramFormats,
|
||||
int resultFormat)
|
||||
{
|
||||
(void)c; (void)paramTypes; (void)paramLengths; (void)paramFormats; (void)resultFormat;
|
||||
printf("CMD:%s\n", cmd);
|
||||
printf("N:%d\n", nParams);
|
||||
for (int i = 0; i < nParams; ++i) {
|
||||
const char *p = paramValues[i];
|
||||
printf("P[%d]=%s\n", i, p ? p : "(null)");
|
||||
}
|
||||
return 1234;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
PGconn conn; // dummy
|
||||
char uid[16]; snprintf(uid, sizeof(uid), "%d", 42);
|
||||
char name[32] = "Hello";
|
||||
char descr[32] = "World";
|
||||
char json[64] = "[1,2,3]";
|
||||
const char *params[4] = { uid, name, descr, json };
|
||||
const char *query = "INSERT INTO t (a,b,c,d) VALUES ($1::int,$2,$3,$4::jsonb)";
|
||||
int r = myexecParams(&conn, query, 4, NULL, params, NULL, NULL, 0);
|
||||
printf("RET:%d\n", r);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user