Skip to content

Commit

Permalink
Fix style of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mkgrgis committed Jan 6, 2025
1 parent 231c76b commit b6f05a6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 42 deletions.
27 changes: 10 additions & 17 deletions sqlite_gis.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ const char *postGisSQLiteCompatibleTypes[] = { "geometry", "geography", NULL };
#ifdef SQLITE_FDW_GIS_ENABLE
/*
* SpatiaLiteAsPostGISgeom
*
* Converts SpatiaLite BLOB to hex value string for PostGIS/GEOS input function
* Converts SpatiaLite BLOB to hex value string for PostGIS/GEOS input function
*/
char *
SpatiaLiteAsPostGISgeom (blobOutput spatiaLiteBlob, Form_pg_attribute att)
Expand Down Expand Up @@ -113,8 +112,7 @@ SpatiaLiteAsPostGISgeom (blobOutput spatiaLiteBlob, Form_pg_attribute att)

/*
* getHexFormOfBlob
*
* Return normal ASCII hex string for a bytes of input data BLOB
* Return normal ASCII hex string for a bytes of input data BLOB
*/
static char*
getHexFormOfBlob(blobOutput b)
Expand All @@ -140,9 +138,8 @@ getHexFormOfBlob(blobOutput b)

/*
* hasSRID
*
* return true if there is any SRID data in hex input of EWKB
* in other cases, including damaged input data, returns false
* Returns true if there is any SRID data in hex input of EWKB
* in other cases, including damaged input data, returns false
*/
static inline bool hasSRID (char *hexEWKB)
{
Expand Down Expand Up @@ -172,9 +169,8 @@ static inline bool hasSRID (char *hexEWKB)

/*
* EWKB2SpatiaLiteBlobImage
*
* gives char* and len struncture for SQLite BLOB binding from
* input hex string with possible EWKB presentation
* Uses char* and len struncture for SQLite BLOB binding from
* input hex string with possible EWKB presentation
*/
static inline blobOutput
EWKB2SpatiaLiteBlobImage (char *hexEWKB, Form_pg_attribute att)
Expand Down Expand Up @@ -226,8 +222,7 @@ EWKB2SpatiaLiteBlobImage (char *hexEWKB, Form_pg_attribute att)

/*
* PostGISgeomAsSpatiaLite
*
* Converts PostGIS/GEOS BLOB as Datum + attribute metadata to SpatiaLite BLOB
* Converts PostGIS/GEOS BLOB as Datum + attribute metadata to SpatiaLite BLOB
*/
blobOutput
PostGISgeomAsSpatiaLite (Datum d, Form_pg_attribute att)
Expand All @@ -243,8 +238,7 @@ PostGISgeomAsSpatiaLite (Datum d, Form_pg_attribute att)

/*
* common_EWKB_error
*
* Message about error inside of both PostGIS/GEOS<->SpatiaLite transformations
* Message about error inside of both PostGIS/GEOS<->SpatiaLite transformations
*/
static void
common_EWKB_error (Form_pg_attribute att, int len, const char* data, bool direction_to_pg)
Expand All @@ -268,9 +262,8 @@ common_EWKB_error (Form_pg_attribute att, int len, const char* data, bool direct

/*
* sqlite_deparse_PostGIS_value
*
* Transform PostGIS/GEOS value from extval to SpatiaLite hex constant
* for a SQLite query. SQLite constant format is EWKB.
* Transform PostGIS/GEOS value from extval to SpatiaLite hex constant
* for a SQLite query. SQLite constant format is EWKB.
*/
void
sqlite_deparse_PostGIS_value(StringInfo buf, char *extval)
Expand Down
62 changes: 37 additions & 25 deletions sqlite_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ static char *
int642binstr(sqlite3_int64 num, char *s, size_t len);

/*
* Human readable message about disallowed combination of PostgreSQL columnn
* data type and SQLite data value affinity
* sqlite_value_to_pg_error
* Human readable message about disallowed combination of PostgreSQL columnn
* data type and SQLite data value affinity
*/
static void
sqlite_value_to_pg_error()
Expand All @@ -50,7 +51,8 @@ sqlite_value_to_pg_error()
}

/*
* Human readable message about disallowed void text for the PostgreSQL columnn
* pg_column_void_text_error
* Human readable message about disallowed void text for the PostgreSQL columnn
*/
static void
pg_column_void_text_error()
Expand All @@ -60,7 +62,8 @@ pg_column_void_text_error()
}

/*
* convert_sqlite_to_pg: Convert SQLite data into PostgreSQL's compatible data types
* convert_sqlite_to_pg
* Converts SQLite value into PostgreSQL's Datum
*/
NullableDatum
sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_value * val, AttInMetadata *attinmeta, AttrNumber attnum, int sqlite_value_affinity, int AffinityBehaviourFlags)
Expand Down Expand Up @@ -616,9 +619,9 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_value * val, AttInMetadata *
}

/*
* sqlite_datum_to_blob:
* Common part of extracting and preparing PostgreSQL bytea data
* for SQLite binding as blob
* sqlite_datum_to_blob
* Common part of extracting and preparing PostgreSQL bytea data
* for SQLite binding as blob
*/
blobOutput
sqlite_datum_to_blob (Datum value)
Expand All @@ -640,6 +643,11 @@ sqlite_datum_to_blob (Datum value)
return (struct blobOutput){dat, len};
}

/*
* get_column_option_string
* By Oid of relation and varattno returns value of requested option
* of foreign table
*/
static char *
get_column_option_string(Oid relid, int varattno, char *optionname)
{
Expand All @@ -661,8 +669,9 @@ get_column_option_string(Oid relid, int varattno, char *optionname)
}

/*
* bind_sql_var:
* Bind the values provided as DatumBind the values and nulls to modify the target table (INSERT/UPDATE)
* bind_sql_var
* Bind the values provided as DatumBind the values and nulls
* to modify the target table (INSERT/UPDATE)
*/
void
sqlite_bind_sql_var(Form_pg_attribute att, int attnum, Datum value, sqlite3_stmt * stmt, bool *isnull, Oid relid)
Expand Down Expand Up @@ -798,7 +807,8 @@ sqlite_bind_sql_var(Form_pg_attribute att, int attnum, Datum value, sqlite3_stmt
bool typeVarLength = false;

getTypeOutputInfo(type, &outputFunctionId, &typeVarLength);
outputString = OidOutputFunctionCall(outputFunctionId, value); /* uuid text belongs to ASCII subset, no need to translate encoding */
outputString = OidOutputFunctionCall(outputFunctionId, value);
/* uuid text belongs to ASCII subset, no need to translate encoding */
ret = sqlite3_bind_text(stmt, attnum, outputString, -1, SQLITE_TRANSIENT);
}
break;
Expand All @@ -823,7 +833,8 @@ sqlite_bind_sql_var(Form_pg_attribute att, int attnum, Datum value, sqlite3_stmt
bool typeVarLength = false;
elog(DEBUG2, "sqlite_fdw : bind mac as text");
getTypeOutputInfo(type, &outputFunctionId, &typeVarLength);
outputString = OidOutputFunctionCall(outputFunctionId, value); /* MAC text belongs to ASCII subset, no need to translate encoding */
outputString = OidOutputFunctionCall(outputFunctionId, value);
/* MAC text belongs to ASCII subset, no need to translate encoding */
ret = sqlite3_bind_text(stmt, attnum, outputString, -1, SQLITE_TRANSIENT);
}
else if (sqlite_aff == SQLITE_BLOB)
Expand Down Expand Up @@ -933,7 +944,8 @@ sqlite_bind_sql_var(Form_pg_attribute att, int attnum, Datum value, sqlite3_stmt
int32 atttypmod = att->atttypmod;

/*
* If a domain has been declared as bytea, it can support PostGIS data type
* If a domain has been declared as bytea,
* it can support PostGIS data type
*/
atttypid = getBaseTypeAndTypmod(atttypid, &atttypmod);

Expand Down Expand Up @@ -971,8 +983,8 @@ sqlite_bind_sql_var(Form_pg_attribute att, int attnum, Datum value, sqlite3_stmt
}

/*
* sqlite_text_value_to_pg_db_encoding:
* Convert SQLite text to PostgreSQL text with database encoding
* sqlite_text_value_to_pg_db_encoding
* Converts SQLite text to PostgreSQL text with database encoding
*/
static char *
sqlite_text_value_to_pg_db_encoding(sqlite3_value *val)
Expand All @@ -994,9 +1006,9 @@ sqlite_text_value_to_pg_db_encoding(sqlite3_value *val)
}

/*
* int642binstr:
* Converts int64 from SQLite to PostgreSQL string from 0 and 1 only
* s must be allocated with length not less than len + 1 bytes
* int642binstr
* Converts int64 from SQLite to PostgreSQL string from 0 and 1 only
* s must be allocated with length not less than len + 1 bytes
*/
static char *
int642binstr(sqlite3_int64 num, char *s, size_t len)
Expand All @@ -1009,8 +1021,8 @@ int642binstr(sqlite3_int64 num, char *s, size_t len)
}

/*
* binstr2int64:
* Converts PostgreSQL string from 0 and 1 only to int64 for SQLite
* binstr2int64
* Converts PostgreSQL string from 0 and 1 only to int64 for SQLite
*/
sqlite3_int64
binstr2int64(const char *s)
Expand Down Expand Up @@ -1039,9 +1051,9 @@ binstr2int64(const char *s)
}

/*
* listed_datatype:
* Checks if name of data type belongs to array of special data type names
* used for PostGIS data type which have not stable Oid
* listed_datatype
* Checks if a name of data type belongs to array of special data type names
* used for PostGIS data type which have not stable Oid
*/
bool
listed_datatype (const char * tn, const char ** arr)
Expand All @@ -1066,9 +1078,9 @@ listed_datatype (const char * tn, const char ** arr)
}

/*
* listed_datatype_oid:
* Checks if Oid of data type is one of Oids of listed data types
* listed in given array.
* listed_datatype_oid
* Checks if Oid of data type is one of Oids of listed data types
* listed in given array.
*/
bool
listed_datatype_oid(Oid atttypid, int32 atttypmod, const char** arr)
Expand Down

0 comments on commit b6f05a6

Please sign in to comment.