getStatementDescription returns the statement description of the sql query according to the given mode. If the mode is one that doesn't require to know the param and result OIDs then nil is returned without error.
( ctx context.Context, mode QueryExecMode, sql string, )
| 890 | // If the mode is one that doesn't require to know the param and result OIDs |
| 891 | // then nil is returned without error. |
| 892 | func (c *Conn) getStatementDescription( |
| 893 | ctx context.Context, |
| 894 | mode QueryExecMode, |
| 895 | sql string, |
| 896 | ) (sd *pgconn.StatementDescription, err error) { |
| 897 | switch mode { |
| 898 | case QueryExecModeCacheStatement: |
| 899 | if c.statementCache == nil { |
| 900 | return nil, errDisabledStatementCache |
| 901 | } |
| 902 | sd = c.statementCache.Get(sql) |
| 903 | if sd == nil { |
| 904 | sd, err = c.Prepare(ctx, stmtcache.StatementName(sql), sql) |
| 905 | if err != nil { |
| 906 | return nil, err |
| 907 | } |
| 908 | c.statementCache.Put(sd) |
| 909 | } |
| 910 | case QueryExecModeCacheDescribe: |
| 911 | if c.descriptionCache == nil { |
| 912 | return nil, errDisabledDescriptionCache |
| 913 | } |
| 914 | sd = c.descriptionCache.Get(sql) |
| 915 | if sd == nil { |
| 916 | sd, err = c.Prepare(ctx, "", sql) |
| 917 | if err != nil { |
| 918 | return nil, err |
| 919 | } |
| 920 | c.descriptionCache.Put(sd) |
| 921 | } |
| 922 | case QueryExecModeDescribeExec: |
| 923 | return c.Prepare(ctx, "", sql) |
| 924 | } |
| 925 | return sd, err |
| 926 | } |
| 927 | |
| 928 | // QueryRow is a convenience wrapper over Query. Any error that occurs while |
| 929 | // querying is deferred until calling Scan on the returned Row. That Row will |