Skip to content

Commit 0c0ee97

Browse files
author
Artyom Abakumov
committed
Merge remote-tracking branch 'origin/master' into put_blr_type_refactoring
2 parents 7445aae + 15d737a commit 0c0ee97

File tree

148 files changed

+3896
-3921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+3896
-3921
lines changed

doc/sql.extensions/README.schemas.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ you can reset the current search path to its initial configuration with the `ALT
7676

7777
Nonexistent schemas can be included in the search path but are ignored during name resolution.
7878

79+
If `SYSTEM` is not included in the schema list, it is automatically added as the last schema in the search path.
80+
7981
The first existing schema in the search path is referred to as the **current schema** and is exclusively used in some
8082
operations.
8183

@@ -103,7 +105,7 @@ create or alter function F1 returns integer as begin end;
103105
grant create table to user USER1;
104106
```
105107

106-
For `ALTER`, `DROP`, and others statements, the system searches for the specified object across all schemas in the
108+
For `ALTER`, `DROP`, and others statements, Firebird searches for the specified object across all schemas in the
107109
search path. The reference is bound to the first matching object found. If no matching object exists in any schema, an
108110
error is raised.
109111

@@ -133,8 +135,7 @@ In this case, the search path is used to locate `TABLE1`, `DOMAIN1`, and `TABLE2
133135

134136
For DDL statements, the search path operates similarly, but with a subtle difference. Once the object being created or
135137
modified is bound to a schema during statement preparation, the search path is implicitly and temporarily modified.
136-
This adjustment sets the search path to the schema of the object. Additionally, if the `SYSTEM` schema was already
137-
present in the search path, it is appended as the last schema.
138+
This adjustment sets the search path to the schema of the object with `SYSTEM` added as the final schema in the path.
138139

139140
```sql
140141
create schema SCHEMA1;
@@ -198,8 +199,8 @@ grant select on table SCHEMA1.TABLE1 to user USER2;
198199
## The SYSTEM schema
199200

200201
All system schema-bound objects (e.g., `RDB$*` and `MON$*`) are now created in a dedicated schema called `SYSTEM`.
201-
The `SYSTEM` schema has a default `USAGE` permission granted to `PUBLIC` and is included in the default search path.
202-
This ensures backward compatibility with previous Firebird versions.
202+
The `SYSTEM` schema has a default `USAGE` permission granted to `PUBLIC` and is automatically included in the
203+
search path. This ensures backward compatibility with previous Firebird versions.
203204

204205
While the `SYSTEM` schema allows operations like index creation and manipulation of those indexes, it is otherwise
205206
locked for DDL changes. Modifying objects within the `SYSTEM` schema through DDL operations is strongly discouraged.
@@ -265,6 +266,8 @@ schema exists, it returns `NULL`.
265266
SET SEARCH_PATH TO <schema name> [, <schema name>]...
266267
```
267268

269+
If `SYSTEM` is not included in the schema list, it is automatically added as the last schema in the search path.
270+
268271
### RDB$GET_CONTEXT
269272

270273
#### CURRENT_SCHEMA (SYSTEM)
@@ -626,8 +629,7 @@ slave side. This allows mapping database objects to a specific schema using a se
626629
## System packages and functions
627630

628631
Firebird includes system packages such as `RDB$TIME_ZONE_UTIL`, `RDB$PROFILER`, and others. These system packages
629-
are now located in the `SYSTEM` schema. If the `SYSTEM` schema is not included in the search path, their usage
630-
requires explicit qualification with `SYSTEM`, as with any other object bound to the `SYSTEM` schema.
632+
are now located in the `SYSTEM` schema.
631633

632634
In contrast, Firebird also provides non-packaged built-in functions like `RDB$GET_CONTEXT`, `ABS`, and `DATEDIFF`.
633635
These functions are not listed in the database metadata (`RDB$FUNCTIONS`) and neither require nor accept the

examples/dbcrypt/CryptApplication.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using namespace Firebird;
3232
class CryptKey : public ICryptKeyCallbackImpl<CryptKey, CheckStatusWrapper>
3333
{
3434
public:
35-
unsigned int callback(unsigned int, const void*, unsigned int length, void* buffer)
35+
unsigned int callback(unsigned int, const void*, unsigned int length, void* buffer) override
3636
{
3737
if (length > 0 && buffer)
3838
{
@@ -113,7 +113,7 @@ class App
113113
throw "setDbCryptCallback";
114114

115115
char s[256];
116-
sprintf(s, "localhost:%s", dbName);
116+
snprintf(s, sizeof(s), "localhost:%s", dbName);
117117
att = p->attachDatabase(status, s, 0, NULL);
118118
if (status->getState() & IStatus::STATE_ERRORS)
119119
throw "attachDatabase";

examples/dbcrypt/CryptKeyHolder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class CryptKeyHolder : public IKeyHolderPluginImpl<CryptKeyHolder, CheckStatusWr
200200
name[sizeof(name) - 1] = 0;
201201
}
202202

203-
unsigned int callback(unsigned int, const void*, unsigned int length, void* buffer)
203+
unsigned int callback(unsigned int, const void*, unsigned int length, void* buffer) override
204204
{
205205
memcpy(buffer, &key, 1);
206206
return 1;

examples/empbuild/empbuild.epp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ else
7474
/* Create the database */
7575

7676
printf ("creating database %s\n", Db_name);
77-
sprintf (cmd, "CREATE DATABASE \"%s\"", Db_name);
77+
snprintf(cmd, sizeof(cmd), "CREATE DATABASE \"%s\"", Db_name);
7878
gds_trans = 0;
7979

8080
EXEC SQL EXECUTE IMMEDIATE :cmd;
@@ -94,39 +94,39 @@ if (SQLCODE)
9494
}
9595

9696
printf ("Turning forced writes off\n");
97-
sprintf (cmd, "gfix -write async %s", Db_name);
97+
snprintf(cmd, sizeof(cmd), "gfix -write async %s", Db_name);
9898
if (system (cmd))
9999
{
100100
printf ("Couldn't turn forced writes off\n");
101101
exit (FINI_ERROR);
102102
}
103103

104104
printf ("Creating tables\n");
105-
sprintf (cmd, "isql %s -q -i empddl.sql", Db_name);
105+
snprintf(cmd, sizeof(cmd), "isql %s -q -i empddl.sql", Db_name);
106106
if (system (cmd))
107107
{
108108
printf ("Couldn't create tables \n");
109109
exit (FINI_ERROR);
110110
}
111111

112112
printf ("Turning off indices and triggers \n");
113-
sprintf (cmd, "isql %s -i indexoff.sql", Db_name);
113+
snprintf(cmd, sizeof(cmd), "isql %s -i indexoff.sql", Db_name);
114114
if (system (cmd))
115115
{
116116
printf ("Couldn't turn off indices and triggers \n");
117117
exit (FINI_ERROR);
118118
}
119119

120120
printf ("Loading column data\n");
121-
sprintf (cmd, "isql %s -i empdml.sql", Db_name);
121+
snprintf(cmd, sizeof(cmd), "isql %s -i empdml.sql", Db_name);
122122
if (system (cmd))
123123
{
124124
printf ("Couldn't load column data \n");
125125
exit (FINI_ERROR);
126126
}
127127

128128
printf ("Turning on indices and triggers \n");
129-
sprintf (cmd, "isql %s -i indexon.sql", Db_name);
129+
snprintf(cmd, sizeof(cmd), "isql %s -i indexon.sql", Db_name);
130130
if (system (cmd))
131131
{
132132
printf ("Couldn't turn on indices and triggers \n");

examples/extauth/TcWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void check(ThrowStatusWrapper* status, int err, const char* text)
5858
return;
5959

6060
char buf[256];
61-
sprintf(buf, "%s: %s", text, error_to_string(err));
61+
snprintf(buf, sizeof(buf), "%s: %s", text, error_to_string(err));
6262
error(status, buf);
6363
}
6464

examples/interfaces/04.print_table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int main()
106106

107107
default:
108108
{
109-
sprintf(s, "Unknown type %d for %s", t, meta->getField(&status, j));
109+
snprintf(s, sizeof(s), "Unknown type %d for %s", t, meta->getField(&status, j));
110110
throw s;
111111
}
112112
continue;

examples/replication/fbSampleReplicator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static const ISC_STATUS wrn[] = { isc_arg_gds, isc_random, isc_arg_string, (ISC_
124124
ReplPlugin::ReplPlugin(IPluginConfig* conf)
125125
{
126126
char fn[100];
127-
sprintf(fn, "session_%08x_%d.log", (unsigned)time(nullptr), logCounter++);
127+
snprintf(fn, sizeof(fn), "session_%08x_%d.log", (unsigned)time(nullptr), logCounter++);
128128
log = fopen(fn, "w");
129129
WriteLog(log, "%p\tReplicatedSession constructed\n", this);
130130
status = master->getStatus();

examples/udr/Triggers.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ FB_UDR_BEGIN_TRIGGER(replicate)
135135
const char* name = triggerMetadata->getField(status, i);
136136

137137
strcat(buffer, " p");
138-
sprintf(buffer + strlen(buffer), "%d type of column \"%s\".\"%s\" = ?", i, table, name);
138+
const size_t buflen = strlen(buffer);
139+
snprintf(buffer + buflen, sizeof(buffer) - buflen, "%d type of column \"%s\".\"%s\" = ?", i, table, name);
139140
}
140141

141142
strcat(buffer,
@@ -175,7 +176,8 @@ FB_UDR_BEGIN_TRIGGER(replicate)
175176
if (i > 0)
176177
strcat(buffer, ", ");
177178
strcat(buffer, ":p");
178-
sprintf(buffer + strlen(buffer), "%d", i);
179+
const size_t buflen = strlen(buffer);
180+
snprintf(buffer + buflen, sizeof(buffer) - buflen, "%d", i);
179181
}
180182

181183
strcat(buffer, ")\n on external data source '");

src/burp/BurpTasks.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,6 @@ void RestoreRelationTask::initItem(BurpGlobals* tdgbl, Item& item)
902902
m_masterGbl->gbl_dpb_data.begin(),
903903
m_masterGbl->gbl_dpb_data.getCount());
904904

905-
dpb.deleteWithTag(isc_dpb_gbak_attach);
906-
907905
const UCHAR* dpbBuffer = dpb.getBuffer();
908906
const USHORT dpbLength = dpb.getBufferLength();
909907

src/burp/backup.epp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3911,7 +3911,7 @@ void write_pub_tables()
39113911

39123912
if (!X.RDB$TABLE_SCHEMA_NAME.NULL)
39133913
{
3914-
PUT_TEXT(att_ptab_table_schema_name, X.RDB$TABLE_NAME);
3914+
PUT_TEXT(att_ptab_table_schema_name, X.RDB$TABLE_SCHEMA_NAME);
39153915
tableName.schema = X.RDB$TABLE_SCHEMA_NAME;
39163916
}
39173917

0 commit comments

Comments
 (0)