Skip to content

Commit

Permalink
fix(format): clarify const-ness of some pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 authored and lidavidm committed Aug 28, 2023
1 parent 3984589 commit 29905d3
Show file tree
Hide file tree
Showing 21 changed files with 47 additions and 39 deletions.
4 changes: 2 additions & 2 deletions adbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ struct ADBC_EXPORT AdbcDriver {
AdbcStatusCode (*DatabaseRelease)(struct AdbcDatabase*, struct AdbcError*);

AdbcStatusCode (*ConnectionCommit)(struct AdbcConnection*, struct AdbcError*);
AdbcStatusCode (*ConnectionGetInfo)(struct AdbcConnection*, uint32_t*, size_t,
AdbcStatusCode (*ConnectionGetInfo)(struct AdbcConnection*, const uint32_t*, size_t,
struct ArrowArrayStream*, struct AdbcError*);
AdbcStatusCode (*ConnectionGetObjects)(struct AdbcConnection*, int, const char*,
const char*, const char*, const char**,
Expand Down Expand Up @@ -1461,7 +1461,7 @@ AdbcStatusCode AdbcConnectionCancel(struct AdbcConnection* connection,
/// \param[out] error Error details, if an error occurs.
ADBC_EXPORT
AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes, size_t info_codes_length,
struct ArrowArrayStream* out,
struct AdbcError* error);

Expand Down
11 changes: 5 additions & 6 deletions c/driver/postgresql/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -827,13 +827,12 @@ AdbcStatusCode PostgresConnectionGetInfoImpl(const uint32_t* info_codes,
}

AdbcStatusCode PostgresConnection::GetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes,
size_t info_codes_length,
struct ArrowArrayStream* out,
struct AdbcError* error) {
// XXX: mistake in adbc.h (should have been const pointer)
const uint32_t* codes = info_codes;
if (!info_codes) {
codes = kSupportedInfoCodes;
info_codes = kSupportedInfoCodes;
info_codes_length = sizeof(kSupportedInfoCodes) / sizeof(kSupportedInfoCodes[0]);
}

Expand All @@ -842,8 +841,8 @@ AdbcStatusCode PostgresConnection::GetInfo(struct AdbcConnection* connection,
struct ArrowArray array;
std::memset(&array, 0, sizeof(array));

AdbcStatusCode status =
PostgresConnectionGetInfoImpl(codes, info_codes_length, &schema, &array, error);
AdbcStatusCode status = PostgresConnectionGetInfoImpl(info_codes, info_codes_length,
&schema, &array, error);
if (status != ADBC_STATUS_OK) {
if (schema.release) schema.release(&schema);
if (array.release) array.release(&array);
Expand Down
2 changes: 1 addition & 1 deletion c/driver/postgresql/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PostgresConnection {

AdbcStatusCode Cancel(struct AdbcError* error);
AdbcStatusCode Commit(struct AdbcError* error);
AdbcStatusCode GetInfo(struct AdbcConnection* connection, uint32_t* info_codes,
AdbcStatusCode GetInfo(struct AdbcConnection* connection, const uint32_t* info_codes,
size_t info_codes_length, struct ArrowArrayStream* out,
struct AdbcError* error);
AdbcStatusCode GetObjects(struct AdbcConnection* connection, int depth,
Expand Down
5 changes: 3 additions & 2 deletions c/driver/postgresql/postgresql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ AdbcStatusCode PostgresConnectionCommit(struct AdbcConnection* connection,
}

AdbcStatusCode PostgresConnectionGetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes,
size_t info_codes_length,
struct ArrowArrayStream* stream,
struct AdbcError* error) {
if (!connection->private_data) return ADBC_STATUS_INVALID_STATE;
Expand Down Expand Up @@ -436,7 +437,7 @@ AdbcStatusCode AdbcConnectionCommit(struct AdbcConnection* connection,
}

AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes, size_t info_codes_length,
struct ArrowArrayStream* stream,
struct AdbcError* error) {
return PostgresConnectionGetInfo(connection, info_codes, info_codes_length, stream,
Expand Down
5 changes: 3 additions & 2 deletions c/driver/sqlite/sqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ AdbcStatusCode SqliteConnectionGetInfoImpl(const uint32_t* info_codes,
} // NOLINT(whitespace/indent)

AdbcStatusCode SqliteConnectionGetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes,
size_t info_codes_length,
struct ArrowArrayStream* out,
struct AdbcError* error) {
CHECK_CONN_INIT(connection, error);
Expand Down Expand Up @@ -1695,7 +1696,7 @@ AdbcStatusCode AdbcConnectionRelease(struct AdbcConnection* connection,
}

AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes, size_t info_codes_length,
struct ArrowArrayStream* out,
struct AdbcError* error) {
return SqliteConnectionGetInfo(connection, info_codes, info_codes_length, out, error);
Expand Down
8 changes: 4 additions & 4 deletions c/driver_manager/adbc_driver_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ AdbcStatusCode ConnectionCommit(struct AdbcConnection*, struct AdbcError* error)
return ADBC_STATUS_NOT_IMPLEMENTED;
}

AdbcStatusCode ConnectionGetInfo(struct AdbcConnection* connection, uint32_t* info_codes,
size_t info_codes_length, struct ArrowArrayStream* out,
struct AdbcError* error) {
AdbcStatusCode ConnectionGetInfo(struct AdbcConnection* connection,
const uint32_t* info_codes, size_t info_codes_length,
struct ArrowArrayStream* out, struct AdbcError* error) {
return ADBC_STATUS_NOT_IMPLEMENTED;
}

Expand Down Expand Up @@ -952,7 +952,7 @@ AdbcStatusCode AdbcConnectionCommit(struct AdbcConnection* connection,
}

AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes, size_t info_codes_length,
struct ArrowArrayStream* out,
struct AdbcError* error) {
if (!connection->private_driver) {
Expand Down
4 changes: 2 additions & 2 deletions go/adbc/drivermgr/adbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ struct ADBC_EXPORT AdbcDriver {
AdbcStatusCode (*DatabaseRelease)(struct AdbcDatabase*, struct AdbcError*);

AdbcStatusCode (*ConnectionCommit)(struct AdbcConnection*, struct AdbcError*);
AdbcStatusCode (*ConnectionGetInfo)(struct AdbcConnection*, uint32_t*, size_t,
AdbcStatusCode (*ConnectionGetInfo)(struct AdbcConnection*, const uint32_t*, size_t,
struct ArrowArrayStream*, struct AdbcError*);
AdbcStatusCode (*ConnectionGetObjects)(struct AdbcConnection*, int, const char*,
const char*, const char*, const char**,
Expand Down Expand Up @@ -1461,7 +1461,7 @@ AdbcStatusCode AdbcConnectionCancel(struct AdbcConnection* connection,
/// \param[out] error Error details, if an error occurs.
ADBC_EXPORT
AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes, size_t info_codes_length,
struct ArrowArrayStream* out,
struct AdbcError* error);

Expand Down
8 changes: 4 additions & 4 deletions go/adbc/drivermgr/adbc_driver_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ AdbcStatusCode ConnectionCommit(struct AdbcConnection*, struct AdbcError* error)
return ADBC_STATUS_NOT_IMPLEMENTED;
}

AdbcStatusCode ConnectionGetInfo(struct AdbcConnection* connection, uint32_t* info_codes,
size_t info_codes_length, struct ArrowArrayStream* out,
struct AdbcError* error) {
AdbcStatusCode ConnectionGetInfo(struct AdbcConnection* connection,
const uint32_t* info_codes, size_t info_codes_length,
struct ArrowArrayStream* out, struct AdbcError* error) {
return ADBC_STATUS_NOT_IMPLEMENTED;
}

Expand Down Expand Up @@ -952,7 +952,7 @@ AdbcStatusCode AdbcConnectionCommit(struct AdbcConnection* connection,
}

AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes, size_t info_codes_length,
struct ArrowArrayStream* out,
struct AdbcError* error) {
if (!connection->private_driver) {
Expand Down
3 changes: 2 additions & 1 deletion go/adbc/pkg/_tmpl/driver.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ package main
//
// typedef const char cchar_t;
// typedef const uint8_t cuint8_t;
// typedef const uint32_t cuint32_t;
// typedef const struct AdbcError ConstAdbcError;
//
// int {{.Prefix}}ArrayStreamGetSchema(struct ArrowArrayStream*, struct ArrowSchema*);
Expand Down Expand Up @@ -1037,7 +1038,7 @@ func toStrSlice(in **C.cchar_t) []string {
}

//export {{.Prefix}}ConnectionGetInfo
func {{.Prefix}}ConnectionGetInfo(cnxn *C.struct_AdbcConnection, codes *C.uint32_t, len C.size_t, out *C.struct_ArrowArrayStream, err *C.struct_AdbcError) (code C.AdbcStatusCode) {
func {{.Prefix}}ConnectionGetInfo(cnxn *C.struct_AdbcConnection, codes *C.cuint32_t, len C.size_t, out *C.struct_ArrowArrayStream, err *C.struct_AdbcError) (code C.AdbcStatusCode) {
defer func() {
if e := recover(); e != nil {
code = poison(err, "AdbcConnectionGetInfo", e)
Expand Down
2 changes: 1 addition & 1 deletion go/adbc/pkg/_tmpl/utils.c.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ AdbcStatusCode AdbcConnectionCommit(struct AdbcConnection* connection,
}

AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection* connection,
uint32_t* info_codes, size_t info_codes_length,
const uint32_t* info_codes, size_t info_codes_length,
struct ArrowArrayStream* out,
struct AdbcError* error) {
if (out) memset(out, 0, sizeof(*out));
Expand Down
2 changes: 1 addition & 1 deletion go/adbc/pkg/_tmpl/utils.h.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ AdbcStatusCode {{.Prefix}}DatabaseSetOptionInt(struct AdbcDatabase*, const char*

AdbcStatusCode {{.Prefix}}ConnectionCancel(struct AdbcConnection*, struct AdbcError*);
AdbcStatusCode {{.Prefix}}ConnectionCommit(struct AdbcConnection* cnxn, struct AdbcError* err);
AdbcStatusCode {{.Prefix}}ConnectionGetInfo(struct AdbcConnection* cnxn, uint32_t* codes, size_t len, struct ArrowArrayStream* out, struct AdbcError* err);
AdbcStatusCode {{.Prefix}}ConnectionGetInfo(struct AdbcConnection* cnxn, const uint32_t* codes, size_t len, struct ArrowArrayStream* out, struct AdbcError* err);
AdbcStatusCode {{.Prefix}}ConnectionGetObjects(struct AdbcConnection* cnxn, int depth, const char* catalog, const char* dbSchema, const char* tableName, const char** tableType, const char* columnName, struct ArrowArrayStream* out, struct AdbcError* err);
AdbcStatusCode {{.Prefix}}ConnectionGetOption(struct AdbcConnection*, const char*, char*, size_t*, struct AdbcError*);
AdbcStatusCode {{.Prefix}}ConnectionGetOptionBytes(struct AdbcConnection*, const char*, uint8_t*, size_t*, struct AdbcError*);
Expand Down
3 changes: 2 additions & 1 deletion go/adbc/pkg/flightsql/driver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/adbc/pkg/flightsql/utils.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/adbc/pkg/flightsql/utils.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion go/adbc/pkg/panicdummy/driver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/adbc/pkg/panicdummy/utils.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/adbc/pkg/panicdummy/utils.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion go/adbc/pkg/snowflake/driver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/adbc/pkg/snowflake/utils.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/adbc/pkg/snowflake/utils.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion python/adbc_driver_manager/adbc_driver_manager/_lib.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ cdef extern from "adbc.h" nogil:
CAdbcError* error)
CAdbcStatusCode AdbcConnectionGetInfo(
CAdbcConnection* connection,
uint32_t* info_codes,
const uint32_t* info_codes,
size_t info_codes_length,
CArrowArrayStream* stream,
CAdbcError* error)
Expand Down

0 comments on commit 29905d3

Please sign in to comment.