- changed component to Core
Prepared statement maximum bind parameters
/* Replace all occurences of ? in this string buffer with prefix[1..99] */
static int _prepare(T S, char prefix) {
int n, i;
for (n = i = 0; S->buffer[i]; i++) if (S->buffer[i] == '?') n++;
if (n > 99)
THROW(SQLException, "Max 99 parameters are allowed in a prepared statement. Found %d parameters in statement", n);
else if (n) {
int j, xl;
char x[3] = {prefix};
int required = (n * 2) + S->used;
if (required >= S->length) {
S->length = required;
RESIZE(S->buffer, S->length);
}
for (i = 0, j = 1; (j <= n); i++) {
if (S->buffer[i] == '?') {
if(j<10){xl=2;x[1]=j+'0';}else{xl=3;x[1]=(j/10)+'0';x[2]=(j%10)+'0';}
memmove(S->buffer + i + xl, S->buffer + i + 1, (S->used - (i + 1)));
memmove(S->buffer + i, x, xl);
S->used += xl - 1;
j++;
}
}
S->buffer[S->used] = 0;
}
return n;
}
We have been using thsi for a while that we can have only maximum 99 prepared parametes , I am unable to understand the reason behind this , why we are fixing this if postgress provide way more binding . My sugession is why cant we make it the maximum limit that postgress have?????.
I will be glad if i would be able to know the reason behind this or if this is done by some mistake i think we need to correct this to the max limit that the database have.
Comments (4)
-
reporter -
repo owner "Max 99 parameters are allowed in a prepared statement”
This is just a convenience limitation when numbering prepared statement parameters. I just assumed and continue to assume that 99 parameters is more than enough for a model on third-normal form. -
reporter Thank you for the quick response , I have understood what your motive is.
-
reporter - changed status to resolved
Resolved
- Log in to comment