6-pg85-fix-auto-prepare-multiconn-2.patch
text/x-patch
Filename: 6-pg85-fix-auto-prepare-multiconn-2.patch
Type: text/x-patch
Part: 0
Message:
Fix auto-prepare #2
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/interfaces/ecpg/ecpglib/execute.c | 3 | 0 |
| src/interfaces/ecpg/ecpglib/prepare.c | 9 | 0 |
diff -dcrp pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c pgsql.1/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c 2010-01-05 18:02:03.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/ecpglib/execute.c 2010-01-18 11:49:17.000000000 +0100
*************** ECPGdo(const int lineno, const int compa
*** 1753,1759 ****
--- 1753,1762 ----
stmt->command = ecpg_strdup(command, lineno);
}
else
+ {
ecpg_raise(lineno, ECPG_INVALID_STMT, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, stmt->command);
+ return (false);
+ }
}
stmt->connection = con;
diff -dcrp pgsql.orig/src/interfaces/ecpg/ecpglib/prepare.c pgsql.1/src/interfaces/ecpg/ecpglib/prepare.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/prepare.c 2010-01-15 12:55:24.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/ecpglib/prepare.c 2010-01-18 11:32:26.000000000 +0100
*************** ecpg_auto_prepare(int lineno, const char
*** 465,472 ****
--- 465,481 ----
/* if not found - add the statement to the cache */
if (entNo)
{
+ struct connection *con;
+ struct prepared_statement *prep;
+
ecpg_log("ecpg_auto_prepare on line %d: statement found in cache; entry %d\n", lineno, entNo);
*name = ecpg_strdup(stmtCacheEntries[entNo].stmtID, lineno);
+
+ con = ecpg_get_connection(connection_name);
+ prep = ecpg_find_prepared_statement(*name, con, NULL);
+ /* This prepared name doesn't exist on this connection. */
+ if (!prep && !ECPGprepare(lineno, connection_name, 0, ecpg_strdup(*name, lineno), query))
+ return (false);
}
else
{