Skip to content

Conversation

@xstevens
Copy link

@xstevens xstevens commented Sep 5, 2018

Server versioning scheme changed in Postgresql 10+. They've moved to two-part rather than three-part versioning. For example, 10.5 rather than 10.5.0. They've also changed the calculation of the server_version_num integer. Full details can be found in the libpq status documentation.

On the face of it this doesn't seem like a huge deal, but it affects encoding.go. In particular the encodeBytea function uses server version check to see if it should use hex encoding.

@cbandy cbandy mentioned this pull request Nov 28, 2018
Copy link

@andriikushch andriikushch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from tiny comments looks reasonable to me.

if err == nil {
cn.parameterStatus.serverVersion = major1*10000 + major2*100 + minor
// if the version string contains at least major1, set the server version
n, _ := fmt.Sscanf(r.string(), "%d.%d.%d", &major1, &major2, &minor)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @xstevens !

I think it still makes sense to check for error here because Sscanf function can return an error and n > 0 at the same time. What do you think about?

writer.string(versionStr)
reader := readBuf(writer.buf)
c.processParameterStatus(&reader)
expectedVersionNum := version

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xstevens Do you think we can avoid this extra variable here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants