(ctx context.Context, b *Batch)
| 1071 | } |
| 1072 | |
| 1073 | func (c *Conn) sendBatchQueryExecModeCacheStatement(ctx context.Context, b *Batch) (pbr *pipelineBatchResults) { |
| 1074 | if c.statementCache == nil { |
| 1075 | return &pipelineBatchResults{ctx: ctx, conn: c, err: errDisabledStatementCache, closed: true} |
| 1076 | } |
| 1077 | |
| 1078 | distinctNewQueries := []*pgconn.StatementDescription{} |
| 1079 | distinctNewQueriesIdxMap := make(map[string]int) |
| 1080 | |
| 1081 | for _, bi := range b.QueuedQueries { |
| 1082 | if bi.sd == nil { |
| 1083 | sd := c.statementCache.Get(bi.SQL) |
| 1084 | if sd != nil { |
| 1085 | bi.sd = sd |
| 1086 | } else { |
| 1087 | if idx, present := distinctNewQueriesIdxMap[bi.SQL]; present { |
| 1088 | bi.sd = distinctNewQueries[idx] |
| 1089 | } else { |
| 1090 | sd = &pgconn.StatementDescription{ |
| 1091 | Name: stmtcache.StatementName(bi.SQL), |
| 1092 | SQL: bi.SQL, |
| 1093 | } |
| 1094 | distinctNewQueriesIdxMap[sd.SQL] = len(distinctNewQueries) |
| 1095 | distinctNewQueries = append(distinctNewQueries, sd) |
| 1096 | bi.sd = sd |
| 1097 | } |
| 1098 | } |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | return c.sendBatchExtendedWithDescription(ctx, b, distinctNewQueries, c.statementCache) |
| 1103 | } |
| 1104 | |
| 1105 | func (c *Conn) sendBatchQueryExecModeCacheDescribe(ctx context.Context, b *Batch) (pbr *pipelineBatchResults) { |
| 1106 | if c.descriptionCache == nil { |
no test coverage detected