bmizerany / pq Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
db, err := sql.Open("...")
db.SetMaxIdleConns(12)
Error: db.SetMaxIdleConns undefined (type *sql.DB has no field or method SetMaxIdleConns)
Be able to implement it?
It seems that each test case is a goroutine, when running tests, it exceeds the connection limitation then it fails.
any ideal? provide a connection manager or something?
sql.Open("postgres", "host=localhost password=correct horse battery staple")
does not work, nor does
sql.Open("postgres", "host=localhost password='correct horse battery staple'")
PostgreSQL's COPY FROM STDIN is much faster for bulk imports (8x in my tests).
It's a bit tricky to implement it with the existing database.sql API, but I think I found a reasonable solution. You can see it here in action: https://github.com/olt/pq/blob/bulk/copy_test.go
The only wart is that sql.Stmt.Close() doesn't pass the errors from the COPY stmt.Close(). You need to call .Exec() without arguments before .Close() to synchronize and get any errors for the otherwise asynchronous inserts. (Don't know if this is a bug in Go and worth reporting?)
What do you think? I could write a bit documentation for it and send a pull request.
Stored procedure invoked using conn.Exec("SELECT sp(....)") is failing with error 'pq: unknown response for simple query: 'D'. 'It is working if conn.Query is used.
With Exec subsequent queries (eg SELECT 1) on same connections are failing with errors like
'D' seems to indicate a data row. Exec can be used for queries like 'INSERT ... RETURNING id' So shouldn't 'D' be handled for Exec case ?
Hi,friend:
I encountered a problem when Using Go-pGSQL, which is as follows:
Execute the SQL statement as follows:
Select * from books where price BETWEEN money(10)and Money (100)
In the use of Golang, the following error occurs:
The function money(Unknown) is not unique and cannot select the best candidate function
Please see the picture below for more information
Looking forward to your reply
When I exec a query that violates a constraint, I get an error back, but unfortunately the fields in it seem to be opaque to me. What is most of interest in the error is the name of the constraint that the query violated. Based on this, I could prepare a friendly message to the user explaining what the problem with their request is.
I suppose I could parse the error string given by Error(), but if there were a friendlier way to get at that constraint name, that would be nice.
Unlike is documented on http://golang.org/pkg/database/sql/#example_DB_Query, this driver cannot handle the "?" placeholder for query parameters. Instead the $ notation must be used. Figuring this out took me far too long while staring at:
SELECT * FROM questions WHERE id=?
pq: S:"ERROR" C:"42883" M:"operator does not exist: integer =?" H:"No operator matches the given name and argument type(s). You might need to add explicit type casts." P:"33" F:"parse_oper.c" L:"755" R:"op_error"
Eventually, I found the correct expression:
db.Query("SELECT * FROM questions WHERE id=$1", 1)
I have encountered a bug in transaction rollback handling. The bug occurs when one opens a transaction, issues a query, rolls back the transaction, then tries to issue another query on the same DB
object that was used to create the transaction.
Error message is:
pq: unexpected describe rows response: 'C'
Error is coming from here: https://github.com/bmizerany/pq/blob/master/conn.go#L216
Postgres manual says 'C' is a legitimate response header:
CommandComplete (B)
Byte1('C')
Identifies the message as a command-completed response.
Int32
Length of message contents in bytes, including self.
String
The command tag. This is usually a single word that identifies which SQL command was completed.
For an INSERT command, the tag is INSERT oid rows, where rows is the number of rows inserted. oid is the object ID of the inserted row if rows is 1 and the target table has OIDs; otherwise oid is 0.
For a DELETE command, the tag is DELETE rows where rows is the number of rows deleted.
For an UPDATE command, the tag is UPDATE rows where rows is the number of rows updated.
For a SELECT or CREATE TABLE AS command, the tag is SELECT rows where rows is the number of rows retrieved.
For a MOVE command, the tag is MOVE rows where rows is the number of rows the cursor's position has been changed by.
For a FETCH command, the tag is FETCH rows where rows is the number of rows that have been retrieved from the cursor.
For a COPY command, the tag is COPY rows where rows is the number of rows copied. (Note: the row count appears only in PostgreSQL 8.2 and later.)
Here's how libpq
handles it: http://doxygen.postgresql.org/fe-protocol3_8c_source.html#l00199
I wrote a test case that reproduces the bug: https://github.com/jmcvetta/pq/blob/tx_bug/conn_test.go#L469
This bug is currently blocking development of PostgreSQL dialect of qbs
ORM: coocood/qbs#11
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.